Initial Contribution
authorThe Android Open Source Project <initial-contribution@android.com>
Tue, 21 Oct 2008 14:00:00 +0000 (07:00 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Tue, 21 Oct 2008 14:00:00 +0000 (07:00 -0700)
456 files changed:
Android.mk [new file with mode: 0644]
sta_dk_4_0_4_32/Android.mk [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Android.mk [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/Android.mk [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/Makefile [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/console.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/console.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/cu_cmd.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/cu_cmd.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/dbg_module.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/eth_utils.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/eth_utils.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/g_tester.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/g_tester.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/ipc.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/ipc.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/ticon.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/ticon.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/wipp_ctrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/CLI/wipp_ctrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/IPC/Linux/cu_ipc.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_event.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_event.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_user.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/IPC/Linux/proc_main.c [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterApiC.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterApiCpp.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterDBG.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterGWSI.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterPM.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterQOS.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterSEC.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterSG.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/TI_OAL.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/Inc/softGeminiTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/OAL/Common/CommonOAL.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/OAL/Common/TI_OAL.cpp [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/OAL/Pform/Linux/TILibLinux.cpp [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/OAL/Pform/Linux/TILibLinux.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/Android.mk [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/CTI_Adapter.cpp [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/CTI_Adapter.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/CommonAdapter.h [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/Makefile [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/TI_Adapter.cpp [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/UtilityAdapter/TI_AdapterApi.cpp [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk [new file with mode: 0644]
sta_dk_4_0_4_32/CUDK/tiwlan_loader/tiwlan_loader.c [new file with mode: 0644]
sta_dk_4_0_4_32/Makefile [new file with mode: 0644]
sta_dk_4_0_4_32/common.inc [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/TI_IPC_Api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/TI_Results.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/bssTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/commonTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/coreDefaultParams.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/memMngrEx.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/osDot11.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/paramMng.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/paramOut.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/ratesTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/roamingMngrTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/scanMngrTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/scanTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/softGeminiTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/srcApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/systemGeneralParam.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/tiQosTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/tiioctl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/tiwlnif.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/whalDefaultParams.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/inc/wspVer.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Application/ExpInc/roamingMngrApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Application/Roaming/roamingMngr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Application/ScanMngr/scanMngr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Application/ScanMngr/scanMngr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Application/inc/roamingMngr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Application/inc/scanMngrApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Export_Inc/whalBus_Api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Export_Inc/whalBus_Defs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmBus.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmBus.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmDebug.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmFwCtrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmFwCtrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmUtils.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmUtils.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalHwEeprom.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalHwEeprom.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalTrace.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalTrace.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/dot11h/spectrumMngmntMgr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/measurementMgr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/measurementMgrSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/requestHandler.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/SwitchChannel/SwitchChannel.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/inc/SwitchChannelApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgrApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgrSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/inc/requestHandler.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/AirLink/inc/spectrumMngmntMgr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgrDbgPrint.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr_API.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr_API.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr_QueueMapping.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/QOS/Inc/trafficAdmControl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/QOS/qosMngr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/QOS/trafficAdmControl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr_API.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/SoftGemini/inc/SoftGeminiApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/SoftGemini/src/SoftGemini.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/SoftGemini/src/SoftGemini.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/apConn/apConn.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/apConn/apConn.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/inc/ScanCncnApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/inc/ScanCncnAppApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncn.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncn.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppApi.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnDrvSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnDrvSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnOidSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnOidSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingContSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingContSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingImmedSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingImmedSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Export_Inc/CmdQueue_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Export_Inc/recoveryCtrl_API.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver_Tx.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/inc/txCtrlBlk_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/inc/txHwQueue_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Export_Inc/TNETW_Driver_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/Export_Inc/TNETW_Driver_types.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/DebugTrace_Xfer/DebugTraceXfer.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/EventMbox/eventMbox.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/HwInit/HwInit.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/HwInit/HwInit.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Result/txResult.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Result/txResult.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/CmdMBox_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/DebugTraceXfer_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/FwEvent_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/HwInit_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/eventMbox_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/rxXfer_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/txResult_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/txXfer_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/MacServices_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/measurementSrvDbgPrint.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/measurementTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/inc/MacServices.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/inc/PowerAuthorization.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MacServices.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/measurementSrvDbgPrint.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization_internal.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv_API.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/tiwlanspi.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/whalHwAccess.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/wspi.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/wspi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/ELP_Controller/ElpCtrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Export_Inc/TNETWIF.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/ElpCtrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArb.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArbSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArb_buffer.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/whalHwAccess.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArbSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb_buffer.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWIF.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/Core_Adapt/CORE_Adapt_Defs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/Core_Adapt/Core_AdaptTx.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/Core_Adapt/Export_Inc/Core_AdaptCB.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/Core_Adapt/Export_Inc/Core_AdaptTx.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/EvHandler/EvHandler.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/EvHandler/EvHandler.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/ExpInc/apConnApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/NetworkCtrl/inc/regulatoryDomainApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/currBss/currBss.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/currBss/currBss.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/Concatenator.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/Concatenator.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/DeConcatenator.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/DeConcatenator.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulUtil.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulUtil.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourX.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourX.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourXManager.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/Clsfr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/Ctrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/RateAdaptation.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/Clsfr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/Ctrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtilApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/RateAdaptation.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitorAPI.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Rx/rx.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Rx/rx.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/MsduList.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/MsduList.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/tx.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/tx.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/DataCtrl_Api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/conn.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/mlmeApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/mlmeBuilder.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/mlmeSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/rsnApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/inc/smeApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Assoc/AssocSM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Assoc/assocSM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Auth/authSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Auth/authSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Auth/open/openAuthSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Auth/open/openAuthSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Auth/shared/sharedKeyAuthSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/Auth/shared/sharedKeyAuthSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/mlmeBuilder.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/mlmeParser.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/mlmeParser.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/mlme/mlmeSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/admCtrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/admCtrlNone.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWep.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWpa.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWpa2.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/broadcastKey802_1x.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/broadcastKeyNone.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/broadcastKeySM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlNone.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWep.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWpa.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWpa2.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKey802_1x.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKeyNone.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKeySM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/keyDerive.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/keyParser.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/keyTypes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/mainKeysSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/mainKeysSmInternal.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecKeysOnly.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecNull.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/rsn.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKey802_1x.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKeyNone.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKeySM.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDerive.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveAes.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveAes.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveTkip.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveTkip.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveWep.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveWep.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyParser.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyParserExternal.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyParserExternal.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyParserWep.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/keyParserWep.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/mainKeysSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/mainSecKeysOnly.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/mainSecNull.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/mainSecSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/rsn.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/unicastKey802_1x.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/unicastKeyNone.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/rsn/unicastKeySM.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/HealthMonitor/healthMonitor.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/HealthMonitor/healthMonitor.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/Inc/connApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/Inc/siteMgrApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/Inc/smeSmApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/configMgr/configMgr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/configMgr/configMgr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/conn/conn.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/conn/connIbss.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/conn/connIbss.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/conn/connInfra.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/conn/connInfra.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/conn/connSelf.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/siteMgr/select.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteHash.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteHash.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteMgr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/siteMgr/templates.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSmApi.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/srv/inc/scrApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/srv/scr/scr.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/core/srv/scr/scr.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalCtrl_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalCtrl_prm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalTx_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_commands.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_descriptors.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_event_mbox.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_host_int.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_infoele.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_radio.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_types.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/ti_types.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/FirmwareApi/whalHwDefs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1130/TnetwRegisters.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1130/whalHwRegs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1150/TnetwRegisters.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1150/whalHwRegs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1251/TnetwRegisters.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1251/whalHwRegs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/TnetwServices/tnetwCommon.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalCtrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalCtrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalDebug.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalParams.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalParams.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalRadio.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalRecovery.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_data/whalDefrag.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_data/whalDefrag_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_data/whalEndpntEnt.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hl_data/whalEndpntEnt_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwCtrl.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwCtrl.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmd.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmd.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmdBit.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmdBit.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxConfig.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxConfig.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/inc/release.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/inc/whalCommon.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/inc/whalSecurity.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/inc/whalWep.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/inc/whalWpa.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/security/whalSecurity.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/security/whalWep.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/hal/security/whalWpa.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/inc/802_11Defs.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/inc/Core_Api.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/inc/Ethernet.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/inc/paramIn.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/bufferPool.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/bufferPool.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/bufferPoolApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/fsm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/fsm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/memMngrEx.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/nrfsm.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/nrfsm.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/report.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/report.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/stack.h [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/utils.c [new file with mode: 0644]
sta_dk_4_0_4_32/common/src/utils/utils.h [new file with mode: 0644]
sta_dk_4_0_4_32/drv_sources.inc [new file with mode: 0644]
sta_dk_4_0_4_32/os_sources.inc [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/IPCKernelApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/cli_cu_common.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/linux_ioctl_common.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/osApi.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/osClsfr.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/osDebug.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/osRgstry.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/inc/osUtil.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/src/osClsfr.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/src/osCmd.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/src/osRgstry.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/common/src/osUtil.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/arch_ti.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/bmtrace.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/debug_module.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/debug_module_ioctl.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/ioctl_init.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/mmc_omap_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/mmc_tnetw1150_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/osAdapter.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/osTIType.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/osrgstry_parser.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/spi_api.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/inc/windows_types.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/bmtrace.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/env_tst.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/esta_drv.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/ioctl_list.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/ioctl_utils.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/ioctl_utils.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/ipc_k.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/ipc_k.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/mmc_tnetw1150_api.c [new file with mode: 0755]
sta_dk_4_0_4_32/pform/linux/src/osRgstry_parser.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/osapi.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/osmemapi.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/proc_stat.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/stack_profile.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/string.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/tiwlan_profile.c [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/tiwlan_profile.h [new file with mode: 0644]
sta_dk_4_0_4_32/pform/linux/src/tnetw_sdio.c [new file with mode: 0755]
wpa_supplicant_lib/Android.mk [new file with mode: 0644]
wpa_supplicant_lib/driver_ti.c [new file with mode: 0644]
wpa_supplicant_lib/driver_ti.h [new file with mode: 0644]

diff --git a/Android.mk b/Android.mk
new file mode 100644 (file)
index 0000000..63185fa
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ifneq ($(TARGET_SIMULATOR),true)
+  include $(all-subdir-makefiles)
+endif
diff --git a/sta_dk_4_0_4_32/Android.mk b/sta_dk_4_0_4_32/Android.mk
new file mode 100644 (file)
index 0000000..5053e7d
--- /dev/null
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/sta_dk_4_0_4_32/CUDK/Android.mk b/sta_dk_4_0_4_32/CUDK/Android.mk
new file mode 100644 (file)
index 0000000..5053e7d
--- /dev/null
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/Android.mk b/sta_dk_4_0_4_32/CUDK/CLI/Android.mk
new file mode 100644 (file)
index 0000000..be6ee2c
--- /dev/null
@@ -0,0 +1,97 @@
+CLI_STATIC_LIB ?= y
+CLI_DEBUG ?= y
+FIRMWARE_DYNAMIC_LOAD ?= y
+BUILD_SUPPL ?= n
+SG  ?= n
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+TARGET = wlan_cu
+LOCAL_MODULE = $(TARGET)
+
+ifeq ($(CLI_DEBUG),y)
+  CLI_DEBUGFLAGS = -O0 -g -fno-builtin -DDEBUG -D TI_DBG  # "-O" is needed to expand inlines
+else
+  CLI_DEBUGFLAGS = -O2
+endif
+
+CLI_STA_DK_ROOT = $(LOCAL_PATH)/../..
+CLI_DK_ROOT = $(CLI_STA_DK_ROOT)
+CLI_COMMON  = $(CLI_DK_ROOT)/common
+CLI_COMSRC  = $(CLI_COMMON)/src
+CLI_TESTSRC = $(CLI_DK_ROOT)/Test
+CLI_CUDK_ROOT = $(LOCAL_PATH)/..
+CLI_IPC_SRC = $(CLI_CUDK_ROOT)/IPC/Linux
+
+DK_INCS = $(CLI_COMMON)/inc \
+       $(CLI_COMSRC)/inc \
+       $(CLI_COMSRC)/utils \
+       $(CLI_COMSRC)/hal/inc \
+       $(CLI_COMSRC)/hal/hl_data \
+       $(CLI_COMSRC)/hal/hl_ctrl \
+       $(CLI_COMSRC)/hal/hw_data \
+       $(CLI_COMSRC)/hal/hw_ctrl \
+       $(CLI_COMSRC)/hal/security \
+       $(CLI_COMSRC)/core/inc \
+       $(CLI_COMSRC)/core/data_ctrl/Tx \
+       $(CLI_COMSRC)/core/data_ctrl/Ctrl \
+       $(CLI_COMSRC)/core/data_ctrl/Ctrl/4X \
+       $(CLI_COMSRC)/core/sme/Inc \
+       $(CLI_COMSRC)/core/sme/siteMgr \
+       $(CLI_COMSRC)/core/sme/configMgr \
+       $(CLI_COMSRC)/core/sme/conn \
+       $(CLI_COMSRC)/core/rsn \
+       $(CLI_COMSRC)/core/rsn/mainKeysSm \
+       $(CLI_COMSRC)/core/rsn/mainKeysSm/keyDerive \
+       $(CLI_COMSRC)/core/rsn/inc \
+       $(CLI_COMSRC)/core/mlme \
+       $(CLI_COMSRC)/core/NetworkCtrl/inc \
+       $(CLI_COMSRC)/core/NetworkCtrl/Measurement \
+       $(CLI_COMSRC)/core/NetworkCtrl/RegulatoryDomain \
+       $(CLI_COMSRC)/core/NetworkCtrl/QOS \
+       $(CLI_CUDK_ROOT)/CLI \
+       $(CLI_CUDK_ROOT)/UtilityAdapter \
+       $(CLI_COMSRC)/hal/FirmwareApi \
+       $(CLI_COMSRC)/hal/TnetwServices \
+       $(CLI_COMSRC)/hal/TnetwServices/TNETW1251
+
+ifeq ($(SG), y)
+DK_INCS += $(CLI_COMSRC)/core/NetworkCtrl/BThWlanCombo
+endif
+
+DK_DEFINES = \
+       -D __BYTE_ORDER_LITTLE_ENDIAN \
+       -D INCLUDE_DEFRAGMENTATION \
+       -D CONFIGURE_BSS_TYPE_STA \
+       -D TNETW1150=1 \
+       -D DOT11_A_G=1 \
+       -D ELP_NO_PDA_SCREEN_VIBRATE
+
+ifeq ($(SG), y)
+DK_DEFINES += -D BTH_COEXISTENCE
+endif
+
+LOCAL_SRC_FILES := ticon.c console.c cu_cmd.c ipc.c wipp_ctrl.c eth_utils.c g_tester.c dbg_module.c
+
+ifeq ($(CLI_STATIC_LIB),y)
+LOCAL_STATIC_LIBRARIES := libWifiApi
+else
+LOCAL_SHARED_LIBRARIES := libWifiApi
+endif
+
+INCLUDES = $(DK_INCS) $(CLI_STA_DK_ROOT)/pform/linux/inc \
+       $(CLI_CUDK_ROOT)/Inc                             \
+       $(CLI_STA_DK_ROOT)/pform/common/inc
+
+LOCAL_CFLAGS = -Wall -Wstrict-prototypes $(CLI_DEBUGFLAGS) -D__LINUX__ $(DK_DEFINES) -mabi=aapcs-linux
+LOCAL_CFLAGS += -DDRV_NAME='"tiwlan"' -DHOST_COMPILE
+
+ifeq ($(FIRMWARE_DYNAMIC_LOAD), y)
+    LOCAL_CFLAGS += -DFIRMWARE_DYNAMIC_LOAD
+endif
+
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+include $(BUILD_EXECUTABLE)
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/Makefile b/sta_dk_4_0_4_32/CUDK/CLI/Makefile
new file mode 100644 (file)
index 0000000..c2bbee4
--- /dev/null
@@ -0,0 +1,192 @@
+
+STATIC_LIB ?= y
+
+DEBUG ?= y
+FIRMWARE_DYNAMIC_LOAD ?= y
+BUILD_SUPPL ?= n
+
+EXC ?= n
+SG  ?= n
+GWSI_SA ?= n
+DRIVER_PROFILING ?= n
+
+STA_DK_ROOT = ../..
+
+ifeq ($(DEBUG),y)
+  DEBUGFLAGS = -O0 -g -DDEBUG -DTI_DBG -fno-builtin   # "-O" is needed to expand inlines
+#  DEBUGFLAGS+= -DDEBUG_MESSAGES
+else
+  DEBUGFLAGS = -O2
+endif
+
+DEBUGFLAGS+= -DHOST_COMPILE
+
+DK_ROOT = $(STA_DK_ROOT)
+COMMON  = $(DK_ROOT)/common
+COMSRC  = $(COMMON)/src
+TESTSRC = $(DK_ROOT)/Test
+CUDK_ROOT ?= $(DK_ROOT)/CUDK
+IPC_SRC = $(CUDK_ROOT)/IPC/Linux
+
+OUTPUT_DIR ?= $(STA_DK_ROOT)/CUDK/CLI
+
+DK_INCS = -I $(CUDK_ROOT)/CLI/drv_inc \
+       -I $(CUDK_ROOT)/CLI/pform_inc
+
+ifeq ($(EXC),y)
+        DK_INCS += \
+       -I $(CUDK_ROOT)/CLI \
+       -I $(CUDK_ROOT)/Inc/EXC \
+       -I $(CUDK_ROOT)/CLI/EXC
+endif
+ifeq ($(SG), y)
+#      DK_INCS += -I $(COMSRC)/core/NetworkCtrl/BThWlanCombo
+endif
+
+DK_DEFINES = \
+       -D __BYTE_ORDER_LITTLE_ENDIAN \
+       -D INCLUDE_DEFRAGMENTATION \
+       -D CONFIGURE_BSS_TYPE_STA \
+       -D TNETW1130=1 \
+       -D DOT11_A_G=1 \
+       -D ELP_NO_PDA_SCREEN_VIBRATE
+ifeq ($(EXC), y)
+       DK_DEFINES += -D EXC_MODULE_INCLUDED
+endif    
+ifeq ($(SG), y)
+       DK_DEFINES += -D BTH_COEXISTENCE
+endif
+
+ifeq ($(DRIVER_PROFILING),y)
+   DK_DEFINES += -D DRIVER_PROFILING
+endif
+
+TARGET := $(OUTPUT_DIR)/wlan_cu
+SRCS  := ticon.c console.c cu_cmd.c eth_utils.c wipp_ctrl.c dbg_module.c ipc.c g_tester.c  
+ifeq ($(EXC), y)
+    SRCS += EXC/cu_cmd_exc.c
+endif
+OBJS = $(SRCS:.c=.o)
+
+DEPS = $(SRCS:%.c=%.d)
+
+# export CROSS_COMPILE ?= arm_v4t_le-
+export CROSS_COMPILE ?= arm-linux-
+
+#ARMFLAGS  = -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe
+#ARMFLAGS += -mapcs -mno-sched-prolog -mapcs-32 -D__LINUX_ARM_ARCH__=4 -march=armv4
+#ARMFLAGS += -mtune=arm9tdmi -mshort-load-bytes -msoft-float  -iwithprefix include
+
+ARMFLAGS  = -fno-common -pipe
+
+TI_UTIL_ADAPTER_LIB_DIR=$(CUDK_ROOT)/UtilityAdapter
+TI_UTIL_ADAPTER_LIB = tiOsLib
+
+#Supplicant image building
+SUPP_ROOT = $(STA_DK_ROOT)/CUDK/Supplicant
+TI_SUPP_LIB_DIR = $(SUPP_ROOT)/odyssey
+
+ifeq ($(BUILD_SUPPL), y)
+  SUPPL_TARGET = $(OUTPUT_DIR)/wlan_suppl
+endif
+
+INCLUDES = $(DK_INCS) -I $(STA_DK_ROOT)/CUDK/CLI/pform_inc \
+                       -I $(STA_DK_ROOT)/CUDK/Inc
+
+ifeq ($(GWSI_SA), n)
+ifeq ($(BUILD_SUPPL), y)
+       INCLUDES +=     -I $(SUPP_ROOT)/odyssey/odSupp/linux/inc
+endif
+endif
+
+CFLAGS = -Wall -Wstrict-prototypes $(DEBUGFLAGS) $(INCLUDES) -D__LINUX__ $(DK_DEFINES)
+CFLAGS += -DDRV_NAME='"tiwlan"'
+
+ifeq ($(FIRMWARE_DYNAMIC_LOAD), y)
+    CFLAGS += -DFIRMWARE_DYNAMIC_LOAD
+endif
+
+ifneq "$(CROSS_COMPILE)" ""            #compile for ARM
+       CFLAGS += $(ARMFLAGS)
+        # strip symbols
+ifneq "$(DEBUG)" "y"
+    LDFLAGS = -s
+endif
+
+endif    # CROSS_COMPILE != ""
+
+.PHONY: all $(TI_UTIL_ADAPTER_LIB) $(SUPPL_TARGET)
+
+all: $(TARGET) $(SUPPL_TARGET)
+
+$(TI_UTIL_ADAPTER_LIB):
+       $(MAKE) -e -C $(TI_UTIL_ADAPTER_LIB_DIR) DEBUG=$(DEBUG) EXC=$(EXC) STATIC_LIB=$(STATIC_LIB) CROSS_COMPILE=$(CROSS_COMPILE) SG=$(SG) DRIVER_PROFILING=$(DRIVER_PROFILING)
+
+ifeq ($(BUILD_SUPPL), y)
+
+$(SUPPL_TARGET):
+       $(MAKE) -e -C $(TI_SUPP_LIB_DIR) DEBUG=$(DEBUG) EXC=$(EXC) CROSS_COMPILE=$(CROSS_COMPILE) STATIC_LIB=$(STATIC_LIB)
+ifeq ($(DEBUG), y)
+       cp -a $(SUPPL_TARGET) $(SUPPL_TARGET)_debug
+       $(CROSS_COMPILE)strip -s $(SUPPL_TARGET)
+endif    #DEBUG
+
+endif
+
+$(TARGET): $(OBJS) $(TI_UTIL_ADAPTER_LIB)
+#      echo MAKECMDGOALS: $(MAKECMDGOALS) : $(findstring $(MAKECMDGOALS), "clean cleanall")
+       $(CROSS_COMPILE)gcc $(OBJS) -L $(CUDK_ROOT)/Output -l $(TI_UTIL_ADAPTER_LIB) $(LDFLAGS) -lpthread -lc -lstdc++ -o $@
+ifeq ($(DEBUG), y)
+       cp -a $(TARGET) $(TARGET)_debug
+       $(CROSS_COMPILE)strip -s $(TARGET)
+endif    #DEBUG
+
+ifeq ("$(findstring $(MAKECMDGOALS), clean cleanall)", "")
+-include .depend
+endif
+
+%.o: %.cpp
+       @echo $@
+       @$(CROSS_COMPILE)gcc $(CFLAGS) -c $^ -o $@
+
+%.o: %.c
+       @echo $@
+       @$(CROSS_COMPILE)gcc $(CFLAGS) -c $< -o $@
+
+%.i: %.c
+       @$(CROSS_COMPILE)gcc $(CFLAGS) -E -c $< > $@
+
+%.d: %.c
+       @echo $@
+       @$(CROSS_COMPILE)gcc $< -MT$(^:%.c=%.o) -M $(CFLAGS) > $@
+
+%.d: %.cpp
+       @echo $@
+       @$(CROSS_COMPILE)gcc $< -MT$(^:%.cpp=%.o) -M $(CFLAGS) > $@
+
+.depend: $(DEPS)
+       rm -f $@
+       for aa in $^; do cat $$aa >> $@; done
+
+.PHONY: clean
+clean:
+       @rm -f .depend $(OBJS) $(DEPS) $(SRCS:.c=.i) *.ko .*.cmd .*.flags *.mod.c *~ *.~*
+
+cleanall: clean
+       $(MAKE) -e -C $(TI_UTIL_ADAPTER_LIB_DIR) CROSS_COMPILE=$(CROSS_COMPILE) clean
+ifeq ($(GWSI_SA), n)
+ifeq ($(BUILD_SUPPL), y)
+       $(MAKE) -e -C $(TI_SUPP_LIB_DIR) CROSS_COMPILE=$(CROSS_COMPILE) clean
+endif
+       @rm -f $(SUPPL_OBJS) $(SUPPL_OBJS:.c=.d) $(OUTPUT_DIR)/wlan_suppl $(SUPPL_TARGET)
+endif
+       @rm -rf $(TARGET) $(OUTPUT_DIR)/../debug
+
+TAGS: $(SRCS)
+       { find $(COMMON) -name '*.h' -print ; \
+         find . -name '*.h' -print ; } | etags -
+         etags -a $(SRCS)
+
+
+
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/console.c b/sta_dk_4_0_4_32/CUDK/CLI/console.c
new file mode 100644 (file)
index 0000000..eb4689a
--- /dev/null
@@ -0,0 +1,996 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef _WINDOWS
+       #include <sys/select.h>
+       #include <unistd.h>
+       #include <signal.h>
+
+       #include "ipc.h"
+       #include "g_tester.h"
+       #include "wipp_ctrl.h"
+#endif /* __LINUX__ */
+
+#ifdef _WINDOWS
+#else
+       #include <errno.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+
+
+#include "ticon.h"
+#include "console.h"
+#include "cu_cmd.h"
+
+static ConEntry_t *p_mon_root;
+static ConEntry_t *p_cur_dir;
+static char       *p_inbuf;
+static volatile int stop_UI_Monitor;
+
+#define INBUF_LENGTH          1024
+/*#define PRINT_LEN_PER_PARM    40*/
+#define ROOT_NAME             "/"
+
+/* Internal functions */
+static void        console_allocRoot( void );
+static void        console_displayDir( ConEntry_t *p_dir );
+static t_TokenType console_getWord( char *name, U16 len );
+static t_TokenType console_getStrParam( char *buf, ConParm_t *param );
+static t_TokenType console_analizeToken( char *name );
+static U16         console_getNParms( ConEntry_t *p_token );
+static int         console_parseParms( ConEntry_t *p_token, U16 *pnParms );
+static ConEntry_t *console_searchToken( ConEntry_t *p_dir, char *name );
+static void        console_dirHelp( void );
+static void        console_displayHelp( ConEntry_t *p_token );
+static int         console_chooseAlias( ConEntry_t *p_dir, ConEntry_t *p_new_token );
+
+
+/***************************************************************
+
+   Function : consoleRunScript
+
+   Description: Execute command from file
+
+   Parameters: script_file - name of script file
+
+   Output:  !NULL - if 'quit' command was executed
+***************************************************************/
+int consoleRunScript( char *script_file )
+{
+    FILE *hfile = fopen(script_file, "r" );
+
+    if( hfile )
+    {
+        char buf[INBUF_LENGTH];
+        stop_UI_Monitor = FALSE;
+
+        while( fgets(buf, sizeof(buf), hfile ) )
+        {
+            console_printf_terminal("script <%s>\n", script_file);
+            console_ParseString( buf );
+            if( stop_UI_Monitor )
+                break;
+        }
+
+        fclose(hfile);
+    }
+    else
+        perror( script_file );
+
+    return stop_UI_Monitor;
+}
+
+
+/***************************************************************
+
+   Function : consoleAddDirExt
+
+   Description: Add subdirectory
+
+   Parameters: p_root - root directory handle (might be NULL)
+               name   - directory name
+
+   Output:  the new created directory handle
+            =NULL - failure
+***************************************************************/
+handle_t consoleAddDirExt(
+                       handle_t   hRoot,          /* Upper directory handle. NULL=root */
+                       const char *name,          /* New directory name */
+                       const char *desc )         /* Optional dir description */
+{
+    ConEntry_t *p_root = (ConEntry_t *)hRoot;
+    ConEntry_t *p_dir;
+    ConEntry_t **p_e;
+
+    if (!p_mon_root)
+        console_allocRoot( );
+
+    if (!p_root)
+        p_root = p_mon_root;
+
+    ASSERT( p_root && (p_root->sel == Dir) );
+
+    if ( (p_dir=(ConEntry_t *)malloc( sizeof( ConEntry_t )) ) == NULL)
+        return NULL;
+
+    memset( p_dir, 0, sizeof( ConEntry_t ) );
+    strncpy( p_dir->name, name, MAX_NAME_LEN );
+    strncpy( p_dir->help, desc, MAX_HELP_LEN );
+    p_dir->sel = Dir;
+
+    console_chooseAlias( p_root, p_dir );
+
+    /* Add new directory to the root's list */
+    p_dir->u.dir.upper = p_root;
+    p_e = &(p_root->u.dir.first);
+    while (*p_e)
+        p_e = &((*p_e)->next);
+    *p_e = p_dir;
+
+    return p_dir;
+}
+
+/***************************************************************
+
+   Function : consoleAddToken
+
+   Description: Add token
+
+   Parameters: p_dir  - directory handle (might be NULL=root)
+               name   - token name
+               help   - help string
+               p_func - token handler
+               p_parms- array of parameter descriptions.
+                        Must be terminated with {0}.
+                        Each parm descriptor is a struct
+                        { "myname",         - name
+                          10,               - low value
+                          20,               - high value
+                          0 }               - default value =-1 no default
+                                              or address for string parameter
+
+   Output:  E_OK - OK
+            !=0 - error
+***************************************************************/
+consoleErr consoleAddToken( handle_t      hDir,
+                      const char    *name,
+                      const char    *help,
+                      FuncToken_t   p_func,
+                      ConParm_t     p_parms[] )
+{
+   ConEntry_t *p_dir = (ConEntry_t *)hDir;
+   ConEntry_t *p_token;
+   ConEntry_t **p_e;
+   U16       i;
+
+   if (!p_mon_root)
+      console_allocRoot( );
+
+   if (!p_dir)
+      p_dir = p_mon_root;
+
+   ASSERT( p_dir && (p_dir->sel == Dir) );
+
+   /* Initialize token structure */
+   if ((p_token=(ConEntry_t *)calloc( 1, sizeof(ConEntry_t) )) == NULL)
+   {
+      fprintf(stderr, "** no memory **\n");
+      return E_NOMEMORY;
+   }
+
+
+   /* Copy name */
+   strncpy( p_token->name, name, MAX_NAME_LEN );
+   strncpy( p_token->help, help, MAX_HELP_LEN );
+   p_token->sel = Token;
+   p_token->u.token.f_tokenFunc = p_func;
+
+   /* Convert name to lower case and choose alias */
+   console_chooseAlias( p_dir, p_token );
+
+   /* Copy parameters */
+   if ( p_parms )
+   {
+      for(i = 0; p_parms->name && p_parms->name[0] && ( i < MAX_NUM_OF_PARMS); i++ )
+      {
+         ConParm_t *p_token_parm = &p_token->u.token.parm[i];
+
+         /* String parameter must have an address */
+         if(p_parms->flags & (CON_PARM_STRING | CON_PARM_LINE))
+         {
+            if ( p_parms->hi_val >= INBUF_LENGTH )
+         {
+                fprintf(stderr, "** buffer too big: %s/%s\n", p_dir->name, name);
+            free( p_token );
+                return E_NOMEMORY;
+
+            }
+            if (p_parms->hi_val == 0 || (p_parms->flags & CON_PARM_RANGE) )
+            {
+            fprintf(stderr, "** Bad string param definition: %s/%s\n", p_dir->name, name );
+                free( p_token );
+            return E_BADPARM;
+         }
+
+            p_parms->value = (U32) calloc(1, p_parms->hi_val+1);
+            if( !p_parms->value )
+            {
+                fprintf(stderr, "** No memory: %s/%s (max.size=%ld)\n", p_dir->name, name, p_parms->hi_val );
+                free( p_token );
+                return E_NOMEMORY;
+            }
+        }
+
+         /* Copy parameter */
+         *p_token_parm = *p_parms;
+         if( p_token_parm->hi_val || p_token_parm->low_val )
+             p_token_parm->flags |= CON_PARM_RANGE;
+         p_token_parm->name = (const char *)p_token->u.token.name[i];
+         strncpy( p_token->u.token.name[i], p_parms->name, MAX_NAME_LEN );
+         ++p_parms;
+      }
+      if ((i == MAX_NUM_OF_PARMS) && p_parms->name[0])
+      {
+            fprintf(stderr, "** Too many params: %s/%s\n", p_dir->name, name );
+         free( p_token );
+         return E_TOOMANY;
+      }
+   }
+
+   /* Add token to the directory */
+   p_e = &(p_dir->u.dir.first);
+   while (*p_e)
+      p_e = &((*p_e)->next);
+   *p_e = p_token;
+
+   return E_OK;
+}
+
+
+/* Monitor driver */
+void consoleStart( void )
+{
+#ifndef _WINDOWS
+   fd_set read_set;
+   int max_fd_index;
+   int result;
+   int pid;
+#endif /* __LINUX__ */
+
+   char inbuf[INBUF_LENGTH];
+
+   if (!p_mon_root)
+      return;
+
+   stop_UI_Monitor = FALSE;
+   console_displayDir( p_cur_dir );
+
+   while(!stop_UI_Monitor)
+   {
+          
+#ifndef _WINDOWS
+          /***********************************************************************************/   
+       /* Wait for one of two external events:                                                                                          */
+       /* -----------------------------------                                                                                  */
+       /*                                                                                                                                                         */
+       /* 1. Data received from STDIN                                                                                            */
+       /* 2. Data received from one of the TCP clients                                                          */
+          /* 3. Data received from iperf process stdout (if enabled)                                   */
+          /****************************************************************************/   
+          
+          /* Prepare the read set fields */
+          FD_ZERO(&read_set);
+          FD_SET(0, &read_set);
+          FD_SET(ipc_pipe[0], &read_set);
+          FD_SET(wipp_control_general_process_out_pipe[0], &read_set);
+
+          /* Determine the maximum index of the file descriptor */
+          max_fd_index = (max(wipp_control_general_process_out_pipe[0], max(0, ipc_pipe[0])) + 1);
+          
+          /* Wait for event - blocking */
+          result = select(max_fd_index, &read_set, NULL, NULL, NULL);
+
+          if (result > 0)
+          {
+                  if (FD_ISSET(0, &read_set))
+                  {
+                          /*****************************/
+                          /* Data received from STDIN */
+                          /***************************/
+                          
+                if ( fgets( inbuf, sizeof(inbuf), stdin ) <= 0 )
+                                return;
+  
+                               console_ParseString( inbuf );
+                          
+                  } 
+                  
+                  if (FD_ISSET(ipc_pipe[0], &read_set))
+                  {
+                          /**********************************/
+                          /* Data received from TCP client */
+                          /********************************/
+
+                          result = read(ipc_pipe[0], (U8 *)inbuf, (U16)sizeof(inbuf));
+
+                          /* Get the pid of the calling process */
+                          pid = *(inbuf + 0) | (*(inbuf + 1) << 8);
+
+                          /* Signal the calling process (tell him that we have 
+                             received the command, and he can send us another one */
+                          if (pid != 0xFFFF)
+                          {
+                                  kill(pid, SIGUSR1); 
+                          }
+                          
+                          if (result > 0)
+                          {
+                                  console_ParseString(inbuf + 2);
+                          }
+                  }
+
+                  if (FD_ISSET(wipp_control_general_process_out_pipe[0], &read_set))
+                  {
+                          /*****************************************/
+                          /* Data received general process stdout */
+                          /***************************************/
+
+                          result = read(wipp_control_general_process_out_pipe[0], (U8 *)inbuf + 3, sizeof(inbuf) - 3);
+
+                          if (result > 0)
+                          {
+                                  wipp_control_send_iperf_results_to_host(WIPP_CONTROL_EVT_RUN_PROCESS_STDOUT, inbuf, result);
+                          }
+                  }
+          }
+          else
+          {
+                  /* Error */
+                  console_printf_terminal("Input selection mismatch...\n");
+
+                  return;
+          }
+
+#else  /* __LINUX__ */
+#endif /* __LINUX__ */
+   }
+}
+
+
+/* Parse the given input string and exit.
+   All commands in the input string are executed one by one.
+*/
+void console_ParseString(char *input_string )
+{
+   ConEntry_t  *p_token;
+   char        name[MAX_NAME_LEN];
+   t_TokenType tType;
+   U16        nParms;
+
+
+#ifndef _WINDOWS
+       /* Check if this is WIPP control command, if it is - process it */
+       if (wipp_control_check_command(input_string))
+       {
+               return;
+       }
+
+       /* Check if this is g_tester control command, if it is - process it */
+       if (g_tester_check_command((unsigned char*) input_string))
+       {
+               return;
+       }
+#endif /* __LINUX__ */
+
+   if (!p_mon_root)
+      return;
+
+   if( input_string[strlen(input_string)-1] == '\n' )
+   {
+      char *s = (char *) &input_string[strlen(input_string)-1];
+         *s = 0;
+   }
+   p_inbuf = (char *)input_string;
+   stop_UI_Monitor = FALSE;
+
+   /* Interpret empty string as "display directory" */
+   if ( p_inbuf && !*p_inbuf )
+      console_displayDir( p_cur_dir );
+
+   while(!stop_UI_Monitor && p_inbuf && *p_inbuf)
+   {
+      tType = console_getWord( name, MAX_NAME_LEN );
+      switch( tType )
+      {
+
+      case NameToken:
+         p_token = console_searchToken( p_cur_dir, name );
+         if (p_token == NULL)
+         {
+            fprintf( stderr, "**Error: '%s'**\n", name);
+            p_inbuf = NULL;
+         }
+         else if (p_token->sel == Dir)
+         {
+            p_cur_dir = p_token;
+            console_displayDir( p_cur_dir );
+         }
+         else
+         {  /* Function token */
+            if (!console_parseParms( p_token, &nParms ))
+               console_displayHelp( p_token );
+            else
+               p_token->u.token.f_tokenFunc( p_token->u.token.parm, nParms );
+         }
+         break;
+
+      case UpToken: /* Go to upper directory */
+         if (p_cur_dir->u.dir.upper)
+            p_cur_dir = p_cur_dir->u.dir.upper;
+         console_displayDir( p_cur_dir );
+         break;
+
+      case RootToken: /* Go to the root directory */
+         if (p_cur_dir->u.dir.upper)
+            p_cur_dir = p_mon_root;
+         console_displayDir( p_cur_dir );
+         break;
+
+      case HelpToken: /* Display help */
+         if (( console_getWord( name, MAX_NAME_LEN ) == NameToken ) &&
+             ((p_token = console_searchToken( p_cur_dir, name )) != NULL ) &&
+             (p_token->sel == Token) )
+            console_displayHelp( p_token );
+         else
+            console_dirHelp( );
+         break;
+
+      case DirHelpToken:
+         console_displayDir( p_cur_dir );
+                       console_printf_terminal("Type ? <name> for command help, \"/\"-root, \"..\"-upper\n" );
+         break;
+
+      case BreakToken: /* Clear buffer */
+         p_inbuf = NULL;
+         break;
+
+      case EmptyToken:
+         break;
+
+      }
+   }
+}
+
+
+/* Stop monitor driver */
+void consoleStop( void )
+{
+   stop_UI_Monitor = TRUE;
+}
+
+
+/*********************************************************/
+/* Internal functions                                    */
+/*********************************************************/
+
+/* Allocate root directory */
+void console_allocRoot( void )
+{
+   /* The very first call. Allocate root structure */
+   if ((p_mon_root=(ConEntry_t *)calloc( 1, sizeof( ConEntry_t ) ) ) == NULL)
+   {
+      ASSERT( p_mon_root );
+      return;
+   }
+   strcpy( p_mon_root->name, ROOT_NAME );
+   p_mon_root->sel = Dir;
+   p_cur_dir = p_mon_root;
+}
+
+/* Display directory */
+void console_displayDir( ConEntry_t *p_dir )
+{
+   char out_buf[512];
+   ConEntry_t *p_token;
+
+   sprintf( out_buf, "%s%s> ", (p_dir==p_mon_root)? "" : ".../", p_dir->name );
+   p_token = p_dir->u.dir.first;
+   while( p_token )
+   {
+      if( (strlen(out_buf) + strlen(p_token->name) + 2)>= sizeof(out_buf) )
+      {
+          fprintf(stderr, "** console_displayDir(): buffer too small....\n");
+          break;
+      }
+      strcat( out_buf, p_token->name );
+      if ( p_token->sel == Dir )
+         strcat( out_buf, "/" );
+      p_token = p_token->next;
+      if (p_token)
+         strcat( out_buf, ", " );
+   }
+   console_printf_terminal("%s\n", out_buf );
+}
+
+
+/* Cut the first U16 from <p_inbuf>.
+   Return the U16 in <name> and updated <p_inbuf>
+*/
+static t_TokenType console_getWord( char *name, U16 len )
+{
+   U16        i=0;
+   t_TokenType tType;
+
+
+   p_inbuf = console_ltrim(p_inbuf);
+
+   while( *p_inbuf && *p_inbuf!=' ' && i<len )
+      name[i++] = *(p_inbuf++);
+
+   if (i<len)
+      name[i] = 0;
+
+   tType   = console_analizeToken( name );
+
+   return tType;
+}
+
+static t_TokenType console_getStrParam( char *buf, ConParm_t *param )
+{
+    t_TokenType tType;
+    U32         i, len = param->hi_val;
+    char        *end_buf;
+
+    p_inbuf = console_ltrim(p_inbuf);
+
+    if( param->flags & CON_PARM_LINE )
+    {
+        strcpy(buf, p_inbuf );
+        p_inbuf += strlen(p_inbuf);
+    }
+    else
+    {
+        if( *p_inbuf == '\"' )
+        {
+            end_buf = strchr(p_inbuf+1, '\"' );
+            if( !end_buf )
+            {
+                fprintf(stderr, "** invalid string param: '%s'\n", p_inbuf );
+                p_inbuf += strlen(p_inbuf);
+                return EmptyToken;
+            }
+            if( (end_buf - p_inbuf - 1) > (int)len )
+            {
+                fprintf(stderr, "** param is too long: '%s'\n", p_inbuf );
+                p_inbuf += strlen(p_inbuf);
+                return EmptyToken;
+            }
+            *end_buf = 0;
+            strcpy( buf, p_inbuf+1 );
+            p_inbuf = end_buf + 1;
+        }
+        else
+        {
+            for( i=0; *p_inbuf && *p_inbuf!=' ' && i<len; i++ )
+                buf[i] = *(p_inbuf++);
+
+            buf[i] = 0;
+            if( *p_inbuf && *p_inbuf != ' ' )
+            {
+                fprintf(stderr, "** param is too long: '%s'\n", p_inbuf-strlen(buf) );
+                p_inbuf += strlen(p_inbuf);
+                return EmptyToken;
+            }
+        }
+    }
+
+    tType   = console_analizeToken( buf );
+
+    return tType;
+}
+
+/* Make a preliminary analizis of <name> token.
+   Returns a token type (Empty, Up, Root, Break, Name)
+*/
+t_TokenType console_analizeToken( char *name )
+{
+   if (!name[0])
+      return EmptyToken;
+
+   if (!strcmp( name, TOKEN_UP ) )
+      return UpToken;
+
+   if (!strcmp( name, TOKEN_ROOT ) )
+      return RootToken;
+
+   if (!strcmp( name, TOKEN_BREAK ) )
+      return BreakToken;
+
+   if (!strcmp( name, TOKEN_HELP ) )
+      return HelpToken;
+
+   if (!strcmp( name, TOKEN_DIRHELP ) )
+      return DirHelpToken;
+
+   return NameToken;
+
+}
+
+
+/* Returns number of parameters of the given token
+*/
+static U16 console_getNParms( ConEntry_t *p_token )
+{
+   U16 i;
+   if ( !p_token->u.token.parm )
+      return 0;
+   for( i=0;
+        (i<MAX_NUM_OF_PARMS-1) &&
+         p_token->u.token.parm[i].name &&
+         p_token->u.token.parm[i].name[0];
+        i++ )
+      ;
+   return i;
+}
+
+/* Parse p_inbuf string based on parameter descriptions in <p_token>.
+   Fill parameter values in <p_token>.
+   Returns the number of parameters filled.
+   To Do: add a option of one-by-one user input of missing parameters.
+*/
+int console_parseParms( ConEntry_t *p_token, U16 *pnParms )
+{
+    U16 nTotalParms = console_getNParms( p_token );
+    U16 nParms=0;
+    char *end_buf = NULL, parm[INBUF_LENGTH];
+    U16 i, print_params = 0;
+    U32 val = 0;
+    S32 sval = 0;
+
+    /* Mark all parameters as don't having an explicit value */
+    for( i=0; i<nTotalParms; i++ )
+            p_token->u.token.parm[i].flags |= CON_PARM_NOVAL;
+
+    /*        -----------------              */
+    p_inbuf = console_ltrim(p_inbuf);
+    if( p_inbuf[0] == '!' && p_inbuf[1] == '!' )
+    {
+        p_inbuf += 2; print_params = 1;
+    }
+    /*        -----------------              */
+
+    /* Build a format string */
+    for( i=0; i<nTotalParms; i++ )
+    {
+        if (p_token->u.token.parm[i].flags & (CON_PARM_STRING | CON_PARM_LINE) )
+        {
+            /* For a string parameter value is the string address */
+            /* and hi_val is the string length                   */
+            if (console_getStrParam( parm, &p_token->u.token.parm[i] ) != NameToken)
+                break;
+            if( strlen(parm) > p_token->u.token.parm[i].hi_val ||
+                (p_token->u.token.parm[i].low_val && p_token->u.token.parm[i].low_val > strlen(parm) ) )
+        {
+                fprintf(stderr, "param '%s' must be %ld..%ld chars\n", p_token->u.token.parm[i].name,
+                        p_token->u.token.parm[i].low_val, p_token->u.token.parm[i].hi_val);
+                return FALSE;
+
+            }
+            strcpy( (char *)p_token->u.token.parm[i].value, parm );
+        }
+        else
+        {
+            if (console_getWord( parm, MAX_PARM_LEN ) != NameToken)
+                break;
+
+            if (p_token->u.token.parm[i].flags & CON_PARM_SIGN)
+                sval = strtol( parm, &end_buf, 0 );
+            else
+                val = strtoul( parm, &end_buf, 0 );
+            if( /*errno || */end_buf <= parm )
+                    break;
+
+/*             if (sscanf( parm, "%i", &val ) != 1)*/
+/*                 break;*/
+            
+            /* Check value */
+            if (p_token->u.token.parm[i].flags & CON_PARM_RANGE)
+            {           
+                if (p_token->u.token.parm[i].flags & CON_PARM_SIGN)
+                {
+                    if ((sval < (S32)p_token->u.token.parm[i].low_val) ||
+                        (sval > (S32)p_token->u.token.parm[i].hi_val) )
+                    {
+                        fprintf( stderr, "%s: %d out of range (%d, %d)\n",
+                            p_token->u.token.parm[i].name, (int)sval,
+                            (int)p_token->u.token.parm[i].low_val, (int)p_token->u.token.parm[i].hi_val );
+                        return FALSE;
+                    }
+
+                }
+                else
+                {                    
+                    if ((val < p_token->u.token.parm[i].low_val) ||
+                        (val > p_token->u.token.parm[i].hi_val) )
+                    {
+                        fprintf( stderr, "%s: %ld out of range (%ld, %ld)\n",
+                            p_token->u.token.parm[i].name, val,
+                            p_token->u.token.parm[i].low_val, p_token->u.token.parm[i].hi_val );
+                        return FALSE;
+                    }
+                }
+            }
+
+            if (p_token->u.token.parm[i].flags & CON_PARM_SIGN)                
+                p_token->u.token.parm[i].value = sval;
+            else
+                p_token->u.token.parm[i].value = val;
+        }
+
+        p_token->u.token.parm[i].flags &= ~CON_PARM_NOVAL;
+        ++nParms;
+    }
+
+    /* Process default values */
+    for( ; i<nTotalParms; i++ )
+    {
+        if ((p_token->u.token.parm[i].flags & CON_PARM_DEFVAL) != 0)
+        {
+            p_token->u.token.parm[i].flags &= ~CON_PARM_NOVAL;
+            ++nParms;
+        }
+        else if (!(p_token->u.token.parm[i].flags & CON_PARM_OPTIONAL) )
+        {
+            /* Mandatory parameter missing */
+            return FALSE;
+        }
+    }
+
+    if( print_params )
+    {
+        printf("Params: %d\n", nParms );
+        for (i=0; i<nParms; i++ )
+        {
+            console_printf_terminal("%d: %s - flags:%d", 
+                i+1, p_token->u.token.parm[i].name,
+                p_token->u.token.parm[i].flags);
+            
+            if (p_token->u.token.parm[i].flags & CON_PARM_SIGN)  
+                console_printf_terminal("min:%d, max:%d, value:%d ",p_token->u.token.parm[i].low_val, p_token->u.token.parm[i].hi_val,
+                    p_token->u.token.parm[i].value);
+            else
+                console_printf_terminal("min:%ld, max:%ld, value:%ld ",p_token->u.token.parm[i].low_val, p_token->u.token.parm[i].hi_val,
+                    p_token->u.token.parm[i].value);
+            
+            console_printf_terminal("(%#lx)",p_token->u.token.parm[i].value );
+            
+            if( p_token->u.token.parm[i].flags & (CON_PARM_LINE | CON_PARM_STRING ))
+            {
+                printf(" - '%s'", (char *) p_token->u.token.parm[i].value );
+            }
+            printf("\n");
+        }
+
+    }
+    *pnParms = nParms;
+
+    return TRUE;
+}
+
+/* Serach a token by name in the current directory */
+ConEntry_t *console_searchToken( ConEntry_t *p_dir, char *name )
+{
+   ConEntry_t *p_token;
+   U16        name_len = (U16)strlen( name );
+
+   /* Check alias */
+   p_token = p_dir->u.dir.first;
+   while( p_token )
+   {
+      if (p_token->alias &&
+          (name_len == ALIAS_LEN) &&
+          !console_stricmp( p_token->alias, name, ALIAS_LEN ) )
+          return p_token;
+      p_token = p_token->next;
+   }
+
+   /* Check name */
+   p_token = p_dir->u.dir.first;
+   while( p_token )
+   {
+      if (!console_stricmp( p_token->name, name, name_len ) )
+         break;
+      p_token = p_token->next;
+   }
+
+   return p_token;
+}
+
+
+/* Display help for each entry in the current directory */
+void  console_dirHelp( void )
+{
+   ConEntry_t *p_token;
+   char        print_str[80];
+
+   p_token = p_cur_dir->u.dir.first;
+
+   while( p_token )
+   {
+      if (p_token->sel == Dir)
+         sprintf( print_str, "%s: directory\n", p_token->name );
+      else
+         sprintf( print_str, "%s(%d parms): %s\n",
+                  p_token->name, console_getNParms(p_token), p_token->help );
+      console_printf_terminal( print_str );
+      p_token = p_token->next;
+   }
+
+   console_printf_terminal( "Type ? <name> for command help, \"/\"-root, \"..\"-upper\n" );
+}
+
+
+/* Display help a token */
+void  console_displayHelp( ConEntry_t *p_token )
+{
+   char bra, ket;
+   U16 nTotalParms = console_getNParms( p_token );
+   U16 i;
+
+   
+   console_printf_terminal( "%s: %s ", p_token->help, p_token->name );
+   for( i=0; i<nTotalParms; i++ )
+   {
+      if (p_token->u.token.parm[i].flags & CON_PARM_OPTIONAL)
+      {
+         bra = '['; ket=']';
+      }
+      else
+      {
+         bra = '<'; ket='>';
+      }
+      console_printf_terminal( "%c%s", bra, p_token->u.token.parm[i].name );
+      if (p_token->u.token.parm[i].flags & CON_PARM_DEFVAL)
+      {
+          console_printf_terminal("=%lu", p_token->u.token.parm[i].value);
+      }
+      if (p_token->u.token.parm[i].flags & CON_PARM_RANGE)
+      {
+          console_printf_terminal( (p_token->u.token.parm[i].flags & CON_PARM_SIGN) ? " (%d..%d%s)" : " (%lu..%lu%s)",
+                  p_token->u.token.parm[i].low_val,
+                  p_token->u.token.parm[i].hi_val,
+                  (p_token->u.token.parm[i].flags & (CON_PARM_STRING | CON_PARM_LINE)) ? " chars" : "" );
+          
+      }
+      console_printf_terminal( "%c \n",ket );
+   }
+}
+
+/* Choose unique alias for <name> in <p_dir> */
+/* Currently only single-character aliases are supported */
+int console_chooseAlias( ConEntry_t *p_dir, ConEntry_t *p_new_token )
+{
+   ConEntry_t *p_token;
+   int         i;
+   char        c;
+   char *new_alias = NULL;
+
+   /* find alias given from user */
+   for(i=0; p_new_token->name[i]; i++ )
+   {
+       if( isupper(p_new_token->name[i]) )
+       {
+           new_alias = &p_new_token->name[i];
+           break;
+       }
+   }
+
+   console_strlwr( p_new_token->name );
+
+   if( new_alias )
+   {
+      p_token = p_dir->u.dir.first;
+
+      while( p_token )
+      {
+         if (p_token->alias && (tolower( *p_token->alias ) == *new_alias) )
+         {
+/*            *new_alias = toupper(*new_alias);*/
+            fprintf( stderr, "**Error: duplicated alias '%c' in <%s> and <%s>**\n", *new_alias,
+                    p_token->name, p_new_token->name );
+            return 0;
+         }
+         p_token = p_token->next;
+      }
+      *new_alias = toupper(*new_alias);
+      p_new_token->alias = new_alias;
+      return 1;
+   }
+
+   i = 0;
+   while( p_new_token->name[i] )
+   {
+      c = p_new_token->name[i];
+      p_token = p_dir->u.dir.first;
+
+      while( p_token )
+      {
+         if (p_token->alias &&
+             (tolower( *p_token->alias ) == c) )
+            break;
+         p_token = p_token->next;
+      }
+      if (p_token)
+         ++i;
+      else
+      {
+         p_new_token->name[i] = toupper( c );
+         p_new_token->alias   = &p_new_token->name[i];
+         break;
+      }
+   }
+   return 1;
+}
+
+
+/* Convert string s to lower case. Return pointer to s */
+char  * console_strlwr( char *s )
+{
+   char  *s0=s;
+
+   while( *s )
+   {
+      *s = tolower( *s );
+      ++s;
+   }
+
+   return s0;
+}
+
+
+/* Compare strings case insensitive */
+int console_stricmp( char *s1, char *s2, U16 len )
+{
+   int  i;
+
+   for( i=0; i<len && s1[i] && s2[i]; i++ )
+   {
+      if (tolower( s1[i])  != tolower( s2[i] ))
+         break;
+   }
+
+   return ( (len - i) * (s1[i] - s2[i]) );
+}
+
+/* Remove leading blanks */
+char * console_ltrim(char *s )
+{
+    while( *s == ' ' || *s == '\t' ) s++;
+    return s;
+}
+
+#ifdef _WINDOWS
+#endif /* _WINDOWS*/
+
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/console.h b/sta_dk_4_0_4_32/CUDK/CLI/console.h
new file mode 100644 (file)
index 0000000..1e30517
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef tiwlan_console_h
+#define tiwlan_console_h
+
+#include <stdio.h>
+#include <assert.h>
+/*
+ * --------------------- *
+ *     error codes
+ * --------------------- *
+ */
+typedef enum
+{
+   E_OK = 0
+   , E_BADPARM
+   , E_TOOMANY
+   , E_NOMEMORY
+   , E_NOT_FOUND
+   , E_EXISTS
+   , E_DUMMY
+} consoleErr_t;
+
+typedef consoleErr_t  consoleErr;
+
+typedef void *                   handle_t;
+
+typedef unsigned char            U8;
+typedef signed char              S8;
+typedef unsigned short           U16;
+typedef signed short             S16;
+typedef unsigned long            U32;
+typedef signed long              S32;
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Monitor parameter flags */
+#define CON_PARM_OPTIONAL    0x01  /* Parameter is optional */
+#define CON_PARM_DEFVAL      0x02  /* Default value is set */
+#define CON_PARM_RANGE       0x04  /* Range is set */
+#define CON_PARM_STRING      0x08  /* String parm */
+#define CON_PARM_LINE        0x10  /* String from the current parser position till EOL */
+#define CON_PARM_SIGN        0x20  /* Signed param */
+#define CON_PARM_NOVAL       0x80  /* Internal flag: parameter is anassigned */
+
+/* Function parameter structure */
+typedef struct ConParm_t
+{
+   const char *name;             /* Parameter name. Shouldn't be allocated on stack! */
+   U8 flags;                     /* Combination of CON_PARM_??? flags */
+   U32 low_val;                  /* Low val for range checking */
+   U32 hi_val;                   /* Hi val for range checking/max length of string */
+   U32 value;                    /* Value/address of string parameter */
+} ConParm_t;
+
+#define CON_LAST_PARM       { NULL, 0, 0, 0, 0 }
+
+/* Monitor command handler prototype */
+typedef void (*FuncToken_t)(ConParm_t parm[], U16 nParms);
+
+/* Add subdirectory to the p_root directory
+   Returns the new directory handle
+*/
+handle_t consoleAddDirExt(
+                       handle_t   hRoot,          /* Upper directory handle. NULL=root */
+                       const char *name,          /* New directory name */
+                       const char *desc );    /* Optional directory description */
+
+/* Add token */
+consoleErr consoleAddToken( handle_t     hDir,     /* Directory handle. NULL=root */
+                      const char    *name,    /* Token name. Shouldn't be allocated on stack! */
+                      const char    *help,    /* Token help. Shouldn't be allocated on stack! */
+                      FuncToken_t   p_func,   /* Token handler */
+                      ConParm_t     p_parms[]);/* Array of token parameters. */
+                                              /* The last array element has parameter */
+                                              /* name = NULL */
+
+/* Monitor driver.
+   Calls XX_Gets in infinite loop to get input string.
+   Gives the string to console_ParseString for processing.
+   Monitor token handler can call consoleStop() to exit the
+   consoleStart.
+*/
+void consoleStart( void );
+
+/* Parse the given input string and exit.
+   All commands in the input string are executed one by one.
+*/
+void console_ParseString( char *input_string );
+
+/* Stop monitor driver */
+void consoleStop( void );
+
+/* Execute commands from 'script_file' */
+int consoleRunScript( char *script_file );
+
+#ifdef _WINDOWS
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* ----------------------------------------------------- */
+
+#define ALIAS_LEN                1
+
+#define MAX_NAME_LEN       80
+#define MAX_HELP_LEN       80
+#define MAX_PARM_LEN       20
+#define MAX_NUM_OF_PARMS   30
+
+#define TOKEN_UP           ".."
+#define TOKEN_ROOT         "/"
+#define TOKEN_BREAK        "#"
+#define TOKEN_HELP         "?"
+#define TOKEN_DIRHELP      "help"
+
+#ifndef FALSE
+       #define FALSE    0
+#endif
+
+#ifndef TRUE
+       #define TRUE    1
+#endif
+
+#ifndef __LINUX__ // TRS:WDK
+       #define perror(str) printf("\nError at %s:%d  - %s.\n", __FILE__, __LINE__, (str))
+#endif /* __LINUX__ */
+//TRS end
+#ifdef    __cplusplus
+       extern "C" {
+#endif   /* __cplusplus */
+
+#ifndef _WINDOWS /* TRS:WDK __LINUX__ */
+       #ifdef ERRCHK
+               # define ASSERT(p) assert(p)
+       #else
+               # define ASSERT(p) do {} while (0)
+       #endif 
+#endif /* TRS:WDK __LINUX__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+typedef enum { Dir, Token } ConEntry_type_t;
+
+/* Parameter name and format */
+typedef char (ParmName_t)[MAX_NAME_LEN+1];
+
+/* Monitor token structure */
+typedef struct ConEntry_t
+{
+   struct ConEntry_t   *next;
+   char                name[MAX_NAME_LEN+1];    /* Entry name */
+   char                help[MAX_HELP_LEN+1];    /* Help string */
+   char                *alias;                  /* Alias - always in upper case*/
+   ConEntry_type_t     sel;                   /* Entry selector */
+
+   union {
+      struct
+      {
+         struct ConEntry_t   *upper;            /* Upper directory */
+         struct ConEntry_t   *first;            /* First entry */
+      } dir;
+      struct t_Token
+      {
+         FuncToken_t    f_tokenFunc;            /* Token handler */
+         ConParm_t      parm[MAX_NUM_OF_PARMS]; /* Parameters array */
+         ParmName_t     name[MAX_NUM_OF_PARMS]; /* Parameter name */
+      } token;
+   } u;
+} ConEntry_t;
+
+/* Token types */
+typedef enum
+{
+   EmptyToken,
+   UpToken,
+   RootToken,
+   BreakToken,
+   HelpToken,
+   DirHelpToken,
+   NameToken
+} t_TokenType;
+
+char * console_strlwr( char *s );
+int    console_stricmp( char *s1, char *s2, U16 len );
+char * console_ltrim( char *s );
+
+#endif /* #ifndef tiwlan_console_h */
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/cu_cmd.c b/sta_dk_4_0_4_32/CUDK/CLI/cu_cmd.c
new file mode 100644 (file)
index 0000000..9c4a3f8
--- /dev/null
@@ -0,0 +1,4896 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifdef _WINDOWS
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#ifndef _WINDOWS
+       #include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/wireless.h>
+
+       #include "tnetwCommon.h"
+#endif /* __LINUX__ */
+
+#include "g_tester.h"
+#include "wspVer.h"
+
+#include "paramOut.h"
+#include "console.h"
+#include "ticon.h"
+#include "cu_cmd.h"
+#include "linux_ioctl_common.h"
+#include "802_11Defs.h"
+
+#ifndef _T
+#define _T(a)    a
+#endif
+
+#ifndef _WINDOWS
+TI_HANDLE   g_id_adapter = 0;
+#endif
+
+#define MAX_SSID_LEN 32
+#define CLI_NUM_OF_TX_CLASFR_CON 4
+
+scan_Params_t appScanParams;
+scan_Policy_t scanPolicy;
+
+/*** Roaming Manager configuration parameters ***/
+roamingMngrConfigParams_t   roamingMngrConfigParams;
+
+static tiUINT32 events_mask = 0; // TRS:PGK
+
+#define NET_BASIC_MASK      0x80    /* defined in common/src/utils/utils.c */
+
+#define IS_BASIC_RATE(a)    ((a) & NET_BASIC_MASK)
+
+#define RATE_2_MBPS(a)    ((float)((a) & (NET_BASIC_MASK-1))/2)
+
+#define GET_NAME_BY_VALUE(arr, value)    get_name_by_value(arr, SIZE_ARR(arr), value)
+
+#define CHAN_FREQ_TABLE_SIZE        (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ))
+
+#define RATE_TABLE_SIZE             (sizeof(rate2Str) / sizeof(named_value_t))
+
+#define ET_TABLE_SIZE               (sizeof(EtEvent2Str) / sizeof(named_value_t))
+
+/* EarlyTermination DISABLE mode - Should be same as in scan.h */
+#define SCAN_ET_COND_DISABLE 0
+
+#define MAX_PSK_STRING_LENGTH       63
+
+#define MIN_PSK_STRING_LENGTH       8
+
+#define PSK_HEXA_LENGTH       64
+
+#define PSK_BUFF_LEN 65
+
+static void get_bssid_list(ConParm_t parm[], U16 nParms, BOOL fullBssidList , OS_802_11_BSSID_EX *pBssid);
+
+static BOOL is_value_rate (tiUINT32 rate)
+{
+
+   switch (rate)
+   {
+   case 1:
+   case 2:
+   case 5:
+   case 6:
+   case 9:
+   case 11:
+   case 12:
+   case 18:
+   case 22:
+   case 24:
+   case 36:
+   case 48:
+   case 54:
+      return (TRUE);
+   default:
+      return (FALSE);
+   }
+
+}
+static BOOL is_value_rate (tiUINT32 rate);
+struct CHAN_FREQ {
+    UINT8       chan;
+    UINT32      freq;
+} ChanFreq[] = {
+    {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000},
+    {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000},
+    {9,2452000},
+    {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000},
+    {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000},
+    {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000},
+    {64,5320000},
+    {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000},
+    {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000},
+    {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000},
+    {153,5765000}, {157,5785000}, {161,5805000} };
+
+static named_value_t power_mode_val[] = {
+        { OS_POWER_MODE_AUTO,        "AUTO" },
+        { OS_POWER_MODE_ACTIVE,      "ACTIVE" },
+        { OS_POWER_MODE_SHORT_DOZE,  "SHORT_DOZE" },
+        { OS_POWER_MODE_LONG_DOZE,   "LONG_DOZE" }
+};
+
+static named_value_t power_level_val[] = {
+        { OS_POWER_LEVEL_ELP,        "ELP" },
+        { OS_POWER_LEVEL_PD,      "PD" },
+        { OS_POWER_LEVEL_AWAKE,  "AWAKE" }
+};
+
+static named_value_t encrypt_type[] = {
+        { OS_ENCRYPTION_TYPE_NONE,              "None" },
+        { OS_ENCRYPTION_TYPE_WEP,               "WEP"  },
+        { OS_ENCRYPTION_TYPE_TKIP,              "TKIP" },
+        { OS_ENCRYPTION_TYPE_AES,               "AES" }
+};
+
+static named_value_t scanType2Str[] = {
+        { SCAN_TYPE_NORMAL_PASSIVE,             "Passive Normal Scan"               },
+        { SCAN_TYPE_NORMAL_ACTIVE,              "Active Normal Scan"                },
+        { SCAN_TYPE_SPS,                        "Scheduled Passive Scan (SPS)"      },
+        { SCAN_TYPE_TRIGGERED_PASSIVE,          "Passive Triggered Scan"            },
+        { SCAN_TYPE_TRIGGERED_ACTIVE,           "Active Triggered Scan"             }
+};
+
+static named_value_t band2Str[] = {
+        { RADIO_BAND_2_4_GHZ,                   "2.4 GHz"                        },
+        { RADIO_BAND_5_0_GHZ,                   "5.0 GHz"                        },
+        { RADIO_BAND_DUAL,                      "Both   "                        }
+};
+
+static named_value_t rate2Str[] = {
+        { DRV_RATE_MASK_AUTO,                   "Auto    "                          },
+        { DRV_RATE_MASK_1_BARKER,               "1 Mbps  "                          },
+        { DRV_RATE_MASK_2_BARKER,               "2 Mbps  "                          },
+        { DRV_RATE_MASK_5_5_CCK,                "5.5 Mbps"                          },
+        { DRV_RATE_MASK_11_CCK,                 "11 Mbps "                          },
+        { DRV_RATE_MASK_22_PBCC,                "22 Mbps "                          },
+        { DRV_RATE_MASK_6_OFDM,                 "6 Mbps  "                          },
+        { DRV_RATE_MASK_9_OFDM,                 "9 Mbps  "                          },
+        { DRV_RATE_MASK_12_OFDM,                "12 Mbps "                          },
+        { DRV_RATE_MASK_18_OFDM,                "18 Mbps "                          },
+        { DRV_RATE_MASK_24_OFDM,                "24 Mbps "                          },
+        { DRV_RATE_MASK_36_OFDM,                "36 Mbps "                          },
+        { DRV_RATE_MASK_48_OFDM,                "48 Mbps "                          },
+        { DRV_RATE_MASK_54_OFDM,                "54 Mbps "                          }
+};
+
+static named_value_t EtEvent2Str[] = {
+        { SCAN_ET_COND_DISABLE,                      "ET disabled  "                     },
+        { SCAN_ET_COND_BEACON,                       "ET on Beacon "                     },
+        { SCAN_ET_COND_PROBE_RESP,                   "ET on Prb Rsp"                     },
+        { SCAN_ET_COND_ANY_FRAME,                    "ET on both   "                     }
+};
+
+/* used in scan_display */
+static char* rate2StrFunc(UINT32 rate)
+{
+    UINT32 i;
+
+    for ( i = 0; i < RATE_TABLE_SIZE; i++ )
+    {
+        if ( rate2Str[ i ].value == rate )
+            return rate2Str[ i ].name;
+    }
+    return rate2Str[ 0 ].name;
+}
+
+/* used in scan_display */
+static char* EtEvent2StrFunc( UINT32 ETCond )
+{
+    int i;
+
+    for ( i = 0; i < ET_TABLE_SIZE; i++ )
+    {
+        if ( EtEvent2Str[ i ].value == ETCond )
+        {
+            return EtEvent2Str[ i ].name;
+        }
+    }
+
+    return EtEvent2Str[ 0 ].name;
+}
+
+/* used in get_bssid_list() */
+UINT8 Freq2Chan(UINT32 freq)
+{
+    UINT32 i;
+
+    for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
+        if(ChanFreq[i].freq == freq) return ChanFreq[i].chan;
+
+    return 0;
+}
+/* IPC events Callback */
+int cli_receive_ev(IPC_EV_DATA*    pData)
+{
+    tiUINT8 *buf;
+    OS_802_11_QOS_TSPEC_PARAMS *AddTsResult;
+    OS_802_11_AUTHENTICATION_REQUEST *request;
+       OS_802_11_DISASSOCIATE_REASON_T  *pDisAssoc;
+    OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *CrossParams;
+    OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS *TrafficIntensityThresholdParams;
+       btCoexStatus_t                          *btCoexStatus;
+
+#if defined (_WINDOWS)
+#endif
+    g_tester_receive_event((tiUINT8)((IPC_EVENT_PARAMS *)pData)->uEventType);
+#if defined (_WINDOWS)
+#endif
+
+    switch(((IPC_EVENT_PARAMS *)pData)->uEventType)
+    {
+        case IPC_EVENT_ASSOCIATED:
+            console_printf_terminal("CLI Event - Associated\n");
+// TRS:HLC
+/*
+#if defined (_WINDOWS)
+#endif
+*/
+//TRS end
+        break;
+        case IPC_EVENT_DISASSOCIATED:
+                       pDisAssoc = (OS_802_11_DISASSOCIATE_REASON_T*)pData->uBuffer;
+                       switch(pDisAssoc->eDisAssocType)
+                       {
+                       case OS_DISASSOC_STATUS_UNSPECIFIED:
+                               console_printf_terminal("CLI Event - Disassociated with unspecified reason (User/SG/Recovery)\n");
+                               break;
+                       case OS_DISASSOC_STATUS_AUTH_REJECT:
+                               if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
+                               {
+                                       console_printf_terminal("CLI Event - Disassociated due to no Auth response \n");
+                               }
+                               else
+                               {
+                                       console_printf_terminal("CLI Event - Disassociated due to Auth response packet with reason = %d\n", pDisAssoc->uStatusCode);
+                               }
+                               break;
+                       case OS_DISASSOC_STATUS_ASSOC_REJECT:
+                               if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
+                               {
+                                       console_printf_terminal("CLI Event - Disassociated due to no Assoc response \n");
+                               }
+                               else
+                               {
+                                       console_printf_terminal("CLI Event - Disassociated due to Assoc response packet with reason = %d\n", pDisAssoc->uStatusCode);
+                               }
+                           break;
+                       case OS_DISASSOC_STATUS_SECURITY_FAILURE:
+                               console_printf_terminal("CLI Event - Disassociated due to RSN failure\n");
+                           break;
+                       case OS_DISASSOC_STATUS_AP_DEAUTHENTICATE:
+                               console_printf_terminal("CLI Event - Disassociated due to AP deAuthenticate packet with reason = %d\n", pDisAssoc->uStatusCode);
+                               break;
+                       case OS_DISASSOC_STATUS_AP_DISASSOCIATE:
+                               console_printf_terminal("CLI Event - Disassociated due to AP disAssoc packet with reason = %d\n", pDisAssoc->uStatusCode);
+                               break;
+                       case OS_DISASSOC_STATUS_ROAMING_TRIGGER:
+                               console_printf_terminal("CLI Event - Disassociated due to roaming trigger = %d\n", pDisAssoc->uStatusCode);
+                               break;
+                       default:
+                               console_printf_terminal("CLI Event - Disassociated with unknown reason = %d\n", pDisAssoc->eDisAssocType);
+                           break;
+                       }
+        break;
+        case IPC_EVENT_LINK_SPEED:
+            console_printf_terminal("CLI Event - LinkSpeed\n");
+        break;
+        case IPC_EVENT_AUTH_SUCC:
+            console_printf_terminal("CLI Event - Authentication Success\n");
+        break;
+        case IPC_EVENT_SCAN_COMPLETE:
+            console_printf_terminal("CLI Event - Scan Complete\n");
+        break;
+        case IPC_EVENT_TIMEOUT:
+            console_printf_terminal("CLI Event - Timeout\n");
+        break;
+        case IPC_EVENT_UNBOUND:
+            console_printf_terminal("CLI Event - Unbound\n");
+        break;
+        case IPC_EVENT_BOUND:
+            console_printf_terminal("CLI Event - Bound\n");
+        break;
+        case IPC_EVENT_EAPOL:
+            console_printf_terminal("CLI Event - EAPOL\n");
+        break;
+        case IPC_EVENT_MEDIA_SPECIFIC:
+            buf = pData->uBuffer;
+            request = (OS_802_11_AUTHENTICATION_REQUEST *) (buf + sizeof(tiUINT32));
+            if( request->Flags == OS_802_11_REQUEST_PAIRWISE_ERROR ||
+                request->Flags == OS_802_11_REQUEST_GROUP_ERROR)
+            console_printf_terminal("CLI Event - Media_Specific\n");
+        break;
+        case IPC_EVENT_CCKM_START:
+            console_printf_terminal("CLI Event - CCKM_Start\n");
+        break;
+
+        case IPC_EVENT_PREAUTH_EAPOL:
+            console_printf_terminal("CLI Event - PreAuth EAPOL\n");
+            break;
+
+        case IPC_EVENT_LOW_SNR:
+            console_printf_terminal("CLI Event - Low SNR\n");
+            break;
+
+        case IPC_EVENT_LOW_RSSI:
+            console_printf_terminal("CLI Event - Low RSSI\n");
+            break;
+
+        case IPC_EVENT_EAP_AUTH_FAILURE:
+            {
+                OS_802_11_EAP_TYPES eapType;
+                tiINT32             status;
+                authStatus_e        eAuthStatusReason;
+
+                               /* Cast the value to be UINT16 16 bits since it is sent this way in the EXCMngr.c */
+                eAuthStatusReason = (authStatus_e)((*(pData->uBuffer)) & 0xFFFF);
+
+                status = TI_GetEAPType( g_id_adapter, &eapType );
+
+                if (eapType == OS_EAP_TYPE_LEAP)
+                {
+                    console_printf_terminal("CLI Event - LEAP Authentication Failed \n");
+                }
+                else if (eapType == OS_EAP_TYPE_FAST)
+                {
+                    console_printf_terminal("CLI Event - EAP-FAST Authentication Failed \n");
+                }
+                else if (eapType == OS_EAP_TYPE_TLS)
+                {
+                    console_printf_terminal("CLI Event - EAP-TLS Authentication Failed \n");
+                }
+
+                switch ( eAuthStatusReason )
+                {
+                case RSN_AUTH_STATUS_INVALID_TYPE:
+                    console_printf_terminal("The reason: Invalid Authentication Type \n");
+                    break;
+                case RSN_AUTH_STATUS_TIMEOUT:
+                    console_printf_terminal("The reason: Authentication Timeout \n");
+                    break;
+                case RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED:
+                case RSN_AUTH_STATUS_CHALLENGE_TO_AP_FAILED:
+                    console_printf_terminal("The reason: username or password incorrect \n");
+                    break;
+                default:
+                    console_printf_terminal("The reason: unknown = %d \n", eAuthStatusReason);
+                    break;
+                }
+
+            }
+            break;
+
+        case IPC_EVENT_TSPEC_STATUS:
+           AddTsResult = (OS_802_11_QOS_TSPEC_PARAMS *)pData->uBuffer;
+           console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_STATUS -- (userPriority = %d, ReasonCode = %d) \n",AddTsResult->uUserPriority,AddTsResult->uReasonCode);
+           console_printf_terminal ("Tspec Parameters (as received through event handler):\n");
+           console_printf_terminal ("-----------------------------------------------------\n");
+           console_printf_terminal ("userPriority = %d\n",AddTsResult->uUserPriority);
+           console_printf_terminal ("uNominalMSDUsize = %d\n",AddTsResult->uNominalMSDUsize);
+           console_printf_terminal ("uMeanDataRate = %d\n",AddTsResult->uMeanDataRate);
+           console_printf_terminal ("uMinimumPHYRate = %d\n",AddTsResult->uMinimumPHYRate);
+           console_printf_terminal ("uSurplusBandwidthAllowance = %d\n",AddTsResult->uSurplusBandwidthAllowance);
+           console_printf_terminal ("uAPSDFlag = %d\n",AddTsResult->uAPSDFlag);
+           console_printf_terminal ("uMediumTime = %d\n\n",AddTsResult->uMediumTime);
+           break;
+        case IPC_EVENT_TSPEC_RATE_STATUS:
+           CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
+           console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_RATE_STATUS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
+           break;
+        case IPC_EVENT_MEDIUM_TIME_CROSS:
+           CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
+           console_printf_terminal("CLI Event - IPC_EVENT_MEDIUM_TIME_CROSS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
+           break;
+        case IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED:
+           TrafficIntensityThresholdParams = (OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS*)pData->uBuffer;
+           printf("CLI Event - IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED\n");
+           printf("---------------------------------------------------------\n");
+           printf("Threshold crossed: %s Threshold\n", ((TrafficIntensityThresholdParams->uHighOrLowThresholdFlag == HIGH_THRESHOLD_CROSS) ? "High" : "Low"));
+           printf("Direction crossed: %s\n\n", ((TrafficIntensityThresholdParams->uAboveOrBelowFlag == CROSS_ABOVE) ? "Above" : "Below"));
+           break;
+
+        case IPC_EVENT_WPA2_PREAUTHENTICATION:
+            {
+                ULONG *WPA2_PreAuth_Status;
+
+               WPA2_PreAuth_Status = (ULONG *)pData->uBuffer;
+               printf("CLI Event - IPC_EVENT_WPA2_PREAUTHENTICATION\n");
+               printf("Status code = %lu\n",*WPA2_PreAuth_Status);
+            }
+           break;
+
+        case IPC_EVENT_ROAMING_COMPLETE:
+            printf("CLI Event - IPC_EVENT_ROAMING_COMPLETE \n");
+        break;
+
+       case IPC_EVENT_BT_COEX_MODE:
+               btCoexStatus = (btCoexStatus_t*)pData->uBuffer;
+               if (btCoexStatus->state)
+               {
+                       console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is ON, minTxRate = %d)\n",btCoexStatus->minTxRate);
+               }
+               else
+               {
+                       console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is OFF)\n");
+               }
+               break;
+
+        default:
+            console_printf_terminal("CLI Event - Unknown event\n");
+        break;
+    }
+    return 0;
+
+
+}
+
+static char *print_rate(rate_e rate)
+{
+    static char buf[20];
+
+    if( rate == 0 )
+        return "Auto (0)";
+
+    sprintf(buf, "%.3g Mbps (%u%s)", RATE_2_MBPS(rate), rate,
+        IS_BASIC_RATE(rate) ? " - basic" : "" );
+    return buf;
+}
+
+static BOOL isJunkSSID(OS_802_11_SSID *ssid )
+{
+    if ((ssid == NULL) || (ssid->SsidLength == 0))
+    {
+        return TRUE;
+    }
+
+    if (ssid->SsidLength > 2)
+    {
+        if ((ssid->Ssid[0] < MAX_SSID_LEN) &&
+            (ssid->Ssid[1] < MAX_SSID_LEN) &&
+            (ssid->Ssid[2] < MAX_SSID_LEN))
+        {
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+static char *get_ssid_string(OS_802_11_SSID *ssid )
+{
+    static char tmp_buf[MAX_SSID_LEN+1];
+    if ((ssid == NULL) || (ssid->SsidLength == 0) || isJunkSSID(ssid))
+        return "<empty>";
+
+    if (ssid->SsidLength < SIZE_ARR(ssid->Ssid))
+           ssid->Ssid[ssid->SsidLength] = 0;
+    else if( ssid->SsidLength == MAX_SSID_LEN )
+    {
+        memcpy(tmp_buf, ssid->Ssid, MAX_SSID_LEN );
+        tmp_buf[MAX_SSID_LEN] = 0;
+        return tmp_buf;
+    }
+    else
+    {
+        console_printf_terminal("error: invalid ssid length (len = %u)\n", ssid->SsidLength );
+        return "<error>";
+    }
+    return (char *) ssid->Ssid;
+}
+/*  return 0 on error
+    or 'mac' if success
+    'str' format: num.num.num.num.num.num (where 'num' is number from 0 to 255)
+*/
+U8* str2MACAddr(char *str, U8 *mac)
+{
+    const int mac_len = 6;
+    int i;
+    char *p = str;
+#ifndef _WINDOWS
+    errno = 0;
+#endif
+    console_printf_terminal("str2MAC():");
+    for( i=0; i<mac_len; i++ )
+    {
+        mac[i] = (U8) strtoul(p, &p, 16);
+#ifndef _WINDOWS
+        if( errno == ERANGE )
+            return NULL;
+#endif
+        console_printf_terminal("%2x.", mac[i] );
+        p++;
+
+    }
+    console_printf_terminal("\n");
+    return mac;
+}
+
+static char * print_mac_2_str(OS_802_11_MAC_ADDRESS mac)
+{
+    static char buf[30];
+
+    sprintf(buf, "%02x.%02x.%02x.%02x.%02x.%02x",
+                mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+    return buf;
+}
+
+/* convert hex MAC addr in the form xx:xx:xx:xx:xx:xx to mac address */
+static void hexStr2MACAddr( char *hexStr, macAddress_t* mac )
+{
+    size_t i;
+    char *currHexStrPos = hexStr;
+    UINT8 tempValue;
+
+    /* convert hex string to lower */
+    for ( i = 0; i < strlen(hexStr); i++ )
+    {
+        hexStr[ i ] = tolower( hexStr[ i ] );
+    }
+
+    /* convert to numbers */
+    for ( i = 0; i < 6; i++ )
+    {
+        tempValue = 0;
+        if ( *currHexStrPos >= 'a' )
+            tempValue = *currHexStrPos - 'a' + 10;
+        else
+            tempValue = *currHexStrPos - '0';
+        currHexStrPos++;
+        tempValue <<= 4;
+        if ( *currHexStrPos >= 'a' )
+            tempValue += *currHexStrPos - 'a' + 10;
+        else
+            tempValue += *currHexStrPos - '0';
+        currHexStrPos += 2;
+        mac->addr[ i ] = tempValue;
+    }
+}
+
+static void mac2HexStr( macAddress_t* mac, char* hexStr )
+{
+    sprintf( hexStr, "%02x:%02x:%02x:%02x:%02x:%02x",
+        mac->addr[0],mac->addr[1],mac->addr[2],mac->addr[3],mac->addr[4],mac->addr[5]);
+}
+
+char *get_name_by_value(named_value_t *arr, int arr_size, UINT32 value)
+{
+    int i;
+    for(i=0; i<arr_size; i++) {
+        if( arr[i].value == value )
+            return arr[i].name;
+    }
+    return "<unknow>";
+}
+
+void cmd_modify_supported_rates(ConParm_t parm[], U16 nParms)
+{
+    rates_t data = { 0 };
+    char debug_buf[256] = { 0 };
+    int i;
+
+    if( nParms == 0 )
+    {
+        if( !TI_GetSupportedRates(g_id_adapter, (tiUINT8*)&data, sizeof(data)) )
+        {
+            console_printf_terminal(" Rates: ");
+            for( i=0; i<MAX_SUPPORTED_RATES && i < data.len; i++ )
+            {
+                console_printf_terminal("%g Mbps(%u%s)%s", RATE_2_MBPS(data.ratesString[i]),
+                    data.ratesString[i],
+                    IS_BASIC_RATE(data.ratesString[i]) ? " - basic" : "",
+                    (i < data.len-1) ? "," : "" );
+            }
+            console_printf_terminal("\n");
+        }
+    }
+    else
+    {
+        char *end_p, *buf = (char *) parm[0].value;
+        float val;
+        console_printf_terminal("param: %s\n", buf );
+#ifndef _WINDOWS
+        errno = 0;
+#endif
+        for( i=0; *buf && i < MAX_SUPPORTED_RATES; i++ )
+        {
+            val = (float) strtod(buf, &end_p);
+            if(
+#ifndef _WINDOWS
+                          errno ||
+#endif
+                          buf == end_p )
+            {
+                console_printf_terminal("cmd_modify_supported_rates(): invalid value - %s\n", buf );
+                return;
+            }
+            if( val > ((1 << (sizeof(data.ratesString[i]) * 8))-1) )
+            {
+                console_printf_terminal("cmd_modify_supported_rates(): out of range '%.*s'\n", end_p - buf, buf );
+                return;
+            }
+            data.ratesString[i] = (tiUINT8) (val);
+
+            sprintf(&debug_buf[strlen(debug_buf)], "%g (%d) ", val, data.ratesString[i] );
+
+            buf = end_p;
+            while( *buf==' ' || *buf == ',' )   buf++;
+
+        }
+
+        if( *buf )
+        {
+            console_printf_terminal("too many parameters. Max=%d\n", MAX_SUPPORTED_RATES );
+            return;
+        }
+
+        data.len = i;
+        console_printf_terminal("**set rates (%d) :%s\n", data.len, debug_buf );
+        TI_SetSupportedRates(g_id_adapter, (tiUINT8*) &data, sizeof(data));
+    }
+}
+
+void cmd_show_status(ConParm_t parm[], U16 nParms)
+{
+    tiINT32 res;
+    OS_802_11_BSSID_EX BssIdInfo;
+
+    tiUINT32 data;
+    char buf[4096] = { 0 };
+    OS_802_11_SSID ssid = { 0 };
+    OS_802_11_MAC_ADDRESS bssid = { 0 };
+
+    UNUSED(parm);
+    UNUSED(nParms);
+
+    buf[0] = 0;
+
+    res = TI_WLAN_IsDriverRun(g_id_adapter, (tiBOOL *)&data);
+    if( res )
+        return ;
+
+    sprintf(buf, "Status   : %s\n", res ? "<error>" : (data ? "running" : "stopped") );
+
+    sprintf(&buf[strlen(buf)], "MAC      : ");
+    if( !TI_GetCurrentAddress(g_id_adapter, &bssid ) )
+        strcat(buf, print_mac_2_str(bssid) );
+    else
+        strcat(buf, "<error>");
+
+    strcat(buf, "\nSSID     : ");
+    if( !TI_GetCurrentSSID(g_id_adapter, &ssid) )
+    {
+        if (!isJunkSSID(&ssid))
+        {
+           strncat(buf, get_ssid_string(&ssid),ssid.SsidLength);
+        }
+        else
+        {
+           strcat(buf,"<empty>");
+        }
+    }
+    else
+        strcat(buf, "<error>" );
+
+    sprintf(&buf[strlen(buf)], "\nBSSID    : ");
+
+   TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
+   strcat(buf, print_mac_2_str(BssIdInfo.MacAddress));
+
+    strcat(buf, "\nChannel  : ");
+    data = 0;
+    if( !TI_GetCurrentChannel(g_id_adapter, &data ) )
+    {
+        sprintf(&buf[strlen(buf)], "%d", data );
+    }
+    else
+        strcat(buf, "<error>");
+
+    console_printf_terminal("==========================\n%s\n==========================\n\n", buf);
+}
+
+void cmd_connect(ConParm_t parm[], U16 nParms)
+{
+    char buf[1] = { 0 };
+    OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
+
+    buf[0] = 0;
+
+    switch (nParms) {
+
+    case 0 :
+        /*
+         *  No SSID & No BSSID are set -
+         *  Use Any SSID & Any BSSID.
+         */
+
+        TI_SetBSSID(g_id_adapter, &bssid );
+        TI_SetSSID(g_id_adapter, (tiUINT8 *) buf);
+        break;
+
+    case 1:
+        /*
+         *  SSID set & BSSID insn't set  -
+         *  Use CLI's SSID & Any BSSID.
+         */
+        TI_SetBSSID(g_id_adapter, &bssid );
+        TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
+        break;
+
+    case 2:
+        /*
+         *  Both SSID & BSSID are set -
+         *  Use CLI's SSID & BSSID.
+         */
+        if( !str2MACAddr((char *) parm[1].value, bssid) )
+            return;
+        TI_SetBSSID(g_id_adapter, &bssid);
+        TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
+        break;
+}
+}
+
+
+void cmd_disassociate(ConParm_t parm[], U16 nParms)
+{
+    UNUSED(parm);
+    UNUSED(nParms);
+
+    TI_Disassociate(g_id_adapter);
+}
+
+void cmd_show_advanced_params(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 mode_4x = 0, preamble = 0xfefefefe;
+    OS_802_11_AUTHENTICATION_MODE auth;
+    OS_802_11_ENCRYPTION_TYPES encrypt;
+    tiUINT32    rts_tresh;
+    tiUINT32    frag_tresh = 0xfefefefe;
+    tiUINT8     tx_power = 0xfe;
+    OS_802_11_POWER_PROFILE power_mode = 0;
+
+    UNUSED(parm);
+    UNUSED(nParms);
+
+    TI_GetAuthenticationMode(g_id_adapter, &auth );
+    TI_GetTxPowerDbm(g_id_adapter, (tiCHAR*) &tx_power);
+    TI_GetFragmentThreshold( g_id_adapter, &frag_tresh);
+    TI_GetRTSThreshold( g_id_adapter, &rts_tresh);
+    TI_Get4XState( g_id_adapter, &mode_4x);
+    TI_GetEncryptionType( g_id_adapter, &encrypt );
+    TI_GetPowerMode(g_id_adapter, (OS_802_11_POWER_PROFILE*) &power_mode );
+    console_printf_terminal("  Authentication : %u\n", auth );
+    console_printf_terminal("      Power mode : %d\n", (tiUINT32) power_mode );
+    console_printf_terminal("  Tx Power (Dbm/10 units) : %d\n", tx_power );
+
+    console_printf_terminal("      Encryption : %u\n", encrypt );
+    console_printf_terminal("        Preamble : <%s>\n", (preamble) ? "short" : "long");
+/*    console_printf_terminal("      Tx antenna : %u\n", tx_ant );*/
+/*    console_printf_terminal(  "      Rx antenna : %u\n", rx_ant );*/
+/*    console_printf_terminal(  "Ap Tx power level: n/a\n" );*/
+/*    console_printf_terminal(  "  Tx power value : %lu\n", tx_power_val );*/
+/*    console_printf_terminal(  "     MAC address : n/a\n" );*/
+    console_printf_terminal(  "        4X state : %d\n", mode_4x );
+/*     console_printf_terminal(  "        B/G mode : n/a\n" );*/
+/*     console_printf_terminal(  "    Country code : n/a\n" );*/
+/*     console_printf_terminal(  "      IP address : n/a\n" );*/
+/*     console_printf_terminal(  "        Net mask : n/a\n" );*/
+/*     console_printf_terminal(  "         Gateway : n/a\n" );*/
+    console_printf_terminal(  " Frag. threshold : %u\n", frag_tresh);
+    console_printf_terminal(  "   RTS threshold : %u\n", rts_tresh );
+
+    console_printf_terminal(  "Power mode: ");
+    print_available_values(power_mode_val);
+
+    console_printf_terminal(  "Encryption type: ");
+    print_available_values(encrypt_type);
+}
+
+void cmd_show_statistics(ConParm_t parm[], U16 nParms)
+{
+    TIWLN_STATISTICS statistics = { 0 } ;
+
+    UNUSED(parm);
+    UNUSED(nParms);
+
+    console_printf_terminal(  "TI_GetStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
+
+    if( TI_GetStatistics( g_id_adapter, &statistics ) )
+    {
+        console_printf_terminal ("Error in getting TI_GetStatistics!!\n");
+        return;
+    }
+
+    console_printf_terminal("******************\n");
+    console_printf_terminal("Driver Statistics:\n");
+    console_printf_terminal("******************\n");
+
+    console_printf_terminal("    dot11CurrentTxRate : %s\n", print_rate(statistics.dot11CurrentTxRate) );
+    console_printf_terminal("   dot11CurrentChannel : %d\n", statistics.dot11CurrentChannel );
+    console_printf_terminal("     currentMACAddress : %s\n", print_mac_2_str(statistics.currentMACAddress) );
+    console_printf_terminal("      dot11DesiredSSID : %s\n", get_ssid_string(&statistics.dot11DesiredSSID) );
+    console_printf_terminal("          dot11BSSType : %d\n", statistics.dot11BSSType );
+    console_printf_terminal("    AuthenticationMode : %d\n", statistics.AuthenticationMode );
+    console_printf_terminal("    bShortPreambleUsed : %d\n", statistics.bShortPreambleUsed );
+    console_printf_terminal("          RTSThreshold : %d\n", statistics.RTSThreshold );
+    console_printf_terminal("FragmentationThreshold : %d\n", statistics.FragmentationThreshold );
+    console_printf_terminal(" bDefaultWEPKeyDefined : %d\n", statistics.bDefaultWEPKeyDefined );
+    console_printf_terminal("             WEPStatus : %d\n", statistics.WEPStatus );
+    console_printf_terminal("             TxAntenna : %d\n", statistics.TxAntenna );
+    console_printf_terminal("             RxAntenna : %d\n", statistics.RxAntenna );
+    console_printf_terminal("            TxPowerDbm : %d\n", statistics.TxPowerDbm );
+    console_printf_terminal("             PowerMode : %d\n", statistics.PowerMode );
+    console_printf_terminal("               RxLevel : %d\n", statistics.RxLevel );
+
+    /**/
+    /* status & AP info*/
+    /**/
+    console_printf_terminal("            dot11State : %d\n", statistics.dot11State );
+
+    /**/
+    /* network layer statistics*/
+    /**/
+    console_printf_terminal("                RecvOk : %d\n", statistics.tiCounters.RecvOk );
+    console_printf_terminal("             RecvError : %d\n", statistics.tiCounters.RecvError );
+    console_printf_terminal("     DirectedBytesRecv : %d\n", statistics.tiCounters.DirectedBytesRecv );
+    console_printf_terminal("    DirectedFramesRecv : %d\n", statistics.tiCounters.DirectedFramesRecv );
+    console_printf_terminal("    MulticastBytesRecv : %d\n", statistics.tiCounters.MulticastBytesRecv );
+    console_printf_terminal("   MulticastFramesRecv : %d\n", statistics.tiCounters.MulticastFramesRecv );
+    console_printf_terminal("    BroadcastBytesRecv : %d\n", statistics.tiCounters.BroadcastBytesRecv );
+    console_printf_terminal("   BroadcastFramesRecv : %d\n", statistics.tiCounters.BroadcastFramesRecv );
+    console_printf_terminal("             FcsErrors : %d\n", statistics.tiCounters.FcsErrors );
+    console_printf_terminal("           BeaconsRecv : %d\n", statistics.tiCounters.BeaconsRecv );
+    console_printf_terminal("          AssocRejects : %d\n", statistics.tiCounters.AssocRejects );
+    console_printf_terminal("         AssocTimeouts : %d\n", statistics.tiCounters.AssocTimeouts );
+    console_printf_terminal("           AuthRejects : %d\n", statistics.tiCounters.AuthRejects );
+    console_printf_terminal("          AuthTimeouts : %d\n", statistics.tiCounters.AuthTimeouts );
+
+    /**/
+    /* other statistics*/
+    /**/
+    console_printf_terminal("        dwSecuritySuit : %d\n", statistics.dwSecuritySuit );
+    console_printf_terminal("       dwSecurityState : %d\n", statistics.dwSecurityState );
+    console_printf_terminal("  dwSecurityAuthStatus : %d\n", statistics.dwSecurityAuthStatus );
+    console_printf_terminal("         dwFeatureSuit : %d\n", statistics.dwFeatureSuit );
+}
+
+void cmd_show_tx_statistics(ConParm_t parm[], U16 nParms)
+{
+    TIWLN_TX_STATISTICS statistics;
+    UINT32 TxQid;
+    UINT32 AverageDelay;
+    UINT32 AverageFWDelay;
+    UINT32 AverageMacDelay;
+    tiINT32 status;
+
+    UNUSED(parm);
+    UNUSED(nParms);
+
+    console_printf_terminal("TI_GetTxStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
+
+    /* The first parameter indicates whether to clear the statistics on read: 0 - don't clear, 1 - clear */
+    if ( 0 == nParms )
+    {
+        status = TI_GetTxStatistics( g_id_adapter, &statistics, 0 );
+    }
+    else
+    {
+        status = TI_GetTxStatistics( g_id_adapter, &statistics, parm[0].value );
+    }
+
+    if( status )
+    {
+        console_printf_terminal ("Error in getting TI_GetTxStatistics!!\n");
+        return;
+    }
+
+    console_printf_terminal("*********************\n");
+    console_printf_terminal("Tx Queues Statistics:\n");
+    console_printf_terminal("*********************\n");
+
+    for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
+    {
+        console_printf_terminal("\nTx Queue %d:\n", TxQid);
+        console_printf_terminal("===========\n");
+
+        console_printf_terminal("  Total Good Frames             : %d\n", statistics.txCounters[TxQid].XmitOk );
+        console_printf_terminal("  Unicast Bytes                 : %d\n", statistics.txCounters[TxQid].DirectedBytesXmit );
+        console_printf_terminal("  Unicast Frames                : %d\n", statistics.txCounters[TxQid].DirectedFramesXmit );
+        console_printf_terminal("  Multicast Bytes               : %d\n", statistics.txCounters[TxQid].MulticastBytesXmit );
+        console_printf_terminal("  Multicast Frames              : %d\n", statistics.txCounters[TxQid].MulticastFramesXmit );
+        console_printf_terminal("  Broadcast Bytes               : %d\n", statistics.txCounters[TxQid].BroadcastBytesXmit );
+        console_printf_terminal("  Broadcast Frames              : %d\n", statistics.txCounters[TxQid].BroadcastFramesXmit );
+        console_printf_terminal("  Retry Failures                : %d\n", statistics.txCounters[TxQid].RetryFailCounter );
+        console_printf_terminal("  Tx Timeout Failures           : %d\n", statistics.txCounters[TxQid].TxTimeoutCounter );
+        console_printf_terminal("  No Link Failures              : %d\n", statistics.txCounters[TxQid].NoLinkCounter );
+        console_printf_terminal("  Other Failures                : %d\n", statistics.txCounters[TxQid].OtherFailCounter );
+        console_printf_terminal("  Max Consecutive Retry Failures : %d\n\n", statistics.txCounters[TxQid].MaxConsecutiveRetryFail );
+
+        console_printf_terminal("  Retry histogram:\n");
+        console_printf_terminal("  ----------------\n\n");
+        console_printf_terminal("  Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 0, 1, 2, 3, 4, 5, 6, 7);
+        console_printf_terminal("  packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
+                                statistics.txCounters[TxQid].RetryHistogram[ 0 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 1 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 2 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 3 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 4 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 5 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 6 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 7 ]);
+        console_printf_terminal("  Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 8, 9, 10, 11, 12, 13, 14, 15);
+        console_printf_terminal("  packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
+                                statistics.txCounters[TxQid].RetryHistogram[ 8 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 9 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 10 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 11 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 12 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 13 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 14 ],
+                                statistics.txCounters[TxQid].RetryHistogram[ 15 ]);
+
+        if (statistics.txCounters[TxQid].NumPackets)
+        {
+            AverageDelay = statistics.txCounters[TxQid].SumTotalDelayMs / statistics.txCounters[TxQid].NumPackets;
+            AverageFWDelay = statistics.txCounters[TxQid].SumFWDelayUs / statistics.txCounters[TxQid].NumPackets;
+            AverageMacDelay = statistics.txCounters[TxQid].SumMacDelayUs / statistics.txCounters[TxQid].NumPackets;
+        }
+        else
+        {
+            AverageDelay = 0;
+            AverageFWDelay = 0;
+            AverageMacDelay = 0;
+        }
+
+        console_printf_terminal("  Total Delay ms (average/sum) : %d / %d\n", AverageDelay, statistics.txCounters[TxQid].SumTotalDelayMs);
+        console_printf_terminal("  FW Delay us (average/sum) : %d / %d\n", AverageFWDelay, statistics.txCounters[TxQid].SumFWDelayUs);
+        console_printf_terminal("  MAC Delay us (average/sum)   : %d / %d\n\n", AverageMacDelay, statistics.txCounters[TxQid].SumMacDelayUs);
+
+        console_printf_terminal("  Delay Ranges [msec]  : Num of packets\n");
+        console_printf_terminal("  -------------------  : --------------\n");
+        console_printf_terminal("        0   -    1     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_0_TO_1] );
+        console_printf_terminal("        1   -   10     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_1_TO_10] );
+        console_printf_terminal("       10   -   20     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_10_TO_20] );
+        console_printf_terminal("       20   -   40     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_20_TO_40] );
+        console_printf_terminal("       40   -   60     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_40_TO_60] );
+        console_printf_terminal("       60   -   80     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_60_TO_80] );
+        console_printf_terminal("       80   -  100     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_80_TO_100] );
+        console_printf_terminal("      100   -  200     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_100_TO_200] );
+        console_printf_terminal("        Above 200      : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_ABOVE_200] );
+    }
+}
+
+void cmd_show_about(ConParm_t parm[], U16 nParms)
+{
+    TIWLN_VERSION_EX data;
+
+    UNUSED(parm);
+    UNUSED(nParms);
+
+    console_printf_terminal("Utility version: %s (%u.%u.%u)\n", SW_VERSION_STR, SW_RELEASE_DAY,
+            SW_RELEASE_MONTH, SW_RELEASE_YEAR );
+    if( TI_GetDriverVersion(g_id_adapter, &data ) )
+        return ;
+
+    console_printf_terminal("Driver version: %u.%u.%u.%u.%u\n", data.DrvVersion.major, data.DrvVersion.minor,
+            data.DrvVersion.bugfix, data.DrvVersion.subld, data.DrvVersion.build );
+    console_printf_terminal("Firmware version: %u.%u.%u.%u.%u\n", data.FWVersion.major, data.FWVersion.minor,
+            data.FWVersion.bugfix, data.FWVersion.subld, data.FWVersion.build );
+    console_printf_terminal("Eeprom Version: %u.%u.%u.%u.%u\n", data.HWVersion.major, data.HWVersion.minor,
+            data.HWVersion.bugfix, data.HWVersion.subld, data.HWVersion.build );
+    console_printf_terminal("Eeprom Version2: %u.%u.%u.%u.%u\n", data.NVVersion.major, data.NVVersion.minor,
+            data.NVVersion.bugfix, data.NVVersion.subld, data.HWVersion.build );
+}
+
+void cmd_modify_ssid(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_SSID ssid = { 0 };
+    OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
+    char *ssid_str;
+
+    if( nParms == 0 )
+    {
+        if(!TI_GetCurrentSSID(g_id_adapter, &ssid))
+            ssid_str = get_ssid_string(&ssid);
+        else
+            ssid_str = "<error>";
+        console_printf_terminal("SSID: %s\n",  ssid_str );
+    }
+    else{
+        /* Setting the new SSID, BRCS BSSID is set to clean pre-set BSSID */
+        TI_SetBSSID(g_id_adapter, &bssid );
+        TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
+}
+}
+
+void cmd_modify_channel(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data1 = 0, data = 0;
+        if( !TI_GetDesiredChannel( g_id_adapter, &data1) )
+            console_printf_terminal("Channel=%d (desired: %d)\n", !TI_GetCurrentChannel(g_id_adapter, &data) ? data : -1, data1 );
+    }
+    else
+        TI_SetDesiredChannel( g_id_adapter, parm[0].value );
+}
+
+void cmd_set_power_mode(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_POWER_PROFILE mode = 0x12345678;
+    if( nParms )
+        TI_ConfigPowerManagement (g_id_adapter, parm[0].value );
+    else
+    {
+        if( !TI_GetPowerMode(g_id_adapter, &mode ) )
+        {
+            console_printf_terminal("Power mode: %d\n", mode );
+            print_available_values(power_mode_val);
+        }
+    }
+}
+
+void cmd_set_PowerSave_PowerLevel(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_POWER_LEVELS mode;
+    if( nParms )
+        TI_SetPowerLevelPS (g_id_adapter, parm[0].value );
+    else
+    {
+        if( !TI_GetPowerLevelPS(g_id_adapter, &mode ) )
+        {
+            console_printf_terminal("Power Level PowerSave: %d\n", mode );
+            print_available_values(power_level_val);
+        }
+    }
+}
+
+void cmd_set_Default_PowerLevel(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_POWER_LEVELS mode;
+    if( nParms )
+        TI_SetPowerLevelDefault (g_id_adapter, parm[0].value );
+    else
+    {
+        if( !TI_GetPowerLevelDefault(g_id_adapter, &mode ) )
+        {
+            console_printf_terminal("Default Power Level: %d\n", mode );
+            print_available_values(power_level_val);
+        }
+    }
+}
+
+void cmd_set_DozeModeInAutoPowerLevel(ConParm_t parm[], U16 nParms)
+{
+       OS_802_11_POWER_PROFILE mode;
+    if( nParms )
+        TI_SetPowerLevelDozeMode (g_id_adapter, parm[0].value );
+    else
+    {
+               /* set Short or Long Doze. no use of other parameters */
+        if( !TI_GetPowerLevelDozeMode(g_id_adapter,&mode ) )
+        {
+            console_printf_terminal("Doze Mode in Auto Power Level: SHORT_DOZE -  %d LONG_DOZE - %d\n",
+                               OS_POWER_MODE_SHORT_DOZE,OS_POWER_MODE_LONG_DOZE);
+        }
+    }
+}
+
+
+void cmd_Beacon_Filter_Set_Desired_State(ConParm_t parm[], U16 nParms)
+{
+    /*there are two modes : feature ACTIVE & PASSIV ( or NOT ACTIVE )*/
+    if( nParms )
+    {
+        TI_SetBeaconFilterDesiredState(g_id_adapter, parm[0].value );
+    }
+    else
+    {
+        console_printf_terminal("Use : 0 =  INACTIVE , 1 = ACTIVE\n" ) ;
+
+    }
+}
+
+void cmd_Beacon_Filter_Get_Desired_State(ConParm_t parm[], U16 nParms)
+{
+    UINT8 desState = FALSE ;
+
+    TI_GetBeaconFilterDesiredState(g_id_adapter, &desState ) ;
+    console_printf_terminal("Desired State is %s\n", (desState == FALSE)?"FILTER INACTIVE":"FILTER ACTIVE" );
+
+
+}
+
+
+
+/* scan commands (new from eSTAdk 5.0) */
+
+void init_scan_params(void)
+{
+    int i,j;
+
+    /* init application scan default params */
+    appScanParams.desiredSsid.len = 0;
+    appScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
+    appScanParams.band = RADIO_BAND_2_4_GHZ;
+    appScanParams.probeReqNumber = 3;
+    appScanParams.probeRequestRate = DRV_RATE_MASK_2_BARKER;
+    appScanParams.numOfChannels = 11;
+    for ( i = 0; i < 11; i++ )
+    {
+        for ( j = 0; j < 6; j++ )
+        {
+            appScanParams.channelEntry[ i ].normalChannelEntry.bssId.addr[ j ] = 0xff;
+        }
+        appScanParams.channelEntry[ i ].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+        appScanParams.channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes = 0;
+        appScanParams.channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 60000;
+        appScanParams.channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 30000;
+        appScanParams.channelEntry[ i ].normalChannelEntry.txPowerDbm = MAX_TX_POWER;
+        appScanParams.channelEntry[ i ].normalChannelEntry.channel = i + 1;
+    }
+
+    /* init default scan policy */
+    scanPolicy.normalScanInterval = 10000;
+    scanPolicy.deterioratingScanInterval = 5000;
+    scanPolicy.maxTrackFailures = 3;
+    scanPolicy.BSSListSize = 4;
+    scanPolicy.BSSNumberToStartDiscovery = 1;
+    scanPolicy.numOfBands = 1;
+    scanPolicy.bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ;
+    scanPolicy.bandScanPolicy[ 0 ].rxRSSIThreshold = -80;
+    scanPolicy.bandScanPolicy[ 0 ].numOfChannles = 11;
+    scanPolicy.bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3;
+    for ( i = 0; i < 11; i++ )
+    {
+        scanPolicy.bandScanPolicy[ 0 ].channelList[ i ] = i + 1;
+    }
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_1_BARKER;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
+    scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_2_BARKER;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
+    scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_5_5_CCK;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
+    scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
+}
+
+void cmd_Scan_Start(ConParm_t parm[], U16 nParms)
+{
+    TI_StartScan( g_id_adapter, &appScanParams );
+    console_printf_terminal("Application scan started.\n");
+}
+
+void cmd_Scan_Stop(ConParm_t parm[], U16 nParms)
+{
+    TI_StopScan( g_id_adapter );
+    console_printf_terminal("Application scan stopped.\n");
+}
+
+void cmd_Scan_app_global_config(ConParm_t parm[], U16 nParms)
+{
+    if ( 0 == strcmp( "<empty>", (char*)parm[0].value) )
+    {
+        appScanParams.desiredSsid.len = 0;
+        appScanParams.desiredSsid.ssidString[ 0 ] = '\0';
+    }
+    else
+    {
+    appScanParams.desiredSsid.len = strlen((char*)parm[0].value);
+    memcpy( &(appScanParams.desiredSsid.ssidString), (char*)parm[0].value, appScanParams.desiredSsid.len );
+    }
+    appScanParams.scanType = parm[1].value;
+    appScanParams.band = parm[2].value;
+    appScanParams.probeReqNumber = (UINT8)parm[3].value;
+    appScanParams.probeRequestRate = parm[4].value;
+#ifdef TI_DBG
+    appScanParams.Tid = (UINT8)parm[5].value;
+    appScanParams.numOfChannels  = (UINT8)parm[6].value;
+#else
+    appScanParams.Tid = 0;
+    appScanParams.numOfChannels = (UINT8)parm[5].value;
+#endif
+}
+
+void cmd_Scan_app_channel_config(ConParm_t parm[], U16 nParms)
+{
+    scan_normalChannelEntry_t* pChannelEntry =
+        &(appScanParams.channelEntry[ parm[0].value ].normalChannelEntry);
+
+       if (parm[2].value < parm[3].value)
+       {
+               console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
+               return;
+       }
+
+    hexStr2MACAddr( (char*)parm[1].value, &(pChannelEntry->bssId) );
+    pChannelEntry->maxChannelDwellTime = parm[2].value;
+    pChannelEntry->minChannelDwellTime = parm[3].value;
+    pChannelEntry->earlyTerminationEvent = parm[4].value;
+    pChannelEntry->ETMaxNumOfAPframes = (UINT8)parm[5].value;
+    pChannelEntry->txPowerDbm = (UINT8)parm[6].value;
+    pChannelEntry->channel = (UINT8)parm[7].value;
+}
+
+void cmd_Scan_app_clear(ConParm_t parm[], U16 nParms)
+{
+    memset( &appScanParams, 0, sizeof(scan_Params_t) );
+    console_printf_terminal("Application scan parameters cleared.\n");
+}
+
+void cmd_Scan_app_display(ConParm_t parm[], U16 nParms)
+{
+    int i;
+    scan_normalChannelEntry_t* pNormalChannel;
+    char bssId[18];
+
+    bssId[17] = '\0';
+    console_printf_terminal("Application Scan params:\n");
+    console_printf_terminal("SSID: %s, Type: %s\n", appScanParams.desiredSsid.ssidString, scanType2Str[ appScanParams.scanType ].name);
+    console_printf_terminal("Band: %s, Number of probe req:%d, probe req. rate:%s\n",
+          band2Str[ appScanParams.band ].name, appScanParams.probeReqNumber, rate2StrFunc( appScanParams.probeRequestRate ) );
+#ifdef TI_DBG
+    console_printf_terminal("Tid :%d\n\n", appScanParams.Tid);
+#else
+    console_printf_terminal("\n");
+#endif
+    console_printf_terminal("Channel  BSS ID             Max time  Min time  ET event     ET frame num Power\n");
+    console_printf_terminal("-------------------------------------------------------------------------------\n");
+    for ( i = 0; i < appScanParams.numOfChannels; i++ )
+    {
+        pNormalChannel = &(appScanParams.channelEntry[ i ].normalChannelEntry);
+        mac2HexStr( &(pNormalChannel->bssId), bssId );
+        console_printf_terminal ("%2d       %s  %7d   %7d   %s%3d          %1d\n",
+               pNormalChannel->channel, bssId, pNormalChannel->maxChannelDwellTime,
+               pNormalChannel->minChannelDwellTime, EtEvent2StrFunc( pNormalChannel->earlyTerminationEvent ),
+               pNormalChannel->ETMaxNumOfAPframes, pNormalChannel->txPowerDbm);
+    }
+    console_printf_terminal("\n");
+}
+
+void cmd_Scan_policy_global_config(ConParm_t parm[], U16 nParms)
+{
+    scanPolicy.normalScanInterval =  parm[ 0 ].value;
+    scanPolicy.deterioratingScanInterval = parm[ 1 ].value;
+    scanPolicy.maxTrackFailures = (UINT8)(parm[ 2 ].value);
+    scanPolicy.BSSListSize = (UINT8)(parm[ 3 ].value);
+    scanPolicy.BSSNumberToStartDiscovery = (UINT8)(parm[ 4 ].value);
+    scanPolicy.numOfBands = (UINT8)(parm[ 5 ].value);
+}
+
+void cmd_Scan_band_global_config(ConParm_t parm[], U16 nParms)
+{
+    scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
+
+    bandPolicy->band = parm[ 1 ].value;
+    bandPolicy->rxRSSIThreshold = (S8)(parm[ 2 ].value);
+    bandPolicy->numOfChannlesForDiscovery = (UINT8)(parm[ 3 ].value);
+    bandPolicy->numOfChannles = (UINT8)(parm[ 4 ].value);
+}
+
+void cmd_Scan_band_channel_config(ConParm_t parm[], U16 nParms)
+{
+    scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
+
+    bandPolicy->channelList[ parm[ 1 ].value ] = (UINT8)(parm[ 2 ].value);
+}
+
+void cmd_Scan_band_track_config(ConParm_t parm[], U16 nParms)
+{
+    scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
+
+       if (parm[6].value < parm[7].value)
+       {
+               console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
+               return;
+       }
+
+    bandPolicy->trackingMethod.scanType = parm[ 1 ].value;
+
+    switch (bandPolicy->trackingMethod.scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        bandPolicy->trackingMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
+        bandPolicy->trackingMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
+        bandPolicy->trackingMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->trackingMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
+        bandPolicy->trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
+        bandPolicy->trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
+        break;
+
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+
+               /* Check if valid TID */
+               if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255))
+               {
+                       console_printf_terminal ("ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value));
+                       parm[ 4 ].value = 255;
+               }
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.triggeringTid = (UINT8)(parm[ 4 ].value);
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
+        bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
+        break;
+
+    case SCAN_TYPE_SPS:
+        bandPolicy->trackingMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->trackingMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->trackingMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value;
+        break;
+
+    default:
+        bandPolicy->trackingMethod.scanType = SCAN_TYPE_NO_SCAN;
+        break;
+    }
+}
+
+void cmd_Scan_band_discover_config(ConParm_t parm[], U16 nParms)
+{
+    scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
+
+       if (parm[6].value < parm[7].value)
+       {
+               console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
+               return;
+       }
+
+    bandPolicy->discoveryMethod.scanType = parm[ 1 ].value;
+
+    switch (bandPolicy->discoveryMethod.scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        bandPolicy->discoveryMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
+        bandPolicy->discoveryMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
+        bandPolicy->discoveryMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
+        bandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
+        bandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
+        break;
+
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+               /* Check if valid TID */
+               if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255))
+               {
+                       console_printf_terminal ("ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value));
+                       parm[ 4 ].value = 255;
+               }
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.triggeringTid = (UINT8)(parm[ 4 ].value);
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
+        bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
+        break;
+
+    case SCAN_TYPE_SPS:
+        bandPolicy->discoveryMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->discoveryMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->discoveryMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value;
+        break;
+
+    default:
+        bandPolicy->discoveryMethod.scanType = SCAN_TYPE_NO_SCAN;
+        break;
+    }
+}
+
+void cmd_Scan_band_immed_config(ConParm_t parm[], U16 nParms)
+{
+    scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
+
+       if (parm[6].value < parm[7].value)
+       {
+               console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
+               return;
+       }
+
+    bandPolicy->immediateScanMethod.scanType = parm[ 1 ].value;
+
+    switch (bandPolicy->immediateScanMethod.scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        bandPolicy->immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
+        bandPolicy->immediateScanMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
+        bandPolicy->immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
+        bandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
+        bandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
+        break;
+
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+               /* Check if valid TID */
+               if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255))
+               {
+                       console_printf_terminal ("ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value));
+                       parm[ 4 ].value = 255;
+               }
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.triggeringTid = (UINT8)(parm[ 4 ].value);
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
+        bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
+        break;
+
+    case SCAN_TYPE_SPS:
+        bandPolicy->immediateScanMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value;
+        bandPolicy->immediateScanMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
+        bandPolicy->immediateScanMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value;
+        break;
+
+    default:
+        bandPolicy->immediateScanMethod.scanType = SCAN_TYPE_NO_SCAN;
+        break;
+    }
+}
+
+void cmd_Scan_policy_display(ConParm_t parm[], U16 nParms)
+{
+    int i;
+
+    console_printf_terminal("Scan Policy:\n");
+    console_printf_terminal("Normal scan interval: %d, deteriorating scan interval: %d\n",
+          scanPolicy.normalScanInterval, scanPolicy.deterioratingScanInterval);
+    console_printf_terminal("Max track attempt failures: %d\n", scanPolicy.maxTrackFailures);
+    console_printf_terminal("BSS list size: %d, number of BSSes to start discovery: %d\n",
+          scanPolicy.BSSListSize, scanPolicy.BSSNumberToStartDiscovery);
+    console_printf_terminal("Number of configured bands: %d\n", scanPolicy.numOfBands);
+    for ( i = 0; i < scanPolicy.numOfBands; i++ )
+    {
+        cmd_Scan_print_band( i );
+    }
+}
+
+void cmd_Scan_print_band( int i )
+{
+    scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ i ]);
+    int j;
+
+    console_printf_terminal("\nBand: %s\n", band2Str[ bandPolicy->band ].name);
+    console_printf_terminal("RSSI Threshold: %d dBm\n", bandPolicy->rxRSSIThreshold);
+    console_printf_terminal("Number of channels for each discovery interval: %d\n", bandPolicy->numOfChannlesForDiscovery);
+    console_printf_terminal("\nTracking Method:\n");
+    cmd_Scan_print_method( &(bandPolicy->trackingMethod) );
+    console_printf_terminal("\nDiscovery Method:\n");
+    cmd_Scan_print_method( &(bandPolicy->discoveryMethod) );
+    console_printf_terminal("\nImmediate Scan Method:\n");
+    cmd_Scan_print_method( &(bandPolicy->immediateScanMethod) );
+    if ( bandPolicy->numOfChannles > 0 )
+    {
+        console_printf_terminal("\nChannel list: ");
+        for ( j = 0; j < bandPolicy->numOfChannles; j++ )
+        {
+            console_printf_terminal("%3d ", bandPolicy->channelList[ j ]);
+        }
+        console_printf_terminal("\n");
+    }
+    else
+        console_printf_terminal("\nNo channels defined.\n");
+}
+
+void cmd_Scan_print_method( scan_Method_t* scanMethod )
+{
+    console_printf_terminal("Scan type: %s\n", scanType2Str[ scanMethod->scanType ].name);
+    switch (scanMethod->scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        cmd_Scan_print_basic_method( &(scanMethod->method.basicMethodParams) );
+        break;
+
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+        cmd_Scan_print_triggered_method( &(scanMethod->method.TidTriggerdMethodParams) );
+        break;
+
+    case SCAN_TYPE_SPS:
+        cmd_Scan_print_sps_method( &(scanMethod->method.spsMethodParams) );
+        break;
+
+    case SCAN_TYPE_NO_SCAN:
+        break;
+    }
+}
+
+void cmd_Scan_print_basic_method( scan_basicMethodParams_t* basicMethodParams )
+{
+    console_printf_terminal("Max channel dwell time: %d, Min channel dwell time: %d\n",
+          basicMethodParams->maxChannelDwellTime, basicMethodParams->minChannelDwellTime);
+    console_printf_terminal("ET condition: %s, ET number of frames: %d\n",
+          EtEvent2StrFunc( basicMethodParams->earlyTerminationEvent ), basicMethodParams->ETMaxNumberOfApFrames);
+    console_printf_terminal("Probe request number: %d, probe request rate: %s, TX power (Dbm/10): %d\n",
+          basicMethodParams->probReqParams.numOfProbeReqs, rate2StrFunc( basicMethodParams->probReqParams.bitrate ),
+          basicMethodParams->probReqParams.txPowerDbm);
+}
+
+void cmd_Scan_print_triggered_method( scan_TidTriggeredMethodParams_t* triggeredMethodParams )
+{
+    console_printf_terminal("Triggering Tid: %d\n", triggeredMethodParams->triggeringTid);
+    cmd_Scan_print_basic_method( &(triggeredMethodParams->basicMethodParams) );
+}
+
+void cmd_Scan_print_sps_method( scan_SPSMethodParams_t* spsMethodParams )
+{
+    console_printf_terminal("ET condition: %s, ET number of frames: %d\n",
+          EtEvent2StrFunc( spsMethodParams->earlyTerminationEvent ), spsMethodParams->ETMaxNumberOfApFrames);
+    console_printf_terminal("Scan duration: %d\n", spsMethodParams->scanDuration);
+}
+
+void cmd_Scan_policy_clear(ConParm_t parm[], U16 nParms)
+{
+    memset( &scanPolicy, 0, sizeof(scan_Policy_t) );
+    console_printf_terminal("Scan policy cleared.\n");
+}
+
+void cmd_Scan_policy_store(ConParm_t parm[], U16 nParms)
+{
+    TI_SetScanPolicy( g_id_adapter, (UINT8*)&scanPolicy, sizeof(scan_Policy_t) );
+    console_printf_terminal("Scan policy stored.\n");
+}
+
+void cmd_Scan_get_bss_list(ConParm_t parm[], U16 nParms)
+{
+    bssList_t list;
+    int i;
+
+    /* get list */
+    if ( (TI_RESULT_OK != TI_GetScanBssList( g_id_adapter, &list )) || (0 == list.numOfEntries) )
+    {
+        return;
+    }
+
+    /* console_printf_terminal list */
+    console_printf_terminal("BSS List:\n");
+    console_printf_terminal("%-17s  %-7s  %-6s  %-4s  %-10s\n", "BSSID", "Band", "Channel", "RSSI", "Neighbor?");
+    console_printf_terminal("-----------------------------------------------------\n");
+    for  ( i = 0; i < list.numOfEntries; i++ )
+    {
+
+        console_printf_terminal( "%s  %s  %-7d  %-4d  %s\n",
+               print_mac_2_str(list.BSSList[ i ].BSSID.addr), band2Str[ list.BSSList[ i ].band ].name,
+               list.BSSList[ i ].channel, list.BSSList[ i ].RSSI,
+               (TRUE == list.BSSList[ i ].bNeighborAP ? "Yes" : "No") );
+    }
+}
+
+void cmd_set_dtag_to_ac_mapping_table(ConParm_t parm[], U16 nParms)
+{
+    int                                i;
+    acTrfcType_e       dtagToAcTable[MAX_NUM_OF_802_1d_TAGS];
+
+    for (i=0; i<MAX_NUM_OF_802_1d_TAGS; i++)
+    {
+        dtagToAcTable[i] = (UINT32) parm[i].value;
+       }
+       console_printf_terminal("Input parameters =%d, %d, %d, %d, %d, %d, %d, %d\n",
+                    (UINT32) parm[0].value,
+                    (UINT32) parm[1].value,
+                    (UINT32) parm[2].value,
+                    (UINT32) parm[3].value,
+                    (UINT32) parm[4].value,
+                    (UINT32) parm[5].value,
+                    (UINT32) parm[6].value,
+                    (UINT32) parm[7].value);
+
+       if (TI_SetDTagToAcMappingTable(g_id_adapter, dtagToAcTable) == TI_RESULT_OK)
+       {
+       }
+       else
+       {
+               console_printf_terminal ("Error: could not set tag_ToAcClsfrTable ...\n");
+       }
+}
+
+void cmd_set_vad(ConParm_t parm[], U16 nParms)
+{
+       txDataVadTimerParams_t  pVadTimer;
+
+       if (0 == nParms)        // GET operation
+       {
+               console_printf_terminal("Set VAD: \n");
+               console_printf_terminal("    Parm 0 -- 1: ENABLE; 0: DISABLE\n");
+               console_printf_terminal("    Parm 1 -- VAD timer duration in ms for enabling action\n");
+               if (TI_GetVAD(g_id_adapter, &pVadTimer) == TI_RESULT_OK)
+               {
+
+                   console_printf_terminal("Current param values: %d, %d\n",
+                                pVadTimer.vadTimerEnabled, pVadTimer.vadTimerDuration);
+               }
+       }
+       else
+       {
+               pVadTimer.vadTimerEnabled  = (UINT16) parm[0].value;
+               pVadTimer.vadTimerDuration = (UINT16) parm[1].value;
+
+               if (pVadTimer.vadTimerEnabled)
+               {
+                       console_printf_terminal("Enabling VAD timer (cycle = %d ms)\n", pVadTimer.vadTimerDuration);
+               }
+               else
+               {
+                       console_printf_terminal("Disabling VAD timer\n");
+               }
+
+               if (TI_SetVAD(g_id_adapter, &pVadTimer) == TI_RESULT_OK)
+               {
+                       console_printf_terminal("Setting VAD is done\n");
+               }
+       }
+}
+
+
+void cmd_set_qos_params(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_QOS_PARAMS pQosParams;
+
+   pQosParams.acID=parm[0].value;
+   pQosParams.MaxLifeTime=parm[1].value;
+   pQosParams.VoiceDeliveryProtocol=0;
+   pQosParams.PSDeliveryProtocol=0;
+
+   if (nParms == 7) /* If the user has input 7 parameters, it means he gave Voice+PS delivery protocol values */
+   {
+      pQosParams.VoiceDeliveryProtocol=parm[5].value;
+      pQosParams.PSDeliveryProtocol=parm[6].value;
+
+      /* If this QOS config was done for a queue OTHER THAN VO, we will zero the DeliveryProtocolPsPoll parameter and notify the user */
+      if ((parm[0].value != 3) && (parm[5].value != 0))
+         {
+            pQosParams.VoiceDeliveryProtocol = 0;
+            console_printf_terminal("Since the acID is not VO, resetting VoiceDeliveryProtocol parameter to PS_NONE\n");
+         }
+      if ((pQosParams.VoiceDeliveryProtocol == 1) && (pQosParams.PSDeliveryProtocol == 1))
+      {
+            pQosParams.VoiceDeliveryProtocol = 1;
+            pQosParams.PSDeliveryProtocol = 0;
+            console_printf_terminal("Since the VoiceDeliveryProtocol is PS_POLL, resetting PSDeliveryProtocol to Legacy\n");
+      }
+   }
+
+   if (TI_SetQosParameters(g_id_adapter, &pQosParams) == TI_RESULT_OK)
+   {
+      console_printf_terminal("Sent QOS params to driver...\n AC Number=%d \n MaxLifeTime=%d \n DeliveryProtocolPsPoll = %d\n PSDeliveryProtocol = %d\n",
+          pQosParams.acID,
+          pQosParams.MaxLifeTime,
+          pQosParams.VoiceDeliveryProtocol,
+          pQosParams.PSDeliveryProtocol);
+   }
+   else
+   {
+      console_printf_terminal ("Error: could not set QOS params...\n");
+   }
+}
+
+void cmd_set_rxTimeOut_params(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_QOS_RX_TIMEOUT_PARAMS rxTimeOut;
+
+    rxTimeOut.psPoll = parm[0].value;
+    rxTimeOut.UPSD   = parm[1].value;
+
+    if (nParms != 2)
+    {
+        console_printf_terminal("Please enter Rx Time Out:\n");
+        console_printf_terminal("Param 0 - psPoll (0 - 65000)\n");
+        console_printf_terminal("Param 1 - UPSD (1 - 65000)\n");
+    }
+    else
+    {
+       if (TI_SetQosRxTimeOut(g_id_adapter, &rxTimeOut) == TI_RESULT_OK)
+       {
+          console_printf_terminal("Sent QOS Rx TimeOut params to driver...\n PsPoll = %d\n UPSD = %d\n",
+              rxTimeOut.psPoll,
+              rxTimeOut.UPSD);
+       }
+       else
+       {
+          console_printf_terminal ("Error: could not set Rx TimeOut..\n");
+       }
+    }
+}
+
+
+void cmd_enable_rx_data_filters(ConParm_t parm[], U16 nParms)
+{
+    console_printf_terminal("Enabling Rx data filtering...\n");
+    TI_EnableDisableRxDataFilters( g_id_adapter, TRUE );
+}
+
+
+void cmd_disable_rx_data_filters(ConParm_t parm[], U16 nParms)
+{
+    console_printf_terminal("Disabling Rx data filtering...\n");
+    TI_EnableDisableRxDataFilters( g_id_adapter, FALSE );
+}
+
+
+void cmd_get_rx_data_filters_statistics(ConParm_t parm[], U16 nParms)
+{
+    TIWLAN_DATA_FILTER_STATISTICS statistics;
+
+
+    console_printf_terminal("Rx data filtering statistics:\n");
+
+    TI_GetRxDataFiltersStatistics( g_id_adapter, &statistics );
+
+    console_printf_terminal("Unmatched packets: %u\n", statistics.UnmatchedPacketsCount);
+    console_printf_terminal("Packets matching filter #1: %u\n", statistics.MatchedPacketsCount[0]);
+    console_printf_terminal("Packets matching filter #2: %u\n", statistics.MatchedPacketsCount[1]);
+    console_printf_terminal("Packets matching filter #3: %u\n", statistics.MatchedPacketsCount[2]);
+    console_printf_terminal("Packets matching filter #4: %u\n", statistics.MatchedPacketsCount[3]);
+}
+
+void cmd_show_power_consumption_stats(ConParm_t parm[])
+{
+    PowerConsumptionTimeStat_t statistics;
+
+
+    TI_GetPowerConsumptionStatistics( g_id_adapter, &statistics );
+
+    console_printf_terminal("\nPower Consumption Statistics:\n");
+    console_printf_terminal("-----------------------------\n");
+    console_printf_terminal("activeTimeCnt_H: %u\n", statistics.activeTimeCnt_Hi);
+    console_printf_terminal("activeTimeCnt_Low: %u\n", statistics.activeTimeCnt_Low);
+    console_printf_terminal("elpTimeCnt_Hi: %u\n", statistics.elpTimeCnt_Hi);
+    console_printf_terminal("elpTimeCnt_Low: %u\n", statistics.elpTimeCnt_Low);
+    console_printf_terminal("powerDownTimeCnt_Hi: %u\n", statistics.powerDownTimeCnt_Hi);
+    console_printf_terminal("powerDownTimeCnt_Low: %u\n", statistics.powerDownTimeCnt_Low);
+
+}
+
+
+
+static void parse_hex_string(char * pString, tiUINT8 * pBuffer, tiUINT8 * Length)
+{
+    char ch;
+    int iter = 0;
+
+    while ((ch = pString[iter]))
+    {
+        UINT8 val = ((ch >= '0' && ch <= '9') ? (ch - '0') :
+                     (ch >= 'A' && ch <= 'F') ? (0xA + ch - 'A') :
+                     (ch >= 'a' && ch <= 'f') ? (0xA + ch - 'a') : 0);
+
+        /* even indexes go to the lower nibble, odd indexes push them to the */
+        /* higher nibble and then go themselves to the lower nibble. */
+        if (iter % 2)
+            pBuffer[iter / 2] = ((pBuffer[iter / 2] << (BIT_TO_BYTE_FACTOR / 2)) | val);
+        else
+            pBuffer[iter / 2] = val;
+
+        ++iter;
+    }
+
+    /* iter = 0 len = 0, iter = 1 len = 1, iter = 2 len = 1, and so on... */
+    *Length = (iter + 1) / 2;
+}
+
+static void parse_binary_string(char * pString, tiUINT8 * pBuffer, tiUINT8 * Length)
+{
+    char ch;
+    int iter = 0;
+
+    while ((ch = pString[iter]))
+    {
+        UINT8 val = (ch == '1' ? 1 : 0);
+
+        if (iter % BIT_TO_BYTE_FACTOR)
+            pBuffer[iter / BIT_TO_BYTE_FACTOR] |= (val << (iter % BIT_TO_BYTE_FACTOR));
+        else
+            pBuffer[iter / BIT_TO_BYTE_FACTOR] = val;
+
+        ++iter;
+    }
+
+    /* iter = 0 len = 0, iter = 1 len = 1, iter = 8 len = 1, and so on... */
+    *Length = (iter + BIT_TO_BYTE_FACTOR - 1) / BIT_TO_BYTE_FACTOR;
+}
+
+void cmd_add_rx_data_filter(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 resultCode;
+    TIWLAN_DATA_FILTER_REQUEST request;
+
+    char * mask = (char *) parm[1].value;
+    char * pattern = (char *) parm[2].value;
+
+
+    request.Offset = (UINT8) parm[0].value;
+
+    parse_binary_string(mask, request.Mask, &request.MaskLength);
+    parse_hex_string(pattern, request.Pattern, &request.PatternLength);
+
+    resultCode = TI_AddRxDataFilter(g_id_adapter, &request);
+
+
+    console_printf_terminal(resultCode == RX_NO_AVAILABLE_FILTERS ? "Error: There are no available filter slots.\n" :
+                            resultCode == RX_FILTER_ALREADY_EXISTS ? "Error: Filter already exists.\n" :
+                            resultCode == NOK ? "Error: Could not add the filter.\n" :
+                            "Filter added.\n");
+}
+
+void cmd_remove_rx_data_filter(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 resultCode;
+    TIWLAN_DATA_FILTER_REQUEST request;
+
+    char * mask = (char *) parm[1].value;
+    char * pattern = (char *) parm[2].value;
+
+    request.Offset = (UINT8) parm[0].value;
+
+    parse_binary_string(mask, request.Mask, &request.MaskLength);
+    parse_hex_string(pattern, request.Pattern, &request.PatternLength);
+
+    resultCode = TI_RemoveRxDataFilter(g_id_adapter, &request);
+
+    console_printf_terminal(resultCode == RX_FILTER_DOES_NOT_EXIST ? "Error: Filter was not found.\n" :
+                            resultCode == NOK ? "Error: Could not remove the filter, removal request must be identical to add request.\n" :
+                            "Filter removed.\n");
+}
+
+void cmd_MaxRxLifetime_params(ConParm_t parm[], U16 nParms)
+{
+    PLT_MIB_t Mib;
+    UINT32 Status;
+    memset(&Mib, 0, sizeof(Mib));
+    Mib.aMib = PLT_MIB_dot11MaxReceiveLifetime;
+
+       if (nParms != 1)
+       {
+          console_printf_terminal("Max Rx lifetime: [0 - 4294967295(0xFFFFFFFF)]\n");
+
+       }
+
+       if (nParms == 0) /*Get MaxRxlifetime */
+    {
+        Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
+        if (OK == Status)
+              console_printf_terminal("MaxRxLifetime = %d\n", Mib.aData.MaxReceiveLifeTime);
+    }
+    else if (nParms == 1)
+    {
+        Mib.Length = sizeof(Mib.aData.MaxReceiveLifeTime);
+        Mib.aData.MaxReceiveLifeTime = parm[0].value;
+        if (OK != TI_PLT_WriteMIB(g_id_adapter, &Mib))
+            console_printf_terminal("TI_PLT_WriteMIB failed\n");
+    }
+}
+
+
+void cmd_add_tspec(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_QOS_TSPEC_PARAMS pTspecParams;
+   tiUINT32 resultCode;
+
+   pTspecParams.uUserPriority = parm[0].value;
+   pTspecParams.uNominalMSDUsize = parm[1].value;
+   pTspecParams.uMeanDataRate = parm[2].value;
+   pTspecParams.uMinimumPHYRate = parm[3].value * 1000 * 1000;
+   pTspecParams.uSurplusBandwidthAllowance = parm[4].value << 13;
+   pTspecParams.uAPSDFlag = parm[5].value;
+
+   resultCode = TI_AddTspec (g_id_adapter,&pTspecParams);
+
+   switch (resultCode)
+   {
+   case OK:
+      console_printf_terminal ("TSpec request sent to driver...\n uUserPriority = %d\n uNominalMSDUsize = %d\n uMeanDataRate = %d\n uMinimumPHYRate = %d\n uSurplusBandwidthAllowance = %d\n uAPSDFlag = %d\n",
+               parm[0].value,
+               parm[1].value,
+               parm[2].value,
+               parm[3].value,
+               parm[4].value,
+               parm[5].value);
+      break;
+   case TRAFIC_ADM_PENDING:
+      console_printf_terminal ("Driver is still waiting for a response of previous request...\n");
+      break;
+   case AC_ALREADY_IN_USE:
+      console_printf_terminal ("Other user priority from the same AC has already used a TSPEC...\n");
+      break;
+   case NOT_CONNECTED:
+      console_printf_terminal ("Not connected to an AP...\n");
+      break;
+   case NO_QOS_AP:
+      console_printf_terminal ("AP does not support QOS...\n");
+      break;
+   case NOK:
+      console_printf_terminal ("Invalid parameter...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+
+   return;
+}
+
+void cmd_get_tspec_params(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_QOS_TSPEC_PARAMS pTspecParams;
+   tiUINT32 resultCode;
+
+   pTspecParams.uUserPriority = parm[0].value;
+
+   resultCode = TI_GetTspecParameters(g_id_adapter, &pTspecParams);
+
+   switch (resultCode)
+   {
+   case OK:
+      console_printf_terminal ("TSpec parameters retrieved:\nuUserPriority = %d\nuNominalMSDUsize = %d\nuMeanDataRate = %d\nuMinimumPHYRate = %d\nuSurplusBandwidthAllowance = %d\nuUAPSD_Flag = %d\nuMediumTime = %d\n",
+               pTspecParams.uUserPriority,
+               pTspecParams.uNominalMSDUsize,
+               pTspecParams.uMeanDataRate,
+               pTspecParams.uMinimumPHYRate,
+               pTspecParams.uSurplusBandwidthAllowance,
+               pTspecParams.uAPSDFlag,
+               pTspecParams.uMediumTime);
+      break;
+   case USER_PRIORITY_NOT_ADMITTED:
+      console_printf_terminal ("User Priority is not admitted...\n");
+      break;
+   case NOT_CONNECTED:
+      console_printf_terminal ("Not connected to an AP...\n");
+      break;
+   case NO_QOS_AP:
+      console_printf_terminal ("AP does not support QOS...\n");
+      break;
+   case NOK:
+      console_printf_terminal ("Invalid parameter...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+
+   return;
+}
+
+void cmd_delete_tspec(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_QOS_DELETE_TSPEC_PARAMS pDelTspecParams;
+   tiUINT32 resultCode;
+
+   pDelTspecParams.uUserPriority = parm[0].value;
+   pDelTspecParams.uReasonCode = parm[1].value;
+
+   resultCode = TI_DeleteTspec(g_id_adapter, &pDelTspecParams);
+
+   switch (resultCode)
+   {
+   case OK:
+      console_printf_terminal ("TSPEC Delete request sent to driver...\n uUserPriority = %d\n uReasonCode = %d\n",
+               pDelTspecParams.uUserPriority,
+               pDelTspecParams.uReasonCode);
+      break;
+   case NOT_CONNECTED:
+      console_printf_terminal ("Not connected to an AP...\n");
+      break;
+   case NO_QOS_AP:
+      console_printf_terminal ("AP does not support QOS...\n");
+      break;
+   case NOK:
+      console_printf_terminal ("Invalid parameter...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+
+}
+
+void cmd_get_ap_qos_params(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_AC_QOS_PARAMS pACQosParams;
+   int i = 0;
+   tiUINT32 resultCode;
+
+   pACQosParams.uAC = i;
+   /* Read AC 0 parameters - just to check if connected to QOS AP etc */
+   resultCode = TI_GetAPQosParameters(g_id_adapter, &pACQosParams);
+
+   switch (resultCode)
+   {
+   case OK:
+   console_printf_terminal ("AP QOS Parameters:\n");
+         console_printf_terminal ("+----+-------------+----------+-----------+-----------+-----------+\n");
+         console_printf_terminal ("| AC | AdmCtrlFlag |   AIFS   |   CwMin   |   CwMax   | TXOPLimit |\n");
+         console_printf_terminal ("+----+-------------+----------+-----------+-----------+-----------+\n");
+
+
+   for (i=0; i<4; i++)
+      {
+         pACQosParams.uAC = i;
+         resultCode = TI_GetAPQosParameters(g_id_adapter, &pACQosParams);
+
+               console_printf_terminal ("| %2d | %11d | %8d | %9d | %9d | %9d |\n",i,
+               pACQosParams.uAssocAdmissionCtrlFlag,
+               pACQosParams.uAIFS,
+               pACQosParams.uCwMin,
+               pACQosParams.uCwMax,
+               pACQosParams.uTXOPLimit);
+      }
+
+         console_printf_terminal ("+----+-------------+----------+-----------+-----------+-----------+\n");
+      break;
+   case NOT_CONNECTED:
+      console_printf_terminal ("Not connected to an AP...\n");
+      break;
+   case NO_QOS_AP:
+      console_printf_terminal ("AP does not support QOS...\n");
+      break;
+   case NOK:
+      console_printf_terminal ("Invalid parameter...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+
+}
+
+void cmd_get_ap_qos_capabilities(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_AP_QOS_CAPABILITIES_PARAMS pAPQosCapabiltiesParams;
+   tiUINT32 resultCode;
+
+   resultCode = TI_GetAPQosCapabilitesParameters(g_id_adapter, &pAPQosCapabiltiesParams);
+
+   switch (resultCode)
+   {
+   case TI_RESULT_OK:
+      console_printf_terminal ("AP Qos Capabilities:\n QOSFlag = %d\n APSDFlag = %d\n",pAPQosCapabiltiesParams.uQOSFlag,pAPQosCapabiltiesParams.uAPSDFlag);
+      break;
+   case NOT_CONNECTED:
+      console_printf_terminal ("Not connected to an AP...\n");
+      break;
+   case NO_QOS_AP:
+      console_printf_terminal ("AP does not support QOS...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+
+   return;
+}
+
+void cmd_get_ac_status(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_AC_UPSD_STATUS_PARAMS pAcStatusParams;
+   tiUINT32 resultCode;
+
+   pAcStatusParams.uAC = parm[0].value;
+
+   resultCode = TI_GetCurrentACStatus(g_id_adapter, &pAcStatusParams);
+
+   switch (resultCode)
+   {
+   case TI_RESULT_OK:
+      console_printf_terminal ("AC %d Status:\nCurrentUAPSDStatus = %d (0=PS_POLL,1=UPSD,2=PS_NONE)\nCurrentAdmissionStatus = %d(0=NOT_ADMITED,1=WAIT,2=ADMITED)\n",
+               pAcStatusParams.uAC,
+               pAcStatusParams.uCurrentUAPSDStatus,
+               pAcStatusParams.pCurrentAdmissionStatus);
+      break;
+   case NOT_CONNECTED:
+      console_printf_terminal ("Not connected to an AP...\n");
+      break;
+   case NO_QOS_AP:
+      console_printf_terminal ("AP does not support QOS...\n");
+      break;
+   case NOK:
+      console_printf_terminal ("Invalid parameters...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+
+}
+
+void cmd_get_desired_ps_mode(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_QOS_DESIRED_PS_MODE pDesiredPsMode;
+   tiUINT32 resultCode;
+
+   resultCode = TI_GetDesiredPsMode(g_id_adapter, &pDesiredPsMode);
+
+   switch (resultCode)
+   {
+   case TI_RESULT_OK:
+      console_printf_terminal ("\n\
+Desired PS Mode (0=PS_POLL, 1=UPSD, 2=PS_NONE):\n\
+===============================================\n\
+General Desired Ps Mode  =  %d\n\
+ BE_AC  Desired Ps Mode  =  %d\n\
+ BK_AC  Desired Ps Mode  =  %d\n\
+ VI_AC  Desired Ps Mode  =  %d\n\
+ VO_AC  Desired Ps Mode  =  %d\n",
+              pDesiredPsMode.uDesiredPsMode,
+              pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_BE],
+              pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_BK],
+              pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_VI],
+              pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_VO]);
+
+      break;
+   case NOK:
+      console_printf_terminal ("Invalid parameters...\n");
+      break;
+   default:
+      console_printf_terminal ("Unknown return value...\n");
+      break;
+   }
+}
+
+
+
+void cmd_medium_usage_threshold(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_THRESHOLD_CROSS_PARAMS pThresholdCrossParams;
+   tiUINT32 resultCode;
+
+   if (nParms == 3) /* If user supplied 3 parameters - this is a SET operation */
+   {
+       pThresholdCrossParams.uAC = parm[0].value;
+       pThresholdCrossParams.uHighThreshold = parm[1].value;
+       pThresholdCrossParams.uLowThreshold = parm[2].value;
+
+      if (pThresholdCrossParams.uLowThreshold > pThresholdCrossParams.uHighThreshold)
+      {
+         console_printf_terminal ("Low threshold cannot be higher than the High threshold...Aborting...\n");
+      }
+      else
+      {
+           resultCode = TI_SetMediumUsageThreshold(g_id_adapter, &pThresholdCrossParams);
+           if (resultCode == TI_RESULT_OK)
+           {
+               console_printf_terminal ("Medium usage threshold for AC %d has been set to:\n LowThreshold = %d\n HighThreshold = %d\n",
+               pThresholdCrossParams.uAC,
+               pThresholdCrossParams.uLowThreshold,
+               pThresholdCrossParams.uHighThreshold);
+           }
+           else
+           {
+               console_printf_terminal ("Error...\n");
+           }
+      }
+
+   }
+   else if (nParms == 1) /* Only 1 parameter means a GET operation */
+   {
+      pThresholdCrossParams.uAC = parm[0].value;
+      pThresholdCrossParams.uLowThreshold = 0;
+      pThresholdCrossParams.uHighThreshold = 0;
+
+      resultCode = TI_GetMediumUsageThreshold(g_id_adapter, &pThresholdCrossParams);
+
+      console_printf_terminal ("Medium usage threshold for AC %d:\n LowThreshold = %d\n HighThreshold = %d\n",
+          pThresholdCrossParams.uAC,
+          pThresholdCrossParams.uLowThreshold,
+          pThresholdCrossParams.uHighThreshold);
+   }
+
+}
+
+void cmd_phy_rate_threshold(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_THRESHOLD_CROSS_PARAMS pThresholdCrossParams;
+   tiUINT32 resultCode;
+
+   if (nParms == 3) /* If user supplied 3 parameters - this is a SET operation */
+   {
+       if ((is_value_rate(parm[1].value) == FALSE) || (is_value_rate(parm[2].value) == FALSE))
+       {
+          console_printf_terminal ("Invalid rate - PHY rate valid values are: 1,2,5,6,9,11,12,18,24,36,48,54\n");
+          return;
+       }
+
+       pThresholdCrossParams.uAC = parm[0].value;
+       pThresholdCrossParams.uHighThreshold = parm[1].value;
+       pThresholdCrossParams.uLowThreshold = parm[2].value;
+
+       if (pThresholdCrossParams.uLowThreshold > pThresholdCrossParams.uHighThreshold)
+       {
+          console_printf_terminal ("Low threshold cannot be higher than the High threshold...Aborting...\n");
+       }
+       else
+       {
+
+           resultCode = TI_SetPhyRateThreshold(g_id_adapter, &pThresholdCrossParams);
+
+           if (resultCode == TI_RESULT_OK)
+           {
+              console_printf_terminal ("PHY rate threshold for AC %d has been set to:\n LowThreshold = %d\n HighThreshold = %d\n",
+                       pThresholdCrossParams.uAC,
+                       pThresholdCrossParams.uLowThreshold,
+                       pThresholdCrossParams.uHighThreshold);
+           }
+           else
+           {
+              console_printf_terminal ("Error...\n");
+           }
+       }
+   }
+   else if (nParms == 1)
+   {
+      pThresholdCrossParams.uAC = parm[0].value;
+      pThresholdCrossParams.uLowThreshold = 0;
+      pThresholdCrossParams.uHighThreshold = 0;
+
+      resultCode = TI_GetPhyRateThreshold(g_id_adapter, &pThresholdCrossParams);
+
+      console_printf_terminal ("PHY rate threshold for AC %d:\n",pThresholdCrossParams.uAC);
+      console_printf_terminal ("LowThreshold = %s\n",print_rate((rate_e) pThresholdCrossParams.uLowThreshold));
+      console_printf_terminal ("HighThreshold = %s\n",print_rate((rate_e) pThresholdCrossParams.uHighThreshold));
+   }
+
+}
+
+void cmd_traffic_intensity_threshold(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS pTrafficIntensityThresholds;
+   tiUINT32 resultCode;
+
+   if (nParms == 3)
+   {
+      pTrafficIntensityThresholds.uHighThreshold = parm[0].value;
+      pTrafficIntensityThresholds.uLowThreshold = parm[1].value;
+      pTrafficIntensityThresholds.TestInterval = parm[2].value;
+
+      if (pTrafficIntensityThresholds.uLowThreshold >= pTrafficIntensityThresholds.uHighThreshold)
+      {
+         console_printf_terminal ("Error: low threshold equal or greater than the high threshold...aborting...\n");
+      }
+
+      resultCode = TI_SetTrafficIntensityThresholds (g_id_adapter, &pTrafficIntensityThresholds);
+
+      if (resultCode == TI_RESULT_OK)
+      {
+         console_printf_terminal ("Successfully set traffic intensity thresholds...\n");
+
+      }
+      else
+      {
+         console_printf_terminal ("Error: result code = %d\n",resultCode);
+      }
+   }
+   else if (nParms == 0)
+   {
+      resultCode = TI_GetTrafficIntensityThresholds (g_id_adapter, &pTrafficIntensityThresholds);
+
+      if (resultCode == TI_RESULT_OK)
+      {
+         console_printf_terminal ("Traffic intensity thresholds :\n HighThreshold = %d\n LowThreshold = %d\n TestInterval = %d\n",
+                  pTrafficIntensityThresholds.uHighThreshold,
+                  pTrafficIntensityThresholds.uLowThreshold,
+                  pTrafficIntensityThresholds.TestInterval);
+      }
+      else
+      {
+         console_printf_terminal ("Error: result code = %d\n",resultCode);
+      }
+
+   }
+
+}
+
+void cmd_enable_traffic_events(ConParm_t parm[], U16 nParms)
+{
+   TI_ToggleTrafficIntensityEvents (g_id_adapter, (tiUINT32)TRUE);
+   console_printf_terminal ("Traffic intensity thresholds enabled...\n");
+}
+
+void cmd_disable_traffic_events(ConParm_t parm[], U16 nParms)
+{
+   TI_ToggleTrafficIntensityEvents (g_id_adapter, (tiUINT32)FALSE);
+   console_printf_terminal ("Traffic intensity thresholds disabled...\n");
+}
+
+void cmd_config_tx_classifier(ConParm_t parm[], U16 nParms)
+{
+    NWIF_CLSFR_ENTRY inParamsBuff[CLI_NUM_OF_TX_CLASFR_CON];
+
+    UINT32 inParamsBuffLen = 0;
+    UINT8 i,ic,iv=0;
+
+    for( ic=0,iv=0; ic<CLI_NUM_OF_TX_CLASFR_CON; ic++)
+    {
+        inParamsBuff[ic].port = (UINT16 )parm[iv].value;
+        iv++;
+        inParamsBuff[ic].pri = (UINT16 )parm[iv].value;
+        iv++;
+        inParamsBuff[ic].ip = 0;
+
+
+        inParamsBuffLen += sizeof(NWIF_CLSFR_ENTRY);
+
+    }
+    for( i=0; i<4; i++,iv++)
+    {
+        for(ic=0;ic<CLI_NUM_OF_TX_CLASFR_CON;ic++)
+        {
+            inParamsBuff[ic].ip |= parm[iv].value << i * 8;
+        }
+    }
+}
+
+void cmd_remove_clsfr_entry (ConParm_t parm[], U16 uParms)
+{
+    clsfr_tableEntry_t newUserTableEntry;
+    int i;
+    clsfrTypeAndSupport ClsfrType;
+    tiINT32 res;
+
+    TI_GetClsfrType(g_id_adapter, &ClsfrType );
+
+    /* Possibly needs to be removed if we want to keep this routine working for old classifier as well */
+    if (ClsfrType.oldVersionSupport == TRUE)
+    {
+      console_printf_terminal ("Old classifier support detected...Remove action disabled (use old classifier config)\n");
+      return;
+    }
+
+    if (uParms >=2)
+        newUserTableEntry.DTag = (tiUINT8) parm[1].value;
+
+    switch(parm[0].value)
+    {
+        case D_TAG_CLSFR:
+            console_printf_terminal("Cannot remove D_TAG classifier entry!\n");
+            return;
+        break;
+        case DSCP_CLSFR:
+            if (uParms != 3)
+            {
+                console_printf_terminal("DSCP_CLSFR Entry type, wrong number of parameters(too many?)\n");
+                return;
+            }
+            newUserTableEntry.Dscp.CodePoint = (tiUINT8) parm[2].value;
+            console_printf_terminal ("Removing DSCP_CLSFR classifier entry\nD-Tag = %d\nCodePoint = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.CodePoint);
+        break;
+        case PORT_CLSFR:
+            if (uParms != 3)
+            {
+                console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters(too many?)\n");
+                return;
+            }
+            newUserTableEntry.Dscp.DstPortNum = (tiUINT16) parm[2].value;
+            console_printf_terminal ("Removing PORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.DstPortNum);
+        break;
+        case IPPORT_CLSFR:
+            if (uParms != 7)
+            {
+                console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters\n");
+                return;
+            }
+            newUserTableEntry.Dscp.DstIPPort.DstPortNum = (tiUINT16) parm[2].value;
+            newUserTableEntry.Dscp.DstIPPort.DstIPAddress = 0;
+            for(i=0; i<4; i++)
+                {
+                    newUserTableEntry.Dscp.DstIPPort.DstIPAddress |= parm[i+3].value << i * 8;
+                }
+            console_printf_terminal ("Removing IPPORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\nIP = %3d.%d.%d.%d\n",
+                    newUserTableEntry.DTag,
+                    newUserTableEntry.Dscp.DstIPPort.DstPortNum,
+                    (int)parm[3].value,(int)parm[4].value,(int)parm[5].value,(int)parm[6].value);
+            break;
+        default:
+            console_printf_terminal("Unknown Classifier Type - Command aborted!\n");
+            return;
+        break;
+    }
+
+    res = TI_RemoveClassifierEntry(g_id_adapter, &newUserTableEntry);
+    if (res)
+    {
+       console_printf_terminal ("Failed to remove classifier entry...return code = %d\n",res);
+    }
+
+}
+
+void cmd_insert_clsfr_entry (ConParm_t parm[], U16 uParms)
+{
+    clsfr_tableEntry_t newUserTableEntry;
+    int i;
+    clsfrTypeAndSupport ClsfrType;
+    tiINT32 res;
+
+    TI_GetClsfrType(g_id_adapter, &ClsfrType );
+
+    if (ClsfrType.oldVersionSupport == TRUE)
+    {
+      console_printf_terminal ("Old classifier support detected...Insert action disabled (use old classifier config)\n");
+      return;
+    }
+
+    if (uParms >=2)
+        newUserTableEntry.DTag = (UINT8) parm[1].value;
+
+    switch(parm[0].value)
+    {
+        case D_TAG_CLSFR:
+            console_printf_terminal("Cannot insert D_TAG classifier entry!\n");
+            return;
+        break;
+        case DSCP_CLSFR:
+            if (uParms != 3)
+            {
+                console_printf_terminal("DSCP_CLSFR Entry type, wrong number of parameters(too many?)\n");
+                return;
+            }
+            newUserTableEntry.Dscp.CodePoint = (UINT8) parm[2].value;
+            console_printf_terminal ("Inserting new DSCP_CLSFR classifier entry\nD-Tag = %d\nCodePoint = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.CodePoint);
+        break;
+        case PORT_CLSFR:
+            if (uParms != 3)
+            {
+                console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters(too many?)\n");
+                return;
+            }
+            newUserTableEntry.Dscp.DstPortNum = (UINT16) parm[2].value;
+            console_printf_terminal ("Inserting new PORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.DstPortNum);
+        break;
+        case IPPORT_CLSFR:
+            if (uParms != 7)
+            {
+                console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters\n");
+                return;
+            }
+            newUserTableEntry.Dscp.DstIPPort.DstPortNum = (UINT16) parm[2].value;
+            newUserTableEntry.Dscp.DstIPPort.DstIPAddress = 0;
+            for(i=0; i<4; i++)
+                {
+                    newUserTableEntry.Dscp.DstIPPort.DstIPAddress |= parm[i+3].value << i * 8;
+                }
+            console_printf_terminal ("Inserting new IPPORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\nIP = %3d.%d.%d.%d\n",
+                    newUserTableEntry.DTag,
+                    newUserTableEntry.Dscp.DstIPPort.DstPortNum,
+                    (int)parm[3].value,(int)parm[4].value,(int)parm[5].value,(int)parm[6].value);
+            break;
+        default:
+            console_printf_terminal("Unknown Classifier Type - Command aborted!\n");
+            return;
+        break;
+    }
+
+    res = TI_ConfigTxClassifier(g_id_adapter, sizeof(clsfr_tableEntry_t), (UINT8 *)&newUserTableEntry);
+    if (res)
+    {
+       console_printf_terminal ("Failed to insert new classifier entry...return code = %d\n",res);
+    }
+
+}
+
+void cmd_poll_ap_packets(ConParm_t parm[], U16 nParms)
+{
+   if (nParms == 0)
+   {
+   TI_PollApPackets (g_id_adapter);
+   console_printf_terminal ("Poll AP packets cmd sent to driver...\n");
+}
+   else if (nParms == 1)
+   {
+      TI_PollApPacketsFromAC (g_id_adapter,parm[0].value);
+      console_printf_terminal ("Poll AP packets (From AC %d) cmd sent to driver...\n",(int)parm[0].value);
+   }
+
+}
+
+void cmd_modify_rate(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 data = 0, data1 = 0;
+
+    if( !TI_GetDesiredRate(g_id_adapter, &data1 ) )
+    {
+        TI_GetCurrentRate(g_id_adapter, &data );
+
+        console_printf_terminal("Rate: %s", print_rate(data));
+        console_printf_terminal(", desired rate: %s\n", print_rate(data1));
+    }
+}
+
+
+#if 0    /* not in use*/
+void cmd_net_current_regdomain(ConParm_t parm[], U16 nParms)
+{
+    UNUSED(nParms);
+    UNUSED(parm);
+
+    console_printf_terminal("not implemented...\n");
+}
+
+ static named_value_t network_type_name[] = {
+     { os802_11FH,                     "FH" } ,
+     { os802_11DS,                     "DS" } ,
+     { os802_11OFDM5,                  "OFDM5" } ,
+     { os802_11OFDM24,                 "OFDM24" } ,
+     { os802_11OFDM24_AND_5,           "OFDM24_AND_5" } ,
+     { os802_11NetworkTypeMax,         "NetworkTypeMax" }
+ };
+
+void cmd_net_network_in_use(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_NETWORK_TYPE data;
+    if( !nParms )
+    {
+        if( !TI_GetNetworkTypeInUse(g_id_adapter, &data ) )
+        {
+            print_available_values(network_type_name);
+
+             console_printf_terminal("Cur.network: %d\n", data );
+        }
+    }
+    else
+        TI_SetNetworkTypeInUse(g_id_adapter, parm[0].value );
+}
+#endif /* if 0*/
+
+void cmd_show_tx_power_level_table(ConParm_t parm[], U16 nParms)
+{
+    TIWLAN_POWER_LEVEL_TABLE powerTable;
+       int i;
+
+    if( !TI_GetTxPowerLevel(g_id_adapter, (tiCHAR*)&powerTable) )
+       {
+        console_printf_terminal("Power level table (Dbm/10)\n");
+               for ( i = 0 ; i < TI_NUM_OF_SUB_BANDS ; i++)
+               {
+                       console_printf_terminal("sub-band %i: %d %d %d %d\n", i,
+                       powerTable.uTxPower[i][0],
+                       powerTable.uTxPower[i][1],
+                       powerTable.uTxPower[i][2],
+                       powerTable.uTxPower[i][3]);
+               }
+       }
+    else
+       {
+        console_printf_terminal("Tx Power level table ERROR !!!\n");
+       }
+}
+void cmd_tx_power_dbm(ConParm_t parm[], U16 nParms)
+{
+    tiCHAR dummyData = 0;
+
+       if (nParms == 0)
+       {
+               if( !TI_GetTxPowerDbm(g_id_adapter, &dummyData))
+               {
+                       console_printf_terminal("Tx Power (Dbm/10) = %d\n", dummyData);
+               }
+       }
+    else
+    {
+        if (parm[0].value > MAX_TX_POWER)
+        {
+            console_printf_terminal("Hey !!! You should use values between %d and %d\n", MIN_TX_POWER, MAX_TX_POWER);
+            return;
+        }
+        /* use U8 cast to fix compile warning */
+        if(! TI_SetTxPowerDbm(g_id_adapter, (U8)parm[0].value) )
+        {
+            console_printf_terminal("Set Tx Power in DBM/10 = %d\n", parm[0].value);
+        }
+    }
+}
+
+
+void cmd_enableDisable_802_11d(ConParm_t parm[], U16 nParms)
+{
+    UINT8 data = 0;
+    tiINT32 result;
+
+    result = TI_Get_802_11d(g_id_adapter, &data );
+    if ( nParms == 0 )
+    {
+        if( result ==  TI_RESULT_OK)
+        {
+            console_printf_terminal("802_11d status=%d\n", data );
+        }
+    }
+    else
+    {
+        result = TI_EnableDisable_802_11d(g_id_adapter, (UINT8) parm[0].value);
+        if ((result != TI_RESULT_OK) && (!parm[0].value))
+        {
+            result = TI_Get_802_11h(g_id_adapter, &data );
+            if (data)
+            {
+                console_printf_terminal("802_11d cannot be disabled while 802_11h is enabled!!\n" );
+            }
+        }
+        else
+        {
+            console_printf_terminal("802_11d status is updated to =%d\n", parm[0].value );
+        }
+
+    }
+
+
+}
+
+void cmd_enableDisable_802_11h(ConParm_t parm[], U16 nParms)
+{
+    UINT8 data = 0;
+    tiINT32 result;
+
+    result = TI_Get_802_11h(g_id_adapter, &data );
+    if( nParms == 0 )
+    {
+        if( result ==  TI_RESULT_OK)
+        {
+            console_printf_terminal("802_11h status=%d\n", data );
+        }
+    }
+    else
+    {
+        TI_EnableDisable_802_11h(g_id_adapter, (UINT8) parm[0].value);
+        if (parm[0].value)
+        {
+            console_printf_terminal("802_11h enables automatically 802_11d!!\n" );
+        }
+
+        console_printf_terminal("802_11h status is updated to =%d\n", parm[0].value );
+
+    }
+
+
+}
+
+void cmd_d_Country_2_4Ie(ConParm_t parm[], U16 nParms)
+{
+    tiINT32 result;
+
+    if( nParms == 0 )
+    {
+        UINT8   countryString[COUNTRY_STRING_LEN+1];
+        result = TI_Get_countryIeFor2_4_Ghz(g_id_adapter, (UINT8**)&countryString );
+        if( result ==  TI_RESULT_OK)
+        {
+            countryString[COUNTRY_STRING_LEN] = '\0';
+            if (countryString[0] == '\0')
+            {
+                console_printf_terminal("802_11d Country for 2.4 GHz is not found\n");
+            }
+            else
+            {
+                console_printf_terminal("802_11d Country for 2.4 GHz is %s \n", countryString );
+            }
+
+        }
+    }
+    else
+    {
+        country_t countryWorld;
+
+        countryWorld.elementId = COUNTRY_IE_ID;
+        countryWorld.len = 6;
+        memcpy( countryWorld.countryIE.CountryString,"GB ", 3);
+        countryWorld.countryIE.tripletChannels[0].firstChannelNumber = 1;
+        countryWorld.countryIE.tripletChannels[0].maxTxPowerLevel = 23;
+        countryWorld.countryIE.tripletChannels[0].numberOfChannels = 11;
+        console_printf_terminal("802_11d Start Setting GB Country for 2.4 GHz \n");
+
+        result = TI_Set_countryIeFor2_4_Ghz(g_id_adapter, countryWorld);
+
+        console_printf_terminal("802_11d Setting GB Country for 2.4 GHz, result=%d\n", result);
+
+    }
+
+
+}
+
+void cmd_d_Country_5Ie(ConParm_t parm[], U16 nParms)
+{
+    tiINT32 result;
+
+    if( nParms == 0 )
+    {
+        UINT8   countryString[COUNTRY_STRING_LEN+1];
+        result = TI_Get_countryIeFor5_Ghz(g_id_adapter, (UINT8**)&countryString );
+        if( result ==  TI_RESULT_OK)
+        {
+            countryString[COUNTRY_STRING_LEN] = '\0';
+            if (countryString[0] == '\0')
+            {
+                console_printf_terminal("802_11d Country for 5 GHz is not found\n");
+            }
+            else
+            {
+                console_printf_terminal("802_11d Country for 5 GHz is %s\n", countryString );
+            }
+        }
+    }
+    else
+    {
+        country_t countryWorld;
+
+        countryWorld.elementId = COUNTRY_IE_ID;
+        countryWorld.len = 6;
+        memcpy( countryWorld.countryIE.CountryString,"US ", 3);
+        countryWorld.countryIE.tripletChannels[0].firstChannelNumber = 36;
+        countryWorld.countryIE.tripletChannels[0].maxTxPowerLevel = 16;
+        countryWorld.countryIE.tripletChannels[0].numberOfChannels = 8;
+        result = TI_Set_countryIeFor5_Ghz(g_id_adapter, countryWorld);
+
+        console_printf_terminal("802_11d Setting US Country for 5 GHz, result=%d\n", result);
+
+    }
+
+}
+
+void cmd_DFS_range(ConParm_t parm[], U16 nParms)
+{
+    tiINT32 result;
+    DFS_ChannelRange_t DFS_ChannelRange;
+
+    if( nParms == 0 )
+    {
+
+        result = TI_Get_minMaxDfsChannels(g_id_adapter, &DFS_ChannelRange );
+        if( result ==  TI_RESULT_OK)
+        {
+            console_printf_terminal("DFS min channel is %d, DFS max channel is %d\n",
+                                    DFS_ChannelRange.minDFS_channelNum, DFS_ChannelRange.maxDFS_channelNum);
+        }
+    }
+    else
+    {
+        DFS_ChannelRange.minDFS_channelNum = (UINT16) parm[0].value;
+        DFS_ChannelRange.maxDFS_channelNum = (UINT16) parm[1].value;
+
+        console_printf_terminal("Given params: min channel %d, DFS max channel %d\n",
+                                parm[0].value, parm[1].value);
+
+        result = TI_Set_minMaxDfsChannels(g_id_adapter, DFS_ChannelRange);
+        if (result ==  TI_RESULT_OK)
+        {
+            console_printf_terminal("Setting DFS min channel %d, DFS max channel %d\n",
+                                    DFS_ChannelRange.minDFS_channelNum, DFS_ChannelRange.maxDFS_channelNum);
+        }
+        else
+        {
+            console_printf_terminal("Setting DFS min channel %d, DFS max channel %d - FAILED !!\n",
+                                    DFS_ChannelRange.minDFS_channelNum, DFS_ChannelRange.maxDFS_channelNum);
+        }
+    }
+
+}
+
+#if 0
+void cmd_modify_tx_power_value(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 1234;
+        if( !TI_GetTxPowerValue(g_id_adapter, &data) )
+            console_printf_terminal(  "Tx Power val = %ld\n", data);
+    }
+    else
+        TI_SetTxPowerValue(g_id_adapter, parm[0].value);
+}
+#endif
+
+void cmd_show_regdomain_table(ConParm_t parm[], U16 nParms)
+{
+    UNUSED(nParms);
+    UNUSED(parm);
+    console_printf_terminal(  "not implemented ....\n");
+}
+
+void cmd_modify_4x_state(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiBOOL data = FALSE;
+        if( !TI_Get4XState(g_id_adapter, &data ) )
+            console_printf_terminal("4x state=%s\n", data ? "True" : "False" );
+    }
+    else    /* param <read-only!!> */
+        TI_Set4XState(g_id_adapter, (BOOL) parm[0].value);
+}
+
+static named_value_t BSS_type[] =
+{
+    { os802_11IBSS,                  "AD-Hoc" },
+    { os802_11Infrastructure,        "Infr." },
+    { os802_11AutoUnknown,           "Auto" },
+/*    { os802_11HighSpeedIBSS,         "HighSpeedIBSS" },*/
+/*    { os802_11InfrastructureMax,     "Max" }*/
+};
+
+void cmd_modify_bss_type(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_NETWORK_MODE data = 0;     //TRS:MEB use correct datatype to avoid compiler warning
+    if( nParms == 0 )
+    {
+        if( !TI_GetBSSType(g_id_adapter, &data ) )
+        {
+            print_available_values(BSS_type);
+
+            console_printf_terminal("Current mode=%d\n", data );
+        }
+    }
+    else    /* param <read-only!!> */
+        TI_SetBSSType(g_id_adapter, (BOOL) parm[0].value);
+}
+
+void cmd_get_driver_state(ConParm_t parm[], U16 nParms)
+{
+   static char stateDesc[6][100] =
+{
+    "DRIVER_STATE_IDLE",
+    "DRIVER_STATE_SCANNING",
+    "DRIVER_STATE_SELECTING",
+    "DRIVER_STATE_CONNECTING",
+    "DRIVER_STATE_CONNECTED",
+    "DRIVER_STATE_DISCONNECTED",
+};
+   driverState_e myState;
+
+   TI_GetDriverState (g_id_adapter, &myState);
+   console_printf_terminal("Driver state is %s\n", stateDesc[(UINT8)myState]);
+}
+
+void cmd_modify_ext_rates_ie(ConParm_t parm[], U16 nParms)
+{
+    static named_value_t ExtRatesIE[] =
+    {
+        { DRAFT_5_AND_EARLIER,  "5_AND_EARLIER" },
+        { DRAFT_6_AND_LATER,    "6_AND_LATER" }
+    };
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 1122;
+        if( !TI_GetExtRatesIE(g_id_adapter, &data ) )
+        {
+            print_available_values(ExtRatesIE);
+            console_printf_terminal("ExtRatesIE=%u\n", data  );
+        }
+    }
+    else
+        TI_SetExtRatesIE(g_id_adapter, (tiUINT32) parm[0].value);
+}
+
+
+/*will return RSSI*/
+void cmd_get_rsii_level(ConParm_t parm[], U16 nParms)
+{
+   tiINT32 rssi ;
+   TI_GetRSSI(g_id_adapter, &rssi);
+   console_printf_terminal("\n Current RSSI : %d\n" ,rssi)  ; // TRS:WDK - add return
+}
+
+
+/*will return SNR ratio*/
+void cmd_get_snr_ratio(ConParm_t parm[], U16 nParms)
+{
+   tiUINT32 snr ;
+   TI_GetSNR(g_id_adapter, &snr);
+   console_printf_terminal("\n Current SNR ratio : %d\n" ,snr)  ;  // TRS:WDK - add return
+}
+
+void cmd_modify_frag_threshold(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 0xfefefefe;
+        if( !TI_GetFragmentThreshold(g_id_adapter, &data ) )
+            console_printf_terminal("Frag. threshold=%d\n", data );
+    }
+    else
+        TI_SetFragmentThreshold(g_id_adapter, parm[0].value);
+}
+
+void cmd_modify_short_slot(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 0xfefefefe;
+        if( !TI_GetShortSlot(g_id_adapter, &data ) )
+            console_printf_terminal("Short slot=%d\n", data );
+    }
+    else
+        TI_SetShortSlot(g_id_adapter, parm[0].value);
+}
+
+void cmd_modify_rts_threshold(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 0xfefefefe;
+        if( !TI_GetRTSThreshold( g_id_adapter, &data) )
+            console_printf_terminal("RTSThreshold=%d\n", data );
+    }
+    else
+        TI_SetRTSThreshold(g_id_adapter, parm[0].value);
+}
+
+void cmd_modify_preamble(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 0xfefefefe;
+        if( !TI_GetShortPreamble( g_id_adapter, &data) )
+            console_printf_terminal("ShortPreamble=%d\n", data );
+    }
+    else
+        TI_SetShortPreamble(g_id_adapter, parm[0].value);
+}
+
+void cmd_modify_antenna_diversity(ConParm_t parm[], U16 nParms)
+{
+    TIWLAN_ANT_DIVERSITY antennaDiversityOptions;
+
+    antennaDiversityOptions.enableRxDiversity = (UINT8)parm[0].value;
+    antennaDiversityOptions.rxSelectedAntenna = (UINT8)parm[1].value;
+    antennaDiversityOptions.enableTxDiversity = (UINT8)parm[2].value;
+    antennaDiversityOptions.txSelectedAntenna = (UINT8)parm[3].value;
+    antennaDiversityOptions.rxTxSharedAnts = (UINT8)parm[4].value;
+    TI_SetAntennaDiversityParams(g_id_adapter, &antennaDiversityOptions);
+    console_printf_terminal("Antenna diversity parameters sent.\n");
+}
+
+void cmd_modify_short_retry(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 0xfefefefe;
+        if( !TI_GetShortRetry( g_id_adapter, &data) )
+            console_printf_terminal("ShortRetry=%d\n", data );
+    }
+    else
+        TI_SetShortRetry(g_id_adapter, parm[0].value);
+}
+
+void cmd_modify_long_retry(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        tiUINT32 data = 0xfefefefe;
+        if( !TI_GetLongRetry( g_id_adapter, &data) )
+            console_printf_terminal("LongRetry=%d\n", data );
+    }
+    else
+        TI_SetLongRetry(g_id_adapter, parm[0].value);
+}
+
+void cmd_start_driver(ConParm_t parm[], U16 nParms)
+{
+    TI_Start( g_id_adapter );
+}
+
+void cmd_stop_driver(ConParm_t parm[], U16 nParms)
+{
+    UNUSED(nParms);
+    UNUSED(parm);
+    TI_Stop(g_id_adapter);
+}
+static TI_HANDLE eventRegistered[IPC_EVENT_MAX];
+
+static named_value_t event_type[] = {
+    { IPC_EVENT_ASSOCIATED,             "Associated" },
+    { IPC_EVENT_DISASSOCIATED,          "Disassociated"  },
+    { IPC_EVENT_LINK_SPEED,             "LinkSpeed" },
+    { IPC_EVENT_AUTH_SUCC,              "Authentication Success" },
+    { IPC_EVENT_SCAN_COMPLETE,          "ScanComplete" },
+    { IPC_EVENT_TIMEOUT,                "Timeout" },
+    { IPC_EVENT_CCKM_START,             "CCKM_Start" },
+    { IPC_EVENT_MEDIA_SPECIFIC,         "Media_Specific" },
+    { IPC_EVENT_EAPOL,                  "EAPOL" },
+    { IPC_EVENT_BOUND,                  "Bound" },
+    { IPC_EVENT_UNBOUND,                "Unbound" },
+    { IPC_EVENT_PREAUTH_EAPOL,          "PreAuth EAPOL"},
+/*  { IPC_EVENT_PER,                    "PER" },*/
+    { IPC_EVENT_LOW_SNR,               "Low SNR" },
+    { IPC_EVENT_LOW_RSSI,               "Low RSSI" },
+    { IPC_EVENT_TSPEC_STATUS,           "IPC_EVENT_TSPEC_STATUS" },
+    { IPC_EVENT_TSPEC_RATE_STATUS,      "IPC_EVENT_TSPEC_RATE_STATUS" },
+    { IPC_EVENT_MEDIUM_TIME_CROSS,      "IPC_EVENT_MEDIUM_TIME_CROSS" },
+    { IPC_EVENT_ROAMING_COMPLETE,       "ROAMING_COMPLETE"},
+    { IPC_EVENT_EAP_AUTH_FAILURE,       "EAP-FAST/LEAP Auth Failed"},
+    { IPC_EVENT_WPA2_PREAUTHENTICATION, "IPC_EVENT_WPA2_PREAUTHENTICATION" },
+    { IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, "IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED" },
+    { IPC_EVENT_BT_COEX_MODE,  "IPC_EVENT_BT_COEX_MODE" },
+
+};
+
+
+void cmd_events_register(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 event;
+    IPC_EVENT_PARAMS pEvent;
+
+   if( nParms )
+   {
+        event = (tiUINT32)parm[0].value;
+
+        if (events_mask & (1 << event))
+        {
+#ifndef _WINDOWS
+            console_printf_terminal("cmd_events_register, event is already enabled! (%d)\n", events_mask);
+#endif
+        }
+        else
+   {
+        pEvent.uEventType       = (tiUINT32)parm[0].value;
+        pEvent.uDeliveryType      = DELIVERY_PUSH;
+        pEvent.pfEventCallback = cli_receive_ev;
+#ifdef _WINDOWS
+#endif
+        if( !TI_RegisterEvent(g_id_adapter, &pEvent) )
+            {
+            eventRegistered[pEvent.uEventType] = pEvent.uEventID;
+
+                events_mask |= (1 << event);
+#ifdef _WINDOWS
+#endif
+            }
+        }
+        }
+    else
+        {
+#ifdef _WINDOWS
+#else
+               print_available_values(event_type);
+#endif
+    }
+
+        }
+void cmd_events_unregister(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 event;
+    IPC_EVENT_PARAMS pEvent;
+
+   if( nParms )
+   {
+        event = (tiUINT32)parm[0].value;
+#ifdef _WINDOWS
+#else
+        pEvent.uEventType = event;
+        pEvent.uEventID = eventRegistered[pEvent.uEventType];
+        TI_UnRegisterEvent(g_id_adapter, &pEvent);
+
+        events_mask &= ~(1 << event);
+#endif
+    }
+    else
+    {
+#ifdef _WINDOWS
+#else
+        print_available_values(event_type);
+#endif
+    }
+}
+
+void cmd_get_selected_bssid_info(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_BSSID_EX myInfo;
+   TI_GetSelectedBSSIDInfo(g_id_adapter, &myInfo);
+
+   console_printf_terminal("Selected BSSID Info:\n");
+   console_printf_terminal("--------------------\n");
+   console_printf_terminal("SSID: %s\n", get_ssid_string(&myInfo.Ssid));
+   console_printf_terminal("BSSID: %02x.%02x.%02x.%02x.%02x.%02x\n",
+          myInfo.MacAddress[0], myInfo.MacAddress[1], myInfo.MacAddress[2], myInfo.MacAddress[3], myInfo.MacAddress[4], myInfo.MacAddress[5] );
+}
+
+int parseBssidIe(OS_802_11_BSSID_EX * bssid)
+{
+    OS_802_11_VARIABLE_IEs *pData;
+    dot11_WME_PARAM_t *  qosParams;
+
+    int length;
+    int retval = 0;
+    /* console_printf_terminal("parseBssidIe,IElength=%d \n",bssid->IELength);*/
+    for (
+            length =sizeof(OS_802_11_FIXED_IEs) , pData = (OS_802_11_VARIABLE_IEs*) ((char*)bssid->IEs + sizeof(OS_802_11_FIXED_IEs));
+            length < (int)(bssid->IELength-3);
+            length += (pData->Length +2),pData =  (OS_802_11_VARIABLE_IEs*)((char*)bssid->IEs  + length)
+        )
+    {
+        /* console_printf_terminal("ElementID=%d pData=%x length=%d length1=%d\n",pData->ElementID,pData,pData->Length,length);*/
+        if (pData->ElementID == DOT11_WME_ELE_ID)
+        {
+            qosParams = (dot11_WME_PARAM_t *)pData;
+            /* console_printf_terminal("OUIType=%x OUI =%x %x %x \n",qosParams->OUIType,qosParams->OUI[0],qosParams->OUI[1],qosParams->OUI[2]);*/
+            if (qosParams->OUIType == dot11_WME_OUI_TYPE)
+            {
+                retval |= dot11_WME_OUI_TYPE;
+            }
+
+
+        }
+    }
+
+
+    return retval;
+}
+
+void cmd_bssid_list(ConParm_t parm[], U16 nParms)
+{
+
+    OS_802_11_BSSID_EX BssIdInfo;
+    TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
+    get_bssid_list(parm, nParms, FALSE , &BssIdInfo );
+}
+
+void cmd_Full_bssid_list(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_BSSID_EX BssIdInfo;
+    TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
+    get_bssid_list(parm, nParms, TRUE , &BssIdInfo);
+}
+
+/*When beacon filter is activated, the current RSSI of the connection with the AP will be displayed despite no beacons are
+ *passed up to the driver*/
+static void get_bssid_list(ConParm_t parm[], U16 nParms, BOOL fullBssidList , OS_802_11_BSSID_EX *pBssid)
+{
+    OS_802_11_BSSID_LIST_EX *list;/* = (OS_802_11_BSSID_LIST_EX *) data; */
+    OS_802_11_BSSID_EX *bssid;
+    tiUINT32 number_items, index;
+    char buffer[8] ;
+    int Qos = 0;
+       BOOL isConnectedAp = FALSE ;   //TRS:MEB move this line earlier to avoid compile error
+    buffer[0] ='\0';
+
+    UNUSED(nParms);
+    UNUSED(parm);
+
+    if (fullBssidList)
+    {
+        if( TI_GetFullBSSIDList(g_id_adapter, &list) || !list )
+            return ;
+    }
+    else
+    {
+    if( TI_GetBSSIDList(g_id_adapter, &list) || !list )
+        return ;
+    }
+
+
+    bssid = &list->Bssid[0];
+    number_items = list->NumberOfItems;
+
+    console_printf_terminal("BssId List: Num=%u\n", number_items );
+
+    if( number_items )
+    {
+        console_printf_terminal("%17s %7s %4s %5s %7s  %10s %s\n", "MAC", "Privacy", "Rssi", "Infra", "Channel","Qos   ", "SSID");
+        while (number_items)
+        {
+            Qos = parseBssidIe(bssid);
+
+/*          console_printf_terminal("Qos=%d\n",Qos);*/
+            if (Qos & dot11_WME_OUI_TYPE)
+            {
+                strcpy(buffer, "WME ");
+            }
+
+            if (Qos == 0)
+            {
+                strcpy(buffer, "NONE ");
+            }
+
+            if (( 0 == memcmp(pBssid->MacAddress ,bssid->MacAddress,sizeof(OS_802_11_MAC_ADDRESS)) ) &&
+                               (pBssid->NetworkTypeInUse == bssid->NetworkTypeInUse))
+            {
+                /*bssid->Rssi = staRssi ;*/
+                isConnectedAp = TRUE ;
+            }
+            else
+            {
+                isConnectedAp = FALSE ;
+            }
+
+            console_printf_terminal("%s %s %7u %4d %5d %7d %10s %s\n",
+                    ( TRUE == isConnectedAp)?"*":" " ,
+                    print_mac_2_str(bssid->MacAddress),
+                    bssid->Privacy, bssid->Rssi,
+                    bssid->InfrastructureMode, Freq2Chan(bssid->Configuration.Union.channel),
+                    buffer,
+                    get_ssid_string(&bssid->Ssid) );
+
+            if (fullBssidList)
+            {
+                console_printf_terminal("   TSF 0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x\n",
+                      bssid->IEs[0], bssid->IEs[1], bssid->IEs[2], bssid->IEs[3],
+                      bssid->IEs[4], bssid->IEs[5], bssid->IEs[6], bssid->IEs[7]);
+                console_printf_terminal("   BeaconInterval 0x%02x%02x\n",  bssid->IEs[9], bssid->IEs[8]);
+                console_printf_terminal("   Capabilities   0x%02x%02x\n",  bssid->IEs[10], bssid->IEs[11]);
+                console_printf_terminal("   Variable IEs:\n");
+                for (index=12; index<bssid->IELength; index++)
+                {
+                    if ((index-12)%8 == 0)
+                    {
+                        console_printf_terminal("\n   ");
+                    }
+                    console_printf_terminal("0x%02x ",bssid->IEs[index]);
+
+                }
+                console_printf_terminal("\n");
+            }
+            bssid = (OS_802_11_BSSID_EX *) (((char *) bssid) + bssid->Length);
+            number_items--;
+        }
+        console_printf_terminal("Infra.mode:");
+        print_available_values(BSS_type);
+    }
+
+    free(list);
+}
+
+#ifdef _WINDOWS
+#else
+PACKED_STRUCT( OS_802_11_BSSID_EX_TEMP,
+       tiUINT32                  Length;
+       OS_802_11_MAC_ADDRESS     MacAddress;
+    PACKED_UNION(Union,
+        tiUINT8  Reserved[2];
+        tiUINT16 Capabilities;
+    );
+       OS_802_11_SSID            Ssid;
+       tiUINT32                  Privacy;
+       OS_802_11_RSSI            Rssi;
+       OS_802_11_NETWORK_TYPE    NetworkTypeInUse;
+       OS_802_11_CONFIGURATION   Configuration;
+       OS_802_11_NETWORK_MODE    InfrastructureMode;
+       OS_802_11_RATES_EX        SupportedRates;
+       tiUINT32                  IELength;
+       tiUINT8                   IEs[MAX_BEACON_BODY_LENGTH+sizeof(OS_802_11_FIXED_IEs)];
+);
+#endif
+
+
+void cmd_FullPrimaryBbssid(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_BSSID_EX_TEMP bssid;
+    OS_802_11_BSSID_EX_TEMP *pBssid = &bssid;
+    UINT32  index;
+    char buffer[8] ;
+    int Qos = 0;
+    buffer[0] ='\0';
+
+    UNUSED(nParms);
+    UNUSED(parm);
+
+    memset(pBssid, 0, sizeof(OS_802_11_BSSID_EX));
+    pBssid->Length = sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) + MAX_BEACON_BODY_LENGTH;
+    if( TI_GetPrimaryBSSIDInfo(g_id_adapter, (OS_802_11_BSSID_EX*)pBssid))
+            return ;
+
+    console_printf_terminal("Primary BssId: Length = %d, IELength=%d \n" , pBssid->Length, pBssid->IELength);
+
+    if (pBssid->Length > sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) + MAX_BEACON_BODY_LENGTH)
+    {
+        console_printf_terminal("Error - Length = %d is too long!!\n", pBssid->Length);
+        return;
+    }
+    if (pBssid->Length < pBssid->IELength)
+    {
+        console_printf_terminal("Error - IELength = %d is too long!!\n", pBssid->IELength);
+        pBssid->IELength = 50;
+        print_mac_2_str(pBssid->MacAddress),
+
+        console_printf_terminal("SSID len=%d\n", pBssid->Ssid.SsidLength);
+
+        return;
+    }
+    console_printf_terminal("%17s %7s %4s %5s %7s  %10s %s\n", "MAC", "Privacy", "Rssi", "Infra", "Channel","Qos   ", "SSID");
+    Qos = parseBssidIe((OS_802_11_BSSID_EX*)pBssid);
+
+    if (Qos & dot11_WME_OUI_TYPE)
+    {
+        strcpy(buffer, "WME ");
+    }
+
+    if (Qos == 0)
+    {
+        strcpy(buffer, "NONE ");
+    }
+
+    console_printf_terminal("%s %7u %4d %5d %7d %10s %s\n",
+            print_mac_2_str(pBssid->MacAddress),
+            pBssid->Privacy, pBssid->Rssi,
+            pBssid->InfrastructureMode, Freq2Chan(pBssid->Configuration.Union.channel),
+            buffer,
+            get_ssid_string(&pBssid->Ssid) );
+
+    {
+        console_printf_terminal("   TSF 0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x\n",
+              pBssid->IEs[0], pBssid->IEs[1], pBssid->IEs[2], pBssid->IEs[3],
+              pBssid->IEs[4], pBssid->IEs[5], pBssid->IEs[6], pBssid->IEs[7]);
+        console_printf_terminal("   BeaconInterval 0x%02x%02x\n",  pBssid->IEs[9], pBssid->IEs[8]);
+        console_printf_terminal("   Capabilities   0x%02x%02x\n",  pBssid->IEs[10], pBssid->IEs[11]);
+        console_printf_terminal("   Variable IEs:\n");
+        for (index=12; index<pBssid->IELength; index++)
+        {
+            if ((index-12)%8 == 0)
+            {
+                console_printf_terminal("\n   ");
+            }
+            console_printf_terminal("0x%02x ",pBssid->IEs[index]);
+
+        }
+        console_printf_terminal("\n");
+    }
+    console_printf_terminal("\nInfra.mode:");
+    print_available_values(BSS_type);
+}
+
+void cmd_file_load(ConParm_t parm[], U16 nParms)
+{
+    consoleRunScript((char *) parm[0].value);
+}
+
+#ifdef TI_DBG
+
+struct report_bit_desc_t
+{
+    int index;
+    char *desc;
+};
+
+struct report_bit_desc_t report[] =
+{
+
+    /* Set 0 */
+    { CONFIG_MGR_MODULE_LOG,        "CONFIG_MGR" },
+    { SME_SM_MODULE_LOG,            "SME_SM" },
+    { SITE_MGR_MODULE_LOG,          "SITE_MGR" },
+    { CONN_MODULE_LOG,              "CONN" },
+    { MLME_SM_MODULE_LOG,           "MLMEE" },
+    { AUTH_MODULE_LOG,              "AUTH" },
+    { ASSOC_MODULE_LOG,             "ASSOC" },
+    { RX_DATA_MODULE_LOG,           "RX_DATA" },
+    { TX_DATA_MODULE_LOG,           "TX_DATA" },
+    { CTRL_DATA_MODULE_LOG,         "CTRL_DATA" },
+    { RSN_MODULE_LOG,               "RSN" },
+    { HAL_RX_MODULE_LOG,            "HAL_RX" },
+    { HAL_TX_MODULE_LOG,            "HAL_TX" },
+    { HAL_CTRL_MODULE_LOG,          "HAL_CTRL" },
+    { HAL_SECURITY_MODULE_LOG,      "HAL_SECUR" },
+    { MEM_MGR_MODULE_LOG,           "MEM_MGR" },
+    { REPORT_MODULE_LOG,            "REPORT" },
+    { SITE_UPDATE_MODULE_LOG,       "SITE_UPDATE" },
+    { REGULATORY_DOMAIN_MODULE_LOG, "REG_DOMAIN" },
+    { MEASUREMENT_MNGR_MODULE_LOG,  "MEASUREMENT_MNGR" },
+    { MEASUREMENT_SRV_MODULE_LOG,   "MEASUREMENT_SRV" },
+    { SOFT_GEMINI_MODULE_LOG,       "SOFT_GEMINI" },
+    { SC_MODULE_LOG,                "SC (Switch Channel)" },
+    { EXC_MANAGER_MODULE_LOG,       "EXC_MANAGER" },
+    { ROAMING_MANAGER_MODULE_LOG,   "ROAMING_MANAGER" },
+    { QOS_MANAGER_MODULE_LOG,       "QOS_MANAGER" },
+    { TRAFFIC_ADM_CTRL_MODULE_LOG,  "TRAFFIC_ADM_CTRL" },
+    { POWER_MANAGER_MODULE_LOG,     "POWER_MANAGER" },
+    { POWER_CONTROL_MODULE_LOG,     "POWER_CONTROL" },
+    { POWER_SERVER_MODULE_LOG,      "POWER_SERVER" },
+    { ELP_MODULE_LOG,               "ELP" },
+    { SCR_MODULE_LOG,               "SCR" },
+    { SCAN_SRV_MODULE_LOG,          "SCAN_SRV" },
+    { SCAN_CNCN_MODULE_LOG,         "SCAN_CNCN" },
+    { SCAN_MNGR_MODULE_LOG,         "SCAN_MNGR" },
+    { GWSI_ADAPT_MODULE_LOG,        "GWSI_ADAPT" },
+    { GWSI_ADAPT_CB_MODULE_LOG,     "GWSI_ADAPT_CB" },
+    { CORE_ADAPT_MODULE_LOG,        "CORE_ADAPT" },
+    { TX_HW_QUEUE_MODULE_LOG,       "TX HW QUEUE" },
+    { TX_CTRL_BLK_MODULE_LOG,       "TX CTRL BLK" },
+    { TX_RESULT_MODULE_LOG,         "TX RESULT" },
+    { TNETW_IF_MODULE_LOG,          "TNETW IF" },
+    { TNETW_ARBITER_MODULE_LOG,     "TNETW ARBITER" },
+    { CURR_BSS_MODULE_LOG,          "CURR_BSS" },
+    { FW_EVENT_MODULE_LOG,          "FW_EVENT" },
+    { CMD_MBOX_MODULE_LOG,          "CMD_MBOX" },
+       { CMDQUEUE_MODULE_LOG,          "CMD_QUEUE" },
+    { EVENT_MBOX_MODULE_LOG,        "EVENT_MBOX"},
+    { TNETW_DRV_MODULE_LOG,         "TNETW DRV" },
+       { TNETW_XFER_MODULE_LOG,        "TX XFER" },
+    { RECOVERY_MGR_MODULE_LOG,      "RECOVERY MGR" },
+    { RECOVERY_CTRL_MODULE_LOG,     "RECOVERY CTRL" },
+    { HW_INIT_MODULE_LOG,           "HW INIT" }
+
+};
+
+
+struct rep_severity_level_t {
+    U8 level;
+    char *desc;
+};
+
+static struct rep_severity_level_t report_severity_level[] = {
+    { 0,                          "----"           },
+    { WLAN_SEVERITY_INIT,         "INIT",          },
+    { WLAN_SEVERITY_INFORMATION,  "INFORMATION",   },
+    { WLAN_SEVERITY_WARNING,      "WARNING",       },
+    { WLAN_SEVERITY_ERROR,        "ERROR",         },
+    { WLAN_SEVERITY_FATAL_ERROR,  "FATAL_ERROR",   },
+    { WLAN_SEVERITY_SM,           "SM",            },
+    { WLAN_SEVERITY_CONSOLE,      "CONSOLE",       },
+    { WLAN_SEVERITY_DEBUG_RX,     "DEBUG RX",      },
+    { WLAN_SEVERITY_DEBUG_TX,     "DEBUG TX",      },
+    { WLAN_SEVERITY_DEBUG_CONTROL,"DEBUG CONTROL", },
+    { WLAN_SEVERITY_GWSI_RECORDING,"GWSI RECORDING"}
+};
+
+static void print_report_module_desc(void)
+{
+    int i;
+    tiUINT8 module_table[WLAN_MAX_LOG_MODULES];
+
+    if (!TI_GetReportModule(g_id_adapter, module_table))
+    {
+        console_printf_terminal("-------------------------------\n");
+        console_printf_terminal("%.5s\tState\t %s\n", "Index", "Desc");
+
+        for( i = 0; i < SIZE_ARR(report); i++)
+        {
+            /* Check if there is string content (the first character is not ZERO) */
+            if( report[i].desc[0] )
+            {
+                console_printf_terminal("%3d\t%c\t%s\n", report[i].index, (module_table[i] == '1') ? '+' : ' ', report[i].desc );
+            }
+        }
+    }
+    else
+    {
+        console_printf_terminal("Error reading the report table form the driver\n");
+    }
+}
+
+void cmd_report_add(ConParm_t parm[], U16 nParms)
+{
+    tiUINT8 module_table[WLAN_MAX_LOG_MODULES];
+
+    if( nParms != 1)
+    {
+        print_report_module_desc();
+        console_printf_terminal( "* Use '%d' (max index) to set all table.\n", WLAN_MAX_LOG_MODULES);
+    }
+    else if(!TI_GetReportModule(g_id_adapter, module_table))
+    {
+        if (parm[0].value == WLAN_MAX_LOG_MODULES)
+        {
+            memset(module_table, '1', sizeof(module_table));
+        }
+        else if(parm[0].value < WLAN_MAX_LOG_MODULES)
+        {
+            module_table[parm[0].value] = '1';
+        }
+        TI_SetReportModule(g_id_adapter, module_table);
+    }
+}
+
+void cmd_report_clear(ConParm_t parm[], U16 nParms)
+{
+    tiUINT8 module_table[WLAN_MAX_LOG_MODULES + 1];
+
+    if( nParms != 1)
+    {
+        print_report_module_desc();
+        console_printf_terminal( "* Use '%d' (max index) to clear all table.\n", WLAN_MAX_LOG_MODULES);
+    }
+    else if(!TI_GetReportModule(g_id_adapter, module_table))
+    {
+        if (parm[0].value == WLAN_MAX_LOG_MODULES)
+        {
+            memset(module_table, '0', WLAN_MAX_LOG_MODULES);
+        }
+        else if (parm[0].value < WLAN_MAX_LOG_MODULES)
+        {
+            module_table[parm[0].value] = '0';
+        }
+        TI_SetReportModule(g_id_adapter, module_table);
+    }
+}
+
+void cmd_report_set(ConParm_t parm[], U16 nParms)
+{
+    U8 *ModuleTable = (U8 *)parm[0].value;
+
+    if( nParms != 1)
+    {
+        print_report_module_desc();
+    }
+    else
+    {
+#ifdef _WINDOWS
+#endif /* _WINDOWS */
+
+        TI_SetReportModule(g_id_adapter, ModuleTable);
+    }
+}
+
+void cmd_hw_register(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 data;
+
+#ifndef _WINDOWS
+        usleep(10 * 1000);
+#elif defined (_WINDOWS)
+#endif
+
+    if( nParms == 1 )
+    {
+        if( !TI_hwReadRegister(g_id_adapter, parm[0].value, &data ) )
+        {
+#ifdef _WINDOWS
+#endif
+        }
+    }
+    else
+    {
+        TI_hwWriteRegister(g_id_adapter, parm[0].value, parm[1].value );
+    }
+}
+
+void cmd_debug_driver_print(ConParm_t parm[], U16 nParms)
+    {
+        tiUINT32 func_id = ( nParms > 0 ) ? parm[0].value : 0;
+        tiUINT32 opt_param = ( nParms > 1 ) ? parm[1].value : 0;
+        tiUINT32 buf[2] = { func_id, opt_param };
+
+        console_printf_terminal("DRV_PRINT: FUNC:%u, PARAM:%u\n", func_id, opt_param);
+        TI_DisplayStats(g_id_adapter, (tiUINT8 *) buf, sizeof(buf) );
+        /* tiwlan_driver_debug_print( g_drv_name, func_id, opt_param ); */
+}
+
+void cmd_debug_buffer_put(ConParm_t parm[], U16 nParms)
+    {
+        tiUINT32 func_id = ( nParms > 0 ) ? parm[0].value : 0;
+        tiUINT32 opt_param = ( nParms > 1 ) ? parm[1].value : 0;
+        tiUINT8 buf[260];  /* no more then 256 + func id */
+
+        if (opt_param == 0)
+            return;
+        *(tiUINT32*) buf = func_id;
+        memcpy (buf + sizeof(func_id),(char *)opt_param,strlen((char *)opt_param));
+
+        console_printf_terminal("cmd_debug_buffer_put: FUNC:%u, PARAM:%u\n", func_id, opt_param);
+        TI_DisplayStats(g_id_adapter, (tiUINT8 *) buf, strlen((char *)opt_param) +  sizeof(func_id));
+        /* tiwlan_driver_debug_print( g_drv_name, func_id, opt_param ); */
+}
+
+static void print_severity_table(tiUINT8 *pTable)
+{
+    int i;
+
+    console_printf_terminal("Severity:\n");
+    console_printf_terminal("-------------------------------\n");
+    console_printf_terminal("%14s\tState\t%s\n", "Severity level", "Desc");
+
+    for( i=1; i<SIZE_ARR(report_severity_level); i++ )
+    {
+        console_printf_terminal("%d\t%c\t%s\n", report_severity_level[i].level, (pTable[i] == '1') ? '+' : ' ',report_severity_level[i].desc );
+    }
+
+    console_printf_terminal( "* Use '0' to clear all table.\n");
+    console_printf_terminal( "* Use '%d' (max index) to set all table.\n", SIZE_ARR(report_severity_level));
+}
+
+void cmd_report_severity_table(ConParm_t parm[], U16 nParms)
+{
+    U8 *pSeverityTable = (U8 *)parm[0].value;
+    tiUINT8 SeverityTable[WLAN_MAX_SEVERITIES];
+#ifdef _WINDOWS
+#endif /* _WINDOWS */
+    if( nParms != 1)
+    {
+        if (!TI_GetReportSeverity( g_id_adapter, &SeverityTable[0]))
+        {
+            print_severity_table(SeverityTable);
+        }
+    }
+    else
+    {
+        TI_SetReportSeverity(g_id_adapter, pSeverityTable);
+    }
+}
+
+void cmd_report_severity_level(ConParm_t parm[], U16 nParms)
+{
+    tiUINT8 SeverityTable[WLAN_MAX_SEVERITIES];
+
+    /* Get the current report severity */
+    if (!TI_GetReportSeverity( g_id_adapter, &SeverityTable[0]))
+    {
+        if(nParms == 0)
+        {
+            /* Parameters error - print the current table values */
+            print_severity_table(SeverityTable);
+        }
+        else
+        {
+            if (parm[0].value == 0)
+            {
+                /* Disable all severity levels */
+
+                memset(SeverityTable, (int)('0'), sizeof(SeverityTable));
+
+                TI_SetReportSeverity(g_id_adapter, SeverityTable);
+            }
+            else if (parm[0].value == SIZE_ARR(report_severity_level))
+            {
+                /* Enable all severity levels */
+
+                memset(SeverityTable, (int)('1'), sizeof(SeverityTable));
+
+                TI_SetReportSeverity(g_id_adapter, SeverityTable);
+            }
+            else if (parm[0].value < SIZE_ARR(report_severity_level))
+            {
+                console_printf_terminal("Toggle severity level %#lx\n", parm[0].value);
+
+                if (SeverityTable[parm[0].value] == '1')
+                {
+                    /* The level is enabled - Disable it */
+                    SeverityTable[parm[0].value] = '0';
+                }
+                else
+                {
+                    /* The bit is disabled - Enable it */
+                    SeverityTable[parm[0].value] = '1';
+                }
+
+                TI_SetReportSeverity(g_id_adapter, SeverityTable);
+            }
+            else
+            {
+                console_printf_terminal("invalid level value: %#lx\n", parm[0].value );
+            }
+        }
+    }
+    else
+    {
+        console_printf_terminal("Error retriving the severity table from the driver\n");
+    }
+}
+
+
+#ifdef DRIVER_PROFILING
+
+void cmd_profile_report(ConParm_t parm[], U16 nParms)
+{
+    TI_ProfileReport( g_id_adapter );
+}
+
+
+void cmd_profile_cpu_estimator_command(ConParm_t parm[], U16 nParms)
+{
+    /* reset or stop command */
+    if (nParms == 1) {
+        //printf("cpu_profile_cpu_estimator: param[0] = %d\n", (tiUINT8)parm[0].value);
+        TI_CpuEstimatorCommand(g_id_adapter, (tiUINT8)parm[0].value, 0);
+    }
+    else /* start command */
+    {
+        //printf("cpu_profile_cpu_estimator: param[0] = %d, param[1] = %d\n",(tiUINT8)parm[0].value,(tiUINT32)parm[1].value);
+        TI_CpuEstimatorCommand(g_id_adapter, (tiUINT8)parm[0].value,(tiUINT32)parm[1].value);
+    }
+}
+
+#endif
+
+void cmd_report_os_dbg_state(ConParm_t parm[], U16 nParms)
+{
+    UINT32 dwOsDbgState;
+
+    if(nParms == 0) {
+        if (TI_GetOsDbgState( g_id_adapter, &dwOsDbgState) == TI_RESULT_OK) {
+            console_printf_terminal("OsDbgState %d (0x%08X)\n", dwOsDbgState, dwOsDbgState);
+        }
+        else {
+            console_printf_terminal("Error retriving the OsDbgState from the driver\n");
+        }
+    }
+    else {
+        TI_SetOsDbgState(g_id_adapter, parm[0].value);
+    }
+}
+
+#endif /* define TI_DBG */
+
+void cmd_privacy_auth(ConParm_t parm[], U16 nParms)
+{
+    if( nParms )
+    {
+        TI_SetAuthenticationMode( g_id_adapter, (tiUINT32)parm[0].value );
+        /*console_printf_terminal("CLI-AuthenticationMode: - %x",(tiUINT32)parm[0].value);*/
+    }
+    else
+    {
+        static named_value_t auth_mode_type[] = {
+            { os802_11AuthModeOpen,             "Open"      },
+            { os802_11AuthModeShared,           "Shared"    },
+            { os802_11AuthModeAutoSwitch,       "AutoSwitch"},
+            { os802_11AuthModeWPA,              "WPA"       },
+            { os802_11AuthModeWPAPSK,           "WPAPSK"    },
+            { os802_11AuthModeWPANone,          "WPANone"   },
+            { os802_11AuthModeWPA2,             "WPA2"      },
+            { os802_11AuthModeWPA2PSK,          "WPA2PSK"   },
+
+            /*{ os802_11AuthModeMax,              "Max"       }*/
+        };
+        OS_802_11_AUTHENTICATION_MODE data;
+
+        if( !TI_GetAuthenticationMode( g_id_adapter, &data ) )
+        {
+            print_available_values(auth_mode_type);
+            console_printf_terminal("AuthenticationMode=%d\n", data );
+        }
+    }
+}
+
+void cmd_privacy_eap(ConParm_t parm[], U16 nParms)
+{
+    if( nParms )
+    {
+        TI_SetEAPType( g_id_adapter, (OS_802_11_EAP_TYPES) parm[0].value );
+        TI_SetEAPTypeDriver( g_id_adapter, (OS_802_11_EAP_TYPES) parm[0].value );
+    }
+    else
+    {
+        static named_value_t eap_type[] = {
+            { OS_EAP_TYPE_GENERIC_TOKEN_CARD,   "TOKEN" },
+            { OS_EAP_TYPE_TLS,                  "TLS"   },
+            INCLUDE_EXC_TYPE_NAMES
+            { OS_EAP_TYPE_TTLS,                 "TTLS"  },
+            { OS_EAP_TYPE_PEAP,                 "PEAP"  },
+            {OS_EAP_TYPE_MS_CHAP_V2,            "CHAP"  }
+        };
+/*temp_closed
+        OS_802_11_EAP_TYPES data;
+
+        if( !TI_GetEAPType( g_id_adapter, &data ) )
+        {
+            print_available_values(eap_type);
+            console_printf_terminal("EAP Type = %d\n", data );
+        }
+*/
+    print_available_values(eap_type);
+    }
+
+}
+
+
+void cmd_privacy_encrypt(ConParm_t parm[], U16 nParms)
+{
+   OS_802_11_ENCRYPTION_TYPES data;
+   if( nParms )
+    {
+        TI_SetEncryptionType( g_id_adapter, (OS_802_11_ENCRYPTION_TYPES) parm[0].value );
+    }
+    else
+    {
+        print_available_values(encrypt_type);
+        console_printf_terminal("Encryption=%d\n", !TI_GetEncryptionType( g_id_adapter, &data ) ? data : -1 );
+    }
+
+}
+void cmd_privacy_credent(ConParm_t parm[], U16 nParms)
+{
+
+    if( nParms == 2 )
+    {
+        TI_SetCredentials(g_id_adapter,(tiCHAR *) parm[0].value, (tiCHAR *) parm[1].value);
+    }
+    else if( nParms == 1 )
+        TI_SetCredentials(g_id_adapter,(tiCHAR *) parm[0].value, NULL);
+    else
+        return;
+
+}
+
+void cmd_privacy_PSKPassphrase(ConParm_t parm[], U16 nParms)
+{
+    char buf[PSK_BUFF_LEN], *pPassphrase;
+    unsigned int len, is_hex_key = 0;
+
+
+       if( nParms == 0 )
+        return;
+
+       len = strlen((char*)(parm[0].value));
+
+       pPassphrase = (char*)(parm[0].value);
+
+       memset(buf,0,PSK_BUFF_LEN);
+
+    if( nParms >= 2 )
+    {
+#ifdef _WINDOWS
+#else
+        if( !stricmp((char *) parm[1].value, "hex") )
+            is_hex_key = 1;
+        else if(!stricmp((char *) parm[1].value, "text"))
+            is_hex_key = 0;
+#endif
+    }
+
+    if( is_hex_key )
+    {
+               if( len != PSK_HEXA_LENGTH )
+        {
+            console_printf_terminal("The hexa PSKPassphrase must be at length of %d hexa digits \n",PSK_HEXA_LENGTH);
+            return ;
+        }
+    }
+       else
+       {
+               if (len > MAX_PSK_STRING_LENGTH || len < MIN_PSK_STRING_LENGTH)
+               {
+            console_printf_terminal("The PSKPassphrase must be between %d to  %d chars \n", MIN_PSK_STRING_LENGTH, MAX_PSK_STRING_LENGTH);
+            return ;
+        }
+       }
+
+       memcpy(buf, (char*)(parm[0].value), len);
+
+       /*TI_SetPSKPassPhrase*/
+       TI_SetPSK(g_id_adapter, (tiCHAR *)buf);
+}
+
+void cmd_privacy_certificate(ConParm_t parm[], U16 nParms)
+{
+#ifdef _WINDOWS // TRS:HLC
+#else
+    console_printf_terminal("Set sertificate file : %s\n", (char*)parm[0].value);
+    if(nParms == 1 )
+        TI_SetCertificateParameters(g_id_adapter, (void*)parm[0].value, 0);
+    else if(nParms == 2 )
+        TI_SetCertificateParameters(g_id_adapter, (void*)parm[0].value,
+                                                   (unsigned int)parm[1].value);
+    else return;
+#endif
+//TRS end
+}
+
+void cmd_privacy_wpa_options(ConParm_t parm[], U16 nParms)
+{
+    if( nParms )
+    {
+        TI_SetWpaOptions(g_id_adapter, parm[0].value );
+    }
+    else
+    {
+        tiUINT32 data;
+        static named_value_t wpa_options[] = {
+            { OS_802_11_OPTION_ENABLE_PROMOTE_MODE,   "PROMOTE_MODE" },
+            { OS_802_11_OPTION_ENABLE_PROMOTE_CIPHER, "PROMOTE_CIPHER"   },
+            { OS_802_11_OPTION_ENABLE_ALL,            "All" }
+        };
+
+        print_available_values(wpa_options);
+        if( !TI_GetWpaOptions(g_id_adapter, &data ) )
+            console_printf_terminal("WPA option=%d\n", data );
+    }
+}
+
+void cmd_privacy_getdefaultkey(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 DefaultKeyId;
+    if (OK == TI_GetDefaultWepKey(g_id_adapter, &DefaultKeyId))
+        console_printf_terminal("WEP default key ID = %d\n", DefaultKeyId );
+
+}
+unsigned int char_2_hexa( char c )
+{
+    if( c >= '0' && c <= '9' )
+        return c - '0';
+    else if( tolower(c) >= 'a' && tolower(c) <= 'f' )
+        return tolower(c) - 'a' + 0x0a;
+    console_printf_terminal("invalid symbol '%c'\n", c );
+    return (unsigned int) -1;
+}
+
+void cmd_privacy_addkey(ConParm_t parm[], U16 nParms)
+{
+    OS_802_11_WEP data;
+    char *buf;
+    unsigned int i, len, is_hex_key = 1;
+    U32 val, val_l;
+    unsigned int key_id = 0;
+    unsigned int def_flag = 0;
+
+    buf = (char *) parm[0].value;
+
+    key_id = (unsigned int)parm[1].value;
+
+    if( parm[2].value )
+        def_flag = 0x80000000;
+
+    if( nParms >= 4 )
+    {
+#ifdef _WINDOWS
+#else
+        if( !stricmp((char *) parm[3].value, "hex") )
+            is_hex_key = 1;
+        else if(!stricmp((char *) parm[3].value, "text"))
+            is_hex_key = 0;
+#endif
+    }
+
+    memset(data.KeyMaterial,0,sizeof(data.KeyMaterial));
+
+    len = strlen(buf);
+
+    if( is_hex_key )
+    {
+        if( len % 2 )
+        {
+            console_printf_terminal("The hexa key should be even length\n");
+            return ;
+        }
+        if(len <= 10) /*10 is number of character for key length 40 bit*/
+            data.KeyLength = 5;
+        else if(len <= 26) /*26 is number of character for key length 128 bit*/
+            data.KeyLength = 13;
+        else if(len <= 58) /*58 is number of character for key length 256 bit*/
+            data.KeyLength = 29;
+        else {
+                console_printf_terminal("**Error key length\n" );
+                return;
+        }
+
+        for( i=0; *buf && i < data.KeyLength; i++ )
+        {
+                val = char_2_hexa(*buf);
+                if( val == (U32) -1 )
+                    return;
+
+                val_l = char_2_hexa(*(++buf));
+                if( val_l == (U32) -1 )
+                    return;
+
+                data.KeyMaterial[i] = (tiUINT8)((val << 4) | val_l);
+                buf++;
+        }
+    }
+    else        /* for ascii key */
+    {
+        if(len <= 5) /*10 is number of character for key length 40 bit*/
+            data.KeyLength = 5;
+        else if(len <= 13) /*26 is number of character for key length 128 bit*/
+            data.KeyLength = 13;
+        else if(len <= 29) /*58 is number of character for key length 256 bit*/
+            data.KeyLength = 29;
+        else {
+                console_printf_terminal("**Error key length\n" );
+                return;
+        }
+        memcpy(data.KeyMaterial, buf, len );
+    }
+
+    data.KeyIndex = def_flag | key_id;
+    data.Length = sizeof(OS_802_11_WEP);
+
+#ifdef DEBUG_MESSAGES
+    console_printf_terminal("cmd_privacy_addkey len = %d, type: %s\nkey:", data.KeyLength, is_hex_key ? "hex" : "text");
+    for(i=0; i<SIZE_ARR(data.KeyMaterial); i++ )
+        console_printf_terminal("%02x", (U32) data.KeyMaterial[i]);
+    console_printf_terminal("\n");
+#endif /*DEBUG_MESSAGES */
+    TI_AddWEPKey(g_id_adapter, &data);
+}
+
+
+void cmd_privacy_removekey(ConParm_t parm[], U16 nParms)
+{
+    TI_RemoveWEPKey(g_id_adapter, (U32) parm[0].value );
+}
+
+void cmd_privacy_key_type(ConParm_t parm[], U16 nParms)
+{
+
+   if( nParms )
+        {
+        TI_SetKeyType( g_id_adapter, (OS_802_11_KEY_TYPES)parm[0].value );
+        console_printf_terminal("CLI-: KeyType - %x\n",(tiUINT32)parm[0].value);
+        }
+    else
+    {
+        static named_value_t key_type[] = {
+            { OS_KEY_TYPE_STATIC,             "STATIC" },
+            { OS_KEY_TYPE_DYNAMIC,            "DYNAMIC"}
+        };
+
+        print_available_values(key_type);
+    }
+
+}
+void cmd_privacy_mixed_mode(ConParm_t parm[], U16 nParms)
+{
+    tiBOOL data;
+
+    if( nParms == 0 )
+    {
+       console_printf_terminal("Mixed Mode: 0 - FALSE, 1 - TRUE\n");
+       data = FALSE;
+       if( !TI_GetMixedMode(g_id_adapter, &data ) );
+            console_printf_terminal("Mixed Mode =%s\n", data ? "True" : "False" );
+
+    }
+    else    /* param <read-only!!> */
+        TI_SetMixedMode(g_id_adapter, (BOOL) parm[0].value);
+}
+
+
+/************** Roaming Manager functions  ******************/
+void cmd_Roaming_enable(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    roamingMngrConfigParams.roamingMngrConfig.enableDisable = ROAMING_ENABLED;
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Roaming is enabled \n");
+}
+
+
+void cmd_Roaming_disable(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    roamingMngrConfigParams.roamingMngrConfig.enableDisable = ROAMING_DISABLED;
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Roaming is disabled \n");
+}
+void cmd_Roaming_lowPassFilter(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt = (UINT16) parm[0].value;
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Time in sec to wait before low quality Roaming Triggers, \n lowPassFilterRoamingAttempt = %d sec\n",
+           roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt);
+}
+
+void cmd_Roaming_qualityIndicator(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold = (S8) parm[0].value;
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Quality indicator (RSSI) to be used when comparing AP List matching quality, \n apQualityThreshold = %d \n",
+           (roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold));
+}
+
+
+void cmd_Roaming_dataRetryThreshold(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold = (UINT8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("dataRetryThreshold = %d \n",
+           roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold);
+
+}
+void cmd_Roaming_numExpectedTbttForBSSLoss(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss =  (UINT8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Number of expected TBTTs for BSS Loss event, \n numExpectedTbttForBSSLoss = %d \n",
+           roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss);
+
+}
+void cmd_Roaming_txRateThreshold(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold =  (UINT8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("txRateThreshold = %d \n",
+           roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold);
+
+}
+void cmd_Roaming_lowRssiThreshold(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold =  (S8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("lowRssiThreshold = %d \n",
+           (roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold));
+
+}
+void cmd_Roaming_lowSnrThreshold(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold =  (S8)parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("lowSnrThreshold = %d \n", roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold);
+}
+void cmd_Roaming_lowQualityForBackgroungScanCondition(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition = (S8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Indicator used to increase the background scan period when quality is low, \n lowQualityForBackgroungScanCondition = %d \n",
+           (roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition));
+
+}
+void cmd_Roaming_normalQualityForBackgroungScanCondition(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition = (S8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Indicator used to reduce the background scan period when quality is normal, \n normalQualityForBackgroungScanCondition = %d \n",
+           (roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition));
+
+}
+
+void cmd_Roaming_rssiFilterWeight(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.rssiFilterWeight =  (UINT8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Rssi Filter Weight = %d \n",
+           (roamingMngrConfigParams.roamingMngrThresholdsConfig.rssiFilterWeight));
+}
+
+void cmd_Roaming_snrFilterWeight(ConParm_t parm[], U16 nParms)
+{
+    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    if( nParms != 0 )
+    {
+        roamingMngrConfigParams.roamingMngrThresholdsConfig.snrFilterWeight =  (UINT8) parm[0].value;
+
+    }
+    TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+    console_printf_terminal("Snr FIlter Weight = %d \n",
+           (roamingMngrConfigParams.roamingMngrThresholdsConfig.snrFilterWeight));
+}
+
+void cmd_Roaming_getConfParams(ConParm_t parm[], U16 nParms)
+{
+   TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
+
+   console_printf_terminal("Roaming is: %s \n", roamingMngrConfigParams.roamingMngrConfig.enableDisable ? "Enabled" : "Disabled");
+   console_printf_terminal("lowPassFilterRoamingAttempt = %d sec, apQualityThreshold = %d\n",
+          roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt,
+                 roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold);
+   console_printf_terminal("Roaming Triggers' thresholds are: \n");
+   console_printf_terminal("dataRetryThreshold = %d, lowQualityForBackgroungScanCondition = %d, \
+lowRssiThreshold = %d, lowSnrThreshold = %d, normalQualityForBackgroungScanCondition = %d, \
+numExpectedTbttForBSSLoss = %d, txRateThreshold = %d \n",
+          roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold,
+                 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition,
+                 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold,
+          roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold,
+                 roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition,
+          roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss,
+          roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold);
+   console_printf_terminal("RSSI / SNR filter weights are: \n");
+   console_printf_terminal("RSSI filter weight = %d, SNR filter weight = %d\n ",
+               roamingMngrConfigParams.roamingMngrThresholdsConfig.rssiFilterWeight,
+               roamingMngrConfigParams.roamingMngrThresholdsConfig.snrFilterWeight);
+}
+
+
+void cmd_bt_coe_enable(ConParm_t parm[], U16 nParms)
+{
+    if( nParms == 0 )
+    {
+        console_printf_terminal("Please enter enable value:\n");
+        console_printf_terminal("0 - Enable\n");
+        console_printf_terminal("1 - Disable\n");
+        console_printf_terminal("2 - Auto\n");
+    }
+    else
+    {
+        TI_SetBtCoeEnable(g_id_adapter, parm[0].value);
+    }
+}
+
+
+void cmd_bt_coe_rate(ConParm_t parm[], U16 nParms)
+{
+    U8 Values[NUM_OF_RATES_IN_SG];
+    U8 Index;
+    if( nParms != NUM_OF_RATES_IN_SG )
+    {
+               console_printf_terminal("0 - 1Mbps (not recommended)\n");
+               console_printf_terminal("1 - 2Mbps (not recommended)\n");
+               console_printf_terminal("2 - 5.5Mbps\n");
+               console_printf_terminal("3 - 6Mbps\n");
+               console_printf_terminal("4 - 9Mbps\n");
+               console_printf_terminal("5 - 11Mbps\n");
+               console_printf_terminal("6 - 12Mbps\n");
+               console_printf_terminal("7 - 18Mbps\n");
+               console_printf_terminal("8 - 22Mbps (not in use)\n");
+               console_printf_terminal("9 - 24Mbps\n");
+               console_printf_terminal("10 - 36Mbps\n");
+               console_printf_terminal("11 - 48Mbps\n");
+               console_printf_terminal("12 - 54Mbps\n");
+    }
+    else
+    {
+        for (Index = 0; Index < NUM_OF_RATES_IN_SG; Index++ )
+        {
+                       Values[Index] = (U8)parm[Index].value;  //TRS:MEB use cast to fix compile warning
+        }
+        TI_SetBtCoeRate(g_id_adapter, Values);
+    }
+}
+
+
+void cmd_bt_coe_config(ConParm_t parm[], U16 nParms)
+{
+    U32 Values[NUM_OF_CONFIG_PARAMS_IN_SG];
+    U8 Index = 0;
+
+    if( nParms != NUM_OF_CONFIG_PARAMS_IN_SG )
+    {
+        console_printf_terminal("Please enter valid config values:\n");
+
+               console_printf_terminal("Param %d - wlanRxMinRateToRespectBtHp (0 - all,2,5,6,9,11,12,18,22,24,36,48,54)  \n",Index++);
+        console_printf_terminal("Param %d - btHpMaxTime (100 - 15000)\n",Index++);
+        console_printf_terminal("Param %d - wlanHpMaxTime (100 - 15000)\n",Index++);
+        console_printf_terminal("Param %d - senseDisableTimer (100 - 15000)\n",Index++);
+        console_printf_terminal("Param %d - protectiveRxTimeBeforeBtHp (10 - 2300)\n",Index++);
+        console_printf_terminal("Param %d - protectiveTxTimeBeforeBtHp (10 - 2300)\n",Index++);
+        console_printf_terminal("Param %d - protectiveRxTimeBeforeBtHpFastAp (10 - 20000)\n",Index++);
+        console_printf_terminal("Param %d - protectiveTxTimeBeforeBtHpFastAp (10 - 20000)\n",Index++);
+        console_printf_terminal("Param %d - protectiveWlanCycleTimeForFastAp (2000 - 65535)\n",Index++);
+        console_printf_terminal("Param %d - btAntiStarvationPeriod (0 - 15000) \n",Index++);
+        console_printf_terminal("Param %d - timeoutNextBtLpPacket (400 - 10000)\n",Index++);
+               console_printf_terminal("Param %d - wakeUpTimeBeforeBeacon   (0 - 20000)  \n",Index++);
+               console_printf_terminal("Param %d - hpdmMaxGuardTime   (0 - 50000)  \n",Index++);
+               console_printf_terminal("Param %d - timeoutNextWlanPacket   (100 - 50000)  \n",Index++);
+        console_printf_terminal("Param %d - sgAntennaType (0 - Single | 1 - Dual | 2 - Single+ )\n",Index++);
+        console_printf_terminal("Param %d - signalingType (0 - Legacy | 1 - Palau | 2 - Other)\n",Index++);
+        console_printf_terminal("Param %d - afhLeverageOn (0 - OFF | 1 - GPIO  | 2 - ON)\n",Index++);
+        console_printf_terminal("Param %d - numberQuietCycle (0 - 10)\n",Index++);
+        console_printf_terminal("Param %d - maxNumCts (0 - 10)\n",Index++);
+        console_printf_terminal("Param %d - numberOfWlanPackets (1 - 10)\n",Index++);
+        console_printf_terminal("Param %d - numberOfBtPackets (2 - 10)\n",Index++);
+        console_printf_terminal("Param %d - numberOfMissedRxForAvalancheTrigger (1 - 255)\n",Index++);
+        console_printf_terminal("Param %d - wlanElpHpSupport (0 - 1)\n",Index++);
+        console_printf_terminal("Param %d - btAntiStarvationNumberOfCyclesWithinThePeriod (0 - 15)  \n",Index++);
+        console_printf_terminal("Param %d - ackModeDuringBtLpInDualAnt (0 - 1)  \n",Index++);
+        console_printf_terminal("Param %d - allowPaSdToggleDuringBtActivityEnable (0 - 1)  \n",Index++);
+               console_printf_terminal("Param %d - sgAutoModeNoCts   (0 - 1)  \n",Index++);
+               console_printf_terminal("Param %d - numOfBtHpRespectedReq   (0 - 20)  \n",Index++);
+   }
+   else
+    {
+        for (Index = 0; Index < NUM_OF_CONFIG_PARAMS_IN_SG; Index++ )
+        {
+            Values[Index] = parm[Index].value;
+        }
+
+               if ( ( (is_value_rate(Values[0])) && (Values[0] != 1) ) || (Values[0] == 0) )
+               {
+                       TI_SetBtCoeConfig(g_id_adapter, (tiUINT32 *)Values);
+               }
+               else
+               {
+                       console_printf_terminal("Error: Param 26 - wlanRxMinRateToRespectBtHp (0 - all,2,5,6,9,11,12,18,22,24,36,48,54)  \n");
+               }
+    }
+}
+
+
+void cmd_bt_coe_get_status(ConParm_t parm[], U16 nParms)
+{
+    U32 Values[NUM_OF_STATUS_PARAMS_IN_SG];
+    /* The print is done inside the module */
+    console_printf_terminal("Done by driver - ");        
+    if( TI_SetBtCoeGetStatus(g_id_adapter,(tiUINT32 *) Values) == OK ) {
+        console_printf_terminal("Ok\n");
+/*      console_printf_terminal("BT Coxistence status: \n\n");
+        console_printf_terminal("Enable: %d\n", Values[0]);
+        console_printf_terminal("Rate: %d\n", Values[1]);
+        console_printf_terminal("BtSignaling: %d\n", Values[2]);
+        console_printf_terminal("BtHPMaxTime: %d\n", Values[3]);
+        console_printf_terminal("WlanHPMaxTime: %d\n", Values[4]);
+        console_printf_terminal("WlanEOSMaxPacket: %d\n", Values[5]);
+        console_printf_terminal("WlanEOSMaxPacketTimeOut: %d\n", Values[6]);
+        console_printf_terminal("BtPTAMaxPacket: %d\n", Values[7]);
+        console_printf_terminal("BtPTAMaxPacketTimeOut: %d\n", Values[8]);
+        console_printf_terminal("WlanSlowAPSocial: %d\n", Values[9]);
+        console_printf_terminal("WlanSlowAPMaxCTS: %d\n", Values[10]);
+        console_printf_terminal("WlanSlowAPMaxTimeToCTS: %d\n", Values[11]);
+        console_printf_terminal("T8_temporary: %d\n", Values[12]);
+        console_printf_terminal("BTtoWLANSwitchTime: %d\n", Values[13]); */
+    }
+    else
+    {
+        console_printf_terminal("Fail\n");    
+/*      console_printf_terminal("Error reading status!\n"); */
+    }
+}
+
+
+void cmd_PLT_RxPerStart(ConParm_t parm[], U16 nParms)
+{
+       UINT32 Status = TI_PLT_RxPerStart(g_id_adapter);
+       if (Status == OK)
+               console_printf_terminal("Plt RX counters started\n");
+       else
+               console_printf_terminal("Plt RX counters start failed\n");
+}
+
+void cmd_PLT_RxPerStop(ConParm_t parm[], U16 nParms)
+{
+       UINT32 Status = TI_PLT_RxPerStop(g_id_adapter);
+       if (Status == OK)
+               console_printf_terminal("Plt RX counters stoped\n");
+       else
+               console_printf_terminal("Plt RX counters stop failed\n");
+}
+
+void cmd_PLT_RxPerClear(ConParm_t parm[], U16 nParms)
+{
+       UINT32 Status = TI_PLT_RxPerClear(g_id_adapter);
+       if (Status == OK)
+               console_printf_terminal("Plt RX counters cleard\n");
+       else
+               console_printf_terminal("Plt RX counters clear failed\n");
+}
+
+void cmd_PLT_RxPerGet(ConParm_t parm[], U16 nParms)
+{
+       PltRxPer_t PltRxPer;
+       UINT32 Status = TI_PLT_RxPerGetResults(g_id_adapter, &PltRxPer);
+
+       if (Status == OK)
+       {
+               console_printf_terminal("FCSErrorCount = %d\n", PltRxPer.FCSErrorCount);
+               console_printf_terminal("PLCPErrorCount  = %d\n", PltRxPer.PLCPErrorCount);
+        console_printf_terminal("SeqNumMissCount = %d\n", PltRxPer.SeqNumMissCount);
+               console_printf_terminal("TotalFrameCount = %d\n", PltRxPer.TotalFrameCount);
+       }
+       else
+               console_printf_terminal("Plt RX counters Get results failed\n");
+}
+
+void cmd_PLT_RegisterRead(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 RegAddress;
+    tiUINT32 RegValue;
+    tiUINT32 Status;
+    char* pTmp;
+
+    /* Converting hex string to tiUINT32*/
+    pTmp = (char*)parm[0].value;
+    sscanf(pTmp , "%x", &RegAddress);
+
+    /*Call the API function */
+    Status = TI_PLT_ReadRegister(g_id_adapter, RegAddress, &RegValue);
+    if( Status == OK )
+        console_printf_terminal("Reg. %#lx = %#x (%d)\n", RegAddress, RegValue, RegValue );
+}
+
+void cmd_PLT_RegisterWrite(ConParm_t parm[], U16 nParms)
+{
+    tiUINT32 RegAddress;
+    tiUINT32 RegValue = 0;
+    tiUINT32 Status;
+    char* pTmp;
+
+    /* Converting hex string to tiUINT32*/
+    printf("cmd_PLT_RegisterWrite\n");
+    pTmp = (char*)parm[0].value;
+    sscanf(pTmp, "%x", &RegAddress);
+    pTmp = (char*)parm[1].value;
+    sscanf(pTmp , "%x", &RegValue);
+    printf("cmd_PLT_RegisterWrite %x %x\n", RegAddress, RegValue);
+
+    /*Call the API function */
+    Status = TI_PLT_WriteRegister(g_id_adapter, RegAddress, RegValue );
+    if (Status == OK)
+        console_printf_terminal("Plt register 0x%x is set to 0x%x OK.\n", RegAddress, RegValue);
+    else
+        console_printf_terminal("Plt register 0x%x is set to 0x%x NOK.\n", RegAddress, RegValue);
+
+}
+
+
+void cmd_PLT_TxContinues(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   PltTxContinues_t PltTxContinues;
+   if ((nParms == 0) || (nParms > 10))
+   {
+      console_printf_terminal("\n");
+         console_printf_terminal("Param 0 - Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz))\n");
+         console_printf_terminal("Param 1 - Channel: (1..14(2.4Ghz), 1..180(5Ghz)) \n");
+         console_printf_terminal("Param 2 - Rate: \n");
+      console_printf_terminal("                1  - 1Mbps\n");
+      console_printf_terminal("                2  - 2Mbps\n");
+      console_printf_terminal("                3  - 5.5Mbps\n");
+      console_printf_terminal("                4  - 11Mbps\n");
+      console_printf_terminal("                6  - 6Mbps\n");
+      console_printf_terminal("                7  - 9Mbps\n");
+      console_printf_terminal("                8  - 12Mbps\n");
+      console_printf_terminal("                9  - 18Mbps\n");
+      console_printf_terminal("                10 - 24Mbps\n");
+      console_printf_terminal("                11 - 36Mbps\n");
+      console_printf_terminal("                12 - 48Mbps\n");
+      console_printf_terminal("                13 - 54Mbps \n");
+         console_printf_terminal("Param 3 - preamble (0-long, 1-short)\n");
+         console_printf_terminal("Param 4 - Delay between packets (uSec)\n");
+      console_printf_terminal("Param 5 - Number of TX frames (0 - endless)\n");
+      console_printf_terminal("Param 6 - Test mode (5-Random data, 9-ZOZO(0,1,0,1,...))\n");
+      console_printf_terminal("Param 7 - Sequance number mode(0 - fixed, 1 - incremented)\n");
+      console_printf_terminal("Param 8 - packet Data legth [bytes] (0 - 2284)\n");
+      console_printf_terminal("Param 9 - peer mac address: [xx:xx:xx:xx:xx:xx]\n");
+
+   }
+   else
+   {
+          PltTxContinues.band              = (UINT8) parm[0].value;
+          PltTxContinues.chID                  = parm[1].value;
+          PltTxContinues.rate                  = parm[2].value;
+          PltTxContinues.preamble              = (UINT8) parm[3].value;
+          PltTxContinues.InterPacketDelay  = parm[4].value;
+       PltTxContinues.NumOfFrames       = parm[5].value;
+          PltTxContinues.mode              = (UINT8) parm[6].value;
+       PltTxContinues.aSeqNumMode       = parm[7].value;
+       PltTxContinues.aPacketLength     = parm[8].value;
+       hexStr2MACAddr( (char*)parm[9].value, &(PltTxContinues.aPeerMacAddr) );
+
+
+          Status = TI_PLT_TxContiues(g_id_adapter, &PltTxContinues);
+               if (Status == OK)
+                       console_printf_terminal("OK\n");
+               else
+                       console_printf_terminal("NOK\n");
+
+   }
+}
+
+void cmd_PLT_TxCW(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   TestCmdChannelBand_t PltTxCW;
+
+   if ((nParms == 0) || (nParms > 2))
+   {
+         console_printf_terminal("Param 0 - Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz))\n");
+         console_printf_terminal("Param 1 - Channel(1..14(2.4Ghz), 1..180(5Ghz))\n");
+   }
+   else
+   {
+          PltTxCW.band         = (RadioBand_e) parm[0].value;
+          PltTxCW.channel      = (Channel_e) parm[1].value;
+
+          Status = TI_PLT_TxCW(g_id_adapter, &PltTxCW);
+               if (Status == OK)
+                       console_printf_terminal("OK\n");
+               else
+                       console_printf_terminal("NOK\n");
+
+   }
+}
+
+void cmd_PLT_TxStop(ConParm_t parm[], U16 nParms)
+{
+       UINT32 Status = TI_PLT_TxStop(g_id_adapter);
+       if (Status == OK)
+               console_printf_terminal("OK\n");
+       else
+               console_printf_terminal("NOK\n");
+}
+
+void cmd_PLT_MIB_CounterTable(ConParm_t parm[], U16 nParms)
+{
+    PLT_MIB_t Mib;
+    UINT32 Status;
+    memset(&Mib, 0, sizeof(Mib));
+    Mib.aMib = PLT_MIB_countersTable;
+
+    Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
+    if (Status == OK)
+    {
+       console_printf_terminal("FCS error count= %d \nPLCP  error count = %d\n",
+                                                          Mib.aData.CounterTable.FCSErrorCount,
+                                                          Mib.aData.CounterTable.PLCPErrorCount);
+    }
+    else
+    {
+               console_printf_terminal("NOK\n");
+    }
+}
+
+void cmd_PLT_MIB_StationID(ConParm_t parm[], U16 nParms)
+{
+    PLT_MIB_t Mib;
+    UINT32 Status;
+    memset(&Mib, 0, sizeof(Mib));
+    Mib.aMib = PLT_MIB_dot11StationId;
+
+    Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
+    if (Status == OK)
+    {
+       console_printf_terminal("MIB_StationID = %02x:%02x:%02x:%02x:%02x:%02x\n",
+                                Mib.aData.StationId.addr[5],
+                                Mib.aData.StationId.addr[4],
+                                Mib.aData.StationId.addr[3],
+                                Mib.aData.StationId.addr[2],
+                                Mib.aData.StationId.addr[1],
+                                Mib.aData.StationId.addr[0]);
+    }
+    else
+    {
+               console_printf_terminal("NOK\n");
+    }
+
+
+}
+
+
+void cmd_modify_ctsToSelf(ConParm_t parm[], U16 nParms)
+{
+    PLT_MIB_t Mib;
+    UINT32 Status;
+    memset(&Mib, 0, sizeof(Mib));
+    Mib.aMib = PLT_MIB_ctsToSelf;
+
+       if (nParms != 1)
+       {
+          console_printf_terminal("CTS to self: [0 - Disable, 1 - Enable]\n");
+       }
+
+       if (nParms == 0) /*Get ctsToSelf */
+    {
+        Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
+        if (OK == Status)
+            console_printf_terminal("ctsToSelf = %s (%d)\n",
+            Mib.aData.CTSToSelfEnable?"Enable":"Disable",
+            Mib.aData.CTSToSelfEnable);
+    }
+    else if (nParms == 1)
+    {
+        Mib.Length = sizeof(Mib.aData.CTSToSelfEnable);
+        Mib.aData.CTSToSelfEnable = parm[0].value;
+        if (OK != TI_PLT_WriteMIB(g_id_adapter, &Mib))
+            console_printf_terminal("TI_PLT_WriteMIB failed\n");
+    }
+}
+
+void cmd_get_arpIpTable(ConParm_t parm[], U16 nParms)
+{
+    PLT_MIB_t Mib;
+    UINT32 Status;
+    memset(&Mib, 0, sizeof(Mib));
+    Mib.aMib = PLT_MIB_arpIpAddressesTable;
+    Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
+    if (OK == Status)
+    {
+       int FilteringEnable = Mib.aData.ArpIpAddressesTable.FilteringEnable;
+       console_printf_terminal("ARP IP Table:\n");
+       console_printf_terminal("FilteringEnable: %s (%d)\n",
+           FilteringEnable?"Enable":"Disable",
+           FilteringEnable);
+       console_printf_terminal("ArpIpAddress: %d.%d.%d.%d\n",
+           Mib.aData.ArpIpAddressesTable.addr[0],
+           Mib.aData.ArpIpAddressesTable.addr[1],
+           Mib.aData.ArpIpAddressesTable.addr[2],
+           Mib.aData.ArpIpAddressesTable.addr[3]
+           );
+    }
+}
+
+void cmd_get_GroupAddressTable(ConParm_t parm[], U16 nParms)
+{
+    PLT_MIB_t Mib;
+    UINT32 Status;
+    memset(&Mib, 0, sizeof(Mib));
+    Mib.aMib = PLT_MIB_dot11GroupAddressesTable;
+    Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
+    if (OK == Status)
+    {
+       int FilteringEnable = Mib.aData.GroupAddressTable.bFilteringEnable;
+       int i;
+
+       console_printf_terminal("Group addresses Table:\n");
+       console_printf_terminal("FilteringEnable: %s (%d)\n",
+           FilteringEnable?"Enable":"Disable",
+           FilteringEnable);
+       console_printf_terminal("nNumberOfAddresses: %d\n", Mib.aData.GroupAddressTable.nNumberOfAddresses);
+       console_printf_terminal("Group addresses: \n");
+
+       for (i=0; i<Mib.aData.GroupAddressTable.nNumberOfAddresses; i++)
+       console_printf_terminal("%x:%x:%x:%x:%x:%x\n",
+           Mib.aData.GroupAddressTable.GroupTable[i].addr[0],
+           Mib.aData.GroupAddressTable.GroupTable[i].addr[1],
+           Mib.aData.GroupAddressTable.GroupTable[i].addr[2],
+           Mib.aData.GroupAddressTable.GroupTable[i].addr[3],
+           Mib.aData.GroupAddressTable.GroupTable[i].addr[4],
+           Mib.aData.GroupAddressTable.GroupTable[i].addr[5]
+           );
+    }
+}
+
+void cmd_PLT_TxCalGainGet(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   PltGainGet_t PLTGainGet;
+
+   Status = TI_PLT_TxCalGainGet(g_id_adapter, &PLTGainGet);
+   if (Status == OK)
+   {
+       console_printf_terminal("\n");
+       console_printf_terminal("TxGain: %d(0x%x)\n", PLTGainGet.TxGain, PLTGainGet.TxGain);
+       console_printf_terminal("TxUpperBound: %d(0x%x)\n", PLTGainGet.TxUpperBound, PLTGainGet.TxUpperBound);
+       console_printf_terminal("TxLowerBound: %d(0x%x)\n", PLTGainGet.TxLowerBound, PLTGainGet.TxLowerBound);
+   }
+   else
+       console_printf_terminal("NOK\n");
+}
+
+
+void cmd_PLT_TxCalGainAdjust(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   UINT32 GainChange;
+   OS_802_11_POWER_LEVELS mode;
+
+
+   if ((nParms == 0) || (nParms > 1))
+   {
+          console_printf_terminal("\n");
+       console_printf_terminal("Param 0 - Gain change (db)\n");
+   }
+   else
+   {
+       GainChange = parm[0].value;
+
+        /* Check Power mode (works only in "awake" mode !!!) */
+        TI_GetPowerLevelDefault(g_id_adapter, &mode );
+        if(mode == OS_POWER_LEVEL_AWAKE)
+        {
+          Status = TI_PLT_TxCalGainAdjust(g_id_adapter, GainChange);
+                   if (Status == OK)
+                           console_printf_terminal("OK\n");
+                   else
+                           console_printf_terminal("NOK\n");
+        }
+        else
+        {
+               console_printf_terminal("Gain Adjust was not performed becouse Default power-mode is not AWAKE\n");
+               console_printf_terminal("Please change defaultPowerLevel parametr in tiwlan.ini file first\n");
+        }
+   }
+}
+
+void cmd_PLT_TxCalStart(ConParm_t parm[], U16 nParms)
+{
+       UINT32 Status;
+          PltTxCalibrationRequest_t tTxStart;
+
+          if (nParms != 1)
+          {
+                  console_printf_terminal("\nParam 0 - Tx Power [0-255]\n");
+          }
+          else
+          {
+        /* use U8 cast to fix compile warning */
+                  tTxStart.refTxPower = (U8)parm[0].value;
+                  Status = TI_PLT_TxCalStart(g_id_adapter,&tTxStart);
+                  if (Status == OK)
+                          console_printf_terminal("OK\n");
+                  else
+                          console_printf_terminal("NOK\n");
+          }
+}
+
+void cmd_PLT_TxCalStop(ConParm_t parm[], U16 nParms)
+{
+       UINT32 Status;
+
+          Status = TI_PLT_TxCalStop(g_id_adapter);
+       if (Status == OK)
+           console_printf_terminal("OK\n");
+       else
+           console_printf_terminal("NOK\n");
+}
+
+void cmd_PLT_RxTxCalNVSUpdateBuffer(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   PltNvsResultsBuffer_t PltNvsResultsBuffer;
+   int i;
+
+   memset(&PltNvsResultsBuffer, 0, sizeof(PltNvsResultsBuffer));
+   Status = TI_PLT_RxTxCalNVSUpdateBuffer(g_id_adapter, &PltNvsResultsBuffer);
+   if (Status == OK)
+   {
+       console_printf_terminal("NVSUpdateBuffer -  number of tables:%d\n", PltNvsResultsBuffer.numOfTables);
+       console_printf_terminal("# \t Offset\t Size\t Data\n");
+       console_printf_terminal("###################################################################\n");
+       for (i=0; (i<PltNvsResultsBuffer.numOfTables) && (i<NVS_RESULTS_MAX_NUM_OF_TABLES); i++)
+       {
+        int j;
+        console_printf_terminal("#%d\t %p\t %.4d\t ",
+                                i,
+                                PltNvsResultsBuffer.tables[i].offset,
+                                PltNvsResultsBuffer.tables[i].size);
+        for (j=0; (j<PltNvsResultsBuffer.tables[i].size) && (j<NVS_RESULTS_MAX_UPDATE_TABLE_SIZE); j++)
+        {
+            console_printf_terminal("%.2x ", PltNvsResultsBuffer.tables[i].data[j]);
+        }
+        console_printf_terminal("\n");
+       }
+   }
+   else
+       console_printf_terminal("NOK\n");
+}
+
+void cmd_PLT_RxCal(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   PltRxCalibrationRequest_t PltRxCalibrationRequest;
+   OS_802_11_POWER_LEVELS mode;
+
+   if ((nParms == 0) || (nParms > 5))
+   {
+      console_printf_terminal("\n");
+         console_printf_terminal("Param 0 - Expected Rssi (db)\n");
+         console_printf_terminal("Param 1 - Channel\n");
+         console_printf_terminal("Param 2 - Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz)\n");
+      console_printf_terminal("Param 3 - Interval between samples(uSec) [100]\n");
+      console_printf_terminal("Param 4 - Number of samples [1000]\n");
+   }
+   else
+   {
+          PltRxCalibrationRequest.expectedRssi = parm[0].value;
+          PltRxCalibrationRequest.channel = (UINT8)parm[1].value;
+          PltRxCalibrationRequest.band = (UINT8)parm[2].value;
+       PltRxCalibrationRequest.intervalBetweenSamplesUsec = parm[3].value;
+       PltRxCalibrationRequest.numOfSamples = (UINT16)parm[4].value;
+
+        /* Check Power mode (works only in "awake" mode !!!) */
+        TI_GetPowerLevelDefault(g_id_adapter, &mode );
+        if(mode == OS_POWER_LEVEL_AWAKE)
+        {
+               Status = TI_PLT_RxCal(g_id_adapter, &PltRxCalibrationRequest);
+               if (Status == OK)
+                       console_printf_terminal("OK\n");
+               else
+                       console_printf_terminal("NOK\n");
+        }
+        else
+        {
+               console_printf_terminal("Rx calibration was not performed becouse Default power-mode is not AWAKE\n");
+               console_printf_terminal("Please change defaultPowerLevel parametr in tiwlan.ini file first\n");
+        }
+   }
+}
+
+void cmd_PLT_RadioTune(ConParm_t parm[], U16 nParms)
+{
+   UINT32 Status;
+   TestCmdChannelBand_t ChannelBand;
+   OS_802_11_POWER_LEVELS mode;
+
+
+   if ((nParms == 0) || (nParms > 2))
+   {
+         console_printf_terminal("Param 0 - Band (0-2.4Ghz, 1-5Ghz, 2-4.9Ghz)\n");
+         console_printf_terminal("Param 1 - Channel\n");
+   }
+   else
+   {
+          ChannelBand.band     = (RadioBand_e) parm[0].value;
+          ChannelBand.channel  = (Channel_e) parm[1].value;
+
+           /* Check Power mode (works only in "awake" mode !!!) */
+        TI_GetPowerLevelDefault(g_id_adapter, &mode );
+               if(mode == OS_POWER_LEVEL_AWAKE)
+               {
+                       Status = TI_PLT_RadioTune(g_id_adapter, &ChannelBand);
+                       if (Status == OK)
+                               console_printf_terminal("OK\n");
+                       else
+                               console_printf_terminal("NOK\n");
+               }
+               else
+               {
+                       console_printf_terminal("Radio tune was not performed becouse Default power-mode is not AWAKE\n");
+                       console_printf_terminal("Please change defaultPowerLevel parametr in tiwlan.ini file first\n");
+               }
+       }
+}
+
+
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/cu_cmd.h b/sta_dk_4_0_4_32/CUDK/CLI/cu_cmd.h
new file mode 100644 (file)
index 0000000..66046f5
--- /dev/null
@@ -0,0 +1,279 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef CU_CMD_H
+#define CU_CMD_H
+
+#ifndef _WINDOWS
+#include <unistd.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/wireless.h>
+#endif /* __LINUX__ */
+
+#ifdef _WINDOWS
+#endif
+
+#include "paramOut.h"
+#include "scanMngrTypes.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "TI_AdapterEXC.h"
+#endif /*EXC_MODULE_INCLUDED*/
+
+#include "TI_AdapterApiC.h"
+
+#include "console.h"
+
+#ifndef _WINDOWS
+#define stricmp strcasecmp
+#endif
+
+#ifdef EXC_MODULE_INCLUDED
+# include "cu_cmd_exc.h"
+#else
+# define INCLUDE_EXC_TYPE_NAMES
+#endif
+
+extern scan_Params_t appScanParams;
+
+void init_scan_params(void);
+
+void cmd_show_status(ConParm_t parm[], U16 nParms);
+void cmd_show_site_table(ConParm_t parm[], U16 nParms);
+void cmd_connect(ConParm_t parm[], U16 nParms);
+void cmd_disassociate(ConParm_t parm[], U16 nParms);
+void cmd_show_advanced_params(ConParm_t parm[], U16 nParms);
+void cmd_show_statistics(ConParm_t parm[], U16 nParms);
+void cmd_show_tx_statistics(ConParm_t parm[], U16 nParms);
+void cmd_show_power_consumption_stats(ConParm_t parm[]);
+void cmd_show_about(ConParm_t parm[], U16 nParms);
+void cmd_modify_ssid(ConParm_t parm[], U16 nParms);
+void cmd_bssid_list(ConParm_t parm[], U16 nParms);
+void cmd_Full_bssid_list(ConParm_t parm[], U16 nParms);
+void cmd_FullPrimaryBbssid(ConParm_t parm[], U16 nParms);
+
+
+void cmd_Scan_Start(ConParm_t parm[], U16 nParms);
+void cmd_Scan_Stop(ConParm_t parm[], U16 nParms);
+void cmd_Scan_app_global_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_app_channel_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_app_clear(ConParm_t parm[], U16 nParms);
+void cmd_Scan_app_display(ConParm_t parm[], U16 nParms);
+
+void cmd_Scan_policy_global_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_band_global_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_band_channel_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_band_track_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_band_discover_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_band_immed_config(ConParm_t parm[], U16 nParms);
+void cmd_Scan_policy_display(ConParm_t parm[], U16 nParms);
+void cmd_Scan_print_band( int i );
+void cmd_Scan_print_method( scan_Method_t* scanMethod );
+void cmd_Scan_print_basic_method( scan_basicMethodParams_t* basicMethodParams );
+void cmd_Scan_print_triggered_method( scan_TidTriggeredMethodParams_t* triggeredMethodParams );
+void cmd_Scan_print_sps_method( scan_SPSMethodParams_t* spsMethodParams );
+void cmd_Scan_policy_clear(ConParm_t parm[], U16 nParms);
+void cmd_Scan_policy_store(ConParm_t parm[], U16 nParms);
+void cmd_Scan_get_bss_list(ConParm_t parm[], U16 nParms);
+
+void cmd_get_selected_bssid_info(ConParm_t parm[], U16 nParms);
+void cmd_get_driver_state(ConParm_t parm[], U16 nParms);
+
+void cmd_get_rsii_level(ConParm_t parm[], U16 nParms);
+void cmd_get_snr_ratio(ConParm_t parm[], U16 nParms);
+
+void cmd_set_clsfr_type (ConParm_t parm[], U16 nParms);
+void cmd_insert_clsfr_entry (ConParm_t parm[], U16 uParms);
+void cmd_remove_clsfr_entry (ConParm_t parm[], U16 uParms);
+
+void cmd_set_qos_params(ConParm_t parm[], U16 nParms);
+void cmd_set_dtag_to_ac_mapping_table(ConParm_t parm[], U16 nParms);
+void cmd_set_vad(ConParm_t parm[], U16 nParms);
+void cmd_config_tx_classifier(ConParm_t parm[], U16 nParms);
+void cmd_poll_ap_packets(ConParm_t parm[], U16 nParms);
+void cmd_set_rxTimeOut_params(ConParm_t parm[], U16 nParms);
+void cmd_enable_rx_data_filters(ConParm_t parm[], U16 nParms);
+void cmd_disable_rx_data_filters(ConParm_t parm[], U16 nParms);
+void cmd_get_rx_data_filters_statistics(ConParm_t parm[], U16 nParms);
+void cmd_add_rx_data_filter(ConParm_t parm[], U16 nParms);
+void cmd_remove_rx_data_filter(ConParm_t parm[], U16 nParms);
+void cmd_MaxRxLifetime_params(ConParm_t parm[], U16 nParms);
+
+void cmd_add_tspec(ConParm_t parm[], U16 nParms);
+void cmd_get_tspec_params(ConParm_t parm[], U16 nParms);
+void cmd_delete_tspec(ConParm_t parm[], U16 nParms);
+void cmd_get_ap_qos_params(ConParm_t parm[], U16 nParms);
+void cmd_get_ap_qos_capabilities(ConParm_t parm[], U16 nParms);
+void cmd_get_ac_status(ConParm_t parm[], U16 nParms);
+int  parseBssidIe(OS_802_11_BSSID_EX * bssid);
+void cmd_get_desired_ps_mode(ConParm_t parm[], U16 nParms);
+void cmd_medium_usage_threshold(ConParm_t parm[], U16 nParms);
+void cmd_phy_rate_threshold(ConParm_t parm[], U16 nParms);
+
+void cmd_traffic_intensity_threshold(ConParm_t parm[], U16 nParms);
+void cmd_enable_traffic_events(ConParm_t parm[], U16 nParms);
+void cmd_disable_traffic_events(ConParm_t parm[], U16 nParms);
+
+void cmd_events_config(ConParm_t parm[], U16 nParms);
+
+void cmd_show_regdomain_table(ConParm_t parm[], U16 nParms);
+/*void cmd_net_network_in_use(ConParm_t parm[], U16 nParms);         (not in use) */
+void cmd_net_current_regdomain(ConParm_t parm[], U16 nParms);
+void cmd_enableDisable_802_11d(ConParm_t parm[], U16 nParms);
+void cmd_enableDisable_802_11h(ConParm_t parm[], U16 nParms);
+void cmd_d_Country_2_4Ie(ConParm_t parm[], U16 nParms);
+void cmd_d_Country_5Ie(ConParm_t parm[], U16 nParms);
+void cmd_DFS_range(ConParm_t parm[], U16 nParms);
+
+
+
+void cmd_modify_channel(ConParm_t parm[], U16 nParms);
+void cmd_modify_rate(ConParm_t parm[], U16 nParms);
+void cmd_show_tx_power_level_table(ConParm_t parm[], U16 nParms);
+void cmd_tx_power_dbm(ConParm_t parm[], U16 nParms);
+void cmd_modify_frag_threshold(ConParm_t parm[], U16 nParms);
+void cmd_modify_rts_threshold(ConParm_t parm[], U16 nParms);
+void cmd_modify_preamble(ConParm_t parm[], U16 nParms);
+void cmd_modify_short_retry(ConParm_t parm[], U16 nParms);
+void cmd_modify_long_retry(ConParm_t parm[], U16 nParms);
+void cmd_modify_short_slot(ConParm_t parm[], U16 nParms);
+void cmd_modify_tx_antenna(ConParm_t parm[], U16 nParms);
+void cmd_modify_rx_antenna(ConParm_t parm[], U16 nParms);
+void cmd_modify_antenna_diversity(ConParm_t parm[], U16 nParms);
+
+void cmd_modify_4x_state(ConParm_t parm[], U16 nParms);
+void cmd_modify_ext_rates_ie(ConParm_t parm[], U16 nParms);
+void cmd_modify_supported_rates(ConParm_t parm[], U16 nParms);
+void cmd_modify_ctsToSelf(ConParm_t parm[], U16 nParms);
+
+
+void cmd_debug_level(ConParm_t parm[], U16 nParms);
+void cmd_hw_register(ConParm_t parm[], U16 nParms);
+void cmd_debug_driver_print(ConParm_t parm[], U16 nParms);
+void cmd_debug_buffer_put(ConParm_t parm[], U16 nParms);
+#ifdef DRIVER_PROFILING
+void cmd_profile_report(ConParm_t parm[], U16 nParms);
+void cmd_profile_cpu_estimator_command(ConParm_t parm[], U16 nParms);
+#endif
+
+void cmd_report_set(ConParm_t parm[], U16 nParms);
+void cmd_report_clear(ConParm_t parm[], U16 nParms);
+void cmd_report_add(ConParm_t parm[], U16 nParms);
+void cmd_report_severity_level(ConParm_t parm[], U16 nParms);
+void cmd_report_severity_table(ConParm_t parm[], U16 nParms);
+void cmd_report_os_dbg_state(ConParm_t parm[], U16 nParms);
+
+void cmd_modify_bss_type(ConParm_t parm[], U16 nParms);
+
+void cmd_init_driver(ConParm_t parm[], U16 nParms);
+void cmd_start_driver(ConParm_t parm[], U16 nParms);
+void cmd_stop_driver(ConParm_t parm[], U16 nParms);
+
+void cmd_privacy_auth(ConParm_t parm[], U16 nParms);
+void cmd_privacy_eap(ConParm_t parm[], U16 nParms);
+void cmd_privacy_encrypt(ConParm_t parm[], U16 nParms);
+void cmd_privacy_credent(ConParm_t parm[], U16 nParms);
+void cmd_privacy_PSKPassphrase(ConParm_t parm[], U16 nParms);
+void cmd_privacy_certificate(ConParm_t parm[], U16 nParms);
+void cmd_privacy_addkey(ConParm_t parm[], U16 nParms);
+void cmd_privacy_removekey(ConParm_t parm[], U16 nParms);
+void cmd_privacy_cckm(ConParm_t parm[], U16 nParms);
+void cmd_privacy_wpa_options(ConParm_t parm[], U16 nParms);
+void cmd_privacy_getdefaultkey(ConParm_t parm[], U16 nParms);
+
+void cmd_file_load(ConParm_t parm[], U16 nParms);
+
+void cmd_set_power_mode(ConParm_t parm[], U16 nParms);
+void cmd_set_PowerSave_PowerLevel(ConParm_t parm[], U16 nParms);
+void cmd_set_Default_PowerLevel(ConParm_t parm[], U16 nParms);
+void cmd_set_DozeModeInAutoPowerLevel(ConParm_t parm[], U16 nParms);
+void cmd_set_min_power_level_boundary(ConParm_t parm[], U16 nParms);
+
+void cmd_events_register(ConParm_t parm[], U16 nParms);
+void cmd_events_unregister(ConParm_t parm[], U16 nParms);
+
+void cmd_bt_coe_enable(ConParm_t parm[], U16 nParms);
+void cmd_bt_coe_rate(ConParm_t parm[], U16 nParms);
+void cmd_bt_coe_config(ConParm_t parm[], U16 nParms);
+void cmd_bt_coe_get_status(ConParm_t parm[], U16 nParms);
+
+void cmd_privacy_key_type(ConParm_t parm[], U16 nParms);
+void cmd_privacy_mixed_mode(ConParm_t parm[], U16 nParms);
+
+
+
+void cmd_Roaming_enable(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_disable(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_lowPassFilter(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_qualityIndicator(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_getConfParams(ConParm_t parm[], U16 nParms);
+
+void cmd_Roaming_dataRetryThreshold(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_numExpectedTbttForBSSLoss(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_txRateThreshold(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_lowSnrThreshold(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_lowRssiThreshold(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_lowQualityForBackgroungScanCondition(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_normalQualityForBackgroungScanCondition(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_rssiFilterWeight(ConParm_t parm[], U16 nParms);
+void cmd_Roaming_snrFilterWeight(ConParm_t parm[], U16 nParms);
+
+void cmd_Beacon_Filter_Set_Desired_State(ConParm_t parm[], U16 nParms);
+void cmd_Beacon_Filter_Get_Desired_State(ConParm_t parm[], U16 nParms);
+
+void cmd_PLT_RegisterRead(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RegisterWrite(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RxPerStart(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RxPerStop(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RxPerClear(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RxPerGet(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxCW(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxContinues(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxStop(ConParm_t parm[], U16 nParms);
+void cmd_PLT_MIB_CounterTable(ConParm_t parm[], U16 nParms);
+void cmd_PLT_MIB_StationID(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxCalGainGet(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxCalGainAdjust(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxCalStart(ConParm_t parm[], U16 nParms);
+void cmd_PLT_TxCalStop(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RxTxCalNVSUpdateBuffer(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RxCal(ConParm_t parm[], U16 nParms);
+void cmd_PLT_RadioTune(ConParm_t parm[], U16 nParms);
+void cmd_get_arpIpTable(ConParm_t parm[], U16 nParms);
+void cmd_get_GroupAddressTable(ConParm_t parm[], U16 nParms);
+
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+
+U8* str2MACAddr(char *str, U8 *mac);
+UINT8 Freq2Chan(UINT32 freq);
+unsigned int char_2_hexa( char c );
+
+#ifdef DEBUG
+# define CHK_NULL(p)    ((p)) ? (void) 0 : fprintf(stderr, "\nfailed: '%s', file %s, line %d\n", #p, __FILE__, __LINE__);
+# define CHK(p)        ((!p)) ? (void) 0 : fprintf(stderr, "\nfailed: '%s', file %s, line %d\n", #p, __FILE__, __LINE__);
+#else
+# define CHK(p)        (p)
+# define CHK_NULL(p)    (p)
+#endif
+
+#endif /* CU_CMD_H */
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c b/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.c
new file mode 100644 (file)
index 0000000..8e0d8e0
--- /dev/null
@@ -0,0 +1,254 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+/****************************************************************************************************/
+/*                                                                                                  */
+/*      MODULE:     dbg_module.c                                                                    */
+/*      PURPOSE:    Handle the debug messages                                                          */
+/*      Note:      This module is for LINUX compilation only!                                                                          */
+/*                                                                                                  */
+/****************************************************************************************************/
+
+
+#include <stdarg.h> 
+#include <unistd.h>
+#include <stdlib.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <stdarg.h>
+
+#include <sys/shm.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/resource.h>
+
+#include "ipc.h"
+#include "ticon.h"
+#include "console.h"
+#include "dbg_module.h"
+#include "eth_utils.h"
+#include "debug_module_ioctl.h"
+
+       /************/
+       /* Defines */
+       /**********/
+
+#define DEBUG_MODULE_BUFFER_SIZE       (255)
+
+       /*********************/
+       /* Global variables */
+       /*******************/
+
+int debug_module_dev_file = -1;
+int debug_module_process_pid = 0;
+
+       /********************************/
+       /* static functions prototypes */
+       /******************************/
+
+unsigned char file_exists(const char *file_name);
+
+       /**************/
+       /* Functions */
+       /************/
+
+/************************************************************************
+ *                        debug_module_init                                    *
+ ************************************************************************
+DESCRIPTION: Initialize the debug module user mode process
+
+  CONTEXT         : main process only!
+************************************************************************/
+void debug_module_init(void)
+{
+       int return_value;
+
+       /*********************************/
+       /* Create the debug device file */
+       /*******************************/
+
+       if (!file_exists("/dev/debug_msg_dev"))
+       {
+               /* Create the debug device file */
+               return_value = system("mknod /dev/debug_msg_dev c 254 0");
+       }
+       
+       debug_module_dev_file = open("/dev/debug_msg_dev", O_RDWR);
+       
+       if (debug_module_dev_file == -1)
+       {
+               console_printf_terminal("Debug module, error opening \"/dev/debug_msg_dev\"\n");
+
+               return;
+       }
+       
+       /* Create another instance of this process */
+       debug_module_process_pid = fork();
+       
+       if (debug_module_process_pid == 0)
+       {
+               /******************/
+               /* Child process */
+               /****************/
+               
+               unsigned char bytes_read;
+               unsigned char ioctl_return_size;
+               t_ioctol1_format ioctl_data;
+               unsigned char in_debug_buffer[DEBUG_MODULE_BUFFER_SIZE + 1];
+       
+               /* Set the priority of this process to the lowest */
+/*             setpriority(PRIO_PROCESS, getpid(), -20);*/
+               
+               console_printf_terminal("Debug module, Hello from child process (pid = %d).\n", getpid());
+               
+               /*******************************/
+               /* Prepare the ioctl's fields */
+               /*****************************/
+               
+               ioctl_data.return_size = &ioctl_return_size;
+               ioctl_data.buffer = (in_debug_buffer + 1);
+               ioctl_data.buffer_size = DEBUG_MODULE_BUFFER_SIZE;
+               
+               while (TRUE)
+               {
+                       /*console_printf_terminal("Debug module, before ioctl\n");*/
+                       
+                       /* Read data from device file - blocking command */
+                       return_value = ioctl(debug_module_dev_file, 10, &ioctl_data);
+                       
+                       /*console_printf_terminal("Debug module, after ioctl (%d)\n", return_value);*/
+                       
+                       if (return_value != -1)
+                       {
+                               bytes_read = ioctl_return_size;
+                               
+                               if (bytes_read > 0)
+                               {
+                                       /* Mark that this is log message */ 
+                                       in_debug_buffer[0] = 0;
+
+                                       /* Put '0' in the end of the string */
+                                       in_debug_buffer[bytes_read + 1] = 0;
+                                       
+                                       console_send_buffer_to_host(ETHERNET_UTILS_LOGGER_MODULE_ID, in_debug_buffer, (bytes_read + 1));
+                               }
+                       }
+                       else
+                       {
+                               console_printf_terminal("Debug module, error reading from device file.\n");
+                       }
+               }
+       }
+}
+
+/************************************************************************
+ *                        debug_module_deinit                           *
+ ************************************************************************
+DESCRIPTION: Deinitialize the debug module user mode process
+
+CONTEXT    : main process only!
+************************************************************************/
+void debug_module_deinit(void)
+{
+       if (debug_module_process_pid)
+       {
+               kill(debug_module_process_pid, SIGKILL);
+       }
+}
+
+/************************************************************************
+ *                        debug_module_get_queue_status                 *
+ ************************************************************************
+DESCRIPTION: Gets the status of the debug module queue 
+
+CONTEXT    : main process only!
+************************************************************************/
+
+struct q_report {
+       unsigned int q_size;
+       unsigned int q_used;
+       unsigned int q_overrun;
+};
+
+#define QUEUE_STATUS_LEN (12)
+void debug_module_get_queue_status(void)
+{
+       int return_value;
+       char status_result[QUEUE_STATUS_LEN + 1];
+       struct q_report report;
+
+       /* Read data from device file - blocking command */
+       return_value = ioctl(debug_module_dev_file, 11, &report);
+
+       if (return_value != -1)            
+       {
+               /* console_printf_terminal("Debug module, debug_module_get_queue_status. (size = %d, used = %d, overrun = %d)\n", report.q_size , report.q_used, report.q_overrun);  */
+
+               memcpy(status_result + 1, &report, sizeof(report));
+
+               /* Mark that this is report message */
+               status_result[0] = 1;
+
+               console_send_buffer_to_host(ETHERNET_UTILS_LOGGER_MODULE_ID, (tiUINT8*) status_result, QUEUE_STATUS_LEN + 1);
+       }
+       else
+       {
+               console_printf_terminal("Debug module, error reading from device file.\n");
+       }
+}
+
+/************************************************************************
+ *                        file_exists                                      *
+ ************************************************************************
+DESCRIPTION: Check if a specific file exists
+
+CONTEXT    : All process.
+
+Returns:     TRUE if the file exists (FALSE otherwise).
+************************************************************************/
+unsigned char file_exists(const char *file_name)
+{
+       int test_file;
+       tiBOOL result = FALSE;;
+
+       /* Try to open the file */
+       test_file = open(file_name, O_RDONLY);
+
+       if (test_file != -1)
+       {
+               /*************************************************/
+               /* The file was successfullu opened - it exists */
+               /***********************************************/
+
+               close(test_file);
+
+               result = TRUE;
+       }
+
+       return result;
+}
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.h b/sta_dk_4_0_4_32/CUDK/CLI/dbg_module.h
new file mode 100644 (file)
index 0000000..ee36569
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef DBG_MODULE_H
+#define DBG_MODULE_H
+
+extern int debug_module_process_pid;
+
+void debug_module_init(void);
+void debug_module_deinit(void);
+
+void debug_module_get_queue_status(void);
+
+#endif /* #define DBG_MODULE_H */
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/eth_utils.c b/sta_dk_4_0_4_32/CUDK/CLI/eth_utils.c
new file mode 100644 (file)
index 0000000..9c2b01c
--- /dev/null
@@ -0,0 +1,553 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/****************************************************************************************************/
+/*                                                                                                  */
+/*      MODULE:     eth_utils.c                                                                     */
+/*      PURPOSE:    Ethernet communication utilities                                                */
+/*                                                                                                  */
+/****************************************************************************************************/
+
+#include <sys/shm.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+
+#include "ipc.h"
+#include "ticon.h"                                                       
+#include "errno.h"
+#include "signal.h"
+#include "eth_utils.h"
+
+extern char* inet_ntoa(struct  in_addr);
+       /************/
+       /* Defines */
+       /**********/
+
+#define LOOGER_ETHERNET_PORT   (700)
+#define WIPP_ETHERNET_PORT             (701)
+#define G_TESTER_ETHERNET_PORT (702)
+
+#define READ_STATE_GET_HEADER          (0x00)
+#define READ_STATE_GET_LENGTH1         (0x01)
+#define READ_STATE_GET_LENGTH2         (0x02)
+#define READ_STATE_GET_PAYLOAD         (0x03)
+
+#define PACKET_PREFIX                  (0xFF)
+
+#define IN_BUFFER_SIZE                 (1024)
+#define OUT_BUFFER_SIZE                        (512)
+
+       /*********************/
+       /* Global variables */
+       /*******************/
+
+unsigned char ethernet_utils_welcome_message[] = {'W', 2, 0, 2, ETH_UTILS_PROTOCOL_VERSION};
+
+char ethernet_utils_module_names[ETHERNET_UTILS_NUMBER_OF_MODULES][20] =
+{
+       "terminal",
+       "logger",
+       "wipp control",
+       "g tester"
+};
+
+       /********************************/
+       /* static functions prototypes */
+       /******************************/
+
+int ethernet_utils_init_module(int module_index, u_short port_number, int *module_pipe, unsigned char mux_uart_id);
+void ethernet_utils_signal_handler(int signal);
+int ethernet_utils_process_in_command(int module_index, unsigned char *read_state, unsigned short *packet_size, unsigned char *in_buffer, unsigned int *in_buffer_offset);
+int ethernet_utils_write_socket(int module_index, int length, unsigned char *buffer);
+void ethernet_utils_disconnect_socket(int module_index);
+
+       /**************/
+       /* Functions */
+       /************/
+
+/************************************************************************
+ *                        ethernet_utils_init                           *
+ ************************************************************************
+DESCRIPTION: Initialize the ethernet communication
+
+CONTEXT           : main process only!
+************************************************************************/
+void ethernet_utils_init()
+{
+       ethernet_logger_process_pid = ethernet_utils_init_module(ETHERNET_UTILS_LOGGER_MODULE_ID, LOOGER_ETHERNET_PORT, ethernet_logger_pipe, LOGGER_MUX_UART_ID);
+       ethernet_wipp_process_pid = ethernet_utils_init_module(ETHERNET_UTILS_WIPP_MODULE_ID, WIPP_ETHERNET_PORT, ethernet_wipp_control_pipe, WIPP_CONTROL_MUX_UART_ID);
+       ethernet_g_tester_process_pid = ethernet_utils_init_module(ETHERNET_UTILS_G_TESTER_MODULE_ID, G_TESTER_ETHERNET_PORT, ethernet_g_tester_pipe, G_TESTER_MUX_UART_ID);
+}
+                 
+/************************************************************************
+ *                        ethernet_utils_deinit                         *
+ ************************************************************************
+DESCRIPTION: Deinitialize the ethernet communication
+
+CONTEXT           : main process only!
+************************************************************************/
+void ethernet_utils_deinit()
+{
+       /* Kill the logger process */
+       if (ethernet_logger_process_pid > 0)
+       {
+               kill(ethernet_logger_process_pid, SIGKILL);
+       }
+
+       /* Kill the wipp control process */
+       if (ethernet_wipp_process_pid > 0)
+       {
+               kill(ethernet_wipp_process_pid, SIGKILL);
+       }
+
+       /* Kill the wipp control process */
+       if (ethernet_g_tester_process_pid > 0)
+       {
+               kill(ethernet_g_tester_process_pid, SIGKILL);
+       }
+}
+
+/************************************************************************
+ *                        ethernet_utils_signal_handler                 *
+ ************************************************************************
+DESCRIPTION: Signal handler - receive the USER
+
+CONTEXT           : Signal owner 
+************************************************************************/
+void ethernet_utils_signal_handler(int signal) 
+{ 
+}
+
+/************************************************************************
+ *                        ethernet_utils_init_module                    *
+ ************************************************************************
+DESCRIPTION: Initialize ethernet communication
+
+RETURNS:   : Process ID of the new process or -1 if error.
+
+CONTEXT           : main process only!
+************************************************************************/
+int ethernet_utils_init_module(int module_index, u_short port_number, int *module_pipe, unsigned char mux_uart_id)
+{
+       int child_process_id;
+
+       /***************************************/
+       /* Create a pipe to control the child */
+       /*************************************/
+
+       if (pipe(module_pipe) < 0)
+       {
+               console_printf_terminal("eth_utils, error creating pipe\n");
+
+               return -1;
+       }
+
+       /* Set the shared memory variables */
+       SHARED_MEMORY_IPC_PIPE(module_index) = module_pipe[1];
+       SHARED_MEMORY_MUX_UART_ID(module_index) = mux_uart_id;
+
+       /* Create a child process */
+       child_process_id = fork();
+
+       if (0 == child_process_id)
+       {
+               /******************/
+               /* Child process */
+               /****************/
+
+               int result;
+               int socket_id;
+               int optval = 1;
+               int socket_alive;
+               int max_fd_index;
+               socklen_t client_addr_len;
+               fd_set read_set;
+               unsigned char out_buffer[OUT_BUFFER_SIZE];
+               unsigned char in_buffer[IN_BUFFER_SIZE];
+               unsigned char read_state;
+               unsigned short packet_size;
+               unsigned int in_buffer_offset;
+               struct sockaddr_in server_addr;
+               struct sockaddr_in client_addr;
+
+               console_printf_terminal("eth_utils, Hello from %s child module (pid = %d).\n", ethernet_utils_module_names[module_index], getpid());
+
+               /* Close the write direction of the pipe  - because i only read information from this pipe. */ 
+               close(module_pipe[1]); 
+
+               SHARED_MEMORY_OUTPUT_PATH(module_index) = OUTPUT_PATH_SIMPLE_UART;
+
+               /* Set the signal handler for the 'SIGUSR1' signal */
+               signal(SIGUSR1, ethernet_utils_signal_handler); 
+
+               while (TRUE)
+               {
+                       /******************/
+                       /* Open a socket */
+                       /****************/
+
+                       socket_id = socket(PF_INET, SOCK_STREAM, 0);
+
+                       if (!socket_id)
+                       {
+                               /* Error opening socket */
+                               
+                               console_printf_terminal("eth_utils, error opening %s socket. (errno = %d)\n", ethernet_utils_module_names[module_index], errno);
+
+                               _exit(1);
+                       }
+
+                       /*************************/
+                       /* Configure the socket */
+                       /***********************/
+
+                       if (setsockopt(socket_id, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) == -1)
+                       {
+                               /* Error setting socket option */
+                               
+                               console_printf_terminal("eth_utils, error setting %s socket option.  (errno = %d)\n", ethernet_utils_module_names[module_index], errno);
+
+                               _exit(1);
+                       }
+
+                       /********************/
+                       /* Bind the socket */
+                       /******************/
+
+                       server_addr.sin_family = AF_INET;
+                       server_addr.sin_addr.s_addr = htonl (INADDR_ANY);
+                       server_addr.sin_port = htons(port_number);
+
+                       result = bind(socket_id, (struct sockaddr *)&server_addr, sizeof(server_addr));
+
+                       if (result != 0)
+                       {
+                               /* Error binding socket */
+                               
+                               console_printf_terminal("eth_utils, error binding %s socket. (errno = %d)\n", ethernet_utils_module_names[module_index], errno);
+
+                               _exit(1);
+                       }
+
+                       /****************************/
+                       /* Listening to the socket */
+                       /**************************/
+
+                       result = listen(socket_id, 5);
+
+                       if (-1 == result)
+                       {
+                               /* Error listening to socket */
+                               
+                               console_printf_terminal("eth_utils, error listening to %s socket. (errno = %d)\n", ethernet_utils_module_names[module_index], errno);
+
+                               _exit(1);
+                       }
+
+                       /**********************/
+                       /* Accept connection */
+                       /********************/
+
+                       client_addr_len = sizeof(client_addr);
+
+                       /* We suppose to get new socket id after accept (blocking action) */
+                       result = accept(socket_id, (struct sockaddr *)&client_addr, &client_addr_len);
+
+                       if (-1 == result)
+                       {                       
+                               /* Error accepting connection */
+                               
+                               console_printf_terminal("eth_utils, error accepting %s connection. (errno = %d)\n", ethernet_utils_module_names[module_index], errno);
+
+                               _exit(1);
+                       }
+
+                       close(socket_id);
+
+                       socket_id = result;
+
+                       read_state = READ_STATE_GET_HEADER;
+
+                       SHARED_MEMORY_ETHERNET_SOCKET_ID(module_index) = socket_id;
+
+                       console_printf_terminal("\n***********************************************\n");
+                       console_printf_terminal("* eth_utils, %s connection accepted. \n", ethernet_utils_module_names[module_index]);
+                       console_printf_terminal("*\n* Remote IP: %s\n***********************************************\n", inet_ntoa(client_addr.sin_addr));
+
+                       /* Switch to ethernet output */
+                       SHARED_MEMORY_OUTPUT_PATH(module_index) = OUTPUT_PATH_ETHERNET;
+
+                       /*********************************/
+                       /* Send Hello message to client */
+                       /*******************************/
+
+                       ethernet_utils_write_socket(module_index, sizeof(ethernet_utils_welcome_message), ethernet_utils_welcome_message);
+
+                       /**********************/
+                       /* Manage connection */
+                       /********************/
+
+                       socket_alive = TRUE;
+
+                       while (socket_alive)
+                       {
+                               /***********************************************************************************/   
+                               /* Wait for one of two external events:                                                                               */
+                               /* -----------------------------------                                                                                   */
+                               /*                                                                                                                                                          */
+                               /* 1. Data received from TCP client and should be transfered to parent process */
+                               /* 2. Data received from parent process and should be transfered to client        */
+                               /*****************************************************************************/   
+
+                               /* Prepare the read set fields */
+                               FD_ZERO(&read_set);
+                               FD_SET(socket_id, &read_set);
+                               FD_SET(module_pipe[0], &read_set);
+
+                               /* Determine the maximum index of the file descriptor */
+                               max_fd_index = (max(socket_id, module_pipe[0]) + 1);
+
+                               /* Wait for event - blocking */
+                               result = select(max_fd_index, &read_set, NULL, NULL, NULL);
+
+                               /************************/
+                               /* Check event results */
+                               /**********************/
+
+                               if (result > 0)
+                               {
+                                       if (FD_ISSET(socket_id, &read_set))
+                                       {
+                                               /******************************/
+                                               /* Data received from client */
+                                               /****************************/
+                                               
+                                               /* Process the input command */
+                                               if (ethernet_utils_process_in_command(module_index, &read_state, &packet_size, in_buffer, &in_buffer_offset) <= 0) 
+                                               {
+                                                       socket_alive = FALSE;
+                                               }
+                                       }
+
+                                       if (FD_ISSET(module_pipe[0], &read_set))
+                    {
+                                               /**************************************/
+                                               /* Data received from parent process */
+                                               /************************************/
+
+                                               result = read(module_pipe[0], out_buffer, sizeof(out_buffer));
+                        if( result < 0 )
+                        {
+                            console_printf_terminal("eth_utils, read error (err=%d)\n", result);
+                            socket_alive = FALSE;
+                        }
+                               
+                                               if (ethernet_utils_write_socket(module_index, result, out_buffer) == -1)
+                                               {
+                                                       socket_alive = FALSE;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       console_printf_terminal("eth_utils, 'select' command error\n");
+
+                                       socket_alive = FALSE;
+                               }
+                       }
+
+                       /* Disconnect the socket */
+                       ethernet_utils_disconnect_socket(module_index);
+               }
+       }
+
+       /* Close the read direction of the pipe  - because i only write information from this pipe. (to child process) */ 
+       close(module_pipe[0]); 
+
+       /* return the process id, I will use it later when i want to kill this process */
+       return child_process_id;
+}
+
+/************************************************************************
+ *                        ethernet_utils_process_in_command             *
+ ************************************************************************
+DESCRIPTION: Handle In commands
+
+CONTEXT           : Only the same process that is reading from the socket
+************************************************************************/
+int ethernet_utils_process_in_command(int module_index, unsigned char *read_state, unsigned short *packet_size, unsigned char *in_buffer, unsigned int *in_buffer_offset)
+{      
+       unsigned char prefix;
+       int socket_id = SHARED_MEMORY_ETHERNET_SOCKET_ID(module_index);
+    int result = 1; 
+
+       /*console_printf_terminal("ethernet_utils_process_in_command (socket = %d)\n", socket_id); */
+
+       /* Continue while there is data in the RX buffer */
+       switch (*read_state)
+       {
+       case READ_STATE_GET_HEADER:
+
+               /* Read the packet prefix - one byte */
+               result = read(socket_id, &prefix, sizeof(prefix));
+               /*console_printf_terminal("ethernet_utils_process_in_command (State = READ_STATE_GET_HEADER, length = %d)\n", result); */
+
+               if (result > 0)
+               {
+                       if (prefix == PACKET_PREFIX)
+                       {
+                               *read_state = READ_STATE_GET_LENGTH1;
+                       }
+                       else
+                       {
+                               console_printf_terminal("ethernet_utils_process_in_command, Error: protocol sync error! \n"); 
+
+                               result = -1;
+                       }
+               }
+
+               break;
+
+       case READ_STATE_GET_LENGTH1:
+
+               /* Read the packet size first byte */
+               result = read(socket_id, (void *)((unsigned char *)(packet_size) + 0), sizeof(unsigned char));
+               /*console_printf_terminal("ethernet_utils_process_in_command (State = READ_STATE_GET_LENGTH1, length = %d)\n", result); */
+               
+               if (result > 0)
+               {
+                       *read_state = READ_STATE_GET_LENGTH2;
+               }
+
+               break;
+
+       case READ_STATE_GET_LENGTH2:
+
+               /* Read the packet size second byte */
+               result = read(socket_id, (void *)((unsigned char *)(packet_size) + 1), sizeof(unsigned char));
+               /*console_printf_terminal("ethernet_utils_process_in_command (State = READ_STATE_GET_LENGTH2, length = %d, packet_size = %d)\n", result, *packet_size); */
+               
+               if (result > 0)
+               {
+                       /* Sanity check on the length */
+
+                       *in_buffer_offset = 0;
+
+                       *read_state = READ_STATE_GET_PAYLOAD;
+               }
+
+               break;
+
+
+       case READ_STATE_GET_PAYLOAD:
+
+               /* Read the packet size second byte */
+               result = read(socket_id, (in_buffer + 3 + *in_buffer_offset), (*packet_size - *in_buffer_offset));
+               /*console_printf_terminal("ethernet_utils_process_in_command (State = READ_STATE_GET_PAYLOAD, offset = %d, length = %d)\n", *in_buffer_offset, result); */
+               
+               if (result > 0)
+               {
+                       *in_buffer_offset += result;
+
+                       if (*packet_size == *in_buffer_offset)
+                       {
+                               /* All the packet has arrived */
+
+                               *read_state = READ_STATE_GET_HEADER;
+
+                               /* Send it to the main process */
+
+                               ipc_send_command_to_main_process(module_index, in_buffer, (*packet_size + 3));
+                       }
+               }
+
+               break;
+       }
+
+       return result;
+}
+
+/************************************************************************
+ *                        ethernet_utils_write_socket                              *
+ ************************************************************************
+DESCRIPTION: write data to socket
+
+CONTEXT    : Only the same process that is writing to the socket
+************************************************************************/
+int ethernet_utils_write_socket(int module_index, int length, unsigned char *buffer)
+{
+       int result;
+
+/*     console_printf_terminal("eth_utils, ethernet_utils_wipp_write() (length = %d).\n", length); */
+
+       /* Write to the socket */
+       result = write(SHARED_MEMORY_ETHERNET_SOCKET_ID(module_index), buffer, length);
+
+/*     console_printf_terminal("eth_utils, ethernet_utils_wipp_write() (result = %d).\n", result); */
+
+       if (result != length)
+       {
+               /**************************/
+               /* Error writing to port */
+               /************************/
+               
+               console_printf_terminal("eth_utils, Error writing to %s socket (result = %d, errno = %d, error = %s)\n", ethernet_utils_module_names[module_index], result, errno, strerror(errno));
+
+               result = -1;
+       }
+
+       return result;
+}
+
+/************************************************************************
+ *                        ethernet_utils_disconnect_socket                         *
+ ************************************************************************
+DESCRIPTION: Disconnect a socket
+
+CONTEXT    : Only the process that is disconnecting
+************************************************************************/
+void ethernet_utils_disconnect_socket(int module_index)
+{
+       char temp_buf[6] = {'x','x','x', '5', '0', 0};
+
+       /* Switch to UART output */
+       SHARED_MEMORY_SWITCH_TO_UART_OUTPUT(module_index);
+
+       console_printf_terminal("eth_utils, disconnecting from %s socket.\n", ethernet_utils_module_names[module_index]);
+
+       switch (module_index)
+       {  
+       case ETHERNET_UTILS_LOGGER_MODULE_ID:
+               /* Set debug path back to UART */
+               ipc_send_command_to_main_process(ETHERNET_UTILS_LOGGER_MODULE_ID, (unsigned char*)temp_buf, 5);
+               break;
+
+       case ETHERNET_UTILS_WIPP_MODULE_ID:
+               temp_buf[3] = WIPP_CONTROL_FROM_GENERAL_PROCESS_DEACTIVATE_IPERF;
+               ipc_send_command_to_main_process(GENERAL_PROCESS_MODULE_ID,(unsigned char*) temp_buf, 5);
+               break;
+       }
+
+       /* Close the socket */
+       close(SHARED_MEMORY_ETHERNET_SOCKET_ID(module_index));
+}
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/eth_utils.h b/sta_dk_4_0_4_32/CUDK/CLI/eth_utils.h
new file mode 100644 (file)
index 0000000..66a5dd5
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef ETH_UTILS_H
+#define ETH_UTILS_H
+
+#define ETH_UTILS_PROTOCOL_VERSION     (4)
+
+void ethernet_utils_init(void);
+void ethernet_utils_deinit(void);
+
+#endif /* #define ETH_UTILS_H */
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/g_tester.c b/sta_dk_4_0_4_32/CUDK/CLI/g_tester.c
new file mode 100644 (file)
index 0000000..8b3fc70
--- /dev/null
@@ -0,0 +1,2411 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+/****************************************************************************************************/
+/*                                                                                                  */
+/*      MODULE:     wipp_ctrl.c                                                                     */
+/*      PURPOSE:    WIPP Control utilities                                                                     */
+/*      Note:      This module is for LINUX compilation only!                                                                          */
+/*                                                                                                  */
+/****************************************************************************************************/
+
+
+#include "TI_AdapterApiC.h"
+#include "osDot11.h"
+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+
+#include "g_tester.h"
+#include "console.h"
+#include "cu_cmd.h"
+#include "ticon.h"
+#include "ipc.h"
+
+#include "paramOut.h"
+
+/************/
+/* Defines */
+/**********/                                       
+
+
+#define G_TESTER_STATUS_OK             (0)
+#define G_TESTER_STATUS_ERROR  (1)
+
+#define G_TESTER_GWSI_INIT_NO_ERROR                                            (0x00)
+#define G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE_LENGTH        (0x01)
+#define G_TESTER_GWSI_INIT_ERROR_OPENING_FW_FILE               (0x02)
+#define G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE_LENGTH        (0x03)
+#define G_TESTER_GWSI_INIT_ERROR_OPENING_EP_FILE               (0x04)
+#define G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE               (0x05)
+#define G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE               (0x06)
+#define G_TESTER_GWSI_INIT_ERROR_ALLOCATION_MEMORY             (0x07)
+
+#define G_TESTER_GWSI_GET_INIT_TABLE_NO_ERROR                          (0x00)
+#define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_NO_FILE_NAME                (0x01)
+#define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_WRITING_TO_FILE     (0x02)
+#define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_CREATING_FILE       (0x03)
+#define G_TESTER_GWSI_GET_INIT_TABLE_ERROR_TABLE_NOT_AVAIL     (0x04)
+
+#define G_TESTER_GWSI_CONFIG_NO_ERROR                                  (0x00)
+#define G_TESTER_GWSI_CONFIG_ERROR_READING_FILE                        (0x01)
+#define G_TESTER_GWSI_CONFIG_ERROR_ALLOCATING_MEMORY   (0x02)
+#define G_TESTER_GWSI_CONFIG_ERROR_GETIING_FILE_SIZE   (0x03)
+#define G_TESTER_GWSI_CONFIG_ERROR_OPENING_FILE                        (0x04)
+
+
+
+extern void quit_func(void);   
+void g_tester_process_general_cmd_run_cmd(unsigned char *cmd_buffer);
+void g_tester_process_get_init_table(unsigned char *cmd_buffer);
+
+void g_tester_send_to_host(tiUINT8 *buffer, tiUINT32 length);
+void g_tester_cmd_status(void);
+void g_tester_bssid_list(void);
+void g_tester_send_received_event(unsigned int cmd_op, tiUINT8 status);
+void g_tester_process_gwsi_init_cmd(unsigned char *cmd_buffer);
+void g_tester_process_gwsi_config_cmd(unsigned char *cmd_buffer);
+void g_tester_process_gwsi_release_cmd(unsigned char *cmd_buffer);
+void g_tester_process_gwsi_cmd(unsigned char *cmd_buffer);
+void g_tester_register_event(tiUINT16 event_mask);
+void g_tester_unregister_event(tiUINT16 event_mask);
+void g_tester_cmd_debug_driver_print(unsigned char *cmd_buffer);
+void g_tester_cmd_get_version(void);
+void g_tester_set_rate(tiUINT8 rate_index);
+void g_tester_wep_add_key(unsigned char *cmd_buffer);
+int g_tester_gwsi_event_handler(IPC_EV_DATA* pData);
+void g_tester_cmd_plt_register_read(UINT32 uiRegAddress);
+void g_tester_cmd_plt_RxPer_GetResults(void);
+void g_tester_cmd_plt_mib_read(unsigned char *cmd_buffer);
+void g_tester_cmd_plt_mib_write(unsigned char *cmd_buffer);
+void g_tester_cmd_get_defaultWEPKey(void);
+void g_tester_Roaming_candidates_list(void);
+void g_tester_scAn__configApp__Display(void);
+void g_tester_plt_calibration_get_nvs_buffer(void);
+
+
+TI_HANDLE gwsi_event_id;
+
+
+/************************************************************************
+*                        g_tester_send_to_host                         *
+************************************************************************
+DESCRIPTION:  
+
+  CONTEXT    : 
+************************************************************************/
+void g_tester_send_to_host(tiUINT8 *buffer, tiUINT32 length)
+{
+    /* console_printf_terminal("g_tester, g_tester_send_to_host (length = %d)!\n", length); */
+    
+    /* Send the buffer to the host */
+    console_send_buffer_to_host(ETHERNET_UTILS_G_TESTER_MODULE_ID, buffer, length);
+}
+
+/************************************************************************
+*                        g_tester_init                                         *
+************************************************************************
+DESCRIPTION:  
+
+  CONTEXT    : 
+************************************************************************/
+void g_tester_init()
+{
+    /************************************/
+    /* Register the GWSI event handler */
+    /**********************************/
+    
+    IPC_EVENT_PARAMS pEvent;
+    
+    
+    pEvent.uEventType       = IPC_EVENT_GWSI;
+    pEvent.uDeliveryType    = DELIVERY_PUSH;
+    pEvent.pfEventCallback  = g_tester_gwsi_event_handler;
+    pEvent.hUserParam          = 0;
+    
+    /* Register the event, set the pEvent.uEventID and the pEvent.uProcessID */ 
+    if(!TI_RegisterEvent(g_id_adapter, &pEvent))
+    {
+        gwsi_event_id = pEvent.uEventID;
+    }
+    else
+    {
+        console_printf_terminal("g_tester,  g_tester_init. ERROR Registering GWSI event\n");
+    }
+    
+}
+
+/************************************************************************
+*                        g_tester_deinit                                       *
+************************************************************************
+DESCRIPTION:  
+
+  CONTEXT    : 
+************************************************************************/
+void g_tester_deinit()
+{
+    /**************************************/
+    /* Unregister the GWSI event handler */
+    /************************************/
+    
+    IPC_EVENT_PARAMS pEvent;
+    
+    pEvent.uEventType = IPC_EVENT_GWSI;
+    pEvent.uEventID   = gwsi_event_id;
+    TI_UnRegisterEvent(g_id_adapter, &pEvent);
+}
+
+/************************************************************************
+*                        wipp_control_check_command                    *
+************************************************************************
+DESCRIPTION: Handle the wipp control specific commands 
+
+  CONTEXT    : main process only!                       
+************************************************************************/
+unsigned char g_tester_check_command(unsigned char *input_string)
+{
+    unsigned char return_value = FALSE;
+    unsigned int cmd_op; 
+    /*ConParm_t parm;*/
+    ConParm_t parms[12];
+    int parms_num;
+    unsigned char* data_string = input_string + 5;
+    
+    if (input_string[0] == '-')
+    {
+        /* Get the command opcode */
+        cmd_op = (input_string[1] | (input_string[2] << 8));
+        
+        console_printf_terminal("g_tester,  g_tester_check_command (OpCode = 0x%x).\n", cmd_op);
+        
+        /* Notify the host that we got the event */
+        g_tester_send_received_event(cmd_op, G_TESTER_STATUS_OK);
+        
+        if (G_TESTER_IS_GENERAL_GROUP_CMD(cmd_op))
+        {
+            /************************************/
+            /* This command is GENERAL command */
+            /**********************************/
+            
+            switch (cmd_op)
+            {
+            case G_TESTER_GENERAL_CMD_RUN_CMD:
+                g_tester_process_general_cmd_run_cmd(data_string);
+                break;
+                
+            case G_TESTER_GENERAL_CMD_GET_INIT_T:
+                g_tester_process_get_init_table(data_string);
+                break;
+                
+            default:
+                console_printf_terminal("g_tester (general switch) - unsupported command!\n");
+                break;
+            }
+        }                 
+        else if (G_TESTER_IS_GWSI_GROUP_CMD(cmd_op))
+        {
+            /*********************************/
+            /* This command is GWSI command */
+            /*******************************/
+            
+            switch (cmd_op)
+            {
+            case G_TESTER_GWSI_CMD_INITIALIZE:
+                g_tester_process_gwsi_init_cmd(data_string);
+                break;
+                
+            case G_TESTER_GWSI_CMD_CONFIG:
+                g_tester_process_gwsi_config_cmd(data_string);
+                break;
+                
+            case G_TESTER_GWSI_CMD_RELEASE:
+                g_tester_process_gwsi_release_cmd(data_string);
+                break;
+                
+            default:
+                g_tester_process_gwsi_cmd(&input_string[1]);
+                break;
+            }            
+        }
+        else
+        {
+            /********************************/
+            /* This command is CLI command */
+            /******************************/
+            switch(cmd_op)
+            {
+            case G_TESTER_CLI_CMD_DRIVER__START:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_start_driver(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_DRIVER__STOP:
+                cmd_stop_driver(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_DRIVER__STATUS:
+                g_tester_cmd_status();
+                break;
+                
+            case G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST:
+                g_tester_bssid_list();
+                break;
+                
+            case G_TESTER_CLI_CMD_CONNECTION__CONNECT:
+                parms[0].value = (U32)(data_string);
+                data_string += 32; /*Seek to the end of the string */
+                parms[1].value = (U32)(data_string);
+                /*Find the number of none empty strings */
+                for(parms_num = 2; (parms_num >= 1) && (strlen((char*)parms[parms_num-1].value) == 0); parms_num--)
+                {
+                }
+                cmd_connect(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_CONNECTION__DISASSOCIATE:
+                cmd_disassociate(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_CONNECTION__STATUS:
+                g_tester_cmd_status();
+                break;
+                
+            case G_TESTER_CLI_CMD_CONNECTION__FULL_BSSID_LIST:
+                cmd_Full_bssid_list(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__SSID:
+                parms[0].value = (U32)(data_string);
+                parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
+                cmd_modify_ssid(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__CHANNEL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_channel(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__RATE:
+                g_tester_set_rate(input_string[5]);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__MODE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_bss_type(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__FRAG:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_frag_threshold(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__RTS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_rts_threshold(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__PREAMBLE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_preamble(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__SLOT:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_short_slot(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__INFO:
+                cmd_get_selected_bssid_info(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__DRIVERSTATE:
+                cmd_get_driver_state(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__SIGNAL:
+                cmd_get_rsii_level(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__TX_POWER_LEVEL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_show_tx_power_level_table(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__TX_POWER_DBM:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_tx_power_dbm(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_ENABLEDISABLE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_enableDisable_802_11d(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__H_ENABLEDISABLE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_enableDisable_802_11h(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_COUNTRY_2_4IE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_d_Country_2_4Ie(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_COUNTRY_5IE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_d_Country_5Ie(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__ANTENNA__DIVERSITYPARAMS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                cmd_modify_antenna_diversity(parms, 5);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__BEACON__SET_BEACON_FILTER_MODE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Beacon_Filter_Set_Desired_State(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__ADVANCED__DRAFT:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_modify_ext_rates_ie(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_MANAGEMENT__ADVANCED__SUPPORTED_RATES:
+                parms[0].value = (U32)(data_string);
+                parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
+                cmd_modify_supported_rates(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_SHOW__STATISTICS:
+                cmd_show_statistics(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SHOW__TX_STATISTICS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_show_tx_statistics(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_SHOW__ADVANCED:
+                cmd_show_advanced_params(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__AUTHENTICATION:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_auth(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__EAP:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_eap(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__ENCRYPTION:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_encrypt(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__KEYTYPE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_key_type(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__MIXEDMODE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_mixed_mode(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__CREDENTIALS:
+                parms[0].value = (U32)(data_string);
+                data_string += 32; /*Seek to the end of the string */
+                parms[1].value = (U32)(data_string);
+                /*Find the number of none empty strings */                             
+                for(parms_num = 2; (parms_num >= 1) && (strlen((char*)parms[parms_num-1].value) == 0); parms_num--)
+                {
+                }
+                cmd_privacy_credent(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__PSKPASSPHRASE:
+                parms[0].value = (U32)(data_string);
+                parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
+                cmd_privacy_PSKPassphrase(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__CERTIFICATE:
+                parms[0].value = (U32)(data_string);
+                data_string += 32; /*Seek top the end of the string */
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                cmd_privacy_certificate(parms, 2);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__WPA_OPTIONS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_wpa_options(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__WEP__ADD:
+                g_tester_wep_add_key(data_string);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__WEP__REMOVE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_removekey(parms, 1);
+                break;
+                
+#ifdef EXC_MODULE_INCLUDED
+            case G_TESTER_CLI_CMD_PRIVACY__EXC__CONFIGURE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_exc_config(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__EXC__NETWORKEAP:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_privacy_exc_netEap(parms, 1);
+                break;
+#endif
+            case G_TESTER_CLI_CMD_SCAN__START:
+                cmd_Scan_Start(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__STOP:
+                cmd_Scan_Stop(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__GLOBAL:
+            {
+                int numOfParam;
+                parms[0].value = (U32)(data_string);                /*SSID*/
+                data_string+=33; /*seek the end of the string */
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);   /*Scan Type*/
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);   /*Band*/
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);   /*Probe Request Number*/
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);   /*Probe Request Rate*/
+#ifdef TI_DBG
+                numOfParam = 7;
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);   /*Tid*/
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);   /*Number of Channels*/
+#else
+                numOfParam = 6;
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);   /* skip XML Tid*/
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);   /*Number of Channels*/
+#endif
+
+                                cmd_Scan_app_global_config(parms, numOfParam);
+            }
+                cmd_Scan_app_global_config(parms, 6);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__CHANNEL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                parms[1].value = (U32)(data_string);
+                data_string += 18; /*seek the end of the string */
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                cmd_Scan_app_channel_config(parms, 8);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__CLEAR:
+                cmd_Scan_app_clear(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGAPP__DISPLAY:
+                cmd_Scan_app_display(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__GLOABAL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                cmd_Scan_policy_global_config(parms, 6);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__MISC:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                cmd_Scan_band_global_config(parms, 5);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__CHANNEL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                cmd_Scan_band_channel_config(parms, 3);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__TRACK:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                P_BUFFER_GET_UINT32(data_string, parms[8].value);
+                P_BUFFER_GET_UINT32(data_string, parms[9].value);
+                P_BUFFER_GET_UINT32(data_string, parms[10].value);
+                cmd_Scan_band_track_config(parms, 11);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__DISCOVERY:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                P_BUFFER_GET_UINT32(data_string, parms[8].value);
+                P_BUFFER_GET_UINT32(data_string, parms[9].value);
+                P_BUFFER_GET_UINT32(data_string, parms[10].value);
+                cmd_Scan_band_discover_config(parms, 11);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__IMMEDIATE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                P_BUFFER_GET_UINT32(data_string, parms[8].value);
+                P_BUFFER_GET_UINT32(data_string, parms[9].value);
+                P_BUFFER_GET_UINT32(data_string, parms[10].value);
+                cmd_Scan_band_immed_config(parms, 11);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__DISPLAY:
+                cmd_Scan_policy_display(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__CLEAR:
+                cmd_Scan_policy_clear(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__STORE:
+                cmd_Scan_policy_store(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BSSLIST:
+                g_tester_Roaming_candidates_list();
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__ENABLE:
+                if (input_string[5] == FALSE)
+                {
+                    cmd_Roaming_disable(NULL, 0);
+                }
+                else
+                {
+                    cmd_Roaming_enable(NULL, 0);
+                }
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__LOW_PASS_FILTER:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_lowPassFilter(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__QUALITY_THRESHOLD:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_qualityIndicator(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__GET:
+                cmd_Roaming_getConfParams(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__TX_RETRY:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_dataRetryThreshold(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__BSS_LOSS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_numExpectedTbttForBSSLoss(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__TX_RATE_THRESHOLD:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_txRateThreshold(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_RSSI_THRESHOLD:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_lowRssiThreshold(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_SNR_THRESHOLD:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_lowSnrThreshold(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_QUALITY_FOR_SCAN:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_lowQualityForBackgroungScanCondition(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__NORMAL_QUALITY_FOR_SCAN:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Roaming_normalQualityForBackgroungScanCondition(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__ADD:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                cmd_add_tspec(parms, 6);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__GET:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_get_tspec_params(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__DELETE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                cmd_delete_tspec(parms, 2);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__AP_PARAMS:
+                cmd_get_ap_qos_params(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__AP_CAPABILITIES:
+                cmd_get_ap_qos_capabilities(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__AC_STATUS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_get_ac_status(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__MEDIUM_USAGE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                cmd_medium_usage_threshold(parms, 3);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__PHY_RATE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                cmd_phy_rate_threshold(parms, 3);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__UPSD__DESIRED_PS_MODE:
+                cmd_get_desired_ps_mode(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__CLASSIFIER__TXCLASSIFIER:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                P_BUFFER_GET_UINT32(data_string, parms[8].value);
+                P_BUFFER_GET_UINT32(data_string, parms[9].value);
+                P_BUFFER_GET_UINT32(data_string, parms[10].value);
+                P_BUFFER_GET_UINT32(data_string, parms[11].value);
+                cmd_config_tx_classifier(parms, 12);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__CLASSIFIER__INSERT:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                cmd_insert_clsfr_entry(parms, 7);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__CLASSIFIER__REMOVE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                cmd_remove_clsfr_entry(parms, 7);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__QOSPARAMS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                cmd_set_qos_params(parms, 4);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__POLL_AP_PACKETS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_poll_ap_packets(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_QOS__RX_TIMEOUT:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                cmd_set_rxTimeOut_params(parms, 2);
+                break;
+                
+            case G_TESTER_CLI_CMD_POWER__SET_POWER_MODE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_set_power_mode(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_POWER__SET_POWERSAVE_POWERLEVEL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_set_PowerSave_PowerLevel(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_POWER__TRAFFIC_THRESHOLDS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                cmd_traffic_intensity_threshold(parms, 3);
+                break;
+                
+            case G_TESTER_CLI_CMD_POWER__ENABLE:
+                cmd_enable_traffic_events(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_POWER__DISABLE:
+                cmd_disable_traffic_events(NULL, 0);
+                break;
+                          
+            case G_TESTER_CLI_CMD_EVENTS__REGISTER:
+                /* Register Event */
+                g_tester_register_event(input_string[5] | (input_string[6] << 8));
+                break;
+                
+            case G_TESTER_CLI_CMD_EVENTS__UNREGISTER:
+                /* Unregister Event */
+                g_tester_unregister_event(input_string[5] | (input_string[6] << 8));
+                break;
+                
+#ifdef TI_DBG
+                
+            case G_TESTER_CLI_CMD_FILE__LOAD:
+                parms[0].value = (U32)(data_string);
+                parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
+                cmd_file_load(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_BT_COEXSISTANCE__ENABLE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_bt_coe_enable(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_BT_COEXSISTANCE__RATE:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                cmd_bt_coe_rate(parms, 8);
+                break;
+                
+            case G_TESTER_CLI_CMD_BT_COEXSISTANCE__CONFIG:
+                               cmd_Scan_app_clear(NULL, 0);
+                                g_tester_scAn__configApp__Display();
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                P_BUFFER_GET_UINT32(data_string, parms[5].value);
+                P_BUFFER_GET_UINT32(data_string, parms[6].value);
+                P_BUFFER_GET_UINT32(data_string, parms[7].value);
+                P_BUFFER_GET_UINT32(data_string, parms[8].value);
+                P_BUFFER_GET_UINT32(data_string, parms[9].value);
+                P_BUFFER_GET_UINT32(data_string, parms[10].value);
+                P_BUFFER_GET_UINT32(data_string, parms[11].value);
+                P_BUFFER_GET_UINT32(data_string, parms[12].value);
+                P_BUFFER_GET_UINT32(data_string, parms[13].value);
+                cmd_bt_coe_config(parms, 14);
+                break;
+                
+            case G_TESTER_CLI_CMD_BT_COEXSISTANCE__STATUS:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_bt_coe_get_status(parms, 1);
+                break;
+                
+#ifdef EXC_MODULE_INCLUDED
+            case G_TESTER_CLI_CMD_MEASUREMENT__ENABLE:
+                cmd_Measurement_enable(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_MEASUREMENT__DISABLE:
+                cmd_Measurement_disable(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_MEASUREMENT__MAX_DURATION:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_Measurement_setMaxDuration(parms, 1);
+                break;
+#endif
+            case G_TESTER_CLI_CMD_REPORT__SET:
+                parms[0].value = (U32)(data_string);
+                parms_num =(strlen((char*)parms[0].value) == 0)?0:1;
+                cmd_report_set(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_REPORT__ADD:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_report_add(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_REPORT__CLEAR:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_report_clear(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_REPORT__LEVEL:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_report_severity_level(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_DEBUG__REGISTER:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                cmd_hw_register(parms, 2);
+                break;
+                
+            case G_TESTER_CLI_CMD_DEBUG__PRINT:
+                g_tester_cmd_debug_driver_print(data_string);
+                break;
+                
+            case G_TESTER_CLI_CMD_DEBUG__BUFFER:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                data_string += 9; /* seek to the end of the string */
+                parms[1].value = (U32)(data_string);
+                parms_num =(strlen((char*)parms[1].value) == 0)?1:2;
+                cmd_debug_buffer_put(parms, parms_num);
+                break;
+                
+            case G_TESTER_CLI_CMD_ROOT__ABOUT:
+                /* Driver version */
+                g_tester_cmd_get_version();  
+                break;
+                
+            case G_TESTER_CLI_CMD_ROOT__QUIT:
+                quit_func();
+                break;
+#endif 
+                
+            case G_TESTER_CLI_CMD_PLT__REGISTER__READ:
+                {
+                    UINT32 RegAddress;
+                    P_BUFFER_GET_UINT32(data_string, RegAddress);
+                    g_tester_cmd_plt_register_read(RegAddress);
+                }
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__REGISTER__WRITE:
+                {
+                    tiUINT32 uiRegAddress; 
+                    tiUINT32 uiRegValue; 
+                    P_BUFFER_GET_UINT32(data_string, uiRegAddress);
+                    P_BUFFER_GET_UINT32(data_string, uiRegValue);
+                    TI_PLT_WriteRegister(g_id_adapter, uiRegAddress, uiRegValue);
+                }
+                break;
+
+            case G_TESTER_CLI_CMD_PLT_RADIO_TUNE:
+                {
+                    UINT32 status;
+                    TestCmdChannelBand_t ChannelBand;
+                    tiUINT8 return_buffer[3];
+                    tiUINT8 *p_return_buffer = return_buffer;                    
+
+                    P_BUFFER_GET_UINT32(data_string, ChannelBand.band);
+                    P_BUFFER_GET_UINT32(data_string, ChannelBand.channel);
+                    status = TI_PLT_RadioTune(g_id_adapter, &ChannelBand);
+                    P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT_RADIO_TUNE, (UINT8)status);
+                    g_tester_send_to_host(return_buffer, 3);
+                }
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__RX_PER__START:
+                cmd_PLT_RxPerStart(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__RX_PER__STOP:
+                cmd_PLT_RxPerStop(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__RX_PER__CLEAR:
+                cmd_PLT_RxPerClear(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__RX_PER__GET_RESULTS:
+                g_tester_cmd_plt_RxPer_GetResults();
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__TX__CW:
+                {
+                    tiUINT8 return_buffer[3];
+                    tiUINT8 *p_return_buffer = return_buffer;                    
+                    tiUINT32 status;
+                    TestCmdChannelBand_t PltTxCW;
+                    P_BUFFER_GET_UINT32(data_string, PltTxCW.band);
+                    P_BUFFER_GET_UINT32(data_string, PltTxCW.channel);
+                    status = TI_PLT_TxCW(g_id_adapter, &PltTxCW);
+                    P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__TX__CW, (UINT8)status);
+                    g_tester_send_to_host(return_buffer, 3);
+                }
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__TX__CONTINUES:
+                {
+                    
+                    PltTxContinues_t PltTxContinues;
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.band);
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.chID);
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.rate);
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.preamble);
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.InterPacketDelay);
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.NumOfFrames);
+                    P_BUFFER_GET_UINT8(data_string, PltTxContinues.mode);
+                    
+                    TI_PLT_TxContiues(g_id_adapter, &PltTxContinues);
+                    
+                    if (OK == TI_PLT_TxContiues(g_id_adapter, &PltTxContinues))
+                        console_printf_terminal("PltTxContinues (band=%d, chID=%d, rate=%d, preamble=%d, InterPacketDelay=%d, NumOfFrames=%d, mode=0x%x)- OK\n",
+                        PltTxContinues.band,             
+                        PltTxContinues.chID,             
+                        PltTxContinues.rate,             
+                        PltTxContinues.preamble,         
+                        PltTxContinues.InterPacketDelay, 
+                        PltTxContinues.NumOfFrames,      
+                        PltTxContinues.mode);
+                    else
+                        console_printf_terminal("PltTxContinues - NOK\n");                    
+                }
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__TX__STOP:
+                cmd_PLT_TxStop(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__MIB__READ:
+                g_tester_cmd_plt_mib_read(data_string);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__MIB__WRITE:
+                g_tester_cmd_plt_mib_write(data_string);
+                break;
+                
+            case G_TESTER_CLI_CMD_PRIVACY__WEP__GET:
+                g_tester_cmd_get_defaultWEPKey();
+                break;
+
+            case G_TESTER_CLI_CMD_PLT__CALIBRATION__RX:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                P_BUFFER_GET_UINT32(data_string, parms[1].value);
+                P_BUFFER_GET_UINT32(data_string, parms[2].value);
+                P_BUFFER_GET_UINT32(data_string, parms[3].value);
+                P_BUFFER_GET_UINT32(data_string, parms[4].value);
+                cmd_PLT_RxCal(parms, 5);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__START:
+                               P_BUFFER_GET_UINT8(data_string, parms[0].value);
+                cmd_PLT_TxCalStart(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__STOP:
+                cmd_PLT_TxCalStop(NULL, 0);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_GET:
+                {
+                    tiUINT8 return_buffer[10];
+                    tiUINT8 *p_return_buffer = return_buffer;                    
+                    
+                    UINT32 status;
+                    PltGainGet_t PLTGainGet;                     
+                    status = TI_PLT_TxCalGainGet(g_id_adapter, &PLTGainGet);
+                    P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_GET, (UINT8)status);
+                    if (status == OK)
+                    {
+                        P_BUFFER_ADD_UINT8(p_return_buffer, PLTGainGet.TxGain);
+                        P_BUFFER_ADD_UINT8(p_return_buffer, PLTGainGet.TxUpperBound);
+                        P_BUFFER_ADD_UINT8(p_return_buffer, PLTGainGet.TxLowerBound);
+                    }
+                    g_tester_send_to_host(return_buffer, p_return_buffer-return_buffer); 
+                }
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_ADJUST:
+                P_BUFFER_GET_UINT32(data_string, parms[0].value);
+                cmd_PLT_TxCalGainAdjust(parms, 1);
+                break;
+                
+            case G_TESTER_CLI_CMD_PLT__CALIBRATION__GET_NVS_BUFFER:
+                g_tester_plt_calibration_get_nvs_buffer();
+                break;
+                
+            default:
+                console_printf_terminal("g_tester - unsupported command!\n");
+                break;
+            }
+        }
+        
+        return_value = TRUE;
+    }
+    
+    return return_value;
+}
+
+/************************************************************************
+*                        g_tester_process_general_cmd_run_cmd          *
+************************************************************************
+DESCRIPTION: 
+
+  CONTEXT    : main process only!                       
+  ************************************************************************/
+  void g_tester_process_general_cmd_run_cmd(unsigned char *cmd_buffer)
+  {
+      tiUINT8 return_buffer[5];
+      tiUINT8 *p_return_buffer = return_buffer;
+      tiUINT16 return_value;
+      
+      console_printf_terminal("g_tester - Executing cmd line: %s\n", cmd_buffer);
+      
+      return_value = (tiUINT16)system((const char*)cmd_buffer);
+      
+      console_printf_terminal("g_tester - Execution result: 0x%x\n", return_value);
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_GENERAL_CMD_RUN_CMD, (UINT8)0x00);
+      
+      /* Add the result */
+      P_BUFFER_ADD_UINT16(p_return_buffer, return_value);
+      
+      g_tester_send_to_host(return_buffer, 5);
+  }
+  
+  /************************************************************************
+  *                        g_tester_process_get_init_table                 *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    : main process only!                     
+  ************************************************************************/
+  void g_tester_process_get_init_table(unsigned char *cmd_buffer)
+  {
+      UINT8 buffer[(1024 * 5)];
+      UINT8 *p_return_buffer = buffer;
+      UINT32 length;
+      
+      UINT8 init_table_file_name_length = *(cmd_buffer + 0); 
+      unsigned char *init_table_file_name = (cmd_buffer + 1); 
+      
+      UINT8 error_code = G_TESTER_GWSI_GET_INIT_TABLE_NO_ERROR;
+      
+      int FileDescriptor;
+      
+      if (init_table_file_name_length == 0)
+      {
+          console_printf_terminal("g_tester, g_tester_process_get_init_table, Error - no file name!\n");
+          
+          error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_NO_FILE_NAME;
+      }
+      else
+      {
+          /* Get the Init buffer from the driver */
+          TI_GWSIGetInitTable(g_id_adapter, (tiUINT32 *)&buffer[0]);
+          
+          /* The first 4 bytes are the buffer length */
+          length = *(UINT32 *)&buffer[0];
+          
+          if (length > 0)
+          {
+              FileDescriptor = open((const char*)init_table_file_name, O_CREAT | O_WRONLY);
+              
+              if (FileDescriptor != -1)
+              {
+                  if (write(FileDescriptor, buffer, length + sizeof(UINT32) ) != length + sizeof(UINT32))
+                  {
+                      console_printf_terminal("g_tester, g_tester_process_get_init_table, Error writing to file (%d)\n", errno);
+                      
+                      error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_WRITING_TO_FILE;
+                  }
+                  else
+                  {
+                      console_printf_terminal("g_tester, g_tester_process_get_init_table, Written 0x%x bytes to %s\n\n", (length - 4), init_table_file_name);
+                  }
+                  
+                  close(FileDescriptor);
+              }
+              else
+              {
+                  console_printf_terminal("g_tester, g_tester_process_get_init_table, Error creating %s (%d)\n", init_table_file_name, errno);
+                  
+                  error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_CREATING_FILE;
+              }
+          }
+          else
+          {
+              console_printf_terminal("g_tester, g_tester_process_get_init_table, Error - driver init table not availble!\n");
+              
+              error_code = G_TESTER_GWSI_GET_INIT_TABLE_ERROR_TABLE_NOT_AVAIL;
+          }
+      }
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_GENERAL_CMD_GET_INIT_T, error_code);
+      
+      g_tester_send_to_host(buffer, 3);
+  }
+  
+  /************************************************************************
+  *                        g_tester_cmd_status                           *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    : main process only!                     
+  ************************************************************************/
+  void g_tester_cmd_status()
+  {
+  /***************************
+  Return buffer structure 
+  
+    Bytes 0-1  : OpCode (0x0003)
+    Byte  2       : Command Status
+    Byte  3       : Status (0/1/2)
+    Bytes 4-9  : MAC Address
+    Byte  10   : SSID length
+    Bytes 11-42: SSID 
+    Bytes 43-48: BSSID
+    Byte  49:  : Channel
+      ***************************/
+      
+      tiUINT8 return_buffer[50];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      tiINT32 res;
+      tiUINT32 data;
+      OS_802_11_BSSID_EX       bssid_ex;
+      OS_802_11_MAC_ADDRESS mac_address;
+      OS_802_11_SSID ssid;
+      
+      /* Set the header to dummy values */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_DRIVER__STATUS, 0x00);
+      
+      /* Get the Driver status (Running / Stop) */
+      res = TI_WLAN_IsDriverRun(g_id_adapter, (tiBOOL *)&data);
+      
+      if (res == 0)
+      {
+          /* Insert the status to the return buffer */
+          P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)data);
+          
+          /* Get the MAC address */
+          res = TI_GetCurrentAddress(g_id_adapter, &mac_address);
+          
+          if (res == 0)
+          {
+              P_BUFFER_ADD_DATA(p_return_buffer, &mac_address, sizeof(mac_address));
+              
+              /* Get the SSID */
+              res = TI_GetCurrentSSID(g_id_adapter, &ssid);
+              
+              if (res == 0)
+              {
+                  /* killme!!!*/
+                  /*if (isJunkSSID((void *)&ssid))*/
+                  /*{*/
+                  /* Put '0' at the length field */
+                  /*   ssid.SsidLength = 0;*/
+                  /*}*/
+                  
+                  /* Add ssid length */
+                  P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)ssid.SsidLength);
+                  
+                  /* Add ssid */
+                  P_BUFFER_ADD_DATA(p_return_buffer, ssid.Ssid, sizeof(ssid.Ssid));
+                  
+                  /* Get the BSSID */
+                  res = TI_GetSelectedBSSIDInfo(g_id_adapter, &bssid_ex);
+                  
+                  if (res == 0)
+                  {
+                      /* Add the BSSID */
+                      P_BUFFER_ADD_DATA(p_return_buffer, &bssid_ex.MacAddress, sizeof(bssid_ex.MacAddress));
+                      
+                      /* Get the Channel */
+                      res = TI_GetCurrentChannel(g_id_adapter, &data);
+                      
+                      if (res == 0)
+                      {
+                          /* Add channel */
+                          P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)data);
+                      }
+                  }
+              }
+          }
+      }
+      
+      p_return_buffer = return_buffer;
+      
+      /* Set the G_Tester result value */
+      res = (res == 0) ? G_TESTER_STATUS_OK : G_TESTER_STATUS_ERROR;
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_DRIVER__STATUS, (UINT8)res);
+      
+      g_tester_send_to_host(return_buffer, 50);
+  }    
+  
+  /************************************************************************
+  *                        g_tester_cmd_status                           *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    : main process only!                     
+  ************************************************************************/
+  void g_tester_bssid_list()
+  {
+  /***************************
+  Return buffer structure (for header):
+  
+    Bytes 0-1  : OpCode (0x0004)
+    Byte  2       : Command Status
+    Byte  3       : Number of elements 
+      ***************************/
+      
+      /***************************
+      Return buffer structure (for each element):
+      
+        Bytes 0-1      : OpCode (0x0005)
+        Byte  2           :  Command Status
+        Bytes 3-8   : MAC Address
+        Byte  9     : Privacy
+        Bytes 10-13 : RSSI
+        Byte  14    : Infra mode
+        Byte  15    : Channel
+        Bytes 16-19 : Qos
+        Byte  20       : SSID length
+        Bytes 21-52 : SSID 
+      ***************************/
+      
+      tiUINT8 return_buffer[55];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      OS_802_11_BSSID_LIST_EX *list;/* = (OS_802_11_BSSID_LIST_EX *) data; */
+      OS_802_11_BSSID_EX *bssid;
+      tiUINT32 number_items;
+      tiINT32 res;
+      tiUINT8 index;
+      tiUINT32 Qos = 0;
+      
+      console_printf_terminal("g_tester,  g_tester_bssid_list()\n");
+      
+      res = TI_GetBSSIDList(g_id_adapter, &list);
+      if( res || !list )
+      {
+          /*************************/
+          /* Error retrieving data */
+          /***********************/
+          
+          /* Set the header */
+          P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, G_TESTER_STATUS_ERROR);
+          
+          /* Set dummy UINT8 */
+          P_BUFFER_ADD_UINT8(p_return_buffer, 0x00);
+          
+          g_tester_send_to_host(return_buffer, 4);
+      }
+      else
+      {
+          bssid = &list->Bssid[0];
+          number_items = list->NumberOfItems;
+          
+          /*********************/
+          /* Header structure */
+          /*******************/
+          
+          /* Set the header */
+          P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, G_TESTER_STATUS_OK);
+          
+          /* Set dummy UINT8 */
+          P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)number_items);
+          
+          g_tester_send_to_host(return_buffer, 4);
+          
+          /***********************/
+          /* Elements structure */
+          /*********************/
+          
+          for (index = 0; index < number_items; index++)
+          {
+              p_return_buffer = return_buffer;
+              
+              /* Set the header */
+              P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, (G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST + 1), G_TESTER_STATUS_OK);
+              
+              P_BUFFER_ADD_DATA(p_return_buffer, bssid->MacAddress, sizeof(bssid->MacAddress));
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssid->Privacy);
+              
+              P_BUFFER_ADD_UINT32(p_return_buffer, bssid->Rssi);
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssid->InfrastructureMode);
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)Freq2Chan(bssid->Configuration.Union.channel));
+              
+              Qos = parseBssidIe(bssid);
+              P_BUFFER_ADD_UINT32(p_return_buffer, (tiUINT32)Qos);
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssid->Ssid.SsidLength);
+              
+              P_BUFFER_ADD_DATA(p_return_buffer, bssid->Ssid.Ssid, sizeof(bssid->Ssid.Ssid));
+              
+              g_tester_send_to_host(return_buffer, 53);
+              
+              /* Move to the next bssid */
+              bssid = (OS_802_11_BSSID_EX *) (((char *) bssid) + bssid->Length);
+          }
+          
+          free(list);
+      }
+}
+
+/************************************************************************
+*                        g_tester_register_event                       *
+************************************************************************
+DESCRIPTION: 
+
+  CONTEXT    :                          
+  ************************************************************************/
+  void g_tester_register_event(tiUINT16 event_mask)
+  {
+      int index;
+      ConParm_t param;
+      
+      console_printf_terminal("g_tester,  g_tester_register_event (Mask = 0x%x)\n", event_mask);
+      
+      /* Go over the mask bits */
+      for (index = 0; index < 16; index++)
+      {
+          if ((event_mask & (1 << index)) != (tiUINT16)0x0000)
+          {
+              param.value = index;
+              cmd_events_register(&param, 1);
+          }
+      }
+  }
+  
+  /************************************************************************
+  *                        g_tester_unregister_event                     *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_unregister_event(tiUINT16 event_mask)
+  {
+      int index;
+      ConParm_t param;
+      
+      console_printf_terminal("g_tester,  g_tester_unregister_event (Mask = 0x%x)\n", event_mask);
+      
+      /* Go over the mask bits */
+      for (index = 0; index < 16; index++)
+      {
+          if ((event_mask & (1 << index)) != (tiUINT16)0x0000)
+          {
+              param.value = index;
+              cmd_events_unregister(&param, 1);
+          }
+      }
+  }
+  
+  /************************************************************************
+  *                        g_tester_cmd_debug_driver_print               *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_cmd_debug_driver_print(unsigned char *cmd_buffer)
+  {
+#ifdef TI_DBG
+      
+      tiUINT32 *buf = (tiUINT32 *)cmd_buffer;
+      
+      ConParm_t param[2];
+      
+      param[0].value = buf[0];
+      param[1].value = buf[1];
+      
+      console_printf_terminal("DEBUG: values: (0x%x, 0x%x)\n", param[0].value, param[1].value);
+      
+      cmd_debug_driver_print((ConParm_t *)&param, 2);
+      
+#endif
+  }
+  
+  /************************************************************************
+  *                        g_tester_receive_event                        *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_receive_event(unsigned char event_index)
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1  : OpCode (0x1050)
+    Byte  2       : Command Status
+    Byte  3       : Event ID 
+      ***************************/
+      
+      tiUINT8 return_buffer[55];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, 0x1050, G_TESTER_STATUS_OK);
+      
+      /* Set event index */
+      P_BUFFER_ADD_UINT8(p_return_buffer, event_index);
+      
+      g_tester_send_to_host(return_buffer, 4);
+  }
+  
+  /************************************************************************
+  *                        g_tester_send_received_event                  *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_send_received_event(unsigned int cmd_op, tiUINT8 status)
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1  : OpCode (0xFFFF)
+    Byte  2-3  : Command Opcode
+      ***************************/
+      
+      tiUINT8 return_buffer[5];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      /* Add the event opcode */
+      P_BUFFER_ADD_UINT16(p_return_buffer, 0x1000);
+      
+      /* Add the command opcode */
+      P_BUFFER_ADD_UINT16(p_return_buffer, cmd_op);
+      
+      /* Add the command opcode */
+      P_BUFFER_ADD_UINT8(p_return_buffer, status);
+      
+      g_tester_send_to_host(return_buffer, 5);
+  }
+  
+  /************************************************************************
+  *                        g_tester_process_gwsi_init_cmd                *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_process_gwsi_init_cmd(unsigned char *cmd_buffer)
+  {
+      char *firmware_file_name;
+      unsigned char firmware_file_name_length;
+      char *e2prom_file_name;
+      unsigned char e2prom_file_name_length;
+      
+      unsigned char *init_buffer = NULL; 
+      UINT32 init_buffer_size;
+      
+      unsigned char host_event_buffer[3];
+      unsigned char *p_host_event_buffer = host_event_buffer;
+      
+      FILE *firmware_file = NULL;
+      FILE *e2prom_file = NULL;
+      UINT32 firmware_image_length = 0;
+      UINT32 e2prom_image_length = 0;
+      
+      unsigned char error_code = G_TESTER_GWSI_INIT_NO_ERROR;
+      
+      /* Prepare the parameters */
+      firmware_file_name_length = *(cmd_buffer + 0); 
+      firmware_file_name = (char*)(cmd_buffer + 1); 
+      e2prom_file_name_length = *(cmd_buffer + firmware_file_name_length + 2); 
+      e2prom_file_name = (char*)(cmd_buffer + firmware_file_name_length + 3); 
+      
+      console_printf_terminal("g_tester, DEBUG:0x%x, 0x%x!\n", firmware_image_length, e2prom_file_name_length);
+      
+      /***************************/
+      /* Open the firmware file */
+      /*************************/
+      
+      if ((firmware_file = fopen(firmware_file_name, "r")) != NULL)
+      {
+          /* Get firmware file length */
+          if (fseek(firmware_file, 0, SEEK_END) == 0)
+          {
+              firmware_image_length = ftell(firmware_file);
+              rewind(firmware_file);
+              
+              console_printf_terminal("g_tester, GWSI Init, Firmeware image file is %s, size = 0x%x!\n", firmware_file_name, firmware_image_length);
+          }
+          else
+          {
+              console_printf_terminal("g_tester, Error retriving firmware file length!\n");
+              
+              error_code = G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE_LENGTH;
+          }
+      }
+      else
+      {
+          console_printf_terminal("g_tester, Error opening firmware file!\n");
+          
+          error_code = G_TESTER_GWSI_INIT_ERROR_OPENING_FW_FILE;
+      }
+      
+      /*************************/
+      /* Open the e2prom file */
+      /***********************/
+      
+      console_printf_terminal("DEBUG The length is : %d\n", e2prom_file_name_length);
+      
+      if ((error_code == G_TESTER_GWSI_INIT_NO_ERROR) && (e2prom_file_name_length > 0))
+      {
+          /* Open the e2prom file */
+          if ((e2prom_file = fopen(e2prom_file_name, "r")) != NULL)
+          {
+              /* Get firmware file length */
+              if (fseek(e2prom_file, 0, SEEK_END) == 0)
+              {
+                  e2prom_image_length = ftell(e2prom_file);
+                  rewind(e2prom_file);
+                  
+                  console_printf_terminal("g_tester, GWSI Init, E2prom image file is %s, size = 0x%x!\n", e2prom_file_name, e2prom_image_length);
+              }
+              else
+              {
+                  console_printf_terminal("g_tester, Error retrieving e2prom file length!\n");
+                  
+                  error_code = G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE_LENGTH;
+              }
+          }
+          else
+          {
+              console_printf_terminal("g_tester, Error opening e2prom file!\n");
+              
+              error_code = G_TESTER_GWSI_INIT_ERROR_OPENING_EP_FILE;
+          }
+      }
+      
+      /****************************/
+      /* Prepare the init struct */
+      /**************************/
+      
+      if (error_code == G_TESTER_GWSI_INIT_NO_ERROR)
+      {
+          init_buffer_size = 16 + firmware_image_length + e2prom_image_length;
+          
+          init_buffer = malloc(init_buffer_size);
+          
+          if (init_buffer != NULL)
+          {
+              /* Set the GWSI tester command parameters */
+              P_BUFFER_ADD_UINT16(init_buffer, G_TESTER_GWSI_CMD_INITIALIZE);  /* Opcode */
+              P_BUFFER_ADD_UINT32(init_buffer, init_buffer_size);                              /* Length */
+              P_BUFFER_ADD_UINT16(init_buffer, 0x0000);                                                        /* Align bytes*/
+              P_BUFFER_ADD_UINT32(init_buffer, firmware_image_length);
+              P_BUFFER_ADD_UINT32(init_buffer, e2prom_image_length);
+              
+              init_buffer -= (16); 
+              
+              /* Read the firmware image */
+              if (fread(init_buffer + (16), 1, firmware_image_length, firmware_file) == firmware_image_length)
+              {
+                  if (e2prom_image_length)
+                  {
+                      /* Read the e2prom image */
+                      if (fread(init_buffer + (16) + firmware_image_length, 1, e2prom_image_length, e2prom_file) != e2prom_image_length)
+                      {
+                          console_printf_terminal("g_tester, GWSI Init, Error reading e2prom image!\n");
+                          
+                          error_code = G_TESTER_GWSI_INIT_ERROR_READING_EP_FILE;
+                      }
+                  }
+                  
+                  if (error_code == G_TESTER_GWSI_INIT_NO_ERROR)
+                  {
+                      console_printf_terminal("g_tester, GWSI Init, Sending command to driver (size = 0x%x)!\n", init_buffer_size);
+                      
+                      /* Send the command */
+                      TI_GWSIInitialize(g_id_adapter, (tiUINT32 *)init_buffer);
+                  }
+              }
+              else
+              {
+                  console_printf_terminal("g_tester, GWSI Init, Error reading firmware image!\n");
+                  
+                  error_code = G_TESTER_GWSI_INIT_ERROR_READING_FW_FILE;
+              }
+          }
+          else
+          {
+              console_printf_terminal("g_tester, GWSI Init, Error allocating memory for init buffer!\n");
+              
+              error_code = G_TESTER_GWSI_INIT_ERROR_ALLOCATION_MEMORY;
+          }
+      } 
+      
+      /************************************/
+      /* Fall-back -> free all resources */
+      /**********************************/
+      
+      if (firmware_file)
+      {
+          fclose(firmware_file);
+      }
+      
+      if (e2prom_file)
+      {
+          fclose(e2prom_file);
+      }
+      
+      if (init_buffer)
+      {
+          free(init_buffer);
+      }                
+      
+      /****************************/
+      /* Send result to the host */
+      /**************************/
+      
+      if (error_code != G_TESTER_GWSI_INIT_NO_ERROR)
+      {
+          /*************************************************/
+          /* Send event with error indication to the host */
+          /***********************************************/
+          
+          P_BUFFER_ADD_HDR_PARAMS(p_host_event_buffer, G_TESTER_GWSI_CMD_INITIALIZE, error_code);
+          
+          g_tester_send_to_host(host_event_buffer, 3);
+      }
+}
+
+/************************************************************************
+*                        g_tester_process_gwsi_config_cmd              *
+************************************************************************
+DESCRIPTION: 
+
+  CONTEXT    :                          
+  ************************************************************************/
+  void g_tester_process_gwsi_config_cmd(unsigned char *cmd_buffer)
+  {
+      char *init_file_name;
+      unsigned char init_file_name_length;
+      
+      unsigned char host_event_buffer[3];
+      unsigned char *p_host_event_buffer = host_event_buffer;
+      
+      int init_file_descriptor;
+      struct stat file_status_record;
+      
+      UINT8 *buffer = NULL;
+      
+      UINT8 error_code = G_TESTER_GWSI_CONFIG_NO_ERROR;
+      
+      /* Prepare the parameters */
+      init_file_name_length = *(cmd_buffer + 0); 
+      init_file_name = (char*)(cmd_buffer + 1); 
+      
+      init_file_descriptor = open(init_file_name, O_RDONLY);
+      
+      if (init_file_descriptor != -1)
+      {
+          if (fstat(init_file_descriptor, &file_status_record) != -1)
+          {
+              buffer = malloc(file_status_record.st_size + (sizeof(UINT16) * 2));
+              
+              if (buffer != NULL)
+              {
+                  int temp;
+                  if ((temp = read(init_file_descriptor, buffer + (sizeof(UINT16) * 2), file_status_record.st_size)) == file_status_record.st_size)
+                  {
+                      console_printf_terminal("g_tester, GWSI_Config, Sending config request to driver (file = %s, buffer size = 0x%x)\n", init_file_name, file_status_record.st_size + (sizeof(UINT16) * 2));
+                      
+                      P_BUFFER_ADD_UINT16(buffer, G_TESTER_GWSI_CMD_CONFIG);
+                      P_BUFFER_ADD_UINT16(buffer, file_status_record.st_size);
+                      buffer -= (sizeof(UINT16) * 2);
+                      
+                      /* Send the command to the driver */
+                      TI_GWSIConfig(g_id_adapter, (tiUINT32 *)buffer);
+                  }
+                  else
+                  {
+                      console_printf_terminal("g_tester, GWSI_Config, Error reading from file (%d)\n", errno);
+                      error_code = G_TESTER_GWSI_CONFIG_ERROR_READING_FILE; 
+                  }
+              }
+              else
+              {
+                  console_printf_terminal("g_tester, GWSI_Config, Error allocating memory (%d)\n", errno);
+                  error_code = G_TESTER_GWSI_CONFIG_ERROR_ALLOCATING_MEMORY;
+              }
+          }
+          else
+          {
+              console_printf_terminal("g_tester, GWSI_Config, Error retriving file size (%d)\n", errno);
+              error_code = G_TESTER_GWSI_CONFIG_ERROR_GETIING_FILE_SIZE;
+          }
+      }
+      else
+      {
+          console_printf_terminal("g_tester, GWSI_Config, Error opening file (%d)\n", errno);
+          error_code = G_TESTER_GWSI_CONFIG_ERROR_OPENING_FILE;
+      }
+      
+      /*******************/
+      /* Free resources */
+      /*****************/
+      
+      if (init_file_descriptor != -1)
+      {
+          close(init_file_descriptor);
+      }
+      
+      if (buffer != NULL)
+      {
+          free(buffer);
+      }
+      
+      /****************************/
+      /* Send result to the host */
+      /**************************/
+      
+      if (error_code != G_TESTER_GWSI_CONFIG_NO_ERROR)
+      {
+          P_BUFFER_ADD_HDR_PARAMS(p_host_event_buffer, G_TESTER_GWSI_CMD_CONFIG, error_code);
+          
+          g_tester_send_to_host(host_event_buffer, 3);
+      }
+  }
+  
+  /************************************************************************
+  *                        g_tester_process_gwsi_release_cmd                     *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_process_gwsi_release_cmd(unsigned char *cmd_buffer)
+  {
+      
+      tiUINT8 return_buffer[2];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      /* Add the event opcode */
+      P_BUFFER_ADD_UINT16(p_return_buffer, G_TESTER_GWSI_CMD_RELEASE);
+      
+      console_printf_terminal("g_tester, GWSI_Release, Sending release to driver.\n");
+      
+      /* Send the command to the driver */
+      TI_GWSIRelease(g_id_adapter, (tiUINT32 *)return_buffer);
+  }
+  
+  
+  /************************************************************************
+  *                        g_tester_process_gwsi_cmd                     *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_process_gwsi_cmd(unsigned char *cmd_buffer)
+  {
+      TI_GWSICommand(g_id_adapter, (tiUINT32 *)cmd_buffer);
+  }
+  
+  /************************************************************************
+  *                        g_tester_process_gwsi_cmd                     *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_cmd_get_version()
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1  : OpCode (0x1050)
+    Byte  2       : Command Status
+    Byte  3-6  : Driver Version
+    Byte  7-10 : FW Version
+    Byte  11-14: HW Version
+    Byte  15-18: NVM Version
+      ***************************/
+      
+      tiUINT32 ret;
+      tiUINT8 return_buffer[19];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      TIWLN_VERSION_EX data;
+      
+      console_printf_terminal("g_tester,  g_tester_cmd_get_version.\n");
+      
+      ret = (tiUINT8)TI_GetDriverVersion(g_id_adapter, &data );
+      
+      if (ret == 0)
+      {
+          /* Set the header */
+          P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_ROOT__ABOUT, G_TESTER_STATUS_OK);
+          
+          /* ADD the versions */
+          P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.DrvVersion));
+          P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.FWVersion));
+          P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.HWVersion));
+          P_BUFFER_ADD_UINT32(p_return_buffer, (UINT32)(*(UINT32 *)&data.NVVersion));
+      }
+      else
+      {
+          /* Set the header */
+          P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_ROOT__ABOUT, G_TESTER_STATUS_ERROR);
+      }
+      
+      g_tester_send_to_host(return_buffer, 19);
+  }
+  
+  
+  /************************************************************************
+  *                        g_tester_get_advanced_statistics_report       *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_set_rate(tiUINT8 rate_index)
+  {
+      ConParm_t param;
+      char rate_1mbps_rate_str[5] = "1";
+      char rate_2mbps_rate_str[5] = "2";
+      char rate_5_5mbps_rate_str[5] = "5.5";
+      char rate_11mbps_rate_str[5] = "11";
+      char rate_22mbps_rate_str[5] = "22";
+      
+      switch(rate_index)
+      {
+      case 0:
+          param.value = (tiUINT32)rate_1mbps_rate_str;
+          break;
+          
+      case 1:
+          param.value = (tiUINT32)rate_2mbps_rate_str;
+          break;
+          
+      case 2:
+          param.value = (tiUINT32)rate_5_5mbps_rate_str;
+          break;
+          
+      case 3:
+          param.value = (tiUINT32)rate_11mbps_rate_str;
+          break;
+          
+      case 4:
+          param.value = (tiUINT32)rate_22mbps_rate_str;
+          break;
+          
+      default:
+          param.value = (tiUINT32)rate_1mbps_rate_str;
+          break;
+      }
+      
+      cmd_modify_rate(&param, 1);
+  }
+  
+  /************************************************************************
+  *                        g_tester_wep_add_key                                                *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  void g_tester_wep_add_key(unsigned char *cmd_buffer)
+  {
+      UINT8 key_length;
+      UINT8 key_type;
+      ConParm_t key_params[4];
+      UINT8 hex_str[] = "hex";
+      UINT8 text_str[] = "text";
+      
+      /* Zero the variables (because i use 8 bit in 32 bit variables) */
+      key_params[1].value = 0;
+      key_params[2].value = 0;
+      
+      /* Read parameters */
+      key_length = cmd_buffer[65];             /* Buffer length */
+      key_type = cmd_buffer[68];                       /* Key type (hex = 0, text = 1) */
+      
+      /* Prepare parameters for the command */
+      key_params[0].value = (tiUINT32)&cmd_buffer[0];
+      cmd_buffer[key_length] = 0;
+      
+      key_params[1].value = (tiUINT32)cmd_buffer[66];
+      
+      key_params[2].value = (tiUINT32)cmd_buffer[67];
+      
+      if (key_type == 0)
+      {
+          key_params[3].value = (tiUINT32)&hex_str[0];
+      }
+      else
+      {
+          key_params[3].value = (tiUINT32)&text_str[0];
+      }
+      
+      /* Call the addkey command */
+      cmd_privacy_addkey(&key_params[0], 4);
+  }
+  
+  /************************************************************************
+  *                        g_tester_gwsi_event_handler                         *
+  ************************************************************************
+  DESCRIPTION: 
+  
+    CONTEXT    :                        
+  ************************************************************************/
+  int g_tester_gwsi_event_handler(IPC_EV_DATA* pData)
+  {
+      console_printf_terminal("g_tester,  g_tester_gwsi_event_handler. (Length = %d)\n", pData->uBufferSize);
+      
+      g_tester_send_to_host(pData->uBuffer, pData->uBufferSize);
+      
+      return 0;
+  }
+  
+  /************************************************************************
+  *                        g_tester_gwsi_event_handler                  *
+  ************************************************************************
+  DESCRIPTION: Read the register value and send it back by event.
+  
+  ************************************************************************/
+  void g_tester_cmd_plt_register_read(UINT32 uiRegAddress)
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1  : OpCode (0x0173)
+    Byte  2    : Command Status
+    Byte  3-6  : Register value
+      ***************************/
+      
+      tiUINT8 return_buffer[19];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      UINT32 uiRegisterValue;
+      tiUINT32 status = TI_PLT_ReadRegister(g_id_adapter, uiRegAddress, &uiRegisterValue);
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__REGISTER__READ, (UINT8)status);
+      
+      /* Add the result */
+      P_BUFFER_ADD_UINT32(p_return_buffer, uiRegisterValue);
+      
+      g_tester_send_to_host(return_buffer, 7);
+  }
+  
+  /************************************************************************
+  *                        g_tester_gwsi_event_handler                  *
+  ****** ******************************************************************
+  DESCRIPTION: Read the PLT RX PER .
+  
+  ************************************************************************/
+  void g_tester_cmd_plt_RxPer_GetResults()
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1   : OpCode (0x0178)
+    Byte  2     : Command Status
+    Byte  3-6   : FCSErrorCount
+    Byte  7-10  : TotalFrameCount
+    Byte  11-14 : PLCPFrameCount
+    Byte  15-18 : SeqNumMissCount
+      ***************************/
+      
+      tiUINT8 return_buffer[20];
+      tiUINT8 *p_return_buffer = return_buffer;
+      
+      PltRxPer_t PltRxPer; 
+      tiUINT32 status = TI_PLT_RxPerGetResults(g_id_adapter, &PltRxPer);
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__RX_PER__GET_RESULTS, (UINT8)status);
+      
+      /* Add the result */
+      P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.FCSErrorCount);
+      P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.TotalFrameCount);
+      P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.PLCPErrorCount);
+      P_BUFFER_ADD_UINT32(p_return_buffer, PltRxPer.SeqNumMissCount);
+      
+      g_tester_send_to_host(return_buffer, p_return_buffer - return_buffer);
+  }
+  
+  /************************************************************************
+  *                        g_tester_cmd_plt_mib_read                  *
+  ****** ******************************************************************
+  DESCRIPTION: Handle the reading of PLT over CLI MIBs .
+  
+  ************************************************************************/
+  void g_tester_cmd_plt_mib_read(unsigned char *cmd_buffer)
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1  : OpCode (0x017C)
+    Byte  2    : Command Status
+    Byte  3-6  : aMib 
+    Byte  7-10 : Mib Length
+    Bye   11-  : MIb data
+      ***************************/
+      
+      PLT_MIB_t* pMib = (PLT_MIB_t*)cmd_buffer;
+      
+      unsigned char return_buffer[3 + sizeof(PLT_MIB_t)];
+      unsigned char* p_return_buffer = return_buffer;
+      unsigned char* pReturnMibBuffer = return_buffer + 3;
+      PLT_MIB_t* pReturnMib = (PLT_MIB_t*)pReturnMibBuffer;
+      tiUINT32 status;
+      int PacketLength;
+      
+      pReturnMib->aMib =  pMib->aMib;
+      pReturnMib->Length = pMib->Length;
+      memcpy(&pReturnMib->aData, &pMib->aData, pMib->Length);
+      
+      status = TI_PLT_ReadMIB(g_id_adapter, pReturnMib);
+      
+      /* Set the event header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__MIB__READ, (UINT8)status);
+      
+      /* Set the MIB data */ 
+      PacketLength = 11 + pReturnMib->Length;
+      g_tester_send_to_host(return_buffer, PacketLength);    
+  }
+  
+  /************************************************************************
+  *                        g_tester_cmd_plt_mib_write                  *
+  ****** ******************************************************************
+  DESCRIPTION: Handle the writing of PLT over CLI MIBs .
+  
+  ************************************************************************/
+  void g_tester_cmd_plt_mib_write(unsigned char *cmd_buffer)
+  {
+      PLT_MIB_t* pMib = (PLT_MIB_t*)cmd_buffer;
+      TI_PLT_WriteMIB(g_id_adapter, pMib);
+  }
+  
+  
+  
+  
+  /************************************************************************
+  *                        g_tester_cmd_get_defaultWEPKey                  *
+  ****** ******************************************************************
+  DESCRIPTION: Get back the default WEP key .
+  
+  ************************************************************************/
+  void g_tester_cmd_get_defaultWEPKey(void)
+  {
+  /***************************
+  Return buffer structure :
+  
+    Bytes 0-1  : OpCode (0x117e)
+    Byte  2    : Command Status
+    Byte  3-6  : Default WEP key ID
+      ***************************/
+      
+      tiUINT8 return_buffer[6];
+      tiUINT8 *p_return_buffer = return_buffer;
+      tiUINT32 WepKeyId;
+      tiUINT32 status = TI_GetDefaultWepKey(g_id_adapter, &WepKeyId);
+      
+      /* Set the header */
+      P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PRIVACY__WEP__GET, (UINT8)status);
+      
+      /* Add the result */
+      P_BUFFER_ADD_UINT32(p_return_buffer, WepKeyId);
+      
+      g_tester_send_to_host(return_buffer, 5);
+  }
+  
+  /************************************************************************
+  *                        g_tester_gwsi_event_handler                         *
+  ************************************************************************
+  DESCRIPTION: Send the roaming candidates table to the GTester
+  
+  ************************************************************************/
+  void g_tester_Roaming_candidates_list(void)
+  {
+  /***************************
+  Return buffer structure (for header):
+  
+    Bytes 0-1  : OpCode (0x0004)
+    Byte  2       : Command Status
+    Byte  3       : Number of elements 
+      ***************************/
+      
+      /***************************
+      Return buffer structure (for each element):
+      
+        Bytes 0-1      : OpCode (0x113c)
+        Byte  2            : Command Status
+        Bytes 3-8   : MAC Address
+        Byte  9     : Band
+        Byte  10    : RSSI
+        Byte  11    : Channel
+        Byte  12    : Neighbor
+      ***************************/
+      tiUINT8 return_buffer[15];
+      tiUINT8 *p_return_buffer = return_buffer;
+      bssList_t bssList;
+      tiINT32 res;
+      tiUINT8 index;
+      
+      
+      /* get list */
+      res = TI_GetScanBssList( g_id_adapter, &bssList);
+      if( res != TI_RESULT_OK)
+      {
+          /*************************/
+          /* Error retrieving data */
+          /***********************/
+          
+          /* Set the header */
+          P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, res);
+          
+          /* Set dummy UINT8 */
+          P_BUFFER_ADD_UINT8(p_return_buffer, 0x00);
+          
+          g_tester_send_to_host(return_buffer, 4);
+      }
+      else
+      {
+          /*********************/
+          /* Header structure */
+          /*******************/
+          
+          /* Set the header */
+          P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST, res);
+          
+          /* Set dummy UINT8 */
+          P_BUFFER_ADD_UINT8(p_return_buffer, bssList.numOfEntries);
+          
+          g_tester_send_to_host(return_buffer, 4);
+          
+          /***********************/
+          /* Elements structure */
+          /*********************/
+          
+          for (index = 0; index < bssList.numOfEntries; index++)
+          {
+              p_return_buffer = return_buffer;
+              
+              /* Set the header */
+              P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BSSLIST, res);
+              
+              P_BUFFER_ADD_DATA(p_return_buffer, bssList.BSSList[index].BSSID.addr , sizeof(bssList.BSSList[index].BSSID));
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssList.BSSList[index].band);
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, bssList.BSSList[index].RSSI-256);  /*convert to negative number*/
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssList.BSSList[index].channel);
+              
+              P_BUFFER_ADD_UINT8(p_return_buffer, (tiUINT8)bssList.BSSList[index].bNeighborAP);
+              
+              g_tester_send_to_host(return_buffer, 13);
+              
+          }  
+      }      
+  }
+  
+  /************************************************************************
+  *                        g_tester_scAn__configApp__Display                           *
+  ************************************************************************
+  DESCRIPTION: Display the application scan configuration
+  
+  ************************************************************************/
+void g_tester_scAn__configApp__Display(void)
+{
+       /***************************
+       Return buffer structure (for each element):
+
+       Bytes 0-1       : OpCode (0x113c)
+       Byte  2     : Command Status
+       Bytes 3-15  : SSID(if SSID is 12 characters)
+    Byte  16    : Scan type
+       Byte  10    : Band
+       Byte  11    : Number of prob req
+       Byte  12    : rate
+    Byte  13    : AC
+       Byte  14    : Number of channel 
+       
+    for every channel:  
+    Byte  15    : channel number
+       Byte  16-21 : BSSID
+    Byte  21-23 : max time
+    Byte  23-27 : min time
+    Byte  28    : ET event
+       Byte  29    : ET frame num
+    Byte  30    : Power
+    Byte  31-   : Same as 15-30 for every channel  grater then 1
+       ***************************/
+   int i;
+   scan_normalChannelEntry_t* pNormalChannel;
+   tiUINT8 return_buffer[512];
+   tiUINT8 sSSID[33];
+   tiUINT8 *p_return_buffer = return_buffer;
+
+       /* Set the header */
+       P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_SCAN__CONFIGAPP__DISPLAY, 0);
+   
+    /* Data */
+    /* SSID*/
+    memset(sSSID, 0, sizeof(sSSID));
+    strcpy((char*)sSSID, (char*)appScanParams.desiredSsid.ssidString);
+    memcpy((void*)p_return_buffer, sSSID, sizeof(sSSID));
+    p_return_buffer += sizeof(sSSID);
+
+
+    P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.scanType);
+    P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.band);
+    P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.probeReqNumber);
+    P_BUFFER_ADD_UINT32(p_return_buffer, appScanParams.probeRequestRate);
+#ifdef TI_DBG    
+    P_BUFFER_ADD_UINT8(p_return_buffer, appScanParams.Tid);
+#else
+    P_BUFFER_ADD_UINT8(p_return_buffer, 0);
+#endif
+    P_BUFFER_ADD_UINT8(p_return_buffer,  appScanParams.numOfChannels);
+    for ( i = 0; i < appScanParams.numOfChannels; i++ )
+    {
+      pNormalChannel = &(appScanParams.channelEntry[ i ].normalChannelEntry);  
+      P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->channel);
+      memcpy((void*)p_return_buffer, (void*)(pNormalChannel->bssId.addr), sizeof(pNormalChannel->bssId.addr));
+      p_return_buffer += sizeof(pNormalChannel->bssId);
+      P_BUFFER_ADD_UINT32(p_return_buffer, pNormalChannel->maxChannelDwellTime);
+      P_BUFFER_ADD_UINT32(p_return_buffer, pNormalChannel->minChannelDwellTime);
+      P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->earlyTerminationEvent);
+      P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->ETMaxNumOfAPframes);
+      P_BUFFER_ADD_UINT8(p_return_buffer, pNormalChannel->txPowerDbm);
+    }
+       g_tester_send_to_host(return_buffer, p_return_buffer-return_buffer);
+}
+
+/*********************************************************************
+*                        g_tester_plt_calibration_get_nvs_buffer          *
+************************************************************************
+DESCRIPTION: Display the NVS update buffers
+************************************************************************/
+void g_tester_plt_calibration_get_nvs_buffer()
+{
+   tiUINT8 return_buffer[sizeof(PltNvsResultsBuffer_t) + 4];
+   tiUINT8 *p_return_buffer = return_buffer;
+   PltNvsResultsBuffer_t PltNvsResultsBuffer;
+   int i;
+   tiUINT32 status;
+   tiUINT32 DataSize;
+   memset(&PltNvsResultsBuffer, 0, sizeof(PltNvsResultsBuffer));
+   status = TI_PLT_RxTxCalNVSUpdateBuffer(g_id_adapter, &PltNvsResultsBuffer);
+   P_BUFFER_ADD_HDR_PARAMS(p_return_buffer, G_TESTER_CLI_CMD_PLT__CALIBRATION__GET_NVS_BUFFER, (UINT8)status);
+   if (status == OK)
+   {
+       P_BUFFER_ADD_UINT32(p_return_buffer, PltNvsResultsBuffer.numOfTables);
+       if (PltNvsResultsBuffer.numOfTables > NVS_RESULTS_MAX_NUM_OF_TABLES)
+       {
+           printf("%s:  aData.aLength (%d) > GWSI_PLT_NVS_RESULTS_MAX_NUM_OF_TABLES(%d) \n", __FUNCTION__,
+               PltNvsResultsBuffer.numOfTables, NVS_RESULTS_MAX_NUM_OF_TABLES);
+       }
+       else
+       {
+           for (i=0; i<PltNvsResultsBuffer.numOfTables; i++)
+           {
+               DataSize = PltNvsResultsBuffer.tables[i].size;
+               P_BUFFER_ADD_UINT16(p_return_buffer, DataSize);
+               P_BUFFER_ADD_UINT16(p_return_buffer, PltNvsResultsBuffer.tables[i].offset);
+                              
+               if (DataSize>NVS_RESULTS_MAX_UPDATE_TABLE_SIZE)
+               {
+                   printf("%s:  DataSize (%d) > NVS_RESULTS_MAX_UPDATE_TABLE_SIZE(%d) \n", __FUNCTION__,
+                       DataSize, NVS_RESULTS_MAX_UPDATE_TABLE_SIZE);
+                   continue;
+               }
+               
+               memcpy((PVOID)p_return_buffer, 
+                      (PVOID)PltNvsResultsBuffer.tables[i].data,
+                      DataSize);
+               p_return_buffer += DataSize;
+           }                
+       }
+   }
+       g_tester_send_to_host(return_buffer, p_return_buffer-return_buffer);
+}
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/g_tester.h b/sta_dk_4_0_4_32/CUDK/CLI/g_tester.h
new file mode 100644 (file)
index 0000000..5973603
--- /dev/null
@@ -0,0 +1,185 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef G_TESTER_H
+#define G_TESTER_H
+
+#define G_TESTER_CMD_GROUP_CLI                 (0x1000)
+#define G_TESTER_CMD_GROUP_GWSI                        (0x2000)
+#define G_TESTER_CMD_GROUP_GENERAL             (0x4000)
+
+                                  
+#define G_TESTER_IS_CLI_GROUP_CMD(_op) ((_op & G_TESTER_CMD_GROUP_CLI) != 0)
+#define G_TESTER_IS_GWSI_GROUP_CMD(_op)        ((_op & G_TESTER_CMD_GROUP_GWSI) != 0)
+#define G_TESTER_IS_GENERAL_GROUP_CMD(_op)     ((_op & G_TESTER_CMD_GROUP_GENERAL) != 0)
+
+#define G_TESTER_GENERAL_CMD_RUN_CMD   (G_TESTER_CMD_GROUP_GENERAL | 0x0001)
+#define G_TESTER_GENERAL_CMD_GET_INIT_T        (G_TESTER_CMD_GROUP_GENERAL | 0x0002)
+
+#define G_TESTER_GWSI_CMD_INITIALIZE   (G_TESTER_CMD_GROUP_GWSI | 0x0060)
+#define G_TESTER_GWSI_CMD_CONFIG           (G_TESTER_CMD_GROUP_GWSI | 0x0061)
+#define G_TESTER_GWSI_CMD_PLT              (G_TESTER_CMD_GROUP_GWSI | 0x0062)
+#define G_TESTER_GWSI_CMD_RELEASE              (G_TESTER_CMD_GROUP_GWSI | 0x0063)
+
+
+#define G_TESTER_CLI_CMD_DRIVER__START                            (G_TESTER_CMD_GROUP_CLI | 0x0001)
+#define G_TESTER_CLI_CMD_DRIVER__STOP                             (G_TESTER_CMD_GROUP_CLI | 0x0002)
+#define G_TESTER_CLI_CMD_DRIVER__STATUS                           (G_TESTER_CMD_GROUP_CLI | 0x0003)
+#define G_TESTER_CLI_CMD_ROOT__ABOUT                              (G_TESTER_CMD_GROUP_CLI | 0x0004)
+#define G_TESTER_CLI_CMD_CONNECTION__BSSID_LIST                   (G_TESTER_CMD_GROUP_CLI | 0x0010)
+#define G_TESTER_CLI_CMD_CONNECTION__CONNECT                      (G_TESTER_CMD_GROUP_CLI | 0x0013)
+#define G_TESTER_CLI_CMD_CONNECTION__DISASSOCIATE                 (G_TESTER_CMD_GROUP_CLI | 0x0014)
+#define G_TESTER_CLI_CMD_PRIVACY__AUTHENTICATION                  (G_TESTER_CMD_GROUP_CLI | 0x0030)
+#define G_TESTER_CLI_CMD_PRIVACY__EXC__NETWORKEAP                 (G_TESTER_CMD_GROUP_CLI | 0x0031)
+#define G_TESTER_CLI_CMD_PRIVACY__ENCRYPTION                      (G_TESTER_CMD_GROUP_CLI | 0x0032)
+#define G_TESTER_CLI_CMD_PRIVACY__KEYTYPE                         (G_TESTER_CMD_GROUP_CLI | 0x0033)
+#define G_TESTER_CLI_CMD_PRIVACY__MIXEDMODE                       (G_TESTER_CMD_GROUP_CLI | 0x0034)
+#define G_TESTER_CLI_CMD_PRIVACY__CREDENTIALS                     (G_TESTER_CMD_GROUP_CLI | 0x0035)
+#define G_TESTER_CLI_CMD_PRIVACY__WEP__ADD                        (G_TESTER_CMD_GROUP_CLI | 0x0036)
+#define G_TESTER_CLI_CMD_PRIVACY__WEP__REMOVE                     (G_TESTER_CMD_GROUP_CLI | 0x0037)
+#define G_TESTER_CLI_CMD_SCAN__START                              (G_TESTER_CMD_GROUP_CLI | 0x0040)
+#define G_TESTER_CLI_CMD_SCAN__STOP                               (G_TESTER_CMD_GROUP_CLI | 0x0041)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGAPP__GLOBAL                  (G_TESTER_CMD_GROUP_CLI | 0x0042)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGAPP__CHANNEL                 (G_TESTER_CMD_GROUP_CLI | 0x0043)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGAPP__CLEAR                   (G_TESTER_CMD_GROUP_CLI | 0x0044)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__GLOABAL              (G_TESTER_CMD_GROUP_CLI | 0x0045)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__MISC           (G_TESTER_CMD_GROUP_CLI | 0x0046)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__CHANNEL        (G_TESTER_CMD_GROUP_CLI | 0x0047)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__TRACK          (G_TESTER_CMD_GROUP_CLI | 0x0048)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__DISCOVERY      (G_TESTER_CMD_GROUP_CLI | 0x0049)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BAND__IMMEDIATE      (G_TESTER_CMD_GROUP_CLI | 0x004a)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__CLEAR                (G_TESTER_CMD_GROUP_CLI | 0x004b)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__STORE                (G_TESTER_CMD_GROUP_CLI | 0x004c)
+#define G_TESTER_CLI_CMD_EVENTS__REGISTER                         (G_TESTER_CMD_GROUP_CLI | 0x0050)
+#define G_TESTER_CLI_CMD_EVENTS__UNREGISTER                       (G_TESTER_CMD_GROUP_CLI | 0x0051)
+#define G_TESTER_CLI_CMD_REPORT__LEVEL                            (G_TESTER_CMD_GROUP_CLI | 0x0060)
+#define G_TESTER_CLI_CMD_REPORT__SET                              (G_TESTER_CMD_GROUP_CLI | 0x0061)
+#define G_TESTER_CLI_CMD_DEBUG__PRINT                             (G_TESTER_CMD_GROUP_CLI | 0x0062)
+#define G_TESTER_CLI_CMD_MANAGEMENT__RATE                         (G_TESTER_CMD_GROUP_CLI | 0x0070)
+#define G_TESTER_CLI_CMD_MANAGEMENT__MODE                         (G_TESTER_CMD_GROUP_CLI | 0x0071)
+#define G_TESTER_CLI_CMD_MANAGEMENT__PREAMBLE                     (G_TESTER_CMD_GROUP_CLI | 0x0072)
+#define G_TESTER_CLI_CMD_MANAGEMENT__CHANNEL                      (G_TESTER_CMD_GROUP_CLI | 0x0073)
+#define G_TESTER_CLI_CMD_MANAGEMENT__FRAG                         (G_TESTER_CMD_GROUP_CLI | 0x0074)
+#define G_TESTER_CLI_CMD_MANAGEMENT__RTS                          (G_TESTER_CMD_GROUP_CLI | 0x0075)
+#define G_TESTER_CLI_CMD_MANAGEMENT__SLOT                         (G_TESTER_CMD_GROUP_CLI | 0x0076)
+#define G_TESTER_CLI_CMD_MANAGEMENT__SIGNAL                       (G_TESTER_CMD_GROUP_CLI | 0x0077)
+#define G_TESTER_CLI_CMD_MANAGEMENT__TX_POWER_LEVEL               (G_TESTER_CMD_GROUP_CLI | 0x0078)
+#define G_TESTER_CLI_CMD_MANAGEMENT__SSID                         (G_TESTER_CMD_GROUP_CLI | 0x007c)
+#define G_TESTER_CLI_CMD_POWER__SET_POWER_MODE                    (G_TESTER_CMD_GROUP_CLI | 0x0090)
+#define G_TESTER_CLI_CMD_ROAMING__ENABLE                          (G_TESTER_CMD_GROUP_CLI | 0x00a0)
+#define G_TESTER_CLI_CMD_ROAMING__LOW_PASS_FILTER                 (G_TESTER_CMD_GROUP_CLI | 0x00a1)
+#define G_TESTER_CLI_CMD_ROAMING__QUALITY_THRESHOLD               (G_TESTER_CMD_GROUP_CLI | 0x00a2)
+#define G_TESTER_CLI_CMD_ROAMING__SET                             (G_TESTER_CMD_GROUP_CLI | 0x00a3)
+
+#define G_TESTER_CLI_CMD_CONNECTION__STATUS                       (G_TESTER_CMD_GROUP_CLI | 0x0106)
+#define G_TESTER_CLI_CMD_CONNECTION__FULL_BSSID_LIST              (G_TESTER_CMD_GROUP_CLI | 0x0107)
+#define G_TESTER_CLI_CMD_MANAGEMENT__INFO                         (G_TESTER_CMD_GROUP_CLI | 0x0110)
+#define G_TESTER_CLI_CMD_MANAGEMENT__DRIVERSTATE                  (G_TESTER_CMD_GROUP_CLI | 0x0111)
+#define G_TESTER_CLI_CMD_MANAGEMENT__TX_POWER_DBM                 (G_TESTER_CMD_GROUP_CLI | 0x0114)
+#define G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_ENABLEDISABLE   (G_TESTER_CMD_GROUP_CLI | 0x0115)
+#define G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__H_ENABLEDISABLE   (G_TESTER_CMD_GROUP_CLI | 0x0116)
+#define G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_COUNTRY_2_4IE   (G_TESTER_CMD_GROUP_CLI | 0x0117)
+#define G_TESTER_CLI_CMD_MANAGEMENT__802_11D_H__D_COUNTRY_5IE     (G_TESTER_CMD_GROUP_CLI | 0x0118)
+#define G_TESTER_CLI_CMD_MANAGEMENT__ANTENNA__DIVERSITYPARAMS     (G_TESTER_CMD_GROUP_CLI | 0x0119)
+#define G_TESTER_CLI_CMD_MANAGEMENT__BEACON__SET_BEACON_FILTER_MODE (G_TESTER_CMD_GROUP_CLI | 0x011a)
+#define G_TESTER_CLI_CMD_MANAGEMENT__ADVANCED__DRAFT              (G_TESTER_CMD_GROUP_CLI | 0x011b)
+#define G_TESTER_CLI_CMD_MANAGEMENT__ADVANCED__SUPPORTED_RATES    (G_TESTER_CMD_GROUP_CLI | 0x011c)
+#define G_TESTER_CLI_CMD_SHOW__STATISTICS                         (G_TESTER_CMD_GROUP_CLI | 0x011d)
+#define G_TESTER_CLI_CMD_SHOW__TX_STATISTICS                      (G_TESTER_CMD_GROUP_CLI | 0x011e)
+#define G_TESTER_CLI_CMD_SHOW__ADVANCED                           (G_TESTER_CMD_GROUP_CLI | 0x011f)
+#define G_TESTER_CLI_CMD_PRIVACY__EAP                             (G_TESTER_CMD_GROUP_CLI | 0x0121)
+#define G_TESTER_CLI_CMD_PRIVACY__PSKPASSPHRASE                   (G_TESTER_CMD_GROUP_CLI | 0x0126)
+#define G_TESTER_CLI_CMD_PRIVACY__CERTIFICATE                     (G_TESTER_CMD_GROUP_CLI | 0x0127)
+#define G_TESTER_CLI_CMD_PRIVACY__WPA_OPTIONS                     (G_TESTER_CMD_GROUP_CLI | 0x0128)
+#define G_TESTER_CLI_CMD_PRIVACY__EXC__CONFIGURE                  (G_TESTER_CMD_GROUP_CLI | 0x012b)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGAPP__DISPLAY                 (G_TESTER_CMD_GROUP_CLI | 0x0132)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__DISPLAY              (G_TESTER_CMD_GROUP_CLI | 0x0139)
+#define G_TESTER_CLI_CMD_SCAN__CONFIGPOLICY__BSSLIST              (G_TESTER_CMD_GROUP_CLI | 0x013c)
+#define G_TESTER_CLI_CMD_ROAMING__GET                             (G_TESTER_CMD_GROUP_CLI | 0x0141)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__TX_RETRY            (G_TESTER_CMD_GROUP_CLI | 0x0143)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__BSS_LOSS            (G_TESTER_CMD_GROUP_CLI | 0x0144)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__TX_RATE_THRESHOLD   (G_TESTER_CMD_GROUP_CLI | 0x0145)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_RSSI_THRESHOLD  (G_TESTER_CMD_GROUP_CLI | 0x0146)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_SNR_THRESHOLD   (G_TESTER_CMD_GROUP_CLI | 0x0147)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__LOW_QUALITY_FOR_SCAN (G_TESTER_CMD_GROUP_CLI | 0x0148)
+#define G_TESTER_CLI_CMD_ROAMING__THRESHOLDS__NORMAL_QUALITY_FOR_SCAN (G_TESTER_CMD_GROUP_CLI | 0x0149)
+#define G_TESTER_CLI_CMD_QOS__UPSD__ADD                           (G_TESTER_CMD_GROUP_CLI | 0x014a)
+#define G_TESTER_CLI_CMD_QOS__UPSD__GET                           (G_TESTER_CMD_GROUP_CLI | 0x014b)
+#define G_TESTER_CLI_CMD_QOS__UPSD__DELETE                        (G_TESTER_CMD_GROUP_CLI | 0x014c)
+#define G_TESTER_CLI_CMD_QOS__UPSD__AP_PARAMS                     (G_TESTER_CMD_GROUP_CLI | 0x014d)
+#define G_TESTER_CLI_CMD_QOS__UPSD__AP_CAPABILITIES               (G_TESTER_CMD_GROUP_CLI | 0x014e)
+#define G_TESTER_CLI_CMD_QOS__UPSD__AC_STATUS                     (G_TESTER_CMD_GROUP_CLI | 0x014f)
+#define G_TESTER_CLI_CMD_QOS__UPSD__MEDIUM_USAGE                  (G_TESTER_CMD_GROUP_CLI | 0x0150)
+#define G_TESTER_CLI_CMD_QOS__UPSD__PHY_RATE                      (G_TESTER_CMD_GROUP_CLI | 0x0151)
+#define G_TESTER_CLI_CMD_QOS__UPSD__DESIRED_PS_MODE               (G_TESTER_CMD_GROUP_CLI | 0x0152)
+#define G_TESTER_CLI_CMD_QOS__CLASSIFIER__TXCLASSIFIER            (G_TESTER_CMD_GROUP_CLI | 0x0153)
+#define G_TESTER_CLI_CMD_QOS__CLASSIFIER__INSERT                  (G_TESTER_CMD_GROUP_CLI | 0x0154)
+#define G_TESTER_CLI_CMD_QOS__CLASSIFIER__REMOVE                  (G_TESTER_CMD_GROUP_CLI | 0x0155)
+#define G_TESTER_CLI_CMD_QOS__QOSPARAMS                           (G_TESTER_CMD_GROUP_CLI | 0x0156)
+#define G_TESTER_CLI_CMD_QOS__POLL_AP_PACKETS                     (G_TESTER_CMD_GROUP_CLI | 0x0157)
+#define G_TESTER_CLI_CMD_QOS__RX_TIMEOUT                          (G_TESTER_CMD_GROUP_CLI | 0x0158)
+#define G_TESTER_CLI_CMD_POWER__SET_POWERSAVE_POWERLEVEL          (G_TESTER_CMD_GROUP_CLI | 0x015a)
+#define G_TESTER_CLI_CMD_POWER__TRAFFIC_THRESHOLDS                (G_TESTER_CMD_GROUP_CLI | 0x015b)
+#define G_TESTER_CLI_CMD_POWER__ENABLE                            (G_TESTER_CMD_GROUP_CLI | 0x015c)
+#define G_TESTER_CLI_CMD_POWER__DISABLE                           (G_TESTER_CMD_GROUP_CLI | 0x015d)
+#define G_TESTER_CLI_CMD_FILE__LOAD                               (G_TESTER_CMD_GROUP_CLI | 0x0162)
+#define G_TESTER_CLI_CMD_BT_COEXSISTANCE__ENABLE                  (G_TESTER_CMD_GROUP_CLI | 0x0163)
+#define G_TESTER_CLI_CMD_BT_COEXSISTANCE__RATE                    (G_TESTER_CMD_GROUP_CLI | 0x0164)
+#define G_TESTER_CLI_CMD_BT_COEXSISTANCE__CONFIG                  (G_TESTER_CMD_GROUP_CLI | 0x0165)
+#define G_TESTER_CLI_CMD_BT_COEXSISTANCE__STATUS                  (G_TESTER_CMD_GROUP_CLI | 0x0166)
+#define G_TESTER_CLI_CMD_MEASUREMENT__ENABLE                      (G_TESTER_CMD_GROUP_CLI | 0x0167)
+#define G_TESTER_CLI_CMD_MEASUREMENT__DISABLE                     (G_TESTER_CMD_GROUP_CLI | 0x0168)
+#define G_TESTER_CLI_CMD_MEASUREMENT__MAX_DURATION                (G_TESTER_CMD_GROUP_CLI | 0x0169)
+#define G_TESTER_CLI_CMD_REPORT__ADD                              (G_TESTER_CMD_GROUP_CLI | 0x016b)
+#define G_TESTER_CLI_CMD_REPORT__CLEAR                            (G_TESTER_CMD_GROUP_CLI | 0x016c)
+#define G_TESTER_CLI_CMD_DEBUG__REGISTER                          (G_TESTER_CMD_GROUP_CLI | 0x016e)
+#define G_TESTER_CLI_CMD_DEBUG__BUFFER                            (G_TESTER_CMD_GROUP_CLI | 0x0170)
+#define G_TESTER_CLI_CMD_ROOT__QUIT                               (G_TESTER_CMD_GROUP_CLI | 0x0172)
+
+#define G_TESTER_CLI_CMD_PLT__REGISTER__READ                      (G_TESTER_CMD_GROUP_CLI | 0x0173)
+#define G_TESTER_CLI_CMD_PLT__REGISTER__WRITE                     (G_TESTER_CMD_GROUP_CLI | 0x0174)
+#define G_TESTER_CLI_CMD_PLT__RX_PER__START                       (G_TESTER_CMD_GROUP_CLI | 0x0175)
+#define G_TESTER_CLI_CMD_PLT__RX_PER__STOP                        (G_TESTER_CMD_GROUP_CLI | 0x0176)
+#define G_TESTER_CLI_CMD_PLT__RX_PER__CLEAR                       (G_TESTER_CMD_GROUP_CLI | 0x0177)
+#define G_TESTER_CLI_CMD_PLT__RX_PER__GET_RESULTS                 (G_TESTER_CMD_GROUP_CLI | 0x0178)
+#define G_TESTER_CLI_CMD_PLT__TX__CW                              (G_TESTER_CMD_GROUP_CLI | 0x0179)
+#define G_TESTER_CLI_CMD_PLT__TX__CONTINUES                       (G_TESTER_CMD_GROUP_CLI | 0x017a)
+#define G_TESTER_CLI_CMD_PLT__TX__STOP                            (G_TESTER_CMD_GROUP_CLI | 0x017b)
+#define G_TESTER_CLI_CMD_PLT__MIB__READ                           (G_TESTER_CMD_GROUP_CLI | 0x017c)
+#define G_TESTER_CLI_CMD_PLT__MIB__WRITE                          (G_TESTER_CMD_GROUP_CLI | 0x017d)
+
+#define G_TESTER_CLI_CMD_PRIVACY__WEP__GET                        (G_TESTER_CMD_GROUP_CLI | 0x017e)
+
+#define G_TESTER_CLI_CMD_PLT__CALIBRATION__RX                     (G_TESTER_CMD_GROUP_CLI | 0x017f)
+#define G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__START              (G_TESTER_CMD_GROUP_CLI | 0x0180)
+#define G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__STOP               (G_TESTER_CMD_GROUP_CLI | 0x0181)
+#define G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_GET           (G_TESTER_CMD_GROUP_CLI | 0x0182)
+#define G_TESTER_CLI_CMD_PLT__CALIBRATION__TX__GAIN_ADJUST        (G_TESTER_CMD_GROUP_CLI | 0x0183)
+#define G_TESTER_CLI_CMD_PLT__CALIBRATION__GET_NVS_BUFFER         (G_TESTER_CMD_GROUP_CLI | 0x0184)
+#define G_TESTER_CLI_CMD_PLT_RADIO_TUNE                           (G_TESTER_CMD_GROUP_CLI | 0x0185)
+
+void g_tester_init(void);
+void g_tester_deinit(void);                                    
+         
+void g_tester_receive_event(unsigned char event_index);
+unsigned char g_tester_check_command(unsigned char *input_string);
+
+#endif /* G_TESTER_H */
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/ipc.c b/sta_dk_4_0_4_32/CUDK/CLI/ipc.c
new file mode 100644 (file)
index 0000000..382471b
--- /dev/null
@@ -0,0 +1,159 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+/****************************************************************************************************/
+/*                                                                                                  */
+/*      MODULE:     ipc.c                                                                           */
+/*      PURPOSE:    Inter Process Communication utils                                               */
+/*      Note:      This module is for LINUX compilation only!                                                                          */
+/*                                                                                                  */
+/****************************************************************************************************/
+
+#include <sys/mman.h>
+#include <sys/ipc.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "console.h"
+#include "ticon.h"
+#include "ipc.h"
+
+       /*********************/
+       /* Global variables */
+       /*******************/
+
+int ethernet_wipp_process_pid = 0;
+int ethernet_g_tester_process_pid = 0;
+int ethernet_logger_process_pid = 0;
+
+
+int ethernet_wipp_control_pipe[2];
+int ethernet_g_tester_pipe[2];
+int ethernet_logger_pipe[2];
+
+int ipc_pipe[2];
+
+void *p_shared_memory;
+
+
+/************************************************************************
+ *                        ipc_initialize                                               *
+ ************************************************************************
+DESCRIPTION: Initialize the IPC 
+
+CONTEXT:  main process only!
+************************************************************************/
+int ipc_initialize()
+{
+       /*****************************/
+       /* Create IPC shared memory */
+       /***************************/
+
+       if ((p_shared_memory = mmap(0, SHARED_MEMORY_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == (void *)-1) 
+       {
+               /* I should use the regular 'printf' function, because the 
+                  'console_printf_terminal' is not working w/o shared memory */
+               printf("IPC Error, can't create shared memory mapping (%s)!\n", strerror(errno));
+
+               return -1;
+       }
+
+       SHARED_MEMORY_TERMINAL_OUTPUT_PATH() = OUTPUT_PATH_SIMPLE_UART;
+
+       /************************/
+       /* Create the IPC pipe */
+       /**********************/
+
+       if (pipe(ipc_pipe) < 0)
+       {
+               console_printf_terminal("IPC Error, can't create pipe\n");
+
+               return -1;
+       }
+
+       /* Close the write direction of the pipe  - because i only read information from this pipe. */ 
+       /*close(ipc_pipe[1]);*/
+
+       return 0;
+}
+
+/************************************************************************
+ *                        ipc_deinitialize                                             *
+ ************************************************************************
+DESCRIPTION: Deinitialize the IPC 
+
+CONTEXT:  main process only!
+************************************************************************/
+void ipc_deinitialize()
+{
+       /* Close the read direction of the pipe */ 
+       close(ipc_pipe[0]);
+}
+
+/************************************************************************
+ *                        ipc_send_command_to_main_process              *
+ ************************************************************************
+DESCRIPTION: Handles the 'SIGUSR1' signal 
+
+CONTEXT:  All child process - NOT FROM parent process!!!!
+************************************************************************/
+void ipc_send_command_to_main_process(int module_index, unsigned char *command, int size)
+{
+       int pid = getpid();
+
+       /*********************************************************************/
+       /* Flow control                                                                                                         */
+       /* The pid of the caller process is inserted, so the main process  */
+       /* will signal it back and release the waiting condition                  */
+       /*****************************************************************/
+
+       command[0] = command[1] = 0xFF;
+
+       switch (module_index)
+       {
+       case ETHERNET_UTILS_G_TESTER_MODULE_ID:
+               command[0] = (pid & 0x00FF);
+               command[1] = ((pid & 0xFF00) >> 8);
+               command[2] = '-';
+               break;
+
+       case ETHERNET_UTILS_WIPP_MODULE_ID:
+       case ETHERNET_UTILS_LOGGER_MODULE_ID:
+               command[0] = (pid & 0x00FF);
+               command[1] = ((pid & 0xFF00) >> 8);
+               command[2] = '+';
+               break;
+
+       case GENERAL_PROCESS_MODULE_ID:
+               command[2] = '!';
+               break;
+       }
+
+       /* Send the buffer to the main process */
+       write(ipc_pipe[1], command, size);
+
+       /* Wait for 300usec (probably the signal will release us earlier) */
+       usleep(300);
+}
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/ipc.h b/sta_dk_4_0_4_32/CUDK/CLI/ipc.h
new file mode 100644 (file)
index 0000000..0770406
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef IPC_H
+#define IPC_H
+
+#define TERMINAL_MUX_UART_ID           (28)
+#define LOGGER_MUX_UART_ID                     (30)
+#define WIPP_CONTROL_MUX_UART_ID       (25)
+#define G_TESTER_MUX_UART_ID           (23)
+
+
+#define ETHERNET_UTILS_NUMBER_OF_MODULES       (4)
+#define ETHERNET_UTILS_TERMINAL_MODULE_ID      (0)
+#define ETHERNET_UTILS_LOGGER_MODULE_ID                (1)
+#define ETHERNET_UTILS_WIPP_MODULE_ID          (2)
+#define ETHERNET_UTILS_G_TESTER_MODULE_ID      (3)
+
+#define GENERAL_PROCESS_MODULE_ID                      (4)
+
+#define WIPP_CONTROL_FROM_GENERAL_PROCESS_SEND_TERMINATE       (0x00)
+#define WIPP_CONTROL_FROM_GENERAL_PROCESS_DEACTIVATE_IPERF     (0x01)
+
+extern void *p_shared_memory;
+extern int ipc_semaphore_id;
+
+extern int ethernet_logger_process_pid;
+extern int ethernet_g_tester_process_pid;
+extern int ethernet_wipp_process_pid;
+
+extern int ethernet_wipp_control_pipe[2];
+extern int ethernet_g_tester_pipe[2];
+extern int ethernet_logger_pipe[2];
+
+extern int ipc_pipe[2];
+
+typedef struct t_shared_memory_rec
+{
+#define OUTPUT_PATH_SIMPLE_UART        (0)
+#define OUTPUT_PATH_MUX_UART   (1)
+#define OUTPUT_PATH_ETHERNET   (2)
+       unsigned char output_paths[ETHERNET_UTILS_NUMBER_OF_MODULES];
+       unsigned char mux_uart_id[ETHERNET_UTILS_NUMBER_OF_MODULES];
+       int ethernet_socket_ids[ETHERNET_UTILS_NUMBER_OF_MODULES]; 
+       int ipc_pipe[ETHERNET_UTILS_NUMBER_OF_MODULES];
+       unsigned char uart_mux_enabled;
+       int debug_module_dev_file;
+       int run_process_state;
+       int run_process_result;
+} shared_memory_reco;
+
+#define SHARED_MEMORY_SIZE     (sizeof(shared_memory_reco))
+
+
+#define SHARED_MEMORY_OUTPUT_PATH(_module_index)               (((shared_memory_reco *)(p_shared_memory))->output_paths[_module_index])        
+#define SHARED_MEMORY_TERMINAL_OUTPUT_PATH()                   (((shared_memory_reco *)(p_shared_memory))->output_paths[ETHERNET_UTILS_TERMINAL_MODULE_ID])    
+#define SHARED_MEMORY_LOGGER_OUTPUT_PATH()                             (((shared_memory_reco *)(p_shared_memory))->output_paths[ETHERNET_UTILS_LOGGER_MODULE_ID])      
+#define SHARED_MEMORY_WIPP_OUTPUT_PATH()                               (((shared_memory_reco *)(p_shared_memory))->output_paths[ETHERNET_UTILS_WIPP_MODULE_ID])        
+
+#define SHARED_MEMORY_ETHERNET_SOCKET_ID(_module_index) (((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[_module_index])        
+#define SHARED_MEMORY_ETHERNET_TERMINAL_SOCKET_ID()            (((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[ETHERNET_UTILS_TERMINAL_MODULE_ID])             
+#define SHARED_MEMORY_ETHERNET_LOGGER_SOCKET_ID()              (((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[ETHERNET_UTILS_LOGGER_MODULE_ID])               
+#define SHARED_MEMORY_ETHERNET_WIPP_SOCKET_ID()                        (((shared_memory_reco *)(p_shared_memory))->ethernet_socket_ids[ETHERNET_UTILS_WIPP_MODULE_ID])
+
+#define SHARED_MEMORY_IPC_PIPE(_module_index)                  (((shared_memory_reco *)(p_shared_memory))->ipc_pipe[_module_index])
+#define SHARED_MEMORY_MUX_UART_ID(_module_index)               (((shared_memory_reco *)(p_shared_memory))->mux_uart_id[_module_index])
+
+#define SHARED_MEMORY_UART_MUX_ENABLED()                               (((shared_memory_reco *)(p_shared_memory))->uart_mux_enabled)   
+
+#define SHARED_MEMORY_RUN_PROCESS_RUNNING()                            (((shared_memory_reco *)(p_shared_memory))->run_process_state)  
+#define SHARED_MEMORY_RUN_PROCESS_RESULT()                             (((shared_memory_reco *)(p_shared_memory))->run_process_result) 
+
+#define SHARED_MEMORY_SWITCH_TO_UART_OUTPUT(_module_index)     (SHARED_MEMORY_OUTPUT_PATH(_module_index) = (SHARED_MEMORY_UART_MUX_ENABLED() ? OUTPUT_PATH_MUX_UART : OUTPUT_PATH_SIMPLE_UART)) 
+
+#define SHARED_MEMORY_DBG_DEV_FILE()                               (((shared_memory_reco *)(p_shared_memory))->debug_module_dev_file) 
+
+
+int ipc_initialize(void);
+void ipc_deinitialize(void);
+void ipc_send_command_to_main_process(int module_index, unsigned char *commnad, int size);
+
+#endif /* IPC_H */
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/ticon.c b/sta_dk_4_0_4_32/CUDK/CLI/ticon.c
new file mode 100644 (file)
index 0000000..ef8658e
--- /dev/null
@@ -0,0 +1,1474 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef _WINDOWS
+#else /* __LINUX__ */
+       #include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/wireless.h>
+#include <stdarg.h>
+#include <sys/socket.h>
+#include <linux/in.h>
+#include "ipc.h"
+#include "wipp_ctrl.h"
+#include "eth_utils.h"
+#include "dbg_module.h"
+#include "g_tester.h"
+       #define LINUX_OS_FILES
+#endif
+
+#define MAX_CERT_FILE_NAME_LENGTH 32
+#define MAX_CERT_PASSWORD_LENGTH 32
+#define MAX_CERT_USER_NAME_LENGTH 32
+#define MAX_PSK_STRING_LENGTH       64 /* MAX string phrase is 63 chars, but hexa phrase is 64 chars excactly */
+#define MIN_PSK_STRING_LENGTH       8  /* MIN string phrase is 8 chars */
+
+#include "paramOut.h"
+#include "linux_ioctl_common.h"
+#include "tiioctl.h"
+#include "console.h"
+#include "ticon.h"
+#include "cu_cmd.h"
+
+#define WLAN_DEVICE_NAME           (_T("TIWLNAPI1"))
+
+#ifdef EXC_MODULE_INCLUDED
+#include "TI_AdapterEXC.h"
+#endif /*EXC_MODULE_INCLUDED*/
+#include "TI_AdapterApiC.h"
+#include "TI_IPC_Api.h"
+
+
+extern void osInitTable(initTable_t *InitTable);
+
+void quit_func(void);
+void dummy_func(void);
+
+void init_extended_tools(void);
+void deinit_extended_tools(void);
+
+char    g_drv_name[IFNAMSIZ + 1];
+
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+
+#define MAX_HOST_MESSAGE_SIZE  (256)
+
+/************************************************************************
+ *                        console_printf_terminal                              *
+ ************************************************************************
+DESCRIPTION: Sends a text message to host
+
+CONTEXT:  Any process, the 'p_shared_memory' points
+                 to the shared memory block
+************************************************************************/
+int console_printf_terminal(const char *arg_list ,...)
+{
+#ifndef _WINDOWS /*TRS:WDK slightly different code needed for each OS*/
+       va_list ap;
+    tiUINT8 msg[MAX_HOST_MESSAGE_SIZE];
+       int message_length;
+
+       /***********************/
+       /* Format the message */
+       /*********************/
+
+       va_start(ap, arg_list);
+       message_length = vsnprintf((char*)&msg[0], sizeof(msg), arg_list, ap);
+
+       /*********************************/
+       /* Send the message to the host */
+       /*******************************/
+
+       return console_send_buffer_to_host(ETHERNET_UTILS_TERMINAL_MODULE_ID, msg, message_length);
+
+#else /* _WINDOWS */
+#endif /* _WINDOWS */
+}
+
+#ifndef _WINDOWS
+#define ETHERNET_PROTOCOL_PREFIX_SIZE  (3)
+#define MUX_UART_PROTOCOL_PREFIX_SIZE  (2)
+/************************************************************************
+ *                        console_send_buffer_to_host                   *
+ ************************************************************************
+DESCRIPTION: Sends a text message to host
+
+CONTEXT:  Any process, the 'p_shared_memory' points
+                 to the shared memory block
+************************************************************************/
+int console_send_buffer_to_host(tiUINT8 module_inedx, tiUINT8 *buffer, tiUINT16 length)
+{
+       tiUINT8 output_path = SHARED_MEMORY_OUTPUT_PATH(module_inedx);
+       tiUINT8 protocol_header[3];
+       int return_size, ret;
+
+       /*****************/
+       /* Sanity check */
+       /***************/
+
+       if (output_path == OUTPUT_PATH_ETHERNET)
+       {
+               /***********************/
+               /* Output to ethernet */
+               /*********************/
+
+               /* Prepare the header */
+               protocol_header[0] = 'W';                                       /* Ethernet protocol Prefix */
+               protocol_header[1] = length & 0xFF;                     /* Message size (first byte) */
+               protocol_header[2] = (length >> 8) & 0xFF;      /* Message size (second byte) */
+
+               /* Send the header */
+               ret = write(SHARED_MEMORY_IPC_PIPE(module_inedx), protocol_header, ETHERNET_PROTOCOL_PREFIX_SIZE);
+        if( ret <= 0 )
+        {
+            printf("\tERROR: %s() returned %d (err=%d)\n\n", __FUNCTION__, ret, errno );
+            return 0;
+        }
+
+               /* Send the message */
+               ret = write(SHARED_MEMORY_IPC_PIPE(module_inedx), buffer, length);
+        if( ret <= 0 )
+        {
+            printf("\tERROR1: %s() returned %d (err=%d)\n\n", __FUNCTION__, ret, errno );
+            return 0;
+        }
+
+               return_size = (ETHERNET_PROTOCOL_PREFIX_SIZE + length);
+       }
+       else if (output_path == OUTPUT_PATH_MUX_UART)
+       {
+               /***********************/
+               /* OUTPUT to mux UART */
+               /*********************/
+
+               /* Write the protocol prefix */
+               protocol_header[0] = (28 << 3);
+               protocol_header[1] = length;
+               fwrite(protocol_header, 1, MUX_UART_PROTOCOL_PREFIX_SIZE, stdout);
+
+               /* Write the message */
+               fwrite(buffer, 1, length, stdout);
+
+               return_size = (MUX_UART_PROTOCOL_PREFIX_SIZE + length);
+       }
+       else
+       {
+               /*******************/
+               /* OUTPUT to UART */
+               /*****************/
+
+               /* Use the original printf function */
+               return_size = printf("%s", buffer);
+       }
+
+       return return_size;
+}
+#endif /* __LINUX__ */
+
+
+#ifdef _WINDOWS
+#endif /* WINDOWS */
+
+void dummy_func()
+{
+    console_printf_terminal("1: not implemented yet!!\n");
+}
+
+void quit_func(void)
+{
+    consoleStop();
+}
+
+int print_usage(char  *eeprom_file_name, char  *init_file_name, char *firmware_file_name)
+{
+#ifdef _WINDOWS
+#else
+    fprintf(stderr, "Usage: ./wlan_cu [driver_name] [options]\n");
+#endif
+    fprintf(stderr, "   -s <filename>  - run script\n");
+    fprintf(stderr, "   -e <filename>  - eeprom image file name. Dft=%s\n", eeprom_file_name);
+    fprintf(stderr, "   -i <filename>  - init file name. Dft=%s\n", init_file_name);
+    fprintf(stderr, "   -f <filename>  - firmware image file name. Dft=%s\n",firmware_file_name);
+    fprintf(stderr, "   -b             - bypass supplicant\n");
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+    return 1;
+}
+
+int init_console_menu(void)
+{
+    handle_t h, h1, h2;
+
+    /* -------------------------------------------- Driver -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "Driver",  "Driver start/stop" ) );
+        {
+            ConParm_t aaa[]  = { { "start_suppl_manager", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Start",  "Start driver", (FuncToken_t) cmd_start_driver, aaa );
+        }
+            consoleAddToken(h, "stoP",   "Stop driver", (FuncToken_t) cmd_stop_driver, NULL );
+            consoleAddToken(h, "stAtus", "Print status", (FuncToken_t) cmd_show_status, NULL );
+
+    /* -------------------------------------------- Connection -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "Connection",  "Connection management" ) );
+        consoleAddToken(h, "Bssid_list",  "Bssid_list", (FuncToken_t) cmd_bssid_list, NULL );
+        {
+            ConParm_t aaa[]  = { { "ssid",     CON_PARM_STRING | CON_PARM_OPTIONAL, 0, 32, 0 },
+                                                                { "bssid", CON_PARM_STRING | CON_PARM_OPTIONAL, 0, 32, 0 },
+                                                               CON_LAST_PARM };
+
+            consoleAddToken(h, "Connect",  "Connect", (FuncToken_t) cmd_connect, aaa );
+        }
+        consoleAddToken(h, "Disassociate",  "disconnect", (FuncToken_t) cmd_disassociate, NULL );
+        consoleAddToken(h, "Status", "Print connection status", (FuncToken_t) cmd_show_status, NULL );
+        consoleAddToken(h, "Full_bssid_list",  "Full_bssid_list", (FuncToken_t) cmd_Full_bssid_list, NULL );
+        consoleAddToken(h, "full_Primary_bssid",  "Full_Primary_bssid", (FuncToken_t) cmd_FullPrimaryBbssid, NULL );
+
+
+    /* -------------------------------------------- Management -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "Management",  "Station management" ) );
+        {
+            ConParm_t aaa[]  = { { "ssid", CON_PARM_LINE | CON_PARM_OPTIONAL, 0, 32, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Ssid",  "Set prefered SSID", (FuncToken_t) cmd_modify_ssid, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "channel", /*CON_PARM_RANGE | */CON_PARM_OPTIONAL, 0, 0/*1000*/, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Channel",  "Set the channel", (FuncToken_t) cmd_modify_channel, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "tx rate", CON_PARM_STRING | CON_PARM_OPTIONAL, 0, 32, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Rate",  "Get TX data rate in Mbps (1,2,5.5,11,22)", (FuncToken_t) cmd_modify_rate, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "BSS_type", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Mode",  "BSS_type", (FuncToken_t) cmd_modify_bss_type, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "frag", /*CON_PARM_RANGE | */CON_PARM_OPTIONAL, 0/*256*/, 0/*2346*/, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Frag",  "Set the fragmentation threshold <256..2346>", (FuncToken_t) cmd_modify_frag_threshold, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "rts", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "rts",  "Set RTS threshold <0..2347>", (FuncToken_t) cmd_modify_rts_threshold, aaa);
+        }
+        {
+            ConParm_t aaa[]  = { { "preamble", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 1, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "prEamble",  "Set preamble type 1=short 0=long", (FuncToken_t) cmd_modify_preamble, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "slot", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "sLot",  "Set short  slot", (FuncToken_t) cmd_modify_short_slot, aaa );
+        }
+            consoleAddToken(h, "Info",  "Get Selected BSSID Info", (FuncToken_t) cmd_get_selected_bssid_info, NULL );
+            consoleAddToken(h, "DriverState",  "Get Driver State", (FuncToken_t) cmd_get_driver_state, NULL );
+            consoleAddToken(h, "siGnal",  "Get Current RSSI level", (FuncToken_t) cmd_get_rsii_level, NULL );
+                       consoleAddToken(h, "snr ratiO",  "Get Current SNR radio", (FuncToken_t) cmd_get_snr_ratio, NULL );
+
+
+        {
+            ConParm_t aaa[]  = { { "Tx power level", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "tX_power_level_table",  "Tx power level", (FuncToken_t) cmd_show_tx_power_level_table, aaa );
+            consoleAddToken(h, "tx_power_dBm_div10",  "Tx power level", (FuncToken_t) cmd_tx_power_dbm, aaa );
+        }
+        consoleAddToken(h, "arP ip addresses table",  "Get ARP IP address table", (FuncToken_t) cmd_get_arpIpTable, NULL);
+    consoleAddToken(h, "groUp address table",  "Get Group address table", (FuncToken_t) cmd_get_GroupAddressTable, NULL);
+
+
+        CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "802_11d_h",  "802_11D_H" ) );
+            {
+                    ConParm_t aaa[]  = { { "802_11_D", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                    ConParm_t bbb[]  = {
+                            { "min DFS channel", CON_PARM_RANGE, 0, 180, 40 },
+                            { "max DFS channel", CON_PARM_RANGE, 0, 180, 140 },
+                             CON_LAST_PARM};
+
+                    consoleAddToken(h1, "D_enableDisable",  "enableDisable_d", (FuncToken_t) cmd_enableDisable_802_11d, aaa );
+                    consoleAddToken(h1, "H_enableDisable",  "enableDisable_h", (FuncToken_t) cmd_enableDisable_802_11h, aaa );
+                    consoleAddToken(h1, "d_Country_2_4Ie",  "d_Country_2_4Ie", (FuncToken_t) cmd_d_Country_2_4Ie, aaa );
+                    consoleAddToken(h1, "d_cOuntry_5Ie",  "d_Country_5Ie", (FuncToken_t) cmd_d_Country_5Ie, aaa );
+
+                    consoleAddToken(h1, "dfS_range",  "DFS_range", (FuncToken_t) cmd_DFS_range, bbb );
+
+            }
+
+
+                                /* b-only, g-only, b&g mode, a-only, a&g mode b-plus-mode */
+        CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Antenna",  "tx/rx selected antenna" ) );
+            {
+                ConParm_t aaa[]  = { { "Enable RX diversity", CON_PARM_RANGE, 0, 1, 0 },
+                                     { "RX selected antenna", CON_PARM_RANGE, 1, 2, 2 },
+                                     { "Enable TX diversity", CON_PARM_RANGE, 0, 1, 0 },
+                                     { "TX selected antenna", CON_PARM_RANGE, 1, 2, 2 },
+                                     { "Share RX and TX antennas", CON_PARM_RANGE, 0, 1, 1 },
+                                     CON_LAST_PARM };
+                consoleAddToken(h1, "Diversityparams",  "Set antenna diversity params", (FuncToken_t) cmd_modify_antenna_diversity, aaa );
+            }
+
+               CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "beacoN",  "Set Beacon Filter Desired State" ) );
+            {
+                ConParm_t beaconFilterDesiredState[]  = { { "Set Beacon Desired State", CON_PARM_OPTIONAL, 0, 0, 0 },
+                                     CON_LAST_PARM };
+                consoleAddToken(h1, "Set Beacon Filter Desired State","Set Beacon Filter Current State", (FuncToken_t) cmd_Beacon_Filter_Set_Desired_State, beaconFilterDesiredState );
+                               consoleAddToken(h1, "Get Beacon Filter Current State","Get Beacon Filter Current State", (FuncToken_t) cmd_Beacon_Filter_Get_Desired_State, beaconFilterDesiredState );
+            }
+
+
+        CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "adVanced",  "Advanced params" ) );
+            {
+                ConParm_t aaa[]  = { { "ext_rates", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h1, "Draft",  "Draft", (FuncToken_t) cmd_modify_ext_rates_ie, aaa );
+            }
+            {
+                ConParm_t aaa[]  = { { "rates", CON_PARM_OPTIONAL | CON_PARM_LINE, 0, 120, 0 }, CON_LAST_PARM };
+                consoleAddToken(h1, "Supported rates",  "rates", (FuncToken_t) cmd_modify_supported_rates, aaa );
+            }
+            {
+                ConParm_t aaa[]  = { { "CtsToSelf", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 1, 0 }, CON_LAST_PARM };
+                consoleAddToken(h1, "Cts to self",  "Enable/Disable CTS to self", (FuncToken_t) cmd_modify_ctsToSelf, aaa );
+            }
+            CHK_NULL(h2 = (handle_t) consoleAddDirExt( (handle_t) h1, "rx data Filter",  "Rx Data Filter" ) );
+                consoleAddToken(h2, "Enable",  "Enable Rx Data Filtering", (FuncToken_t) cmd_enable_rx_data_filters, NULL );
+                consoleAddToken(h2, "Disable",  "Enable Rx Data Filtering", (FuncToken_t) cmd_disable_rx_data_filters, NULL );
+                {
+                    ConParm_t aaa[]  =
+                    {
+                        { "Offset", CON_PARM_RANGE, 0, 255, 0 },
+                        { "Mask", CON_PARM_STRING, 0, 64, 0 },
+                        { "Pattern", CON_PARM_STRING, 0, 128, 0 },
+                        CON_LAST_PARM
+                    };
+                    consoleAddToken(h2, "Add",  "Add Rx Data Filter", (FuncToken_t) cmd_add_rx_data_filter, aaa );
+                }
+                {
+                    ConParm_t aaa[]  =
+                    {
+                        { "Offset", CON_PARM_RANGE, 0, 255, 0 },
+                        { "Mask", CON_PARM_STRING, 0, 64, 0 },
+                        { "Pattern", CON_PARM_STRING, 0, 128, 0 },
+                        CON_LAST_PARM
+                    };
+                    consoleAddToken(h2, "Remove",  "Remove Rx Data Filter", (FuncToken_t) cmd_remove_rx_data_filter, aaa );
+                }
+                consoleAddToken(h2, "Statistics",  "Print Rx Data Filtering Statistics", (FuncToken_t) cmd_get_rx_data_filters_statistics, NULL );
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "Show",  "Show params" ) );
+        consoleAddToken(h, "Statistics",  "Show statistics", (FuncToken_t) cmd_show_statistics, NULL );
+               {
+                       ConParm_t aaa[]  = { { "Clear stats on read", CON_PARM_OPTIONAL | CON_PARM_RANGE, 0, 1, 0 }, CON_LAST_PARM };
+                       consoleAddToken(h, "Tx statistics",  "Show tx statistics", (FuncToken_t) cmd_show_tx_statistics, aaa );
+               }
+               consoleAddToken(h, "Advanced",  "Show advanced params", (FuncToken_t) cmd_show_advanced_params, NULL );
+
+        consoleAddToken(h, "Power consumption",  "Show power consumption statistics", (FuncToken_t) cmd_show_power_consumption_stats, NULL );
+
+        /* -------------------------------------------- Privacy -------------------------------------------- */
+
+        CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "Privacy",  "Privacy configuration" ) );
+            {
+                ConParm_t aaa[]  = { { "mode", CON_PARM_OPTIONAL, 0, 0, 0 },CON_LAST_PARM };
+                consoleAddToken(h, "Authentication",  "Set authentication mode",
+                            (FuncToken_t)cmd_privacy_auth, aaa );
+            }
+            {
+                ConParm_t aaa[]  = { { "type", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h, "EAP",  "Set EAP type", (FuncToken_t)cmd_privacy_eap, aaa );
+            }
+            {
+                ConParm_t aaa[]  = { { "type", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h, "encRyption",  "Set Encryption type", (FuncToken_t)cmd_privacy_encrypt, aaa);
+            }
+
+            {
+                ConParm_t aaa[]  = { { "type", 0, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h, "Keytype",  "Set key type", (FuncToken_t) cmd_privacy_key_type, aaa );
+            }
+
+            {
+                ConParm_t aaa[]  = { { "mode", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h, "Mixedmode",  "Set mixed mode", (FuncToken_t) cmd_privacy_mixed_mode, aaa );
+            }
+
+            {
+                ConParm_t aaa[]  = {
+                    { "User:", CON_PARM_STRING, 0, MAX_CERT_USER_NAME_LENGTH, 0 },
+                    { "Password:", CON_PARM_STRING | CON_PARM_OPTIONAL, 0, MAX_CERT_PASSWORD_LENGTH , 0 },
+                    CON_LAST_PARM };
+                consoleAddToken(h, "Credentials",  "Set Credentials ", (FuncToken_t)cmd_privacy_credent, aaa);
+            }
+            {
+                               ConParm_t aaa[]  =
+                    {
+                        { "Passphrase", CON_PARM_STRING, MIN_PSK_STRING_LENGTH, MAX_PSK_STRING_LENGTH, 0},
+                        { "key type (hex | text) [text]", CON_PARM_OPTIONAL | CON_PARM_STRING, 0, 5, 0},
+                        CON_LAST_PARM
+                    };
+                consoleAddToken(h, "PSKPassphrase",  "Set PSK Passphrase", (FuncToken_t)cmd_privacy_PSKPassphrase, aaa );
+            }
+#ifdef _WINDOWS  // TRS:HLC certificate hash for Windows
+#else
+            {
+                ConParm_t aaa[]  = { { "Certificate Name:", CON_PARM_STRING, 0, MAX_CERT_FILE_NAME_LENGTH, 0 },
+                { "Validate (yes - 1 /no - 0):", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h, "cerTificate",  "Set Certificate",(FuncToken_t)cmd_privacy_certificate, aaa);
+
+            }
+#endif
+            {
+                ConParm_t aaa[]  = { { "option", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+                consoleAddToken(h, "wpa_Options",  "Set WPA options", (FuncToken_t)cmd_privacy_wpa_options, aaa );
+            }
+            CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Wep",  "Wep" ) );
+                {
+                    ConParm_t aaa[]  =
+                    {
+                        { "Key Value", CON_PARM_STRING, 0, 64, 0},
+                        { "Tx Key Index", 0, 0, 0, 0 },
+                        { "Default Key (yes - 1 /no - 0)", 0, 0, 0, 0 },
+                        { "key type (hex | text) [hex]", CON_PARM_OPTIONAL | CON_PARM_STRING, 0, 5, 0},
+                        CON_LAST_PARM
+                    };
+                    consoleAddToken(h1, "Add",  "Add WEP", (FuncToken_t)cmd_privacy_addkey, aaa );
+                }
+                {
+                    ConParm_t aaa[]  = { { "Key Index", 0, 0, 0, 0 }, CON_LAST_PARM };
+                    consoleAddToken(h1, "Remove",  "Remove WEP", (FuncToken_t)cmd_privacy_removekey, aaa);
+                }
+                consoleAddToken(h1, "Get Default Key ID",  "Get Default Key ID", (FuncToken_t)cmd_privacy_getdefaultkey, NULL);
+
+
+#ifdef EXC_MODULE_INCLUDED
+            add_EXC_menu( h );
+#endif/*EXC_MODULE_INCLUDED*/
+
+    /* -------------------------------------------- Scan -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "scAn",  "Scan Service Configuration" ) );
+        consoleAddToken(h, "Start",  "Start Application Scan", (FuncToken_t) cmd_Scan_Start, NULL );
+        consoleAddToken(h, "sTop",  "Stop Application Scan", (FuncToken_t) cmd_Scan_Stop, NULL );
+        CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "configApp",  "Configure Application Scan Params" ) );
+        {
+            ConParm_t aaa[]  = {
+                    { "SSID", CON_PARM_STRING, 0, 33, 0 },
+#ifdef TI_DBG /* limitn application scan to normal only in release version */
+                    { "Scan Type", CON_PARM_RANGE, SCAN_TYPE_NORMAL_PASSIVE, SCAN_TYPE_TRIGGERED_ACTIVE, 0 },
+#else
+                    { "Scan Type", CON_PARM_RANGE, SCAN_TYPE_NORMAL_PASSIVE, SCAN_TYPE_NORMAL_ACTIVE, 0 },
+#endif
+                    { "Band", CON_PARM_RANGE, 0, 1, 0 },
+                    { "Probe Request Number", CON_PARM_RANGE, 0, 255, 0 },
+                    { "Probe Request Rate", CON_PARM_RANGE, 0, DRV_RATE_MASK_54_OFDM, 0 },
+
+#ifdef TI_DBG
+                    { "Tid", CON_PARM_RANGE, 0, 255, 0 },
+#endif
+                    { "Number of Channels", CON_PARM_RANGE, 0, 16, 0 },
+                    CON_LAST_PARM };
+            consoleAddToken(h1, "Global",  "Config Global Params", (FuncToken_t) cmd_Scan_app_global_config, aaa );
+        }
+        {
+            ConParm_t aaa[]  = {
+                    { "Index", CON_PARM_RANGE, 0, 30, 0 },
+                    { "BSSID (xx:xx:xx:xx:xx:xx)", CON_PARM_STRING, 0, 18, 0 },
+                    { "Max Dwell Time", CON_PARM_RANGE, 0, 100000000, 0 },
+                    { "Min Dwell Time", CON_PARM_RANGE, 0, 100000000, 0 },
+                    { "ET Condition", CON_PARM_RANGE, SCAN_ET_COND_DISABLE, SCAN_ET_COND_ANY_FRAME, 0 },
+                    { "ET Frame Number", CON_PARM_RANGE, 0, 255, 0 },
+                    { "TX power level", CON_PARM_RANGE, 0, MAX_TX_POWER, 0 },
+                    { "Channel Number", CON_PARM_RANGE, 0, 255, 0 },
+                    CON_LAST_PARM };
+            consoleAddToken(h1, "Channel",  "Config Channel Params", (FuncToken_t) cmd_Scan_app_channel_config, aaa );
+        }
+        consoleAddToken(h1, "cLear",  "Clear All Params", (FuncToken_t) cmd_Scan_app_clear, NULL );
+        consoleAddToken(h1, "Display",  "Display Params", (FuncToken_t) cmd_Scan_app_display, NULL );
+
+        CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "configPolicy",  "Configure scan manager scan policy" ) );
+        {
+            ConParm_t aaa[]  = {
+                    { "Normal scan interval (msec)", CON_PARM_RANGE, 0, 3600000, 5000 },
+                    { "Deteriorating scan interval", CON_PARM_RANGE, 0, 3600000, 3000 },
+                    { "Max Track Failures", CON_PARM_RANGE, 0, 20, 3 },
+                    { "BSS list size", CON_PARM_RANGE, 0, 16, 8 },
+                    { "BSS Number to start discovery", CON_PARM_RANGE, 0, 16, 4 },
+                    { "Number of bands", CON_PARM_RANGE, 0, 2, 1 },
+                     CON_LAST_PARM };
+            consoleAddToken(h1, "Gloabal",  "Set Global policy Params", (FuncToken_t) cmd_Scan_policy_global_config, aaa );
+        }
+
+            CHK_NULL(h2 = (handle_t) consoleAddDirExt( (handle_t) h1, "Band",  "Configure band scan policy" ) );
+            {
+                ConParm_t aaa[]  = {
+                        { "Index", CON_PARM_RANGE, 0, 1, 0 },
+                        { "Band", CON_PARM_RANGE, 0, 1, 0 },
+                        { "RSSI threshold", CON_PARM_RANGE| CON_PARM_SIGN, -100, 0, 0 },
+                        { "Channel number for discovery cycle", CON_PARM_RANGE, 0, 30, 5 },
+                        { "Number of Channels", CON_PARM_RANGE, 0, 30, 0 },
+                         CON_LAST_PARM };
+                consoleAddToken(h2, "Misc",   "Set misc band params",  (FuncToken_t) cmd_Scan_band_global_config, aaa );
+            }
+            {
+                ConParm_t aaa[]  = {
+                        { "Band Index", CON_PARM_RANGE, 0, 1, 0 },
+                        { "Channel Index", CON_PARM_RANGE, 0, 29, 0 },
+                        { "Channel", CON_PARM_RANGE, 0, 160, 0 },
+                         CON_LAST_PARM };
+                consoleAddToken(h2, "Channel",   "Set Channel params",  (FuncToken_t) cmd_Scan_band_channel_config, aaa );
+            }
+            {
+                ConParm_t aaa[]  = {
+                        { "Band Index", CON_PARM_RANGE, 0, 1, 0 },
+                        { "Scan Type", CON_PARM_RANGE, 0, 5, 0 },
+                        { "ET event", CON_PARM_RANGE, SCAN_ET_COND_DISABLE, SCAN_ET_COND_ANY_FRAME, SCAN_ET_COND_DISABLE },
+                        { "ET num of frames", CON_PARM_RANGE, 0, 255,0 },
+                        { "Triggering AC", CON_PARM_RANGE, 0, 255, 0 },
+                        { "Scan Duration (SPS)", CON_PARM_RANGE, 0, 100000000, 2000 },
+                        { "Max dwell time", CON_PARM_RANGE, 0, 100000000, 60000 },
+                        { "Min dwell time", CON_PARM_RANGE, 0, 100000000, 30000 },
+                        { "Probe req. number", CON_PARM_RANGE, 0, 255, 2 },
+
+                        { "Probe req. rate", CON_PARM_RANGE, 0, DRV_RATE_MASK_54_OFDM, 0 },
+
+                        { "TX power level", CON_PARM_RANGE, 0, MAX_TX_POWER, 0 },
+                         CON_LAST_PARM };
+                consoleAddToken(h2, "Track",   "Set tracking method params",  (FuncToken_t) cmd_Scan_band_track_config, aaa );
+            }
+            {
+                ConParm_t aaa[]  = {
+                        { "Band Index", CON_PARM_RANGE, 0, 1, 0 },
+                        { "Scan Type", CON_PARM_RANGE, 0, 5, 0 },
+                        { "ET event", CON_PARM_RANGE, SCAN_ET_COND_DISABLE, SCAN_ET_COND_ANY_FRAME, SCAN_ET_COND_DISABLE },
+                        { "ET num of frames", CON_PARM_RANGE, 0, 255,0 },
+                        { "Triggering AC", CON_PARM_RANGE, 0, 255, 0 },
+                        { "Scan Duration (SPS)", CON_PARM_RANGE, 0, 100000000, 2000 },
+                        { "Max dwell time", CON_PARM_RANGE, 0, 100000000, 60000 },
+                        { "Min dwell time", CON_PARM_RANGE, 0, 100000000, 30000 },
+                        { "Probe req. number", CON_PARM_RANGE, 0, 255, 2 },
+
+                        { "Probe req. rate", CON_PARM_RANGE, 0, DRV_RATE_MASK_54_OFDM, 0 },
+
+                        { "TX power level", CON_PARM_RANGE, 0, MAX_TX_POWER, 0 },
+                         CON_LAST_PARM };
+                consoleAddToken(h2, "Discovery",   "Set Discovery method params",  (FuncToken_t) cmd_Scan_band_discover_config, aaa );
+            }
+            {
+                ConParm_t aaa[]  = {
+                        { "Band Index", CON_PARM_RANGE, 0, 1, 0 },
+                        { "Scan Type", CON_PARM_RANGE, 0, 5, 0 },
+                        { "ET event", CON_PARM_RANGE, SCAN_ET_COND_DISABLE, SCAN_ET_COND_ANY_FRAME, SCAN_ET_COND_DISABLE },
+                        { "ET num of frames", CON_PARM_RANGE, 0, 255,0 },
+                        { "Triggering AC", CON_PARM_RANGE, 0, 255, 0 },
+                        { "Scan Duration (SPS)", CON_PARM_RANGE, 0, 100000000, 2000 },
+                        { "Max dwell time", CON_PARM_RANGE, 0, 100000000, 60000 },
+                        { "Min dwell time", CON_PARM_RANGE, 0, 100000000, 30000 },
+                        { "Probe req. number", CON_PARM_RANGE, 0, 255, 2 },
+
+                        { "Probe req. rate", CON_PARM_RANGE, 0, DRV_RATE_MASK_54_OFDM, 0 },
+
+                        { "TX power level", CON_PARM_RANGE, 0, MAX_TX_POWER, 0 },
+                         CON_LAST_PARM };
+                consoleAddToken(h2, "Immediate",   "Set Immediate method params",  (FuncToken_t) cmd_Scan_band_immed_config, aaa );
+            }
+
+
+        consoleAddToken(h1, "Display",  "Display Policy Params", (FuncToken_t) cmd_Scan_policy_display, NULL );
+        consoleAddToken(h1, "Clear",  "Clear Polciy Params", (FuncToken_t) cmd_Scan_policy_clear, NULL );
+        consoleAddToken(h1, "Store",  "Send policy to scan manager", (FuncToken_t) cmd_Scan_policy_store, NULL );
+        consoleAddToken(h1, "bsslisT", "Display BSS list", (FuncToken_t) cmd_Scan_get_bss_list, NULL );
+
+
+       /************ ROAMING manager commands - start  ********************/
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "roaminG",  "Roaming Manager configuration" ) );
+       consoleAddToken(h, "Enable",  "Enable Internal Roaming", (FuncToken_t) cmd_Roaming_enable, NULL );
+       consoleAddToken(h, "Disable",  "Disable Internal Roaming", (FuncToken_t) cmd_Roaming_disable, NULL );
+       {
+               ConParm_t aaa[]  = {
+                               { "Low pass filter time", CON_PARM_DEFVAL, 0, 1440, 30 }, CON_LAST_PARM };
+               consoleAddToken(h, "Low pass filter",  "Time in sec ", (FuncToken_t) cmd_Roaming_lowPassFilter, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "Quality threshold", CON_PARM_DEFVAL | CON_PARM_SIGN, -150, 0, -100 }, CON_LAST_PARM };
+               consoleAddToken(h, "Quality threshold",  "Quality indicator", (FuncToken_t) cmd_Roaming_qualityIndicator, aaa );
+       }
+
+       consoleAddToken(h, "Get ",  "Get Roaming config params ", (FuncToken_t) cmd_Roaming_getConfParams, NULL );
+
+    CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Thresholds",  "Set Roaming MNGR triggers thresholds" ) );
+       {
+               ConParm_t aaa[]  = {
+                               { "Tx retry", CON_PARM_DEFVAL, 0, 255, 20 }, CON_LAST_PARM };
+               consoleAddToken(h1, "Tx retry ",  "Consecutive number of TX retries", (FuncToken_t) cmd_Roaming_dataRetryThreshold, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "Bss loss", CON_PARM_DEFVAL, 1, 255, 4 }, CON_LAST_PARM };
+               consoleAddToken(h1, "Bss loss ",  "Number of TBTTs", (FuncToken_t) cmd_Roaming_numExpectedTbttForBSSLoss, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "tx Rate threshold", CON_PARM_DEFVAL, 0, 54, 2 }, CON_LAST_PARM };
+                               consoleAddToken(h1, "tx Rate threshold ",  "TX rate (fallback) threshold", (FuncToken_t) cmd_Roaming_txRateThreshold, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "Low rssi threshold", CON_PARM_DEFVAL | CON_PARM_SIGN, -150, 0, -80 }, CON_LAST_PARM };
+
+                               consoleAddToken(h1, "Low rssi threshold ",  "Low RSSI threshold", (FuncToken_t) cmd_Roaming_lowRssiThreshold, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "low Snr threshold", CON_PARM_DEFVAL, 0, 255, 10 }, CON_LAST_PARM };
+               consoleAddToken(h1, "low Snr threshold ",  "Low SNR threshold", (FuncToken_t) cmd_Roaming_lowSnrThreshold, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "low Quality for scan", CON_PARM_DEFVAL | CON_PARM_SIGN, -150, -40, -85 }, CON_LAST_PARM };
+                               consoleAddToken(h1, "low Quality for scan ",  "Increase the background scan", (FuncToken_t) cmd_Roaming_lowQualityForBackgroungScanCondition, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "Normal quality for scan", CON_PARM_DEFVAL | CON_PARM_SIGN, -150, -40, -70 }, CON_LAST_PARM };
+                               consoleAddToken(h1, "Normal Quality for scan ",  "Reduce the background scan", (FuncToken_t) cmd_Roaming_normalQualityForBackgroungScanCondition, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "Rssi filter weight", CON_PARM_DEFVAL, 0, 100, 10 }, CON_LAST_PARM };
+                               consoleAddToken(h1, "rssI filter weight ",  "Set weight for the last RSSI value in the AVG calculation", (FuncToken_t) cmd_Roaming_rssiFilterWeight, aaa );
+       }
+       {
+               ConParm_t aaa[]  = {
+                               { "Snr filter weight", CON_PARM_DEFVAL, 0, 100, 10 }, CON_LAST_PARM };
+                               consoleAddToken(h1, "snr Filter weight ",  "Set weight for the last SNR value in the AVG calculation", (FuncToken_t) cmd_Roaming_snrFilterWeight, aaa );
+       }
+
+       /************ ROAMING manager commands - end  ********************/
+
+    /* -------------------------------------------- QOS -------------------------------------------- */
+
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "qOs",  "Quality of service" ) );
+
+               CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Upsd",  "UPSD Sub-menu" ) );
+        {       ConParm_t TspecParams[]  = {
+                { "UserPriority", CON_PARM_RANGE, 0, 7, 1  },
+                { "NominalMSDUsize", CON_PARM_RANGE, 1, 2312, 1  },
+                { "MeanDataRate (Bps units)", CON_PARM_RANGE, 0, 54000000, 0 },
+                { "MinimumPHYRate (Mbps units)", CON_PARM_RANGE , 0, 54, 0  },
+                { "SurplusBandwidthAllowance", CON_PARM_RANGE , 0, 7, 0 },
+                { "UPSD Mode (0 - Legacy, 1 - U-APSD)", CON_PARM_RANGE , 0, 1, 0 },
+                    CON_LAST_PARM };
+                consoleAddToken(h1, "Add",  "Add TSPEC", (FuncToken_t) cmd_add_tspec, TspecParams );
+        }
+        {
+            ConParm_t UPid[]  = { { "User priority", CON_PARM_RANGE, 0, 7, 1  }, CON_LAST_PARM };
+            consoleAddToken(h1, "Get",  "Get TSPEC Params", (FuncToken_t) cmd_get_tspec_params, UPid );
+        }
+        {
+            ConParm_t UPid[]  = { { "UserPriority", CON_PARM_RANGE, 0, 7, 1  },
+                                  { "ReasonCode", CON_PARM_RANGE, 32, 45, 32  }, CON_LAST_PARM };
+            consoleAddToken(h1, "Delete",  "Delete TSPEC", (FuncToken_t) cmd_delete_tspec, UPid );
+        }
+
+        consoleAddToken(h1, "aP params", "Get AP QoS parameters", (FuncToken_t) cmd_get_ap_qos_params, NULL );
+        consoleAddToken(h1, "ap Capabilities", "Get AP QoS capabilities parameters", (FuncToken_t) cmd_get_ap_qos_capabilities, NULL );
+
+        {
+            ConParm_t ACid[]  = { { "AC", CON_PARM_RANGE, 0, 3, 3  }, CON_LAST_PARM };
+            consoleAddToken(h1, "ac Status", "Get Current AC Status", (FuncToken_t) cmd_get_ac_status, ACid );
+        }
+
+            {
+                ConParm_t MediumUsageParams[]  = {
+                    { "AC", CON_PARM_RANGE, 0, 3, 3  },
+                    { "HighThreshold", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 100, 1  },
+                    { "LowThreshold", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 100, 1 },
+                     CON_LAST_PARM };
+                    consoleAddToken(h1, "Medium usage", "Medium usage threshold", (FuncToken_t) cmd_medium_usage_threshold, MediumUsageParams );
+            }
+            {
+                ConParm_t PhyRateParams[]  = {
+                    { "AC", CON_PARM_RANGE, 0, 3, 3  },
+                    { "HighThreshold", CON_PARM_RANGE | CON_PARM_OPTIONAL, 1, 54, 1  },
+                    { "LowThreshold", CON_PARM_RANGE | CON_PARM_OPTIONAL, 1, 54, 1 },
+                     CON_LAST_PARM };
+                    consoleAddToken(h1, "phy Rate", "PHY rate threshold", (FuncToken_t) cmd_phy_rate_threshold, PhyRateParams );
+            }
+        consoleAddToken(h1, "dEsired ps mode", "Get desired PS mode", (FuncToken_t) cmd_get_desired_ps_mode, NULL );
+
+    CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Classifier",  "Classifier sub-menu" ) );
+        {
+            ConParm_t aaa[]  = {{ "con0 Port = ", CON_PARM_RANGE, 0, 65535, 0  },
+                                { "con0 Pri = ", CON_PARM_RANGE, 0, 7, 0  },
+                                { "con1 Port = ", CON_PARM_RANGE, 0, 65535, 0  },
+                                { "con1 Pri = ", CON_PARM_RANGE, 0, 7, 0  },
+                                { "con2 Port = ", CON_PARM_RANGE, 0, 65535, 0  },
+                                { "con2 Pri = ", CON_PARM_RANGE, 0, 7, 0  },
+                                { "con3 Port = ", CON_PARM_RANGE, 0, 65535, 0  },
+                                { "con3 Pri = ", CON_PARM_RANGE, 0, 7, 0  },
+                                { "cons Ip1 = ", CON_PARM_RANGE, 0,255 , 0   },
+                                { "cons Ip2 = ", CON_PARM_RANGE, 0,255 , 0   },
+                                { "cons Ip3 = ", CON_PARM_RANGE, 0,255 , 0   },
+                                { "cons Ip4 = ", CON_PARM_RANGE, 0,255 , 0   },
+                                CON_LAST_PARM };
+            consoleAddToken(h1, "TxClassifier", "Config Tx Classifier", (FuncToken_t) cmd_config_tx_classifier, aaa );
+        }
+
+        {       ConParm_t aaa[]  = {
+                { "Type", CON_PARM_RANGE, DSCP_CLSFR, CLSFR_TYPE_MAX, 0  },
+                { "D-Tag", CON_PARM_RANGE, CLASSIFIER_DTAG_MIN, CLASSIFIER_DTAG_MAX, CLASSIFIER_DTAG_DEF  },
+                { "Param1", CON_PARM_RANGE, 0, 65535, 0 },
+                { "Ip1", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0  },
+                { "Ip2", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                { "Ip3", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                               { "Ip4", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                    CON_LAST_PARM };
+                consoleAddToken(h1, "Insert ",  "Insert new classification entry", (FuncToken_t) cmd_insert_clsfr_entry, aaa );
+        }
+
+        {       ConParm_t aaa[]  = {
+                { "Type", CON_PARM_RANGE, DSCP_CLSFR, CLSFR_TYPE_MAX, 0  },
+                { "D-Tag", CON_PARM_RANGE, CLASSIFIER_DTAG_MIN, CLASSIFIER_DTAG_MAX, CLASSIFIER_DTAG_DEF  },
+                { "Param1", CON_PARM_RANGE, 0, 65535, 0 },
+                { "Ip1", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0  },
+                { "Ip2", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                { "Ip3", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                               { "Ip4", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                    CON_LAST_PARM };
+                consoleAddToken(h1, "Remove",  "Remove classification entry", (FuncToken_t) cmd_remove_clsfr_entry, aaa );
+        }
+
+       {
+            ConParm_t aaa[]  = {
+            { "acID", CON_PARM_RANGE, 0, 3, 0  },
+            { "MaxLifeTime", CON_PARM_RANGE , 0, 1024, 0  },
+            { "Reserved and ignored (ShortMaxRetries)", CON_PARM_RANGE , 0, 255, 0 },
+            { "Reserved and ignored (LongMaxRetries)", CON_PARM_RANGE , 0, 255, 0 },
+            { "Reserved and ignored (RxTimeout)", CON_PARM_RANGE , 0, 65535, 0  },
+            { "Voice delivery Protocol (VO QUEUE ONLY : 0 - None, 1 - PS POLL)", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 1, 0 },
+                       { "PS Delivery Protocol (1 - U-APSD, 2 - Legacy)", CON_PARM_RANGE | CON_PARM_OPTIONAL, 1 /*PS_SCHEME_UPSD_TRIGGER*/, 2/*PS_SCHEME_LEGACY_PSPOLL*/, 2/*PS_SCHEME_LEGACY_PSPOLL*/},
+                CON_LAST_PARM };
+            consoleAddToken(h, "QosParams ",  "Set QOS Parameters", (FuncToken_t) cmd_set_qos_params, aaa );
+        }
+
+        {
+            ConParm_t aaa[]  = {
+            { "dtag0_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag1_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag2_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag3_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag4_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag5_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag6_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+            { "dtag7_to_ac", CON_PARM_RANGE, 0, 3, 0  },
+                CON_LAST_PARM };
+            consoleAddToken(h, "Set_dtag2ac_mapping_table ",  "Set dtag2ac mapping table", (FuncToken_t) cmd_set_dtag_to_ac_mapping_table, aaa );
+        }
+
+        {
+            ConParm_t aaa[]  = {
+            { "Enable", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 1, 0  },
+            { "vadTimerDuration", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 100, 0  },
+                CON_LAST_PARM };
+            consoleAddToken(h, "setVad ",  "Set VAD", (FuncToken_t) cmd_set_vad, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "AC", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 3, 3  }, CON_LAST_PARM };
+            consoleAddToken(h, "Poll AP packets", "Poll Ap Packets", (FuncToken_t) cmd_poll_ap_packets, aaa );
+        }
+
+               {
+            ConParm_t aaa[]  = {
+            { "PsPoll", CON_PARM_RANGE, 0, 65000, 0  },
+            { "UPSD", CON_PARM_RANGE , 0, 65000, 0  },
+                CON_LAST_PARM };
+            consoleAddToken(h, "Rx TimeOut ",  "Rx TimeOut ", (FuncToken_t) cmd_set_rxTimeOut_params, aaa );
+        }
+               {
+            ConParm_t aaa[]  = {
+            { "MaxRxLifeTime", CON_PARM_OPTIONAL|CON_PARM_RANGE, 0, 0xffffffff, 0  },
+                CON_LAST_PARM };
+            consoleAddToken(h, "Max Rx Lifetime",  "Max Rx Lifetime", (FuncToken_t) cmd_MaxRxLifetime_params, aaa );
+        }
+
+
+
+
+
+        /* -------------------------------------------- Power Management -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "poWer",  "Power Management" ) );
+        {
+               /* Set Power Mode Command */
+               ConParm_t powerModeCmd[]  = {
+                    { "PowerMode", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 3, 1 }, /* Min/Max/Def */
+                    CON_LAST_PARM };
+               consoleAddToken(h, "set_Power_mode",  "Set user power mode", (FuncToken_t) cmd_set_power_mode, powerModeCmd );
+
+        }
+        {
+               /* Set Power Save Power level Command */
+               ConParm_t powerSavePowerLevelCmd[]  = {
+                    { "PowerSavePowerLevel", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 2, 2 }, /* Min/Max/Def */
+                    CON_LAST_PARM };
+            consoleAddToken(h, "set_powersave_powerLevel",  "Set the Power level during PowerSave", (FuncToken_t) cmd_set_PowerSave_PowerLevel, powerSavePowerLevelCmd );
+
+        }
+               {
+               /* Set default Power level Command */
+               ConParm_t defaultPowerLevelCmd[]  = {
+                    { "DefaultPowerLevel", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 2, 2 }, /* Min/Max/Def */
+                    CON_LAST_PARM };
+            consoleAddToken(h, "set_deFault_powerlevel",  "Set the default power level", (FuncToken_t) cmd_set_Default_PowerLevel, defaultPowerLevelCmd );
+
+        }
+               {
+               /* Set doze mode in auto power mode */
+               ConParm_t powerSaveDozeMode[]  = {
+                    { "DozeModeInAuto", CON_PARM_RANGE | CON_PARM_OPTIONAL, AUTO_POWER_MODE_DOZE_MODE_MIN_VALUE, AUTO_POWER_MODE_DOZE_MODE_MAX_VALUE, AUTO_POWER_MODE_DOZE_MODE_DEF_VALUE },
+                    CON_LAST_PARM };
+            consoleAddToken(h, "set_doZe_mode_in_auto",  "Set doze mode in auto power mode", (FuncToken_t) cmd_set_DozeModeInAutoPowerLevel, powerSaveDozeMode );
+
+        }
+        {
+            ConParm_t TrafficIntensityParams[]  = {
+                { "HighThreshold (packets/sec)", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 1000, 100  },
+                { "LowThreshold (packets/sec)", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 1000, 25 },
+                { "CheckInterval (ms)", CON_PARM_RANGE | CON_PARM_OPTIONAL, 100, 10000, 1000 },
+                 CON_LAST_PARM };
+                consoleAddToken(h, "traffic_Thresholds", "Set/Get traffic intensity thresholds", (FuncToken_t) cmd_traffic_intensity_threshold, TrafficIntensityParams );
+        }
+         consoleAddToken(h, "eNable",  "enable traffic intensity events", (FuncToken_t) cmd_enable_traffic_events, NULL );
+         consoleAddToken(h, "Disable",  "disable traffic intensity events", (FuncToken_t) cmd_disable_traffic_events, NULL );
+
+       /* -------------------------------------------- Events -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "eVents",  "Events" ) );
+        {
+            ConParm_t aaa[]  = { { "type", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Register",  "IPC events", (FuncToken_t)cmd_events_register, aaa);
+        }
+        {
+            ConParm_t aaa[]  = { { "type", CON_PARM_OPTIONAL, 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Unregister",  "IPC events", (FuncToken_t)cmd_events_unregister, aaa);
+        }
+    CHK_NULL(h = (handle_t) consoleAddDirExt( NULL, "File",  "restore configuration" ) );
+        {
+            ConParm_t aaa[]  = { { "filename", CON_PARM_STRING, 0, 128, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Load",  "Load profile", (FuncToken_t) cmd_file_load, aaa );
+        }
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "Bt CoExsistance",  "BT - Wlan CoExsistance" ) );
+        {
+                       ConParm_t aaa[]  = { { "enable", CON_PARM_RANGE | CON_PARM_OPTIONAL,
+                                                               SOFT_GEMINI_ENABLED_MIN, SOFT_GEMINI_ENABLED_MAX, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Enable", "Enable BT Coexistense", (FuncToken_t) cmd_bt_coe_enable, aaa );
+        }
+        {
+                       ConParm_t aaa[]  = { { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               { "rate", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 255, 0 },
+                                                               CON_LAST_PARM };
+            consoleAddToken(h, "Rate", "Select Rates", (FuncToken_t) cmd_bt_coe_rate, aaa );
+        }
+               {
+            ConParm_t aaa[]  = {
+                                                       { "wlanRxMinRateToRespectBtHp", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_MIN , SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_MAX, 0  },
+                                                       { "btHpMaxTime", CON_PARM_RANGE | CON_PARM_OPTIONAL,
+                                                       SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_MIN, SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_MAX, 0  },
+                                                       { "wlanHpMaxTime", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_MIN, SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_MAX, 0  },
+                                                       { "senseDisableTimer", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_MIN, SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_MAX, 0  },
+                                                       { "protectiveRxTimeBeforeBtHp", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_MAX, 0  },
+                                                       { "protectiveTxTimeBeforeBtHp", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_MAX, 0  },
+                                                       { "protectiveRxTimeBeforeBtHpFastAp", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_MAX, 0  },
+                                                       { "protectiveTxTimeBeforeBtHpFastAp", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_MAX, 0  },
+                                                       { "protectiveWlanCycleTimeForFastAp", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_MIN, SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_MAX, 0  },
+                            { "btAntiStarvationPeriod", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_MIN , SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_MAX, 0  },
+                                                       { "timeoutNextBtLpPacket", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_MIN, SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_MAX,0  },
+                                                       { "wakeUpTimeBeforeBeacon", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_MIN , SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_MAX, 0  },
+                                                       { "hpdmMaxGuardTime", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_MIN , SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_MAX, 0  },
+                                                       { "timeoutNextWlanPacket", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_MIN , SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_MAX, 0  },
+                                                       { "sgAntennaType", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_MIN, SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_MAX , 0  },
+                                                       { "signalingType", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_SIGNALING_TYPE_MIN, SOFT_GEMINI_PARAMS_SIGNALING_TYPE_MAX , 0  },
+                                                       { "afhLeverageOn", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_MIN, SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_MAX, 0  },
+                                                       { "numberQuietCycle", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_MIN, SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_MAX , 0  },
+                                                       { "maxNumCts", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_MAX_NUM_CTS_MIN, SOFT_GEMINI_PARAMS_MAX_NUM_CTS_MAX, 0  },
+                                                       { "numberOfWlanPackets", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_MIN, SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_MAX,0  },
+                                                       { "numberOfBtPackets", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_MIN, SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_MAX,0  },
+                                                       { "numberOfMissedRxForAvalancheTrigger", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_MIN, SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_MAX, 0  },
+                                                       { "wlanElpHpSupport", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_ELP_HP_MIN, SOFT_GEMINI_PARAMS_ELP_HP_MAX, 0  },
+                                                       { "btAntiStarvationNumberOfCyclesWithinThePeriod", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_MIN , SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_MAX, 0  },
+                            { "ackModeDuringBtLpInDualAnt", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                            SOFT_GEMINI_PARAMS_ACK_MODE_MIN , SOFT_GEMINI_PARAMS_ACK_MODE_MAX, 0  },
+                            { "allowPaSdToggleDuringBtActivityEnable", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_ALLOW_PA_SD_MIN , SOFT_GEMINI_PARAMS_ALLOW_PA_SD_MAX, 0  },
+                                                       { "sgAutoModeNoCts", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_MIN , SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_MAX, 0  },
+                                                       { "numOfBtHpRespectedReq", CON_PARM_RANGE | CON_PARM_OPTIONAL ,
+                                                       SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_MIN , SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_MAX, 0  },
+                                                       CON_LAST_PARM };
+
+                       consoleAddToken(h, "Config",  "Parameters configuration", (FuncToken_t) cmd_bt_coe_config, aaa );
+               }
+        {
+                       ConParm_t aaa[]  = { { "status", CON_PARM_RANGE | CON_PARM_OPTIONAL, 0, 3, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Status", "Get status", (FuncToken_t) cmd_bt_coe_get_status, aaa );
+        }
+#ifdef EXC_MODULE_INCLUDED
+               /************ MEASUREMENT commands - start  ********************/
+               CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "measuremenT",  "Measurement configuration" ) );
+               consoleAddToken(h, "Enable",  "Enable Measurement", (FuncToken_t) cmd_Measurement_enable, NULL );
+               consoleAddToken(h, "Disable",  "Disable Measurement", (FuncToken_t) cmd_Measurement_disable, NULL );
+               {
+                       ConParm_t aaa[]  = {
+                                       { "Change max duration", CON_PARM_RANGE, 0, 2000, 300 }, CON_LAST_PARM };
+                       consoleAddToken(h, "Max duration",  "Time in msec ", (FuncToken_t) cmd_Measurement_setMaxDuration, aaa );
+               }
+               /************ MEASUREMENT commands - end  ********************/
+#endif /* EXC_MODULE_INCLUDED*/
+
+#ifdef TI_DBG
+
+      /* -------------------------------------------- Report -------------------------------------------- */
+
+    CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) NULL, "Report",  "Debug features" ) );
+        {
+            ConParm_t aaa[]  =
+                       {
+                               { "module table", CON_PARM_STRING | CON_PARM_OPTIONAL , WLAN_MAX_LOG_MODULES, WLAN_MAX_LOG_MODULES, 0 },
+                               CON_LAST_PARM };
+            consoleAddToken(h1, "Set",  "set report module table", (FuncToken_t) cmd_report_set, aaa );
+        }
+        {
+            ConParm_t aaa[]  =
+                       {
+                               { "module", CON_PARM_OPTIONAL, 0, 0, 0 },
+                               CON_LAST_PARM
+                       };
+            consoleAddToken(h1, "Add",  "set report for specified module", (FuncToken_t) cmd_report_add, aaa );
+        }
+        {
+                       ConParm_t aaa[]  =
+                       {
+                               { "module", CON_PARM_OPTIONAL, 0, 0, 0 },
+                               CON_LAST_PARM
+                       };
+            consoleAddToken(h1, "Clear",  "clear report for specified module", (FuncToken_t) cmd_report_clear, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "level", CON_PARM_OPTIONAL , 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h1, "Level",  "set report severity level", (FuncToken_t) cmd_report_severity_level, aaa );
+        }
+        {
+            ConParm_t aaa[]  = { { "osDbgState", CON_PARM_OPTIONAL , 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h1, "Osdbgstate",  "set OS abstraction layer debug dtate", (FuncToken_t) cmd_report_os_dbg_state, aaa );
+        }
+
+      /* -------------------------------------------- Debug -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "dEbug",  "Debug features" ) );
+        {
+            ConParm_t aaa[]  = {{ "reg_num", 0, 0, 0, 0 },
+                                { "value", CON_PARM_OPTIONAL , 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "Register",  "read/write HW register", (FuncToken_t) cmd_hw_register, aaa );
+        }
+
+        {
+            ConParm_t aaa[]  = {{ "func_num", CON_PARM_OPTIONAL, 0, 0, 0 },
+                                { "param", CON_PARM_OPTIONAL , 0, 0, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "print",  "print driver debug info", (FuncToken_t) cmd_debug_driver_print, aaa );
+        }
+
+
+               {
+                       ConParm_t aaa[]  = { { "func_num", CON_PARM_OPTIONAL, 0, 0, 0 },
+                                                                                       { "string param", CON_PARM_LINE, 0, 128, 0 },
+                                                                                       CON_LAST_PARM };
+                       consoleAddToken(h, "Buffer",  "Pass the buffer to the driver", (FuncToken_t)cmd_debug_buffer_put, aaa );
+               }
+
+#ifdef DRIVER_PROFILING
+        consoleAddToken(h, "proFile report",  "Show driver resource usage", (FuncToken_t) cmd_profile_report, NULL );
+        {
+            ConParm_t aaa[] = {{ "command_type", CON_PARM_DEFVAL | CON_PARM_RANGE, 1, 3, 3 },
+                                { "resolution", CON_PARM_OPTIONAL , 0, 0, 0 },
+                                CON_LAST_PARM
+                                };
+            consoleAddToken(h, "Cpu estimator command",  "start/stop/reset cpu estimator", (FuncToken_t) cmd_profile_cpu_estimator_command, aaa );
+        }
+
+#endif
+
+
+#endif /*TI_DBG*/
+
+      /* -------------------------------------------- PLT -------------------------------------------- */
+
+    CHK_NULL(h = (handle_t) consoleAddDirExt( (handle_t) NULL, "pLt",  "PLatform table Testings" ) );
+        CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Register",  "Register Read/Write" ) );
+        {
+            ConParm_t aaa[]  = {{ "address(hex)", CON_PARM_STRING, 1, 8, 0 },
+                                 CON_LAST_PARM };
+            consoleAddToken(h1, "Read",  "read register", (FuncToken_t) cmd_PLT_RegisterRead, aaa );
+        }
+
+        {
+            ConParm_t aaa[]  = {{ "address(hex)", CON_PARM_STRING, 1, 8, 0 },
+                                { "value(hex)", CON_PARM_STRING, 1, 8, 0 },
+                                 CON_LAST_PARM };
+            consoleAddToken(h1, "Write",  "write register", (FuncToken_t) cmd_PLT_RegisterWrite, aaa );
+        }
+
+               {
+            ConParm_t aaa[]  = {{ "Band", CON_PARM_OPTIONAL|CON_PARM_RANGE, 0, 2, 0 },
+            { "Channel", CON_PARM_OPTIONAL|CON_PARM_RANGE , 1, 161, 0 }, CON_LAST_PARM };
+            consoleAddToken(h, "rAdio tune",  "Set the RX channel", (FuncToken_t) cmd_PLT_RadioTune, aaa );
+        }
+
+               CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "rx Per",  "RX PER test" ) );
+                       {
+                               ConParm_t aaa[] = {CON_LAST_PARM};
+                               consoleAddToken(h1, "Start",  "Stop RX PER counters", (FuncToken_t) cmd_PLT_RxPerStart, aaa );
+                               consoleAddToken(h1, "stoP",  "Stop RX PER counters", (FuncToken_t) cmd_PLT_RxPerStop, aaa );
+                               consoleAddToken(h1, "Clear",  "Clear RX PER counters", (FuncToken_t) cmd_PLT_RxPerClear, aaa );
+                               consoleAddToken(h1, "Get",  "Get RX PER counters", (FuncToken_t) cmd_PLT_RxPerGet, aaa );
+                       }
+
+               CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Tx",  "TX test test" ) );
+                               {
+                    ConParm_t aaa[]  = {{ "Band", CON_PARM_OPTIONAL|CON_PARM_RANGE, 0, 2, 0 },
+                    { "Channel", CON_PARM_OPTIONAL , 1, 161, 0 }, CON_LAST_PARM };
+                               consoleAddToken(h1, "Cw",  "Start CW test", (FuncToken_t) cmd_PLT_TxCW, aaa );
+                               }
+                {
+                    ConParm_t aaa[]  = {{ "Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz))", CON_PARM_OPTIONAL|CON_PARM_RANGE, 0, 2, 0 },
+                    { "Channel: (1..14(2.4Ghz), 1..180(5Ghz))", CON_PARM_OPTIONAL|CON_PARM_RANGE , 1, 161, 14 },
+                    { "Rate: 1-1M,2-2M,3-5.5M,4-11M,6-6M,7-9M,8-12M,9-18M.10-24M,11-36M,12-48M,13-54M", CON_PARM_OPTIONAL|CON_PARM_RANGE , 1, 13, 13 },
+                    { "preamble (0-long, 1-short)", CON_PARM_OPTIONAL|CON_PARM_RANGE , 0, 1, 1 },
+                    { "InterPacketDelay- Delay between packets (uSec)", CON_PARM_OPTIONAL|CON_PARM_RANGE , 0, 0xffffffff, 0 },
+                    { "Number of TX frames (0 - endless)", CON_PARM_OPTIONAL|CON_PARM_RANGE , 0, 0xffffffff, 100 },
+                    { "Test mode (5-Random data, 9-ZOZO(0,1,0,1,...))", CON_PARM_OPTIONAL|CON_PARM_RANGE , 5, 9, 9 },
+                    { "Sequance number mode (0 - fixed, 1 - incremented)", CON_PARM_OPTIONAL|CON_PARM_RANGE , 0, 1, 0 },
+                    { "packet data length [bytes] (0 - 2284)", CON_PARM_OPTIONAL|CON_PARM_RANGE , 0, 2284, 100 },
+                    { "peer mac address (xx:xx:xx:xx:xx:xx)", CON_PARM_STRING, 0, 18, 0 },
+                                                                       CON_LAST_PARM };
+                                                                       consoleAddToken(h1, "coNtinues",  "Start TX continues test", (FuncToken_t) cmd_PLT_TxContinues, aaa );
+
+                               }
+                               {
+                               ConParm_t aaa[] = {CON_LAST_PARM};
+                               consoleAddToken(h1, "Stop",  "Stop TX tests", (FuncToken_t) cmd_PLT_TxStop, aaa );
+                               }
+               CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Mib",  "Mibs" ) );
+                          consoleAddToken(h1, "Counter table",  "Read_MIB_CounterTable", (FuncToken_t) cmd_PLT_MIB_CounterTable, NULL);
+                          consoleAddToken(h1, "station Id",  "MIB_Station_id", (FuncToken_t) cmd_PLT_MIB_StationID, NULL );
+
+                /* -------------------------------------------- PLT Calibrations -------------------------------------------- */
+                CHK_NULL(h1 = (handle_t) consoleAddDirExt( (handle_t) h, "Calibration",  "RX/TX calibrations" ) );
+                {
+                    ConParm_t aaa[]  = {
+                    { "Expected Rssi (Input signal generated power [1/16 db])", CON_PARM_RANGE|CON_PARM_SIGN, -2000, 2000, 0 },
+                    { "Channel", CON_PARM_RANGE|CON_PARM_DEFVAL , 1, 161, 1 },
+                    { "Band (0- 2.4Ghz, 1- 5Ghz, 2- 4.9Ghz)", CON_PARM_RANGE|CON_PARM_DEFVAL , 0, 2, 0 },
+                    { "Interval between Samples (uSec)", CON_PARM_OPTIONAL|CON_PARM_DEFVAL , 0, 0xffff, 100 },
+                    { "Number of samples", CON_PARM_OPTIONAL|CON_PARM_RANGE|CON_PARM_DEFVAL , 1, 2000, 1000 },
+                    CON_LAST_PARM };
+                    consoleAddToken(h1, "RX",  "RX calibration", (FuncToken_t) cmd_PLT_RxCal, aaa );
+                }
+
+                CHK_NULL(h2 = (handle_t) consoleAddDirExt( (handle_t) h1, "TX",  "TX calibrations" ) );
+                               {
+                                       ConParm_t aaa[]  = {{ "Ref Tx power dBM/10 ",CON_PARM_RANGE, MIN_TX_POWER, MAX_TX_POWER, 0 },
+                                                                               CON_LAST_PARM };
+                                       consoleAddToken(h2, "Start",  "Start TX calibration", (FuncToken_t) cmd_PLT_TxCalStart, aaa );
+                               }
+                consoleAddToken(h2, "stoP",  "Stop TX calibration", (FuncToken_t) cmd_PLT_TxCalStop, NULL );
+                consoleAddToken(h2, "gain Get",  "Gain get", (FuncToken_t) cmd_PLT_TxCalGainGet, NULL );
+                {
+                    ConParm_t aaa[]  = {{ "Gain adjust",CON_PARM_RANGE|CON_PARM_SIGN, 0, 124, 0 },
+                        CON_LAST_PARM };
+                    consoleAddToken(h2, "gain Adjust",  "Set gain", (FuncToken_t) cmd_PLT_TxCalGainAdjust, aaa );
+                }
+
+                consoleAddToken(h1, "Get_NVS_Buffer",  "Get the NVS buffers needed for update", (FuncToken_t) cmd_PLT_RxTxCalNVSUpdateBuffer, NULL );
+
+                /* -------------------------------------------- Root -------------------------------------------- */
+
+       consoleAddToken(NULL, "aboUt",  "About", (FuncToken_t) cmd_show_about, NULL );
+    consoleAddToken(NULL, "Quit",  "quit", (FuncToken_t) quit_func, NULL );
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+
+    return 0;
+}
+
+
+    /*  Return '0' if success */
+int init_driver( char *adapter_name, char *eeprom_file_name, char *init_file_name, char *firmware_file_name )
+{
+#ifndef _WINDOWS
+    FILE *f1=NULL, *f2=NULL, *f3 = NULL;
+    UINT32 eeprom_image_length=0;
+    UINT32 init_file_length=0;
+    UINT32 firmware_image_length = 0;
+    UINT32 req_size;
+    tiwlan_dev_init_t *init_info=NULL;
+#endif
+    int rc = -1;
+       ConParm_t param;
+    tiUINT32 tmpData = 1;
+
+//TRS:MEB add ability to convert adapter_name to tiCHAR type
+#ifndef _WINDOWS
+    if( !adapter_name || !*adapter_name )
+        return rc;
+
+    g_id_adapter = TI_AdapterInit( adapter_name );
+
+#else
+#endif
+//TRS end
+
+#ifdef _WINDOWS
+#endif
+
+#ifndef _WINDOWS
+    /* Send init request to the driver */
+    if (eeprom_file_name &&
+        (f1 = fopen(eeprom_file_name, "r"))!=NULL)
+    {
+        if (fseek(f1, 0, SEEK_END))
+        {
+            fprintf(stderr, "Cannot seek eeprom image file <%s>\n", eeprom_file_name);
+            goto init_driver_end;
+        }
+        eeprom_image_length = ftell(f1);
+        printf("NVS size = %d\n", eeprom_image_length); /* Dm: */
+        rewind(f1);
+    }
+#ifdef FIRMWARE_DYNAMIC_LOAD
+    if (firmware_file_name &&
+        (f2 = fopen(firmware_file_name, "r"))!=NULL)
+    {
+        if (fseek(f2, 0, SEEK_END))
+        {
+            fprintf(stderr, "Cannot seek firmware file <%s>\n", firmware_file_name);
+            goto init_driver_end;
+        }
+        firmware_image_length = ftell(f2);
+        rewind(f2);
+    }
+#endif
+    if (init_file_name &&
+        (f3 = fopen(init_file_name, "r"))!=NULL)
+    {
+        if (fseek(f3, 0, SEEK_END))
+        {
+            fprintf(stderr, "Cannot seek init file <%s>\n", init_file_name);
+            goto init_driver_end;
+        }
+        init_file_length = ftell(f3);
+        rewind(f3);
+    }
+
+    /* Now when we can calculate the request length. allocate it and read the files */
+    req_size = offsetof(tiwlan_dev_init_t, data)+ eeprom_image_length + (init_file_length+1) + firmware_image_length;
+    init_info = (tiwlan_dev_init_t *)malloc(req_size);
+    if (!init_info)
+    {
+        fprintf(stderr, "No memory to allocate init request (%d bytes)\n", req_size);
+        goto init_driver_end;
+    }
+    init_info->eeprom_image_length   = eeprom_image_length;
+    init_info->firmware_image_length = firmware_image_length;
+    init_info->init_file_length      = init_file_length;
+    if (eeprom_image_length &&
+        fread(&init_info->data[0], 1, eeprom_image_length, f1)<eeprom_image_length)
+    {
+        fprintf(stderr, "Error reading eeprom image %s, %s\n", eeprom_file_name, strerror(errno));
+        goto init_driver_end;
+    }
+    if (firmware_image_length &&
+        fread(&init_info->data[eeprom_image_length], 1, firmware_image_length, f2)<firmware_image_length)
+    {
+        fprintf(stderr, "Error reading firmware image %s, %s\n", firmware_file_name, strerror(errno));
+        goto init_driver_end;
+    }
+    if (init_file_length &&
+        fread(&init_info->data[eeprom_image_length+firmware_image_length], 1, init_file_length, f3)<init_file_length)
+    {
+        fprintf(stderr, "Error reading init_file %s, %s\n", init_file_name, strerror(errno));
+        goto init_driver_end;
+    }
+
+    rc = IPC_DeviceIoControl(adapter_name, TIWLN_SET_INIT_INFO, init_info, req_size, NULL, 0, NULL);
+
+    /*Send configMge start command as the cli is started*/
+    IPC_DeviceIoControl(adapter_name, TIWLN_DRIVER_STATUS_SET, &tmpData, sizeof(tiUINT32), NULL, 0, NULL);
+
+init_driver_end:
+    if (f1)
+        fclose(f1);
+    if (f2)
+        fclose(f2);
+    if (f3)
+        fclose(f3);
+    if (init_info)
+        free(init_info);
+#endif
+
+       /*********************/
+       /* Reset CLI events */
+       /*******************/
+
+       for (param.value = 0; param.value < IPC_EVENT_MAX; param.value++)
+       {
+               cmd_events_unregister(&param, 1);
+       }
+
+    return rc;
+}
+
+/* TRS:GAA separated Windows/Linux setup routines for readability */
+#ifndef _WINDOWS
+void init_extended_tools()
+{
+       /* Initialize IPC */
+       ipc_initialize();
+
+       /* Initialize ethernet utilities */
+       ethernet_utils_init();
+
+       /* Initialize wipp control */
+       wipp_control_init();
+
+       /* Initialize debug module task */
+       debug_module_init();
+}
+
+void deinit_extended_tools()
+{
+       ipc_deinitialize();
+
+       /* Deinitialize ethernet utilities */
+       ethernet_utils_deinit();
+
+       /* Deinitialize wipp control */
+       wipp_control_deinit();
+
+       /* Deinitializew debug module task */
+       debug_module_deinit();
+       }
+#endif
+
+#ifdef _WINDOWS
+#endif
+//TRS:GAA end of specific O/S init/deinit routines
+
+
+// TICON.EXE main module
+int main(int argc, char ** argv)
+{
+    int i;
+    char *script_file = NULL;
+    char  *eeprom_file_name = "/NVS/nvs_map.bin";
+    char  *init_file_name = "/voice/tiwlan.ini";
+    char *firmware_file_name = "/apps/firmware.bin";
+    int stop_UI = 0;
+    int bypass_supplicant = 0;
+    ConParm_t param;
+
+    // TRS:PGK -- To ensure that the data structure above is actually initialized to
+    //            a NULL string.
+    g_drv_name[0] = '\0';
+
+#ifndef _WINDOWS
+       /* TRS:AS for WM extended tools have to be initialized after parsing of the command line arguments*/
+       init_extended_tools();
+#endif /* __LINUX__*/
+    if( argc > 1 )
+    {
+        i=1;
+        if( argv[i][0] != '-' )
+        {
+            strcpy( g_drv_name, argv[i++] );
+        }
+        for( ;i < argc; i++ )
+        {
+            if( !strcmp(argv[i], "-h" ) || !strcmp(argv[i], "--help") )
+                return print_usage(eeprom_file_name, init_file_name, firmware_file_name);
+            else if(!strcmp(argv[i], "-f" ) )
+            {
+                firmware_file_name = argv[++i];
+            }
+            else if(!strcmp(argv[i], "-e") && (i+1<argc))
+            {
+                eeprom_file_name = argv[++i];
+            }
+            else if(!strcmp(argv[i], "-b"))
+            {
+                bypass_supplicant = 1;
+            }
+            else if(!strcmp(argv[i], "-i") && (i+1<argc))
+            {
+                init_file_name = argv[++i];
+            }
+            else if(!strcmp(argv[i], "-s" ) )
+            {
+                script_file = argv[++i];
+            }
+#ifdef _WINDOWS // TRS:AS for Windows only. -w switch allows to not disable WZC.
+#endif /* ifdef _WINDOWS */
+            else
+            {
+                fprintf(stderr, "ticon: unknown parameter '%s'\n", argv[i] );
+
+#ifndef _WINDOWS
+                               deinit_extended_tools();
+#endif /* ifdef __LINUX__*/
+
+                return 0;
+            }
+        }
+    }
+
+
+    if( !g_drv_name[0] )
+    {
+               #ifndef _WINDOWS
+                       strcpy(g_drv_name, TIWLAN_DRV_NAME "0" );
+               #else 
+               #endif
+    }
+
+    /* TRS:PGK -- before this function call, do not use console_printf_terminal() */
+       #ifdef _WINDOWS
+       #endif /* ifdef _WINDOWS */
+    //console_printf_terminal("ticon: g_drv_name = %s\n", g_drv_name );
+
+    // TRS:PGK -- From this point on, use console_printf_terminal()
+
+    if (init_driver(g_drv_name, eeprom_file_name, init_file_name, firmware_file_name) != 0)
+       {
+               deinit_extended_tools();
+        return -1;
+       }
+
+#ifndef _WINDOWS
+       /* Initialize g_tester module */
+       g_tester_init();
+#endif /* __LINUX__ */
+
+    if (!bypass_supplicant)
+    {
+        console_printf_terminal("Starting up supplicant...\n" );
+        TI_StartSM(g_id_adapter);
+    }
+
+    /* ----------------------------------------------------------- */
+    init_console_menu();
+
+    init_scan_params();
+
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+
+    if( script_file )
+    {
+        stop_UI = consoleRunScript (script_file);
+    }
+
+    if( !stop_UI )
+        consoleStart();
+
+#ifndef _WINDOWS
+       /* Deinitialize g_tester module */
+       g_tester_deinit();
+#endif /* __LINUX__ */
+
+    // TRS:PGK -- NOW it is good to assume that the events might have been
+    //  registered in the past.
+    for (param.value = 0; param.value < IPC_EVENT_MAX; param.value++)
+    {
+        cmd_events_unregister(&param, 1);
+    }
+
+
+    if (!bypass_supplicant)
+    {
+        console_printf_terminal("Stop supplicant manager...\n" );
+        TI_StopSM(g_id_adapter);
+    }
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+
+    console_printf_terminal("De-init the adapter...\n" );
+    TI_AdapterDeinit(g_id_adapter);
+
+       deinit_extended_tools();
+
+    printf("\nLeaving ticon\n");  //TRS:MEB added printf
+
+    return 1;
+}
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/ticon.h b/sta_dk_4_0_4_32/CUDK/CLI/ticon.h
new file mode 100644 (file)
index 0000000..1145247
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef TICON_H
+#define TICON_H
+#include <stdio.h>
+#include <string.h>
+
+#include "osTIType.h"
+#include "cli_cu_common.h"
+
+#ifndef IFNAMSIZ
+#define        IFNAMSIZ        16
+#endif
+
+extern         char    g_drv_name[IFNAMSIZ + 1];
+IMPORT_TI_API extern TI_HANDLE         g_id_adapter; //TRS:MEB support usage of DLL
+
+#ifdef _WINDOWS
+#endif
+/*int iw_sockets_open(void); */
+
+
+int console_printf_terminal(const char *arg_list ,...);
+
+#ifndef _WINDOWS
+       int console_send_buffer_to_host(tiUINT8 module_inedx, tiUINT8 *buffer, tiUINT16 length);
+#endif /* __LINUX__ */
+
+#endif /* #define TICON_H */
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/wipp_ctrl.c b/sta_dk_4_0_4_32/CUDK/CLI/wipp_ctrl.c
new file mode 100644 (file)
index 0000000..b7a2db6
--- /dev/null
@@ -0,0 +1,903 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+/****************************************************************************************************/
+/*                                                                                                  */
+/*      MODULE:     wipp_ctrl.c                                                                     */
+/*      PURPOSE:    WIPP Control utilities                                                                     */
+/*      Note:      This module is for LINUX compilation only!                                                                          */
+/*                                                                                                  */
+/****************************************************************************************************/
+
+#include <sys/shm.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdarg.h> 
+#include <stdlib.h>
+#include <termios.h>
+#include <dirent.h>
+
+
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include "ipc.h"
+#include "ticon.h"
+#include "cu_cmd.h"
+#include "console.h"
+#include "eth_utils.h"
+#include "wipp_ctrl.h"
+#include "dbg_module.h"
+#include "TI_AdapterApiC.h"
+
+       /************/
+       /* Defines */
+       /**********/
+
+#define WIPP_HEADER(_buffer, _op)      ({_buffer[0] = '+'; _buffer[1] = _op;})
+#define WIPP_CONTROL_HEADER_SIZE       (2)
+
+#define TEMP_BUFFER_SIZE               (256)
+#define MAX_PROCESS_TABLE_INDEX        (50)
+       /*********************/
+       /* Global variables */
+       /*******************/
+int wipp_control_general_process_pid = 0;
+int wipp_control_general_process_out_pipe[2];
+int wipp_control_general_process_in_pipe[2];
+
+int process_table_current_index = 0;
+int process_table[MAX_PROCESS_TABLE_INDEX][2];
+
+
+       /********************************/
+       /* static functions prototypes */
+       /******************************/
+
+void wipp_control_initialize_general_process(void);
+int wipp_control_send_message(unsigned char *buffer, unsigned int length);
+void wipp_control_cpu_usage(ConParm_t parm[], U16 nParms);
+void wipp_control_mem_usage(ConParm_t parm[], U16 nParms);
+void wipp_control_report_version(ConParm_t parm[], U16 nParms);
+void wipp_control_set_pp_mode(ConParm_t parm[], U16 nParms);
+void wipp_control_disable_term_echo(void);
+void wipp_control_set_baud_rate(int rate_index);
+void wipp_control_active_iperf(char *iperf_cmd_line);
+void wipp_control_deactive_iperf(void);
+void wipp_control_kill_family_process(int father_pid);
+void wipp_control_fill_process_table(void);
+void  wipp_control_get_version(void);
+
+
+       /**************/
+       /* Functions */
+       /************/
+
+/************************************************************************
+ *                        wipp_control_init                            *
+ ************************************************************************
+DESCRIPTION: Initialize the wipp control module.
+                        The iperf control process is prepared during this stage.
+
+CONTEXT           : main process only!
+************************************************************************/
+void wipp_control_init(void)
+{
+       wipp_control_initialize_general_process();
+}
+
+/************************************************************************
+*                        wipp_control_deinit                           *
+ ************************************************************************
+DESCRIPTION: Deinitialize the wipp control module.
+                        
+                        Kill all the process involved 
+************************************************************************/
+void wipp_control_deinit(void)
+{                                                      
+       /* Kill the general process process */
+       if (wipp_control_general_process_pid > 0)
+       {
+               /* Update the process list */
+               wipp_control_fill_process_table();
+
+               /* Kill all the child's of the general process */
+               wipp_control_kill_family_process(wipp_control_general_process_pid);
+
+               wipp_control_general_process_pid = 0;
+       }
+}
+
+/************************************************************************
+*                        wipp_control_initialize_general_process                               *
+ ************************************************************************
+DESCRIPTION: 
+************************************************************************/
+void wipp_control_initialize_general_process()
+{
+       /***********************************/
+       /* Initialize the general process */
+       /*********************************/
+
+       SHARED_MEMORY_RUN_PROCESS_RUNNING() = FALSE;
+       
+       if (pipe(wipp_control_general_process_out_pipe) < 0)
+       {
+               console_printf_terminal("wipp_control, wipp_control_initialize_general_process - Error creating out pipe!\n");
+               
+               return;
+       }
+
+       if (pipe(wipp_control_general_process_in_pipe) < 0)
+       {
+               console_printf_terminal("wipp_control, wipp_control_initialize_general_process - Error creating in pipe!\n");
+               
+               return;
+       }
+
+       /* Create a child process */
+       wipp_control_general_process_pid = fork();
+       
+       if (0 == wipp_control_general_process_pid)
+       {
+               /******************/
+               /* Child process */
+               /****************/
+               
+               int result;
+               char in_buffer[512];
+               char command_buffer[4] = {0x0, 0x00, 0x00, WIPP_CONTROL_FROM_GENERAL_PROCESS_SEND_TERMINATE};
+
+               /* Close the read direction of the pipe  - because i only write information from this pipe. */ 
+               close(wipp_control_general_process_out_pipe[0]); 
+               
+               /* Close the write direction of the pipe  - because i only write information from this pipe. */ 
+               close(wipp_control_general_process_in_pipe[1]); 
+
+               console_printf_terminal("wipp_control, Hello from general process child module (pid = %d).\n", getpid());
+               
+               /* Redirect the output to the control pipe */
+               result = dup2(wipp_control_general_process_out_pipe[1], 1);
+
+               if (result == 1)
+               {
+                       /* The duplication is ok! - we can start working */
+                       
+                       while (TRUE)
+                       {
+                               result = read(wipp_control_general_process_in_pipe[0], in_buffer, sizeof(in_buffer));
+
+                               in_buffer[result] = 0;
+                               
+                               /* Mark that the process is running */
+                               SHARED_MEMORY_RUN_PROCESS_RUNNING() = TRUE; 
+                               
+                               /* Run the command line */
+                               result = system(in_buffer);
+
+                               /* Save the running result */
+                               SHARED_MEMORY_RUN_PROCESS_RESULT() = result;
+                               
+                               /* Mark that the process is not running */
+                               SHARED_MEMORY_RUN_PROCESS_RUNNING() = FALSE; 
+
+                               /* Send indication to the main process that the general process is terminated */
+                               ipc_send_command_to_main_process(GENERAL_PROCESS_MODULE_ID,(unsigned char*) command_buffer, 4);
+                       }
+               }
+               else
+               {
+                       /* Terminate the process ... */
+                       exit(0);
+               }
+       }
+       else
+       {
+               /* Close the write direction of the pipe  - because i only write information from this pipe. */ 
+               close(wipp_control_general_process_out_pipe[1]); 
+               
+               /* Close the read direction of the pipe  - because i only write information from this pipe. */ 
+               close(wipp_control_general_process_in_pipe[0]); 
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_send_message                     *
+ ************************************************************************
+DESCRIPTION: Sends a text message to host 
+
+NOTE:           Maximum length is 'WIPP_CONTROL_MESSAGE_MAX_LENGTH' bytes!
+
+CONTEXT:  Main process only!
+************************************************************************/
+#define WIPP_CONTROL_MESSAGE_MAX_LENGTH        (512)
+
+int wipp_control_send_message(unsigned char *buffer, unsigned int length)
+{
+       /*************************/
+       /* send message to host */
+       /***********************/
+
+       return console_send_buffer_to_host(ETHERNET_UTILS_WIPP_MODULE_ID, buffer, length);
+}
+
+/************************************************************************
+ *                        wipp_control_check_command                    *
+ ************************************************************************
+DESCRIPTION: Handle the wipp control specific commands 
+                        
+CONTEXT    : main process only!                         
+************************************************************************/
+unsigned char wipp_control_check_command(char *input_string)
+{
+       ConParm_t param;
+       int result;
+       unsigned char return_value = FALSE;
+
+       if (input_string[0] == '!')
+       {
+               switch (input_string[1])
+               {
+               case WIPP_CONTROL_FROM_GENERAL_PROCESS_SEND_TERMINATE:
+                       wipp_control_send_iperf_results_to_host(WIPP_CONTROL_EVT_RUN_PROCESS_TERMINATE, NULL, 0);
+                       break;
+
+               case WIPP_CONTROL_FROM_GENERAL_PROCESS_DEACTIVATE_IPERF:
+                       wipp_control_deactive_iperf();
+                       break;
+               }
+
+               return_value = TRUE;
+       }
+
+       if (input_string[0] == '+')
+       {
+               switch (input_string[1])
+               {
+               case WIPP_CONTROL_CMD_CPU_USAGE:
+                       wipp_control_cpu_usage((ConParm_t *)NULL, (UINT)NULL);
+                       break;
+                       
+               case WIPP_CONTROL_CMD_MEM_USAGE:
+                       wipp_control_mem_usage((ConParm_t *)NULL, (UINT)NULL);
+                       break;
+                       
+               case WIPP_CONTROL_CMD_REPORT_VERSION:
+                       wipp_control_report_version((ConParm_t *)NULL, (UINT)NULL);
+                       break;
+                       
+               case WIPP_CONTROL_CMD_DEBUG_CONTROL:
+                       
+                       param.value = input_string[3] - '0';
+                                               
+                       switch (input_string[2])
+                       {
+                       case '0':
+                               /****************************/
+                               /* Enable the debug module */
+                               /**************************/
+                               
+                               console_printf_terminal("WIPP Control, Enable debug kernal module.\n");
+
+                               result = system("echo b > /dev/debug_msg_dev");
+                               
+                               if (result == -1)
+                               {
+                                       console_printf_terminal("Error enabling debug module");
+                               }
+                               
+                               break;
+                               
+                       case '1':
+                               /*****************************/
+                               /* Disable the debug module */
+                               /***************************/
+
+                               console_printf_terminal("WIPP Control, Disable debug kernel module.\n");
+                               
+                               result = system("echo c > /dev/debug_msg_dev");
+                               
+                               if (result == -1)
+                               {
+                                       console_printf_terminal("Error disabling debug module");
+                               }
+                               
+                               break;
+                               
+        #ifdef TI_DBG
+
+                       case '2':
+                               /***********************/
+                               /* Select debug level */
+                               /*********************/
+                               
+                               param.value = (U32)&input_string[3];
+                               /*console_printf_terminal("WIPP Control, Set debug mask (%s).\n", (char *)param.value);*/
+                               
+                               cmd_report_severity_table(&param, 1);
+                               
+                               break;
+                               
+                       case '3':
+                               /*********************/
+                               /* Add module debug */
+                               /*******************/
+
+                               cmd_report_add(&param, 1);
+                               
+                               break;
+                               
+                       case '4':
+                               /***********************/
+                               /* Clear module debug */
+                               /*********************/
+
+                               cmd_report_clear(&param, 1);
+                               
+                               break;
+
+                       case '5':                                                                        
+                               /*********************/
+                               /* Set module debug */
+                               /*******************/
+
+                               param.value = (U32)&input_string[3];
+                               /*console_printf_terminal("WIPP Control, Set module mask (%s).\n", param.value);*/
+                       
+                               cmd_report_set(&param, 1);
+
+                               break;
+
+        #endif /* TI_DBG */
+
+                       case '6':
+                               /***************************************/
+                               /* Get debug module buffer statistics */
+                               /*************************************/
+
+                               debug_module_get_queue_status();
+
+                               break;
+
+                       case '7':
+
+                               /* Translate the value from range of '0-4' to range of '-20 - 20' */
+                               param.value <<= 3;
+                               param.value -= 20;
+
+                               console_printf_terminal("WIPP Control, Set debug module priority (%d).\n", param.value);
+
+                               errno = 0;
+
+                               /* Change the debug process priority */
+/*                             if (setpriority(PRIO_PROCESS, debug_module_process_pid, param.value) != 0)*/
+/*                             {*/
+/*                                     console_printf_terminal("WIPP Control, Error changing priority!\n");*/
+/*                             }*/
+
+                               break;
+                               
+                       default:
+                               console_printf_terminal("++ command error (debug switch)!\n");
+                               break;
+
+                       }
+                       break;
+                       
+               case WIPP_CONTROL_CMD_DEBUG_PATH:
+                       param.value = input_string[2] - '0';
+
+                       console_printf_terminal("WIPP Control, Activate debug API (%d).\n", param.value);
+                       
+                       wipp_control_set_pp_mode(&param, 1);
+                       break;
+
+               case WIPP_CONTROL_CMD_ACTIVATE_PROCESS:
+                       wipp_control_active_iperf((char *)&input_string[1]);
+                       break;
+
+               case WIPP_CONTROL_CMD_TERMINATE_PROCESS:
+                       wipp_control_deactive_iperf();
+                       break;
+            
+               case WIPP_CONTROL_CMD_GET_VERSIONS:
+                       wipp_control_get_version();
+                       break;
+       
+               default:
+                       console_printf_terminal("wipp control ++ command error!\n");
+                       break;
+               }
+
+               return_value = TRUE;
+       }
+
+       return return_value;
+}
+
+/************************************************************************
+ *                        wipp_control_cpu_usage                           *
+ ************************************************************************
+DESCRIPTION: Report to the host the current CPU usage
+************************************************************************/
+
+#define MAX_CPU_INFO_LINE_LEN (50)
+
+void wipp_control_cpu_usage(ConParm_t parm[], U16 nParms)
+{
+       FILE *stat_file;
+       char cpu_stat_line[MAX_CPU_INFO_LINE_LEN];
+
+       stat_file = fopen("/proc/stat", "r");   
+
+       if (stat_file != NULL)
+       {
+               if (fgets((cpu_stat_line + WIPP_CONTROL_HEADER_SIZE), MAX_CPU_INFO_LINE_LEN, stat_file) != NULL)
+               {
+                       WIPP_HEADER(cpu_stat_line, '1');
+                       wipp_control_send_message((unsigned char*)cpu_stat_line, strlen(cpu_stat_line));
+               }
+               else
+               {
+                       cpu_stat_line[WIPP_CONTROL_HEADER_SIZE] = 0;
+                       wipp_control_send_message((unsigned char*)cpu_stat_line, 3);
+               }
+
+               /**********************************************/
+               /* Output the message to the standard output */
+               /********************************************/
+
+               fclose(stat_file);
+       }
+       else
+       {
+               cpu_stat_line[WIPP_CONTROL_HEADER_SIZE] = 0;
+               wipp_control_send_message((unsigned char*)cpu_stat_line, 3);
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_report_version                  *
+ ************************************************************************
+DESCRIPTION: Report to the host the current Memory usage
+************************************************************************/
+
+#define  MAX_MEM_INFO_LINE_LEN (250)
+
+void wipp_control_mem_usage(ConParm_t parm[], U16 nParms)
+{
+       FILE *ver_file;
+       char mem_stat_line[MAX_MEM_INFO_LINE_LEN];
+
+       /* Proceed only in 'pp' mode */
+       ver_file = fopen("/proc/meminfo", "r"); 
+
+       if (ver_file != NULL)
+       {
+               while (fgets((mem_stat_line + WIPP_CONTROL_HEADER_SIZE), MAX_MEM_INFO_LINE_LEN, ver_file) != NULL)
+               {
+                       WIPP_HEADER(mem_stat_line, '2');
+                       mem_stat_line[WIPP_CONTROL_HEADER_SIZE] = 0;
+                       wipp_control_send_message((unsigned char*)mem_stat_line, strlen(mem_stat_line));
+               }
+
+               fclose(ver_file);
+       }                                                                                                                          
+}
+
+/************************************************************************
+ *                        wipp_control_set_pp_mode                             *
+ ************************************************************************
+DESCRIPTION: Set the driver to work with debug_module
+************************************************************************/
+void wipp_control_set_pp_mode(ConParm_t parm[], U16 nParms)
+{
+  #ifdef TI_DBG
+       TI_SetReportPPMode(g_id_adapter, parm[0].value); 
+  #endif
+}
+
+/************************************************************************
+ *                        wipp_control_mem_usage                           *
+ ************************************************************************
+DESCRIPTION: Report to the host the current Memory usage
+************************************************************************/
+
+#define MAX_VER_INFO_LINE_LEN (250)
+
+void wipp_control_report_version(ConParm_t parm[], U16 nParms)
+{
+       FILE *ver_file;
+       char ver_line[MAX_VER_INFO_LINE_LEN];
+
+       ver_file = fopen("/proc/version", "r"); 
+
+       if (ver_file != NULL)
+       {
+               if (fgets((ver_line + WIPP_CONTROL_HEADER_SIZE), MAX_VER_INFO_LINE_LEN, ver_file) != NULL)
+               {
+                       WIPP_HEADER(ver_line, '3');
+                       ver_line[125] = 0;
+                       wipp_control_send_message((unsigned char*)ver_line, strlen(ver_line));
+               }
+
+               fclose(ver_file);
+       }
+       else
+       {
+               /* Write the protocol prefix - mark error ('0' in len) */
+               WIPP_HEADER(ver_line, '3');
+               ver_line[WIPP_CONTROL_HEADER_SIZE] = 0;
+               wipp_control_send_message((unsigned char*)ver_line, strlen(ver_line));
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_disable_term_echo                *
+ ************************************************************************
+DESCRIPTION: 
+************************************************************************/
+void wipp_control_disable_term_echo()
+{
+       struct termios term;
+
+       if (isatty(STDIN_FILENO) == 0)
+       {
+               console_printf_terminal("wipp control, Error, standart input is not a terminal device\n");
+       }
+       else
+       {
+               if (tcgetattr(STDIN_FILENO, &term) != -1)
+               {
+                       /* Disable the echoing */
+                       term.c_lflag &= ~(ECHO);
+
+                       if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &term) != -1)
+                       {
+                               console_printf_terminal("wipp control, Echo is disabled!\n");
+                       }
+                       else
+                       {
+                               console_printf_terminal("wipp control, Error writing terminal attributes\n");
+                       }
+               }
+               else
+               {
+                       console_printf_terminal("wipp control, Error reading terminal attributes\n");
+               }
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_set_baud_rate                    *
+ ************************************************************************
+DESCRIPTION: Set the UART baudrate
+************************************************************************/
+void wipp_control_set_baud_rate(int rate_index)
+{
+       struct termios term;
+       int r1,r2;
+
+       if (isatty(STDIN_FILENO) == 0)
+       {
+               console_printf_terminal("wipp control, Error, standart input is not a terminal device\n");
+       }
+       else
+       {
+               if (tcgetattr(STDIN_FILENO, &term) != -1)
+               {
+                       /* Change the baud rate*/
+
+                       r1 = cfsetispeed(&term, B230400);
+                       r2 = cfsetospeed(&term, B230400);
+
+                       console_printf_terminal("wipp control, results: %d, %d\n", r1, r2);
+               }
+               else
+               {
+                       console_printf_terminal("wipp control, Error reading terminal attributes\n");
+               }
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_active_iperf                            *
+ ************************************************************************
+DESCRIPTION: Start the iperf process
+************************************************************************/
+void wipp_control_active_iperf(char *iperf_cmd_line)
+{
+       unsigned int command_length;
+
+       if (SHARED_MEMORY_RUN_PROCESS_RUNNING())
+       {
+               console_printf_terminal("wipp control, wipp_control_active_iperf: Error: process already running!\n");
+
+               wipp_control_send_iperf_results_to_host(WIPP_CONTROL_EVT_RUN_PROCESS_IS_RUNING, NULL, 0);;
+       }
+       else
+       {
+               iperf_cmd_line++;
+
+               command_length = *(iperf_cmd_line + 0) | (*(iperf_cmd_line + 1) << 8) | (*(iperf_cmd_line + 2) << 16) | (*(iperf_cmd_line + 3) << 24);
+               iperf_cmd_line += 4;
+               iperf_cmd_line[command_length] = 0;
+
+               console_printf_terminal("wipp control, wipp_control_active_iperf (Len = %d, Cmd = %s)\n", command_length, iperf_cmd_line);
+
+               /* Send the command to the process */
+               write(wipp_control_general_process_in_pipe[1], iperf_cmd_line, command_length);
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_deactive_iperf                  *
+ ************************************************************************
+DESCRIPTION: Stop the iperf process (if it's running) 
+************************************************************************/
+void wipp_control_deactive_iperf()
+{
+       if (!SHARED_MEMORY_RUN_PROCESS_RUNNING())
+       {
+               console_printf_terminal("wipp control, wipp_control_active_iperf: Error: process is not running!\n");
+
+               wipp_control_send_iperf_results_to_host(WIPP_CONTROL_EVT_RUN_PROCESS_IS_NOT_RUNING, NULL, 0);
+       }
+       else
+       {
+               console_printf_terminal("wipp control, wipp_control_deactive_iperf\n");
+
+               /* Kill the general process process */
+               if (wipp_control_general_process_pid > 0)
+               {
+                       /* Update the process list */
+                       wipp_control_fill_process_table();
+
+                       /* Kill all the child's of the general process */
+                       wipp_control_kill_family_process(wipp_control_general_process_pid);
+
+                       wipp_control_general_process_pid = 0;
+               }
+
+               close(wipp_control_general_process_out_pipe[0]); 
+               close(wipp_control_general_process_in_pipe[1]); 
+               
+               /* Initialize the general process */
+               wipp_control_initialize_general_process();
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_send_iperf_results_to_host       *
+ ************************************************************************
+DESCRIPTION: Send the run process results to the host via ethernet.
+                        The first parameter is the event type (one of the defines), 
+                        it is inserted in the ___ byte of the buffer. Therefor the input
+                        buffer ("inbuf") actual data should start at the ___ byte of the buffer.
+
+CONTEXT           : main process only!
+************************************************************************/
+void wipp_control_send_iperf_results_to_host(unsigned char event, char *inbuf, int result)
+{
+       /* console_printf_terminal("wipp_control, wipp_control_send_iperf_results_to_host (event = %d)\n", event); */
+       unsigned char temp_buffer[5] = {'+', '4', '0', '0', '0'};
+       temp_buffer[2] = event;
+
+       switch (event)
+       {
+       case WIPP_CONTROL_EVT_RUN_PROCESS_STDOUT:
+               WIPP_HEADER(inbuf, '4');
+               inbuf[2] = event;
+               wipp_control_send_message((unsigned char*)inbuf, result + 3);
+               break;
+
+       case WIPP_CONTROL_EVT_RUN_PROCESS_TERMINATE:
+               temp_buffer[3] = (SHARED_MEMORY_RUN_PROCESS_RESULT() & 0x00FF);
+               temp_buffer[4] = ((SHARED_MEMORY_RUN_PROCESS_RESULT() & 0xFF00) >> 8);
+               wipp_control_send_message(temp_buffer, 5);              
+               break;
+
+       case WIPP_CONTROL_EVT_RUN_PROCESS_IS_RUNING:
+       case WIPP_CONTROL_EVT_RUN_PROCESS_IS_NOT_RUNING:
+               wipp_control_send_message(temp_buffer, 3);              
+               break;
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_kill_family_process                     *
+ ************************************************************************
+DESCRIPTION: Recursive kill of all the process child's.
+       
+
+CONTEXT           : 
+************************************************************************/
+void wipp_control_kill_family_process(int father_pid)
+{
+       int index;
+       int status;
+       
+       /* Check to see this process is a parent */
+       for (index = 0; index < process_table_current_index; index++)
+       {
+               if (process_table[index][1] == father_pid)
+               {
+                       wipp_control_kill_family_process(process_table[index][0]);
+               }
+       }
+
+       /* Search for the process and kill it */
+
+       for (index = 0; index < process_table_current_index; index++)
+       {
+               if (process_table[index][0] == father_pid)
+               {
+                       /* Kill the process */
+                       kill(process_table[index][0] ,SIGKILL);
+
+                       waitpid(process_table[index][0], &status, WUNTRACED);
+
+                       /*console_printf_terminal("wipp_control, wipp_control_kill_family_process, Killing index %d, [%d][%d]\n",process_table[index][0], process_table[index][1]);*/
+
+                       /* Mark the process as killed */
+                       process_table[index][0] = process_table[index][1] = -1;
+                                               
+               }
+       }
+}
+
+/************************************************************************
+ *                        wipp_control_fill_process_table                      *
+ ************************************************************************
+DESCRIPTION: Update the table with the current processs information
+       
+
+CONTEXT           : 
+************************************************************************/
+void wipp_control_fill_process_table()
+{
+       DIR *p_directory;
+       struct dirent *p_dir_entry;
+       int direcroty_string_lengh;
+       int index;
+       int is_valid_process_directory;
+
+       /* Clear the table */
+       process_table_current_index = 0;
+
+       /* Open the directory */
+       if ((p_directory = opendir("/proc/")) == NULL)
+       {
+               console_printf_terminal("wipp_control, wipp_control_fill_process_table, Can't open directory!");
+               return;
+       }
+
+       /* Go over all the files in the directory */
+       while ((p_dir_entry = readdir(p_directory)) != NULL)
+       {
+               /* Get rid of the unwanted file names */
+               if ((strcmp(p_dir_entry->d_name, ".") == 0) || 
+                       (strcmp(p_dir_entry->d_name, "..") == 0)) 
+               {
+                       continue;
+               }
+                                                               
+               direcroty_string_lengh = strlen(p_dir_entry->d_name);
+               
+               is_valid_process_directory = 1;
+
+               /* Check if it is valid process directory name */
+               for (index = 0; index < direcroty_string_lengh; index++)
+               {
+                       if ((p_dir_entry->d_name[index] > '9') || (p_dir_entry->d_name[index] < '0'))
+                       {
+                               is_valid_process_directory = 0;
+
+                               break;
+                       }
+               }
+
+               if (is_valid_process_directory)
+               {
+                       FILE *file_des;
+                       int temp_number;
+                       char temp_buffer[TEMP_BUFFER_SIZE];
+
+                       if (snprintf(temp_buffer, TEMP_BUFFER_SIZE, "/proc/%s/status", p_dir_entry->d_name) > 0)
+                       {
+                               /* Get the information out of the status file */
+                               if ((file_des = fopen(temp_buffer, "r")) > 0)
+                               {
+                                       /* Skip the first four lines */
+                                       fgets(temp_buffer, TEMP_BUFFER_SIZE, file_des);
+                                       fgets(temp_buffer, TEMP_BUFFER_SIZE, file_des);
+                                       fgets(temp_buffer, TEMP_BUFFER_SIZE, file_des);
+                                       fgets(temp_buffer, TEMP_BUFFER_SIZE, file_des);
+
+                                       /* Get the process id */
+                                       fgets(temp_buffer, TEMP_BUFFER_SIZE, file_des);
+                                       sscanf(temp_buffer, "%s %d", &temp_buffer[TEMP_BUFFER_SIZE / 2], &temp_number);
+                                       process_table[process_table_current_index][0] = temp_number;
+
+                                       /* Get the parent process id */                                 
+                                       fgets(temp_buffer, TEMP_BUFFER_SIZE, file_des);
+                                       sscanf(temp_buffer, "%s %d", &temp_buffer[TEMP_BUFFER_SIZE / 2], &temp_number);
+                                       process_table[process_table_current_index][1] = temp_number;
+
+                                       fclose(file_des);
+
+                                       process_table_current_index++;
+                                       if (process_table_current_index == MAX_PROCESS_TABLE_INDEX)
+                                       {
+                                               console_printf_terminal("wipp_control, wipp_control_fill_process_table, Error, reached maximum process table index\n");
+
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       closedir(p_directory);
+}
+
+/************************************************************************
+ *                        wipp_control_get_version                     *
+ ************************************************************************
+DESCRIPTION: 
+                        
+CONTEXT    :                    
+************************************************************************/
+void  wipp_control_get_version(void)
+{
+       /***************************
+       Return buffer structure :
+
+       Byte  0    : Header ('+')
+    Byte  1    : OpCode ('a')
+       Byte  2    : Command Status
+       Byte  3-6  : Driver Version
+       Byte  7-10 : FW Version
+       ***************************/
+       
+       tiUINT32 ret;
+       tiUINT8 return_buffer[11];
+
+    TIWLN_VERSION_EX VersionData;
+
+       console_printf_terminal("WIPP control,  wipp_control__get_version.\n");
+
+    ret = (tiUINT8)TI_GetDriverVersion(g_id_adapter, &VersionData);
+
+    memset(return_buffer, 0, sizeof(return_buffer) / sizeof(return_buffer[0]));
+    WIPP_HEADER(return_buffer, 'a');
+       return_buffer[2] = (UINT8)ret;
+    if (ret == OK)
+       {
+        memcpy(return_buffer + 3, &(VersionData.DrvVersion), 4);
+        memcpy(return_buffer + 7, &(VersionData.FWVersion), 4);
+       }
+       wipp_control_send_message(return_buffer, sizeof(return_buffer));
+}
+
diff --git a/sta_dk_4_0_4_32/CUDK/CLI/wipp_ctrl.h b/sta_dk_4_0_4_32/CUDK/CLI/wipp_ctrl.h
new file mode 100644 (file)
index 0000000..9a023a5
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef WIPP_CTRL_H
+#define WIPP_CTRL_H
+
+extern int wipp_control_general_process_pid;
+extern int wipp_control_general_process_out_pipe[2];
+
+
+#define WIPP_CONTROL_CMD_CPU_USAGE                             ('1')
+#define WIPP_CONTROL_CMD_MEM_USAGE                             ('2')
+#define WIPP_CONTROL_CMD_REPORT_VERSION                        ('3')
+#define WIPP_CONTROL_CMD_DEBUG_CONTROL                 ('4')
+#define WIPP_CONTROL_CMD_DEBUG_PATH                            ('5')
+#define WIPP_CONTROL_CMD_ACTIVATE_PROCESS              ('6')
+#define WIPP_CONTROL_CMD_TERMINATE_PROCESS             ('7')
+#define WIPP_CONTROL_CMD_GET_VERSIONS              ('a')
+
+
+#define WIPP_CONTROL_EVT_RUN_PROCESS_STDOUT                    (0x00)
+#define WIPP_CONTROL_EVT_RUN_PROCESS_TERMINATE         (0x01)
+#define WIPP_CONTROL_EVT_RUN_PROCESS_IS_RUNING         (0x02)
+#define WIPP_CONTROL_EVT_RUN_PROCESS_IS_NOT_RUNING  (0x03)
+void wipp_control_send_iperf_results_to_host(unsigned char event, char *inbuf, int result);
+
+unsigned char wipp_control_check_command(char *input_string);
+
+void wipp_control_init(void);
+void wipp_control_deinit(void);
+
+#endif /* #define WIPP_CTRL_H */
diff --git a/sta_dk_4_0_4_32/CUDK/IPC/Linux/cu_ipc.c b/sta_dk_4_0_4_32/CUDK/IPC/Linux/cu_ipc.c
new file mode 100644 (file)
index 0000000..97fe7e1
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include "osTIType.h"
+/*#include "cu_ipc.h"*/
+
+const char* socket_name = "/var/run/echo_server";
+struct sockaddr_un serv_addr, clnt_addr;
+int clnt_sfd;
+/***************************************************************************/
+void config_ipc_init(char* device_name)
+{
+       int serv_addr_len, clnt_addr_len;
+
+       /* Store the client name in the socket address. */
+       /*bzero(serv_addr,sizeof(serv_addr));*/
+       serv_addr.sun_family = AF_LOCAL;
+       strcpy (serv_addr.sun_path, socket_name);
+
+       serv_addr_len = sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path);
+
+    unlink("/var/run/echo_client");
+
+       /* Create the socket. */
+       if((clnt_sfd = socket(AF_LOCAL, SOCK_DGRAM, 0))<0)
+       {
+               printf("--config_ipc_init(): error creating socket\n");
+               exit(1);
+
+       }
+
+       /* Store the client name in the socket address. */
+       /*bzero(clnt_addr,sizeof(clnt_addr));*/
+       clnt_addr.sun_family = AF_LOCAL;
+       strcpy (clnt_addr.sun_path, "/var/run/echo_client");
+       clnt_addr_len = sizeof(clnt_addr.sun_family)+strlen(clnt_addr.sun_path);
+
+       if ( (bind (clnt_sfd, (struct sockaddr *)&clnt_addr, clnt_addr_len )) < 0)
+       {
+               printf("---config_ipc_init(): Error binding \n");
+        unlink(clnt_addr.sun_path);
+    }
+    /*InitTIS_Manager( device_name );*/
+    return;
+
+}
+/***************************************************************************/
+int ipc_send_tosuppl(void *pData, tiUINT32 size)
+{
+    int rc;
+    /*printf("---ipc_send_tosuppl(): %x", size);*/
+    int serv_addr_len = sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path);
+       rc = sendto(clnt_sfd, pData, size, 0,
+                       (struct sockaddr *)&serv_addr, serv_addr_len );
+       if( rc < 0 )
+       {
+               printf("---ipc_send_tosuppl():  Error sending message - %x(%s)\n",errno, strerror(errno));
+        unlink(clnt_addr.sun_path);
+
+       }
+
+    /*printf("--ipc_send_tosuppl():  Message has been sent - %x\n",rc);    */
+    return rc;
+}
+/***************************************************************************/
+void config_ipc_terminate(void)
+{
+    unlink("/var/run/echo_client");
+    /*TerminateTIS_Manager() //TIWLN_SUPPL_TERMINATE*/
+}
+
+
diff --git a/sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_event.c b/sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_event.c
new file mode 100644 (file)
index 0000000..33d4560
--- /dev/null
@@ -0,0 +1,338 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <linux/stddef.h>
+#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
+
+#include <pthread.h>
+
+#include "ipc_event.h"
+#include "cli_cu_common.h"
+#include "tiioctl.h"
+#include "TI_IPC_Api.h"
+
+static int dev_socket = -1;
+static int serv_sfd = -1;
+
+config_registry_t cnfg_registry_table;
+
+UINT32 prId;
+
+static tiINT32  ipc_start = 0;
+/******************************************************************
+    _ipc_EventHandler
+    Driver events handler
+*/
+tiVOID _ipc_EventHandler(UINT8* pEvMessage,  tiUINT32 nEvMessageSize )
+{
+/*    print_memory_dump((char*)pEvMessage, nEvMessageSize );*/
+       if (((IPC_EVENT_PARAMS*) pEvMessage)->pfEventCallback == NULL)
+       {
+        printf("\n---_ipc_EventHandler: ERROR Bad Callback pointer\n");
+        return;
+       }
+
+    if(nEvMessageSize < sizeof(IPC_EVENT_PARAMS))
+    {
+        print_err("\n---_ipc_EventHandler: ERROR event size - %x\n ",nEvMessageSize);
+        return;
+    }
+    print_deb("--_ipc_EventHandler: \n");
+    ((IPC_EVENT_PARAMS*) pEvMessage)->pfEventCallback((IPC_EV_DATA * )pEvMessage);    
+}
+/*********************************************************************
+    _ipc_cu_handler
+    CLI configuration events handler
+*/
+tiVOID _ipc_cu_handler(UINT8* pMessage,  tiUINT32 nMessageSize)
+{
+    print_deb("\n---_ipc_cu_handler() data size - %d\n ",nMessageSize);
+
+    print_memory_dump((char*)pMessage, nMessageSize );
+    IPC_CONFIG_PARAMS *pData_tosend = (IPC_CONFIG_PARAMS *)malloc(sizeof(IPC_CONFIG_PARAMS));
+
+    pData_tosend->F_ConfigNotification = cnfg_registry_table.cfg_cb;
+
+    (*pData_tosend->F_ConfigNotification)(pMessage, nMessageSize );
+
+    free(pData_tosend);
+}
+/*********************************************************************/
+
+void check_unbound(void)
+{
+/*
+    OS_802_11_MAC_ADDRESS curr_mac = { 0 };
+    UINT32  size;
+    if(IPC_DeviceIoControl((TI_HANDLE)ti_drv_name, TIWLN_802_3_CURRENT_ADDRESS, NULL, 0, &curr_mac,
+                                    sizeof(OS_802_11_MAC_ADDRESS),  (tiUINT32*)nSize ))
+    {
+        send unbound
+
+    }
+ */
+}
+/**************************************************************/
+void *_ipc_EventThread(void *args)
+{
+       /* set timeout for select*/
+       int fd;
+    char* buf = (char*)malloc(4096); /* the maximum acceptable size*/
+    fd_set fds_read;
+       struct nlmsghdr * nlHdr;
+       UINT8 * pData;
+       tiUINT32 nDataLen;
+
+       if (dev_socket > serv_sfd)
+               fd = dev_socket+1;
+       else
+        fd = serv_sfd+1;
+
+       print_deb("---_ipc_EventThread() - thread is running fd = %d\n", fd);
+
+       while(1)
+       {
+               /* create fd_set*/
+               FD_ZERO(&fds_read);
+
+        if (dev_socket != -1) 
+            FD_SET(dev_socket, &fds_read);
+               
+        if (serv_sfd != -1) 
+            FD_SET(serv_sfd, &fds_read);
+
+        /* wait for packet on two sockets*/
+        int n = select(fd, &fds_read, NULL, NULL,NULL );
+
+        /* if data is available, receive it*/
+        if( n > 0 )
+        {
+                       /* this is event from the driver*/
+                       if( FD_ISSET(dev_socket, &fds_read) )
+                       {
+                           /* get 'n' bytes from driver socket*/
+                n = recvfrom(dev_socket, buf, 4096, 0, NULL,NULL/*(struct sockaddr*)&sanl, &sanllen*/);
+                if (n <= 0)
+                {
+                    perror(__FUNCTION__);
+                    continue;
+                }
+                               nlHdr = (struct nlmsghdr *)buf;
+
+                               /* Check if header is valid */
+                               if((NLMSG_OK(nlHdr, n) == 0) || (nlHdr->nlmsg_type == NLMSG_ERROR)){
+                                       perror("Error in recieved NetLink packet");
+                                       continue;
+                               }
+                               pData = (UINT8 *)NLMSG_DATA(nlHdr);
+                               nDataLen = NLMSG_PAYLOAD(nlHdr,n);
+                               _ipc_EventHandler (pData, nDataLen );
+
+            }
+
+                       else if( FD_ISSET(serv_sfd, &fds_read) )
+                       {
+                
+                print_deb(" ---_ipc_EventThread() cu receive socket: %x \n",
+                                                                    serv_sfd);
+
+                /*printf(" ---_ipc_EventThread() cu receive enable cnfg_registry_table.enable\n");*/
+                               /* read, get # bytes read*/
+                                   
+                                   n = recvfrom(serv_sfd, buf, 4096, 0,NULL,NULL);
+                                   if(n < 0)
+                                   {
+                                           print_err("--- _ipc_EventThread() -ERROR receiving config msg \n");
+                        continue;
+                                   }
+                                   else
+                        _ipc_cu_handler((UINT8*) buf, n);
+                       }
+
+            else
+                print_err(" ---_ipc_EventThread() cu not a socket: %x \n",serv_sfd);
+        }
+    }
+
+    print_err("IPC exits \n");
+
+    return 0;
+}
+
+
+/******************************************************************************/
+tiINT32 rtnl_open(void)
+{
+
+    int fd;
+    struct sockaddr_nl      local;
+    prId = getpid();
+
+    /*printf("PROCCESS: %d\n", prId);*/
+
+    fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_USERSOCK);
+    if (fd < 0) {
+         perror(__FUNCTION__);
+         return -1;
+     }
+
+     memset(&local, 0, sizeof(local));
+     local.nl_family = AF_NETLINK;
+     /*    local.nl_groups = RTMGRP_LINK;*/
+     local.nl_pid = prId;
+
+     if (bind(fd, (struct sockaddr*)&local, sizeof(local)) < 0) {
+         perror(__FUNCTION__);
+         return -1;
+     }
+     /*printf("User: socket - %d\n",fd);*/
+     return fd;
+
+
+}
+/*****************************************************************************/
+tiINT32 cnfg_open(void)
+{
+       /*int rc;*/
+       struct sockaddr_un serv_addr;/* clnt_addr;*/
+
+       int serv_addr_len;/* clnt_addr_len, max_clnt_len, n;*/
+
+    unlink("/var/run/echo_server");
+       /* Create socket */
+       if(( serv_sfd = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0)
+       {
+               print_err("--Server: error creating socket\n");
+               return -1;
+       }
+    print_deb("---cnfg_open(): socket - %d\n", serv_sfd);
+       /*bzero(serv_addr,sizeof(serv_addr));*/
+       /* Store the client s name in the socket address. */
+       serv_addr.sun_family = AF_LOCAL;
+       strcpy (serv_addr.sun_path, "/var/run/echo_server");
+
+       serv_addr_len = sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path);
+
+       if(bind(serv_sfd, (struct sockaddr*)&serv_addr, serv_addr_len) <0 )
+       {
+               print_err("--Server: error binding to server socket - err %d(%s)\n", errno, strerror(errno));
+               return -1;
+       }
+       return 0;
+}
+/*****************************************************************************/
+tiINT32 ipc_interfaces_init(tiVOID)
+{
+       int                 rc;
+    pthread_t           ev_thread_id;
+
+
+       /* Open netlink channel */
+    if((dev_socket = rtnl_open()) < 0)
+    {
+      printf("\nCan't initialize rtnetlink socket\n");
+      return -1;
+    }
+    print_deb("---ipc_interfaces_init - rtnetlink socket  is created \n");
+    rc = pthread_create(&ev_thread_id, NULL, _ipc_EventThread, (void*)NULL);
+
+    print_deb("---ipc_CreateInterface() - thread is created \n");
+       if (rc)
+               printf("---ipc_CreateInterface() - ERROR code from pthread_create() is %d\n", rc);
+       return 0;
+}
+/******************************************************************************/
+tiINT32 IPC_RegisterEvent(TI_HANDLE hDevice, IPC_EVENT_PARAMS*         pEvParams)
+{
+
+    /*set ioctl event enable*/
+    IPC_EVENT_PARAMS* pReg = (IPC_EVENT_PARAMS*)pEvParams;
+    IPC_EVENT_PARAMS ouput;
+    tiINT32 res;
+    tiUINT32 bytesReturned;
+
+    if(pReg->uEventType == IPC_EVENT_UNBOUND)/*insert UNBOUND*/
+    {
+               return 0;
+    }
+
+
+    pEvParams->uDeliveryType = DELIVERY_PUSH;
+    pEvParams->uProcessID = prId;
+    print_deb("---IPC_RegisterEvent() event - %#x\n",  pReg->uEventType);
+    res = IPC_DeviceIoControl(hDevice, TIWLN_802_11_ENABLE_EVENT, (tiVOID*)pEvParams, sizeof(IPC_EVENT_PARAMS), /*NULL,0*/&ouput, sizeof(IPC_EVENT_PARAMS), &bytesReturned );
+    pReg->uEventID = ouput.uEventID;
+    return res;
+
+}
+/******************************************************************************/
+tiINT32 IPC_UnRegisterEvent(TI_HANDLE hDevice, IPC_EVENT_PARAMS* pEvParams)
+{
+    UINT32 id = (UINT32)pEvParams->uEventID;
+    tiUINT32 bytesReturned;
+
+    /*set ioctl event disable*/
+    return IPC_DeviceIoControl(hDevice, TIWLN_802_11_DISABLE_EVENT, (tiVOID*)&id, sizeof(UINT32), NULL, 0, &bytesReturned );
+}
+/******************************************************************************/
+tiINT32 IPC_RegisterConfig(tiVOID* pEvParams, tiUINT32 EvParamsSize)
+{
+    /*set ioctl event enable*/
+
+    IPC_CONFIG_PARAMS  *pData      = (IPC_CONFIG_PARAMS*)pEvParams;
+
+    cnfg_registry_table.len = EvParamsSize;
+    cnfg_registry_table.cfg_cb = pData->F_ConfigNotification;
+    cnfg_registry_table.enable = 1;
+    print_deb("---IPC_RegisterConfig() l - %x \n", cnfg_registry_table.len);
+    return 0;
+
+}
+
+/*****************************************************************************/
+TI_HANDLE IPC_Init(void)
+{
+    int rc = 0;
+    if(ipc_start)
+        return (TI_HANDLE)rc;
+    else
+    {
+        rc = ipc_interfaces_init();
+        ipc_start++;
+    }
+    return (TI_HANDLE)rc;
+
+}
+/*****************************************************************************/
+tiINT32 IPC_DeInit (void)
+{
+   /* close(dev_socket );*/
+   /* close(serv_sfd );*/
+    return 0;
+}
diff --git a/sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_event.h b/sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_event.h
new file mode 100644 (file)
index 0000000..ee3c089
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+#ifndef _IPC_EVENT
+#define _IPC_EVENT
+
+
+#include "ipc_event.h"
+#include "osTIType.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+tiINT32 ipc_CreateInterface (tiVOID);
+
+
+typedef struct IPC_CONFIG_PARAMS
+{
+    tiUINT32   len;
+    tiINT32 (*F_ConfigNotification)(tiVOID*  pCuData, tiUINT32 nDataSize);
+    tiUINT32      enable;
+}IPC_CONFIG_PARAMS;
+
+typedef struct config_registry
+{
+       tiUINT32        len;
+       TI_HANDLE       hReceiver;
+       PVOID       cfg_cb;
+       tiUINT32    enable;
+}config_registry_t;
+
+typedef struct unbound_registry
+{
+       TI_HANDLE       hReceiver;
+       PVOID       cfg_cb;
+       tiUINT32    enable;
+}unbound_registry_t;
+
+typedef struct _reg_clients
+{
+       UINT32          EventCode;
+    UINT32      ProcessId;
+}reg_clients_t;
+tiINT32 IPC_RegisterConfig(tiVOID* pEvParams, tiUINT32 EvParamsSize);
+
+tiINT32 ipc_interfaces_init(tiVOID);
+
+tiINT32 cnfg_open(tiVOID);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_user.c b/sta_dk_4_0_4_32/CUDK/IPC/Linux/ipc_user.c
new file mode 100644 (file)
index 0000000..ec1d7a7
--- /dev/null
@@ -0,0 +1,332 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/wireless.h>
+#include <stdlib.h>
+
+#include <unistd.h>
+
+#include "tiioctl.h"
+
+#include "osDot11.h"
+#include "linux_ioctl_common.h"
+#include "cli_cu_common.h"
+
+#include "TI_IPC_Api.h"
+
+
+static int     g_socket = 0;                /* socket descriptor */
+
+static int iw_sockets_open(void)
+{
+/*    int netlink_sock = -1;  */      /* Kernel user interface device */
+    int ipx_sock = -1;              /* IPX socket                   */
+    int ax25_sock = -1;             /* AX.25 socket                 */
+    int inet_sock = -1;             /* INET socket                  */
+    int ddp_sock = -1;              /* Appletalk DDP socket         */
+
+        /*
+         * Now pick any (exisiting) useful socket family for generic queries
+     * Note : don't open all the socket, only returns when one matches,
+     * all ocols might not be valid.
+     * Workaround by Jim Kaba <jkaba@sarnoff.com>
+     * Note : in 99% of the case, we will just open the inet_sock.
+     * The remaining 1% case are not fully correct...
+         */
+    /*netlink_sock=socket(PF_NETLINK, SOCK_DGRAM, 0);
+    if(netlink_sock!=-1)
+        return netlink_sock;*/
+    inet_sock=socket(AF_INET, SOCK_DGRAM, 0);
+    if(inet_sock!=-1)
+        return inet_sock;
+    ipx_sock=socket(AF_IPX, SOCK_DGRAM, 0);
+    if(ipx_sock!=-1)
+        return ipx_sock;
+    ax25_sock=socket(AF_AX25, SOCK_DGRAM, 0);
+    if(ax25_sock!=-1)
+        return ax25_sock;
+    ddp_sock=socket(AF_APPLETALK, SOCK_DGRAM, 0);
+    /*
+    * If this is -1 we have no known network layers and its time to jump.
+    */
+    return ddp_sock;
+}
+
+
+TI_HANDLE IPC_DeviceOpen (tiVOID* pAdapterName)
+{
+   g_socket = iw_sockets_open();
+   if( g_socket == -1 )
+   {
+       perror("socket");
+       return 0;
+   }    
+    /* create interfaces for events receiving */
+    /*
+    if (_ipc_CreateInterface(pAdapterName))
+    {
+        print_err("**IPC error**\n");
+        return NULL;
+    }
+    */
+    return (pAdapterName && *((char *) pAdapterName)) ? (TI_HANDLE) pAdapterName : NULL;
+}
+
+tiINT32 IPC_DeviceClose(TI_HANDLE hDevice)
+{
+    if( g_socket )
+           close( g_socket );
+    return 0;
+}
+
+tiINT32 IPC_DeviceIoControl(TI_HANDLE hDevice, tiUINT32 ioctl_cmd, tiVOID* bufIn, tiUINT32 sizeIn, 
+                                                tiVOID* bufOut, tiUINT32 sizeOut, tiUINT32* sizeRet  )
+
+{
+    int res, max_size, cmd;
+    struct ifreq req;
+    tiioctl_req_t *ti_req = (tiioctl_req_t *) &req.ifr_ifru;
+    tiVOID* buf, *setget_buf = NULL;
+    tiUINT32 size;
+    int cmd_type = ((bufOut) ? IOCTL_GET : 0) | ((bufIn) ? IOCTL_SET : 0);
+    if( !g_socket )
+    {
+        print_err("**Socket error**\n");
+        return -EINVAL;
+    }
+    
+    if( (cmd_type & IOCTL_SETGET) == IOCTL_SETGET )
+    {
+        size = max( max(sizeIn, sizeOut ), 8 );        /* always pass as pointer to buffer*/
+        if( size >= 0xFFFF )
+        {
+            print_err("Max. size for SET_GET ioctl - %u bytes (sizeIn=%u, sizeOut=%u)\n",
+                    0xFFFF, sizeIn, sizeOut );
+            return -ENOMEM;
+        }
+        buf = setget_buf = malloc(size);
+        if( !setget_buf ){
+                       print_err("IPC_DeviceIoControl: setget_buf is NULL\n");
+            return -ENOMEM;
+               }
+        memmove(setget_buf, bufIn, sizeIn );
+        
+        cmd = SIOCDEVPRIVATE;
+    }
+    else
+    {
+        if( cmd_type & IOCTL_GET )
+        {
+            buf = bufOut;
+            size = sizeOut;
+            cmd = SIOCDEVPRIVATE+1;        /* for GET private ioctls */
+        }
+        else
+        {
+            buf = bufIn;
+            size= sizeIn;
+            cmd = SIOCDEVPRIVATE;        /* for SET private ioctls */
+        }
+    }
+#if DEBUG    
+    memset(&req, 0xfe, sizeof(req) );
+#endif    
+    print_deb("===IPC_DeviceIoControl('%s', cmd=%u (%s%s), data=%p (%#x), size=%u, sizeRet = %p(%x))\n", 
+            (char *) hDevice, ioctl_cmd, 
+            (cmd_type & IOCTL_SET) ? "SET" : "", (cmd_type & IOCTL_GET) ? "GET" : "", 
+            buf, (buf) ? * (tiINT32 *)buf : 0, size, sizeRet,  sizeRet ? *sizeRet : -1);
+
+    max_size = ((char *) &req + sizeof(req)) - (char *) &ti_req->user_data_pointer;
+    
+    ti_req->length      = size;
+    ti_req->cmd         = ioctl_cmd;
+    ti_req->cmd_type    = cmd_type;
+
+    if( size > max_size )
+    {
+        ti_req->user_data_pointer     = (tiUINT32) buf;
+    }
+    else
+    {
+        if( cmd_type & IOCTL_SET )         /* SET ioctl */
+        {
+            /*print_deb("util_get_ioctl(): offset=%d, data='%s', size=%d\n", offset, (char *)data, size);*/
+            memmove( ((tiCHAR *) &ti_req->user_data_pointer), buf, size );
+        }
+        else 
+            ti_req->user_data_pointer = 0;
+    }
+
+    strncpy(req.ifr_ifrn.ifrn_name, (char *) hDevice, IFNAMSIZ);
+
+    print_deb("===== send_ioctl: socket=%d, cmd=%d, &req=%p\n", g_socket, cmd, &req );
+    print_deb("===== send_ioctl: req={name='%s', sub_cmd=%ld, size=%ld (max=%d), data=%p\n",
+                req.ifr_ifrn.ifrn_name, ti_req->cmd, ti_req->length, max_size, (void *) ti_req->user_data_pointer );
+
+/*    print_memory_dump( (char *) &req, sizeof(req));*/
+    res = ioctl(g_socket, cmd, &req);
+#ifdef GWSI_DRIVER
+       /* Yuck - set the result to 0 in case ioctl return error */ 
+       if (res == -1) res = 0;
+#endif
+       if( res )
+    {            /* for DEBUG version ONLY*/
+        print_deb( "** IPC_DeviceIoControl() return %d\n", res /*(char *) hDevice*/ );
+/*        return res;*/
+    }
+    else
+    {
+        if( cmd_type & IOCTL_GET )
+        {
+                       size = ti_req->length;
+
+            if( (cmd_type & IOCTL_SETGET) == IOCTL_SETGET )
+            {
+                               memmove(bufOut,setget_buf,size);
+                free( setget_buf );                
+            }
+            else
+            {
+                if( size <= max_size )
+                    memmove( buf, (char *) &ti_req->user_data_pointer, size );
+                print_memory_dump((char *) buf, min(32, size) );
+                print_deb( "IPC_DeviceIoControl(): Size=%u, max_size=%d, *data=%x\n", size, max_size, * (tiUINT32*) buf );
+            }
+        }
+        
+        if( sizeRet )
+            *sizeRet = size;    /* ti_req->length */
+    
+        print_deb("===== send_ioctl: res=%d, sizeRet=%p (%x)\n", res, sizeRet, sizeRet ? *sizeRet : -1);
+    }
+
+    return res;
+}
+
+
+/* --------------------------------------------------------- */
+
+
+
+/* tiINT32 TI_hwReset (TI_HANDLE  hAdapter)*/
+/* {*/
+/*     tiUINT32 data = 1;*/
+/*     return IPC_DeviceIoControl( hAdapter, TIWLN_HW_RESET_HW, IOCTRL_SET, &data, sizeof(data) );*/
+/*      return tiwlan_get_ioctl(hAdapter, -1, TIWLN_HW_RESET_HW, &data, sizeof(data) ); */
+/* }*/
+
+/* tiINT32 TI_NumberOfAntennas (TI_HANDLE hAdapter, tiUINT32* puNumberOfAntennas )*/
+/* {*/
+/*     return IPC_DeviceIoControl( hAdapter, TIWLN_802_11_NUMBER_OF_ANTENNAS, IOCTRL_GET, puNumberOfAntennas, sizeof(tiUINT32) );*/
+/* }*/
+
+
+/* int tiwlan_set_mixed_mode( U32 drv_handler, U32 data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_MIXED_MODE_SET, &data, sizeof(data) );*/
+/* }*/
+/* */
+/* int tiwlan_get_mixed_mode( U32 drv_handler, U32 *p_data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_MIXED_MODE_GET, p_data, sizeof(*p_data) );*/
+/* }*/
+/* */
+/* int tiwlan_set_privacy_mode( U32 drv_handler, U32 data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_PRIVACY_MODE_SET, &data, sizeof(data) );*/
+/* }*/
+/* */
+/* int tiwlan_get_privacy_mode( U32 drv_handler, U32 *p_data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_PRIVACY_MODE_GET, p_data, sizeof(*p_data) );*/
+/* }*/
+/* */
+/* int tiwlan_set_exc_security_type( U32 drv_handler, U32 data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_EXC_SECURITY_TYPE_SET, &data, sizeof(data) );*/
+/* }*/
+/* */
+/* int tiwlan_get_exc_security_type( U32 drv_handler, U32 *p_data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_EXC_SECURITY_TYPE_GET, p_data, sizeof(*p_data) );*/
+/* }*/
+/* int tiwlan_set_tx_power_val( U32 drv_handler, U32 data )*/
+/* {*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_TX_POWER_VALUE_SET, &data, sizeof(data) );*/
+/* }*/
+/* */
+/* int tiwlan_get_tx_power_val( U32 drv_handler, U32 *p_data )*/
+/* {*/
+/*     print_deb("===GET_TX_POWER_VAL: %d\n", TIWLN_TX_POWER_VALUE_GET );*/
+/*     return tiwlan_get_ioctl( g_id_adapter, -1, TIWLN_TX_POWER_VALUE_GET, p_data, sizeof(*p_data) );*/
+/* }*/
+/* */
+
+/* int tiwlan_get_current_mac( TI_HANDLE drv_handler, OS_802_11_MAC_ADDRESS *data)*/
+/* {*/
+/*     return IPC_DeviceIoControl(drv_handler, TIWLN_802_3_CURRENT_ADDRESS, NULL, 0, data, sizeof(*data), NULL);*/
+/* }*/
+
+/* int tiwlan_get_current_channel(TI_HANDLE drv_handler, tiUINT32 *data)*/
+/* {*/
+/*     return IPC_DeviceIoControl( drv_handler, TIWLN_802_11_CHANNEL_GET, NULL, 0, data, sizeof(data), NULL );*/
+/* }*/
+
+/* int tiwlan_get_desired_ssid(TI_HANDLE drv_handler, char *data)*/
+/* {*/
+/*     OS_802_11_SSID ssid = { 0 };*/
+/*     int res = IPC_DeviceIoControl( drv_handler, TIWLN_802_11_DESIRED_SSID_GET, NULL, 0, &ssid, sizeof(OS_802_11_SSID), NULL );*/
+/*     if( !res )*/
+/*     {*/
+/*         memmove(data, ssid.Ssid, ssid.SsidLength );*/
+/*         data[ssid.SsidLength] = 0;*/
+/*     }*/
+/*     return res;*/
+/* }*/
+
+
+void print_memory_dump(char *addr, int size )
+{
+    int i;
+    char buf[4096];
+
+    if( size * 4 > sizeof(buf) )
+    {
+        print_err("print_memory_dump(): buffer too small\n");
+        return;
+    }
+
+    buf[0] = 0;
+    for(i=0; i<size; i++ )
+    {
+        if( !(i % 16) )
+            sprintf(&buf[strlen(buf)], "%sTI_CU:%p: ", (i) ? "\n" : "", addr+i );
+        sprintf(&buf[strlen(buf)], "%02x ", (unsigned char) addr[i] );
+    }
+    print_deb("%s\n", buf);
+}
+
diff --git a/sta_dk_4_0_4_32/CUDK/IPC/Linux/proc_main.c b/sta_dk_4_0_4_32/CUDK/IPC/Linux/proc_main.c
new file mode 100644 (file)
index 0000000..b171bef
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/**************************************************************************/
+/*                                                                        */
+/* MODULE:  proc_main.c                                                 */
+/* PURPOSE: Supplicant Initialization                                    */
+/*                                                                       */
+/**************************************************************************/
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <fcntl.h>      /* for O_WRONLY*/
+
+ #include <sys/time.h>
+ #include <sys/resource.h>
+ #include <unistd.h>
+
+typedef unsigned int    UINT32;     /*nick*/
+
+#include "osTIType.h"
+
+#include "TI_SupplicantStub.h"
+#include "TI_IPC_Api.h"
+#include "ipc_event.h"
+
+
+
+extern tiBOOL      g_bTerminate ;
+
+int main(int argc, char ** argv)
+{
+#ifdef TI_DBG
+    struct rlimit rLimit;
+
+    rLimit.rlim_cur = 1024*1024;
+    rLimit.rlim_max = 1024*1024;
+
+    setrlimit(RLIMIT_CORE,&rLimit);
+#endif
+
+    FILE *f = fopen("/dev/console", "w" );
+    int hfile_output = -1;
+    if( !f )
+        fprintf(stderr, "/dev/console open failed: %d(%s)\n", errno, strerror(errno) );
+    else
+    {
+        if( dup2( f->_fileno, 1 ) == -1 )
+        {
+            fprintf(f, "dup2(hfile, 1) failed: %d(%s)\n", errno, strerror(errno) );
+        }
+        if( dup2( f->_fileno, 2 ) == -1 )
+        {
+            fprintf(f, "dup2(hfile, 2) failed: %d(%s)\n", errno, strerror(errno) );
+        }
+    }
+
+    if( argc == 2 )
+    {
+        hfile_output = open((char *) argv[1], O_WRONLY );
+        if( hfile_output == -1 )
+        {
+            perror((char *) argv[1]);
+            goto exit;
+        }
+        if( dup2( 1, hfile_output ) == -1 )
+        {
+            fprintf(stderr, "dup2(1, hfile_output) failed: %d(%s)\n", errno, strerror(errno) );
+        }
+        if( dup2( 2, hfile_output ) == -1 )
+        {
+            fprintf(stderr, "dup2(2, hfile_output) failed: %d(%s)\n", errno, strerror(errno) );
+        }
+    }
+    /* Open socket channel for CLI configuration */
+    if(cnfg_open() != 0)
+       {
+        printf("\nCan't initialize configure socket\n");
+        return -1;
+    }
+
+    if(IPC_Init())
+    {
+        printf("---main(): ERROR IPC init\n");
+
+    }
+
+    IPC_CONFIG_PARAMS *pRegistry_config = (IPC_CONFIG_PARAMS*)malloc(sizeof(IPC_CONFIG_PARAMS));
+
+    pRegistry_config->F_ConfigNotification = SendDataStub;
+
+    if(IPC_RegisterConfig((void*)pRegistry_config,
+                                                sizeof(IPC_CONFIG_PARAMS)))
+    {
+        printf("---main(): ERROR registration CONFIG Messages\n");
+    }
+       free(pRegistry_config);
+
+
+    for(;g_bTerminate != TRUE;)
+    {
+        usleep(1000000);     /* sleep 1 sec*/
+    }
+       
+exit:
+    if( f > 0 )
+        fclose( f );
+    if( hfile_output > 0 )
+        close( hfile_output );
+    return 0;
+}
+
+
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterApiC.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterApiC.h
new file mode 100644 (file)
index 0000000..7652a0f
--- /dev/null
@@ -0,0 +1,1521 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+/*--------------------------------------------------------------------------*/
+/* Module:      TI_AdapterApiC.H*/
+/**/
+/* Purpose:     This module contains "C" interface for TI WLAN Utility Adapter.*/
+/**/
+/*--------------------------------------------------------------------------*/
+#ifndef _TI_ADAPTER_API_H
+#define _TI_ADAPTER_API_H
+
+#include "paramOut.h"
+#include "roamingMngrTypes.h"
+#include "tiwlnif.h"
+#include "TI_IPC_Api.h"
+
+
+#include "TI_AdapterQOS.h"
+#include "TI_AdapterGWSI.h"
+#include "TI_AdapterSEC.h"
+#include "TI_AdapterSG.h"
+#include "TI_AdapterPM.h"
+
+#ifdef EXC_MODULE_INCLUDED
+    #include "TI_AdapterEXC.h"
+    #define EXC_SUPPORT_H    ADAPTER_EXC
+#else
+    #define EXC_SUPPORT_H
+#endif /*EXC_MODULE_INCLUDED*/
+
+#ifdef TI_DBG     
+#include "TI_AdapterDBG.h"
+#endif/* TI_DBG*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    
+/******************************************************************************
+
+    Name:   TI_AdapterInit
+    Desc:   Create and initialize the Utility Adapter object
+    Params: pszDeviceName - Pointer to a null-terminated string that contains 
+                            the name of the specific WLAN device, If this parameter
+                            is NULL, TI_AdapterInit() returns a handle to the adapter
+                            object that will work with first founded WLAN device.
+    
+    Return: If the function succeeds, the return value is a handle to the 
+            specified Adapter. If the function fails, the return value is NULL.
+    
+******************************************************************************/
+    TI_HANDLE   TI_AdapterInit              (tiCHAR*    pszDeviceName );
+
+/******************************************************************************
+
+    Name:   TI_AdapterDeinit
+    Desc:   This function destroys the Utility Adapter object.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_AdapterDeinit            (TI_HANDLE  hAdapter      );
+
+/******************************************************************************
+
+    Name:   TI_GetApiVersion
+    Desc:   This function retrieves the API version information.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_GetApiVersion            (TI_HANDLE  hAdapter, tiUINT32* puApiVersion);
+
+
+/******************************************************************************
+
+    Name:   TI_GetDriverVersion
+    Desc:   This function retrieves the driver and firmware version information. 
+            PdrvVersion points to a TIWLN_VERSION structure, which is defined in
+            tiwlnif.h.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pdrvVersion - A pointer to TIWLN_VERSION_EX structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetDriverVersion      (TI_HANDLE  hAdapter, 
+                                      TIWLN_VERSION_EX* pdrvVersion ); 
+
+
+/******************************************************************************
+
+    Name:   TI_GetCurrentAddress
+    Desc:   This function retrieves the MAC Address of the wireless card.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pCurrentAddr - A pointer to OS_802_11_MAC_ADDRESS that contains the 
+                           MAC Address.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetCurrentAddress     (TI_HANDLE  hAdapter, 
+                                      OS_802_11_MAC_ADDRESS* pCurrentAddr);
+
+
+
+/******************************************************************************
+
+    Name:   TI_GetDriverCapabilities
+    Desc:   This function retrieves the driver capabilities list.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pDrvCapabilities - A pointer to a OS_802_11_DRIVER_CAPABILITIES 
+                               structure that contains the WiLink\99 4.0 driver 
+                               capabilities.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetDriverCapabilities(TI_HANDLE  hAdapter, 
+                                     OS_802_11_DRIVER_CAPABILITIES* pDrvCapabilities);
+
+/******************************************************************************
+
+    Name:   TI_SetBSSID
+    Desc:   Specify the BSSID to connect.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pAddrBSSID - A pointer to an OS_802_11_MAC_ADDRESS structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetBSSID                 (TI_HANDLE  hAdapter, 
+                                         OS_802_11_MAC_ADDRESS *pAddrBSSID);
+
+/******************************************************************************
+
+    Name:   TI_GetBSSID
+    Desc:   This function retrieves the BSSID of the current connection
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pAddrBSSID - A pointer to an OS_802_11_MAC_ADDRESS structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetBSSID                 (TI_HANDLE  hAdapter, 
+                                         OS_802_11_MAC_ADDRESS *pAddrBSSID);
+
+/******************************************************************************
+
+    Name:   TI_GetBSSIDList
+    Desc:   This function retrieves the BSSID list from the driver after a scan
+            operation completes. ppBSSIDlist points to an OS_802_11_BSSID_LIST_EX
+            structure, which is defined in osDot11.h.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pAddrBSSID - A pointer to an OS_802_11_BSSID_LIST structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetBSSIDList             (TI_HANDLE  hAdapter, 
+                                         OS_802_11_BSSID_LIST_EX** ppBSSIDlist );
+
+
+
+/******************************************************************************
+
+    Name:   TI_GetFullBSSIDList
+    Desc:   This function is almost the same as TI_SetBSSIDList, the only 
+            difference is that is retrieves more information than TI_SetBSSIDList.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            ppBSSIDlist - A pointer to an OS_802_11_BSSID_LIST structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetFullBSSIDList         (TI_HANDLE  hAdapter, 
+                                         OS_802_11_BSSID_LIST_EX** ppBSSIDlist );
+
+/******************************************************************************
+
+    Name:   TI_GetSelectedBSSIDInfo
+    Desc:   Retrieves the BSSID information from the driver after a scan operation
+            completes and select was performed. The information structure is 
+            published in OS_802_11_BSSID_EX format (see TI_GetBSSIDList() command).
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSelectedBSSIDInfo - A pointer to a structure to be filled with the 
+                                 selected BSSID information.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetSelectedBSSIDInfo     (TI_HANDLE hAdapter, 
+                                         OS_802_11_BSSID_EX  *pSelectedBSSIDInfo);
+
+/******************************************************************************
+
+    Name:   TI_GetPrimaryBSSIDInfo
+    Desc:   Retrieves the primary BSSID information from the driver, i.e. the BSSID
+                The STA is currently connected to. The information structure is 
+            published in OS_802_11_BSSID_EX format (see TI_GetBSSIDList() command).
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSelectedBSSIDInfo - A pointer to a structure to be filled with the 
+                                 selected BSSID information.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetPrimaryBSSIDInfo      (TI_HANDLE hAdapter, 
+                                         OS_802_11_BSSID_EX  *pSelectedBSSIDInfo);
+
+/******************************************************************************
+
+    Name:   TI_SetDesiredChannel
+    Desc:   This function sets the desired operating channel. uDesiredChannel 
+            points to a channel number, which can range from 1 to 14, 
+            36,40,44,48,52,56,60,64 depended from mode.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uDesiredChannel - A pointer to a tiUINT32 that contains the channel
+                              number.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetDesiredChannel        (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uDesiredChannel);
+
+/******************************************************************************
+
+    Name:   TI_GetDesiredChannel
+    Desc:   This function retrieves the desired operating channel. 
+            puDesiredChannel points to a channel number, which can range from 
+            1 to 14, 36,40,44,48,52,56,60,64 depended on mode (a/b/g).
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puDesiredChannel - A pointer to a tiUINT32 that contains the channel
+                               number.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetDesiredChannel        (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puDesiredChannel);
+
+/******************************************************************************
+
+    Name:   TI_GetCurrentChannel
+    Desc:   This function retrieves the current operating channel. 
+            puDesiredChannel points to a channel number, which can range from 
+            1 to 14, 36,40,44,48,52,56,60,64 depended on mode (a/b/g).
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puCurrentChannel - A pointer to a tiUINT32 that contains the current
+                               channel number.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetCurrentChannel        (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puCurrentChannel);
+
+/******************************************************************************
+
+    Name:   TI_GetDesiredRate
+    Desc:   This function retrieves the desired transmission rate for the adapter.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puDesiredRate - A pointer to a tiUINT32 that contains the desired 
+                            transmission rate
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetDesiredRate           (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puDesiredRate);
+/******************************************************************************
+
+    Name:   TI_GetCurrentRate
+    Desc:   This function retrieves the current transmission rate for the 
+            adapter. The adapter may change the desired rate if using AUTO rate.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puCurrentRate - A pointer to a tiUINT32 that contains the current 
+                            transmission rate
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetCurrentRate           (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puCurrentRate);
+
+/******************************************************************************
+
+    Name:   TI_SetFragmentThreshold
+    Desc:   This function sets the current fragmentation threshold.
+            Only packets that are greater than the fragmentation threshold are
+            fragmented.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uFragmentThreshold - a pointer to a tiUINT32 that contains the 
+                                 fragmentation threshold in bytes.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetFragmentThreshold     (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uFragmentThreshold );
+
+/******************************************************************************
+
+    Name:   TI_GetFragmentThreshold
+    Desc:   This function retrieves the current fragmentation threshold.
+            Only packets that are greater than the fragmentation threshold 
+            are fragmented.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uFragmentThreshold - A pointer to a tiUINT32 that contains the 
+                                 fragmentation threshold in bytes.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetFragmentThreshold     (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puFragmentThreshold);
+
+/******************************************************************************
+
+    Name:   TI_SetBSSType
+    Desc:   This function sets the network mode, either Infrastructure or Ad Hoc.
+            uBSSType points to an OS_802_11_NETWORK_MODE enum, which is defined in
+            osDot11.h.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uBSSType - Points to the network mode (OS_802_11_NETWORK_MODE enum):
+                       os802_11IBSS - for Ad Hoc mode.
+                       os802_11Infrastructure - for infrastructure mode.
+                       os802_11AutoUnknown - for automatic mode in which the 
+                                             adapter can switch between Ad Hoc and 
+                                             infrastructure modes as required.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetBSSType               (TI_HANDLE  hAdapter, 
+                                         OS_802_11_NETWORK_MODE  uBSSType );
+
+/******************************************************************************
+
+    Name:   TI_GetBSSType
+    Desc:   This function retrieves the network mode. For more information see 
+            TI_SetBSSID().
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puBSSType - A pointer to the network mode (OS_802_11_NETWORK_MODE enum):
+                        see TI_SetBSSType.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetBSSType               (TI_HANDLE  hAdapter, 
+                                         OS_802_11_NETWORK_MODE* puBSSType);
+
+
+
+/******************************************************************************
+
+    Name:   TI_SetBeaconFilterDesiredState
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uBeaconFilterMode - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetBeaconFilterDesiredState(TI_HANDLE  hAdapter, 
+                                           OS_802_11_BEACON_FILTER_MODE uBeaconFilterMode );
+
+/******************************************************************************
+
+    Name:   TI_GetBeaconFilterDesiredState
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uBeaconFilterMode - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetBeaconFilterDesiredState(TI_HANDLE  hAdapter, 
+                                           tiUINT8* uBeaconFilterMode );
+
+/******************************************************************************
+
+    Name:   TI_SetRTSThreshold
+    Desc:   This function sets the current RTS (Request to Send) threshold.
+            The value specifies the packet size, in bytes, beyond which the WLAN
+            invokes its RTS/CTS mechanism. Packets that exceed the specified RTS
+            threshold trigger the RTS/CTS mechanism. The NIC transmits smaller
+            packets without RTS/CTS.
+            An RTS threshold value of 0 indicates that the NIC should transmit all
+            packets with RTS/CTS.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uRTSThreshold - Contains the RTS Threshold in bytes.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetRTSThreshold          (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uRTSThreshold  );
+
+/******************************************************************************
+
+    Name:   TI_GetRTSThreshold
+    Desc:   This function retrieves the current RTS (Request to Send) threshold.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puRTSThreshold - A pointer to a tiUINT32 that contains the RTS 
+                             Threshold in bytes.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetRTSThreshold          (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puRTSThreshold );  
+
+/******************************************************************************
+
+    Name:   TI_SetShortPreamble
+    Desc:   This function sets the current preamble length. 
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    uShortPreamble - Indicates the preamble length. A value of 0 specifies long 
+                     preambles and a value of 1 specifies short preambles.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetShortPreamble         (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uShortPreamble );
+
+/******************************************************************************
+
+    Name:   TI_GetShortPreamble
+    Desc:   This function retrieves the current preamble length. A value of 0 
+            (zero) in puShortPreamble specifies long preambles and a value of 
+            1 (one) specifies short preambles.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puShortPreamble - A pointer to a tiUINT32 that indicates the 
+                              preamble length.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetShortPreamble         (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puShortPreamble);
+
+
+/******************************************************************************
+
+    Name:   TI_SetSSID
+    Desc:   This function sets desired SSID.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSSIDname - Pointer to a null-terminated string that contains a 
+                        desired SSID
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetSSID                  (TI_HANDLE  hAdapter, 
+                                         tiUINT8*   pSSIDname   );
+
+/******************************************************************************
+
+    Name:   TI_GetDesiredSSID
+    Desc:   This function retrieves the desired SSID.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSSID - Pointer to a null-terminated string that contains a desired
+                    SSID.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetDesiredSSID           (TI_HANDLE  hAdapter, 
+                                         OS_802_11_SSID* pSSID  );
+
+/******************************************************************************
+
+    Name:   TI_GetCurrentSSID
+    Desc:   This function retrieves the current SSID.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSSID - Pointer to a null-terminated string that contains a current
+                    SSID.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetCurrentSSID           (TI_HANDLE  hAdapter, 
+                                         OS_802_11_SSID* pSSID   );
+
+/******************************************************************************
+
+    Name:   TI_GetStatistics
+    Desc:   This function retrieves driver statistics. pStatistics points to a 
+            TIWLN_STATISTICS structure, which is defined in tiwlnif.h. The 
+            OS_802_11* types are defined in osDot11.h.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pStatistics - A pointer to a TIWLN_STATISTICS structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetStatistics            (TI_HANDLE  hAdapter, 
+                                         TIWLN_STATISTICS* pStatistics );
+
+/******************************************************************************
+
+    Name:   TI_GetTxStatistics
+    Desc:   This function retrieves driver statistics. pStatistics points to a
+            TIWLN_TX_STATISTICS structure, which is defined in tiwlnif.h. The 
+            OS_802_11* types are defined in osDot11.h. The TIWLN_TX_STATISTICS
+            structure includes the structure txDataCounters_t.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pTxStatistics - A pointer to a TIWLN_TX_STATISTICS structure.
+            clearStatsFlag - Indication whether to clear the statistic counters
+                             upon read.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetTxStatistics          (TI_HANDLE  hAdapter, 
+                                         TIWLN_TX_STATISTICS* pTxStatistics, 
+                                         UINT32 clearStatsFlag );
+
+/******************************************************************************
+
+Name:   TI_EnableDisableRxDataFilters
+Desc:   This function enables or disables the Rx Data Filter feature.
+
+Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+        enable - 0 to disable the feature, any other value to enable
+Return: TI_RESULT_OK on success. Any other value indicates an error.
+
+******************************************************************************/
+tiINT32     TI_EnableDisableRxDataFilters(TI_HANDLE hAdapter,
+                                          tiBOOL enabled);
+
+
+/******************************************************************************
+
+Name:   TI_AddRxDataFilter
+Desc:   This function adds the given filter to the WLAN driver's list of
+data filters.
+
+Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+pRequest - A pointer to the data filter request.
+Return: TI_RESULT_OK on success, RX_FILTER_ALREADY_EXISTS if filter
+        already exists. Any other value indicates an error.
+
+******************************************************************************/
+tiINT32     TI_AddRxDataFilter          (TI_HANDLE hAdapter,
+                                         TIWLAN_DATA_FILTER_REQUEST * pRequest);
+
+
+/******************************************************************************
+
+Name:   TI_GetRxDataFiltersStatistics
+Desc:   This function adds the given filter to the WLAN driver's list of
+        data filters.
+
+Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+        pRequest - A pointer to the data filter request.
+Return: TI_RESULT_OK on success. Any other value indicates an error.
+
+******************************************************************************/
+tiINT32     TI_GetRxDataFiltersStatistics(TI_HANDLE hAdapter,
+                                          TIWLAN_DATA_FILTER_STATISTICS * pStatistics);
+
+
+/******************************************************************************
+
+Name:   TI_GetPowerConsumptionStatistics
+Desc:   This function retrieves the power consumption statisticts from the FW.
+
+Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+        pStatistics - A pointer to the statistics data structure.
+Return: TI_RESULT_OK on success. Any other value indicates an error.
+
+******************************************************************************/
+tiINT32     TI_GetPowerConsumptionStatistics(TI_HANDLE hAdapter, PowerConsumptionTimeStat_t * pStatistics);
+
+
+
+/******************************************************************************
+
+Name:   TI_RemoveRxDataFilter
+Desc:   This function removes a previously added filter with the given
+        details from the WLAN driver's list of data filters. Note that the
+        request must be identical to the one given when the filter was added.
+
+Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+        pRequest - A pointer to the data filter request.
+Return: TI_RESULT_OK on success, RX_FILTER_DOES_NOT_EXIST if filter
+        doesn't exist. Any other value indicates an error.
+
+******************************************************************************/
+tiINT32     TI_RemoveRxDataFilter          (TI_HANDLE hAdapter,
+                                            TIWLAN_DATA_FILTER_REQUEST * pRequest);
+
+
+/******************************************************************************
+
+    Name:   TI_SetSupportedRates
+    Desc:   This function sets the transmission rates supported by the driver.
+            This is the list of basic and supported rates. Basic rates have MSB
+            set to 1 (one).
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSupportedRatesLst - A pointer to a buffer that contains list of rates.
+            uBufLength - Contains a size of buffer.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetSupportedRates        (TI_HANDLE  hAdapter, 
+                                         tiUINT8*   pSupportedRatesLst, 
+                                         tiUINT32  uBufLength );
+
+/******************************************************************************
+
+    Name:   TI_GetSupportedRates
+    Desc:   This function retrieves the transmission rates supported by the driver.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSupportedRatesLst - A pointer to a buffer that contains list of rates.
+            uBufLength - Contains a size of buffer
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetSupportedRates        (TI_HANDLE  hAdapter, 
+                                         tiUINT8*   pSupportedRatesLst, 
+                                         tiUINT32  uBufLength );
+
+
+/******************************************************************************
+
+    Name:   TI_SetIBSSProtection
+    Desc:   Sets the 802.11g extended rate protection (ERP) configuration of 
+            the driver. Configuration of ERP is only possible when the adapter 
+            is operating in Ad Hoc mode. In infrastructure mode, the driver uses
+            the ERP method supported by the AP.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uProtection - Indicates the 802.11g protections.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   This function supported only on WiLink\99 4.0 - based designs.
+    
+******************************************************************************/
+tiINT32     TI_SetIBSSProtection        (TI_HANDLE  hAdapter, 
+                                         tiUINT32  uProtection );
+
+/******************************************************************************
+
+    Name:   TI_GetIBSSProtection
+    Desc:   Returns the 802.11g extended rate protection (ERP) configuration of 
+            the driver. For more information see TI_SetIBSSProtection().
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puProtection - A pointer to a tiUINT32 that indicates the 802.11g
+                           protections.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetIBSSProtection        (TI_HANDLE  hAdapter, 
+                                         tiUINT32* puProtection);
+
+/******************************************************************************
+
+    Name:   TI_GetDriverState
+    Desc:   This function returns a driver's state.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puDriverState - A pointer to a driverState_e that indicates the 
+                            driver state:
+                            DRIVER_STATE_IDLE = 0,
+                            DRIVER_STATE_SCANNING = 1,
+                            DRIVER_STATE_SELECTING = 2,
+                            DRIVER_STATE_CONNECTING = 3,
+                            DRIVER_STATE_CONNECTED = 4,
+                            DRIVER_STATE_DISCONNECTED = 5,
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetDriverState           (TI_HANDLE  hAdapter,  
+                                         driverState_e* puDriverState );
+
+/******************************************************************************
+
+    Name:   TI_SetShortSlot
+    Desc:   Sets the 802.11g slot time. 
+            A value of 0 (zero) in uShortSlot indicates a long slot time (20 uSec) 
+            A value of 1 (one) in uShortSlot indicates a short slot time (9 uSec).
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uShortSlot - Indicates the 802.11g slot time.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    Note: This function supported only on WiLink\99 4.0 - based designs.
+    
+******************************************************************************/
+tiINT32     TI_SetShortSlot             (TI_HANDLE  hAdapter, 
+                                         tiUINT32  uShortSlot  );
+
+/******************************************************************************
+
+    Name:   TI_GetShortSlot
+    Desc:   Returns the 802.11g slot time. Refer to TI_SetShortSlot.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puShortSlot - pointer to a tiUINT32 that indicates the 802.11g slot
+                          time.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetShortSlot             (TI_HANDLE  hAdapter, 
+                                         tiUINT32* puShortSlot );
+
+/******************************************************************************
+
+    Name:   TI_SetTxPowerDbm
+    Desc:   This function sets the maximum station transmit power in Dbm. The station 
+            also takes into consideration two additional power level settings 
+            AP-IE and Chip ID. The final setting is the minimum of among these
+            three settings.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uTxPower - Contains a station power level
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetTxPowerDbm          (TI_HANDLE  hAdapter, 
+                                         tiUINT8  uTxPower);
+
+/******************************************************************************
+
+    Name:   TI_GetTxPowerLevel
+    Desc:   Retrieve the current station power level table.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puTxPower - A pointer to a tiCHAR that contains the station power 
+                        level table.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetTxPowerLevel          (TI_HANDLE  hAdapter, 
+                                         tiCHAR* puTxPower);
+
+/******************************************************************************
+
+    Name:   TI_GetTxPowerDbm
+    Desc:   Retrieve the current Tx Power in Dbm/10 value.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puTxPower - A pointer to a tiCHAR that contains the station TX power
+                        in Dbm value.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetTxPowerDbm            (TI_HANDLE  hAdapter, 
+                                         tiCHAR* puTxPower);
+
+/******************************************************************************
+
+    Name:   TI_GetSupportedNetworkTypes
+    Desc:   This function retrieves the supported network types.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pNetTypeLst - Pointer to the buffer that contains list of supported 
+                          network types.
+            uMaxNetTypes - Maximum number of types that will contains in the 
+                           buffer pNetTypeLst.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetSupportedNetworkTypes (TI_HANDLE  hAdapter, 
+                                         OS_802_11_NETWORK_TYPE* pNetTypeLst, 
+                                         tiUINT32 uMaxNetTypes);
+
+/******************************************************************************
+
+    Name:   TI_SetNetworkTypeInUse
+    Desc:   This function sets the network type.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uNetType - Contains network type:
+                        os802_11FH,
+                        os802_11DS,
+                        os802_11OFDM5,
+                        os802_11OFDM24,
+                        os802_11OFDM24_AND_5 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetNetworkTypeInUse      (TI_HANDLE  hAdapter, 
+                                         OS_802_11_NETWORK_TYPE   uNetType  );
+
+/******************************************************************************
+
+    Name:   TI_GetNetworkTypeInUse
+    Desc:   This function retrieves the current network type in use.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puNetType - Pointer to the buffer that contains value of network type.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetNetworkTypeInUse      (TI_HANDLE  hAdapter, 
+                                         OS_802_11_NETWORK_TYPE*  puNetType );
+
+
+/******************************************************************************
+
+    Name:   TI_GetNumberOfAntennas
+    Desc:   This function retrieves the number of antennas.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puNumberOfAntennas - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetNumberOfAntennas      (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puNumberOfAntennas    );
+
+/******************************************************************************
+
+    Name:   TI_SetAntennaDiversityParams
+    Desc:   This function sets various antenna diversity parameters.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pAntennaDiversityOptions - Pointer to antenna diversity parameters 
+                  structure holding required parameters:
+                  enableRxDiversity - specifies whether antenna diversity should
+                                      be enables for reception.
+                  rxSelectedAntenna - specifies which antenna to use for reception.
+                  enableTxDiversity - specifies whether antenna diversity should 
+                                      be enables for transmission.
+                  txSelectedAntenna - specifies which antenna to use for 
+                                      transmission.
+                  rxTxSharedAnts    - specifies whether to share reception and
+                                      transmission antennas.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetAntennaDiversityParams(TI_HANDLE  hAdapter, 
+                                         PTIWLAN_ANT_DIVERSITY pAntennaDiversityOptions);
+
+
+/******************************************************************************
+
+    Name:   TI_GetRegDomainTable
+    Desc:   This function retrieves the regularity domain table.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pRegDomainTable - Pointer to TIWLAN_REGDOMAINS structure which includes
+                              regulatory domains table and its size.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetRegDomainTable(TI_HANDLE  hAdapter, 
+                                 TIWLN_REGDOMAINS* pRegDomainTable);                                         
+                                         
+/******************************************************************************
+
+    Name:   TI_EnableDisable_802_11d
+    Desc:   This function enables or disables the 802.11d protocol.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            enableDisable_802_11d - Enable or Disable value
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_EnableDisable_802_11d    (TI_HANDLE  hAdapter, 
+                                         tiUINT8 enableDisable_802_11d);
+
+/******************************************************************************
+
+    Name:   TI_Get_802_11d
+    Desc:   This function retrieves whether the 802.11d protocol in enabled or 
+            disabled.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            enableDisable_802_11d - A pointer to a tiUINT8 which returns an 
+                                    Enable or Disable value.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Get_802_11d              (TI_HANDLE  hAdapter, 
+                                         tiUINT8 *enableDisable_802_11d);
+
+/******************************************************************************
+
+    Name:   TI_EnableDisable_802_11h
+    Desc:   This function enables or disables the 802.11h protocol.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            enableDisable_802_11h - Enable or Disable value
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_EnableDisable_802_11h    (TI_HANDLE  hAdapter, 
+                                         tiUINT8 enableDisable_802_11h);
+
+/******************************************************************************
+
+    Name:   TI_Get_802_11h
+    Desc:   This function retrieves whether the 802.11h protocol in enabled or
+            disabled.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            enableDisable_802_11h - A pointer to a tiUINT8 which returns an 
+                                    Enable or Disable value.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Get_802_11h              (TI_HANDLE  hAdapter, 
+                                         tiUINT8 *enableDisable_802_11h);
+
+/******************************************************************************
+
+    Name:   TI_Set_countryIeFor2_4_Ghz
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            countryIe - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Set_countryIeFor2_4_Ghz  (TI_HANDLE  hAdapter, 
+                                         country_t countryIe);
+
+/******************************************************************************
+
+    Name:   TI_Get_countryIeFor2_4_Ghz
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            countryString - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Get_countryIeFor2_4_Ghz  (TI_HANDLE  hAdapter, 
+                                         tiUINT8 **countryString);
+
+/******************************************************************************
+
+    Name:   TI_Set_countryIeFor5_Ghz
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            countryIe - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Set_countryIeFor5_Ghz    (TI_HANDLE  hAdapter, 
+                                         country_t countryIe);
+
+/******************************************************************************
+
+    Name:   TI_Get_countryIeFor5_Ghz
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            countryString - 
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Get_countryIeFor5_Ghz    (TI_HANDLE  hAdapter, 
+                                         tiUINT8 **countryString);
+
+/******************************************************************************
+
+    Name:   TI_Set_minMaxDfsChannels
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            DFS_ChannelRange - Minimum and maximum cahnnel numbers for which 
+                               DFS is used
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Set_minMaxDfsChannels    (TI_HANDLE  hAdapter,
+                                         DFS_ChannelRange_t DFS_ChannelRange);
+
+/******************************************************************************
+
+    Name:   TI_Get_minMaxDfsChannels
+    Desc:   
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            DFS_ChannelRange - Minimum and maximum cahnnel numbers for which 
+                               DFS is used
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Get_minMaxDfsChannels    (TI_HANDLE  hAdapter,
+                                         DFS_ChannelRange_t *DFS_ChannelRange);
+
+/******************************************************************************
+
+    Name:   TI_Start
+    Desc:   This command starts the driver operation. The driver will start 
+            scanning and will try to connect according to its configuration.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   Used for Linux only.
+
+******************************************************************************/
+    tiINT32     TI_Start                    (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_Stop
+    Desc:   This command blocks the driver's API and turns off the WiLink\99 4.0 
+            HW. The driver will be kept loaded and will keep its configuration
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   Used for Linux only.
+    
+******************************************************************************/
+    tiINT32     TI_Stop                     (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_StartSM
+    Desc:   This command starts the Supplicant Manager module operation.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_StartSM                  (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_StopSM
+    Desc:   This command stops the supplicant manager operation.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_StopSM                   (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_GetRSSI
+    Desc:   This function returns the current RSSI.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pRSSI - The current RSSI level.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetRSSI                  (TI_HANDLE  hAdapter, 
+                                         tiINT32* pRSSI); 
+
+/******************************************************************************
+
+    Name:   TI_GetSNR
+    Desc:   This function returns the current SNR.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pSNR - The current SNR level.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetSNR                   (TI_HANDLE  hAdapter, 
+                                         tiUINT32* pSNR); 
+
+/******************************************************************************
+
+    Name:   TI_Disassociate
+    Desc:   This command sets Junk SSID to the Driver. It makes the WiLink\99 4.0
+            to disassociate any current AP and to return to idle state. The 
+            Driver does not attempt to connect to any other AP until a valid 
+            SSID is set.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_Disassociate             (TI_HANDLE  hAdapter);
+
+
+
+/******************************************************************************
+
+    Name:   TI_RegisterEvent
+    Desc:   This function registers a driver event, which will trigger the 
+            specified callback function.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pEventParams - Information about the event to which you are registering.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_RegisterEvent            (TI_HANDLE  hAdapter, 
+                                         IPC_EVENT_PARAMS*     pEventParams );
+
+/******************************************************************************
+
+    Name:   TI_UnRegisterEvent
+    Desc:   This function un-registers a driver event.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pEventParams - Information about the event to which you are 
+                           registering.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_UnRegisterEvent          (TI_HANDLE  hAdapter, 
+                                         IPC_EVENT_PARAMS*     pEventParams );
+
+/******************************************************************************
+
+    Name:   TI_StartScan
+    Desc:   Starts a scan operation. The user can define the scan parameters.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pScanParams - The parameters for the requested scan.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   up to 16 scanned channels.
+    
+******************************************************************************/
+tiINT32     TI_StartScan                (TI_HANDLE  hAdapter, 
+                                         scan_Params_t *pScanParams);
+
+/******************************************************************************
+
+    Name:   TI_StopScan
+    Desc:   Send a command to the WiLink\99 4.0 driver to terminate the scan process.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_StopScan                 (TI_HANDLE  hAdapter);
+    
+/******************************************************************************
+
+    Name:   TI_SetScanPolicy
+    Desc:   Sends a command buffer to the driver scan manager logic.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            buffer - A pointer to the buffer holding the scan policy.
+            bufferLength - The length of the above buffer.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetScanPolicy            (TI_HANDLE  hAdapter, 
+                                         UINT8* buffer, 
+                                         UINT16 bufferLength);
+
+/******************************************************************************
+
+    Name:   TI_GetScanBssList
+    Desc:   Retrieves the scan manager tracking BSS list. This function should 
+            be used for debug purposes only.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            bssList - A pointer to a buffer in which the BSS list will be stored.                      
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetScanBssList           (TI_HANDLE  hAdapter, 
+                                         bssList_t* bssList);
+
+
+
+
+
+
+    /* ****************************************** */
+/******************************************************************************
+
+    Name:   TI_WLAN_IsDriverRun 
+    Desc:   This command returns the driver status, running or Idle.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pbStatus - The Driver status, running or IDLE.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_WLAN_IsDriverRun             (TI_HANDLE  hAdapter, 
+                                             tiBOOL* pbStatus);
+
+/******************************************************************************
+
+    Name:   TI_Set4XState   
+    Desc:   This command sets the 4X state.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            bStatus - TRUE-4X enabled, FALSE \96 disabled..
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   NOT SUPPORTED !!!
+    
+******************************************************************************/
+tiINT32     TI_Set4XState                   (TI_HANDLE  hAdapter, 
+                                             tiBOOL bStatus);
+
+/******************************************************************************
+
+    Name:   TI_Get4XState   
+    Desc:   This command returns 4X status.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pbStatus - .
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_Get4XState                   (TI_HANDLE  hAdapter, 
+                                             tiBOOL* pbStatus);
+
+/******************************************************************************
+
+    Name:   TI_SetExtRatesIE    
+    Desc:   This command sets the Draft number.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uExtRatesIE - The Draft number: 5 or earlier, 6 or later..
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetExtRatesIE                (TI_HANDLE  hAdapter, 
+                                             tiUINT32 uExtRatesIE);
+
+/******************************************************************************
+
+    Name:   TI_GetExtRatesIE    
+    Desc:   This command returns the Draft number.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puExtRatesIE - The Draft number: 5 or earlier, 6 or later..
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetExtRatesIE                (TI_HANDLE  hAdapter, 
+                                             tiUINT32* puExtRatesIE);
+
+/******************************************************************************
+
+    Name:   TI_SetEarlyWakeupMode    
+    Desc:   This command sets the Early Wakeup mode.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uEarlyWakeup - The early Wakeup  mode: 0 - disabled, 1 - enabled
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32      TI_SetEarlyWakeupMode          (TI_HANDLE  hAdapter,
+                                              tiUINT8 uEarlyWakeup);
+
+/******************************************************************************
+
+    Name:   TI_GetEarlyWakeupMode    
+    Desc:   This command returns the Early Wakeup mode.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uEarlyWakeup - The early Wakeup  mode: 0 - disabled, 1 - enabled
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32      TI_GetEarlyWakeupMode         (TI_HANDLE  hAdapter,
+                                              tiUINT8* uEarlyWakeup);
+
+
+/******************************************************************************
+
+    Name:   TI_SetRoamingConfiguration  
+    Desc:   The TI_SetRoamingConfiguration() function sends a command buffer to 
+            the driver roaming manager logic.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            buffer - The command buffer.
+            bufferLength - The roam command buffer length (bytes).
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_SetRoamingConfiguration      (TI_HANDLE  hAdapter, 
+                                             UINT8* buffer, 
+                                             UINT16 bufferLength);
+
+/******************************************************************************
+
+    Name:   TI_GetRoamingConfiguration  
+    Desc:   The TI_SetRoamingConfiguration() function sends a command buffer to 
+            the driver roaming manager logic.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            buffer - The command buffer.
+            bufferLength - The roam command buffer length (bytes).
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+tiINT32     TI_GetRoamingConfiguration      (TI_HANDLE  hAdapter, 
+                                             UINT8* buffer, 
+                                             UINT16 bufferLength);
+
+
+
+
+/* PLT */
+/******************************************************************************
+
+    Name:   TI_PLT_ReadRegister 
+    Desc:   This command reads a firmware register value.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uRegisterAddr  - Register address.
+            puRegisterData - Pointer to the register data.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_ReadRegister     (TI_HANDLE  hAdapter,
+                                         UINT32 uRegisterAddr,
+                                         PUINT32 puRegisterData );
+
+/******************************************************************************
+
+    Name:   TI_PLT_WriteRegister    
+    Desc:   This command writes a firmware register value.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uRegisterAddr - Register address.
+            uRegisterData - register data.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_WriteRegister    (TI_HANDLE  hAdapter,
+                                         UINT32 uRegisterAddr,
+                                         UINT32 uRegisterData );
+/******************************************************************************
+
+    Name:   TI_PLT_RxPerStart   
+    Desc:   Start or resume the PER measurement. 
+            This function will put the device in promiscuous mode, and resume counters update. 
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_RxPerStart       (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_PLT_RxPerStop    
+    Desc:   Stop Rx PER measurements. 
+            This function stop counters update and make it is safe to read the PER test result.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_RxPerStop        (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_PLT_RxPerClear   
+    Desc:   Clear the Rx PER test results.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_RxPerClear       (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_PLT_RxPerGetResults  
+    Desc:   Get the last Rx PER test results.
+            The RX PER test is conducted in order to evaluate the PER of received packets and is basically done by measuring the ratio between the amount of packets received with FCS errors and the total amount of packets received at a certain period of time.
+            You can Start and Stop the frame accumulation several times, and read the total frame count after the last Stop command.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPltRxPer - The PLT PER results.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_RxPerGetResults  (TI_HANDLE  hAdapter,
+                                         PltRxPer_t* pPltRxPer );
+/******************************************************************************
+
+    Name:   TI_PLT_TxCW 
+    Desc:   Generate carrier wave in a specific channel and band..
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPltTxCW -  The Carrier wave channel and band.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_TxCW             (TI_HANDLE  hAdapter,
+                                         TestCmdChannelBand_t* pPltTxCW);
+/******************************************************************************
+
+    Name:   TI_PLT_TxContiues   
+    Desc:   Continuous transmit series of numbers with a valid MAC header (
+            "CAFE BABE" & "DEAD BEEF" as MAC address). However there is no 802.11 air access compliance.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPltTxContinues -  Infrmation about continuess transmition.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_TxContiues       (TI_HANDLE  hAdapter,
+                                         PltTxContinues_t* pPltTxContinues);
+/******************************************************************************
+
+    Name:   TI_PLT_TxStop   
+    Desc:   Stop packet transmission initiated by the TI_PLT_TxCW() and TI_PLT_TxContiues() functions.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_TxStop           (TI_HANDLE  hAdapter);
+
+/******************************************************************************
+
+    Name:   TI_PLT_ReadMIB  
+    Desc:   Reads a PLT MIB.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pMib - Holds the MIB structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_ReadMIB          (TI_HANDLE  hAdapter,
+                                         PLT_MIB_t* pMib);
+/******************************************************************************
+
+    Name:   TI_PLT_WriteMIB 
+    Desc:   Writes a PLT MIB.
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pMib - Holds the MIB structure.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_WriteMIB         (TI_HANDLE  hAdapter,
+                                         PLT_MIB_t* pMib);
+
+/******************************************************************************
+          TX Calibration functions
+******************************************************************************/
+
+/******************************************************************************
+    Name:   TI_PLT_TxCalGainGet        
+    Desc:      Retrieves the TX chain gain settings.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPLTGainGet - Holds the return gain results.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+       tiINT32         TI_PLT_TxCalGainGet             (TI_HANDLE  hAdapter,
+                                         PltGainGet_t* pPLTGainGet);
+
+/******************************************************************************
+
+    Name:   TI_PLT_TxCalGainAdjust     
+    Desc:      Changes the TX chain gain settings.
+            Value is provided in 0.25 dB steps. (e.g. 0xfe is -0.5dB ; 0x10 is +4 dB)
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uTxGainChange - the TX gain change from current value in 2's complement.
+                               Value is defined in steps of 0.25dB.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+       tiINT32         TI_PLT_TxCalGainAdjust  (TI_HANDLE  hAdapter,
+                                         tiINT32   uTxGainChange);
+
+/******************************************************************************
+
+    Name:   TI_PLT_TxCalStart  
+    Desc:      This PLT function handles all the activities required before initiating the TX calibration procedure.
+            As part of it activities it should make sure that CLPC is disabled and the gain control loop is open.            
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+                       pPLTTxCal - Band, Channel, Reference Tx power.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+       tiINT32         TI_PLT_TxCalStart       (TI_HANDLE  hAdapter,
+                                                                        PltTxCalibrationRequest_t* pPLTTxCal);
+
+/******************************************************************************
+
+    Name:   TI_PLT_TxCalStop   
+    Desc:      This PLT function is a cleanup functions for the radio to be able to resume normal operation.
+            As part of its activities it should put the CLPC mode back into operation.            
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+       tiINT32         TI_PLT_TxCalStop        (TI_HANDLE  hAdapter);
+    
+/******************************************************************************
+
+    Name:   TI_PLT_TxCalStop   
+    Desc:      This PLT function provides the all information required by the upper 
+            driver in order to update the NVS image. It received a parameter 
+            defining the type of update information required and provides an array 
+            of elements defining the data bytes to be written to the NVS image and 
+            the byte offset in which they should be written.            
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPLT_NVSUpdateBuffer - The data to be updated in the NVS file.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+       tiINT32         TI_PLT_RxTxCalNVSUpdateBuffer   (TI_HANDLE  hAdapter,
+                                             PltNvsResultsBuffer_t* pPLT_NVSUpdateBuffer);
+
+    
+/******************************************************************************
+
+    Name:   TI_PLT_TxCalGainAdjust     
+    Desc:      This PLT function perform a RSSI measurement on the selected channel, 
+            and returns the data bytes to be written to the NVS image and 
+            the byte offset in which they should be written. 
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPltRxCalibration_t - The input and output parametrs needed for the RX calibration.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+       tiINT32         TI_PLT_RxCal(TI_HANDLE  hAdapter,
+                             PltRxCalibrationRequest_t* pPltRxCalibration_t); 
+
+    
+/******************************************************************************
+
+    Name:   TI_PLT_RadioTune 
+    Desc:   Generate carrier wave in a specific channel and band..
+    Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+            TestCmdChannelBand_t -  The channel and band.
+    Return: TI_RESULT_OK on success. Any other value indicates an error.
+    
+******************************************************************************/
+    tiINT32     TI_PLT_RadioTune         (TI_HANDLE  hAdapter,
+                                         TestCmdChannelBand_t* pChannelBand);
+
+#ifdef _WINDOWS
+#endif 
+
+
+/******************************************************************************
+
+Name:   TI_PLT_TxPowerRef 
+Desc:   Set Tx power reference.
+Params: hAdapter - The Adapter handle returned by TI_AdapterInit().
+uTxPower -  Tx power in Dbm/10.
+Return: TI_RESULT_OK on success. Any other value indicates an error.
+
+******************************************************************************/
+       tiINT32     TI_PLT_TxPowerRef                (TI_HANDLE  hAdapter,
+                                                                                        tiUINT32 uTxPower);
+
+       
+
+#ifdef TI_DBG
+#ifdef DRIVER_PROFILING
+    tiINT32     TI_ProfileReport                (TI_HANDLE  hAdapter);
+    tiINT32     TI_CpuEstimatorCommand          (TI_HANDLE  hAdapter, tiUINT8 uType, tiUINT32 uData);
+#endif
+#endif
+
+    tiINT32     TI_Open_EAPOL_Interface        ( TI_HANDLE  hAdapter);
+    tiINT32     TI_Close_EAPOL_Interface       ( TI_HANDLE  hAdapter);
+    tiINT32     TI_Send_EAPOL_Packet           ( TI_HANDLE  hAdapter, tiVOID* pData, tiUINT32 uSize );
+    tiINT32     TI_GetAssociationInfo       (TI_HANDLE  hAdapter, OS_802_11_ASSOCIATION_INFORMATION** ppInfo );
+
+    tiINT32     TI_AddKey                   (TI_HANDLE  hAdapter, OS_802_11_KEY*        pKey    );
+    tiINT32     TI_RemoveKey                (TI_HANDLE  hAdapter, OS_802_11_REMOVE_KEY* pRemoveKey);
+
+/******************************************************************************
+
+    Add support for EXC API functions
+
+******************************************************************************/
+  EXC_SUPPORT_H
+
+/*****************************************************************************/
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+tiBOOL TI_CheckAdapterObject(void *pObj);
+
+#endif /* _TI_ADAPTER_API_H*/
+
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterApiCpp.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterApiCpp.h
new file mode 100644 (file)
index 0000000..9766fed
--- /dev/null
@@ -0,0 +1,344 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterApiCpp.h*/
+/**/
+/* Purpose:*/
+/**/
+/*--------------------------------------------------------------------------*/
+#ifndef _TIWLAN_INTERFACE_H
+#define _TIWLAN_INTERFACE_H
+
+#include "paramOut.h"
+#include "tiwlnif.h"
+#include "roamingMngrTypes.h"
+
+#ifdef EXC_MODULE_INCLUDED
+    #define EXC_MODULE_SUPPORT_AH    ADAPTER_EXC_SUPPORT_AH
+#else
+    #define EXC_MODULE_SUPPORT_AH
+#endif /*EXC_MODULE_INCLUDED */
+
+struct   TI_WLAN_AdapterAPI
+{      
+    virtual ~TI_WLAN_AdapterAPI(){};
+    virtual tiINT32     GetApiVersion               ( tiUINT32*    pdwApiVersion )                                  = 0;
+
+    virtual tiINT32     GetBSSID                    ( OS_802_11_MAC_ADDRESS*    pAddrBSSID)                                                    = 0;
+    virtual tiINT32     SetBSSID                    ( OS_802_11_MAC_ADDRESS*    pAddrBSSID)                            = 0;
+    virtual tiINT32     GetBSSIDList                ( OS_802_11_BSSID_LIST_EX** ppBSSIDlist )                       = 0;
+    virtual tiINT32     GetFullBSSIDList            ( OS_802_11_BSSID_LIST_EX** ppBSSIDlist )                       = 0;
+
+    virtual tiINT32     GetCurrentAddress           ( OS_802_11_MAC_ADDRESS*    pCurrentAddr)                       = 0;
+     
+    virtual tiINT32     SetDesiredChannel           ( tiUINT32  uDesiredChannel   )                                 = 0;
+    virtual tiINT32     GetDesiredChannel           ( tiUINT32* puDesiredChannel  )                                 = 0;
+    virtual tiINT32     GetCurrentChannel           ( tiUINT32* puCurrentChannel  )                                 = 0;
+        
+    virtual tiINT32     GetDesiredRate              ( tiUINT32* puDesiredRates    )                                 = 0;
+    virtual tiINT32     GetCurrentRate              ( tiUINT32* puCurrentRates    )                                 = 0;
+
+    virtual tiINT32     SetFragmentThreshold        ( tiUINT32  uFragmentThreshold  )                               = 0;
+    virtual tiINT32     GetFragmentThreshold        ( tiUINT32* puFragmentThreshold )                               = 0;
+
+    virtual tiINT32     SetBSSType                  ( OS_802_11_NETWORK_MODE  uBSSType  )                           = 0;
+    virtual tiINT32     GetBSSType                  ( OS_802_11_NETWORK_MODE* puBSSType )                           = 0;
+
+    virtual tiINT32     SetLongRetry                ( tiUINT32  uLongRetry  )                                       = 0;
+    virtual tiINT32     GetLongRetry                ( tiUINT32* puLongRetry )                                       = 0;
+    
+    virtual tiINT32     ConfigPowerManagement       ( OS_802_11_POWER_PROFILE thePowerMgrProfile )                  = 0;
+
+    virtual tiINT32     SetRTSThreshold             ( tiUINT32  uRTSThreshold  )                                    = 0;
+    virtual tiINT32     GetRTSThreshold             ( tiUINT32* puRTSThreshold )                                    = 0;    
+
+    virtual tiINT32     SetShortPreamble            ( tiUINT32  uShortPreamble )                                    = 0;
+    virtual tiINT32     GetShortPreamble            ( tiUINT32* puShortPreamble)                                    = 0;
+
+    virtual tiINT32     SetShortRetry               ( tiUINT32  uShortRetry )                                       = 0;
+    virtual tiINT32     GetShortRetry               ( tiUINT32* puShortRetry )                                      = 0;
+
+    virtual tiINT32     SetSSID                     ( tiUINT8*   pSSIDname )                                         = 0;
+    virtual tiINT32     GetDesiredSSID              ( OS_802_11_SSID*   pSSID       )                               = 0;
+    virtual tiINT32     GetCurrentSSID              ( OS_802_11_SSID*   pSSID       )                               = 0;
+    
+    virtual tiINT32     GetStatistics               ( TIWLN_STATISTICS* ptiStatistics )                             = 0;
+    virtual tiINT32     GetTxStatistics             ( TIWLN_TX_STATISTICS* ptiTxStatistics, UINT32 clearStatsFlag ) = 0;
+    
+    virtual tiINT32     EnableDisableRxDataFilters  ( tiBOOL  enabled )                                             = 0;
+    virtual tiINT32     GetRxDataFiltersStatistics  ( TIWLAN_DATA_FILTER_STATISTICS * pStatistics )                 = 0;
+    virtual tiINT32     AddRxDataFilter             ( TIWLAN_DATA_FILTER_REQUEST * pRequest )                       = 0;
+    virtual tiINT32     RemoveRxDataFilter          ( TIWLAN_DATA_FILTER_REQUEST * pRequest )                       = 0;
+    
+    virtual tiINT32     SetSupportedRates           ( tiUINT8*  pSupportedRatesLst, tiUINT32  uBufLength)           = 0;
+    virtual tiINT32     GetSupportedRates           ( tiUINT8*  pSupportedRatesLst, tiUINT32  uBufLength)           = 0;
+
+    virtual tiINT32     GetDriverVersion            ( TIWLN_VERSION_EX*  pdrvVersion )                              = 0;
+
+    virtual tiINT32     SetIBSSProtection           ( tiUINT32  uProtection )                                       = 0;
+    virtual tiINT32     GetIBSSProtection           ( tiUINT32* puProtection)                                       = 0;
+
+    virtual tiINT32     GetDriverState              ( driverState_e* puDriverState )                                = 0;
+
+    virtual tiINT32     SetShortSlot                ( tiUINT32  uShortSlot )                                        = 0;
+    virtual tiINT32     GetShortSlot                ( tiUINT32* puShortSlot)                                        = 0;
+
+    virtual tiINT32     SetTxPowerDbm              ( tiUINT8  uTxPower  )                                         = 0;
+    virtual tiINT32     GetTxPowerLevel             ( tiCHAR* puTxPower )                                         = 0;
+    virtual tiINT32     GetTxPowerDbm               ( tiCHAR* puTxPower )                                         = 0;
+
+    virtual tiINT32     GetSupportedNetworkTypes    ( OS_802_11_NETWORK_TYPE* pNetTypeLst, tiUINT32 uMaxNetTypes )  = 0;
+    virtual tiINT32     SetNetworkTypeInUse         ( OS_802_11_NETWORK_TYPE  uNetType   )                          = 0;
+    virtual tiINT32     GetNetworkTypeInUse         ( OS_802_11_NETWORK_TYPE* puNetType  )                          = 0;
+           
+    virtual tiINT32     GetNumberOfAntennas         ( tiUINT32* puNumberOfAntennas    )                             = 0;
+    virtual tiINT32     SetAntennaDiversityParams   ( PTIWLAN_ANT_DIVERSITY pAntennaDiversityOptions )              = 0;
+
+    virtual tiINT32     EnableDisable_802_11d       ( tiUINT8  enableDisable_802_11d )                              = 0;
+    virtual tiINT32     EnableDisable_802_11h       ( tiUINT8  enableDisable_802_11h )                              = 0;
+    virtual tiINT32     Get_802_11d                 ( tiUINT8*  enableDisable_802_11d )                             = 0;
+    virtual tiINT32     Get_802_11h                 ( tiUINT8*  enableDisable_802_11h )                             = 0;
+    virtual tiINT32     Set_countryIeFor2_4_Ghz     ( country_t countryIe)                                          = 0;
+    virtual tiINT32     Get_countryIeFor2_4_Ghz     ( tiUINT8 **countryString)                                       = 0;
+    virtual tiINT32     Set_countryIeFor5_Ghz        ( country_t countryIe)                                          = 0;
+    virtual tiINT32     Get_countryIeFor5_Ghz       ( tiUINT8 **countryString)                                       = 0;
+    virtual tiINT32     Set_minMaxDfsChannels       (DFS_ChannelRange_t DFS_ChannelRange)                           = 0;
+    virtual tiINT32     Get_minMaxDfsChannels       (DFS_ChannelRange_t *DFS_ChannelRange)                          = 0;
+
+
+    virtual tiINT32     Start                       ()                                                              = 0;
+    virtual tiINT32     Stop                        ()                                                              = 0;
+    virtual tiINT32     Suspend                     ()                                                              = 0;
+    virtual tiINT32     StartSM                     ()                                                              = 0;
+    virtual tiINT32     StopSM                      ()                                                              = 0;
+    
+    virtual tiINT32     GetRSSI                     ( tiINT32* pRssi )                                                                 = 0;
+       virtual tiINT32     GetSNR                      ( tiUINT32* pSnr )                                                                                              = 0;
+   
+    virtual tiINT32     Disassociate                ( )                                                             = 0;
+    
+    virtual tiINT32     SetAuthenticationMode       ( OS_802_11_AUTHENTICATION_MODE  uAuthenticationMode )          = 0;
+    virtual tiINT32     GetAuthenticationMode       ( OS_802_11_AUTHENTICATION_MODE* puAuthenticationMode)          = 0;
+
+    virtual tiINT32     SetEAPType                  ( OS_802_11_EAP_TYPES  uEAPType )                               = 0;
+    virtual tiINT32     SetEAPTypeDriver            ( OS_802_11_EAP_TYPES  uEAPType )                               = 0;
+    virtual tiINT32     GetEAPType                  ( OS_802_11_EAP_TYPES* puEAPType)                               = 0;
+    virtual tiINT32     SetEncryptionType           ( OS_802_11_ENCRYPTION_TYPES  uEncryptType )                    = 0;
+    virtual tiINT32     GetEncryptionType           ( OS_802_11_ENCRYPTION_TYPES* puEncryptType)                    = 0;
+
+    virtual tiINT32     SetCredentials              ( tiCHAR* pszUserName, tiCHAR* pszPassword )                    = 0;
+
+    virtual tiINT32     SetPSK                      ( tiCHAR* pszPSK )                                              = 0;
+
+    virtual tiINT32     SetKeyType                  ( OS_802_11_KEY_TYPES uKeyType )                                = 0;
+
+ /*   virtual tiINT32     SetCertificateParameters    ( TI_SHA1_HASH* pSha1Hash, tiBOOL bValidateServerCert )         = 0;*/
+    virtual tiINT32     SetCertParamsSHA1           ( TI_SHA1_HASH* pSha1Hash, tiBOOL bValidateServerCert )         = 0;
+    virtual tiINT32     SetCertParamsFileName       ( tiCHAR* pszFileName,     tiBOOL bValidateServerCert )         = 0;
+
+    virtual tiINT32     AddWEPKey                   ( OS_802_11_WEP*        pWEP        )                           = 0;
+    virtual tiINT32     RemoveWEPKey                ( tiUINT32 uKeyIndex )                                          = 0;
+    virtual tiINT32     GetDefaultWepKey            (tiUINT32* puKeyIndex )                                         = 0;
+    
+    virtual tiINT32     AddKey                      ( OS_802_11_KEY*        pKey        )                           = 0;
+    virtual tiINT32     RemoveKey                   ( OS_802_11_REMOVE_KEY* pRemoveKey  )                           = 0;
+    virtual tiINT32     SetMixedMode                ( tiBOOL    bStatus     )                                      = 0;
+    virtual tiINT32     GetMixedMode                ( tiBOOL*    pbStatus     )                                      = 0;
+    virtual tiINT32     SetPMKIDmap                 ( OS_802_11_PMKID*          pPMKIDMap   )                       = 0;
+
+    virtual tiINT32     GetAssociationInfo          ( OS_802_11_ASSOCIATION_INFORMATION** ppInfo )                  = 0;
+
+    virtual tiINT32     RegisterEvent               ( IPC_EVENT_PARAMS* pEventParams)                               = 0;
+    virtual tiINT32     UnRegisterEvent             ( IPC_EVENT_PARAMS* pEventParams)                               = 0;
+
+    virtual tiINT32     GetDriverCapabilities       ( OS_802_11_DRIVER_CAPABILITIES* pDriverCapabilities )          = 0;
+       virtual tiINT32     GetSelectedBSSIDInfo        ( OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)                      = 0;
+    virtual tiINT32        GetPrimaryBSSIDInfo         ( OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)                      = 0;
+
+
+    virtual tiINT32            SetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds) = 0;
+    virtual tiINT32            GetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds) = 0;
+    virtual tiINT32            ToggleTrafficIntensityEvents ( tiUINT32 NewStatus )                                         = 0;
+
+    virtual tiINT32     StartScan                   ( scan_Params_t *pScanParams )                                  = 0;
+    virtual tiINT32     StopScan                    ( )                                                             = 0;
+    virtual tiINT32     SetScanPolicy               ( UINT8* buffer, UINT16 bufferLength )                          = 0;
+    virtual tiINT32     GetScanBssList              ( bssList_t* bssList )                                          = 0;
+
+    virtual tiINT32        PollApPackets               ( )                                                             = 0;
+    virtual tiINT32        PollApPacketsFromAC         ( tiUINT32 AC )                                                 = 0;
+    virtual tiINT32        SetDTagToAcMappingTable     ( acTrfcType_e* pDtagToAcTable )                         = 0;
+    virtual tiINT32        SetVAD                      ( txDataVadTimerParams_t* pVadTimer )                           = 0;
+    virtual tiINT32        GetVAD                      ( txDataVadTimerParams_t* pVadTimer )                           = 0;
+    virtual tiINT32        SetQosParameters            ( OS_802_11_QOS_PARAMS* pQosParams )                            = 0;
+       virtual tiINT32     SetRxTimeOut                ( OS_802_11_QOS_RX_TIMEOUT_PARAMS* pRxTimeOut )                 = 0;
+
+
+       virtual tiINT32         GetAPQosParameters                      ( OS_802_11_AC_QOS_PARAMS* pACQosParams)                                                = 0;
+    virtual    tiINT32         GetAPQosCapabilitesParameters ( OS_802_11_AP_QOS_CAPABILITIES_PARAMS* pAPQosCapabiltiesParams) = 0;
+       virtual tiINT32         AddTspec                                        ( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)                                             = 0;
+       virtual tiINT32         GetTspecParameters                      ( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)                                             = 0;
+       virtual tiINT32         DeleteTspec                                     ( OS_802_11_QOS_DELETE_TSPEC_PARAMS* pDelTspecParams)                   = 0;
+       virtual tiINT32         GetCurrentACStatus              ( OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams)             = 0;
+       virtual tiINT32         SetMediumUsageThreshold         ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)              = 0;
+       virtual tiINT32         SetPhyRateThreshold                     ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)              = 0;
+       virtual tiINT32         GetMediumUsageThreshold         ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)              = 0;
+       virtual tiINT32         GetPhyRateThreshold                     ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)              = 0;
+       virtual tiINT32         GetDesiredPsMode                        ( OS_802_11_QOS_DESIRED_PS_MODE* pDesiredPsMode)                                = 0;
+
+    virtual tiINT32     GetUserPriorityOfStream     ( STREAM_TRAFFIC_PROPERTIES* streamProperties)                  = 0;
+
+    virtual tiINT32     ConfigTxClassifier          ( tiUINT32 inParamsBuffLen, tiUINT8  *pInParamsBuff)            = 0;
+    virtual tiINT32        RemoveClassifierEntry       ( clsfr_tableEntry_t *pClsfrEntry )                             = 0;
+    virtual tiINT32     GetClsfrType                ( clsfrTypeAndSupport *currClsfrType )                          = 0;
+    virtual tiINT32     Set4XState                   ( tiBOOL    bStatus     )                                      = 0;
+    virtual tiINT32     Get4XState                   ( tiBOOL*   lpbStatus   )                                      = 0;
+    virtual tiINT32     SetRSSITrigger               ( tiBOOL    bRSSItr     )                                      = 0;    
+    virtual tiINT32     GetRSSITrigger               ( tiBOOL*   lpbRSSItr   )                                      = 0;
+    
+    virtual tiINT32     SetWEPStatus                 ( tiUINT32  dwWEPStatus     )                                  = 0;
+    virtual tiINT32     GetWEPStatus                 ( tiUINT32* lpdwWEPStatus   )                                  = 0;
+
+    virtual tiINT32     SetConfiguration             ( OS_802_11_CONFIGURATION*  pConfiguration )                   = 0;
+    virtual tiINT32     GetConfiguration             ( OS_802_11_CONFIGURATION*  pConfiguration )                   = 0;    
+
+    virtual tiINT32     SetPrivacyFilter             ( tiUINT32  dwPrivacyFilter )                                  = 0;
+    virtual tiINT32     GetPrivacyFilter             ( tiUINT32* pdwPrivacyFilter)                                  = 0;
+
+    virtual tiINT32     SetExtRatesIE                ( tiUINT32  dwExtRatesIE    )                                  = 0;
+    virtual tiINT32     GetExtRatesIE                ( tiUINT32* pdwExtRatesIE   )                                  = 0;
+
+    virtual tiINT32     SetEarlyWakeupMode                ( tiUINT8  uEarlyWakeup   )                                  = 0;
+    virtual tiINT32     GetEarlyWakeupMode                ( tiUINT8* uEarlyWakeup   )                                  = 0;
+
+    virtual tiINT32     IsDriverRun                 (tiBOOL* pbStatus )                                             = 0;
+
+    virtual tiINT32     GWSICommand                                     (tiUINT32* pGWSICommand )                                      = 0;
+    virtual tiINT32     GWSIInitialize                          (tiUINT32* pGWSICommand )                                      = 0;
+    virtual tiINT32     GWSIConfig                                      (tiUINT32* pGWSICommand )                                      = 0;
+    virtual tiINT32     GWSIRelease                                     (tiUINT32* pGWSICommand )                                      = 0;
+       virtual tiINT32     GWSIGetInitTable                     (tiUINT32* pGWSICommand )                                                                              = 0;
+
+    virtual tiINT32     hwReadRegister               ( tiUINT32 dwRegisterAddr, tiUINT32* pdwValue )                = 0;
+    virtual tiINT32     hwWriteRegister              ( tiUINT32 dwRegisterAddr, tiUINT32  dwValue  )                = 0;
+
+    virtual tiINT32     ReloadDefaults              ( )                                                             = 0;
+    virtual tiINT32     IsDriverLoaded              ( )                                                             = 0;
+
+       virtual tiINT32     SetBtCoeEnable              ( tiUINT32 uModeEnable )                                                                                        = 0;
+       virtual tiINT32     SetBtCoeRate                                ( tiUINT8 *pRate )                                                                                              = 0;
+       virtual tiINT32     SetBtCoeConfig                              ( tiUINT32 *pConfig )                                                                                   = 0;
+       virtual tiINT32     SetBtCoeGetStatus                   ( tiUINT32 *pStatus )                                                                                   = 0;
+
+#ifdef TI_DBG    
+    virtual tiINT32     GetDebugBuffer              ( tiUINT8* pBuffer, tiUINT32  dwLenght  )                       = 0;
+   
+    virtual tiINT32     SetReportModule             ( tiUINT8* pData )                                             = 0;
+    virtual tiINT32     GetReportModule             ( tiUINT8* pData )                                             = 0;    
+
+    virtual tiINT32     SetReportSeverity           ( tiUINT8* pData )                                             = 0;
+    virtual tiINT32     GetReportSeverity           ( tiUINT8* pData )                                             = 0;    
+
+    virtual tiINT32     SetOsDbgState               ( tiUINT32  uData )                                             = 0;
+    virtual tiINT32     GetOsDbgState               ( tiUINT32* puData )                                             = 0;    
+
+    virtual tiINT32     SetReportPPMode             ( tiUINT32  uData )                                             = 0;
+
+    virtual tiINT32     DisplayStats                ( tiUINT8*  puDbgBuffer,    tiUINT32 uBuffSize)                 = 0;
+
+#ifdef DRIVER_PROFILING
+    virtual tiINT32     ProfileReport               ()                                                              = 0;
+    virtual tiINT32     CpuEstimatorCommand         (tiUINT8 uType, tiUINT32 uData)                                 = 0;
+#endif
+
+#endif /*TI_DBG*/
+    virtual tiINT32     SetWPAOptions               ( tiUINT32      fWPA_options)                                                       = 0;
+    virtual tiINT32     GetWPAOptions               ( tiUINT32 * fWPA_options)                                      = 0;
+
+    virtual tiINT32     GetRegDomainTable           ( TIWLN_REGDOMAINS*     pRegDomainTable )                       = 0;
+    virtual tiINT32     GetMediumUsage              ( TIWLN_MEDIUM_USAGE*   pMediumUsage    )                       = 0;
+    
+    virtual tiINT32     SetPowerMode                ( OS_802_11_POWER_PROFILE  uPower   )                           = 0;
+    virtual tiINT32     GetPowerMode                ( OS_802_11_POWER_PROFILE* puPower  )                           = 0;
+
+       virtual tiINT32 SetPowerLevelPS( OS_802_11_POWER_LEVELS   uPower) = 0;
+       virtual tiINT32 GetPowerLevelPS( OS_802_11_POWER_LEVELS* puPower) = 0;  
+
+       virtual tiINT32 SetPowerLevelDefault( OS_802_11_POWER_LEVELS   uPower) = 0;
+       virtual tiINT32 GetPowerLevelDefault( OS_802_11_POWER_LEVELS* puPower) = 0;     
+       
+       virtual tiINT32 SetPowerLevelDozeMode( OS_802_11_POWER_PROFILE   uPower) = 0;
+       virtual tiINT32 GetPowerLevelDozeMode( OS_802_11_POWER_PROFILE* puPower) = 0;   
+
+    
+       virtual tiINT32 SetBeaconFilterDesiredState( OS_802_11_BEACON_FILTER_MODE   uBeaconFilterMode) = 0;
+       virtual tiINT32 GetBeaconFilterDesiredState( tiUINT8*  pBeaconFilterMode) = 0;
+
+
+    virtual tiINT32     Open_EAPOL_Interface        ( )                                                             = 0;
+    virtual tiINT32     Close_EAPOL_Interface       ( )                                                             = 0;
+    virtual tiINT32     Send_EAPOL_Packet           ( tiVOID* pData, tiUINT32 uSize )                               = 0;
+
+       virtual tiINT32     Set_RoamingConfParams       ( UINT8* buffer, UINT16 bufferLength)                                               = 0;
+       virtual tiINT32     Get_RoamingConfParams       ( UINT8* buffer, UINT16 bufferLength )                                              = 0;
+    
+    virtual tiINT32     GetPowerConsumptionStatistics( PowerConsumptionTimeStat_t * pStatistics)                    = 0;
+    
+       /*PLT*/
+       virtual tiINT32         PLT_ReadRegister                        ( UINT32 uRegisterAddr, UINT32* uRegisterData )                                 = 0;
+       virtual tiINT32         PLT_WriteRegister                       ( UINT32 uRegisterAddr, UINT32 uRegisterData )                                  = 0;
+       virtual tiINT32         PLT_RxPerStart                          ()                                                                                                                              = 0;
+       virtual tiINT32         PLT_RxPerStop                           ()                                                                                                                              = 0;
+       virtual tiINT32         PLT_RxPerClear                          ()                                                                                                                              = 0;
+       virtual tiINT32         PLT_RxPerGetResults                     ( PltRxPer_t* pPltRxPer )                                                                               = 0;
+       virtual tiINT32         PLT_TxCW                                        ( TestCmdChannelBand_t* pPltTxCW)                                     = 0;
+       virtual tiINT32         PLT_TxContiues                          ( PltTxContinues_t* pPltTxContinues)                            = 0;
+       virtual tiINT32         PLT_TxStop                              ()                                                                                                                              = 0;
+       virtual tiINT32         PLT_ReadMIB                                     ( PLT_MIB_t* pMib )                                                             = 0;
+       virtual tiINT32         PLT_WriteMIB                            ( PLT_MIB_t* pMib )                                                             = 0;
+       virtual tiINT32         PLT_TxCalGainGet                    (PltGainGet_t* pPLTGainGet)                                     = 0;
+       virtual tiINT32         PLT_TxCalGainAdjust             (tiINT32   uTxGainChange)                                       = 0;
+       virtual tiINT32         PLT_TxCalStart              (PltTxCalibrationRequest_t* pPLTTxCal)                          = 0;
+    virtual tiINT32            PLT_TxCalStop               ()                                                              = 0;
+       virtual tiINT32         PLT_RxTxCalNVSUpdateBuffer      (PltNvsResultsBuffer_t* pPLT_NVSUpdateBuffer)                   = 0;
+       virtual tiINT32         PLT_RxCal                   (PltRxCalibrationRequest_t* pPltRxCalibration_t)                = 0; 
+    virtual tiINT32     PLT_RadioTune               (TestCmdChannelBand_t* pChannelBand)                                   = 0;
+
+    #ifdef _WINDOWS
+       #endif
+    
+
+    EXC_MODULE_SUPPORT_AH
+};     /* TI_WLAN_AdapterAPI*/
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+    TI_WLAN_AdapterAPI* TI_AdapterCppInit           ( tiCHAR* pszDeviceName , tiBOOL bForce ); 
+     tiINT32             TI_AdapterCppDeinit         ( TI_WLAN_AdapterAPI*  pAdapter, tiBOOL bForce);
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /*_TIWLAN_INTERFACE_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterDBG.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterDBG.h
new file mode 100644 (file)
index 0000000..a6ddc22
--- /dev/null
@@ -0,0 +1,185 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterDBG.h*/
+/**/
+/* Purpose:            */
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef TI_ADAPTER_DBG_H
+#define TI_ADAPTER_DBG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+/******************************************************************************
+
+    Name:   TI_DisplayStats    
+    Desc:      This function calls the driver internal debug function with the 
+            supplied information.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puDbgBuffer - A buffer holding debug parameter. The first 4-byte 
+                          word is the debug function to call, and the second 
+                          word is an optional parameter, whose value depends 
+                          on the debug function
+            uBuffSize - The size of the buffer.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_DisplayStats                 (TI_HANDLE  hAdapter, 
+                                             tiUINT8*  puDbgBuffer,    
+                                             tiUINT32  uBuffSize  );
+
+    /************** logging control in linux *****************************************/
+/******************************************************************************
+
+    Name:   TI_SetReportModule 
+    Desc:      This function sets the modules which reporting is performed.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pData - A pointer to the bitmask defining the modules for which report 
+                    information will be printed (see TIWlanModuleLogName_e)
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetReportModule              (TI_HANDLE  hAdapter, 
+                                             tiUINT8 *pData);
+
+/******************************************************************************
+
+    Name:   TI_GetReportModule 
+    Desc:      This function retrieves the modules which reporting is performed.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pData - A pointer to the bitmask defining the modules for which report 
+                    information will be printed (see TIWlanModuleLogName_e)
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetReportModule              (TI_HANDLE  hAdapter, 
+                                             tiUINT8 *pData);
+
+/******************************************************************************
+
+    Name:   TI_SetReportSeverity       
+    Desc:      This function sets the severities for which report information will
+            be available. To request the information for a severity level to be
+            available, include "1 << desired severity value" in the bitmask.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pData - A pointer to a 1-byte bitmask of the severities:
+                     WLAN_SEVERITY_INIT         1
+                     WLAN_SEVERITY_INFORMATION  2
+                     WLAN_SEVERITY_WARNING      3
+                     WLAN_SEVERITY_ERROR        4
+                     WLAN_SEVERITY_FATAL_ERROR  5
+                     WLAN_SEVERITY_SM           6
+                     WLAN_SEVERITY_CONSOLE      7
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetReportSeverity            (TI_HANDLE  hAdapter, 
+                                             tiUINT8* pData);
+
+/******************************************************************************
+
+    Name:   TI_GetReportSeverity       
+    Desc:      This function retrieves the report severities bit mask.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pData - A pointer to a 1-byte word in which severity bitmask will
+            be written.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetReportSeverity            (TI_HANDLE  hAdapter, 
+                                             tiUINT8* pData);
+
+
+/******************************************************************************
+
+    Name:   TI_SetOsDbgState   
+    Desc:      Set OS adaptation layer debug state
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uData - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetOsDbgState                           (TI_HANDLE  hAdapter, 
+                                             tiUINT32 uData);
+
+/******************************************************************************
+
+    Name:   TI_GetOsDbgState   
+    Desc:      Get OS adaptation layer debug state
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uData - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetOsDbgState                           (TI_HANDLE  hAdapter, 
+                                             tiUINT32* puData);
+
+
+/******************************************************************************
+
+    Name:   TI_SetReportPPMode 
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uData - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetReportPPMode                         (TI_HANDLE  hAdapter, 
+                                             tiUINT32 uData);
+
+/******************************************************************************
+
+    Name:   TI_hwWriteRegister 
+    Desc:      This debug command writes a value to a register.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uRegisterAddr - 
+            dwValue - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_hwWriteRegister              (TI_HANDLE  hAdapter, 
+                                             tiUINT32 uRegisterAddr, 
+                                             tiUINT32 dwValue );
+
+/******************************************************************************
+
+    Name:   TI_hwReadRegister  
+    Desc:      This debug command reads a value of a register.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uRegisterAddr - 
+            puValue - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_hwReadRegister               (TI_HANDLE  hAdapter, 
+                                             tiUINT32 uRegisterAddr, 
+                                             tiUINT32* puValue );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TI_ADAPTER_DBG_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterGWSI.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterGWSI.h
new file mode 100644 (file)
index 0000000..55ec2b9
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterGWSI.h*/
+/**/
+/* Purpose:            */
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef TI_ADAPTER_GWSI_H
+#define TI_ADAPTER_GWSI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+/******************************************************************************
+
+    Name:   TI_GWSICommand     
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pGWSICommand - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GWSICommand                  (TI_HANDLE  hAdapter, 
+                                             tiUINT32* pGWSICommand );
+
+/******************************************************************************
+
+    Name:   TI_GWSIInitialize  
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pGWSICommand - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GWSIInitialize               (TI_HANDLE  hAdapter, 
+                                             tiUINT32* pGWSICommand );
+
+/******************************************************************************
+
+    Name:   TI_GWSIConfig      
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pGWSICommand - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GWSIConfig                   (TI_HANDLE  hAdapter, 
+                                             tiUINT32* pGWSICommand );
+
+/******************************************************************************
+
+    Name:   TI_GWSIGetInitTable        
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pGWSICommand - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GWSIGetInitTable             (TI_HANDLE  hAdapter, 
+                                             tiUINT32* pGWSICommand );
+
+/******************************************************************************
+
+    Name:   TI_GWSIRelease     
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pGWSICommand - .
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GWSIRelease                                     (TI_HANDLE  hAdapter, 
+                                             tiUINT32* pGWSICommand );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TI_ADAPTER_GWSI_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterPM.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterPM.h
new file mode 100644 (file)
index 0000000..3cc9519
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterPM.h*/
+/**/
+/* Purpose:            This API is responsible for the power management of the STA */
+/*--------------------------------------------------------------------------*/
+
+#ifndef TI_ADAPTER_PM_H
+#define TI_ADAPTER_PM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/******************************************************************************
+
+    Name:      TI_SetPowerMode
+       Desc:   Set the driver\92s power save profile.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    thePowerMgrProfile - one of: OS_POWER_MODE_AUTO,
+                                 OS_POWER_MODE_ACTIVE,
+                                 OS_POWER_MODE_SHORT_DOZE,
+                                 OS_POWER_MODE_LONG_DOZE
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetPowerMode          (TI_HANDLE  hAdapter, 
+                                      OS_802_11_POWER_PROFILE thePowerMgrProfile);
+
+/******************************************************************************
+
+    Name:      TI_GetPowerMode
+       Desc:   Get the driver\92s power save profile (see Power Management 
+            application notes).
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    thePowerMgrProfile - one of: OS_POWER_MODE_AUTO,
+                                 OS_POWER_MODE_ACTIVE,
+                                 OS_POWER_MODE_SHORT_DOZE,
+                                 OS_POWER_MODE_LONG_DOZE
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetPowerMode          (TI_HANDLE  hAdapter, 
+                                      OS_802_11_POWER_PROFILE* thePowerMgrProfile);
+
+
+/******************************************************************************
+
+    Name:      TI_ConfigPowerManagement
+    Desc:      Set the driver\92s power management mode.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            thePowerMgrProfile - Power management mode:
+                TI_POWER_MODE_ACTIVE: The driver keeps the WiLink\99 4.0 in Active 
+                                      state all the time.
+                TI_POWER_MODE_SHORT_DOZE: The WiLink\99 4.0 wakes up the host on 
+                                      every beacon passes the beacon to the driver 
+                                      and returns to ELP Doze immediately.
+                TI_POWER_MODE_LONG_DOZE: The WiLink\99 4.0 uses advanced algorithms
+                                      to provide advanced system Power Save. The 
+                                      features used in WiLink\99 4.0 are:
+                                      Wake on DTIM 
+                                      Beacon Filtering
+                TI_POWER_MODE_AUTO: Uses the TI algorithm to decide the best power
+                                      profile (TNET_ACTIVE, SHORT_DOZE, LONG_DOZE) 
+                                      to use. The feature used in WiLink\99 4.0 is 
+                                      set to ACTIVE in high Traffic and to return 
+                                      to PS in low Traffic.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_ConfigPowerManagement    (TI_HANDLE  hAdapter, 
+                                         OS_802_11_POWER_PROFILE thePowerMgrProfile );
+
+    
+/******************************************************************************
+
+    Name:      TI_SetPowerLevelPS
+    Desc:      This function sets the driver's power level mode.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPowerLevel - Sets the power level mode to ELP, PD or AWAKE
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetPowerLevelPS          (TI_HANDLE  hAdapter, 
+                                         OS_802_11_POWER_LEVELS uPowerLevel );
+
+/******************************************************************************
+
+    Name:      TI_GetPowerLevelPS
+    Desc:      This function retrieves the driver's power level mode.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uPowerLevel - A pointer to the OS_802_11_POWER_LEVELS enum type 
+                          (ELP, PD or AWAKE)
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetPowerLevelPS          (TI_HANDLE  hAdapter, 
+                                         OS_802_11_POWER_LEVELS* pPowerLevel );
+
+/******************************************************************************
+
+    Name:      TI_SetPowerLevelDefault
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uPowerLevel - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetPowerLevelDefault     (TI_HANDLE  hAdapter, 
+                                         OS_802_11_POWER_LEVELS uPowerLevel );
+
+/******************************************************************************
+
+    Name:      TI_GetPowerLevelDefault
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pPowerLevel - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetPowerLevelDefault     (TI_HANDLE  hAdapter, 
+                                         OS_802_11_POWER_LEVELS* pPowerLevel );
+    
+/******************************************************************************
+
+    Name:      TI_SetPowerMode
+       Desc:   Set the driver\92s doze mode when the power level is in 
+                       Auto mode
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    thePowerMgrProfile - one of: OS_POWER_MODE_SHORT_DOZE,
+                                 OS_POWER_MODE_LONG_DOZE
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetPowerLevelDozeMode  (TI_HANDLE  hAdapter, 
+                                      OS_802_11_POWER_PROFILE thePowerMgrProfile);
+
+/******************************************************************************
+
+    Name:      TI_GetPowerLevelDozeMode
+       Desc:   Get the driver\92s doze mode when the power level is in 
+                       Auto mode
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    thePowerMgrProfile - one of: OS_POWER_MODE_SHORT_DOZE,
+                                 OS_POWER_MODE_LONG_DOZE
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetPowerLevelDozeMode  (TI_HANDLE  hAdapter, 
+                                      OS_802_11_POWER_PROFILE* thePowerMgrProfile);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TI_ADAPTER_PM_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterQOS.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterQOS.h
new file mode 100644 (file)
index 0000000..ec91398
--- /dev/null
@@ -0,0 +1,499 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterQOS.h*/
+/**/
+/* Purpose:            */
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef TI_ADAPTER_QOS_H
+#define TI_ADAPTER_QOS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+#include "tiQosTypes.h"
+
+/******************************************************************************
+
+    Name:      TI_SetQosParameters
+    Desc:      This function commands the driver to set AC (Tx queue) with 
+            specific QOS parameters.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pQosParams - A pointer to the OS_802_11_QOS_PARAMS structure:
+                acID - The number of AC to configure (0-3).
+                MaxLifeTime - Maximum time to keep the frame in the HW (msec).
+                VoiceDeliveryProtocol - The protocol used for voice exchange
+                                        0 = No protocol is used.
+                                        1 = use PS-Poll frames
+                PSDeliveryProtocol - 0 = Legacy
+                                     1 = U-APSD
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32 TI_SetQosParameters       (TI_HANDLE hAdapter, 
+                                   OS_802_11_QOS_PARAMS* pQosParams );
+
+
+/******************************************************************************
+
+    Name:      TI_GetAPQosParameters
+    Desc:      This function retrieves the associated AP\92s QOS parameters.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pACQosParams - A Pointer to the OS_802_11_AP_QOS_PARAMS structure:
+                uAC - Indicates the AC to which the function is addressed 
+                        (range 0-3).
+                uAssocAdmissionCtrlFlag - Indicates if the AC requires admission
+                        before data transmission (0-1).
+                uAIFS - Indicates the required AIFS by the AP for the specified
+                        AC (2-15).
+                uCwMin - Indicates the required CwMin by the AP for the specified
+                        AC (0-15).
+                uCwMax - Indicates the required CwMax by the AP for the specified
+                        AC (0-15).
+                uTXOPLimit - Indicates the required TXOPLimit by the AP for the 
+                        specified AC (in units of 32 microseconds).
+    Return:    TI_RESULT_OK indicates success.
+            TI_RESULT_NOT_CONNECTED indicates that the STA is not connected to 
+                                    any AP.
+            TI_RESULT_NO_QOS_AP indicates that the associated AP does not 
+                                    support QOS.
+            TI_RESULT_NOK indicates invalid parameters. 
+    Note:   This function should be called only after the STA was associated with 
+            an infrastructure AP.
+       
+******************************************************************************/
+tiINT32        TI_GetAPQosParameters     (TI_HANDLE hAdapter, 
+                                   OS_802_11_AC_QOS_PARAMS* pACQosParams);
+
+
+/******************************************************************************
+
+    Name:      TI_GetAPQosCapabilitesParameters
+    Desc:      This function retrieves the associated AP\92s QOS capabilities.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pAPQosCapabiltiesParams - A Pointer to the  
+                OS_802_11_AP_QOS_CAPABILITIES_PARAMS structure:
+                    uQOSFlag - Flag that indicates whether the AP supports 
+                                QOS (0-1)
+                    uAPSDFlag - Flag that indicates whether the AP supports 
+                                U-APSD (0-1)
+    Return:    TI_RESULT_OK indicates success.
+            TI_RESULT_NOT_CONNECTED indicates that the STA is not connected to any AP.
+            TI_RESULT_NOK indicates invalid parameters.
+    Note:   This function should be called only after the STA was associated with 
+            an infrastructure AP.
+            
+******************************************************************************/
+tiINT32        TI_GetAPQosCapabilitesParameters  (TI_HANDLE hAdapter, 
+                                           OS_802_11_AP_QOS_CAPABILITIES_PARAMS* pAPQosCapabiltiesParams);
+
+
+/******************************************************************************
+
+    Name:      TI_PollApPackets
+    Desc:      This function commands the driver to issue a polling frame to 
+            retrieve downlink traffic from the AP. It should be activated by
+            the voice application when there is no uplink traffic during a 
+            voice call. This is used for a non-QoS association (so AC_BE
+            is used).
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32 TI_PollApPackets         (TI_HANDLE hAdapter);
+
+/******************************************************************************
+
+    Name:      TI_PollApPacketsFromAC
+    Desc:      This function commands the driver to issue a polling frame to 
+            retrieve downlink traffic from the AP. It should be activated by 
+            the voice application when there is no uplink traffic during a 
+            voice call. The polling is either PS-Poll (for legacy PS) or 
+            QoS-Null-Data (for UPSD). 
+            Null-Data frame is sent after the PS-Poll to activate the 
+            triggered-scan, which is only triggered by data frames. These
+            packets are transmitted on the VO_AC, for QoS associations.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            AC - The AC to be polled (values may be 0 to 3)
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32        TI_PollApPacketsFromAC   (TI_HANDLE hAdapter, 
+                                  tiUINT32 AC );
+
+/******************************************************************************
+
+    Name:      TI_SetShortRetry
+    Desc:      This function commands the driver to set Best Effort AC with maximum
+            number of transmits retries to perform for short packets.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uShortRetry - Maximum number of transmits retries to perform for 
+                          short packets
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetShortRetry            (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uShortRetry  );
+
+/******************************************************************************
+
+    Name:      TI_GetShortRetry
+    Desc:      This function gets the maximum number of transmits retries to perform 
+            for short packets of the Best Effort AC.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puShortRetry - Maximum number of transmits retries to perform for 
+                           short packets.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetShortRetry            (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puShortRetry );
+
+
+/******************************************************************************
+
+    Name:      TI_SetLongRetry
+    Desc:      This function commands the driver to set Best Effort AC with maximum
+            number of transmits retries to perform for long packets.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uLongRetry - Maximum number of transmits retries to perform for long
+            packets.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetLongRetry             (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uLongRetry );
+
+/******************************************************************************
+
+    Name:      TI_GetLongRetry
+    Desc:      This function gets the maximum number of transmits retries to perform 
+            for long packets of the Best Effort AC.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puLongRetry - Maximum number of transmits retries to perform for long 
+            packets.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetLongRetry             (TI_HANDLE  hAdapter, 
+                                         tiUINT32*  puLongRetry);
+
+/******************************************************************************
+
+    Name:      TI_SetQosRxTimeOut
+    Desc:      
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pRxTimeOut - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32 TI_SetQosRxTimeOut        (TI_HANDLE hAdapter, 
+                                   OS_802_11_QOS_RX_TIMEOUT_PARAMS*  pRxTimeOut);
+
+
+
+/******************************************************************************
+
+    Name:      TI_AddTspec
+    Desc:      This function commands the driver to add TSPEC for the specific 
+            user Priority.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pTspecParams - Pointer to OS_802_11_QOS_TSPEC_PARAMS strcuture:
+            uUserPriority - Indicates the User priority for which TSPEC is 
+                            requested (range 0-7)
+            uNominalMSDUsize - Indicates the Nominal MSDU size in units of 
+                            bytes (16 LSB only).
+            uMeanDataRate - Indicates the average data rate in units of bits 
+                            per sec
+            uMinimumPHYRate - Indicates the desired minimum PHY rate in units 
+                            of bits per sec
+            uSurplusBandwidth - 
+            hAllowance - Indicates the excess allocation of time (and bandwidth)
+                            over and above the stated application rates 
+                            (represented as fix Q13 numberand used 16 LSB only).
+            uUPSDFlag - Indicates if the AC shouls support U-APSD (0-1)
+            uMediumTime - Indicates the amount of time admitted to this UP. 
+                            Used only for Tspec response notification (16 LSB 
+                            only).
+            uReasonCode - Indicates the reason code of AP response (applicable 
+                            only in TSEPC response event, this field is zero 
+                            in ADD_TSPEC request).
+    Return:    TI_RESULT_OK - Success. Any other value indicates an error.
+            TI_RESULT_TRAFIC_ADM_PENDING \96 Driver is still waiting for a response of previous request.
+            TI_RESULT_AC_ALREADY_IN_USE \96 Means that other user priority from the same AC has already been used.
+            TI_RESULT_NOT_CONNECTED -Indicates that the STA is not connected to any AP.
+            TI_RESULT_NO_QOS_AP - indicates that the associated AP does not support QOS.
+            TI_RESULT_ADM_CTRL_DISABLE \96 Indicates that station configured to not support admission control.
+            TI_RESULT_NOK \96 Parameters are not valid.
+    Notes:  1. Only one TSPEC per AC can be used. For example, user can\92
+                request TSPEC for UP 6 and 7 since those two UPs are mapped 
+                to the same AC.
+            2. User can issue Tspec request only after he gets a response of 
+                the previous request.
+       
+******************************************************************************/
+tiINT32        TI_AddTspec               (TI_HANDLE hAdapter, 
+                                   OS_802_11_QOS_TSPEC_PARAMS* pTspecParams);
+
+/******************************************************************************
+
+    Name:      TI_GetTspecParameters
+    Desc:      This function retrieves Tspec parameters for a specific user 
+            Priority.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pTspecParams - Includes TSPEC parameters as indicated in 
+                            TI_AddTspec().
+    Return:    TI_RESULT_OK \96 Driver retrieves the TSPEC parameters.
+            TI_RESULT_NOT_CONNECTED - Indicates that the STA is not connected
+                                      to any AP.
+            TI_RESULT_NO_QOS_AP - indicates that the associated AP does not 
+                                  support QOS.
+            TI_RESULT_TRAFIC_ADM_PENDING \96 Driver is waiting for a TSPEC response.
+            TI_RESULT_NOK \96 Parameters are not valid.
+    Note:   This function should be called only after TSPEC Response event 
+            with valid reason code.    
+******************************************************************************/
+tiINT32        TI_GetTspecParameters     (TI_HANDLE hAdapter, 
+                                   OS_802_11_QOS_TSPEC_PARAMS* pTspecParams);
+
+/******************************************************************************
+
+    Name:      TI_DeleteTspec
+    Desc:      This function commands the driver to remove TSPEC request for the 
+            specific user Priority.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    pDelTspecParams - A Pointer to the  OS_802_11_QOS_DELETE_TSPEC_PARAMS structure:
+            uUserPriority - Indicates the User priority of which TSPEC to delete
+                            (range 0-7)
+            uReasonCode - Indicates the reason code for delete TSPEC request 
+                            (32-39,45).
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32        TI_DeleteTspec            (TI_HANDLE hAdapter, 
+                                   OS_802_11_QOS_DELETE_TSPEC_PARAMS* pDelTspecParams);
+
+/******************************************************************************
+
+    Name:      TI_GetCurrentACStatus
+    Desc:      This function retrieves the status of the AC in terms of U-APSD
+            activation and admission granted.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pAcStatusParams - Pointer to OS_802_11_QOS_AC_UPSD_STATUS_PARAMS:
+                uAC - Indicates the AC to which the function is addressed 
+                        (range 0-3)
+                uCurrentUAPSDStatus - Current UAPSD status.
+                uCurrentAdmissionStatus - TRUE if the selected AC can be used
+                        for traffic transmission, i.e. either admission is not
+                        required by the AP for this AC, or admission is required
+                        and a successful TSPEC took place. In all other cases the
+                        contents of this field should be FALSE.
+    Return:    TI_RESULT_OK - Success.
+            TI_RESULT_NOT_CONNECTED - Indicates that the STA is not connected to
+                        any AP.
+            TI_RESULT_NO_QOS_AP - indicates that the associated AP does not 
+                        support QOS.
+            TI_RESULT_NOK \96 Parameters are not valid.
+       
+******************************************************************************/
+tiINT32        TI_GetCurrentACStatus     (TI_HANDLE hAdapter, 
+                                   OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams);
+
+/******************************************************************************
+
+    Name:      TI_SetMediumUsageThreshold
+    Desc:      This function set the Medium Usage low and high threshold for a 
+            specific AC.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pThresholdCrossParams - OS_802_11_THRESHOLD_CROSS_PARAMS:
+                uAC - Indicates the AC to which the configuration is addressed 
+                        (range 0-3)
+                uHighThreshold - Indicates high threshold in percentage over 
+                        the allowed medium usage (1-100).
+                uLowThreshold - Indicates low threshold in percentage below the
+                        allowed medium usage (1-100).
+    Return:    TI_RESULT_OK \96 Driver set the thresholds.
+            TI_RESULT_NOK \96 Parameters are not valid.
+       
+******************************************************************************/
+tiINT32        TI_SetMediumUsageThreshold (TI_HANDLE hAdapter, 
+                                    OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+
+/******************************************************************************
+
+    Name:      TI_GetMediumUsageThreshold
+    Desc:      This function retrieves the Medium Usage low and high threshold for 
+            a specific AC.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pThresholdCrossParams - Pointer that holds the MediumUsage current 
+                                    thresholds (see TI_SetMediumUsageThreshold).
+    Return:    TI_RESULT_OK \96 Driver retrieved the thresholds.
+            TI_RESULT_NOK \96 Parameters are not valid.
+                                    
+******************************************************************************/
+tiINT32        TI_GetMediumUsageThreshold (TI_HANDLE hAdapter, 
+                                    OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+
+
+/******************************************************************************
+
+    Name:      TI_SetPhyRateThreshold
+    Desc:      This function set the Phy Rate low and high thresholds for a 
+            specific AC.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pThresholdCrossParams - OS_802_11_THRESHOLD_CROSS_PARAMS:
+                uAC - Indicates the AC to which the configuration is addressed
+                        (range 0-3)
+                uHighThreshold - Indicates high Phy Rate threshold in Mbs 
+                        (1,2,5,6,9,11,12,18,24,36,48,54).
+                uLowThreshold - Indicates low Phy Rate threshold in Mbs
+                        (1,2,5,6,9,11,12,18,24,36,48,54)
+    Return:    TI_RESULT_OK \96 Driver set the thresholds.
+            TI_RESULT_NOK \96 Parameters are not valid.
+                        
+******************************************************************************/
+tiINT32        TI_SetPhyRateThreshold (TI_HANDLE hAdapter, 
+                                OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+
+
+/******************************************************************************
+
+    Name:      TI_GetPhyRateThreshold
+    Desc:      This function retrieves the Phy Rate thresholds for a specific AC.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pThresholdCrossParams - Pointer that holds the PhyRate current 
+                                    thresholds.
+    Return:    TI_RESULT_OK \96 Driver retrieved the thresholds.
+            TI_RESULT_NOK \96 Parameters are not valid.
+                                    
+******************************************************************************/
+tiINT32        TI_GetPhyRateThreshold (TI_HANDLE hAdapter, 
+                                OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+
+/******************************************************************************
+
+    Name:      TI_GetDesiredPsMode
+    Desc:      This function retrieves the desired Power Save mode per AC. The PS 
+            mode can be either PS-Poll Legacy or UPSD.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            desiredPsMode - Pointer that holds the desired PS mode.
+    Return:    TI_RESULT_OK \96 Driver retrieved the thresholds.
+            TI_RESULT_NOK \96 Parameters are not valid.
+            
+******************************************************************************/
+tiINT32 TI_GetDesiredPsMode   (TI_HANDLE hAdapter, 
+                               OS_802_11_QOS_DESIRED_PS_MODE *desiredPsMode );
+
+/******************************************************************************
+
+    Name:      TI_ConfigTxClassifier
+    Desc:      This function sends the configuration buffer to the OsSend package.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            inParamsBuffLen - Configuration buffer length.
+            inParamsBuff - Configuration buffer pointer. 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32 TI_ConfigTxClassifier             (TI_HANDLE hAdapter, 
+                                           tiUINT32 inParamsBuffLen,
+                                           tiUINT8  *inParamsBuff);
+
+/******************************************************************************
+
+    Name:      TI_RemoveClassifierEntry
+    Desc:      This function removes a classifier entry.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pClsfrEntry - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32        TI_RemoveClassifierEntry          (TI_HANDLE hAdapter, 
+                                           clsfr_tableEntry_t *pClsfrEntry);
+
+/******************************************************************************
+
+    Name:      TI_GetClsfrType
+    Desc:      This function retrieves the classifier type.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            currClsfrType - pointer to clsfrTypeAndSupport struct:
+                ClsfrType: one of
+                    D_TAG_CLSFR = 0,
+                    DSCP_CLSFR =1,
+                    PORT_CLSFR =2,
+                    IPPORT_CLSFR =3,
+                oldVersionSupport:
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32 TI_GetClsfrType                   (TI_HANDLE hAdapter, 
+                                           clsfrTypeAndSupport *currClsfrType );
+
+/******************************************************************************
+
+    Name:      TI_SetTrafficIntensityThresholds
+    Desc:      This function sets the traffic intensity high and low thresholds.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pTrafficThresholds - A pointer to the 
+                    OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS structure values:
+                        uHighThreshold, uLowThreshold, TestInterval;
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32                TI_SetTrafficIntensityThresholds (TI_HANDLE  hAdapter, 
+                OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds);
+
+/******************************************************************************
+
+    Name:   TI_GetTrafficIntensityThresholds   
+    Desc:      This function retrieves the traffic intensity high and low thresholds.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pTrafficThresholds - A pointer to the 
+                    OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS structure values.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32            TI_GetTrafficIntensityThresholds (TI_HANDLE  hAdapter, 
+                OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds);
+
+/******************************************************************************
+
+    Name:      TI_ToggleTrafficIntensityEvents
+    Desc:      This function toggles between the traffic intensity operation.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            NewStatus - Enable or disable value (TRUE or FALSE)
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32            TI_ToggleTrafficIntensityEvents  (TI_HANDLE  hAdapter, 
+                                              tiUINT32 NewStatus );
+
+tiINT32     TI_SetDTagToAcMappingTable(TI_HANDLE  hAdapter, acTrfcType_e* pDtagToAcTable );
+tiINT32     TI_SetVAD(TI_HANDLE  hAdapter, txDataVadTimerParams_t* pVadTimer );
+tiINT32     TI_GetVAD(TI_HANDLE  hAdapter, txDataVadTimerParams_t* pVadTimer );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TI_ADAPTER_QOS_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterSEC.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterSEC.h
new file mode 100644 (file)
index 0000000..bd55699
--- /dev/null
@@ -0,0 +1,324 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterSEC.h*/
+/**/
+/* Purpose:            */
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef TI_ADAPTER_SEC_H
+#define TI_ADAPTER_SEC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+/******************************************************************************
+
+    Name:      TI_SetAuthenticationMode
+       Desc:   This function sets the system's authentication mode.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    uAuthMode - one of: os802_11AuthModeOpen,
+                        os802_11AuthModeShared,
+                        os802_11AuthModeAutoSwitch,
+                        os802_11AuthModeWPA,
+                        os802_11AuthModeWPAPSK,
+                        os802_11AuthModeWPANone,
+                        os802_11AuthModeWPA2,
+                        os802_11AuthModeWPA2PSK,
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetAuthenticationMode (TI_HANDLE  hAdapter, 
+                                      OS_802_11_AUTHENTICATION_MODE  uAuthMode);
+
+/******************************************************************************
+
+    Name:      TI_GetAuthenticationMode
+       Desc:   This function retrieves the 802.11 authentication mode.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    puAuthMode - one of: os802_11AuthModeOpen,
+                         os802_11AuthModeShared,
+                         os802_11AuthModeAutoSwitch,
+                         os802_11AuthModeWPA,
+                         os802_11AuthModeWPAPSK,
+                         os802_11AuthModeWPANone,
+                         os802_11AuthModeWPA2,
+                         os802_11AuthModeWPA2PSK,
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetAuthenticationMode (TI_HANDLE  hAdapter, 
+                                      OS_802_11_AUTHENTICATION_MODE* puAutMode);
+
+
+/******************************************************************************
+
+    Name:      TI_SetCertificateParameters
+       Desc:   This function is used for WPA or EXC Certificate configuration.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pData - 
+            bValidateServerCert - 
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetCertificateParameters (TI_HANDLE  hAdapter, 
+                                         tiVOID* pData, 
+                                         tiBOOL bValidateServerCert );
+
+/******************************************************************************
+
+    Name:      TI_SetEAPType
+    Desc:      This function sets the current EAP type in the Supplicant.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uEAPType - Contains value of current EAP type from enumeration 
+                       OS_802_11_EAP_TYPES:
+                        OS_EAP_TYPE_NONE = -1,
+                        OS_EAP_TYPE_MD5_CHALLENGE = 4,
+                        OS_EAP_TYPE_GENERIC_TOKEN_CARD = 6,
+                        OS_EAP_TYPE_TLS = 13,
+                        OS_EAP_TYPE_LEAP = 17,
+                        OS_EAP_TYPE_TTLS = 21,
+                        OS_EAP_TYPE_PEAP = 25,
+                        OS_EAP_TYPE_MS_CHAP_V2 = 26,
+                        OS_EAP_TYPE_FAST = 43
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   Under Linux (ASD device): MD5_CHALLENGE, GENERIC_TOKEN_CARD, TTLS,
+                                      PEAP and MS_CHAP_V2 are not supported.
+    
+******************************************************************************/
+tiINT32     TI_SetEAPType               (TI_HANDLE  hAdapter,
+                                         OS_802_11_EAP_TYPES  uEAPType );
+
+/******************************************************************************
+
+    Name:      TI_GetEAPType
+    Desc:      This function retrieves the current EAP type.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puEAPType - Pointer to a OS_802_11_EAP_TYPES value that contains
+                        current EAP type
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetEAPType               (TI_HANDLE  hAdapter, 
+                                         OS_802_11_EAP_TYPES* puEAPType);
+
+/******************************************************************************
+
+    Name:      TI_SetEAPTypeDriver
+    Desc:      This function sets the current EAP type in the driver.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uEAPType - Contains value of current EAP type from enumeration 
+                       OS_802_11_EAP_TYPES.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+    Note:   Under Linux (ASD device): MD5_CHALLENGE, GENERIC_TOKEN_CARD, TTLS,
+                                      PEAP and MS_CHAP_V2 are not supported.
+    
+******************************************************************************/
+tiINT32     TI_SetEAPTypeDriver         (TI_HANDLE  hAdapter, 
+                                         OS_802_11_EAP_TYPES  uEAPType );
+
+
+/******************************************************************************
+
+    Name:      TI_SetEncryptionType
+    Desc:      This function sets the Encryption type. This function sets both 
+            the driver and the supplicant via an IOCTL.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uEncryptType - Contains value of current encrypt type from enumeration 
+                           OS_802_11_ENCRYPTION_TYPES:
+                               OS_ENCRYPTION_TYPE_NONE = 0,
+                               OS_ENCRYPTION_TYPE_WEP,
+                               OS_ENCRYPTION_TYPE_TKIP,
+                               OS_ENCRYPTION_TYPE_AES,
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetEncryptionType        (TI_HANDLE  hAdapter, 
+                                         OS_802_11_ENCRYPTION_TYPES  uEncryptType );
+
+/******************************************************************************
+
+    Name:      TI_GetEncryptionType
+    Desc:      This function retrieves the current encryption type.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puEncryptType - Pointer to a OS_802_11_EAP_TYPES value that contains 
+                            current encrypt type
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetEncryptionType        (TI_HANDLE  hAdapter, 
+                                         OS_802_11_ENCRYPTION_TYPES* puEncryptType);
+
+/******************************************************************************
+
+    Name:      TI_SetCredentials
+    Desc:      This function sets the User Name and Password in the supplicant.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pszUserName - Pointer to a null-terminated string that contains the 
+                          user name.
+            pszPassword - Pointer to a null-terminated string that contains the 
+                          password.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetCredentials           (TI_HANDLE  hAdapter, 
+                                         tiCHAR* pszUserName, 
+                                         tiCHAR* pszPassword );
+
+/******************************************************************************
+
+    Name:      TI_SetPSK
+    Desc:      This function sets the PSK Password Phrase for WPA type encryption
+            in the supplicant.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pszPSK - Pointer to a null-terminated string that contains the PSK
+                     password phrase
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetPSK                   (TI_HANDLE  hAdapter, 
+                                         tiCHAR* pszPSK );
+
+/******************************************************************************
+
+    Name:      TI_SetKeyType
+    Desc:      This function sets the encryption key type, OS_KEY_TYPE_STATIC uses
+            the regular 802.11 WEP, and OS_KEY_TYPE_DYNAMIC uses 802.1x (WPA)
+            encryption.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uKeyType - Define the security key type:
+                        OS_KEY_TYPE_STATIC = 0,
+                        OS_KEY_TYPE_DYNAMIC
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetKeyType               (TI_HANDLE  hAdapter, 
+                                         OS_802_11_KEY_TYPES uKeyType );
+                                            
+
+/******************************************************************************
+
+    Name:      TI_AddWEPKey
+    Desc:      This function enables you to add a new static WEP key and to 
+            indicate whether the key is the default key. The function should
+            be used only in static key mode.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pWEP - A pointer to an OS_802_11_WEP structure:
+                    Length      - specifies the length of the OS_802_11_WEP 
+                                  structure in bytes.
+                    KeyIndex    - specifies which key to add. KeyIndex can be 
+                                  0 to 3. When the most significant bit is set
+                                  to 1, the key is set as the default key.
+                    KeyLength   - specifies the length of the KeyMaterial 
+                                  character array in bytes.
+                    KeyMaterial - specifies an array that identifies the WEP key.
+                                  The length of this array is variable.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_AddWEPKey                (TI_HANDLE  hAdapter, 
+                                         OS_802_11_WEP* pWEP    );
+
+/******************************************************************************
+
+    Name:      TI_RemoveWEPKey
+    Desc:      This function removes a static WEP key.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            uKeyIndex - Contains the index of the key to remove.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_RemoveWEPKey             (TI_HANDLE  hAdapter, 
+                                         tiUINT32   uKeyIndex   );
+/******************************************************************************
+
+    Name:      TI_GetDefaultWepKey
+    Desc:      This function returns the default WEP key as it was previously set by TI_AddWEPKey function.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            puKeyIndex - Pointer to the index of the default WEP key.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32                TI_GetDefaultWepKey        (TI_HANDLE  hAdapter,
+                                        tiUINT32* puKeyIndex );
+/******************************************************************************
+
+    Name:      TI_SetMixedMode
+    Desc:      This function enables the station to connect to an AP with or without
+            WEP. When disabled, only the configured security mode is possible.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            bStatus - FALSE for disable, TRUE for enable.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetMixedMode             (TI_HANDLE  hAdapter, 
+                                         tiBOOL bStatus);
+
+/******************************************************************************
+
+    Name:      TI_GetMixedMode
+    Desc:      This function checks if the station can connect to an AP with or 
+            without WEP.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pbStatus - FALSE indicates Mixed mode is disbaled, TRUE for enable.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetMixedMode             (TI_HANDLE  hAdapter, 
+                                         tiBOOL* pbStatus);
+
+/******************************************************************************
+
+    Name:      TI_SetWpaOptions
+    Desc:      This function sets WPA promotion options. The STA supports promotion
+            of WPA2 authentication and AES encryption. Promotion means that if 
+            the STA is configured to WPA , the STA connects to either WPA or 
+            WPA2 according to the AP\92s max support. This function sets both the 
+            Driver and the Supplicant via an IOCTL.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            fWPAOptions - The required WPA options.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+    Notes:  Supports only the ENABLE_ALL option.
+       
+******************************************************************************/
+tiINT32     TI_SetWpaOptions            (TI_HANDLE  hAdapter, 
+                                         tiUINT32   fWPAOptions );
+
+/******************************************************************************
+
+    Name:      TI_GetWpaOptions
+    Desc:      This function retrieves the WPA promotion options.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            fWPAOptions - Current WPA options
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_GetWpaOptions            (TI_HANDLE  hAdapter, 
+                                         tiUINT32 *fWPAOptions );
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* TI_ADAPTER_SEC_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterSG.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_AdapterSG.h
new file mode 100644 (file)
index 0000000..bdb31cc
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_AdapterSG.h*/
+/**/
+/* Purpose:            This API enables / disables the Bluetooth coexistence support, */
+/*              sets the parameters of the Bluetooth coexistence feature and */
+/*              retrieve its status. These functions are usually unavailable, */
+/*              unless the WiLink\99 4.0 WLAN driver is specifically compiled to */
+/*              support Bluetooth coexistence.*/
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef TI_ADAPTER_SG_H
+#define TI_ADAPTER_SG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+ #include "softGeminiTypes.h"
+    
+
+/******************************************************************************
+
+    Name:   TI_SetBtCoeEnable  
+    Desc:      This function enables and disables the Bluetooth coexistence feature
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    ModeEnable - One of the following values:
+                  SG_ENABLE(0) \96WLAN enabled
+                  SG_DISABLE(1) \96 WLAN disabled
+                  SG_SENSE_NO_ACTIVITY(2) \96WLAN disabled, waiting for a BTH 
+                                           sense interrupt
+                  SG_SENSE_ACTIVE(3) - WLAN enabled, waiting for a BTH sense 
+                                       interrupt.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetBtCoeEnable               (TI_HANDLE  hAdapter, 
+                                             tiUINT32 ModeEnable );
+
+/******************************************************************************
+
+    Name:   TI_SetBtCoeRate    
+    Desc:      This function sets the rate to be used when Bluetooth coexistence 
+            feature is enabled.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pRate - One of the following values:
+                    0 \96 11 Mbps
+                    1 \96 5.5 and 11 Mbps
+                    2 \96 5.5, 11 and 22 Mbps
+                    3 \96 11 and 22 Mbps.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetBtCoeRate                 (TI_HANDLE  hAdapter, 
+                                             tiUINT8 *pRate );
+
+/******************************************************************************
+
+    Name:   TI_SetBtCoeConfig  
+    Desc:      This function configures Bluetooth coexistence parameters.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+    pConfig - Pointer that holds the bluetooth coexistence paramaters, 
+              in the following order (each parameter is 32 bits long):
+              - the length inmsec of the BT period in the TDM
+              - the length in msec of the WLAN period in the TDM
+              - the length in msec of the BT period in the TDM in AFH mode
+              - the length in msec of the BOTH period in the TDM in AFH mode
+              - min time in msec between last BT activity & defining BT as 
+                inactive
+              - min time in msec between last WLAN activity & defining WLAN 
+                as inactive
+              - min time in msec between last WLAN activity & defining WLAN as
+                in RxGuard mode
+              - the maximum length of time the BT HP will be respected
+              - the maximum length of time the WLAN HP will be respected
+              - the length of time when working in SENSE mode that the BT needs
+                to be inactive in order to DISABLE the SG
+              - the length in msec of Bt time between every WLAN RxGuard.
+              - the length in msec left for Wlan in RxGuard state
+              - WLAN HW generated mode during BT period
+              - specifies whether to use the AFH information from the BT
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetBtCoeConfig               (TI_HANDLE  hAdapter, 
+                                             tiUINT32 *pConfig );
+
+/******************************************************************************
+
+    Name:   TI_SetBtCoeGetStatus       
+    Desc:      This function retrieves Bluetooth coexistence feature parameters.
+    Params:    hAdapter - The Adapter handle returned by TI_AdapterInit().
+            pStatus - Pointer that holds the Bluetooth coexistence feature 
+            status. 16 4-byte words should be allocated.
+            The 1st word will hold the enable status (set by TI_SetBtCoeEnable).
+            The 2nd word will hold the rate (set by TI_SetBtCoeRate).
+            Words 3 to 15 will hold all the parameters set by TI_SetBtCoeConfig.
+    Return:    TI_RESULT_OK on success. Any other value indicates an error.
+       
+******************************************************************************/
+tiINT32     TI_SetBtCoeGetStatus            (TI_HANDLE  hAdapter, 
+                                             tiUINT32 *pStatus );
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TI_ADAPTER_SG_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/TI_OAL.h b/sta_dk_4_0_4_32/CUDK/Inc/TI_OAL.h
new file mode 100644 (file)
index 0000000..4e1fdb0
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:      TI_OAL.h*/
+/**/
+/* Purpose:     This file contains a interface for the TI_OAL class.*/
+/**/
+/*////////////////////////////////////////////////////////////////////*/
+
+#if !defined(AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_)
+#define AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif /* _MSC_VER > 1000*/
+
+#include "osTIType.h"
+#include "TI_Results.h"
+
+#ifdef _UNICODE
+    #define tisprintf   swprintf
+    #define tistrncpy   wcsncpy
+#else
+    #define tisprintf   sprintf
+    #define tistrncpy   strncpy
+#endif
+
+
+class  TI_OSWrapCriticalSection
+{               
+    protected:
+                tiVOID*     m_pCS;   
+    public: 
+        static  TI_OSWrapCriticalSection*   CreateObject();
+        static  tiVOID          DeleteObject(TI_OSWrapCriticalSection* pObj);
+        
+                    TI_OSWrapCriticalSection() {}
+        virtual    ~TI_OSWrapCriticalSection() {}
+        virtual tiVOID    Enter               ()  = 0;
+        virtual tiVOID    Leave               ()  = 0;
+};
+
+class  TI_OSCriticalSection
+{
+        TI_OSWrapCriticalSection*               m_pWrapCS;
+     
+    public: 
+                    TI_OSCriticalSection();
+                   ~TI_OSCriticalSection();
+                tiVOID    Enter               ();
+                tiVOID    Leave               ();
+};
+/*
+class  TI_OSWrapEvent
+{               
+    protected:
+                tiVOID*     m_pEvent;   
+    public: 
+        static  TI_OSWrapEvent*   CreateObject();
+        
+                    TI_OSWrapEvent()    {}
+                   ~TI_OSWrapEvent()    {}
+        virtual tiUINT32    Wait    ( tiUINT32 uTime )  = 0;
+        virtual tiVOID      Set     ()  = 0;
+        virtual tiVOID      Reset   ()  = 0;
+};
+
+class  TI_OSEvent
+{
+        TI_OSWrapEvent*               m_pWrapEvent;
+     
+    public: 
+                    TI_OSEvent();
+                   ~TI_OSEvent();
+             tiUINT32    Wait    ( tiUINT32 uTime );
+             tiVOID      Set     ();
+             tiVOID      Reset   ();
+};
+*/
+typedef tiUINT32 (* tiPTHREAD_START_ROUTINE)( tiVOID* pThreadParameter );
+
+class  TI_OAL  
+{
+    protected:
+        
+                                TI_OAL            ();
+        virtual                ~TI_OAL            ();
+
+        static  TI_OAL*       _instance;
+        static  tiUINT32        m_uReferenceCount; 
+        
+    public:
+        static  TI_OAL*     GetInstance             (); /* static function for create TI_OSlib object*/
+        static  tiVOID      FreeInstance            (); /* static function for release TI_OAL object*/
+
+        /* list of functions that will call from Utility Adapter and Utility GUI modules */
+        virtual tiVOID      TIOutputDebugString     (tiCHAR* lpOutputString)                                        = 0;
+        virtual tiBOOL      TIIsBadWritePtr         (tiVOID* lp, tiUINT32 ucb )                                     = 0;
+
+        /* list of functions that will call from Windows Utility module */
+        virtual tiUINT32    TILoadLibrary           (tiCHAR*    pLibFileName)                                       = 0;
+        virtual tiBOOL      TIFreeLibrary           (tiUINT32   hLibModule)                                         = 0;
+        virtual tiUINT32    TIGetProcAddress        (tiUINT32   hModule, tiCHAR* lpProcName )                       = 0;
+        virtual tiUINT32    TIRegisterWindowMessage (tiCHAR*    pszMsgName )                                        = 0;
+        virtual tiBOOL      TIPostMessage           (tiUINT32 hWnd, tiUINT32 Msg, tiUINT32 wParam, tiUINT32 lParam) = 0;
+        virtual tiVOID      TIPrintLastError        (tiCHAR*    psz)                                                = 0;
+        virtual tiUINT32    TIGetCurrentThreadId    ()                                                              = 0;
+        virtual tiUINT32    TICreateThread          (tiPTHREAD_START_ROUTINE pStartAddress, tiVOID* pParameter )    = 0;
+        virtual tiVOID      TISleep                 (tiUINT32 msec)                                                = 0;
+};
+
+#define TIOALib_OBJECT_CREATOR_IMP( ClassApi, ClassBase )   \
+ClassBase* ClassBase::CreateObject(){ return (ClassBase*) new ClassApi;} \
+tiVOID  ClassBase::DeleteObject(ClassBase* pObj){ClassApi* pRealObj = (ClassApi*)pObj; \
+if(pRealObj)delete pRealObj; }
+
+
+#define TIOALib_SINGLETON_CLASS_IMP( ClassApi )             \
+TI_OAL* TI_OAL::GetInstance()                               \
+{ return (TI_OAL*) ClassApi::GetInstance(); }               \
+TI_OAL* ClassApi::GetInstance()                             \
+{if( _instance == 0){_instance = new ClassApi();}           \
+m_uReferenceCount++; return _instance;}                     \
+tiVOID TI_OAL::FreeInstance()                               \
+{ ClassApi::FreeInstance(); }                               \
+tiVOID ClassApi::FreeInstance()                             \
+{ m_uReferenceCount--;if(!m_uReferenceCount && _instance )  \
+{delete (ClassApi*)_instance;_instance = NULL;}}                                                   
+    
+#endif /* !defined(AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_)*/
+
diff --git a/sta_dk_4_0_4_32/CUDK/Inc/softGeminiTypes.h b/sta_dk_4_0_4_32/CUDK/Inc/softGeminiTypes.h
new file mode 100644 (file)
index 0000000..3e8eebc
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             SOFT_GEMINI_TYPES.H*/
+/**/
+/* Purpose:            This module contains All the system definisions.*/
+/**/
+/*--------------------------------------------------------------------------*/
+#ifndef __SOFT_GEMINI_TYPES_H__
+#define __SOFT_GEMINI_TYPES_H__
+
+
+#pragma pack(1)
+typedef struct
+{
+       BOOL    state;
+       UINT8   minTxRate;
+} btCoexStatus_t;
+#pragma pack()
+
+
+#endif /* __SOFT_GEMINI_TYPES_H__  */
diff --git a/sta_dk_4_0_4_32/CUDK/OAL/Common/CommonOAL.h b/sta_dk_4_0_4_32/CUDK/OAL/Common/CommonOAL.h
new file mode 100644 (file)
index 0000000..7675a8b
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef COMMON_OAL_H
+#define COMMON_OAL_H
+
+#ifdef _WINDOWS
+#endif
+#include <stdio.h>
+#include "TI_Results.h"
+#include "TI_OAL.h"
+
+#endif /* COMMON_OAL_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/OAL/Common/TI_OAL.cpp b/sta_dk_4_0_4_32/CUDK/OAL/Common/TI_OAL.cpp
new file mode 100644 (file)
index 0000000..377688f
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+// TIOsLib.cpp : Defines the entry point for the DLL application.
+//
+#include "CommonOAL.h"
+
+#ifdef _WINDOWS
+#endif //_WINDOWS
+
+
+//////////////////////////////////////////////////////////////////////
+// TI_OAL Class
+//////////////////////////////////////////////////////////////////////
+TI_OAL*  TI_OAL::_instance        = NULL;
+tiUINT32   TI_OAL::m_uReferenceCount= 0;
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+TI_OAL::TI_OAL()
+{
+}
+
+TI_OAL::~TI_OAL()
+{
+}
+
+TI_OSCriticalSection::TI_OSCriticalSection()
+{
+    m_pWrapCS = TI_OSWrapCriticalSection::CreateObject();
+}
+
+TI_OSCriticalSection::~TI_OSCriticalSection()
+{
+    if ( m_pWrapCS )
+    {
+       TI_OSWrapCriticalSection::DeleteObject(m_pWrapCS);
+        m_pWrapCS = NULL;
+    }
+}
+
+tiVOID    
+TI_OSCriticalSection::Enter()
+{
+    if ( m_pWrapCS )
+        m_pWrapCS->Enter();
+}
+
+tiVOID
+TI_OSCriticalSection::Leave()
+{
+    if ( m_pWrapCS )
+        m_pWrapCS->Leave();
+}
+
+
+/*******************************************************************************************/
+/*******************************************************************************************/
+/*******************************************************************************************/
+/*
+TI_OSEvent::TI_OSEvent()
+{
+    m_pWrapEvent = TI_OSWrapEvent::CreateObject();
+}
+
+TI_OSEvent::~TI_OSEvent()
+{
+    if ( m_pWrapEvent )
+        delete m_pWrapEvent;
+}
+
+tiVOID    
+TI_OSEvent::Set()
+{
+    if ( m_pWrapEvent )
+        m_pWrapEvent->Set();
+}
+
+tiVOID    
+TI_OSEvent::Reset()
+{
+    if ( m_pWrapEvent )
+        m_pWrapEvent->Reset();
+}
+
+tiUINT32
+TI_OSEvent::Wait(tiUINT32 uTime)
+{
+    if ( !m_pWrapEvent )
+        return TI_RESULT_FAILED;
+        
+    return m_pWrapEvent->Wait(uTime);
+}
+*/
diff --git a/sta_dk_4_0_4_32/CUDK/OAL/Pform/Linux/TILibLinux.cpp b/sta_dk_4_0_4_32/CUDK/OAL/Pform/Linux/TILibLinux.cpp
new file mode 100644 (file)
index 0000000..482f4ad
--- /dev/null
@@ -0,0 +1,299 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+// TILibLinux.cpp :
+//
+#include <stdio.h>
+#include <errno.h>
+#include <time.h>
+
+#include "CommonOAL.h"
+#include "TILibLinux.h"
+#include <pthread.h>
+
+//////////////////////////////////////////////////////////////////////
+// CTI_LibLinux Class
+//////////////////////////////////////////////////////////////////////
+TIOALib_SINGLETON_CLASS_IMP( CTI_LibLinux )
+TIOALib_OBJECT_CREATOR_IMP( CTI_OSCriticalSectionLinux, TI_OSWrapCriticalSection )
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CTI_LibLinux::CTI_LibLinux()
+{
+}
+
+CTI_LibLinux::~CTI_LibLinux()
+{
+}
+
+tiVOID        
+CTI_LibLinux::TIOutputDebugString (tiCHAR* lpOutputString)
+{
+    if ( lpOutputString )
+        fprintf(stderr, lpOutputString);
+}
+
+tiUINT32   
+CTI_LibLinux::TILoadLibrary(tiCHAR* lpLibFileName)
+{
+    return 0;
+}
+tiUINT32
+CTI_LibLinux::TIGetCurrentThreadId()
+{
+    return pthread_self();
+}
+
+tiBOOL        
+CTI_LibLinux::TIFreeLibrary( tiUINT32 hLibModule )
+{
+    return 0;
+}
+
+tiUINT32        
+CTI_LibLinux::TIRegisterWindowMessage (tiCHAR* lpszMsgName)
+{
+    return 0;
+}
+
+tiBOOL        
+CTI_LibLinux::TIPostMessage(tiUINT32 hWnd, tiUINT32 uMsg, tiUINT32 wParam, tiUINT32 lParam)
+{
+    return 0;
+}
+
+tiUINT32 
+CTI_LibLinux::TIGetProcAddress(tiUINT32 hModule, tiCHAR* lpProcName )
+{
+    return 0;
+}
+
+tiBOOL
+CTI_LibLinux::TIIsBadWritePtr(tiVOID *lp, tiUINT32 ucb )
+{
+    return FALSE;   //IsBadWritePtr(lp, ucb );
+}
+
+tiVOID
+CTI_LibLinux::TIPrintLastError(tiCHAR* lpsz)
+{
+#ifdef DEBUG_MESSAGES    
+    tiCHAR szTmp[512];
+    sprintf(szTmp,"%s LastError(0x%Xh)\n", lpsz, errno);
+    TIOutputDebugString(szTmp);
+#endif
+}
+
+
+tiUINT32
+CTI_LibLinux::TICreateThread(tiPTHREAD_START_ROUTINE pStartAddress, tiVOID* pParameter )
+{
+    uxTHREAD_START_ROUTINE  thread_start_address = (uxTHREAD_START_ROUTINE)pStartAddress;
+    pthread_t               supp_thread_id;
+    pthread_attr_t          supp_thread_attrs;
+
+    pthread_attr_init(&supp_thread_attrs);
+
+    int iRet = pthread_create(&supp_thread_id, &supp_thread_attrs, thread_start_address, pParameter);
+
+    pthread_attr_destroy(&supp_thread_attrs);
+
+    if ( iRet == 0)
+        return TI_RESULT_OK;
+
+    return TI_RESULT_FAILED;
+}
+
+
+CTI_OSCriticalSectionLinux::CTI_OSCriticalSectionLinux()
+{
+  /*  m_pCS = (tiVOID*) new pthread_rwlock_t;
+
+    if ( m_pCS )
+    {
+        memset( m_pCS, 0, sizeof(pthread_rwlock_t));
+        pthread_rwlock_init((pthread_rwlock_t*) m_pCS, NULL )
+    }
+    */
+}
+
+CTI_OSCriticalSectionLinux::~CTI_OSCriticalSectionLinux()
+{
+    /*
+    if (m_pCS)
+    {
+        pthread_rwlock_destroy((pthread_rwlock_t*) m_pCS);
+        delete m_pCS;
+        m_pCS = NULL;
+    }
+    */
+}
+
+tiVOID
+CTI_OSCriticalSectionLinux::Enter()
+{
+    /*
+    if ( m_pCS )
+        pthread_rwlock_wrlock((pthread_rwlock_t*) m_pCS);
+    */
+}
+
+tiVOID
+CTI_OSCriticalSectionLinux::Leave()
+{
+    /*
+    if ( m_pCS )
+        pthread_rwlock_unlock((pthread_rwlock_t*) m_pCS);
+    */
+}
+
+tiVOID
+CTI_LibLinux::TISleep(tiUINT32 msec)
+{
+    struct timespec req;
+
+    req.tv_sec = 0;
+    req.tv_nsec = 100000; /* sleep for 100 msec */
+    nanosleep( &req, NULL );
+}
+
+/*
+
+CTI_OSEventLinux::CTI_OSEventLinux()
+{   
+    m_bSet = FALSE;
+
+    pthread_condattr_init(&m_CondAttr); 
+    pthread_cond_init(&m_Cond, &m_CondAttr);
+    
+    pthread_mutexattr_init(&m_MutexAttr);
+    pthread_mutexattr_settype(&m_MutexAttr, PTHREAD_MUTEX_NORMAL);
+
+    m_pEvent = (tiVOID*) new pthread_mutex_t;
+
+    if ( m_pEvent )
+    {
+        memset( m_pEvent, 0, sizeof(pthread_mutex_t));
+        pthread_mutex_init( (pthread_mutex_t*) m_pEvent, &m_MutexAttr);
+    }
+}
+
+CTI_OSEventLinux::~CTI_OSEventLinux()
+{
+    if (m_pEvent)
+    {
+        pthread_mutex_destroy((pthread_mutex_t*) m_pEvent);
+        delete m_pEvent;
+        m_pEvent = NULL;
+    }
+
+    pthread_mutexattr_destroy(&m_attr);
+    pthread_cond_destroy(&m_Cond);
+    pthread_condattr_destroy(&m_CondAttr);  
+}
+
+tiVOID
+CTI_OSEventLinux::Set()
+{
+    if ( m_pEvent )
+        pthread_cond_signal((pthread_mutex_t*) m_pEvent);
+}
+
+tiUINT32
+CTI_OSEventLinux::Wait(tiUINT32 uTimeout)
+{
+    if (m_pEvent)
+    {
+        pthread_mutex_lock((pthread_mutex_t*) m_pEvent);
+
+        if (uTimeout == INFINITE)
+        {
+            while (!m_bSet) // have to wait for the event
+                pthread_cond_wait(&m_Cond, (pthread_mutex_t*) m_pEvent );
+        }
+        else
+        {
+            timespec  timeOut;
+            clock_gettime(CLOCK_REALTIME, &timeOut);
+            
+            // if there are seconds involved
+            if (uTimeout >= 1000)
+            {
+                timeOut.tv_sec += uTimeout / 1000;
+        
+                // get rest
+                int nRemain = nMilliseconds % 1000;
+                if (nRemain != 0)
+                {
+                    timeOut.tv_nsec +=  nRemain * 1000000L;
+            
+                    // wrapped into the next second
+                    if (timeOut.tv_nsec > 1000000000L)
+                    {
+                        timeOut.tv_nsec -= 1000000000L;
+                        timeOut.tv_sec++;
+                    }
+                }
+            }
+            else
+            {
+                timeOut.tv_nsec +=  uTimeout * 1000000L;
+            }
+
+            while (!m_bSet) // have to wait for the event
+            {
+                // the following line releases the mutex and waits until the 
+                // condition is signalled.  when the call returns, we own the
+                // mutex again, unless an exception is thrown, in which case
+                // the mutex is unlocked
+
+                int nResult = pthread_cond_timedwait(&m_Cond, (pthread_mutex_t*) m_pEvent , &timeOut));
+            
+                if ( nResult != 0 ) 
+                {
+                    pthread_mutex_unlock((pthread_mutex_t*) m_pEvent);
+                    // time out, we have the lock
+                    pthread_mutex_lock((pthread_mutex_t*) m_pEvent);
+                          
+                    // return "time out" condition
+                    return;  
+               }
+
+        }
+};
+
+inline _dcfTimeOut::_dcfTimeOut(unsigned int nMilliseconds)
+{
+    int nResult = clock_gettime(CLOCK_REALTIME, &_tsWhen);
+    
+#ifdef _DEBUG
+    DCF_ASSERT(nResult == 0);
+#endif
+    
+    
+}
+    }
+    return TI_RESULT_OK;
+}
+*/
+
diff --git a/sta_dk_4_0_4_32/CUDK/OAL/Pform/Linux/TILibLinux.h b/sta_dk_4_0_4_32/CUDK/OAL/Pform/Linux/TILibLinux.h
new file mode 100644 (file)
index 0000000..68d9c98
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/* TILibLinux.h: interface for the CTI_LibLinux class.*/
+/**/
+/*////////////////////////////////////////////////////////////////////*/
+
+#if !defined(TI_LIB_LINUX_H_)
+#define TI_LIB_LINUX_H_
+
+class CTI_OSCriticalSectionLinux : public TI_OSWrapCriticalSection
+{
+    public: 
+                    CTI_OSCriticalSectionLinux();
+                   ~CTI_OSCriticalSectionLinux();
+        tiVOID      Enter                   ();
+        tiVOID      Leave                   ();
+};
+/*
+class CTI_OSEventLinux : public TI_OSWrapEvent
+{
+        pthread_mutexattr_t m_MutexAttr;
+        pthread_cond_t      m_Cond;
+        pthread_condattr_t  m_CondAttr;
+        tiBOOL              m_bSet;
+    public:
+                    CTI_OSEventLinux();
+                   ~CTI_OSEventLinux();
+    
+        tiUINT32    Wait                (tiUINT32 uTime);
+        tiVOID      Set                 ();
+        tiVOID      Reset               ();
+};
+*/
+typedef tiVOID* (* uxTHREAD_START_ROUTINE)( tiVOID* pThreadParameter );
+
+class CTI_LibLinux: public TI_OAL  
+{
+    public:
+                                CTI_LibLinux    ();
+        virtual                ~CTI_LibLinux    ();
+
+        static  TI_OAL*     GetInstance  ();
+        static  tiVOID      FreeInstance();
+
+                /* list of functions that will call from Utility Adapter and Utility GUI modules */
+                tiVOID      TIOutputDebugString     (tiCHAR* lpOutputString);
+                tiBOOL      TIIsBadWritePtr         (tiVOID* lp, tiUINT32 ucb );
+
+        /* list of functions that will call from Windows Utility module */
+                tiUINT32    TILoadLibrary           (tiCHAR*    pLibFileName);
+                tiBOOL      TIFreeLibrary           (tiUINT32   hLibModule);
+                tiUINT32    TIGetProcAddress        (tiUINT32   hModule, tiCHAR* lpProcName );
+                tiUINT32    TIRegisterWindowMessage (tiCHAR*    pszMsgName );
+                tiBOOL      TIPostMessage           (tiUINT32 hWnd, tiUINT32 Msg, tiUINT32 wParam, tiUINT32 lParam);
+                tiVOID      TIPrintLastError        (tiCHAR*    psz);
+                tiUINT32    TIGetCurrentThreadId();
+                tiUINT32    TICreateThread          (tiPTHREAD_START_ROUTINE pStartAddress, tiVOID* pParameter );
+                tiVOID      TISleep                 (tiUINT32 msec);
+};
+
+#endif /* !defined(TI_LIB_LINUX_H_)*/
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/Android.mk b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/Android.mk
new file mode 100644 (file)
index 0000000..089dfef
--- /dev/null
@@ -0,0 +1,53 @@
+CLI_DEBUG ?= y
+CLI_STATIC_LIB ?= y
+SG ?= n
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE = libWifiApi
+
+ifeq ($(CLI_DEBUG),y)
+  CLI_DEBUGFLAGS = -O0 -g -fno-builtin -DDEBUG -D TI_DBG  # "-O" is needed to expand inlines
+else
+  CLI_DEBUGFLAGS = -O2
+endif
+
+CLI_STA_DK_ROOT = $(LOCAL_PATH)/../..
+CLI_CUDK_ROOT = $(LOCAL_PATH)/..
+
+
+LOCAL_SRC_FILES := \
+       ../OAL/Common/TI_OAL.cpp \
+       ../OAL/Pform/Linux/TILibLinux.cpp \
+       TI_AdapterApi.cpp \
+       TI_Adapter.cpp \
+       CTI_Adapter.cpp \
+       ../IPC/Linux/ipc_event.c \
+       ../IPC/Linux/cu_ipc.c \
+       ../IPC/Linux/ipc_user.c
+
+ifeq ($(SG), y)
+LOCAL_CFLAGS += -D BTH_COEXISTENCE
+endif
+
+INCLUDEDIR = $(CLI_CUDK_ROOT)/Inc \
+       $(CLI_CUDK_ROOT)/OAL/Common \
+       $(CLI_CUDK_ROOT)/UtilityAdapter \
+       $(CLI_STA_DK_ROOT)/common/inc \
+       $(CLI_STA_DK_ROOT)/pform/linux/inc \
+       $(CLI_STA_DK_ROOT)/pform/common/inc \
+       $(CLI_CUDK_ROOT)/IPC/Linux \
+       $(CLI_STA_DK_ROOT)/common/src/hal/FirmwareApi \
+       $(CLI_CUDK_ROOT)/CLI
+
+LOCAL_CFLAGS += -Wall -D__LINUX__ $(CLI_DEBUGFLAGS) -mabi=aapcs-linux -DHOST_COMPILE
+
+LOCAL_C_INCLUDES := $(INCLUDEDIR)
+LOCAL_MODULE_TAGS := tests
+
+ifeq ($(CLI_STATIC_LIB),y)
+include $(BUILD_STATIC_LIBRARY)
+else
+include $(BUILD_SHARED_LIBRARY)
+endif
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/CTI_Adapter.cpp b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/CTI_Adapter.cpp
new file mode 100644 (file)
index 0000000..76d3d3f
--- /dev/null
@@ -0,0 +1,3336 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+//--------------------------------------------------------------------------
+// Module:             CTI_Adapter.cpp
+//
+// Purpose:            implementation of the CTI_WLAN_AdapterAPI class.
+//
+//--------------------------------------------------------------------------
+
+#include <string.h>
+
+#include "CommonAdapter.h"
+#ifdef _WINDOWS
+#endif
+
+#ifndef _WINDOWS
+       #include "g_tester.h"
+#endif  
+
+#include "paramOut.h"
+
+#ifdef _WINDOWS
+#endif
+TI_OSCriticalSection   m_csInitAdapter; 
+
+#define TI_WLAN_API_VER   0x00400002
+
+
+
+_AdapterItem* CTI_WLAN_AdapterAPI::m_pAdaptersList = NULL;
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CTI_WLAN_AdapterAPI::CTI_WLAN_AdapterAPI(tiCHAR* lpszAdapterName)
+{
+#ifdef TI_EMBEDDED_SUPPLICANT
+    m_pSupplicant = NULL;
+#endif /* ifdef TI_EMBEDDED_SUPPLICANT */
+    m_pszAdapterName = NULL;
+    m_pOSLib = TI_OAL::GetInstance();
+    m_pRegistry = new TI_OSRegistry; // temporary solution
+#ifdef _WINDOWS
+#else
+    m_pIPCmod = new TI_IPC(/*lpszAdapterName*/);
+#endif 
+
+#ifdef TI_EMBEDDED_SUPPLICANT
+    m_bSupplicantInUse = FALSE;
+#endif /* ifdef TI_EMBEDDED_SUPPLICANT */
+    
+    if (lpszAdapterName)
+    {
+        tiUINT32 uSize = 0;
+#ifndef  _UNICODE
+        uSize = strlen( lpszAdapterName );
+#else
+        uSize = wcslen( lpszAdapterName );
+#endif
+        tiUINT32 uBuffLength = sizeof(tiCHAR)*(uSize+1);
+        m_pszAdapterName = new tiCHAR[uSize+1];
+        
+        if (!m_pszAdapterName)
+            return ;
+        
+        memset(m_pszAdapterName, 0, uBuffLength);
+        memcpy(m_pszAdapterName, lpszAdapterName, uBuffLength - sizeof(tiCHAR) );
+#ifndef _WINDOWS
+        m_pIPCmod->IPC_DeviceOpen(m_pszAdapterName);
+#endif
+    }
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::StartSM( )
+{
+#ifdef TI_EMBEDDED_SUPPLICANT
+       #ifndef _WINDOWS
+               m_bSupplicantInUse = TRUE;
+               if ( m_pSupplicant == NULL )
+                       m_pSupplicant = new TI_IPC_Supplicant(m_pszAdapterName);
+               else
+                       return TI_RESULT_FAILED;
+       #else
+       #endif
+#endif /* ifdef TI_EMBEDDED_SUPPLICANT */
+    
+    return TI_RESULT_OK;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::StopSM( )
+{
+#ifdef TI_EMBEDDED_SUPPLICANT
+#ifndef _WINDOWS
+    if (m_bSupplicantInUse && m_pSupplicant != NULL )
+    {
+        delete m_pSupplicant;
+        m_pSupplicant = NULL;
+        m_bSupplicantInUse = FALSE;
+    }
+    else
+        return TI_RESULT_FAILED;
+#else
+#endif
+#endif
+    return TI_RESULT_OK;
+}
+/********************************************************************/
+
+CTI_WLAN_AdapterAPI::~CTI_WLAN_AdapterAPI()
+{
+#ifndef _WINDOWS
+    if ( m_pIPCmod )
+    {
+        m_pIPCmod->IPC_DeviceClose();
+        delete m_pIPCmod;
+        m_pIPCmod = NULL;
+    }
+#else    
+#endif
+    if (m_pRegistry)
+    {
+        delete m_pRegistry;
+        m_pRegistry = NULL;
+    }
+    
+    if ( m_pOSLib )
+    {
+        m_pOSLib->FreeInstance();
+        m_pOSLib = NULL;
+    }
+    
+    if ( m_pszAdapterName )
+    {
+        delete [] m_pszAdapterName;
+        m_pszAdapterName = NULL;
+    }
+#ifdef TI_EMBEDDED_SUPPLICANT
+#ifndef _WINDOWS
+    if (m_pSupplicant != NULL )
+    {
+        delete m_pSupplicant;
+        m_pSupplicant = NULL;
+    }
+#endif    
+#endif
+}
+
+/********************************************************************/
+
+CTI_WLAN_AdapterAPI*
+CTI_WLAN_AdapterAPI::GetTIWLANAdapter(tiCHAR* lpszAdapterName, tiBOOL bForce)
+{
+    
+    m_csInitAdapter.Enter();
+    
+    if ( bForce )
+    {
+        CTI_WLAN_AdapterAPI* pAdapter = new CTI_WLAN_AdapterAPI(lpszAdapterName);
+        m_csInitAdapter.Leave();
+        return pAdapter;
+    }
+    
+    _AdapterItem* pCurrentItem = m_pAdaptersList;
+    
+    BOOL  bNULL = FALSE;
+    if (!lpszAdapterName)
+    {
+        bNULL = TRUE;
+        m_csInitAdapter.Leave();
+        return NULL;
+    }
+    
+    while( pCurrentItem )
+    {
+        tiINT32 iResult = -1;
+        
+        if ( !bNULL )
+#ifndef  _UNICODE
+            iResult = strcmp(pCurrentItem->m_pAdapterName, lpszAdapterName );
+#else
+        iResult = wcscmp(pCurrentItem->m_pAdapterName, lpszAdapterName );
+#endif
+        else
+        {
+            if ( !pCurrentItem->m_pAdapterName )
+                iResult = 0;    
+        }   
+        
+        if (!iResult)
+        {
+            pCurrentItem->AddRef();
+            m_csInitAdapter.Leave();
+            return pCurrentItem->m_dwAdapterID;
+        }
+        
+        pCurrentItem = pCurrentItem->m_pNextItem;
+    }
+    
+    pCurrentItem = new _AdapterItem;
+    
+    pCurrentItem->m_pNextItem = m_pAdaptersList;
+    
+    if ( m_pAdaptersList )
+        m_pAdaptersList->m_pPrevItem = pCurrentItem;
+    
+    m_pAdaptersList = pCurrentItem;
+    
+    if (lpszAdapterName)
+    {
+        tiUINT32 uSize = 0;
+#ifndef  _UNICODE
+        uSize = strlen( lpszAdapterName );
+#else
+        uSize = wcslen( lpszAdapterName );
+#endif
+        tiUINT32 uBuffLenght = sizeof(tiCHAR)*(uSize+1);
+        tiCHAR* pBuff = new tiCHAR[uSize+1];
+        
+        if (!pBuff)
+        {
+            m_csInitAdapter.Leave();
+            return NULL;
+        } 
+        
+        memset(pBuff, 0, uBuffLenght);
+        memcpy(pBuff, lpszAdapterName, uBuffLenght - sizeof(tiCHAR) );
+        m_pAdaptersList->m_pAdapterName = pBuff;
+    }
+    
+    pCurrentItem->m_dwAdapterID = new CTI_WLAN_AdapterAPI(lpszAdapterName);
+    
+    m_csInitAdapter.Leave();
+    return m_pAdaptersList->m_dwAdapterID;
+}
+
+/********************************************************************/
+
+tiINT32 
+CTI_WLAN_AdapterAPI::FreeTIWLANAdapter(CTI_WLAN_AdapterAPI* pAdapter, tiBOOL bForce )
+{
+    m_csInitAdapter.Enter();
+    
+#ifndef _WINDOWS
+    if ( bForce && pAdapter)
+    {
+        delete pAdapter;
+        pAdapter = NULL;
+        m_csInitAdapter.Leave();
+        return TI_RESULT_OK;
+    }
+#else   
+#endif
+    if (
+#ifndef _WINDOWS
+               !pAdapter ||
+#endif
+    // TRS:PGK -- If there is no adapter list, exit.  Nothing to free.
+               !m_pAdaptersList)
+    {
+        m_csInitAdapter.Leave();
+        return TI_RESULT_FAILED;
+    }
+    
+    _AdapterItem* pCurrentItem = m_pAdaptersList;
+    while( pCurrentItem )
+    {
+        
+        if (pCurrentItem->m_dwAdapterID == pAdapter )
+        {
+            pCurrentItem->DecRef();
+            if ( !pCurrentItem->m_uRef )
+            {
+                _AdapterItem* pPrev = pCurrentItem->m_pPrevItem;
+                if ( pPrev )
+                    pPrev->m_pNextItem = pCurrentItem->m_pNextItem;
+                
+                _AdapterItem* pNext = pCurrentItem->m_pNextItem;
+                if ( pNext )
+                    pNext->m_pPrevItem = pCurrentItem->m_pPrevItem;
+                
+                if ( !pNext && !pPrev )
+                    m_pAdaptersList = NULL;
+                
+                if ( pCurrentItem->m_pAdapterName )
+                    delete [] pCurrentItem->m_pAdapterName;
+                
+                delete pCurrentItem->m_dwAdapterID;
+                delete pCurrentItem;
+                
+            }
+            
+            m_csInitAdapter.Leave();
+            return TI_RESULT_OK;
+        }
+        
+        pCurrentItem = pCurrentItem->m_pNextItem;
+    }
+    
+    if ( pAdapter )
+        delete pAdapter;
+    
+    m_csInitAdapter.Leave();
+    return TI_RESULT_FAILED;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::CheckObjectMemory(tiVOID *pObj, tiUINT32 uSizeObj)
+{
+    if ( !pObj || !uSizeObj )
+        return FALSE;
+    
+    return !(m_pOSLib->TIIsBadWritePtr(pObj, uSizeObj));
+}
+/***************************************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::tiMiniportSetInformation(tiUINT32 dwInfoCode,tiVOID* lpInfoBuffer, tiUINT32* lpdwCbInfoBuffer)
+{
+    tiUINT32    dwRet       = 0;
+    tiUINT32    dwLength    = *lpdwCbInfoBuffer + sizeof(dwInfoCode);
+    tiUINT8*    lpBuffer    = new tiUINT8[dwLength];
+    tiUINT32 dwRetSize;
+    
+    if ( !lpBuffer )
+        return TI_RESULT_NOT_ENOUGH_MEMORY;
+    
+    memcpy(lpBuffer, &dwInfoCode, sizeof(dwInfoCode));
+    memcpy((tiUINT8*)lpBuffer + sizeof(dwInfoCode), lpInfoBuffer, *lpdwCbInfoBuffer);
+    
+    dwRet = tiIoCtrl(TIWLN_IOCTL_OID_SET_INFORMATION,lpBuffer, dwLength,NULL,0,&dwRetSize);
+    
+    delete [] lpBuffer;
+    return dwRet;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::tiIoCtrl(tiUINT32 dwIoCtrl, tiVOID* pInBuffer, tiUINT32 uInBufferSize,
+                              tiVOID* pOutBuffer, tiUINT32 dwOutBufferSize, tiUINT32* dwBytesReturned)
+{
+       #ifdef TI_EMBEDDED_SUPPLICANT
+               if ( m_bSupplicantInUse )
+               {
+                       #ifdef _WINDOWS
+                       #endif  
+                               switch (dwIoCtrl)
+                               {
+                                       case TIWLN_802_11_SSID_SET:
+                                       case TIWLN_802_11_INFRASTRUCTURE_MODE_SET:
+                                       case TIWLN_802_11_AUTHENTICATION_MODE_SET:
+                                       case TIWLN_802_11_WEP_STATUS_SET:
+                                       case TIWLN_802_11_PSK_SET:
+                                       case TIWLN_802_11_EAP_TYPE_SET:
+                                       case TIWLN_802_11_USER_ID_SET:
+                                       case TIWLN_802_11_USER_PASSWORD_SET:
+                                       case TIWLN_802_11_CERT_PARAMS_SHA1_SET:
+                                       case TIWLN_802_11_CERT_PARAMS_FILE_NAME_SET:
+                                       case TIWLN_802_11_KEY_TYPE_SET:
+                                       case TIWLN_802_11_EXC_NETWORK_EAP_SET:
+                                       case TIWLN_802_11_EXC_CONFIGURATION_SET:
+                                       case TIWLN_802_11_ADD_WEP:
+                                       case TIWLN_802_11_WPA_OPTIONS_SET:
+                                       #ifdef _WINDOWS
+                                       #else
+                                               return m_pSupplicant->SendDataProxy(dwIoCtrl, pInBuffer, uInBufferSize);
+                                       #endif
+                               }
+                               #ifdef _WINDOWS
+                               #endif
+                               }
+       #endif /* ifdef TI_EMBEDDED_SUPPLICANT */
+#ifdef _WINDOWS
+#else   
+    tiUINT32 bRet = m_pIPCmod->IPC_DeviceIoControl( dwIoCtrl, pInBuffer, uInBufferSize,
+        pOutBuffer, dwOutBufferSize, dwBytesReturned); 
+    return bRet;
+#endif
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetStatistics(TIWLN_STATISTICS* ptiStatistics)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(ptiStatistics, sizeof(TIWLN_STATISTICS)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_STATISTICS, NULL, 0, ptiStatistics, sizeof(TIWLN_STATISTICS),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetTxStatistics(TIWLN_TX_STATISTICS* ptiTxStatistics, UINT32 clearStatsFlag)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( ptiTxStatistics )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_TX_STATISTICS, 
+            &clearStatsFlag, sizeof(UINT32), 
+            ptiTxStatistics, sizeof(TIWLN_TX_STATISTICS),&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetBSSIDList(OS_802_11_BSSID_LIST_EX** ppBSSIDlist)
+{
+    tiUINT32    nSize = 0;
+    if ( ppBSSIDlist == NULL)
+        return TI_RESULT_FAILED;
+    
+    tiINT32 bRet = GetVariableLengthOID(TIWLN_802_11_BSSID_LIST, (tiVOID**)ppBSSIDlist, &nSize, 10000);
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetFullBSSIDList(OS_802_11_BSSID_LIST_EX** ppBSSIDlist)
+{
+    tiUINT32    nSize = 0;
+    if ( ppBSSIDlist == NULL)
+        return TI_RESULT_FAILED;
+    
+    tiINT32 bRet = GetVariableLengthOID(TIWLN_802_11_FULL_BSSID_LIST, (tiVOID**)ppBSSIDlist, &nSize, 10000);
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetCurrentAddress( OS_802_11_MAC_ADDRESS*    pCurrentAddr)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pCurrentAddr, sizeof (OS_802_11_MAC_ADDRESS)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_3_CURRENT_ADDRESS, NULL, 0, pCurrentAddr, sizeof( OS_802_11_MAC_ADDRESS ), &dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetDesiredSSID( OS_802_11_SSID*  pDesiredSSID )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pDesiredSSID, sizeof(OS_802_11_SSID)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SSID_GET, NULL, 0, pDesiredSSID, sizeof(OS_802_11_SSID),&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetCurrentSSID( OS_802_11_SSID*  pCurrentSSID )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pCurrentSSID, sizeof(OS_802_11_SSID)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SSID_GET, NULL, 0, pCurrentSSID, sizeof(OS_802_11_SSID),&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32 CTI_WLAN_AdapterAPI::SetSSID( tiUINT8*  pszSSIDname )
+{
+#ifdef _WINDOWS     // TRS:WDK
+#endif
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pszSSIDname && m_pRegistry )
+    {
+        tiUINT32    uSize = 0;
+        
+#ifdef _WINDOWS     
+#else  // __LINUX__
+#ifdef  _UNICODE
+        uSize = wcslen( pszSSIDname );
+#else
+        uSize = strlen((char *)pszSSIDname);  
+#endif
+        tiUINT32 dwNameSize = 0;
+        
+        if ( uSize <= MAX_SSID_LENGTH )
+            dwNameSize = uSize * sizeof(tiUINT8);
+        else
+            dwNameSize = MAX_SSID_LENGTH * sizeof(tiUINT8);
+#endif
+        
+        if (pszSSIDname != NULL)
+        {
+            
+            OS_802_11_SSID ssid;
+            memset( &ssid, 0, sizeof(OS_802_11_SSID) );
+            
+#ifdef _WINDOWS     // TRS:WDK
+#else // __LINUX__
+#ifdef  _UNICODE
+            wcstombs((tiCHAR* )ssid.Ssid, pszSSIDname, MAX_SSID_LENGTH);
+            ssid.SsidLength = MAX_SSID_LENGTH;
+#else
+            memcpy((tiCHAR*)ssid.Ssid, pszSSIDname, dwNameSize );
+            ssid.SsidLength = dwNameSize;
+#endif
+#endif
+            
+            dwRetValue = tiIoCtrl(TIWLN_802_11_SSID_SET, &ssid, sizeof(OS_802_11_SSID),NULL, 0,&dwRetSize);
+#ifdef _WINDOWS
+#endif           
+        }    
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetBSSType( OS_802_11_NETWORK_MODE   uBSSType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    dwRetValue = tiIoCtrl(TIWLN_802_11_INFRASTRUCTURE_MODE_SET, &uBSSType, sizeof(OS_802_11_NETWORK_MODE),NULL, 0,&dwRetSize);
+#ifdef _WINDOWS
+#endif           
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetBSSType( OS_802_11_NETWORK_MODE*  puBSSType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    if (CheckObjectMemory( puBSSType, sizeof(OS_802_11_NETWORK_MODE)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_INFRASTRUCTURE_MODE_GET, NULL, 0, puBSSType, sizeof(OS_802_11_NETWORK_MODE),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetEAPType( OS_802_11_EAP_TYPES  uEAPType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    if (uEAPType)
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_EAP_TYPE_SET, &uEAPType, sizeof(OS_802_11_EAP_TYPES),NULL, 0,&dwRetSize); 
+    } 
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetEAPTypeDriver( OS_802_11_EAP_TYPES  uEAPType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_EAP_TYPE_DRIVER_SET, &uEAPType, sizeof(OS_802_11_EAP_TYPES),NULL,0,&dwRetSize); 
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetEAPType( OS_802_11_EAP_TYPES* puEAPType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_EAP_TYPE_GET, NULL, 0, puEAPType, sizeof(OS_802_11_ENCRYPTION_STATUS),&dwRetSize); 
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetEncryptionType( OS_802_11_ENCRYPTION_TYPES uEncryptType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    OS_802_11_ENCRYPTION_STATUS uEncryptStatus = os802_11WEPDisabled;
+    
+    switch( uEncryptType )
+    {
+    case    OS_ENCRYPTION_TYPE_NONE:
+        uEncryptStatus = os802_11WEPDisabled;
+        break;
+    case    OS_ENCRYPTION_TYPE_WEP:
+        uEncryptStatus = os802_11Encryption1Enabled;
+        break;
+    case    OS_ENCRYPTION_TYPE_TKIP:
+        uEncryptStatus = os802_11Encryption2Enabled;
+        break;
+    case    OS_ENCRYPTION_TYPE_AES:
+        uEncryptStatus = os802_11Encryption3Enabled;
+        break;
+    default:
+        uEncryptStatus = os802_11WEPDisabled;
+    }
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_SET, &uEncryptStatus, sizeof(OS_802_11_ENCRYPTION_STATUS),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetEncryptionType( OS_802_11_ENCRYPTION_TYPES* puEncryptType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
+    tiUINT32 dwRetSize;
+    
+    if ( puEncryptType && CheckObjectMemory( puEncryptType, sizeof(OS_802_11_ENCRYPTION_TYPES)) )
+    {
+        OS_802_11_ENCRYPTION_STATUS uEncryptStatus;
+        dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_GET, NULL, 0, &uEncryptStatus, sizeof(OS_802_11_ENCRYPTION_STATUS),&dwRetSize); 
+        
+        if ( dwRetValue == TI_RESULT_OK )
+        {
+            switch( uEncryptStatus )
+            {
+            case    os802_11WEPDisabled:
+                *puEncryptType = OS_ENCRYPTION_TYPE_NONE;
+                break;
+            case    os802_11Encryption1Enabled:
+                *puEncryptType =  OS_ENCRYPTION_TYPE_WEP;
+                break;
+            case    os802_11Encryption2Enabled:
+                *puEncryptType = OS_ENCRYPTION_TYPE_TKIP;
+                break;
+            case    os802_11Encryption3Enabled:
+                *puEncryptType =  OS_ENCRYPTION_TYPE_AES;
+                break;
+            default:
+                dwRetValue = TI_RESULT_FAILED;
+            } // switch
+        }
+    } // end of memory check
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetCredentials( tiCHAR* pszUserName, tiCHAR* pszPassword )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pszUserName != NULL )
+    {
+        tiUINT32    uSize = 0;
+        
+#ifdef  _UNICODE
+        uSize = wcslen( pszUserName );
+#else
+        uSize = strlen(pszUserName);  
+#endif
+        tiUINT32 dwNameSize = uSize * sizeof(tiCHAR);
+        
+        if ( CheckObjectMemory( pszUserName, dwNameSize ))
+            dwRetValue = tiIoCtrl(TIWLN_802_11_USER_ID_SET, pszUserName, dwNameSize + sizeof(tiCHAR),NULL, 0,&dwRetSize);
+    }
+    else
+        dwRetValue = tiIoCtrl(TIWLN_802_11_USER_ID_SET, NULL, 0l,NULL, 0,&dwRetSize);
+    
+    
+    if ( pszPassword != NULL )
+    {
+        tiUINT32    uSize = 0;
+        
+#ifdef  _UNICODE
+        uSize = wcslen( pszPassword );
+#else
+        uSize = strlen(pszPassword);  
+#endif
+        tiUINT32 dwNameSize = uSize * sizeof(tiCHAR);
+        
+        if ( CheckObjectMemory( pszPassword, dwNameSize ))
+            dwRetValue = tiIoCtrl(TIWLN_802_11_USER_PASSWORD_SET, pszPassword, dwNameSize + sizeof(tiCHAR),NULL, 0,&dwRetSize);
+    }
+    else
+        dwRetValue = tiIoCtrl(TIWLN_802_11_USER_PASSWORD_SET, NULL, 0l,NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetPSK( tiCHAR* pszPSK )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pszPSK != NULL )
+    {
+        tiUINT32    uSize = 0;
+        
+#ifdef  _UNICODE
+        uSize = wcslen( pszPSK );
+#else
+        uSize = strlen(pszPSK);  
+#endif
+        tiUINT32 dwNameSize = uSize * sizeof(tiCHAR);
+        
+        if ( CheckObjectMemory( pszPSK, dwNameSize ))
+            dwRetValue = tiIoCtrl(TIWLN_802_11_PSK_SET, pszPSK, dwNameSize + sizeof(tiCHAR),NULL, 0,&dwRetSize);
+    }
+    else
+        dwRetValue = tiIoCtrl(TIWLN_802_11_PSK_SET, NULL, 0l,NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetCertParamsSHA1( TI_SHA1_HASH* pSha1Hash, tiBOOL bValidateServerCert )
+{
+    tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
+    tiUINT32 dwRetSize;
+    
+    if ( pSha1Hash && CheckObjectMemory(pSha1Hash, sizeof(TI_SHA1_HASH)))
+    {
+        tiUINT32  uSize = sizeof(TI_SHA1_HASH) + sizeof(tiBOOL);
+        tiUINT8*  pByte = new tiUINT8[uSize];
+        if ( pByte == NULL )
+            return TI_RESULT_NOT_ENOUGH_MEMORY;
+        
+        tiUINT8* pBufferTmp = pByte;
+        
+        memset(pByte, 0, uSize);
+        memcpy(pBufferTmp, &bValidateServerCert, sizeof(tiBOOL));
+        pBufferTmp += sizeof(tiBOOL);
+        memcpy(pBufferTmp, pSha1Hash, sizeof(TI_SHA1_HASH));
+        
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CERT_PARAMS_SHA1_SET, pByte, uSize,NULL, 0,&dwRetSize);
+        
+        delete [] pByte;
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetCertParamsFileName( tiCHAR* pszFileName, tiBOOL bValidateServerCert )
+{
+    tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
+    tiUINT32 dwRetSize;
+    
+    if ( pszFileName != NULL )
+    {
+        tiUINT32    uSize = 0;
+        
+#ifdef  _UNICODE
+        uSize = wcslen( pszFileName );
+#else
+        uSize = strlen(pszFileName);  
+#endif
+        tiUINT32 dwSize = (uSize + 1) * sizeof(tiCHAR) + sizeof(tiBOOL);
+        
+        tiUINT8*  pByte = new tiUINT8[dwSize];
+        
+        if ( pByte == NULL )
+            return TI_RESULT_NOT_ENOUGH_MEMORY;
+        
+        tiUINT8* pBufferTmp = pByte;
+        
+        memset(pByte, 0, dwSize);
+        memcpy(pBufferTmp, &bValidateServerCert, sizeof(tiBOOL));
+        pBufferTmp += sizeof(tiBOOL);
+        memcpy(pBufferTmp, pszFileName, uSize);
+        
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CERT_PARAMS_FILE_NAME_SET, pByte, dwSize,NULL, 0,&dwRetSize);
+        
+        delete [] pByte;
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::AddWEPKey( OS_802_11_WEP*    pWEP )
+{
+    tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pWEP, sizeof(OS_802_11_WEP)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_ADD_WEP, pWEP, sizeof(OS_802_11_WEP),NULL, 0,&dwRetSize);
+        
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32                 
+CTI_WLAN_AdapterAPI::RemoveWEPKey( tiUINT32 uKeyIndex )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_REMOVE_WEP, &uKeyIndex, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetWPAOptions( tiUINT32 fWPA_options)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_WPA_OPTIONS_SET, &fWPA_options, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 CTI_WLAN_AdapterAPI::GetWPAOptions( tiUINT32 * fWPA_options)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(fWPA_options, sizeof(tiUINT32)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_WPA_OPTIONS_GET, NULL, 0, fWPA_options, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32                 
+CTI_WLAN_AdapterAPI::SetPMKIDmap(OS_802_11_PMKID*  pPMKIDMap)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pPMKIDMap, pPMKIDMap->Length))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_PMKID_SET, pPMKIDMap, pPMKIDMap->Length,NULL, 0,&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::AddKey( OS_802_11_KEY*   pKey )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pKey, pKey->Length))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_ADD_KEY, pKey, pKey->Length,NULL, 0,&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::RemoveKey( OS_802_11_REMOVE_KEY* pRemoveKey  )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pRemoveKey, sizeof(OS_802_11_REMOVE_KEY)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_REMOVE_KEY, pRemoveKey, sizeof(OS_802_11_REMOVE_KEY),NULL, 0,&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::RegisterEvent( IPC_EVENT_PARAMS* pEventParams )
+{
+#ifdef _WINDOWS     // TRS:WDK
+#else
+    return m_pIPCmod->IPC_RegisterEvent(pEventParams);
+#endif
+}
+/********************************************************************/
+tiINT32                 
+CTI_WLAN_AdapterAPI::UnRegisterEvent( IPC_EVENT_PARAMS* pEventParams/*tiINT32 iRegisterID*/ ) 
+{
+#ifdef _WINDOWS     // TRS:WDK
+#else
+    return m_pIPCmod->IPC_UnRegisterEvent(pEventParams);
+#endif
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::ConfigPowerManagement( OS_802_11_POWER_PROFILE thePowerMgrProfile )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_MGR_PROFILE, &thePowerMgrProfile, sizeof(OS_802_11_POWER_PROFILE),NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetAssociationInfo( OS_802_11_ASSOCIATION_INFORMATION** ppInfo )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    
+    tiUINT32 nSize = 0;
+    
+    if ( ppInfo == NULL)
+        return TI_RESULT_FAILED;
+    
+    dwRetValue = GetVariableLengthOID(TIWLN_802_11_ASSOCIATION_INFORMATION, (tiVOID**)ppInfo, &nSize, 10000);
+    if ( TI_SUCCEEDED (dwRetValue) )
+    {
+        if (nSize == 0 || nSize < sizeof(OS_802_11_ASSOCIATION_INFORMATION) || *ppInfo == NULL )
+            dwRetValue = TI_RESULT_FAILED;
+        
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+///////////////////////////////////////////////////////////////////////
+// Assorted utility functions
+
+// This function queries for a variable length OID. Starting from a
+// suggested size (nNextAllocation), it keeps querying until the size
+// requirement is met. It does this repeatedly rather than once because
+// the size requirement for an OID can vary from one call to the next, and
+// also because some adapters don't report the correct required size value.
+tiINT32
+CTI_WLAN_AdapterAPI::GetVariableLengthOID(tiUINT32 oid, tiVOID** pp, tiUINT32* pnSize, tiUINT32 nNextAllocation)
+{
+    tiVOID*     p = NULL;
+    tiUINT32    nSize;
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    // reset return values
+    *pp = NULL;
+    *pnSize = 0;
+    
+    // query until we have a big enough buffer or get an error
+    for( ; ; )
+    {
+        // try next allocation
+        nSize = nNextAllocation;
+        
+        if ( nSize )
+        {
+            p = malloc(nSize);
+            if (!p) 
+                return TI_RESULT_FAILED;
+            memset(p,0,nSize);
+        }
+        
+        
+        // get OID
+        dwRetValue = tiIoCtrl(oid, p, nSize, p, nSize, &dwRetSize);
+        
+        if( dwRetSize && nNextAllocation <= nSize && nSize != 0 )
+            break;
+        else
+            nNextAllocation = dwRetSize;
+        
+        // failed: free buffer
+        if ( p )
+        {
+            free(p);
+            p = NULL;
+        }
+        // if buffer overflow but new size is less than we used, return error
+        // NOTE: this would be a NIC bug and we have to avoid an infinite loop
+        if( nNextAllocation <= nSize )
+            return TI_RESULT_FAILED;
+    }
+    
+    // return pointer, size
+    *pp = p;
+    *pnSize = nNextAllocation;
+    
+    // success
+    return TI_RESULT_OK;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::StartScan( scan_Params_t *pScanParams )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_START_APP_SCAN_SET, pScanParams, sizeof(scan_Params_t),NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::StopScan( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_STOP_APP_SCAN_SET, NULL, 0,NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetScanPolicy( UINT8* buffer, UINT16 bufferLength )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_SCAN_POLICY_PARAM_SET, buffer, bufferLength,NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetScanBssList( bssList_t* bssList )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_SCAN_BSS_LIST_GET, NULL, 0, bssList, sizeof(bssList_t),&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::PollApPackets( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POLL_AP_PACKETS, NULL, 0, NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::PollApPacketsFromAC( tiUINT32 AC )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POLL_AP_PACKETS_FROM_AC, &AC, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::SetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pTrafficThresholds, sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SET_TRAFFIC_INTENSITY_THRESHOLDS, pTrafficThresholds , sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS),NULL, 0,&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::GetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_TRAFFIC_INTENSITY_THRESHOLDS, pTrafficThresholds , sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS), pTrafficThresholds , sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS),&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::ToggleTrafficIntensityEvents ( tiUINT32 NewStatus )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    tiUINT32 localVal = NewStatus;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS, &localVal , sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetDTagToAcMappingTable( acTrfcType_e* pDtagToAcTable )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    txDataQosParams_t  txDataQosParams;
+    
+    if (CheckObjectMemory(pDtagToAcTable, sizeof(acTrfcType_e)))
+    {
+        for (int i=0; i<MAX_NUM_OF_802_1d_TAGS; i++)
+        {
+            if (pDtagToAcTable[i] < MAX_NUM_OF_AC)
+            {
+                txDataQosParams.qosParams.tag_ToAcClsfrTable[i] = pDtagToAcTable[i];
+            }
+            else
+            {
+                return dwRetValue;
+            }
+       }
+
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SET_DTAG_TO_AC_MAPPING_TABLE, &txDataQosParams, sizeof(txDataQosParams_t), NULL, 0,&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetVAD( txDataVadTimerParams_t* pVadTimer )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pVadTimer, sizeof(txDataVadTimerParams_t)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SET_VAD, pVadTimer, sizeof(txDataVadTimerParams_t), NULL, 0,&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetVAD( txDataVadTimerParams_t* pVadTimer )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pVadTimer, sizeof(txDataVadTimerParams_t)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_GET_VAD, pVadTimer, sizeof(txDataVadTimerParams_t), pVadTimer, sizeof(txDataVadTimerParams_t),&dwRetSize);
+    }
+    return dwRetValue; 
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetQosParameters( OS_802_11_QOS_PARAMS* pQosParams )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pQosParams, sizeof(OS_802_11_QOS_PARAMS)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SET_QOS_PARAMS, pQosParams, sizeof(OS_802_11_QOS_PARAMS),NULL, 0,&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetRxTimeOut( OS_802_11_QOS_RX_TIMEOUT_PARAMS* pRxTimeOut )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pRxTimeOut, sizeof(OS_802_11_QOS_PARAMS)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SET_RX_TIMEOUT, pRxTimeOut, sizeof(OS_802_11_QOS_RX_TIMEOUT_PARAMS),NULL, 0,&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetAPQosParameters( OS_802_11_AC_QOS_PARAMS* pACQosParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pACQosParams, sizeof(OS_802_11_AC_QOS_PARAMS)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_GET_AP_QOS_PARAMS, pACQosParams, sizeof(OS_802_11_AC_QOS_PARAMS), pACQosParams, sizeof(OS_802_11_AC_QOS_PARAMS),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetUserPriorityOfStream( STREAM_TRAFFIC_PROPERTIES* streamProperties)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(streamProperties, sizeof(STREAM_TRAFFIC_PROPERTIES)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_GET_USER_PRIORITY_OF_STREAM, streamProperties, sizeof(STREAM_TRAFFIC_PROPERTIES), streamProperties, sizeof(STREAM_TRAFFIC_PROPERTIES),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetAPQosCapabilitesParameters( OS_802_11_AP_QOS_CAPABILITIES_PARAMS* pAPQosCapabiltiesParams )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_AP_QOS_CAPABILITIES, NULL, 0, pAPQosCapabiltiesParams, sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS),&dwRetSize);
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::AddTspec ( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_ADD_TSPEC, pTspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetTspecParameters( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_TSPEC_PARAMS, pTspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS), pTspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS),&dwRetSize);
+    return dwRetValue;
+}/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::DeleteTspec( OS_802_11_QOS_DELETE_TSPEC_PARAMS* pDelTspecParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_DELETE_TSPEC, pDelTspecParams, sizeof(OS_802_11_QOS_DELETE_TSPEC_PARAMS),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI:: GetCurrentACStatus( OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_CURRENT_AC_STATUS, pAcStatusParams, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS), pAcStatusParams, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS),&dwRetSize);
+    return dwRetValue;
+}/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI:: SetMediumUsageThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_SET_MEDIUM_USAGE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI:: SetPhyRateThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_SET_PHY_RATE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI:: GetMediumUsageThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_MEDIUM_USAGE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS), pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI:: GetPhyRateThreshold(OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_PHY_RATE_THRESHOLD, pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS), pThresholdCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS),&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI:: GetDesiredPsMode(OS_802_11_QOS_DESIRED_PS_MODE* pDesiredPsMode)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_DESIRED_PS_MODE, NULL, 0, pDesiredPsMode, sizeof(OS_802_11_QOS_DESIRED_PS_MODE),&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::ConfigTxClassifier(tiUINT32 inParamsBuffLen, tiUINT8  *pInParamsBuff)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pInParamsBuff && CheckObjectMemory(pInParamsBuff, inParamsBuffLen) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CONFIG_TX_CLASS, pInParamsBuff, inParamsBuffLen,NULL, 0,&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::RemoveClassifierEntry(clsfr_tableEntry_t *pClsfrEntry)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (pClsfrEntry)
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_REMOVE_CLSFR_ENTRY, pClsfrEntry, sizeof(clsfr_tableEntry_t),NULL, 0,&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+/**********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetClsfrType (clsfrTypeAndSupport *currClsfrType)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_CLSFR_TYPE, NULL, 0, currClsfrType, sizeof(clsfrTypeAndSupport),&dwRetSize);      
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::GetDriverCapabilities (OS_802_11_DRIVER_CAPABILITIES* pDriverCapabilities )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_DRIVERS_CAPABILITIES, pDriverCapabilities, sizeof(OS_802_11_DRIVER_CAPABILITIES), pDriverCapabilities, sizeof(OS_802_11_DRIVER_CAPABILITIES),&dwRetSize);
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetSelectedBSSIDInfo(OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_SELECTED_BSSID_INFO, pSelectedBSSIDInfo, sizeof(OS_802_11_BSSID_EX), pSelectedBSSIDInfo, sizeof(OS_802_11_BSSID_EX),&dwRetSize);
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetPrimaryBSSIDInfo(OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)
+{
+       tiUINT32 dwRetValue = TI_RESULT_FAILED;
+       tiUINT32 dwRetSize;
+    tiUINT32 outBufLen;
+
+    outBufLen = pSelectedBSSIDInfo->Length; //sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) + 300;
+
+   dwRetValue = tiIoCtrl(TIWLN_802_11_GET_PRIMARY_BSSID_INFO, pSelectedBSSIDInfo, outBufLen, pSelectedBSSIDInfo, outBufLen, &dwRetSize);
+   return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::EnableDisableRxDataFilters(tiBOOL enabled)
+{
+    tiUINT32 dwRetSize;
+
+    return tiIoCtrl(TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS, &enabled, sizeof(enabled), NULL, 0, &dwRetSize);
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetRxDataFiltersStatistics(TIWLAN_DATA_FILTER_STATISTICS * pStatistics)
+{
+    tiUINT32 dwRetSize;
+
+    return tiIoCtrl(TIWLN_GET_RX_DATA_FILTERS_STATISTICS, NULL, 0, pStatistics, sizeof(TIWLAN_DATA_FILTER_STATISTICS), &dwRetSize);
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetPowerConsumptionStatistics(PowerConsumptionTimeStat_t * pStatistics)
+{
+    tiUINT32 dwRetSize;
+
+    return tiIoCtrl(TIWLN_GET_POWER_CONSUMPTION_STATISTICS, NULL, 0, pStatistics, sizeof(PowerConsumptionTimeStat_t), &dwRetSize);
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::AddRxDataFilter(TIWLAN_DATA_FILTER_REQUEST * pRequest)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+
+    if ( pRequest )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_ADD_RX_DATA_FILTER, pRequest, sizeof(TIWLAN_DATA_FILTER_REQUEST), NULL, 0, &dwRetSize);
+    }
+
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::RemoveRxDataFilter(TIWLAN_DATA_FILTER_REQUEST * pRequest)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+
+    if ( pRequest )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REMOVE_RX_DATA_FILTER, pRequest, sizeof(TIWLAN_DATA_FILTER_REQUEST), NULL, 0, &dwRetSize);
+    }
+
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetTxPowerDbm(tiUINT8 uTxPower)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_TX_POWER_DBM_SET, &uTxPower, sizeof(UINT8),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetPowerMode(OS_802_11_POWER_PROFILE uPower )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_MODE_SET, &uPower, sizeof(OS_802_11_POWER_PROFILE),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetPowerMode(OS_802_11_POWER_PROFILE* puPower)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_MODE_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_PROFILE),&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetPowerLevelPS(OS_802_11_POWER_LEVELS uPower )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_PS_SET, &uPower, sizeof(OS_802_11_POWER_LEVELS),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetPowerLevelPS( OS_802_11_POWER_LEVELS* puPower)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_PS_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_LEVELS),&dwRetSize);
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetPowerLevelDefault(OS_802_11_POWER_LEVELS uPower )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DEFAULT_SET, &uPower, sizeof(OS_802_11_POWER_LEVELS),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetPowerLevelDefault( OS_802_11_POWER_LEVELS* puPower)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DEFAULT_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_LEVELS),&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetPowerLevelDozeMode(OS_802_11_POWER_PROFILE uPower )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DOZE_MODE_SET, &uPower, sizeof(OS_802_11_POWER_PROFILE),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetPowerLevelDozeMode( OS_802_11_POWER_PROFILE* puPower)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_POWER_LEVEL_DOZE_MODE_GET, NULL, 0, puPower, sizeof(OS_802_11_POWER_PROFILE),&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetBeaconFilterDesiredState( OS_802_11_BEACON_FILTER_MODE   uBeaconFilterMode)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_SET, &uBeaconFilterMode, sizeof(OS_802_11_BEACON_FILTER_MODE),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetBeaconFilterDesiredState( tiUINT8* pDesiredState)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_GET, NULL, 0, pDesiredState, sizeof(UINT8),&dwRetSize);
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetTxPowerLevel(tiCHAR* puTxPower )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puTxPower )
+    {
+               dwRetValue = tiIoCtrl(TIWLN_802_11_TX_POWER_LEVEL_GET, NULL, 0, puTxPower, sizeof(TIWLAN_POWER_LEVEL_TABLE),&dwRetSize);      
+    }
+    
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetTxPowerDbm(tiCHAR* puTxPower )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puTxPower )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_TX_POWER_DBM_GET, NULL, 0, puTxPower, sizeof(UINT8),&dwRetSize);      
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32  
+CTI_WLAN_AdapterAPI::Set4XState(tiBOOL bStatus)
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+    
+    bRet = m_pRegistry->PutDW(_T("Mode4x"), bStatus);
+    
+    return bRet;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::Get4XState(tiBOOL* lpbStatus)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_4XACTIVESTATE_GET, NULL, 0, lpbStatus, sizeof(tiBOOL),&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetDesiredRate(tiUINT32* puDesiredRates)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puDesiredRates )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_DESIRED_RATES_GET, NULL, 0, puDesiredRates, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetCurrentRate(tiUINT32* puCurrentRates)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puCurrentRates )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CURRENT_RATES_GET, NULL, 0, puCurrentRates, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetFragmentThreshold(tiUINT32 dwFragmentThreshold)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_FRAGMENTATION_THRESHOLD_SET, &dwFragmentThreshold, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetFragmentThreshold(tiUINT32* lpdwFragmentThreshold)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( lpdwFragmentThreshold )
+    {
+        dwRetValue = tiIoCtrl( TIWLN_802_11_FRAGMENTATION_THRESHOLD_GET, NULL, 0,
+            lpdwFragmentThreshold, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetRTSThreshold(tiUINT32 uRTSThreshold)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_RTS_THRESHOLD_SET, &uRTSThreshold, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetRTSThreshold(tiUINT32* puRTSThreshold )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puRTSThreshold )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_RTS_THRESHOLD_GET, NULL, 0, puRTSThreshold, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetShortPreamble(tiUINT32 uShortPreamble)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_PREAMBLE_SET, &uShortPreamble, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetShortPreamble(tiUINT32* puShortPreamble)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puShortPreamble )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_PREAMBLE_GET, NULL, 0, puShortPreamble, sizeof(tiUINT32),&dwRetSize);
+        
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetShortRetry(tiUINT32 uShortRetry)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_RETRY_SET, &uShortRetry, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetShortRetry(tiUINT32* puShortRetry)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puShortRetry )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SHORT_RETRY_GET, NULL, 0, puShortRetry, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetLongRetry(tiUINT32 uLongRetry)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_LONG_RETRY_SET, &uLongRetry, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetLongRetry(tiUINT32* puLongRetry)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puLongRetry )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_LONG_RETRY_GET, NULL, 0, puLongRetry, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetSupportedNetworkTypes(OS_802_11_NETWORK_TYPE* pNetTypeLst, tiUINT32 uMaxNetTypes )
+{
+    tiUINT32 dwRetValue = TI_RESULT_INVALID_PARAMETER;
+    tiUINT32 dwRetSize;
+    tiUINT32    uSizeList = sizeof(OS_802_11_NETWORK_TYPE)*uMaxNetTypes;
+    
+    if ( pNetTypeLst && CheckObjectMemory(pNetTypeLst, uSizeList) )
+    {
+        tiUINT32 dwNetTypesSize = sizeof(OS_802_11_NETWORK_TYPE_LIST) + (uMaxNetTypes - 1) * sizeof(OS_802_11_NETWORK_TYPE);
+        
+        OS_802_11_NETWORK_TYPE_LIST*    pNetworkTypeList = NULL;
+        pNetworkTypeList = (OS_802_11_NETWORK_TYPE_LIST*) new tiUINT8[dwNetTypesSize];
+        
+        if( !pNetworkTypeList )
+            return TI_RESULT_NOT_ENOUGH_MEMORY;
+        
+        memset(pNetworkTypeList, 0, dwNetTypesSize );
+        
+        pNetworkTypeList->NumberOfItems = uMaxNetTypes;
+        
+        dwRetValue = tiIoCtrl(TIWLN_802_11_NETWORK_TYPES_SUPPORTED, NULL, 0, pNetTypeLst, dwNetTypesSize,&dwRetSize);
+        
+        if ( dwRetSize )
+        {
+            dwRetValue = TI_RESULT_OK;
+            memcpy(pNetTypeLst, pNetworkTypeList, uSizeList);
+        } 
+        
+        delete [] pNetworkTypeList;
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetNetworkTypeInUse( OS_802_11_NETWORK_TYPE uNetType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_NETWORK_TYPE_IN_USE_SET, &uNetType, sizeof(OS_802_11_NETWORK_TYPE),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetNetworkTypeInUse( OS_802_11_NETWORK_TYPE*   puNetType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puNetType )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_NETWORK_TYPE_IN_USE_GET, NULL, 0, puNetType, sizeof(OS_802_11_NETWORK_TYPE),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetBSSID( OS_802_11_MAC_ADDRESS* pAddrBSSID )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pAddrBSSID && CheckObjectMemory(pAddrBSSID, sizeof(OS_802_11_MAC_ADDRESS)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_BSSID_GET, NULL, 0, pAddrBSSID, sizeof( OS_802_11_MAC_ADDRESS ),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetBSSID( OS_802_11_MAC_ADDRESS* lpAddrBSSID )
+{
+    tiUINT32 dwRetValue;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_BSSID_SET, lpAddrBSSID, sizeof( OS_802_11_MAC_ADDRESS ),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetRSSITrigger( tiBOOL bRSSItr )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_RSSI_TRIGGER_SET, &bRSSItr, sizeof(tiBOOL),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetRSSITrigger( tiBOOL* pbRSSItr )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_RSSI_TRIGGER_GET, NULL, 0, pbRSSItr, sizeof( tiBOOL ),&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetAntennaDiversityParams( PTIWLAN_ANT_DIVERSITY pAntennaDiversityOptions )
+{
+    tiINT32    bRet    = TI_RESULT_FAILED;
+    tiUINT32   dwRetSize;
+    
+    bRet = tiIoCtrl(TIWLAN_802_11_ANTENNA_DIVERSITY_PARAM_SET, pAntennaDiversityOptions, sizeof(TIWLAN_ANT_DIVERSITY), NULL, 0, &dwRetSize);
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetWEPStatus(tiUINT32 dwWEPStatus)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_SET, &dwWEPStatus, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetWEPStatus(tiUINT32*   lpdwWEPStatus)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( lpdwWEPStatus )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_WEP_STATUS_GET, NULL, 0, lpdwWEPStatus, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetDesiredChannel( tiUINT32 dwDesiredChannel )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_DESIRED_CHANNEL_SET, &dwDesiredChannel, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetDesiredChannel( tiUINT32*   lpdwDesiredChannel )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( lpdwDesiredChannel )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_DESIRED_CHANNEL_GET, NULL, 0, lpdwDesiredChannel, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetCurrentChannel( tiUINT32* puCurrentChannel )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puCurrentChannel )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CHANNEL_GET, NULL, 0, puCurrentChannel, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetBtCoeEnable( tiUINT32 uModeEnable) 
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(BT_COEXSISTANCE_SET_ENABLE, &uModeEnable, sizeof(tiUINT32),NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetBtCoeRate( tiUINT8 *pRate )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(BT_COEXSISTANCE_SET_RATE, pRate, sizeof(tiUINT8)*NUM_OF_RATES_IN_SG,NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetBtCoeConfig( tiUINT32 *pConfig )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    
+    dwRetValue = tiIoCtrl(BT_COEXSISTANCE_SET_CONFIG, pConfig, sizeof(tiUINT32) * NUM_OF_CONFIG_PARAMS_IN_SG,NULL,0,NULL);
+    
+    return dwRetValue;
+}
+
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetBtCoeGetStatus( tiUINT32 *pStatus )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(BT_COEXSISTANCE_GET_STATUS, NULL, 0, pStatus, sizeof(tiUINT32) * NUM_OF_STATUS_PARAMS_IN_SG,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+
+
+#ifdef TI_DBG
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::DisplayStats( tiUINT8*  puDbgBuffer, tiUINT32 uBuffSize)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puDbgBuffer && CheckObjectMemory(puDbgBuffer, uBuffSize) )
+    {
+        dwRetValue = tiIoCtrl( TIWLN_DISPLAY_STATS, puDbgBuffer, uBuffSize,NULL, 0,&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::SetReportModule( tiUINT8 *pData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize = 0;
+    
+    if ( pData && CheckObjectMemory(pData, WLAN_MAX_LOG_MODULES) )
+    {
+        dwRetValue = tiIoCtrl( TIWLN_REPORT_MODULE_SET, pData, WLAN_MAX_LOG_MODULES, NULL, 0, &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetReportModule( tiUINT8* pData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pData )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REPORT_MODULE_GET, NULL, 0, pData, WLAN_MAX_LOG_MODULES, &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetReportSeverity( tiUINT8  *pData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pData && CheckObjectMemory(pData, WLAN_MAX_SEVERITIES) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REPORT_SEVERITY_SET, pData, WLAN_MAX_SEVERITIES, NULL, 0, &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetReportSeverity( tiUINT8* pData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pData )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REPORT_SEVERITY_GET, NULL, 0, pData, WLAN_MAX_SEVERITIES, &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetOsDbgState( tiUINT32 uData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_OS_DBG_STATE_SET, &uData, sizeof(tiUINT32), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetOsDbgState( tiUINT32* puData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puData )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_OS_DBG_STATE_GET, NULL, 0, puData, sizeof(tiUINT32), &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetReportPPMode( tiUINT32  uData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_REPORT_PPMODE_SET, &uData, sizeof(tiUINT32), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetDebugBuffer( tiUINT8* pBuffer, tiUINT32  dwLenght)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pBuffer && CheckObjectMemory(pBuffer, sizeof(tiUINT8)*dwLenght) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_GET_DBG_BUFFER, NULL, 0, pBuffer, sizeof(tiUINT8)*dwLenght,&dwRetSize);
+        
+    }
+    return dwRetValue;
+}
+
+
+#ifdef DRIVER_PROFILING
+tiINT32                 
+CTI_WLAN_AdapterAPI::ProfileReport()
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+
+    dwRetValue =  tiIoCtrl(TIWLAN_PROFILING_REPORT,NULL, 0,NULL,0,&dwRetSize);
+
+    return dwRetValue;
+}
+
+tiINT32
+CTI_WLAN_AdapterAPI::CpuEstimatorCommand(tiUINT8 uType, tiUINT32 uData)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    tiUINT32 dwCommandParam;
+
+    /* set command param: type | (24 LSB) data */
+    dwCommandParam = (uData & 0xFFFFFF) | (((tiUINT32)uType) << 24);
+
+    //printf("CpuEstimatorCommand: type=%d, data =%d, dwCommandParam = %x\n", uType, uData, dwCommandParam);
+    dwRetValue =  tiIoCtrl(TIWLAN_PROFILING_CPU_ESTIMATOR_CMD,&dwCommandParam, sizeof(dwCommandParam),NULL, 0,&dwRetSize);
+
+    return dwRetValue;
+}
+#endif
+
+#endif //TI_DBG
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetSupportedRates( tiUINT8* pSupportedRatesLst, tiUINT32 uBufLength)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pSupportedRatesLst && CheckObjectMemory(pSupportedRatesLst, uBufLength) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SUPPORTED_RATES_SET, pSupportedRatesLst, uBufLength,NULL, 0,&dwRetSize);
+        
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetSupportedRates( tiUINT8* pSupportedRatesLst, tiUINT32 uBufLength)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pSupportedRatesLst && CheckObjectMemory(pSupportedRatesLst, uBufLength) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SUPPORTED_RATES, NULL, 0, pSupportedRatesLst, uBufLength,&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::SetConfiguration( OS_802_11_CONFIGURATION*   pConfiguration )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pConfiguration && CheckObjectMemory(pConfiguration, sizeof(OS_802_11_CONFIGURATION)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CONFIGURATION_SET, pConfiguration, sizeof(OS_802_11_CONFIGURATION),NULL, 0,&dwRetSize);
+        
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetConfiguration( OS_802_11_CONFIGURATION*   pConfiguration )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pConfiguration && CheckObjectMemory(pConfiguration, sizeof(OS_802_11_CONFIGURATION)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_CONFIGURATION_GET, NULL, 0, pConfiguration, sizeof(OS_802_11_CONFIGURATION),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetAuthenticationMode( OS_802_11_AUTHENTICATION_MODE uAuthenticationMode )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_AUTHENTICATION_MODE_SET, &uAuthenticationMode, sizeof(OS_802_11_AUTHENTICATION_MODE),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetAuthenticationMode( OS_802_11_AUTHENTICATION_MODE* puAuthenticationMode )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puAuthenticationMode )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_AUTHENTICATION_MODE_GET, NULL, 0, puAuthenticationMode, sizeof(OS_802_11_AUTHENTICATION_MODE),&dwRetSize);
+        
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::SetPrivacyFilter( tiUINT32 dwPrivacyFilter )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_PRIVACY_FILTER_SET, &dwPrivacyFilter, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::GetPrivacyFilter( tiUINT32* pdwPrivacyFilter )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pdwPrivacyFilter )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_PRIVACY_FILTER_GET, NULL, 0, pdwPrivacyFilter, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::SetKeyType( OS_802_11_KEY_TYPES uKeyType )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_KEY_TYPE_SET, &uKeyType, sizeof(OS_802_11_KEY_TYPES),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetMixedMode( tiBOOL bStatus )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_MIXED_MODE_SET, &bStatus, sizeof(tiBOOL),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetMixedMode( tiBOOL* pbStatus )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pbStatus )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_MIXED_MODE_GET, NULL, 0, pbStatus, sizeof( tiBOOL ),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::EnableDisable_802_11d( tiUINT8 enableDisable_802_11d)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11D, &enableDisable_802_11d, sizeof(tiUINT8), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Get_802_11d( tiUINT8 *enableDisable_802_11d)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( enableDisable_802_11d )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_802_11D, NULL, 0, enableDisable_802_11d, sizeof(tiUINT8),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::EnableDisable_802_11h( tiUINT8 enableDisable_802_11h)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11H, &enableDisable_802_11h, sizeof(tiUINT8), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Get_802_11h( tiUINT8 *enableDisable_802_11h)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( enableDisable_802_11h )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_802_11H, NULL, 0, enableDisable_802_11h, sizeof(tiUINT8),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Set_countryIeFor2_4_Ghz( country_t countryIe)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_SET_COUNTRY_2_4, &countryIe, sizeof(country_t), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Get_countryIeFor2_4_Ghz( tiUINT8 **countryString)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( countryString )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_COUNTRY_2_4, NULL, 0, countryString, COUNTRY_STRING_LEN,&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Set_countryIeFor5_Ghz( country_t countryIe)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_SET_COUNTRY_5, &countryIe, sizeof(country_t), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Get_countryIeFor5_Ghz( tiUINT8 **countryString)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( countryString )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_COUNTRY_5, NULL, 0, countryString, COUNTRY_STRING_LEN,&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Set_minMaxDfsChannels( DFS_ChannelRange_t DFS_ChannelRange)
+{
+       tiUINT32 dwRetValue = TI_RESULT_FAILED;
+       tiUINT32 dwRetSize;
+
+    dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_SET_DFS_RANGE, &DFS_ChannelRange, sizeof(DFS_ChannelRange_t), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Get_minMaxDfsChannels( DFS_ChannelRange_t *DFS_ChannelRange)
+{
+       tiUINT32 dwRetValue = TI_RESULT_FAILED;
+       tiUINT32 dwRetSize;
+
+    if ( DFS_ChannelRange )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REG_DOMAIN_GET_DFS_RANGE, NULL, 0, DFS_ChannelRange, sizeof(DFS_ChannelRange_t), &dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetIBSSProtection( tiUINT32 uProtection )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_IBSS_PROTECTION_SET, &uProtection, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetIBSSProtection ( tiUINT32* puProtection )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puProtection )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_IBSS_PROTECTION_GET, NULL, 0, puProtection, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::SetShortSlot( tiUINT32 dwShortSlot )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_SHORT_SLOT_SET, &dwShortSlot, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetShortSlot( tiUINT32* pdwShortSlot)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pdwShortSlot )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_SHORT_SLOT_GET, NULL, 0, pdwShortSlot, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::SetExtRatesIE( tiUINT32 dwExtRatesIE)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_EXT_RATES_IE_SET, &dwExtRatesIE, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetExtRatesIE( tiUINT32* pdwExtRatesIE)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pdwExtRatesIE )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_EXT_RATES_IE_GET, NULL, 0, pdwExtRatesIE, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::SetEarlyWakeupMode( tiUINT8 dwEarlyWakeup)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_EARLY_WAKEUP_IE_SET, &dwEarlyWakeup, sizeof(tiUINT8),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetEarlyWakeupMode( tiUINT8* pdwEarlyWakeup)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pdwEarlyWakeup )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_EARLY_WAKEUP_IE_GET, NULL, 0, pdwEarlyWakeup, sizeof(tiUINT8),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::Open_EAPOL_Interface( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_OPEN_EAPOL_INTERFACE, NULL, 0, NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Close_EAPOL_Interface( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_CLOSE_EAPOL_INTERFACE, NULL, 0, NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Send_EAPOL_Packet( tiVOID* pData, tiUINT32 uSize )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pData && CheckObjectMemory(pData, uSize) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_SEND_EAPOL_PACKET, pData, uSize,NULL, 0,&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::hwReadRegister( tiUINT32 dwRegisterAddr, tiUINT32* pdwValue )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    TIWLN_REG_RW sRegRead;
+    
+    if (!pdwValue )
+        return TI_RESULT_FAILED;
+    
+    sRegRead.regSize = 4;
+    sRegRead.regAddr = dwRegisterAddr;
+    sRegRead.regValue = 0;
+    
+    dwRetValue = tiIoCtrl(TIWLN_HW_READ_REGISTER, &sRegRead, sizeof(TIWLN_REG_RW), &sRegRead, sizeof(TIWLN_REG_RW),&dwRetSize);
+    
+    *pdwValue = sRegRead.regValue;
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::hwWriteRegister( tiUINT32 dwRegisterAddr, tiUINT32 dwValue )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    TIWLN_REG_RW sRegRead;
+    
+    sRegRead.regSize     = 4;
+    sRegRead.regAddr     = dwRegisterAddr;
+    sRegRead.regValue    = dwValue;
+    
+    dwRetValue = tiIoCtrl(TIWLN_HW_WRITE_REGISTER, &sRegRead, sizeof(TIWLN_REG_RW),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Disassociate( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_DISASSOCIATE, NULL, 0,NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::ReloadDefaults( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_RELOAD_DEFAULTS, NULL, 0,NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::IsDriverLoaded( )
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+#ifndef _WINDOWS
+    
+    TI_HANDLE hDevice = m_pIPCmod->IPC_DeviceOpen(m_pszAdapterName);
+    if (hDevice)
+        bRet = TI_RESULT_OK;
+    
+    m_pIPCmod->IPC_DeviceClose();
+#endif  
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetRSSI( tiINT32* pRssi )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    
+    if (CheckObjectMemory(pRssi, sizeof(tiUINT32)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_RSSI,NULL,0,pRssi, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetSNR( tiUINT32* pSnr )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    
+    if (CheckObjectMemory(pSnr, sizeof(tiUINT32)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_SNR,NULL,0,pSnr, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetNumberOfAntennas(tiUINT32* puNumberOfAntennas)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( puNumberOfAntennas )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_NUMBER_OF_ANTENNAS, NULL, 0, puNumberOfAntennas, sizeof(tiUINT32),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetDriverVersion( TIWLN_VERSION_EX* pdrvVersion )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pdrvVersion && CheckObjectMemory(pdrvVersion, sizeof(TIWLN_VERSION_EX)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_GET_SW_VERSION, NULL, 0, pdrvVersion, sizeof(TIWLN_VERSION_EX),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetRegDomainTable( TIWLN_REGDOMAINS* pRegDomainTable )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pRegDomainTable && CheckObjectMemory(pRegDomainTable, sizeof(TIWLN_REGDOMAINS)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_REGDOMAIN_TABLE, NULL, 0, pRegDomainTable, sizeof(TIWLN_REGDOMAINS),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetMediumUsage( TIWLN_MEDIUM_USAGE* pMediumUsage )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pMediumUsage && CheckObjectMemory(pMediumUsage, sizeof(TIWLN_MEDIUM_USAGE)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_MEDIUMUSAGE, NULL, 0, pMediumUsage, sizeof(TIWLN_MEDIUM_USAGE),&dwRetSize);
+    }
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetApiVersion( tiUINT32* pdwApiVersion )
+{
+    *pdwApiVersion = TI_WLAN_API_VER;
+    return TI_RESULT_OK;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GetDriverState( driverState_e* puDriverState )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    *puDriverState = (driverState_e)0;
+    dwRetValue = tiIoCtrl(TIWLN_802_11_GET_DRIVER_STATE, NULL, 0, puDriverState, sizeof(tiUINT32),&dwRetSize);
+    
+    switch (((driverState_e)*puDriverState) & 0xff)
+    {
+    case SM_STATE_IDLE:
+        *puDriverState = DRIVER_STATE_IDLE;
+        break;
+    case SM_STATE_SCANNING:
+        *puDriverState = DRIVER_STATE_SCANNING;
+        break;
+    case SM_STATE_SELECTING:
+        *puDriverState = DRIVER_STATE_SELECTING;
+        break;
+    case SM_STATE_CONNECTING:
+        *puDriverState = DRIVER_STATE_CONNECTING;
+        break;
+    case SM_STATE_CONNECTED:
+    case SM_STATE_QUIET_SCAN:
+    case SM_STATE_ROAMING_QUIET_SCAN:
+    case SM_STATE_MEASUREMENT:
+    case SM_STATE_POWER_MNGR_PENDS_QUIET_SCAN:
+        *puDriverState = DRIVER_STATE_CONNECTED;
+        break;
+    case SM_STATE_INTER_SCAN_TIMEOUT:
+        *puDriverState = DRIVER_STATE_DISCONNECTED;
+        break;
+    case SM_STATE_RADIO_STAND_BY:
+        *puDriverState = DRIVER_STATE_IDLE;
+        break;
+    default:
+        break;
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+tiINT32
+CTI_WLAN_AdapterAPI::Start( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    tiUINT32 Data = 1;
+    
+    dwRetValue = tiIoCtrl(TIWLN_DRIVER_STATUS_SET, &Data, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Stop( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    tiUINT32 Data = 0;
+    dwRetValue = tiIoCtrl(TIWLN_DRIVER_STATUS_SET, &Data, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Suspend( )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    tiUINT32 Data = 0;
+    
+    dwRetValue = tiIoCtrl(TIWLN_DRIVER_SUSPEND, &Data, sizeof(tiUINT32),NULL, 0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::IsDriverRun( tiUINT32* pbStatus )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if ( pbStatus && CheckObjectMemory(pbStatus, sizeof(tiUINT32)) )
+    {
+        dwRetValue = tiIoCtrl(TIWLN_DRIVER_STATUS_GET, NULL, 0, pbStatus, sizeof(tiUINT32),&dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+#define GWSI_DISPACH_OPCODE(_p_gwsi_buffer)                            ((*((tiUINT8 *)_p_gwsi_buffer + 0) | (*((tiUINT8 *)_p_gwsi_buffer + 1) << 8)))
+#define GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(_p_gwsi_buffer)     ((*((tiUINT8 *)_p_gwsi_buffer + 2) | (*((tiUINT8 *)_p_gwsi_buffer + 3) << 8)) + 4)
+#define GWSI_DISPACH_CALC_BUFFER_LONG_LEN(_p_gwsi_buffer)      (*((tiUINT8 *)_p_gwsi_buffer + 2) | (*((tiUINT8 *)_p_gwsi_buffer + 3) << 8) | (*((tiUINT8 *)_p_gwsi_buffer + 4) << 16) | (*((tiUINT8 *)_p_gwsi_buffer + 5) << 24) + 4)
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GWSICommand( tiUINT32* pGWSICommand )
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetSize = tiIoCtrl(GWSI_DISPATCH_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(pGWSICommand));
+    
+    if ( dwRetSize  )
+        bRet = TI_RESULT_OK;
+    
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GWSIInitialize( tiUINT32* pGWSICommand )
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    /* This command requires size of 4 bytes */
+    dwRetSize = tiIoCtrl(GWSI_INITIALIZE_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_LONG_LEN(pGWSICommand));
+    
+    if ( dwRetSize  )
+        bRet = TI_RESULT_OK;
+    
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GWSIConfig( tiUINT32* pGWSICommand )
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetSize = tiIoCtrl(GWSI_CONFIGURE_TABLE_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(pGWSICommand));
+    
+    if ( dwRetSize  )
+        bRet = TI_RESULT_OK;
+    
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::GWSIRelease( tiUINT32* pGWSICommand )
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetSize = tiIoCtrl(GWSI_RELEASE_COMMAND, pGWSICommand, GWSI_DISPACH_CALC_BUFFER_SHORT_LEN(pGWSICommand));
+    
+    if ( dwRetSize  )
+        bRet = TI_RESULT_OK;
+    
+    
+    return bRet;
+}
+
+/********************************************************************/
+tiINT32     
+CTI_WLAN_AdapterAPI::GWSIGetInitTable (tiUINT32* pGWSICommand )
+{
+    tiUINT32 bRet = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetSize = tiIoCtrl(GWSI_GET_INIT_TABLE_COMMAND, NULL, 0, pGWSICommand, (1024 * 5));
+    
+    if ( dwRetSize  )
+        bRet = TI_RESULT_OK;
+    
+    
+    return bRet;
+}
+
+#ifndef _WINDOWS
+       /********************************************************************/
+       tiINT32
+       TI_IPC::IPC_DeviceIoControl(tiUINT32 dwIoControlCode, tiVOID* lpInBuffer,
+                                                               tiUINT32 nInBufferSize, tiVOID* lpOutBuffer,
+                                                               tiUINT32 nOutBufferSize, tiUINT32* lpBytesReturned)
+       {
+               if (!m_hDevice)
+                       return TI_RESULT_INVALIDE_HANDLE;
+               
+               return ::IPC_DeviceIoControl(m_hDevice, dwIoControlCode, lpInBuffer,
+                       nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned);
+       }
+       
+       TI_IPC::TI_IPC()    
+       { 
+               m_hDevice = NULL;
+               IPC_Init();
+       }
+       
+       TI_IPC::~TI_IPC()    
+       { 
+               IPC_DeInit();
+       }
+       
+       TI_HANDLE
+       TI_IPC::IPC_DeviceOpen (tiCHAR* pAdapterName)
+       {
+               m_hDevice = ::IPC_DeviceOpen(pAdapterName);
+               return m_hDevice;
+       }
+       
+       tiVOID
+       TI_IPC::IPC_DeviceClose()
+       {
+               ::IPC_DeviceClose(m_hDevice);
+               m_hDevice = NULL;
+       }
+       
+       tiINT32 
+       TI_IPC::IPC_RegisterEvent( IPC_EVENT_PARAMS* pEventParams )
+       {
+               return ::IPC_RegisterEvent(m_hDevice, pEventParams);
+       }
+       
+       
+       tiINT32
+       TI_IPC::IPC_UnRegisterEvent( IPC_EVENT_PARAMS* pEventParams )
+       {
+               return ::IPC_UnRegisterEvent(m_hDevice, pEventParams);
+       }
+#endif
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Set_RoamingConfParams( UINT8* buffer, UINT16 bufferLength)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_802_11_ROAMING_CONFIG_PARAMS_SET, buffer, bufferLength,NULL,0,&dwRetSize);
+    
+    return dwRetValue;
+}
+/********************************************************************/
+tiINT32
+CTI_WLAN_AdapterAPI::Get_RoamingConfParams( UINT8* buffer, UINT16 bufferLength)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(buffer, bufferLength))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_802_11_ROAMING_CONFIG_PARAMS_GET, NULL, 0, buffer, bufferLength, &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+/********************************************************************/
+
+/****************************   PLT  ********************************/
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_ReadRegister( UINT32 uRegisterAddr, PUINT32 puRegisterData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(puRegisterData, sizeof(UINT32)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_PLT_READ_REGISTER, &uRegisterAddr, sizeof(UINT32), puRegisterData, sizeof(UINT32), &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_WriteRegister( UINT32 uRegisterAddr, UINT32 uRegisterData )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    TIWLN_REG_RW sRegWrite;
+    
+    sRegWrite.regSize     = 4;
+    sRegWrite.regAddr     = uRegisterAddr;
+    sRegWrite.regValue    = uRegisterData;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_WRITE_REGISTER, &sRegWrite, sizeof(TIWLN_REG_RW),NULL, 0,&dwRetSize);
+    
+    
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RxPerStart()
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_START, NULL, 0, NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RxPerStop()
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_STOP, NULL, 0, NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RxPerClear()
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_CLEAR, NULL, 0, NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RxPerGetResults( PltRxPer_t* pPltRxPer )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    if (CheckObjectMemory(pPltRxPer, sizeof(PltRxPer_t)))
+    {
+        dwRetValue = tiIoCtrl(TIWLN_PLT_RX_PER_GET_RESULTS, NULL, 0, pPltRxPer, sizeof(PltRxPer_t), &dwRetSize);
+    }
+    
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxCW(TestCmdChannelBand_t* pPltTxCW)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_TX_CW, pPltTxCW, sizeof(*pPltTxCW), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxContiues(PltTxContinues_t* pPltTxContinues)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_TX_CONTINUES, pPltTxContinues, sizeof(PltTxContinues_t), NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxStop()
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    
+    dwRetValue = tiIoCtrl(TIWLN_PLT_TX_STOP, NULL, 0, NULL, 0, &dwRetSize);
+    
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_ReadMIB ( PLT_MIB_t* pMib )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;      
+    tiUINT32 dwRetSize; 
+    if (CheckObjectMemory(pMib, sizeof(PLT_MIB_t)))
+    {
+      dwRetValue = tiIoCtrl(TIWLN_PLT_MIB_READ,
+                                                         (tiVOID*)pMib,(tiUINT32)sizeof(PLT_MIB_t),
+                                                         (tiVOID*)pMib,(tiUINT32)sizeof(PLT_MIB_t),
+                                                         &dwRetSize);
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_WriteMIB( PLT_MIB_t* pMib )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    dwRetValue = tiIoCtrl(TIWLN_PLT_MIB_WRITE,
+                                                 pMib, sizeof(PLT_MIB_t),
+                                                 NULL, 0,
+                                                 &dwRetSize);
+    return dwRetValue;
+}
+
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::GetDefaultWepKey(  tiUINT32* puKeyIndex )
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;
+    tiUINT32 dwRetSize;
+    UINT32 InfoCode = VAL_DEFAULT_KEY_ID;
+    
+    dwRetValue = tiIoCtrl(TIWLN_IOCTL_OID_QUERY_INFORMATION, &InfoCode, (tiUINT32)sizeof(InfoCode), puKeyIndex, sizeof(tiUINT32), &dwRetSize);
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxCalGainGet(PltGainGet_t* pPLTGainGet)
+{
+    return PLT_RxTXCal((void*)pPLTGainGet, sizeof(PltGainGet_t), TEST_CMD_PLT_GAIN_GET);
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxCalGainAdjust(tiINT32   uTxGainChange)
+{
+    return PLT_RxTXCal(&uTxGainChange, sizeof(tiINT32), TEST_CMD_PLT_GAIN_ADJUST);
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxCalStart(PltTxCalibrationRequest_t* pPLTTxCal)
+{
+    return PLT_RxTXCal((void*)pPLTTxCal, sizeof(PltTxCalibrationRequest_t), TEST_CMD_PLT_TXPOWER_CAL_START);
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_TxCalStop()
+{
+    return PLT_RxTXCal(NULL, 0, TEST_CMD_PLT_TXPOWER_CAL_STOP);
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RxTxCalNVSUpdateBuffer(PltNvsResultsBuffer_t* pPLT_NVSUpdateBuffer)
+{
+    return PLT_RxTXCal(pPLT_NVSUpdateBuffer, sizeof(PltNvsResultsBuffer_t), TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER);
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RxCal(PltRxCalibrationRequest_t* pPltRxCalibration)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;      
+    tiUINT32 dwRetSize;
+    TestCmd_t TestCmd;
+
+    if ( CheckObjectMemory(pPltRxCalibration, sizeof(PltRxCalibrationRequest_t)) )
+    {   
+        memset(&TestCmd, 0, sizeof(TestCmd));
+        memcpy(&TestCmd.testCmd_u, pPltRxCalibration, sizeof(PltRxCalibrationRequest_t));
+        TestCmd.testCmdId = TEST_CMD_PLT_RX_CALIBRATION;
+
+        dwRetValue = tiIoCtrl(TIWLN_PLT_RX_CAL,
+                              (tiVOID*) &TestCmd, sizeof(TestCmd),
+                              (tiVOID*) &TestCmd, sizeof(TestCmd),
+                              &dwRetSize);
+    }
+    /* 
+     * for RX calibration, we query the status on a polling loop until it is complete.
+     * This is done to avoid a WinMobile bug, where returning pending will make Win re-send
+     * the OID after a while
+     * This is a patch, and a unified a-synchronous method must be implemented
+     * for all IOCTLs
+     */
+    if (TI_RESULT_OK == dwRetValue)
+    {
+        TI_STATUS   TIStatus = PENDING;
+        while ( PENDING == TIStatus )
+        {
+            dwRetValue = PLT_RxCalStatus( &TIStatus );
+            m_pOSLib->TISleep(100);
+        }
+    }
+    return dwRetValue;
+}
+
+/********************************************************************/
+tiINT32                
+CTI_WLAN_AdapterAPI::PLT_RadioTune(TestCmdChannelBand_t* pChannelBand)
+{
+    return PLT_RxTXCal(pChannelBand, sizeof(TestCmdChannelBand_t), TEST_CMD_RADIO_TUNE);
+}
+
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::PLT_RxTXCal(void* pTestCmdData, tiUINT32 Length, TestCmdID_e TestCmdID)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;      
+    tiUINT32 dwRetSize;
+    TestCmd_t TestCmd;
+
+    
+    if ((Length==0) ||
+        (CheckObjectMemory(pTestCmdData, Length)))
+    {   
+        memset(&TestCmd, 0, sizeof(TestCmd));
+        memcpy(&TestCmd.testCmd_u, pTestCmdData, Length);
+        TestCmd.testCmdId = TestCmdID;
+
+        dwRetValue = tiIoCtrl(TIWLN_PLT_RX_TX_CAL,
+                              (tiVOID*) &TestCmd, sizeof(TestCmd),
+                              (tiVOID*) &TestCmd, sizeof(TestCmd),
+                              &dwRetSize);
+    }
+    if (TI_RESULT_OK == dwRetValue)
+    {
+        memcpy(pTestCmdData, &TestCmd.testCmd_u, Length);
+    }
+    return dwRetValue;    
+}
+
+/********************************************************************/
+tiINT32 
+CTI_WLAN_AdapterAPI::PLT_RxCalStatus(TI_STATUS* pStatus)
+{
+    tiUINT32 dwRetValue = TI_RESULT_FAILED;      
+    tiUINT32 dwRetSize;
+
+    dwRetValue = tiIoCtrl(TIWLN_PLT_RX_CAL_RESULT,
+                          NULL, 0, (tiVOID*)pStatus, sizeof(*pStatus), &dwRetSize);
+
+    return dwRetValue;
+}
+
+/********************************************************************/
+#ifdef _WINDOWS
+#endif
+
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/CTI_Adapter.h b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/CTI_Adapter.h
new file mode 100644 (file)
index 0000000..fe9e084
--- /dev/null
@@ -0,0 +1,441 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             CTI_Adapter.h*/
+/**/
+/* Purpose:            interface for the ITI_WLAN_Adapter class.*/
+/**/
+/*--------------------------------------------------------------------------*/
+
+#if !defined(AFX_CTI_WLAN_ADAPTER_H__3B4F299B_AF52_40DE_BE67_A032DA1FB441__INCLUDED_)
+#define AFX_CTI_WLAN_ADAPTER_H__3B4F299B_AF52_40DE_BE67_A032DA1FB441__INCLUDED_
+
+#include "tiwlnif.h"
+
+#if _MSC_VER > 1000
+#pragma once
+#endif /* _MSC_VER > 1000*/
+
+#define TIWLNAPI_READ       0
+#define TIWLNAPI_WRITE      1
+#define TIWLNAPI_READWRITE  2
+
+#define MAX_SSID_LENGTH     32
+
+#ifndef _T
+#define _T(x)  x
+#endif
+
+
+
+
+#ifdef EXC_MODULE_INCLUDED
+    #define EXC_EXPANSION           CASE_EXC_SUPPORT
+    #define EXC_MODULE_SUPPORT_H    ADAPTER_EXC_SUPPORT_H
+#else
+    #define EXC_EXPANSION
+    #define EXC_MODULE_SUPPORT_H
+#endif /*EXC_MODULE_INCLUDED */
+
+#ifdef _WINDOWS
+#else
+
+class TI_IPC
+{
+       TI_HANDLE m_hDevice;
+    public:
+        TI_IPC();
+       ~TI_IPC(); 
+        tiINT32    IPC_DeviceIoControl  (   tiUINT32    dwIoControlCode, 
+                                        tiVOID* lpInBuffer, tiUINT32 nInBufferSize,
+                                        tiVOID* lpOutBuffer, tiUINT32 nOutBufferSize, 
+                                        tiUINT32* lpBytesReturned);
+        TI_HANDLE   IPC_DeviceOpen      ( tiCHAR* pAdapterName);
+        tiVOID      IPC_DeviceClose     ();
+        tiINT32     IPC_RegisterEvent   ( IPC_EVENT_PARAMS* pEventParams );
+        tiINT32     IPC_UnRegisterEvent ( IPC_EVENT_PARAMS* pEventParams );
+}; 
+#endif /* _WINDOWS */
+
+class TI_OSRegistry
+{
+    public:
+        tiUINT32    PutSZ(tiCHAR* /*lpszName*/, tiCHAR* /* lpszValue*/) {return TRUE;}
+        tiUINT32       PutDW(tiCHAR* /*lpszName*/, tiUINT32   /* dwValue*/)   {return TRUE;}
+
+};
+
+class CTI_WLAN_AdapterAPI;
+
+struct _AdapterItem
+{
+        _AdapterItem()
+        { 
+            m_dwAdapterID   = NULL;
+            m_pAdapterName  = NULL; 
+            m_pNextItem     = NULL;
+            m_pPrevItem     = NULL;
+            m_uRef          = 1;
+        }
+                    
+        CTI_WLAN_AdapterAPI*            m_dwAdapterID;
+        tiCHAR*                         m_pAdapterName;
+        tiUINT32                        m_uRef;
+
+        _AdapterItem*                   m_pNextItem;
+        _AdapterItem*                   m_pPrevItem;
+       
+        tiUINT32                        AddRef()    {return ++m_uRef;}
+        tiUINT32                        DecRef()    {return --m_uRef;}
+};
+
+class CTI_WLAN_AdapterAPI : public TI_WLAN_AdapterAPI 
+{
+    protected:                                                   
+
+        static  _AdapterItem*           m_pAdaptersList;
+
+                                           CTI_WLAN_AdapterAPI     ( tiCHAR* lpszAdapterName );
+           virtual                        ~CTI_WLAN_AdapterAPI     ();
+                tiINT32                 PLT_RxTXCal(void* pTestCmdData, tiUINT32 Length, TestCmdID_e TestCmdID);
+                tiCHAR*                 m_pszAdapterName;
+                tiINT32                 PLT_RxCalStatus(TI_STATUS* pStatus);
+    
+    private:
+#ifdef _WINDOWS
+#else
+                TI_IPC*                 m_pIPCmod;
+#endif
+#ifdef TI_EMBEDDED_SUPPLICANT
+                       TI_IPC_Supplicant* m_pSupplicant;
+#endif /* ifdef TI_EMBEDDED_SUPPLICANT */
+                TI_OSRegistry*          m_pRegistry;
+                TI_OAL*                 m_pOSLib;
+#ifdef TI_EMBEDDED_SUPPLICANT
+                tiBOOL                  m_bSupplicantInUse;
+#endif /* ifdef TI_EMBEDDED_SUPPLICANT */
+
+                tiINT32                 tiIoCtrl                (tiUINT32 dwIoCtrl, tiVOID* pInBuffer, tiUINT32 dwInBufferSize, 
+                                                                 tiVOID* pOutBuffer = NULL, tiUINT32 dwOutBufferSize = 0, tiUINT32* dwBytesReturned = NULL);
+                tiINT32                 tiMiniportSetInformation(tiUINT32 dwInfoCode,tiVOID* lpInfoBuffer, 
+                                                                 tiUINT32* lpdwCbInfoBuffer);
+                tiINT32                 tiMiniportQueryInformation(tiUINT32 dwInfoCode, tiVOID* lpInfoBuffer, 
+                                                                 tiUINT32* lpdwCbInfoBuffer);
+    public:
+           static  CTI_WLAN_AdapterAPI*    GetTIWLANAdapter        (tiCHAR* lpszAdapterName, tiBOOL bForce);
+        static  tiINT32                 FreeTIWLANAdapter       ( CTI_WLAN_AdapterAPI* pAdapter, tiBOOL bForce);
+                tiINT32                 CheckObjectMemory       (tiVOID* pObj, tiUINT32 uSizeObj);
+
+        virtual tiINT32                 GetApiVersion           ( tiUINT32* pdwApiVersion );
+
+           virtual tiINT32                 GetBSSID                ( OS_802_11_MAC_ADDRESS* pAddrBSSID );
+           virtual tiINT32                 SetBSSID                ( OS_802_11_MAC_ADDRESS* pAddrBSSID );
+
+        virtual tiINT32                 GetBSSIDList            ( OS_802_11_BSSID_LIST_EX** ppBSSIDlist);
+        virtual tiINT32                 GetFullBSSIDList        ( OS_802_11_BSSID_LIST_EX** ppBSSIDlist);
+
+        virtual tiINT32                 GetCurrentAddress       ( OS_802_11_MAC_ADDRESS*    pCurrentAddr);
+
+        virtual tiINT32                 SetDesiredChannel       ( tiUINT32  uDesiredChannel  );
+        virtual tiINT32                 GetDesiredChannel       ( tiUINT32* puDesiredChannel );
+        virtual tiINT32                 GetCurrentChannel       ( tiUINT32* puCurrentChannel );
+
+        virtual tiINT32                 GetDesiredRate          ( tiUINT32* puDesiredRates );
+        virtual tiINT32                 GetCurrentRate          ( tiUINT32* puCurrentRates );
+
+        virtual tiINT32                 SetFragmentThreshold    ( tiUINT32  uFragmentThreshold  );
+        virtual tiINT32                 GetFragmentThreshold    ( tiUINT32* puFragmentThreshold );
+
+        virtual tiINT32                 SetBSSType              ( OS_802_11_NETWORK_MODE  uBSSType );
+        virtual tiINT32                 GetBSSType              ( OS_802_11_NETWORK_MODE* puBSSType);
+
+        virtual tiINT32                 SetLongRetry            ( tiUINT32  uLongRetry  );
+        virtual tiINT32                 GetLongRetry            ( tiUINT32* puLongRetry );
+
+        virtual tiINT32                 SetRTSThreshold         ( tiUINT32  uRTSThreshold   );
+        virtual tiINT32                 GetRTSThreshold         ( tiUINT32* puRTSThreshold  );
+
+        virtual tiINT32                 SetShortPreamble        ( tiUINT32  uShortPreamble  );
+        virtual tiINT32                 GetShortPreamble        ( tiUINT32* puShortPreamble );
+
+        virtual tiINT32                 SetShortRetry           ( tiUINT32  uShortRetry     );
+        virtual tiINT32                 GetShortRetry           ( tiUINT32* puShortRetry    );
+
+        virtual tiINT32                 SetSSID                 ( tiUINT8*   pSSIDname );
+        virtual tiINT32                 GetDesiredSSID          ( OS_802_11_SSID*   pSSID );
+        virtual tiINT32                 GetCurrentSSID          ( OS_802_11_SSID*   pSSID );
+
+        virtual tiINT32                 GetStatistics           (TIWLN_STATISTICS* tiStatistics);
+        virtual tiINT32                 GetTxStatistics         (TIWLN_TX_STATISTICS* tiTxStatistics, UINT32 clearStatsFlag);
+               
+
+        virtual tiINT32                 EnableDisableRxDataFilters( tiBOOL enabled );
+        virtual tiINT32                 GetRxDataFiltersStatistics( TIWLAN_DATA_FILTER_STATISTICS * pStatistics );
+        virtual tiINT32                 AddRxDataFilter         ( TIWLAN_DATA_FILTER_REQUEST * pRequest );
+        virtual tiINT32                 RemoveRxDataFilter      ( TIWLAN_DATA_FILTER_REQUEST * pRequest );
+
+        virtual tiINT32                 SetSupportedRates       ( tiUINT8* pSupportedRatesLst, tiUINT32  uBufLength);
+        virtual tiINT32                 GetSupportedRates       ( tiUINT8* pSupportedRatesLst, tiUINT32  uBufLength);
+
+        virtual tiINT32                 GetDriverVersion        ( TIWLN_VERSION_EX* pdrvVersion );
+
+        virtual tiINT32                 SetIBSSProtection       ( tiUINT32  uProtection    );
+        virtual tiINT32                 GetIBSSProtection       ( tiUINT32* puProtection   );
+
+        virtual tiINT32                 GetDriverState          ( driverState_e* puDriverState );
+
+        virtual tiINT32                 SetShortSlot            ( tiUINT32  dwShortSlot );
+        virtual tiINT32                 GetShortSlot            ( tiUINT32* pdwShortSlot);
+
+        virtual tiINT32                 SetTxPowerDbm          ( tiUINT8  uTxPower   );
+        virtual tiINT32                 GetTxPowerLevel         ( tiCHAR* puTxPower  );
+        virtual tiINT32                 GetTxPowerDbm           ( tiCHAR* puTxPower  );
+
+        virtual tiINT32                 GetSupportedNetworkTypes( OS_802_11_NETWORK_TYPE* pNetTypeLst, tiUINT32 uMaxNetTypes    );
+        virtual tiINT32                 SetNetworkTypeInUse     ( OS_802_11_NETWORK_TYPE  uNetType                              );
+        virtual tiINT32                 GetNetworkTypeInUse     ( OS_802_11_NETWORK_TYPE* pdwNetType                            );  
+
+        virtual tiINT32                 GetNumberOfAntennas     ( tiUINT32* puNumberOfAntennas    );
+        virtual tiINT32                 SetAntennaDiversityParams( PTIWLAN_ANT_DIVERSITY pAntennaDiversityOptions );
+
+        virtual tiINT32                 Start                   ( );
+        virtual tiINT32                 Stop                    ( );
+        virtual tiINT32                 Suspend                 ( );
+        virtual tiINT32                 StartSM                 ( );
+        virtual tiINT32                 StopSM                  ( );
+
+        virtual tiINT32                 EnableDisable_802_11d   ( tiUINT8  enableDisable_802_11d );
+        virtual tiINT32                 EnableDisable_802_11h   ( tiUINT8  enableDisable_802_11h );
+        virtual tiINT32                 Get_802_11d             ( tiUINT8*  enableDisable_802_11d );
+        virtual tiINT32                 Get_802_11h             ( tiUINT8*  enableDisable_802_11h );
+        virtual tiINT32                 Set_countryIeFor2_4_Ghz ( country_t countryIe);
+        virtual tiINT32                 Get_countryIeFor2_4_Ghz ( tiUINT8 **countryString);
+        virtual tiINT32                 Set_countryIeFor5_Ghz    ( country_t countryIe);
+        virtual tiINT32                 Get_countryIeFor5_Ghz   ( tiUINT8 **countryString);
+        virtual tiINT32                 Set_minMaxDfsChannels   ( DFS_ChannelRange_t DFS_ChannelRange);
+        virtual tiINT32                 Get_minMaxDfsChannels   ( DFS_ChannelRange_t *DFS_ChannelRange);
+
+        virtual tiINT32                 GetRSSI                     ( tiINT32* pRssi );
+               virtual tiINT32                 GetSNR                      ( tiUINT32* pSnr );
+
+        virtual tiINT32                 Disassociate            ( );
+
+        virtual tiINT32                 SetAuthenticationMode   ( OS_802_11_AUTHENTICATION_MODE  uAuthenticationMode  );                          
+        virtual tiINT32                 GetAuthenticationMode   ( OS_802_11_AUTHENTICATION_MODE* puAuthenticationMode );
+
+        virtual tiINT32                 SetEAPType              ( OS_802_11_EAP_TYPES  uEAPType );
+        virtual tiINT32                 SetEAPTypeDriver        ( OS_802_11_EAP_TYPES  uEAPType );
+        virtual tiINT32                 GetEAPType              ( OS_802_11_EAP_TYPES* puEAPType);
+
+        virtual tiINT32                 SetEncryptionType       ( OS_802_11_ENCRYPTION_TYPES  uEncryptType  );
+        virtual tiINT32                 GetEncryptionType       ( OS_802_11_ENCRYPTION_TYPES* puEncryptType );
+
+        virtual tiINT32                 SetCredentials          ( tiCHAR* pszUserName, tiCHAR* pszPassword );
+        
+        virtual tiINT32                 SetPSK                  ( tiCHAR* pszPSK );
+        virtual tiINT32                 SetKeyType              ( OS_802_11_KEY_TYPES uKeyType );
+     /*   virtual tiINT32                 SetUserID               ( tiCHAR* pszUserID ); */
+        virtual tiINT32                 SetMixedMode            ( tiBOOL bStatus );
+        virtual tiINT32                 GetMixedMode            ( tiBOOL* pbStatus );
+
+        virtual tiINT32                 SetCertParamsSHA1       ( TI_SHA1_HASH* pSha1Hash, tiBOOL bValidateServerCert );
+        virtual tiINT32                 SetCertParamsFileName   ( tiCHAR* pszFileName,     tiBOOL bValidateServerCert );
+
+        virtual tiINT32                 AddWEPKey               ( OS_802_11_WEP*   pWEP             );
+        virtual tiINT32                 RemoveWEPKey            ( tiUINT32         uKeyIndex        ); 
+        virtual tiINT32                 GetDefaultWepKey        (tiUINT32* puKeyIndex );
+
+        virtual tiINT32                 AddKey                  ( OS_802_11_KEY*   pKey             );
+        virtual tiINT32                 RemoveKey               ( OS_802_11_REMOVE_KEY* pRemoveKey  ); 
+
+        virtual tiINT32                 SetPMKIDmap             ( OS_802_11_PMKID*          pPMKIDMap   );
+
+               virtual tiINT32                 ConfigPowerManagement   ( OS_802_11_POWER_PROFILE thePowerMgrProfile );
+
+        virtual tiINT32                 GetAssociationInfo      ( OS_802_11_ASSOCIATION_INFORMATION** ppInfo );
+
+        virtual tiINT32                 RegisterEvent           ( IPC_EVENT_PARAMS*  pEventParams );
+        virtual tiINT32                 UnRegisterEvent         ( IPC_EVENT_PARAMS* pEventParams );
+        /*virtual tiINT32                 UnRegisterEvent         ( tiINT32 iRegisterID );*/
+        
+        virtual tiINT32                 StartScan               ( scan_Params_t *pScanParams );
+        virtual tiINT32                 StopScan                ( );
+        virtual tiINT32                 SetScanPolicy           ( UINT8* buffer, UINT16 bufferLength );
+        virtual tiINT32                 GetScanBssList          ( bssList_t* bssList );
+
+        virtual tiINT32                        PollApPackets           ( );
+        virtual tiINT32                        PollApPacketsFromAC         ( tiUINT32 AC );
+
+        virtual tiINT32                        SetDTagToAcMappingTable ( acTrfcType_e* pDtagToAcTable );
+        virtual tiINT32                        SetVAD ( txDataVadTimerParams_t* pVadTimer );
+        virtual tiINT32                        GetVAD ( txDataVadTimerParams_t* pVadTimer );
+
+        virtual tiINT32                        SetQosParameters        ( OS_802_11_QOS_PARAMS* pQosParams );
+               virtual tiINT32                 SetRxTimeOut            ( OS_802_11_QOS_RX_TIMEOUT_PARAMS* pRxTimeOut );
+
+
+               virtual tiINT32                                 GetAPQosParameters                      ( OS_802_11_AC_QOS_PARAMS* pACQosParams);
+        virtual tiINT32                                        GetAPQosCapabilitesParameters ( OS_802_11_AP_QOS_CAPABILITIES_PARAMS* pAPQosCapabiltiesParams);
+               virtual tiINT32                                 AddTspec                                        ( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams);
+               virtual tiINT32                                 GetTspecParameters                      ( OS_802_11_QOS_TSPEC_PARAMS* pTspecParams);
+               virtual tiINT32                                 DeleteTspec                                     ( OS_802_11_QOS_DELETE_TSPEC_PARAMS* pDelTspecParams);
+               virtual tiINT32                                 GetCurrentACStatus              ( OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams);
+               virtual tiINT32                                 SetMediumUsageThreshold         ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+               virtual tiINT32                                 SetPhyRateThreshold                     ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+        virtual        tiINT32                                 GetMediumUsageThreshold         ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+               virtual tiINT32                                 GetPhyRateThreshold                     ( OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams);
+               virtual tiINT32                                 GetDesiredPsMode                        ( OS_802_11_QOS_DESIRED_PS_MODE* pDesiredPsMode);
+
+        virtual tiINT32                 GetUserPriorityOfStream     ( STREAM_TRAFFIC_PROPERTIES* streamProperties);
+
+        virtual tiINT32                 ConfigTxClassifier      ( tiUINT32 inParamsBuffLen, tiUINT8  *pInParamsBuff);
+        virtual tiINT32                        RemoveClassifierEntry   ( clsfr_tableEntry_t *pClsfrEntry );
+        virtual tiINT32                 GetClsfrType            ( clsfrTypeAndSupport *currClsfrType );
+
+               virtual tiINT32                         GetDriverCapabilities   ( OS_802_11_DRIVER_CAPABILITIES* pDriverCapabilities );
+        virtual tiINT32                        GetSelectedBSSIDInfo    ( OS_802_11_BSSID_EX  *pSelectedBSSIDInfo);
+        virtual tiINT32                        GetPrimaryBSSIDInfo     ( OS_802_11_BSSID_EX  *pSelectedBSSIDInfo);
+
+        virtual        tiINT32                                 SetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds);
+        virtual        tiINT32                                 GetTrafficIntensityThresholds ( OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds);
+        virtual tiINT32                 ToggleTrafficIntensityEvents ( tiUINT32 NewStatus );
+
+        virtual tiINT32                 Set4XState              ( tiBOOL    bStatus     );
+        virtual tiINT32                 Get4XState              ( tiBOOL*   lpbStatus   ); 
+
+        virtual tiINT32                 SetRSSITrigger          ( tiBOOL    bRSSItr                 );
+        virtual tiINT32                 GetRSSITrigger          ( tiBOOL*   pbRSSItr                );
+
+        virtual tiINT32                 SetWEPStatus            ( tiUINT32  dwWEPStatus     );
+        virtual tiINT32                 GetWEPStatus            ( tiUINT32* pdwWEPStatus    );
+
+        virtual tiINT32                 SetConfiguration        ( OS_802_11_CONFIGURATION*   pConfiguration );
+        virtual tiINT32                 GetConfiguration        ( OS_802_11_CONFIGURATION*   pConfiguration );
+
+        virtual tiINT32                 SetPrivacyFilter        ( tiUINT32  dwPrivacyFilter  );
+        virtual tiINT32                 GetPrivacyFilter        ( tiUINT32* pdwPrivacyFilter );
+
+        virtual tiINT32                 SetExtRatesIE           ( tiUINT32  dwExtRatesIE    );
+        virtual tiINT32                 GetExtRatesIE           ( tiUINT32* pdwExtRatesIE   );
+
+        virtual tiINT32                 SetEarlyWakeupMode      ( tiUINT8  dwEarlyWakeup);
+        virtual tiINT32                 GetEarlyWakeupMode      ( tiUINT8* dwEarlyWakeup);
+
+        virtual tiINT32                 hwReadRegister          ( tiUINT32  dwRegisterAddr, tiUINT32* pdwValue );
+        virtual tiINT32                 hwWriteRegister         ( tiUINT32  dwRegisterAddr, tiUINT32  dwValue  );
+
+        virtual tiINT32                 ReloadDefaults          ( );
+        virtual tiINT32                 IsDriverLoaded          ( );
+
+               virtual tiINT32                 SetBtCoeEnable          ( tiUINT32 uModeEnable);
+               virtual tiINT32                 SetBtCoeRate            ( tiUINT8 *pRate);
+               virtual tiINT32                 SetBtCoeConfig          ( tiUINT32 *pConfig);
+               virtual tiINT32                 SetBtCoeGetStatus       ( tiUINT32 *pStatus);
+
+#ifdef TI_DBG
+        virtual tiINT32                 GetDebugBuffer          ( tiUINT8*  pBuffer, tiUINT32  dwLenght  );
+        
+        virtual tiINT32                 SetReportModule         ( tiUINT8* pData );
+        virtual tiINT32                 GetReportModule         ( tiUINT8* pData );    
+
+        virtual tiINT32                 SetReportSeverity       ( tiUINT8* pData );
+        virtual tiINT32                 GetReportSeverity       ( tiUINT8* pData );
+
+        virtual tiINT32                 SetOsDbgState           ( tiUINT32 uData );
+        virtual tiINT32                 GetOsDbgState           ( tiUINT32* puData );    
+
+               virtual tiINT32                 SetReportPPMode        ( tiUINT32  uData );
+
+        virtual tiINT32                 DisplayStats            ( tiUINT8*  puDbgBuffer, tiUINT32 uBuffSize);
+
+#ifdef DRIVER_PROFILING
+               virtual tiINT32                                 ProfileReport                   ();
+               virtual tiINT32                                 CpuEstimatorCommand             (tiUINT8 uType, tiUINT32 uData);
+#endif
+
+
+#endif
+        virtual tiINT32                 SetWPAOptions           ( tiUINT32      fWPA_options);
+        virtual tiINT32                 GetWPAOptions( tiUINT32 * fWPA_options);
+        
+        virtual tiINT32                 GetRegDomainTable       ( TIWLN_REGDOMAINS*     pRegDomainTable );
+        virtual tiINT32                 GetMediumUsage          ( TIWLN_MEDIUM_USAGE*   pMediumUsage    );
+
+        virtual tiINT32                 SetPowerMode                ( OS_802_11_POWER_PROFILE  uPower              );
+        virtual tiINT32                 GetPowerMode                ( OS_802_11_POWER_PROFILE* puPower             );
+               
+           virtual tiINT32                 SetPowerLevelPS             (OS_802_11_POWER_LEVELS  uPower);
+           virtual tiINT32                 GetPowerLevelPS             (OS_802_11_POWER_LEVELS* puPower);
+                                        
+           virtual tiINT32                 SetPowerLevelDefault        (OS_802_11_POWER_LEVELS  uPower);
+           virtual tiINT32                 GetPowerLevelDefault        (OS_802_11_POWER_LEVELS* puPower);
+                                        
+           virtual tiINT32                 SetPowerLevelDozeMode       (OS_802_11_POWER_PROFILE  uPower);
+           virtual tiINT32                 GetPowerLevelDozeMode       (OS_802_11_POWER_PROFILE* puPower);
+
+        
+           virtual tiINT32                 SetBeaconFilterDesiredState ( OS_802_11_BEACON_FILTER_MODE   uBeaconFilterMode);
+           virtual tiINT32                 GetBeaconFilterDesiredState ( tiUINT8*   pBeaconFilterMode);
+
+
+        virtual tiINT32                 IsDriverRun                 ( tiBOOL* pbStatus );
+               virtual tiINT32                 GWSICommand                 ( tiUINT32* pbStatus );
+               virtual tiINT32                 GWSIInitialize              ( tiUINT32* pbStatus );
+               virtual tiINT32                 GWSIConfig                  ( tiUINT32* pbStatus );
+               virtual tiINT32                 GWSIRelease                 ( tiUINT32* pbStatus );
+                                                                       
+               virtual tiINT32                                 GWSIGetInitTable                ( tiUINT32* pGWSICommand );
+                                                                    
+        virtual tiINT32                 Open_EAPOL_Interface        ( );
+        virtual tiINT32                 Close_EAPOL_Interface       ( );
+        virtual tiINT32                 Send_EAPOL_Packet           ( tiVOID* pData, tiUINT32 uSize );
+                                                                    
+               tiINT32                                 GetVariableLengthOID        ( tiUINT32  uOID, tiVOID** pp, tiUINT32* pnSize, tiUINT32 nNextAllocation = 0);
+                                                                    
+               virtual tiINT32                 Set_RoamingConfParams       ( UINT8* buffer, UINT16 bufferLength);
+               virtual tiINT32                 Get_RoamingConfParams       ( UINT8* buffer, UINT16 bufferLength);
+                                                                    
+        virtual tiINT32                 GetPowerConsumptionStatistics(PowerConsumptionTimeStat_t * pStatistics);
+                                        
+               /*PLT                                                       */
+               virtual tiINT32                                 PLT_ReadRegister                    ( UINT32 uRegisterAddr, PUINT32 uRegisterData );
+               virtual tiINT32                                 PLT_WriteRegister                   ( UINT32 uRegisterAddr, UINT32 uRegisterData );
+               virtual tiINT32                                 PLT_RxPerStart                      ();
+               virtual tiINT32                                 PLT_RxPerStop                       ();
+               virtual tiINT32                                 PLT_RxPerClear                      ();
+               virtual tiINT32                                 PLT_RxPerGetResults                 ( PltRxPer_t* pPltRxPer );
+               virtual tiINT32                                 PLT_TxCW                                    ( TestCmdChannelBand_t* pPltTxCW);
+               virtual tiINT32                                 PLT_TxContiues                      ( PltTxContinues_t* pPltTxContinues);
+               virtual tiINT32                                 PLT_TxStop                          ();
+               virtual tiINT32                                 PLT_ReadMIB                                 ( PLT_MIB_t* pMib );
+               virtual tiINT32                                 PLT_WriteMIB                        ( PLT_MIB_t* pMib );
+           virtual tiINT32                         PLT_TxCalGainGet                (PltGainGet_t* pPLTGainGet);
+           virtual tiINT32                         PLT_TxCalGainAdjust         (tiINT32   uTxGainChange);
+               virtual tiINT32                     PLT_TxCalStart                  (PltTxCalibrationRequest_t* pPLTTxCal);
+        virtual tiINT32                            PLT_TxCalStop                   ();
+           virtual tiINT32                         PLT_RxTxCalNVSUpdateBuffer  (PltNvsResultsBuffer_t* pPLT_NVSUpdateBuffer);
+           virtual tiINT32                         PLT_RxCal                   (PltRxCalibrationRequest_t* pPltRxCalibration_t);
+        virtual tiINT32                 PLT_RadioTune               (TestCmdChannelBand_t* pChannelBand);
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+        EXC_MODULE_SUPPORT_H
+};
+#endif /* !defined(AFX_CTI_WLAN_ADAPTER_H__3B4F299B_AF52_40DE_BE67_A032DA1FB441__INCLUDED_)*/
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/CommonAdapter.h b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/CommonAdapter.h
new file mode 100644 (file)
index 0000000..9f1e78b
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+#ifndef _COMMON_ADAPTER_H
+#define _COMMON_ADAPTER_H
+
+#if defined(_WINDOWS)
+#else
+#include <stdlib.h>
+#define _UTIL_ADAPTER
+#endif /*_WINDOWS*/
+
+#include <stdio.h>
+#include "tiwlnif.h"
+
+#include "tiioctl.h"
+
+#include "osTIType.h"
+#include "osDot11.h"
+#include "public_commands.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "TI_AdapterEXC.h"
+#include "osDot11Exc.h"
+#endif /*EXC_MODULE_INCLUDED */
+
+#include "TI_IPC_Api.h"
+#include "TI_Results.h"
+#include "TI_OAL.h"
+
+#include "TI_AdapterApiC.h"
+#include "TI_AdapterApiCpp.h"
+#include "CTI_Adapter.h"
+
+#endif /* _COMMON_ADAPTER_H*/
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/Makefile b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/Makefile
new file mode 100644 (file)
index 0000000..a1acf8c
--- /dev/null
@@ -0,0 +1,145 @@
+DEBUG ?= y
+STATIC_LIB ?= y
+EXC ?= n
+SG ?= n
+DRIVER_PROFILING ?= n
+
+OUTPUT_DIR ?= ../Output
+
+LIB_NAME = libtiOsLib
+
+ifeq ($(CUDK_ROOT), "")
+       CUDK_ROOT = ..
+endif
+
+ifeq ($(DEBUG),y)
+  DEBUGFLAGS = -O0 -g -fno-builtin -DDEBUG -D TI_DBG  # "-O" is needed to expand inlines
+else
+  DEBUGFLAGS = -O2
+endif
+DEBUGFLAGS+= -DHOST_COMPILE
+
+
+ifeq ($(STATIC_LIB),y)
+       TARGET = $(OUTPUT_DIR)/$(LIB_NAME).a
+else
+       TARGET = $(OUTPUT_DIR)/$(LIB_NAME).so
+endif
+
+CUDK_ROOT ?= ..
+IPC_DIR = $(CUDK_ROOT)/IPC
+OAL_DIR = $(CUDK_ROOT)/OAL
+CROSS_COMPILE ?= arm_v4t_le-
+
+SRCS = $(OAL_DIR)/Common/TI_OAL.cpp \
+       $(OAL_DIR)/Pform/Linux/TILibLinux.cpp \
+       $(CUDK_ROOT)/UtilityAdapter/Linux/IpcWithTISMLinux.cpp \
+       $(CUDK_ROOT)/UtilityAdapter/TI_AdapterApi.cpp \
+       $(CUDK_ROOT)/UtilityAdapter/TI_Adapter.cpp \
+       $(CUDK_ROOT)/UtilityAdapter/CTI_Adapter.cpp \
+       $(CUDK_ROOT)/UtilityAdapter/TI_IPC_Suppl.cpp \
+       $(IPC_DIR)/Linux/ipc_event.c \
+       $(IPC_DIR)/Linux/cu_ipc.c \
+       $(IPC_DIR)/Linux/ipc_user.c
+
+ifeq ($(EXC), y)
+SRCS += $(CUDK_ROOT)/UtilityAdapter/EXC/CTI_AdapterEXC.cpp \
+        $(CUDK_ROOT)/UtilityAdapter/EXC/TI_AdapterApiEXC.cpp
+
+CFLAGS := -D EXC_MODULE_INCLUDED
+endif
+
+ifeq ($(SG), y)
+CFLAGS += -D BTH_COEXISTENCE
+endif
+
+ifeq ($(DRIVER_PROFILING),y)
+   CFLAGS += -D DRIVER_PROFILING
+endif
+
+#ARMFLAGS  = -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -Uarm -fno-common -pipe
+#ARMFLAGS += -mapcs -mno-sched-prolog -mapcs-32 -D__LINUX_ARM_ARCH__=4 -march=armv4
+#ARMFLAGS += -mtune=arm9tdmi -mshort-load-bytes -msoft-float  -iwithprefix include
+
+ARMFLAGS  = -fno-common -pipe
+
+
+INCLUDEDIR = -I $(CUDK_ROOT)/Inc \
+       -I $(CUDK_ROOT)/OAL/Common \
+       -I $(CUDK_ROOT)/UtilityAdapter \
+       -I $(CUDK_ROOT)/../common/inc \
+       -I $(CUDK_ROOT)/../common/src/hal/FirmwareApi \
+       -I $(CUDK_ROOT)/TISMgr \
+       -I $(CUDK_ROOT)/../pform/linux/inc \
+       -I $(CUDK_ROOT)/../pform/common/inc \
+       -I $(CUDK_ROOT)/IPC/Linux \
+       -I $(CUDK_ROOT)/CLI \
+       -I $(CUDK_ROOT)/CLI/drv_inc \
+       -I $(CUDK_ROOT)/CLI/pform_inc
+
+ifeq ($(EXC),y)
+        INCLUDEDIR += \
+        -I $(CUDK_ROOT)/../common/inc/EXC \
+        -I $(CUDK_ROOT)/Inc/EXC
+endif
+       
+       
+       
+
+CFLAGS += -Wall -D__LINUX__ -D_IPC_SUPPL -DTI_EMBEDDED_SUPPLICANT
+CFLAGS += $(DEBUGFLAGS)
+CFLAGS += $(INCLUDEDIR) $(ARMFLAGS)
+
+OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SRCS)))
+
+DEPS = $(OBJS:%.o=%.d)
+
+all: $(TARGET)
+
+$(OUTPUT_DIR)/libtiOsLib.a: $(OBJS)
+       rm -f $@
+       $(CROSS_COMPILE)$(AR) -q $@ $^
+
+$(OUTPUT_DIR)/libtiOsLib.so: $(OBJS)
+       rm -f $@
+       $(CROSS_COMPILE)gcc -shared $(CFLAGS) $(OBJS) -lc -o $@
+       $(CROSS_COMPILE)strip $@
+
+ifeq ($(findstring "clean", $(MAKECMDGOALS)), "")
+-include .depend
+endif
+
+%.o: %.cpp
+       @echo $@
+       @$(CROSS_COMPILE)gcc -c $(CFLAGS) $< -o $@
+
+%.o: %.c
+       @echo $@
+       @$(CROSS_COMPILE)gcc -c $(CFLAGS) $< -o $@
+
+%.i: %.cpp %.c
+       $(CROSS_COMPILE)gcc -E -v -c $(CFLAGS) $< -o $@
+
+%.s: %.cpp %.c
+       $(CROSS_COMPILE)gcc -save-temps -c $(CFLAGS) $< -o $@
+
+%.d: %.cpp
+       @echo $@
+       @$(CROSS_COMPILE)gcc $< -MT$(^:%.cpp=%.o) -M $(CFLAGS) > $@
+
+%.d: %.c
+       @echo $@
+       @$(CROSS_COMPILE)gcc $< -MT$(^:%.c=%.o) -M $(CFLAGS) > $@
+
+.depend: $(DEPS)
+       rm -f $@
+       for aa in $^; do cat $$aa >> $@; done
+
+clean:
+       @rm -f .depend $(OBJS) $(DEPS) $(OUTPUT_DIR)/libtiOsLib.a $(OUTPUT_DIR)/libtiOsLib.so
+
+TAGS: $(SRCS)
+       { find ${BASE_DIR}/common -name '*.h' -print ; \
+         find ${BASE_DIR}/Test -name '*.h' -print ; \
+         find . -name '*.h' -print ; } | etags -
+         etags -a $(SRCS)
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/TI_Adapter.cpp b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/TI_Adapter.cpp
new file mode 100644 (file)
index 0000000..6ae425d
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+//--------------------------------------------------------------------------
+// Module:             TI_Adapter.cpp
+//
+// Purpose:            
+//
+//--------------------------------------------------------------------------
+
+#include "CommonAdapter.h"
+#ifdef _WINDOWS
+#endif
+
+tiBOOL TI_CheckAdapterObject(void *pObj)
+{
+    tiBOOL bRes = FALSE;
+    
+    TI_OAL*  pOSLib = TI_OAL::GetInstance();
+    if (pOSLib)
+        bRes = !(pOSLib->TIIsBadWritePtr(pObj, sizeof(CTI_WLAN_AdapterAPI)));
+
+    TI_OAL::FreeInstance();
+
+    return bRes;
+}
+
+TI_WLAN_AdapterAPI* TI_AdapterCppInit(tiCHAR* pszDeviceName, tiBOOL bForce )
+{
+    return CTI_WLAN_AdapterAPI::GetTIWLANAdapter(pszDeviceName, bForce);
+}
+
+tiINT32 TI_AdapterCppDeinit( TI_WLAN_AdapterAPI* pAdapter, tiBOOL bForce )
+{
+    return CTI_WLAN_AdapterAPI::FreeTIWLANAdapter((CTI_WLAN_AdapterAPI*)pAdapter, bForce);
+}
+
diff --git a/sta_dk_4_0_4_32/CUDK/UtilityAdapter/TI_AdapterApi.cpp b/sta_dk_4_0_4_32/CUDK/UtilityAdapter/TI_AdapterApi.cpp
new file mode 100644 (file)
index 0000000..e819af7
--- /dev/null
@@ -0,0 +1,1698 @@
+/*******************************************************************************
+**+--------------------------------------------------------------------------+**
+**|                                                                          |**
+**| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
+**|                                                                          |**
+**| Licensed under the Apache License, Version 2.0 (the "License");          |**
+**| you may not use this file except in compliance with the License.         |**
+**| You may obtain a copy of the License at                                  |**
+**|                                                                          |**
+**|     http://www.apache.org/licenses/LICENSE-2.0                           |**
+**|                                                                          |**
+**| Unless required by applicable law or agreed to in writing, software      |**
+**| distributed under the License is distributed on an "AS IS" BASIS,        |**
+**| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
+**| See the License for the specific language governing permissions and      |**
+**| limitations under the License.                                           |**
+**|                                                                          |**
+**+--------------------------------------------------------------------------+**
+*******************************************************************************/
+
+//--------------------------------------------------------------------------
+// Module:             TI_AdapterApi.cpp
+//
+// Purpose:            C interface implementation
+//
+//--------------------------------------------------------------------------
+
+#include "CommonAdapter.h"
+#ifdef _WINDOWS
+#endif
+
+tiBOOL TI_CheckAdapterObject(void *pObj);
+
+/********************************************************************/
+tiINT32      
+TI_GetStatistics(TI_HANDLE hAdapter, TIWLN_STATISTICS* pStatistics)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetStatistics(pStatistics);
+}
+/********************************************************************/
+tiINT32      
+TI_GetTxStatistics(TI_HANDLE hAdapter, TIWLN_TX_STATISTICS* pTxStatistics, UINT32 clearStatsFlag)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetTxStatistics(pTxStatistics, clearStatsFlag);
+}
+/********************************************************************/
+tiINT32
+TI_EnableDisableRxDataFilters(TI_HANDLE hAdapter, tiBOOL enabled)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->EnableDisableRxDataFilters(enabled);
+}
+/********************************************************************/
+tiINT32
+TI_GetRxDataFiltersStatistics(TI_HANDLE hAdapter, TIWLAN_DATA_FILTER_STATISTICS * pStatistics)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetRxDataFiltersStatistics(pStatistics);
+}
+/********************************************************************/
+tiINT32
+TI_GetPowerConsumptionStatistics(TI_HANDLE hAdapter, PowerConsumptionTimeStat_t * pStatistics)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPowerConsumptionStatistics(pStatistics);
+                                              
+}
+/********************************************************************/
+tiINT32
+TI_AddRxDataFilter(TI_HANDLE hAdapter, TIWLAN_DATA_FILTER_REQUEST * pRequest)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->AddRxDataFilter(pRequest);
+}
+/********************************************************************/
+tiINT32
+TI_RemoveRxDataFilter(TI_HANDLE hAdapter, TIWLAN_DATA_FILTER_REQUEST * pRequest)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->RemoveRxDataFilter(pRequest);
+}
+/********************************************************************/
+//returns RSSI
+tiINT32      
+TI_GetRSSI(TI_HANDLE hAdapter, tiINT32* pRssi)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetRSSI(pRssi);
+}
+
+
+/********************************************************************/
+//returns SNR
+tiINT32      
+TI_GetSNR(TI_HANDLE hAdapter, tiUINT32* pSnr)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetSNR(pSnr);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetDTagToAcMappingTable(TI_HANDLE  hAdapter, acTrfcType_e* pDtagToAcTable )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetDTagToAcMappingTable(pDtagToAcTable);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetVAD(TI_HANDLE  hAdapter, txDataVadTimerParams_t* pVadTimer )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetVAD(pVadTimer);
+}
+
+/********************************************************************/
+tiINT32      
+TI_GetVAD(TI_HANDLE  hAdapter, txDataVadTimerParams_t* pVadTimer )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetVAD(pVadTimer);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetQosParameters(TI_HANDLE  hAdapter, OS_802_11_QOS_PARAMS* pQosParams )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetQosParameters(pQosParams);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetQosRxTimeOut(TI_HANDLE  hAdapter, OS_802_11_QOS_RX_TIMEOUT_PARAMS* pRxTimeOut )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetRxTimeOut(pRxTimeOut);
+}
+
+/********************************************************************/
+tiINT32      
+TI_GetAPQosParameters(TI_HANDLE  hAdapter, OS_802_11_AC_QOS_PARAMS* pACQosParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetAPQosParameters(pACQosParams);
+}
+/********************************************************************/
+tiINT32      
+TI_GetAPQosCapabilitesParameters(TI_HANDLE  hAdapter, OS_802_11_AP_QOS_CAPABILITIES_PARAMS* pAPQosCapabiltiesParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetAPQosCapabilitesParameters(pAPQosCapabiltiesParams);
+}
+/********************************************************************/
+tiINT32      
+TI_AddTspec    (TI_HANDLE  hAdapter, OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->AddTspec(pTspecParams);
+}
+/********************************************************************/
+tiINT32      
+TI_GetTspecParameters(TI_HANDLE  hAdapter, OS_802_11_QOS_TSPEC_PARAMS* pTspecParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetTspecParameters(pTspecParams);
+}
+/********************************************************************/
+tiINT32      
+TI_DeleteTspec(TI_HANDLE  hAdapter, OS_802_11_QOS_DELETE_TSPEC_PARAMS* pDelTspecParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->DeleteTspec(pDelTspecParams);
+}
+/********************************************************************/
+tiINT32      
+TI_GetCurrentACStatus(TI_HANDLE  hAdapter, OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetCurrentACStatus(pAcStatusParams);
+}
+/********************************************************************/
+tiINT32      
+TI_SetMediumUsageThreshold(TI_HANDLE  hAdapter, OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetMediumUsageThreshold(pThresholdCrossParams);
+}
+/********************************************************************/
+tiINT32      
+TI_SetPhyRateThreshold(TI_HANDLE  hAdapter, OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPhyRateThreshold(pThresholdCrossParams);
+}
+/********************************************************************/
+tiINT32      
+TI_GetMediumUsageThreshold(TI_HANDLE  hAdapter, OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetMediumUsageThreshold(pThresholdCrossParams);
+}
+/********************************************************************/
+tiINT32      
+TI_GetPhyRateThreshold(TI_HANDLE  hAdapter, OS_802_11_THRESHOLD_CROSS_PARAMS* pThresholdCrossParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPhyRateThreshold(pThresholdCrossParams);
+}
+/********************************************************************/
+tiINT32            
+TI_PollApPackets(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PollApPackets();
+}
+/********************************************************************/
+tiINT32     
+TI_PollApPacketsFromAC(TI_HANDLE  hAdapter, tiUINT32 AC)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PollApPacketsFromAC(AC);
+}
+/********************************************************************/
+tiINT32
+TI_SetTrafficIntensityThresholds (TI_HANDLE  hAdapter, OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetTrafficIntensityThresholds(pTrafficThresholds);
+}
+/********************************************************************/
+tiINT32
+TI_GetTrafficIntensityThresholds (TI_HANDLE  hAdapter, OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS* pTrafficThresholds)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetTrafficIntensityThresholds(pTrafficThresholds);
+}
+/********************************************************************/
+tiINT32
+TI_ToggleTrafficIntensityEvents (TI_HANDLE  hAdapter, tiUINT32 NewStatus )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->ToggleTrafficIntensityEvents(NewStatus);
+}
+/********************************************************************/
+tiINT32     
+TI_GetBSSIDList(TI_HANDLE  hAdapter, OS_802_11_BSSID_LIST_EX** ppBSSIDlist)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetBSSIDList(ppBSSIDlist);
+}
+/********************************************************************/
+tiINT32     
+TI_GetFullBSSIDList(TI_HANDLE  hAdapter, OS_802_11_BSSID_LIST_EX** ppBSSIDlist)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetFullBSSIDList(ppBSSIDlist);
+}
+
+/********************************************************************/
+tiINT32      
+TI_GetCurrentSSID(TI_HANDLE  hAdapter, OS_802_11_SSID* pSSID)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetCurrentSSID(pSSID);
+}
+/********************************************************************/
+tiINT32      
+TI_GetCurrentRate(TI_HANDLE  hAdapter, tiUINT32*  puCurrentRate)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetCurrentRate(puCurrentRate);
+}
+/********************************************************************/
+tiINT32      
+TI_GetCurrentAddress(TI_HANDLE  hAdapter, OS_802_11_MAC_ADDRESS*    pCurrentAddr)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetCurrentAddress(pCurrentAddr);
+}
+/********************************************************************/
+tiINT32      
+TI_GetDesiredSSID(TI_HANDLE  hAdapter, OS_802_11_SSID* pSSID)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDesiredSSID(pSSID);
+}
+/********************************************************************/
+tiINT32      
+TI_SetSSID(TI_HANDLE hAdapter, tiUINT8* pSSIDname)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetSSID(pSSIDname);
+}
+/********************************************************************/
+tiINT32 
+TI_SetBSSType(TI_HANDLE hAdapter, OS_802_11_NETWORK_MODE uBSSType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBSSType(uBSSType);
+}
+/********************************************************************/
+tiINT32      
+TI_GetBSSType(TI_HANDLE hAdapter, OS_802_11_NETWORK_MODE* puBSSType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetBSSType(puBSSType);
+}
+/********************************************************************/
+tiINT32      
+TI_SetEAPType(TI_HANDLE hAdapter, OS_802_11_EAP_TYPES uEAPType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetEAPType(uEAPType);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetEAPTypeDriver(TI_HANDLE hAdapter, OS_802_11_EAP_TYPES uEAPType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetEAPTypeDriver(uEAPType);
+}
+
+/********************************************************************/
+tiINT32      
+TI_GetEAPType(TI_HANDLE hAdapter, OS_802_11_EAP_TYPES* puEAPType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetEAPType(puEAPType);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetEncryptionType(TI_HANDLE hAdapter, OS_802_11_ENCRYPTION_TYPES uEncryptType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetEncryptionType(uEncryptType);
+}
+/********************************************************************/
+tiINT32      
+TI_GetEncryptionType(TI_HANDLE hAdapter, OS_802_11_ENCRYPTION_TYPES* puEncryptType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetEncryptionType(puEncryptType);
+}
+/********************************************************************/
+tiINT32     
+TI_SetCredentials(TI_HANDLE  hAdapter, tiCHAR* pszUserName, tiCHAR* pszPassword )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetCredentials( pszUserName, pszPassword );
+}
+/********************************************************************
+Sets the PSK password phrase for WPA encryption.
+Parameters:
+    hAdapter        -   The handle to the Adapter object returned 
+                        by TI_AdapterInit 
+    pszPSK          -   A null-terminated string that contains the 
+                        PSK password phrase
+********************************************************************/
+tiINT32     
+TI_SetPSK(TI_HANDLE  hAdapter, tiCHAR* pszPSK )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPSK( pszPSK);
+}                                   
+
+/********************************************************************/
+tiINT32     
+TI_SetCertificateParameters(TI_HANDLE  hAdapter, tiVOID* pData, tiBOOL bValidateServerCert )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+#ifdef _WINDOWS
+#else
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetCertParamsFileName((tiCHAR*) pData, bValidateServerCert);
+#endif
+}
+/********************************************************************/
+tiINT32      
+TI_SetTxPowerDbm(TI_HANDLE hAdapter, tiUINT8 uTxPower)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetTxPowerDbm(uTxPower);
+}
+/********************************************************************/
+tiINT32      
+TI_GetTxPowerLevel(TI_HANDLE hAdapter, tiCHAR* puTxPower)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetTxPowerLevel(puTxPower);
+}
+
+/********************************************************************/
+tiINT32      
+TI_GetTxPowerDbm(TI_HANDLE hAdapter, tiCHAR* puTxPower)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetTxPowerDbm(puTxPower);
+}
+
+/********************************************************************/
+tiINT32
+TI_Set4XState(TI_HANDLE hAdapter, tiBOOL bStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Set4XState(bStatus);
+}
+/********************************************************************/
+tiINT32      
+TI_Get4XState(TI_HANDLE hAdapter, tiBOOL* pbStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get4XState(pbStatus);
+}
+
+/********************************************************************/
+tiINT32      
+TI_GetDesiredRate(TI_HANDLE hAdapter, tiUINT32* puDesiredRates)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDesiredRate(puDesiredRates);
+}
+/********************************************************************/
+tiINT32      
+TI_SetFragmentThreshold(TI_HANDLE hAdapter, tiUINT32 uFragmentThreshold)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetFragmentThreshold(uFragmentThreshold);
+}
+/********************************************************************/
+tiINT32
+TI_GetFragmentThreshold(TI_HANDLE hAdapter, tiUINT32* puFragmentThreshold)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetFragmentThreshold(puFragmentThreshold);
+}
+/********************************************************************/
+tiINT32      
+TI_SetRTSThreshold(TI_HANDLE  hAdapter, tiUINT32 uRTSThreshold)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetRTSThreshold(uRTSThreshold);
+}
+/********************************************************************/
+tiINT32      
+TI_GetRTSThreshold(TI_HANDLE hAdapter, tiUINT32* puRTSThreshold)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetRTSThreshold(puRTSThreshold);
+}
+/********************************************************************/
+tiINT32      
+TI_SetShortPreamble(TI_HANDLE hAdapter, tiUINT32 uShortPreamble)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetShortPreamble(uShortPreamble);
+}
+/********************************************************************/
+tiINT32      
+TI_GetShortPreamble(TI_HANDLE  hAdapter, tiUINT32* puShortPreamble)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetShortPreamble(puShortPreamble);
+}
+/********************************************************************/
+tiINT32      
+TI_SetShortRetry(TI_HANDLE  hAdapter,tiUINT32 uShortRetry)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetShortRetry(uShortRetry);
+}
+/********************************************************************/
+tiINT32
+TI_GetShortRetry(TI_HANDLE hAdapter, tiUINT32* puShortRetry )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetShortRetry(puShortRetry);
+}
+/********************************************************************/
+tiINT32      
+TI_SetLongRetry(TI_HANDLE hAdapter, tiUINT32 uLongRetry)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetLongRetry(uLongRetry);
+}
+/********************************************************************/
+tiINT32      
+TI_GetLongRetry(TI_HANDLE hAdapter, tiUINT32* puLongRetry)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetLongRetry(puLongRetry);
+}
+/********************************************************************/
+tiINT32
+TI_GetSupportedNetworkTypes(TI_HANDLE hAdapter, OS_802_11_NETWORK_TYPE* pNetTypeLst, tiUINT32 uMaxNetTypes)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetSupportedNetworkTypes(pNetTypeLst, uMaxNetTypes);
+}
+/********************************************************************/
+tiINT32      
+TI_SetNetworkTypeInUse(TI_HANDLE  hAdapter, OS_802_11_NETWORK_TYPE uNetType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetNetworkTypeInUse(uNetType);
+}
+/********************************************************************/
+tiINT32      
+TI_GetNetworkTypeInUse(TI_HANDLE  hAdapter, OS_802_11_NETWORK_TYPE* puNetType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetNetworkTypeInUse(puNetType);
+}
+/********************************************************************/
+tiINT32           
+TI_SetKeyType(TI_HANDLE hAdapter, OS_802_11_KEY_TYPES uKeyType )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetKeyType(uKeyType);
+}
+/********************************************************************/
+tiINT32           
+TI_SetMixedMode(TI_HANDLE  hAdapter,tiBOOL  bStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetMixedMode(bStatus);
+}
+/********************************************************************/
+tiINT32
+TI_GetMixedMode(TI_HANDLE  hAdapter, tiBOOL* pbStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetMixedMode(pbStatus);
+}
+/********************************************************************/
+tiINT32      
+TI_GetBSSID(TI_HANDLE  hAdapter,OS_802_11_MAC_ADDRESS* pAddrBSSID)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetBSSID(pAddrBSSID);
+}
+/********************************************************************/
+tiINT32 
+TI_SetBSSID(TI_HANDLE  hAdapter,OS_802_11_MAC_ADDRESS* pAddrBSSID)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBSSID(pAddrBSSID);
+}
+
+/********************************************************************/
+tiINT32
+TI_SetRSSITrigger(TI_HANDLE  hAdapter,tiBOOL  bRSSItr)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetRSSITrigger(bRSSItr);
+}
+/********************************************************************/
+tiINT32
+TI_GetRSSITrigger(TI_HANDLE  hAdapter, tiBOOL* pbRSSItr)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetRSSITrigger(pbRSSItr);
+}
+/********************************************************************/
+tiINT32      
+TI_SetAntennaDiversityParams( TI_HANDLE hAdapter, PTIWLAN_ANT_DIVERSITY pAntennaDiversityOptions )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetAntennaDiversityParams(pAntennaDiversityOptions);
+}
+/********************************************************************/
+tiINT32      
+TI_SetWEPStatus(TI_HANDLE  hAdapter, tiUINT32 uWEPStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetWEPStatus(uWEPStatus);
+}
+/********************************************************************/
+tiINT32      
+TI_GetWEPStatus(TI_HANDLE  hAdapter,tiUINT32* puWEPStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetWEPStatus(puWEPStatus);
+}
+/********************************************************************/
+tiINT32      
+TI_SetDesiredChannel(TI_HANDLE  hAdapter,tiUINT32 uDesiredChannel)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetDesiredChannel(uDesiredChannel);
+}
+/********************************************************************/
+tiINT32      
+TI_GetDesiredChannel(TI_HANDLE  hAdapter,tiUINT32* puDesiredChannel)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDesiredChannel(puDesiredChannel);
+}
+/********************************************************************/
+tiINT32 
+TI_GetCurrentChannel(TI_HANDLE  hAdapter, tiUINT32*  puCurrentChannel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetCurrentChannel(puCurrentChannel);
+}
+/********************************************************************/
+tiINT32      
+TI_SetSupportedRates(TI_HANDLE  hAdapter, tiUINT8* pSupportedRatesLst, tiUINT32 uBufLength)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetSupportedRates(pSupportedRatesLst, uBufLength);
+}
+/********************************************************************/
+tiINT32      
+TI_GetSupportedRates(TI_HANDLE  hAdapter, tiUINT8* pSupportedRatesLst, tiUINT32 uBufLength )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetSupportedRates(pSupportedRatesLst, uBufLength);
+}
+/********************************************************************/
+tiINT32      
+TI_SetConfiguration(TI_HANDLE  hAdapter, OS_802_11_CONFIGURATION* pConfiguration)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetConfiguration(pConfiguration);
+}
+/********************************************************************/
+tiINT32
+TI_GetConfiguration(TI_HANDLE hAdapter, OS_802_11_CONFIGURATION* pConfiguration)    
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetConfiguration(pConfiguration);
+}
+/********************************************************************/
+tiINT32
+TI_SetAuthenticationMode(TI_HANDLE  hAdapter, OS_802_11_AUTHENTICATION_MODE uAuthenticationMode)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetAuthenticationMode(uAuthenticationMode);
+}
+/********************************************************************/
+tiINT32      
+TI_GetAuthenticationMode(TI_HANDLE  hAdapter, OS_802_11_AUTHENTICATION_MODE* puAuthenticationMode)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetAuthenticationMode(puAuthenticationMode);
+}
+/********************************************************************/
+tiINT32
+TI_SetPrivacyFilter(TI_HANDLE  hAdapter, tiUINT32 uPrivacyFilter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPrivacyFilter(uPrivacyFilter);
+}
+/********************************************************************/
+tiINT32      
+TI_GetPrivacyFilter(TI_HANDLE  hAdapter, tiUINT32* puPrivacyFilter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPrivacyFilter(puPrivacyFilter);
+}
+
+/********************************************************************/
+tiINT32      
+TI_EnableDisable_802_11d(TI_HANDLE  hAdapter, tiUINT8 enableDisable_802_11d)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->EnableDisable_802_11d(enableDisable_802_11d);
+}
+/********************************************************************/
+tiINT32      
+TI_Get_802_11d(TI_HANDLE  hAdapter, tiUINT8 *enableDisable_802_11d)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get_802_11d(enableDisable_802_11d);
+}
+
+/********************************************************************/
+tiINT32      
+TI_EnableDisable_802_11h(TI_HANDLE  hAdapter, tiUINT8 enableDisable_802_11h)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->EnableDisable_802_11h(enableDisable_802_11h);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Get_802_11h(TI_HANDLE  hAdapter, tiUINT8 *enableDisable_802_11h)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get_802_11h(enableDisable_802_11h);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Set_countryIeFor2_4_Ghz(TI_HANDLE  hAdapter, country_t countryIe)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Set_countryIeFor2_4_Ghz(countryIe);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Get_countryIeFor2_4_Ghz(TI_HANDLE  hAdapter, tiUINT8 **countryString)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get_countryIeFor2_4_Ghz(countryString);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Set_countryIeFor5_Ghz(TI_HANDLE  hAdapter, country_t countryIe)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Set_countryIeFor5_Ghz(countryIe);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Get_countryIeFor5_Ghz(TI_HANDLE  hAdapter, tiUINT8 **countryString)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get_countryIeFor5_Ghz(countryString);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Set_minMaxDfsChannels(TI_HANDLE  hAdapter, DFS_ChannelRange_t DFS_ChannelRange)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Set_minMaxDfsChannels(DFS_ChannelRange);
+}
+
+/********************************************************************/
+tiINT32      
+TI_Get_minMaxDfsChannels(TI_HANDLE  hAdapter, DFS_ChannelRange_t *DFS_ChannelRange)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get_minMaxDfsChannels(DFS_ChannelRange);
+}
+
+/********************************************************************/
+tiINT32
+TI_GetDriverState(TI_HANDLE  hAdapter, driverState_e* puDriverState )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDriverState(puDriverState);
+}
+/********************************************************************/
+tiINT32
+TI_SetIBSSProtection(TI_HANDLE  hAdapter, tiUINT32   uProtection )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetIBSSProtection(uProtection);
+}
+/********************************************************************/
+tiINT32
+TI_GetIBSSProtection(TI_HANDLE  hAdapter, tiUINT32*  puProtection)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetIBSSProtection(puProtection);
+}
+/********************************************************************/
+tiINT32      
+TI_SetShortSlot(TI_HANDLE  hAdapter, tiUINT32 uShortSlot)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetShortSlot(uShortSlot);
+}
+/********************************************************************/
+tiINT32
+TI_GetShortSlot(TI_HANDLE  hAdapter, tiUINT32*  puShortSlot)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetShortSlot(puShortSlot);
+}
+/********************************************************************/
+tiINT32      
+TI_SetExtRatesIE(TI_HANDLE  hAdapter, tiUINT32 uExtRatesIE)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetExtRatesIE(uExtRatesIE);
+}
+/********************************************************************/
+tiINT32      
+TI_SetEarlyWakeupMode(TI_HANDLE  hAdapter, tiUINT8 uEarlyWakeup)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetEarlyWakeupMode(uEarlyWakeup);
+}
+/********************************************************************/
+tiINT32      
+TI_GetEarlyWakeupMode(TI_HANDLE  hAdapter, tiUINT8* uEarlyWakeup)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetEarlyWakeupMode(uEarlyWakeup);
+}
+/********************************************************************/
+tiINT32      
+TI_GetExtRatesIE(TI_HANDLE  hAdapter, tiUINT32* puExtRatesIE)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetExtRatesIE(puExtRatesIE);
+}
+/********************************************************************/
+tiINT32
+TI_AddWEPKey(TI_HANDLE  hAdapter, OS_802_11_WEP* pWEP)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->AddWEPKey(pWEP);
+}
+/********************************************************************/
+tiINT32      
+TI_RemoveWEPKey(TI_HANDLE  hAdapter, tiUINT32 uKeyIndex)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->RemoveWEPKey(uKeyIndex);
+}
+/********************************************************************/
+tiINT32
+TI_AddKey(TI_HANDLE  hAdapter, OS_802_11_KEY* pKey)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->AddKey(pKey);
+}
+/********************************************************************/
+tiINT32     
+TI_RemoveKEY(TI_HANDLE  hAdapter, OS_802_11_REMOVE_KEY* pRemoveKey  ) 
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->RemoveKey(pRemoveKey);
+}
+/********************************************************************/
+tiINT32     
+TI_GetPowerMode(TI_HANDLE  hAdapter, OS_802_11_POWER_PROFILE* pPowerProfile )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPowerMode(pPowerProfile);
+}
+/********************************************************************/
+tiINT32
+TI_SetPowerMode(TI_HANDLE  hAdapter, OS_802_11_POWER_PROFILE uPowerProfile )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPowerMode(uPowerProfile);
+}
+/********************************************************************/
+tiINT32     
+TI_SetPowerLevelPS(TI_HANDLE  hAdapter, OS_802_11_POWER_LEVELS uPowerLevel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPowerLevelPS(uPowerLevel);
+}
+/********************************************************************/
+tiINT32     
+TI_GetPowerLevelPS(TI_HANDLE  hAdapter, OS_802_11_POWER_LEVELS* pPowerLevel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPowerLevelPS(pPowerLevel);
+}
+/********************************************************************/
+tiINT32     
+TI_SetPowerLevelDefault(TI_HANDLE  hAdapter, OS_802_11_POWER_LEVELS uPowerLevel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPowerLevelDefault(uPowerLevel);
+}
+/********************************************************************/
+tiINT32     
+TI_GetPowerLevelDefault(TI_HANDLE  hAdapter, OS_802_11_POWER_LEVELS* pPowerLevel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPowerLevelDefault(pPowerLevel);
+}
+/********************************************************************/
+tiINT32     
+TI_SetPowerLevelDozeMode(TI_HANDLE  hAdapter, OS_802_11_POWER_PROFILE uPowerLevel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetPowerLevelDozeMode(uPowerLevel);
+}
+/********************************************************************/
+tiINT32     
+TI_GetPowerLevelDozeMode(TI_HANDLE  hAdapter, OS_802_11_POWER_PROFILE* pPowerLevel )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPowerLevelDozeMode(pPowerLevel);
+}
+/********************************************************************/
+tiINT32     
+TI_SetBeaconFilterDesiredState(TI_HANDLE  hAdapter, OS_802_11_BEACON_FILTER_MODE uBeaconFilterDesiredState )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBeaconFilterDesiredState(uBeaconFilterDesiredState);
+}
+
+/********************************************************************/
+tiINT32     
+TI_GetBeaconFilterDesiredState(TI_HANDLE  hAdapter, tiUINT8* pBeaconFilterState )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetBeaconFilterDesiredState(pBeaconFilterState);
+}
+
+
+/********************************************************************/
+tiINT32
+TI_ConfigPowerManagement(TI_HANDLE  hAdapter, OS_802_11_POWER_PROFILE uPowerProfile )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->ConfigPowerManagement(uPowerProfile);
+}
+
+/********************************************************************/
+tiINT32     
+TI_RegisterEvent(TI_HANDLE  hAdapter, IPC_EVENT_PARAMS*  pEventParams )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->RegisterEvent(pEventParams);
+}
+/********************************************************************/
+tiINT32     
+TI_UnRegisterEvent(TI_HANDLE  hAdapter, IPC_EVENT_PARAMS*       pEventParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->UnRegisterEvent(pEventParams);
+}
+/********************************************************************/
+tiINT32      
+TI_hwReadRegister(TI_HANDLE  hAdapter, tiUINT32 uRegisterAddr, tiUINT32* puValue )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->hwReadRegister(uRegisterAddr, puValue);
+}
+
+/********************************************************************/
+tiINT32     
+TI_StartScan(TI_HANDLE  hAdapter, scan_Params_t *pScanParams)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->StartScan(pScanParams);
+}
+/********************************************************************/
+tiINT32     
+TI_StopScan(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->StopScan();
+}
+/********************************************************************/
+tiINT32
+TI_SetScanPolicy(TI_HANDLE  hAdapter, UINT8* buffer, UINT16 bufferLength)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetScanPolicy(buffer, bufferLength);
+}
+/********************************************************************/
+tiINT32
+TI_GetScanBssList(TI_HANDLE  hAdapter, bssList_t* bssList)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetScanBssList(bssList);
+}
+/********************************************************************/
+tiINT32            
+TI_ConfigTxClassifier(TI_HANDLE  hAdapter, 
+                      tiUINT32 inParamsBuffLen,
+                      tiUINT8  *inParamsBuff)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->ConfigTxClassifier(inParamsBuffLen,inParamsBuff);
+}
+/********************************************************************/
+tiINT32            
+TI_RemoveClassifierEntry(TI_HANDLE  hAdapter, clsfr_tableEntry_t *pClsfrEntry)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->RemoveClassifierEntry(pClsfrEntry);
+}
+/********************************************************************/
+tiINT32 
+TI_GetClsfrType(TI_HANDLE  hAdapter, 
+                clsfrTypeAndSupport *currClsfrType)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetClsfrType(currClsfrType);
+}
+/********************************************************************/
+tiINT32 
+TI_GetDesiredPsMode(TI_HANDLE  hAdapter, OS_802_11_QOS_DESIRED_PS_MODE *desiredPsMode)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDesiredPsMode(desiredPsMode);
+}
+/********************************************************************/
+tiINT32 
+TI_GetDriverCapabilities (TI_HANDLE  hAdapter, OS_802_11_DRIVER_CAPABILITIES* pDriverCapabilities )
+{
+   if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDriverCapabilities(pDriverCapabilities);
+}
+/********************************************************************/
+tiINT32        TI_GetSelectedBSSIDInfo(TI_HANDLE hAdapter, OS_802_11_BSSID_EX  *pSelectedBSSIDInfo )
+{
+       tiINT32 Rssi;
+
+   if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+
+   /* Query the RSSI so it will be updated in the Site Manager in CORE so the BSSID List retrive will be updated with
+   the correct current RSSI */
+   ((TI_WLAN_AdapterAPI *) hAdapter)->GetRSSI(&Rssi);  
+   
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetSelectedBSSIDInfo(pSelectedBSSIDInfo);
+}
+/********************************************************************/
+tiINT32        TI_GetPrimaryBSSIDInfo(TI_HANDLE hAdapter, OS_802_11_BSSID_EX  *pSelectedBSSIDInfo)
+{
+   tiINT32 Rssi;
+
+   if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+
+   /* Query the RSSI so it will be updated in the Site Manager in CORE so the BSSID List retrive will be updated with
+   the correct current RSSI */
+   ((TI_WLAN_AdapterAPI *) hAdapter)->GetRSSI(&Rssi);     
+
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetPrimaryBSSIDInfo(pSelectedBSSIDInfo);
+}
+/********************************************************************/
+tiINT32      
+TI_hwWriteRegister(TI_HANDLE  hAdapter, tiUINT32 uRegisterAddr, tiUINT32 dwValue )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->hwWriteRegister(uRegisterAddr, dwValue);
+}
+/********************************************************************/
+tiINT32 
+TI_Disassociate(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Disassociate();
+}
+/********************************************************************/
+tiUINT32      
+TI_ReloadDefaults(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->ReloadDefaults();
+}
+/********************************************************************/
+tiINT32            
+TI_IsDriverLoaded(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->IsDriverLoaded();
+}
+/********************************************************************/
+tiINT32      
+TI_GetNumberOfAntennas(TI_HANDLE hAdapter, tiUINT32* puNumberOfAntennas)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetNumberOfAntennas(puNumberOfAntennas);
+}
+/********************************************************************/
+tiINT32      
+TI_GetDriverVersion(TI_HANDLE  hAdapter, TIWLN_VERSION_EX* pdrvVersion)               
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDriverVersion(pdrvVersion);
+}
+
+
+/********************************************************************/
+tiINT32      
+TI_SetBtCoeEnable(TI_HANDLE  hAdapter, tiUINT32 ModeEnable)               
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBtCoeEnable(ModeEnable);
+}
+/********************************************************************/
+tiINT32      
+TI_SetBtCoeRate(TI_HANDLE  hAdapter, tiUINT8 *pRate)               
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBtCoeRate(pRate);
+}
+/********************************************************************/
+tiINT32      
+TI_SetBtCoeConfig(TI_HANDLE  hAdapter, tiUINT32 *pConfig)               
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBtCoeConfig(pConfig);
+}
+
+/********************************************************************/
+tiINT32      
+TI_SetBtCoeGetStatus(TI_HANDLE  hAdapter, tiUINT32 *pStatus)               
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetBtCoeGetStatus(pStatus);
+}
+
+
+
+#ifdef TI_DBG
+/********************************************************************/
+tiUINT32      
+TI_DebugBuffer(TI_HANDLE  hAdapter, tiUINT8* pBuffer, tiUINT32  uLenght)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDebugBuffer(pBuffer, uLenght);
+}
+/********************************************************************/
+tiINT32
+TI_SetReportModule(TI_HANDLE  hAdapter, tiUINT8* pData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetReportModule(pData);
+}
+/********************************************************************/
+tiINT32
+TI_GetReportModule(TI_HANDLE  hAdapter, tiUINT8* pData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetReportModule(pData);
+}
+/********************************************************************/
+tiINT32     
+TI_SetOsDbgState(TI_HANDLE  hAdapter, tiUINT32 uData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetOsDbgState(uData);
+}
+/********************************************************************/
+tiINT32     
+TI_GetOsDbgState(TI_HANDLE  hAdapter, tiUINT32* puData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetOsDbgState(puData);
+}
+/********************************************************************/
+tiINT32     
+TI_SetReportSeverity(TI_HANDLE  hAdapter, tiUINT8* pData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetReportSeverity(pData);
+}
+/********************************************************************/
+tiINT32     
+TI_GetReportSeverity(TI_HANDLE  hAdapter, tiUINT8* pData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetReportSeverity(pData);
+}
+/********************************************************************/
+tiINT32
+TI_SetReportPPMode(TI_HANDLE  hAdapter, tiUINT32 uData)            
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetReportPPMode(uData);
+}
+/********************************************************************/
+tiINT32
+TI_DisplayStats(TI_HANDLE  hAdapter, tiUINT8* puDbgBuffer, tiUINT32 uBuffSize)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->DisplayStats(puDbgBuffer, uBuffSize);
+}
+#endif //TI_DBG
+/********************************************************************/
+tiINT32      
+TI_GetRegDomainTable(TI_HANDLE  hAdapter, TIWLN_REGDOMAINS* pRegDomainTable)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetRegDomainTable(pRegDomainTable);
+}
+/********************************************************************/
+tiINT32      
+TI_GetMediumUsage(TI_HANDLE  hAdapter, TIWLN_MEDIUM_USAGE* pMediumUsage)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetMediumUsage(pMediumUsage);
+}
+/********************************************************************/
+tiINT32
+TI_GetApiVersion(TI_HANDLE  hAdapter, tiUINT32* puApiVersion)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetApiVersion(puApiVersion);
+}
+/********************************************************************/
+tiINT32
+TI_StartSM(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->StartSM();
+}
+/********************************************************************/
+tiINT32     
+TI_StopSM( TI_HANDLE  hAdapter )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->StopSM();
+}
+/********************************************************************/
+tiINT32     
+TI_GetAssociationInfo(TI_HANDLE  hAdapter, OS_802_11_ASSOCIATION_INFORMATION** ppInfo) 
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+
+    if ( ppInfo == NULL)
+        return TI_RESULT_FAILED;
+
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetAssociationInfo( ppInfo );
+}
+/********************************************************************/
+TI_HANDLE   
+TI_AdapterInit(tiCHAR*  pszAdapterName)
+{
+    return (TI_HANDLE) TI_AdapterCppInit(pszAdapterName, FALSE); 
+}
+
+/********************************************************************/
+tiINT32      
+TI_AdapterDeinit(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    TI_AdapterCppDeinit((TI_WLAN_AdapterAPI *) hAdapter, FALSE );
+    return TI_RESULT_OK;
+}
+/********************************************************************/
+tiINT32     
+TI_Start(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Start();
+}
+/********************************************************************/    
+tiINT32     
+TI_Stop(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Stop();
+}
+/********************************************************************/
+tiINT32     
+TI_WLAN_IsDriverRun(TI_HANDLE  hAdapter, tiBOOL* pbStatus)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->IsDriverRun(pbStatus);
+}
+/********************************************************************/
+tiINT32     
+TI_SetWpaOptions(TI_HANDLE  hAdapter, tiUINT32      fWPAOptions )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->SetWPAOptions(fWPAOptions);
+}
+/********************************************************************/
+tiINT32 TI_GetWpaOptions(TI_HANDLE  hAdapter, tiUINT32 * fWPAOptions )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+       return TI_RESULT_FAILED;
+
+     //return ((TI_WLAN_AdapterAPI *) hAdapter)->GetWPAOptions(fWPAOptions);
+}
+
+/********************************************************************/
+tiINT32     
+TI_SetRoamingConfiguration(TI_HANDLE  hAdapter, UINT8* buffer, UINT16 bufferLength)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Set_RoamingConfParams(buffer, bufferLength);
+}
+
+tiINT32     
+TI_GetRoamingConfiguration(TI_HANDLE  hAdapter, UINT8* buffer, UINT16 bufferLength)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Get_RoamingConfParams(buffer, bufferLength);
+}
+/********************************************************************/
+tiINT32     
+TI_GWSICommand(TI_HANDLE  hAdapter, tiUINT32* pGWSICommand )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GWSICommand(pGWSICommand);
+
+}
+
+/********************************************************************/
+tiINT32     
+TI_GWSIInitialize(TI_HANDLE  hAdapter, tiUINT32* pGWSICommand )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GWSIInitialize(pGWSICommand);
+       
+}
+
+/********************************************************************/
+tiINT32     
+TI_GWSIConfig(TI_HANDLE  hAdapter, tiUINT32* pGWSICommand )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GWSIConfig(pGWSICommand);
+       
+}
+
+/********************************************************************/
+tiINT32     
+TI_GWSIRelease(TI_HANDLE  hAdapter, tiUINT32* pGWSICommand )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GWSIRelease(pGWSICommand);
+       
+}
+
+/********************************************************************/
+
+tiINT32     
+TI_GWSIGetInitTable(TI_HANDLE  hAdapter, tiUINT32* pGWSICommand )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GWSIGetInitTable(pGWSICommand);
+
+}
+/********************************************************************/
+  
+//PLT
+
+tiINT32
+TI_PLT_ReadRegister(TI_HANDLE  hAdapter, UINT32 uRegisterAddr, PUINT32 uRegisterData )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_ReadRegister( uRegisterAddr,  uRegisterData );
+}
+
+tiINT32
+TI_PLT_WriteRegister(TI_HANDLE  hAdapter, UINT32 uRegisterAddr, UINT32 uRegisterData )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_WriteRegister( uRegisterAddr, uRegisterData );
+}
+
+
+tiINT32
+TI_PLT_RxPerStart(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RxPerStart();
+}
+
+tiINT32
+TI_PLT_RxPerStop(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RxPerStop();
+}
+
+tiINT32
+TI_PLT_RxPerClear(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RxPerClear();
+}
+
+tiINT32
+TI_PLT_RxPerGetResults(TI_HANDLE  hAdapter, PltRxPer_t* pPltRxPer )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RxPerGetResults( pPltRxPer );
+}
+
+tiINT32
+TI_PLT_TxCW(TI_HANDLE  hAdapter, TestCmdChannelBand_t* pPltTxCW)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxCW(pPltTxCW);
+}
+
+tiINT32
+TI_PLT_TxContiues(TI_HANDLE  hAdapter, PltTxContinues_t* pPltTxContinues)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxContiues( pPltTxContinues);
+}
+       
+tiINT32
+TI_PLT_TxStop(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxStop( );
+}
+
+tiINT32
+TI_PLT_ReadMIB(TI_HANDLE  hAdapter, PLT_MIB_t* pMib )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_ReadMIB(pMib);
+}
+
+tiINT32
+TI_PLT_WriteMIB(TI_HANDLE  hAdapter, PLT_MIB_t* pMib )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_WriteMIB(pMib);
+}
+
+tiINT32                
+TI_GetDefaultWepKey(TI_HANDLE  hAdapter, tiUINT32* puKeyIndex )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->GetDefaultWepKey(puKeyIndex);
+}
+
+tiINT32
+TI_PLT_TxCalGainGet(TI_HANDLE  hAdapter, PltGainGet_t* pPLTGainGet)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxCalGainGet(pPLTGainGet);
+}
+
+tiINT32
+TI_PLT_TxCalGainAdjust(TI_HANDLE  hAdapter, tiINT32   uTxGainChange)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxCalGainAdjust(uTxGainChange);
+}
+
+tiINT32                
+TI_PLT_TxCalStart(TI_HANDLE  hAdapter, PltTxCalibrationRequest_t* pPLTTxCal)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxCalStart(pPLTTxCal);
+}
+
+tiINT32                
+TI_PLT_TxCalStop(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_TxCalStop();
+}
+
+tiINT32                
+TI_PLT_RxTxCalNVSUpdateBuffer(TI_HANDLE  hAdapter, PltNvsResultsBuffer_t* pPLT_NVSUpdateBuffer)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RxTxCalNVSUpdateBuffer(pPLT_NVSUpdateBuffer);
+}
+
+tiINT32                
+TI_PLT_RxCal(TI_HANDLE  hAdapter, PltRxCalibrationRequest_t* pPltRxCalibration)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RxCal(pPltRxCalibration);
+}
+
+tiINT32                
+TI_PLT_RadioTune(TI_HANDLE  hAdapter, TestCmdChannelBand_t* pChannelBand)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->PLT_RadioTune(pChannelBand);
+}
+
+/********************************************************************/
+#ifdef _WINDOWS
+#endif
+
+/********************************************************************/
+
+#ifdef TI_DBG
+
+#ifdef DRIVER_PROFILING
+
+tiINT32     
+TI_ProfileReport(TI_HANDLE  hAdapter)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->ProfileReport();
+}
+
+tiINT32                 
+TI_CpuEstimatorCommand(TI_HANDLE  hAdapter, tiUINT8 uType, tiUINT32 uData)
+{
+    if ( !TI_CheckAdapterObject(hAdapter) )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->CpuEstimatorCommand(uType, uData);
+}
+
+#endif
+
+#endif // TI_DBG
+
+/********************************************************************/
+tiINT32     
+TI_Send_EAPOL_Packet( TI_HANDLE  hAdapter, tiVOID* pData, tiUINT32 uSize )
+{
+    if ( !TI_CheckAdapterObject(hAdapter) || !pData )
+        return TI_RESULT_FAILED;
+    return ((TI_WLAN_AdapterAPI *) hAdapter)->Send_EAPOL_Packet(pData,uSize);
+}
+/********************************************************************/
diff --git a/sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk b/sta_dk_4_0_4_32/CUDK/tiwlan_loader/Android.mk
new file mode 100644 (file)
index 0000000..5b60265
--- /dev/null
@@ -0,0 +1,97 @@
+CLI_STATIC_LIB ?= y
+CLI_DEBUG ?= y
+FIRMWARE_DYNAMIC_LOAD ?= y
+BUILD_SUPPL ?= n
+SG  ?= n
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+TARGET = wlan_loader
+LOCAL_MODULE = $(TARGET)
+
+ifeq ($(CLI_DEBUG),y)
+  CLI_DEBUGFLAGS = -O0 -g -fno-builtin -DDEBUG -D TI_DBG  # "-O" is needed to expand inlines
+else
+  CLI_DEBUGFLAGS = -O2
+endif
+
+CLI_STA_DK_ROOT = $(LOCAL_PATH)/../..
+CLI_DK_ROOT = $(CLI_STA_DK_ROOT)
+CLI_COMMON  = $(CLI_DK_ROOT)/common
+CLI_COMSRC  = $(CLI_COMMON)/src
+CLI_TESTSRC = $(CLI_DK_ROOT)/Test
+CLI_CUDK_ROOT = $(LOCAL_PATH)/..
+CLI_IPC_SRC = $(CLI_CUDK_ROOT)/IPC/Linux
+
+DK_INCS = $(CLI_COMMON)/inc \
+       $(CLI_COMSRC)/inc \
+       $(CLI_COMSRC)/utils \
+       $(CLI_COMSRC)/hal/inc \
+       $(CLI_COMSRC)/hal/hl_data \
+       $(CLI_COMSRC)/hal/hl_ctrl \
+       $(CLI_COMSRC)/hal/hw_data \
+       $(CLI_COMSRC)/hal/hw_ctrl \
+       $(CLI_COMSRC)/hal/security \
+       $(CLI_COMSRC)/core/inc \
+       $(CLI_COMSRC)/core/data_ctrl/Tx \
+       $(CLI_COMSRC)/core/data_ctrl/Ctrl \
+       $(CLI_COMSRC)/core/data_ctrl/Ctrl/4X \
+       $(CLI_COMSRC)/core/sme/Inc \
+       $(CLI_COMSRC)/core/sme/siteMgr \
+       $(CLI_COMSRC)/core/sme/configMgr \
+       $(CLI_COMSRC)/core/sme/conn \
+       $(CLI_COMSRC)/core/rsn \
+       $(CLI_COMSRC)/core/rsn/mainKeysSm \
+       $(CLI_COMSRC)/core/rsn/mainKeysSm/keyDerive \
+       $(CLI_COMSRC)/core/rsn/inc \
+       $(CLI_COMSRC)/core/mlme \
+       $(CLI_COMSRC)/core/NetworkCtrl/inc \
+       $(CLI_COMSRC)/core/NetworkCtrl/Measurement \
+       $(CLI_COMSRC)/core/NetworkCtrl/RegulatoryDomain \
+       $(CLI_COMSRC)/core/NetworkCtrl/QOS \
+       $(CLI_CUDK_ROOT)/CLI \
+       $(CLI_CUDK_ROOT)/UtilityAdapter \
+       $(CLI_COMSRC)/hal/FirmwareApi \
+       $(CLI_COMSRC)/hal/TnetwServices \
+       $(CLI_COMSRC)/hal/TnetwServices/TNETW1251
+
+ifeq ($(SG), y)
+DK_INCS += $(CLI_COMSRC)/core/NetworkCtrl/BThWlanCombo
+endif
+
+DK_DEFINES = \
+       -D __BYTE_ORDER_LITTLE_ENDIAN \
+       -D INCLUDE_DEFRAGMENTATION \
+       -D CONFIGURE_BSS_TYPE_STA \
+       -D TNETW1150=1 \
+       -D DOT11_A_G=1 \
+       -D ELP_NO_PDA_SCREEN_VIBRATE
+
+ifeq ($(SG), y)
+DK_DEFINES += -D BTH_COEXISTENCE
+endif
+
+LOCAL_SRC_FILES := tiwlan_loader.c
+
+ifeq ($(CLI_STATIC_LIB),y)
+LOCAL_STATIC_LIBRARIES := libWifiApi
+else
+LOCAL_SHARED_LIBRARIES := libWifiApi
+endif
+LOCAL_SHARED_LIBRARIES += libc libhardware
+
+INCLUDES = $(DK_INCS) $(CLI_STA_DK_ROOT)/pform/linux/inc \
+       $(CLI_CUDK_ROOT)/Inc                             \
+       $(CLI_STA_DK_ROOT)/pform/common/inc
+
+LOCAL_CFLAGS = -Wall -Wstrict-prototypes $(CLI_DEBUGFLAGS) -D__LINUX__ $(DK_DEFINES) -mabi=aapcs-linux
+LOCAL_CFLAGS += -DDRV_NAME='"tiwlan"' -DHOST_COMPILE
+
+ifeq ($(FIRMWARE_DYNAMIC_LOAD), y)
+    LOCAL_CFLAGS += -DFIRMWARE_DYNAMIC_LOAD
+endif
+
+LOCAL_C_INCLUDES = $(INCLUDES)
+
+include $(BUILD_EXECUTABLE)
diff --git a/sta_dk_4_0_4_32/CUDK/tiwlan_loader/tiwlan_loader.c b/sta_dk_4_0_4_32/CUDK/tiwlan_loader/tiwlan_loader.c
new file mode 100644 (file)
index 0000000..d2af19b
--- /dev/null
@@ -0,0 +1,374 @@
+/*
+ * tiwlan driver loader - utility to load firmware and calibration data
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ */
+
+/* Copyright © Texas Instruments Incorporated (Oct 2005)
+ * THIS CODE/PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
+ * EITHER EXPRESS OR IMPLIED, INCLUDED BUT NOT LIMITED TO , THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
+ * This program has been modified from its original operation by Texas 
+ * Instruments Incorporated. These changes are covered under version 2 
+ * of the GNU General Public License, dated June 1991. 
+ *
+ * Copyright © Google Inc (Feb 2008)
+*/
+/*-------------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef __LINUX__
+#ifdef EEPROM_MEMORY_SUPPORT
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#endif
+#endif
+
+#ifdef ANDROID
+#include <cutils/properties.h>
+
+#define LOG_TAG "wlan_loader"
+
+#include <cutils/log.h>
+#include <hardware/power.h>
+#define PROGRAM_NAME    "wlan_loader"
+#endif
+       
+#include "paramOut.h"
+#include "linux_ioctl_common.h"
+#include "osApi.h"
+#include "tiioctl.h"
+#include "TI_AdapterApiC.h"
+#include "TI_IPC_Api.h"
+#include "osTIType.h"
+#include "cli_cu_common.h"
+/*---------------------------------------------------------*/
+#ifndef offsetof
+#define offsetof(type, field)    ((unsigned int) (&(((type *)(0))->field)))
+#endif
+
+#ifndef IFNAMSIZ
+#define        IFNAMSIZ        16
+#endif
+
+#ifdef ANDROID
+
+#define ENABLE_LOG_ERROR
+#define ENABLE_LOG_DEBUG
+
+#ifdef ENABLE_LOG_ERROR
+#define print_error(fmt, args...) \
+    { LOGE(fmt , ## args); }
+#else
+#define print_error(fmt, args...) \
+    do { } while (0)
+#endif /* ENABLE_LOG_ERROR */
+
+#ifdef ENABLE_LOG_DEBUG
+#define print_debug(fmt, args...) \
+    { LOGD(fmt , ## args); }
+#else
+#define print_debug(fmt, args...) \
+    do { } while (0)
+#endif /* ENABLE_LOG_MOUNT */
+
+#else /* !ANDROID */
+
+#define print_error printf
+#define print_debug printf
+
+#endif /* ifdef ANDROID */
+
+
+/*---------------------------------------------------------*/
+char g_drv_name[IFNAMSIZ + 1];
+TI_HANDLE g_id_adapter = 0;
+/*---------------------------------------------------------*/
+int print_usage(void)
+{
+    printf("Usage: ./wlan_loader [driver_name] [options]\n");
+#ifdef HOST_PLATFORM_WIPP
+    printf("   -e <filename>  - eeprom image file name. default=/var/run/nvs_map.bin\n");
+#else
+    printf("   -e <filename>  - eeprom image file name. default=./nvs_map.bin\n");
+#endif
+    printf("   -i <filename>  - init file name. default=tiwlan.ini\n");
+    printf("   -f <filename>  - firmware image file name. default=firmware.bin\n");
+    return 1;
+}
+
+/*  Return '0' if success */
+int init_driver( char *adapter_name, char *eeprom_file_name, char *init_file_name, char *firmware_file_name )
+{
+#ifdef __LINUX__
+    FILE *f1 = NULL, *f2 = NULL, *f3 = NULL;
+    UINT32 eeprom_image_length = 0;
+    UINT32 init_file_length = 0;
+    UINT32 firmware_image_length = 0;
+    UINT32 req_size = 0;
+    tiwlan_dev_init_t *init_info = NULL;
+#ifdef EEPROM_MEMORY_SUPPORT
+    volatile unsigned long *nvsPtr = NULL;
+    int fd = -1;
+#endif    
+#endif
+    int rc = -1, count = 0;
+    tiUINT32 tmpData = 1;
+
+    print_debug("adapter %s, eeprom %s, init %s, firmware %s\n",
+               adapter_name, eeprom_file_name, init_file_name, firmware_file_name);
+
+    if( !adapter_name || !*adapter_name )
+        return rc;
+
+    g_id_adapter = TI_AdapterInit( adapter_name );
+
+    if( g_id_adapter == 0 ) {
+      print_error("wlan_loader: failed to initialize Utility-Adapter interface...aborting...\n");
+      goto init_driver_end;
+    }
+
+#ifdef __LINUX__
+    /* Send init request to the driver */
+    if (eeprom_file_name) {
+        if ((f1 = fopen(eeprom_file_name, "r")) == NULL) {
+            print_error("Cannot open eeprom image file <%s>: %s\n",
+                    eeprom_file_name, strerror(errno));
+            goto init_driver_end;
+        }
+        if (fseek(f1, 0, SEEK_END)) {
+            print_error("Cannot seek eeprom image file <%s>: %s\n",
+                    eeprom_file_name, strerror(errno));
+            goto init_driver_end;
+        }
+        eeprom_image_length = ftell(f1);
+        rewind(f1);
+    }
+#ifdef EEPROM_MEMORY_SUPPORT
+    else {
+       fd = open("/dev/mem", O_RDWR | O_SYNC);
+       if( fd == -1 ) {
+            print_error("Cannot access /dev/mem\n");
+            goto init_driver_end;
+       }
+       nvsPtr = (volatile unsigned long *)mmap(0,0x1000,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x13F13000);
+       eeprom_image_length = *(nvsPtr + (0xE0C >> 2));
+       print_debug("---Eeprom from Memory Size = %u\n", eeprom_image_length);
+    }
+#endif
+#ifdef FIRMWARE_DYNAMIC_LOAD
+    if( firmware_file_name) {
+        if ((f2 = fopen(firmware_file_name, "r")) == NULL ) {
+            print_error("Cannot open firmware file <%s>: %s\n",
+                    firmware_file_name, strerror(errno));
+            goto init_driver_end;
+        }
+        if( fseek(f2, 0, SEEK_END) ) {
+            print_error( "Cannot seek firmware file <%s>: %s\n",
+                    firmware_file_name, strerror(errno));
+            goto init_driver_end;
+        }
+        firmware_image_length = ftell(f2);
+        rewind(f2);
+    }
+#endif
+    if( init_file_name) {
+        if ((f3 = fopen(init_file_name, "r")) == NULL ) {
+            print_error( "Cannot open init file <%s>: %s\n",
+                    init_file_name, strerror(errno));
+            goto init_driver_end;
+        }
+        if( fseek(f3, 0, SEEK_END) ) {
+            print_error("Cannot seek init file <%s>: %s\n",
+                    init_file_name, strerror(errno));
+            goto init_driver_end;
+        }
+        init_file_length = ftell(f3);
+        rewind(f3);
+    }
+
+    /* Now when we can calculate the request length. allocate it and read the files */
+    req_size = offsetof(tiwlan_dev_init_t, data)+ eeprom_image_length + (init_file_length+1) + firmware_image_length;
+    init_info = (tiwlan_dev_init_t *)malloc(req_size);
+    if( !init_info ) {
+        print_error("No memory to allocate init request (%d bytes)\n", req_size);
+        goto init_driver_end;
+    }
+    init_info->eeprom_image_length   = eeprom_image_length;
+    init_info->firmware_image_length = firmware_image_length;
+    init_info->init_file_length      = init_file_length;
+#ifdef EEPROM_MEMORY_SUPPORT
+    if( (nvsPtr != NULL) && eeprom_image_length ) {
+        memcpy(&init_info->data[0], (void *)(nvsPtr + (0xE40 >> 2)), eeprom_image_length);
+        munmap( (void *)nvsPtr, 0x1000 );
+        close( fd );
+    }
+    else
+#endif    
+    if( eeprom_image_length &&
+        fread(&init_info->data[0], 1, eeprom_image_length, f1) < eeprom_image_length ) {
+        print_error("Error reading eeprom image %s: %s\n", eeprom_file_name, strerror(errno));
+        goto init_driver_end;
+    }
+    if( firmware_image_length &&
+        fread(&init_info->data[eeprom_image_length], 1, firmware_image_length, f2) < firmware_image_length ) {
+        print_error("Error reading firmware image %s: %s\n", firmware_file_name, strerror(errno));
+        goto init_driver_end;
+    }
+    if( init_file_length &&
+        fread(&init_info->data[eeprom_image_length+firmware_image_length], 1, init_file_length, f3) < init_file_length ) {
+        print_error("Error reading init_file %s: %s\n", init_file_name, strerror(errno));
+        goto init_driver_end;
+    }
+
+    do { /* Need to wait till driver will be created in sdio_probe() */
+       print_debug("Configuring adapter\n");
+        rc = IPC_DeviceIoControl(adapter_name, TIWLN_SET_INIT_INFO, init_info, req_size, NULL, 0, NULL);
+       print_debug("Adapter configuration rc = %d\n", rc);
+        if( rc != 0 ) {
+            if( count > 4 ) {
+                break;
+            }
+            count++;
+            sleep(1);
+        }
+    } while( rc != 0 );
+
+    /* Send configMge start command as the cli is started */
+    if( rc == 0 ) {
+       print_debug("Starting configMge\n");
+        rc = IPC_DeviceIoControl(adapter_name, TIWLN_DRIVER_STATUS_SET, &tmpData, sizeof(tiUINT32), NULL, 0, NULL);
+       print_debug("ConfigMge start rc = %d\n", rc);
+    }
+
+init_driver_end:
+    if( f1 )
+        fclose(f1);
+    if( f2 )
+        fclose(f2);
+    if( f3 )
+        fclose(f3);
+    if( init_info )
+        free(init_info);
+#endif
+    if( rc == 0 ) {
+       print_debug("Driver configured\n");
+    } else {
+       print_debug("Driver configuration failed (%d)\n", rc);
+    }
+    return rc;
+}
+
+#ifdef ANDROID
+int check_and_set_property(char *prop_name, char *prop_val)
+{
+    char prop_status[PROPERTY_VALUE_MAX];
+    int count;
+
+    for(count=4;( count != 0 );count--) {
+        property_set(prop_name, prop_val);
+        if( property_get(prop_name, prop_status, NULL) &&
+            (strcmp(prop_status, prop_val) == 0) )
+           break;
+    }
+    if( count ) {
+        print_debug("Set property %s = %s - Ok\n", prop_name, prop_val);
+    }
+    else {
+        print_debug("Set property %s = %s - Fail\n", prop_name, prop_val);
+    }
+    return( count );
+}
+#endif
+
+#ifdef __LINUX__
+int main(int argc, char ** argv)
+{
+    int i;
+#ifdef HOST_PLATFORM_WIPP
+    char *eeprom_file_name = "/NVS/nvs_map.bin";
+    char *init_file_name = "/voice/tiwlan.ini";
+    char *firmware_file_name = "/apps/firmware.bin";
+#else
+    char *eeprom_file_name = "./nvs_map.bin";
+    char *init_file_name = "./tiwlan.ini";
+    char *firmware_file_name = "./firmware.bin";
+#endif
+
+    if( argc > 1 ) {
+        i=1;
+        if( argv[i][0] != '-' ) {
+            strcpy( g_drv_name, argv[i++] );
+        }
+        for(;( i < argc );i++) {
+            if( !strcmp(argv[i], "-h" ) || !strcmp(argv[i], "--help") )
+                return print_usage();
+            else if( !strcmp(argv[i], "-f" ) ) {
+                firmware_file_name = argv[++i];
+            }
+            else if( !strcmp(argv[i], "-e") && ((i+1) < argc) ) {
+                eeprom_file_name = argv[++i];
+            }
+            else if( !strcmp(argv[i], "-i") && ((i+1) < argc) ) {
+                init_file_name = argv[++i];
+            }
+            else if( !strcmp(argv[i], "-n" ) ) {
+               eeprom_file_name = NULL;
+            }
+            else {
+                printf("ticon: unknown parameter '%s'\n", argv[i] );
+#ifdef ANDROID         
+                check_and_set_property("wlan.driver.status", "failed");
+#endif         
+                return -1;
+            }
+        }
+    }
+#else
+int start_cli()
+{
+    char *eeprom_file_name = NULL;
+    char *init_file_name = NULL;
+    char *firmware_file_name = NULL;
+#endif
+    if( !g_drv_name[0] ) {
+#if defined(__LINUX__)
+        strcpy(g_drv_name, TIWLAN_DRV_NAME "0" );
+#else
+        strcpy(g_drv_name, TIWLAN_DRV_NAME );
+#endif
+    }
+
+#ifdef ANDROID
+    acquire_wake_lock(PARTIAL_WAKE_LOCK, PROGRAM_NAME);
+#endif
+       
+    if( init_driver(g_drv_name, eeprom_file_name, init_file_name, firmware_file_name) != 0 ) {
+       print_error("init_driver() failed\n");
+#ifdef ANDROID    
+        check_and_set_property("wlan.driver.status", "failed");
+        release_wake_lock(PROGRAM_NAME);
+#endif    
+        return -1;
+    }
+
+    TI_AdapterDeinit(g_id_adapter);
+#ifdef ANDROID    
+    print_debug("Firmware loaded and running OK\n");
+    check_and_set_property("wlan.driver.status", "ok");
+    release_wake_lock(PROGRAM_NAME);
+#endif    
+    return 0;
+}
diff --git a/sta_dk_4_0_4_32/Makefile b/sta_dk_4_0_4_32/Makefile
new file mode 100644 (file)
index 0000000..7404f8c
--- /dev/null
@@ -0,0 +1,177 @@
+##
+## Flags
+##
+export FIRMWARE_DYNAMIC_LOAD ?= y
+
+##
+##
+## File lists and locations
+##
+##
+
+#
+# DK_ROOT must be set prior to including common.inc
+#
+DK_ROOT := .
+ifeq ($(M),)
+    M = drivers/net/wireless/tiwlan1251
+endif
+DK_ROOT_INC = $(M)
+
+#
+# Includes common definitions and source file list
+#
+ifneq ($(KERNELRELEASE),)
+    include $(M)/common.inc
+    include $(M)/drv_sources.inc
+    include $(M)/os_sources.inc
+else
+ifeq ($(KERNEL_DIR),)
+    KERNEL_DIR = .
+endif
+    include common.inc
+    include drv_sources.inc
+    include os_sources.inc
+endif
+
+#
+# OS include paths required for compilation.
+# 
+OS_INCS = $(DK_ROOT)/pform/linux/inc $(DK_ROOT)/pform/common/inc
+OS_INCS += $(DK_ROOT)/common/src/core/EvHandler
+
+#
+# Location and filename of the driver .lib file created by this makefile.
+#
+OUTPUT_DIR = $(DK_ROOT)
+OUTPUT_FILE = $(OUTPUT_DIR)/libestadrv.a
+
+OS_SRCS = \
+    $(DK_ROOT)/pform/common/src/osCmd.c \
+    $(DK_ROOT)/pform/common/src/osUtil.c \
+    $(DK_ROOT)/pform/common/src/osClsfr.c \
+    $(DK_ROOT)/pform/common/src/osRgstry.c \
+    $(DK_ROOT)/pform/linux/src/esta_drv.c \
+    $(DK_ROOT)/pform/linux/src/mmc_tnetw1150_api.c \
+    $(DK_ROOT)/pform/linux/src/tnetw_sdio.c \
+    $(DK_ROOT)/pform/linux/src/osapi.c \
+    $(DK_ROOT)/pform/linux/src/osmemapi.c \
+    $(DK_ROOT)/pform/linux/src/env_tst.c \
+    $(DK_ROOT)/pform/linux/src/ioctl_list.c \
+    $(DK_ROOT)/pform/linux/src/ioctl_utils.c \
+    $(DK_ROOT)/pform/linux/src/osRgstry_parser.c \
+    $(DK_ROOT)/pform/linux/src/ipc_k.c \
+    $(DK_ROOT)/pform/linux/src/proc_stat.c
+    
+ifeq ($(DRIVER_PROFILING),y)
+    OS_SRCS += $(DK_ROOT)/pform/linux/src/tiwlan_profile.c
+endif
+
+ifeq ($(STACK_PROFILING_ON),y)
+    OS_SRCS += $(DK_ROOT)/pform/linux/src/stack_profile.c
+    EXTRA_CFLAGS += -D STACK_PROFILE
+endif
+
+ifeq ($(NO_ARCH_STRCMP),y)
+    OS_SRCS += $(DK_ROOT)/pform/linux/src/string.c
+endif
+    
+OS_OBJS = $(patsubst %.c, %.o, $(OS_SRCS))
+
+#
+# Remove debug info
+#
+EXTRA_LDFLAGS += --strip-debug 
+
+##
+##
+## Build process
+##
+##
+
+ifneq ($(KERNELRELEASE),)
+
+
+       ##
+       ##
+       ## This is the kernel build phase - set the appropriate arguments
+       ##
+       ##
+
+       #
+       # Adds the current directory as a prefix to all include directories.
+       #
+       EXTRA_CFLAGS += $(addprefix -I$(DK_ROOT_INC)/, $(DK_INCS) $(OS_INCS))
+
+       #
+       # Intermediate object name - this should be converted to the appropriate library file
+       # after the kernel makefile finishes its work.
+       #
+       obj-$(CONFIG_TIWLAN1251) += wlan.o
+       
+       #
+       # List of object files the kernel makefile needs to compile.
+       #
+       wlan-objs := $(DK_OBJS) $(OS_OBJS)
+
+       
+else   # ifneq ($(KERNELRELEASE),)
+
+       #
+       # Adds the current directory as a prefix to all include directories.
+       #
+       EXTRA_CFLAGS += $(addprefix -I$(M)/, $(DK_INCS) $(OS_INCS))
+
+
+##
+##
+## This is the regular build phase - act according to the make actions
+##
+##
+
+#
+# The location of the kernel makefile
+#
+KERNEL_DIR ?= /vobs/wlan_linux2.6/kernel-2.6/
+
+
+#
+# Build the driver lib file
+#
+.PHONY: all
+all: .depend $(OUTPUT_FILE)
+
+
+#
+# Prints variables
+#
+.PHONY: help
+help:
+       @echo Default Compilation:      BOARD=$(WIFI_BOARD) PLATFORM=$(PLATFORM) DEBUG=$(DEBUG) INTR=$(INTR) WSPI=$(WSPI) EXC=$(EXC) EXTRA CFLAGS: $(EXTRA_CFLAGS)
+
+
+#
+# Recursively cleans the driver files.
+#
+.PHONY: clean
+clean:
+       $(MAKE) -C $(KERNEL_DIR) M=`pwd` ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) clean
+       @rm -f *.o *.a *~ *.~* core .depend dep $(DK_OBJS) $(OS_OBJS) $(DEPS)
+
+
+#
+# Causes the library file to get rebuilt.
+#
+.depend:
+       rm -f $(OUTPUT_FILE)
+
+
+#
+# Recursively builds the library file.
+#
+$(OUTPUT_FILE):
+       $(MAKE) -C $(KERNEL_DIR) M=`pwd` ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules
+       @$(CROSS_COMPILE)$(AR) rcs $@ $(DK_OBJS) $(OS_OBJS)
+
+
+endif  # ifneq ($(KERNELRELEASE),)
diff --git a/sta_dk_4_0_4_32/common.inc b/sta_dk_4_0_4_32/common.inc
new file mode 100644 (file)
index 0000000..561c21c
--- /dev/null
@@ -0,0 +1,174 @@
+##
+##
+## Directory Locations
+##
+##
+
+HAL_ROOT    := $(DK_ROOT)
+COMMON      := $(DK_ROOT)/common
+COMSRC      := $(COMMON)/src
+HALSRCR     := $(HAL_ROOT)/common
+HALSRC      := $(HALSRCR)/src
+DRV_BYPASS  := $(COMSRC)/driver_bypass
+LINUX_PFORM := $(DK_ROOT)/pform/linux
+PFORM       := $(DK_ROOT)/pform
+
+##
+##
+## Make Flags
+##
+##
+
+#
+# Choose an interface (CRTWIPP)
+#
+WIFI_BOARD ?= MSM_DREAM
+
+#
+# Choose the TNET type (1251)
+#
+PLATFORM ?= 1251
+
+#
+# Compile with EXC support or not
+#
+EXC ?= n
+
+#
+# Choose the bus type (n for SDIO, y for WSPI)
+#
+WSPI ?= n
+
+#
+# Use periodic interrupt
+#
+INTR ?= y
+
+#
+# Use work queues
+#
+WORKQUEUE ?= y
+
+#
+# Enable or disable debugging
+#
+DEBUG ?= n
+
+#
+# Enable or disable OS and init messages
+#
+INFO ?= n
+
+#
+# Archtecture Type
+#
+ARCH ?= arm
+
+#
+# Cross Compiler Prefix
+#
+CROSS_COMPILE ?= arm-eabi-
+
+#
+# Enable driver profiling
+#
+DRIVER_PROFILING ?= n
+
+
+
+
+##
+##
+## Driver Compilation Directives
+##
+##
+
+ifeq ($(EXC),y)
+    DK_DEFINES += -D EXC_MODULE_INCLUDED
+endif
+
+ifeq ($(INTR),n)
+    DK_DEFINES += -D PRIODIC_INTERRUPT
+endif    
+
+ifeq ($(WORKQUEUE),y)
+    DK_DEFINES += -D DM_USE_WORKQUEUE
+endif    
+
+ifeq ($(DEBUG),y)
+    DK_DEFINES += -D TI_DBG
+    DK_DEFINES += -D REPORT_LOG
+else
+    DK_DEFINES += -U REPORT_LOG
+endif
+
+DK_DEFINES += -D __BYTE_ORDER_LITTLE_ENDIAN
+DK_DEFINES += -D CONFIGURE_BSS_TYPE_STA
+DK_DEFINES += -D PERIODIC_WAKEUP
+
+ifeq ($(DRIVER_PROFILING),y)
+   DK_DEFINES += -D DRIVER_PROFILING
+endif
+
+
+##
+##
+## Platform Compilation Directives
+##
+##
+
+ifeq ($(WIFI_BOARD),CRTWIPP)
+       TIWLAN_OMAP1610_CRTWIPP ?= y
+       PFORM_DEFINES += -D TIWLAN_OMAP1610_CRTWIPP
+endif
+
+ifeq ($(PLATFORM),1251)
+    PFORM_DEFINES += -D TNETW1150=1
+    PFORM_DEFINES += -D TNETW1251=1
+endif
+
+ifeq ($(WSPI),y)
+       PFORM_DEFINES += -D HW_ACCESS_WSPI
+else
+       PFORM_DEFINES += -D HW_ACCESS_SDIO
+       PFORM_DEFINES += -D USE_SYNC_API
+       PFORM_DEFINES += -D USE_RECOVERY
+endif
+
+ifeq ($(INFO),y)
+    PFORM_DEFINES += -D OS_INFO_MESSAGES
+       PFORM_DEFINES += -D INIT_MESSAGES
+endif
+
+ifeq ($(WIFI_BOARD),CRTWIPP)
+PFORM_DEFINES += -D TIWLAN_OMAP1610
+endif
+
+ifeq ($(WIFI_BOARD),MSM_DREAM)
+PFORM_DEFINES += -D TIWLAN_MSM7000
+endif
+
+# PFORM_DEFINES += -D DEBUG_MESSAGES
+PFORM_DEFINES += -D HOST_COMPILE
+PFORM_DEFINES += -D FW_RUNNING_AS_STA
+PFORM_DEFINES += -D NOT_SUPPORT_08_BIT_ACCESS_COMMAND
+PFORM_DEFINES += -D FOUR_ALIGNMENT
+PFORM_DEFINES += -D USE_INIT_FILE
+
+ifeq ($(FIRMWARE_DYNAMIC_LOAD),y)
+PFORM_DEFINES += -D FIRMWARE_DYNAMIC_LOAD
+endif
+
+##
+##
+## Miscellaneous Compilation Directivcs
+##
+##
+
+EXTRA_CFLAGS += -fsigned-char
+EXTRA_CFLAGS += -D __int64="long long"
+EXTRA_CFLAGS += -D __LINUX__
+EXTRA_CFLAGS += -D TIWLN_MAJOR_VERSION=5
+EXTRA_CFLAGS += -D TIWLN_MINOR_VERSION=1
+EXTRA_CFLAGS += $(DK_DEFINES)
+EXTRA_CFLAGS += $(PFORM_DEFINES)
diff --git a/sta_dk_4_0_4_32/common/inc/TI_IPC_Api.h b/sta_dk_4_0_4_32/common/inc/TI_IPC_Api.h
new file mode 100644 (file)
index 0000000..6241a36
--- /dev/null
@@ -0,0 +1,155 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _TI_IPC_API_H
+#define _TI_IPC_API_H
+
+#include "osTIType.h"
+#include "TI_Results.h"
+
+
+#define MAX_REGISTERED_MODULES 5
+#define MAX_EVENT_DATA_SIZE 2048
+#define MAX_SEND_EVENTS 4
+
+#ifdef _WINDOWS
+#endif 
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/*******************Defines*********************/
+
+/* WARNING! DON'T CHANGE THE ORDER OF EVENTS! */
+/* OS EVENTS MUST COME FIRST!*/
+
+enum
+{
+    IPC_EVENT_ASSOCIATED = 0,
+    IPC_EVENT_DISASSOCIATED,
+    IPC_EVENT_LINK_SPEED,
+    IPC_EVENT_AUTH_SUCC,
+    IPC_EVENT_SCAN_COMPLETE,
+    IPC_EVENT_TIMEOUT,
+    IPC_EVENT_CCKM_START,
+    IPC_EVENT_MEDIA_SPECIFIC,
+    IPC_EVENT_MAX_OS_EVENT = IPC_EVENT_MEDIA_SPECIFIC,
+    IPC_EVENT_EAPOL,
+    IPC_EVENT_BOUND,
+    IPC_EVENT_UNBOUND,
+    IPC_EVENT_PREAUTH_EAPOL,
+    IPC_EVENT_RESERVED2,
+    IPC_EVENT_LOW_SNR,
+    IPC_EVENT_LOW_RSSI,
+    IPC_EVENT_TSPEC_STATUS,
+    IPC_EVENT_TSPEC_RATE_STATUS,
+    IPC_EVENT_MEDIUM_TIME_CROSS,
+    IPC_EVENT_ROAMING_COMPLETE,
+    IPC_EVENT_EAP_AUTH_FAILURE,
+    IPC_EVENT_WPA2_PREAUTHENTICATION,
+    IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED,
+    IPC_EVENT_GWSI,
+    IPC_EVENT_BT_COEX_MODE,
+    IPC_EVENT_MAX
+};
+
+enum
+{
+    DELIVERY_PUSH =0,
+    DELIVERY_GET_DATA
+};
+
+/************************* IOCTLs Functions *******************************/
+
+TI_HANDLE   IPC_Init(void);
+
+tiINT32     IPC_DeInit(void);
+
+TI_HANDLE   IPC_DeviceOpen(tiVOID* AdapterName); /* get hDevice Handle*/
+
+tiINT32     IPC_DeviceClose(TI_HANDLE hDevice);
+
+tiINT32     IPC_DeviceIoControl(TI_HANDLE   hDevice,
+                            tiUINT32    IoControlCode, 
+                            tiVOID*     pInBuffer,
+                            tiUINT32    InBufferSize,
+                            tiVOID*     pOutBuffer,
+                            tiUINT32    pOutBufferSize,
+                            tiUINT32*   pBytesReturned);
+
+/************************* Events Functions *******************************/
+
+typedef struct _IPC_EV_DATA * PIPC_EV_DATA;  
+
+typedef tiINT32 (*TI_EVENT_CALLBACK) (PIPC_EV_DATA  pData);
+
+typedef struct _IPC_EVENT_PARAMS
+{
+    tiUINT32            uEventType;
+    TI_HANDLE           uEventID;
+    tiUINT32            uProcessID;
+    tiUINT32            uDeliveryType;
+    TI_HANDLE           hUserParam;            /* Handle to back reference*/
+    TI_EVENT_CALLBACK   pfEventCallback;
+}IPC_EVENT_PARAMS;
+
+/* EvParams are assumed to be the first field. Any addtions shoild be made 
+    afterwards
+ */
+typedef struct _IPC_EV_DATA
+{
+    IPC_EVENT_PARAMS    EvParams;
+    tiUINT32            uBufferSize;
+    tiUINT8             uBuffer[MAX_EVENT_DATA_SIZE];
+}IPC_EV_DATA;
+
+
+/*this function will also enable event and pass all the parameters about it*/
+/* returns unique ID of registered event, to be passed later for unregister*/
+tiINT32 IPC_RegisterEvent(TI_HANDLE             hDevice,    /* Driver Handle*/
+                          IPC_EVENT_PARAMS*     pEvParams);  /* size of the structure + size of the params*/
+
+tiINT32 IPC_UnRegisterEvent(TI_HANDLE   hDevice,
+                            IPC_EVENT_PARAMS*   pEvParams); /* returned by IPC_RegisterEvent*/
+
+/***************************************************************************/
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /*_IPC_UTIL_H*/
+
diff --git a/sta_dk_4_0_4_32/common/inc/TI_Results.h b/sta_dk_4_0_4_32/common/inc/TI_Results.h
new file mode 100644 (file)
index 0000000..05d873f
--- /dev/null
@@ -0,0 +1,62 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             TI_Results.h*/
+/**/
+/* Purpose:            */
+/**/
+/*--------------------------------------------------------------------------*/
+#ifndef _TI_RESULTS_H
+#define _TI_RESULTS_H
+
+#define TI_RESULT_UNBOUND               0x00000001
+
+#define TI_RESULT_OK                0
+#define TI_RESULT_FAILED            0xFFFFFFFF  /* -1*/
+#define TI_RESULT_INVALIDE_HANDLE   0xFFFFFFFE  /* -2*/
+#define TI_RESULT_SM_NOT_FOUND      0xFFFFFFFD  /* -3*/
+#define TI_RESULT_INVALID_PARAMETER     0xFFFFFFFC  /* -4*/
+#define TI_RESULT_REGISTRY_FAILED       0xFFFFFFFB  /* -5*/
+#define TI_RESULT_NOT_ENOUGH_MEMORY     0xFFFFFFFA  /* -6*/
+#define TI_RESULT_DRIVER_ERROR          0xFFFFFFF9  /* -7*/
+#define TI_RESULT_IPC_ERROR             0xFFFFFFF8  /* -8*/
+
+
+#define TI_SUCCEEDED(Status)    (Status == TI_RESULT_OK)
+#define TI_FAILED(Status)       (Status != TI_RESULT_OK)
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/inc/bssTypes.h b/sta_dk_4_0_4_32/common/inc/bssTypes.h
new file mode 100644 (file)
index 0000000..0810f54
--- /dev/null
@@ -0,0 +1,128 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 bssTypes.h
+ *  \brief This file include public type definitions for Driver-wide BSS information
+ *  \author Ronen Kalish
+ *  \date 05-April-2005
+ */
+
+
+#ifndef __BSS_TYPES_API_H__
+#define __BSS_TYPES_API_H__
+
+#include "osDot11.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+#define MAX_NUM_OF_NEIGHBOR_APS     30
+#define MAX_SIZE_OF_BSS_TRACK_LIST  16
+/** \enum resultFrameType_e 
+ * \brief enumerates the different types for a result frame
+ */
+typedef enum
+{
+       SCAN_RFT_BEACON = 0,                                    /**< result frame is a beacon */
+       SCAN_RFT_PROBE_RESPONSE                                 /**< result frame is a probe response */
+} resultFrameType_e;
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct bssEntry_t
+ * \brief This structure contains a single BSS entry
+ */
+typedef struct
+{
+/* values in beacon with fixed length */
+    macAddress_t        BSSID;                  /**< BSSID of this entry */
+    UINT64              lastRxTSF;              /**< TSF of last received frame */
+    UINT16              beaconInterval;         /**< Beacon interval of this AP */
+    UINT16              capabilities;           /**< capabilities of this AP */
+/* IE's in beacon */
+    UINT8               DTIMPeriod;             /**< DTIm period (in beacon interval quantas */
+       resultFrameType_e       resultType;             /**< The type of frame in pBuffer */
+    UINT16              bufferLength;           /**< length of rest of beacon (or probe response) buffer */
+    UINT8*              pBuffer;                /**< rest of beacon (or probe response) buffer */
+/* Information from other sources */
+    radioBand_e         band;                   /**< band on which the AP transmits */
+    UINT8               channel;                /**< channel on which the AP transmits */
+    UINT8               rxRate;                 /**< Rate at which last frame was received */
+    UINT32              lastRxHostTimestamp;    /**< 
+                                                 * the host timestamp (in milliseconds) at which last frame 
+                                                 * was received
+                                                 */
+    INT8                RSSI;                   /**< average RSSI */
+    INT8                lastRSSI;               /** last given RSSI */
+       BOOLEAN             bNeighborAP;            /**< Indicates whether this is a neighbor AP */
+} bssEntry_t;
+
+/** \struct bssList_t
+ * \brief This structure contains the BSS list
+ */
+typedef struct
+{
+       UINT8                                   numOfEntries;                               /**< number of entries in the list */
+       bssEntry_t              BSSList[ MAX_SIZE_OF_BSS_TRACK_LIST ];      /**< list of entries */
+} bssList_t;
+
+/** \struct neighborAP_t
+ * \brief This structure contains information on one neighbor AP
+ */
+typedef struct
+{
+       macAddress_t            BSSID;                          /**< The BSSID (MAC address) of this AP */
+       UINT8                               channel;                        /**< the channel on which the AP transmits */
+       radioBand_e                         band;                           /**< the band used by the AP */
+} neighborAP_t;
+
+/** \struct neighborAPList_t
+ * \brief This structure contains a list of Neighbor APs
+ */
+typedef struct
+{
+       UINT8                               numOfEntries;                           /**< the number of entries in the list */
+       neighborAP_t            APListPtr[ MAX_NUM_OF_NEIGHBOR_APS ];   /**< a pointer to the list of APs */
+} neighborAPList_t;
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/inc/commonTypes.h b/sta_dk_4_0_4_32/common/inc/commonTypes.h
new file mode 100644 (file)
index 0000000..36a4201
--- /dev/null
@@ -0,0 +1,1133 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __COMMON_TYPES_H__
+#define __COMMON_TYPES_H__
+
+#include "osTIType.h"
+#include "osDot11.h"
+#include "tiwlnif.h"
+#include "paramMng.h"
+#include "whalDefaultParams.h"
+
+/*****************************************************************************
+ **                                                                         **
+ **                                                                         **
+ **                       CONSTANTS                                         **
+ **                                                                         **
+ **                                                                         **
+ *****************************************************************************/
+
+/************************************/
+/*      Report Module values        */
+/************************************/
+
+#define CONFIG_MGR_MODULE_LOG               (0x00)
+#define SME_SM_MODULE_LOG                   (0x01)
+#define SITE_MGR_MODULE_LOG                 (0x02)
+#define CONN_MODULE_LOG                     (0x03)
+#define MLME_SM_MODULE_LOG                  (0x04)
+#define AUTH_MODULE_LOG                     (0x05)
+#define ASSOC_MODULE_LOG                    (0x06)
+#define RX_DATA_MODULE_LOG                  (0x07)
+#define TX_DATA_MODULE_LOG                  (0x08)
+#define CTRL_DATA_MODULE_LOG                (0x09)
+#define RSN_MODULE_LOG                      (0x0A)
+#define HAL_RX_MODULE_LOG                   (0x0B)
+#define HAL_TX_MODULE_LOG                   (0x0C)
+#define HAL_CTRL_MODULE_LOG                 (0x0D)
+#define HAL_SECURITY_MODULE_LOG             (0x0E)
+#define MEM_MGR_MODULE_LOG                  (0x0F)
+#define REPORT_MODULE_LOG                   (0x10)
+#define SITE_UPDATE_MODULE_LOG              (0x11)
+#define REGULATORY_DOMAIN_MODULE_LOG        (0x12)
+#define MEASUREMENT_MNGR_MODULE_LOG         (0x13)
+#define MEASUREMENT_SRV_MODULE_LOG          (0x14)
+#define SOFT_GEMINI_MODULE_LOG              (0x15)
+#define SC_MODULE_LOG                       (0x16)
+#define EXC_MANAGER_MODULE_LOG              (0x17)
+#define ROAMING_MANAGER_MODULE_LOG          (0x18)
+#define QOS_MANAGER_MODULE_LOG              (0x19)
+#define TRAFFIC_ADM_CTRL_MODULE_LOG         (0x1A)
+#define POWER_MANAGER_MODULE_LOG            (0x1B)
+#define POWER_CONTROL_MODULE_LOG            (0x1C)      
+#define POWER_SERVER_MODULE_LOG             (0x1D)
+#define ELP_MODULE_LOG                      (0x1E)
+#define SCR_MODULE_LOG                      (0x1F)
+#define SCAN_SRV_MODULE_LOG                 (0x20)
+#define SCAN_CNCN_MODULE_LOG                (0x21)
+#define SCAN_MNGR_MODULE_LOG                (0x22)
+#define GWSI_ADAPT_MODULE_LOG               (0x23)
+#define GWSI_ADAPT_CB_MODULE_LOG            (0x24)
+#define CORE_ADAPT_MODULE_LOG               (0x25)
+#define TX_HW_QUEUE_MODULE_LOG              (0x26)
+#define TX_CTRL_BLK_MODULE_LOG              (0x27)
+#define TX_RESULT_MODULE_LOG                (0x28)
+#define TNETW_IF_MODULE_LOG                 (0x29)
+#define TNETW_ARBITER_MODULE_LOG            (0x2a)
+#define CURR_BSS_MODULE_LOG                 (0x2b)
+#define FW_EVENT_MODULE_LOG                 (0x2c)
+#define CMD_MBOX_MODULE_LOG                 (0x2d)
+#define CMDQUEUE_MODULE_LOG                 (0x2e)
+#define EVENT_MBOX_MODULE_LOG               (0x2f)
+#define TNETW_DRV_MODULE_LOG                (0x30)
+#define TNETW_XFER_MODULE_LOG               (0x31)
+#define RECOVERY_MGR_MODULE_LOG                                (0x32)
+#define RECOVERY_CTRL_MODULE_LOG                       (0x33)
+#define HW_INIT_MODULE_LOG                                     (0x34)
+
+#define WLAN_MAX_LOG_MODULES                (HW_INIT_MODULE_LOG + 1)
+
+                                            
+/************************************/      
+/*      Report Severity values      */  
+/************************************/
+#define WLAN_SEVERITY_INIT                  1
+#define WLAN_SEVERITY_INFORMATION           2
+#define WLAN_SEVERITY_WARNING               3
+#define WLAN_SEVERITY_ERROR                 4
+#define WLAN_SEVERITY_FATAL_ERROR           5
+#define WLAN_SEVERITY_SM                    6
+#define WLAN_SEVERITY_CONSOLE               7
+#define WLAN_SEVERITY_DEBUG_RX              8
+#define WLAN_SEVERITY_DEBUG_TX              9
+#define WLAN_SEVERITY_DEBUG_CONTROL        10
+#define WLAN_SEVERITY_GWSI_RECORDING       11
+
+#define WLAN_MAX_SEVERITIES                (WLAN_SEVERITY_GWSI_RECORDING + 1)
+
+
+
+#define     MAX_INFO_ELEMENT_LEN    (32)
+
+#define     IP_ADDR_LEN             4
+#define     IP_V4_ADDR_LEN          4
+#define     IP_V6_ADDR_LEN          6
+
+
+#define     MAX_MULTICAST_GROUP_ADDRS   8
+
+
+#define NUM_OF_NOISE_HISTOGRAM_COUNTERS (8)
+
+
+#define     MAX_SUPPORTED_RATES         32
+#define     RATES_SET_LEN               2
+
+#define     MIN_DEFAULT_KEY_ID          0
+#define     MAX_DEFAULT_KEY_ID          3
+
+#define     KEY_RSC_LEN                 8
+
+#define     MIN_KEY_LEN                 5
+#define     MAX_KEY_LEN                 32
+
+#define     MAX_IDENTITY_LEN            64
+#define     MAX_PASSWD_LEN              128
+
+#define     MAX_NUM_OUI                 16
+#define     DOT11_OUI_LEN               3
+                            
+/* The maximum number of multiple SSIDs that can be used in a single scan command */
+#define SCAN_MAX_SSID_NUM           (1)
+
+/* The maximum number of information elements that sent in an active scan probe request 
+   including the SSID */
+#define SCAN_MAX_INFO_ELEMENTS      (3)
+
+/* WoneIndex value when running as station */
+#define STATION_WONE_INDEX          (0)
+
+/* Power translation table definitions */
+#define NUM_POWER_LEVELS                    (4)
+#define MAX_POWER_LEVEL                                                (0)
+#define MIN_POWER_LEVEL                                                (NUM_POWER_LEVELS - 1)
+#define DBM_TO_TX_POWER_FACTOR                         10
+
+/* TX_POWER is in Dbm/10 units */
+#define MAX_TX_POWER                                           255 
+#define MIN_TX_POWER                                           0   
+#define NUM_SUB_BANDS_FOR_POWER_TABLE          5
+#define BAND_2_4_POWER_TABLE                           0
+
+#define MAX_NUM_OF_TX_RATE_CLASS_POLICIES 8 /* max num of policies */
+#define MAX_PARAM_MODULE_NUMBER         (GET_PARAM_MODULE_NUMBER(MAX_PARAM_MODULE_PARAM)) /*19*/
+#define FW_VERSION_LEN  20
+#ifndef TI_STATUS
+#define TI_STATUS systemStatus_e
+#endif
+#define NUM_OF_MAX_TRIPLET_CHANNEL (32)
+#define COUNTRY_STRING_LEN 3
+
+/* Definitions for Rx Filter MIB.                                           */
+#define PLT_MIB_RX_FILTER_PROMISCOUS_SET    (UINT8) 0x01       /* set \97 Enable: Forward all frames to host driver*/
+#define PLT_MIB_RX_FILTER_PROMISCOUS_CLEAR  (UINT8) 0x00       /* cleared \97 Disable: Do not orward all frames to the host driver*/
+#define PLT_MIB_RX_FILTER_BSSID_SET         (UINT8) 0x02       /* set \97 filter enabled: receive only those frames that match the BSSID given in the Join command*/
+#define PLT_MIB_RX_FILTER_BSSID_CLEAR       (UINT8) 0x00       /* cleared \97 filter disabled: ignore BSSID in receiving*/
+
+
+
+/*****************************************************************************
+ **                                                                         **
+ **                                                                         **
+ **                       ENUMS                                             **
+ **                                                                         **
+ **                                                                         **
+ *****************************************************************************/
+
+typedef enum
+{
+    txPolicy54 = 0,
+    txPolicy48,
+    txPolicy36,
+    txPolicy24,
+    txPolicy22,
+    txPolicy18,
+    txPolicy12,
+    txPolicy11,
+    txPolicy9,
+    txPolicy6,
+    txPolicy5_5,
+    txPolicy2,
+    txPolicy1,
+    MAX_NUM_OF_TX_RATES_IN_CLASS
+}txRateClassId_e;
+
+
+typedef enum{
+    DROP_NEW_PACKET = 0,
+    DROP_OLD_PACKET
+}qOvFlowPolicy_e;
+
+typedef enum
+{
+   SG_ENABLE                = 0,
+   SG_DISABLE                  ,
+   SG_SENSE_NO_ACTIVITY        ,
+   SG_SENSE_ACTIVE
+} SoftGeminiEnableModes_e;
+
+
+typedef enum
+{
+    IP_VER_4 = 0,
+    IP_VER_6
+} IPver_e;
+
+typedef enum
+{
+    DRV_MODULATION_NONE     = 0,
+    DRV_MODULATION_CCK      = 1,
+    DRV_MODULATION_PBCC     = 2,
+    DRV_MODULATION_QPSK     = 3,
+    DRV_MODULATION_OFDM     = 4,
+} modulationType_e;
+
+/* tx antenna */
+typedef enum
+{
+    TX_ANTENNA_2        = 0,
+    TX_ANTENNA_1        = 1
+} txAntenna_e;
+
+/* rx antenna */
+typedef enum
+{
+    RX_ANTENNA_1        = 0,
+    RX_ANTENNA_2        = 1,
+    RX_ANTENNA_FULL     = 2,
+    RX_ANTENNA_PARTIAL  = 3
+} rxAntenna_e;
+
+typedef enum
+{
+    HW_CLOCK_40_MHZ = 40,
+    HW_CLOCK_80_MHZ = 80
+} hwClock_e;
+
+typedef enum
+{
+  MAXIM                 = 0,
+  RFMD                  = 1,
+  RADIA_BG              = 2,
+  RADIA_ABG             = 3,
+  UNKNOWN_RADIO_TYPE    = 4
+} radioType_e;
+
+ /** Available cipher suites for admission control */
+typedef enum
+{
+    RSN_CIPHER_NONE     = 0,        /**< no chpiher suite */
+    RSN_CIPHER_WEP      = 1,        /**< WEP-40 chpiher suite */
+    RSN_CIPHER_TKIP     = 2,        /**< TKIP chpiher suite */
+    RSN_CIPHER_AES_WRAP = 3,        /**< AES WRAP chpiher suite */
+    RSN_CIPHER_AES_CCMP = 4,        /**< AES CCMP chpiher suite */
+    RSN_CIPHER_WEP104   = 5,        /**< WEP-104 chpiher suite */
+    RSN_CIPHER_CKIP     = 6,        /**< CKIP chpiher suite */
+    RSN_CIPHER_UNKNOWN  = 255       /**< UNKNOWN chpiher suite */
+} cipherSuite_e;
+
+
+/** RSN supported authentication suites */
+typedef enum
+{
+    RSN_AUTH_OPEN           = 0,        /*< Legacy Open authentication suite */
+    RSN_AUTH_SHARED_KEY     = 1,        /*< Legacy Shared Key authentication suite */
+    RSN_AUTH_AUTO_SWITCH    = 2,        /*< Automatic authentication suite */
+    RSN_AUTH_NONE           = 255       /*< no authentication suite */
+} authSuite_e;
+
+/* Available External authentication modes for admission control */
+typedef enum
+{
+   RSN_EXT_AUTH_MODE_OPEN           =   RSN_AUTH_OPEN,
+   RSN_EXT_AUTH_MODE_SHARED_KEY     =   RSN_AUTH_SHARED_KEY,
+   RSN_EXT_AUTH_MODE_AUTO_SWITCH    =   RSN_AUTH_AUTO_SWITCH,
+   RSN_EXT_AUTH_MODE_WPA,
+   RSN_EXT_AUTH_MODE_WPAPSK,
+   RSN_EXT_AUTH_MODE_WPANONE,
+   RSN_EXT_AUTH_MODE_WPA2,
+   RSN_EXT_AUTH_MODE_WPA2PSK,
+   RSN_EXT_AUTH_MODEMAX          /* Not a real mode, defined as upper bound */
+} externalAuthMode_e;
+
+typedef enum
+{
+    RSN_AUTH_STATUS_INVALID_TYPE                = 0x0001,
+    RSN_AUTH_STATUS_TIMEOUT                     = 0x0002,
+    RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED    = 0x0003,
+    RSN_AUTH_STATUS_CHALLENGE_TO_AP_FAILED      = 0x0004
+} authStatus_e;
+
+/************************************/
+/*      System return values.       */
+/************************************/
+#undef OK
+#undef NOK
+
+typedef enum
+{
+    /* System section */
+#if !defined(OK) || (OK!=0)
+    OK                          = 0,
+#endif
+#if !defined(NOK) || (NOK!=1)
+    NOK                         = 1,
+#endif
+    /* GWSI status */
+    GWSI_FAILED                 = 1,
+    PARAM_NOT_SUPPORTED         = 2,
+    PARAM_VALUE_NOT_VALID       = 3,
+    CONFIGURATION_NOT_VALID     = 4,
+    NO_SITE_SELECTED_YET        = 5,
+    RE_SCAN_NEEDED              = 6,
+    EXTERNAL_SET_PARAM_DENIED   = 7,
+    EXTERNAL_GET_PARAM_DENIED   = 8,
+    PARAM_MODULE_NUMBER_INVALID = 9,
+    STATION_IS_NOT_RUNNING      = 10,
+    CARD_IS_NOT_INSTALLED       = 11,
+
+    /* Data path section */
+    RX_MIC_FAILURE_ERROR        = 12,
+    RX_DECRYPT_FAILURE          = 13,
+    RX_STATUS_FAILURE           = 14,
+    TX_QUEUE_SELECTED_OK        = 15,
+    NO_TX_QUEUE_SELECTED        = 16,
+    TX_STATUS_PENDING           = 17,
+    TX_STATUS_NO_RESOURCES      = 18,
+    TX_STATUS_FAILURE           = 19,
+    TX_STATUS_OK                = 20,
+
+    /* 4x section */
+    MAKE_CONCATENATION          = 21,
+    SEND_ONE_MSDU               = 22,
+    DO_NOT_SEND_MSDU            = 23,
+    FOUR_X_DISABLE              = 24,
+
+    /* Scanning section */
+    NO_COUNTRY                  = 25,
+    SCAN_ALREADY_IN_PROGRESS    = 26,
+    NO_SCAN_IN_PROGRESS         = 27,
+
+    /* Setting same power */
+    TX_POWER_SET_SAME_VALUE  = 28,
+    /* changing service channel */
+    CHANNEL_CHANGED             = 29,
+    SUPPORT_IMMEDIATE_MEASUREMENT_ONLY = 30,
+    MEASUREMENT_TYPE_NOT_SUPPORT = 31,
+    MEASUREMENT_CAN_NOT_EXECUTED_IN_PARALLEL = 32,
+    MEASUREMENT_REQUEST_IGNORED = 33,
+    CANNOT_SET_MEASUREMENT_PARAM_WHEN_ACTIVATED = 34,
+    CANNOT_SET_CHANNEL_THAT_IS_NOT_SUPPORTED = 35,
+
+    /* rsn */
+    STATUS_BAD_KEY_PARAM = 36,
+    STATUS_RX_MIC_FAIL   = 37,
+
+    /* site Manager */
+    STATUS_FIRST_PRIMARY_SITE_SET = 38,
+
+    /*
+    Power Management
+    */
+    POWER_SAVE_802_11_SUCCESS = 39,
+    POWER_SAVE_802_11_FAIL = 40,
+    POWER_SAVE_802_11_NOT_ALLOWED = 41,
+    PENDING = 42,
+
+    /* GWSI TX packet sending status */
+    SEND_COMPLETE_SUCCESS       = 44,
+    SEND_COMPLETE_RETRY_EXCEEDED = 45,
+    SEND_COMPLETE_LIFETIME_EXCEEDED = 46,
+    SEND_COMPLETE_NO_LINK       = 47,
+    SEND_COMPLETE_MAC_CRASHED   = 48,
+    /*POWER_SAVE_802_11_NOT_ALLOWED = 39,*/
+    POWER_SAVE_802_11_IS_CURRENT = 49,
+
+    /* GWSI TX Send-Packet status */
+    SEND_PACKET_XFER_DONE   = 50, /* Xfer completed, another packet can be sent, Xfer-Done won't be called. */
+    SEND_PACKET_SUCCESS     = 51, /* Xfer in process, another packet can be sent, Xfer-Done will be called. */
+    SEND_PACKET_PENDING     = 52, /* Xfer in process, another packet CAN-NOT be sent. Xfer-Done will be called. */
+    SEND_PACKET_BUSY        = 53, /* Packet rejected due to queue lack of resources. 
+                                     Should be sent again after resources are freed on Tx-complete. */
+    SEND_PACKET_ERROR       = 54, /* Packet rejected due to API violation (sending in PENDING state or wrong params. */
+    SEND_PACKET_RECOVERY    = 55, /* Recovery happened during Xfer */
+
+    /* QoSMngr */
+    TI_WLAN_QOS_RETURN_CODES, /* detailed in tiQosTypes.h */
+
+    /* TNETWIF Return Errors */
+    TNETWIF_NONE,
+    TNETWIF_OK,
+    TNETWIF_COMPLETE,
+    TNETWIF_PENDING,
+    TNETWIF_ERROR,
+    TNETWIF_MORE,
+
+    /* Rx Data Filters */
+    RX_NO_AVAILABLE_FILTERS,
+    RX_FILTER_ALREADY_EXISTS,
+    RX_FILTER_DOES_NOT_EXIST,
+
+       /* Soft Gemini */
+       SG_REJECT_MEAS_SG_ACTIVE,
+
+} systemStatus_e;
+
+typedef enum
+{
+    NO_FAILURE = -1,
+    NO_SCAN_COMPLETE_FAILURE = 0,
+    MBOX_FAILURE,
+    HW_AWAKE_FAILURE,
+    BUS_ERROR,
+    DEVICE_ERROR,
+    TX_STUCK,
+    DISCONNECT_TIMEOUT,
+    POWER_SAVE_FAILURE,
+    MEASUREMENT_FAILURE,
+    MAX_FAILURE_EVENTS
+} failureEvent_e;
+
+/** \enum TnetWakeOn_e */
+typedef enum 
+{
+    
+    TNET_WAKE_ON_BEACON,           /**< Indicate the wake on event of the HW - beacon.
+                                    * In this event the HW configure to be awake on every beacon.
+                                    */
+
+    TNET_WAKE_ON_DTIM,             /**< Indicate the wake on event of the HW - DTIM. In this event
+                                    * the HW configure to be awake on every DITM (configure by the AP).
+                                    */
+
+    TNET_WAKE_ON_N_BEACON,          /**< Indicate the wake on event of the HW - listen interval.
+                                    * In this event the HW configure to be awake on every
+                                    * configured number of beacons.
+                                    */
+
+    TNET_WAKE_ON_N_DTIM,            /**< Indicate the wake on event of the HW - listen interval.
+                                    * In this event the HW configure to be awake on every
+                                    * configured number of beacons.
+                                    */
+
+    TNET_WAKE_ON_HOST              /**< Indicate the wake on event of the HW - Host access only
+                                    */
+                                
+}PowerMgr_TnetWakeOn_e;
+
+
+/** \enum PowerMgr_RequestFor_802_11_PS_e */
+typedef enum 
+{
+    REQUEST_TO_ENTER_POWER_SAVE_802_11,                 /**< request to enter to power save
+                                                         * of 802.11
+                                                         */
+
+    REQUEST_NOT_TO_CHANGE_POWER_SAVE_802_11,            /**< request to not change the
+                                                         * power save of 802.11
+                                                         */
+
+    REQUEST_TO_EXIT_POWER_SAVE_802_11                  /**< request to exit from power save
+                                                         * of 802.11
+                                                         */
+}PowerMgr_RequestFor_802_11_PS_e;
+
+typedef enum 
+{
+    POWER_SAVE_OFF,                  /**< power save of 802.11
+                                                         */
+
+    POWER_SAVE_ON ,                     /**< power save on 802.11
+                                                         */
+
+    POWER_SAVE_KEEP_CURRENT    /**< power save 802.11 don't change
+                                                         */
+}PowerMgr_802_11_PsMode_e;
+
+typedef enum 
+{
+    POWERAUTHO_POLICY_ELP       = 0,
+    POWERAUTHO_POLICY_PD        = 1,
+    POWERAUTHO_POLICY_AWAKE     = 2,
+    POWERAUTHO_POLICY_NUM
+} powerAutho_PowerPolicy_e;
+
+typedef enum 
+{
+    ELPCTRL_MODE_NORMAL = 0,
+    ELPCTRL_MODE_KEEP_AWAKE
+} elpCtrl_Mode_e;
+
+/*
+ * this enum defines the protocol modes of the QOS management object.
+ */
+typedef enum{
+    WME = 0,
+    NONE_QOS,
+}qosProtocols_e;
+
+typedef enum
+{
+    RX_PACKET_TYPE_DATA = 0,
+    RX_PACKET_TYPE_MANAGEMENT
+}rxPacketType_e;
+
+typedef enum
+{
+    DOT11_B_MODE    = 1,
+    DOT11_A_MODE    = 2,
+    DOT11_G_MODE    = 3,
+    DOT11_DUAL_MODE = 4,
+
+    DOT11_MAX_MODE
+} dot11mode_e;
+
+/* hw access method*/
+typedef enum
+{
+    HW_ACCESS_BUS_SLAVE_INDIRECT    = 0,
+    HW_ACCESS_BUS_SLAVE_DIRECT      = 1,
+    HW_ACCESS_BUS_MASTER            = 2
+} hwAccessMethod_e;
+
+/*
+ * this enum includes the header converting modes configured to dataCtrl object.
+ */
+typedef enum{
+    NO_CONVERT = 0,
+    QOS_CONVERT,
+    LEGACY_CONVERT,
+}headerConvetMode_e;
+
+/* * this enum defines the admission state configured to dataCtrl object.
+ */
+typedef enum{
+    ADMISSION_NOT_REQUIRED = 0,
+    ADMISSION_REQUIRED = 1,
+}admissionState_e;
+
+
+/*****************************************************************************
+ **                                                                         **
+ **                                                                         **
+ **                       TYPEDEFS                                          **
+ **                                                                         **
+ **                                                                         **
+ *****************************************************************************/
+/**<
+* Callback for 802.11 PS - Success/Fail
+*/
+typedef void (*ps802_11_NotificationCB_t)(TI_HANDLE module,
+                                          TI_STATUS thePsSuccess);
+
+/**<
+* Asynchronous init mode callback function type
+*/
+typedef void (*fnotify_t)(TI_HANDLE module, TI_STATUS status);
+                                          
+typedef struct
+{
+    UINT8 txRate[MAX_NUM_OF_TX_RATES_IN_CLASS];
+    UINT8 shortRetryLimit;
+    UINT8 longRetryLimit;
+    UINT8 flags;
+}txRateClass_t;
+
+typedef struct
+{
+    UINT32      numOfRateClasses;
+    txRateClass_t rateClass[MAX_NUM_OF_TX_RATE_CLASS_POLICIES];
+}txRatePolicy_t;
+
+PACKED_STRUCT( e2Version_t,
+
+    UINT16 major;
+    UINT8  minor;
+    UINT8  last;
+    UINT16 bugfix;
+);
+
+PACKED_STRUCT( TripletCahnnel_t,
+
+    UINT8           firstChannelNumber;
+    UINT8           numberOfChannels;
+    UINT8           maxTxPowerLevel;
+);
+
+PACKED_STRUCT( IpAddress_t,
+
+    UINT8 addr[IP_ADDR_LEN];
+);
+
+PACKED_STRUCT( informationElementHeader_t,
+
+    UINT8 eleId;
+    UINT8 eleLen;
+);
+
+PACKED_STRUCT( informationElement_t,
+
+    informationElementHeader_t  hdr;    
+    UINT8                       info[MAX_INFO_ELEMENT_LEN];             
+);
+
+PACKED_STRUCT( countryIE_t,
+
+    UINT8               CountryString[COUNTRY_STRING_LEN];
+    TripletCahnnel_t    tripletChannels[NUM_OF_MAX_TRIPLET_CHANNEL];
+);
+
+/* Struct retrieved from NVS */
+typedef struct   
+{
+       UINT8                                   uDbm[NUM_SUB_BANDS_FOR_POWER_TABLE][NUM_POWER_LEVELS]; 
+} powerLevelTable_t;
+
+PACKED_STRUCT( SoftGeminiParam_t,
+       UINT32                                                                                                          wlanRxMinRateToRespectBtHp; /* Integer rate number. Note that Fw gets it in Index rate */
+    UINT16                                                      btHpMaxTime;                          /* the maximum length of time the BT HP will be respected*/
+    UINT16                                                      wlanHpMaxTime;                     /* the maximum length of time the WLAN HP will be respected*/
+    UINT16                                                      senseDisableTimer; /* the length of time when working in SENSE mode that the BT needs to be inactive in order to DISABLE the SG*/
+    UINT16                                                      protectiveRxTimeBeforeBtHp;
+    UINT16                                                      protectiveTxTimeBeforeBtHp; 
+    UINT16                                                      protectiveRxTimeBeforeBtHpFastAp;   /*new      range: 10-20000    default: 1500*/
+    UINT16                                                      protectiveTxTimeBeforeBtHpFastAp;   /*new      range: 10-20000    default: 3000*/
+    UINT16                                                      protectiveWlanCycleTimeForFastAp;   /*new      range: 2000-65535                default: 8700*/
+    UINT16                                                      btAntiStarvationPeriod;             /* 0 - 15000Msec */
+    UINT16                                                      timeoutNextBtLpPacket;
+       UINT16                                                      wakeUpTimeBeforeBeacon;
+       UINT16                                                                                                          hpdmMaxGuardTime;                                       /* 0-50000 */
+    UINT16                                                                                                             timeoutNextWlanPacket;
+    UINT8                                                       sgAntennaType;
+    UINT8                                                       signalingType; 
+    UINT8                                                       afhLeverageOn;                      /* specifies whether to use the AFH information from the BT */
+    UINT8                                                       numberQuietCycle;
+    UINT8                                                       maxNumCts;       
+    UINT8                                                       numberOfWlanPackets;  
+    UINT8                                                       numberOfBtPackets;     
+    UINT8                                                       numberOfMissedRxForAvalancheTrigger;             /*new      range: 1-255          default: 5*/
+    UINT8                                                       wlanElpHpSupport;                                                 /* new     range: 0-1              default: 1*/
+    UINT8                                                       btAntiStarvationNumberOfCyclesWithinThePeriod; /* 0 - 15 Cycles */
+    UINT8                                                       ackModeDuringBtLpInDualAnt;
+    UINT8                                                       allowPaSdToggleDuringBtActivityEnable;
+       UINT8                                                                                                           sgAutoModeNoCts;
+       UINT8                                                                                                       numOfBtHpRespectedReq;                               
+
+); /* Parameters directly to FW */
+
+PACKED_STRUCT( interogateCmdHdr_t,
+
+    UINT16      id;
+    UINT16      len;
+);
+
+/* Struct for retrieving powerLevelTable_t with interrogate IE */
+typedef struct   
+{
+       interogateCmdHdr_t      tPowerLevelResCmdHdr;
+       powerLevelTable_t               tTable; 
+} powerLevelTableInterrogate_t;
+
+typedef struct
+{
+    interogateCmdHdr_t      noiseHistResCmdHdr;
+    UINT32  counters[NUM_OF_NOISE_HISTOGRAM_COUNTERS];
+    UINT32  numOfLostCycles;
+    UINT32  numOfTxHwGenLostCycles;
+    UINT32  numOfRxLostCycles;
+} noiseHistogramResults_t;
+/*
+ * interogateCmdCBParams_t:
+ * Note that this structure is used by the GWSI 
+ * both for setting (writing to the device) and
+ * for retreiving (Reading from the device),
+ * while being called with a completion CB
+ */
+typedef struct
+{
+    void*       CB_Func;    /* Completion CB function*/
+    TI_HANDLE   CB_handle;  /* CB handle*/
+    UINT8*      CB_buf;     /* Buffer contains the content to be written or the retrieved content*/
+} interogateCmdCBParams_t;
+
+
+typedef struct
+{
+    void*       CB_Func;
+    TI_HANDLE   CB_handle;
+    UINT8*      CB_buf;
+} configureCmdCBParams_t;
+
+PACKED_STRUCT( securityKeys_t,
+
+    keyType_e       keyType;                /* key type (WEP, TKIP etc.) */
+
+    UINT32          encLen;
+    UINT8           encKey[MAX_KEY_LEN];
+
+    UINT8           micRxKey[MAX_KEY_LEN];
+    UINT8           micTxKey[MAX_KEY_LEN];
+
+    UINT32          keyIndex;                       /* id=0 is broadcast key */
+    macAddress_t    macAddress;
+    UINT8           keyRsc[KEY_RSC_LEN];
+);
+
+
+typedef struct
+{
+    UINT8   queueID;
+    UINT8   channelType;
+    UINT8   tsid;
+    UINT32  dot11EDCATableMSDULifeTime;
+    UINT8   psScheme;
+    UINT8   ackPolicy;
+    UINT32  APSDConf[2];
+} queueTrafficParams_t;
+
+typedef struct
+{
+    UINT8  ac;
+    UINT8  cwMin;
+    UINT16 cwMax;
+    UINT8  aifsn;
+    UINT16 txopLimit;
+}acQosParams_t;
+
+PACKED_STRUCT( rxTimeOut_t, 
+    UINT16  psPoll;
+    UINT16  UPSD;
+);
+
+PACKED_STRUCT( QOS_AC_IE_ParametersRecord_t,
+
+    UINT8           ACI_AIFSN;
+    UINT8           ECWmin_ECWmax;
+    UINT16          TXOPLimit;
+);
+
+PACKED_STRUCT( ACParameters_t,
+
+    QOS_AC_IE_ParametersRecord_t        ACBEParametersRecord;
+    QOS_AC_IE_ParametersRecord_t        ACBKParametersRecord;
+    QOS_AC_IE_ParametersRecord_t        ACVIParametersRecord;
+    QOS_AC_IE_ParametersRecord_t        ACVOParametersRecord;
+);
+
+
+typedef struct{
+    UINT8          PsMode;             /*  power save mode.        */
+    UINT16           TxQueueSize;
+    UINT8            QueueIndex;
+    qOvFlowPolicy_e  QueueOvFlowPolicy;
+    UINT8    ackPolicy;
+    UINT32           MsduLifeTime;
+}acTrfcCtrl_t;
+
+typedef struct{
+    headerConvetMode_e      headerConverMode;                             /* header converting mode        */
+    BOOL                    convertTagZeroFrames;                         /* flag for converting zero tags */
+    trafficAdmState_e       admissionState;                             /* AC admission state            */
+    admissionState_e        admissionRequired;                          /* AC admission is mandatory.    */
+    acTrfcType_e            tag_ToAcClsfrTable[MAX_NUM_OF_802_1d_TAGS]; /* tag to AC classification      */
+}qosParams_t;
+
+typedef struct{
+    acTrfcCtrl_t  acTrfcCtrl;
+    qosParams_t   qosParams;
+    UINT8       *tsrsArr;
+    UINT8         tsrsArrLen;
+    UINT8         acID;
+}txDataQosParams_t;
+
+typedef struct{
+       UINT8                       voiceTspecConfigure;
+       UINT8                       videoTspecConfigure;
+}TspecConfigure_t;
+
+
+/*************************************/
+/*   TNETW Driver init table.        */
+/*************************************/
+
+PACKED_STRUCT(whalCtrl_tx_Queue_t,
+    UINT8       numDesc;
+    UINT8       priority;
+);
+
+
+PACKED_STRUCT(whalCtrl_init_t,
+    UINT8           hwAccessMethod;
+    UINT8           maxSitesFragCollect;
+    UINT8           packetDetectionThreshold;
+    UINT32          blockSize;
+    UINT8           rxDescNum;
+    UINT8           txDescNum;
+    UINT32          nullTemplateSize;
+    UINT32          beaconTemplateSize;
+    UINT32          probeRequestTemplateSize;
+    UINT32          probeResponseTemplateSize;
+    UINT32          PsPollTemplateSize;
+    UINT32          qosNullDataTemplateSize;
+    UINT32          tddRadioCalTimout;
+    UINT32          CrtRadioCalTimout;
+    int             UseMboxInterrupt;
+    int             UseTxDataInterrupt;
+    UINT32      TraceBufferSize;
+    BOOLEAN         bDoPrint;
+    UINT8           StaMacAddress[MAC_ADDR_LEN];
+    UINT8           UsePlcpHeader;
+    UINT8           numTxQueues;
+    whalCtrl_tx_Queue_t tx_attrib_queue[MAX_NUM_OF_TX_QUEUES];
+    BOOL            TxFlashEnable;
+    UINT8           rxMemBlkNumber;
+    UINT8           txMinMemBlkNumber;
+    UINT16          txCompleteTimeout;
+    UINT8           txCompleteThreshold;
+    UINT8      TxBlocksHighPercentPerAc[MAX_NUM_OF_AC];
+    UINT8      TxBlocksLowPercentPerAc[MAX_NUM_OF_AC];
+    UINT16      BeaconRxTimeout;
+    UINT16      BroadcastRxTimeout;
+    UINT8       RxBroadcastInPs;
+    UINT8       ConsecutivePsPollDeliveryFailureThreshold;
+);
+
+
+PACKED_STRUCT(halCtrlConfigParams_t,
+    UINT8                   halCtrlCalibrationChannel2_4;
+    UINT8                   halCtrlCalibrationChannel5_0;
+    UINT16                  halCtrlRtsThreshold;
+    UINT16                  halCtrlFragThreshold;
+    UINT32                  halCtrlMaxTxMsduLifetime;
+    UINT32                  halCtrlMaxRxMsduLifetime;
+    UINT8                   halCtrlRateFallbackRetry;
+    UINT16                  halCtrlListenInterval;
+    BOOL                    halCtrlEnable4x;
+    txAntenna_e             halCtrlTxAntenna;
+    rxAntenna_e             halCtrlRxAntenna;
+    UINT8                   halCtrlMacClock;
+    UINT8                   halCtrlArmClock;
+    BOOL                    halCtrlRxEnergyDetection;
+    BOOL                    halCtrlTxEnergyDetection;
+    BOOL                    halCtrlEepromLessEnable;
+    UINT16                  halCtrlBcnRxTime;
+    BOOL                    halCtrlRxDisableBroadcast;
+    BOOL                    halCtrlRecoveryEnable;
+    BOOL                    halCtrlFirmwareDebug;
+    /* hardware ACI parameters */
+    UINT8                   halCtrlACIMode;
+    UINT8                   halCtrlInputCCA;
+    UINT8                   halCtrlQualifiedCCA;
+    UINT8                   halCtrlStompForRx;
+    UINT8                   halCtrlStompForTx;
+    UINT8                   halCtrlTxCCA;
+    rxTimeOut_t             rxTimeOut;
+    UINT8                   halCtrlTxCompleteThreshold;
+    BOOL                                       WiFiWmmPS;
+
+);
+
+typedef struct
+{
+    UINT16                  gpioBitNumForRadioDisableFeature;
+}radioDisableParams_t;
+
+ /* New Power*/
+PACKED_STRUCT(PowerSrvInitParams_t,
+    /* powerMgmtConfig IE */
+    UINT8                       numNullPktRetries; 
+    UINT8                       hangOverPeriod;
+);
+
+PACKED_STRUCT( scanSrvInitParams_t,
+    UINT32                      numberOfNoScanCompleteToRecovery;
+    UINT32                      uTriggeredScanTimeOut; /* i.e. split scan */
+);
+
+PACKED_STRUCT(reportInitParams_t,
+    UINT8   SeverityTable[WLAN_MAX_SEVERITIES];
+    UINT8   ModuleTable[WLAN_MAX_LOG_MODULES];
+);
+
+PACKED_STRUCT(beaconFilterParams_t,
+    UINT8                           desiredState;
+    UINT8                           currentState;
+    UINT8                           numOfStored;
+    UINT8                           IETable[BEACON_FILTER_IE_TABLE_MAX_SIZE]; 
+    UINT8                           numOfElements;
+    UINT8                           IETableSize;
+        
+);
+
+PACKED_STRUCT(arpIpFilterParams_t,
+    UINT8                           isFilterEnabled;
+    IpAddress_t                     arpIpInitParams;    
+);
+
+PACKED_STRUCT(macAddrFilterParams_t,
+    UINT8                           isFilterEnabled;
+    UINT8                           numOfMacAddresses;
+    macAddress_t                    macAddrTable[MAX_MULTICAST_GROUP_ADDRS];
+
+);
+
+PACKED_STRUCT(txXferInitParams_t,
+    /* Duration in which HW buffer is full until recovery is triggered */
+    UINT32                      timeToTxStuckMs; 
+);
+
+PACKED_STRUCT(macPreambleParams_t,
+    UINT8                       earlyWakeUp;
+);
+
+/*
+ * TnetwDrv_InitParams_t:
+ * This structure encapsulates the initialization data required by the TnetwDrv layer
+ */
+PACKED_STRUCT(TnetwDrv_InitParams_t,
+    whalCtrl_init_t                 whalCtrl_init;
+    halCtrlConfigParams_t           halCtrlConfigParams;
+    reportInitParams_t              reportParams;
+    PowerSrvInitParams_t            PowerSrvInitParams;
+    scanSrvInitParams_t             scanSrvInitParams;
+    arpIpFilterParams_t             arpIpFilterParams;
+    macAddrFilterParams_t           macAddrFilterParams;
+    beaconFilterParams_t            beaconFilterParams;
+    txXferInitParams_t              txXferInitParams;
+    macPreambleParams_t             macPreambleParams;
+);
+
+/* PLT*/
+typedef struct 
+{
+    UINT32      FCSErrorCount;  /* increment when an FCS error is detected in a received MPDU*/
+    UINT32      TotalFrameCount;/* increment for each packet.*/        
+       UINT32      PLCPErrorCount;  /* increment when an PLCP error is detected in a received MPDU*/
+    UINT32      SeqNumMissCount; /* Increment when an sequence number of arrived packet is not in order */
+    UINT32      SeqNumMissCountRef; /* holds the reference value for seqNumMissCount test start */
+}PltRxPer_t;
+
+typedef struct 
+{
+    UINT32 chID; /* Channel number */
+    UINT32 rate;    /* index of the transmit */
+    UINT32 InterPacketDelay;/*(ms) */
+    UINT32 NumOfFrames;
+    UINT32 aPacketLength;
+    UINT32 aSeqNumMode; /* fixed / incremented */
+    macAddress_t  aPeerMacAddr;
+    UINT8 preamble;  /* {PREAMBLE_LONG | PREAMBLE_SHORT } */
+    UINT8 band; /* {PBCC_MODULATION_MASK |OFDM_MODULATION_MASK } */
+    UINT8 mode; /* {AUTO_SEQ_NUMBER | RANDOM_DATA | ZOZO_DATA} */
+    UINT8 aPadding[3];
+}PltTxContinues_t;
+
+ /* ChannelBand_t -                                                    */
+/*              This structure holds the parameters for TX carrier test and radio tune*/
+typedef struct  
+{
+    UINT32 channel; /* Channel number*/
+    UINT32 band;    /* Band */
+} ChannelBand_t;
+
+
+ /* PLT - MIBs structures */
+/* TMIB -                                                                   */
+/*              Specifies the type of a MIB element                         */
+typedef enum
+{
+    PLT_MIB_dot11StationId = 0x1001,
+    PLT_MIB_dot11MaxReceiveLifetime,
+    PLT_MIB_dot11SlotTime,
+    PLT_MIB_dot11GroupAddressesTable,
+    PLT_MIB_dot11WepDefaultKeyId,
+    PLT_MIB_dot11CurrentTxPowerLevel,
+    PLT_MIB_dot11RTSThreshold,
+
+    PLT_MIB_ctsToSelf = 0x1101,
+    PLT_MIB_arpIpAddressesTable,
+    PLT_MIB_templateFrame,
+    PLT_MIB_rxFilter,
+    PLT_MIB_beaconFilterIETable,
+    PLT_MIB_beaconFilterEnable,
+    PLT_MIB_sleepMode,
+    PLT_MIB_wlanWakeUpInterval,
+    PLT_MIB_beaconLostCount,
+    PLT_MIB_rcpiThreshold,
+    PLT_MIB_statisticsTable,
+    PLT_MIB_ibssPsConfig,
+    PLT_MIB_txRatePolicy,
+    PLT_MIB_countersTable,
+    PLT_MIB_btCoexsitenceMode,
+    PLT_MIB_btCoexistenceParameters
+} PLT_MIB_e;
+
+
+#define PLT_MAX_MULTICAST_GROUP_ADDRS 8
+
+typedef struct 
+{
+    macAddress_t   GroupTable[PLT_MAX_MULTICAST_GROUP_ADDRS];        
+       tiUINT8        bFilteringEnable;
+    tiUINT8        nNumberOfAddresses;
+}PLT_MIB_GroupAdressTable_t;
+
+
+typedef struct 
+{
+    tiUINT32    FilteringEnable;
+    UCHAR       addr[IP_V4_ADDR_LEN];
+}PLT_MIB_ArpIpAddressesTable_t;
+
+
+/* TTemplateType -                                                          */
+/*              Specifies the type of a templateFrame                       */
+typedef enum
+{                                       /* Frame type:                  */
+    PLT_TEMPLATE_TYPE_BEACON,               /* 0 for beacon template,       */
+    PLT_TEMPLATE_TYPE_PROBE_REQUEST,        /* 1 for probe request template,*/
+    PLT_TEMPLATE_TYPE_NULL_FRAME,           /* 2 for NULL data frame        */
+    PLT_TEMPLATE_TYPE_PROBE_RESPONSE,       /* 3 for probe response frame   */
+    PLT_TEMPLATE_TYPE_QOS_NULL_FRAME,       /* 4 for QOS NULL data frame    */
+    PLT_TEMPLATE_TYPE_PS_POLL,              /* 5 for PS-Poll frame          */
+} PLT_MIB_TemplateType_t;
+
+#define PLT_MIB_TEMPLATE_DATA_MAX_LEN 256
+typedef struct 
+{
+    PLT_MIB_TemplateType_t   FrameType;
+    tiUINT32                 Rate;
+    tiUINT16                 Length;
+    tiUINT8                  Data[PLT_MIB_TEMPLATE_DATA_MAX_LEN];
+}PLT_TemplateFrame_t;
+
+typedef struct 
+{
+    tiUINT32  WakeUpInterval;
+    tiUINT8   ListenInterval;    /* Listen interval in unit of the beacon/DTIM */
+}PLT_MIB_WlanWakeUpInterval_t;
+
+
+typedef struct 
+{
+    tiUINT32 PLCPErrorCount;
+    tiUINT32 FCSErrorCount;
+}PLT_MIB_CounterTable_t;
+
+
+/*the max table sized is : ( number of 221 * 8 bytes ) + ( non-221 * 2 bytes )
+  Must be synchronized with the size of ACX defined in public_infoele.h interface
+  with the FW
+*/
+#define PLT_MIB_MAX_SIZE_OF_IE_TABLE 112 
+/* NOTE: struct is only meant to be used as a pointer reference to an actual*/
+/*       buffer. Table size is not a constant and is derived from the buffer*/
+/*       size given with the WriteMIB command or readMIBComplete event      */
+typedef struct 
+{
+    UINT8   iNumberOfIEs;       /* number of information elements in table  */
+    UINT8   iIETable[PLT_MIB_MAX_SIZE_OF_IE_TABLE];         
+}PLT_SBeaconFilterIETable_t;
+
+typedef union 
+{
+     macAddress_t StationId;
+     tiUINT32 MaxReceiveLifeTime;
+     UINT32 SlotTime;
+     PLT_MIB_GroupAdressTable_t GroupAddressTable;
+     tiUINT8   WepDefaultKeyId;
+     tiUINT8   PowerLevel;
+     tiUINT16  RTSThreshold;
+     tiUINT32  CTSToSelfEnable;
+     PLT_MIB_ArpIpAddressesTable_t ArpIpAddressesTable;
+     PLT_TemplateFrame_t TemplateFrame;
+     tiUINT8  RxFilter;
+     PLT_MIB_WlanWakeUpInterval_t  WlanWakeUpInterval;
+     PLT_MIB_CounterTable_t CounterTable;
+     PLT_SBeaconFilterIETable_t BeaconFilter;
+     txRatePolicy_t txRatePolicy;
+}PLT_MIB_data_u;
+
+
+typedef struct{
+    PLT_MIB_e      aMib;  
+    UINT32         Length;
+    PLT_MIB_data_u aData;   
+}PLT_MIB_t;
+
+
+#endif /* __COMMON_TYPES_H__ */
diff --git a/sta_dk_4_0_4_32/common/inc/coreDefaultParams.h b/sta_dk_4_0_4_32/common/inc/coreDefaultParams.h
new file mode 100644 (file)
index 0000000..31993da
--- /dev/null
@@ -0,0 +1,1266 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _CORE_DEFAULT_PARAMS_H
+#define _CORE_DEFAULT_PARAMS_H
+                                 
+#if defined(__ARMCC__) 
+#include "public_infoele.h"
+#endif
+/************************************/
+/*      Min, Max & Default values   */
+/************************************/
+
+/* In this section are defined default, min & max values for parameters, according to the MIB */
+/* This values are used as following:
+        - By the OS abstraction layer in order to fill the init table with the default values
+        if the NVRAM/Registry value for the parameter is invalid
+        - By the core modules in order to perform validity check upon setting a parameter. */
+
+
+#define SITE_MGR_CHANNEL_MIN                    1
+#define SITE_MGR_CHANNEL_A_MIN                  36 /*   band A*/
+#define SITE_MGR_CHANNEL_B_G_MAX                14 /*   band B&G*/
+#define SITE_MGR_CHANNEL_MAX                    201
+#define SITE_MGR_CHANNEL_DEF                    11
+
+#define SITE_MGR_DOT_11_MODE_MIN                DOT11_B_MODE
+#define SITE_MGR_DOT_11_MODE_MAX                DOT11_DUAL_MODE
+#define SITE_MGR_DOT_11_MODE_DEF                DOT11_G_MODE
+
+#define SITE_MGR_BSSID_DEF                      "DEADDEADDEAD"
+
+#define SITE_MGR_SSID_STRING_DEF                ""
+#define SITE_MGR_SSID_LEN_DEF                   0
+
+#define SITE_MGR_BSS_TYPE_DEF                   BSS_INFRASTRUCTURE
+
+#define SITE_MGR_DEF_RATE_SET_MAX_BASIC_DEF     DRV_RATE_2M
+#define SITE_MGR_DEF_RATE_SET_MAX_ACTIVE_DEF    DRV_RATE_11M
+
+#define SITE_MGR_MGMT_FRAME_RATE_MIN            DRV_RATE_1M
+#define SITE_MGR_MGMT_FRAME_RATE_MAX            DRV_RATE_22M
+#define SITE_MGR_MGMT_FRAME_RATE_DEF            DRV_RATE_2M
+
+#define SITE_MGR_MODULATION_TYPE_DEF            DRV_MODULATION_CCK
+
+#define SITE_MGR_BEACON_INTERVAL_MIN            1
+#define SITE_MGR_BEACON_INTERVAL_MAX            65535
+#define SITE_MGR_BEACON_INTERVAL_DEF            200
+
+/* number of events to wake up on -
+    For WakeOnBeacon- Aging interval =  SITE_MGR_NUMBER_OF_EVENTS_BEFORE_AGING * BeaconInterval
+    For WakeOnDtim - Aging interval =  SITE_MGR_NUMBER_OF_EVENTS_BEFORE_AGING * BeaconInterval * DtimPeriod */
+#define SITE_MGR_NUMBER_OF_EVENTS_BEFORE_AGING_MIN  2
+#define SITE_MGR_NUMBER_OF_EVENTS_BEFORE_AGING_MAX  20
+#define SITE_MGR_NUMBER_OF_EVENTS_BEFORE_AGING_DEF  10
+
+#define SITE_MGR_NUMBER_OF_TX_FAILURE_BEFORE_AGING_MIN  3
+#define SITE_MGR_NUMBER_OF_TX_FAILURE_BEFORE_AGING_MAX  100
+#define SITE_MGR_NUMBER_OF_TX_FAILURE_BEFORE_AGING_DEF  6
+
+#define SITE_MGR_ROAMING_STATS_RESET_TIMEOUT_MIN   5        /* in seconds */
+#define SITE_MGR_ROAMING_STATS_RESET_TIMEOUT_MAX   60
+#define SITE_MGR_ROAMING_STATS_RESET_TIMEOUT_DEF   10
+
+#define SITE_MGR_LNA_BEACON_INT_COUNT_MIN       2   
+#define SITE_MGR_LNA_BEACON_INT_COUNT_MAX       0xFFFF
+#define SITE_MGR_LNA_BEACON_INT_COUNT_DEF       3
+
+#define SITE_MGR_LNA_PD_THRESHOLD_LOW_MIN       0x00    
+#define SITE_MGR_LNA_PD_THRESHOLD_LOW_MAX       0xff    
+#define SITE_MGR_LNA_PD_THRESHOLD_LOW_DEF       0x90    
+
+#define SITE_MGR_LNA_PD_THRESHOLD_HIGH_MIN      0x00    
+#define SITE_MGR_LNA_PD_THRESHOLD_HIGH_MAX      0xff    
+#define SITE_MGR_LNA_PD_THRESHOLD_HIGH_DEF      0xD5    
+
+#define SITE_MGR_LNA_EN_DINAMYC_TX_ALGO_DEF     0   
+#define SITE_MGR_LNA_EN_DINAMYC_TX_ALGO_MAX     1
+#define SITE_MGR_LNA_EN_DINAMYC_TX_ALGO_MIN     0
+
+#define SITE_MGR_PREAMBLE_TYPE_DEF              PREAMBLE_SHORT
+
+#define SITE_MGR_EXTERNAL_MODE_MIN              0
+#define SITE_MGR_EXTERNAL_MODE_MAX              1
+#define SITE_MGR_EXTERNAL_MODE_DEF              0
+
+#define SITE_MGR_PERFORM_BUILD_IN_TEST_RECOVEY_MIN      FALSE
+#define SITE_MGR_PERFORM_BUILD_IN_TEST_RECOVEY_MAX      TRUE
+#define SITE_MGR_PERFORM_BUILD_IN_TEST_RECOVEY_DEF      FALSE
+
+#define SITE_MGR_WiFiAdHoc_MIN                  0
+#define SITE_MGR_WiFiAdHoc_MAX                  1
+#define SITE_MGR_WiFiAdHoc_DEF                  0
+
+
+
+#define SITE_MGR_BROADCAST_BACKGROUND_SCAN_MIN  FALSE
+#define SITE_MGR_BROADCAST_BACKGROUND_SCAN_MAX  TRUE
+#define SITE_MGR_BROADCAST_BACKGROUND_SCAN_DEF  FALSE
+
+#define SITE_MGR_PERIODIC_BROADCAST_BACKGROUND_SCAN_MIN FALSE
+#define SITE_MGR_PERIODIC_BROADCAST_BACKGROUND_SCAN_MAX TRUE
+#define SITE_MGR_PERIODIC_BROADCAST_BACKGROUND_SCAN_DEF FALSE
+
+#define SITE_MGR_PERIODIC_BROADCAST_BACKGROUND_SCAN_INTERVAL_TIME_MIN   10000  /* in miliseconds */
+#define SITE_MGR_PERIODIC_BROADCAST_BACKGROUND_SCAN_INTERVAL_TIME_MAX   3600000
+#define SITE_MGR_PERIODIC_BROADCAST_BACKGROUND_SCAN_INTERVAL_TIME_DEF   60000
+
+#define SITE_MGR_KEEP_ALIVE_MIN                 FALSE
+#define SITE_MGR_KEEP_ALIVE_MAX                 TRUE
+#define SITE_MGR_KEEP_ALIVE_DEF                 TRUE
+
+#define SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF        44
+
+#define MAX_SITES_BG_BAND   32
+#define MAX_SITES_A_BAND    20
+#define MAX_HASH_ENTRIES    32 /* must a power of 2  and more or less the site table size */
+
+#define NUM_OF_SITE_TABLE   2
+
+/* Beacon broadcast options */
+#define BCN_RX_TIMEOUT_DEF_VALUE 10000
+#define BCN_RX_TIMEOUT_MIN_VALUE 1
+#define BCN_RX_TIMEOUT_MAX_VALUE 65535
+    
+#define        BROADCAST_RX_TIMEOUT_DEF_VALUE 20000
+#define BROADCAST_RX_TIMEOUT_MIN_VALUE 1 
+#define BROADCAST_RX_TIMEOUT_MAX_VALUE 65535
+
+#define        RX_BROADCAST_IN_PS_DEF_VALUE 1
+#define RX_BROADCAST_IN_PS_MIN_VALUE 0
+#define RX_BROADCAST_IN_PS_MAX_VALUE 1
+
+#define        CONSECUTIVE_PS_POLL_FAILURE_DEF 4
+#define CONSECUTIVE_PS_POLL_FAILURE_MIN 1
+#define CONSECUTIVE_PS_POLL_FAILURE_MAX 100
+
+#define        PS_POLL_FAILURE_PERIOD_DEF 20
+#define PS_POLL_FAILURE_PERIOD_MIN 0       /* '0' is disabled */
+#define PS_POLL_FAILURE_PERIOD_MAX 60000
+
+/*---------------------------*/
+/*  Classifier parameters    */
+/*---------------------------*/
+
+#define CLSFR_TYPE_MIN                                         1 /* 1 - Dtag, 2 - Port, 3 - IP & port */ 
+#define CLSFR_TYPE_DEF                                         3
+#define CLSFR_TYPE_MAX                                         3
+
+/* general values of D-tags */
+#define CLASSIFIER_DTAG_MIN                                    0 
+#define CLASSIFIER_DTAG_MAX                                    7
+#define CLASSIFIER_DTAG_DEF                                    0 
+
+/* general values of code points in 
+the DSCP classification table*/
+#define CLASSIFIER_CODE_POINT_MIN              0 
+#define CLASSIFIER_CODE_POINT_MAX              63
+#define CLASSIFIER_CODE_POINT_DEF              0
+
+/* general values of port numbers */
+#define CLASSIFIER_PORT_MIN                                    1 
+#define CLASSIFIER_PORT_MAX                                    65535
+#define CLASSIFIER_PORT_DEF                                    1024 
+
+/* general values of IP addresses */
+#define CLASSIFIER_IPADDRESS_MIN                       0x0                     /* TBD according to spec!*/
+#define CLASSIFIER_IPADDRESS_DEF                       0x0A030DC4      /* MY IP ... TBD according to spec!*/
+#define CLASSIFIER_IPADDRESS_MAX                       0xFFFFFFFF  /* TBD according to spec!*/
+
+/* DSCP (differentiated services code 
+point) classifier parameters  
+--------------------------------*/
+/* number of classifier entries in the 
+   classification table (in case of DSCP classifier) */
+
+#define NUM_OF_CODE_POINTS_MIN                         0
+#define NUM_OF_CODE_POINTS_MAX                         16
+#define NUM_OF_CODE_POINTS_DEF                         0
+
+/* def values of code points in the DSCP classification table*/
+#define DSCP_CLASSIFIER_CODE_POINT_DEF 0x0
+
+/* def values of D-tags in the DSCP classification table*/
+#define DSCP_CLASSIFIER_DTAG_DEF                       0
+
+/* Port Classifier parameters 
+--------------------------------*/
+
+/* number of entries in the classification table (in case of destination port classifier) */
+#define NUM_OF_PORT_CLASSIFIERS_MIN                    0
+#define NUM_OF_PORT_CLASSIFIERS_MAX                    16
+#define NUM_OF_PORT_CLASSIFIERS_DEF                    0
+
+/* def values of port numbers in the destination port classification table*/
+#define PORT_CLASSIFIER_PORT_DEF                       5000
+
+/* def values of D-tags in the destination port classification table*/
+#define PORT_CLASSIFIER_DTAG_DEF                       7
+
+/* IP&Port Classifier parameters 
+--------------------------------*/
+
+/* number of active entries in the 
+IP&Port classification table  */
+#define NUM_OF_IPPORT_CLASSIFIERS_MIN          0
+#define NUM_OF_IPPORT_CLASSIFIERS_MAX          16
+#define NUM_OF_IPPORT_CLASSIFIERS_DEF          0
+
+/* def values of IP addresses in the IP&Port classification table*/
+#define IPPORT_CLASSIFIER_IPADDRESS_DEF        167972292
+
+/* def values of port numbers in the IP&Port classification table*/
+#define IPPORT_CLASSIFIER_PORT_DEF             5004
+
+/* def values of D-tags in the IP&Port classification table*/
+#define IPPORT_CLASSIFIER_DTAG_DEF             7
+
+/* end of classifier parameters */
+
+#define MAX_USER_PRIORITY                      (7)
+
+
+
+#define  WME_ENABLED_MIN                       (FALSE)
+#define  WME_ENABLED_MAX                       (TRUE)
+#define  WME_ENABLED_DEF                       (TRUE)
+
+#define  QOS_TRAFFIC_ADM_CTRL_ENABLED_MIN                                 (FALSE)
+#define  QOS_TRAFFIC_ADM_CTRL_ENABLED_MAX                                 (TRUE) 
+#define  QOS_TRAFFIC_ADM_CTRL_ENABLED_DEF                                 (TRUE) 
+
+#define  QOS_DESIRED_PS_MODE_MIN                       PS_SCHEME_LEGACY
+#define  QOS_DESIRED_PS_MODE_MAX                       MAX_PS_SCHEME
+#define  QOS_DESIRED_PS_MODE_DEF                       PS_SCHEME_UPSD_TRIGGER
+
+#define  QOS_TAG_ZERO_PRIO_MIN                 (FALSE)
+#define  QOS_TAG_ZERO_PRIO_MAX                 (TRUE)
+#define  QOS_TAG_ZERO_PRIO_DEF                 (TRUE)
+
+
+/* for the AC */
+#define  QOS_TX_OP_CONTINUATION_MIN             0
+#define  QOS_TX_OP_CONTINUATION_MAX             1
+#define  QOS_TX_OP_CONTINUATION_DEF            1
+
+#define  QOS_TX_OP_LIMIT_MIN                   0
+#define  QOS_TX_OP_LIMIT_MAX                   32000     
+#define  QOS_TX_OP_LIMIT_DEF                   0
+
+/* for packet burst in non-qos protocol */
+#define  QOS_PACKET_BURST_ENABLE_MIN             0
+#define  QOS_PACKET_BURST_ENABLE_DEF            0
+#define  QOS_PACKET_BURST_ENABLE_MAX             1
+
+#define  QOS_PACKET_BURST_TXOP_LIMIT_MIN         0
+#define  QOS_PACKET_BURST_TXOP_LIMIT_MAX         1000     
+#define  QOS_PACKET_BURST_TXOP_LIMIT_DEF         93
+
+#define  QOS_RX_TIMEOUT_PS_POLL_MIN                0
+#define  QOS_RX_TIMEOUT_PS_POLL_MAX                (200000)
+#define  QOS_RX_TIMEOUT_PS_POLL_DEF                15
+
+#define  QOS_RX_TIMEOUT_UPSD_MIN                   0
+#define  QOS_RX_TIMEOUT_UPSD_MAX                   (200000)
+#define  QOS_RX_TIMEOUT_UPSD_DEF                   15
+
+#define  QOS_MSDU_LIFE_TIME_MIN                0
+#define  QOS_MSDU_LIFE_TIME_MAX                1024
+
+#define  QOS_MSDU_LIFE_TIME_BE_MIN             (QOS_MSDU_LIFE_TIME_MIN)
+#define  QOS_MSDU_LIFE_TIME_BE_MAX             (QOS_MSDU_LIFE_TIME_MAX)
+#define  QOS_MSDU_LIFE_TIME_BE_DEF             (512)
+
+#define  QOS_MSDU_LIFE_TIME_BK_MIN             (QOS_MSDU_LIFE_TIME_MIN)
+#define  QOS_MSDU_LIFE_TIME_BK_MAX             (QOS_MSDU_LIFE_TIME_MAX)
+#define  QOS_MSDU_LIFE_TIME_BK_DEF             (100)
+
+#define  QOS_MSDU_LIFE_TIME_VI_MIN             (QOS_MSDU_LIFE_TIME_MIN)
+#define  QOS_MSDU_LIFE_TIME_VI_MAX             (QOS_MSDU_LIFE_TIME_MAX)
+#define  QOS_MSDU_LIFE_TIME_VI_DEF             (100)
+
+#define  QOS_MSDU_LIFE_TIME_VO_MIN             (QOS_MSDU_LIFE_TIME_MIN)
+#define  QOS_MSDU_LIFE_TIME_VO_MAX             (QOS_MSDU_LIFE_TIME_MAX)
+#define  QOS_MSDU_LIFE_TIME_VO_DEF             (40)
+
+#define  QOS_TX_QUEUE_SIZE_MIN                 1
+#define  QOS_TX_QUEUE_SIZE_MAX                 128
+
+#define  QOS_TX_QUEUE0_SIZE_MIN                (QOS_TX_QUEUE_SIZE_MIN)
+#define  QOS_TX_QUEUE0_SIZE_MAX                (QOS_TX_QUEUE_SIZE_MAX)
+#define  QOS_TX_QUEUE0_SIZE_DEF                (32)
+
+#define  QOS_TX_QUEUE1_SIZE_MIN                (QOS_TX_QUEUE_SIZE_MIN)
+#define  QOS_TX_QUEUE1_SIZE_MAX                (QOS_TX_QUEUE_SIZE_MAX)
+#define  QOS_TX_QUEUE1_SIZE_DEF                (32)
+
+#define  QOS_TX_QUEUE2_SIZE_MIN                (QOS_TX_QUEUE_SIZE_MIN)
+#define  QOS_TX_QUEUE2_SIZE_MAX                (QOS_TX_QUEUE_SIZE_MAX)
+#define  QOS_TX_QUEUE2_SIZE_DEF                (32)
+
+#define  QOS_TX_QUEUE3_SIZE_MIN                (QOS_TX_QUEUE_SIZE_MIN)
+#define  QOS_TX_QUEUE3_SIZE_MAX                (QOS_TX_QUEUE_SIZE_MAX)
+#define  QOS_TX_QUEUE3_SIZE_DEF                (32)
+
+#define  QOS_WME_PS_MODE_BE_MIN                (PS_SCHEME_LEGACY)
+#define  QOS_WME_PS_MODE_BE_MAX                (MAX_PS_SCHEME)
+#define  QOS_WME_PS_MODE_BE_DEF                (PS_SCHEME_LEGACY_PSPOLL)
+
+#define  QOS_WME_PS_MODE_BK_MIN                (PS_SCHEME_LEGACY)      
+#define  QOS_WME_PS_MODE_BK_MAX                (MAX_PS_SCHEME)          
+#define  QOS_WME_PS_MODE_BK_DEF                (PS_SCHEME_LEGACY_PSPOLL)
+
+#define  QOS_WME_PS_MODE_VI_MIN                (PS_SCHEME_LEGACY)      
+#define  QOS_WME_PS_MODE_VI_MAX                (MAX_PS_SCHEME)          
+#define  QOS_WME_PS_MODE_VI_DEF                (PS_SCHEME_LEGACY_PSPOLL)
+
+#define  QOS_WME_PS_MODE_VO_MIN                (PS_SCHEME_LEGACY)      
+#define  QOS_WME_PS_MODE_VO_MAX                (MAX_PS_SCHEME)          
+#define  QOS_WME_PS_MODE_VO_DEF                (PS_SCHEME_LEGACY_PSPOLL)
+
+
+/* 
+ * new host interface method 
+ * sum of High threshold TxBlocks > 100% of Tx blocks 
+ */
+#define  QOS_TX_BLKS_HIGH_PRCNT_MIN            (0)
+#define  QOS_TX_BLKS_HIGH_PRCNT_MAX            (100)
+
+#define  QOS_TX_BLKS_HIGH_PRCNT_BK_DEF         (25)
+#define  QOS_TX_BLKS_HIGH_PRCNT_BE_DEF         (35)   
+#define  QOS_TX_BLKS_HIGH_PRCNT_VI_DEF         (35)
+#define  QOS_TX_BLKS_HIGH_PRCNT_VO_DEF         (35)
+/*
+ * sum of Low threshold TxBlocks < 100% of Tx blocks 
+ */
+#define  QOS_TX_BLKS_LOW_PRCNT_BK_DEF         (15)
+#define  QOS_TX_BLKS_LOW_PRCNT_BE_DEF         (25)   
+#define  QOS_TX_BLKS_LOW_PRCNT_VI_DEF         (25)
+#define  QOS_TX_BLKS_LOW_PRCNT_VO_DEF         (25)
+
+
+
+#define  QOS_QID_MIN                           0
+#define  QOS_QID_MAX                           3
+
+#define  QOS_AC_MIN                            QOS_QID_MIN
+#define  QOS_AC_MAX                            QOS_QID_MAX
+
+#define  QOS_AIFS_MIN                          1
+#define  QOS_AIFS_MAX                          15
+
+#define QOS_CWMIN_MIN                          0
+#define QOS_CWMIN_MAX                          15
+
+#define QOS_CWMAX_MIN                          0
+#define QOS_CWMAX_MAX                          15
+
+#define QOS_TIMEOUT_MIN                        0
+#define QOS_TIMEOUT_MAX                        65535
+
+#define QOS_ACK_POLICY_MIN                     0
+#define QOS_ACK_POLICY_MAX                     1
+
+#define QOS_TRAFFIC_TYPE_MIN                   0
+#define QOS_TRAFFIC_TYPE_MAX                   1
+
+#define QOS_SHORT_RETRY_LIMIT_MIN              1
+#define QOS_SHORT_RETRY_LIMIT_MAX              255
+#define QOS_SHORT_RETRY_LIMIT_DEF              10
+
+#define QOS_SHORT_RETRY_LIMIT_BE_MIN           (QOS_SHORT_RETRY_LIMIT_MIN)
+#define QOS_SHORT_RETRY_LIMIT_BE_MAX           (QOS_SHORT_RETRY_LIMIT_MAX)
+#define QOS_SHORT_RETRY_LIMIT_BE_DEF           (QOS_SHORT_RETRY_LIMIT_DEF)
+
+#define QOS_SHORT_RETRY_LIMIT_BK_MIN           (QOS_SHORT_RETRY_LIMIT_MIN)
+#define QOS_SHORT_RETRY_LIMIT_BK_MAX           (QOS_SHORT_RETRY_LIMIT_MAX)
+#define QOS_SHORT_RETRY_LIMIT_BK_DEF           (QOS_SHORT_RETRY_LIMIT_DEF)
+
+#define QOS_SHORT_RETRY_LIMIT_VI_MIN           (QOS_SHORT_RETRY_LIMIT_MIN)
+#define QOS_SHORT_RETRY_LIMIT_VI_MAX           (QOS_SHORT_RETRY_LIMIT_MAX)
+#define QOS_SHORT_RETRY_LIMIT_VI_DEF           (QOS_SHORT_RETRY_LIMIT_DEF)
+
+#define QOS_SHORT_RETRY_LIMIT_VO_MIN           (QOS_SHORT_RETRY_LIMIT_MIN)
+#define QOS_SHORT_RETRY_LIMIT_VO_MAX           (QOS_SHORT_RETRY_LIMIT_MAX)
+#define QOS_SHORT_RETRY_LIMIT_VO_DEF           (4)
+
+
+#define QOS_LONG_RETRY_LIMIT_MIN               1
+#define QOS_LONG_RETRY_LIMIT_MAX               255
+#define QOS_LONG_RETRY_LIMIT_DEF               4
+
+#define QOS_LONG_RETRY_LIMIT_BE_MIN           (QOS_LONG_RETRY_LIMIT_MIN)
+#define QOS_LONG_RETRY_LIMIT_BE_MAX           (QOS_LONG_RETRY_LIMIT_MAX)
+#define QOS_LONG_RETRY_LIMIT_BE_DEF           (QOS_LONG_RETRY_LIMIT_DEF)
+
+#define QOS_LONG_RETRY_LIMIT_BK_MIN           (QOS_LONG_RETRY_LIMIT_MIN)
+#define QOS_LONG_RETRY_LIMIT_BK_MAX           (QOS_LONG_RETRY_LIMIT_MAX)
+#define QOS_LONG_RETRY_LIMIT_BK_DEF           (QOS_LONG_RETRY_LIMIT_DEF)
+
+#define QOS_LONG_RETRY_LIMIT_VI_MIN           (QOS_LONG_RETRY_LIMIT_MIN)
+#define QOS_LONG_RETRY_LIMIT_VI_MAX           (QOS_LONG_RETRY_LIMIT_MAX)
+#define QOS_LONG_RETRY_LIMIT_VI_DEF           (QOS_LONG_RETRY_LIMIT_DEF)
+
+#define QOS_LONG_RETRY_LIMIT_VO_MIN           (QOS_LONG_RETRY_LIMIT_MIN)
+#define QOS_LONG_RETRY_LIMIT_VO_MAX           (QOS_LONG_RETRY_LIMIT_MAX)
+#define QOS_LONG_RETRY_LIMIT_VO_DEF           (QOS_LONG_RETRY_LIMIT_DEF)
+
+
+
+#define QOS_QUEUE_0_OVFLOW_POLICY_MIN          (DROP_NEW_PACKET)
+#define QOS_QUEUE_0_OVFLOW_POLICY_MAX          (DROP_OLD_PACKET)
+#define QOS_QUEUE_0_OVFLOW_POLICY_DEF          (DROP_NEW_PACKET)
+
+#define QOS_QUEUE_1_OVFLOW_POLICY_MIN          (DROP_NEW_PACKET)
+#define QOS_QUEUE_1_OVFLOW_POLICY_MAX          (DROP_OLD_PACKET)
+#define QOS_QUEUE_1_OVFLOW_POLICY_DEF          (DROP_NEW_PACKET)
+
+#define QOS_QUEUE_2_OVFLOW_POLICY_MIN          (DROP_NEW_PACKET)
+#define QOS_QUEUE_2_OVFLOW_POLICY_MAX          (DROP_OLD_PACKET)
+#define QOS_QUEUE_2_OVFLOW_POLICY_DEF          (DROP_NEW_PACKET)
+
+#define QOS_QUEUE_3_OVFLOW_POLICY_MIN          (DROP_NEW_PACKET)
+#define QOS_QUEUE_3_OVFLOW_POLICY_MAX          (DROP_OLD_PACKET)
+#define QOS_QUEUE_3_OVFLOW_POLICY_DEF          (DROP_NEW_PACKET)
+
+#define QOS_ACK_POLICY_BE_MIN             (ACK_POLICY_LEGACY)
+#define QOS_ACK_POLICY_BE_MAX                    (MAX_ACK_POLICY)      
+#define QOS_ACK_POLICY_BE_DEF             (ACK_POLICY_LEGACY)
+
+#define QOS_ACK_POLICY_BK_MIN             (ACK_POLICY_LEGACY)
+#define QOS_ACK_POLICY_BK_MAX                    (MAX_ACK_POLICY)   
+#define QOS_ACK_POLICY_BK_DEF             (ACK_POLICY_LEGACY)
+
+#define QOS_ACK_POLICY_VI_MIN             (ACK_POLICY_LEGACY)
+#define QOS_ACK_POLICY_VI_MAX                    (MAX_ACK_POLICY)   
+#define QOS_ACK_POLICY_VI_DEF             (ACK_POLICY_LEGACY)
+
+#define QOS_ACK_POLICY_VO_MIN             (ACK_POLICY_LEGACY)
+#define QOS_ACK_POLICY_VO_MAX                    (MAX_ACK_POLICY)   
+#define QOS_ACK_POLICY_VO_DEF             (ACK_POLICY_LEGACY)
+
+
+/* MAX_SP_LEN_VALUES
+  00 - all buffered frames 
+  01 - 2
+  10 - 4 
+  11 - 6
+*/
+
+#define QOS_MAX_SP_LEN_MIN                                             0
+#define QOS_MAX_SP_LEN_MAX                                             3
+#define QOS_MAX_SP_LEN_DEF                                             1 /* means maxSpLen = 2 (changed for SoftGemini requiremnet) */
+
+
+/*---------------------------
+      ROAMING parameters
+-----------------------------*/
+#define ROAMING_MNGR_ENABLE_MIN             0
+#define ROAMING_MNGR_ENABLE_MAX             1
+#define ROAMING_MNGR_ENABLE_DEF             0
+
+#define ROAMING_MNGR_ENABLE_PERIODIC_SCAN_MIN       0
+#define ROAMING_MNGR_ENABLE_PERIODIC_SCAN_MAX       1
+#define ROAMING_MNGR_ENABLE_PERIODIC_SCAN_DEF       0
+
+#define ROAMING_MNGR_RSSI_GAP_MIN                   0
+#define ROAMING_MNGR_RSSI_GAP_MAX                   50
+#define ROAMING_MNGR_RSSI_GAP_DEF                   10
+
+#define ROAMING_MNGR_PERIODIC_SCAN_TIEMOUT_MIN      1000
+#define ROAMING_MNGR_PERIODIC_SCAN_TIEMOUT_MAX      10000
+#define ROAMING_MNGR_PERIODIC_SCAN_TIEMOUT_DEF      3000
+
+#define ROAMING_MNGR_PERIODIC_SCAN_MIN_CH_MIN       5
+#define ROAMING_MNGR_PERIODIC_SCAN_MIN_CH_MAX       60
+#define ROAMING_MNGR_PERIODIC_SCAN_MIN_CH_DEF       5
+
+#define ROAMING_MNGR_PERIODIC_SCAN_MAX_CH_MIN       5
+#define ROAMING_MNGR_PERIODIC_SCAN_MAX_CH_MAX       60
+#define ROAMING_MNGR_PERIODIC_SCAN_MAX_CH_DEF       20
+
+#define ROAMING_MNGR_PERIODIC_SCAN_ET_MODE_MIN      0
+#define ROAMING_MNGR_PERIODIC_SCAN_ET_MODE_MAX      3
+#define ROAMING_MNGR_PERIODIC_SCAN_ET_MODE_DEF      3
+
+#define ROAMING_MNGR_PERIODIC_SCAN_MAX_NUM_FRAMES_MIN       1
+#define ROAMING_MNGR_PERIODIC_SCAN_MAX_NUM_FRAMES_MAX       30
+#define ROAMING_MNGR_PERIODIC_SCAN_MAX_NUM_FRAMES_DEF       1
+
+#define ROAMING_MNGR_PERIODIC_SCAN_NUM_PROBE_REQ_MIN        1
+#define ROAMING_MNGR_PERIODIC_SCAN_NUM_PROBE_REQ_MAX        10
+#define ROAMING_MNGR_PERIODIC_SCAN_NUM_PROBE_REQ_DEF        2
+
+/*---------------------------
+    Measurement parameters
+-----------------------------*/
+#define MEASUREMENT_TRAFFIC_THRSHLD_MIN             1       /* Packets Per Second threshold */
+#define MEASUREMENT_TRAFFIC_THRSHLD_MAX             1000
+#define MEASUREMENT_TRAFFIC_THRSHLD_DEF             400
+
+#define MEASUREMENT_MAX_DUR_NON_SRV_CHANNEL_MIN            1           /* In ms */
+#define MEASUREMENT_MAX_DUR_NON_SRV_CHANNEL_MAX             1000
+#define MEASUREMENT_MAX_DUR_NON_SRV_CHANNEL_DEF             300
+
+
+/*---------------------------
+      EXC Manager parameters
+-----------------------------*/
+#define EXC_MNGR_ENABLE_MIN             EXC_MODE_DISABLED
+#define EXC_MNGR_ENABLE_MAX             EXC_MODE_STANDBY
+#define EXC_MNGR_ENABLE_DEF             EXC_MODE_ENABLED
+
+#define EXC_TEST_IGNORE_DEAUTH_0_DEF            1
+#define EXC_TEST_IGNORE_DEAUTH_0_MIN            0
+#define EXC_TEST_IGNORE_DEAUTH_0_MAX            1
+
+#define SITE_MGR_ROAMING_TX_RATE_PERCENTAGE_MIN         30
+#define SITE_MGR_ROAMING_TX_RATE_PERCENTAGE_MAX         75
+#define SITE_MGR_ROAMING_TX_RATE_PERCENTAGE_DEF         40
+
+
+#define SITE_MGR_ROAMING_RSSI_MIN                       0
+#define SITE_MGR_ROAMING_RSSI_MAX                       100
+#define SITE_MGR_ROAMING_RSSI_DEF                       80
+
+#define SITE_MGR_ROAMING_CONS_TX_ERRORS_MIN                            1
+#define SITE_MGR_ROAMING_CONS_TX_ERRORS_MAX                            200     
+#define SITE_MGR_ROAMING_CONS_TX_ERRORS_DEF                            10
+
+
+#define SITE_MGR_POSTDISCONNECT_TIMEOUT_DEF     6000 /*6 sec*/
+#define SITE_MGR_POSTDISCONNECT_TIMEOUT_MIN     1000
+#define SITE_MGR_POSTDISCONNECT_TIMEOUT_MAX     10000
+
+#define CONN_SELF_TIMEOUT_MIN                   1 * 1000        /* 1 seconds */
+#define CONN_SELF_TIMEOUT_MAX                   60 * 1000       /* 1 minute */
+#define CONN_SELF_TIMEOUT_DEF                   10 * 1000       /* 10 seconds */
+
+#define AUTH_RESPONSE_TIMEOUT_MIN               100
+#define AUTH_RESPONSE_TIMEOUT_MAX               5000
+#define AUTH_RESPONSE_TIMEOUT_DEF               500
+
+#define AUTH_MAX_RETRY_COUNT_MIN                1
+#define AUTH_MAX_RETRY_COUNT_MAX                5
+#define AUTH_MAX_RETRY_COUNT_DEF                2
+
+#define ASSOC_RESPONSE_TIMEOUT_MIN              1000
+#define ASSOC_RESPONSE_TIMEOUT_MAX              5000
+#define ASSOC_RESPONSE_TIMEOUT_DEF              2000
+
+#define ASSOC_MAX_RETRY_COUNT_MIN               1
+#define ASSOC_MAX_RETRY_COUNT_MAX               5
+#define ASSOC_MAX_RETRY_COUNT_DEF               2
+
+#define RX_DATA_FILTERS_ENABLED_MIN      FALSE
+#define RX_DATA_FILTERS_ENABLED_MAX      TRUE
+#define RX_DATA_FILTERS_ENABLED_DEF      FALSE
+
+#define RX_DATA_FILTERS_DEFAULT_ACTION_MIN      FILTER_DROP
+#define RX_DATA_FILTERS_DEFAULT_ACTION_MAX      FILTER_FW_HANDLE
+#define RX_DATA_FILTERS_DEFAULT_ACTION_DEF      FILTER_DROP
+
+#define RX_DATA_FILTERS_FILTER_OFFSET_DEF       0
+#define RX_DATA_FILTERS_FILTER_OFFSET_MIN       0
+#define RX_DATA_FILTERS_FILTER_OFFSET_MAX       255
+
+#define RX_DATA_FILTERS_FILTER_MASK_DEF         ""
+#define RX_DATA_FILTERS_FILTER_MASK_LEN_DEF     0
+
+#define RX_DATA_FILTERS_FILTER_PATTERN_DEF      ""
+#define RX_DATA_FILTERS_FILTER_PATTERN_LEN_DEF  0
+
+#define TX_DATA_NUMBER_OF_DATA_QUEUES_MIN       1
+#define TX_DATA_NUMBER_OF_DATA_QUEUES_MAX       10
+#define TX_DATA_NUMBER_OF_DATA_QUEUES_DEF       4
+
+#define TX_DATA_CREDIT_CALC_TIMOEUT_DEF                        100
+#define TX_DATA_CREDIT_CALC_TIMOEUT_MIN                        20
+#define TX_DATA_CREDIT_CALC_TIMOEUT_MAX                        1000
+
+#define TX_DATA_FRAC_OF_LIFE_TIME_TO_DROP_DEF  50
+#define TX_DATA_FRAC_OF_LIFE_TIME_TO_DROP_MIN  1   /* 0% means we drop everything... so make it 1 */
+#define TX_DATA_FRAC_OF_LIFE_TIME_TO_DROP_MAX  100 /* don't drop anything (unless time expired)   */
+
+#define TX_DATA_ADM_CTRL_DELAY_DUE_TO_MEDIUM_OVER_USAGE_DEF                            FALSE
+#define TX_DATA_ADM_CTRL_DELAY_DUE_TO_MEDIUM_OVER_USAGE_MIN                            FALSE
+#define TX_DATA_ADM_CTRL_DELAY_DUE_TO_MEDIUM_OVER_USAGE_MAX                            TRUE
+
+#define TX_DATA_ADM_CTRL_DOWN_GRADE_DEF                        TRUE
+#define TX_DATA_ADM_CTRL_DOWN_GRADE_MIN                        FALSE
+#define TX_DATA_ADM_CTRL_DOWN_GRADE_MAX                        TRUE
+
+#define TRAFFIC_ADM_CONTROL_TIMEOUT_MIN       (10)
+#define TRAFFIC_ADM_CONTROL_TIMEOUT_MAX       (10000)
+#define TRAFFIC_ADM_CONTROL_TIMEOUT_DEF       (5000)
+
+#define CTRL_DATA_TRAFFIC_THRESHOLD_HIGH_MIN    1           /* Traffic intensity threshold - Measured in packets */
+#define CTRL_DATA_TRAFFIC_THRESHOLD_HIGH_MAX    1000
+#define CTRL_DATA_TRAFFIC_THRESHOLD_HIGH_DEF    100
+
+#define CTRL_DATA_TRAFFIC_THRESHOLD_LOW_MIN     1           /* Traffic intensity threshold - Measured in packets */
+#define CTRL_DATA_TRAFFIC_THRESHOLD_LOW_MAX     1000
+#define CTRL_DATA_TRAFFIC_THRESHOLD_LOW_DEF     25
+
+#define CTRL_DATA_TRAFFIC_THRESHOLD_INTERVAL_MIN   50       /* Traffic intensity threshold - Traffic test interval - measured in ms */
+#define CTRL_DATA_TRAFFIC_THRESHOLD_INTERVAL_MAX   10000
+#define CTRL_DATA_TRAFFIC_THRESHOLD_INTERVAL_DEF   1000
+
+#define CTRL_DATA_TRAFFIC_THRESHOLD_ENABLED_MIN FALSE
+#define CTRL_DATA_TRAFFIC_THRESHOLD_ENABLED_MAX TRUE
+#define CTRL_DATA_TRAFFIC_THRESHOLD_ENABLED_DEF FALSE
+
+#define TRAFFIC_MONITOR_MIN_INTERVAL_PERCENT_MIN   10
+#define TRAFFIC_MONITOR_MIN_INTERVAL_PERCENT_MAX   90
+#define TRAFFIC_MONITOR_MIN_INTERVAL_PERCENT_DEF   50
+
+#define CTRL_DATA_CONT_TX_THRESHOLD_MIN  2
+#define CTRL_DATA_CONT_TX_THRESHOLD_MAX  256
+#define CTRL_DATA_CONT_TX_THRESHOLD_DEF  30
+
+#define CTRL_DATA_STEP_UP_TX_THRESHOLD_MIN    2
+#define CTRL_DATA_STEP_UP_TX_THRESHOLD_MAX    256
+#define CTRL_DATA_STEP_UP_TX_THRESHOLD_DEF    10
+
+#define CTRL_DATA_FB_SHORT_INTERVAL_MIN         20
+#define CTRL_DATA_FB_SHORT_INTERVAL_MAX         2000
+#define CTRL_DATA_FB_SHORT_INTERVAL_DEF         50
+
+#define CTRL_DATA_FB_LONG_INTERVAL_MIN          100
+#define CTRL_DATA_FB_LONG_INTERVAL_MAX          10000
+#define CTRL_DATA_FB_LONG_INTERVAL_DEF          2000
+
+#define RATE_ADAPTATION_TIMEOUT_MIN             1
+#define RATE_ADAPTATION_TIMEOUT_MAX             3600
+#define RATE_ADAPTATION_TIMEOUT_DEF             300
+
+#define RATE_ADAPT_HIGH_TRSH_AC_VO_MIN                 0
+#define RATE_ADAPT_HIGH_TRSH_AC_VO_MAX                 54      
+#define RATE_ADAPT_HIGH_TRSH_AC_VO_DEF                 0
+
+#define RATE_ADAPT_HIGH_TRSH_AC_VI_MIN                 0
+#define RATE_ADAPT_HIGH_TRSH_AC_VI_MAX                 54      
+#define RATE_ADAPT_HIGH_TRSH_AC_VI_DEF                 0
+
+#define RATE_ADAPT_HIGH_TRSH_AC_BE_MIN                 0
+#define RATE_ADAPT_HIGH_TRSH_AC_BE_MAX                 54      
+#define RATE_ADAPT_HIGH_TRSH_AC_BE_DEF                 0
+
+#define RATE_ADAPT_HIGH_TRSH_AC_BK_MIN                 0
+#define RATE_ADAPT_HIGH_TRSH_AC_BK_MAX                 54      
+#define RATE_ADAPT_HIGH_TRSH_AC_BK_DEF                 0
+
+#define RATE_ADAPT_LOW_TRSH_AC_VO_MIN                  0
+#define RATE_ADAPT_LOW_TRSH_AC_VO_MAX                  54      
+#define RATE_ADAPT_LOW_TRSH_AC_VO_DEF                  0
+
+#define RATE_ADAPT_LOW_TRSH_AC_VI_MIN                  0
+#define RATE_ADAPT_LOW_TRSH_AC_VI_MAX                  54      
+#define RATE_ADAPT_LOW_TRSH_AC_VI_DEF                  0
+
+#define RATE_ADAPT_LOW_TRSH_AC_BE_MIN                  0
+#define RATE_ADAPT_LOW_TRSH_AC_BE_MAX                  54      
+#define RATE_ADAPT_LOW_TRSH_AC_BE_DEF                  0
+
+#define RATE_ADAPT_LOW_TRSH_AC_BK_MIN                  0
+#define RATE_ADAPT_LOW_TRSH_AC_BK_MAX                  54      
+#define RATE_ADAPT_LOW_TRSH_AC_BK_DEF                  0
+
+#define CTRL_DATA_RATE_CONTROL_ENABLE_MIN       FALSE
+#define CTRL_DATA_RATE_CONTROL_ENABLE_MAX       TRUE
+#define CTRL_DATA_RATE_CONTROL_ENABLE_DEF       FALSE
+
+#define CTRL_DATA_FOUR_X_ENABLE_MIN             FALSE
+#define CTRL_DATA_FOUR_X_ENABLE_MAX             TRUE
+#define CTRL_DATA_FOUR_X_ENABLE_DEF             FALSE
+
+#define CTRL_DATA_RATE_POLICY_USER_SHORT_RETRY_LIMIT_MIN 1
+#define CTRL_DATA_RATE_POLICY_USER_SHORT_RETRY_LIMIT_MAX 255
+#define CTRL_DATA_RATE_POLICY_USER_SHORT_RETRY_LIMIT_DEF 10
+
+#define CTRL_DATA_RATE_POLICY_USER_LONG_RETRY_LIMIT_MIN 1  
+#define CTRL_DATA_RATE_POLICY_USER_LONG_RETRY_LIMIT_MAX 255
+#define CTRL_DATA_RATE_POLICY_USER_LONG_RETRY_LIMIT_DEF 4  
+
+#define CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_CCK_DEF            "1,1,1,1,1,1,1,1,1,1,1,1,1"
+#define CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_PBCC_DEF   "1,1,1,1,1,1,1,1,1,1,1,1,1"
+#define CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_OFDM_DEF   "0,0,0,1,0,0,0,1,0,0,1,1,1"
+#define CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_OFDMA_DEF  "0,0,0,1,0,0,1,0,0,1,0,0,0"
+
+#define CTRL_DATA_RATE_POLICY_SG_SHORT_RETRY_LIMIT_MIN 1
+#define CTRL_DATA_RATE_POLICY_SG_SHORT_RETRY_LIMIT_MAX 255
+#define CTRL_DATA_RATE_POLICY_SG_SHORT_RETRY_LIMIT_DEF 10
+
+#define CTRL_DATA_RATE_POLICY_SG_LONG_RETRY_LIMIT_MIN 1  
+#define CTRL_DATA_RATE_POLICY_SG_LONG_RETRY_LIMIT_MAX 255
+#define CTRL_DATA_RATE_POLICY_SG_LONG_RETRY_LIMIT_DEF 4  
+
+#define CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_CCK_DEF      "1,1,1,1,1,1,1,5,1,1,1,1,1"
+#define CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_PBCC_DEF     "1,1,1,1,1,1,1,5,1,1,1,1,1"
+#define CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_OFDM_DEF     "1,1,1,1,1,1,1,5,1,1,1,1,1"
+#define CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_OFDMA_DEF    "1,1,1,1,1,1,1,5,1,1,1,1,1"
+
+#define CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN 100
+
+#define REPORT_SEVERITY_VALUE_MIN               0
+#define REPORT_SEVERITY_VALUE_MAX               0xFF
+#define REPORT_SEVERITY_VALUE_DEF               0xB8    /* WLAN_SEVERITY_WARNING | WLAN_SEVERITY_ERROR | WLAN_SEVERITY_FATAL_ERROR | WLAN_SEVERITY_CONSOLE */
+
+#define RSN_AUTH_SUITE_MIN                      RSN_AUTH_OPEN
+#define RSN_AUTH_SUITE_MAX                      RSN_AUTH_NONE
+#define RSN_AUTH_SUITE_DEF                      RSN_AUTH_OPEN
+
+#define RSN_DEFAULT_KEY_ID_MIN                  0
+#define RSN_DEFAULT_KEY_ID_MAX                  (DOT11_MAX_DEFAULT_WEP_KEYS - 1)
+#define RSN_DEFAULT_KEY_ID_DEF                  0
+
+#define RSN_PMKSA_LIFETIME_MIN                                 1                       /* 1 sec */
+#define RSN_PMKSA_LIFETIME_MAX                                 4233600         /* 49 days in sec */
+#define RSN_PMKSA_LIFETIME_DEF                                 86400           /* 1 day in sec */
+
+#define RSN_WEP_STATUS_MIN                      0
+#define RSN_WEP_STATUS_MAX                      1
+#define RSN_WEP_STATUS_DEF                      0
+
+#define RSN_WEPMIXEDMODE_ENABLED_MIN                    0
+#define RSN_WEPMIXEDMODE_ENABLED_MAX                    1
+#define RSN_WEPMIXEDMODE_ENABLED_DEF                    0
+
+#define RSN_WPAMIXEDMODE_ENABLE_MIN             0
+#define RSN_WPAMIXEDMODE_ENABLE_MAX             1
+#define RSN_WPAMIXEDMODE_ENABLE_DEF             1
+
+
+#define RSN_PREAUTH_ENABLE_MIN                  0
+#define RSN_PREAUTH_ENABLE_MAX                  1
+#define RSN_PREAUTH_ENABLE_DEF                  1
+
+#define RSN_PREAUTH_TIMEOUT_MIN                  500
+#define RSN_PREAUTH_TIMEOUT_MAX                  60000
+#define RSN_PREAUTH_TIMEOUT_DEF                  2000  /* In mSec units */
+
+
+#define  RSN_PMKIDCANDLIST_DELAY_MIN            3000
+#define  RSN_PMKIDCANDLIST_DELAY_MAX            9000
+#define  RSN_PMKIDCANDLIST_DELAY_DEF            4000
+
+
+/* 4X VALUES */
+#define DESIRED_CONCATENATION_ENABLE_DEF        TRUE
+#define DESIRED_CWMIN_ENABLE_DEF                TRUE
+#define DESIRED_CWCOMBO_ENABLE_DEF              FALSE
+#define DESIRED_ACKEMULATION_ENABLE_DEF         FALSE
+#define DESIRED_ERP_PROTECTION_ENABLE_DEF       FALSE
+#define MAX_CONCAT_SIZE_DEF                     4032
+#define IBSS_FOUR_X_MODE_PAYLOAD_SIZE           4032
+#define INFRASTRUCTURE_FOUR_X_MODE_PAYLOAD_SIZE 1300
+#define NOT_FOUR_X_MODE_PAYLOAD_SIZE            1500
+
+/* SME Values */
+
+#define ENABLE_SME_SCAN_DEF                                1
+#define ENABLE_SME_SCAN_MIN                     0
+#define ENABLE_SME_SCAN_MAX                     1
+
+#define SME_INTER_SCAN_MIN_DEF                  10000 /* 10 seconds */ 
+#define SME_INTER_SCAN_MIN_MIN                     1000
+#define SME_INTER_SCAN_MIN_MAX                 3600000
+
+#define SME_INTER_SCAN_MAX_DEF                  60000 /* 60 seconds */ 
+#define SME_INTER_SCAN_MAX_MIN                     1000
+#define SME_INTER_SCAN_MAX_MAX                 3600000
+
+#define SME_INTER_SCAN_DELTA_DEF                1000 /* 1sec*/ 
+#define SME_INTER_SCAN_DELTA_MIN                       100
+#define SME_INTER_SCAN_DELTA_MAX               10000
+
+
+/*        B\G First Scan Params              */
+/*       ----------------------              */
+#define SME_SCAN_BG_LIST_BAND_STRING_MAX_SIZE    100
+#define SME_SCAN_BG_LIST_BAND_VAL_DEF                  "1,2,3,4,5,6,7,8,9,10,11,12,13,14"   /* All chaneels */
+
+#define SME_SCAN_BG_MIN_DWELL_TIME_DEF                 30000
+#define SME_SCAN_BG_MIN_DWELL_TIME_MIN                 100
+#define SME_SCAN_BG_MIN_DWELL_TIME_MAX                 1000000
+
+#define SME_SCAN_BG_MAX_DWELL_TIME_DEF                 60000
+#define SME_SCAN_BG_MAX_DWELL_TIME_MIN                 100
+#define SME_SCAN_BG_MAX_DWELL_TIME_MAX                 1000000
+
+#define        SME_SCAN_BG_NUM_PROB_REQ_DEF                    3
+#define SME_SCAN_BG_NUM_PROB_REQ_MIN                   1
+#define SME_SCAN_BG_NUM_PROB_REQ_MAX                   5
+
+#define SME_SCAN_BG_PROB_REQ_RATE_DEF              0x2         /* Represented as bitmask */
+#define SME_SCAN_BG_PROB_REQ_RATE_MIN                  0x1                     /* 1M=0x1, 2M=0x2, 5.5M=0x4, 11M=0x8,    */
+#define SME_SCAN_BG_NUM_PROB_REQ_RATE_MAX              0x1000          /* 22M=0x10, 6M=0x20, 9M=0x40, 12M=0x80, */
+                                                                                                                       /* 18M=0x100, 24M=0x200, 36M=0x400, */
+                                                                                                                       /* 48M=0x800, 54M=0x1000 */ 
+
+#define SME_SCAN_BG_TX_POWER_DEF                               MAX_TX_POWER    /* Dbm/10 Units */
+#define SME_SCAN_BG_TX_POWER_MIN                               MIN_TX_POWER
+#define SME_SCAN_BG_TX_POWER_MAX                               MAX_TX_POWER
+
+
+/*        A First Scan Params              */
+/*       ----------------------              */
+#define SME_SCAN_A_LIST_BAND_STRING_MAX_SIZE    100
+#define SME_SCAN_A_LIST_BAND_VAL_DEF                   "36,40,44,48,52,56,60,64"   /* All chaneels */
+
+#define SME_SCAN_A_MIN_DWELL_TIME_DEF                  30000
+#define SME_SCAN_A_MIN_DWELL_TIME_MIN                  100
+#define SME_SCAN_A_MIN_DWELL_TIME_MAX                  1000000
+
+#define SME_SCAN_A_MAX_DWELL_TIME_DEF                  60000
+#define SME_SCAN_A_MAX_DWELL_TIME_MIN                  100
+#define SME_SCAN_A_MAX_DWELL_TIME_MAX                  1000000
+
+#define        SME_SCAN_A_NUM_PROB_REQ_DEF                             3
+#define SME_SCAN_A_NUM_PROB_REQ_MIN                            1
+#define SME_SCAN_A_NUM_PROB_REQ_MAX                            5
+
+#define SME_SCAN_A_PROB_REQ_RATE_DEF               0x20         /* Represented as bitmask */
+#define SME_SCAN_A_PROB_REQ_RATE_MIN                   0x20            /* 1M=0x1, 2M=0x2, 5.5M=0x4, 11M=0x8,    */
+#define SME_SCAN_A_NUM_PROB_REQ_RATE_MAX               0x1000          /* 22M=0x10, 6M=0x20, 9M=0x40, 12M=0x80, */
+                                                                                                                       /* 18M=0x100, 24M=0x200, 36M=0x400, */
+                                                                                                                       /* 48M=0x800, 54M=0x1000 */ 
+#define SME_SCAN_A_TX_POWER_DEF                                MAX_TX_POWER    /* Dbm/10 */
+#define SME_SCAN_A_TX_POWER_MIN                                MIN_TX_POWER
+#define SME_SCAN_A_TX_POWER_MAX                                MAX_TX_POWER
+
+/* Scan SRV parameters */
+#define SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_DEF            3
+#define SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_MIN            1
+#define        SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_MAX             1000000
+
+#define SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_DEF           50000
+#define SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_MIN           0
+#define        SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_MAX            0xffffffff
+
+/*
+  EEPROM-less support
+*/
+#define REG_MAC_ADDR_STR_LEN                    17
+#define REG_ARP_IP_ADDR_STR_LEN                                        11
+#define REG_MAC_ADDR_PREAMBLE_STR_LEN                  9
+#define BEACON_FILTER_STRING_MAX_LEN                   300
+
+#define HAL_CTRL_EEPROMLESS_ENABLE_DEF          1
+#define HAL_CTRL_EEPROMLESS_ENABLE_MIN          0
+#define HAL_CTRL_EEPROMLESS_ENABLE_MAX          1
+
+/* Scanning Channel Values */
+#define MAX_CHAN_BITMAP_BYTES                   (26)
+
+#define MAX_CHANNEL_IN_BAND_2_4                                        14
+
+#define SCAN_CONTROL_TABLE_ENTRY_MIN            (0x00)
+#define SCAN_CONTROL_TABLE_ENTRY_MAX            (0xff)
+#define SCAN_CONTROL_TABLE_ENTRY_DEF            (0xff)
+
+/* country code reset time out */
+#define REGULATORY_DOMAIN_COUNTRY_TIME_RESET_MIN     (1000)       /* 1 sec   */
+#define REGULATORY_DOMAIN_COUNTRY_TIME_RESET_MAX     (1000000000) /* 11 days */
+#define REGULATORY_DOMAIN_COUNTRY_TIME_RESET_DEF     (60000)      /* 60 Sec  */
+
+/* d/h Enabling */
+
+#define MULTI_REGULATORY_DOMAIN_ENABLED_MIN     (FALSE) /* 802.11d */
+#define MULTI_REGULATORY_DOMAIN_ENABLED_MAX     (TRUE)
+#define MULTI_REGULATORY_DOMAIN_ENABLED_DEF     (FALSE)
+
+#define SPECTRUM_MANAGEMENT_ENABLED_MIN         (FALSE) /* 802.11h */
+#define SPECTRUM_MANAGEMENT_ENABLED_MAX         (TRUE)
+#define SPECTRUM_MANAGEMENT_ENABLED_DEF         (FALSE)
+
+/* Tx Power table (Power level to Dbm)*/
+#define TX_POWER_LEVEL_TABLE_24                 "21,13,10,7"
+#define TX_POWER_LEVEL_TABLE_5                  "20,12,9,6" 
+
+/* Scan concentrator init parameters - default dwell time values for driver passive scan */
+#define SCAN_CNCN_DRIVER_DEFAULT_DWELL_TIME_DEF 200000
+#define SCAN_CNCN_DRIVER_DEFAULT_DWELL_TIME_MIN 10000
+#define SCAN_CNCN_DRIVER_DEFAULT_DWELL_TIME_MAX 500000
+
+#define SCAN_CNCN_MIN_DURATION_FOR_OID_SCANS_DEF 30
+#define SCAN_CNCN_MIN_DURATION_FOR_OID_SCANS_MIN 0
+#define SCAN_CNCN_MIN_DURATION_FOR_OID_SCANS_MAX 1000000
+
+/* Packet Filtering Define */
+#define MIN_NUM_OF_BEACONS_IN_BUFFER 1
+#define DEF_NUM_OF_BEACONS_IN_BUFFER 5
+#define MAX_NUM_OF_BEACONS_IN_BUFFER 10
+
+/* Soft Gemini Enabling */
+#define SOFT_GEMINI_ENABLED_MIN                                                (SG_ENABLE)
+#define SOFT_GEMINI_ENABLED_MAX                                                (SG_SENSE_NO_ACTIVITY) /* same as Auto*/
+#define SOFT_GEMINI_ENABLED_DEF                                                (SG_DISABLE)    /* we don't use SG_SENSE_ACTIVE*/
+
+#define SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_MIN                           (100)  
+#define SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_MAX                           (15000)
+#define SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_DEF                           (2000) 
+
+#define SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_MIN                                (100)
+#define SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_MAX                                (15000)
+#define SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_DEF                                (5000)
+
+#define SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_MIN                             (100)
+#define SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_MAX                             (15000)
+#define SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_DEF                             (1350)
+
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_MIN                              (10)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_MAX                              (2300)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_DEF                              (1500)
+
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_MIN                              (10)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_MAX                              (2300)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_DEF                              (1500)
+
+#define SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_MIN                               (400)
+#define SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_MAX                               (10000)
+#define SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_DEF                               (3000)
+
+#define SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_MIN                         (0)
+#define SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_MAX                         (7)
+#define SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_DEF                         (0)
+
+#define SOFT_GEMINI_PARAMS_SIGNALING_TYPE_MIN                          (0)
+#define SOFT_GEMINI_PARAMS_SIGNALING_TYPE_MAX                          (3)
+#define SOFT_GEMINI_PARAMS_SIGNALING_TYPE_DEF                          (1)
+
+#define SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_MIN                                 (0)
+#define SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_MAX                                 (2)
+#define SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_DEF                                 (0)
+
+#define SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_MIN              (0)  
+#define SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_MAX              (10)
+#define SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_DEF              (0) 
+
+#define SOFT_GEMINI_PARAMS_MAX_NUM_CTS_MIN                     (0)  
+#define SOFT_GEMINI_PARAMS_MAX_NUM_CTS_MAX                     (10)
+#define SOFT_GEMINI_PARAMS_MAX_NUM_CTS_DEF                     (3) 
+
+#define SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_MIN                  (1)  
+#define SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_MAX                  (10)
+#define SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_DEF                  (2) 
+
+#define SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_MIN                    (2)  
+#define SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_MAX                    (10)
+#define SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_DEF                    (2) 
+
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_MIN                         (10)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_MAX                         (20000)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_DEF                         (1500)
+
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_MIN                         (10)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_MAX                         (20000)
+#define SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_DEF                         (3000)
+
+#define SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_MIN                         (2000)
+#define SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_MAX                         (65535)
+#define SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_DEF                         (8700)
+
+#define SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_MIN                        (1)  
+#define SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_MAX                        (255)
+#define SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_DEF                        (5) 
+
+#define SOFT_GEMINI_PARAMS_ELP_HP_MIN                  (0)  
+#define SOFT_GEMINI_PARAMS_ELP_HP_MAX                  (1)
+#define SOFT_GEMINI_PARAMS_ELP_HP_DEF                  (0) 
+
+#define SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_MIN                      (0)  
+#define SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_MAX                      (15000)
+#define SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_DEF                      (500) 
+
+#define SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_MIN                   (0)  
+#define SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_MAX                   (15)
+#define SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_DEF                   (4) 
+
+#define SOFT_GEMINI_PARAMS_ALLOW_PA_SD_MIN                     (0)  
+#define SOFT_GEMINI_PARAMS_ALLOW_PA_SD_MAX                     (1)
+#define SOFT_GEMINI_PARAMS_ALLOW_PA_SD_DEF                     (1) 
+
+#define SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_MIN                      (0)  
+#define SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_MAX                      (20000)
+#define SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_DEF                      (6300) 
+
+
+#define SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_MIN                   (0)  
+#define SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_MAX                   (50000)
+#define SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_DEF                   (1600) 
+
+#define SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_MIN                      (100)  
+#define SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_MAX                      (50000)
+#define SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_DEF                      (2550) 
+
+#define SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_MIN                        (0)  
+#define SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_MAX                        (1)
+#define SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_DEF                        (0) 
+
+#define SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_MIN                 (0)  
+#define SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_MAX                 (20)
+#define SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_DEF                 (3) 
+
+#define SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_MIN                        (0)  
+#define SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_MAX                        (54)
+#define SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_DEF                        (24) 
+
+
+#define SOFT_GEMINI_PARAMS_ACK_MODE_MIN                                (0)  
+#define SOFT_GEMINI_PARAMS_ACK_MODE_MAX                                (1)
+#define SOFT_GEMINI_PARAMS_ACK_MODE_DEF                                (1) 
+
+#define SOFT_GEMINI_SCAN_NUMBER_OF_PROBE_REQUEST_MIN           (0)  
+#define SOFT_GEMINI_SCAN_NUMBER_OF_PROBE_REQUEST_MAX           (255)
+#define SOFT_GEMINI_SCAN_NUMBER_OF_PROBE_REQUEST_DEF           (8) 
+
+#define SOFT_GEMINI_SCAN_COMPENSATION_PERCENT_MIN                      (0)  
+#define SOFT_GEMINI_SCAN_COMPENSATION_PERCENT_MAX                      (1000)
+#define SOFT_GEMINI_SCAN_COMPENSATION_PERCENT_DEF                      (50) 
+
+#define SOFT_GEMINI_SCAN_COMPENSATION_MAX_TIME_MIN                     (1)  
+#define SOFT_GEMINI_SCAN_COMPENSATION_MAX_TIME_MAX                     (1000000)
+#define SOFT_GEMINI_SCAN_COMPENSATION_MAX_TIME_DEF                     (120000) 
+
+#define SOFT_GEMINI_BSS_LOSS_COMPENSATION_PERCENT_MIN                  (0)  
+#define SOFT_GEMINI_BSS_LOSS_COMPENSATION_PERCENT_MAX                  (1000)
+#define SOFT_GEMINI_BSS_LOSS_COMPENSATION_PERCENT_DEF                  (100) 
+
+#define WIFI_WMM_PS_MIN                        (0)  
+#define WIFI_WMM_PS_MAX                        (1)
+#define WIFI_WMM_PS_DEF                        (0) 
+
+
+/*  TX FLAGS    */
+/*--------------*/
+#define TX_DATA_MGMT_MSDU           0x0001
+#define TX_DATA_DATA_MSDU           0x0002
+#define TX_DATA_EAPOL_MSDU          0x0004
+#define TX_DATA_NULL_MSDU           0x0008 /* used for sending null frame before and after measuring a non serving channel */
+#define TX_DATA_MULTICAST_FRAME     0x0010
+#define TX_DATA_FROM_OS             0x0020
+#define TX_DATA_IAPP_MSDU           0x0040
+#define TX_DATA_PS_POLL             0x0080
+#define TX_DATA_ENCRYPT_MSDU        0x0100
+
+
+/*  TX FLAGS for tx complete 2  - used for requesting txComplete*/
+/*--------------*/
+#define TX_DATA_USE_TX_COMPLETE     0x01 /* need only for TxComplete indication */
+#define TX_DATA_DISCONNECT_TEST     0x02
+#define TX_DATA_VO_SYNC_TRIG        0x04
+#define TX_DATA_DISASSOC_SYNC_TRIG  0x08
+#define TX_DATA_DEAUTH_SYNC_TRIG    0x10
+
+
+
+/* Structures definitions */
+PACKED_STRUCT( rates_t,
+
+    UINT8       len;
+    UINT8       ratesString[MAX_SUPPORTED_RATES];
+);
+
+/* Configurable Scan Rate */
+#define SCAN_RATE_MODE_B_MIN    (DRV_RATE_1M)
+#define SCAN_RATE_MODE_B_MAX    (DRV_RATE_11M)
+#define SCAN_RATE_MODE_B_DEF    (DRV_RATE_2M)
+
+#define SCAN_RATE_MODE_G_MIN    (DRV_RATE_1M)
+#define SCAN_RATE_MODE_G_MAX    (DRV_RATE_54M)
+#define SCAN_RATE_MODE_G_DEF    (DRV_RATE_2M)
+
+#define SCAN_RATE_MODE_A_MIN    (DRV_RATE_6M)
+#define SCAN_RATE_MODE_A_MAX    (DRV_RATE_54M)
+#define SCAN_RATE_MODE_A_DEF    (DRV_RATE_6M)
+
+/* Probe request number during scan */
+#define SCAN_PROBE_REQ_NUMBER_MIN   1
+#define SCAN_PROBE_REQ_NUMBER_MAX   7
+#define SCAN_PROBE_REQ_NUMBER_DEF   3
+
+
+/*****************************************************************************
+ **         POWER MANAGER MODULE REGISTRY DEFINITIONS                       **
+ *****************************************************************************/
+/** \enum PowerMode_e */
+/* MUST be sync with OS_802_11_POWER_PROFILE */
+typedef enum 
+{
+    POWER_MODE_AUTO,        /**< In this mode the power manager module is toggle states
+                             * (ACTIVE, SHORT_DOZE and LONG_DOZE) by its own inner algorithm.
+                             */
+
+    POWER_MODE_ACTIVE,      /**< In this mode there is no power save, the host interface & the radio
+                             * is always active. The TNET is constantly awake. This mode is used,
+                             * for example, when the device is powered from an AC power source,
+                             * and provides maximum throughput and minimal latency.
+                             */
+
+    POWER_MODE_SHORT_DOZE,  /**< In this mode the system is going to ELP state and awakes (by the
+                             * FW) every beacon. The F/W wakes up the host on every Beacon passes
+                             * the Beacon to the driver and returns to ELP Doze as soon as possible.
+                             */
+
+    POWER_MODE_LONG_DOZE,    /**< In this mode the system is going to ELP state and awakes (by the
+                             * FW) every DTIM or listen interval. This mode consumes low power,
+                             * while still waking-up for Beacons once in a while. The system spends
+                             * a lot of time in ELP-Doze, and the F/W rarely wakes up the host.
+                             */
+
+    POWER_MODE_PS_ONLY,     /**< In this mode the system is setting the Ps as ON. 
+                                                        * the ELP state is changing to SHORT or LONG DOZE (According to last configuration). 
+                                                        * Auto mode won't be used here.
+                             */
+
+    POWER_MODE_MAX
+}PowerMgr_PowerMode_e;
+
+
+/** \enum PowerMgr_Priority_e */
+typedef enum 
+{
+    POWER_MANAGER_USER_PRIORITY,           /**< indicates the default user priority. */
+    POWER_MANAGER_SG_PRIORITY,             /**< Indicate the Soft Gemini priority */
+    POWER_MANAGER_PS_POLL_FAILURE_PRIORITY,/**< After receiving the PsPoll failure event */
+    POWER_MANAGER_MAX_PRIORITY                                                                         
+}PowerMgr_Priority_e;
+
+
+enum PowerMgr_registryDefinitions
+{
+    POWER_MODE_MIN_VALUE = POWER_MODE_AUTO,
+    POWER_MODE_MAX_VALUE = POWER_MODE_LONG_DOZE,
+    POWER_MODE_DEF_VALUE = POWER_MODE_AUTO,
+
+    BEACON_RECEIVE_TIME_MIN_VALUE = 10,
+    BEACON_RECEIVE_TIME_MAX_VALUE = 1000,
+    BEACON_RECEIVE_TIME_DEF_VALUE = 50,
+
+    BASE_BAND_WAKE_UP_TIME_MIN_VALUE = 100,      /* in micro seconds */
+    BASE_BAND_WAKE_UP_TIME_MAX_VALUE = 10000,
+    BASE_BAND_WAKE_UP_TIME_DEF_VALUE = 2000,
+
+    PLL_LOCK_TIME_MIN_VALUE = 500,
+    PLL_LOCK_TIME_MAX_VALUE = 20000,
+    PLL_LOCK_TIME_DEF_VALUE = 4000,
+
+    HANGOVER_PERIOD_MIN_VALUE = 5,
+    HANGOVER_PERIOD_MAX_VALUE = 255,
+    HANGOVER_PERIOD_DEF_VALUE = 5,
+
+    BEACON_LISTEN_INTERVAL_MIN_VALUE = 1,
+    BEACON_LISTEN_INTERVAL_MAX_VALUE = 50,
+    BEACON_LISTEN_INTERVAL_DEF_VALUE = 1,
+
+    DTIM_LISTEN_INTERVAL_MIN_VALUE = 1,
+    DTIM_LISTEN_INTERVAL_MAX_VALUE = 50,
+    DTIM_LISTEN_INTERVAL_DEF_VALUE = 1,
+
+    BEACON_FILTERING_MIN_VALUE = 0,
+    BEACON_FILTERING_MAX_VALUE = 30,
+    BEACON_FILTERING_DEF_VALUE = 10,
+
+    N_CONSECUTIVE_BEACONS_MISSED_MIN_VALUE = 0,
+    N_CONSECUTIVE_BEACONS_MISSED_MAX_VALUE = 50,
+    N_CONSECUTIVE_BEACONS_MISSED_DEF_VALUE = 1,
+
+    ENTER_TO_802_11_POWER_SAVE_RETRIES_MIN_VALUE = 0,
+    ENTER_TO_802_11_POWER_SAVE_RETRIES_MAX_VALUE = 50,
+    ENTER_TO_802_11_POWER_SAVE_RETRIES_DEF_VALUE = 5,
+
+    AUTO_POWER_MODE_INTERVAL_MIN_VALUE = 100,
+    AUTO_POWER_MODE_INTERVAL_MAX_VALUE = 30000,
+    AUTO_POWER_MODE_INTERVAL_DEF_VALUE = 1000,
+
+    AUTO_POWER_MODE_ACTIVE_TH_MIN_VALUE = 2,
+    AUTO_POWER_MODE_ACTIVE_TH_MAX_VALUE = 30000,
+    AUTO_POWER_MODE_ACTIVE_TH_DEF_VALUE = 15,
+
+    AUTO_POWER_MODE_DOZE_TH_MIN_VALUE = 1,
+    AUTO_POWER_MODE_DOZE_TH_MAX_VALUE = 30000,
+    AUTO_POWER_MODE_DOZE_TH_DEF_VALUE = 8,
+
+    AUTO_POWER_MODE_DOZE_MODE_MIN_VALUE = POWER_MODE_SHORT_DOZE,
+    AUTO_POWER_MODE_DOZE_MODE_MAX_VALUE = POWER_MODE_LONG_DOZE,
+    AUTO_POWER_MODE_DOZE_MODE_DEF_VALUE = POWER_MODE_LONG_DOZE,
+
+    DEFAULT_POWER_LEVEL_MIN_VALUE = POWERAUTHO_POLICY_ELP,
+    DEFAULT_POWER_LEVEL_MAX_VALUE = POWERAUTHO_POLICY_AWAKE,
+    DEFAULT_POWER_LEVEL_DEF_VALUE = POWERAUTHO_POLICY_ELP,
+
+       PS_POWER_LEVEL_MIN_VALUE = POWERAUTHO_POLICY_ELP,
+       PS_POWER_LEVEL_MAX_VALUE = POWERAUTHO_POLICY_AWAKE,
+    PS_POWER_LEVEL_DEF_VALUE = POWERAUTHO_POLICY_ELP,
+
+       POWER_MGMNT_MODE_DEF_VALUE = 1,
+    POWER_MGMNT_MODE_MIN_VALUE = 0,
+    POWER_MGMNT_MODE_MAX_VALUE = 1,
+
+       POWER_MGMNT_NEED_TO_SEND_NULL_PACKET_DEF_VALUE = 1,
+    POWER_MGMNT_NEED_TO_SEND_NULL_PACKET_MIN_VALUE = 0,
+    POWER_MGMNT_NEED_TO_SEND_NULL_PACKET_MAX_VALUE = 1,
+
+       /*
+        bit14 - "1" send Prob Request in PBCC
+        bit15 - "1" short preamble, "0" long preammle
+        bit0:bit12  Rates 
+        */
+       POWER_MGMNT_NULL_PACKET_RATE_MOD_DEF_VALUE =  ((1<<DRV_RATE_1M) | (1<<DRV_RATE_2M)),
+    POWER_MGMNT_NULL_PACKET_RATE_MOD_MIN_VALUE = 0,
+    POWER_MGMNT_NULL_PACKET_RATE_MOD_MAX_VALUE = 255 ,
+
+       POWER_MGMNT_NUM_NULL_PACKET_RETRY_DEF_VALUE = 5,
+    POWER_MGMNT_NUM_NULL_PACKET_RETRY_MIN_VALUE = 1,
+    POWER_MGMNT_NUM_NULL_PACKET_RETRY_MAX_VALUE = 255,
+};
+
+/*****************************************************************************
+ **         END POWER MANAGER MODULE REGISTRY DEFINITIONS                   **
+ *****************************************************************************/
+
+
+typedef enum
+{
+    ERP_PROTECTION_NONE       = 0,
+    ERP_PROTECTION_STANDARD   = 1,
+    ERP_PROTECTION_TI_TRICK   = 2
+} erpProtectionType_e;
+
+
+#endif /* _CORE_DEFAULT_PARAMS_H */
diff --git a/sta_dk_4_0_4_32/common/inc/memMngrEx.h b/sta_dk_4_0_4_32/common/inc/memMngrEx.h
new file mode 100644 (file)
index 0000000..6ae50e7
--- /dev/null
@@ -0,0 +1,501 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**************************************************************************/
+/*                                                                        */
+/*     MODULE:         memMngr.h                                         */
+/*      PURPOSE:        Driver memory management                          */
+/*                                                                        */
+/**************************************************************************/
+#ifndef _MEM_MNGR_H_
+#define _MEM_MNGR_H_
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "osApi.h"
+#include "TNETW_Driver_types.h"
+
+/*Ronnie: set # of MSDUs and BDs to be used in memMngrEx.c*/
+#define                DEF_NUMBER_OF_MSDUS                                                     200  /* Total number of packets queued in driver. */
+#define                DEF_NUMBER_OF_BDS                                                       400  /* Assuming typical MSDU uses 2 or 3 BDs. */
+
+#define                MIN_NUMBER_OF_BUF_POOLS                                         1
+#define                MAX_NUMBER_OF_BUF_POOLS                                         3
+
+#ifdef SUPPORT_4X
+#define                DEF_NUMBER_OF_BUF_POOLS                                         3
+#define                DEF_BUFFER_LENGTH_POOL_1                                        64
+#define                DEF_BUFFER_LENGTH_POOL_2                                        2048
+#define                DEF_BUFFER_LENGTH_POOL_3                                        4096
+#else
+#define                DEF_NUMBER_OF_BUF_POOLS                                         3
+#define                DEF_BUFFER_LENGTH_POOL_1                                        64
+#define                DEF_BUFFER_LENGTH_POOL_2                                        256
+#define                DEF_BUFFER_LENGTH_POOL_3                                        2048
+#endif
+
+#define                MIN_BUFFER_LENGTH                                                       64
+#define                MAX_BUFFER_LENGTH                                                       4096
+#define                DEF_NUMBER_OF_BUFFERS_IN_POOL_1                         160
+#define                DEF_NUMBER_OF_BUFFERS_IN_POOL_2                         160
+#define                DEF_NUMBER_OF_BUFFERS_IN_POOL_3                         160
+
+
+#define WLAN_DRV_NULL_MEM_HANDLE                                               0xffffffff 
+       
+#define NUM_OF_FREE_ARGS                                                               5
+
+#define MAX_NUM_OF_TIME_STAMPS                          8 
+
+#define memMgr_BufLength(BufAddr) ( ((mem_BD_T *)BufAddr)->length   )
+#define memMgr_BufOffset(BufAddr) ( ((mem_BD_T *)BufAddr)->dataOffset )
+#define memMgr_BufData(BufAddr)   ( ((mem_BD_T *)BufAddr)->data )
+#define memMgr_BufNext(BufAddr)   ( ((mem_BD_T *)BufAddr)->nextBDPtr )
+
+#define memMgr_MsduHdrLen(MsduAddr)            ( ((mem_MSDU_T *)MsduAddr)->headerLen )
+#define memMgr_MsduFirstLen(MsduAddr)  ( ((mem_MSDU_T *)MsduAddr)->firstBDPtr->length )
+#define memMgr_MsduHandle(MsduAddr)            ( ((mem_MSDU_T *)MsduAddr)->handle )
+/*
+ * Header resides after the Descriptor
+ */
+#define memMgr_MsduHdrAddr(MsduAddr)    ( memMgr_BufData(((mem_MSDU_T *)MsduAddr)->firstBDPtr) + \
+                                          memMgr_BufOffset(((mem_MSDU_T *)MsduAddr)->firstBDPtr) + sizeof(DbTescriptor))
+
+#define memMgr_MsduNextAddr(MsduAddr)  ( ((mem_MSDU_T *)MsduAddr)->firstBDPtr->nextBDPtr )
+#define memMgr_MsduDataAddr(MsduAddr)  ( ((mem_MSDU_T *)MsduAddr)->firstBDPtr )
+#define memMgr_MsduDataSize(MsduAddr)  ( ((mem_MSDU_T *)MsduAddr)->dataLen )
+#define memMgr_MsduNextGet(MsduAddr)   ( ((mem_MSDU_T *)MsduAddr)->nextMSDUinList)
+#define memMgr_MsduFreeFuncGet(MsduAddr)( ((mem_MSDU_T *)MsduAddr)->freeFunc)
+#define memMgr_MsduFreeArg0Get(MsduAddr)( ((mem_MSDU_T *)MsduAddr)->freeArgs[0])
+#define memMgr_MsduFreeArg1Get(MsduAddr)( ((mem_MSDU_T *)MsduAddr)->freeArgs[1])
+#define memMgr_MsduFreeArg2Get(MsduAddr)( ((mem_MSDU_T *)MsduAddr)->freeArgs[2])
+#define memMgr_MsduFreeArg3Get(MsduAddr)( ((mem_MSDU_T *)MsduAddr)->freeArgs[3])
+#define memMgr_MsduFreeArg4Get(MsduAddr)( ((mem_MSDU_T *)MsduAddr)->freeArgs[4])
+
+typedef enum
+{
+       /*
+        * Allocate on Tx
+        */
+       MLME_MODULE             = 0,
+       OS_ABS_TX_MODULE,
+       RSN_MODULE,
+       HAL_TX_MODULE,
+       CONCAT_MODULE,
+       DE_CONCAT_MODULE,
+       ACK_EMUL_MODULE,
+       TX_MODULE,
+       MEASUREMENT_MODULE,
+       SITE_MGR_MODULE,
+       EXC_MANAGER_MODULE,
+       TRACE_BUFFER_MODULE,
+       ADM_CTRL_QOS_MODULE,
+       CURRENT_BSS_MODULE,
+       /*
+        * Allocate on Rx
+        */
+       HAL_RX_MODULE,
+       CORE_RX_MODULE,
+       MLME_RX_MODULE,    
+       OS_ABS_RX_MODULE, 
+       RSN_RX_MODULE,  
+       MEASUREMENT_RX_MODULE, 
+       SITE_MGR_RX_MODULE,    
+       EXC_MANAGER_RX_MODULE, 
+
+       HAL_WEP1_RX,
+       HAL_WEP2_RX,
+       HAL_DEFRAG_RX,
+       HAL_DUPLICA_RX,
+
+       /*
+    DO NOT TOUCH - MODULE_FREE_MSDU, MAX_NUMBER_OF_MODULE!
+    */
+       MODULE_FREE_MSDU,
+    MAX_NUMBER_OF_MODULE
+
+}allocatingModule_e;
+
+
+typedef void (*ap_FreeMemFunc)(TI_HANDLE, TI_HANDLE, TI_STATUS);
+
+#ifdef TNETW_MASTER_MODE
+typedef void (*bd_FreeMemFunc)( UINT32 , UINT32, UINT32, UINT32, UINT32 );
+#endif
+
+typedef struct mem_DataBuf_T mem_DataBuf_T;
+struct mem_DataBuf_T {
+    /* READ ONLY */
+       /* The user MUST not change the following fields */
+       UINT32                  handle;                         /* Hanlde of this Data Buffer Structure */
+    mem_DataBuf_T*  nextDataBuf;    /* pointer to the next free DataBuf
+                                           when this DataBuf is in Free mode */
+       UINT32                  refCount;                       /* number of instances of this Data Buf */
+       /* PUBLIC - For the use of the User */
+       UINT32                  poolIndex;              /* the buffer pool index */
+       UINT8                   *data;                  /* pointer to the Data */
+#if defined TNETW_MASTER_MODE
+       OS_PHYSICAL_ADDRESS     data_physical; /* Physical address of the data */
+#endif
+};
+
+typedef struct mem_BD_T mem_BD_T;
+struct mem_BD_T {
+    /* READ ONLY */
+       /* The user MUST not change the following fields */
+       UINT32                  handle;                 /* Hanlde of this BD Data Structure */
+       UINT32                  refCount;               /* number of instances of this BD */
+       mem_DataBuf_T*  dataBuf;        /* pointer to the Data Buffer */
+       /* PUBLIC - For the use of the User */
+    char*           data;           /* Pointer to the Data */
+       UINT32                  dataOffset;             /* offset of the data */
+       UINT32                  length;                 /* Tx : the length of the entire data (including TxDescriptor,TNETWIF_WRITE_OFFSET_BYTES etc..) */
+                                                                       /* Rx : the length of the data (excluding TNETWIF_READ_OFFSET_BYTES)                                                    */                                      
+       mem_BD_T*               nextBDPtr;              /* pointer to the next BD */
+
+#if defined TNETW_MASTER_MODE
+       UINT32  data_physical_low;              /* Physical address (low) of the data */
+    bd_FreeMemFunc     freeFunc;               /* pointer to the Data Buffer free function */
+       UINT32                  freeArgs[NUM_OF_FREE_ARGS];     /* arguments to be send with the free function */
+#endif
+
+};
+
+typedef struct mem_MSDU_T mem_MSDU_T;
+struct mem_MSDU_T {
+    /* READ ONLY */
+       /* The user MUST not change the following fields */
+       UINT32                          handle;                 /* handle of this MSDU data structure */
+       mem_MSDU_T *            nextFreeMSDU;   /* pointer to the next Free MSDU when
+                                                                          this MSDU Buffer is in Free mode */
+       /* PUBLIC - For the use of the User */
+    UINT32                             headerLen;      /* the length of the 802.11 header */
+       mem_BD_T *                      firstBDPtr;             /* pointer to the first BD */
+       mem_BD_T *                      lastBDPtr;              /* pointer to the last BD */
+       ap_FreeMemFunc          freeFunc;               /* pointer to the Data Buffer free function */
+       UINT32                          freeArgs[NUM_OF_FREE_ARGS];     /* arguments to be send with the free function */
+       UINT32                          dataLen;                /* length of the data (only data) of the firstBDPtr */
+       allocatingModule_e      module;                 /* the allocating module */
+
+       /* support Msdu List */
+    mem_MSDU_T *               nextMSDUinList; /* pointer to the next MSDU in Tx queue link list. */
+    mem_MSDU_T *               prevMSDUinList; /* pointer to the previos MSDU in Tx queue link list. */
+       
+       
+       UINT32                          txFlags;                /* Tx flags */
+       UINT8                           txCompleteFlags;                /* Tx complete flags */
+       UINT32              insertionTime;  /* time of msdu insersion to driver. */
+       UINT8               qosTag;         /* 802.11d qos tag */
+#ifdef DM_USE_WORKQUEUE
+    mem_MSDU_T *        msdu_next;      /* Used for Workqueue list */
+#endif /* DM_USE_WORKQUEUE */
+#ifdef TI_DBG
+    UINT32              timeStamp [MAX_NUM_OF_TIME_STAMPS];   
+                                        /* array of time stamps */ 
+    UINT32              timeStampNum;   /* number of time stamps */ 
+#endif
+};
+
+typedef struct
+{
+       UINT32                  buffersSize;            /* the size of the buffers in the pool */
+       UINT32                  numFreeDataBuf;         /* number of free data buffers */
+       UINT32                  dataBufMaxNumber;       /* maximum number of buffers */
+       mem_DataBuf_T*  firstFreeDataBuf;       /* pointer to the first free Data Buffer */
+       mem_DataBuf_T*  dataBufPool;            /* list of Data Buffers */
+#ifdef TNETW_MASTER_MODE
+       OS_PHYSICAL_ADDRESS     physicalDataBufPoolPtr;
+#endif
+       UINT8*                          dataBufPoolPtr;
+
+}buffersPool_t;
+
+/* structures for initialization of Memory manager */
+typedef struct
+{
+       UINT32  numOfbuffers;
+       UINT32  buffersSize;
+}bufPoolInit_t;
+
+typedef struct
+{
+       UINT8   numOfPools;
+       bufPoolInit_t   bufPoolInit[MAX_NUMBER_OF_BUF_POOLS];
+}memMngrInit_t;
+
+/* MemMngr Control Block */
+typedef struct 
+{
+       TI_HANDLE               hReport;                        /* report handle                */
+       TI_HANDLE               hOs;                            /* Os handle                    */
+       TI_HANDLE               hCriticalSectionProtect;
+
+       UINT32                  currentNumberOfPools;
+
+       UINT32                  msduMaxNumber;          /* maximum number of MSDUs */
+       UINT32                  bdMaxNumber;            /* maximum number of BD;s */
+
+       mem_MSDU_T*     msduPool;                       /* list of MSDU Buffer Desciptors       */
+       mem_BD_T*               bdPool;                         /* list of BD Buffer Descriptors        */
+
+       mem_MSDU_T*     firstFreeMSDU;          /* pointer to the first free MSDU       */
+       mem_BD_T*               firstFreeBD;            /* pointer to the first free BD         */
+
+       UINT32                  numFreeMSDU;            /* number of free MSDU's */
+       UINT32                  numFreeBD;                      /* number of free BD's */
+
+       UINT32                  moduleAllocCount[MAX_NUMBER_OF_MODULE]; /* counters of allocated */
+                                                                                                                       /* msdu per module               */
+
+       buffersPool_t   buffersPool[MAX_NUMBER_OF_BUF_POOLS];   /* Pools of Data Buffers */
+
+}memMngr_t;
+
+typedef struct 
+{
+       UINT32 numOfFreeBufPool1;
+       UINT32 numOfFreeBufPool2;
+       UINT32 numOfFreeBufPool3;
+       UINT32 numOfFreeBDs;
+       UINT32 numOfFreeMsdu;
+}memMgrResources_t;
+
+/*************************************************************************
+ *                        wlan_memMngrInit                                  *
+ *************************************************************************
+DESCRIPTION: Init of the Memory Manager module
+
+INPUT:
+OUTPUT:
+RETURN:      OK/NOK
+**************************************************************************/
+TI_HANDLE wlan_memMngrInit(TI_HANDLE hOs);
+
+/*************************************************************************
+ *                        wlan_memMngrDestroy                            *
+ *************************************************************************
+DESCRIPTION:
+
+
+
+INPUT:      
+OUTPUT:     
+
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrDestroy(TI_HANDLE hMemMngr);
+
+/*************************************************************************
+ *                        wlan_memMngrConfigure                           *
+ *************************************************************************
+DESCRIPTION:
+
+
+
+INPUT:      
+OUTPUT:    
+
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrConfigure(TI_HANDLE hMemMngr, TI_HANDLE hOs, TI_HANDLE hReport);
+
+/*************************************************************************
+ *                        wlan_memMngrAllocDataBuf                           *
+ *************************************************************************
+DESCRIPTION:This function allocates BDs and Data Buffers according to the
+                       required length. The memory manager will allocate the Data
+                       Buffers, update the buffer pointer in the BD structure and link
+                       the BDs when more than one Data Buffer is required.
+
+INPUT:      len - the length of the required data buffer
+OUTPUT:     BDPtr - a pointer in which this function will return a pointer
+                                       to the allocated BD
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocDataBuf(TI_HANDLE hMemMngr, mem_BD_T** bdPtr, UINT32 len);
+
+/*************************************************************************
+ *                        wlan_memMngrAllocBDs                                  *
+ *************************************************************************
+DESCRIPTION:This function allocates and returns a pointer to an array of BDs.
+                       This function does not allocate any memory buffers.
+
+INPUT:      BDsNumber - number of required BDs
+OUTPUT:     BDsPtr - a pointer in which this function will return a pointer
+                                        to an array of BD pointers
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocBDs(TI_HANDLE hMemMngr, UINT32 bdNumber, mem_BD_T** bdPtr);
+
+/*************************************************************************
+ *                        wlan_memMngrAllocMSDU                          *
+ *************************************************************************
+DESCRIPTION:This function allocates MPDU structure.
+
+INPUT:         len - the length of the required data buffer
+                    if len=0, than only MSDU buffer will be allocated
+OUTPUT:     MSDUPtr - a pointer in which this function will return a pointer
+                                         to the MSDU structure
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocMSDU (TI_HANDLE hMemMngr, mem_MSDU_T** MSDUPtr,     
+                                                         UINT32 len, allocatingModule_e module);
+
+/*************************************************************************
+ *                        wlan_memMngrAllocMSDUBufferOnly                   *
+ *************************************************************************
+DESCRIPTION:This function allocates MPDU structure - without Data Buffers
+
+INPUT:
+OUTPUT:     MSDUPtr - a pointer in which this function will return a pointer
+                                         to the MSDU structure
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocMSDUBufferOnly(TI_HANDLE hMemMngr, mem_MSDU_T** MSDUPtr, 
+                                                                          allocatingModule_e module);
+
+/*************************************************************************
+ *                        wlan_memMngrDuplicateMSDU                      *
+ *************************************************************************
+DESCRIPTION:This function duplicates the MSDU.
+
+INPUT:      handle - handle of the MSDU the user want to duplicate
+OUTPUT:     newHandle - pointer in which this function sets the handle of
+                    the duplicated MSDU.
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrDuplicateMSDU(TI_HANDLE hMemMngr, UINT32 handle, UINT32* newHandle);
+
+/*************************************************************************
+ *                        wlan_memMngrFreeMSDU                                  *
+ *************************************************************************
+DESCRIPTION:Free MSDU structure. This function will free all BDs and Data
+                       Buffers that are bind to this MSDU.
+
+INPUT:      handle - handle of this MSDU
+OUTPUT:
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrFreeMSDU(TI_HANDLE hMemMngr, UINT32 handle);
+
+/*************************************************************************
+ *                                                                                                                              *
+ *************************************************************************
+DESCRIPTION:
+INPUT:      
+OUTPUT:
+RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrFreeListOfMSDU(TI_HANDLE hMemMngr, UINT32 handle);
+
+
+/*************************************************************************
+ *                        wlan_memMngrFreeBD                            *
+ *************************************************************************
+DESCRIPTION:Free BD structure. This function will free a list of BD
+                       structures and the Data Buffer that is being pointed by these BD
+                       if any. (e.g. - free MPDU)
+
+INPUT:      handle - handle of this BD
+OUTPUT:
+RETURN:     freeFlag - return TRUE if this BD list was freed
+                       return FALSE if this BD list was not freed (refCount>0)
+**************************************************************************/
+UINT32 wlan_memMngrFreeBD(TI_HANDLE hMemMngr, UINT32 handle);
+
+/*************************************************************************
+ *                                                                                              *
+ *************************************************************************
+DESCRIPTION:
+
+INPUT:      
+OUTPUT:
+RETURN:     
+**************************************************************************/
+TI_STATUS wlan_memMngrFreeAllOsAlocatesBuffer(TI_HANDLE hMemMngr);
+
+/*************************************************************************
+ *                                                                                              *
+ *************************************************************************
+DESCRIPTION:
+
+INPUT:      
+OUTPUT:
+RETURN:     
+**************************************************************************/
+TI_STATUS wlan_memMngrCopyMsduFreeFunc(TI_HANDLE hMemMngr, UINT32 destMsduHandle, UINT32 sourceMsduHandle);
+
+/*************************************************************************
+ *                                                                                              *
+ *************************************************************************
+DESCRIPTION:
+
+INPUT:      
+OUTPUT:
+RETURN:     
+**************************************************************************/
+TI_STATUS wlan_memMngrGetMemMgrResources(TI_HANDLE hMemMngr, memMgrResources_t* memMgrResources);
+
+/*************************************************************************
+ *                                                                                              *
+ *************************************************************************
+DESCRIPTION:
+
+INPUT:      
+OUTPUT:
+RETURN:     
+**************************************************************************/
+TI_STATUS wlan_memMngrChangeMsduOwner(TI_HANDLE hMemMngr,allocatingModule_e newModule,mem_MSDU_T *pMsdu);
+
+
+TI_STATUS wlan_memMngrSwapMsdu(TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu_1, mem_MSDU_T *pMsdu_2);
+
+
+TI_STATUS wlan_memMngrAddTimeStamp (TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu);
+
+/*************************************************************************
+ *                                               TEST_FUNCTIONS                                 *
+ *************************************************************************/
+void memMngrPrintHandle(TI_HANDLE hMemMngr, UINT32 handle);
+void memMngrFullPrint(TI_HANDLE hMemMngr);
+void memMngrPrint(TI_HANDLE hMemMngr);
+
+/*test function*/
+TI_STATUS txDataSTUB_txSendMsdu(TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu);
+void print_MsduDataHeader(TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu);
+void memMngrPrintMSDUWithItsBds(mem_MSDU_T* pMsdu );
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/inc/osDot11.h b/sta_dk_4_0_4_32/common/inc/osDot11.h
new file mode 100644 (file)
index 0000000..0a8e926
--- /dev/null
@@ -0,0 +1,774 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             osDot11.h                                           */
+/*                                                                          */
+/* Purpose:                                                                 */
+/*                                                                          */
+/*--------------------------------------------------------------------------*/
+#ifndef __OSDOT11_H__
+#define __OSDOT11_H__
+
+#include "osTIType.h"
+#include "tiQosTypes.h"
+/*#include "public_types.h"*/
+
+
+#define     MAC_ADDR_LEN            6
+PACKED_STRUCT( macAddress_t,
+                         
+  UINT8 addr[MAC_ADDR_LEN];
+);
+
+
+
+#define        OS_STATUS_MEDIA_SPECIFIC_INDICATION     ((NDIS_STATUS)0x40010012L)
+
+#define OS_802_11_REQUEST_REAUTH                                       0x01
+#define OS_802_11_REQUEST_KEYUPDATE                                    0x02
+#define OS_802_11_REQUEST_PAIRWISE_ERROR                       0x06
+#define OS_802_11_REQUEST_GROUP_ERROR                          0x0E
+
+/**/
+/*  Per-packet information for Ieee8021QInfo.*/
+/**/
+typedef struct _OS_PACKET_8021Q_INFO
+{
+    union
+    {
+        struct
+        {
+            UINT32      UserPriority:3;         /* 802.1p priority*/
+            UINT32      CanonicalFormatId:1;    /* always 0*/
+            UINT32      VlanId:12;              /* VLAN Identification*/
+            UINT32      Reserved:16;            /* set to 0*/
+        }   TagHeader;
+
+        PVOID  Value;
+    }u;
+} OS_PACKET_8021Q_INFO, *POS_PACKET_8021Q_INFO;
+
+typedef tiUINT8 OS_802_11_MAC_ADDRESS[6];
+
+typedef tiULONGLONG OS_802_11_KEY_RSC;
+
+PACKED_STRUCT( _OS_802_11_SSID,
+
+    tiUINT32 SsidLength;
+    tiUINT8  Ssid[32];
+); 
+typedef _OS_802_11_SSID OS_802_11_SSID, *POS_802_11_SSID;
+
+typedef enum _OS_802_11_NETWORK_TYPE
+{
+  os802_11FH,
+  os802_11DS,
+  os802_11OFDM5,
+  os802_11OFDM24,
+  os802_11Automode,
+  os802_11NetworkTypeMax
+} OS_802_11_NETWORK_TYPE;
+
+PACKED_STRUCT( _OS_802_11_NETWORK_TYPE_LIST ,
+
+  tiUINT32                  NumberOfItems;
+  OS_802_11_NETWORK_TYPE NetworkType [1];
+);
+typedef _OS_802_11_NETWORK_TYPE_LIST OS_802_11_NETWORK_TYPE_LIST, *POS_802_11_NETWORK_TYPE_LIST;
+
+typedef enum _OS_802_11_POWER_MODE
+{
+  /*Continuous access mode (CAM). */
+  /*When the power mode is set to CAM, the device is always on. */
+  os802_11PowerModeCAM, 
+
+  /*Specifies maximum (MAX) power saving. A power mode of MAX */
+  /*results in the greatest power savings for the 802.11 NIC radio. */
+  os802_11PowerModeMAX_PSP,
+
+  /*Specifies fast power-saving mode. This power mode provides */
+  /*the best combination of network performance and power usage. */
+  os802_11PowerModeFast_PSP,
+  os802_11PowerModeMax
+} OS_802_11_POWER_MODE;
+
+/*specified in milliwatts (mW).*/
+typedef tiUINT32 OS_802_11_TX_POWER_LEVEL;
+
+/*Normal value from -10 and -200*/
+typedef INT32 OS_802_11_RSSI; 
+
+/*Length */
+/*  Specifies the length of the OS_802_11_CONFIGURATION_FH structure in bytes. */
+/*HopPattern*/
+/*  Specifies the hop pattern used to determine the hop sequence. */
+/*  As defined by the 802.11 standard, the layer management entity (LME) of */
+/*  the physical layer uses a hop pattern to determine the hop sequence. */
+/*HopSet*/
+/*  Specifies a set of patterns. The LME of the physical layer uses these */
+/*  patterns to determine the hop sequence. */
+/*DwellTime*/
+/*  Specifies the maximum period of time during which the transmitter */
+/*  should remain fixed on a channel. This interval is described in Kµsec (1024 µsec). */
+PACKED_STRUCT( _OS_802_11_CONFIGURATION_FH ,
+
+    tiUINT32  Length; 
+    tiUINT32  HopPattern;
+    tiUINT32  HopSet; 
+    tiUINT32  DwellTime;
+);
+typedef _OS_802_11_CONFIGURATION_FH OS_802_11_CONFIGURATION_FH, *POS_802_11_CONFIGURATION_FH;
+
+/*Length */
+/*  Specifies the length of the NDIS_802_11_CONFIGURATION structure in bytes. */
+/*BeaconPeriod */
+/*  Specifies the interval between beacon message transmissions. */
+/*  This value is specified in Kµsec (1024 µsec). */
+/*ATIMWindow */
+/*  Specifies the announcement traffic information message (ATIM) window in */
+/*  Kµsec (1024 µsec). The ATIM window is a short time period immediately */
+/*  after the transmission of each beacon in an IBSS configuration. */
+/*  During the ATIM window, any station can indicate the need to transfer data */
+/*  to another station during the following data-transmission window. */
+/*DSConfig */
+/*  Specifies the frequency of the selected channel in kHz. */
+/*FHConfig */
+/*  Specifies the frequency hopping configuration in an OS_802_11_CONFIGURATION_FH structure. */
+#ifdef _WINDOWS
+#else
+  PACKED_STRUCT( _OS_802_11_CONFIGURATION ,
+
+    tiUINT32 Length;
+    tiUINT32 BeaconPeriod;
+    tiUINT32 ATIMWindow;
+     PACKED_UNION(Union,
+        tiUINT32 DSConfig;
+        tiUINT32 channel;
+     );
+
+  OS_802_11_CONFIGURATION_FH FHConfig;
+  );
+#endif
+
+typedef _OS_802_11_CONFIGURATION OS_802_11_CONFIGURATION, *POS_802_11_CONFIGURATION;
+
+/*Ndis802_11IBSS */
+/*  Specifies the independent basic service set (IBSS) mode. */
+/*  This mode is also known as ad hoc mode. */
+/*Ndis802_11Infrastructure */
+/*  Specifies the infrastructure mode. */
+/*Ndis802_11AutoUnknown */
+/*  Specifies an automatic mode. In this mode, the 802.11 NIC can switch */
+/*  between ad hoc and infrastructure modes as required. */
+/*Ndis802_11HighSpeedIBSS*/
+/*  Specifies proprietary ad hoc mode that works only PBCC.*/
+typedef enum _OS_802_11_NETWORK_MODE
+{
+  os802_11IBSS,
+  os802_11Infrastructure,
+  os802_11AutoUnknown,
+  os802_11HighSpeedIBSS,
+  os802_11InfrastructureMax
+} OS_802_11_NETWORK_MODE, OS_802_11_NETWORK_INFRASTRUCTURE,*POS_802_11_NETWORK_INFRASTRUCTURE;
+
+/**/
+/*The rates array contains a set of eight octets. */
+/*Each octet contains a desired data rate in units of .5 Mbps.*/
+/**/
+typedef tiUINT8 OS_802_11_RATES[8];
+
+typedef tiUINT8 OS_802_11_RATES_EX[16];
+
+PACKED_STRUCT( _OS_802_11_FIXED_IEs ,
+
+       tiUINT8  TimeStamp[8]; 
+       tiUINT16 BeaconInterval;
+       tiUINT16 Capabilities; 
+);
+typedef _OS_802_11_FIXED_IEs OS_802_11_FIXED_IEs, *POS_802_11_FIXED_IEs;
+
+PACKED_STRUCT( _OS_802_11_VARIABLE_IEs ,
+
+       tiUINT8 ElementID;
+       tiUINT8 Length; /* Number of bytes in data field*/
+       tiUINT8 data[1];
+);
+typedef _OS_802_11_VARIABLE_IEs OS_802_11_VARIABLE_IEs, *POS_802_11_VARIABLE_IEs;
+
+/*#pragma pack(push)*/
+#ifdef _WINDOWS
+#else
+  PACKED_STRUCT( _OS_802_11_BSSID      ,
+    tiUINT32 Length;
+   OS_802_11_MAC_ADDRESS  MacAddress;
+    PACKED_UNION(Union,
+        tiUINT8  Reserved[2];
+        tiUINT16 Capabilities; 
+    );
+    OS_802_11_SSID  Ssid;
+      tiUINT32                  Privacy;
+    OS_802_11_RSSI  Rssi;
+    OS_802_11_NETWORK_TYPE  NetworkTypeInUse;
+    OS_802_11_CONFIGURATION  Configuration;
+    OS_802_11_NETWORK_MODE   InfrastructureMode;
+    OS_802_11_RATES  SupportedRates;
+    /*tiUINT32           channel;*/
+  );
+#endif
+typedef _OS_802_11_BSSID OS_802_11_BSSID, *POS_802_11_BSSID;
+
+PACKED_STRUCT( _OS_802_11_BSSID_LIST ,
+
+    tiUINT32          NumberOfItems;
+  OS_802_11_BSSID  Bssid[1];
+);
+typedef _OS_802_11_BSSID_LIST OS_802_11_BSSID_LIST, *POS_802_11_BSSID_LIST;
+
+#ifdef _WINDOWS
+#else
+
+  PACKED_STRUCT( _OS_802_11_BSSID_EX ,
+
+       tiUINT32                  Length;
+       OS_802_11_MAC_ADDRESS  MacAddress;
+       PACKED_UNION(Union,
+               tiUINT8  Reserved[2];
+               tiUINT16 Capabilities; 
+       );
+       OS_802_11_SSID  Ssid;
+       tiUINT32                  Privacy;
+       OS_802_11_RSSI  Rssi;
+       OS_802_11_NETWORK_TYPE  NetworkTypeInUse;
+       OS_802_11_CONFIGURATION  Configuration;
+       OS_802_11_NETWORK_MODE   InfrastructureMode;
+       OS_802_11_RATES_EX  SupportedRates;
+       tiUINT32                  IELength;
+       tiUINT8                   IEs[1];
+  );
+
+#endif
+
+typedef _OS_802_11_BSSID_EX OS_802_11_BSSID_EX, *POS_802_11_BSSID_EX, OS_WLAN_BSSID_EX, *POS_WLAN_BSSID_EX;
+
+
+PACKED_STRUCT( _OS_802_11_BSSID_LIST_EX        ,
+
+    tiUINT32              NumberOfItems;
+  OS_802_11_BSSID_EX  Bssid[1];
+);
+typedef _OS_802_11_BSSID_LIST_EX OS_802_11_BSSID_LIST_EX, *POS_802_11_BSSID_LIST_EX;
+
+/*#pragma pack(pop)*/
+
+typedef tiUINT32 OS_802_11_FRAGMENTATION_THRESHOLD;
+typedef tiUINT32 OS_802_11_RTS_THRESHOLD;
+typedef tiUINT32 OS_802_11_ANTENNA;
+
+
+/*Length */
+/*  Specifies the length of the NDIS_802_11_WEP structure in bytes. */
+/*KeyIndex */
+/*  Specifies which key to add or remove. The global keys are represented */
+/*  by values of zero to n. When the most significant bit is set to 1, */
+/*  it indicates the key used to transmit to the access point. */
+/*KeyLength */
+/*  Specifies the length of the KeyMaterial character array in bytes. */
+/*KeyMaterial */
+/*  Specifies an arraythat identifies the WEP key. The length of this array is */
+/*  variable and depends upon the value of the KeyLength member. */
+
+typedef tiUINT32 OS_802_11_KEY_INDEX;
+
+PACKED_STRUCT( _OS_802_11_WEP ,
+
+    tiUINT32 Length;
+    tiUINT32 KeyIndex; 
+    tiUINT32 KeyLength;
+    tiUINT8  KeyMaterial [32]; 
+);
+typedef _OS_802_11_WEP OS_802_11_WEP, *POS_802_11_WEP;
+
+/* Key mapping keys require a BSSID*/
+/*typedef tiUINT64 OS_802_11_KEY_RSC;*/
+
+/*#pragma pack(0)*/
+typedef struct _OS_802_11_KEY
+{
+    tiUINT32                  Length;             /* Length of this structure*/
+    tiUINT32                  KeyIndex;
+    tiUINT32                  KeyLength;          /* length of key in bytes*/
+    OS_802_11_MAC_ADDRESS BSSID;
+    OS_802_11_KEY_RSC KeyRSC;
+    tiUINT8                   KeyMaterial[32];     /* variable length depending on above field*/
+} OS_802_11_KEY, *POS_802_11_KEY;
+/*#pragma pack()*/
+
+/*#pragma pack(1)*/
+PACKED_STRUCT( _OS_802_11_REMOVE_KEY ,
+
+    tiUINT32                  Length;             /* Length of this structure*/
+    tiUINT32                  KeyIndex;
+    OS_802_11_MAC_ADDRESS BSSID;
+);
+typedef _OS_802_11_REMOVE_KEY OS_802_11_REMOVE_KEY, *POS_802_11_REMOVE_KEY;
+/*#pragma pack()*/
+
+#define OS_802_11_AI_REQFI_CAPABILITIES     1
+#define OS_802_11_AI_REQFI_LISTENINTERVAL   2
+#define OS_802_11_AI_REQFI_CURRENTAPADDRESS 4
+
+
+#define OS_802_11_AI_RESFI_CAPABILITIES     1
+#define OS_802_11_AI_RESFI_STATUSCODE       2
+#define OS_802_11_AI_RESFI_ASSOCIATIONID    4
+
+#ifndef GWSI_LIB
+
+#ifndef _WINDOWS
+#pragma pack(1)
+#endif /* ifndef _WINDOWS */
+
+#ifdef _WINDOWS // TRS:AS "reserved field added to OS_802_11_AI_REQFI and OS_802_11_AI_RESFI
+                // structures conflicts with WM expectations and cause a problem with WPA.
+#else  /* ifdef _WINDOWS */
+PACKED_STRUCT( OS_802_11_AI_REQFI , 
+    
+       tiUINT16 Capabilities;
+       tiUINT16 ListenInterval;
+       OS_802_11_MAC_ADDRESS  CurrentAPAddress;
+    tiUINT16 reserved; /* added for packing */
+);
+
+PACKED_STRUCT( OS_802_11_AI_RESFI ,
+    
+       tiUINT16 Capabilities;
+       tiUINT16 StatusCode;
+       tiUINT16 AssociationId;
+    tiUINT16 reserved; /* added for packing */
+);
+#endif /* ifdef _WINDOWS */
+
+PACKED_STRUCT( _OS_802_11_ASSOCIATION_INFORMATION ,
+    tiUINT32 Length;
+    tiUINT16 AvailableRequestFixedIEs;
+/*    struct _OS_802_11_AI_REQFI 
+   {
+       tiUINT16 Capabilities;
+       tiUINT16 ListenInterval;
+       OS_802_11_MAC_ADDRESS  CurrentAPAddress;
+   } RequestFixedIEs;
+*/
+    OS_802_11_AI_REQFI RequestFixedIEs;
+    tiUINT32 RequestIELength;
+    tiUINT32 OffsetRequestIEs;
+    tiUINT16 AvailableResponseFixedIEs;
+/*    struct _OS_802_11_AI_RESFI 
+      {
+               tiUINT16 Capabilities;
+               tiUINT16 StatusCode;
+               tiUINT16 AssociationId;
+      } ResponseFixedIEs;
+*/
+    OS_802_11_AI_RESFI ResponseFixedIEs;
+    tiUINT32 ResponseIELength;
+    tiUINT32 OffsetResponseIEs;
+
+);
+typedef _OS_802_11_ASSOCIATION_INFORMATION OS_802_11_ASSOCIATION_INFORMATION, *POS_802_11_ASSOCIATION_INFORMATION;
+#ifndef _WINDOWS
+#pragma pack()
+#endif /* ifndef _WINDOWS */
+
+#endif
+
+/* supported EAP types*/
+typedef enum _OS_802_11_EAP_TYPES
+{
+        OS_EAP_TYPE_NONE                                = -1,
+       OS_EAP_TYPE_MD5_CHALLENGE               = 4,
+       OS_EAP_TYPE_GENERIC_TOKEN_CARD  = 6,
+       OS_EAP_TYPE_TLS                                 = 13,
+       OS_EAP_TYPE_LEAP                                = 17,
+       OS_EAP_TYPE_TTLS                                = 21,
+       OS_EAP_TYPE_PEAP                                = 25,
+       OS_EAP_TYPE_MS_CHAP_V2                  = 26,
+        OS_EAP_TYPE_FAST                = 43
+} OS_802_11_EAP_TYPES;
+
+/* encryption type*/
+typedef enum _OS_802_11_ENCRYPTION_TYPES
+{
+       OS_ENCRYPTION_TYPE_NONE = 0,
+       OS_ENCRYPTION_TYPE_WEP,
+       OS_ENCRYPTION_TYPE_TKIP,
+       OS_ENCRYPTION_TYPE_AES 
+} OS_802_11_ENCRYPTION_TYPES;
+
+/* Key type*/
+typedef enum _OS_802_11_KEY_TYPES
+{
+    OS_KEY_TYPE_STATIC = 0,
+    OS_KEY_TYPE_DYNAMIC
+} OS_802_11_KEY_TYPES;
+
+/* ELP mode*/
+typedef enum _OS_802_11_ELP_MODES
+{
+       OS_ELP_MODE_DISABLE,
+       OS_ELP_MODE_SYNC,
+    OS_ELP_MODE_NON_SYNC
+} OS_802_11_ELP_MODES;
+
+/* Roaming mode*/
+typedef enum _OS_802_11_ROAMING_MODES
+{
+       OS_ROAMING_MODE_DISABLE,
+       OS_ROAMING_MODE_ENABLE
+} OS_802_11_ROAMING_MODES;
+
+typedef enum _OS_802_11_POWER_PROFILE
+{
+    OS_POWER_MODE_AUTO,
+    OS_POWER_MODE_ACTIVE,
+    OS_POWER_MODE_SHORT_DOZE,
+    OS_POWER_MODE_LONG_DOZE
+} OS_802_11_POWER_PROFILE;
+
+typedef enum _OS_802_11_POWER_LEVELS
+{
+    OS_POWER_LEVEL_ELP,
+    OS_POWER_LEVEL_PD,
+    OS_POWER_LEVEL_AWAKE,
+} OS_802_11_POWER_LEVELS;
+
+
+typedef enum _OS_802_11_BEACON_FILTER_MODE
+{
+    OS_BEACON_FILTER_MODE_INACTIVE,
+    OS_BEACON_FILTER_MODE_ACTIVE,
+} OS_802_11_BEACON_FILTER_MODE;
+
+typedef enum _OS_802_11_SCAN_TYPES
+{
+    OS_SCAN_TYPE_PASSIVE,
+    OS_SCAN_TYPE_BROADCAST,
+    OS_SCAN_TYPE_UNICAST
+} OS_802_11_SCAN_TYPES;
+
+typedef enum _OS_802_11_VOICE_DELIVERY_PROTOCOL
+{
+    OS_VOICE_DELIVERY_PROTOCOL_DISABLED,
+    OS_VOICE_DELIVERY_PROTOCOL_PS_POLL   
+} OS_802_11_VOICE_DELIVERY_PROTOCOL;
+
+PACKED_STRUCT( _OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS ,
+
+    tiUINT32 uHighThreshold;
+       tiUINT32 uLowThreshold;
+    tiUINT32 TestInterval;
+);
+typedef _OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS;
+
+typedef struct{
+       tiUINT32 uHighOrLowThresholdFlag;                /* high or low */
+       tiUINT32 uAboveOrBelowFlag;       /* direction of crossing */
+} OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS;
+
+typedef tiUINT8   OS_802_11_PMKID_VALUE[16];
+
+PACKED_STRUCT( _OS_BSSIDInfo ,
+
+    OS_802_11_MAC_ADDRESS   BSSID;
+    OS_802_11_PMKID_VALUE   PMKID;
+);
+typedef _OS_BSSIDInfo OS_BSSIDInfo, *POS_BSSIDInfo;
+
+PACKED_STRUCT( _OS_802_11_PMKID        ,
+
+    tiUINT32        Length;
+    tiUINT32        BSSIDInfoCount;
+    OS_BSSIDInfo    osBSSIDInfo[1];
+);
+typedef _OS_802_11_PMKID OS_802_11_PMKID, *POS_802_11_PMKID;
+
+typedef enum _OS_802_11_WEP_STATUS 
+{
+  os802_11WEPEnabled = 0,
+  os802_11Encryption1Enabled = os802_11WEPEnabled,
+  os802_11WEPDisabled,
+  os802_11EncryptionDisabled = os802_11WEPDisabled,
+  os802_11WEPKeyAbsent,
+  os802_11Encryption1KeyAbsent = os802_11WEPKeyAbsent,
+  os802_11WEPNotSupported,
+  os802_11EncryptionNotSupported = os802_11WEPNotSupported,
+  os802_11Encryption2Enabled,
+  os802_11Encryption2KeyAbsent,
+  os802_11Encryption3Enabled,
+  os802_11Encryption3KeyAbsent
+} OS_802_11_WEP_STATUS, OS_802_11_ENCRYPTION_STATUS;
+
+/*os802_11AuthModeOpen */
+/*  Specifies 802.11 open authentication mode. There are no checks when accepting */
+/*  clients in this mode. */
+/*os802_11AuthModeShared */
+/*  Specifies 802.11 shared authentication that uses a pre-shared wired equivalent */
+/*  privacy (WEP) key. */
+/*os802_11AuthModeAutoSwitch */
+/*  Specifies auto-switch mode. When using auto-switch mode, the NIC tries 802.11 shared */
+/*  authentication mode first. If shared mode fails, the NIC attempts to use 802.11 open */
+/*  authentication mode. */
+
+typedef enum _OS_802_11_AUTHENTICATION_MODE 
+{
+    os802_11AuthModeOpen,
+    os802_11AuthModeShared,
+    os802_11AuthModeAutoSwitch,
+    os802_11AuthModeWPA,
+    os802_11AuthModeWPAPSK,
+    os802_11AuthModeWPANone,
+    os802_11AuthModeWPA2,
+    os802_11AuthModeWPA2PSK,
+    os802_11AuthModeMax
+} OS_802_11_AUTHENTICATION_MODE;
+
+
+/*os802_11PrivFilterAcceptAll */
+/*  Specifies an open mode. In this mode, the NIC accepts any packet if the packet */
+/*  is not encrypted or if the NIC successfully decrypts it. */
+/*os802_11PrivFilter8021xWEP */
+/*  Specifies a filtering mode. In the 802.1X filtering mode, 802.1X packets are */
+/*  accepted even if they are not encrypted. However, the NIC accepts nothing else */
+/*  unless it is encrypted using WEP. */
+typedef enum _OS_802_11_PRIVACY_FILTER 
+{
+  os802_11PrivFilterAcceptAll, 
+  os802_11PrivFilter8021xWEP 
+} OS_802_11_PRIVACY_FILTER;
+
+typedef enum _OS_802_11_RELOAD_DEFAULTS
+{
+  os802_11ReloadWEPKeys
+} OS_802_11_RELOAD_DEFAULTS, *POS_802_11_RELOAD_DEFAULTS;
+
+typedef enum _OS_802_11_STATUS_TYPE
+{
+    os802_11StatusType_Authentication,
+    os802_11StatusType_PMKID_CandidateList = 2,
+    os802_11StatusTypeMax       /* not a real type, defined as an upper bound */
+} OS_802_11_STATUS_TYPE, *POS_802_11_STATUS_TYPE;
+
+PACKED_STRUCT( _OS_802_11_STATUS_INDICATION     ,
+
+    OS_802_11_STATUS_TYPE StatusType;
+);
+typedef _OS_802_11_STATUS_INDICATION OS_802_11_STATUS_INDICATION, *POS_802_11_STATUS_INDICATION;
+
+
+typedef struct _OS_802_11_AUTHENTICATION_REQUEST
+{
+    tiUINT32                           Length;             /* Length of this structure*/
+    OS_802_11_MAC_ADDRESS      BSSID;
+       tiUINT32                                Flags;
+}OS_802_11_AUTHENTICATION_REQUEST, *POS_802_11_AUTHENTICATION_REQUEST;
+
+typedef enum
+{
+       OS_DISASSOC_STATUS_UNSPECIFIED                  =   0,  
+       OS_DISASSOC_STATUS_AUTH_REJECT                          =   1,
+       OS_DISASSOC_STATUS_ASSOC_REJECT                         =   2,
+       OS_DISASSOC_STATUS_SECURITY_FAILURE             =   3,
+       OS_DISASSOC_STATUS_AP_DEAUTHENTICATE            =   4,
+       OS_DISASSOC_STATUS_AP_DISASSOCIATE                      =   5,
+       OS_DISASSOC_STATUS_ROAMING_TRIGGER                      =   6
+
+}      OS_802_11_DISASSOCIATE_REASON_E;
+
+typedef struct
+{
+       OS_802_11_DISASSOCIATE_REASON_E  eDisAssocType;
+       UINT32                                                   uStatusCode;
+} OS_802_11_DISASSOCIATE_REASON_T;
+
+#define OS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLE   0x01
+
+PACKED_STRUCT( _OS_802_11_PMKID_CANDIDATE  ,
+
+    OS_802_11_MAC_ADDRESS BSSID;
+    tiUINT32              Flags;
+);
+typedef _OS_802_11_PMKID_CANDIDATE OS_802_11_PMKID_CANDIDATE, *POS_802_11_PMKID_CANDIDATE;
+
+PACKED_STRUCT( _OS_802_11_PMKID_CANDIDATELIST ,
+
+    tiUINT32                   Version;       /* Version of the structure*/
+    tiUINT32                   NumCandidates; /* No. of pmkid candidates*/
+    OS_802_11_PMKID_CANDIDATE  CandidateList[1];
+);
+typedef _OS_802_11_PMKID_CANDIDATELIST OS_802_11_PMKID_CANDIDATELIST, *POS_802_11_PMKID_CANDIDATELIST;
+
+
+typedef UINT8 OS_802_11_MAC_PMKID_VALUE[16];
+
+PACKED_STRUCT( _OS_802_11_BSSIDInfo    ,
+
+    OS_802_11_MAC_ADDRESS      BSSID;
+    OS_802_11_MAC_PMKID_VALUE  PMKID;
+);
+typedef _OS_802_11_BSSIDInfo OS_802_11_BSSIDInfo, *POS_802_11_BSSIDInfo;
+
+
+PACKED_STRUCT( _OS_802_11_AUTH_ENCRYPTION ,
+
+    OS_802_11_AUTHENTICATION_MODE AuthModeSupported;
+    OS_802_11_ENCRYPTION_STATUS   EncryptionStatusSupported;
+);
+typedef _OS_802_11_AUTH_ENCRYPTION OS_802_11_AUTH_ENCRYPTION, *POS_802_11_AUTH_ENCRYPTION;
+
+PACKED_STRUCT( _OS_802_11_CAPABILITY  ,
+
+    tiUINT32 Length;
+    tiUINT32 Version;
+    tiUINT32 NoOfPmKIDs;
+    tiUINT32 NoOfAuthEncryptPairsSupported;
+    OS_802_11_AUTH_ENCRYPTION AuthEncryptionSupported[1];
+
+);
+typedef _OS_802_11_CAPABILITY OS_802_11_CAPABILITY, *POS_802_11_CAPABILITY;
+
+#define OID_CAPABILITY_VERSION 2
+
+
+
+typedef enum _OS_802_11_REG_DOMAIN
+{
+  os802_11_Domain_FCC = 0x10,
+  os802_11_Domain_IC = 0x20,
+  os802_11_Domain_ETSI = 0x30,
+  os802_11_Domain_Spain = 0x31,
+  os802_11_Domain_France = 0x32,
+  os802_11_Domain_MKK = 0x40,
+  os802_11_Domain_MKK1 = 0x41,
+  os802_11_Domain_US   = 0x50,         
+  os802_11_Domain_WB   = 0x51,
+  os802_11_Domain_EXWB = 0x52,
+} OS_802_11_REG_DOMAIN;
+
+
+
+#define     MAX_SSID_LEN            32
+
+PACKED_STRUCT(ssid_t ,
+
+    UINT8       len;
+    char        ssidString[MAX_SSID_LEN];
+);
+
+
+typedef enum
+{
+    RADIO_BAND_2_4_GHZ      = 0,
+    RADIO_BAND_5_0_GHZ      = 1,
+    RADIO_BAND_DUAL         = 2,
+    RADIO_BAND_NUM_OF_BANDS = 2
+} radioBand_e;
+
+
+
+
+#define OID_TI_VERSION                                                 0xFF080001
+
+
+/* propritary OIDs used by FUNK supplicant for WPA Mixed mode support*/
+/* WPA2 MIxed mode OIDs */
+#define CGUID_FSW_802_11_AVAILABLE_OPTIONS      {0x1a905534, 0xe71f, 0x46d1, {0xa2, 0xcb, 0xa5, 0x57, 0x01, 0x76, 0x38, 0xfd}}
+#define CGUID_FSW_802_11_OPTIONS                               {0xdc7a51b7, 0x2236, 0x467d, {0xb1, 0x55, 0x03, 0x50, 0x42, 0x04, 0xcf, 0x30}}
+
+#define OID_FSW_802_11_AVAILABLE_OPTIONS        0xFF010237
+#define OID_FSW_802_11_OPTIONS                  0xFF010238
+
+
+
+/**/
+/* IEEE 802.11 OIDs*/
+/**/
+#define OID_802_11_BSSID                        0x0D010101
+#define OID_802_11_SSID                         0x0D010102
+#define OID_802_11_INFRASTRUCTURE_MODE          0x0D010108
+#define OID_802_11_ADD_WEP                      0x0D010113
+#define OID_802_11_REMOVE_WEP                   0x0D010114
+#define OID_802_11_DISASSOCIATE                 0x0D010115
+#define OID_802_11_AUTHENTICATION_MODE          0x0D010118
+#define OID_802_11_PRIVACY_FILTER               0x0D010119
+#define OID_802_11_BSSID_LIST_SCAN              0x0D01011A
+#define OID_802_11_WEP_STATUS                   0x0D01011B
+#define OID_802_11_RELOAD_DEFAULTS              0x0D01011C
+#define OID_802_11_ADD_KEY                      0x0D01011D
+#define OID_802_11_REMOVE_KEY                   0x0D01011E
+#define OID_802_11_ASSOCIATION_INFORMATION      0x0D01011F
+#define OID_802_11_NETWORK_TYPES_SUPPORTED      0x0D010203
+#define OID_802_11_NETWORK_TYPE_IN_USE          0x0D010204
+#define OID_802_11_TX_POWER_LEVEL               0x0D010205
+#define OID_802_11_RSSI                         0x0D010206
+#define OID_802_11_RSSI_TRIGGER                 0x0D010207
+#define OID_802_11_FRAGMENTATION_THRESHOLD      0x0D010209
+#define OID_802_11_RTS_THRESHOLD                0x0D01020A
+#define OID_802_11_NUMBER_OF_ANTENNAS           0x0D01020B
+#define OID_802_11_RX_ANTENNA_SELECTED          0x0D01020C
+#define OID_802_11_TX_ANTENNA_SELECTED          0x0D01020D
+#define OID_802_11_SUPPORTED_RATES              0x0D01020E
+#define OID_802_11_DESIRED_RATES                0x0D010210
+#define OID_802_11_CONFIGURATION                0x0D010211
+#define OID_802_11_STATISTICS                   0x0D020212
+#define OID_802_11_POWER_MODE                   0x0D010216
+#define OID_802_11_BSSID_LIST                   0x0D010217
+
+//#ifndef _USER_MODE
+//#define OID_802_11_CAPABILITY                                        0x0D010218
+//#define OID_802_11_PMKID                                             0x0D010219
+//#endif
+
+
+
+/* AnyWPA mode flags used in propritary FUNK suplicant OIDs*/
+
+#define     OS_802_11_OPTION_ENABLE_PROMOTE_MODE        0x00000001 /*bit 0*/
+#define     OS_802_11_OPTION_ENABLE_PROMOTE_CIPHER      0x00000002 /*bit 1*/
+
+#define     OS_802_11_OPTION_ENABLE_ALL                 0x00000003 
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/inc/paramMng.h b/sta_dk_4_0_4_32/common/inc/paramMng.h
new file mode 100644 (file)
index 0000000..fd59bbb
--- /dev/null
@@ -0,0 +1,431 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __PARAM_MGR_H__
+#define __PARAM_MGR_H__
+
+ /* This file contains the definitions for the parameters that can be Set/Get from outside.
+    The parmeters that can be Set/Get from inside the driver only are defined in the file paramIn.h */
+
+/****************************************************************************
+                                PARAMETERS ISSUE
+    Each parameter in the system is defined as UINT32. The parameter
+    structue is as following:
+
+ bit   31   30 - 24     23    22 - 16    15 - 8       7 - 0
+    +-----+----------+-----+----------+-----------+-----------+
+    | Set | Reserved | Get | Reserved | Module    | Parameter |
+    | bit |          | bit |          | number    | number    |
+    +-----+----------+-----+----------+-----------+-----------+
+
+  The 'set' bit indicates whteher this parameter can be set from OS abstraction layer.
+  The 'get' bit indicates whteher this parameter can be get from OS abstraction layer.
+  (All the parameters can be Get/Set from insied the driver.)
+  The module number indicated who is the oner of the parameter.
+  The parameter number is the parameter unique number used to identify it.
+
+****************************************************************************/
+
+#define EXTERNAL_SET_ENABLE(x) (x & 0x80000000)
+#define EXTERNAL_GET_ENABLE(x) (x & 0x00800000)
+#define GET_PARAM_MODULE_NUMBER(x) ((x & 0x0000FF00) >> 8)
+#ifdef GWSI_LIB
+/* In some compilers the macro definition defaults to int, and 0x80000000 exceeds that limit */
+#define     SET_BIT         ((int)0x80000000)
+#else
+#define     SET_BIT         0x80000000
+#endif
+#define     GET_BIT         0x00800000
+
+ /* Following are the modules numbers */
+/* NOTICE! whenever you add a module, you have to increment MAX_PARAM_MODULE_NUMBER as well!!! */
+typedef enum
+{
+    AUTH_MODULE_PARAM               = 0x0100,
+    ASSOC_MODULE_PARAM              = 0x0200,
+    RX_DATA_MODULE_PARAM            = 0x0300,
+    TX_DATA_MODULE_PARAM            = 0x0400,
+    CTRL_DATA_MODULE_PARAM          = 0x0500,
+    SITE_MGR_MODULE_PARAM           = 0x0600,
+    CONN_MODULE_PARAM               = 0x0700,
+    RSN_MODULE_PARAM                = 0x0800,
+    ADM_CTRL_MODULE_PARAM           = 0x0900,
+    HAL_CTRL_MODULE_PARAM           = 0x0A00,
+    REPORT_MODULE_PARAM             = 0x0B00,
+    SME_SM_MODULE_PARAM             = 0x0C00,
+    MLME_SM_MODULE_PARAM            = 0x0D00,
+    REGULATORY_DOMAIN_MODULE_PARAM  = 0x0E00,
+    MEASUREMENT_MODULE_PARAM        = 0x0F00,
+    EXC_MANAGER_MODULE_PARAM        = 0x1000,
+    ROAMING_MANAGER_MODULE_PARAM    = 0x1100,
+    SOFT_GEMINI_PARAM               = 0x1200,
+    QOS_MANAGER_PARAM               = 0x1300,
+    POWER_MANAGER_PARAM             = 0x1400,
+    SCAN_CNCN_PARAM                 = 0x1500,
+    SCAN_MNGR_PARAM                 = 0x1600,
+
+    /*
+    Last module - DO NOT TOUCH!
+    */
+    MODULE_PARAM_LAST_MODULE
+
+}   moduleParam_e;
+
+enum
+{
+    /*
+    the MAX_PARAM_MODULE_PARAM is the module param last module +1 therefore there is a need
+    to -1 to get to real last module number.
+    */
+    MAX_PARAM_MODULE_PARAM = MODULE_PARAM_LAST_MODULE - 1
+};
+
+/* Following are the parameters numbers. Each module can have 256 parameters */
+typedef enum
+{
+    /* Driver General section */
+    DRIVER_STATUS_PARAM                         =           GET_BIT                         | 0x00,
+
+    /* HAL Control section */
+    HAL_CTRL_RTS_THRESHOLD_PARAM                = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x01,
+    HAL_CTRL_FRAG_THRESHOLD_PARAM               = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x02,
+    HAL_CTRL_COUNTERS_PARAM                     =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x03,
+    HAL_CTRL_LISTEN_INTERVAL_PARAM              = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x04,
+    HAL_CTRL_CURRENT_BEACON_INTERVAL_PARAM      =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x05,
+    HAL_CTRL_TX_POWER_PARAM                     = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x06,
+    HAL_CTRL_TX_ANTENNA_PARAM                   = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x07,
+    HAL_CTRL_RX_ANTENNA_PARAM                   = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x08,
+    HAL_CTRL_MIN_POWER_LEVEL          = SET_BIT |           HAL_CTRL_MODULE_PARAM | 0x09,
+    HAL_CTRL_CLK_RUN_ENABLE                     = SET_BIT |           HAL_CTRL_MODULE_PARAM | 0x0A,
+    HAL_CTRL_QUEUES_PARAMS                      = SET_BIT |           HAL_CTRL_MODULE_PARAM | 0x0B, 
+    HAL_CTRL_AC_PARAMS                          = SET_BIT |           HAL_CTRL_MODULE_PARAM | 0x0C, 
+    HAL_CTRL_TX_RATE_CLASS_PARAMS               = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x0D,
+    HAL_CTRL_DOT11_MAX_TX_MSDU_LIFE_TIME        = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x0E,
+    HAL_CTRL_DOT11_MAX_RX_MSDU_LIFE_TIME        = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x0F,
+    HAL_CTRL_PS_POLL_GENERATION_MODE            = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x10,
+    HAL_CTRL_CTS_TO_SELF_PARAM                  = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x11,
+    HAL_CTRL_TX_ACK_POLICY                      = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x12,
+
+    HAL_CTRL_TX_COUNTERS_PARAM                  =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x14,
+    HAL_CTRL_RX_TIME_OUT_PARAM                  = SET_BIT |           HAL_CTRL_MODULE_PARAM | 0x15,
+
+    HAL_CTRL_ANTENNA_DIVERSITY_PARAMS           = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x18,
+    HAL_CTRL_CURRENT_CHANNEL                    =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x19,
+    HAL_CTRL_RSSI_LEVEL_PARAM                   =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x1a,
+    HAL_CTRL_SNR_RATIO_PARAM                    =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x1b,
+    HAL_CTRL_BCN_BRC_OPTIONS                    =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x1c,
+    
+   /* PLT params */    
+    HAL_CTRL_PLT_READ_REGISTER                  =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x1d,
+    HAL_CTRL_PLT_WRITE_REGISTER                 = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x1e,
+
+    HAL_CTRL_PLT_RX_PER_START                   = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x1f,
+    HAL_CTRL_PLT_RX_PER_STOP                    = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x20,
+    HAL_CTRL_PLT_RX_PER_CLEAR                   = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x21,
+    HAL_CTRL_PLT_RX_PER_GET_RESULTS             =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x22,
+    HAL_CTRL_PLT_TX_CW                          = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x23,
+    HAL_CTRL_PLT_TX_CONTINUES                   = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x24,
+    HAL_CTRL_PLT_TX_STOP                        = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x25,
+    HAL_CTRL_PLT_WRITE_MIB                      = SET_BIT           | HAL_CTRL_MODULE_PARAM | 0x26,
+    HAL_CTRL_PLT_READ_MIB                       =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x27,
+
+    HAL_CTRL_PLT_RX_TX_CAL                      =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x28,
+    HAL_CTRL_PLT_RX_CAL_STATUS                  =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x29,
+
+    /* misc section */
+    HAL_CTRL_EARLY_WAKEUP                       = SET_BIT | GET_BIT | HAL_CTRL_MODULE_PARAM | 0x30,
+    HAL_CTRL_POWER_CONSUMPTION                  =           GET_BIT | HAL_CTRL_MODULE_PARAM | 0x31,
+
+
+    /* Site manager section */
+    SITE_MGR_DESIRED_CHANNEL_PARAM              = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x01,
+    SITE_MGR_DESIRED_BSSID_PARAM                = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x02,
+    SITE_MGR_DESIRED_SSID_PARAM                 = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x03,
+    SITE_MGR_DESIRED_BSS_TYPE_PARAM             = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x04,
+    SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM   = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x05,
+    SITE_MGR_DESIRED_TX_RATE_PARAM              =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x07,
+    SITE_MGR_DESIRED_MODULATION_TYPE_PARAM      = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x08,
+    SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM      = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x09,
+    SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM        = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x0A,
+
+    SITE_MGR_CURRENT_RADIO_TYPE_PARAM           =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x0D,
+    SITE_MGR_CURRENT_CHANNEL_PARAM              = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x0E,
+    SITE_MGR_CURRENT_SSID_PARAM                 =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x0F,
+    SITE_MGR_CURRENT_RATE_PAIR_PARAM            =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x10,
+    SITE_MGR_CURRENT_MODULATION_TYPE_PARAM      =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x11,
+    SITE_MGR_CURRENT_SIGNAL_PARAM               = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x12,
+    SITE_MGR_BSSID_LIST_PARAM                   =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x13,
+    SITE_MGR_TI_WLAN_COUNTERS_PARAM             =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x14,
+    SITE_MGR_PRIMARY_SITE_PARAM                 =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x15,
+    SITE_MGR_EEPROM_VERSION_PARAM               =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x16,
+    SITE_MGR_FIRMWARE_VERSION_PARAM             =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x17,
+    SITE_MGR_DESIRED_DOT11_MODE_PARAM           = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x18,
+    SITE_MGR_OPERATIONAL_MODE_PARAM             =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x19,
+    SITE_MGR_USE_DRAFT_NUM_PARAM                = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x1A,
+    SITE_MGR_DESIRED_SLOT_TIME_PARAM            = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x1B,
+    SITE_MGR_CURRENT_SLOT_TIME_PARAM            =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x1C,
+    SITE_MGR_CURRENT_PREAMBLE_TYPE_PARAM        =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x1D,
+    SITE_MGR_BUILT_IN_TEST_STATUS_PARAM         =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x1E,
+    SITE_MGR_CONFIGURATION_PARAM                = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x1F,
+    SITE_MGR_DISASSOCIATE_PARAM                 = SET_BIT           | SITE_MGR_MODULE_PARAM | 0x20,
+    SITE_MGR_DEAUTHENTICATE_PARAM               = SET_BIT           | SITE_MGR_MODULE_PARAM | 0x21,
+    SITE_MGR_BSSID_LIST_SCAN_PARAM              = SET_BIT           | SITE_MGR_MODULE_PARAM | 0x22,
+    SITE_MGR_AP_TX_POWER_PARAM                  =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x23,
+    SITE_MGR_DESIRED_TX_RATE_PRCT_SET           = SET_BIT           | SITE_MGR_MODULE_PARAM | 0x26,
+    SITE_MGR_DESIRED_RSSI_THRESHOLD_SET         = SET_BIT           | SITE_MGR_MODULE_PARAM | 0x27,
+
+    SITE_MGR_SITE_ENTRY_BY_INDEX                =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x28,
+    SITE_MGR_CUR_NUM_OF_SITES                   =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x29,
+    SITE_MGR_CURRENT_TSF_TIME_STAMP             =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x2A,    
+    SITE_MGR_GET_SELECTED_BSSID_INFO            =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x2B,
+    SITE_MGR_DESIRED_CONS_TX_ERRORS_THREH       = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x2C,
+    SITE_MGR_SUPPORTED_NETWORK_TYPES            =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x2D,
+    SITE_MGR_GET_AP_QOS_CAPABILITIES            =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x2E,
+    SITE_MGR_CURRENT_BSSID_PARAM                =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x2F,
+    SITE_MGR_LAST_RX_RATE_PARAM                 =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x30,
+    SITE_MGR_LAST_BEACON_BUF_PARAM              =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x31,
+    SITE_MGR_CURRENT_TX_RATE_PARAM              =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x32,
+    SITE_MGR_CURRENT_BSS_TYPE_PARAM             =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x33,
+    SITE_MGR_BSSID_FULL_LIST_PARAM              =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x34,
+    SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM  = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x35,
+    SITE_MGR_ALLOW_TX_POWER_CHECK               = SET_BIT | GET_BIT | SITE_MGR_MODULE_PARAM | 0x36,
+    SITE_MGR_NETWORK_TYPE_IN_USE                               =           GET_BIT | SITE_MGR_MODULE_PARAM | 0x37,
+
+    /* MLME section */
+    MLME_BEACON_RECV                            =           GET_BIT | MLME_SM_MODULE_PARAM  | 0x01,
+
+    /* SME SM section */
+    SITE_MGR_CONNECTION_STATUS_PARAM            =           GET_BIT | SME_SM_MODULE_PARAM   | 0x01,
+    SME_SM_STATE_PARAM                          =           GET_BIT | SME_SM_MODULE_PARAM   | 0x02,
+    SME_SCAN_ENABLED_PARAM                      = SET_BIT | GET_BIT | SME_SM_MODULE_PARAM   | 0x03,
+    
+    /* Scan concentrator section */
+    SCAN_CNCN_START_APP_SCAN                    = SET_BIT |           SCAN_CNCN_PARAM       | 0x01,
+    SCAN_CNCN_STOP_APP_SCAN                     = SET_BIT |           SCAN_CNCN_PARAM       | 0x02,
+    SCAN_CNCN_BSSID_LIST_SCAN_PARAM             = SET_BIT           | SCAN_CNCN_PARAM       | 0x03,
+
+    /* Scan Manager module */
+    SCAN_MNGR_SET_CONFIGURATION                 = SET_BIT |           SCAN_MNGR_PARAM       | 0x01,
+    SCAN_MNGR_BSS_LIST_GET                      =           GET_BIT | SCAN_MNGR_PARAM       | 0x02,
+
+    /* Connection section */
+    CONN_SELF_TIMEOUT_PARAM                     = SET_BIT | GET_BIT | CONN_MODULE_PARAM | 0x01,
+
+    /* Auth section */
+    AUTH_RESPONSE_TIMEOUT_PARAM                 = SET_BIT | GET_BIT | AUTH_MODULE_PARAM | 0x01,
+    AUTH_COUNTERS_PARAM                         =           GET_BIT | AUTH_MODULE_PARAM | 0x02,
+
+    /* Assoc section */
+    ASSOC_RESPONSE_TIMEOUT_PARAM                = SET_BIT | GET_BIT | ASSOC_MODULE_PARAM | 0x01,
+    ASSOC_COUNTERS_PARAM                        =           GET_BIT | ASSOC_MODULE_PARAM | 0x02,
+    ASSOC_ASSOCIATION_INFORMATION_PARAM         =           GET_BIT | ASSOC_MODULE_PARAM | 0x03,
+    ASSOC_ASSOCIATION_RESP_PARAM                =           GET_BIT | ASSOC_MODULE_PARAM | 0x04,
+
+    /* RSN section */
+    RSN_PRIVACY_OPTION_IMPLEMENTED_PARAM        =           GET_BIT | RSN_MODULE_PARAM | 0x01,
+    RSN_KEY_PARAM                               = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x02,
+    RSN_SECURITY_STATE_PARAM                    =           GET_BIT | RSN_MODULE_PARAM | 0x03,
+    RSN_ENCRYPTION_STATUS_PARAM                 = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x04,
+    RSN_ADD_KEY_PARAM                           = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x05,
+    RSN_REMOVE_KEY_PARAM                        = SET_BIT           | RSN_MODULE_PARAM | 0x06,
+    RSN_EXT_AUTHENTICATION_MODE                 = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x07,
+    RSN_MIXED_MODE                              = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x08,
+    RSN_DEFAULT_KEY_ID                          = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x09,
+    RSN_EXC_NETWORK_EAP                         = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x0A,
+    RSN_AUTH_ENCR_CAPABILITY                    =           GET_BIT | RSN_MODULE_PARAM | 0x11,
+    RSN_PMKID_LIST                              = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x12,
+    RSN_WPA_PROMOTE_AVAILABLE_OPTIONS           =           GET_BIT | RSN_MODULE_PARAM | 0x13,
+    RSN_WPA_PROMOTE_OPTIONS                     = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x14,
+    RSN_PRE_AUTH_STATUS                         =           GET_BIT | RSN_MODULE_PARAM | 0x15,
+    RSN_EAP_TYPE                                = SET_BIT | GET_BIT | RSN_MODULE_PARAM | 0x16,
+    WPA_801_1X_AKM_EXISTS                       =           GET_BIT | RSN_MODULE_PARAM | 0x17,
+
+
+    /* RX data section */
+    RX_DATA_COUNTERS_PARAM                      =           GET_BIT | RX_DATA_MODULE_PARAM | 0x01,
+    RX_DATA_EXCLUDE_UNENCRYPTED_PARAM           = SET_BIT | GET_BIT | RX_DATA_MODULE_PARAM | 0x02,
+    RX_DATA_EXCLUDE_BROADCAST_UNENCRYPTED_PARAM = SET_BIT | GET_BIT | RX_DATA_MODULE_PARAM | 0x03,
+    RX_DATA_ENABLE_DISABLE_RX_DATA_FILTERS      = SET_BIT | GET_BIT | RX_DATA_MODULE_PARAM | 0x04,
+    RX_DATA_ADD_RX_DATA_FILTER                  = SET_BIT           | RX_DATA_MODULE_PARAM | 0x05,
+    RX_DATA_REMOVE_RX_DATA_FILTER               = SET_BIT           | RX_DATA_MODULE_PARAM | 0x06,
+    RX_DATA_GET_RX_DATA_FILTERS_STATISTICS      =           GET_BIT | RX_DATA_MODULE_PARAM | 0x07,
+
+
+    /* TX data section */
+    TX_DATA_PORT_STATUS_PARAM                   =           GET_BIT | TX_DATA_MODULE_PARAM | 0x01,
+    TX_DATA_COUNTERS_PARAM                      =           GET_BIT | TX_DATA_MODULE_PARAM | 0x02,
+    TX_DATA_RESET_COUNTERS_PARAM                = SET_BIT           | TX_DATA_MODULE_PARAM | 0x03,
+    TX_DATA_ENCRYPTION_FIELD_SIZE               = SET_BIT           | TX_DATA_MODULE_PARAM | 0x04,
+    TX_DATA_PS_MODE_PARAM                       = SET_BIT           | TX_DATA_MODULE_PARAM | 0x05,
+    TX_DATA_CONFIG_TX_QUEUE_SIZE                = SET_BIT           | TX_DATA_MODULE_PARAM | 0x07,
+    TX_DATA_CONVERT_HEADER_MODE                 = SET_BIT | GET_BIT | TX_DATA_MODULE_PARAM | 0x08,
+    TX_DATA_CONVERT_TAG_ZERO_HEADER_MODE        = SET_BIT           | TX_DATA_MODULE_PARAM | 0x09,
+    TX_DATA_TAG_TO_AC_CLASSIFIER_TABLE          = SET_BIT           | TX_DATA_MODULE_PARAM | 0x0A,
+    TX_DATA_PS_STATUS                           = SET_BIT           | TX_DATA_MODULE_PARAM | 0x0B,
+    TX_DATA_SET_AC_QUEUE_INDEX                  = SET_BIT           | TX_DATA_MODULE_PARAM | 0x0D,
+    TX_DATA_CONFIG_TX_QUEUE_OVFLOW_POLICY       = SET_BIT           | TX_DATA_MODULE_PARAM | 0x0E,
+    TX_DATA_CONFIG_AC_MSDU_LIFE_TIME            = SET_BIT           | TX_DATA_MODULE_PARAM | 0x0F,
+    TX_DATA_CONFIG_AC_ACK_POLICY                = SET_BIT           | TX_DATA_MODULE_PARAM | 0x10,
+    TX_DATA_AC_ADMISSION_STATE                  = SET_BIT           | TX_DATA_MODULE_PARAM | 0x11,
+    TX_DATA_SET_MEDIUM_USAGE_THRESHOLD          = SET_BIT           | TX_DATA_MODULE_PARAM | 0x12,
+    TX_DATA_GET_MEDIUM_USAGE_THRESHOLD          = SET_BIT | GET_BIT | TX_DATA_MODULE_PARAM | 0x13,
+    TX_DATA_POLL_AP_PACKETS_FROM_AC             = SET_BIT           | TX_DATA_MODULE_PARAM | 0x14,
+    TX_DATA_REPORT_TS_STATISTICS                =           GET_BIT | TX_DATA_MODULE_PARAM | 0x15,
+    TX_DATA_SET_VAD                             = SET_BIT           | TX_DATA_MODULE_PARAM | 0x16,
+    TX_DATA_GET_VAD                             =           GET_BIT | TX_DATA_MODULE_PARAM | 0x17,
+
+    /* CTRL data section */
+    CTRL_DATA_COUNTERS_PARAM                    =           GET_BIT | CTRL_DATA_MODULE_PARAM | 0x01,
+    CTRL_DATA_RATE_CONTROL_ENABLE_PARAM         = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x02,
+    CTRL_DATA_CURRENT_BSSID_PARAM               =           GET_BIT | CTRL_DATA_MODULE_PARAM | 0x03,
+    CTRL_DATA_CURRENT_BSS_TYPE_PARAM            =           GET_BIT | CTRL_DATA_MODULE_PARAM | 0x04,
+    CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM =           GET_BIT | CTRL_DATA_MODULE_PARAM | 0x05,
+    CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM       =           GET_BIT | CTRL_DATA_MODULE_PARAM | 0x06,
+    CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM   = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x07,
+    CTRL_DATA_MAC_ADDRESS                       = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x08,
+    CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM     = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x09,
+    CTRL_DATA_CURRENT_RTS_CTS_STATUS_PARAM      = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x0A,
+    CTRL_DATA_FOUR_X_ENABLE_PARAM               = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x0B,
+    CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM      = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x0C,
+    CTRL_DATA_CLSFR_TYPE                        =           GET_BIT | CTRL_DATA_MODULE_PARAM | 0x0D,
+    CTRL_DATA_CLSFR_CONFIG                      = SET_BIT           | CTRL_DATA_MODULE_PARAM | 0x0E,
+    CTRL_DATA_CLSFR_REMOVE_ENTRY                = SET_BIT           | CTRL_DATA_MODULE_PARAM | 0x0F,
+    CTRL_DATA_GET_USER_PRIORITY_OF_STREAM       = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x10,
+    CTRL_DATA_SHORT_RETRY_LIMIT_PARAM           = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x11,
+    CTRL_DATA_LONG_RETRY_LIMIT_PARAM            = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x12,
+    CTRL_DATA_CURRENT_RATE_CLASS_CLIENT         = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x13,
+    CTRL_DATA_NEXT_RATE_MASK_FOR_CLIENT         = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x14,
+
+    CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD       = SET_BIT | GET_BIT | CTRL_DATA_MODULE_PARAM | 0x15,
+    CTRL_DATA_TOGGLE_TRAFFIC_INTENSITY_EVENTS   = SET_BIT           | CTRL_DATA_MODULE_PARAM | 0x16,
+    CTRL_DATA_TSRS_PARAM                        = SET_BIT           | CTRL_DATA_MODULE_PARAM | 0x17,
+
+    /* REPORT section */
+    REPORT_MODULE_ON_PARAM                      = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x01,
+    REPORT_MODULE_OFF_PARAM                     = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x02,
+    REPORT_MODULE_TABLE_PARAM                   = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x03,
+    REPORT_SEVERITY_ON_PARAM                    = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x04,
+    REPORT_SEVERITY_OFF_PARAM                   = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x05,
+    REPORT_SEVERITY_TABLE_PARAM                 = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x06,
+    REPORT_PPMODE_VALUE_PARAM                   = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x07,
+    REPORT_OS_DBG_STATE_VALUE_PARAM             = SET_BIT | GET_BIT | REPORT_MODULE_PARAM | 0x08,
+
+    /* regulatory domain section */
+    REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM   =           GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x02,
+    REGULATORY_DOMAIN_ENABLED_PARAM                         =           GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x03,
+    REGULATORY_DOMAIN_CURRENT_REGULATORY_DOMAIN_PARAM       =           GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x04,
+    REGULATORY_DOMAIN_TX_POWER_LEVEL_TABLE_PARAM            =                  GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x07,
+    REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM         = SET_BIT | GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x08,
+    REGULATORY_DOMAIN_UPDATE_CHANNEL_VALIDITY               = SET_BIT |           REGULATORY_DOMAIN_MODULE_PARAM | 0x09,
+    REGULATORY_DOMAIN_TEMPORARY_TX_ATTENUATION_PARAM        = SET_BIT |           REGULATORY_DOMAIN_MODULE_PARAM | 0x0B,
+    REGULATORY_DOMAIN_ENABLE_DISABLE_802_11D                = SET_BIT |           REGULATORY_DOMAIN_MODULE_PARAM | 0x0C,
+    REGULATORY_DOMAIN_ENABLE_DISABLE_802_11H                = SET_BIT |           REGULATORY_DOMAIN_MODULE_PARAM | 0x0D,
+    REGULATORY_DOMAIN_COUNTRY_2_4_PARAM                     = SET_BIT | GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x0E,
+    REGULATORY_DOMAIN_COUNTRY_5_PARAM                       = SET_BIT | GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x0F,
+    REGULATORY_DOMAIN_DFS_CHANNELS_RANGE                    = SET_BIT | GET_BIT | REGULATORY_DOMAIN_MODULE_PARAM | 0x10,
+
+
+    /* measurement section */
+    MEASUREMENT_ENABLE_DISABLE_PARAM                        = SET_BIT |          MEASUREMENT_MODULE_PARAM | 0x01,
+    MEASUREMENT_MAX_DURATION_PARAM                          = SET_BIT |          MEASUREMENT_MODULE_PARAM | 0x02,
+
+#ifdef EXC_MODULE_INCLUDED
+    /* EXC */
+    
+    EXC_CONFIGURATION                                   = SET_BIT | GET_BIT | EXC_MANAGER_MODULE_PARAM | 0x01,
+    EXC_ROGUE_AP_DETECTED                               = SET_BIT           | EXC_MANAGER_MODULE_PARAM | 0x02,
+    EXC_REPORT_ROGUE_APS                                = SET_BIT           | EXC_MANAGER_MODULE_PARAM | 0x03,
+    EXC_AUTH_SUCCESS                                    = SET_BIT           | EXC_MANAGER_MODULE_PARAM | 0x04,
+    EXC_CCKM_REQUEST                                    = SET_BIT           | EXC_MANAGER_MODULE_PARAM | 0x05,
+    EXC_CCKM_RESULT                                     = SET_BIT           | EXC_MANAGER_MODULE_PARAM | 0x06,
+    EXC_ENABLED                                         = SET_BIT | GET_BIT | EXC_MANAGER_MODULE_PARAM | 0x07,
+    EXC_CURRENT_AP_SUPPORTED_VERSION                    =           GET_BIT | EXC_MANAGER_MODULE_PARAM | 0x08,
+#endif
+
+    /* Roaming manager */
+    ROAMING_MNGR_APPLICATION_CONFIGURATION          = SET_BIT | GET_BIT | ROAMING_MANAGER_MODULE_PARAM | 0x01,
+
+    /* Parameters used for DEBUG */
+    ROAMING_MNGR_TRIGGER_EVENT                      = SET_BIT           | ROAMING_MANAGER_MODULE_PARAM | 0x02,
+    ROAMING_MNGR_CONN_STATUS                        = SET_BIT           | ROAMING_MANAGER_MODULE_PARAM | 0x03, 
+    ROAMING_MNGR_CONF_PARAM                         =           GET_BIT | ROAMING_MANAGER_MODULE_PARAM | 0x04,
+#ifdef TI_DBG
+    ROAMING_MNGR_PRINT_STATISTICS                   =           GET_BIT | ROAMING_MANAGER_MODULE_PARAM | 0x05,
+    ROAMING_MNGR_RESET_STATISTICS                   =           GET_BIT | ROAMING_MANAGER_MODULE_PARAM | 0x06,
+    ROAMING_MNGR_PRINT_CURRENT_STATUS               =           GET_BIT | ROAMING_MANAGER_MODULE_PARAM | 0x07,
+    ROAMING_MNGR_PRINT_CANDIDATE_TABLE              =           GET_BIT | ROAMING_MANAGER_MODULE_PARAM | 0x08,
+#endif
+
+
+    SOFT_GEMINI_SET_ENABLE                              = SET_BIT |           SOFT_GEMINI_PARAM        | 0x01,
+    SOFT_GEMINI_SET_RATE                                = SET_BIT |           SOFT_GEMINI_PARAM        | 0x02,
+    SOFT_GEMINI_SET_CONFIG                              = SET_BIT |           SOFT_GEMINI_PARAM        | 0x03,
+    SOFT_GEMINI_GET_STATUS                              =           GET_BIT | SOFT_GEMINI_PARAM        | 0x04,
+
+
+    /* QOS manager params */
+    QOS_MNGR_SHORT_RETRY_LIMIT_PARAM                    = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x01,
+    QOS_MNGR_LONG_RETRY_LIMIT_PARAM                     = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x02,
+    QOS_PACKET_BURST_ENABLE                             = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x03,
+    QOS_MNGR_SET_SITE_PROTOCOL                          = SET_BIT |           QOS_MANAGER_PARAM | 0x04,
+    QOS_MNGR_SET_802_11_POWER_SAVE_STATUS               = SET_BIT |           QOS_MANAGER_PARAM | 0x05,
+    QOS_MNGR_SET_OS_PARAMS                              = SET_BIT |           QOS_MANAGER_PARAM | 0x07,
+    QOS_MNGR_SET_OPERATIONAL_MODE                       = SET_BIT |           QOS_MANAGER_PARAM | 0x08,
+    QOS_MNGR_CURRENT_PS_MODE                            = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x09,
+    QOS_MNGR_AP_QOS_PARAMETERS                          = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x0A,
+    QOS_MNGR_OS_TSPEC_PARAMS                            = SET_BIT |           QOS_MANAGER_PARAM | 0x0B,
+    QOS_MNGR_AC_STATUS                                  = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x0C,
+    QOS_MNGR_ADD_TSPEC_REQUEST                          = SET_BIT           | QOS_MANAGER_PARAM | 0x0D,
+    QOS_MNGR_DEL_TSPEC_REQUEST                          = SET_BIT           | QOS_MANAGER_PARAM | 0x0E,
+    QOS_MNGR_ACTIVE_PROTOCOL                            =           GET_BIT | QOS_MANAGER_PARAM | 0x0F,
+    QOS_SET_RATE_THRESHOLD                              = SET_BIT           | QOS_MANAGER_PARAM | 0x10,
+    QOS_GET_RATE_THRESHOLD                              = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x11,
+    QOS_MNGR_GET_DESIRED_PS_MODE                        =           GET_BIT | QOS_MANAGER_PARAM | 0x12,
+    QOS_SET_RX_TIME_OUT                                 = SET_BIT           | QOS_MANAGER_PARAM | 0x14, 
+    QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC                   = SET_BIT | GET_BIT | QOS_MANAGER_PARAM | 0x15,
+    QOS_MNGR_RESEND_TSPEC_REQUEST                       = SET_BIT           | QOS_MANAGER_PARAM | 0x16,
+
+    /* Power Manager params */
+    POWER_MGR_POWER_MODE                                = SET_BIT | GET_BIT | POWER_MANAGER_PARAM | 0x01,
+    POWER_MGR_DISABLE_PRIORITY                          = SET_BIT |           POWER_MANAGER_PARAM | 0x02,   
+    POWER_MGR_ENABLE_PRIORITY                           = SET_BIT |           POWER_MANAGER_PARAM | 0x03,    
+    POWER_MGR_POWER_LEVEL_PS                            = SET_BIT | GET_BIT | POWER_MANAGER_PARAM | 0x04,
+    POWER_MGR_POWER_LEVEL_DEFAULT                       = SET_BIT | GET_BIT | POWER_MANAGER_PARAM | 0x05,
+    POWER_MGR_POWER_LEVEL_DOZE_MODE                     = SET_BIT | GET_BIT | POWER_MANAGER_PARAM | 0x06,
+
+}   externalParam_e;
+
+
+#endif /* __PARAM_MGR_H__ */
diff --git a/sta_dk_4_0_4_32/common/inc/paramOut.h b/sta_dk_4_0_4_32/common/inc/paramOut.h
new file mode 100644 (file)
index 0000000..7bc0265
--- /dev/null
@@ -0,0 +1,1403 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __PARAM_OUT_H__
+#define __PARAM_OUT_H__
+
+#include "osTIType.h"
+#include "osDot11.h"
+#include "tiwlnif.h"
+#include "ratesTypes.h"
+#include "scanTypes.h"
+#include "bssTypes.h"
+#include "roamingMngrTypes.h"
+#include "public_commands.h"
+#include "public_infoele.h"
+#include "public_radio.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "paramOutExc.h"
+#else
+#define   EXC_PARAM_FIELDS
+#endif
+#include "paramMng.h"
+#include "commonTypes.h"
+#include "coreDefaultParams.h"
+
+#define DOT11_MAX_DEFAULT_WEP_KEYS          ( 4  )
+#define ACX_64BITS_WEP_KEY_LENGTH_BYTES     ( 5  )
+#define ACX_128BITS_WEP_KEY_LENGTH_BYTES    ( 13 )
+#define ACX_256BITS_WEP_KEY_LENGTH_BYTES    ( 29 )
+#define ACX_MAX_WEP_KEY_LENGTH_BYTES        ( 29 )
+
+#define RX_LEVEL_TABLE_SIZE             (15)
+#define SPECIAL_BG_CHANNEL              (14)
+
+#define BEACON_FILTER_STRING_MAX_LEN 300  /*this is the max possible string length from INI file*/
+    
+#define BEACON_FILTER_IE_TABLE_MIN_SIZE 0 
+#define BEACON_FILTER_IE_TABLE_MAX_NUM (6+32)
+#define BEACON_FILTER_IE_TABLE_MIN_NUM 0 
+
+#define RX_DATA_FILTER_MAX_MASK_SIZE            (8)
+#define RX_DATA_FILTER_MAX_PATTERN_SIZE         (64)
+#define RX_DATA_FILTER_MAX_FIELD_PATTERNS       (8)
+#define RX_DATA_FILTER_FILTER_BOUNDARY          (256)
+
+#define RX_DATA_FILTER_FLAG_NO_BIT_MASK         (0)
+#define RX_DATA_FILTER_FLAG_USE_BIT_MASK        (1)
+#define RX_DATA_FILTER_FLAG_IP_HEADER           (0)
+#define RX_DATA_FILTER_FLAG_ETHERNET_HEADER     (2)
+
+#define RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY (14)
+
+
+/* Soft gemini  values */
+
+#define NUM_OF_RATES_IN_SG MAX_NUM_OF_TX_RATES_IN_CLASS /* all rates (13)... */
+#define SG_RATES_STRING_MAX_DEF 100
+#define SG_RATES_DEF "0,0,1,0,0,1,1,1,0,1,1,1,1" /* all rates but 1,2,6,9,22 */
+#define NUM_OF_CONFIG_PARAMS_IN_SG 28
+#define NUM_OF_STATUS_PARAMS_IN_SG 28
+
+
+/*used by UtilInfoCodeQueryInformation , UtilInfoCodeSetInformation*/
+#define VAL_TX_POWER_VALUE                     100
+#define VAL_NETWORK_TYPE                       101
+#define VAL_AP_TX_POWER_LEVEL      102
+/* #define VAL_COUNTRY_CODE                    103 */ 
+/* #define VAL_REG_DOMAIN_BAND_24          104 */
+/* #define VAL_REG_DOMAIN_BAND_50          105 */
+#define VAL_PACKET_BURSTING                    106
+#define VAL_MIXED_MODE                         107
+#define VAL_PRIVACY_MODE                       108
+#define VAL_EXC_SECURITY                       109
+#define VAL_DEFAULT_KEY_ID                     110
+#define VAL_AP_SUPPORT_CHANELS                 111
+
+
+
+typedef enum
+{
+    DRAFT_5_AND_EARLIER = 5,
+    DRAFT_6_AND_LATER   = 6
+
+} draftNumber_t;
+
+PACKED_STRUCT( ratePair_t,
+
+  rate_e    maxBasic;
+  rate_e    maxActive;
+);
+
+typedef enum
+{
+    RTS_CTS_DISABLED = 0,
+    RTS_CTS_ENABLED  = 1
+
+} RtsCtsStatus_e;
+
+/* Parameters Structures Definitions per parameter type */
+typedef enum
+{
+    AUTH_LEGACY_OPEN_SYSTEM     = 0,
+    AUTH_LEGACY_SHARED_KEY      = 1,
+    AUTH_LEGACY_AUTO_SWITCH     = 2,
+    AUTH_LEGACY_RESERVED1       = 128,
+    AUTH_LEGACY_NONE            = 255,
+} legacyAuthType_e;
+
+typedef enum
+{
+    CONNECTION_NONE             = 0,
+    CONNECTION_INFRA            = 1,
+    CONNECTION_IBSS             = 2,
+    CONNECTION_SELF             = 3,
+} connectionType_e;
+
+typedef enum
+{
+    RADIO_IN_STAND_BY           = 0,
+    RADIO_OUT_OF_STAND_BY       = 1,
+}radioStandByState_t;
+
+/**** Regulatory Domain module types ****/
+
+/* Scan Control Table for 2.4-G band type */
+PACKED_STRUCT( scanControlTable24_t,
+
+    UINT8       tableString[NUM_OF_CHANNELS_24];
+);
+
+/* Scan Control Table for 5G-band type */
+PACKED_STRUCT( scanControlTable5_t,
+
+    UINT8       tableString[A_5G_BAND_NUM_CHANNELS];
+);
+
+/* Scan Control Table type */
+PACKED_STRUCT( scanControlTable_t,
+
+    scanControlTable5_t     ScanControlTable5;
+    scanControlTable24_t    ScanControlTable24;
+);
+
+PACKED_STRUCT( country_t,
+
+    UINT8              elementId;
+       UINT8           len;
+    countryIE_t countryIE;
+);
+
+PACKED_STRUCT( channelPair_t,
+
+    UINT8   firstChennelNum;
+    UINT8   NumOfChannels;
+);
+
+typedef enum
+{
+    ACTIVE_SCANNING     = 0,
+    PASSIVE_SCANNING    = 1,
+} regulatoryDomain_scanOption_e;
+
+PACKED_STRUCT( regulatoryDomainParam_t,
+
+    UINT8*      pChannelBitMap;
+    UINT8       channelCnt;
+    INT8        txPower;
+);
+
+PACKED_STRUCT( powerCapability_t,
+
+    UINT8       minTxPower;
+    UINT8       maxTxPower;
+);
+
+
+/* SoftGemini module init parameters */
+typedef struct
+{
+    SoftGeminiEnableModes_e SoftGeminiEnable;
+       UINT8                                   SoftGeminiRate[NUM_OF_RATES_IN_SG];
+    SoftGeminiParam_t          SoftGeminiParam;
+       UINT8                                   scanNumOfProbeRequest;
+       UINT32                                  scanCompensationPercent;                        
+       UINT32                                  scanCompensationMaxTime;
+       UINT32                                  BSSLossCompensationPercent;
+ } SoftGeminiInitParams_t;
+
+typedef enum
+{
+    PHY_UNKNOWN         = 0,
+    PHY_FH              = 1,
+    PHY_DSS             = 2,
+    PHY_UN_USED         = 3,
+    PHY_OFDM            = 4,
+    PHY_HIGH_RATE_DSS   = 5,
+    PHY_ERP             = 6
+} phyType_e;
+
+
+typedef enum
+{
+    CLOSE           = 0,
+    OPEN_NOTIFY     = 1,
+    OPEN_EAPOL      = 2,
+    OPEN            = 3,
+    MAX_NUM_OF_RX_PORT_STATUS,
+} portStatus_e;
+
+typedef enum
+{
+    TX_DATA_CLOSED = 0,
+    TX_DATA_OPEN   = 1
+
+} txDataHalInterfaceStatus_t;
+
+
+typedef enum
+{
+    GWSI_PENDING   = 0,
+    GWSI_OPEN   = 1
+} txDataGwsiInterfaceStatus_e;
+
+
+typedef enum
+{
+    DRIVER_STATUS_IDLE              = 0,
+    DRIVER_STATUS_RUNNING           = 1,
+} driverStatus_e;
+
+typedef enum
+{
+    OS_ABS_LAYER    = 0,
+    RSN             = 1,
+} eapolDestination_e;
+
+/* enumerator for PRE_AUTH event */
+typedef enum
+{
+   RSN_PRE_AUTH_START,
+   RSN_PRE_AUTH_END,
+} preAuthStatusEvent_e;
+
+
+typedef enum
+{
+    STATUS_SCANNING         = 0,
+    STATUS_SCAN_COMPLETE    = 1,
+} scanStatus_e;
+
+typedef enum
+{
+    SCAN_DISABLED   = 0,       /* FALSE*/
+    SCAN_ENABLED    = 1,       /* TRUE*/
+       SKIP_NEXT_SCAN  = 2             /* Skip only one next coming scan, then set this parameter to TRUE*/
+} scanEnabledOptions_e;
+
+
+
+
+PACKED_STRUCT( rxDataCounters_t,
+
+    UINT32      RecvOk;                 /* the number of frames that the NIC receives without errors */
+    UINT32      DirectedBytesRecv;      /* the number of bytes in directed packets that are received without errors */
+    UINT32      DirectedFramesRecv;     /* the number of directed packets that are received without errors */
+    UINT32      MulticastBytesRecv;     /* the number of bytes in multicast/functional packets that are received without errors */
+    UINT32      MulticastFramesRecv;    /* the number of multicast/functional packets that are received without errors */
+    UINT32      BroadcastBytesRecv;     /* the number of bytes in broadcast packets that are received without errors. */
+    UINT32      BroadcastFramesRecv;    /* the number of broadcast packets that are received without errors. */
+    UINT32      LastSecBytesRecv;       /* the number of bytes received without errors during last second */
+
+);
+
+typedef struct rxDataFilterRequest_t
+{
+    UINT8       offset;
+    UINT8       maskLength;
+    UINT8       patternLength;
+    UINT8       mask[RX_DATA_FILTER_MAX_MASK_SIZE];
+    UINT8       pattern[RX_DATA_FILTER_MAX_PATTERN_SIZE];
+} rxDataFilterRequest_t;
+
+typedef struct rxDataFilterFieldPattern_t
+{
+    UINT8       offset;
+    UINT8       length;
+    UINT8       flag;
+    UINT8       pattern[RX_DATA_FILTER_MAX_PATTERN_SIZE];
+    UINT8       mask[RX_DATA_FILTER_MAX_PATTERN_SIZE];
+} rxDataFilterFieldPattern_t;
+
+PACKED_STRUCT( ctrlDataCounters_t,
+
+    UINT32      icvFailCounter;
+    UINT32      keyNotFoundCounter;
+    UINT32      MicFailureCounter;
+
+);
+
+
+typedef struct 
+{
+       PowerMgr_PowerMode_e    PowerMode;
+       PowerMgr_Priority_e     powerMngPriority; 
+}PowerMgr_PowerMode_t;
+
+
+typedef struct 
+{
+       void    *handler;
+       void    *callback; 
+}QoS_renegVoiceTspecReq_t;
+
+/* Authentication/encryption capability */
+#define MAX_AUTH_ENCR_PAIR 13
+
+typedef struct 
+{
+       externalAuthMode_e  authenticationMode;
+       cipherSuite_e       cipherSuite;
+
+} authEncrPairList_t;
+
+typedef struct 
+{
+       UINT32                 NoOfPMKIDs;
+       UINT32                 NoOfAuthEncrPairSupported;
+       authEncrPairList_t     authEncrPairs[MAX_AUTH_ENCR_PAIR];
+
+} rsnAuthEncrCapability_t;
+
+typedef struct 
+{
+       UINT32              numOfPreAuthBssids;
+       macAddress_t            *listOfPreAuthBssid;
+
+} rsnPreAuthBssidList_t;
+
+
+PACKED_STRUCT( signal_t,
+
+    INT32       rssi;
+    UINT8       snr;
+);
+
+PACKED_STRUCT( rateMask_t,
+
+    UINT32  basicRateMask;
+    UINT32  supportedRateMask;
+);
+
+PACKED_STRUCT( assocInformation_t,
+
+    UINT8        *assocRespBuffer;
+    UINT32       assocRespLen;
+    UINT8        *assocReqBuffer;
+    UINT32       assocReqLen;
+
+);
+
+/* QOS Parameters Structure */
+
+typedef struct
+{
+    macAddress_t    siteMacAddress;
+    BOOL            priority;
+} siteMgr_prioritySite_t;
+
+/*MULTIPLE QUEUES STRUCTURE */
+
+
+
+
+#define TX_POLICY_FLAGS_TRUNCATE          0x1
+#define TX_POLICY_FLAGS_PEEAMBLE_OVERRIDE 0x2
+#define TX_POLICY_FLAGS_SHORT_PREAMBLE    0x4
+
+
+typedef struct{
+       UINT32 thresholdCross;                /* high or low */
+       UINT32 thresholdCrossDirection;       /* direction of crossing */
+} trafficIntensityThresholdCross_t;
+
+/************************************/
+/*      QOS edcf params             */
+/************************************/
+
+/*
+#define CW_MIN_DEF                         15
+#define CW_MIN_MAX                         31
+#define CW_MAX_DEF                         1023
+*/
+#define CW_MIN_DEF                         4 /* the power of 2 - cwMin = 2^4-1 = 15 */
+#define CW_MIN_MAX                         5 /* the power of 2 - cwMax = 2^5-1 = 31 */
+#define CW_MAX_DEF                         10
+
+#define AIFS_DEF                            2
+#define NO_RX_TIME_OUT                      0
+#define NO_RX_ACK_POLICY                    0
+#define DATA_DCF                            0    /* MSDUs are sent completely including retrys - normal legacy traffic */
+#define QOS_DATA_EDCF                       1    /* MPDUs are sent according to TXOP limits - */
+#define RETRY_PREEMPTION_DISABLE            0
+#define QOS_CONTROL_TAG_MASK                0x0007
+#define QOS_CONTROL_EOSP_MASK                0x0010
+
+
+
+/* this enum is used for the different txRateClass_t which are components of txRatePolicy_t */
+typedef enum {
+       USER_RATE_CLASS         = 0,
+       SG_RATE_CLASS           = 1,
+       NUM_OF_RATE_CLASS_CLIENTS = 2
+} rateClassClients_e;
+
+typedef struct {
+       rateClassClients_e      clientID;
+       UINT32                          clientRateMask;
+}      rateClassRateMask_t;
+
+
+typedef enum{
+    AC_ACTIVE = 0,
+    AC_NOT_ACTIVE,
+}acActive;
+
+
+typedef struct
+{
+       UINT8   *buffer;
+       UINT16  bufLength;
+       UINT8   isBeacon;       /* If true, Beacon packet is returned, otherwise it is Probe Response */
+} BufferParameters_t;
+
+
+
+typedef struct{
+       UINT32          trafficAdmCtrlResponseTimeout;
+    BOOL        trafficAdmCtrlUseFixedMsduSize;
+}trafficAdmCtrlInitParams_t;
+
+typedef struct{
+    BOOL       wmeEnable;
+    BOOL       trafficAdmCtrlEnable;
+    BOOL       qosTagZeroConverHeader;
+       UINT8      PacketBurstEnable;
+       UINT32     PacketBurstTxOpLimit;
+    UINT32     TxOpLimit[MAX_NUM_OF_AC];
+    UINT32     MsduLifeTime[MAX_NUM_OF_AC];
+    rxTimeOut_t     rxTimeOut;
+    UINT8      ShortRetryLimit[MAX_NUM_OF_AC];
+    UINT8      LongRetryLimit[MAX_NUM_OF_AC];
+    UINT16      TxQueueSize[MAX_NUM_OF_TX_QUEUES];
+    UINT8   desiredWmeAcPsMode[MAX_NUM_OF_AC];       /* wme per ac power save mode */
+    qOvFlowPolicy_e   QueueOvFlowPolicy[MAX_NUM_OF_TX_QUEUES];
+       UINT8       acAckPolicy[MAX_NUM_OF_AC];          /* ack policy per AC */
+    trafficAdmCtrlInitParams_t trafficAdmCtrlInitParams;
+       UINT8                   desiredPsMode;                                           /* The desired PS mode of the station */
+       UINT8                           desiredMaxSpLen;
+
+}QosMngrInitParams_t;
+
+
+
+/*END OF MULTIPLE QUEUES STRUCTURE*/
+
+
+typedef struct
+{
+       UINT16          bufferSize;
+       UINT8           *buffer;
+} applicationConfigBuffer_t;
+
+typedef struct
+{
+    macAddress_t       bssID;
+    UINT16                     channel;
+} apChannelPair_t;
+
+typedef struct
+{
+    apChannelPair_t    *apChannelPairs;
+    UINT16             numOfEntries;
+} neighbor_AP_t;
+
+typedef struct
+{
+    /* One channel max duration time. (time slot 0 - 65000) */
+    UINT16          maxChannelDuration;
+    /* One channel max duration time. (time slot 0 - 65000) */
+    UINT16          minChannelDuration;
+    /* 0 = Stay until max duration time. 1 = Terminate scan in
+    a channel upon a reception of Prob-Res or Beacon. 2 = Terminate scan
+    in a channel upon a reception of any frame*/
+    UINT8           earlyTerminationMode;
+    /* number of AP frames (beacon/probe_resp) to trigger Early termination.
+    Applicable only when EarlyTerminationMode = 1 */
+    UINT8           eTMaxNumOfAPframes;
+    /* Number of probe request transmitted on each channel */
+    UINT8           numOfProbeReq;
+
+} periodicScanParams_t;
+
+
+typedef struct
+{      
+       UINT16          channelNum;
+       BOOL            channelValidity;
+       radioBand_e             band;
+} channelValidity_t;
+
+typedef struct
+{
+       BOOL    channelValidity; /*TRUE-valid, FALSE-invalid */
+       UINT8   maxTxPowerDbm;          /* In Dbm/10 units */
+}      channelCapabilityRet_t;
+
+typedef struct
+{
+       UINT8           *listOfChannels;
+       UINT8           sizeOfList;
+} supportedChannels_t;
+
+typedef struct
+{
+       regulatoryDomain_scanOption_e   scanOption; /* Passive or Active */
+       UINT8   channelNum;     
+       radioBand_e                     band;           
+}      channelCapabilityReq_t;
+
+typedef struct
+{
+       UINT16  minDFS_channelNum;      
+       UINT16  maxDFS_channelNum;      
+}      DFS_ChannelRange_t;
+
+typedef struct
+{
+       txDataCounters_t        *pTxDataCounters;
+       UINT8                           acID;
+}      reportTsStatisticsReq_t;
+
+typedef struct
+{
+       UINT16                          vadTimerEnabled;
+       UINT16                          vadTimerDuration;
+} txDataVadTimerParams_t;
+
+/* General Parameters Structure */
+
+typedef struct{
+    UINT32              paramType;
+    UINT32              paramLength;
+
+    union
+    {
+        /* Driver General section */
+        driverStatus_e          driverStatus;
+
+        /* HAL Control section */
+        UINT8                   halCtrlCtsToSelf;
+        UINT8                   halCtrlTxPowerDbm;
+
+        /* site manager section */
+        UINT8                   siteMgrDesiredChannel;
+        macAddress_t            siteMgrDesiredBSSID;
+        ssid_t                  siteMgrDesiredSSID;
+        bssType_e               siteMgrDesiredBSSType;
+        ratePair_t              siteMgrDesiredRatePair;
+        rates_t                 siteMgrDesiredBasicRateSet;
+        rates_t                 siteMgrDesiredSupportedRateSet;
+        rateMask_t              siteMgrCurrentRateMask;
+        UINT8                   siteMgrDesiredTxRate;
+        UINT8                   siteMgrCurrentTxRate;
+        modulationType_e        siteMgrDesiredModulationType;
+        UINT16                  siteMgrDesiredBeaconInterval;
+        preamble_e              siteMgrDesiredPreambleType;
+        preamble_e              siteMgrCurrentPreambleType;
+        radioType_e             siteMgrRadioType;
+        radioBand_e             siteMgrRadioBand;
+        OS_802_11_BSSID_LIST_EX *pSiteMgrBssidList;
+        OS_802_11_BSSID_EX      *pSiteMgrSelectedSiteInfo;
+        OS_802_11_BSSID         *pSiteMgrPrimarySiteDesc;
+        dot11mode_e             siteMgrDot11Mode;
+        dot11mode_e             siteMgrDot11OperationalMode;
+        draftNumber_t           siteMgrUseDraftNum;
+        UINT8                   siteMgrCurrentChannel;
+        ssid_t                  siteMgrCurrentSSID;
+               bssType_e                               siteMgrCurrentBSSType;
+        modulationType_e        siteMgrCurrentModulationType;
+        slotTime_e              siteMgrSlotTime;
+        signal_t                siteMgrCurrentSignal;
+        UINT8                   siteMgrNumberOfSites;
+        TIWLN_COUNTERS          siteMgrTiWlanCounters;
+        BOOL                    siteMgrBuiltInTestStatus;
+        UINT8                   siteMgrFwVersion[FW_VERSION_LEN]; /* Firmware version - null terminated string*/
+        e2Version_t             siteMgrEEpromVersion;             /* EEPROM version*/
+        UINT32                  siteMgrDisAssocReason;
+        UINT32                  siteMgrNextDtimTimeStamp;
+        UINT16                  siteMgrSiteCapability;
+        BOOL                    siteMgrFourxParam;
+        UINT16                  beaconInterval;
+        UINT8                   APTxPower;
+        BOOL                    siteMgrQuietScanInProcess;
+        BOOL                    siteMgrScanSliceCurrentlyActive;
+        UINT8                   siteMgrRoamingRssiGapThreshold;
+        UINT8                   timeStamp[8];
+        BOOL                    siteMgrBeaconRecv;
+        UINT32                  siteMgrDtimPeriod;
+        INT32                   siteMgrCurrentRssi;
+        UINT8                   siteMgrIndexOfDesiredSiteEntry;
+        UINT8                    *pSiteMgrDesiredSiteEntry;
+        UINT8                   siteMgrCurrentTsfTimeStamp[8];
+        UINT8                   siteMgrUsrConfigTxPower;
+
+
+        OS_802_11_CONFIGURATION *pSiteMgrConfiguration;
+        siteMgr_prioritySite_t  siteMgrPrioritySite;
+               BufferParameters_t              siteMgrLastBeacon;
+               UINT8                                   siteMgrDesiredBeaconFilterState;
+               BOOL                                    siteMgrAllowTxPowerCheck;
+
+        /* SME SM section */
+        scanStatus_e            smeSmScanStatus;
+               scanEnabledOptions_e    smeSMScanEnabled;
+        TIWLN_DOT11_STATUS      smeSmConnectionStatus;
+        UINT8                   smeSmState;
+
+        /* connection SM section */
+        UINT32                  connSelfTimeout;
+
+        /* auth SM section */
+        UINT32                  authResponseTimeout;
+
+        /* assoc SM section */
+        UINT32                  assocResponseTimeout;
+#ifndef GWSI_LIB
+        OS_802_11_ASSOCIATION_INFORMATION      assocAssociationInformation;
+#endif /* GWSI_LIB */
+               
+        /* RSN section */
+        BOOL                    rsnPrivacyOptionImplemented;
+        authSuite_e             rsnDesiredAuthType;
+        OS_802_11_KEY           rsnOsKey;
+        rsnAuthEncrCapability_t *pRsnAuthEncrCapability;
+        UINT32                  rsnNoOfPMKIDs;
+        OS_802_11_PMKID         rsnPMKIDList;
+        UINT32                  rsnWPAPromoteFlags;
+        UINT32                  rsnWPAMixedModeSupport;
+        UINT32                  rsnAuthState; /* supp_1XStates */
+        cipherSuite_e           rsnEncryptionStatus;
+        UINT8                   rsnHwEncDecrEnable; /* 0- disable, 1- enable*/
+        securityKeys_t          *pRsnKey;
+        UINT8                   rsnDefaultKeyID;
+
+        externalAuthMode_e      rsnExtAuthneticationMode;
+        BOOL                    rsnMixedMode;
+               BOOL                                    rsnPreAuthStatus;
+               macAddress_t                    rsnApMac;
+        OS_802_11_EAP_TYPES     eapType;
+        BOOL                    wpa_802_1x_AkmExists;
+
+
+        /* Rx Data section */
+        rxDataCounters_t        rxDataCounters;
+        BOOL                    rxDataFilterEnableDisable;
+        TIWLAN_DATA_FILTER_REQUEST rxDataFilterRequest;
+
+        /* Tx Data section */
+        portStatus_e            txDataPortStatus;
+        txDataCounters_t        *pTxDataCounters;
+               reportTsStatisticsReq_t tsMetricsCounters;
+        OS_802_11_THRESHOLD_CROSS_PARAMS  txDataMediumUsageThreshold;
+               txDataHalInterfaceStatus_t  txDataHalInterfaceStatus;
+        UINT8                       txDataEncryptionFieldSize;
+
+        /* Ctrl Data section */
+        ctrlDataCounters_t      ctrlDataCounters;
+        BOOL                    ctrlDataRateControlEnable;
+        BOOL                    ctrlDataPowerSaveEnable;
+        BOOL                    ctrlDataPowerSaveForce;
+        BOOL                    ctrlDataFourXEnable;
+        BOOL                    ctrlDatapowerSaveEnhanceAlgorithm;
+        erpProtectionType_e     ctrlDataIbssProtecionType;
+        RtsCtsStatus_e          ctrlDataRtsCtsStatus;
+        BOOL                    ctrlDataProtectionEnabled;
+        BOOL                    ctrlDataCerruentFourXstate;
+
+        macAddress_t            ctrlDataCurrentBSSID;
+        bssType_e               ctrlDataCurrentBssType;
+        UINT32                  ctrlDataCurrentRateMask;
+        rate_e                  ctrlDataCurrentBasicRate;
+        preamble_e              ctrlDataCurrentPreambleType;
+        rate_e                  ctrlDataCurrentActiveRate;
+        macAddress_t            ctrlDataDeviceMacAddress;
+        STREAM_TRAFFIC_PROPERTIES   ctrlDataUpOfStream;
+               clsfr_tableEntry_t              ctrlDataClsfrInsertTable;
+        clsfrTypeAndSupport     ctrlDataClsfrType;
+        OS_802_11_THRESHOLD_CROSS_PARAMS  ctrlDataRateThreshold;
+               rateClassClients_e              ctrlDataRateClassID;
+               rateClassRateMask_t             ctrlDataRateClassMask;
+
+               ULONG                                   ctrlDataTrafficIntensityEventsFlag;
+               OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS ctrlDataTrafficIntensityThresholds;
+
+        connectionType_e        connType;
+
+        /* MLME SM section */
+        legacyAuthType_e        mlmeLegacyAuthType;
+        legacyAuthType_e        authLegacyAuthType;
+        BOOL                    mlmeReAssoc;
+
+
+        BOOL                    rxDataExcludeUnencrypted;
+        eapolDestination_e      rxDataEapolDestination;
+        portStatus_e            rxDataPortStatus;
+
+        BOOL                    txDataCurrentPrivacyInvokedMode;
+        BOOL                    txDataEapolEncryptionStatus;
+        UINT32                  txDataPollApPacketsFromACid;      /* AC to poll AP packets from */
+
+        modulationType_e        ctrlDataCurrentModulationType;
+        modulationType_e        ctrlDataCurrentBasicModulationType;
+        UINT32                  ctrlDataBasicRateBitMask;
+
+        /* regulatory Domain section */
+        regulatoryDomainParam_t regulatoryDomainParam;
+        UINT8                   channel;
+        country_t*              pCountry;
+        UINT8                   pCountryString[COUNTRY_STRING_LEN];
+        BOOL                    spectrumManagementEnabled;
+        BOOL                    regulatoryDomainEnabled;
+        powerCapability_t       powerCapability;
+        UINT8*                  pSupportedChannel;
+        UINT8                   powerConstraint;
+        UINT8                   desiredTxPower; /* The desired Tx power inforced by the User (Utility),
+                                                 or The desired Tx power (in Dbm) as forced by teh OS */
+        UINT8                   ExternTxPowerPreferred; /*for other extern elements that want        
+                                                        to effect the transmit power*/
+               powerLevelTable_t               powerLevelTable;
+               channelValidity_t               channelValidity;
+               channelCapabilityRet_t  channelCapabilityRet;
+               channelCapabilityReq_t  channelCapabilityReq;
+               supportedChannels_t             supportedChannels;                                      
+        BOOL                    enableDisable_802_11d;
+        BOOL                    enableDisable_802_11h;
+               BOOL                                    bActivateTempPowerFix;
+               BOOL                                    bIsCountryFound;
+               BOOL                                    bIsChannelSupprted;
+        DFS_ChannelRange_t      DFS_ChannelRange;
+        radioBand_e             eRadioBand;
+
+        /* Measurement Manager section */
+               UINT32                                  measurementEnableDisableStatus;
+        UINT16                                 measurementTrafficThreshold;
+               UINT16                                  measurementMaxDuration;
+        interogateCmdCBParams_t     interogateCmdCBParams;
+
+
+        /* soft Gemini section */
+        SoftGeminiEnableModes_e                SoftGeminiEnable;
+               UINT8                                           SoftGeminiRate[NUM_OF_RATES_IN_SG];
+        UINT32                                         SoftGeminiParamArray[NUM_OF_CONFIG_PARAMS_IN_SG];
+
+               /* case EXC MODULE INCLUDED */
+               EXC_PARAM_FIELDS
+
+        /* Application Config Parameters Manager */
+               applicationConfigBuffer_t       applicationConfigBuffer;
+               roamingMngrConfigParams_t       roamingConfigBuffer;
+               UINT32                                          roamingTriggerType;
+               UINT32                                          roamingConnStatus;
+        bssList_t*              pScanBssList;
+        scan_Params_t*          pScanParams;
+
+        /* tx data qos related parameters */
+        txDataQosParams_t           txDataQosParams;
+
+        txDataVadTimerParams_t         txDataVadTimerParams;
+
+        /* QOS Manager */
+        qosProtocols_e              qosSiteProtocol;
+               UINT8                                           qosPacketBurstEnb;     /* Packet Burst Enable */
+               dot11mode_e                                     qosMngrOperationalMode;
+               UINT8                                   desiredPsMode;
+               UINT8                                   currentPsMode;
+               TspecConfigure_t                TspecConfigure;
+
+        /* Qos params from Os */
+               OS_802_11_QOS_RX_TIMEOUT_PARAMS rxTimeOut;
+
+        OS_802_11_QOS_PARAMS        qosOsParams;
+               OS_802_11_AC_QOS_PARAMS         qosApQosParams;
+               
+        /* AP Qos Capabilities */
+        OS_802_11_AP_QOS_CAPABILITIES_PARAMS qosApCapabilities;
+
+        /* Qos current AC status */
+        OS_802_11_AC_UPSD_STATUS_PARAMS   qosCurrentAcStatus;
+
+        OS_802_11_QOS_DELETE_TSPEC_PARAMS   qosDelTspecRequest;
+        OS_802_11_QOS_TSPEC_PARAMS     qosAddTspecRequest;
+               QoS_renegVoiceTspecReq_t           qosRenegotiateTspecRequest;
+
+        OS_802_11_QOS_TSPEC_PARAMS     qosTspecParameters;
+
+               OS_802_11_THRESHOLD_CROSS_PARAMS  QOSRateThreshold;
+               OS_802_11_QOS_DESIRED_PS_MODE   qosDesiredPsMode;
+
+       /* Power Manager */
+        PowerMgr_PowerMode_e    PowerMode;
+        powerAutho_PowerPolicy_e PowerSavePowerLevel;
+        powerAutho_PowerPolicy_e DefaultPowerLevel;
+        PowerMgr_PowerMode_t           powerMngPowerMode;
+        PowerMgr_Priority_e            powerMngPriority;
+        PowerMgr_PowerMode_e   powerMngDozeMode;
+
+
+        /* txRatePolicy params */
+        txRatePolicy_t         TxRatePolicy;
+       
+        TIWLN_RADIO_RX_QUALITY RxRadioQuality ;
+               
+        /*PLT MIB*/
+        PLT_MIB_t PltMib;
+
+    } content;
+} paramInfo_t;
+
+/* Set/get params function prototype */
+typedef TI_STATUS (*paramFunc_t)(TI_HANDLE handle, paramInfo_t *pParam);
+
+
+typedef enum
+{
+  MIN_BASIC_TX_RATE         = 0, /* The rate of the CTL & MGMT packets will be the minimal rate advertised in the Basic rate set */
+  MAX_BASIC_TX_RATE         = 1, /* The rate of the CTL &MGMT packets will be the maximal rate advertised in the Basic rate set */
+  SPECIFIC_TX_RATE          = 2, /* The rate of the CTL & MGMT packets will be according to the configuration in the MgmtCtrlTxRate registry */
+} mgmtCtrlTxRateOption_e;
+
+
+
+/*-----------------------------------------------------*/
+/*      EEPROM-less support                            */
+/*-----------------------------------------------------*/
+#define MAX_CALL_DATA_REG_NUM                30
+#define HW_EEPROM_PRESENTED                  1
+#define HW_EEPROM_NOT_PRESENTED              0
+
+PACKED_STRUCT( ELPTable_t,
+
+    UINT8   ClockControl;
+    UINT16  ClockWakupTime;
+    UINT8   Reserved1;
+    UINT16  Reserved2;
+    UINT8   A_1_8_Control;
+    UINT16  A_1_8_WakeupTime;
+    UINT8   VsyncControl;
+    UINT16  VsyncWakeupTime;
+    UINT8   GcVccControl;
+    UINT16  GcVccWakeupTime;
+    UINT8   Reserved3;
+    UINT16  BBRadioWakeupTime;
+    UINT8   Reserved4;
+    UINT16  ClockIdleTime;
+
+);
+
+PACKED_STRUCT( MiscTable_t,
+
+    UINT16  TxActivityLED;
+    UINT16  InitLED;
+    UINT16  DiagLED;
+    UINT8   Reserved1;
+
+);
+
+
+PACKED_STRUCT( PhyRegisters_t,
+
+    UINT16  RegAddress;
+    UINT16  RegValue;
+
+);
+
+
+typedef enum
+{
+    PS_MODE_ELP         = 0,
+    PS_MODE_POWER_DOWN  = 1,
+    PS_MODE_ACTIVE      = 2,
+    PS_MODE_WAKE_TNET   = 3,
+} powerSaveModes_e;
+
+
+/**************************** Beginning of Init Params ************************************/
+
+
+typedef struct
+{
+    UINT8                   siteMgr_radioRxLevel[RX_LEVEL_TABLE_SIZE];
+    UINT8                   siteMgr_radioLNA[RX_LEVEL_TABLE_SIZE];
+    UINT8                   siteMgr_radioRSSI[RX_LEVEL_TABLE_SIZE];
+    UINT32                  factorRSSI; /* for RADIA only */
+}radioValues_t;
+
+typedef struct
+{
+    radioType_e         siteMgr_radioType;
+    UINT8               RxLevelTableSize;
+    radioValues_t*      pSiteMgr_selectedRadioValues;
+    radioValues_t       siteMgr_rfmdRadioValues;
+    radioValues_t       siteMgr_maximRadioValues;
+    radioValues_t       siteMgr_radiaRadioValues;
+}siteMgr_radioValues_t;
+       
+
+typedef struct
+{
+    UINT8                   siteMgrDesiredChannel;
+    macAddress_t            siteMgrDesiredBSSID;
+    ssid_t                  siteMgrDesiredSSID;
+    bssType_e               siteMgrDesiredBSSType;
+    dot11mode_e             siteMgrDesiredDot11Mode;
+    radioBand_e             siteMgrSupportedBand;
+    draftNumber_t           siteMgrUseDraftNum;
+    UINT32                  siteMgrRegstryBasicRate[DOT11_MAX_MODE];
+    UINT32                  siteMgrRegstrySuppRate[DOT11_MAX_MODE];
+    UINT32                  siteMgrRegstryBasicRateMask;
+    UINT32                  siteMgrRegstrySuppRateMask;
+    rateMask_t              siteMgrCurrentDesiredRateMask;
+    ratePair_t              siteMgrDesiredRatePair;
+    UINT32                  siteMgrMatchedBasicRateMask;
+    UINT32                  siteMgrMatchedSuppRateMask;
+    UINT32                  siteMgrMatchedMaxBasicRate;
+    UINT32                  siteMgrMatchedMaxActiveRate;
+    rate_e                  siteMgrRegstryDesiredTxRate;
+    rate_e                  siteMgrCurrentDesiredTxRate;
+       mgmtCtrlTxRateOption_e  siteMgrRegstryDesiredMgmtCtrlTxRateOption;
+       rate_e                                  siteMgrRegstryDesiredMgmtCtrlTxRate;
+    modulationType_e        siteMgrDesiredModulationType;
+    preamble_e              siteMgrDesiredPreambleType;
+    slotTime_e              siteMgrDesiredSlotTime;
+    UINT16                  siteMgrDesiredBeaconInterval;
+    siteMgr_radioValues_t   siteMgrRadioValues;
+    UINT8                   siteMgrFwVersion[FW_VERSION_LEN]; /* Firmware version - null terminated string*/
+    e2Version_t             siteMgrEEpromVersion;             /* EEPROM version*/
+    UINT32                  siteMgrDesiredAtimWindow;
+    UINT32                  siteMgrFreq2ChannelTable[SITE_MGR_CHANNEL_MAX+1];
+    
+    BOOL                    siteMgrDesiredkeepAliveEnable;
+    UINT8                   siteMgrExternalConfiguration;
+    UINT8                   siteMgrPrivacyMode;
+    BOOL                    siteMgrWiFiAdhoc;
+
+       /* TX Power Control parameters */
+    UINT32                  TxPowerCheckTime;
+    UINT32                  TxPowerControlOn;
+    INT32                   TxPowerRssiThresh;
+    INT32                   TxPowerRssiRestoreThresh;
+       
+       beaconFilterParams_t    beaconFilterParams; /*contains the desired state*/
+
+} siteMgrInitParams_t;
+
+
+/** \struct scan_Params_t
+ * \brief This structure contains parameters for a scan operation
+ */
+typedef struct
+{
+       UINT8                           txPowerDbm;                     /* In units of Dbm/10 */ 
+    UINT8               probeReqNumber;         /**< number of probe requests to send (for active scan) */
+    rateMask_e          probeRequestRate;       /**< the rate at which to send the probe requests */
+    UINT8               numOfChannels;          /**< number of channels for BG (2.4) band */
+    UINT8                              channelsList[ MAX_NUMBER_OF_CHANNELS_PER_SCAN ];  /* scan channels list for BG */
+       UINT32                          minDwellTime;
+       UINT32                          maxDwellTime;
+} sme_scan_Params_t;
+
+
+typedef struct
+{
+    BOOL                    EnableFirstConnScan;
+    UINT32                  InterScanIntervalMin;
+    UINT32                  InterScanIntervalMax;
+       UINT32                  InterScanIntervalDelta;
+       sme_scan_Params_t       scanParamsBG;
+    sme_scan_Params_t          scanParamsA;
+} smeInitParams_t;
+
+typedef struct
+{
+    UINT32                  connSelfTimeout;
+} connInitParams_t;
+
+typedef struct
+{
+    UINT32                  authResponseTimeout;
+    UINT32                  authMaxRetryCount;
+} authInitParams_t;
+
+typedef struct
+{
+    UINT32                  assocResponseTimeout;
+    UINT32                  assocMaxRetryCount;
+} assocInitParams_t;
+
+typedef struct
+{
+       UINT8                           highRateThreshold;
+       UINT8                           lowRateThreshold;
+       BOOL                            enableEvent;
+}tspecsRateParameters_t;
+
+typedef struct
+{
+    UINT8                   contTxPacketsThreshold;
+    UINT8                   stepUpTxPacketsThreshold;
+    UINT32                  ctrlDataFBShortInterval;
+    UINT32                  ctrlDataFBLongInterval;
+    UINT32                  rateAdapt_timeout;
+       tspecsRateParameters_t  tspecsRateParameters[MAX_NUM_OF_AC];
+
+}rateAdaptationInitParam_t;
+
+
+typedef struct
+{
+    BOOL                    ctrlDataPowerSaveEnhanceAlgorithm;
+    UINT16                  ctrlDataPowerSaveTimeOut;
+    UINT8                   ctrlDataPowerSaveTxThreshold;
+    UINT8                   ctrlDataPowerSaveRxThreshold;
+
+}powerSaveInitParams_t;
+
+typedef struct
+{
+    BOOL                    desiredConcatenationEnable;
+    BOOL                    desiredCWMinEnable;
+    BOOL                    desiredCWComboEnable;
+    BOOL                    desiredAckEmulationEnable;
+    BOOL                    desiredERP_ProtectionEnable;
+    UINT32                  desiredMaxConcatSize;
+    UINT16                  desiredCWMin;
+    UINT16                  desiredCWMax;
+}fourXInitParams_t;
+
+
+typedef struct
+{
+    UINT32  len;
+    rate_e  rateAdaptRatesTable[MAX_SUPPORTED_RATES];
+    UINT8   rateAdaptFBTable[MAX_SUPPORTED_RATES];
+    UINT8   rateAdaptSUTable[MAX_SUPPORTED_RATES];
+} ctrlData_rateAdapt_t;
+
+typedef struct
+{
+    ctrlData_rateAdapt_t    ctrlDataCckRateTable;
+    ctrlData_rateAdapt_t    ctrlDataPbccRateTable;
+    ctrlData_rateAdapt_t    ctrlDataOfdmRateTable;
+    ctrlData_rateAdapt_t    ctrlDataOfdmARateTable;
+} rateTables_t;
+
+typedef struct
+{
+       UINT8 longRetryLimit;
+       UINT8 shortRetryLimit;
+}txRatePolicyParams;
+
+typedef struct  
+{
+       UINT8 txRate[MAX_NUM_OF_TX_RATES_IN_CLASS];
+} policyClassRatesArray_t;
+
+typedef struct
+{
+    BOOL                        ctrlDataRateControlEnable;
+    BOOL                        ctrlDataPowerSaveEnable;
+    BOOL                        ctrlDataFourXEnable;
+    BOOL                        ctrlDataSoftGeminiEnable;
+    macAddress_t                ctrlDataDeviceMacAddress;
+    rateAdaptationInitParam_t   rateAdaptationInitParam;
+    powerSaveInitParams_t       powerSaveInitParams;
+    fourXInitParams_t           fourXInitParams;
+       clsfr_Params_t                          ClsfrInitParam;
+    rateTables_t                rateTable;
+    erpProtectionType_e         ctrlDataDesiredIbssProtection;
+    RtsCtsStatus_e              ctrlDataDesiredCtsRtsStatus;
+    OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS   ctrlDataTrafficThreshold;
+    BOOL                        ctrlDataTrafficThresholdEnabled;
+    txRatePolicyParams          ctrlDataTxRatePolicy      [NUM_OF_RATE_CLASS_CLIENTS];
+       policyClassRatesArray_t         policyClassRatesArrayCck  [NUM_OF_RATE_CLASS_CLIENTS];
+       policyClassRatesArray_t         policyClassRatesArrayPbcc [NUM_OF_RATE_CLASS_CLIENTS];
+       policyClassRatesArray_t         policyClassRatesArrayOfdm [NUM_OF_RATE_CLASS_CLIENTS];
+       policyClassRatesArray_t         policyClassRatesArrayOfdmA[NUM_OF_RATE_CLASS_CLIENTS];
+
+} ctrlDataInitParams_t;
+
+typedef struct
+{
+    UINT8                   txDataNumOfDataQueues;
+    UINT32                  uFracOfLifeTimeToDrop;
+       UINT32                                  creditCalculationTimeout;
+    BOOL                    admCtrlDelayDueToMediumTimeOverUsage;
+       BOOL                                    admissionDownGradeEnable;
+       BOOL                                    bCreditCalcTimerEnabled;
+       /* IMPORT_FROM_4_0_1 */
+       BOOL                                    txDataHostPacketProcessing;
+
+} txDataInitParams_t;
+
+#define MAX_KEYS_NUM                    4
+
+typedef struct
+{
+    authSuite_e             authSuite;
+    BOOL                    privacyOn;
+    securityKeys_t          keys[MAX_KEYS_NUM];
+    UINT8                   defaultKeyId;
+    externalAuthMode_e      externalAuthMode;
+    BOOL                    mixedMode;
+    BOOL                    WPAMixedModeEnable;
+    BOOL                    preAuthSupport;
+       UINT32                                  preAuthTimeout;
+} rsnInitParams_t;
+
+typedef enum
+{
+    RADIO_B_G_INDEX = 0,
+    RADIO_A_B_G_INDEX = 1,
+    NUM_OF_RADIO_TYPES = 2
+} regulatoryDomain_radioIndexType_e;
+
+/* Regulatory Domain module init parameters */
+typedef struct
+{
+    UINT32                      uTimeOutToResetCountryMs;   /* Time after which country code will be reset */
+    UINT8                       multiRegulatoryDomainEnabled; /* 802.11d */
+    UINT8                       spectrumManagementEnabled; /* 802.11h */
+    UINT8                       desiredTxPower;
+       UINT8                                           uTemporaryTxPower;
+    scanControlTable_t          desiredScanControlTable;/* for 5 and 2.4 Ghz*/
+} regulatoryDomainInitParams_t;
+
+#ifdef EXC_MODULE_INCLUDED
+typedef enum
+{
+    EXC_MODE_DISABLED,
+    EXC_MODE_ENABLED,
+    EXC_MODE_STANDBY
+} excMngr_mode_t;
+
+typedef struct
+{
+    excMngr_mode_t  excEnabled;
+} excMngrParams_t;
+#endif
+
+/* Measurement module init parameters */
+typedef struct
+{
+    UINT16              trafficIntensityThreshold;
+    UINT16              maxDurationOnNonServingChannel;
+#ifdef EXC_MODULE_INCLUDED
+    excMngr_mode_t      excEnabled;
+#endif
+} measurementInitParams_t;
+
+/* Switch Channel Module module init parameters */
+typedef struct
+{
+    BOOL              dot11SpectrumManagementRequired;
+
+} SwitchChannelInitParams_t;
+
+typedef struct
+{
+  UINT32       qosClassifierTable[MAX_NUM_OF_802_1d_TAGS];
+}
+clsfrParams_t;
+
+/* WDK pack structure */
+#ifdef _WINDOWS
+#endif
+
+typedef struct
+{
+    PowerMgr_PowerMode_e        powerMode;
+    UINT32                      beaconReceiveTime;
+    UINT8                       hangoverPeriod;
+    UINT8                       beaconListenInterval;
+    UINT8                               dtimListenInterval;
+    UINT8                       nConsecutiveBeaconsMissed;
+    UINT8                       EnterTo802_11PsRetries;
+    UINT8                       HwPsPollResponseTimeout;
+    UINT16                                     autoModeInterval;
+    UINT16                                     autoModeActiveTH;
+    UINT16                                     autoModeDozeTH;
+    PowerMgr_PowerMode_e        autoModeDozeMode;
+
+       powerAutho_PowerPolicy_e defaultPowerLevel;
+       powerAutho_PowerPolicy_e PowerSavePowerLevel;           
+
+       
+       /* powerMgmtConfig IE */
+    UINT8                                              mode;
+    UINT8                                              needToSendNullData;  
+    UINT8                                              numNullPktRetries; 
+    UINT8                                              hangOverPeriod;
+    UINT16                                             NullPktRateModulation; 
+
+       /* PMConfigStruct */
+       UINT32                                          ELPEnable;                      /* based on "elpType" */
+       UINT32                                          WakeOnGPIOenable;       /* based on "hwPlatformType" */
+       UINT32                                          BaseBandWakeUpTime;     /* BBWakeUpTime */
+       UINT32                                          PLLlockTime;
+
+       /* ACXWakeUpCondition */
+    UINT8                                              listenInterval;
+
+    /* BET */
+    UINT32  MaximalFullBeaconReceptionInterval; /* maximal time between full beacon reception */
+    UINT8   BetEnableThreshold;
+    UINT8   BetDisableThreshold;
+    UINT8      BetEnable;             
+    UINT8   MaximumConsecutiveET;
+
+    UINT32                                             PsPollDeliveryFailureRecoveryPeriod;
+}PowerMgrInitParams_t;
+
+
+typedef struct
+{
+       UINT32 healthCheckPeriod;
+       UINT8  FullRecoveryEnable;
+       BOOL   recoveryTriggerEnabled[ MAX_FAILURE_EVENTS ];
+} healthMonitorInitParams_t;
+
+typedef struct
+{
+    BOOL   ignoreDeauthReason0;
+} apConnParams_t;
+
+typedef struct
+{
+    UINT32 passiveScanDwellTime;
+    UINT32 minimumDurationBetweenOidScans;
+} scanConcentratorInitParams_t;
+
+
+typedef struct
+{
+       BOOL                rxDataHostPacketProcessing;
+    BOOL                rxDataFiltersEnabled;
+    filter_e            rxDataFiltersDefaultAction;
+    rxDataFilterRequest_t rxDataFilterRequests[MAX_DATA_FILTERS];
+}rxDataInitParams_t;
+
+
+typedef struct
+{
+    uint32 activeTimeCnt_Low;
+    uint32 activeTimeCnt_Hi;
+    uint32 powerDownTimeCnt_Low;
+    uint32 powerDownTimeCnt_Hi;
+    uint32 elpTimeCnt_Low;
+    uint32 elpTimeCnt_Hi;
+}PowerConsumptionTimeStat_t;
+
+
+/* This table is forwarded to the driver upon creation by the Os abstraction layer. */
+typedef struct
+{
+       TnetwDrv_InitParams_t           TnetwDrv_InitParams;
+
+    siteMgrInitParams_t             siteMgrInitParams;
+    connInitParams_t                connInitParams;
+    authInitParams_t                authInitParams;
+    assocInitParams_t               assocInitParams;
+    txDataInitParams_t              txDataInitParams;
+    ctrlDataInitParams_t            ctrlDataInitParams;
+    rsnInitParams_t                 rsnInitParams;
+    regulatoryDomainInitParams_t    regulatoryDomainInitParams;
+    measurementInitParams_t         measurementInitParams;
+    smeInitParams_t                 smeInitParams;
+    SoftGeminiInitParams_t          SoftGeminiInitParams;
+    QosMngrInitParams_t             qosMngrInitParams;
+    clsfrParams_t                   clsfrParams;
+#ifdef EXC_MODULE_INCLUDED
+    excMngrParams_t                 excMngrParams;
+#endif
+       SwitchChannelInitParams_t               SwitchChannelInitParams;
+       healthMonitorInitParams_t               healthMonitorInitParams;
+    apConnParams_t                  apConnParams;
+    PowerMgrInitParams_t            PowerMgrInitParams;
+    scanConcentratorInitParams_t    scanConcentratorInitParams;
+       rxDataInitParams_t              rxDataInitParams;
+       BOOL                                                    SendINIBufferToUser;
+    /* Traffic Monitor */
+    UINT8                           trafficMonitorMinIntervalPercentage;
+} initTable_t;
+
+/* WDK end usage of packing */
+#ifdef _WINDOWS
+#endif
+
+/**************************** End of Init Params ************************************/
+
+
+
+#define P_BUFFER_ADD_UINT8(_p_buffer, _uint8)                          \
+               {                                                                                                               \
+                       *(tiUINT8 *)(_p_buffer++) = _uint8;                             \
+               }
+
+#define P_BUFFER_ADD_UINT16(_p_buffer, _uint16)                          \
+               {                                                                                                                 \
+                       *(tiUINT8 *)(_p_buffer++) = (_uint16 & 0x00FF);           \
+                       *(tiUINT8 *)(_p_buffer++) = ((_uint16 & 0xFF00) >> 8);\
+               }
+
+#define P_BUFFER_ADD_UINT32(_p_buffer, _uint32)                                                   \
+{                                                                                                                                         \
+                       *(tiUINT8 *)(_p_buffer++) = (_uint32 & 0x000000FF);                \
+                       *(tiUINT8 *)(_p_buffer++) = ((_uint32 & 0x0000FF00) >> 8); \
+                       *(tiUINT8 *)(_p_buffer++) = ((_uint32 & 0x00FF0000) >> 16);\
+                       *(tiUINT8 *)(_p_buffer++) = ((_uint32 & 0xFF000000) >> 24);\
+               }
+
+#define P_BUFFER_ADD_DATA(_p_buffer, _p_data, _len)            \
+               {                                                                                                               \
+                       memcpy(_p_buffer, _p_data, _len);                                       \
+                       _p_buffer += _len;                                                                      \
+               }                 
+
+#define P_BUFFER_GET_UINT8(_p_buffer, _uint8)                                  \
+               {                                                                                                               \
+                       _uint8 = *(tiUINT8 *)(_p_buffer++);                                     \
+               }
+
+#define P_BUFFER_GET_UINT16(_p_buffer, _uint16)                                    \
+               {                                                                                                           \
+                       _uint16 = *(tiUINT8 *)(_p_buffer++);                        \
+                       _uint16 |= (*(tiUINT8 *)(_p_buffer++) << 8);            \
+               }
+
+
+#define P_BUFFER_GET_UINT32(_p_buffer, _uint32)                                        \
+               {                                                                                                               \
+                       _uint32 = *(tiUINT8 *)(_p_buffer++);                        \
+                       _uint32 |= (*(tiUINT8 *)(_p_buffer++) << 8);            \
+                       _uint32 |= (*(tiUINT8 *)(_p_buffer++) << 16);           \
+                       _uint32 |= (*(tiUINT8 *)(_p_buffer++) << 24);           \
+               }
+
+#define P_BUFFER_ADD_HDR_PARAMS(_p_buffer, _op, _status)       \
+               {                                                                                                               \
+                       *(tiUINT8 *)(_p_buffer + 0) = (_op & 0x00FF);           \
+                       *(tiUINT8 *)(_p_buffer + 1) = ((_op & 0xFF00) >> 8);\
+                       *(tiUINT8 *)(_p_buffer + 2) = _status;                          \
+                       _p_buffer += 3;                                                                         \
+               }
+
+
+
+
+#endif /* __PARAM_OUT_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/inc/ratesTypes.h b/sta_dk_4_0_4_32/common/inc/ratesTypes.h
new file mode 100644 (file)
index 0000000..c842604
--- /dev/null
@@ -0,0 +1,138 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef RATES_TYPES_H
+#define RATES_TYPES_H
+
+typedef enum
+{
+    DRV_RATE_AUTO       = 0,
+    DRV_RATE_1M         = 1,
+    DRV_RATE_2M         = 2,
+    DRV_RATE_5_5M       = 3,
+    DRV_RATE_11M        = 4,
+    DRV_RATE_22M        = 5,
+    DRV_RATE_6M         = 6,
+    DRV_RATE_9M         = 7,
+    DRV_RATE_12M        = 8,
+    DRV_RATE_18M        = 9,
+    DRV_RATE_24M        = 10,
+    DRV_RATE_36M        = 11,
+    DRV_RATE_48M        = 12,
+    DRV_RATE_54M        = 13,
+    DRV_RATE_MAX        = 13,
+    DRV_RATE_INVALID= 0xFF
+} rate_e;
+
+
+typedef enum
+{
+    DRV_RATE_MASK_AUTO          = DRV_RATE_AUTO, /*0x0000,*/
+    DRV_RATE_MASK_1_BARKER      = (1<<(DRV_RATE_1M - 1)), /*0x0001,*/
+    DRV_RATE_MASK_2_BARKER      = (1<<(DRV_RATE_2M - 1)), /*0x0002,*/
+    DRV_RATE_MASK_5_5_CCK       = (1<<(DRV_RATE_5_5M - 1)), /*0x0004,*/
+    DRV_RATE_MASK_11_CCK        = (1<<(DRV_RATE_11M - 1)), /*0x0008,*/
+    DRV_RATE_MASK_22_PBCC       = (1<<(DRV_RATE_22M - 1)), /*0x0010,*/
+    DRV_RATE_MASK_6_OFDM        = (1<<(DRV_RATE_6M - 1)), /*0x0020,*/
+    DRV_RATE_MASK_9_OFDM        = (1<<(DRV_RATE_9M - 1)), /*0x0040,*/
+    DRV_RATE_MASK_12_OFDM       = (1<<(DRV_RATE_12M - 1)), /*0x0080,*/
+    DRV_RATE_MASK_18_OFDM       = (1<<(DRV_RATE_18M - 1)), /*0x0100,*/
+    DRV_RATE_MASK_24_OFDM       = (1<<(DRV_RATE_24M - 1)), /*0x0200,*/
+    DRV_RATE_MASK_36_OFDM       = (1<<(DRV_RATE_36M - 1)), /*0x0400,*/
+    DRV_RATE_MASK_48_OFDM       = (1<<(DRV_RATE_48M - 1)), /*0x0800,*/
+    DRV_RATE_MASK_54_OFDM       = (1<<(DRV_RATE_54M - 1)), /*0x1000*/
+} rateMask_e;
+
+/*GWSI_RATE*/
+#define GWSI_1Mbits    0x00000001
+#define GWSI_2Mbits    0x00000002
+#define GWSI_5_5Mbits  0x00000004
+#define GWSI_6Mbits    0x00000008
+#define GWSI_9Mbits    0x00000010
+#define GWSI_11Mbits   0x00000020
+#define GWSI_12Mbits   0x00000040
+#define GWSI_18Mbits   0x00000080
+#define GWSI_22Mbits   0x00000100
+#define GWSI_24Mbits   0x00000200
+#define GWSI_36Mbits   0x00000800
+#define GWSI_48Mbits   0x00001000
+#define GWSI_54Mbits   0x00002000
+
+/*HW_RATE*/
+#define HW_RATE_1M                     (0x0A)
+#define HW_RATE_2M                     (0x14)
+#define HW_RATE_5_5M           (0x37)
+#define HW_RATE_5_5M_PBCC      (0xB7)
+#define HW_RATE_11M                    (0x6E)
+#define HW_RATE_11M_PBCC       (0xEE)
+#define HW_RATE_22M_PBCC       (0xDC)
+#define HW_RATE_6M                     (0x0B)
+#define HW_RATE_9M                     (0x0F)
+#define HW_RATE_12M                    (0x0A)
+#define HW_RATE_18M                    (0x0E)
+#define HW_RATE_24M                    (0x09)
+#define HW_RATE_36M                    (0x0D)
+#define HW_RATE_48M                    (0x08)
+#define HW_RATE_54M                    (0x0C)
+
+#define HW_BIT_RATE_1MBPS   0x00000001
+#define HW_BIT_RATE_2MBPS   0x00000002
+#define HW_BIT_RATE_5_5MBPS 0x00000004
+#define HW_BIT_RATE_6MBPS   0x00000008
+#define HW_BIT_RATE_9MBPS   0x00000010
+#define HW_BIT_RATE_11MBPS  0x00000020
+#define HW_BIT_RATE_12MBPS  0x00000040
+#define HW_BIT_RATE_18MBPS  0x00000080
+#define HW_BIT_RATE_22MBPS  0x00000100
+#define HW_BIT_RATE_24MBPS  0x00000200
+#define HW_BIT_RATE_36MBPS  0x00000400
+#define HW_BIT_RATE_48MBPS  0x00000800
+#define HW_BIT_RATE_54MBPS  0x00001000
+
+
+#define SHORT_PREAMBLE_BIT  BIT_0               /*CCK or Barker depending on the rate*/
+#define OFDM_MOD_TYPE       BIT_6
+#define PBCC_MOD_TYPE       BIT_7
+
+typedef enum
+{
+    MOD_PBCC = 1,
+    MOD_CCK,
+    MOD_OFDM
+}Modulation_e;
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/inc/roamingMngrTypes.h b/sta_dk_4_0_4_32/common/inc/roamingMngrTypes.h
new file mode 100644 (file)
index 0000000..42d0873
--- /dev/null
@@ -0,0 +1,102 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 roamingMngrTypes.h
+ *  \brief Internal Roaming Manager Types API
+ *
+ *  \see roamingMngr.c
+ */
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Roaming Manager                                               *
+ *   PURPOSE: Roaming Manager Module Types                                  *    *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ROAMING_MNGR_TYPES_H_
+#define _ROAMING_MNGR_TYPES_H_
+
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+/* configuration of Roaming manager */
+#define ROAMING_ENABLED                1
+#define ROAMING_DISABLED               0
+
+#pragma pack(1)
+typedef struct
+{
+       UINT16  enableDisable;                                  /* ROAMING_ENABLED, ROAMING_DISABLED - BOOL is not used, 
+                                                                                               beacuse of misdefinition between the Driver and CU */
+    UINT16     lowPassFilterRoamingAttempt;    /* Time to wait in sec, before roaming due to the low connection quality */
+       INT8    apQualityThreshold;                             /* Quality indicator (RSSI) to be used when comparing AP List matching quality */
+
+} roamingMngrConfig_t;
+#pragma pack()
+
+#pragma pack(1)
+typedef struct
+{
+    /* Roaming trigger thresholds */ 
+       /* Note - It's the applicatio's responsibility to chage the threshold when Voice is On */
+       UINT8   dataRetryThreshold;                             /* Consecutive number of TX retries */  
+    UINT8      numExpectedTbttForBSSLoss;              /* number of expected TBTTs for BSS Loss event */
+       UINT8   txRateThreshold;                                /* TX rate (fallback) threshold */
+       INT8    lowRssiThreshold;                               /* low RSSI threshold */
+       UINT8   lowSnrThreshold;                                /* low SNR threshold */
+       INT8    lowQualityForBackgroungScanCondition; /* Indicator used to increase the background scan period when quality is low. */
+       INT8    normalQualityForBackgroungScanCondition; /* Indicator used to reduce the background scan period when quality is normal. */
+       UINT8   rssiFilterWeight;                               /* last RSSI weight in the AVG calculation */
+       UINT8   snrFilterWeight;                                /* last SNR weight in the AVG calculation */
+} roamingMngrThresholdsConfig_t;
+#pragma pack()
+
+
+
+#pragma pack(1)
+typedef struct
+{
+       roamingMngrConfig_t                             roamingMngrConfig;
+       roamingMngrThresholdsConfig_t   roamingMngrThresholdsConfig;
+} roamingMngrConfigParams_t;
+#pragma pack()
+
+
+
+#endif /*  _ROAMING_MNGR_TYPES_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/inc/scanMngrTypes.h b/sta_dk_4_0_4_32/common/inc/scanMngrTypes.h
new file mode 100644 (file)
index 0000000..dd2aee7
--- /dev/null
@@ -0,0 +1,209 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 scanMngrTypes.h
+ *  \brief This file include public type definitions for the scan manager application level module,
+ *  \brief to be included both by driver and user-mode.
+ *  \author Ronen Kalish
+ *  \date 01-Mar-2005
+ */
+
+#ifndef __SCAN_MNGR_TYPES_API_H__
+#define __SCAN_MNGR_TYPES_API_H__
+
+#include "scanTypes.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/* AMximal number of channels per band policy */
+#define MAX_BAND_POLICY_CHANNLES    30
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct scan_probReqParams_t
+ * \brief This structure contains all information needed for probe request transmission.
+ */
+typedef struct
+{
+       UINT8                                           numOfProbeReqs;                     /**< number of probe requests to send */
+       UINT8                                           txPowerDbm;                            /**< TX power at which to transmit */
+       rateMask_e                                      bitrate;                            /**< Bit rate at which to transmit */
+} scan_probReqParams_t;
+
+/** \struct scan_basicMethodParams_t
+ * \brief This structure contains parameters for basic scan operation
+ */
+typedef struct
+{
+       UINT32                                          maxChannelDwellTime;                /**< Maximum time to spend on each channel */
+       UINT32                                          minChannelDwellTime;                /**< 
+                                                                     * Minimum time to spend on each channel
+                                                                     * (if no activity at all was discovered
+                                                                     */
+       scan_ETCondition_e                      earlyTerminationEvent;              /**< The cause for early termination */
+       UINT8                                           ETMaxNumberOfApFrames;              /**< 
+                                                                     * Number of frames from the above type after which
+                                                                     * scan is early terminated.
+                                                                     */
+       scan_probReqParams_t            probReqParams;                      /**< Parameters for probe request transmission */
+} scan_basicMethodParams_t;
+
+/** \struct scan_TidTriggeredMethodParams_t
+ * \brief This structure contains parameters for Tid-Triggered scan operation
+ */
+typedef struct 
+{
+       scan_basicMethodParams_t        basicMethodParams;                                      /**< Basic scan parameters */
+       UINT8                                           triggeringTid;                                          /**< 
+                                                                                                                                        * Tid triggering the basic scan, 
+                                                                                                                                        * one channel at a time.
+                                                                                                                                        */
+} scan_TidTriggeredMethodParams_t;
+
+/** \struct scan_SPSMethodParams_t
+ * \brief This structure contains parameters for SPS scan operation
+ */
+typedef struct 
+{
+       scan_ETCondition_e                      earlyTerminationEvent;                          /**< The cause for early termination */
+       UINT8                                   ETMaxNumberOfApFrames;              /**< 
+                                                                     * Number of frames from the above type after which
+                                                                     * scan is early terminated.
+                                                                     */
+       UINT32                                          scanDuration;                       /**< Time to spend on each channel (in usec) */
+} scan_SPSMethodParams_t;
+
+/** \struct scan_Method_t
+ * \brief This structure contains scan type, and accompanying parameters
+ */
+typedef struct 
+{
+       scan_Type_e                                     scanType;                           /**<
+                                                                     * scan type (normal - active or passive),
+                                                                     * Tid-Triggered (active or passive), or SPS
+                                                                     */
+       union
+       {
+               scan_basicMethodParams_t                    basicMethodParams;      /**< scan parameters for normal scan */
+        scan_TidTriggeredMethodParams_t                TidTriggerdMethodParams; /**< scan parameters for Tid-Triggered scan */
+        scan_SPSMethodParams_t                         spsMethodParams;        /**< scan parameters for SPS scan */
+       } method;
+} scan_Method_t;
+
+/** \struct scan_bandPolicy_t
+ * \brief This structure contains parameters comprising a scan policy for a single band
+ */
+typedef struct
+{
+       radioBand_e                             band;                               /**< the band (2.4 / 5 GHz) */
+       scan_Method_t               discoveryMethod;                    /**< scan method used to discover new BSS'es */
+       scan_Method_t                   trackingMethod;                     /**<
+                                                                     * scan method used to track previously 
+                                                                     * discovered AP's
+                                                                     */
+       scan_Method_t                   immediateScanMethod;                /**< scan method used for immediate scan */
+       INT8                                    rxRSSIThreshold;                    /**< quality threshold for received frames */
+       UINT8                                       numOfChannlesForDiscovery;          /**<
+                                                                     * number of channels to scan at each discovery
+                                                                     * attempt
+                                                                     */
+       UINT8                                       numOfChannles;                      /**< number of channels to use on this band */
+       UINT8                                   channelList[ MAX_BAND_POLICY_CHANNLES ];
+                                                                    /**< all possible channels */
+} scan_bandPolicy_t;
+
+/** \struct scan_Policy_t
+ * \brief This structure contains parameters comprising scan policies on all bands
+ */
+typedef struct
+{
+    UINT32                             normalScanInterval;                     /**<
+                                                                     * time interval (im msec) at which to perform
+                                                                     * continuous scan, when current BSS quality is
+                                                                     * considered "normal".
+                                                                     */
+    UINT32                             deterioratingScanInterval;              /**<
+                                                                     * time interval (in msec) at which to perform
+                                                                     * continuous scab, when current BSS quality is
+                                                                     * considered "deteriorating"
+                                                                     */
+    UINT8                                      maxTrackFailures;                       /**<
+                                                                     * the max number of track failures to keep
+                                                                     * an AP in the BSS list
+                                                                     */
+    UINT8                                      BSSListSize;                            /**< the number of APs in the BSS list */
+    UINT8                                      BSSNumberToStartDiscovery;              /**<
+                                                                     * the number of APs in the BSS list at which
+                                                                     * discovery process is initiated
+                                                                     */
+    UINT8                              numOfBands;                             /**< number of bands to scan */
+    scan_bandPolicy_t          bandScanPolicy[ RADIO_BAND_NUM_OF_BANDS ];/**< bands' policies */
+} scan_Policy_t;
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+
+#endif /* __SCAN_MNGR_TYPES_API_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/inc/scanTypes.h b/sta_dk_4_0_4_32/common/inc/scanTypes.h
new file mode 100644 (file)
index 0000000..58d50be
--- /dev/null
@@ -0,0 +1,180 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _SCAN_TYPES_H
+#define _SCAN_TYPES_H
+
+#include "osTIType.h"
+#include "ratesTypes.h"
+#include "osDot11.h"
+#include "commonTypes.h"
+
+/*****************************************************************************************
+                                             Scan Definitions
+                                                 ---------------
+This file is included by the whalCtrl_api.h , it should not be included apart. !!!!!!!
+*****************************************************************************************/
+
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+#define MAX_NUMBER_OF_CHANNELS_PER_SCAN                                        16
+#define SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND         MAX_NUMBER_OF_CHANNELS_PER_SCAN
+#define SCAN_MAX_NUM_OF_SPS_CHANNELS_PER_COMMAND            16
+#define SCAN_DEFAULT_MIN_CHANNEL_DWELL_TIME                 30000
+#define SCAN_DEFAULT_MAX_CHANNEL_DWELL_TIME                 60000
+#define SCAN_DEFAULT_EARLY_TERMINATION_EVENT                SCAN_ET_COND_DISABLE
+#define SCAN_DEFAULT_EARLY_TERMINATION_NUM_OF_FRAMES        0
+
+ /*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+
+/** \enum scan_Type_e
+ * \brief enumerates the different scan types
+ */
+typedef enum
+{
+    SCAN_TYPE_NORMAL_PASSIVE = 0,   /**< normal passive scan */
+    SCAN_TYPE_NORMAL_ACTIVE,        /**< normal active scan */
+    SCAN_TYPE_SPS,                  /**< scheduled passive scan */
+    SCAN_TYPE_TRIGGERED_PASSIVE,    /**< triggered passive scan */
+    SCAN_TYPE_TRIGGERED_ACTIVE,     /**< triggered active scan */
+    SCAN_TYPE_NO_SCAN               /**< no scan to perform */
+} scan_Type_e;
+
+/** \enum scan_ETCondition_e
+ * \brief enumerates the different early termination conditions
+ */
+typedef enum
+{
+    SCAN_ET_COND_DISABLE     = 0x00,        /**< no early termination */
+    SCAN_ET_COND_BEACON      = 0x10,        /**< early termination on beacons */
+    SCAN_ET_COND_PROBE_RESP  = 0x20,        /**< early termination on probe responses */
+    SCAN_ET_COND_ANY_FRAME   = 0x30,        /**< early termination on beacons and probe responses */
+    SCAN_ET_COND_NUM_OF_CONDS= 0x4          /**< number of early termination conditions */ 
+} scan_ETCondition_e;
+
+/***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct scan_normalChannelEntry_t
+ * \brief This structure contains single channel parameters for normal scan operation (inc. triggered)
+ */
+typedef struct
+{
+    macAddress_t        bssId;                      /**< BSS Id to filter with */
+    UINT32              maxChannelDwellTime;        /**< 
+                                                     * maximum time to dwell on the channel, in microseconds 
+                                                     * (if something was received)
+                                                     */
+    UINT32              minChannelDwellTime;        /**< 
+                                                     * minimum time to dwell on the channel, in microseconds
+                                                     * (if nothing was received)
+                                                     */
+    scan_ETCondition_e  earlyTerminationEvent;      /**< the event triggering early termination */
+    UINT8               ETMaxNumOfAPframes;         /**< 
+                                                     * the number of frames to receive 
+                                                     * to activate  early termination
+                                                     */
+    
+    UINT8               txPowerDbm     ;               /**< 
+                                                      * the tx power to use for probe requests (for active scan)
+                                                      */
+    UINT8               channel;                    /**< the channel to scan */
+} scan_normalChannelEntry_t;
+
+/** \struct scan_SPSChannelEntry_t
+ * \brief This structure contains single channel parameters for an SPS scan operation
+ */
+typedef struct
+{
+    macAddress_t         bssId;                      /**< BSS Id to filter with */
+    UINT32               scanDuration;               /**< time to dwell on the channel in microseconds */
+    UINT32               scanStartTime;              /**< exact time to start scan in 4 lower bytes of the TSF */
+    scan_ETCondition_e   earlyTerminationEvent;      /**< the event triggering early termination */
+    UINT8                ETMaxNumOfAPframes;         /**< 
+                                                      * the number of frames to receive 
+                                                      * to activate  early termination
+                                                      */
+    UINT8                channel;                    /**< the channel to scan */
+} scan_SPSChannelEntry_t;
+
+/** \union scan_channelEntry_u
+ * \brief This union holds single channel parameters either for normal scan or for SPS scan
+ */
+typedef union
+{
+    scan_normalChannelEntry_t   normalChannelEntry;     /**< normal scan parameters */
+    scan_SPSChannelEntry_t      SPSChannelEntry;        /**< SPS scan parameters */
+} scan_channelEntry_u;
+
+/** \struct scan_Params_t
+ * \brief This structure contains parameters for a scan operation
+ */
+typedef struct
+{
+    ssid_t              desiredSsid;            /**< the SSID to search (optional) */
+    scan_Type_e         scanType;               /**< 
+                                                 * scan type (normal - active or passive, 
+                                                 * SPS, triggered - active or passive)
+                                                 */
+    radioBand_e         band;                   /**< band to scan (A / BG) */
+    UINT8               probeReqNumber;         /**< number of probe requests to send (for active scan) */
+    rateMask_e          probeRequestRate;       /**< the rate at which to send the probe requests */
+    UINT8               Tid;                    /**< the Tid triggering the scan (for triggered scan) */
+    UINT64              latestTSFValue;         /**< 
+                                                 * for SPS scan - the latest TSF at which a frame was 
+                                                 * received. Used to detect TSF error (AP recovery).
+                                                 */
+    UINT32              SPSScanDuration;        /**<
+                                                 * for SPS scan ONLY - the time duration of the scan (in
+                                                 * milliseconds), used to set timer according to.
+                                                 */
+    UINT8               numOfChannels;          /**< number of channels */
+
+       scan_channelEntry_u     channelEntry[ MAX_NUMBER_OF_CHANNELS_PER_SCAN ];      /**< channels array */
+} scan_Params_t;
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/inc/softGeminiTypes.h b/sta_dk_4_0_4_32/common/inc/softGeminiTypes.h
new file mode 100644 (file)
index 0000000..cc267d7
--- /dev/null
@@ -0,0 +1,55 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             SOFT_GEMINI_TYPES.H                                 */
+/*                                                                          */
+/* Purpose:            This module contains All the system definisions.    */
+/*                                                                          */
+/*--------------------------------------------------------------------------*/
+#ifndef __SOFT_GEMINI_TYPES_H__
+#define __SOFT_GEMINI_TYPES_H__
+
+
+#pragma pack(1)
+typedef struct
+{
+       BOOL    state;
+       UINT8   minTxRate;
+} btCoexStatus_t;
+#pragma pack()
+
+
+#endif /* __SOFT_GEMINI_TYPES_H__  */
diff --git a/sta_dk_4_0_4_32/common/inc/srcApi.h b/sta_dk_4_0_4_32/common/inc/srcApi.h
new file mode 100644 (file)
index 0000000..b16a2e9
--- /dev/null
@@ -0,0 +1,149 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**************************************************************************/
+/*                                                                        */
+/* MODULE:  srcApi.h                                                     */
+/* PURPOSE: Header file of config Manager module                         */
+/*                                                                        */
+/**************************************************************************/
+
+#ifndef __SRC_API_H__
+#define __SRC_API_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "memMngrEx.h"
+
+#define DRIVER_SHUTDOWN_SME_STOPPED       0x1
+#define DRIVER_SHUTDOWN_COMPLETE          (DRIVER_SHUTDOWN_SME_STOPPED)
+
+TI_HANDLE configMgr_create(TI_HANDLE        hOs,void *pWLAN_Images,
+                           initTable_t      *pInitTable,
+                           macAddress_t     *pMac);
+
+TI_HANDLE configMgr_init  (TI_HANDLE        hOs,TI_HANDLE  hConfigManager,void *pWLAN_Images,
+                           initTable_t      *pInitTable,
+                           macAddress_t     *pMac);
+
+
+/* Unload for windows */
+TI_STATUS configMgr_unLoad(TI_HANDLE hConfigMgr);
+
+/* Start unload process (stop SME) */
+TI_STATUS configMgr_InitiateUnload(TI_HANDLE hConfigMgr);
+
+/* Unload all modules (free memory etc) */
+TI_STATUS configMgr_UnloadModules (TI_HANDLE hConfigMgr);
+
+/* Return internal shutdown status */
+UINT8 configMgr_DriverShutdownStatus(TI_HANDLE hConfigMgr);
+
+TI_STATUS configMgr_start(TI_HANDLE hConfigMgr);
+
+TI_STATUS configMgr_stop(TI_HANDLE hConfigMgr);
+
+TI_STATUS configMgr_setParam(TI_HANDLE         hConfigMgr, 
+                                                 paramInfo_t   *pParam);
+
+TI_STATUS configMgr_getParam(TI_HANDLE         hConfigMgr, 
+                                                 paramInfo_t   *pParam);
+
+TI_STATUS configMgr_sendMsdu(TI_HANDLE         hConfigMgr, 
+                                               mem_MSDU_T      *pMsdu,
+                                               UINT8 packet_DTag);
+
+TI_STATUS configMgr_PollApPackets(TI_HANDLE            hConfigMgr);
+
+
+TI_STATUS configMgr_checkTxQueueSize(TI_HANDLE hConfigMgr,UINT8 qIndex);
+
+/* Event Handler wrapper */
+UINT32 configMgr_RegisterEvent(TI_HANDLE               hConfigMgr, PUCHAR pData, ULONG Length);
+
+UINT32 configMgr_UnRegisterEvent(TI_HANDLE             hConfigMgr, TI_HANDLE uEventID);
+
+UINT32 configMgr_MaskEvent(TI_HANDLE           hConfigMgr, UINT32 uEventID);
+
+UINT32 configMgr_UnMaskEvent(TI_HANDLE         hConfigMgr, UINT32 uEventID);
+
+/* Initiated from User Space to fetch event data*/
+UINT32 configMgr_GetEventData                  (TI_HANDLE              hConfigMgr, PUCHAR pData,   ULONG* pLength);
+
+/* Memory manager wrapper */
+TI_STATUS configMgr_allocBDs(TI_HANDLE hConfigMgr, 
+                                                 UINT32 bdNumber, 
+                                                 mem_BD_T** bdPtr);
+
+TI_STATUS configMgr_allocMSDU(TI_HANDLE hConfigMgr, 
+                                                 mem_MSDU_T** MSDUPtr, 
+                                                 UINT32 len, 
+                                                 allocatingModule_e module);
+
+TI_STATUS configMgr_allocMSDUBufferOnly(TI_HANDLE hConfigMgr, 
+                                                                       mem_MSDU_T** MSDUPtr, 
+                                                                       allocatingModule_e module);
+
+TI_STATUS configMgr_memMngrFreeMSDU(TI_HANDLE hConfigMgr, 
+                                                                UINT32 handle);
+
+/* HAL wrapper */
+TI_STATUS configMgr_HandleBusTxn_Complete(TI_HANDLE hConfigMgr);
+
+TI_STATUS configMgr_handleInterrupts(TI_HANDLE hConfigMgr);
+
+TI_STATUS configMgr_enableInterrupts(TI_HANDLE hConfigMgr);
+
+TI_STATUS configMgr_disableInterrupts(TI_HANDLE hConfigMgr);
+
+UINT32  configMgr_checkInterrupts(TI_HANDLE hConfigMgr);
+
+BOOL configMgr_isCardExist(TI_HANDLE hConfigMgr);
+
+BOOL configMgr_areInputsFromOsDisabled(TI_HANDLE hConfigMgr);
+
+UINT32 configMgr_ReadMacRegister(TI_HANDLE hConfigMgr, UINT32  addr);
+void  configMgr_WriteMacRegister(TI_HANDLE hConfigMgr, UINT32  addr, UINT32    val);
+UINT32 configMgr_ReadPhyRegister(TI_HANDLE hConfigMgr, UINT32  addr);
+void configMgr_WritePhyRegister(TI_HANDLE hConfigMgr, UINT32   addr, UINT32    val);
+
+UINT32 configMgr_getPacketHeaderLength(TI_HANDLE hConfigMgr, void *pData, UINT32 txFlags);
+
+void configMgr_SlaveAckMaskNotification(TI_HANDLE hConfigMgr);
+
+void configMgr_GetInitParams (TI_HANDLE hConfigMgr, UINT8* ioBuffer, UINT16 *outBufLen);
+
+#endif /* __SRC_API_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/inc/systemGeneralParam.h b/sta_dk_4_0_4_32/common/inc/systemGeneralParam.h
new file mode 100644 (file)
index 0000000..0d67435
--- /dev/null
@@ -0,0 +1,48 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             SYSTEM_GENERAL_PARAM.H                              */
+/*                                                                          */
+/* Purpose:            This module contains All the system definisions.    */
+/*                                                                          */
+/*--------------------------------------------------------------------------*/
+#ifndef __SYSTEM_GENERAL_PARAM_H__
+#define __SYSTEM_GENERAL_PARAM_H__
+
+
+
+
+#endif /* __SYSTEM_GENERAL_PARAM_H__  */
diff --git a/sta_dk_4_0_4_32/common/inc/tiQosTypes.h b/sta_dk_4_0_4_32/common/inc/tiQosTypes.h
new file mode 100644 (file)
index 0000000..c22ce99
--- /dev/null
@@ -0,0 +1,272 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             tiQosTypes.h*/
+/**/
+/* Purpose:            */
+/**/
+/*--------------------------------------------------------------------------*/
+
+#if !defined TI_QOS_TYPES_H
+#define TI_QOS_TYPES_H
+
+
+#define TI_WLAN_QOS_RETURN_CODES \
+       NOT_CONNECTED,\
+       TRAFIC_ADM_PENDING,\
+       NO_QOS_AP,\
+       ADM_CTRL_DISABLE,\
+       AC_ALREADY_IN_USE,\
+    USER_PRIORITY_NOT_ADMITTED\
+/*
+       NOT_CONNECTED       - Not connected to AP 
+       TRAFIC_ADM_PENDING  - TSPEC request sent - awaiting response
+       NO_QOS_AP           - primary AP does not support QOS (WME)
+       ADM_CTRL_DISABLE    - Admission control disabled
+       AC_ALREADY_IN_USE   - A TSPEC has already been sent on this specific AC
+    USER_PRIORITY_NOT_ADMITTED - User priority is not admitted (TSPEC not sent)
+*/
+
+
+typedef enum{
+    QOS_AC_BE = 0,
+    QOS_AC_BK,
+    QOS_AC_VI,
+    QOS_AC_VO,
+    QOS_HIGHEST_AC_INDEX = QOS_AC_VO,
+
+}acTrfcType_e; /* for TI_HANDLE hAcTrfcCtrl */
+
+#define MAX_NUM_OF_AC                                  ( QOS_HIGHEST_AC_INDEX+1 )
+#define FIRST_AC_INDEX                                 QOS_AC_BE
+#define MAX_NUM_OF_802_1d_TAGS          8
+
+#define AC_PARAMS_MAX_TSID              15
+#define MAX_APSD_CONF                   0xffff
+
+
+/*
+ * this enum defines FW PS policing modes
+ */
+typedef struct _OS_802_11_QOS_PARAMS
+{
+    tiUINT32 acID;
+    tiUINT32 MaxLifeTime;
+    tiUINT32 VoiceDeliveryProtocol;
+    tiUINT32 PSDeliveryProtocol;
+} OS_802_11_QOS_PARAMS;
+
+typedef struct  {
+       tiUINT32 psPoll;
+       tiUINT32 UPSD;
+} OS_802_11_QOS_RX_TIMEOUT_PARAMS;
+
+typedef struct _OS_802_11_AC_QOS_PARAMS
+{
+       tiUINT32 uAC;
+       tiUINT32 uAssocAdmissionCtrlFlag;
+               tiUINT32 uAIFS;
+               tiUINT32 uCwMin;
+               tiUINT32 uCwMax;
+               tiUINT32 uTXOPLimit;
+} OS_802_11_AC_QOS_PARAMS;
+
+typedef struct _OS_802_11_AP_QOS_CAPABILITIES_PARAMS
+{
+       tiUINT32 uQOSFlag;
+       tiUINT32 uAPSDFlag;
+} OS_802_11_AP_QOS_CAPABILITIES_PARAMS;
+
+typedef struct _OS_802_11_QOS_TSPEC_PARAMS
+{
+    tiUINT32 uUserPriority;
+    tiUINT32 uNominalMSDUsize; /* in bytes */
+       tiUINT32 uMeanDataRate;         /* bits per second */
+       tiUINT32 uMinimumPHYRate;       /* 1,2,5,6,9,11,12,18,......*/
+       tiUINT32 uSurplusBandwidthAllowance;
+    tiUINT32 uAPSDFlag;
+       tiUINT32 uMediumTime;
+    tiUINT32 uReasonCode;
+} OS_802_11_QOS_TSPEC_PARAMS;
+
+typedef struct _OS_802_11_QOS_DELETE_TSPEC_PARAMS
+{
+    tiUINT32 uUserPriority;
+       tiUINT32 uReasonCode;
+} OS_802_11_QOS_DELETE_TSPEC_PARAMS;
+
+typedef struct _OS_802_11_QOS_DESIRED_PS_MODE
+{
+    tiUINT32 uDesiredPsMode;
+       tiUINT32 uDesiredWmeAcPsMode[MAX_NUM_OF_AC];
+} OS_802_11_QOS_DESIRED_PS_MODE;
+
+
+
+/* When this value is added to reason code in TSPEC events, it indicates a TSPEC response which was unexpected at the time */
+/* For example, a TSPEC response arrives after a TSPEC timeout */
+#define TSPEC_RESPONSE_UNEXPECTED      0x1000   
+
+typedef enum{
+       ADDTS_RESPONSE_ACCEPT = 0,
+/*     ADDTS_RESPONSE_REJECT,  - according to the standard*/
+       ADDTS_RESPONSE_AP_PARAM_INVALID = 253,
+       ADDTS_RESPONSE_TIMEOUT = 254,
+       TSPEC_DELETED_BY_AP = 255,
+} tspec_status_e;
+
+typedef struct _OS_802_11_AC_UPSD_STATUS_PARAMS
+{
+   tiUINT32 uAC;
+   tiUINT32 uCurrentUAPSDStatus;
+   tiUINT32 pCurrentAdmissionStatus;
+} OS_802_11_AC_UPSD_STATUS_PARAMS;
+
+typedef struct _OS_802_11_THRESHOLD_CROSS_PARAMS
+{
+    tiUINT32 uAC;
+    tiUINT32 uHighThreshold;
+       tiUINT32 uLowThreshold;
+} OS_802_11_THRESHOLD_CROSS_PARAMS;
+
+typedef struct OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS
+{
+    tiUINT32 uAC;
+       tiUINT32 uHighOrLowThresholdFlag;  /* According to thresholdCross_e enum */
+    tiUINT32 uAboveOrBelowFlag;        /* According to thresholdCrossDirection_e enum */
+} OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS;
+
+typedef enum{
+       HIGH_THRESHOLD_CROSS,
+       LOW_THRESHOLD_CROSS,
+} thresholdCross_e;
+
+typedef enum{
+       CROSS_ABOVE,
+       CROSS_BELOW,
+} thresholdCrossDirection_e;
+
+typedef struct _STREAM_TRAFFIC_PROPERTIES{
+   UINT32 dstIpAddress;
+   UINT32 dstPort;
+   UINT32 PktTag;
+   UINT32 userPriority;
+} STREAM_TRAFFIC_PROPERTIES;
+
+
+typedef enum{
+       AC_NOT_ADMITTED,
+       AC_WAIT_ADMISSION,
+       AC_ADMITTED
+} trafficAdmState_e;
+
+typedef enum{
+   UPLINK_DIRECTION = 0,
+   DOWNLINK_DIRECTION = 1,
+   RESERVED_DIRECTION = 2,
+   BI_DIRECTIONAL = 3,
+} streamDirection_e;
+
+
+/* classification algorithms: 
+  0) D-tag to D-tag
+  1) DSCP to D-tag
+  2) Destination port number to D-tag 
+  3) Destination IP&Port to D-tag
+*/
+typedef enum{
+       D_TAG_CLSFR = 0,
+       DSCP_CLSFR =1,
+       PORT_CLSFR =2,
+       IPPORT_CLSFR =3,
+       CLSFR_TYPE_MAX = IPPORT_CLSFR,
+} clsfr_type_e;
+
+typedef struct clsfrTypeAndSupport
+{
+   ULONG        ClsfrType;
+   UINT8        oldVersionSupport;
+} clsfrTypeAndSupport;
+
+
+/*************************/
+/*   classifier params   */
+/*************************/
+
+/* This type represents a pair of 
+destination IP address and destination port number. */
+typedef struct 
+{
+       UINT32  DstIPAddress;
+       UINT16  DstPortNum;
+} IP_Port_t;
+
+/* Classification mapping 
+   table.
+*/
+typedef struct 
+{
+       union   
+       {
+               IP_Port_t       DstIPPort; /* for destination IP&Port classifier*/
+               UINT16          DstPortNum; /* for destination Port classifier*/
+               UINT8           CodePoint; /* for DSCP classifier*/
+       }Dscp;
+       UINT8           DTag; 
+} clsfr_tableEntry_t;
+
+/* Classifier parameters */
+
+/* number of classifier entries in the classification table */
+#define NUM_OF_CLSFR_TABLE_ENTRIES     16
+
+typedef struct
+{
+       clsfr_type_e            clsfrType; /* The type of the classifier: D-tag, DSCP, Port or IP&Port */
+       UINT8                           NumOfActiveEntries; /* The number of active entries in the classification table */
+       clsfr_tableEntry_t      
+       ClsfrTable[NUM_OF_CLSFR_TABLE_ENTRIES]; /* Classification table - size changed from 15 to 16*/
+} clsfr_Params_t;
+
+/* This type is use by setParam to insert classifier table entries */
+typedef struct
+{
+       UINT8   EntriesNum;
+       UINT32  *BufferPtr; 
+} clsfr_insertEntry_t;
+
+#endif /* TI_QOS_TYPES_H */
+
diff --git a/sta_dk_4_0_4_32/common/inc/tiioctl.h b/sta_dk_4_0_4_32/common/inc/tiioctl.h
new file mode 100644 (file)
index 0000000..14eb0ef
--- /dev/null
@@ -0,0 +1,1331 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __TIIOCTL_H__
+#define __TIIOCTL_H__
+
+/* OID Mode*/
+#define IOCTRL_SET    0
+#define IOCTRL_GET    1
+#define IOCTRL_SET_GET 2
+
+#ifndef FILE_DEVICE_UNKNOWN
+
+/**/
+/* Macro definition for defining IOCTL and FSCTL function control codes.  Note*/
+/* that function codes 0-2047 are reserved for Microsoft Corporation, and*/
+/* 2048-4095 are reserved for customers.*/
+/**/
+
+#define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
+    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
+)
+
+#define FILE_DEVICE_UNKNOWN     0x00000022
+#define METHOD_BUFFERED         0
+#define FILE_ANY_ACCESS         0
+
+#endif     /* FILE_DEVICE_UNKNOWN */
+
+/* IOCTL info, needs to be visible for application. Should be in a custom range (0x800..)*/
+#define SHELLDRV_IOCTL_INDEX  0x00800
+
+/* Offsets for IOTCLS bases*/
+#define D11BASIC_IOCTLS_OFFSET          0x0
+#define D11PACKET_PARAMS_IOCTLS_OFFSET  0x100
+#define RATES_IOCTLS_OFFSET             0x200
+#define CHANNEL_IOCTLS_OFFSET           0x300
+#define POWER_IOCTLS_OFFSET             0x400
+#define SECURITY_IOCTLS_OFFSET          0x500
+#define MISC_IOCTLS_OFFSET              0x600
+#define DEBUG_IOCTLS_OFFSET             0x700
+#define SCAN_IOCTLS_OFFSET              0x800
+#define VOICE_QOS_IOCTLS_OFFSET         0x900
+#define ROAMING_IOCTLS_OFFSET           0xa00
+#define MEASUREMENT_IOCTLS_OFFSET       0xa80
+#define PLT_IOCTLS_OFFSET               0xb00
+
+#ifdef _WINDOWS // Windows Mobile specific IOCTL's
+#endif /* ifdef _WINDOWS */
+/********************************************/
+
+typedef struct tagDeviceInfo
+{
+char csKeyName[260];
+char csDriverKey[260];
+char csDescription[260];
+} TIWLNDEVINFO, *PTIWLNDEVINFO;
+
+
+/**********************  Basic dot11 Functionality ****************************************/
+
+#define TIWLN_802_11_BSSID_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_BSSID_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)                            
+
+#define TIWLN_802_11_BSSID_LIST CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SSID_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SSID_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DESIRED_SSID_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DISASSOCIATE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 7, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_ASSOCIATION_INFORMATION CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 8, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_NETWORK_TYPES_SUPPORTED CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 9, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_NETWORK_TYPE_IN_USE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 10, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_NETWORK_TYPE_IN_USE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_INFRASTRUCTURE_MODE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_INFRASTRUCTURE_MODE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DESIRED_INFRASTRUCTURE_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_AUTHENTICATION_MODE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_AUTHENTICATION_MODE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 16, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_CONFIGURATION_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 17, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_CONFIGURATION_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 18, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_FULL_BSSID_LIST  CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11BASIC_IOCTLS_OFFSET + 19, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+/**********************  Rates Functionality  ****************************************/
+
+#define TIWLN_802_11_SUPPORTED_RATES CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + RATES_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DESIRED_RATES_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + RATES_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SUPPORTED_RATES_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + RATES_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_CURRENT_RATES_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + RATES_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_EXT_RATES_IE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + RATES_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_EXT_RATES_IE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + RATES_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+/**********************  Channel Functionality  ****************************************/
+
+#define TIWLN_802_11_DESIRED_CHANNEL_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DESIRED_CHANNEL_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_CHANNEL_GET   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_CURRENT_REGDOMAIN_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_CURRENT_REGDOMAIN_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REGDOMAIN_TABLE   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_ROAM_PROFILE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 7, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_ROAM_PROFILE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 8, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11D CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 9, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11H CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 10, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_GET_802_11D CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_GET_802_11H CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_GET_COUNTRY_2_4 CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_SET_COUNTRY_2_4 CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_GET_COUNTRY_5 CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_SET_COUNTRY_5 CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 16, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_SET_DFS_RANGE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 17, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REG_DOMAIN_GET_DFS_RANGE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + CHANNEL_IOCTLS_OFFSET + 18, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+/**********************  Power Functionality  ****************************************/
+
+#define TIWLN_802_11_POWER_MODE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_MODE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_TX_POWER_LEVEL_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_TX_POWER_DBM_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_NUMBER_OF_ANTENNAS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RX_ANTENNA_SELECTED_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RX_ANTENNA_SELECTED_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 7, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_TX_ANTENNA_SELECTED_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 8, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_TX_ANTENNA_SELECTED_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 9, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLAN_802_11_ANTENNA_DIVERSITY_PARAM_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 10, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RSSI CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RSSI_TRIGGER_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RSSI_TRIGGER_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SLEEP_CMD CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_TX_POWER_DBM_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_MGR_PROFILE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 16, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_LEVEL_BOUNDARY CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 17, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+
+#define TIWLN_802_11_PERODIC_WAKEUP_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 18, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_PERODIC_WAKEUP_TIMEOUT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 19, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_LEVEL_DEFAULT_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 20, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_LEVEL_DEFAULT_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 21, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_LEVEL_PS_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 22, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_LEVEL_PS_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 23, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 24, \
+                                            METHOD_BUFFERED,          \
+                                            FILE_ANY_ACCESS)
+
+
+
+#define TIWLN_802_11_SNR CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 25, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                            SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 26, \
+                                            METHOD_BUFFERED,          \
+                                            FILE_ANY_ACCESS) 
+
+#define TIWLN_802_11_POWER_LEVEL_DOZE_MODE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 27, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POWER_LEVEL_DOZE_MODE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                                       SHELLDRV_IOCTL_INDEX + POWER_IOCTLS_OFFSET + 28, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+
+/**********************  dot11 Network Packet Parameters ****************************************/
+
+#define TIWLN_802_11_FRAGMENTATION_THRESHOLD_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_FRAGMENTATION_THRESHOLD_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RTS_THRESHOLD_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RTS_THRESHOLD_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SHORT_PREAMBLE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SHORT_PREAMBLE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SHORT_RETRY_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 7, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SHORT_RETRY_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 8, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_LONG_RETRY_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 9, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_LONG_RETRY_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SHORT_SLOT_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SHORT_SLOT_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_IBSS_PROTECTION_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_IBSS_PROTECTION_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + D11PACKET_PARAMS_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+/************************** Security **************************************/
+
+#define TIWLN_802_11_ADD_WEP CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_REMOVE_WEP CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_WEP_STATUS_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_WEP_STATUS_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_PRIVACY_FILTER_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_PRIVACY_FILTER_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+#define TIWLN_802_11_ADD_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_REMOVE_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_OPEN_EAPOL_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_CLOSE_EAPOL_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 16, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SEND_EAPOL_PACKET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 17, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_MIXED_MODE_SET CTL_CODE(FILE_DEVICE_UNKNOWN,   \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 18, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_MIXED_MODE_GET  CTL_CODE(FILE_DEVICE_UNKNOWN,  \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 19, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_SECURITY_TYPE_SET  CTL_CODE(FILE_DEVICE_UNKNOWN,   \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 20, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_SECURITY_TYPE_GET  CTL_CODE(FILE_DEVICE_UNKNOWN,   \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 21, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+/* Supplicant use only*/
+#define TIWLN_SUPPL_INIT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 22, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_SUPPL_TERMINATE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 23, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_PSK_SET         CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 24, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_EAP_TYPE_SET      CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 25, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_USER_ID_SET        CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 26, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_USER_PASSWORD_SET        CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 27, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_CERT_PARAMS_SHA1_SET    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 28, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_ROGUE_AP_DETECTED    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 29, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_REPORT_ROGUE_APS    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 30, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_CCKM_REQUEST    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 31, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_CCKM_RESULT    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 32, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_PMKID_GET    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 33, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_KEY_TYPE_SET    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 34, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_CONFIGURATION_SET   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 35, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_CONFIGURATION_GET   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 36, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_NETWORK_EAP_SET   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 37, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_NETWORK_EAP_GET   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 38, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+/* Supplicant use only*/
+#define TIWLN_802_11_CERT_PARAMS_FILE_NAME_SET   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 39, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EXC_AUTH_SUCCESS        CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 40, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_PMKID_SET    CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 41, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_WPA_OPTIONS_GET            CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 42, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)  
+                                           
+#define TIWLN_802_11_WPA_OPTIONS_SET            CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 43, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)                 
+
+#define TIWLN_802_11_CAPABILITY_GET            CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 44, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS) 
+                                            
+#define TIWLN_802_11_AVAILABLE_OPTIONS_GET            CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 45, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS) 
+
+
+#define TIWLN_802_11_EAP_TYPE_GET      CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 46, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_EAP_TYPE_DRIVER_SET      CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SECURITY_IOCTLS_OFFSET + 47, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+/************************** Misc **************************************/
+
+#define TIWLN_IOCTL_OID_QUERY_INFORMATION CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 1, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_IOCTL_OID_SET_INFORMATION CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_MEDIUMUSAGE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_STATISTICS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_RELOAD_DEFAULTS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_DRIVER_STATUS_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_DRIVER_STATUS_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 7, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_HW_READ_REGISTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 8, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_HW_WRITE_REGISTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 9, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_HW_RESET_HW CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 10, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_ENABLE_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DISABLE_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SET_INIT_INFO CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_3_CURRENT_ADDRESS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_APIP_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_4XACTIVESTATE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 16, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_SW_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 17, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_EVENT_DATA CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 18, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_DRIVER_SUSPEND CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 19, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define SET_IPC_EVENT_HANDLE CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 20, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define DESTROY_IPC_EVENT_HANDLE CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 21, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_CONFIG_EVENTS_RSSI     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 22, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_DRIVERS_CAPABILITIES     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 23, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_SELECTED_BSSID_INFO     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 24, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_DRIVER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 25, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+        
+#define BT_COEXSISTANCE_SET_ENABLE CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 26, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define BT_COEXSISTANCE_SET_RATE   CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 27, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define BT_COEXSISTANCE_SET_CONFIG CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 28, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define BT_COEXSISTANCE_GET_STATUS CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 29, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+#define TIWLN_802_11_TX_STATISTICS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 30, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define GWSI_DISPATCH_COMMAND CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 31, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define GWSI_GET_INIT_TABLE_COMMAND CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 32, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define GWSI_INITIALIZE_COMMAND CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 33, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define GWSI_CONFIGURE_TABLE_COMMAND CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 34, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define GWSI_RELEASE_COMMAND CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 36, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define GWSI_DISPATCH_GET_CMD_LEN(_p_cmd)   (*((tiUINT16 *)_p_cmd + 1))
+
+#define TIWLN_802_11_SET_TRAFFIC_INTENSITY_THRESHOLDS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 37, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_TRAFFIC_INTENSITY_THRESHOLDS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 38, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 39, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_PRIMARY_BSSID_INFO CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 40, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_EARLY_WAKEUP_IE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 41, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_EARLY_WAKEUP_IE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 42, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 43, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_ADD_RX_DATA_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 44, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REMOVE_RX_DATA_FILTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 45, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_RX_DATA_FILTERS_STATISTICS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 46, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_POWER_CONSUMPTION_STATISTICS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MISC_IOCTLS_OFFSET + 47, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+/************************** Debug **************************************/
+                    
+#ifdef TI_DBG
+
+
+#define TIWLN_GET_DBG_BUFFER CTL_CODE(FILE_DEVICE_UNKNOWN,   \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 2, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SET_MODULE CTL_CODE(FILE_DEVICE_UNKNOWN,  \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 3, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_MODULE CTL_CODE(FILE_DEVICE_UNKNOWN,  \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 4, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SET_DEBUG_FLAG CTL_CODE(FILE_DEVICE_UNKNOWN,  \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 5, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_DEBUG_FLAG CTL_CODE(FILE_DEVICE_UNKNOWN,  \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 6, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_DISPLAY_STATS CTL_CODE(FILE_DEVICE_UNKNOWN,   \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 7, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_SET_SEVERITY CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 8, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_GET_SEVERITY CTL_CODE(FILE_DEVICE_UNKNOWN,    \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 9, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REPORT_MODULE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 10, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REPORT_MODULE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REPORT_SEVERITY_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REPORT_SEVERITY_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+#define TIWLN_DRIVER_DEBUG_PRINT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_REPORT_PPMODE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_OS_DBG_STATE_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 16, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_OS_DBG_STATE_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 17, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#ifdef DRIVER_PROFILING
+
+#define TIWLAN_PROFILING_REPORT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 18, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLAN_PROFILING_CPU_ESTIMATOR_CMD CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + DEBUG_IOCTLS_OFFSET + 19, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_START    0x01
+#define TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_STOP     0x02
+#define TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_RESET    0x03
+
+#endif /* DRIVER_PROFILING */
+
+#endif  /* TI_DBG*/
+
+
+/************************************** Scan ********************************************/
+
+#define TIWLN_802_11_START_APP_SCAN_SET     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SCAN_IOCTLS_OFFSET + 1,\
+                            METHOD_BUFFERED,                              \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_STOP_APP_SCAN_SET     CTL_CODE(FILE_DEVICE_UNKNOWN,  \
+                            SHELLDRV_IOCTL_INDEX + SCAN_IOCTLS_OFFSET + 2,\
+                            METHOD_BUFFERED,                              \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SCAN_POLICY_PARAM_SET  CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SCAN_IOCTLS_OFFSET + 3,\
+                            METHOD_BUFFERED,                              \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SCAN_BSS_LIST_GET      CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + SCAN_IOCTLS_OFFSET + 4,\
+                            METHOD_BUFFERED,                              \
+                            FILE_ANY_ACCESS)
+
+/*************************************** Voice & QOS ********************************************/
+
+#define TIWLN_802_11_SET_QOS_PARAMS     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 2, \
+                                        METHOD_BUFFERED,          \
+                                        FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POLL_AP_PACKETS   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 3, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_CONFIG_TX_CLASS   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 4, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_REMOVE_CLSFR_ENTRY   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 5, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_CLSFR_TYPE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 6, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_AP_QOS_PARAMS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 7, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_AP_QOS_CAPABILITIES CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 8, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_ADD_TSPEC CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 9, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_TSPEC_PARAMS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 10, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_DELETE_TSPEC CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 11, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_CURRENT_AC_STATUS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 12, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SET_MEDIUM_USAGE_THRESHOLD CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 13, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SET_PHY_RATE_THRESHOLD CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 14, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_MEDIUM_USAGE_THRESHOLD CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 15, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_PHY_RATE_THRESHOLD CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 16, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+
+#define TIWLN_802_11_GET_USER_PRIORITY_OF_STREAM CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 17, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_POLL_AP_PACKETS_FROM_AC   CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 18, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_GET_DESIRED_PS_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 19, \
+                            METHOD_BUFFERED,          \
+                            FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_SET_RX_TIMEOUT     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 20, \
+                                        METHOD_BUFFERED,          \
+                                        FILE_ANY_ACCESS)
+                                        
+#define TIWLN_802_11_SET_DTAG_TO_AC_MAPPING_TABLE     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 21, \
+                                        METHOD_BUFFERED,          \
+                                        FILE_ANY_ACCESS)
+                                        
+#define TIWLN_802_11_SET_VAD     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 22, \
+                                        METHOD_BUFFERED,          \
+                                        FILE_ANY_ACCESS) 
+#define TIWLN_802_11_GET_VAD     CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + VOICE_QOS_IOCTLS_OFFSET + 23, \
+                                        METHOD_BUFFERED,          \
+                                        FILE_ANY_ACCESS)                                                                                
+                                                                               
+/*****************************************************************************************************/
+/***  Roaming Manager Configuration Parameters  ***/
+
+#define TIWLN_802_11_ROAMING_CONFIG_PARAMS_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + ROAMING_IOCTLS_OFFSET + 1, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_802_11_ROAMING_CONFIG_PARAMS_GET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + ROAMING_IOCTLS_OFFSET + 2, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+
+/*****************************************************************************************************/
+/***  measurement Manager Configuration Parameters  ***/
+
+#define TIWLN_802_11_MEASUREMENT_ENABLE_DISABLE_PARAMS_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MEASUREMENT_IOCTLS_OFFSET + 1, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+
+#define TIWLN_802_11_MEASUREMENT_MAX_DURATION_PARAMS_SET CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + MEASUREMENT_IOCTLS_OFFSET + 2, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+
+
+
+
+/*************************************** PLT ********************************************/
+
+#define TIWLN_PLT_WRITE_REGISTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 1, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_READ_REGISTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 2, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_PER_START CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 3, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_PER_STOP CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 4, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_PER_CLEAR CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 5, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_PER_GET_RESULTS CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 6, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_TX_CW CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 7, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_TX_CONTINUES CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 8, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_TX_STOP CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 9, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_MIB_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 10, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_MIB_READ CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 11, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_TX_CAL CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 12, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_CAL CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 13, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#define TIWLN_PLT_RX_CAL_RESULT CTL_CODE(FILE_DEVICE_UNKNOWN, \
+                            SHELLDRV_IOCTL_INDEX + PLT_IOCTLS_OFFSET + 14, \
+                                       METHOD_BUFFERED,          \
+                                       FILE_ANY_ACCESS)
+
+#ifdef _WINDOWS
+#endif /* ifdef _WINDOWS */
+
+#endif
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/inc/tiwlnif.h b/sta_dk_4_0_4_32/common/inc/tiwlnif.h
new file mode 100644 (file)
index 0000000..ebad92a
--- /dev/null
@@ -0,0 +1,421 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __TIWLNIF_H__
+#define __TIWLNIF_H__
+
+#include "osDot11.h"
+#ifndef TIWLNAPI_EXPORTS
+#include "osTIType.h"
+#endif
+
+#define REGDOMAIN_TABLE_SIZE 16
+
+#define MAX_NUM_OF_TX_QUEUES  4
+
+
+typedef enum _tiwlnOSVersion
+{
+    tiwlnIsWin95   = 1,
+    tiwlnIsWin98   = 2,
+    tiwlnIsWinNT   = 3,
+    tiwlnIsWin98SE = 4,
+    tiwlnIsWinME   = 5,
+    tiwlnIsWin2K   = 6,
+    tiwlnIsWinXP   = 7
+} TIWLN_OS_VERSION;
+
+typedef enum _TIWLN_PRIVACY_MODE
+{
+    TIWLN_PRIVACY_NONE = 0,
+    TIWLN_PRIVACY_WEP,
+    TIWLN_PRIVACY_ZCU,
+    TIWLN_PRIVACY_EXC
+}TIWLN_PRIVACY_MODE;
+
+PACKED_STRUCT( _dbgBufferHdr ,
+
+    tiCHAR*        pBuff;
+    tiUINT32*       puIndex;
+    tiUINT32        uSize;
+);
+typedef _dbgBufferHdr DBG_BUFFER_HDR;
+
+PACKED_STRUCT( _TIWLN_REG_RW ,
+
+    tiUINT32 regSize;
+    tiUINT32 regAddr;
+    tiUINT32 regValue;
+);
+typedef _TIWLN_REG_RW TIWLN_REG_RW;
+
+PACKED_STRUCT( _ACX_VERSION_DEF , 
+
+    tiUINT8 major;
+    tiUINT8 minor;
+    tiUINT8 bugfix;
+    tiUINT8 subld;
+    tiUINT8 build;
+);
+typedef _ACX_VERSION_DEF acxVersionDef, *pacxVersionDef;
+
+PACKED_STRUCT( _TIWLN_VERSION ,
+
+    acxVersionDef AppVersion;
+    acxVersionDef DrvVersion;
+    acxVersionDef FWVersion;
+    acxVersionDef HWVersion;
+    tiUINT32      osNdisVersion;   /* for OS Windows - Ndis, for Linux - WirelessExt ver.*/
+);
+typedef _TIWLN_VERSION TIWLN_VERSION, *PTIWLN_VERSION;
+
+PACKED_STRUCT( _TIWLN_VERSION_EX ,
+
+    acxVersionDef AppVersion;
+    acxVersionDef DrvVersion;
+    acxVersionDef FWVersion;
+    acxVersionDef HWVersion;
+    tiUINT32      osNdisVersion;       /* for OS Windows - Ndis, for Linux - WirelessExt ver.*/
+    tiUINT32      extVerSign;            /* Extended version signature*/
+    acxVersionDef NVVersion;
+);
+typedef _TIWLN_VERSION_EX TIWLN_VERSION_EX, *PTIWLN_VERSION_EX;
+
+typedef enum _TIWLN_RATES
+{
+    TIWLN_RATE_1          = 0x0A,
+    TIWLN_RATE_2          = 0x14,
+    TIWLN_RATE_5_5        = 0x37,
+    TIWLN_RATE_5_5_PBCC   = 0xB7,
+    TIWLN_RATE_11         = 0x6E,
+    TIWLN_RATE_11_PBCC    = 0xEE,
+    TIWLN_RATE_22_PBCC    = 0xDC
+} TIWLN_RATES;
+
+typedef enum _TIWLN_DOT11_STATUS
+{
+    eDot11Idle           = 0,
+    eDot11Scaning        = 1,
+    eDot11Connecting     = 2,
+    eDot11Associated     = 3,
+    eDot11Disassociated  = 4,
+    eDot11RadioDisabled  = 5,
+    eDot11Error          = 1000,
+} TIWLN_DOT11_STATUS;
+
+typedef enum _TIWLN_SECURITY_STATE  /* Values are compatible with 802.1x'S IMSTATE*/
+{
+    eSecurityStateHalted = 0,           /* Security state machine halted*/
+    eSecurityStateStarting,         /* state machine is starting*/
+    eSecurityStateInitializing,     /* state machine is initializing*/
+    eSecurityStateDisabled,         /* state machine is disabled*/
+    eSecurityStateNotAuthenticated, /* Not authenticated state*/
+    eSecurityStateAuthenticating,       /* Authentication request is sent*/
+    eSecurityStateAuthenticated     /* Authenticated state*/
+} TIWLN_SECURITY_STATE;
+
+PACKED_STRUCT( _OS_802_11_DRIVER_CAPABILITIES ,
+
+    tiUINT8 EXCVersion; 
+);
+typedef _OS_802_11_DRIVER_CAPABILITIES OS_802_11_DRIVER_CAPABILITIES;
+
+
+/* SME SM definitions - Need to update this whenever the SME SM states change */
+/* Table is used for "translating" SME SM states into more "simple" states reported by the TI_GetDriverState API call */
+typedef enum
+{
+    SM_STATE_IDLE                           = 0,
+    SM_STATE_SCANNING                       = 1,
+    SM_STATE_SELECTING                      = 2,
+    SM_STATE_CONNECTING                     = 3,
+    SM_STATE_CONNECTED                      = 4,
+    SM_STATE_QUIET_SCAN                     = 5,
+    SM_STATE_INTER_SCAN_TIMEOUT             = 6,
+    SM_STATE_ROAMING_QUIET_SCAN             = 7,
+    SM_STATE_RADIO_STAND_BY                 = 8,
+    SM_STATE_MEASUREMENT                    = 9,
+    SM_STATE_POWER_MNGR_PENDS_QUIET_SCAN    = 10
+} stateDrvSme_e;
+
+typedef enum
+{
+    DRIVER_STATE_IDLE                    = 0,
+    DRIVER_STATE_SCANNING                = 1,
+    DRIVER_STATE_SELECTING               = 2,
+    DRIVER_STATE_CONNECTING              = 3,
+    DRIVER_STATE_CONNECTED               = 4,
+    DRIVER_STATE_DISCONNECTED            = 5,
+} driverState_e;
+
+PACKED_STRUCT( _TIWLAN_CONFIG_SCAN_PARAMS ,
+
+    UINT32    uMaxChanScanTime;
+    UINT32    uMinChanScanTime;
+    UINT32    uEarlyTerminationMode;
+    UINT32    uETMaxNumOfAPframes;
+    UINT32    uScanInterval;
+    UINT32    uNumOfProbeReq;
+);
+typedef _TIWLAN_CONFIG_SCAN_PARAMS TIWLAN_CONFIG_SCAN_PARAMS;
+
+
+/* The Tx path delay histogram ranges in msec. */
+typedef enum
+{
+    TX_DELAY_RANGE_MIN        = 0,
+
+    TX_DELAY_RANGE_0_TO_1     = 0,
+    TX_DELAY_RANGE_1_TO_10    = 1,
+    TX_DELAY_RANGE_10_TO_20   = 2,
+    TX_DELAY_RANGE_20_TO_40   = 3,
+    TX_DELAY_RANGE_40_TO_60   = 4,
+    TX_DELAY_RANGE_60_TO_80   = 5,
+    TX_DELAY_RANGE_80_TO_100  = 6,
+    TX_DELAY_RANGE_100_TO_200 = 7,
+    TX_DELAY_RANGE_ABOVE_200  = 8,
+
+    TX_DELAY_RANGE_MAX        = 8,
+    TX_DELAY_RANGES_NUM       = 9,
+} TxDelayRanges_e;
+
+#define TX_RETRY_HISTOGRAM_SIZE 16
+
+PACKED_STRUCT( txDataCounters_t ,
+
+    UINT32      XmitOk;                 /* the number of frames that were transferred to TNET without errors */
+    UINT32      DirectedBytesXmit;      /* the number of bytes in directed packets that are transmitted without errors */
+    UINT32      DirectedFramesXmit;     /* the number of directed packets that are transmitted without errors */
+    UINT32      MulticastBytesXmit;     /* the number of bytes in multicast/functional packets that are transmitted without errors.*/
+    UINT32      MulticastFramesXmit;    /* the number of multicast/functional packets that are transmitted without errors.*/
+    UINT32      BroadcastBytesXmit;     /* the number of bytes in broadcast packets that are transmitted without */
+    UINT32      BroadcastFramesXmit;    /* the number of broadcast packets that are transmitted without errors */
+
+    UINT32      RetryHistogram[ TX_RETRY_HISTOGRAM_SIZE ];
+                                        /* Histogram counting the number of packets xfered with any retry number */
+    UINT32      RetryFailCounter;       /* Number of packets that failed transmission due to retry number exceeded */
+    UINT32      TxTimeoutCounter;       /* Number of packets that failed transmission due to lifetime expiry */
+    UINT32      NoLinkCounter;          /* Number of packets that failed transmission due to link failure */
+    UINT32      OtherFailCounter;       /* Number of packets that failed transmission due to other reasons */
+    UINT32      MaxConsecutiveRetryFail;/* Maximum consecutive packets that failed transmission due to retry limit exceeded */
+
+    /*  TX path delay statistics  */
+    UINT32      txDelayHistogram[TX_DELAY_RANGES_NUM];/* Histogram of Tx path delay (host + MAC). */
+    UINT32      NumPackets;             /* For average calculation - Total packets counted. */
+    UINT32      SumTotalDelayMs;        /* For average calculation - the sum of packets total delay. */
+    UINT32      SumFWDelayUs;           /* For average calculation - The sum of packets FW delay. */
+    UINT32      SumMacDelayUs;          /* For average calculation - the sum of packets MAC delay. */
+); 
+
+typedef struct
+{
+    txDataCounters_t  txCounters[ MAX_NUM_OF_TX_QUEUES ];
+} TIWLN_TX_STATISTICS;
+
+PACKED_STRUCT( TIWLN_COUNTERS ,
+
+    UINT32  RecvOk;              /* num of frames that the NIC receives without errors*/
+    UINT32  RecvError;           /* num of frames that a NIC receives but does not indicate to the protocols due to errors*/
+    UINT32  RecvNoBuffer;        /* num of frames that the NIC cannot receive due to lack of NIC receive buffer space     */
+    UINT32  DirectedBytesRecv;   /* num of bytes in directed packets that are received without errors                     */
+    UINT32  DirectedFramesRecv;  /* num of directed packets that are received without errors                              */
+    UINT32  MulticastBytesRecv;  /* num of bytes in multicast/functional packets that are received without errors         */
+    UINT32  MulticastFramesRecv; /* num of multicast/functional packets that are received without errors                  */
+    UINT32  BroadcastBytesRecv;  /* num of bytes in broadcast packets that are received without errors.                   */
+    UINT32  BroadcastFramesRecv; /* num of broadcast packets that are received without errors.                            */
+
+    UINT32  FragmentsRecv;
+    UINT32  FrameDuplicates;
+    UINT32  FcsErrors;
+
+    UINT32  BeaconsXmit;
+    UINT32  BeaconsRecv;
+    UINT32  AssocRejects;
+    UINT32  AssocTimeouts;
+    UINT32  AuthRejects;
+    UINT32  AuthTimeouts;
+);
+
+PACKED_STRUCT( _TIWLN_STATISTICS ,
+
+    /**/
+    /* config info*/
+    /**/
+    tiUINT32                        dot11CurrentTxRate;
+    tiUINT32                        dot11CurrentChannel;
+    OS_802_11_MAC_ADDRESS           currentMACAddress;
+    OS_802_11_SSID                  dot11DesiredSSID; 
+    OS_802_11_NETWORK_MODE          dot11BSSType;
+    OS_802_11_AUTHENTICATION_MODE   AuthenticationMode;
+    tiBOOL                          bShortPreambleUsed;
+    tiUINT32                        RTSThreshold;
+    tiUINT32                        FragmentationThreshold;
+    tiBOOL                          bDefaultWEPKeyDefined;
+    OS_802_11_WEP_STATUS            WEPStatus;
+    tiUINT32                        TxAntenna;
+    tiUINT32                        RxAntenna;
+    tiUINT32                        TxPowerDbm;
+    tiUINT32                        PowerMode;
+    tiINT32                         RxLevel;
+
+    /**/
+    /* status & AP info*/
+    /**/
+    TIWLN_DOT11_STATUS  dot11State;
+    OS_802_11_BSSID     targetAP; 
+
+    /**/
+    /* network layer statistics (except Tx statistics which are handled sparately)*/
+    /**/
+    TIWLN_COUNTERS tiCounters;
+
+    /**/
+    /* other statistics*/
+    /**/
+    tiUINT32  dwSecuritySuit;           /* Security suit bitmask (see defines)*/
+    tiUINT32  dwSecurityState;          /* 802.1x security protocol state*/
+    tiUINT32  dwSecurityAuthStatus;     /* Security suit authentication status*/
+    tiUINT32  dwFeatureSuit;            /* Additional features suit bitmask (see defines)*/
+
+);
+typedef _TIWLN_STATISTICS TIWLN_STATISTICS;
+
+/* Statistics security suit bitmasks*/
+#define TIWLN_STAT_SECURITY_RESERVE_1   0x0001
+#define TIWLN_STAT_SECURITY_SSN  0x0002
+
+/* Features suit bitmasks*/
+#define TIWLN_FEATURE_4XENABLED  0x0001
+#define TIWLN_FEATURE_4XACTIVE   0x0002
+
+PACKED_STRUCT( _TIWLN_REGDOMAINS ,
+
+    tiUINT8 Length;
+    tiUINT8 Table[REGDOMAIN_TABLE_SIZE];
+);
+typedef _TIWLN_REGDOMAINS TIWLN_REGDOMAINS;
+
+PACKED_STRUCT( _TIWLN_MEDIUM_USAGE ,
+
+    tiUINT32            MediumUsage;
+    tiUINT32            Period;
+);
+typedef _TIWLN_MEDIUM_USAGE TIWLN_MEDIUM_USAGE;
+
+typedef struct _RADIO_RX_QUALITY
+{
+    tiINT32             Snr;
+    tiINT32             Rssi;
+}TIWLN_RADIO_RX_QUALITY;
+
+#define MAX_NUM_DATA_FILTERS                4
+
+PACKED_STRUCT( _TIWLAN_DATA_FILTER_STATISTICS ,
+
+    tiUINT32            UnmatchedPacketsCount;
+    tiUINT32            MatchedPacketsCount[MAX_NUM_DATA_FILTERS];
+);
+typedef _TIWLAN_DATA_FILTER_STATISTICS TIWLAN_DATA_FILTER_STATISTICS;
+
+#define MAX_DATA_FILTER_MASK_LENGTH         8
+#define MAX_DATA_FILTER_PATTERN_LENGTH      64
+
+PACKED_STRUCT ( _TIWLAN_DATA_FILTER_REQUEST ,
+
+    tiUINT8             Offset;
+    tiUINT8             MaskLength;
+    tiUINT8             Mask[MAX_DATA_FILTER_MASK_LENGTH];
+    tiUINT8             PatternLength;
+    tiUINT8             Pattern[MAX_DATA_FILTER_PATTERN_LENGTH];
+);
+typedef _TIWLAN_DATA_FILTER_REQUEST TIWLAN_DATA_FILTER_REQUEST;
+
+
+#define MAX_NUM_PROFILES 4
+
+PACKED_STRUCT( _TIWLN_PROFILE ,
+
+    tiBOOL                          bPresent;
+    OS_802_11_SSID                  dot11DesiredSSID; 
+    OS_802_11_NETWORK_MODE          dot11BSSType;
+    OS_802_11_AUTHENTICATION_MODE   AuthenticationMode;
+    OS_802_11_WEP                   WepDefaultKey[4];
+    tiUINT32                        WepDefaultKeyID;
+    tiBOOL                          bWepDefaultKeySet;
+    OS_802_11_WEP_STATUS            WEPStatus;
+
+    /**/
+    /* Which one should be included???*/
+    /**/
+    tiUINT32                        dot11TxRate;
+    tiUINT32                        dot11Channel;
+    tiBOOL                          bShortPreambleUsed;
+    tiBOOL                          bHighSpeed;
+    tiUINT32                        RTSThreshold;
+    tiUINT32                        FragmentationThreshold;
+
+    tiUINT32                        TxAntenna;
+    tiUINT32                        RxAntenna;
+    tiUINT32                        TxPowerDbm;
+    tiUINT32                        PowerMode;
+);
+typedef _TIWLN_PROFILE TIWLN_PROFILE, *PTIWLN_PROFILE;
+
+
+/* SHA1 hash (of certificate)*/
+typedef struct _TI_SHA1_HASH
+{
+    tiUINT8 aHash[20];
+} TI_SHA1_HASH;
+
+PACKED_STRUCT( _TIWLAN_ANT_DIVERSITY ,
+
+    tiUINT8   enableRxDiversity;
+    tiUINT8   rxSelectedAntenna;
+    tiUINT8   enableTxDiversity;
+    tiUINT8   txSelectedAntenna;
+    tiUINT8   rxTxSharedAnts;
+);
+typedef _TIWLAN_ANT_DIVERSITY TIWLAN_ANT_DIVERSITY, *PTIWLAN_ANT_DIVERSITY;
+
+#define TI_NUM_OF_SUB_BANDS 5
+#define TI_NUM_OF_POWER_LEVEL 4
+
+typedef struct
+{
+       tiUINT8 uTxPower[TI_NUM_OF_SUB_BANDS][TI_NUM_OF_POWER_LEVEL]; /* Maximun Dbm in Dbm/10 units */
+} TIWLAN_POWER_LEVEL_TABLE;
+
+#endif /* __TIWLNIF_H__*/
diff --git a/sta_dk_4_0_4_32/common/inc/whalDefaultParams.h b/sta_dk_4_0_4_32/common/inc/whalDefaultParams.h
new file mode 100644 (file)
index 0000000..32ff4aa
--- /dev/null
@@ -0,0 +1,353 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_DEFAULT_PARAMS_H
+#define _WHAL_DEFAULT_PARAMS_H
+
+
+/*****************************************************************************
+ **                                                                         **
+ **                                                                         **
+ **                       CONSTANTS                                         **
+ **                                                                         **
+ **                                                                         **
+ *****************************************************************************/
+
+/* PALAU Group Address Default Values */
+#define NUM_GROUP_ADDRESS_VALUE_DEF 0   
+#define NUM_GROUP_ADDRESS_VALUE_MIN 0
+#define NUM_GROUP_ADDRESS_VALUE_MAX 8
+
+/* Early Wakeup Default Values */
+#define EARLY_WAKEUP_ENABLE_MIN         (FALSE)
+#define EARLY_WAKEUP_ENABLE_MAX         (TRUE)
+#define EARLY_WAKEUP_ENABLE_DEF         (TRUE)
+
+/* ARP IP Filter Default Values */
+#define MIN_FILTER_ENABLE_VALUE 0
+#define MAX_FILTER_ENABLE_VALUE 2
+#define DEF_FILTER_ENABLE_VALUE 0
+#define FILTER_ENABLE_FLAG_LEN  1
+
+/* Beacon filter Deafult Values */
+#define DEF_BEACON_FILTER_ENABLE_VALUE 1
+#define DEF_BEACON_FILTER_IE_TABLE_NUM 15
+#define MIN_BEACON_FILTER_ENABLE_VALUE 0
+#define MAX_BEACON_FILTER_ENABLE_VALUE 1
+#define BEACON_FILTER_IE_TABLE_DEF_SIZE 35
+#define BEACON_FILTER_IE_TABLE_MAX_SIZE 100
+#define BEACON_FILTER_IE_TABLE_MIN_SIZE 0 
+#define BEACON_FILTER_IE_TABLE_MAX_NUM (6+32)
+#define BEACON_FILTER_IE_TABLE_MIN_NUM 0 
+
+#define HAL_CTRL_BET_ENABLE_MIN                                        0
+#define HAL_CTRL_BET_ENABLE_MAX                                        1
+#define HAL_CTRL_BET_ENABLE_DEF                                        1
+
+#define HAL_CTRL_BET_MAX_CONSC_MIN                             1
+#define HAL_CTRL_BET_MAX_CONSC_MAX                             50
+#define HAL_CTRL_BET_MAX_CONSC_DEF                             8
+
+/* TX XFER parameters */
+#define TX_XFER_HW_BUFFER_FULL_DUR_RECOVERY_DEF     50
+#define TX_XFER_HW_BUFFER_FULL_DUR_RECOVERY_MIN     30
+#define TX_XFER_HW_BUFFER_FULL_DUR_RECOVERY_MAX     1000
+
+/* Default Value for Atheros time out value */
+#define DEF_TX_POWER_ADJUST_TIME_OUT            5000
+
+#define DEF_NUM_STORED_FILTERS 1
+#define MIN_NUM_STORED_FILTERS 1
+#define MAX_NUM_STORED_FILTERS 8
+
+#define HAL_CTRL_HW_ACCESS_METHOD_MIN           0
+#define HAL_CTRL_HW_ACCESS_METHOD_MAX           2
+#define HAL_CTRL_HW_ACCESS_METHOD_DEF           1
+
+#define HAL_CTRL_SITE_FRAG_COLLECT_MIN          2
+#define HAL_CTRL_SITE_FRAG_COLLECT_MAX          10
+#define HAL_CTRL_SITE_FRAG_COLLECT_DEF          3
+
+
+#define HAL_CTRL_HOST_RX_DESC_MIN               1
+#define HAL_CTRL_HOST_RX_DESC_MAX               127
+#define HAL_CTRL_HOST_RX_DESC_DEF               32 /* instead of 40 - for a bigger TKIP FW*/
+
+#define HAL_CTRL_HOST_TX_DESC_MIN               1
+#define HAL_CTRL_HOST_TX_DESC_MAX               127
+#define HAL_CTRL_HOST_TX_DESC_DEF               32 /* instead of 40 - for a bigger TKIP FW*/
+
+#define HAL_CTRL_ACX_RX_DESC_MIN                1
+#define HAL_CTRL_ACX_RX_DESC_MAX                127
+#define HAL_CTRL_ACX_RX_DESC_DEF                32
+
+#define HAL_CTRL_ACX_TX_DESC_MIN                1
+#define HAL_CTRL_ACX_TX_DESC_MAX                127
+#define HAL_CTRL_ACX_TX_DESC_DEF                16
+
+#define HAL_CTRL_ACX_BLOCK_SIZE_MIN             256
+#define HAL_CTRL_ACX_BLOCK_SIZE_MAX             2000
+#define HAL_CTRL_ACX_BLOCK_SIZE_DEF             256
+
+#define HAL_CTRL_RX_BLOCKS_RATIO_MIN            0
+#define HAL_CTRL_RX_BLOCKS_RATIO_MAX            100
+#define HAL_CTRL_RX_BLOCKS_RATIO_DEF            50
+
+#define HAL_CTRL_USE_PLCP_HDR_DEF               1
+#define HAL_CTRL_USE_PLCP_HDR_MAX               1
+#define HAL_CTRL_USE_PLCP_HDR_MIN               0
+
+#define HAL_CTRL_TX_FLASH_ENABLE_MIN            FALSE
+#define HAL_CTRL_TX_FLASH_ENABLE_MAX            TRUE
+#define HAL_CTRL_TX_FLASH_ENABLE_DEF            TRUE
+
+#define HAL_CTRL_USE_INTR_TRHESHOLD_MIN         0
+#define HAL_CTRL_USE_INTR_TRHESHOLD_MAX         1
+#define HAL_CTRL_USE_INTR_TRHESHOLD_DEF         0
+
+#define HAL_CTRL_USE_TX_DATA_INTR_MIN           0
+#define HAL_CTRL_USE_TX_DATA_INTR_MAX           1
+
+#if (!defined TIWLN_WINCE30) || (defined EMBEDDED_BOARD1)
+#define HAL_CTRL_USE_TX_DATA_INTR_DEF           1
+#else
+#define HAL_CTRL_USE_TX_DATA_INTR_DEF           0
+#endif
+
+#define NUM_OF_CHANNELS_24                      (14)
+#define A_5G_BAND_MIN_CHANNEL                          36
+#define A_5G_BAND_MAX_CHANNEL                          180
+#define A_5G_BAND_NUM_CHANNELS                                 (A_5G_BAND_MAX_CHANNEL-A_5G_BAND_MIN_CHANNEL+1)
+
+
+#define HAL_CTRL_CALIBRATION_CHANNEL_2_4_MIN              1
+#define HAL_CTRL_CALIBRATION_CHANNEL_2_4_MAX              NUM_OF_CHANNELS_24
+#define HAL_CTRL_CALIBRATION_CHANNEL_2_4_DEF              1
+
+#define HAL_CTRL_CALIBRATION_CHANNEL_5_0_MIN              34
+#define HAL_CTRL_CALIBRATION_CHANNEL_5_0_MAX              A_5G_BAND_MAX_CHANNEL
+#define HAL_CTRL_CALIBRATION_CHANNEL_5_0_DEF              36
+
+#define HAL_CTRL_CALIBRATION_CHANNEL_4_9_MIN              8
+#define HAL_CTRL_CALIBRATION_CHANNEL_4_9_MAX              16
+#define HAL_CTRL_CALIBRATION_CHANNEL_4_9_DEF              12
+
+#define HAL_CTRL_RTS_THRESHOLD_MIN              0
+#define HAL_CTRL_RTS_THRESHOLD_MAX              4096
+#define HAL_CTRL_RTS_THRESHOLD_DEF              2347
+
+#define HAL_CTRL_BCN_RX_TIME_OUT_MIN            10      /* ms */
+#define HAL_CTRL_BCN_RX_TIME_OUT_MAX            1000    /* ms */
+#define HAL_CTRL_BCN_RX_TIME_OUT_DEF            10      /* ms */
+
+#define HAL_CTRL_RX_DISABLE_BROADCAST_MIN       FALSE
+#define HAL_CTRL_RX_DISABLE_BROADCAST_MAX       TRUE
+#define HAL_CTRL_RX_DISABLE_BROADCAST_DEF       FALSE
+
+/* Indicate if the recovery process is active or not */
+#define HAL_CTRL_RECOVERY_ENABLE_MIN            FALSE
+#define HAL_CTRL_RECOVERY_ENABLE_MAX            TRUE
+#define HAL_CTRL_RECOVERY_ENABLE_DEF            TRUE
+
+#define HAL_CTRL_FRAG_THRESHOLD_MIN             256
+#define HAL_CTRL_FRAG_THRESHOLD_MAX             4096
+#define HAL_CTRL_FRAG_THRESHOLD_DEF             2312
+
+#define HAL_CTRL_MAX_TX_MSDU_LIFETIME_MIN       0
+#define HAL_CTRL_MAX_TX_MSDU_LIFETIME_MAX       3000
+#define HAL_CTRL_MAX_TX_MSDU_LIFETIME_DEF       512
+
+#define HAL_CTRL_MAX_RX_MSDU_LIFETIME_MIN       0
+#define HAL_CTRL_MAX_RX_MSDU_LIFETIME_MAX       0xFFFFFFFF
+#define HAL_CTRL_MAX_RX_MSDU_LIFETIME_DEF       512000
+
+
+#define HAL_CTRL_LISTEN_INTERVAL_MIN            1
+#define HAL_CTRL_LISTEN_INTERVAL_MAX            10
+#define HAL_CTRL_LISTEN_INTERVAL_DEF            3
+
+#define HAL_CTRL_MAX_FULL_BEACON_MIN            0
+#define HAL_CTRL_MAX_FULL_BEACON_MAX            10000
+#define HAL_CTRL_MAX_FULL_BEACON_DEF            1000
+
+#define HAL_CTRL_BET_ENABLE_THRESHOLD_MIN       0
+#define HAL_CTRL_BET_ENABLE_THRESHOLD_MAX       255
+#define HAL_CTRL_BET_ENABLE_THRESHOLD_DEF       8
+
+#define HAL_CTRL_BET_DISABLE_THRESHOLD_MIN       0
+#define HAL_CTRL_BET_DISABLE_THRESHOLD_MAX       255
+#define HAL_CTRL_BET_DISABLE_THRESHOLD_DEF       12
+
+/* This field indicates the number of transmit retries to attempt at
+    the rate specified in the TNETW1130 Tx descriptor before
+    falling back to the next lowest rate.
+    If this field is set to 0xff, then rate fallback is disabled.
+    If this field is 0, then there will be 0 retries before starting fallback.*/
+#define HAL_CTRL_RATE_FB_RETRY_LIMIT_MIN        0   /* => No retries before starting RateFallBack */
+#define HAL_CTRL_RATE_FB_RETRY_LIMIT_MAX        255 /* =>0xff for disabling Rate fallback */
+#define HAL_CTRL_RATE_FB_RETRY_LIMIT_DEF        0
+
+#define HAL_CTRL_TX_ANTENNA_MIN                 TX_ANTENNA_2
+#define HAL_CTRL_TX_ANTENNA_MAX                 TX_ANTENNA_1
+#define HAL_CTRL_TX_ANTENNA_DEF                 TX_ANTENNA_1
+
+#define HAL_CTRL_RX_ANTENNA_MIN                 RX_ANTENNA_1
+#define HAL_CTRL_RX_ANTENNA_MAX                 RX_ANTENNA_PARTIAL
+#define HAL_CTRL_RX_ANTENNA_DEF                 RX_ANTENNA_FULL
+
+#define HAL_CTRL_TX_CMPLT_THRESHOLD_DEF         0
+#define HAL_CTRL_TX_CMPLT_THRESHOLD_MIN         0
+#define HAL_CTRL_TX_CMPLT_THRESHOLD_MAX         15
+
+#define HAL_CTRL_ACI_MODE_MIN                   0
+#define HAL_CTRL_ACI_MODE_MAX                   255
+#define HAL_CTRL_ACI_MODE_DEF                   0
+    
+#define HAL_CTRL_ACI_INPUT_CCA_MIN              0
+#define HAL_CTRL_ACI_INPUT_CCA_MAX              255
+#define HAL_CTRL_ACI_INPUT_CCA_DEF              1
+    
+#define HAL_CTRL_ACI_QUALIFIED_CCA_MIN          0
+#define HAL_CTRL_ACI_QUALIFIED_CCA_MAX          255
+#define HAL_CTRL_ACI_QUALIFIED_CCA_DEF          3
+    
+#define HAL_CTRL_ACI_STOMP_FOR_RX_MIN           0
+#define HAL_CTRL_ACI_STOMP_FOR_RX_MAX           255
+#define HAL_CTRL_ACI_STOMP_FOR_RX_DEF           2
+    
+#define HAL_CTRL_ACI_STOMP_FOR_TX_MIN           0
+#define HAL_CTRL_ACI_STOMP_FOR_TX_MAX           255
+#define HAL_CTRL_ACI_STOMP_FOR_TX_DEF           0
+    
+#define HAL_CTRL_ACI_TX_CCA_MIN                 0
+#define HAL_CTRL_ACI_TX_CCA_MAX                 255
+#define HAL_CTRL_ACI_TX_CCA_DEF                 1
+
+/************************************/      
+/*      Rates values                */  
+/************************************/
+
+
+#define BASIC_RATE_SET_1_2                  0
+#define BASIC_RATE_SET_1_2_5_5_11           1
+
+
+#define BASIC_RATE_SET_UP_TO_12             2
+#define BASIC_RATE_SET_UP_TO_18             3
+#define BASIC_RATE_SET_1_2_5_5_6_11_12_24   4
+#define BASIC_RATE_SET_UP_TO_36             5
+#define BASIC_RATE_SET_UP_TO_48             6
+#define BASIC_RATE_SET_UP_TO_54             7
+#define BASIC_RATE_SET_UP_TO_24             8
+#define BASIC_RATE_SET_6_12_24              9
+
+
+/* Keep increasing define values - related to increasing suported rates */
+#define SUPPORTED_RATE_SET_1_2              0
+#define SUPPORTED_RATE_SET_1_2_5_5_11       1
+#define SUPPORTED_RATE_SET_1_2_5_5_11_22    2
+#define SUPPORTED_RATE_SET_UP_TO_18         3
+#define SUPPORTED_RATE_SET_UP_TO_24         4
+#define SUPPORTED_RATE_SET_UP_TO_36         5
+#define SUPPORTED_RATE_SET_UP_TO_48         6
+#define SUPPORTED_RATE_SET_UP_TO_54         7
+#define SUPPORTED_RATE_SET_ALL              8
+#define SUPPORTED_RATE_SET_ALL_OFDM         9
+
+
+/*****************************************************************************
+ **                                                                         **
+ **                                                                         **
+ **                       ENUMS                                             **
+ **                                                                         **
+ **                                                                         **
+ *****************************************************************************/
+
+typedef enum
+{
+    BSS_INDEPENDENT         = 0,
+    BSS_INFRASTRUCTURE      = 1,
+    BSS_ANY                 = 2,
+    BSS_AP                  = 3
+} bssType_e;
+
+
+typedef enum
+{
+    PREAMBLE_LONG           = 0,
+    PREAMBLE_SHORT          = 1,
+    PREAMBLE_UNSPECIFIED    = 0xFF
+} preamble_e;
+
+typedef enum
+{
+    PHY_SLOT_TIME_LONG = 0,
+    PHY_SLOT_TIME_SHORT = 1
+} slotTime_e;
+
+typedef enum
+{
+    NULL_KEY = 0,
+    WEP_KEY,
+    TKIP_KEY,
+    AES_KEY,
+    EXC_KEY,
+} keyType_e;
+
+/* make it same as "rate_e" */
+typedef enum
+{
+  REG_RATE_AUTO_BIT         = 0, /* This value is reserved if this enum is used for MgmtCtrlTxRate  - The auto mode is noly valid for data packets */
+  REG_RATE_1M_BIT           = 1,
+  REG_RATE_2M_BIT           = 2,
+  REG_RATE_5_5M_CCK_BIT     = 3,
+  REG_RATE_11M_CCK_BIT      = 4,
+  REG_RATE_22M_PBCC_BIT     = 5,
+  REG_RATE_6M_OFDM_BIT      = 6,
+  REG_RATE_9M_OFDM_BIT      = 7,
+  REG_RATE_12M_OFDM_BIT     = 8,
+  REG_RATE_18M_OFDM_BIT     = 9,
+  REG_RATE_24M_OFDM_BIT     = 10,
+  REG_RATE_36M_OFDM_BIT     = 11,
+  REG_RATE_48M_OFDM_BIT     = 12,
+  REG_RATE_54M_OFDM_BIT     = 13
+} registryTxRate_e;
+
+
+
+
+
+
+#endif /* _WHAL_DEFAULT_PARAMS_H */
diff --git a/sta_dk_4_0_4_32/common/inc/wspVer.h b/sta_dk_4_0_4_32/common/inc/wspVer.h
new file mode 100644 (file)
index 0000000..637a82b
--- /dev/null
@@ -0,0 +1,59 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/   
+
+/**************************************************************************/
+/*                                                                        */
+/*   MODULE:  wspVer.h                                                    */
+/*   PURPOSE: release specific definitions file.                          */
+/*                                                                        */
+/**************************************************************************/
+#ifndef _WSP_VER_H_                            
+#define _WSP_VER_H_                             
+
+#define SW_VERSION_MAJOR    4
+#define SW_VERSION_MINOR    0
+#define SW_VERSION_PATCH    4
+#define SW_VERSION_SUBLD       3
+#define SW_VERSION_BUILD    2
+#define SW_VERSION_STR      "WiLink_Driver_4.0.4.3.2"
+
+/* base version */
+
+#define SW_RELEASE_MONTH    2
+#define SW_RELEASE_DAY      14
+#define SW_RELEASE_YEAR     2008
+
+#endif /* _WSP_VER_H_ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Application/ExpInc/roamingMngrApi.h b/sta_dk_4_0_4_32/common/src/Application/ExpInc/roamingMngrApi.h
new file mode 100644 (file)
index 0000000..51e4668
--- /dev/null
@@ -0,0 +1,89 @@
+/** \file roamingMngrApi.h
+ *  \brief Internal Roaming Manager API
+ *
+ *  \see roamingMngr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Roaming Manager                                               *
+ *   PURPOSE: Roaming Manager Module API                                   *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ROAMING_MNGR_API_H_
+#define _ROAMING_MNGR_API_H_
+
+/*#include "802_11Defs.h"*/
+#include "osApi.h"
+#include "paramOut.h"
+#include "scanMngrApi.h"
+#include "bssTypes.h"
+
+/* Constants */
+
+/* Enumerations */
+
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+/* Creates the Roaming Manager Module */
+TI_HANDLE roamingMngr_create(TI_HANDLE hOs);
+
+/* Configures Roaming Manager Module */
+TI_STATUS roamingMngr_init(TI_HANDLE hRoamingMngr,
+                                         TI_HANDLE hReport,
+                                         TI_HANDLE hScanMngr,
+                                         TI_HANDLE hAPConnection);
+/* Unloads the Roaming Manager Module */
+TI_STATUS roamingMngr_unload(TI_HANDLE hRoamingMngr);
+/* IF for getting Roaming Manager Module parameters */
+TI_STATUS roamingMngr_getParam(TI_HANDLE hRoamingMngr, paramInfo_t *pParam);
+/* IF for setting Roaming Manager Module parameters */
+TI_STATUS roamingMngr_setParam(TI_HANDLE hRoamingMngr, paramInfo_t *pParam);
+
+
+#endif /*  _ROAMING_MNGR_API_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/Application/Roaming/roamingMngr.c b/sta_dk_4_0_4_32/common/src/Application/Roaming/roamingMngr.c
new file mode 100644 (file)
index 0000000..bab1132
--- /dev/null
@@ -0,0 +1,2347 @@
+/***************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Roaming Manager                                               *
+ *   PURPOSE:                                                               *
+ *   Roaming manager is responsible to receive Roaming triggers and try
+ *      to select a better AP.
+ *      The Roaming triggers are: Low RSSI, PER, consecutive No ACK on TX,
+ *      beacon Missed or External request.
+ *      In each Internal Roaming request, scan is performed and selection for 
+ *      better AP. Better AP is defined as a different AP with better RSSI,
+ *      and similar SSID and security settings.
+ *      If better AP is found, there is a check for fast-roaming via the
+ *      Supplicant. Then connection to the new AP is invoked.
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "report.h"
+#include "fsm.h"
+#include "utils.h"
+
+#include "scanMngrApi.h"
+#include "roamingMngrApi.h"
+#include "apConnApi.h"
+#include "roamingMngrTypes.h"
+#include "bssTypes.h"
+
+/* Constants */
+
+/* Init bits */
+#define ROAMING_MNGR_CONTEXT_INIT_BIT       1
+#define ROAMING_MNGR_SM_INIT_BIT            2
+
+#define DEFAULT_AP_QUALITY                  (-70)
+#define DEFAULT_LOW_PASS_FILTER             (30)
+#define DEFAULT_DATA_RETRY_THRESHOLD        (20)
+#define DEFAULT_LOW_QUALITY_SCAN_COND       (-60)
+#define DEFAULT_NORMAL_QUALITY_SCAN_COND    (-50)
+#define DEFAULT_LOW_RSSI                    (-70)
+#define DEFAULT_LOW_SNR                     (0)
+#define DEFAULT_TBTT_4_BSS_LOSS             (10)
+#define DEFAULT_LOW_TX_RATE                 (2)
+/* Enumerations */
+
+/** state machine states */
+typedef enum 
+{
+    ROAMING_STATE_IDLE                      = 0,
+    ROAMING_STATE_WAIT_4_TRIGGER    = 1,
+    ROAMING_STATE_WAIT_4_CMD        = 2,
+    ROAMING_STATE_SCANNING          = 3,
+    ROAMING_STATE_SELECTING         = 4,
+    ROAMING_STATE_CONNECTING        = 5,
+    ROAMING_STATE_LAST              = 6
+} roamingMngr_smStates;
+
+/** State machine events */
+typedef enum 
+{
+    ROAMING_EVENT_START             = 0, /* CONNECTED */
+    ROAMING_EVENT_STOP              = 1, /* NOT CONNECTED */
+    ROAMING_EVENT_ROAM_TRIGGER      = 2,
+    ROAMING_EVENT_SCAN              = 3, 
+    ROAMING_EVENT_SELECT            = 4, 
+    ROAMING_EVENT_REQ_HANDOVER      = 5, 
+    ROAMING_EVENT_ROAM_SUCCESS      = 6, 
+    ROAMING_EVENT_FAILURE           = 7, 
+    ROAMING_EVENT_LAST              = 8
+} roamingMngr_smEvents;
+
+/* scan types */
+typedef enum 
+{
+    ROAMING_NO_SCAN, 
+    ROAMING_PARTIAL_SCAN,
+    ROAMING_PARTIAL_SCAN_RETRY,
+    ROAMING_FULL_SCAN,
+    ROAMING_FULL_SCAN_RETRY
+} scan4RoamingType_e;
+
+/* Roaming Trigger groups, according to Roaming Triggers */
+typedef enum
+{
+    ROAMING_TRIGGER_BG_SCAN_GROUP = ROAMING_TRIGGER_NORMAL_QUALITY_FOR_BG_SCAN,
+    ROAMING_TRIGGER_LOW_QUALITY_GROUP = ROAMING_TRIGGER_MAX_TX_RETRIES,
+    ROAMING_TRIGGER_FAST_CONNECT_GROUP = ROAMING_TRIGGER_SWITCH_CHANNEL,
+    ROAMING_TRIGGER_FULL_CONNECT_GROUP = ROAMING_TRIGGER_SECURITY_ATTACK
+} roamingMngr_connectTypeGroup_e;
+
+
+#define ROAMING_MNGR_NUM_STATES     ROAMING_STATE_LAST   
+#define ROAMING_MNGR_NUM_EVENTS     ROAMING_EVENT_LAST  
+
+#define INVALID_CANDIDATE_INDEX     0xFF
+#define CURRENT_AP_INDEX            0xFE
+
+/* Typedefs */
+
+typedef struct _roamingMngr_t   roamingMngr_t;
+/* Structures */
+typedef struct 
+{
+    UINT8   preAuthBSSList[MAX_SIZE_OF_BSS_TRACK_LIST];
+    UINT8   numOfPreAuthBSS;
+    UINT8   neighborBSSList[MAX_SIZE_OF_BSS_TRACK_LIST];
+    UINT8   numOfNeighborBSS;
+    UINT8   regularBSSList[MAX_SIZE_OF_BSS_TRACK_LIST];
+    UINT8   numOfRegularBSS;
+} listOfCandidateAps_t;
+
+#define MAX_ROAMING_TRIGGERS  ROAMING_TRIGGER_LAST
+
+struct _roamingMngr_t
+{
+    /*** Roaming manager parameters that can be configured externally ***/
+    roamingMngrConfig_t         roamingMngrConfig;
+    roamingMngrThresholdsConfig_t   roamingMngrThresholdsConfig;
+    UINT32                      lowPassFilterRoamingAttemptInMsec;
+
+    /*** Internal roaming parameters ***/
+    /* the roaming trigger type */
+    apConn_roamingTrigger_e     roamingTrigger;
+    /* Roaming SM current state */
+    roamingMngr_smStates        currentState;
+    /* Indicate if a trigger is already in process, and therefore the 
+        other triggers will be ignored */
+    BOOL                        maskRoamingEvents;
+    /* TS to filter Too many low Quality roaming triggers */
+    UINT32                      lowQualityTriggerTimestamp;
+    /* the scan type performed for Roaming */
+    scan4RoamingType_e          scanType; 
+    /* list of BSS received from Scan Manager */
+    bssList_t                   *pListOfAPs;
+    /* Indicating if Neighbor APs exist */
+    BOOL                        neighborApsExist;
+    /* a list of the candiadte APs indexes in pListOfAPs according to
+        neighbor APs, pre-auth APs and other APs */
+    listOfCandidateAps_t        listOfCandidateAps;
+    /* The current candidate AP's index to Roam to */
+    UINT8                       candidateApIndex;
+    /* Indicates whether at least one handover was performed */
+    BOOL                        handoverWasPerformed;
+    /* The station capabilities for the current Connection */
+    apConn_staCapabilities_t    staCapabilities;
+
+    /* Roaming manager SM */
+    fsm_stateMachine_t          *pRoamingSm;
+                                
+    /* Roaming manager handles to other objects */                                
+    TI_HANDLE                   hReport;
+    TI_HANDLE                   hOs;
+    TI_HANDLE                   hScanMngr;
+    TI_HANDLE                   hAPConnection;
+
+#ifdef TI_DBG
+
+    /* Debug trace for Roaming statistics */
+    UINT32                      roamingTriggerEvents[MAX_ROAMING_TRIGGERS];
+    UINT32                      roamingHandoverEvents[MAX_ROAMING_TRIGGERS];
+    UINT32                      roamingSuccesfulHandoverNum;    
+    UINT32                      roamingFailedHandoverNum;   
+    UINT32                      roamingTriggerTimestamp;
+    UINT32                      roamingHandoverStartedTimestamp;
+    UINT32                      roamingHandoverCompletedTimestamp;
+    UINT32                      roamingAverageSuccHandoverDuration;
+    UINT32                      roamingAverageRoamingDuration;
+#endif
+    
+};
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+
+#ifdef REPORT_LOG
+
+static char *roamingMngr_stateDesc[ROAMING_MNGR_NUM_STATES] = {  
+        "STATE_IDLE",              
+        "STATE_WAIT_4_TRIGGER",                                                
+        "STATE_WAIT_4_CMD",                                         
+        "STATE_SCANNING",                                                  
+        "STATE_SELECTING",
+        "CONNECTING"     
+    };
+    
+static char *roamingMngr_eventDesc[ROAMING_MNGR_NUM_EVENTS] = {
+        "EVENT_START",        
+        "EVENT_STOP",             
+        "EVENT_ROAM_TRIGGER",         
+        "EVENT_SCAN",         
+        "EVENT_SELECT",     
+        "EVENT_REQ_HANDOVER",   
+        "EVENT_ROAM_SUCCESS",      
+        "EVENT_FAILURE"
+    };                           
+
+#endif
+
+/* Function prototypes */
+/* SM functions */
+static TI_STATUS roamingMngr_smEvent(UINT8 *currState, UINT8 event, void* data);
+static TI_STATUS roamingMngr_smUnexpected(void *pData);
+static TI_STATUS roamingMngr_smNop(void *pData);
+static TI_STATUS roamingMngr_smStartIdle(void *pData);
+static TI_STATUS roamingMngr_smStop(void *pData);
+static TI_STATUS roamingMngr_smStopWhileScanning(void *pData);
+static TI_STATUS roamingMngr_smRoamTrigger(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smInvokeScan(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smSelection(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smHandover(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smSuccHandover(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smFailHandover(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smScanFailure(TI_HANDLE hRoamingMngr);
+static TI_STATUS roamingMngr_smDisconnectWhileConnecting(TI_HANDLE hRoamingMngr);
+
+
+
+/************** callback funtions called by AP Connection **************/
+/* called when a trigger for Roaming occurs */
+TI_STATUS roamingMngr_triggerRoamingCb(TI_HANDLE hRoamingMngr, void *pData);
+/* called when CONN status event occurs */
+TI_STATUS roamingMngr_connStatusCb(TI_HANDLE hRoamingMngr, void *pData);
+/* called when Neighbor APs is updated */
+TI_STATUS roamingMngr_updateNeighborApListCb(TI_HANDLE hRoamingMngr, void *pData);
+
+/* internal functions */
+static void roamingMngr_releaseModule(roamingMngr_t *pRoamingMngr, UINT32 initVec);
+
+#ifdef TI_DBG
+/* debug function */
+static void roamingMngr_printStatistics(TI_HANDLE hRoamingMngr);
+static void roamingMngr_resetStatistics(TI_HANDLE hRoamingMngr);
+#endif
+
+
+/**
+*
+* roamingMngr_create
+*
+* \b Description: 
+*
+* Create the Roaming Manager context.
+*
+* \b ARGS:
+*
+*  I   - hOs - OS handler  \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_HANDLE roamingMngr_create(TI_HANDLE hOs)
+{
+    TI_STATUS       status;
+    roamingMngr_t   *pRoamingMngr;
+    UINT32          initVec;
+
+    initVec = 0;
+
+    pRoamingMngr = os_memoryAlloc(hOs, sizeof(roamingMngr_t));
+    if (pRoamingMngr == NULL)
+        return NULL;
+
+    initVec |= (1 << ROAMING_MNGR_CONTEXT_INIT_BIT);
+    pRoamingMngr->hOs   = hOs;
+
+    status = fsm_Create(hOs, &pRoamingMngr->pRoamingSm, ROAMING_MNGR_NUM_STATES, ROAMING_MNGR_NUM_EVENTS);
+    if (status != OK)
+    {
+        roamingMngr_releaseModule(pRoamingMngr, initVec);
+        WLAN_OS_REPORT(("FATAL ERROR: roamingMngr_create(): Error Creating pRoamingSm - Aborting\n"));
+        return NULL;
+    }
+    initVec |= (1 << ROAMING_MNGR_SM_INIT_BIT);
+
+    
+    return pRoamingMngr;
+}
+
+/**
+*
+* roamingMngr_releaseModule
+*
+* \b Description: 
+*
+* Called by the un load function
+* Go over the vector, for each bit that is set, release the corresponding module.
+*
+* \b ARGS:
+*
+*  I   - pRoamingMngr - Roaming Manager context  \n
+*  I   - initVec - indicates which modules should be released
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa roamingMngr_create
+*/
+static void roamingMngr_releaseModule(roamingMngr_t *pRoamingMngr, UINT32 initVec)
+{
+
+    if (pRoamingMngr==NULL)
+    {
+        return;
+    }
+    if (initVec & (1 << ROAMING_MNGR_SM_INIT_BIT))
+    {
+        fsm_Unload(pRoamingMngr->hOs, pRoamingMngr->pRoamingSm);
+    }
+
+    if (initVec & (1 << ROAMING_MNGR_CONTEXT_INIT_BIT))
+    {
+        utils_nullMemoryFree(pRoamingMngr->hOs, pRoamingMngr, sizeof(roamingMngr_t));
+    }
+
+    initVec = 0;
+}
+
+
+/**
+*
+* roamingMngr_unload
+*
+* \b Description: 
+*
+* Unload Roaming Manager module from memory
+*
+* \b ARGS:
+*
+*  I   - hAdmCtrl - Roaming Manager context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa roamingMngr_create
+*/
+TI_STATUS roamingMngr_unload(TI_HANDLE hRoamingMngr)
+{
+    UINT32          initVec;
+
+    if (hRoamingMngr == NULL)
+    {
+        return OK;
+    }
+
+    initVec = 0xFFFF;
+    roamingMngr_releaseModule(hRoamingMngr, initVec);
+
+    return OK;
+}
+
+/**
+*
+* roamingMngr_config
+*
+* \b Description: 
+*
+* Configure the Roaming Manager module.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - Roaming Manager context  \n
+*  I   - hReport - Report context  \n
+*  I   - hOs - OS context  \n
+*  I   - hSiteMgr - Site Manager context  \n
+*  I   - hSmeSm - SME context  \n
+*  I   - hCtrlData - Control Data context  \n
+*  I   - hPowerMgr - Power Manager context  \n
+*  I   - pRoamingParams - init roaming parameters read from the registry  \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+
+TI_STATUS roamingMngr_init(TI_HANDLE hRoamingMngr,
+                      TI_HANDLE hReport,
+                      TI_HANDLE hScanMngr,
+                      TI_HANDLE hAPConnection)
+{
+    roamingMngr_t           *pRoamingMngr;
+    TI_STATUS               status;
+#ifdef TI_DBG
+    UINT8                   index;
+#endif
+
+    /** Station broadcast key State Machine matrix */
+    fsm_actionCell_t    roamingMngr_matrix[ROAMING_MNGR_NUM_STATES][ROAMING_MNGR_NUM_EVENTS] =
+    {
+        /* next state and actions for IDLE state */
+        {   {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smStartIdle},        /* START            */
+            {ROAMING_STATE_IDLE, roamingMngr_smNop},                        /* STOP             */ 
+            {ROAMING_STATE_IDLE, roamingMngr_smNop},                        /* ROAM_TRIGGER     */
+            {ROAMING_STATE_IDLE, roamingMngr_smUnexpected},                 /* SCAN             */
+            {ROAMING_STATE_IDLE, roamingMngr_smUnexpected},                 /* SELECT           */
+            {ROAMING_STATE_IDLE, roamingMngr_smUnexpected},                 /* REQ_HANDOVER     */
+            {ROAMING_STATE_IDLE, roamingMngr_smUnexpected},                 /* ROAM_SUCCESS     */
+            {ROAMING_STATE_IDLE, roamingMngr_smUnexpected}                  /* FAILURE          */
+        },                                                                              
+
+        /* next state and actions for WAIT_4_TRIGGER state */    
+        {   {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smUnexpected},   /* START            */ 
+            {ROAMING_STATE_IDLE, roamingMngr_smStop},                   /* STOP             */ 
+            {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smRoamTrigger},      /* ROAM_TRIGGER     */ 
+            {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smUnexpected},   /* SCAN             */ 
+            {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smUnexpected},   /* SELECT           */ 
+            {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smUnexpected},   /* REQ_HANDOVER     */ 
+            {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smUnexpected},   /* ROAM_SUCCESS     */ 
+            {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smUnexpected}    /* FAILURE          */
+        },                                                                              
+    
+        /* next state and actions for WAIT_4_CMD state */    
+        {   {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smUnexpected},               /* START            */ 
+            {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smUnexpected},               /* STOP             */ 
+            {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smUnexpected},               /* ROAM_TRIGGER     */ 
+            {ROAMING_STATE_SCANNING, roamingMngr_smInvokeScan},                 /* SCAN             */ 
+            {ROAMING_STATE_SELECTING, roamingMngr_smSelection},                 /* SELECT           */ 
+            {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smUnexpected},               /* REQ_HANDOVER     */ 
+            {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smUnexpected},               /* ROAM_SUCCESS     */ 
+            {ROAMING_STATE_WAIT_4_CMD, roamingMngr_smUnexpected}                /* FAILURE          */ 
+        },                                                                              
+
+        /* next state and actions for SCANNING state */                      
+        {   {ROAMING_STATE_SCANNING, roamingMngr_smUnexpected},              /* START            */
+            {ROAMING_STATE_IDLE, roamingMngr_smStopWhileScanning},           /* STOP             */
+            {ROAMING_STATE_SCANNING, roamingMngr_smNop},                     /* ROAM_TRIGGER     */
+            {ROAMING_STATE_SCANNING, roamingMngr_smInvokeScan},              /* SCAN             */
+            {ROAMING_STATE_SELECTING, roamingMngr_smSelection},              /* SELECT           */
+            {ROAMING_STATE_SCANNING, roamingMngr_smUnexpected},              /* REQ_HANDOVER     */
+            {ROAMING_STATE_SCANNING, roamingMngr_smUnexpected},              /* ROAM_SUCCESS     */
+            {ROAMING_STATE_IDLE, roamingMngr_smScanFailure}                  /* FAILURE          */
+                                                                                   
+        }, 
+
+        /* next state and actions for SELECTING state */                      
+        {   {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected},             /* START            */
+            {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected},             /* STOP             */
+            {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected},             /* ROAM_TRIGGER     */
+            {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected},             /* SCAN             */
+            {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected},             /* SELECT           */
+            {ROAMING_STATE_CONNECTING, roamingMngr_smHandover},              /* REQ_HANDOVER     */
+            {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected},             /* ROAM_SUCCESS     */
+            {ROAMING_STATE_SELECTING, roamingMngr_smUnexpected}              /* FAILURE          */
+                                                                                   
+        }, 
+
+        /* next state and actions for CONNECTING state */                      
+        {   {ROAMING_STATE_CONNECTING, roamingMngr_smUnexpected},           /* START            */ 
+            {ROAMING_STATE_IDLE, roamingMngr_smStop},                       /* STOP             */ 
+            {ROAMING_STATE_IDLE, roamingMngr_smDisconnectWhileConnecting},      /* ROAM_TRIGGER     */ 
+            {ROAMING_STATE_CONNECTING, roamingMngr_smUnexpected},           /* SCAN,            */ 
+            {ROAMING_STATE_CONNECTING, roamingMngr_smUnexpected},           /* SELECT           */ 
+            {ROAMING_STATE_CONNECTING, roamingMngr_smHandover},             /* REQ_HANDOVER     */ 
+            {ROAMING_STATE_WAIT_4_TRIGGER, roamingMngr_smSuccHandover} ,    /* ROAM_SUCCESS     */ 
+            {ROAMING_STATE_IDLE, roamingMngr_smFailHandover}                /* FAILURE          */ 
+                                                                                   
+        } 
+
+
+
+    }; 
+
+    if (hRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+
+    /* Update handlers */
+    pRoamingMngr->hReport   = hReport;
+    pRoamingMngr->hScanMngr = hScanMngr;
+    pRoamingMngr->hAPConnection = hAPConnection;
+
+    /* Init intrenal variables */
+    pRoamingMngr->currentState = ROAMING_STATE_IDLE;
+    pRoamingMngr->roamingMngrConfig.enableDisable = ROAMING_DISABLED; 
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+    pRoamingMngr->maskRoamingEvents= TRUE;
+    pRoamingMngr->scanType = ROAMING_NO_SCAN;
+    pRoamingMngr->candidateApIndex = INVALID_CANDIDATE_INDEX;
+    pRoamingMngr->handoverWasPerformed = FALSE;
+    pRoamingMngr->lowQualityTriggerTimestamp = 0;
+    pRoamingMngr->neighborApsExist = FALSE;
+    pRoamingMngr->pListOfAPs = NULL;
+    pRoamingMngr->candidateApIndex = INVALID_CANDIDATE_INDEX;
+    pRoamingMngr->listOfCandidateAps.numOfNeighborBSS = 0;
+    pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS = 0;
+    pRoamingMngr->listOfCandidateAps.numOfRegularBSS = 0;
+
+#ifdef TI_DBG
+    /* debug counters */
+    pRoamingMngr->roamingSuccesfulHandoverNum = 0;    
+    pRoamingMngr->roamingHandoverStartedTimestamp = 0;  
+    pRoamingMngr->roamingHandoverCompletedTimestamp = 0;
+    pRoamingMngr->roamingAverageSuccHandoverDuration = 0; 
+    pRoamingMngr->roamingAverageRoamingDuration = 0;  
+    pRoamingMngr->roamingFailedHandoverNum = 0;
+
+    for (index=ROAMING_TRIGGER_NONE; index<ROAMING_TRIGGER_LAST; index++)
+    {
+        pRoamingMngr->roamingTriggerEvents[index] = 0;
+        pRoamingMngr->roamingHandoverEvents[index] = 0;
+    }
+#endif
+
+    /* config the FSM */
+    status = fsm_Config(pRoamingMngr->pRoamingSm, 
+                        &roamingMngr_matrix[0][0], 
+                        ROAMING_MNGR_NUM_STATES, 
+                        ROAMING_MNGR_NUM_EVENTS, 
+                        roamingMngr_smEvent, pRoamingMngr->hOs);
+
+    return status;
+}
+
+/* For debug */
+extern TI_STATUS apConn_reportRoamingEvent(TI_HANDLE hAPConnection,apConn_roamingTrigger_e roamingEventType,void *pRoamingEventData);
+
+/**
+*
+* roamingMngr_setParam - Set a specific parameter to the roamingMngr SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the roamingMngr SM.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_setParam(TI_HANDLE hRoamingMngr, paramInfo_t *pParam)
+{
+    roamingMngr_t       *pRoamingMngr;
+    TI_STATUS           status=OK;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+
+    if ((hRoamingMngr == NULL) || (pParam == NULL))
+    {
+        return NOK;
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_setParam   %X \n", 
+                          pParam->paramType));
+
+
+    switch (pParam->paramType)
+    {
+    
+    case ROAMING_MNGR_APPLICATION_CONFIGURATION:
+        {
+            roamingMngrConfigParams_t   *pRoamingMngrConfigParams;
+    
+            if (pParam->content.applicationConfigBuffer.bufferSize < sizeof(roamingMngrConfigParams_t))
+            {
+                WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                      ("roamingMngr_setParam bad  size = %d \n", 
+                                      pParam->content.applicationConfigBuffer.bufferSize));
+                return NOK;
+            }
+    
+            pRoamingMngrConfigParams = (roamingMngrConfigParams_t*)pParam->content.applicationConfigBuffer.buffer;
+    
+            /* Configure the Roaming Parmeters */
+            WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,("roamingMngr_setParam Configuration: \n \
+                                   enableDisable= %d,\n  lowPassFilterRoamingAttempt=%d,\n \
+                                   apQualityThreshold=%d\n", 
+                                   pRoamingMngrConfigParams->roamingMngrConfig.enableDisable,
+                                   pRoamingMngrConfigParams->roamingMngrConfig.lowPassFilterRoamingAttempt,
+                                   pRoamingMngrConfigParams->roamingMngrConfig.apQualityThreshold));
+
+            pRoamingMngr->roamingMngrConfig.apQualityThreshold = pRoamingMngrConfigParams->roamingMngrConfig.apQualityThreshold;
+            pRoamingMngr->roamingMngrConfig.lowPassFilterRoamingAttempt = pRoamingMngrConfigParams->roamingMngrConfig.lowPassFilterRoamingAttempt;
+            pRoamingMngr->lowPassFilterRoamingAttemptInMsec = pRoamingMngrConfigParams->roamingMngrConfig.lowPassFilterRoamingAttempt * 1000;
+
+            /* Configure the Roaming Trigger thresholds */
+            WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,("roamingMngr_setParam Thresholds: \n \
+                                   dataRetryThreshold= %d,\n  lowQualityForBackgroungScanCondition=%d,\n \
+                                   lowRssiThreshold=%d,\n lowSNRThreshold=%d,\n \
+                                   normalQualityForBackgroungScanCondition=%d,\n \
+                                   numExpectedTbttForBSSLoss=%d,\n txRateThreshold=%d \n \n", 
+                                   pRoamingMngrConfigParams->roamingMngrThresholdsConfig.dataRetryThreshold,
+                                   pRoamingMngrConfigParams->roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition,
+                                   pRoamingMngrConfigParams->roamingMngrThresholdsConfig.lowRssiThreshold,
+                                   pRoamingMngrConfigParams->roamingMngrThresholdsConfig.lowSnrThreshold,                                  pRoamingMngrConfigParams->roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition,
+                                   pRoamingMngrConfigParams->roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss,
+                                   pRoamingMngrConfigParams->roamingMngrThresholdsConfig.txRateThreshold));
+
+            os_memoryCopy(pRoamingMngr->hOs, &pRoamingMngr->roamingMngrThresholdsConfig, &pRoamingMngrConfigParams->roamingMngrThresholdsConfig, sizeof(roamingMngrThresholdsConfig_t));
+            
+            status = apConn_setRoamThresholds(pRoamingMngr->hAPConnection, &pRoamingMngrConfigParams->roamingMngrThresholdsConfig);
+
+            if (pRoamingMngr->roamingMngrConfig.enableDisable && 
+                !pRoamingMngrConfigParams->roamingMngrConfig.enableDisable)
+            {   /* disable Roaming Manager */
+                apConn_unregisterRoamMngrCallb(pRoamingMngr->hAPConnection);
+                pRoamingMngr->roamingMngrConfig.enableDisable = ROAMING_DISABLED;
+                return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_STOP, pRoamingMngr));
+            }
+            else if (!pRoamingMngr->roamingMngrConfig.enableDisable && 
+                pRoamingMngrConfigParams->roamingMngrConfig.enableDisable)
+            {   /* enable Roaming Manager */
+                /* Save the Roaming Configuration parameters */
+                pRoamingMngr->roamingMngrConfig.enableDisable = pRoamingMngrConfigParams->roamingMngrConfig.enableDisable;
+                /* register Roaming callback */
+                apConn_registerRoamMngrCallb(pRoamingMngr->hAPConnection, 
+                                             roamingMngr_triggerRoamingCb,
+                                             roamingMngr_connStatusCb,
+                                             roamingMngr_updateNeighborApListCb);
+            }
+        }
+        break;
+
+    /*********** For Debug Purposes ***********/
+
+    case ROAMING_MNGR_TRIGGER_EVENT:
+        /* Enable/disable Internal Roaming */
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_setParam TRIGGER_EVENT=  %d \n", 
+                              pParam->content.roamingTriggerType));
+        apConn_reportRoamingEvent(pRoamingMngr->hAPConnection, (apConn_roamingTrigger_e)pParam->content.roamingTriggerType, NULL);
+        break;
+    
+    case ROAMING_MNGR_CONN_STATUS:
+        /* External request to connect to BBSID */
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_setParam CONN_STATUS=  %d \n",
+                               pParam->content.roamingConnStatus));
+        roamingMngr_connStatusCb(pRoamingMngr, &pParam->content.roamingConnStatus);
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_setParam bad param=  %X\n", 
+                              pParam->paramType));
+
+        break;
+    }
+
+
+    return status;
+}
+
+/**
+*
+* roamingMngr_getParam - Get a specific parameter from the roamingMngr SM
+*
+* \b Description: 
+*
+* Get a specific parameter from the roamingMngr SM.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_getParam(TI_HANDLE hRoamingMngr, paramInfo_t *pParam)
+{
+    roamingMngr_t       *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+
+    if ((hRoamingMngr == NULL) || (pParam == NULL))
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_getParam   %X \n", 
+                          pParam->paramType));
+
+    switch (pParam->paramType)
+    {
+    case ROAMING_MNGR_APPLICATION_CONFIGURATION:
+        {
+            roamingMngrConfigParams_t   *pRoamingMngrConfigParams;
+    
+            pRoamingMngrConfigParams = (roamingMngrConfigParams_t *)&pParam->content.roamingConfigBuffer;
+    
+            if (pRoamingMngr->roamingMngrConfig.enableDisable == ROAMING_DISABLED) 
+            {   
+                pRoamingMngrConfigParams->roamingMngrConfig.enableDisable = FALSE;
+            }
+            else 
+            {
+                pRoamingMngrConfigParams->roamingMngrConfig.enableDisable = TRUE;
+            }
+            pRoamingMngrConfigParams->roamingMngrConfig.apQualityThreshold = pRoamingMngr->roamingMngrConfig.apQualityThreshold;
+            pRoamingMngrConfigParams->roamingMngrConfig.lowPassFilterRoamingAttempt = pRoamingMngr->roamingMngrConfig.lowPassFilterRoamingAttempt;
+
+            apConn_getRoamThresholds(pRoamingMngr->hAPConnection, &pRoamingMngr->roamingMngrThresholdsConfig);
+            os_memoryCopy(pRoamingMngr->hOs, &pRoamingMngrConfigParams->roamingMngrThresholdsConfig, &pRoamingMngr->roamingMngrThresholdsConfig, sizeof(roamingMngrThresholdsConfig_t));
+            pParam->paramLength = sizeof(roamingMngrConfigParams_t);
+        }
+        break;
+
+    case ROAMING_MNGR_CONF_PARAM:
+        WLAN_OS_REPORT(("Roaming is: %s \n", pRoamingMngr->roamingMngrConfig.enableDisable ? "Enabled" : "Disabled"));
+        WLAN_OS_REPORT(("lowPassFilterRoamingAttempt = %d msec, apQualityThreshold = %d\n", 
+               pRoamingMngr->roamingMngrConfig.lowPassFilterRoamingAttempt,
+               pRoamingMngr->roamingMngrConfig.apQualityThreshold));
+        break;
+#ifdef TI_DBG
+    case ROAMING_MNGR_PRINT_STATISTICS:
+        roamingMngr_printStatistics(pRoamingMngr);
+        break;
+
+    case ROAMING_MNGR_RESET_STATISTICS:
+        roamingMngr_resetStatistics(pRoamingMngr);
+        break;
+
+    case ROAMING_MNGR_PRINT_CURRENT_STATUS:
+        WLAN_OS_REPORT(("Roaming Current State = %s, enableDisable=%d\n, maskRoamingEvents = %d, roamingTrigger=%d \n scanType=%d, handoverWasPerformed=%d \n, candidateApIndex=%d, lowQualityTriggerTimestamp=%d \n",
+                        roamingMngr_stateDesc[pRoamingMngr->currentState],
+                        pRoamingMngr->roamingMngrConfig.enableDisable,
+                        pRoamingMngr->maskRoamingEvents,
+                        pRoamingMngr->roamingTrigger,
+                        pRoamingMngr->scanType,
+                        pRoamingMngr->handoverWasPerformed,
+                        pRoamingMngr->candidateApIndex,
+                        pRoamingMngr->lowQualityTriggerTimestamp));
+        break;
+    case ROAMING_MNGR_PRINT_CANDIDATE_TABLE:
+        {
+            UINT32      index;
+
+            if (pRoamingMngr->pListOfAPs==NULL)
+            {
+                WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                         ("Roaming Mngr the candidate AP list is invalid \n") );
+                break;
+            }
+            WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                     ("The number of candidates is %d\n",
+                                      pRoamingMngr->pListOfAPs->numOfEntries) );
+
+            WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                     ("Roaming Mngr Neighbor AP list, num of candidates = %d\n",
+                                      pRoamingMngr->listOfCandidateAps.numOfNeighborBSS) );
+
+            for (index=0; index<pRoamingMngr->listOfCandidateAps.numOfNeighborBSS; index++)
+            {
+                UINT32  candidateIndex;
+                bssEntry_t  *pBssEntry;
+
+                candidateIndex = pRoamingMngr->listOfCandidateAps.neighborBSSList[index];
+                pBssEntry = &pRoamingMngr->pListOfAPs->BSSList[candidateIndex];
+                WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                         ("candiate %d, BSSID=%x-%x-%x-%x-%x-%x, RSSI =%d \n", 
+                                          candidateIndex, pBssEntry->BSSID.addr[0], 
+                                          pBssEntry->BSSID.addr[1], pBssEntry->BSSID.addr[2],
+                                          pBssEntry->BSSID.addr[3], pBssEntry->BSSID.addr[4],
+                                          pBssEntry->BSSID.addr[5], pBssEntry->RSSI) );
+            }
+            WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                     ("Roaming Mngr Pre-Auth AP list, num of candidates = %d\n",
+                                      pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS) );
+
+            for (index=0; index<pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS; index++)
+            {
+                UINT32  candidateIndex;
+                bssEntry_t  *pBssEntry;
+
+                candidateIndex = pRoamingMngr->listOfCandidateAps.preAuthBSSList[index];
+                pBssEntry = &pRoamingMngr->pListOfAPs->BSSList[candidateIndex];
+                WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                         ("candiate %d, BSSID=%x-%x-%x-%x-%x-%x, RSSI =%d \n", 
+                                          candidateIndex, pBssEntry->BSSID.addr[0], 
+                                          pBssEntry->BSSID.addr[1], pBssEntry->BSSID.addr[2],
+                                          pBssEntry->BSSID.addr[3], pBssEntry->BSSID.addr[4], 
+                                          pBssEntry->BSSID.addr[5], pBssEntry->RSSI) );
+            }
+            WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                     ("Roaming Mngr Regular AP list, num of candidates = %d\n",
+                                      pRoamingMngr->listOfCandidateAps.numOfRegularBSS) );
+
+            for (index=0; index<pRoamingMngr->listOfCandidateAps.numOfRegularBSS; index++)
+            {
+                UINT32  candidateIndex;
+                bssEntry_t  *pBssEntry;
+
+                candidateIndex = pRoamingMngr->listOfCandidateAps.regularBSSList[index];
+                pBssEntry = &pRoamingMngr->pListOfAPs->BSSList[candidateIndex];
+                WLAN_REPORT_INFORMATION( pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                         ("candiate %d, BSSID=%x-%x-%x-%x-%x-%x, RSSI =%d \n", 
+                                          candidateIndex, pBssEntry->BSSID.addr[0], 
+                                          pBssEntry->BSSID.addr[1], pBssEntry->BSSID.addr[2],
+                                          pBssEntry->BSSID.addr[3], pBssEntry->BSSID.addr[4],
+                                          pBssEntry->BSSID.addr[5], pBssEntry->RSSI) );
+            }
+        }
+        break;
+
+#endif /*TI_DBG*/
+
+    default:
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_getParam  bad paramType= %X \n", 
+                              pParam->paramType));
+        return NOK;
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* roamingMngr_triggerRoamingCb 
+*
+* \b Description: 
+*
+* This procedure is called when Roaming should be triggered
+ * due to one of apConn_roamingTrigger_e Roaming Reasons.
+ * Save the trigger and process it only if there's no other Roaming trigger
+ * in process.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I   - pData - pointer to roaming trigger
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_triggerRoamingCb(TI_HANDLE hRoamingMngr, void *pData)
+{
+    roamingMngr_t       *pRoamingMngr;
+    apConn_roamingTrigger_e     roamingTrigger;
+    UINT32                      curTimestamp;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if ((pRoamingMngr == NULL) || (pData == NULL))
+    {
+        return NOK;
+    }
+
+    roamingTrigger = *(apConn_roamingTrigger_e *)pData;
+
+    if (roamingTrigger >= ROAMING_TRIGGER_LAST)
+    {
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_triggerRoamingCb, bad roaming trigger = %d\n", roamingTrigger)); 
+        return NOK;
+    }
+#ifdef TI_DBG
+    /* save parameters for debug*/
+    pRoamingMngr->roamingTriggerEvents[pRoamingMngr->roamingTrigger]++;
+#endif
+    if (roamingTrigger <= ROAMING_TRIGGER_BG_SCAN_GROUP)
+    {
+        BOOL    lowQuality = FALSE;
+        if (roamingTrigger == ROAMING_TRIGGER_LOW_QUALITY_FOR_BG_SCAN)
+        {
+            lowQuality = TRUE;
+        }
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_triggerRoamingCb, lowQuality = %d \n", 
+                       lowQuality)); 
+        scanMngr_qualityChangeTrigger(pRoamingMngr->hScanMngr, lowQuality);
+    }
+    else
+    {
+        if (roamingTrigger > pRoamingMngr->roamingTrigger)
+        {   /* Save the highest priority roaming trigger */
+            pRoamingMngr->roamingTrigger = roamingTrigger;
+            WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_triggerRoamingCb, higher trigger = %d \n", 
+                           roamingTrigger)); 
+
+        }
+
+        curTimestamp = os_timeStampMs(pRoamingMngr->hOs);
+
+        /* If "No BSS" trigger received, disable count of low pass filter timer */
+        if (roamingTrigger > ROAMING_TRIGGER_LOW_QUALITY_GROUP)
+        {
+            pRoamingMngr->lowQualityTriggerTimestamp = 0;
+        }
+
+        /* Do not invoke a new Roaming Trigger when a previous one is in process */
+        if (pRoamingMngr->maskRoamingEvents == FALSE)
+        {   /* No Roaming trigger is in process */
+            /* If the trigger is low quality check the low pass filter */
+            WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_triggerRoamingCb, trigger = %d \n", 
+                       roamingTrigger)); 
+            if (roamingTrigger <= ROAMING_TRIGGER_LOW_QUALITY_GROUP)
+            {
+                UINT32 deltaTs = curTimestamp-pRoamingMngr->lowQualityTriggerTimestamp;
+
+                if ((pRoamingMngr->lowQualityTriggerTimestamp != 0) &&
+                    (deltaTs < pRoamingMngr->lowPassFilterRoamingAttemptInMsec))
+                {  /* Ignore the low quality events. till the low pass time elapses */
+                    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                  ("roamingMngr_triggerRoamingCb, trigger = %d Ignored!!,deltaTs=%d, curTimestamp = %d, lowQualityTriggerTimestamp = %d, lowPassFilterRoamingAttempt=%d\n", 
+                                   roamingTrigger, deltaTs, curTimestamp, pRoamingMngr->lowQualityTriggerTimestamp, pRoamingMngr->lowPassFilterRoamingAttemptInMsec)); 
+                    return OK;
+                }
+                pRoamingMngr->lowQualityTriggerTimestamp = curTimestamp;
+            }
+
+            /* Mask all future roaming events */
+            pRoamingMngr->maskRoamingEvents = TRUE;
+
+#ifdef TI_DBG
+            /* For debug */
+            pRoamingMngr->roamingTriggerTimestamp = curTimestamp;
+#endif
+            return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_ROAM_TRIGGER, pRoamingMngr));  
+        }
+        else if (roamingTrigger > ROAMING_TRIGGER_FAST_CONNECT_GROUP)
+        {   /* If the trigger is from the Full Connect group, then stop the connection. */
+            return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_ROAM_TRIGGER, pRoamingMngr));  
+            
+        }
+    }
+
+    return OK;
+}
+
+/**
+*
+* roamingMngr_connStatusCb 
+*
+* \b Description: 
+*
+* This procedure is called when the connection status event
+ * is triggered.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I   - pData - pointer to the connection status.
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_connStatusCb(TI_HANDLE hRoamingMngr, void *pData)
+{
+    roamingMngr_t               *pRoamingMngr;
+    apConn_connStatus_e         connStatus;
+    roamingMngr_smEvents        roamingEvent;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if ((pRoamingMngr == NULL) || (pData == NULL))
+    {
+        return NOK;
+    }
+
+    connStatus = ((apConn_connStatus_t *)pData)->status;
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_connStatusCb, conn status = %d\n", connStatus)); 
+
+    if (!pRoamingMngr->roamingMngrConfig.enableDisable)
+    {
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_connStatusCb, connStatus=%d was received while Roaming is disabled. Stop Roaming \n", 
+                               connStatus));
+        return NOK;
+    }
+
+    switch (connStatus)
+    {
+    case CONN_STATUS_CONNECTED: roamingEvent = ROAMING_EVENT_START;
+        /* Get station capabilities */
+        apConn_getStaCapabilities(pRoamingMngr->hAPConnection, &pRoamingMngr->staCapabilities); 
+        break;     
+    case CONN_STATUS_NOT_CONNECTED: roamingEvent = ROAMING_EVENT_STOP;
+        break;
+    case CONN_STATUS_HANDOVER_SUCCESS: roamingEvent = ROAMING_EVENT_ROAM_SUCCESS;
+#ifdef TI_DBG
+        /* For debug */
+        pRoamingMngr->roamingSuccesfulHandoverNum++;
+        pRoamingMngr->roamingHandoverCompletedTimestamp = os_timeStampMs(pRoamingMngr->hOs);
+        pRoamingMngr->roamingAverageSuccHandoverDuration += os_timeStampMs(pRoamingMngr->hOs)-pRoamingMngr->roamingHandoverStartedTimestamp;
+        pRoamingMngr->roamingAverageRoamingDuration +=  os_timeStampMs(pRoamingMngr->hOs)-pRoamingMngr->roamingTriggerTimestamp;
+        pRoamingMngr->roamingHandoverEvents[pRoamingMngr->roamingTrigger]++;
+#endif
+        break;
+    case CONN_STATUS_HANDOVER_FAILURE: roamingEvent = ROAMING_EVENT_REQ_HANDOVER;
+#ifdef TI_DBG
+        /* For debug */
+        pRoamingMngr->roamingFailedHandoverNum++;
+#endif
+        break;
+    default:
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_connStatusCb, bad connStatus = %d\n", connStatus)); 
+        return NOK;
+/*        break; - unreachable */
+    }
+
+    return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, roamingEvent, pRoamingMngr));
+
+
+}
+
+
+
+
+
+/**
+*
+* roamingMngr_updateNeighborApListCb 
+*
+* \b Description: 
+*
+* This procedure is called when Neighbor AP list is received from the AP.
+ * Save the list, and set them in Scan Manager object.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I   - pData - pointer to the list of Neighbor APs.
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_updateNeighborApListCb(TI_HANDLE hRoamingMngr, void *pData)
+{
+    roamingMngr_t           *pRoamingMngr;
+    neighborAPList_t        *pNeighborAPList;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if ((pRoamingMngr == NULL) || (pData == NULL))
+    {
+        return NOK;
+    }
+
+    pNeighborAPList = (neighborAPList_t *)pData;
+    if (pNeighborAPList->numOfEntries>0)
+    {
+        pRoamingMngr->neighborApsExist = TRUE;
+    }
+    else
+    {
+        pRoamingMngr->neighborApsExist = FALSE;
+    }
+    
+    if (pRoamingMngr->roamingMngrConfig.enableDisable)
+    {
+        scanMngr_setNeighborAPs (pRoamingMngr->hScanMngr, pNeighborAPList);
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_updateNeighborApListCb, numberOfAps = %d, enableDisable=%d\n", 
+                       pNeighborAPList->numOfEntries, pRoamingMngr->roamingMngrConfig.enableDisable)); 
+
+    return OK;
+}
+
+/**
+*
+* roamingMngr_immediateScanComplete 
+*
+* \b Description: 
+*
+* This procedure is called when Scan Manager completed Immediate Scan for Roaming
+ * It performs the following:
+ * - Partial or Full scan
+ * - Re-try Partial or Full scan if the previous scan failed
+ * - Full scan if the previous partial scan didn't get any APS
+ * - Fail event if all the Scans failed
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I   - scanCmpltStatus - the scan result, success or failure with different reasons
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_immediateScanComplete(TI_HANDLE hRoamingMngr, scan_mngrResultStatus_e scanCmpltStatus)
+{
+    roamingMngr_t           *pRoamingMngr;
+    roamingMngr_smEvents    roamingEvent;
+
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_immediateScanComplete, scanCmpltStatus = %d\n", scanCmpltStatus)); 
+
+    if (scanCmpltStatus == SCAN_MRS_SCAN_COMPLETE_OK)
+    {   /* The scan completed OK, get the updated list of APs */
+        pRoamingMngr->pListOfAPs = scanMngr_getBSSList(pRoamingMngr->hScanMngr);
+        if ((pRoamingMngr->pListOfAPs != NULL) && (pRoamingMngr->pListOfAPs->numOfEntries > 0))
+        {   /* APs were found, start selection */
+            pRoamingMngr->scanType = ROAMING_NO_SCAN;
+            roamingEvent = ROAMING_EVENT_SELECT;
+        }
+        else
+        {   /* There were no APs, if the scan was partial, retry full scan */
+            if ((pRoamingMngr->scanType == ROAMING_PARTIAL_SCAN) ||
+                (pRoamingMngr->scanType == ROAMING_PARTIAL_SCAN_RETRY))
+            {
+                pRoamingMngr->scanType = ROAMING_FULL_SCAN;
+                roamingEvent = ROAMING_EVENT_SCAN;
+            }
+            else
+            {   /* No APs were found in FULL SCAN, report failure */
+                roamingEvent = ROAMING_EVENT_SELECT;
+            }
+        }
+    }
+    else
+    {   /* The scan failed, retry scanning according to the current scan type */
+        pRoamingMngr->pListOfAPs = scanMngr_getBSSList(pRoamingMngr->hScanMngr);
+        if ((pRoamingMngr->pListOfAPs != NULL) && (pRoamingMngr->pListOfAPs->numOfEntries > 0))
+        {   /* APs were found, start selection */
+            pRoamingMngr->scanType = ROAMING_NO_SCAN;
+            roamingEvent = ROAMING_EVENT_SELECT;
+        }
+        else
+        {   /* The scan failed, and there were no APs found. 
+                Retry scanning according to the current scan type */
+        switch (pRoamingMngr->scanType)
+        {
+        case ROAMING_PARTIAL_SCAN:
+            roamingEvent = ROAMING_EVENT_SCAN;
+            pRoamingMngr->scanType = ROAMING_PARTIAL_SCAN_RETRY;
+            break;
+        case ROAMING_PARTIAL_SCAN_RETRY:
+            roamingEvent = ROAMING_EVENT_SELECT;
+            pRoamingMngr->scanType = ROAMING_NO_SCAN;
+            break;
+        case ROAMING_FULL_SCAN:
+            roamingEvent = ROAMING_EVENT_SCAN;
+            pRoamingMngr->scanType = ROAMING_FULL_SCAN_RETRY;
+            break;
+        case ROAMING_FULL_SCAN_RETRY:
+                roamingEvent = ROAMING_EVENT_SELECT;
+            pRoamingMngr->scanType = ROAMING_NO_SCAN;
+            break;
+        default:
+            roamingEvent = ROAMING_EVENT_SELECT;
+            WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_immediateScanComplete, pRoamingMngr->scanType = %d\n", pRoamingMngr->scanType)); 
+            pRoamingMngr->scanType = ROAMING_NO_SCAN;       
+            break;
+            }
+
+        }
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_immediateScanComplete, roamingEvent = %d, scanType=%d\n", 
+                       roamingEvent, pRoamingMngr->scanType)); 
+
+    return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, roamingEvent, pRoamingMngr));
+
+    
+}
+
+
+/* called by the Scan Manager when new BSSID was found */
+/**
+*
+* roamingMngr_updateNewBssList 
+*
+* \b Description: 
+*
+* This procedure is called when Scan Manager finds new BSSIDs.
+* These BSSIDs are sent to RSn to invoke Pre-Auth if allowed.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*  I   - bssList - list of BSSIDs
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+TI_STATUS roamingMngr_updateNewBssList(TI_HANDLE hRoamingMngr, bssList_t *bssList)
+{
+
+    roamingMngr_t       *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if ((pRoamingMngr == NULL) || (bssList == NULL))
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_updateNewBssList, number of APs = %d\n", bssList->numOfEntries)); 
+
+    if (pRoamingMngr->currentState != ROAMING_STATE_WAIT_4_TRIGGER)
+    {
+        WLAN_REPORT_WARNING(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_updateNewBssList, ignore APs when not in WAIT_4_TRIGGER state \n")); 
+        return NOK;
+    }
+
+
+    if (pRoamingMngr->staCapabilities.authMode!=os802_11AuthModeWPA2)
+    {   /* No Pre-Auth is required */
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_updateNewBssList, No Pre-Auth is required\n")); 
+        return OK;
+    }
+    apConn_preAuthenticate(pRoamingMngr->hAPConnection, bssList);
+
+    return OK;
+
+}
+
+
+/*****************************************************************************
+**         Private Function section                                      **
+*****************************************************************************/
+
+
+
+/**
+*
+* roamingMngr_smEvent
+*
+* \b Description: 
+*
+* Roaming Manager state machine transition function
+*
+* \b ARGS:
+*
+*  I/O - currentState - current state in the state machine\n
+*  I   - event - specific event for the state machine\n
+*  I   - pData - Data for state machine action function\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS roamingMngr_smEvent(UINT8 *currState, UINT8 event, void* data)
+{
+    TI_STATUS       status;
+    UINT8           nextState;
+    roamingMngr_t   *pRoamingMngr = (roamingMngr_t*)data;
+
+
+    status = fsm_GetNextState(pRoamingMngr->pRoamingSm, *currState, event, &nextState);
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, ("roamingMngr_smEvent, fsm_GetNextState error\n"));
+        return(NOK);
+    }
+
+#ifdef TI_DBG
+    WLAN_REPORT_SM(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("<%s, %s> --> %s\n\n",
+                               roamingMngr_stateDesc[*currState],
+                               roamingMngr_eventDesc[event],
+                               roamingMngr_stateDesc[nextState]));
+#endif
+
+    status = fsm_Event(pRoamingMngr->pRoamingSm, currState, event, (void *)pRoamingMngr);
+
+#ifdef TI_DBG
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, ("roamingMngr_smEvent fsm_Event error\n"));
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                  ("<%s, %s> --> %s\n\n",
+                                   roamingMngr_stateDesc[*currState],
+                                   roamingMngr_eventDesc[event],
+                                   roamingMngr_stateDesc[nextState]));
+    }
+#endif
+
+    return status;
+
+}
+
+/**
+*
+* roamingMngr_smRoamTrigger 
+*
+* \b Description: 
+*
+* This procedure is called when an Roaming event occurs: BSS LOSS, LOW Quality etc.
+ * Performs the following:
+ * - If Roaming is disabled, ignore.
+ * - Indicate Driver that Roaming process is starting
+ * - Get the BSS list from the Scan Manager.
+ * - If the list is not empty, start SELECTION
+ * - If the list is empty, start SCANNING. The type of scan is decided
+ *      according to the Neigbor APs existence.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smRoamTrigger(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+    roamingMngr_smEvents    roamingEvent;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                ("roamingMngr_smRoamTrigger, enableDisable = %d\n",pRoamingMngr->roamingMngrConfig.enableDisable));
+
+
+    if (!pRoamingMngr->roamingMngrConfig.enableDisable)
+    {   /* Ignore any other Roaming event when Roaming is disabled */
+        WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                    ("roamingMngr_smRoamTrigger, when Roaming is disabled\n"));
+        return OK;
+    }
+    /* Indicate the driver that Roaming process is starting */
+    apConn_prepareToRoaming(pRoamingMngr->hAPConnection, pRoamingMngr->roamingTrigger);
+
+    /* Get the current BSSIDs from ScanMngr */
+    pRoamingMngr->pListOfAPs = scanMngr_getBSSList(pRoamingMngr->hScanMngr);
+    if ((pRoamingMngr->pListOfAPs != NULL) && (pRoamingMngr->pListOfAPs->numOfEntries > 0))
+    {   /* No need to SCAN, start SELECTING */
+        roamingEvent = ROAMING_EVENT_SELECT;
+    } 
+    else
+    {   /* check if list of APs exists in order to verify which scan to start */
+        roamingEvent = ROAMING_EVENT_SCAN;
+        if (pRoamingMngr->neighborApsExist)
+        {   /* Scan only Neighbor APs */
+            pRoamingMngr->scanType = ROAMING_PARTIAL_SCAN;
+        }
+        else
+        {   /* Scan all channels */
+            pRoamingMngr->scanType = ROAMING_FULL_SCAN;
+        }
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                ("roamingMngr_smRoamTrigger, scanType = %d\n", pRoamingMngr->scanType));
+
+    return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, roamingEvent, pRoamingMngr));
+}
+
+/**
+*
+* roamingMngr_smInvokeScan 
+*
+* \b Description: 
+*
+* This procedure is called when scan should be performed in order
+ * to select an AP to roam to.
+ * This can be the first scan, a second scan after partail scan,
+ * or scan after previous scan was failed.
+ * In any case, the scan can either be:
+ *  partail, on list of channles or
+ *  full on all channels.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smInvokeScan(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t       *pRoamingMngr;
+    scan_mngrResultStatus_e     scanResult;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    /* check which scan should be performed: Partial on list of channels, or full scan */
+    if ((pRoamingMngr->scanType == ROAMING_PARTIAL_SCAN) ||
+        (pRoamingMngr->scanType == ROAMING_PARTIAL_SCAN_RETRY))
+    {
+        scanResult = scanMngr_startImmediateScan (pRoamingMngr->hScanMngr, TRUE);
+    }
+    else
+    {    /* Scan all channels */
+        scanResult = scanMngr_startImmediateScan (pRoamingMngr->hScanMngr, FALSE);
+    }
+   
+    if (scanResult != SCAN_MRS_SCAN_RUNNING)
+    {   /* the scan failed, immitate scan complete event */
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                    ("roamingMngr_smInvokeScan, scanResult = %d\n", scanResult));
+        roamingMngr_immediateScanComplete(pRoamingMngr, scanResult);
+    }
+    return OK;
+
+}
+
+/**
+*
+* roamingMngr_smSelection 
+*
+* \b Description: 
+*
+* This procedure is called when selection should be performed.
+*   It perform the following:
+ * Prepare the candidate APs to roam according to:
+ *  - Priority APs
+ *  - Pre-Authenticated APs
+ * If the candidate AP list is empty, only the current AP can be re-selected
+ * Select one AP and trigger REQ_HANDOVER event.
+ * 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smSelection(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t               *pRoamingMngr;
+    UINT32                      index;
+
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+
+    pRoamingMngr->listOfCandidateAps.numOfNeighborBSS = 0;
+    pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS = 0;
+    pRoamingMngr->listOfCandidateAps.numOfRegularBSS = 0;
+
+    pRoamingMngr->candidateApIndex = INVALID_CANDIDATE_INDEX;
+
+    if ((pRoamingMngr->pListOfAPs == NULL) || 
+        (pRoamingMngr->pListOfAPs->numOfEntries == 0))
+    {   /* Error, there cannot be selection  */
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_smSelection pListOfAPs is empty \n"));
+        return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_REQ_HANDOVER, pRoamingMngr));
+    }
+
+    /* Build the candidate AP list */
+    for (index=0; index<pRoamingMngr->pListOfAPs->numOfEntries; index++ )
+    {
+        if ( (pRoamingMngr->roamingTrigger <= ROAMING_TRIGGER_LOW_QUALITY_GROUP) &&
+            (pRoamingMngr->pListOfAPs->BSSList[index].RSSI < pRoamingMngr->roamingMngrConfig.apQualityThreshold))
+        {   /* Do not insert APs with low quality to the selection table, 
+                if the Roaming Trigger was low Quality */
+            WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("candidate AP %x-%x-%x-%x-%x-%x with RSSI too low =%d, Quality=%d  \n",
+                               pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[0],
+                               pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[1],
+                               pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[2],
+                               pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[3],
+                               pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[4],
+                               pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[5],
+                               pRoamingMngr->pListOfAPs->BSSList[index].RSSI,
+                               pRoamingMngr->roamingMngrConfig.apQualityThreshold));
+
+            continue;
+        }
+
+        if (apConn_isSiteBanned(pRoamingMngr->hAPConnection, &pRoamingMngr->pListOfAPs->BSSList[index].BSSID) == TRUE)
+        {
+            WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG,
+                    ("%s: Candidate AP %02X-%02X-%02X-%02X-%02X-%02X is banned!\n", __FUNCTION__,
+                            pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[0],
+                            pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[1],
+                            pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[2],
+                            pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[3],
+                            pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[4],
+                            pRoamingMngr->pListOfAPs->BSSList[index].BSSID.addr[5]));
+            continue;
+        }
+
+        if (pRoamingMngr->pListOfAPs->BSSList[index].bNeighborAP)
+        {   /* The AP is a neighbor AP, insert its index to the neighbor APs list */
+            pRoamingMngr->listOfCandidateAps.neighborBSSList[pRoamingMngr->listOfCandidateAps.numOfNeighborBSS] = index; 
+            pRoamingMngr->listOfCandidateAps.numOfNeighborBSS++;
+        }
+        else if (apConn_getPreAuthAPStatus(pRoamingMngr->hAPConnection, 
+                        &pRoamingMngr->pListOfAPs->BSSList[index].BSSID))
+        {   /* This AP is a pre-auth AP */
+            pRoamingMngr->listOfCandidateAps.preAuthBSSList[pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS] = index; 
+            pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS++;
+        }
+        else
+        {   /* This AP is not Neighbor nor Pre-Auth */
+            pRoamingMngr->listOfCandidateAps.regularBSSList[pRoamingMngr->listOfCandidateAps.numOfRegularBSS] = index; 
+            pRoamingMngr->listOfCandidateAps.numOfRegularBSS++;
+        }
+    }
+
+#ifdef TI_DBG
+    {   /* for debug */
+        paramInfo_t     param;
+
+        param.paramType = ROAMING_MNGR_PRINT_CANDIDATE_TABLE;
+        roamingMngr_getParam(pRoamingMngr, &param);
+
+    }
+#endif
+    return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_REQ_HANDOVER, pRoamingMngr));
+
+}
+
+
+
+/**
+*
+* roamingMngr_smHandover 
+*
+* \b Description: 
+*
+* This procedure is called when handover should be invoked.
+*   Go over the candidate APs and start handover to each of them. 
+ * If there's no candidate APs, disconnect.
+ * Handover to the current AP is allowed only if the trigger is
+ * low quality.
+ * 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smHandover(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+    bssEntry_t              *pApToConnect;
+    apConn_connRequest_t    requestToApConn;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+
+    if ((pRoamingMngr->handoverWasPerformed) && (pRoamingMngr->candidateApIndex == CURRENT_AP_INDEX))
+    {   /* Handover with the current AP already failed, Disconnect */
+        return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_FAILURE, pRoamingMngr));
+    }
+    if (pRoamingMngr->listOfCandidateAps.numOfNeighborBSS > 0)
+    {   /* Neighbor APs are the highest priority to Roam */
+        pRoamingMngr->candidateApIndex = 
+            pRoamingMngr->listOfCandidateAps.neighborBSSList[pRoamingMngr->listOfCandidateAps.numOfNeighborBSS-1];
+        pRoamingMngr->listOfCandidateAps.numOfNeighborBSS--;
+    }
+    else if (pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS > 0)
+    {   /* Pre-Auth APs are the second priority to Roam */
+        pRoamingMngr->candidateApIndex = 
+            pRoamingMngr->listOfCandidateAps.preAuthBSSList[pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS-1];
+        pRoamingMngr->listOfCandidateAps.numOfPreAuthBSS--;
+    }
+    else if (pRoamingMngr->listOfCandidateAps.numOfRegularBSS > 0)
+    {   /* Regular APs are APs that are not pre-authenticated and not Neighbor */
+        pRoamingMngr->candidateApIndex = 
+            pRoamingMngr->listOfCandidateAps.regularBSSList[pRoamingMngr->listOfCandidateAps.numOfRegularBSS-1];
+        pRoamingMngr->listOfCandidateAps.numOfRegularBSS--;
+    }
+    else
+    {   /* No Candidate APs */
+        pRoamingMngr->candidateApIndex = INVALID_CANDIDATE_INDEX;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smHandover, candidateApIndex=%d \n", pRoamingMngr->candidateApIndex));
+
+
+    if (pRoamingMngr->candidateApIndex == INVALID_CANDIDATE_INDEX)
+    {   /* No cnadidate to Roam to, only the current AP is candidate */
+        if (pRoamingMngr->roamingTrigger <= ROAMING_TRIGGER_LOW_QUALITY_GROUP)
+        {   /* If the trigger to Roam is low quality, and there are no candidate APs
+                to roam to, retain connected to the current AP */
+            requestToApConn.requestType = (pRoamingMngr->handoverWasPerformed) ? AP_CONNECT_RECONNECT_CURR_AP : AP_CONNECT_RETAIN_CURR_AP;
+            pRoamingMngr->candidateApIndex = CURRENT_AP_INDEX;
+        }
+        else
+        {   /* Disconnect the BSS, there are no more APs to roam to */
+            return (roamingMngr_smEvent((UINT8*)&pRoamingMngr->currentState, ROAMING_EVENT_FAILURE, pRoamingMngr));
+        }
+    }
+    else
+    {   /* There is a valid candidate AP */
+        if (pRoamingMngr->roamingTrigger > ROAMING_TRIGGER_FAST_CONNECT_GROUP)
+        {   /* Full re-connection should be perfromed */
+            requestToApConn.requestType = AP_CONNECT_FULL_TO_AP; 
+        }
+        else
+        {   /* Fast re-connection should be perfromed */
+            requestToApConn.requestType = AP_CONNECT_FAST_TO_AP; 
+        }
+    }
+#ifdef TI_DBG
+    /* For debug */
+    if (!pRoamingMngr->handoverWasPerformed)
+    {   /* Take the time before the first handover started */
+        pRoamingMngr->roamingHandoverStartedTimestamp = os_timeStampMs(pRoamingMngr->hOs);
+    }
+#endif
+    
+    if (pRoamingMngr->candidateApIndex == CURRENT_AP_INDEX)
+    {   /* get the current AP */
+        pApToConnect = apConn_getBSSParams(pRoamingMngr->hAPConnection);
+    }
+    else
+    {   /* get the candidate AP */
+        pRoamingMngr->handoverWasPerformed = TRUE;
+        pApToConnect = &pRoamingMngr->pListOfAPs->BSSList[pRoamingMngr->candidateApIndex];
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smHandover, candidateApIndex=%d, requestType = %d, channel=%d \n", 
+                       pRoamingMngr->candidateApIndex, requestToApConn.requestType, pApToConnect->channel));
+
+    requestToApConn.dataBufLength = 0;
+    return (apConn_connectToAP(pRoamingMngr->hAPConnection, pApToConnect, &requestToApConn, TRUE));
+}
+
+
+
+/**
+*
+* roamingMngr_smDisconnectWhileConnecting 
+*
+* \b Description: 
+*
+* This procedure is called when the Station is in the process of connection,
+ * and the AP disconnects the station. 
+ * 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smDisconnectWhileConnecting(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smDisconnectWhileConnecting, candidateApIndex=%d \n", pRoamingMngr->candidateApIndex));
+
+    if (pRoamingMngr->roamingTrigger > ROAMING_TRIGGER_FAST_CONNECT_GROUP)
+    {   /* If the trigger is from the Full Connect group, then stop the connection. */
+        /* clean intenal variables */
+        pRoamingMngr->maskRoamingEvents = TRUE;
+        pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+        scanMngr_stopContScan(pRoamingMngr->hScanMngr);
+#ifdef TI_DBG
+        pRoamingMngr->roamingFailedHandoverNum++;
+#endif
+        return (apConn_disconnect(pRoamingMngr->hAPConnection));
+        
+    }
+
+    return OK;
+
+}
+
+/**
+*
+* roamingMngr_smSuccHandover 
+*
+* \b Description: 
+*
+* This procedure is called when handover succeeded.
+ * Inform Scan Manager about the new AP.    
+ * UnMask Roaming Triggers. 
+ * 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smSuccHandover(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+    bssEntry_t              *pNewConnectedAp;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smSuccHandover, candidateApIndex=%d \n", pRoamingMngr->candidateApIndex));
+
+    if (pRoamingMngr->handoverWasPerformed &&
+        (pRoamingMngr->pListOfAPs != NULL) &&
+        (pRoamingMngr->pListOfAPs->numOfEntries>0))
+    {
+        if (pRoamingMngr->candidateApIndex == CURRENT_AP_INDEX)
+        {   /* get the current AP */
+            pNewConnectedAp = apConn_getBSSParams(pRoamingMngr->hAPConnection);
+        }
+        else
+        {   /* get the candidate AP */
+            pNewConnectedAp = &pRoamingMngr->pListOfAPs->BSSList[pRoamingMngr->candidateApIndex];
+        }
+
+        scanMngr_handoverDone(pRoamingMngr->hScanMngr, 
+                          &pNewConnectedAp->BSSID,
+                          pNewConnectedAp->band);
+    }
+    pRoamingMngr->maskRoamingEvents = FALSE;
+    pRoamingMngr->candidateApIndex = INVALID_CANDIDATE_INDEX;
+    pRoamingMngr->handoverWasPerformed = FALSE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    /* Start pre-authentication in order to set PMKID
+        for the current AP */
+    if (pRoamingMngr->staCapabilities.authMode==os802_11AuthModeWPA2)
+    {   /* No Pre-Auth is required */
+        bssList_t           bssList;
+
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_smStartIdle, Pre-Auth to cur AP\n")); 
+        bssList.numOfEntries = 0;
+        apConn_preAuthenticate(pRoamingMngr->hAPConnection, &bssList);
+    }
+
+    return OK;
+}
+
+
+
+
+/**
+*
+* roamingMngr_smFailHandover 
+*
+* \b Description: 
+*
+* This procedure is called when handover failed and there are no more
+ * APs to roam to. Disconnect the BSS and retrun to IDLE state.
+* 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smFailHandover(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smFailHandover \n"));
+
+    /* clean intenal variables */
+    pRoamingMngr->maskRoamingEvents = TRUE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    scanMngr_stopContScan(pRoamingMngr->hScanMngr);
+#ifdef TI_DBG
+    pRoamingMngr->roamingFailedHandoverNum++;
+#endif
+    return (apConn_disconnect(pRoamingMngr->hAPConnection));
+}
+
+
+
+
+/**
+*
+* roamingMngr_smScanFailure 
+*
+* \b Description: 
+*
+* This procedure is called when all scan attempts failed. 
+ * Send Disconnect event and return to IDLE state.
+ *
+* 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smScanFailure(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smScanFailure \n"));
+
+    /* clean intenal variables */
+    pRoamingMngr->maskRoamingEvents = TRUE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    scanMngr_stopContScan(pRoamingMngr->hScanMngr);
+
+    return (apConn_disconnect(pRoamingMngr->hAPConnection));
+}
+
+#if 0
+/**
+*
+* roamingMngr_smCmdFailure 
+*
+* \b Description: 
+*
+* This procedure is called when all the driver failed to prepare to Roaming. 
+ * Mask all future Roaming triggers.
+ *
+* 
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smCmdFailure(TI_HANDLE hRoamingMngr)
+{
+    roamingMngr_t           *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                      ("roamingMngr_smCmdFailure \n"));
+
+    /* clean intenal variables */
+    pRoamingMngr->maskRoamingEvents = TRUE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    return OK;
+    
+}
+#endif
+
+/**
+*
+* roamingMngr_smStartIdle - Start event when in Idle state
+*
+* \b Description: 
+*
+* Start event when in Idle state. 
+ * This function is called when the station becomes CONNECTED.
+ * Perform the following:
+ * - The current state becomes WAIT_4_TRIGGER 
+ * - Unmask Roaming events
+ * - Set handoverWasPerformed to FALSE
+ * - Start the Scan Manager
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smStartIdle(void *pData)
+{
+    roamingMngr_t       *pRoamingMngr;
+    bssEntry_t          *pCurBssEntry;
+
+    pRoamingMngr = (roamingMngr_t*)pData;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                              ("roamingMngr_smStartIdle, Unmask Roaming events and start continuos scan \n"));
+
+    pRoamingMngr->maskRoamingEvents = FALSE;
+    pRoamingMngr->handoverWasPerformed = FALSE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    pCurBssEntry = apConn_getBSSParams(pRoamingMngr->hAPConnection);
+    scanMngr_startContScan(pRoamingMngr->hScanMngr, &pCurBssEntry->BSSID, pCurBssEntry->band);
+
+    /* Start pre-authentication in order to set PMKID
+        for the current AP */
+    if (pRoamingMngr->staCapabilities.authMode==os802_11AuthModeWPA2)
+    {   /* No Pre-Auth is required */
+        bssList_t           bssList;
+
+        WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("roamingMngr_smStartIdle, Pre-Auth to cur AP\n")); 
+        bssList.numOfEntries = 0;
+        apConn_preAuthenticate(pRoamingMngr->hAPConnection, &bssList);
+    }
+
+    return OK;
+}
+
+
+
+/**
+*
+* roamingMngr_smNop - Do nothing
+*
+* \b Description: 
+*
+* Do nothing in the SM.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smNop(void *pData)
+{
+    roamingMngr_t       *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)pData;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                (" roamingMngr_smNop\n"));
+    
+    return OK;
+}
+
+/**
+*
+* roamingMngr_smUnexpected - Unexpected event
+*
+* \b Description: 
+*
+* Unexpected event in the SM.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smUnexpected(void *pData)
+{
+    roamingMngr_t       *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)pData;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    WLAN_REPORT_ERROR(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                (" roamingMngr_smUnexpected, state = %d\n", pRoamingMngr->currentState));
+    
+    return NOK;
+}
+
+
+
+
+
+/**
+*
+* roamingMngr_smStop - Stop all timers and clean DB
+*
+* \b Description: 
+*
+* Stop event in start state. Stop timers, clean internal vars
+ *  and exit PS if necessary.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smStop(void *pData)
+{
+    roamingMngr_t       *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)pData;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                (" roamingMngr_smStop\n"));
+
+    scanMngr_stopContScan(pRoamingMngr->hScanMngr);
+    /* clean intenal variables */
+    pRoamingMngr->maskRoamingEvents = TRUE;
+    pRoamingMngr->neighborApsExist = FALSE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    return OK;
+}
+/**
+*
+* roamingMngr_smStopWhileScanning - 
+*
+* \b Description: 
+*
+* Stop event means that the station is not in Connected State. 
+ * Stop continuos and immediate scans and clean internal vars.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS roamingMngr_smStopWhileScanning(void *pData)
+{
+    roamingMngr_t       *pRoamingMngr;
+
+    pRoamingMngr = (roamingMngr_t*)pData;
+    if (pRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+    WLAN_REPORT_INFORMATION(pRoamingMngr->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                (" roamingMngr_smStopWhileScanning\n"));
+
+    scanMngr_stopImmediateScan(pRoamingMngr->hScanMngr);
+    scanMngr_stopContScan(pRoamingMngr->hScanMngr);
+
+    /* clean intenal variables */
+    pRoamingMngr->maskRoamingEvents = TRUE;
+    pRoamingMngr->neighborApsExist = FALSE;
+    pRoamingMngr->roamingTrigger = ROAMING_TRIGGER_NONE;
+
+    return OK;
+}
+
+  
+#ifdef TI_DBG
+/**
+*
+* roamingMngr_debugTrace 
+*
+* \b Description: 
+*
+* This procedure is called for debug only, to trace the roaming triggers and events
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static void roamingMngr_printStatistics(TI_HANDLE hRoamingMngr)
+{
+
+
+    roamingMngr_t       *pRoamingMngr;
+    UINT8               index;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return;
+    }
+
+    WLAN_OS_REPORT(("******** ROAMING_TRIGGERS ********\n"));
+    for (index=ROAMING_TRIGGER_LOW_TX_RATE; index<ROAMING_TRIGGER_LAST; index++)
+    {
+        switch (index)
+        {
+        case ROAMING_TRIGGER_LOW_TX_RATE:
+            WLAN_OS_REPORT(("- Low TX rate = %d\n",     pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_LOW_SNR:
+            WLAN_OS_REPORT(("- Low Snr = %d\n",         pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_LOW_QUALITY:
+            WLAN_OS_REPORT(("- Low Quality = %d\n",     pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_MAX_TX_RETRIES:
+            WLAN_OS_REPORT(("- MAX TX retries = %d\n",  pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_BSS_LOSS:
+            WLAN_OS_REPORT(("- BSS Loss TX = %d\n",     pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_SWITCH_CHANNEL:
+            WLAN_OS_REPORT(("- Switch Channel = %d\n",  pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_AP_DISCONNECT:
+            WLAN_OS_REPORT(("- AP Disconnect = %d\n",   pRoamingMngr->roamingTriggerEvents[index]));
+            break;
+        case ROAMING_TRIGGER_SECURITY_ATTACK:
+            WLAN_OS_REPORT(("- SEC attack = %d\n",      pRoamingMngr->roamingTriggerEvents[index]));
+            break;  
+        default:
+            break;
+        }
+    }
+
+    WLAN_OS_REPORT(("******** Succ ROAMING_HANDOVERS ********\n"));
+
+    for (index=ROAMING_TRIGGER_LOW_QUALITY; index<ROAMING_TRIGGER_LAST; index++)
+    {
+        switch (index)
+        {
+        case ROAMING_TRIGGER_LOW_TX_RATE:               
+            WLAN_OS_REPORT(("- Low TX rate = %d\n",     pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_LOW_SNR:               
+            WLAN_OS_REPORT(("- Low Snre = %d\n",        pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_LOW_QUALITY:               
+            WLAN_OS_REPORT(("- Low Quality = %d\n",     pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_MAX_TX_RETRIES:            
+            WLAN_OS_REPORT(("- MAX TX retries = %d\n",  pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_BSS_LOSS:                  
+            WLAN_OS_REPORT(("- BSS Loss TX = %d\n",     pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_SWITCH_CHANNEL:            
+            WLAN_OS_REPORT(("- Switch Channel = %d\n",   pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_AP_DISCONNECT:             
+            WLAN_OS_REPORT(("- AP Disconnect = %d\n",   pRoamingMngr->roamingHandoverEvents[index]));
+            break;                                     
+        case ROAMING_TRIGGER_SECURITY_ATTACK:           
+            WLAN_OS_REPORT(("- SEC attack = %d\n",      pRoamingMngr->roamingHandoverEvents[index])); 
+            break;                                     
+        default:
+            break;
+        }
+    }
+
+    WLAN_OS_REPORT(("******** ROAMING STATISTICS ********\n"));
+    WLAN_OS_REPORT(("- Num of succesful handovers = %d\n", pRoamingMngr->roamingSuccesfulHandoverNum)); 
+    WLAN_OS_REPORT(("- Num of failed handovers = %d\n", pRoamingMngr->roamingFailedHandoverNum)); 
+    if (pRoamingMngr->roamingSuccesfulHandoverNum >0)
+    {
+        WLAN_OS_REPORT(("- Succesful average succesful handover duration = %d\n", pRoamingMngr->roamingAverageSuccHandoverDuration/pRoamingMngr->roamingSuccesfulHandoverNum)); 
+        WLAN_OS_REPORT(("- Succesful average roaming duration = %d\n", pRoamingMngr->roamingAverageRoamingDuration/pRoamingMngr->roamingSuccesfulHandoverNum)); 
+    }
+
+
+}
+
+
+/**
+*
+* roamingMngr_resetDebugTrace 
+*
+* \b Description: 
+*
+* This procedure is called for debug only, to reset Roaming debug trace 
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - roamingMngr SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static void roamingMngr_resetStatistics(TI_HANDLE hRoamingMngr)
+{
+
+    roamingMngr_t       *pRoamingMngr;
+    UINT8               index;
+
+    pRoamingMngr = (roamingMngr_t*)hRoamingMngr;
+    if (pRoamingMngr == NULL)
+    {
+        return;
+    }
+    WLAN_OS_REPORT(("Resetting all ROAMING_EVENTS \n"));
+
+    pRoamingMngr->roamingSuccesfulHandoverNum = 0;    
+    pRoamingMngr->roamingHandoverStartedTimestamp = 0;  
+    pRoamingMngr->roamingHandoverCompletedTimestamp = 0;
+    pRoamingMngr->roamingAverageSuccHandoverDuration = 0; 
+    pRoamingMngr->roamingAverageRoamingDuration = 0;  
+    pRoamingMngr->roamingFailedHandoverNum = 0;
+
+    for (index=ROAMING_TRIGGER_LOW_QUALITY; index<ROAMING_TRIGGER_LAST; index++)
+    {
+        pRoamingMngr->roamingHandoverEvents[index] = 0;
+        pRoamingMngr->roamingTriggerEvents[index] = 0;
+    }
+}
+
+#endif /*TI_DBG*/
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Application/ScanMngr/scanMngr.c b/sta_dk_4_0_4_32/common/src/Application/ScanMngr/scanMngr.c
new file mode 100644 (file)
index 0000000..de3a388
--- /dev/null
@@ -0,0 +1,4328 @@
+/** \file scanMngr.c
+ *  \brief This file include the scan manager module implementation
+ *  \author Ronen Kalish
+ *  \date 01-Mar-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "802_11Defs.h"
+#include "scanMngr.h"
+#include "roamingMngr.h"
+#include "osApi.h"
+#include "ScanCncnApi.h"
+#include "report.h"
+#include "regulatoryDomainApi.h"
+#include "utils.h"
+#include "roamingMngr.h"
+#include "siteMgrApi.h"
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Creates the scan manager object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the OS object.\n
+ * \return a pointer to the scan manager object if successfull, NULL otherwise.\n
+ */
+TI_HANDLE scanMngr_create( TI_HANDLE hOS )
+{
+    int i,j,allocVector = 0;
+    scanMngr_t* pScanMngr ;
+    
+    /* allocate the scan manager object */
+    pScanMngr = os_memoryAlloc( hOS, sizeof(scanMngr_t) );
+    if ( NULL == pScanMngr )
+    {
+        WLAN_OS_REPORT( ("scanMngr_create: Failed allocating scan manager object storage.\n") );
+        return NULL;
+    }
+    pScanMngr->hOS = hOS;
+    allocVector |= SCAN_MNGR_ALLOC_VECTOR_OBJECT;
+
+    /* create timer */
+    pScanMngr->hContinuousScanTimer = os_timerCreate( hOS, scanMngr_GetUpdatedTsfDtimMibForScan, (TI_HANDLE)pScanMngr );
+    
+    if ( NULL == pScanMngr->hContinuousScanTimer )
+    {
+        WLAN_OS_REPORT( ("scanMngr_create: Failed creating continuous scan timer.\n") );
+        scanMngrFreeMem( (TI_HANDLE)pScanMngr, allocVector );
+        return NULL;
+    }
+    
+    allocVector |= SCAN_MNGR_ALLOC_VECTOR_TIMER;
+
+    /* allocate frame storage space for BSS list */
+    for ( i = 0; i < MAX_SIZE_OF_BSS_TRACK_LIST; i++ )
+    {
+        pScanMngr->BSSList.BSSList[ i ].pBuffer = os_memoryAlloc( hOS, MAX_BEACON_BODY_LENGTH );
+        if ( NULL == pScanMngr->BSSList.BSSList[ i ].pBuffer )
+        {
+            WLAN_OS_REPORT( ("scanMngr_create: Failed allocating scan result buffer for index %d.\n", i) );
+            /* failed to allocate a buffer - release all buffers that were allocated by now */
+            for ( j = i-1; j >= 0; j-- )
+            {
+                os_memoryFree( hOS, pScanMngr->BSSList.BSSList[ j ].pBuffer, MAX_BEACON_BODY_LENGTH );
+            }
+            /* release the rest of the module */
+            scanMngrFreeMem( (TI_HANDLE)pScanMngr, allocVector );
+            return NULL;
+        }
+    }
+    allocVector |= SCAN_MNGR_ALLOC_VECTOR_FRAME;
+
+    return (TI_HANDLE)pScanMngr;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Initializes the scan manager.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param hReport - handle to the report object.\n
+ * \param hRegDomain - handle to the regulatory domain object.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param hRoamMngr - handle to the roaming manager object.\n
+ * \param hSiteMngr - handle to the site manager object.\n
+ */
+void scanMngr_init( TI_HANDLE hScanMngr, TI_HANDLE hReport, TI_HANDLE hRegDomain, 
+                    TI_HANDLE hScanCncn, TI_HANDLE hRoamMngr, TI_HANDLE hSiteMngr,
+                    TI_HANDLE hHalCtrl)
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    WLAN_REPORT_INFORMATION( hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("scanMngr_init called, hScanMngr=0x%x, hReport=0x%x, hRegDomain=0x%x, "
+                              "hScanCncn=0x%x, hRaomMngr=0x%x.\n",
+                              hScanMngr, hReport, hRegDomain, hScanCncn, hRoamMngr) );
+
+    /* store handles */
+    pScanMngr->hReport = hReport;
+    pScanMngr->hRegulatoryDomain = hRegDomain;
+    pScanMngr->hScanCncn = hScanCncn;
+    pScanMngr->hRoamingMngr = hRoamMngr;
+    pScanMngr->hSiteMngr = hSiteMngr;
+    pScanMngr->hHalCtrl  = hHalCtrl;
+
+    /* mark that continuous scan timer is not running */
+    pScanMngr->bTimerRunning = FALSE;
+
+    /* mark that continuous scan process is not running */
+    pScanMngr->bContinuousScanStarted = FALSE;
+
+    /* nullify scan policy */
+    os_memoryZero( pScanMngr->hOS, &(pScanMngr->scanPolicy), sizeof(scan_Policy_t) );
+
+    /* initialize the BSS list to empty list */
+    pScanMngr->BSSList.numOfEntries = 0;
+
+    /* mark no continuous and immediate scans are currently running */
+    pScanMngr->contScanState = SCAN_CSS_IDLE;
+    pScanMngr->immedScanState = SCAN_ISS_IDLE;
+    pScanMngr->bNewBSSFound = FALSE;
+    pScanMngr->consecNotFound = 0;
+    
+    /* mark no AP recovery occured */
+    pScanMngr->bSynchronized = TRUE;
+    
+    /* mark no neighbor APs */
+    pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_2_4_GHZ ].numOfEntries = 0;
+    pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_5_0_GHZ ].numOfEntries = 0;
+
+    /* mark no discovery process */
+    pScanMngr->currentDiscoveryPart = SCAN_SDP_NO_DISCOVERY;
+
+    /* initialize the low quality indication to indicate that normal quality interval should be used */
+    pScanMngr->bLowQuality = FALSE;
+
+    /* clear current BSS field (put broadcast MAC) */
+    for ( i = 0; i < MAC_ADDR_LEN; i++ )
+    {
+        pScanMngr->currentBSS.addr[ i ] = 0xff;
+    }
+    pScanMngr->currentBSSBand = RADIO_BAND_2_4_GHZ;
+
+    /* register scan concentrator callbacks */
+    scanConcentrator_registerScanResultCB( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT,
+                                           scanMngr_contScanCB, hScanMngr );
+    scanConcentrator_registerScanResultCB( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_IMMED,
+                                           scanMngr_immedScanCB, hScanMngr );
+
+#ifdef TI_DBG
+    /* nullify statistics */
+    os_memoryZero( pScanMngr->hOS, &(pScanMngr->stats), sizeof(scan_mngrStat_t) );
+    /* nullify scan parameters - for debug prints before start */
+    os_memoryZero( pScanMngr->hOS, &(pScanMngr->scanParams), sizeof(scan_Params_t) );
+    /* initialize other variables for debug print */
+    pScanMngr->bImmedNeighborAPsOnly = FALSE;
+    pScanMngr->bNewBSSFound = FALSE;
+#endif
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief unloads the scan manager object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_unload( TI_HANDLE hScanMngr )
+{
+    scanMngrFreeMem( hScanMngr, 0xff );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Frees scan manager resources.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param allocVector - bit vector indicating which resources were allocated.\n
+ */
+void scanMngrFreeMem( TI_HANDLE hScanMngr, UINT8 allocVector )
+{
+    scanMngr_t* pScanMngr = hScanMngr;
+    UINT8 i;
+
+    /* free frame storage space */
+    if ( SCAN_MNGR_ALLOC_VECTOR_FRAME & allocVector )
+    {
+        for ( i = 0; i < MAX_SIZE_OF_BSS_TRACK_LIST; i++ )
+        {
+            os_memoryFree( pScanMngr->hOS, pScanMngr->BSSList.BSSList[ i ].pBuffer, MAX_BEACON_BODY_LENGTH );
+        }
+    }
+
+    /* free the timer */
+    if ( SCAN_MNGR_ALLOC_VECTOR_TIMER & allocVector )
+    {
+        os_timerStop( pScanMngr->hOS, pScanMngr->hContinuousScanTimer );
+        os_timerDestroy( pScanMngr->hOS, pScanMngr->hContinuousScanTimer );
+    }
+
+    /* free the scan manager object */
+    if ( SCAN_MNGR_ALLOC_VECTOR_OBJECT & allocVector )
+    {
+        os_memoryFree( pScanMngr->hOS, hScanMngr, sizeof(scanMngr_t) );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Starts an immediate scan operation.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param pNeighborAPsOnly - TRUE if scan for neighbor APs only, FALSE if scan on all channels.\n
+ * \return status indication.\n
+ * \retval SCAN_MRS_SCAN_RUNNING - the scan started successfully and is now running.\n
+ * \retval SCAN_MRS_SCAN_NOT_ATTEMPTED_ALREADY_RUNNING - scan was not attempted because it is already running.\n
+ * \retval SCAN_MRS_SCAN_NOT_ATTEMPTED_EMPTY_POLICY - scan was not attempted because NULL policy defined.\n
+ * \retval SCAN_MRS_SCAN_NOT_ATTEMPTED_NO_CHANNLES_AVAILABLE - scan was not attempted because no channels were available.\n
+ * \retval SCAN_MRS_SCAN_FAILED - scan failed to start at lower levels.\n
+ */
+scan_mngrResultStatus_e scanMngr_startImmediateScan( TI_HANDLE hScanMngr, BOOLEAN bNeighborAPsOnly)
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    scan_bandPolicy_t *gPolicy, *aPolicy;
+    scan_cncnResultStatus_e resultStatus;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_startImmediateScan called, hScanMngr=0x%x, bNeighborAPsOnly=%s.\n",
+                              hScanMngr,
+                              (TRUE == bNeighborAPsOnly ? "TRUE" : "FALSE")) );
+  
+    /* sanity check - whether immediate scan is already running */
+    if ( SCAN_ISS_IDLE != pScanMngr->immedScanState )
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("Immediate scan attempted while it is already running, in state:%d.\n", pScanMngr->immedScanState) );
+        return SCAN_MRS_SCAN_NOT_ATTEMPTED_ALREADY_RUNNING;
+    }
+
+    /* get policies by band */
+    gPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_2_4_GHZ );
+    aPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_5_0_GHZ );
+
+    /* check whether a policy is defined for at least one band */
+    if ( ((NULL == gPolicy) || (SCAN_TYPE_NO_SCAN == gPolicy->immediateScanMethod.scanType)) && /* no policy for G band */
+         ((NULL == aPolicy) || (SCAN_TYPE_NO_SCAN == aPolicy->immediateScanMethod.scanType)) ) /* no policy for A band */
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Immediatse scan attempted when no policy is defined.\n") );
+        return SCAN_MRS_SCAN_NOT_ATTEMPTED_EMPTY_POLICY;
+    }
+
+    /* First try to scan on G band - if a policy is defined and channels are available */
+    if ( (NULL != gPolicy) && /* policy is defined for G */
+         (SCAN_TYPE_NO_SCAN != gPolicy->immediateScanMethod.scanType) )
+    {
+        /* build scan command */
+        scanMngrBuildImmediateScanCommand( hScanMngr, gPolicy, bNeighborAPsOnly );
+        
+        /* if no channels are available, proceed to band A */
+        if ( 0 < pScanMngr->scanParams.numOfChannels )
+        {
+            /* mark that immediate scan is running on band G */
+            pScanMngr->immedScanState = SCAN_ISS_G_BAND;
+            pScanMngr->bImmedNeighborAPsOnly = bNeighborAPsOnly;
+
+            /* if continuous scan is running, mark that it should quit */
+            if ( SCAN_CSS_IDLE != pScanMngr->contScanState )
+            {
+                WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                         ("scanMngr_startImmediateScan called 1, switched to STOPPING state \n"));
+
+                pScanMngr->contScanState = SCAN_CSS_STOPPING;
+            }
+
+            /* send scan command to scan concentrator */
+            resultStatus = scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_IMMED, &(pScanMngr->scanParams) );
+            if ( SCAN_CRS_SCAN_RUNNING != resultStatus )
+            {
+                WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Failed to start immediate scan on band G, return code %d.\n", resultStatus) );
+#ifdef TI_DBG
+                pScanMngr->stats.ImmediateGByStatus[ resultStatus ]++;
+#endif
+                return SCAN_MRS_SCAN_FAILED;
+            }
+            return SCAN_MRS_SCAN_RUNNING;
+        }
+    }
+
+    /* if G scan did not start (because no policy is configured or no channels are available, try A band */
+    if ( (NULL != aPolicy) &&
+         (SCAN_TYPE_NO_SCAN != aPolicy->immediateScanMethod.scanType) )
+    {
+        /* build scan command */
+        scanMngrBuildImmediateScanCommand( hScanMngr, aPolicy, bNeighborAPsOnly );
+
+        /* if no channels are available, report error */
+        if ( 0 == pScanMngr->scanParams.numOfChannels )
+        {
+            WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                                 ("No channels available for scan operation.\n") );
+            return SCAN_MRS_SCAN_NOT_ATTEMPTED_NO_CHANNLES_AVAILABLE;
+        }
+        else
+        {
+            /* mark that immediate scan is running on band A */
+            pScanMngr->immedScanState = SCAN_ISS_A_BAND;
+
+            /* if continuous scan is running, mark that it should quit */
+            if ( SCAN_CSS_IDLE != pScanMngr->contScanState )
+            {
+                WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                         ("scanMngr_startImmediateScan called 2, switched to STOPPING state \n"));
+
+                pScanMngr->contScanState = SCAN_CSS_STOPPING;
+            }
+
+            /* send scan command to scan concentrator */
+            resultStatus = scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_IMMED, &(pScanMngr->scanParams) );
+            if ( SCAN_CRS_SCAN_RUNNING != resultStatus )
+            {
+                WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Failed to start immediate scan on band A, return code %d.\n", resultStatus) );
+#ifdef TI_DBG
+                pScanMngr->stats.ImmediateAByStatus[ resultStatus ]++;
+#endif
+                return SCAN_MRS_SCAN_FAILED;
+            }
+            return SCAN_MRS_SCAN_RUNNING;
+        }
+    }
+    else
+    {
+        /* since we passed the policy check, we arrived here because we didn't had channel on G and policy on A */
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("No channels available for scan operation.\n") );
+        return SCAN_MRS_SCAN_NOT_ATTEMPTED_NO_CHANNLES_AVAILABLE;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Stops an immediate scan operation.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_stopImmediateScan( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngrStopImmediateScan called, hScanMngr=0x%x", hScanMngr) );
+
+    /* check that immediate scan is running */
+    if ( (SCAN_ISS_A_BAND != pScanMngr->immedScanState) && (SCAN_ISS_G_BAND != pScanMngr->immedScanState) )
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("Immediate scan stop request when immediate scan is in state:%d", pScanMngr->immedScanState) );
+        return;
+    }
+
+#ifdef TI_DBG
+    switch ( pScanMngr->immedScanState )
+    {
+    case SCAN_ISS_G_BAND:
+        pScanMngr->stats.ImmediateGByStatus[ SCAN_CRS_SCAN_STOPPED ]++;
+        break;
+
+    case SCAN_ISS_A_BAND:
+        pScanMngr->stats.ImmediateAByStatus[ SCAN_CRS_SCAN_STOPPED ]++;
+        break;
+
+    default:
+        break;
+    }
+#endif
+    /* mark immediate scan status as stopping */
+    pScanMngr->immedScanState = SCAN_ISS_STOPPING;
+
+    /* send a stop command to scan concentrator */
+    scanConcentrator_stopScan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_IMMED );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Starts the continuous scan timer.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param currentBSS - the AP we are currently connected to.\n
+ * \currentBSSBand - the band of the current BSS.\n
+ */
+void scanMngr_startContScan( TI_HANDLE hScanMngr, macAddress_t* currentBSS, radioBand_e currentBSSBand )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int currentBSSNeighborIndex;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_StartContScan called, hScanMngr=0x%x.\n", hScanMngr) );
+
+    /* if continuous scan is already running, it means we get a start command w/o stop */
+    if ( TRUE == pScanMngr->bContinuousScanStarted )
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hOS, SCAN_MNGR_MODULE_LOG,
+                             ("Start continuous scan requested when continuous scan is running.\n") );
+        return;
+    }
+
+    /* mark that continuous scan was started */
+    pScanMngr->bContinuousScanStarted = TRUE;
+    
+    /* before reading and marking the new BSS - make sure that the old one is marked as NOT DISCOVERED */
+    currentBSSNeighborIndex = scanMngrGetNeighborAPIndex( hScanMngr, pScanMngr->currentBSSBand, &(pScanMngr->currentBSS) );
+    if ( -1 != currentBSSNeighborIndex )
+    {
+        pScanMngr->neighborAPsDiscoveryList[ pScanMngr->currentBSSBand ].trackStatusList[ currentBSSNeighborIndex ] = 
+            SCAN_NDS_NOT_DISCOVERED;
+    }
+
+    /* Now copy current BSS - to be used when setting neighbor APs */
+    pScanMngr->currentBSSBand = currentBSSBand;
+    os_memoryCopy( pScanMngr->hOS, &(pScanMngr->currentBSS), currentBSS, MAC_ADDR_LEN );
+
+    /* if current BSS is in the neighbor AP list, mark it as current BSS */
+    currentBSSNeighborIndex = scanMngrGetNeighborAPIndex( hScanMngr, currentBSSBand, currentBSS );
+    if ( -1 != currentBSSNeighborIndex )
+    {
+        pScanMngr->neighborAPsDiscoveryList[ currentBSSBand ].trackStatusList[ currentBSSNeighborIndex ] = 
+            SCAN_NDS_CURRENT_AP;
+    }
+
+    /* reset discovery cycle */
+    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_2_4_GHZ ] = 0;
+    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_5_0_GHZ ] = 0;
+    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_2_4_GHZ ] = 0;
+    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_5_0_GHZ ] = 0;
+    pScanMngr->currentDiscoveryPart = SCAN_SDP_NEIGHBOR_G;
+    scanMngrSetNextDiscoveryPart( hScanMngr );
+
+    /* clear the BSS tracking list */
+    pScanMngr->BSSList.numOfEntries = 0;
+
+    /* start timer (if timeout is configured) */
+    if ( ((TRUE == pScanMngr->bLowQuality) && (0 < pScanMngr->scanPolicy.normalScanInterval)) ||
+         ((FALSE == pScanMngr->bLowQuality) && (0 < pScanMngr->scanPolicy.deterioratingScanInterval)) )
+    {
+        pScanMngr->bTimerRunning = TRUE;
+        os_timerStart( pScanMngr->hOS, 
+                       pScanMngr->hContinuousScanTimer, 
+                       (FALSE == pScanMngr->bLowQuality ?
+                        pScanMngr->scanPolicy.normalScanInterval :
+                        pScanMngr->scanPolicy.deterioratingScanInterval),
+                       TRUE );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Stops the continuous scan timer.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_stopContScan( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    UINT8 i;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_stopContScan called, hScanMngr=0x%x, state =%d\n", 
+                              hScanMngr, pScanMngr->contScanState) );
+        
+    /* if continuous scan is not running, it means we get a stop command w/o start */
+    if ( FALSE == pScanMngr->bContinuousScanStarted )
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hOS, SCAN_MNGR_MODULE_LOG,
+                             ("Stop continuous scan when continuous scan is not running.\n") );
+        return;
+    }
+
+    /* mark that continuous scan is not running */
+    pScanMngr->bContinuousScanStarted = FALSE;
+
+    /* stop timer */
+    if ( TRUE == pScanMngr->bTimerRunning )
+    {
+        os_timerStop( pScanMngr->hOS, pScanMngr->hContinuousScanTimer );
+        pScanMngr->bTimerRunning = FALSE;
+    }
+
+    /* if continuous scan is currently running */
+    if ( (SCAN_CSS_IDLE != pScanMngr->contScanState) &&
+         (SCAN_CSS_STOPPING != pScanMngr->contScanState) )
+    {
+        /* send a stop scan command to the scan concentartor */
+        scanConcentrator_stopScan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT );
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("scanMngr_stopContScan called, switched to STOPPING state \n"));
+
+#ifdef TI_DBG
+        switch ( pScanMngr->contScanState )
+        {
+        case SCAN_CSS_TRACKING_G_BAND:
+            pScanMngr->stats.TrackingGByStatus[ SCAN_CRS_SCAN_STOPPED ]++;
+            break;
+
+        case SCAN_CSS_TRACKING_A_BAND:
+            pScanMngr->stats.TrackingAByStatus[ SCAN_CRS_SCAN_STOPPED ]++;
+            break;
+
+        case SCAN_CSS_DISCOVERING:
+            if ( RADIO_BAND_2_4_GHZ == pScanMngr->statsLastDiscoveryBand )
+            {
+                pScanMngr->stats.DiscoveryGByStatus[ SCAN_CRS_SCAN_STOPPED ]++;
+            }
+            else
+            {
+                pScanMngr->stats.DiscoveryAByStatus[ SCAN_CRS_SCAN_STOPPED ]++;
+            }
+            break;
+
+        default:
+            break;
+        }
+#endif
+        /* mark that continuous scan is stopping */
+        pScanMngr->contScanState = SCAN_CSS_STOPPING;
+    }
+
+    /* clear current neighbor APs */
+    pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_2_4_GHZ ].numOfEntries = 0;
+    pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_5_0_GHZ ].numOfEntries = 0;
+
+    /* clear current BSS field .This is for the case that scanMngr_setNeighborAPs() is called before scanMngr_startcontScan() */
+    for ( i = 0; i < MAC_ADDR_LEN; i++ )
+    {
+        pScanMngr->currentBSS.addr[ i ] = 0xff;
+    }
+
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief returns the currently available BSS list. Verifies channels with the reg. domain.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \return BSS list structure pointer.\n
+ */
+bssList_t* scanMngr_getBSSList( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    UINT8 BSSIndex;
+    paramInfo_t param;
+
+    
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_getBSSList called, hScanMngr=0x%x.\n", hScanMngr) );
+
+    /* loop on all BSS'es */
+    for ( BSSIndex = 0; BSSIndex < pScanMngr->BSSList.numOfEntries; )
+    {
+        /* verify channel validity with the reg domain - for active scan! 
+           (because connection will be attempted on the channel... */
+        param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+        param.content.channelCapabilityReq.band = pScanMngr->BSSList.BSSList[ BSSIndex ].band;
+        param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+        param.content.channelCapabilityReq.channelNum = pScanMngr->BSSList.BSSList[ BSSIndex ].channel;
+        regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+        /* if channel is not valid */
+        if ( !param.content.channelCapabilityRet.channelValidity )
+        {
+            /* will replace this entry with one further down the array, if any. Therefore, index is not increased
+               (because a new entry will be placed in the same index). If this is the last entry - the number of
+               BSSes will be decreased, and thus the loop will exit */
+            scanMngrRemoveBSSListEntry( hScanMngr, BSSIndex );
+        }
+        else
+        {
+            BSSIndex++;
+        }
+    }
+
+    /* return the BSS list */
+    return (bssList_t*)&(pScanMngr->BSSList);
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Sets the neighbor APs.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param neighborAPList - the neighbor AP list.\n
+ */
+void scanMngr_setNeighborAPs( TI_HANDLE hScanMngr, neighborAPList_t* neighborAPList )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int neighborAPIndex, currentBSSNeighborIndex;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_setNeighborAPs called, hScanMngr=0x%x.\n", hScanMngr) );
+    scanMngrTracePrintNeighborAPsList( hScanMngr, neighborAPList );
+
+    /* if continuous scan is running, indicate that it shouldn't proceed to next scan (if any) */
+    if ( pScanMngr->contScanState != SCAN_CSS_IDLE )
+    {
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("scanMngr_setNeighborAPs called, switched to STOPPING state \n"));
+
+        pScanMngr->contScanState = SCAN_CSS_STOPPING;
+    }
+   
+    /* clear current neighbor APs */
+    pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_2_4_GHZ ].numOfEntries = 0;
+    pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_5_0_GHZ ].numOfEntries = 0;
+
+    /* copy new neighbor APs, according to band */
+    for ( neighborAPIndex = 0; neighborAPIndex < neighborAPList->numOfEntries; neighborAPIndex++ )
+    {
+        /* insert to appropriate list */
+        os_memoryCopy( pScanMngr->hOS,
+                       &(pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band ].APListPtr[ pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band  ].numOfEntries ]),
+                       &(neighborAPList->APListPtr[ neighborAPIndex ]),
+                       sizeof(neighborAP_t) );
+
+        /* if AP is in track list, mark as discovered. This is done only if continuous scan
+           has already started, to ensure the roaming canidate list holds valid information */
+        if ( TRUE == pScanMngr->bContinuousScanStarted )
+        {
+            pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band  ].trackStatusList[ pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band  ].numOfEntries ] =
+                ( -1 == scanMngrGetTrackIndexByBssid( hScanMngr, &(neighborAPList->APListPtr[ neighborAPIndex ].BSSID) ) ? 
+                  SCAN_NDS_NOT_DISCOVERED : 
+                  SCAN_NDS_DISCOVERED );
+        }
+        else
+        {
+            /* if continuous scan has not yet started, all AP's are yet to be discovered... */
+            pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band  ].trackStatusList[ pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band  ].numOfEntries ] =
+                SCAN_NDS_NOT_DISCOVERED;
+        }
+
+        /* increase neighbor AP count */
+        pScanMngr->neighborAPsDiscoveryList[ neighborAPList->APListPtr[ neighborAPIndex ].band  ].numOfEntries++;
+    }
+    
+    /* remove all tracked APs that are designated as neighbor APs, but are not anymore. Policy has not
+       changed, so there's no need to check APs that are not neighbor APs and were inserted to the BSS
+       list because they are on a policy defined channel. */
+    scanMngrUpdateBSSList( hScanMngr, TRUE, FALSE );
+
+    /* if current BSS is a neighbor AP, mark it */
+    currentBSSNeighborIndex = scanMngrGetNeighborAPIndex( hScanMngr, 
+                                                          pScanMngr->currentBSSBand, 
+                                                          &(pScanMngr->currentBSS) );
+    if ( -1 != currentBSSNeighborIndex )
+    {
+        pScanMngr->neighborAPsDiscoveryList[ pScanMngr->currentBSSBand ].trackStatusList[ currentBSSNeighborIndex ] = 
+            SCAN_NDS_CURRENT_AP;
+    }
+
+    /* reset discovery counters */
+    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_2_4_GHZ ] = 0;
+    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_5_0_GHZ ] = 0;
+    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_2_4_GHZ ] = 0;
+    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_5_0_GHZ ] = 0;
+    /* set current discovery part to first part (G neighbor APs) */
+    pScanMngr->currentDiscoveryPart = SCAN_SDP_NEIGHBOR_G;
+    /* now advance discovery part */
+    scanMngrSetNextDiscoveryPart( hScanMngr );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief change quality level (normal / deteriorating).\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bLowQuality - TRUE if quality is deteriorating, FALSE if quality is normal.\n
+ */
+void scanMngr_qualityChangeTrigger( TI_HANDLE hScanMngr, BOOLEAN bLowQuality )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_qualityChangeTrigger called, hScanMngr=0x%x, bLowQuality=%s.\n",
+                              hScanMngr, (TRUE == bLowQuality ? "TRUE" : "FALSE")) );
+
+    /* remember the low quality trigger (in case policy changes, to know which timer interval to use) */
+    pScanMngr->bLowQuality = bLowQuality;
+
+    /* This function shouldn't be called when continuous scan is not running */
+    if ( FALSE == pScanMngr->bContinuousScanStarted )
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Quality change trigger when continuous scan is not running.\n") );
+    }
+
+    /* stop the timer */
+    if ( TRUE == pScanMngr->bTimerRunning )
+    {
+        os_timerStop( pScanMngr->hOS, pScanMngr->hContinuousScanTimer );
+        /* start the timer with the new interval */
+        os_timerStart( pScanMngr->hOS, pScanMngr->hContinuousScanTimer, 
+                       (TRUE == bLowQuality ? 
+                        pScanMngr->scanPolicy.deterioratingScanInterval : 
+                        pScanMngr->scanPolicy.normalScanInterval),
+                       TRUE );
+    }
+}
+
+
+/**
+ * \author Ronen Kalish\n
+ * \date 13-Mar-2005\n
+ * \brief Notifies the scan manager of a roaming event. Should be called BEFORE the SCR group 
+ * \brief is changed back to connected.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param macAddress - mac address of the new AP.\n
+ * \param band - the band of the new AP.\n
+ */
+void scanMngr_handoverDone( TI_HANDLE hScanMngr, macAddress_t* macAddress, radioBand_e band )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i, currentBSSNeighborIndex;
+
+    /* mark that TSF values are not synchronized */
+    pScanMngr->bSynchronized = FALSE;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_handoverDone called\n"));
+
+    /* if previous AP is in neighbor AP list, mark it as not discoverd */
+    currentBSSNeighborIndex = scanMngrGetNeighborAPIndex( hScanMngr,
+                                                          pScanMngr->currentBSSBand,
+                                                          &(pScanMngr->currentBSS) );
+    if ( -1 != currentBSSNeighborIndex )
+    {
+        pScanMngr->neighborAPsDiscoveryList[ pScanMngr->currentBSSBand ].trackStatusList[ currentBSSNeighborIndex ] = 
+            SCAN_NDS_NOT_DISCOVERED;
+    }
+
+    /* copy new current AP info */
+    pScanMngr->currentBSSBand = band;
+    os_memoryCopy( pScanMngr->hOS, &(pScanMngr->currentBSS), macAddress, MAC_ADDR_LEN );
+
+    /* if new current AP is a neighbor AP, mark it */
+    currentBSSNeighborIndex = scanMngrGetNeighborAPIndex( hScanMngr, band, macAddress );
+    if ( -1 != currentBSSNeighborIndex )
+    {
+        pScanMngr->neighborAPsDiscoveryList[ band ].trackStatusList[ currentBSSNeighborIndex ] = 
+            SCAN_NDS_CURRENT_AP;
+        /* note - no need to update discovery index - when adding neighbor APs the check (whether discovery should
+           be attempted) is done for every channel! */
+    }
+
+    /* if a continuous scan is running, mark that it should stop */
+    if ( SCAN_CSS_IDLE != pScanMngr->contScanState )
+    {
+
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("scanMngr_handoverDone called, switched to STOPPING state \n"));
+
+        pScanMngr->contScanState = SCAN_CSS_STOPPING;
+        scanConcentrator_stopScan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT );
+    }
+
+    /* if the new AP is in the track list */
+    i = scanMngrGetTrackIndexByBssid( hScanMngr, macAddress );
+    if ( i != -1 )
+    {
+        /* remove it */
+        scanMngrRemoveBSSListEntry( hScanMngr, i );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Callback used by the scan concentrator for immediate scan result.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param resultStatus - reason for calling this function (frame received / scan complete).\n
+ * \param frameInfo - frame related information (in case of a frame reception).\n
+ * \param SPSStatus - bitmap indicating which channels were scan, in case of an SPS scan.\n
+ */
+void scanMngr_immedScanCB( TI_HANDLE hScanMngr, scan_cncnResultStatus_e resultStatus, 
+                           scan_frameInfo_t* frameInfo, UINT16 SPSStatus )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    scan_bandPolicy_t* aPolicy;
+    scan_cncnResultStatus_e nextResultStatus;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_immedScanCB called, hScanMngr=0x%x, resultStatus=%d",
+                              hScanMngr, resultStatus) );
+    
+    switch (resultStatus)
+    {
+    /* if this function is called because a frame was received, update the BSS list accordingly */
+    case SCAN_CRS_RECEIVED_FRAME:
+        scanMngrUpdateReceivedFrame( hScanMngr, frameInfo );
+        break;
+
+    /* scan was completed successfuly */
+    case SCAN_CRS_SCAN_COMPLETE_OK:
+        /* act according to immediate scan state */
+        switch (pScanMngr->immedScanState)
+        {
+        /* immediate scan on G finished */
+        case SCAN_ISS_G_BAND:
+#ifdef TI_DBG
+        pScanMngr->stats.ImmediateGByStatus[ resultStatus ]++;
+#endif
+        /* check if another scan is needed (this time on A) */
+        aPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_5_0_GHZ );
+            if ( (NULL != aPolicy) &&
+                 (SCAN_TYPE_NO_SCAN != aPolicy->immediateScanMethod.scanType) )
+        {
+            /* build scan command */
+            scanMngrBuildImmediateScanCommand( hScanMngr, aPolicy, pScanMngr->bImmedNeighborAPsOnly );
+
+            /* if no channels are available, report error */
+            if ( 0 < pScanMngr->scanParams.numOfChannels )
+            {
+                /* mark that immediate scan is running on band A */
+                pScanMngr->immedScanState = SCAN_ISS_A_BAND;
+
+                /* send scan command to scan concentrator */
+                nextResultStatus = 
+                    scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_IMMED, &(pScanMngr->scanParams) );
+                if ( SCAN_CRS_SCAN_RUNNING != nextResultStatus )
+                {
+                    pScanMngr->immedScanState = SCAN_ISS_IDLE;
+                    WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                         ("Failed to start immediate scan on band A, return code %d.\n", resultStatus) );
+#ifdef TI_DBG
+                    pScanMngr->stats.ImmediateAByStatus[ nextResultStatus ]++;
+#endif
+                    roamingMngr_immediateScanComplete( pScanMngr->hRoamingMngr, SCAN_MRS_SCAN_COMPLETE_OK ); 
+                }
+            }
+            else
+            {
+                /* mark that immediate scan is not running */
+                pScanMngr->immedScanState = SCAN_ISS_IDLE;
+                
+                /* no channels are actually available for scan - notify the roaming manager of the scan complete */
+                roamingMngr_immediateScanComplete( pScanMngr->hRoamingMngr, SCAN_MRS_SCAN_COMPLETE_OK );
+            }
+        }
+        else
+        {
+            /* mark that immediate scan is not running */
+            pScanMngr->immedScanState = SCAN_ISS_IDLE;
+
+            /* otherwise, notify the roaming manager of the scan complete */
+            roamingMngr_immediateScanComplete( pScanMngr->hRoamingMngr, SCAN_MRS_SCAN_COMPLETE_OK );
+        }
+        break;
+
+        /* stop immediate scan was requested */
+        case SCAN_ISS_STOPPING:
+            /* mark that immediate scan is not running */
+            pScanMngr->immedScanState = SCAN_ISS_IDLE;
+
+            /* notify the roaming manager of the scan complete */
+            roamingMngr_immediateScanComplete( pScanMngr->hRoamingMngr, SCAN_MRS_SCAN_STOPPED ); 
+            break;
+
+        /* Scan completed on A band */
+        case SCAN_ISS_A_BAND:
+            /* mark that immediate scan is not running */
+            pScanMngr->immedScanState = SCAN_ISS_IDLE;
+#ifdef TI_DBG
+            pScanMngr->stats.ImmediateAByStatus[ resultStatus ]++;
+#endif
+            /* otherwise, notify the roaming manager of the scan complete */
+            roamingMngr_immediateScanComplete( pScanMngr->hRoamingMngr, SCAN_MRS_SCAN_COMPLETE_OK ); 
+            break;
+        
+        default:
+            /* should not be at any other stage when CB is invoked */
+            WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Immediate scan CB called with scan complete OK reason in state:%d", pScanMngr->immedScanState) );
+
+            /* reset continuous scan to idle */
+            pScanMngr->immedScanState = SCAN_ISS_IDLE;
+            break;
+        }
+        break;
+
+    /* scan was completed due to an error! */
+    default:
+#ifdef TI_DBG
+        switch (pScanMngr->immedScanState)
+        {
+        case SCAN_ISS_G_BAND:
+            pScanMngr->stats.ImmediateGByStatus[ resultStatus ]++;
+            break;
+
+        case SCAN_ISS_A_BAND:
+            pScanMngr->stats.ImmediateAByStatus[ resultStatus ]++;
+            break;
+
+        default:
+            break;
+        }
+#endif
+        /* mark that immediate scan is not running */
+        pScanMngr->immedScanState = SCAN_ISS_IDLE;     
+        
+        roamingMngr_immediateScanComplete( pScanMngr->hRoamingMngr, scanMngrConvertResultStatus(resultStatus) ); 
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Callback used by the scan concentrator for continuous scan result.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param resultStatus - reason for calling this function (frame received / scan complete).\n
+ * \param frameInfo - frame related info (in case of a frame reception).\n
+ * \param SPSStatus - bitmap indicating which channels were scan, in case of an SPS scan.\n
+ */
+void scanMngr_contScanCB( TI_HANDLE hScanMngr, scan_cncnResultStatus_e resultStatus, 
+                         scan_frameInfo_t* frameInfo, UINT16 SPSStatus )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    scan_bandPolicy_t *aPolicy;
+    scan_cncnResultStatus_e nextResultStatus;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_contScanCB called, hScanMngr=0x%x, resultStatus=%d, SPSStatus=%d\n",
+                              hScanMngr, resultStatus, SPSStatus) );
+    switch (resultStatus)
+    {
+    /* frame received - update BSS list accordingly */
+    case SCAN_CRS_RECEIVED_FRAME:
+        scanMngrUpdateReceivedFrame( hScanMngr, frameInfo );
+        break;
+
+    /* scan was completed successfully - either continue to next stage or simply finish this cycle */
+    case SCAN_CRS_SCAN_COMPLETE_OK:
+#ifdef SCAN_MNGR_DBG
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Continuous scan completes successfuly.\n") );
+        scanMngrDebugPrintBSSList( hScanMngr );
+#endif
+#ifdef TI_DBG
+        if ( SCAN_TYPE_SPS == pScanMngr->scanParams.scanType )
+        {
+            int i;
+
+            /*update SPS channels attendant statistics */
+            for ( i = 0; i < pScanMngr->scanParams.numOfChannels; i++ )
+            {
+                if ( FALSE == WAS_SPS_CHANNEL_ATTENDED( SPSStatus, i ) )
+                {
+                    pScanMngr->stats.SPSChannelsNotAttended[ i ]++;
+                }
+            }
+        }
+#endif
+    
+        /* first, remove APs that were not tracked. Note that this function does NOT
+           increase the retry counter, and therefore there's no harm in calling it even if only 
+           some of the APs were searched in the previous tracking command, or previous command was
+           discovery */
+        scanMngrPerformAging( hScanMngr );
+
+        /* if new BSS's were found (or enough scan iterations passed w/o finding any), notify the roaming manager */
+        if ( ((TRUE == pScanMngr->bNewBSSFound) || 
+              (SCAN_MNGR_CONSEC_SCAN_ITER_FOR_PRE_AUTH < pScanMngr->consecNotFound)) &&
+             (pScanMngr->BSSList.numOfEntries > 0) ) /* in case no AP was found for specified iterations number,
+                                                        but no AP is present, and so is pre-auth */
+        {
+            pScanMngr->bNewBSSFound = FALSE;
+            pScanMngr->consecNotFound = 0;
+            roamingMngr_updateNewBssList( pScanMngr->hRoamingMngr, (bssList_t*)&(pScanMngr->BSSList) );
+        }
+
+        /* act according to continuous scan state */
+        switch (pScanMngr->contScanState)
+        {
+        case SCAN_CSS_TRACKING_G_BAND:
+#ifdef TI_DBG
+            pScanMngr->stats.TrackingGByStatus[ resultStatus ]++;
+#endif    
+            WLAN_REPORT_INFORMATION(pScanMngr->hReport , SCAN_MNGR_MODULE_LOG , ("\n Starting SCAN_CSS_TRACKING_G_BAND \n"));
+          /* if necessary, attempt tracking on A */
+            aPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_5_0_GHZ );
+            /* if a policy is defined for A band tracking, attempt to perform it */
+            if ( (NULL != aPolicy) &&
+                 (SCAN_TYPE_NO_SCAN != aPolicy->trackingMethod.scanType) )
+            {
+                /* recalculate current TSF, to adjust the TSF read at the beginning of
+                   the continuous scan process with the tracking on G duration */
+                pScanMngr->currentTSF += 
+                    ((os_timeStampMs( pScanMngr->hOS ) - pScanMngr->currentHostTimeStamp) * 1000);
+
+                /* build scan command */
+                scanMngrBuildTrackScanCommand( hScanMngr, aPolicy, RADIO_BAND_5_0_GHZ );
+
+                /* if channels are available for tracking on A */
+                if ( 0 < pScanMngr->scanParams.numOfChannels )
+                {
+                    /* mark that continuous scan is now tracking on A */
+                    pScanMngr->contScanState = SCAN_CSS_TRACKING_A_BAND;
+
+                    /* send scan command */
+                    nextResultStatus = 
+                        scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT, &(pScanMngr->scanParams) );
+                    if ( SCAN_CRS_SCAN_RUNNING != nextResultStatus )
+                    {
+                        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                             ("Failed to start tracking continuous scan on band A, return code %d.\n", resultStatus) );
+#ifdef TI_DBG
+                        pScanMngr->stats.TrackingAByStatus[ nextResultStatus ]++;
+#endif
+                        pScanMngr->contScanState = SCAN_CSS_IDLE;
+                    }
+#ifdef SCAN_MNGR_DBG
+                    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                             ("Tracking on A started.\n") );
+#endif
+                    return;
+                }
+            }
+            /* in case a TSF error was received on last continuous scan cycle, mark (now, that tracking
+               on both bands was attempted), that TSF values are synchronized */
+            pScanMngr->bSynchronized = TRUE;
+            
+            /* the break is missing on purpose: if tracking on A was not successful (or not needed), continue to discovery */
+
+        case SCAN_CSS_TRACKING_A_BAND:
+#ifdef TI_DBG
+            /* update stats - since there's no break above, we must check that the state is indeed tracking on A */
+            if ( SCAN_CSS_TRACKING_A_BAND == pScanMngr->contScanState )
+            {
+                pScanMngr->stats.TrackingAByStatus[ resultStatus ]++;
+            }
+#endif
+            WLAN_REPORT_INFORMATION(pScanMngr->hReport , SCAN_MNGR_MODULE_LOG , ("\n SCAN_CSS_TRACKING_A_BAND \n" )) ;
+            /* if necessary and possible, attempt discovery */
+            if ( (SCAN_SDP_NO_DISCOVERY != pScanMngr->currentDiscoveryPart) &&
+                 (pScanMngr->BSSList.numOfEntries <= pScanMngr->scanPolicy.BSSNumberToStartDiscovery) )
+            {
+                /* build scan command */
+                scanMngrBuildDiscoveryScanCommand( hScanMngr );
+
+                /* if channels are available for discovery */
+                if ( 0 < pScanMngr->scanParams.numOfChannels )
+                {
+                    /* mark that continuous scan is now in discovery state */
+                    pScanMngr->contScanState = SCAN_CSS_DISCOVERING;
+
+                    /* mark that no new APs were discovered in this discovery operation */
+                    pScanMngr->bNewBSSFound = FALSE;
+
+                    /* send scan command */
+                    nextResultStatus = 
+                        scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT, &(pScanMngr->scanParams) );
+                    if ( SCAN_CRS_SCAN_RUNNING != nextResultStatus )
+                    {
+                        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                             ("Failed to start discovery continuous scan, nextResultStatus %d.\n", nextResultStatus) );
+                        pScanMngr->contScanState = SCAN_CSS_IDLE;
+                    }
+#ifdef SCAN_MNGR_DBG
+                    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                             ("Disocvery started.\n") );
+#endif
+                    return;
+                }
+            }
+
+            /* the break is missing on purpose: if discovery was not successful (or not needed), finish scan cycle */
+
+        case SCAN_CSS_DISCOVERING:
+#ifdef TI_DBG
+            /* update stats - since there's no break above, we must check that the state is indeed discocery */
+            if ( SCAN_CSS_DISCOVERING == pScanMngr->contScanState )
+            {
+                if ( RADIO_BAND_2_4_GHZ == pScanMngr->statsLastDiscoveryBand )
+                {
+                    pScanMngr->stats.DiscoveryGByStatus[ resultStatus ]++;
+                }
+                else
+                {
+                    pScanMngr->stats.DiscoveryAByStatus[ resultStatus ]++;
+                }
+            }
+#endif
+            /* continuous scan cycle is complete */
+            pScanMngr->contScanState = SCAN_CSS_IDLE;
+
+            break;
+
+        case SCAN_CSS_STOPPING:
+            /* continuous scan cycle is complete */
+            pScanMngr->contScanState = SCAN_CSS_IDLE;
+            break;
+
+        default:
+            /* should not be at any other stage when CB is invoked */
+            WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Continuous scan CB called with scan complete OK reason in state:%d\n", pScanMngr->contScanState) );
+            
+            /* reset continuous scan to idle */
+            pScanMngr->contScanState = SCAN_CSS_IDLE;
+            pScanMngr->bNewBSSFound = FALSE;
+            break;
+        }
+        break;
+
+    /* SPS scan was completed with TSF error */
+    case SCAN_CRS_TSF_ERROR:
+        /* report the recovery event */
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                                 ("Continuous scan callback called with TSF error indication\n") );
+        /* mark that the TSF values are no longer valid */
+        pScanMngr->bSynchronized = FALSE;
+#ifdef TI_DBG
+        switch ( pScanMngr->contScanState )
+        {
+        case SCAN_CSS_TRACKING_G_BAND:
+            pScanMngr->stats.TrackingGByStatus[ resultStatus ]++;
+            break;
+
+        case SCAN_CSS_TRACKING_A_BAND:
+            pScanMngr->stats.TrackingAByStatus[ resultStatus ]++;
+            break;
+
+        default:
+            break;
+        }
+#endif
+        /* stop continuous scan cycle for this time (to avoid tracking using discovery only on A, thus 
+           having mixed results - some are synchronized, some are not */
+        pScanMngr->contScanState = SCAN_CSS_IDLE;
+        break;
+
+    default:
+        /* report the status received */
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Continuous scan CB called with status %d\n", resultStatus) );
+
+        /* also perform aging (since it does not increase counter, no harm done if this was not tracking */
+        scanMngrPerformAging( hScanMngr );
+#ifdef TI_DBG
+        switch ( pScanMngr->contScanState )
+        {
+        case SCAN_CSS_TRACKING_G_BAND:
+            pScanMngr->stats.TrackingGByStatus[ resultStatus ]++;
+            break;
+
+        case SCAN_CSS_TRACKING_A_BAND:
+            pScanMngr->stats.TrackingAByStatus[ resultStatus ]++;
+            break;
+
+        case SCAN_CSS_DISCOVERING:
+            if ( RADIO_BAND_2_4_GHZ == pScanMngr->statsLastDiscoveryBand )
+            {
+                pScanMngr->stats.DiscoveryGByStatus[ resultStatus ]++;
+            }
+            else
+            {
+                pScanMngr->stats.DiscoveryGByStatus[ resultStatus ]++;
+            }
+        default:
+            break;
+        }
+#endif  
+        /* finish scan for this iteration */
+        pScanMngr->contScanState = SCAN_CSS_IDLE;
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 08-Mar-2005\n
+ * \brief Parses and executes a get param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param pParam - the param to get.\n
+ * \return OK if the parameter was get successfully, NOK otherwise.\n
+ */
+TI_STATUS scanMngr_getParam( TI_HANDLE hScanMngr, paramInfo_t *pParam )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_getParam called, hScanMngr=0x%x, pParam=0x%x\n",
+                              hScanMngr, pParam) );
+
+    /* act according to parameter type */
+    switch ( pParam->paramType )
+    {
+    case SCAN_MNGR_BSS_LIST_GET:
+        pParam->content.pScanBssList = scanMngr_getBSSList( hScanMngr );
+        break;
+
+    default:
+        WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                   ("Scan manager getParam called with param type %d.\n", pParam->paramType) );
+        return PARAM_NOT_SUPPORTED;
+/*        break; - unreachable */
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Parses and executes a set param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param pParam - the param to set.\n
+ * \return OK if the parameter was set successfully, NOK otherwise.\n
+ */
+TI_STATUS scanMngr_setParam( TI_HANDLE hScanMngr, paramInfo_t *pParam )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_setParam called, hScanMngr=0x%x, pParam=0x%x, pParam->paramType=%d, "
+                              "pParam->content.applicationConfigBuffer.buffer=0x%x, "
+                              "pParam->content.applicationConfigBuffer.bufferSize=%d.\n",
+                              hScanMngr, pParam, pParam->paramType, pParam->content.applicationConfigBuffer.buffer,
+                              pParam->content.applicationConfigBuffer.bufferSize) );
+    
+    /* act according to parameter type */
+    switch ( pParam->paramType )
+    {
+    case SCAN_MNGR_SET_CONFIGURATION:
+        if ( sizeof(scan_Policy_t) != pParam->content.applicationConfigBuffer.bufferSize )
+        {
+            WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                               ("Scan manager set configuration received with wrong buffer size %d.\n", 
+                                pParam->content.applicationConfigBuffer.bufferSize) );
+            return NOK;
+        }
+        scanMngr_setScanPolicy( hScanMngr, (scan_Policy_t*)(pParam->content.applicationConfigBuffer.buffer)  );
+        break;
+        
+    default:
+        WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                           ("Set param, Params is not supported:%d\n", pParam->paramType) );
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Sets the scan policy.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanPolicy - a pointer to the policy data.\n
+ */
+void scanMngr_setScanPolicy( TI_HANDLE hScanMngr, scan_Policy_t* scanPolicy )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngr_setScanPolicy called, hScanMngr=0x%x.\n", hScanMngr) );
+#ifdef SCAN_MNGR_DBG
+    scanMngrTracePrintScanPolicy( scanPolicy );
+#endif
+
+    /* if continuous or immediate scan are running, indicate that they shouldn't proceed to next scan (if any),
+       and stop the scan operation (in case a triggered scan was in progress and the voice was stopped, the scan
+       must be stopped or a recovery will occur */
+    if ( pScanMngr->contScanState != SCAN_CSS_IDLE )
+    {
+        pScanMngr->contScanState = SCAN_CSS_STOPPING;
+        scanConcentrator_stopScan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT );
+    }
+    if ( pScanMngr->immedScanState != SCAN_ISS_IDLE )
+    {
+        pScanMngr->immedScanState = SCAN_ISS_STOPPING;
+        scanConcentrator_stopScan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_IMMED );
+    }
+
+    /* set new scan policy */
+    os_memoryCopy( pScanMngr->hOS, &(pScanMngr->scanPolicy), scanPolicy, sizeof(scan_Policy_t) );
+
+    /* remove all tracked APs that are not on a policy defined channel (neighbor APs haven't changed,
+       so there's no need to check them */
+    scanMngrUpdateBSSList( hScanMngr, FALSE, TRUE );
+
+    /* if continuous scan timer is running, stop it */
+    if ( TRUE == pScanMngr->bTimerRunning )
+    {
+        os_timerStop( pScanMngr->hOS, pScanMngr->hContinuousScanTimer );
+        pScanMngr->bTimerRunning = FALSE;
+    }
+
+    /* if continuous scan was started, start the timer using the new intervals */
+    if ( TRUE == pScanMngr->bContinuousScanStarted )
+    {
+        pScanMngr->bTimerRunning = TRUE;
+        os_timerStart( pScanMngr->hOS, pScanMngr->hContinuousScanTimer, 
+                       (FALSE == pScanMngr->bLowQuality ? 
+                        pScanMngr->scanPolicy.normalScanInterval : 
+                        pScanMngr->scanPolicy.deterioratingScanInterval), 
+                       TRUE );
+    }
+
+    /* reset discovery counters */
+    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_2_4_GHZ ] = 0;
+    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_5_0_GHZ ] = 0;
+    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_2_4_GHZ ] = 0;
+    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_5_0_GHZ ] = 0;
+    /* set current discovery part to first part */
+    pScanMngr->currentDiscoveryPart = SCAN_SDP_NEIGHBOR_G;
+    /* now advance discovery part to first valid part */
+    scanMngrSetNextDiscoveryPart( hScanMngr );
+}
+
+/**
+ * \author Terence Zaoui\n
+ * \date 06-Feb-2006\n
+ * \brief CB function for current TSF and last beacon TSF and DTIM read.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param status - read status (OK / NOK).\n
+ * \param CB_buf - a pointer to the data read.\n
+ */
+void scanMngrGetCurrentTsfDtimMibCB(TI_HANDLE hScanMngr, TI_STATUS status, UINT8* CB_buf) 
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    
+    os_memoryCopy(pScanMngr->hOS, (UINT8*)&(pScanMngr->currTsfDtimMib) , CB_buf , sizeof(tsf_dtim_mib_t) ) ;
+
+    /* set the current TSF and last beacon TSF and DTIM count */
+    INT64_HIGHER( pScanMngr->currentTSF ) = pScanMngr->currTsfDtimMib.CurrentTSFHigh;
+    INT64_LOWER( pScanMngr->currentTSF )  = pScanMngr->currTsfDtimMib.CurrentTSFLow;
+
+    INT64_HIGHER( pScanMngr->lastLocalBcnTSF ) = pScanMngr->currTsfDtimMib.lastTBTTHigh;
+    INT64_LOWER( pScanMngr->lastLocalBcnTSF )  = pScanMngr->currTsfDtimMib.lastTBTTLow;
+    
+    pScanMngr->lastLocalBcnDTIMCount = pScanMngr->currTsfDtimMib.LastDTIMCount;
+    
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport , SCAN_MNGR_MODULE_LOG , 
+                             ("\n currentTSF = %u-%u lastLocalBcnTSF = %u-%u lastDTIMCount = %d \n",
+                             INT64_HIGHER( pScanMngr->currentTSF ), INT64_LOWER( pScanMngr->currentTSF ),
+                             INT64_HIGHER( pScanMngr->lastLocalBcnTSF ), INT64_LOWER( pScanMngr->lastLocalBcnTSF ),
+                             pScanMngr->lastLocalBcnDTIMCount ) );
+
+    /* get the current host time stamp */
+    pScanMngr->currentHostTimeStamp = os_timeStampMs( pScanMngr->hOS );
+
+    /* now that the current TSF and last beacon TSF had been retrieved from the FW,
+       continuous scan may proceed */
+    scanMngrPerformContinuousScan(hScanMngr);
+}
+
+/**
+ * \author Terence Zaoui\n
+ * \date 06-Feb-2006\n
+ * \brief requests current TSF and last beacon TSF and DTIM from the FW.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_GetUpdatedTsfDtimMibForScan( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    whalParamInfo_t         whalParam;
+    TI_STATUS reqStatus = OK;
+    
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport , SCAN_MNGR_MODULE_LOG , 
+                             ("\nscanMngr_GetUpdatedTsfDtimMibForScan called\n") );
+    
+    /* Getting the current TSF and DTIM values */
+    whalParam.paramType = HAL_CTRL_TSF_DTIM_MIB;
+    whalParam.content.interogateCmdCBParams.CB_Func = (void *)scanMngrGetCurrentTsfDtimMibCB;
+    whalParam.content.interogateCmdCBParams.CB_handle = hScanMngr;
+    whalParam.content.interogateCmdCBParams.CB_buf = (UINT8*)(&(pScanMngr->currTsfDtimMib));
+    reqStatus = whalCtrl_GetParam( pScanMngr->hHalCtrl, &whalParam );
+    if ( OK != reqStatus )
+    {
+        WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                           ("%s: getParam from HAL CTRL failed wih status: %d\n",
+                            __FUNCTION__, reqStatus) );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Starts a continuous scan operation.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrPerformContinuousScan( TI_HANDLE hScanMngr )
+{
+
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    scan_bandPolicy_t *gPolicy, *aPolicy;
+    scan_cncnResultStatus_e resultStatus;
+    paramInfo_t param;
+
+#ifdef SCAN_MNGR_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("scanMngrPerformContinuousScan called, hScanMngr=0x%x.\n", hScanMngr) );
+    scanMngrDebugPrintBSSList( hScanMngr );
+#endif
+    
+    /* this function is called due to continuous scan timer expiry, to start a new continuous scan cycle.
+       If the continuous scan is anything but idle, a new cycle is not started. */
+    if ( SCAN_CSS_IDLE != pScanMngr->contScanState )
+    {
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Continuous scan timer expired and continuous scan state is:%d\n", pScanMngr->contScanState) );
+        return;
+    }
+
+    /* retrieve the current BSS DTIM period and beacon interval, for SPS DTIM avoidance
+       calculations later. This is done before the continuous scan process is started, 
+       to check that they are not zero (in case the STA disconnected and somehow the 
+       scan manager was not notified of the event). If the STA disconnected, the continuous
+       scan process is aborted */
+    param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
+    siteMgr_getParam( pScanMngr->hSiteMngr, &param );
+    pScanMngr->currentBSSBeaconInterval = param.content.beaconInterval;
+    
+    param.paramType = SITE_MGR_DTIM_PERIOD_PARAM;
+    siteMgr_getParam( pScanMngr->hSiteMngr, &param );
+    pScanMngr->currentBSSDtimPeriod = param.content.siteMgrDtimPeriod;
+
+    /* now check that none of the above is zero */
+    if ( (0 == pScanMngr->currentBSSBeaconInterval) || (0 == pScanMngr->currentBSSDtimPeriod) )
+    {
+        WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                           ("Trying to start continuous scan cycle but DTIM period=%d and beacon interval=%d\n",
+                            pScanMngr->currentBSSDtimPeriod, pScanMngr->currentBSSBeaconInterval) );
+        return;
+    }
+
+    /* increase the consecutive not found counter */
+    pScanMngr->consecNotFound++;
+
+    /* first try tracking on G */
+    gPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_2_4_GHZ );
+    /* if a policy is defined for G band tracking, attempt to perform it */
+    if ( (NULL != gPolicy) &&
+         (SCAN_TYPE_NO_SCAN != gPolicy->trackingMethod.scanType) )
+    {
+        /* build scan command */
+        scanMngrBuildTrackScanCommand( hScanMngr, gPolicy, RADIO_BAND_2_4_GHZ );
+
+        /* if channels are available for tracking on G */
+        if ( 0 < pScanMngr->scanParams.numOfChannels )
+        {
+            /* mark that continuous scan is now tracking on G */
+            pScanMngr->contScanState = SCAN_CSS_TRACKING_G_BAND;
+
+            /* send scan command */
+            resultStatus = scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT, &(pScanMngr->scanParams) );
+            if ( SCAN_CRS_SCAN_RUNNING != resultStatus )
+            {
+                WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Failed to start tracking continuous scan on G, return code %d.\n", resultStatus) );
+#ifdef TI_DBG
+                pScanMngr->stats.TrackingGByStatus[ resultStatus ]++;
+#endif
+                pScanMngr->contScanState = SCAN_CSS_IDLE;
+            }
+#ifdef SCAN_MNGR_DBG
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                         ("Tracking on G started.\n") );
+#endif            
+            return;
+        }
+    }
+
+    /* if not, try tracking on A */
+    aPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_5_0_GHZ );
+    /* if a policy is defined for A band tracking, attempt to perform it */
+    if ( (NULL != aPolicy) &&
+         (SCAN_TYPE_NO_SCAN != aPolicy->trackingMethod.scanType) )
+    {
+        /* build scan command */
+        scanMngrBuildTrackScanCommand( hScanMngr, aPolicy, RADIO_BAND_5_0_GHZ );
+
+        /* if channels are available for tracking on A */
+        if ( 0 < pScanMngr->scanParams.numOfChannels )
+        {
+            /* mark that continuous scan is now tracking on A */
+            pScanMngr->contScanState = SCAN_CSS_TRACKING_A_BAND;
+
+            /* send scan command */
+            resultStatus = scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT, &(pScanMngr->scanParams) );
+            if ( SCAN_CRS_SCAN_RUNNING != resultStatus )
+            {
+                WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Failed to start tracking continuous scan on A, return code %d.\n", resultStatus) );
+#ifdef TI_DBG
+                pScanMngr->stats.TrackingAByStatus[ resultStatus ]++;
+#endif
+                pScanMngr->contScanState = SCAN_CSS_IDLE;
+            }
+#ifdef SCAN_MNGR_DBG
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                         ("Tracking on A started.\n") );
+#endif
+            return;
+        }
+    }
+    /* in case a TSF error was received on last continuous scan cycle, mark (now, that tracking
+       on both bands was attempted), that TSF values are synchronized */
+    pScanMngr->bSynchronized = TRUE;                   
+
+    /* if this does not work as well, try discovery */
+    /* discovery can be performed if discovery part is valid (this is maintained whenever a new policy or neighbor AP list
+       is set, a discovery scan command is built, and a new neighbor AP is discovered) */
+    if ( (SCAN_SDP_NO_DISCOVERY != pScanMngr->currentDiscoveryPart) &&
+         (pScanMngr->BSSList.numOfEntries <= pScanMngr->scanPolicy.BSSNumberToStartDiscovery) )
+    {
+        /* build scan command */
+        scanMngrBuildDiscoveryScanCommand( hScanMngr );
+
+        /* if channels are available for discovery */
+        if ( 0 < pScanMngr->scanParams.numOfChannels )
+        {
+            /* mark that continuous scan is now in discovery state */
+            pScanMngr->contScanState = SCAN_CSS_DISCOVERING;
+
+            /* mark that no new BSS's were found (yet) */
+            pScanMngr->bNewBSSFound = FALSE;
+
+            /* send scan command */
+            resultStatus = scanConcentrator_scan( pScanMngr->hScanCncn, SCAN_SCC_ROAMING_CONT, &(pScanMngr->scanParams) );
+            if ( SCAN_CRS_SCAN_RUNNING != resultStatus )
+            {
+                WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Failed to start discovery continuous scan, resultStatus %d.\n", resultStatus) );
+#ifdef TI_DBG
+                if ( RADIO_BAND_2_4_GHZ == pScanMngr->statsLastDiscoveryBand )
+                {
+                    pScanMngr->stats.DiscoveryGByStatus[ resultStatus ]++;
+                }
+                else
+                {
+                    pScanMngr->stats.DiscoveryAByStatus[ resultStatus ]++;
+                }
+#endif
+                pScanMngr->contScanState = SCAN_CSS_IDLE;
+            }
+#ifdef SCAN_MNGR_DBG
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                 ("Discovery started.\n") );
+#endif
+            return;
+        }
+    }
+
+    /* if we got here, no scan had executed successfully - print a warning */
+    WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                         ("Unable to perform continuous scan.\n") );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Perform aging on the BSS list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrPerformAging( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    UINT8 BSSEntryIndex;
+
+#ifdef SCAN_MNGR_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Performing Aging.\n") );
+#endif
+    /* loop on all entries in the BSS list */
+    for ( BSSEntryIndex = 0; BSSEntryIndex < pScanMngr->BSSList.numOfEntries; )
+    {
+        /* if an entry failed enough consecutive track attempts - remove it */
+        if ( pScanMngr->BSSList.scanBSSList[ BSSEntryIndex ].trackFailCount > 
+             pScanMngr->scanPolicy.maxTrackFailures )
+        {
+            /* will replace this entry with one further down the array, if any. Therefore, index is not increased
+               (because a new entry will be placed in the same index). If this is the last entry - the number of
+               BSSes will be decreased, and thus the loop will exit */
+#ifdef SCAN_MNGR_DBG
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Aging: removing BSSID %2x:%2x:%2x:%2x:%2x:%2x from index: %d.\n",
+                                      pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID.addr[ 0 ],
+                                      pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID.addr[ 1 ],
+                                      pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID.addr[ 2 ], 
+                                      pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID.addr[ 3 ], 
+                                      pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID.addr[ 4 ], 
+                                      pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID.addr[ 5 ], 
+                                      pScanMngr->BSSList.numOfEntries) );
+#endif
+            scanMngrRemoveBSSListEntry( hScanMngr, BSSEntryIndex );
+        }
+        else
+        {
+            BSSEntryIndex++;
+        }
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Updates object data according to a received frame.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param frameInfo - pointer to frame related information.\n
+ */
+void scanMngrUpdateReceivedFrame( TI_HANDLE hScanMngr, scan_frameInfo_t* frameInfo )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int BSSListIndex, neighborAPIndex;
+    scan_bandPolicy_t* pBandPolicy;
+
+#ifdef SCAN_MNGR_DBG
+    scanMngrDebugPrintReceivedFrame( hScanMngr, frameInfo );
+#endif
+#ifdef TI_DBG
+    pScanMngr->stats.receivedFrames++;
+#endif
+    /* first check if the frame pass RSSI threshold. If not discard it and continue */
+    pBandPolicy = scanMngrGetPolicyByBand( hScanMngr, frameInfo->band );
+    if ( NULL == pBandPolicy ) /* sanity checking */
+    {
+        WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                           ("Recieved framed on band %d, for which policy is not defined!\n", frameInfo->band) );
+#ifdef TI_DBG
+        pScanMngr->stats.discardedFramesOther++;
+#endif
+        return;
+    }
+
+    if ( frameInfo->rssi < pBandPolicy->rxRSSIThreshold )
+    {
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Discarding frame beacuse RSSI %d is lower than threshold %d\n",
+                                  frameInfo->rssi, pBandPolicy->rxRSSIThreshold) );
+#ifdef TI_DBG
+        pScanMngr->stats.discardedFramesLowRSSI++;
+#endif
+        return;
+    }
+    
+    /* search for this AP in the tracking list */
+    BSSListIndex = scanMngrGetTrackIndexByBssid( hScanMngr, frameInfo->bssId );
+
+    /* if the frame received from an AP in the track list */
+    if ( -1 != BSSListIndex )
+    {
+        scanMngrUpdateBSSInfo( hScanMngr, BSSListIndex, frameInfo );
+    }
+    /* otherwise, if the list is not full and AP is either a neighbor AP or on a policy defined channel: */
+    else 
+    {
+        neighborAPIndex = scanMngrGetNeighborAPIndex( hScanMngr, frameInfo->band, frameInfo->bssId );
+
+        if ( (pScanMngr->BSSList.numOfEntries < pScanMngr->scanPolicy.BSSListSize) &&
+             ((TRUE == scanMngrIsPolicyChannel( hScanMngr, frameInfo->band, frameInfo->channel )) ||
+              (-1 != neighborAPIndex)) ) 
+        {
+            /* insert the AP to the list */
+            scanMngrInsertNewBSSToTrackingList( hScanMngr, frameInfo );
+
+            /* if this is a neighbor AP */
+            if ( -1 != neighborAPIndex )
+            {
+                /* mark in the neighbor AP list that it's being tracked */
+                pScanMngr->neighborAPsDiscoveryList[ frameInfo->band ].trackStatusList[ neighborAPIndex ] = SCAN_NDS_DISCOVERED;
+
+                /* if the discovery index for this neighbor AP band points to this AP, 
+                   advance it and advance discovery part if needed */
+                if ( pScanMngr->neighborAPsDiscoveryIndex[ frameInfo->band ] == neighborAPIndex )
+                {
+                    do {
+                        pScanMngr->neighborAPsDiscoveryIndex[ frameInfo->band ]++; /* advance discovery index */
+                    /* while discovery list is not exhausted and no AP for discovery is found */
+                    } while ( (pScanMngr->neighborAPsDiscoveryIndex[ frameInfo->band ] < pScanMngr->neighborAPsDiscoveryList[ frameInfo->band ].numOfEntries) &&
+                              (SCAN_NDS_NOT_DISCOVERED != pScanMngr->neighborAPsDiscoveryList[ frameInfo->band ].trackStatusList[ pScanMngr->neighborAPsDiscoveryIndex[ frameInfo->band ] ]) );
+                    /* if discovery list isexhausted */
+                    if ( pScanMngr->neighborAPsDiscoveryIndex[ frameInfo->band ] == pScanMngr->neighborAPsDiscoveryList[ frameInfo->band ].numOfEntries )
+                    {
+                        /* restart discovery cycle for this band's neighbor APs */
+                        pScanMngr->neighborAPsDiscoveryIndex[ frameInfo->band ] = 0;
+                        /* set new discovery part (if needed) */
+                        scanMngrSetNextDiscoveryPart( hScanMngr );
+                    }
+                }
+            }
+        }
+#ifdef TI_DBG
+        else
+        {
+            pScanMngr->stats.discardedFramesOther++;
+        }
+#endif
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 17-Mar-2005\n
+ * \brief Cerate a new tracking entry and store the newly discovered AP info in it.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param frameInfo - a pointer to the information received from this AP.\n
+ */
+void scanMngrInsertNewBSSToTrackingList( TI_HANDLE hScanMngr, scan_frameInfo_t* frameInfo )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+#ifdef SCAN_SPS_USE_DRIFT_COMPENSATION
+    int i;
+#endif
+    
+    /* mark that a new AP was discovered (for discovery stage) */
+    pScanMngr->bNewBSSFound = TRUE;
+
+    /* insert fields that are not update regulary */
+    pScanMngr->BSSList.BSSList[ pScanMngr->BSSList.numOfEntries ].bNeighborAP = 
+        ( -1 == scanMngrGetNeighborAPIndex( hScanMngr, frameInfo->band, frameInfo->bssId ) ?
+          FALSE :
+          TRUE );
+    os_memoryCopy( pScanMngr->hOS, 
+                   (void *)&(pScanMngr->BSSList.BSSList[ pScanMngr->BSSList.numOfEntries ].BSSID.addr[ 0 ]), 
+                   (void *)frameInfo->bssId,
+                   MAC_ADDR_LEN );
+
+    /* initialize average RSSI value */
+    pScanMngr->BSSList.BSSList[ pScanMngr->BSSList.numOfEntries ].RSSI = frameInfo->rssi;
+    pScanMngr->BSSList.BSSList[ pScanMngr->BSSList.numOfEntries ].lastRSSI = frameInfo->rssi;
+
+#ifdef SCAN_SPS_USE_DRIFT_COMPENSATION
+    /* initialize previous delta change array (used for SPS drift compensation) */
+    pScanMngr->BSSList.scanBSSList[ pScanMngr->BSSList.numOfEntries ].prevTSFDelta = 0;
+    pScanMngr->BSSList.scanBSSList[ pScanMngr->BSSList.numOfEntries ].deltaChangeArrayIndex = 0;
+    for ( i = 0; i < SCAN_SPS_NUM_OF_TSF_DELTA_ENTRIES; i++ )
+    {
+        pScanMngr->BSSList.scanBSSList[ pScanMngr->BSSList.numOfEntries ].deltaChangeArray[ i ] = 0;
+    }
+#endif
+
+    /* update regular fields */
+    pScanMngr->BSSList.scanBSSList[ pScanMngr->BSSList.numOfEntries ].trackFailCount = 0; /* for correct statistics update */
+    scanMngrUpdateBSSInfo( hScanMngr, pScanMngr->BSSList.numOfEntries, frameInfo );
+
+    /* increase the number of tracked APs */
+    pScanMngr->BSSList.numOfEntries++;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 17-Mar-2005\n
+ * \brief Updates tracked AP information.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param BSSListIndex - index to the BSS list where the AP information is stored.\n
+ * \param frameInfo - a pointer to the information received from this AP.\n
+ */
+void scanMngrUpdateBSSInfo( TI_HANDLE hScanMngr, UINT8 BSSListIndex, scan_frameInfo_t* frameInfo )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    /* update AP data */
+    pScanMngr->BSSList.BSSList[ BSSListIndex ].lastRxHostTimestamp = os_timeStampMs( pScanMngr->hOS );
+    pScanMngr->BSSList.BSSList[ BSSListIndex ].resultType = (frameInfo->parsedIEs->subType == BEACON) ? SCAN_RFT_BEACON : SCAN_RFT_PROBE_RESPONSE;
+    pScanMngr->BSSList.BSSList[ BSSListIndex ].band = frameInfo->band;
+    pScanMngr->BSSList.BSSList[ BSSListIndex ].channel = frameInfo->channel;
+    /* if the received TSF (which is the lower 32 bits) is smaller than the lower 32 bits of the last beacon
+       TSF, it means the higher 32 bits should be increased by 1 (TSF overflow to higher 32 bits occurred between
+       last beacon of current AP and this frame). */
+    if ( INT64_LOWER( (pScanMngr->currentTSF) )  > frameInfo->staTSF )
+    {
+        INT64_HIGHER( (pScanMngr->BSSList.scanBSSList[ BSSListIndex ].localTSF) ) = 
+            INT64_HIGHER( (pScanMngr->currentTSF) ) + 1;
+    }
+    else
+    {
+        INT64_HIGHER( (pScanMngr->BSSList.scanBSSList[ BSSListIndex ].localTSF) ) = 
+            INT64_HIGHER( (pScanMngr->currentTSF) );
+    }
+    INT64_LOWER( (pScanMngr->BSSList.scanBSSList[ BSSListIndex ].localTSF) ) = frameInfo->staTSF;
+    
+    if ( BEACON == frameInfo->parsedIEs->subType )
+    {
+        os_memoryCopy( pScanMngr->hOS, &(pScanMngr->BSSList.BSSList[ BSSListIndex ].lastRxTSF),
+                       (void *)frameInfo->parsedIEs->content.iePacket.timestamp, TIME_STAMP_LEN );
+        pScanMngr->BSSList.BSSList[ BSSListIndex ].beaconInterval = 
+            frameInfo->parsedIEs->content.iePacket.beaconInerval;
+        pScanMngr->BSSList.BSSList[ BSSListIndex ].capabilities = 
+            frameInfo->parsedIEs->content.iePacket.capabilities;
+    }
+    else
+    {
+        os_memoryCopy( pScanMngr->hOS, &(pScanMngr->BSSList.BSSList[ BSSListIndex ].lastRxTSF),
+                       (void *)frameInfo->parsedIEs->content.iePacket.timestamp, TIME_STAMP_LEN );
+        pScanMngr->BSSList.BSSList[ BSSListIndex ].beaconInterval = 
+            frameInfo->parsedIEs->content.iePacket.beaconInerval;
+        pScanMngr->BSSList.BSSList[ BSSListIndex ].capabilities = 
+            frameInfo->parsedIEs->content.iePacket.capabilities;
+    }
+#ifdef TI_DBG
+    /* 
+       update track fail histogram:
+       1. only done when tracking (to avoid updating due to "accidental re-discovery"
+       2. only done for APs which have their track fail count larger than 0. The reason for that is because
+          when tracking is started, the track fail count is increased, and thus if it is 0 tracking was not
+          attempted for this AP, or more than one frame was received as a result of tracking operation for the AP.
+    */
+    if ( ((SCAN_CSS_TRACKING_A_BAND == pScanMngr->contScanState) ||
+          (SCAN_CSS_TRACKING_G_BAND == pScanMngr->contScanState)) &&
+         (0 < pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount) )
+    {
+        if ( SCAN_MNGR_STAT_MAX_TRACK_FAILURE <= 
+            pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount )
+        {
+            pScanMngr->stats.ConsecutiveTrackFailCountHistogram[ SCAN_MNGR_STAT_MAX_TRACK_FAILURE - 1 ]++;
+        }
+        else
+        {
+            pScanMngr->stats.ConsecutiveTrackFailCountHistogram[ pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount - 1 ]++;
+        }
+    }
+#endif
+    pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount = 0;
+
+    /* update RSSI value */
+    {
+        INT8    rssiPrevVal = pScanMngr->BSSList.BSSList[ BSSListIndex ].RSSI;
+        INT8    tmpRssiAvg = ((RSSI_PREVIOUS_COEFFICIENT * rssiPrevVal) +
+                              ((10-RSSI_PREVIOUS_COEFFICIENT) * frameInfo->rssi)) / 10;
+
+        pScanMngr->BSSList.BSSList[ BSSListIndex ].lastRSSI = frameInfo->rssi;
+        
+        if (rssiPrevVal!=0)
+        {
+             /* for faster convergence on RSSI changes use rounding error calculation with latest sample and not 
+                on latest average */
+            if (frameInfo->rssi > tmpRssiAvg)
+                tmpRssiAvg++;
+            else
+                if (frameInfo->rssi < tmpRssiAvg)
+                    tmpRssiAvg--;
+        
+            pScanMngr->BSSList.BSSList[ BSSListIndex ].RSSI = tmpRssiAvg;
+        }
+        else
+        {
+            pScanMngr->BSSList.BSSList[ BSSListIndex ].RSSI = frameInfo->rssi;
+        }
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("given RSSI=%d, AVRG RSSI=%d\n", 
+                                  frameInfo->rssi,
+                                  pScanMngr->BSSList.BSSList[ BSSListIndex ].RSSI));
+
+    }
+
+    pScanMngr->BSSList.BSSList[ BSSListIndex ].rxRate = frameInfo->rate;
+    os_memoryCopy( pScanMngr->hOS, pScanMngr->BSSList.BSSList[ BSSListIndex ].pBuffer, 
+                   frameInfo->buffer, frameInfo->bufferLength );    
+    pScanMngr->BSSList.BSSList[ BSSListIndex ].bufferLength = frameInfo->bufferLength;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 16-Mar-2005\n
+ * \brief Search tracking list for an entry matching given BSSID.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bssId - the BSSID to search for.\n
+ * \return entry index if found, -1 if no entry matching the BSSID was found.\n
+ */
+INT8 scanMngrGetTrackIndexByBssid( TI_HANDLE hScanMngr, macAddress_t* bssId )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    for ( i = 0; i < pScanMngr->BSSList.numOfEntries; i++ )
+    {
+        if ( 0 == os_memoryCompare( pScanMngr->hOS, (UINT8*)bssId, 
+                                    (UINT8*)&(pScanMngr->BSSList.BSSList[ i ].BSSID) , MAC_ADDR_LEN ) )
+        {
+            return i;
+        }
+    }
+    return -1;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Search current policy for band policy
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param band - the band to find policy for.\n
+ * \return the policy structure if found, NULL if no policy configured for this band.\n
+ */
+scan_bandPolicy_t* scanMngrGetPolicyByBand( TI_HANDLE hScanMngr, radioBand_e band )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    /* loop on all configured policies, and look for the requested band */
+    for ( i = 0; i < pScanMngr->scanPolicy.numOfBands; i++ )
+    {
+        if ( band == pScanMngr->scanPolicy.bandScanPolicy[ i ].band )
+        {
+            return &(pScanMngr->scanPolicy.bandScanPolicy[ i ]);
+        }
+    }
+
+    /* if no policy was found, there's no policy configured for the requested band */
+    return NULL;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Sets the next discovery part according to current discovery part, policies and neighbor APs availability .\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrSetNextDiscoveryPart( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    scan_discoveryPart_e nextDiscoveryPart, originalDiscoveryPart;
+    
+    /* sanity check - if discovery part is not valid, restart from first discovery part */
+    if ( SCAN_SDP_NO_DISCOVERY <= pScanMngr->currentDiscoveryPart )
+    {
+        pScanMngr->currentDiscoveryPart = SCAN_SDP_NEIGHBOR_G;
+    }
+
+    /* if current discovery part is valid, do nothing */
+    if ( TRUE == scanMngrIsDiscoveryValid( hScanMngr, pScanMngr->currentDiscoveryPart ) )
+    {
+        return;
+    }
+
+    /* next discovery part is found according to current part, in the following order:
+       Neighbor APs on G, Neighbor APs on A, Channel list on G, Channel list on A */
+    /* get next discovery part */
+    nextDiscoveryPart = pScanMngr->currentDiscoveryPart;
+    originalDiscoveryPart = pScanMngr->currentDiscoveryPart;
+
+    do
+    {
+        nextDiscoveryPart++;
+        /* loop back to first discovery part if discovery list end had been reached */
+        if ( SCAN_SDP_NO_DISCOVERY == nextDiscoveryPart )
+        {
+            nextDiscoveryPart = SCAN_SDP_NEIGHBOR_G;
+        }
+    /* try next discovery part until first one is reached again or a valid part is found */
+    } while( (nextDiscoveryPart != originalDiscoveryPart) &&
+             (FALSE == scanMngrIsDiscoveryValid( hScanMngr, nextDiscoveryPart )) );
+
+    /* if a discovery part for which discovery is valid was found, use it */
+    if ( TRUE == scanMngrIsDiscoveryValid( hScanMngr, nextDiscoveryPart ) )
+    {
+        pScanMngr->currentDiscoveryPart = nextDiscoveryPart;
+    }
+    /* otherwise don't do discovery */
+    else
+    {
+        pScanMngr->currentDiscoveryPart = SCAN_SDP_NO_DISCOVERY;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Checks whether discovery should be performed on the specified discovery part.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param discoveryPart - the discovery part to check.\n
+ */
+BOOLEAN scanMngrIsDiscoveryValid( TI_HANDLE hScanMngr, scan_discoveryPart_e discoveryPart )
+{
+    scanMngr_t* pScanMngr = (TI_HANDLE)hScanMngr;
+    scan_bandPolicy_t *gPolicy, *aPolicy;
+
+    gPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_2_4_GHZ );
+    aPolicy = scanMngrGetPolicyByBand( hScanMngr, RADIO_BAND_5_0_GHZ );
+
+    switch (discoveryPart)
+    {
+    case SCAN_SDP_NEIGHBOR_G:
+        /* for discovery on G neighbor APs, a policy must be defined for G, discovery scan type should be present,
+           number of neighbor APs on G should be greater than zero, and at least one AP should be yet undiscovered */
+        if ( (NULL != gPolicy) &&
+             (SCAN_TYPE_NO_SCAN != gPolicy->discoveryMethod.scanType) &&
+             (0 < pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_2_4_GHZ ].numOfEntries) &&
+             (TRUE == scanMngrNeighborAPsAvailableForDiscovery( hScanMngr, RADIO_BAND_2_4_GHZ )) )
+        {
+            return TRUE;
+        }
+        else
+        {
+            return FALSE;
+        }
+/*        break; - unreachable */
+
+    case SCAN_SDP_NEIGHBOR_A:
+        /* for discovery on A neighbor APs, a policy must be defined for A, discovery scan type should be present,
+           number of neighbor APs on A should be greater than zero, and at least one AP should be yet undiscovered */
+        if ( (NULL != aPolicy) &&
+             (SCAN_TYPE_NO_SCAN != aPolicy->discoveryMethod.scanType) &&
+             (0 < pScanMngr->neighborAPsDiscoveryList[ RADIO_BAND_5_0_GHZ ].numOfEntries) &&
+             (TRUE == scanMngrNeighborAPsAvailableForDiscovery( hScanMngr, RADIO_BAND_5_0_GHZ )) )
+        {
+            return TRUE;
+        }
+        else
+        {
+            return FALSE;
+        }
+/*        break; - unreachable */
+
+    case SCAN_SDP_CHANNEL_LIST_G:
+        /* for discovery on G channel list, a policy must be defined for G, discovery scan type should be present,
+           and number of channels in G channel list should be greater than zero */
+        if ( (NULL != gPolicy) &&
+             (SCAN_TYPE_NO_SCAN != gPolicy->discoveryMethod.scanType) &&
+             (0 < gPolicy->numOfChannles) )
+        {
+            return TRUE;
+        }
+        else
+        {
+            return FALSE;
+        }
+/*        break; - unreachable */
+
+    case SCAN_SDP_CHANNEL_LIST_A:
+        /* for discovery on A channel list, a policy must be defined for A, discovery scan type should be present,
+           and number of channels in A channel list should be greater than zero */
+        if ( (NULL != aPolicy) &&
+             (SCAN_TYPE_NO_SCAN != aPolicy->discoveryMethod.scanType) &&
+             (0 < aPolicy->numOfChannles) )
+        {
+            return TRUE;
+        }
+        else
+        {
+            return FALSE;
+        }
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Checking whather discovery is valid for discovery part %d", discoveryPart) );
+        return FALSE;
+/*        break; - unreachable */
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 07-Mar-2005\n
+ * \brief Check whether there are neighbor APs to track on the given band.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - The scan policy for the requested band.\n
+ * \param bNeighborAPsOnly - whether to scan for neighbor APs only or for all policy defined channels.\n
+ */
+BOOLEAN scanMngrNeighborAPsAvailableForDiscovery( TI_HANDLE hScanMngr, radioBand_e band )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+
+    /* loop on all neighbor APs of the given band */
+    for ( i = 0; i < pScanMngr->neighborAPsDiscoveryList[ band ].numOfEntries; i++ )
+    {
+        /* if a neighbor AP is not being tracked, meaning it yet has to be discovered, return TRUE */
+        if ( SCAN_NDS_NOT_DISCOVERED == pScanMngr->neighborAPsDiscoveryList[ band ].trackStatusList[ i ] )
+        {
+            return TRUE;
+        }
+    }
+    /* if all neighbor APs are being tracked (or no neighbor APs available) return FALSE */
+    return FALSE;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Builds a scan command on the object workspace for immediate scan.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - The scan policy for the requested band.\n
+ * \param bNeighborAPsOnly - whether to scan for neighbor APs only or for all policy defined channels.\n
+ */
+void scanMngrBuildImmediateScanCommand( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy, BOOLEAN bNeighborAPsOnly )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int channelIndex;
+    paramInfo_t param;
+    macAddress_t broadcastAddress;
+    int i;
+
+    /* first, build the command header */
+    scanMngrBuildScanCommandHeader( hScanMngr, &(bandPolicy->immediateScanMethod), bandPolicy->band );
+
+    /* if requested to scan on neighbor APs only */
+    if ( TRUE == bNeighborAPsOnly )
+    {
+        /* loop on all neighbor APs */
+        channelIndex = 0;
+        while ( (channelIndex < pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].numOfEntries) && 
+                (pScanMngr->scanParams.numOfChannels < SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND) )
+        {
+            /* verify channel with reg domain */
+            param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+            param.content.channelCapabilityReq.band = bandPolicy->band;
+            if ( (bandPolicy->immediateScanMethod.scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                 (bandPolicy->immediateScanMethod.scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+                 (bandPolicy->immediateScanMethod.scanType == SCAN_TYPE_SPS) )
+            {
+                param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+            }
+            else
+            {
+                param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+            }
+            param.content.channelCapabilityReq.channelNum = 
+                pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].APListPtr[ channelIndex ].channel;
+            regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+            /* if the channel is allowed, insert it to the scan command */
+            if (param.content.channelCapabilityRet.channelValidity)
+            {
+                scanMngrAddNormalChannel( hScanMngr, &(bandPolicy->immediateScanMethod), 
+                                          pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].APListPtr[ channelIndex ].channel,
+                                          &(pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].APListPtr[ channelIndex ].BSSID),
+                                          param.content.channelCapabilityRet.maxTxPowerDbm );
+            }
+            channelIndex++;
+        }
+    }
+    else
+    /* scan on all policy defined channels */
+    {
+        /* set the broadcast address */
+        for ( i = 0; i < MAC_ADDR_LEN; i++ )
+        {
+            broadcastAddress.addr[ i ] = 0xff;
+        }
+
+        /* loop on all channels in the policy */
+        channelIndex = 0;
+        while ( (channelIndex < bandPolicy->numOfChannles) &&
+                (pScanMngr->scanParams.numOfChannels < SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND) )
+        {
+            /* verify channel with reg domain */
+            param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+            param.content.channelCapabilityReq.band = bandPolicy->band;
+            if ( (bandPolicy->immediateScanMethod.scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                 (bandPolicy->immediateScanMethod.scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+                 (bandPolicy->immediateScanMethod.scanType == SCAN_TYPE_SPS) )
+            {
+                param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+            }
+            else
+            {
+                param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+            }
+            param.content.channelCapabilityReq.channelNum = bandPolicy->channelList[ channelIndex ];
+            regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+            /* if the channel is allowed, insert it to the scan command */
+            if (param.content.channelCapabilityRet.channelValidity)
+            {
+                scanMngrAddNormalChannel( hScanMngr, &(bandPolicy->immediateScanMethod), 
+                                          bandPolicy->channelList[ channelIndex ],
+                                          &broadcastAddress,
+                                          param.content.channelCapabilityRet.maxTxPowerDbm );
+            }
+            channelIndex++;
+        }
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 03-Mar-2005\n
+ * \brief Builds a scan command on the object workspace for tracking.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - The scan policy for the band to track on.\n
+ * \param band - the band to scan.\n
+ */
+void scanMngrBuildTrackScanCommand( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy, radioBand_e band )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int BSSListIndex;
+    paramInfo_t param;
+    scan_Method_t* scanMethod;
+
+    WLAN_REPORT_INFORMATION(pScanMngr->hReport , SCAN_MNGR_MODULE_LOG , ("\n scanMngrBuildTrackScanCommand \n" )) ;
+
+
+    /* SPS is performed differently from all other scan types, and only if TSF error has not occured */
+    if ( (SCAN_TYPE_SPS == bandPolicy->trackingMethod.scanType) && (TRUE == pScanMngr->bSynchronized) )
+    {
+        /* build the command header */
+        WLAN_REPORT_INFORMATION(pScanMngr->hReport , SCAN_MNGR_MODULE_LOG ,("\nSPS invoked\n") );
+        scanMngrBuildScanCommandHeader( hScanMngr, &(bandPolicy->trackingMethod), band );
+     
+        /* build the channel list */
+        scanMngrAddSPSChannels( hScanMngr, &(bandPolicy->trackingMethod), band );
+        return;
+    }
+
+    /* the scan method to use is the method defined for tracking, unless this is SPS and TSF error occurred,
+       in which case we use the discovery method this time. */
+    if ( (SCAN_TYPE_SPS == bandPolicy->trackingMethod.scanType) && (FALSE == pScanMngr->bSynchronized) )
+    {
+        /* use discovery scan method */
+        scanMethod = &(bandPolicy->discoveryMethod);
+    }
+    else
+    {
+        /* use tracking method */
+        scanMethod = &(bandPolicy->trackingMethod);
+    }
+
+    /* build the command header */
+    scanMngrBuildScanCommandHeader( hScanMngr, scanMethod, band );
+
+    /* insert channels from tracking list according to requested band */
+    BSSListIndex = 0;
+    while ( (BSSListIndex < pScanMngr->BSSList.numOfEntries) &&
+            (pScanMngr->scanParams.numOfChannels < SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND) )
+    {
+        /* if BSS is on the right band */
+        if ( band == pScanMngr->BSSList.BSSList[ BSSListIndex ].band )
+        {
+            /* verify the channel with the reg domain */
+            param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+            param.content.channelCapabilityReq.band = band;
+            if ( (scanMethod->scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                 (scanMethod->scanType == SCAN_TYPE_TRIGGERED_PASSIVE) )
+            {
+                param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+            }
+            else
+            {
+                param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+            }
+            param.content.channelCapabilityReq.channelNum = pScanMngr->BSSList.BSSList[ BSSListIndex ].channel;
+            regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+            /* if channel is verified for requested scan type */
+            if ( param.content.channelCapabilityRet.channelValidity )
+            {
+                scanMngrAddNormalChannel( hScanMngr, scanMethod, 
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].channel,
+                                          &(pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID),
+                                          param.content.channelCapabilityRet.maxTxPowerDbm );
+
+                /* increase AP track attempts counter */
+                if ( (SCAN_TYPE_SPS == bandPolicy->trackingMethod.scanType) && (FALSE == pScanMngr->bSynchronized) )
+                {
+                    pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount = 
+                        pScanMngr->scanPolicy.maxTrackFailures + 1;
+                }
+                else
+                {
+                    pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount++;
+                }
+            }
+            /* if channel is not verified, there are two options:
+               1. we are using the tracking method, and thus the AP should be removed (because we are unable
+                  to track it)
+               2. we are using the discovery method (because a TSF error occurred and tracking method is SPS).
+                  In this case, it seems we do not have to remove the AP (because the channel may not be valid
+                  for active scan but it is valid for passive scan), but since we had a TSF error the AP would
+                  be removed anyhow if not re-discovered now, so no harm done in removing it as well. */
+            else
+            {
+                /* removing an AP is done by increasing its track failure counter to maximum. Since it is
+                   not tracked, it would not be found, and thus would be removed by aging process performed
+                   at scan completion */
+                pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount = 
+                    pScanMngr->scanPolicy.maxTrackFailures + 1;
+#ifdef TI_DBG
+                /* update statistics */
+                pScanMngr->stats.APsRemovedInvalidChannel++;
+#endif
+            }
+        }
+        BSSListIndex++;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 03-Mar-2005\n
+ * \brief Builds a scan command on the object workspace for discovery.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrBuildDiscoveryScanCommand( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    radioBand_e band;
+    scan_bandPolicy_t* bandPolicy;
+
+    /* find on which band to discover at current cycle */
+    if ( (SCAN_SDP_NEIGHBOR_G == pScanMngr->currentDiscoveryPart) ||
+         (SCAN_SDP_CHANNEL_LIST_G == pScanMngr->currentDiscoveryPart) )
+    {
+        band = RADIO_BAND_2_4_GHZ;
+        bandPolicy = scanMngrGetPolicyByBand( hScanMngr, band );
+    }
+    else
+    {
+        band = RADIO_BAND_5_0_GHZ;
+        bandPolicy = scanMngrGetPolicyByBand( hScanMngr, band );
+    }
+
+    /* first, build the command header */
+    scanMngrBuildScanCommandHeader( hScanMngr, &(bandPolicy->discoveryMethod), band );
+
+    /* channels are added according to current discovery part */
+    switch ( pScanMngr->currentDiscoveryPart )
+    {
+    case SCAN_SDP_NEIGHBOR_G:
+        /* add channels from neighbor AP discovery list */
+        scanMngrAddNeighborAPsForDiscovery( hScanMngr, bandPolicy );
+
+        /* if neighbor AP list is exhausted, proceed to next discovery part */
+        if ( 0 == pScanMngr->neighborAPsDiscoveryIndex[ band ] )
+        {
+            pScanMngr->currentDiscoveryPart++;
+            scanMngrSetNextDiscoveryPart( hScanMngr );
+        }
+
+        /* if need to discover more APs, (not enough neighbor APs), proceed to G channel list */
+        if ( pScanMngr->scanParams.numOfChannels < bandPolicy->numOfChannlesForDiscovery )
+        {
+            scanMngrAddChannelListForDiscovery( hScanMngr, bandPolicy );
+        }
+
+#ifdef TI_DBG
+        pScanMngr->statsLastDiscoveryBand = RADIO_BAND_2_4_GHZ;
+#endif
+        break;
+
+    case SCAN_SDP_NEIGHBOR_A:
+        /* add channels from neighbor AP discovery list */
+        scanMngrAddNeighborAPsForDiscovery( hScanMngr, bandPolicy );
+
+        /* if neighbor AP list is exhausted, proceed to next discovery part */
+        if ( 0 == pScanMngr->neighborAPsDiscoveryIndex[ band ] )
+        {
+            pScanMngr->currentDiscoveryPart++;
+            scanMngrSetNextDiscoveryPart( hScanMngr );
+        }
+
+        /* if need to discover more APs, (not enough neighbor APs), proceed to A channel list */
+        if ( pScanMngr->scanParams.numOfChannels < bandPolicy->numOfChannlesForDiscovery )
+        {
+            scanMngrAddChannelListForDiscovery( hScanMngr, bandPolicy );
+        }
+
+#ifdef TI_DBG
+        pScanMngr->statsLastDiscoveryBand = RADIO_BAND_5_0_GHZ;
+#endif
+        break;
+
+    case SCAN_SDP_CHANNEL_LIST_G:
+        /* add channels from policy channel list */
+        scanMngrAddChannelListForDiscovery( hScanMngr, bandPolicy );
+
+        /* if channel list is exhausted, proceed to next discovery part */
+        if ( 0 == pScanMngr->channelDiscoveryIndex[ band ] )
+        {
+            pScanMngr->currentDiscoveryPart++;
+            scanMngrSetNextDiscoveryPart( hScanMngr );
+        }
+
+        /* if need to discover more APs (not enough channels on channel list), proceed to G neighbor APs */
+        if ( pScanMngr->scanParams.numOfChannels < bandPolicy->numOfChannlesForDiscovery )
+        {
+            scanMngrAddNeighborAPsForDiscovery( hScanMngr, bandPolicy );
+        }
+
+#ifdef TI_DBG
+        pScanMngr->statsLastDiscoveryBand = RADIO_BAND_2_4_GHZ;
+#endif
+        break;
+
+    case SCAN_SDP_CHANNEL_LIST_A:
+        /* add channels from policy channel list */
+        scanMngrAddChannelListForDiscovery( hScanMngr, bandPolicy );
+
+        /* if channel list is exhausted, proceed to next discovery part */
+        if ( 0 == pScanMngr->channelDiscoveryIndex[ band ] )
+        {
+            pScanMngr->currentDiscoveryPart++;
+            scanMngrSetNextDiscoveryPart( hScanMngr );
+        }
+
+        /* if need to discover more APs (not enough channels on channel list), proceed to A neighbor APs */
+        if ( pScanMngr->scanParams.numOfChannels < bandPolicy->numOfChannlesForDiscovery )
+        {
+            scanMngrAddNeighborAPsForDiscovery( hScanMngr, bandPolicy );
+        }
+#ifdef TI_DBG
+        pScanMngr->statsLastDiscoveryBand = RADIO_BAND_5_0_GHZ;
+#endif
+        break;
+
+    case SCAN_SDP_NO_DISCOVERY:
+    default:
+        WLAN_REPORT_ERROR( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                           ("scanMngrBuildDiscoveryScanCommand called and current discovery part is %d",
+                            pScanMngr->currentDiscoveryPart) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Builds the scan command header on the object workspace.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanMethod - The scan method (and parameters) to use.\n
+ * \param band - the band to scan.\n
+ */
+void scanMngrBuildScanCommandHeader( TI_HANDLE hScanMngr, scan_Method_t* scanMethod, radioBand_e band )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+
+    /* set general scan parameters */
+    /* SSID is not set - scan concentrator will set it for the scan manager to current SSID */
+    pScanMngr->scanParams.scanType = scanMethod->scanType;
+    pScanMngr->scanParams.band = band;
+
+    switch (scanMethod->scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+        /* In active scan, the desired SSID is set by the scan concentrator to the current SSID.
+           Stting anything not zero triggers this in the scan concentrator */
+        pScanMngr->scanParams.desiredSsid.len = 1;
+        pScanMngr->scanParams.probeReqNumber = scanMethod->method.basicMethodParams.probReqParams.numOfProbeReqs;
+        pScanMngr->scanParams.probeRequestRate = scanMethod->method.basicMethodParams.probReqParams.bitrate;
+        break;
+
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+        /* In active scan, the desired SSID is set by the scan concentrator to the current SSID.
+           Stting anything not zero triggers this in the scan concentrator */
+        pScanMngr->scanParams.desiredSsid.len = 1;
+        pScanMngr->scanParams.probeReqNumber = scanMethod->method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs;
+        pScanMngr->scanParams.probeRequestRate = scanMethod->method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate;
+        pScanMngr->scanParams.Tid = scanMethod->method.TidTriggerdMethodParams.triggeringTid;
+        break;
+
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+        pScanMngr->scanParams.Tid = scanMethod->method.TidTriggerdMethodParams.triggeringTid;
+        /* In Passive scan, Desired SSID length is set to 0 so that the Scan concentrator won't replace
+           it with the current SSID (to be able to receive beacons from AP's with multiple or hidden
+           SSID) */
+        pScanMngr->scanParams.desiredSsid.len = 0;
+        break;
+
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        /* In Passive scan, Desired SSID length is set to 0 so that the Scan concentrator won't replace
+           it with the current SSID (to be able to receive beacons from AP's with multiple or hidden
+           SSID) */
+        pScanMngr->scanParams.desiredSsid.len = 0;
+        break;
+
+    case SCAN_TYPE_SPS:
+        /* SPS doesn't have SSID filter, it only uses BSSID filter */
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Unrecognized scan type %d when building scan command", scanMethod->scanType) );
+        break;
+    }
+
+    /* set 0 channels - actual channel will be added by caller */
+    pScanMngr->scanParams.numOfChannels = 0;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Add neighbor APs to scan command on the object workspace for discovery scan.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - the scan policy for the band to use.\n
+ */
+void scanMngrAddNeighborAPsForDiscovery( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int neighborAPIndex = pScanMngr->neighborAPsDiscoveryIndex[ bandPolicy->band ];
+    paramInfo_t param;
+
+    /* loop while neighbor AP list has not been exhausted, command is not full and not enough APs for discovery had been found */
+    while ( (pScanMngr->scanParams.numOfChannels < bandPolicy->numOfChannlesForDiscovery) &&
+            (pScanMngr->scanParams.numOfChannels < SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND) &&
+            (neighborAPIndex < pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].numOfEntries) )
+    {
+        /* if the AP is not being tracked */
+        if ( SCAN_NDS_NOT_DISCOVERED == 
+             pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].trackStatusList[ neighborAPIndex ] )
+        {
+            /* verify channel with reg domain */
+            param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+            param.content.channelCapabilityReq.band = bandPolicy->band;
+            if ( (bandPolicy->discoveryMethod.scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                 (bandPolicy->discoveryMethod.scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+                 (bandPolicy->discoveryMethod.scanType == SCAN_TYPE_SPS) )
+            {
+                param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+            }
+            else
+            {
+                param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+            }
+            param.content.channelCapabilityReq.channelNum = 
+                pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].APListPtr[ neighborAPIndex ].channel;
+            regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+            /* if the channel is allowed, insert it to the scan command */
+            if (param.content.channelCapabilityRet.channelValidity)
+            {
+                scanMngrAddNormalChannel( hScanMngr, &(bandPolicy->discoveryMethod), 
+                                          pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].APListPtr[ neighborAPIndex ].channel,
+                                          &(pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].APListPtr[ neighborAPIndex ].BSSID),
+                                          param.content.channelCapabilityRet.maxTxPowerDbm );
+            }
+        }
+        neighborAPIndex++;
+    }
+
+    /* if neighbor AP list has been exhuasted */
+    if ( neighborAPIndex == pScanMngr->neighborAPsDiscoveryList[ bandPolicy->band ].numOfEntries )
+    {
+        /* reset discovery index */
+        pScanMngr->neighborAPsDiscoveryIndex[ bandPolicy->band ] = 0;
+    }
+    else
+    {
+        /* just update neighbor APs discovery index */
+        pScanMngr->neighborAPsDiscoveryIndex[ bandPolicy->band ] = neighborAPIndex;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Add channel from policy channels list to scan command on the object workspace for discovery scan.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - the scan policy for the band to use.\n
+ */
+void scanMngrAddChannelListForDiscovery( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    paramInfo_t param;
+    macAddress_t broadcastAddress;
+    int i, channelListIndex = pScanMngr->channelDiscoveryIndex[ bandPolicy->band ];
+
+
+    /* set broadcast MAC address */
+    for ( i = 0; i < MAC_ADDR_LEN; i++ )
+    {
+        broadcastAddress.addr[ i ] = 0xff;
+    }
+
+    /* loop while channel list has not been exhausted, command is not full, and not enough APs for discovery had been found */
+    while ( (pScanMngr->scanParams.numOfChannels < bandPolicy->numOfChannlesForDiscovery) &&
+            (pScanMngr->scanParams.numOfChannels < SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND) &&
+            (channelListIndex < bandPolicy->numOfChannles) )
+    {
+        /* verify channel with reg domain */
+        param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+        param.content.channelCapabilityReq.band = bandPolicy->band;
+        if ( (bandPolicy->discoveryMethod.scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+             (bandPolicy->discoveryMethod.scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+             (bandPolicy->discoveryMethod.scanType == SCAN_TYPE_SPS) )
+        {
+            param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+        }
+        else
+        {
+            param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+        }
+        param.content.channelCapabilityReq.channelNum = 
+            bandPolicy->channelList[ channelListIndex ];
+        regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+        /* if the channel is allowed, insert it to the scan command */
+        if (param.content.channelCapabilityRet.channelValidity)
+        {
+            scanMngrAddNormalChannel( hScanMngr, &(bandPolicy->discoveryMethod), 
+                                      bandPolicy->channelList[ channelListIndex ],
+                                      &broadcastAddress,
+                                      param.content.channelCapabilityRet.maxTxPowerDbm );
+        }
+        channelListIndex++;
+    }
+        
+    /* if channel discovery list has been exhuasted */
+    if ( channelListIndex == bandPolicy->numOfChannles )
+    {
+        /* reset discovery index */
+        pScanMngr->channelDiscoveryIndex[ bandPolicy->band ] = 0;
+    }
+    else
+    {
+        /* just update channel list discovery index */
+        pScanMngr->channelDiscoveryIndex[ bandPolicy->band ] = channelListIndex;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Add SPS channels to scan command on the object workspace.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanMethod - The scan method (and parameters) to use.\n
+ * \param band - the band to scan.\n
+ */
+void scanMngrAddSPSChannels( TI_HANDLE hScanMngr, scan_Method_t* scanMethod, radioBand_e band )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    UINT64 EarliestTSFToInsert;
+    UINT32 timeToStartInAdvance = scanMethod->method.spsMethodParams.scanDuration /
+        SCAN_SPS_DURATION_PART_IN_ADVANCE;
+    scan_SPSHelper_t nextEventArray[ MAX_SIZE_OF_BSS_TRACK_LIST ];
+    int BSSListIndex, i, j, nextEventArrayHead, nextEventArraySize;
+    paramInfo_t param;
+#ifdef SCAN_MNGR_SPS_DBG
+    UINT32 highValue, lowValue, maxNextEventArraySize;
+#endif
+
+    WLAN_REPORT_INFORMATION(pScanMngr->hReport , SCAN_MNGR_MODULE_LOG ,("\nscanMngrAddSPSChannels invoked for band %d\n",band) );
+    /* initialize latest TSF value */
+    pScanMngr->scanParams.latestTSFValue = 0;
+
+    /* initialize the next event arry */
+    nextEventArrayHead = -1;
+    nextEventArraySize = 0;
+
+#ifdef SCAN_MNGR_SPS_DBG
+    highValue = INT64_HIGHER( pScanMngr->currentTSF );
+    lowValue = INT64_LOWER( pScanMngr->currentTSF );
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("current TSF: %u-%u\n", highValue, lowValue) );
+#endif
+    
+    /* insert channels from tracking list to next event array according to requested band */
+    for ( BSSListIndex = 0; BSSListIndex < pScanMngr->BSSList.numOfEntries; BSSListIndex++ )
+    {
+        /* if BSS is on the right band */
+        if ( band == pScanMngr->BSSList.BSSList[ BSSListIndex ].band )
+        {
+            /* verify the channel with the reg domain */
+            param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+            param.content.channelCapabilityReq.band = band;
+            param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+            param.content.channelCapabilityReq.channelNum = pScanMngr->BSSList.BSSList[ BSSListIndex ].channel;
+            regulatoryDomain_getParam( pScanMngr->hRegulatoryDomain, &param );
+
+            /* if channel is verified for requested scan type */
+            if ( param.content.channelCapabilityRet.channelValidity )
+            {
+                /* if this AP local TSF value is greater that latest TSF value, change it */
+                if ( pScanMngr->BSSList.scanBSSList[ BSSListIndex ].localTSF > pScanMngr->scanParams.latestTSFValue )
+                {
+                    /* the latest TSF value is used by the FW to detect TSF error (an AP recovery). When a TSF
+                       error occurs, the latest TSF value should be in the future (because the AP TSF was 
+                       reset). */
+                    pScanMngr->scanParams.latestTSFValue = pScanMngr->BSSList.scanBSSList[ BSSListIndex ].localTSF;
+                }
+
+                /* calculate the TSF of the next event for tracked AP. Scan should start 
+                   SCAN_SPS_DURATION_PART_IN_ADVANCE before the calculated event */
+                nextEventArray[ nextEventArraySize ].nextEventTSF = 
+                    scanMngrCalculateNextEventTSF( hScanMngr, &(pScanMngr->BSSList), BSSListIndex, 
+                                                   pScanMngr->currentTSF + SCAN_SPS_GUARD_FROM_CURRENT_TSF +
+                                                   timeToStartInAdvance ) - timeToStartInAdvance;
+#ifdef SCAN_MNGR_SPS_DBG
+                highValue = INT64_HIGHER( nextEventArray[ nextEventArraySize ].nextEventTSF );
+                lowValue = INT64_LOWER( nextEventArray[ nextEventArraySize ].nextEventTSF );
+                WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                         ("BSSID:%02x:%02x:%02x:%02x:%02x:%02x will send frame at TSF:%x-%x\n",
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID.addr[ 0 ],
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID.addr[ 1 ],
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID.addr[ 2 ],
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID.addr[ 3 ],
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID.addr[ 4 ],
+                                          pScanMngr->BSSList.BSSList[ BSSListIndex ].BSSID.addr[ 5 ],
+                                          highValue, lowValue) );
+#endif
+                nextEventArray[ nextEventArraySize ].trackListIndex = BSSListIndex;
+
+                /* insert it, sorted, to the next event array */
+                /* if need to insert as head (either because list is empty or because it has earliest TSF) */
+                if ( (-1 == nextEventArrayHead) ||
+                     (nextEventArray[ nextEventArraySize ].nextEventTSF < nextEventArray[ nextEventArrayHead ].nextEventTSF) )
+                {
+                    /* link the newly inserted AP to the current head */
+                    nextEventArray[ nextEventArraySize ].nextAPIndex = nextEventArrayHead;
+                    /* make current head point to newly inserted AP */
+                    nextEventArrayHead = nextEventArraySize;
+                    nextEventArraySize++;
+                }
+                /* insert into the list */
+                else
+                {
+                    /* start with list head */
+                    i = nextEventArrayHead;
+                    /* while the new AP TSF is larger and list end had not been reached */
+                    while ( (nextEventArray[ i ].nextAPIndex != -1) && /* list end had not been reached */
+                            (nextEventArray[ nextEventArray[ i ].nextAPIndex ].nextEventTSF < nextEventArray[ nextEventArraySize ].nextEventTSF) ) /* next event TSF of the next AP in the list is smaller than that of the AP being inserted */
+                    {
+                        /* proceed to the next AP */
+                        i = nextEventArray[ i ].nextAPIndex;
+                    }
+                    /* insert this AP to the list, right after the next event entry found */
+                    nextEventArray[ nextEventArraySize ].nextAPIndex = nextEventArray[ i ].nextAPIndex;
+                    nextEventArray[ i ].nextAPIndex = nextEventArraySize;
+                    nextEventArraySize++;
+                }
+            }
+            /* if for some reason a channel on which an AP was found is not valid for passive scan,
+               the AP should be removed. */
+            else
+            {
+                /* removing the AP is done by increasing its track count to maximum - and since it is
+                   not tracked it will not be discovered, and thus will be deleted when the scan is complete */
+                pScanMngr->BSSList.scanBSSList[ BSSListIndex ].trackFailCount = 
+                    pScanMngr->scanPolicy.maxTrackFailures + 1;
+#ifdef TI_DBG
+                /*update statistics */
+                pScanMngr->stats.APsRemovedInvalidChannel++;
+#endif
+            }
+        }
+    }
+
+#ifdef SCAN_MNGR_SPS_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("SPS list after first stage:\n") );
+    scanMngrDebugPrintSPSHelperList( hScanMngr, nextEventArray, nextEventArrayHead, nextEventArraySize );
+    maxNextEventArraySize = nextEventArraySize;
+#endif
+
+    /* insert channels from next event array to scan command */
+    EarliestTSFToInsert = pScanMngr->currentTSF + SCAN_SPS_GUARD_FROM_CURRENT_TSF;
+    /* insert all APs to scan command (as long as command is not full) */
+    while ( (nextEventArraySize > 0) &&
+            (pScanMngr->scanParams.numOfChannels < SCAN_MAX_NUM_OF_SPS_CHANNELS_PER_COMMAND) )
+    {
+        /* if first list entry fits, and it doesn't collide with current AP DTIM */
+        if ( EarliestTSFToInsert < nextEventArray[ nextEventArrayHead ].nextEventTSF )
+        {
+            if ( FALSE == scanMngrDTIMInRange( hScanMngr, nextEventArray[ nextEventArrayHead ].nextEventTSF,
+                                               nextEventArray[ nextEventArrayHead ].nextEventTSF + scanMethod->method.spsMethodParams.scanDuration ) )
+            {
+                /* insert it to scan command */
+                pScanMngr->scanParams.channelEntry[ pScanMngr->scanParams.numOfChannels ].SPSChannelEntry.scanStartTime = 
+                    INT64_LOWER( (nextEventArray[ nextEventArrayHead ].nextEventTSF) );
+                pScanMngr->scanParams.channelEntry[ pScanMngr->scanParams.numOfChannels ].SPSChannelEntry.scanDuration = 
+                    scanMethod->method.spsMethodParams.scanDuration;
+                pScanMngr->scanParams.channelEntry[ pScanMngr->scanParams.numOfChannels ].SPSChannelEntry.ETMaxNumOfAPframes = 
+                    scanMethod->method.spsMethodParams.ETMaxNumberOfApFrames;
+                pScanMngr->scanParams.channelEntry[ pScanMngr->scanParams.numOfChannels ].SPSChannelEntry.earlyTerminationEvent = 
+                    scanMethod->method.spsMethodParams.earlyTerminationEvent;
+                pScanMngr->scanParams.channelEntry[ pScanMngr->scanParams.numOfChannels ].SPSChannelEntry.channel = 
+                    pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].channel;
+                os_memoryCopy( pScanMngr->hOS, 
+                               &(pScanMngr->scanParams.channelEntry[ pScanMngr->scanParams.numOfChannels ].SPSChannelEntry.bssId),
+                               &(pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID),
+                               MAC_ADDR_LEN );
+                /* increase the AP track attempts counter */
+                pScanMngr->BSSList.scanBSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].trackFailCount++;
+                /* increase number of channels in scan command */
+                pScanMngr->scanParams.numOfChannels++;
+                /* set earliest TSF that would fit in scan command */
+                EarliestTSFToInsert = nextEventArray[ nextEventArrayHead ].nextEventTSF + 
+                                      scanMethod->method.spsMethodParams.scanDuration + 
+                                      SCAN_SPS_GUARD_FROM_LAST_BSS;
+                /* remove it from next event array */
+                nextEventArrayHead = nextEventArray[ nextEventArrayHead ].nextAPIndex;
+                nextEventArraySize--;
+            }
+            else
+            {
+                UINT32 beaconIntervalUsec = 
+                    pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].beaconInterval * 1024;
+
+                /* if the next beacon also collide with DTIM */
+                if ( TRUE == scanMngrDTIMInRange( hScanMngr, nextEventArray[ nextEventArrayHead ].nextEventTSF + beaconIntervalUsec,
+                                                  nextEventArray[ nextEventArrayHead ].nextEventTSF + scanMethod->method.spsMethodParams.scanDuration + beaconIntervalUsec ) )
+                {
+                    /* An AP whose two consecutive beacons collide with current AP DTIM is not trackable by SPS!!! 
+                       Shouldn't happen at a normal setup, but checked to avoid endless loop.
+                       First, remove it from the tracking list (by increasing it's track count above the maximum) */
+                    pScanMngr->BSSList.scanBSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].trackFailCount = 
+                        pScanMngr->scanPolicy.maxTrackFailures + 1;
+
+                    /* and also remove it from the SPS list */
+                    nextEventArrayHead = nextEventArray[ nextEventArrayHead ].nextAPIndex;
+                    nextEventArraySize--;
+
+#ifdef TI_DBG
+                    /* update statistics */
+                    pScanMngr->stats.APsRemovedDTIMOverlap++;
+#endif
+                }
+                else
+                {
+                    /* calculate next event TSF - will get the next beacon, since timeToStartInAdvance is added to current beacon TSF */
+                    nextEventArray[ nextEventArrayHead ].nextEventTSF = 
+                        scanMngrCalculateNextEventTSF( hScanMngr, &(pScanMngr->BSSList),
+                                                       nextEventArray[ nextEventArrayHead ].trackListIndex,
+                                                       nextEventArray[ nextEventArrayHead ].nextEventTSF + timeToStartInAdvance + 1) 
+                                                            - timeToStartInAdvance;
+
+#ifdef SCAN_MNGR_SPS_DBG
+                    highValue = INT64_HIGHER( nextEventArray[ nextEventArrayHead ].nextEventTSF );
+                    lowValue = INT64_LOWER( nextEventArray[ nextEventArrayHead ].nextEventTSF );
+                    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                             ("reacalculating next frame for BSSID:%02x:%02x:%02x:%02x:%02x:%02x at TSF:%x-%x, bacause of DTIM collision\n",
+                                             pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 0 ],
+                                             pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 1 ],
+                                             pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 2 ],
+                                             pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 3 ],
+                                             pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 4 ],
+                                             pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 5 ],
+                                             highValue, lowValue) );
+#endif
+
+                    /* reinsert to the next event array, sorted */
+                    /* if still needs to be head, do nothing (because it's still head). otherwise: */
+                    if ( (1 < nextEventArraySize) && /* list has more than one entry */
+                         (nextEventArray[ nextEventArrayHead ].nextEventTSF > nextEventArray[ nextEventArray[ nextEventArrayHead ].nextAPIndex ].nextEventTSF) ) /* first event in list is earlier */
+                    {
+                        /* first remove the head from the list */
+                        j = nextEventArrayHead;
+                        nextEventArrayHead = nextEventArray[ nextEventArrayHead ].nextAPIndex;
+
+                        /* start with list head */
+                        i = nextEventArrayHead;
+                        /* while the new AP TSF is larger and list end had not been reached */
+                        while ( (nextEventArray[ i ].nextAPIndex != -1) && /* list end had not been reached */
+                                (nextEventArray[ nextEventArray[ i ].nextAPIndex ].nextEventTSF < nextEventArray[ j ].nextEventTSF) ) /* next event TSF of the next AP in the list is smaller than that of the AP being inserted */
+                        {
+                            /* proceed to the next AP */
+                            i = nextEventArray[ i ].nextAPIndex;
+                        }
+                        /* insert this AP to the list, right after the next event entry found */
+                        nextEventArray[ j ].nextAPIndex = nextEventArray[ i ].nextAPIndex;
+                        nextEventArray[ i ].nextAPIndex = j;
+                    }
+
+#ifdef SCAN_MNGR_SPS_DBG
+                    scanMngrDebugPrintSPSHelperList( hScanMngr, nextEventArray, nextEventArrayHead, maxNextEventArraySize );
+#endif
+#ifdef TI_DBG
+                    /* update statistics */
+                    pScanMngr->stats.SPSSavedByDTIMCheck++;
+#endif
+                }
+            }
+        }
+        else
+        {
+            /* calculate next event TSF */
+            nextEventArray[ nextEventArrayHead ].nextEventTSF = 
+                scanMngrCalculateNextEventTSF( hScanMngr, &(pScanMngr->BSSList),
+                                               nextEventArray[ nextEventArrayHead ].trackListIndex,
+                                               EarliestTSFToInsert + timeToStartInAdvance ) - timeToStartInAdvance;
+
+#ifdef SCAN_MNGR_SPS_DBG
+            highValue = INT64_HIGHER( nextEventArray[ nextEventArrayHead ].nextEventTSF );
+            lowValue = INT64_LOWER( nextEventArray[ nextEventArrayHead ].nextEventTSF );
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("reacalculating next frame for BSSID:%02x:%02x:%02x:%02x:%02x:%02x at TSF:%x-%x\n",
+                                     pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 0 ],
+                                     pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 1 ],
+                                     pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 2 ],
+                                     pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 3 ],
+                                     pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 4 ],
+                                     pScanMngr->BSSList.BSSList[ nextEventArray[ nextEventArrayHead ].trackListIndex ].BSSID.addr[ 5 ],
+                                     highValue, lowValue) );
+#endif
+
+            /* reinsert to the next event array, sorted */
+            /* if still needs to be head, do nothing (because it's still head). otherwise: */
+            if ( (1 < nextEventArraySize) && /* list has more than one entry */
+                 (nextEventArray[ nextEventArrayHead ].nextEventTSF > nextEventArray[ nextEventArray[ nextEventArrayHead ].nextAPIndex ].nextEventTSF) ) /* first event in list is earlier */
+            {
+                /* first remove the head from the list */
+                j = nextEventArrayHead;
+                nextEventArrayHead = nextEventArray[ nextEventArrayHead ].nextAPIndex;
+
+                /* start with list head */
+                i = nextEventArrayHead;
+                /* while the new AP TSF is larger and list end had not been reached */
+                while ( (nextEventArray[ i ].nextAPIndex != -1) && /* list end had not been reached */
+                        (nextEventArray[ nextEventArray[ i ].nextAPIndex ].nextEventTSF < nextEventArray[ j ].nextEventTSF) ) /* next event TSF of the next AP in the list is smaller than that of the AP being inserted */
+                {
+                    /* proceed to the next AP */
+                    i = nextEventArray[ i ].nextAPIndex;
+                }
+                /* insert this AP to the list, right after the next event entry found */
+                nextEventArray[ j ].nextAPIndex = nextEventArray[ i ].nextAPIndex;
+                nextEventArray[ i ].nextAPIndex = j;
+            }
+
+#ifdef SCAN_MNGR_SPS_DBG
+            scanMngrDebugPrintSPSHelperList( hScanMngr, nextEventArray, nextEventArrayHead, maxNextEventArraySize );
+#endif
+        }
+    }
+    /* For SPS scan, the scan duration is added to the command, since later on current TSF cannot be 
+       reevaluated. The scan duration is TSF at end of scan minus current TSF, divided by 1000 (convert
+       to milliseconds) plus 1 (for the division reminder). */
+    pScanMngr->scanParams.SPSScanDuration = 
+        (((UINT32)(EarliestTSFToInsert - SCAN_SPS_GUARD_FROM_LAST_BSS - pScanMngr->currentTSF)) / 1000) + 1;    
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 07-Mar-2005\n
+ * \brief Calculates local TSF of the next event (beacon or GPR) of the given tracked AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param BSSList - a pointer to the track list.\n
+ * \param entryIndex - the index of the AP for which calculation is requires in the tracking list.\n
+ * \param initialTSFValue - local TSF value AFTER which the next event is to found.\n
+ * \return The approximate current TSF
+ */
+UINT64 scanMngrCalculateNextEventTSF( TI_HANDLE hScanMngr, scan_BSSList_t* BSSList, UINT8 entryIndex, UINT64 initialTSFValue )
+{
+    UINT64 remoteBeaconTSF, localBeaconTSF;
+    INT64 localRemoteTSFDelta;
+    UINT32 reminder;
+    INT32 averageDeltaChange = 0;
+    int i; 
+#ifdef SCAN_MNGR_SPS_DBG
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+#endif /* SCAN_MNGR_SPS_DBG */
+
+/* graphical representation:
+                               E      E      E      E      E      E      E      E      E
+Remote TSF Line:               |      |      |      |      |      |      |      |      |
+0                    remoteTSF |      |      |      |      |      |      |      |      | Returned value
++-----------------------+------+------+------+------+------+------+------+------+------+------+----------------...
+
+Local TSF Line:
+    0                localTSF                                                   initialTSFValue
+    +-------------------+---------------------------------------------------------------+-----+---------------...
+
+  note that:
+  1. both lines Don't start at the same time!
+  2. remoteTSF and localTSF were measured when last frame was received from the tracked AP. the difference between their
+     values is the constant difference between the two lines.
+  3. initialTSFValue is the local TSF the first event after which is requested.
+  4. returned value is the TSF (in local scale!) of the next event of the tracked AP.
+  5. an E represents an occurring event, which is a scheduled frame transmission (beacon or GPR) of the tracked AP.
+*/
+  
+    /*
+     * The next event TSF is calculated as follows:
+     * first, the difference between the local TSF (that of the AP the STA is currently connected to) and the 
+     * remote TSF (that of the AP being tracked) is calculated using the TSF values measured when last scan was
+     * performed. Than, the initial TSF value is converted to remote TSF value, using the delta just calculated.
+     * The next remote TSF is found (in remote TSF value) by subtracting the reminder of dividing the current
+     * remote TSF value by the remote beacon interval (time passed from last beacon) from the current remote TSF
+     * (hence amounting to the last beacon remote TSF), and than adding beacon interval. This is finally converted 
+     * back to local TSF, which is the requested value.
+     *
+     * After all this is done, clock drift between current AP and remote AP is compensated. This is done in thr
+     * following way: the delte between local TSF and remote TSF is compared to this value at the last scan
+     * (if they are equal, the clocks tick at the same rate). This difference is store in an array holding a
+     * configured number of such previous differences (currenlty 4). The average value of these previous values
+     * is then calculated, and added the the TSF value calculated before. This way, the average drift between 
+     * the local AP and the candidate AP is measured, and the next drift value can be estimated and thus
+     * taken into account.
+     */
+
+#ifdef SCAN_MNGR_SPS_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("initial TSF value:%x-%x\n", 
+                              INT64_HIGHER( initialTSFValue ), INT64_LOWER( initialTSFValue )) );
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("local time stamp:%x-%x\n", 
+                             INT64_HIGHER( BSSList->scanBSSList[ entryIndex ].localTSF ), 
+                             INT64_LOWER( BSSList->scanBSSList[ entryIndex ].localTSF )) );
+#endif
+    /* calculate the delta between local and remote TSF */
+    localRemoteTSFDelta = BSSList->scanBSSList[ entryIndex ].localTSF - 
+        BSSList->BSSList[ entryIndex ].lastRxTSF;
+    /* convert initial TSF to remote timeline */
+    remoteBeaconTSF = initialTSFValue - localRemoteTSFDelta;
+#ifdef SCAN_MNGR_SPS_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Local TSF:%u-%u, Remote TSF: %u-%u\n",
+                              INT64_HIGHER(BSSList->scanBSSList[ entryIndex ].localTSF), 
+                              INT64_LOWER(BSSList->scanBSSList[ entryIndex ].localTSF), 
+                              INT64_HIGHER(BSSList->BSSList[ entryIndex ].lastRxTSF), 
+                              INT64_LOWER(BSSList->BSSList[ entryIndex ].lastRxTSF) ) );
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("TSF delta:%u-%u, current remote TSF:%u-%u\n",
+                              INT64_HIGHER(localRemoteTSFDelta),
+                              INT64_LOWER(localRemoteTSFDelta),
+                              INT64_HIGHER(remoteBeaconTSF ),
+                              INT64_LOWER(remoteBeaconTSF )) );
+#endif
+    /* find last remote beacon transmission by subtracting the reminder of current remote TSF divided
+       by the beacon interval (indicating how much time passed since last beacon) from current remote
+       TSF */
+    reminder = reminder64( remoteBeaconTSF, BSSList->BSSList[ entryIndex ].beaconInterval * 1024 );
+    remoteBeaconTSF -= reminder;
+
+#ifdef SCAN_MNGR_SPS_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("reminder=%d\n",reminder) );
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Last remote beacon TSF:%x-%x\n",
+                              INT64_HIGHER(remoteBeaconTSF),
+                              INT64_LOWER(remoteBeaconTSF)) );
+#endif
+    /* advance from last beacon to next beacon */
+    remoteBeaconTSF += BSSList->BSSList[ entryIndex ].beaconInterval * 1024;
+#ifdef SCAN_MNGR_SPS_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Next remote beacon TSF:%x-%x\n",
+                              INT64_HIGHER(remoteBeaconTSF),
+                              INT64_LOWER(remoteBeaconTSF)) );
+#endif
+
+#ifdef SCAN_SPS_USE_DRIFT_COMPENSATION
+    /* update delta change array with the change between current and last delta (if last delta is valid) */
+    if ( 0 != BSSList->scanBSSList[ entryIndex ].prevTSFDelta )
+    {
+        BSSList->scanBSSList[ entryIndex ].deltaChangeArray[ BSSList->scanBSSList[ entryIndex ].deltaChangeArrayIndex ] = 
+            (INT32)(localRemoteTSFDelta - BSSList->scanBSSList[ entryIndex ].prevTSFDelta);
+#ifdef SCAN_MNGR_SPS_DBG
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("current delta^2:%d\n", localRemoteTSFDelta - BSSList->scanBSSList[ entryIndex ].prevTSFDelta) );
+#endif
+        if ( SCAN_SPS_NUM_OF_TSF_DELTA_ENTRIES == ++BSSList->scanBSSList[ entryIndex ].deltaChangeArrayIndex )
+        {
+            BSSList->scanBSSList[ entryIndex ].deltaChangeArrayIndex = 0;
+        }
+    }
+    BSSList->scanBSSList[ entryIndex ].prevTSFDelta = localRemoteTSFDelta;
+    
+    /* calculate average delta change, and add (or subtract) it from beacon timing */
+    for ( i = 0; i < SCAN_SPS_NUM_OF_TSF_DELTA_ENTRIES; i++ )
+    {
+        averageDeltaChange += BSSList->scanBSSList[ entryIndex ].deltaChangeArray[ i ];
+    }
+    averageDeltaChange /= SCAN_SPS_NUM_OF_TSF_DELTA_ENTRIES;
+#ifdef SCAN_MNGR_SPS_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("average delta change: %d\n", averageDeltaChange) ); 
+#endif /* SCAN_MNGR_SPS_DBG */
+    remoteBeaconTSF += averageDeltaChange;
+#endif
+
+    /* convert to local TSF */
+    localBeaconTSF = remoteBeaconTSF + localRemoteTSFDelta;
+
+#ifdef SCAN_SPS_USE_DRIFT_COMPENSATION
+    /* if beacon (in local TSF) is before initial TSF value (possible due to drift compensation),
+       proceed to next beacon */
+    if ( localBeaconTSF < initialTSFValue )
+    {
+        localBeaconTSF += (BSSList->BSSList[ entryIndex ].beaconInterval * 1024);
+    }
+#endif
+
+    return localBeaconTSF;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 20-September-2005\n
+ * \brief Check whether a time range collides with current AP DTIM
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param rangeStart - the time range start TSF.\n
+ * \param rangeEnd - the time range end TSF.\n
+ * \return Whether the event collides with a DTIM (TRUF if it does, FALSE if it doesn't).\n
+ */
+BOOLEAN scanMngrDTIMInRange( TI_HANDLE hScanMngr, UINT64 rangeStart, UINT64 rangeEnd )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    UINT64 DTIMEventStart, DTIMEventEnd;
+    UINT32 DTIMPeriodInUsec; /* DTIM period in micro seconds */
+
+#ifdef SCAN_MNGR_DTIM_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("DTIM check: SPS raneg start:%x-%x, end:%x-%x\n",
+                              INT64_HIGHER(rangeStart), INT64_LOWER(rangeStart),
+                              INT64_HIGHER(rangeEnd), INT64_LOWER(rangeEnd)) );
+#endif
+
+    /* calculate DTIM period */
+    DTIMPeriodInUsec = pScanMngr->currentBSSBeaconInterval * 1024 * pScanMngr->currentBSSDtimPeriod;
+
+#ifdef SCAN_MNGR_DTIM_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("DTIM period in usec: %d\n", DTIMPeriodInUsec) );
+#endif
+
+    /* calculate (from DTIM count) the first DTIM after the last seen beacon. The last seen beacon will always
+       occur before the SPS - because it already happened, and the SPS is a future event. However, the next DTIM
+       is not necessarily prior to the SPS - it is also a future event (if the last beacon was not a DTIM) */
+    if ( 0 == pScanMngr->lastLocalBcnDTIMCount )
+    {   /* The last beacon was a DTIM */
+        DTIMEventStart = pScanMngr->lastLocalBcnTSF;
+    }
+    else
+    {   /* The last beacon was not a DTIM - calculate the next beacon that will be a DTIM */
+        DTIMEventStart = pScanMngr->lastLocalBcnTSF + 
+            ((pScanMngr->currentBSSDtimPeriod - pScanMngr->lastLocalBcnDTIMCount) * pScanMngr->currentBSSBeaconInterval);
+        WLAN_REPORT_INFORMATION(pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,("\n Next DTIM TSF:%u-%u , last beacon TSF:%u-%u, last DTIM count: %d, beacon interval: %d\n",
+                              INT64_HIGHER(DTIMEventStart), INT64_LOWER(DTIMEventStart), 
+                              INT64_HIGHER(pScanMngr->lastLocalBcnTSF), INT64_LOWER(pScanMngr->lastLocalBcnTSF),
+                              pScanMngr->lastLocalBcnDTIMCount, pScanMngr->currentBSSBeaconInterval)) ;
+    }
+#ifdef SCAN_MNGR_DTIM_DBG
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Next DTIM TSF:%u-%u, last beacon TSF:%u-%u, last DTIM count: %d, beacon interval: %d\n",
+                              INT64_HIGHER(DTIMEventStart), INT64_LOWER(DTIMEventStart), 
+                              INT64_HIGHER(pScanMngr->lastLocalBcnTSF), INT64_LOWER(pScanMngr->lastLocalBcnTSF),
+                              pScanMngr->lastLocalBcnDTIMCount, pScanMngr->currentBSSBeaconInterval) );
+#endif
+
+    /* calculate the DTIM event end (add the DTIM length). Note that broadcast frames after the DTIM are not
+       taken into consideration because their availability and length varies. Even if at some point SPS will be
+       missed due to broadcast RX frames, it does not mean this AP cannot be tracked. */
+    DTIMEventEnd = DTIMEventStart + SCAN_SPS_FW_DTIM_LENGTH;
+
+    /* if this DTIM is after the SPS end - than no collision will occur! */
+    if ( DTIMEventStart > rangeEnd )
+    {
+#ifdef SCAN_MNGR_DTIM_DBG
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("no collision because DTIM is after SPS\n") );
+#endif
+        return FALSE;
+    }
+    /* if this DTIM end is not before the SPS range start - it means the DTIM is colliding with the SPS, because
+       it neither ends before the SPS nor starts after it */
+    else if ( DTIMEventEnd >= rangeStart )
+    {
+#ifdef SCAN_MNGR_DTIM_DBG
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Collision beacuse DTIM is not before SPS\n") );
+#endif        
+        return TRUE;
+    }
+    /* the DTIM is before the SPS range - find the first DTIM after the SPS start (and check if it's colliding
+       with the SPS range */
+    else 
+    {
+        /* get the usec difference from the SPS range start to the last DTIM */
+        UINT64 usecDiffFromRangeStartToLastDTIM = rangeStart - DTIMEventStart;
+        /* get the reminder from the usec difference divided by the DTIM period - the time (in usec) from last DTIM
+           to SPS start */
+        UINT32 reminder = reminder64( usecDiffFromRangeStartToLastDTIM, DTIMPeriodInUsec );
+        /* get the next DTIM start time by adding DTIM period to the last DTIM before the SPS range start */
+        DTIMEventStart = rangeStart - reminder + DTIMPeriodInUsec;
+        /* get DTIM end time */
+        DTIMEventEnd = DTIMEventStart + SCAN_SPS_FW_DTIM_LENGTH;
+#ifdef SCAN_MNGR_DTIM_DBG
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Diff from range start to last DTIM: %x-%x, reminder:%d, DTIM start:%x-%x, DTIM end: %x-%x\n",
+                                  INT64_HIGHER(usecDiffFromRangeStartToLastDTIM), INT64_LOWER(usecDiffFromRangeStartToLastDTIM),
+                                  reminder, INT64_HIGHER(DTIMEventStart), INT64_LOWER(DTIMEventStart),
+                                  INT64_HIGHER(DTIMEventEnd), INT64_LOWER(DTIMEventEnd)) );
+#endif
+
+        /* if the SPS starts after the DTIM ends or before the DTIM starts - no collision occurs */
+        if ( (rangeStart > DTIMEventEnd) || (rangeEnd < DTIMEventStart) )
+        {
+#ifdef SCAN_MNGR_DTIM_DBG
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("No collision will occur because DTIM is before or after SPS\n") );
+#endif
+            return FALSE;
+        }
+        /* otherwise - a collision will occur! */
+        {
+#ifdef SCAN_MNGR_DTIM_DBG
+            WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                     ("Collision will occur!\n") );
+#endif
+            return TRUE;
+        }
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 03-Mar-2005\n
+ * \brief Add a normal channel entry to the object workspace scan command.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanMethod - The scan method (and parameters) to use.\n
+ * \param channel - the channel index.\n
+ * \param BSSID - pointer to the BSSID to use (may be broadcast.\n
+ * \param txPowerDbm - tx power to transmit probe requests.\n
+ */
+void scanMngrAddNormalChannel( TI_HANDLE hScanMngr, scan_Method_t* scanMethod, UINT8 channel, 
+                               macAddress_t* BSSID, UINT8 txPowerDbm )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int commandChannelIndex;
+    scan_basicMethodParams_t* basicMethodParams;
+
+    /* get next channel in the object workspace */
+    commandChannelIndex = pScanMngr->scanParams.numOfChannels;
+    pScanMngr->scanParams.numOfChannels++;
+
+    /* get basic method params pointer according to scan type */
+    switch ( scanMethod->scanType )
+    {
+    case SCAN_TYPE_NORMAL_PASSIVE:
+    case SCAN_TYPE_NORMAL_ACTIVE:  
+        basicMethodParams = &(scanMethod->method.basicMethodParams);
+        break;
+
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+        basicMethodParams = &(scanMethod->method.TidTriggerdMethodParams.basicMethodParams);
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("Unercognized scan type %d when adding normal channel to scan list.\n", scanMethod->scanType ) );
+        basicMethodParams = NULL;
+    }
+
+    /* set params */
+    pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.channel = channel;
+    pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.txPowerDbm = 
+        MIN( txPowerDbm, basicMethodParams->probReqParams.txPowerDbm );
+    pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.maxChannelDwellTime = 
+        basicMethodParams->maxChannelDwellTime;
+    pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.minChannelDwellTime = 
+        basicMethodParams->minChannelDwellTime;
+    pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.earlyTerminationEvent = 
+        basicMethodParams->earlyTerminationEvent;
+    pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.ETMaxNumOfAPframes = 
+        basicMethodParams->ETMaxNumberOfApFrames;
+    os_memoryCopy( pScanMngr->hOS, 
+                   &(pScanMngr->scanParams.channelEntry[ commandChannelIndex ].normalChannelEntry.bssId),
+                   BSSID,
+                   MAC_ADDR_LEN );
+}
+                                    
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Removes an entry from the BSS list (by replacing it with another entry, if any).
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param BSSEntryIndex - index of the entry to remove.\n
+ */
+void scanMngrRemoveBSSListEntry( TI_HANDLE hScanMngr, UINT8 BSSEntryIndex )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    UINT8* tempResultBuffer;
+
+#ifdef TI_DBG
+    /*update statistics */
+    if ( SCAN_MNGR_STAT_MAX_TRACK_FAILURE <= pScanMngr->BSSList.scanBSSList[ BSSEntryIndex ].trackFailCount )
+    {
+        pScanMngr->stats.ConsecutiveTrackFailCountHistogram[ SCAN_MNGR_STAT_MAX_TRACK_FAILURE - 1 ]++;
+    }
+    else
+    {
+        pScanMngr->stats.ConsecutiveTrackFailCountHistogram[ pScanMngr->BSSList.scanBSSList[ BSSEntryIndex ].trackFailCount ]++;
+    }
+#endif
+    /* if no more entries are available, simply reduce the number of entries.
+       As this is the last entry, it won't be accessed any more. */
+    if ( (pScanMngr->BSSList.numOfEntries-1) == BSSEntryIndex )
+    {
+
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Removing last entry %d in BSS list\n", pScanMngr->BSSList.numOfEntries) );
+
+        pScanMngr->BSSList.numOfEntries--;
+    }
+    else
+    {
+#ifdef SCAN_MNGR_DBG
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("Removing entry %d of %d\n", BSSEntryIndex, pScanMngr->BSSList.numOfEntries) );
+#endif
+        /* keep the scan result buffer pointer */
+        tempResultBuffer = pScanMngr->BSSList.BSSList[ BSSEntryIndex ].pBuffer;
+        /* copy the last entry over this one */
+        os_memoryCopy( pScanMngr->hOS, &(pScanMngr->BSSList.BSSList[ BSSEntryIndex ]),
+                       &(pScanMngr->BSSList.BSSList[ pScanMngr->BSSList.numOfEntries-1 ]),
+                       sizeof(bssEntry_t) );
+        os_memoryCopy( pScanMngr->hOS, &(pScanMngr->BSSList.scanBSSList[ BSSEntryIndex ]),
+                       &(pScanMngr->BSSList.scanBSSList[ pScanMngr->BSSList.numOfEntries-1 ]),
+                       sizeof(scan_BSSEntry_t) );
+        /* replace the scan result buffer of the last entry */
+        pScanMngr->BSSList.BSSList[ pScanMngr->BSSList.numOfEntries-1 ].pBuffer = tempResultBuffer;
+        /* decrease the number of BSS entries */
+        pScanMngr->BSSList.numOfEntries--;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Removes all BSS list entries that are neither neighbor APs not on a policy defined channel.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bCheckNeighborAPs - whether to verify that APs marked as neighbor APs are really neighbor APs.\n
+ * \param bCheckChannels - whether to verify that APs not marked as neighbor APs are on policy defined channel.\n
+ */
+void scanMngrUpdateBSSList( TI_HANDLE hScanMngr, BOOLEAN bCheckNeighborAPs, BOOLEAN bCheckChannels )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int BSSEntryIndex;
+
+    /* loop on all BSS list entry */
+    for ( BSSEntryIndex = 0; BSSEntryIndex < pScanMngr->BSSList.numOfEntries; BSSEntryIndex++ )
+    {
+        /* an AP can be in the BSS list either because it's a neighbor AP or, if not, because it's on a
+           policy defined channel. When Neighbor AP list is changed, it is only necessary to check APs that
+           are in the list because they are neighbor APs. When the policy is changed, it is only necessary
+           to check APs that are in the list because they are on a policy defined channel. */
+
+        /* if a check for neighbor APs is requested, check only APs that are designated as neighbor APs,
+           and only check if they still are neighbor APs */
+        if ( (TRUE == bCheckNeighborAPs) && 
+             (TRUE == pScanMngr->BSSList.BSSList[ BSSEntryIndex ].bNeighborAP) &&
+             (-1 == scanMngrGetNeighborAPIndex( hScanMngr, 
+                                                pScanMngr->BSSList.BSSList[ BSSEntryIndex ].band,
+                                                &(pScanMngr->BSSList.BSSList[ BSSEntryIndex ].BSSID) )) )
+        {
+            /* remove it */
+            scanMngrRemoveBSSListEntry( hScanMngr, BSSEntryIndex );
+        }
+
+        /* if a check for policy defined channels is requested, check only APs that are not designated as 
+           neighbor APs */
+        if ( (TRUE == bCheckChannels) &&
+             (FALSE == pScanMngr->BSSList.BSSList[ BSSEntryIndex ].bNeighborAP) &&
+             (FALSE == scanMngrIsPolicyChannel( hScanMngr, 
+                                                pScanMngr->BSSList.BSSList[ BSSEntryIndex ].band, 
+                                                pScanMngr->BSSList.BSSList[ BSSEntryIndex ].channel )) )
+        {
+            /* remove it */
+            scanMngrRemoveBSSListEntry( hScanMngr, BSSEntryIndex );
+        }
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief returns the index of a neighbor AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param band - the band on which the AP resides.\n
+ * \param bssId - the AP's BSSID.\n
+ * \return the index into the neighbor AP list for the given address, -1 if AP is not in list.\n
+ */
+INT8 scanMngrGetNeighborAPIndex( TI_HANDLE hScanMngr, radioBand_e band, macAddress_t* bssId )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    /* loop on all neighbor APS for this AP's band, and compare BSSID's */
+    for ( i = 0; i < pScanMngr->neighborAPsDiscoveryList[ band ].numOfEntries; i++ )
+    {
+        if ( 0 == os_memoryCompare( pScanMngr->hOS, 
+                                    (PUINT8)&(bssId->addr[ 0 ]), 
+                                    (PUINT8)&(pScanMngr->neighborAPsDiscoveryList[ band ].APListPtr[ i ].BSSID.addr[ 0 ]),
+                                    MAC_ADDR_LEN ) )
+        {
+            return i;
+        }
+    }
+
+    /* if the AP wasn't found in the list, it's not a neighbor AP... */
+    return -1;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Checks whether a channel is defined on a policy.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param band - the band on which the channel is.\n
+ * \param channel - the channel number.\n
+ * \return TRUE if channel is defined on policy, FALSE otherwise.\n
+ */
+BOOLEAN scanMngrIsPolicyChannel( TI_HANDLE hScanMngr, radioBand_e band, UINT8 channel )
+{
+    int i;
+    scan_bandPolicy_t* bandPolicy = scanMngrGetPolicyByBand( hScanMngr, band );
+
+    
+    /* check if the AP's band is defined in the policy */
+    if ( NULL == bandPolicy )
+    {
+        return FALSE;
+    }
+
+    /* loop on all channels for the AP's band */
+    for ( i = 0; i < bandPolicy->numOfChannles; i++ )
+    {
+        if ( bandPolicy->channelList[ i ] == channel )
+        {
+            return TRUE;
+        }
+    }
+
+    /* if no channel was found, the AP is NOT on a policy configured channel */
+    return FALSE;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 18-Apr-2005\n
+ * \brief Converts scan concentrator result status to scan manager result status, to be returned to roaming manager.\n
+ *
+ * Function Scope \e Private.\n
+ * \param result status - scan concentrator result status.\n
+ * \return appropriate scan manager status.\n
+ */
+scan_mngrResultStatus_e scanMngrConvertResultStatus( scan_cncnResultStatus_e resultStatus )
+{
+    switch (resultStatus)
+    {
+    case SCAN_CRS_SCAN_COMPLETE_OK:
+        return  SCAN_MRS_SCAN_COMPLETE_OK;
+/*        break; - unreachable */
+
+    case SCAN_CRS_SCAN_RUNNING:
+        return SCAN_MRS_SCAN_RUNNING;
+/*        break; - unreachable */
+
+    case SCAN_CRS_SCAN_FAILED:
+        return SCAN_MRS_SCAN_FAILED;
+/*        break; - unreachable */
+
+    case SCAN_CRS_SCAN_STOPPED:
+        return SCAN_MRS_SCAN_STOPPED;
+/*        break; - unreachable */
+
+    case SCAN_CRS_TSF_ERROR:
+        return SCAN_MRS_SCAN_FAILED;
+/*        break; - unreachable */
+
+    case SCAN_CRS_SCAN_ABORTED_FW_RESET:
+        return SCAN_MRS_SCAN_ABORTED_FW_RESET;
+/*        break; - unreachable */
+
+    case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
+        return SCAN_MRS_SCAN_ABORTED_HIGHER_PRIORITY;
+/*        break; - unreachable */
+
+    default:
+        return SCAN_MRS_SCAN_FAILED;
+/*        break; - unreachable */
+    }
+}
+
+/************************************************************************/
+/*                         Trace functions                             */
+/************************************************************************/
+
+#ifdef REPORT_LOG
+
+static char scanTypeDesc[ 6 ][ MAX_DESC_LENGTH ] = 
+{
+    "passive normal scan",
+    "active normal scan",
+    "SPS scan",
+    "passive triggered scan",
+    "active triggered scan",
+    "no scan type"
+};
+
+static char earlyTerminationConditionDesc[ 4 ][ MAX_DESC_LENGTH ] =
+{
+    "Early termination disabled",
+    "Early termination on beacon",
+    "Early termination on probe response",
+    "Early termination on both"
+};
+
+#ifdef TI_DBG
+static char booleanDesc[ 2 ][ MAX_DESC_LENGTH ] =
+{
+    "No",
+    "Yes"
+};
+
+static char contScanStatesDesc[ SCAN_CSS_NUM_OF_STATES ][ MAX_DESC_LENGTH ] =
+{
+    "IDLE",
+    "TRACKING ON G",
+    "TRACKING ON A",
+    "DISCOVERING",
+    "STOPPING"
+};
+
+static char immedScanStatesDesc[ SCAN_ISS_NUM_OF_STATES ][ MAX_DESC_LENGTH ] = 
+{
+    "IDLE",
+    "IMMEDIATE ON G",
+    "IMMEDIATE ON A",
+    "STOPPING"
+};
+
+static char discoveryPartDesc[ SCAN_SDP_NUMBER_OF_DISCOVERY_PARTS ][ MAX_DESC_LENGTH ] =
+{
+    "G neighbor APs",
+    "A neighbor APs",
+    "G channels",
+    "A Channels",
+    "No discovery"
+};
+
+static char neighborDiscovreyStateDesc[ SCAN_NDS_NUMBER_OF_NEIGHBOR_DISCOVERY_STATES ][ MAX_DESC_LENGTH ] =
+{
+    "Discovered",
+    "Not discovered",
+    "Current AP"
+};
+
+static char earlyTerminationDesc[ SCAN_ET_COND_NUM_OF_CONDS ][ MAX_DESC_LENGTH ] =
+{
+    "None",
+    "Beacon",
+    "Prob. resp."
+    "Bcn & prob. resp."
+};
+#endif
+
+#endif
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a neighbor AP list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param neighborAPList - the list of neighbor APs to print.\n
+ */
+void scanMngrTracePrintNeighborAPsList( TI_HANDLE hScanMngr, neighborAPList_t *neighborAPList )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    /* print number of entries */
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Neighbor AP list with %d entries.\n\n", neighborAPList->numOfEntries) );
+    
+    /* print all APs in list */
+    for ( i = 0; i < neighborAPList->numOfEntries; i++ )
+    {
+        scanMngrTracePrintNeighborAP( hScanMngr, &(neighborAPList->APListPtr[ i ]) );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a neighbor AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param neighborAP - the neighbor AP to print.\n
+ */
+void scanMngrTracePrintNeighborAP( TI_HANDLE hScanMngr, neighborAP_t* neighborAP )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    /* print neighbor AP content */
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("Neighbor AP band: %s, channel: %d, MAC address (BSSID): %2x:%2x:%2x:%2x:%2x:%2xn",
+                              (RADIO_BAND_2_4_GHZ == neighborAP->band ? "2.4 GHz (b/g)" : "5 GHz (a)"),
+                              neighborAP->channel,
+                              neighborAP->BSSID.addr[ 0 ], neighborAP->BSSID.addr[ 1 ], neighborAP->BSSID.addr[ 2 ],
+                              neighborAP->BSSID.addr[ 3 ], neighborAP->BSSID.addr[ 4 ], neighborAP->BSSID.addr[ 5 ]) );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print scan policy.\n
+ *
+ * Function Scope \e Private.\n
+ * \param scanPolicy - scan policy to print.\n
+ */
+void scanMngrTracePrintScanPolicy( scan_Policy_t* scanPolicy )
+{
+    int i;
+
+    /* print general policy parameters */
+    WLAN_OS_REPORT(("Global policy parameters:\n"));
+    WLAN_OS_REPORT(("Normal scan interval: %d, deteriorating scan interval: %d\n",
+                    scanPolicy->normalScanInterval, scanPolicy->deterioratingScanInterval));
+    WLAN_OS_REPORT(("BSS list size: %d, numnber of tracked APs to start discovery: %d, "
+                    "Max track failures:% d\n", scanPolicy->BSSListSize, 
+                    scanPolicy->BSSNumberToStartDiscovery, scanPolicy->maxTrackFailures));
+
+    /* print band policy parameters for all available bands */
+    for ( i = 0; i < scanPolicy->numOfBands; i++ )
+    {
+        scanMngrTracePrintBandScanPolicy( &(scanPolicy->bandScanPolicy[ i ]) );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a band scan policy AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param bandPolicy - the band scan policy to print.\n
+ */
+void scanMngrTracePrintBandScanPolicy( scan_bandPolicy_t* bandPolicy )
+{
+    int i;
+
+    WLAN_OS_REPORT(("Band scan policy for band: %s\n", 
+                    (RADIO_BAND_2_4_GHZ == bandPolicy->band ? "2.4 GHz (b/g)" : "5.0 GHz (a)")));
+    WLAN_OS_REPORT(("Maximal number of channels to scan at each discovery interval %d:\n", 
+                    bandPolicy->numOfChannlesForDiscovery));
+    WLAN_OS_REPORT(("RSSI Threshold: %d\n", bandPolicy->rxRSSIThreshold));
+    WLAN_OS_REPORT(("Tracking method:\n"));
+    scanMngrTracePrintScanMethod( &(bandPolicy->trackingMethod) );
+    WLAN_OS_REPORT(("Discovery method:\n"));
+    scanMngrTracePrintScanMethod( &(bandPolicy->discoveryMethod) );
+    WLAN_OS_REPORT(("Immediate scan method:\n"));
+    scanMngrTracePrintScanMethod( &(bandPolicy->immediateScanMethod) );
+    WLAN_OS_REPORT(("Channels: "));
+    for( i = 0; i < bandPolicy->numOfChannles; i++ )
+    {
+        WLAN_OS_REPORT(("%d ", bandPolicy->channelList[ i ]));
+    }
+    WLAN_OS_REPORT(("\n"));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a scan method
+ *
+ * Function Scope \e Private.\n
+ * \param scanMethod - the scan method to print.\n
+ */
+void scanMngrTracePrintScanMethod( scan_Method_t* scanMethod )
+{
+    WLAN_OS_REPORT(("Scan type: %s\n", scanTypeDesc[ scanMethod->scanType ]));
+
+    switch (scanMethod->scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        scanMngrTracePrintNormalScanMethod( &(scanMethod->method.basicMethodParams) );
+        break;
+    
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+        scanMngrTracePrintTriggeredScanMethod( &(scanMethod->method.TidTriggerdMethodParams) );
+        break;
+
+    case SCAN_TYPE_SPS:
+        scanMngrTracePrintSPSScanMethod( &(scanMethod->method.spsMethodParams) );
+        break;
+
+    case SCAN_TYPE_NO_SCAN:
+    default:
+        WLAN_OS_REPORT(("No scan method defined\n"));
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief print a normal scan method
+ *
+ * Function Scope \e Private.\n
+ * \param basicMethodParams - the basic method parameters to print.\n
+ */
+void scanMngrTracePrintNormalScanMethod( scan_basicMethodParams_t* basicMethodParams )
+{
+    WLAN_OS_REPORT(("Max channel dwell time: %d, min channel dwell time: %d\n",
+                    basicMethodParams->maxChannelDwellTime, basicMethodParams->minChannelDwellTime));
+    WLAN_OS_REPORT(("Early termination condition: %s, frame number for early termination: %d\n",
+                    earlyTerminationConditionDesc[ basicMethodParams->earlyTerminationEvent >> 4 ],
+                    basicMethodParams->ETMaxNumberOfApFrames));
+    WLAN_OS_REPORT(("Number of probe requests: %d, TX level: %d, probe request rate: %d\n", 
+                    basicMethodParams->probReqParams.numOfProbeReqs,
+                    basicMethodParams->probReqParams.txPowerDbm,
+                    basicMethodParams->probReqParams.bitrate));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief print an AC triggered scan method
+ *
+ * Function Scope \e Private.\n
+ * \param triggeredMethodParams - the AC-triggered method parameters to print.\n
+ */
+void scanMngrTracePrintTriggeredScanMethod( scan_TidTriggeredMethodParams_t* triggeredMethodParams )
+{
+    WLAN_OS_REPORT(("Triggering Tid: %d\n", triggeredMethodParams->triggeringTid));
+    scanMngrTracePrintNormalScanMethod( &(triggeredMethodParams->basicMethodParams) );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief print a SPS scan method
+ *
+ * Function Scope \e Private.\n
+ * \param SPSMethodParams - the SPS method parameters to print.\n
+ */
+void scanMngrTracePrintSPSScanMethod( scan_SPSMethodParams_t* SPSMethodParams )
+{
+    WLAN_OS_REPORT(("Early termination condition: %s, frame number for early termination: %d\n",
+                    earlyTerminationConditionDesc[ SPSMethodParams->earlyTerminationEvent ],
+                    SPSMethodParams->ETMaxNumberOfApFrames));
+    WLAN_OS_REPORT(("Scan duration: %d\n", SPSMethodParams->scanDuration));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 31-Mar-2005\n
+ * \brief print debug information for every received frame.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param frameInfo - holding all frame related information.\n
+ */
+void scanMngrDebugPrintReceivedFrame( TI_HANDLE hScanMngr, scan_frameInfo_t *frameInfo )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("Scan manager received the following frame:\n") );
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("from BSSID: %02x:%02x:%02x:%02x:%02x:%02x, band: %d, channel: %d\n", 
+                             frameInfo->bssId->addr[ 0 ], frameInfo->bssId->addr[ 1 ],
+                             frameInfo->bssId->addr[ 2 ], frameInfo->bssId->addr[ 3 ],
+                             frameInfo->bssId->addr[ 4 ], frameInfo->bssId->addr[ 5 ],
+                             frameInfo->band, frameInfo->channel) );
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG, 
+                             ("rate: %d, received at TSF (lower 32 bits): %d\n", 
+                             frameInfo->rate, frameInfo->staTSF) );
+    if ( BEACON == frameInfo->parsedIEs->subType )
+    {
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("remote TSF value: %x-%x\n",
+                                  INT64_HIGHER( frameInfo->parsedIEs->content.iePacket.timestamp ),
+                                  INT64_LOWER( frameInfo->parsedIEs->content.iePacket.timestamp )) );
+
+    }
+    else
+    {
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("remote TSF value: %x-%x\n",
+                                  INT64_HIGHER( frameInfo->parsedIEs->content.iePacket.timestamp ),
+                                  INT64_LOWER( frameInfo->parsedIEs->content.iePacket.timestamp )) );
+    }
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("RSSI: %d\n", frameInfo->rssi) );
+}
+/**
+ * \author Ronen Kalish\n
+ * \date 31-Mar-2005\n
+ * \brief print BSS list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrDebugPrintBSSList( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    if ( 0 == pScanMngr->BSSList.numOfEntries )
+    {
+        WLAN_OS_REPORT(("BSS lisy is empty.\n"));
+        return;
+    }
+    
+    WLAN_OS_REPORT(("BSS List:\n") );
+
+    for ( i = 0; i < pScanMngr->BSSList.numOfEntries; i++ )
+    {
+        WLAN_OS_REPORT(  ("Entry number: %d\n", i) );
+        scanMngrDebugPrintBSSEntry( hScanMngr,  i );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 31-Mar-2005\n
+ * \brief print one entry in the BSS list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param entryIndex - the index of the entry to print.\n
+ */
+void scanMngrDebugPrintBSSEntry( TI_HANDLE hScanMngr, UINT8 entryIndex )
+{
+#ifdef REPORT_LOG
+
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    bssEntry_t* pBssEntry = &(pScanMngr->BSSList.BSSList[ entryIndex ]);
+    scan_BSSEntry_t * pScanBssEntry = &(pScanMngr->BSSList.scanBSSList[ entryIndex ]);
+
+    WLAN_OS_REPORT( ("BSSID: %02x:%02x:%02x:%02x:%02x:%02x, band: %d\n", pBssEntry->BSSID.addr[ 0 ],
+                              pBssEntry->BSSID.addr[ 1 ], pBssEntry->BSSID.addr[ 2 ],
+                              pBssEntry->BSSID.addr[ 3 ], pBssEntry->BSSID.addr[ 4 ],
+                              pBssEntry->BSSID.addr[ 5 ], pBssEntry->band) );
+    WLAN_OS_REPORT( ("channel: %d, beacon interval: %d, average RSSI: %d dBm\n", 
+                              pBssEntry->channel, pBssEntry->beaconInterval, pBssEntry->RSSI) );
+    WLAN_OS_REPORT(  ("Neighbor AP: %s, track fail count: %d\n", 
+                              (TRUE == pBssEntry->bNeighborAP ? "YES" : "NO"),
+                              pScanBssEntry->trackFailCount) );
+    WLAN_OS_REPORT(  ("local TSF: %d-%d, remote TSF: %x-%x\n", 
+                              INT64_HIGHER( pScanBssEntry->localTSF ), INT64_LOWER( pScanBssEntry->localTSF ),
+                              INT64_HIGHER( pBssEntry->lastRxTSF ), INT64_LOWER( pBssEntry->lastRxTSF )) );
+    WLAN_OS_REPORT( ("Host Time Stamp: %d, last received rate: %d\n", 
+                              pBssEntry->lastRxHostTimestamp, pBssEntry->rxRate) );
+
+#endif
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-Apr-2005\n
+ * \brief print SPS helper list
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param spsHelperList - the list to print.\n
+ * \param arrayHead - the index of the first element in the list.\n
+ * \param arraySize - the size of the array.\n
+ */
+void scanMngrDebugPrintSPSHelperList( TI_HANDLE hScanMngr, scan_SPSHelper_t* spsHelperList, int arrayHead, int arraySize )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i;
+
+    WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                             ("SPS helper list size:%d, list head:%d\n", arraySize, arrayHead) );
+    for ( i = 0; i < arraySize; i++ )
+    {
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("track list index:%d, BSSID:%02x:%02x:%02x:%02x:%02x:%02x\n", 
+                                  spsHelperList[ i ].trackListIndex,
+                                  pScanMngr->BSSList.BSSList[ spsHelperList[ i ].trackListIndex ].BSSID.addr[ 0 ],
+                                  pScanMngr->BSSList.BSSList[ spsHelperList[ i ].trackListIndex ].BSSID.addr[ 1 ],
+                                  pScanMngr->BSSList.BSSList[ spsHelperList[ i ].trackListIndex ].BSSID.addr[ 2 ],
+                                  pScanMngr->BSSList.BSSList[ spsHelperList[ i ].trackListIndex ].BSSID.addr[ 3 ],
+                                  pScanMngr->BSSList.BSSList[ spsHelperList[ i ].trackListIndex ].BSSID.addr[ 4 ],
+                                  pScanMngr->BSSList.BSSList[ spsHelperList[ i ].trackListIndex ].BSSID.addr[ 5 ]) );
+        WLAN_REPORT_INFORMATION( pScanMngr->hReport, SCAN_MNGR_MODULE_LOG,
+                                 ("TSF:%x-%x, next entry index:%d\n", 
+                                  INT64_HIGHER(spsHelperList[ i ].nextEventTSF), 
+                                  INT64_LOWER(spsHelperList[ i ].nextEventTSF),
+                                  spsHelperList[ i ].nextAPIndex) );
+    }
+}
+
+#ifdef TI_DBG
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print scan manager statistics.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_statsPrint( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_OS_REPORT(("-------------- Scan Manager Statistics ---------------\n"));
+    WLAN_OS_REPORT(("Discovery scans on G result histogram:\n"));
+    scanMngrStatsPrintScanResultHistogram( pScanMngr->stats.DiscoveryGByStatus );
+    WLAN_OS_REPORT(("\nDiscovery scans on A result histogram:\n"));
+    scanMngrStatsPrintScanResultHistogram( pScanMngr->stats.DiscoveryAByStatus );
+    WLAN_OS_REPORT(("\nTracking scans on G result histogram:\n"));
+    scanMngrStatsPrintScanResultHistogram( pScanMngr->stats.TrackingGByStatus );    
+    WLAN_OS_REPORT(("\nTracking scans on A result histogram:\n"));
+    scanMngrStatsPrintScanResultHistogram( pScanMngr->stats.TrackingAByStatus );    
+    WLAN_OS_REPORT(("\nImmediate scans on G result histogram:\n"));
+    scanMngrStatsPrintScanResultHistogram( pScanMngr->stats.ImmediateGByStatus );    
+    WLAN_OS_REPORT(("\nImmediate scans on A result histogram:\n"));
+    scanMngrStatsPrintScanResultHistogram( pScanMngr->stats.ImmediateAByStatus );
+    WLAN_OS_REPORT(("\nTrack fail count histogram:\n"));
+    scanMngrStatsPrintTrackFailHistogrsm( pScanMngr->stats.ConsecutiveTrackFailCountHistogram );
+    WLAN_OS_REPORT(("Frames received:%d, frames discarded low RSSI:%d, frames discarded other:%d\n",
+                    pScanMngr->stats.receivedFrames, pScanMngr->stats.discardedFramesLowRSSI, 
+                    pScanMngr->stats.discardedFramesOther));
+    WLAN_OS_REPORT(("\nSPS channels not attened histogram:\n"));
+    scanMngrStatsPrintSPSChannelsHistogram( pScanMngr->stats.SPSChannelsNotAttended );
+    WLAN_OS_REPORT(("\nSPS attempts changed due to DTIM collision:%d, APs removed due to DTIM overlap: %d\n",
+                    pScanMngr->stats.SPSSavedByDTIMCheck, pScanMngr->stats.APsRemovedDTIMOverlap));
+    WLAN_OS_REPORT(("APs removed due to invalid channel: %d\n", pScanMngr->stats.APsRemovedInvalidChannel));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print scan result histogram statistics.\n
+ *
+ * Function Scope \e Private.\n
+ * \param scanResultHistogram - Scan results histogram (by scan complete reason).\n
+ */
+void scanMngrStatsPrintScanResultHistogram( UINT32 scanResultHistogram[] )
+{
+    WLAN_OS_REPORT(("Complete OK   failed    stopped    TSF error    FW reset   aborted\n"));
+    WLAN_OS_REPORT(("%-6d        %-5d     %-5d      %-5d        %-5d      %-5d\n",
+                    scanResultHistogram[ SCAN_CRS_SCAN_COMPLETE_OK ],
+                    scanResultHistogram[ SCAN_CRS_SCAN_FAILED ],
+                    scanResultHistogram[ SCAN_CRS_SCAN_STOPPED ],
+                    scanResultHistogram[ SCAN_CRS_TSF_ERROR ],
+                    scanResultHistogram[ SCAN_CRS_SCAN_ABORTED_FW_RESET ],
+                    scanResultHistogram[ SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY ]));    
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print track fail count histogram statistics.\n
+ *
+ * Function Scope \e Private.\n
+ * \param trackFailHistogram - tracking failure histogram (by tracking retry).\n
+ */
+void scanMngrStatsPrintTrackFailHistogrsm( UINT32 trackFailHistogram[] )
+{
+    WLAN_OS_REPORT(("Attempts: 0      1      2      3      4\n"));
+    WLAN_OS_REPORT(("          %-6d %-6d %-6d %-6d %-6d\n\n",
+                    trackFailHistogram[0], trackFailHistogram[1],trackFailHistogram[2],
+                    trackFailHistogram[3], trackFailHistogram[4]));
+    WLAN_OS_REPORT(("Attempts: 5      6      7      8      9 or more\n"));
+    WLAN_OS_REPORT(("          %-6d %-6d %-6d %-6d %-6d\n\n",
+                    trackFailHistogram[5], trackFailHistogram[6],trackFailHistogram[7],
+                    trackFailHistogram[8],trackFailHistogram[9]));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 24-July-2005\n
+ * \brief Print SPS attendant channel histogram statistics.\n
+ *
+ * Function Scope \e Private.\n
+ * \param SPSChannelsNotAttendedHistogram - SPS channels attendant histogram.\n
+ */
+void scanMngrStatsPrintSPSChannelsHistogram( UINT32 SPSChannelsNotAttendedHistogram[] )
+{
+    WLAN_OS_REPORT(("Channel index: 0      1      2      3\n"));
+    WLAN_OS_REPORT(("               %-6d %-6d %-6d %-6d\n\n",
+                    SPSChannelsNotAttendedHistogram[ 0 ], SPSChannelsNotAttendedHistogram[ 1 ],
+                    SPSChannelsNotAttendedHistogram[ 2 ], SPSChannelsNotAttendedHistogram[ 3 ]));
+    WLAN_OS_REPORT(("Channel index: 4      5      6      7\n"));
+    WLAN_OS_REPORT(("               %-6d %-6d %-6d %-6d\n\n",
+                    SPSChannelsNotAttendedHistogram[ 4 ], SPSChannelsNotAttendedHistogram[ 5 ],
+                    SPSChannelsNotAttendedHistogram[ 6 ], SPSChannelsNotAttendedHistogram[ 7 ]));
+    WLAN_OS_REPORT(("Channel index: 8      9      10     11\n"));
+    WLAN_OS_REPORT(("               %-6d %-6d %-6d %-6d\n\n",
+                    SPSChannelsNotAttendedHistogram[ 8 ], SPSChannelsNotAttendedHistogram[ 9 ],
+                    SPSChannelsNotAttendedHistogram[ 10 ], SPSChannelsNotAttendedHistogram[ 11 ]));
+    WLAN_OS_REPORT(("Channel index: 12     13     14     15\n"));
+    WLAN_OS_REPORT(("               %-6d %-6d %-6d %-6d\n\n",
+                    SPSChannelsNotAttendedHistogram[ 12 ], SPSChannelsNotAttendedHistogram[ 13 ],
+                    SPSChannelsNotAttendedHistogram[ 14 ], SPSChannelsNotAttendedHistogram[ 15 ]));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Reset scan manager statistics.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_statsReset( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    os_memoryZero( pScanMngr->hOS, &(pScanMngr->stats), sizeof(scan_mngrStat_t) );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 25-July-2005\n
+ * \brief Print Neighbor AP list.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - Handle to the scan manager object.\n
+ */
+void scanMngrDebugPrintNeighborAPList( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+    int i,j;
+    
+    WLAN_OS_REPORT(("-------------- Scan Manager Neighbor APs List ---------------\n"));
+    for ( i = 0; i < RADIO_BAND_NUM_OF_BANDS; i++ )
+    {
+        WLAN_OS_REPORT(("Neighbor AP list for band:%d\n", i));
+        if ( 0 == pScanMngr->neighborAPsDiscoveryList[ i ].numOfEntries )
+        {
+            WLAN_OS_REPORT(("Neighbor AP list is empty.\n"));
+            continue; /* to next band */
+        }
+        WLAN_OS_REPORT(("%-17s %-4s %-7s %-30s\n", "BSSID", "Band", "Channel", "Discovery state"));
+        WLAN_OS_REPORT(("------------------------------------------------------\n"));
+        for ( j = 0; j < pScanMngr->neighborAPsDiscoveryList[ i ].numOfEntries; i++ )
+        {
+            scanMngrDebugPrintNeighborAP( &(pScanMngr->neighborAPsDiscoveryList[ i ].APListPtr[ j ]),
+                                          pScanMngr->neighborAPsDiscoveryList[ i ].trackStatusList[ j ] );
+        }
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 25-July-2005\n
+ * \brief Print One neighbor AP entry.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pNeighborAp - pointer to the neighbor AP data.\n
+ * \param discovery state - the discovery state of this neighbor AP.\n
+ */
+void scanMngrDebugPrintNeighborAP( neighborAP_t* pNeighborAp, scan_neighborDiscoveryState_e discoveryState )
+{
+    WLAN_OS_REPORT(("%02x:%02x:%02x:%02x:%02x:%02x %-4d %-7d %-30s\n", 
+                    pNeighborAp->BSSID.addr[ 0 ], pNeighborAp->BSSID.addr[ 1 ], pNeighborAp->BSSID.addr[ 2 ],
+                    pNeighborAp->BSSID.addr[ 3 ], pNeighborAp->BSSID.addr[ 4 ], pNeighborAp->BSSID.addr[ 5 ],
+                    pNeighborAp->band, pNeighborAp->channel, neighborDiscovreyStateDesc[ discoveryState ]));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-July-2005\n
+ * \brief Prints a scan command.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pScanParams - a pointer to the scan parameters structure.\n
+ */
+void scanMngrDebugPrintScanCommand( scan_Params_t* pScanParams )
+{
+    int i;
+
+    if ( 0 == pScanParams->numOfChannels )
+    {
+        WLAN_OS_REPORT(("Invalid scan command.\n"));
+        return;
+    }
+
+    WLAN_OS_REPORT(("Scan type: %s, band: %d\n", scanTypeDesc[ pScanParams->scanType ], pScanParams->band));
+    
+    switch (pScanParams->scanType)
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE:
+        WLAN_OS_REPORT(("Probe request number:%d, rate:%x, TX level:%d\n",
+                        pScanParams->probeReqNumber, pScanParams->probeRequestRate));
+        /* break is missing on purpose!!! */
+
+    case SCAN_TYPE_NORMAL_PASSIVE:
+        WLAN_OS_REPORT(("SSID: %s\n", pScanParams->desiredSsid));
+        WLAN_OS_REPORT(("%-4s %-17s %-17s %-20s %-8s %-14s %-14s\n", "Chnl", "BSSID", "Early ter. event", 
+                        "Early ter. frame num", "TX level", "Max dwell time", "Min dwell time"));
+        WLAN_OS_REPORT(("------------------------------------------------------------------------------------------------------\n"));
+        for ( i = 0; i < pScanParams->numOfChannels; i++ )
+        {
+            scanMngrDebugPrintNormalChannelParam( &(pScanParams->channelEntry[ i ].normalChannelEntry) );
+        }
+        break;
+
+    case SCAN_TYPE_TRIGGERED_ACTIVE:
+        WLAN_OS_REPORT(("Probe request number:%d, rate:%x, TX level:%d\n",
+                        pScanParams->probeReqNumber, pScanParams->probeRequestRate ));
+        /* break is missing on purpose!!! */
+
+    case SCAN_TYPE_TRIGGERED_PASSIVE:
+        WLAN_OS_REPORT(("SSID: %s, Tid: %d\n", pScanParams->desiredSsid, pScanParams->Tid));
+        WLAN_OS_REPORT(("%-4s %-17s %-17s %-20s %-8s %-14s %-14s\n", "Chnl", "BSSID", "Early ter. event", 
+                        "Early ter. frame num", "TX level", "Max dwell time", " Min dwell time"));
+        WLAN_OS_REPORT(("------------------------------------------------------------------------------------------------------\n"));
+        for ( i = 0; i < pScanParams->numOfChannels; i++ )
+        {
+            scanMngrDebugPrintNormalChannelParam( &(pScanParams->channelEntry[ i ].normalChannelEntry) );
+        }
+        break;
+
+    case SCAN_TYPE_SPS:
+        WLAN_OS_REPORT(("Total scan duration (for scan timer): %d, latest TSF value: %x-%x\n", 
+                        pScanParams->SPSScanDuration, 
+                        INT64_HIGHER(pScanParams->latestTSFValue), INT64_LOWER(pScanParams->latestTSFValue)));
+        WLAN_OS_REPORT(("%-4s %-17s %-17s %-7s %-16s %-20s\n", "Chnl", "BSSID", "Start time (TSF)", "Duration",
+                        "Early ter. event", "Early ter. frame num"));
+        WLAN_OS_REPORT(("---------------------------------------------------------------------------------------\n"));
+        for ( i = 0; i < pScanParams->numOfChannels; i++ )
+        {
+            scanMngrDebugPrintSPSChannelParam( &(pScanParams->channelEntry[ i ].SPSChannelEntry) );
+        }
+        break;
+
+    case SCAN_TYPE_NO_SCAN:
+    default:
+        WLAN_OS_REPORT(("Invalid scan type: %d\n", pScanParams->scanType));
+        break;
+    }
+    
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-July-2005\n
+ * \brief Prints scan command single normal channel.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pNormalChannel - a pointer to the normal channel to print.\n
+ */
+void scanMngrDebugPrintNormalChannelParam( scan_normalChannelEntry_t* pNormalChannel )
+{
+    WLAN_OS_REPORT(("%-4d %02x:%02x:%02x:%02x:%02x:%02x %-17s %-20d %-8d %-14d %-14d\n", pNormalChannel->channel, 
+                    pNormalChannel->bssId.addr[ 0 ], pNormalChannel->bssId.addr[ 1 ], pNormalChannel->bssId.addr[ 2 ],
+                    pNormalChannel->bssId.addr[ 3 ], pNormalChannel->bssId.addr[ 4 ], pNormalChannel->bssId.addr[ 5 ],
+                    earlyTerminationDesc[ pNormalChannel->earlyTerminationEvent >> 8 ],
+                    pNormalChannel->ETMaxNumOfAPframes, pNormalChannel->txPowerDbm,
+                    pNormalChannel->minChannelDwellTime, pNormalChannel->maxChannelDwellTime));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-July-2005\n
+ * \brief Prints scan command single SPS channel.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pSPSChannel - a pointer to the SPS channel to print.\n
+ */
+void scanMngrDebugPrintSPSChannelParam( scan_SPSChannelEntry_t* pSPSChannel )
+{
+    WLAN_OS_REPORT(("%-4d %02x:%02x:%02x:%02x:%02x:%02x %8x-%8x %-7d %-16s %-3d\n", 
+                    pSPSChannel->channel, pSPSChannel->bssId.addr[ 0 ], pSPSChannel->bssId.addr[ 1 ], 
+                    pSPSChannel->bssId.addr[ 2 ], pSPSChannel->bssId.addr[ 3 ], pSPSChannel->bssId.addr[ 4 ],
+                    pSPSChannel->bssId.addr[ 5 ], INT64_HIGHER(pSPSChannel->scanStartTime), 
+                    INT64_LOWER(pSPSChannel->scanStartTime), pSPSChannel->scanDuration, 
+                    earlyTerminationDesc[ pSPSChannel->earlyTerminationEvent >> 8 ], pSPSChannel->ETMaxNumOfAPframes));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 25-July-2005\n
+ * \brief Prints all data in the scan manager object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrDebugPrintObject( TI_HANDLE hScanMngr )
+{
+    scanMngr_t* pScanMngr = (scanMngr_t*)hScanMngr;
+
+    WLAN_OS_REPORT(("-------------- Scan Manager Object Dump ---------------\n"));
+    WLAN_OS_REPORT(("Continuous scan timer running: %s, Continuous scan started:%s\n",
+                    booleanDesc[ pScanMngr->bTimerRunning ], booleanDesc[ pScanMngr->bContinuousScanStarted ]));
+    WLAN_OS_REPORT(("Current BSS in low quality: %s, AP TSF synchronized: %s\n",
+                    booleanDesc[ pScanMngr->bLowQuality ], booleanDesc[ pScanMngr->bSynchronized ]));
+    WLAN_OS_REPORT(("Continuous scan state: %s, Immediate scan state: %s\n",
+                    contScanStatesDesc[ pScanMngr->contScanState ], immedScanStatesDesc[ pScanMngr->immedScanState ]));
+    WLAN_OS_REPORT(("Discovery part: %s, G channels discovery Index: %d, A channels discovery index: %d\n",
+                    discoveryPartDesc[ pScanMngr->currentDiscoveryPart ], 
+                    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_2_4_GHZ ],
+                    pScanMngr->channelDiscoveryIndex[ RADIO_BAND_5_0_GHZ ]));
+    WLAN_OS_REPORT(("G neighbor APs discovery index: %d, A neighbor APs discovery index: %d\n",
+                    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_2_4_GHZ ],
+                    pScanMngr->neighborAPsDiscoveryIndex[ RADIO_BAND_5_0_GHZ ]));
+    WLAN_OS_REPORT(("Current BSS MAC: %02x:%02x:%02x:%02x:%02x:%02x, Current BSS band: %d\n",
+                    pScanMngr->currentBSS.addr[ 0 ], pScanMngr->currentBSS.addr[ 1 ], pScanMngr->currentBSS.addr[ 2 ],
+                    pScanMngr->currentBSS.addr[ 3 ], pScanMngr->currentBSS.addr[ 4 ], pScanMngr->currentBSS.addr[ 5 ],
+                    pScanMngr->currentBSSBand));
+    WLAN_OS_REPORT(("Last beacon DTIM count:%d, TSF:%x-%x\n",
+                    pScanMngr->lastLocalBcnDTIMCount, 
+                    INT64_HIGHER(pScanMngr->currentTSF), INT64_LOWER(pScanMngr->currentTSF)));
+    WLAN_OS_REPORT(("-------------- Scan Manager Policy ---------------\n"));
+    scanMngrTracePrintScanPolicy( &(pScanMngr->scanPolicy) );
+    WLAN_OS_REPORT(("-------------- Scan Manager BSS List ---------------\n"));
+    scanMngrDebugPrintBSSList( hScanMngr );
+    scanMngrDebugPrintNeighborAPList( hScanMngr );
+    scanMngr_statsPrint( hScanMngr );
+    WLAN_OS_REPORT(("New BSS found during last discovery:%s, Number of scan cycles during which no new AP was found: %d\n",
+                    booleanDesc[ pScanMngr->bNewBSSFound ], pScanMngr->consecNotFound));
+    WLAN_OS_REPORT(("Scan for neighbor APs only at last immediate scan: %s\n", 
+                    booleanDesc[ pScanMngr->bImmedNeighborAPsOnly ]));
+    WLAN_OS_REPORT(("-------------- Last issued scan command ---------------\n"));
+    scanMngrDebugPrintScanCommand( &(pScanMngr->scanParams) );
+    WLAN_OS_REPORT(("-------------- Handles ---------------\n"));
+    WLAN_OS_REPORT(("Continuous scan timer: %x, OS:% x, Reg. domain: %x\n",
+                    pScanMngr->hContinuousScanTimer, pScanMngr->hOS, pScanMngr->hRegulatoryDomain));
+    WLAN_OS_REPORT(("Report: %x, Roaming manager: %x, Scan concentrator: %x\n",
+                    pScanMngr->hReport, pScanMngr->hRoamingMngr, pScanMngr->hScanCncn));
+}
+
+#endif /* TI_DBG */
diff --git a/sta_dk_4_0_4_32/common/src/Application/ScanMngr/scanMngr.h b/sta_dk_4_0_4_32/common/src/Application/ScanMngr/scanMngr.h
new file mode 100644 (file)
index 0000000..619bfcd
--- /dev/null
@@ -0,0 +1,902 @@
+/** \file scanMngr.h
+ *  \brief This file include private definitions for the scan manager module.
+ *  \author Ronen Kalish
+ *  \date 01-Mar-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCAN_MNGR_H__
+#define __SCAN_MNGR_H__
+
+#include "scanMngrApi.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/* allocation vector constants */
+#define SCAN_MNGR_ALLOC_VECTOR_OBJECT           0x01
+#define SCAN_MNGR_ALLOC_VECTOR_TIMER            0x02
+#define SCAN_MNGR_ALLOC_VECTOR_FRAME            0x03
+
+/* SPS guard times */
+#ifdef TI_DBG
+#define SCAN_SPS_GUARD_FROM_CURRENT_TSF         300000 /* 300 msecs - to allow for some debug printouts */
+#else
+#define SCAN_SPS_GUARD_FROM_CURRENT_TSF         50000 /* 50 msecs */
+#endif /* TI_DBG */
+#define SCAN_SPS_GUARD_FROM_LAST_BSS            2000 /* 2 msecs */
+#define SCAN_SPS_DURATION_PART_IN_ADVANCE       4 /* 1/4 of scan duration in advance */
+#define SCAN_SPS_USE_DRIFT_COMPENSATION         1 /* if defined, use drift compensation algorithm */
+#define SCAN_SPS_NUM_OF_TSF_DELTA_ENTRIES       4 /* number of TSF delta ^ 2 entries */
+#define SCAN_SPS_FW_DTIM_LENGTH                 1000 /* time (in usec) for a DTIM event to complete in the FW */
+
+/* Quality calculation constants */
+#define RSSI_PREVIOUS_COEFFICIENT               9
+
+/* scan iteration number after which, if no new AP was found, pre-auth needs to be re-done */
+#define SCAN_MNGR_CONSEC_SCAN_ITER_FOR_PRE_AUTH 50
+
+#define MAX_DESC_LENGTH                         50 /* max characters for a description string */
+#define SCAN_MNGR_STAT_MAX_TRACK_FAILURE        10 /* max track filures for statistics histogram */
+
+#ifdef TI_DBG
+/*#define SCAN_MNGR_DBG 1
+#define SCAN_MNGR_SPS_DBG 1
+#define SCAN_MNGR_DTIM_DBG 1 */
+#endif
+
+ /*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+ /** \enum scan_immedScanState_e 
+ * \brief enumerates immediate scan internal status
+ */
+typedef enum
+{
+    SCAN_ISS_IDLE = 0,                  /**< immediate scan is not running */
+    SCAN_ISS_G_BAND,                    /**< immediate scan is running on G band */
+    SCAN_ISS_A_BAND,                    /**< immediate scan is running on A band */
+    SCAN_ISS_STOPPING,                  /**< stop was requested and is now pending */
+    SCAN_ISS_NUM_OF_STATES              /**< number of available immediate scan states states */
+} scan_immedScanState_e;
+
+/** \enum scan_contScanState_e 
+ * \brief enumerates continuous scan internal status
+ */
+typedef enum
+{
+       SCAN_CSS_IDLE = 0,                  /**< continuous scan is not running */
+       SCAN_CSS_TRACKING_G_BAND,           /**< continuous scan is performing tracking scan on G */
+    SCAN_CSS_TRACKING_A_BAND,           /**< continuous scan is performing tracking scan on A */
+       SCAN_CSS_DISCOVERING,               /**< continuous scan is performing discovery scan */
+    SCAN_CSS_STOPPING,                  /**< continuous scan is waiting for scan complete notification */
+    SCAN_CSS_NUM_OF_STATES              /**< number of available continuous scan states */
+} scan_contScanState_e;
+
+/** \enum scan_discoveryPart_e 
+ * \brief enumerates the different parts in the discovery process
+ */
+typedef enum
+{
+       SCAN_SDP_NEIGHBOR_G = 0,            /**< attempting to discover neighbor APs in G band */
+       SCAN_SDP_NEIGHBOR_A,                /**< attempting to discover neighbor APs in A band */
+       SCAN_SDP_CHANNEL_LIST_G,            /**< attempting to discover all APs in G band */
+       SCAN_SDP_CHANNEL_LIST_A,            /**< attempting to discover all APs in A band */
+    SCAN_SDP_NO_DISCOVERY,              /**< no discovery should be attempted */
+    SCAN_SDP_NUMBER_OF_DISCOVERY_PARTS  /**< number of discovery parts available */
+} scan_discoveryPart_e;
+
+/** \enum scan_neighborDiscoveryState_e
+ * \brief enumerates the different discovery states possible for a neighbor AP
+ */
+typedef enum
+{
+    SCAN_NDS_DISCOVERED = 0,            /**< Neighbor AP was discovered and is now being tracked */
+    SCAN_NDS_NOT_DISCOVERED,            /**< Neighbor AP was not yet discovered, and should be */
+    SCAN_NDS_CURRENT_AP,                /**< 
+                                         * Neighbor AP is the AP STA is currently connected to, 
+                                         * and shouldn't be discovered
+                                         */
+    SCAN_NDS_NUMBER_OF_NEIGHBOR_DISCOVERY_STATES
+                                        /**< number of available neighbor disocvery states */
+} scan_neighborDiscoveryState_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+#define WAS_SPS_CHANNEL_ATTENDED( SPSStatus, i )    \
+    (0 != (SPSStatus & (1<<i)) ? TRUE : FALSE)
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct scan_neighborAPListDiscovery_t
+ * \brief This structure contains Neighbor AP list and their detection status
+ */
+typedef struct
+{
+       UINT8                                           numOfEntries;                                   /**< number of entries in the list */
+    neighborAP_t                           APListPtr[ MAX_NUM_OF_NEIGHBOR_APS ];           /**< neighbor APs list */
+       scan_neighborDiscoveryState_e   trackStatusList[ MAX_NUM_OF_NEIGHBOR_APS ];     /**< tracking status list */
+} scan_neighborAPListDiscovery_t;
+
+/** \struct scan_BSSEntry
+ * \brief This structure contains information relevant only for scan manager module on a BSS
+ */
+typedef struct
+{
+       UINT8                                   trackFailCount;                 /**< number of consecutive failed track attempts */
+    UINT64                                     localTSF;                       /**<
+                                                             * the TSF of the AP the station is connected to at the
+                                                             * reception of the last frame from this AP
+                                                             */
+#ifdef SCAN_SPS_USE_DRIFT_COMPENSATION
+    INT64               prevTSFDelta;                                               /**< Previous TSF delta */
+    INT32               deltaChangeArray[ SCAN_SPS_NUM_OF_TSF_DELTA_ENTRIES ];      /**< 
+                                                                                     * Array holding deltas 
+                                                                                     * between prev. TSF delta
+                                                                                     */
+    int                 deltaChangeArrayIndex;                                      /**< 
+                                                                                     * index to where next entry
+                                                                                     * in the delta array should
+                                                                                     * be stored
+                                                                                     */
+#endif
+} scan_BSSEntry_t;
+
+/** \struct scan_BSSList
+ * \brief This structure contains the BSS tracking list.
+ */
+typedef struct
+{
+    UINT8               numOfEntries;                                               /**< Number of entries in the list */
+    bssEntry_t          BSSList[ MAX_SIZE_OF_BSS_TRACK_LIST ];                      /**< BSS public information */
+    scan_BSSEntry_t     scanBSSList[ MAX_SIZE_OF_BSS_TRACK_LIST ];                  /**< 
+                                                                                     * BSS scan manager private 
+                                                                                     * information
+                                                                                     */
+} scan_BSSList_t;
+
+/** \struct scan_SPSHelper_t
+ * \brief This structure contains information used for building SPS scan command
+ */
+typedef struct
+{
+    UINT64                          nextEventTSF;                                   /**< 
+                                                                                     * local TSF value of AP next frame 
+                                                                                     * transmission
+                                                                                     */
+    int                             trackListIndex;                                 /**< index to BSS info in the track list */
+    int                             nextAPIndex;                                    /**< index of next AP entry */
+} scan_SPSHelper_t;
+
+#ifdef TI_DBG
+/** \struct scan_mngrStat_t
+ * \brief holds all scan manager statistics
+ */
+typedef struct
+{
+    UINT32      receivedFrames;                                     /**< Number of scan results received */
+    UINT32      discardedFramesLowRSSI;                             /**< 
+                                                                     * Number of frames discarded due 
+                                                                     * to RSSI lower than threshold
+                                                                     */
+    UINT32      discardedFramesOther;                               /**< 
+                                                                     * Number of frames discarded due to 
+                                                                     * other reasons (invalid band, 
+                                                                     * list full)
+                                                                     */
+    UINT32      SPSSavedByDTIMCheck;                                /**<
+                                                                     * Number of SPS scans that were moved
+                                                                     * due to the DTIM collision detection mechanism
+                                                                     */
+    UINT32      APsRemovedDTIMOverlap;                              /**< 
+                                                                     * Number of times APs were removed from
+                                                                     * tracking list because all their beacons
+                                                                     * collide with current AP DTIMs
+                                                                     */
+    UINT32      APsRemovedInvalidChannel;                           /**<
+                                                                     * Number of times APs were removed from
+                                                                     * tracking list because their channel was
+                                                                     * not valid for tracking scan type
+                                                                     */
+    UINT32      TrackingGByStatus[ SCAN_CRS_NUM_OF_RES_STATUS ];    /**< 
+                                                                     * Number of track scans on G,
+                                                                     * according to completion status
+                                                                     */
+    UINT32      TrackingAByStatus[ SCAN_CRS_NUM_OF_RES_STATUS ];    /**< 
+                                                                     * Number of track scans on A,
+                                                                     * according to completion status
+                                                                     */
+    UINT32      DiscoveryGByStatus[ SCAN_CRS_NUM_OF_RES_STATUS ];   /**< 
+                                                                     * Number of discovery scans on G,
+                                                                     * according to completion status
+                                                                     */
+    UINT32      DiscoveryAByStatus[ SCAN_CRS_NUM_OF_RES_STATUS ];   /**< 
+                                                                     * Number of discovery scans on A,
+                                                                     * according to completion status
+                                                                     */
+    UINT32      ImmediateGByStatus[ SCAN_CRS_NUM_OF_RES_STATUS ];   /**< 
+                                                                     * Number of immediate scans on G,
+                                                                     * according to completion status
+                                                                     */
+    UINT32      ImmediateAByStatus[ SCAN_CRS_NUM_OF_RES_STATUS ];   /**< 
+                                                                     * Number of immediate scans on A,
+                                                                     * according to completion status
+                                                                     */
+    UINT32      ConsecutiveTrackFailCountHistogram[ SCAN_MNGR_STAT_MAX_TRACK_FAILURE ];
+                                                                    /**< 
+                                                                     * Number of consecutive track
+                                                                     * fail counts */
+    UINT32      SPSChannelsNotAttended[ SCAN_MAX_NUM_OF_SPS_CHANNELS_PER_COMMAND ];
+                                                                    /**<
+                                                                     * Number of times SPS channels were
+                                                                     * not scanned by FW, according to
+                                                                     * their location in the scan command
+                                                                     */
+} scan_mngrStat_t;
+#endif
+
+/** \struct scanMngr_t
+ * \brief This structure contains the scan manager object data
+ */
+typedef struct
+{
+       tsf_dtim_mib_t                                  currTsfDtimMib;
+    /* handles to other modules */
+    TI_HANDLE                                  hOS;                                            /**< handle to the OS object */
+    TI_HANDLE                                  hReport;                                        /**< handle to the report object */
+    TI_HANDLE                                  hRegulatoryDomain;                              /**< 
+                                                                                     * handle to the regulatory domain
+                                                                                     * object
+                                                                                     */
+    TI_HANDLE                                  hScanCncn;                                      /**< 
+                                                                                     * handle to the scan concentrator
+                                                                                     * object
+                                                                                     */
+    TI_HANDLE                                  hRoamingMngr;                                   /**< 
+                                                                                     * handle to the roaming manager 
+                                                                                     * object
+                                                                                     */
+    TI_HANDLE                       hSiteMngr;                                      /**< 
+                                                                                     * handle to the site manager object*/
+    TI_HANDLE                                          hHalCtrl;                                                                                
+    /* start / stop flag */
+    BOOLEAN                         bContinuousScanStarted;                         /**<
+                                                                                     * Indicates whether continuous scan
+                                                                                     * was started
+                                                                                     */
+    /* Timer */
+    TI_HANDLE                                  hContinuousScanTimer;                           /**< continuous scan timer object */
+    BOOLEAN                         bTimerRunning;                                  /**< 
+                                                                                     * indicates whether the timer was 
+                                                                                     * started
+                                                                                     */
+
+    /* scan policy */
+    scan_Policy_t                                  scanPolicy;                                     /**< scan policy */
+    BOOLEAN                         bLowQuality;                                    /**<
+                                                                                     * Indicates whether to use the low
+                                                                                     * quality time or normal quality
+                                                                                     * timer for continuous scan.
+                                                                                     */
+
+    /* tracking and discovery information */
+    scan_contScanState_e                       contScanState;                                  /**< current continuous scan state */
+    scan_immedScanState_e           immedScanState;                                 /**< current immediate scan state */
+       BOOLEAN                                                 bImmedNeighborAPsOnly;                                                  /**< 
+                                                                                                                                                                        * whether immediate scan is to search
+                                                                                                                                                                        * for neighbor AP's only
+                                                                                                                                                                        */
+    scan_neighborAPListDiscovery_t     neighborAPsDiscoveryList[ RADIO_BAND_NUM_OF_BANDS ];
+                                                                                    /**< 
+                                                                                     * List of neighbor APs and their
+                                                                                     * discovery status
+                                                                                     */
+    UINT8                                      neighborAPsDiscoveryIndex[ RADIO_BAND_NUM_OF_BANDS ];
+                                                                                    /**< 
+                                                                                     * Indexes for the neighbor APs
+                                                                                     * discovery lists
+                                                                                     */
+    UINT8                              channelDiscoveryIndex[ RADIO_BAND_NUM_OF_BANDS ];  /**< Indexes for the channels lists */
+    scan_discoveryPart_e                       currentDiscoveryPart;                           /**< current discovery part */
+    BOOLEAN                                    bSynchronized;                                  /**< 
+                                                                                     * TRUE if SPS data is synchronized
+                                                                                     * (no TSF error event occurred)
+                                                                                     */
+    UINT64                          currentTSF;                                     /**< 
+                                                                                     * the local current TSF value 
+                                                                                     */
+       UINT32                                                  currentHostTimeStamp;                                                   /**<
+                                                                                                                                                                        * The current local host time stamp
+                                                                                                                                                                        * (at the time of the above TSF value)
+                                                                                                                                                                        */
+    UINT8                           lastLocalBcnDTIMCount;                          /**<
+                                                                                     * the DTIM count at the last 
+                                                                                     * local beacon reception in the FW
+                                                                                     */
+    UINT64                                                     lastLocalBcnTSF;                                                                /**<
+                                                                                                                                                                        * The local TSF value at the last 
+                                                                                                                                                                        * local beacon reception
+                                                                                                                                                                        */     
+       macAddress_t                    currentBSS;                                     /**< MAC address of current BSS */
+    radioBand_e                     currentBSSBand;                                 /**< band of current BSS */
+       UINT32                                                  currentBSSBeaconInterval;                                               /**< Beacon interval of current BSS */
+       UINT32                                                  currentBSSDtimPeriod;                                                   /**< DTIM period of current BSS */
+    BOOLEAN                         bNewBSSFound;                                   /**< 
+                                                                                     * Indicates whether a new BSS was
+                                                                                     * found during the last discovery
+                                                                                     * stage
+                                                                                     */
+    UINT16                          consecNotFound;                                 /**<
+                                                                                     * consecutive number of scan 
+                                                                                     * cycles in which no new AP was found
+                                                                                     * (used to re-pre-auth current APs)
+                                                                                     */
+    scan_Params_t                              scanParams;                                     /**< temporary storage for scan command */
+    scan_BSSList_t                             BSSList;                                        /**< BSS list (also used for tracking) */
+#ifdef TI_DBG
+    scan_mngrStat_t                 stats;                                          /**< statistics */
+    radioBand_e                     statsLastDiscoveryBand;                         /**< 
+                                                                                     * For statistics: the band on which
+                                                                                     * discovery was last performed.
+                                                                                     */
+#endif
+} scanMngr_t;
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Frees scan manager resources.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param allocVector - bit vector indicating which resources were allocated.\n
+ */
+void scanMngrFreeMem( TI_HANDLE hScanMngr, UINT8 allocVector );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Starts a continuous scan operation.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrPerformContinuousScan( TI_HANDLE hScanMngr );
+
+void scanMngrGetCurrentTsfDtimMibCB(TI_HANDLE hScanMngr, TI_STATUS status, UINT8* CB_buf) ;
+void scanMngr_GetUpdatedTsfDtimMibForScan(TI_HANDLE hScanMngr) ;
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Perform aging on the BSS list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrPerformAging( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Updates object data according to a received frame.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param frameInfo - all frame related information.\n
+ */
+void scanMngrUpdateReceivedFrame( TI_HANDLE hScanMngr, scan_frameInfo_t* frameInfo );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 17-Mar-2005\n
+ * \brief Cerate a new tracking entry and store the newly discovered AP info in it.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param frameInfo - a pointer to the information received from this AP.\n
+ */
+void scanMngrInsertNewBSSToTrackingList( TI_HANDLE hScanMngr, scan_frameInfo_t* frameInfo );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 17-Mar-2005\n
+ * \brief Updates tracked AP information.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param BSSListIndex - index to the BSS list where the AP information is stored.\n
+ * \param frameInfo - a pointer to the information received from this AP.\n
+ */
+void scanMngrUpdateBSSInfo( TI_HANDLE hScanMngr, UINT8 BSSListIndex, scan_frameInfo_t* frameInfo );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 16-Mar-2005\n
+ * \brief Searched tracking list for an entry matching given BSSID.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bssId - the BSSID to search for.\n
+ * \return entry index if found, -1 if no entry matching the BSSID was found.\n
+ */
+INT8 scanMngrGetTrackIndexByBssid( TI_HANDLE hScanMngr, macAddress_t* bssId );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Search current policy for band policy
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param band - the band to find policy for.\n
+ * \return the policy structure if found, NULL if no policy configured for this band.\n
+ */
+scan_bandPolicy_t* scanMngrGetPolicyByBand( TI_HANDLE hScanMngr, radioBand_e band );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Sets the next discovery part according to current discovery part, policies and neighbor APs availability .\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrSetNextDiscoveryPart( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Checks whether discovery should be performed on the specified discovery part.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param discoveryPart - the discovery part to check.\n
+ */
+BOOLEAN scanMngrIsDiscoveryValid( TI_HANDLE hScanMngr, scan_discoveryPart_e discoveryPart );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 07-Mar-2005\n
+ * \brief Check whether there are neighbor APs to track on the given band.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - The scan policy for the requested band.\n
+ * \param bNeighborAPsOnly - whether to scan for neighbor APs only or for all policy defined channels.\n
+ */
+BOOLEAN scanMngrNeighborAPsAvailableForDiscovery( TI_HANDLE hScanMngr, radioBand_e band );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Builds a scan command on the object workspace for immediate scan.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - The scan policy for the requested band.\n
+ * \param bNeighborAPsOnly - whether to scan for neighbor APs only or for all policy defined channels.\n
+ */
+void scanMngrBuildImmediateScanCommand( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy, BOOLEAN bNeighborAPsOnly );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 03-Mar-2005\n
+ * \brief Builds a scan command on the object workspace for tracking.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - The scan policy for the band to track on.\n
+ * \param band - the band to scan.\n
+ */
+void scanMngrBuildTrackScanCommand( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy, radioBand_e band );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 03-Mar-2005\n
+ * \brief Builds a scan command on the object workspace for discovery.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrBuildDiscoveryScanCommand( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Builds the scan command header on the object workspace.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanMethod - The scan method (and parameters) to use.\n
+ * \param band - the band to scan.\n
+ */
+void scanMngrBuildScanCommandHeader( TI_HANDLE hScanMngr, scan_Method_t* scanMethod, radioBand_e band );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Add neighbor APs to scan command on the object workspace for discovery scan.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - the scan policy for the band to use.\n
+ */
+void scanMngrAddNeighborAPsForDiscovery( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 06-Mar-2005\n
+ * \brief Add channel from policy channels list to scan command on the object workspace for discovery scan.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bandPolicy - the scan policy for the band to use.\n
+ */
+void scanMngrAddChannelListForDiscovery( TI_HANDLE hScanMngr, scan_bandPolicy_t* bandPolicy );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Add SPS channels to scan command on the object workspace.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanMethod - The scan method (and parameters) to use.\n
+ * \param band - the band to scan.\n
+ */
+void scanMngrAddSPSChannels( TI_HANDLE hScanMngr, scan_Method_t* scanMethod, radioBand_e band );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 07-Mar-2005\n
+ * \brief Calculates local TSF of the next event (beacon or GPR) of the given tracked AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param BSSList - a pointer to the track list.\n
+ * \param entryIndex - the index of the AP for which calculation is requires in the tracking list.\n
+ * \param initialTSFValue - local TSF value AFTER which the next event is to found.\n
+ * \return The approximate current TSF
+ */
+UINT64 scanMngrCalculateNextEventTSF( TI_HANDLE hScanMngr, scan_BSSList_t* BSSList, UINT8 entryIndex, UINT64 initialTSFValue );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 20-September-2005\n
+ * \brief Check whether a time range collides with current AP DTIM
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param rangeStart - the time range start TSF.\n
+ * \param eventEnd - the time range end TSF.\n
+ * \return Whether the event collides with a DTIM (TRUF if it does, FALSE if it doesn't).\n
+ */
+BOOLEAN scanMngrDTIMInRange( TI_HANDLE hScanMngr, UINT64 eventStart, UINT64 eventEnd );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 03-Mar-2005\n
+ * \brief Add a normal channel entry to the object workspace scan command.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanMethod - The scan method (and parameters) to use.\n
+ * \param channel - the channel index.\n
+ * \param BSSID - pointer to the BSSID to use (may be broadcast.\n
+ * \param txPowerDbm - Tx power to transmit probe requests.\n
+ */
+void scanMngrAddNormalChannel( TI_HANDLE hScanMngr, scan_Method_t* scanMethod, UINT8 channel, 
+                                                          macAddress_t* BSSID, UINT8 txPowerDbm);
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Removes an entry from the BSS list (by replacing it with another entry, if any).\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param BSSEntryIndex - index of the entry to remove.\n
+ */
+void scanMngrRemoveBSSListEntry( TI_HANDLE hScanMngr, UINT8 BSSEntryIndex );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Removes all BSS list entries that are neither neighbor APs not on a policy defined channel.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bCheckNeighborAPs - whether to verify that APs marked as neighbor APs are really neighbor APs.\n
+ * \param bCheckChannels - whether to verify that APs not marked as neighbor APs are on policy defined channel.\n
+ */
+void scanMngrUpdateBSSList( TI_HANDLE hScanMngr, BOOLEAN bCheckNeighborAPs, BOOLEAN bCheckChannels );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief returns the index of a neighbor AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param band - the band on which the AP resides.\n
+ * \param bssId - the AP's BSSID.\n
+ * \return the index into the neighbor AP list for the given address, -1 if AP is not in list.\n
+ */
+INT8 scanMngrGetNeighborAPIndex( TI_HANDLE hScanMngr, radioBand_e band, macAddress_t* bssId );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Mar-2005\n
+ * \brief Checks whether a channel is defined on a policy.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param band - the band on which the channel is.\n
+ * \param channel - the channel number.\n
+ * \return TRUE if channel is defined on policy, FALSE otherwise.\n
+ */
+BOOLEAN scanMngrIsPolicyChannel( TI_HANDLE hScanMngr, radioBand_e band, UINT8 channel );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 18-Apr-2005\n
+ * \brief Converts scan concentrator result status to scan manager result status, to be returned to roaming manager.\n
+ *
+ * Function Scope \e Private.\n
+ * \param result status - scan concentrator result status.\n
+ * \return appropriate scan manager status.\n
+ */
+scan_mngrResultStatus_e scanMngrConvertResultStatus( scan_cncnResultStatus_e resultStatus );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a neighbor AP list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param neighborAPList - the list of neighbor APs to print
+ */
+void scanMngrTracePrintNeighborAPsList( TI_HANDLE hScanMngr, neighborAPList_t *neighborAPList );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a neighbor AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param neighborAP - the neighbor AP to print
+ */
+void scanMngrTracePrintNeighborAP( TI_HANDLE hScanMngr, neighborAP_t* neighborAP );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a band scan policy AP.\n
+ *
+ * Function Scope \e Private.\n
+ * \param bandPolicy - the band scan policy to print.\n
+ */
+void scanMngrTracePrintBandScanPolicy( scan_bandPolicy_t* bandPolicy );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print a scan method
+ *
+ * Function Scope \e Private.\n
+ * \param scanMethod - the scan method to print.\n
+ */
+void scanMngrTracePrintScanMethod( scan_Method_t* scanMethod );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief print a normal scan method
+ *
+ * Function Scope \e Private.\n
+ * \param basicMethodParams - the basic method parameters to print.\n
+ */
+void scanMngrTracePrintNormalScanMethod( scan_basicMethodParams_t* basicMethodParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief print an AC triggered scan method
+ *
+ * Function Scope \e Private.\n
+ * \param triggeredMethodParams - the Tid-triggered method parameters to print.\n
+ */
+void scanMngrTracePrintTriggeredScanMethod( scan_TidTriggeredMethodParams_t* triggeredMethodParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief print a SPS scan method
+ *
+ * Function Scope \e Private.\n
+ * \param SPSMethodParams - the SPS method parameters to print.\n
+ */
+void scanMngrTracePrintSPSScanMethod( scan_SPSMethodParams_t* SPSMethodParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 31-Mar-2005\n
+ * \brief print debug information for every received frame.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param frameInfo - holding all frame related information.\n
+ */
+void scanMngrDebugPrintReceivedFrame( TI_HANDLE hScanMngr, scan_frameInfo_t *frameInfo );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 31-Mar-2005\n
+ * \brief print BSS list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrDebugPrintBSSList( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 31-Mar-2005\n
+ * \brief print one entry in the BSS list.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param entryIndex - the index of the entry to print.\n
+ */
+void scanMngrDebugPrintBSSEntry( TI_HANDLE hScanMngr, UINT8 entryIndex );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-Apr-2005\n
+ * \brief print SPS helper list
+ *
+ * Function Scope \e Private.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param spsHelperList - the list to print.\n
+ * \param arrayHead - the index of the first element in the list.\n
+ * \param arraySize - the size of the array.\n
+ */
+void scanMngrDebugPrintSPSHelperList( TI_HANDLE hScanMngr, scan_SPSHelper_t* spsHelperList, int arrayHead, int arraySize );
+
+#ifdef TI_DBG
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print scan result histogram statistics.\n
+ *
+ * Function Scope \e Private.\n
+ * \param scanResultHistogram - Scan results histogram (by scan complete reason).\n
+ */
+void scanMngrStatsPrintScanResultHistogram( UINT32 scanResultHistogram[] );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print track fail count histogram statistics.\n
+ *
+ * Function Scope \e Private.\n
+ * \param trackFailHistogram - tracking failure histogram (by tracking retry).\n
+ */
+void scanMngrStatsPrintTrackFailHistogrsm( UINT32 trackFailHistogram[] );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print SPS attendant channel histogram statistics.\n
+ *
+ * Function Scope \e Private.\n
+ * \param SPSChannelsNotAttendedHistogram - SPS channels attendant histogram.\n
+ */
+void scanMngrStatsPrintSPSChannelsHistogram( UINT32 SPSChannelsNotAttendedHistogram[] );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 25-July-2005\n
+ * \brief Print One neighbor AP entry.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pNeighborAp - pointer to the neighbor AP data.\n
+ * \param discovery state - the discovery state of this neighbor AP.\n
+ */
+void scanMngrDebugPrintNeighborAP( neighborAP_t* pNeighborAp, scan_neighborDiscoveryState_e discoveryState );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-July-2005\n
+ * \brief Prints a scan command.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pScanParams - a pointer to the scan parameters structure.\n
+ */
+void scanMngrDebugPrintScanCommand( scan_Params_t* pScanParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-July-2005\n
+ * \brief Prints scan command single normal channel.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pNormalChannel - a pointer to the normal channel to print.\n
+ */
+void scanMngrDebugPrintNormalChannelParam( scan_normalChannelEntry_t* pNormalChannel );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-July-2005\n
+ * \brief Prints scan command single SPS channel.\n
+ *
+ * Function Scope \e Private.\n
+ * \param pSPSChannel - a pointer to the SPS channel to print.\n
+ */
+void scanMngrDebugPrintSPSChannelParam( scan_SPSChannelEntry_t* pSPSChannel );
+
+
+#endif /* TI_DBG */
+
+#endif /* __SCAN_MNGR_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/Application/inc/roamingMngr.h b/sta_dk_4_0_4_32/common/src/Application/inc/roamingMngr.h
new file mode 100644 (file)
index 0000000..fae8b2b
--- /dev/null
@@ -0,0 +1,81 @@
+/** \file roamingMngr.h
+ *  \brief Internal Roaming Manager API
+ *
+ *  \see roamingMngr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Roaming Manager                                              *
+ *   PURPOSE: Roaming Manager Module API                                    *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ROAMING_MNGR_H_
+#define _ROAMING_MNGR_H_
+
+/*#include "802_11Defs.h"*/
+#include "osApi.h"
+#include "paramOut.h"
+#include "scanMngrApi.h"
+#include "bssTypes.h"
+
+/* Constants */
+
+/* Enumerations */
+
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+
+/* called by the Scan Manager when scan for Roaming completed */
+TI_STATUS roamingMngr_immediateScanComplete(TI_HANDLE hRoamingMngr, scan_mngrResultStatus_e scanCmpltStatus);
+
+/* called by the Scan Manager when new BSSID was found */
+TI_STATUS roamingMngr_updateNewBssList(TI_HANDLE hRoamingMngr, bssList_t *newBss_entry);
+
+
+#endif /*  _ROAMING_MNGR_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/Application/inc/scanMngrApi.h b/sta_dk_4_0_4_32/common/src/Application/inc/scanMngrApi.h
new file mode 100644 (file)
index 0000000..3a129be
--- /dev/null
@@ -0,0 +1,356 @@
+/***************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 scanMngrApi.h
+ *  \brief This file include public definitions for the scan manager module, comprising its API.
+ *  \author Ronen Kalish
+ *  \date 01-Mar-2005
+ */
+
+#ifndef __SCAN_MNGR_API_H__
+#define __SCAN_MNGR_API_H__
+
+#include "scanMngrTypes.h"
+#include "bssTypes.h"
+#include "ScanCncnApi.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scan_mngrResultStatus_e 
+ * \brief enumerates the different result statuses that the scan manager
+ * \brief can return in response to an immediate scan request.
+ */
+typedef enum
+{
+       SCAN_MRS_SCAN_COMPLETE_OK= 0,                           /**< Scan was completed successfully */
+       SCAN_MRS_SCAN_RUNNING,                                  /**< Scan was started successfully and is now running */ 
+       SCAN_MRS_SCAN_NOT_ATTEMPTED_ALREADY_RUNNING,            /**< scan was not attempted because it is already running */
+    SCAN_MRS_SCAN_NOT_ATTEMPTED_EMPTY_POLICY,               /**< 
+                                                             * Scan was not attempted because the policy defines
+                                                             * NULL scan type
+                                                             */
+       SCAN_MRS_SCAN_NOT_ATTEMPTED_NO_CHANNLES_AVAILABLE,      /**< 
+                                                             * Scan was not attempted because no channels are 
+                                                             * available for scan, according to the defined policy.
+                                                             */
+       SCAN_MRS_SCAN_FAILED,                                   /**< Scan failed to start */
+       SCAN_MRS_SCAN_STOPPED,                                  /**< Scan was stopped by caller */
+       SCAN_MRS_SCAN_ABORTED_FW_RESET,                         /**< Scan was aborted due to recovery */
+       SCAN_MRS_SCAN_ABORTED_HIGHER_PRIORITY,                  /**< Scan was aborted due to a higher priority client */
+} scan_mngrResultStatus_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Creates the scan manager object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the OS object.\n
+ * \return a pointer to the scan manager object if successful, NULL otherwise.\n
+ */
+TI_HANDLE scanMngr_create( TI_HANDLE hOS );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Initializes the scan manager.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param hReport - handle to the report object.\n
+ * \param hRegDomain - handle to the regulatory domain object.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param hRoamMngr - handle to the roaming manager object.\n
+ * \param hSiteMngr - handle to the site manager object.\n
+ */
+void scanMngr_init( TI_HANDLE hScanMngr, TI_HANDLE hReport, TI_HANDLE hRegDomain, 
+                    TI_HANDLE hScanCncn, TI_HANDLE hRoamMngr, TI_HANDLE hSiteMngr,
+                                       TI_HANDLE hHalCtrl);
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief unloads the scan manager object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_unload( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Starts an immediate scan operation.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param pNeighborAPsOnly - TRUE if scan for neighbor APs only, FALSE if scan on all channels.\n
+ * \return status indication.\n
+ * \retval SCAN_MRS_SCAN_RUNNING - the scan started successfully and is now running.\n
+ * \retval SCAN_MRS_SCAN_NOT_ATTEMPTED_ALREADY_RUNNING - scan was not attempted because it is already running.\n
+ * \retval SCAN_MRS_SCAN_NOT_ATTEMPTED_EMPTY_POLICY - scan was not attempted because NULL policy defined.\n
+ * \retval SCAN_MRS_SCAN_NOT_ATTEMPTED_NO_CHANNLES_AVAILABLE - scan was not attempted because no channels were available.\n
+ * \retval SCAN_MRS_SCAN_FAILED - scan failed to start at lower levels.\n
+ */
+scan_mngrResultStatus_e scanMngr_startImmediateScan( TI_HANDLE hScanMngr, BOOLEAN bNeighborAPsOnly);
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Stops an immediate scan operation.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_stopImmediateScan( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Starts the continuous scan timer.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param currentBSS - the AP we are currently connected to.\n
+ * \currentBSSBand - the band of the current BSS.\n
+ */
+void scanMngr_startContScan( TI_HANDLE hScanMngr, macAddress_t* currentBSS, radioBand_e currentBSSBand );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Stops the continuous scan timer.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_stopContScan( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief returns the currently available BSS list.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \return BSS list structure pointer.\n
+ */
+bssList_t *scanMngr_getBSSList( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Sets the neighbor APs.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param neighborAPList - the neighbor AP list.\n
+ */
+void scanMngr_setNeighborAPs( TI_HANDLE hScanMngr, neighborAPList_t* neighborAPList );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief change quality level (normal / deteriorating).\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param bLowQuality - TRUE if quality is deteriorating, FALSE if quality is normal.\n
+ */
+void scanMngr_qualityChangeTrigger( TI_HANDLE hScanMngr, BOOLEAN bLowQuality );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 13-Mar-2005\n
+ * \brief Notifies the scan manager of a roaming event. Should be called BEFORE the SCR group 
+ * \brief is changed back to connected.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param macAddress - mac address of the new AP.\n
+ * \param band - the band of the new AP.\n
+ */
+void scanMngr_handoverDone( TI_HANDLE hScanMngr, macAddress_t* macAddress, radioBand_e band );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Callback used by the scan concentrator for immediate scan result.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param resultStatus - reason for calling this function (frame received / scan complete).\n
+ * \param frameInfo - frame related information (in case of a frame reception).\n
+ * \param SPSStatus - bitmap indicating which channels were scan, in case of an SPS scan.\n
+ */
+void scanMngr_immedScanCB( TI_HANDLE hScanMngr, scan_cncnResultStatus_e resultStatus, 
+                           scan_frameInfo_t* frameInfo, UINT16 SPSStatus );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Callback used by the scan concentrator for continuous scan result.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param resultStatus - reason for calling this function (frame received / scan complete).\n
+ * \param frameInfo - frame related info (in case of a frame reception).\n
+ * \param SPSStatus - bitmap indicating which channels were scan, in case of an SPS scan.\n
+ */
+void scanMngr_contScanCB( TI_HANDLE hScanMngr, scan_cncnResultStatus_e resultStatus, 
+                         scan_frameInfo_t* frameInfo, UINT16 SPSStatus );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 08-Mar-2005\n
+ * \brief Parses and executes a get param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param pParam - the param to get.\n
+ * \return OK if the parameter was get successfully, NOK otherwise.\n
+ */
+TI_STATUS scanMngr_getParam( TI_HANDLE hScanMngr, paramInfo_t *pParam );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Parses and executes a set param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param pParam - the param to set.\n
+ * \return OK if the parameter was set successfully, NOK otherwise.\n
+ */
+TI_STATUS scanMngr_setParam( TI_HANDLE hScanMngr, paramInfo_t *pParam );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Mar-2005\n
+ * \brief Sets the scan policy.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ * \param scanPolicy - a pointer to the policy data.\n
+ */
+void scanMngr_setScanPolicy( TI_HANDLE hScanMngr, scan_Policy_t* scanPolicy );
+
+#ifdef TI_DBG
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Mar-2005\n
+ * \brief Print scan policy.\n
+ *
+ * Function Scope \e Private.\n
+ * \param scanPolicy - scan policy to print.\n
+ */
+void scanMngrTracePrintScanPolicy( scan_Policy_t* scanPolicy );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Print scan manager statistics.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_statsPrint( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 26-May-2005\n
+ * \brief Reset scan manager statistics.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngr_statsReset( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 25-July-2005\n
+ * \brief Print Neighbor AP list.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - Handle to the scan manager object.\n
+ */
+void scanMngrDebugPrintNeighborAPList( TI_HANDLE hScanMngr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 25-July-2005\n
+ * \brief Prints all data in the scan manager object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanMngr - handle to the scan manager object.\n
+ */
+void scanMngrDebugPrintObject( TI_HANDLE hScanMngr );
+
+#endif /* TI_DBG */
+
+#endif /* __SCAN_MNGR_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Export_Inc/whalBus_Api.h b/sta_dk_4_0_4_32/common/src/BusAccess/Export_Inc/whalBus_Api.h
new file mode 100644 (file)
index 0000000..b389a86
--- /dev/null
@@ -0,0 +1,192 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalBus_Api.h
+ *   PURPOSE: Bus access component API
+ *
+ ****************************************************************************/
+
+#ifndef _WHAL_BUS_API_H
+#define _WHAL_BUS_API_H
+
+#include "whalCtrl_api.h"
+#include "whalCommon.h"
+#include "whalHwDefs.h" 
+#include "whalBus_Defs.h"
+#include "memMngrEx.h"
+#include "commonTypes.h"
+
+/*
+ * --------------------------------------------------------------
+ *                  Creation/Configuration API
+ * --------------------------------------------------------------
+ */                  
+TI_HANDLE   whalBus_Create  (TI_HANDLE hOs);
+int         whalBus_Destroy (TI_HANDLE hWhalBus);
+TI_STATUS   whalBus_Config  (TI_HANDLE hWhalBus, 
+                             TI_HANDLE hWhalCtrl,
+                             UINT8     AccessMode, 
+                             UINT32    RegBaseAddr,
+                             UINT32    MemBaseAddr,
+                             TI_HANDLE hReport, 
+                             TI_HANDLE hMemMgr,
+                             fnotify_t fCb,
+                             TI_HANDLE hCb);
+TI_HANDLE   whalBus_GetTnentwifHandle (TI_HANDLE hWhalBus);
+int         whalBus_ExitFromInitMode  (TI_HANDLE hWhalBus);
+int         whalBus_ReConfig          (TI_HANDLE hWhalBus);
+
+/*
+ * --------------------------------------------------------------
+ *                  Registers/Memory access API
+ * --------------------------------------------------------------
+ */                  
+UINT32  whalBus_MacRegRead       (TI_HANDLE hWhalBus, UINT32 RegAddr);
+void    whalBus_MacRegWrite      (TI_HANDLE hWhalBus, UINT32 RegAddr, UINT32 Val);
+void    whalBus_PhyRegWrite      (TI_HANDLE hWhalBus, UINT32 PhyRegAddr, UINT32 DataVal);
+UINT32  whalBus_PhyRegRead       (TI_HANDLE hWhalBus, UINT32 PhyRegAddr);
+void    whalBus_MemWrite         (TI_HANDLE hWhalBus, UINT32 Addr, char *data, int Len);
+void    whalBus_MemRead          (TI_HANDLE hWhalBus, UINT32 Addr, char *data, int Len);
+
+/*
+ * --------------------------------------------------------------
+ *                  Firmware control API
+ * --------------------------------------------------------------
+ */                  
+typedef struct
+{
+    UINT32  radioType;
+    UINT8   MacClock;
+    UINT8   ArmClock;
+    BOOL    FirmwareDebug;
+    UINT32  minorE2Ver;
+    UINT32  majorE2Ver;
+    UINT32  bugfixE2Ver;
+} BootAttr_T;
+
+
+TI_STATUS  whalBus_FwCtrl_Boot     (TI_HANDLE hWhalBus, TI_HANDLE hHwCtrl, BootAttr_T *pBootAttr);
+int        whalBus_FwCtrl_Reset    (TI_HANDLE hWhalBus);
+int        whalBus_FwCtrl_isCardIn (TI_HANDLE hWhalBus);
+void       whalBus_FwCtrl_Halt     (TI_HANDLE hWhalBus);
+UINT32     whalBus_FwCtrl_GetRadioStandByState
+                                   (TI_HANDLE hWhalBus);
+
+/*
+ * --------------------------------------------------------------
+ *                  Interrupt handler API
+ * --------------------------------------------------------------
+ */                  
+
+/*  states */
+typedef enum
+{
+    STATE_INIT          = 0,
+    STATE_DPC              ,    
+    STATE_OPERATIONAL      ,
+    STATE_WAIT_FOR_DPC      ,
+}whalHwIntr_states;
+
+/* Callback template */
+typedef void (*whal_hwIntrCB)(void *pObj);
+
+/*Power Ctrl Callback template */
+#define PWRCTRL_CB_TYPE_INTR_WAS_ISSUE  0
+#define PWRCTRL_CB_TYPE_INTR_STARTED    1
+typedef void (*whal_PwrCtrlCB)(TI_HANDLE pObj, int CbType);
+
+
+void whalBus_TNETWIF_HandleBusTxn_Complete  (TI_HANDLE hWhalBus);
+
+/*
+ * --------------------------------------------------------------
+ *                  TNETWIF API
+ * --------------------------------------------------------------
+ */
+int whalBus_TNETWIF_ElpCtrl_SetMode(TI_HANDLE hWhalBus, elpCtrl_Mode_e mode);
+
+/*
+ * --------------------------------------------------------------
+ *                  Debug API
+ * -------------------------------------------------------------- 
+ */                  
+void    whalBus_performHealthMonitorTest(TI_HANDLE hWhalBus, UINT32 TEST);
+/*
+ * General
+ */
+
+#define BUS_PRINT_ALL           1
+
+/* 
+ * Control
+ */
+#define BUS_PRINT_MBOX_INFO     10
+#define BUS_PRINT_INTR_INFO     11
+#define BUS_PRINT_ACCESS_INFO   12
+#define BUS_PRINT_EEPROM        13
+#define BUS_PRINT_TRACE_A_B     14
+#define BUS_PRINT_ARBITER       15
+
+/*
+ * Tx
+ */
+#define BUS_PRINT_TX_INFO       20
+#define BUS_PRINT_TX            21
+#define BUS_PRINT_TX_QUEUE      22
+
+/*
+ * Rx
+ */
+#define BUS_PRINT_RX_INFO       30
+#define BUS_CLEAR_RX_INFO       31
+
+/*
+ * Debug
+ */
+#define BUS_PRINT_REG_DUMP      40
+#define BUS_PRINT_RX_REGS       41
+#define BUS_PRINT_TX_REGS       42
+#define BUS_PRINT_SCR_PAD_REGS  43
+#define BUS_PRINT_LIST_REGS     44
+#define BUS_PRINT_MEM           45
+
+void    whalBus_PrintInfo(TI_HANDLE hWhalBus, UINT32 funcType, void *pParam);
+/***************************************************************************************************
+************************************* New Hal ******************************************************
+***************************************************************************************************/
+
+#endif /* _WHAL_BUS_API_H */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Export_Inc/whalBus_Defs.h b/sta_dk_4_0_4_32/common/src/BusAccess/Export_Inc/whalBus_Defs.h
new file mode 100644 (file)
index 0000000..858b440
--- /dev/null
@@ -0,0 +1,207 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalBus_Defs.h
+ *   PURPOSE: Bus access component structures definitions
+ *
+ ****************************************************************************/
+
+#ifndef _WHAL_BUS_DEFS_H
+#define _WHAL_BUS_DEFS_H
+
+#include "public_types.h"
+#include "osTIType.h"
+#include "ratesTypes.h"
+#include "commonTypes.h"
+#include "public_host_int.h"
+#include "public_descriptors.h"
+
+/* Typedefs */
+
+typedef struct
+{
+    rxPacketType_e packetType;
+    UINT8          rxLevel;
+    INT8           rssi;
+    UINT8          SNR;
+    UINT8          band;
+    UINT32         TimeStamp;
+} rxXfer_Reserved_t;
+
+typedef struct
+{
+    rxPacketType_e packetType;
+    TI_STATUS     status;
+    rate_e      Rate;   
+    UINT8       SNR;
+    INT8        Rssi;   
+    UINT8       channel;
+    UINT32      packetInfo;
+    UINT8       band;
+    UINT32      TimeStamp;
+}Rx_attr_t;
+
+
+
+/* Callback for rx packet */
+typedef void (*packetReceiveCB_t)(TI_HANDLE hObj,
+                                  TI_STATUS aStatus,
+                                  const void *aFrame,
+                                  UINT16 aLength,
+                                  UINT32 aRate,
+                                  UINT8  aChannel,
+                                  UINT8 aRCPI,
+                                  void *Reserved,
+                                  UINT32 aFlags);
+
+/* CallBack for Buffer request */
+typedef const void *(*requestForBufferCB_t)(TI_HANDLE hObj, UINT16 aLength, UINT32 uEncryptionFlag);
+
+
+/* Scan complete Callback - This routine is called from the HAL upon TNET scan complete */
+typedef void (*scanCompleteCB_t)(TI_HANDLE hScanSrv, char* str, UINT32 strLen);
+
+/* Disassociation sent - This function is called by the HAL's Tx to indicate that dissasociation frame has been sent.*/
+typedef void (*disassocSentCB_t)(TI_HANDLE Hobj);
+
+/* Incoming Info Callback */
+typedef void (*InfoCB_t)(TI_HANDLE handle, char* buf, UINT32 bufSize);
+/* Device Error Callback */
+typedef void (*deviceErrorCB_t)(TI_HANDLE siteMgr);
+
+/* Mac status Callback */
+typedef void (*MacStatusCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);
+
+/* Health Report Callback */
+typedef void (*HealthReportCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);
+
+/* Aci Indication Callback */
+typedef void (*AciIndicationCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);
+
+/* Failure Event Callback */
+typedef void (*failureEventCB_t)(TI_HANDLE handle, failureEvent_e failureEvent);
+
+/*
+ * --------------------------------------------------------------
+ *                  DmaParams_T - Rx/Tx Queues and Bufffers params
+ * --------------------------------------------------------------
+ */
+
+
+typedef struct
+{
+    int     NumTxQueues;
+    int     NumRxQueues;
+    UINT32  BlockSize;
+    int     NumTxBlocks;
+    int     NumRxBlocks;
+    int     TxNumDesc[MAX_NUM_OF_TX_QUEUES];
+    int     RxNumDesc;
+    int     TxQPriority[MAX_NUM_OF_TX_QUEUES];
+    int     RxQPriority;
+
+    UINT16  NumStations;
+    UINT8   RxQueue_Priority;
+    UINT8   RxQueue_Type;
+
+    UINT32  TraceBufferSize;
+    BOOLEAN TraceBufferDoPrint;
+
+    UINT8   rxMemBlkNumber;
+    UINT8   txMinMemBlkNumber;
+
+} DmaParams_T;
+
+
+/*
+ * --------------------------------------------------------------
+ *                  Internal hal attributes
+ * --------------------------------------------------------------
+ */                  
+
+
+
+typedef enum
+{
+    SW_DIVS_TX_RESET       = 0,     /* reset, i.e. invalid value */
+    SW_DIVS_TX_ANT2        = BIT_2, /* defined to match TX_PING0 & CFG_ANT_SEL*/
+    SW_DIVS_TX_ANT1        = BIT_3, /* defined to match TX_PING0 & CFG_ANT_SEL*/
+    SW_DIVS_RX_W_LAST_TX   = BIT_4,
+    SW_DIVS_TOGGLE_DISABLE = BIT_5,
+    SW_DIVS_TOGGLE_COUNT_MASK = BIT_6+BIT_7
+} SwAntDivs_enum;
+
+
+#define CTRL_NO_TX_COMPLETE 0x40
+
+
+#define    RX_PACKET_FLAGS_MATCH_RXADDR1    0x00000001
+#define    RX_PACKET_FLAGS_GROUP_ADDR       0x00000002
+#define    RX_PACKET_FLAGS_BCAST            0x00000004
+#define    RX_PACKET_FLAGS_STAINTIM         0x00000008
+#define    RX_PACKET_FLAGS_VIRTUAL_BM       0x00000010
+#define    RX_PACKET_FLAGS_MATCH_SSID       0x00000020
+#define    RX_PACKET_FLAGS_MATCH_BSSID      0x00000040
+#define    RX_PACKET_FLAGS_ENCRYPTION       0x00030000
+#define    RX_PACKET_FLAGS_MORE_PACKETS     0x00040000
+#define    RX_PACKET_FLAGS_MEASURMENT       0x00080000
+
+#define    RX_DESC_FLAGS_ENCRYPTION                    8
+#define    RX_PACKET_FLAGS_ENCRYPTION_SHIFT 16
+#define    RX_PACKET_FLAGS_ENCRYPTION_SHIFT_FROM_DESC      (RX_PACKET_FLAGS_ENCRYPTION_SHIFT - RX_DESC_FLAGS_ENCRYPTION)
+
+/* The next definitions are used to decide which encryption is used by the Rx flags */
+#define    RX_FLAGS_NO_SECURITY 0  
+#define           RX_FLAGS_WEP                 1
+#define           RX_FLAGS_TKIP                2
+#define           RX_FLAGS_AES                 3
+
+#define    RX_DESC_PACKETID_SHIFT 11
+#define    RX_MAX_PACKET_ID      3
+
+
+/* Cal backs */
+
+/* Callback for rx compleate */
+
+
+typedef void (*WhalSendPacketTranferCB_t)(TI_HANDLE hWhalTx,
+                                          TI_STATUS TxStatus,
+                                          UINT32    aPacketId,
+                                          void      *reserved);
+
+#endif /* _WHAL_BUS_DEFS_H */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmBus.c b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmBus.c
new file mode 100644 (file)
index 0000000..e453b6b
--- /dev/null
@@ -0,0 +1,498 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalBus_Api.c
+ *   PURPOSE: shared memory bus access component API
+ *
+ ****************************************************************************/
+#include "whalCommon.h"
+#include "whalCtrl.h"
+#include "whalBus_Api.h"
+#include "shmBus.h"
+#include "TNETWIF.h"
+#include "TNETWArb.h"
+#include "TNETW_Driver.h"
+#include "whalHwAccess.h"
+#include "CmdMBox_api.h"
+#include "eventMbox_api.h"
+#include "FwEvent_api.h"
+
+
+/* Handle return status inside a state machine */
+#define EXCEPT(pwhalbus,status)                                 \
+    switch (status) {                                           \
+        case OK:                                                \
+        case TNETWIF_COMPLETE:                                  \
+             break;                                             \
+        case TNETWIF_PENDING:                                   \
+             return;                                            \
+        default:                                                \
+             whal_hwCtrl_FinalizeOnFailure (pwhalbus->hHwCtrl); \
+             return;                                            \
+    }
+
+
+ /****************************************************************************
+ *                      static function declaration
+ *****************************************************************************/
+static void whalBus_ConfigSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);
+
+ /****************************************************************************
+ *                      whalBus_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the Bus access component
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+TI_HANDLE whalBus_Create (TI_HANDLE hOs)
+{
+    whalBus_T *pWhalBus;
+
+    pWhalBus = os_memoryAlloc (hOs, sizeof(whalBus_T));
+    if (pWhalBus == NULL)
+        return NULL;
+
+    os_memoryZero (hOs, pWhalBus, sizeof(whalBus_T));
+
+    pWhalBus->hOs = hOs;
+
+    pWhalBus->hTNETWIF  = TNETWIF_Create (hOs);
+    pWhalBus->pHwEeprom = whal_hwEeprom_Create (hOs);
+
+  #ifdef TI_DBG
+    pWhalBus->pTrc      = whal_traceCreate(hOs);
+  #else
+    pWhalBus->pTrc      = NULL;
+  #endif
+    
+    if (!pWhalBus->hTNETWIF || !pWhalBus->pHwEeprom)
+    {
+        whalBus_Destroy ((TI_HANDLE)pWhalBus);
+        return NULL;
+    }
+
+    return (TI_HANDLE)pWhalBus;
+}
+
+/****************************************************************************
+ *                      whalBus_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object 
+ * 
+ * INPUTS:  
+ *      hWhalBus        The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalBus_Destroy(TI_HANDLE hWhalBus)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    if (pWhalBus == NULL)
+        return OK;
+
+    whal_hwEeprom_Destroy(pWhalBus->pHwEeprom);
+    
+#ifdef TI_DBG
+    whal_traceDestroy(pWhalBus->pTrc);
+#endif
+    TNETWIF_Destroy(pWhalBus->hTNETWIF);
+
+    os_memoryFree(pWhalBus->hOs, pWhalBus, sizeof(whalBus_T));
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whalBus_ConfigSm()
+ ****************************************************************************
+ * DESCRIPTION: Config the object 
+ * 
+ * INPUTS:  
+ *      hWhalBus        The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static void whalBus_ConfigSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T  *pWhalBus  = (whalBus_T *)hWhalBus;
+    WHAL_CTRL  *pWhalCtrl = (WHAL_CTRL *)pWhalBus->hWhalCtrl;   
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)pWhalCtrl->hTNETW_Driver;
+
+    /* Pass the TNETWIF handle in each SHM Bus Module : HwIntr,HwRx,HwTx,Hw_Mbox,Hw_EventMbox */
+    /* From now on these modules will  be using only the TNETWIF handle and this one will send the request to the HwAccess module */
+    switch (pWhalBus->uInitStage)
+    {
+    case 0:
+        pWhalBus->uInitStage ++;
+        whal_hwEeprom_Config (pWhalBus->pHwEeprom, pWhalBus->hTNETWIF, pWhalBus->hReport);
+
+        /* disable interrupts */
+        status = TNETWIF_WriteRegOpt (pTnetwDrv->hTNETWIF, 
+                                      ACX_REG_INTERRUPT_MASK, 
+                                      ACX_INTR_ALL,
+                                      HAL_INIT_MODULE_ID,
+                                      whalBus_ConfigSm,
+                                      hWhalBus);
+        EXCEPT (pWhalBus, status)
+
+    case 1:
+        pWhalBus->uInitStage = 0;
+
+        CmdMBox_Config (pTnetwDrv->hCmdMBox, 
+                        pWhalBus->hTNETWIF, 
+                        pTnetwDrv->hFwEvent, 
+                        pTnetwDrv->hCmdQueue, 
+                        pWhalBus->hReport);
+
+        eventMbox_Config (pTnetwDrv->hEventMbox, 
+                          pTnetwDrv->hTNETWIF, 
+                          pTnetwDrv->hHwIntr, 
+                          pTnetwDrv->hReport,
+                          pTnetwDrv->hFwEvent,
+                          pTnetwDrv->hHalCtrl);
+
+      #ifdef TI_DBG
+        /* Initiate the trace object */
+        whal_traceConfig (pWhalBus->pTrc, pWhalBus->hTNETWIF, pWhalBus->hReport);
+      #endif 
+
+        /* Call upper module callback */
+        pWhalBus->fCb (pWhalBus->hCb, status);
+
+        WLAN_REPORT_INIT (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whalBus_Config: EXITING SUCCESS !!!\n"));
+    }
+}
+
+
+/****************************************************************************
+ *                      whalBus_Config()
+ ****************************************************************************
+ * DESCRIPTION: Config the object 
+ * 
+ * INPUTS:  
+ *      hWhalBus        The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whalBus_Config
+(
+    TI_HANDLE hWhalBus, 
+    TI_HANDLE hWhalCtrl,
+    UINT8     AccessMode, 
+    UINT32    RegBaseAddr, 
+    UINT32    MemBaseAddr, 
+    TI_HANDLE hReport, 
+    TI_HANDLE hMemMgr,
+    fnotify_t fCb,
+    TI_HANDLE hCb
+)
+{
+    whalBus_T  *pWhalBus  = (whalBus_T *)hWhalBus;
+    WHAL_CTRL  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)pWhalCtrl->hTNETW_Driver;
+
+    if (pWhalBus == NULL)
+        return OK;
+
+    pWhalBus->hReport = hReport;
+    pWhalBus->hTnetwDrv = (TI_HANDLE)pTnetwDrv;
+    pWhalBus->hWhalCtrl = hWhalCtrl;
+    pWhalBus->fCb = fCb;
+    pWhalBus->hCb = hCb;
+    pWhalBus->uInitStage = 0;
+
+    /* Call the TNETWIF Configuration */
+    return TNETWIF_Config (pWhalBus->hTNETWIF, 
+                           hReport, 
+                           RegBaseAddr, 
+                           MemBaseAddr, 
+                           whalBus_ConfigSm, 
+                           hWhalBus);   
+}
+
+
+/****************************************************************************
+ *                      whalBus_GetTnentwifHandle()
+ ****************************************************************************
+ * DESCRIPTION: Return TNETWIF handle
+ * 
+ * INPUTS:  
+ *      hWhalBus        The object handle
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF handle
+ ****************************************************************************/
+TI_HANDLE whalBus_GetTnentwifHandle (TI_HANDLE hWhalBus)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    return pWhalBus->hTNETWIF;
+}
+
+/****************************************************************************
+ *                      whalBus_ExitFromInitMode()
+ ****************************************************************************
+ * DESCRIPTION: Change the state of the Bus Access After init
+ * 
+ * INPUTS:  
+ *      hWhalBus        The object handle
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalBus_ExitFromInitMode(TI_HANDLE hWhalBus)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)pWhalBus->hTnetwDrv;
+  #if defined(USE_SYNC_API)
+    UINT32      uIntVect;
+  #endif
+
+    /* Set The Bus Access Mbox to Work in Async Mode */
+    CmdMBox_SetModeNormal (pTnetwDrv->hCmdMBox);
+
+  #if defined(USE_SYNC_API)
+
+    uIntVect = FwEvent_GetEnabled (pTnetwDrv->hFwEvent);
+
+    /* Clearing all the interrupt status register sources */
+    TNETWIF_WriteRegSync (pWhalBus->hTNETWIF, ACX_REG_INTERRUPT_MASK, ~uIntVect); 
+
+  #endif
+
+    return OK;
+}
+/*
+ * --------------------------------------------------------------
+ *                  Registers/Memory access API
+ * --------------------------------------------------------------
+ */ 
+
+UINT32 whalBus_MacRegRead(TI_HANDLE hWhalBus, UINT32 RegAddr)
+{
+    UINT32 data = 0;
+  #ifdef USE_SYNC_API
+    TNETWIF_ReadRegSync(((whalBus_T *)hWhalBus)->hTNETWIF,RegAddr,(UINT32 *)&data);
+  #endif
+    return data;
+}
+
+void whalBus_MacRegWrite(TI_HANDLE hWhalBus, UINT32 RegAddr, UINT32 Val)
+{
+  #ifdef USE_SYNC_API
+    TNETWIF_WriteRegSync(((whalBus_T *)hWhalBus)->hTNETWIF, RegAddr, Val);
+  #endif
+}
+
+void whalBus_MemCopyTo (TI_HANDLE hWhalBus, char *DestOffset, char *Src, int Len)
+{
+  #ifdef USE_SYNC_API
+    TNETWIF_WriteMemSync(((whalBus_T *)hWhalBus)->hTNETWIF,(UINT32)DestOffset,(UINT8*)Src,Len);
+  #endif
+}
+void whalBus_MemCopyFrom (TI_HANDLE hWhalBus, UINT8 *Dest, char *SrcOffset, int Len)
+{
+  #ifdef USE_SYNC_API
+    TNETWIF_ReadMemSync(((whalBus_T *)hWhalBus)->hTNETWIF,(UINT32)SrcOffset,Dest,Len);
+  #endif
+}
+
+#define WRITE_PHY_NUM_RETRIES     4
+
+void    whalBus_PhyRegWrite      (TI_HANDLE hWhalBus, UINT32 PhyRegAddr, UINT32 DataVal)
+{
+  #ifdef USE_SYNC_API
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    int NumRetries=1;
+    UINT32 data;
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, ACX_PHY_ADDR_REG, PhyRegAddr);
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, ACX_PHY_DATA_REG, DataVal);
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, ACX_PHY_CTRL_REG, ACX_PHY_REG_WR_MASK);
+
+    os_StalluSec(pWhalBus->hOs, 10000);
+
+    /* wait for write complete */
+        TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,ACX_PHY_CTRL_REG,&data);
+    while (data  && (NumRetries < WRITE_PHY_NUM_RETRIES))
+    {
+        NumRetries++;
+        WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("ACX_PHY_CTRL_REG Write, Addr - %#x  Data - %#x, retry\n", PhyRegAddr, DataVal));
+        os_StalluSec(pWhalBus->hOs, 10000);
+                TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,ACX_PHY_CTRL_REG,&data);
+    }
+  #endif
+} 
+
+UINT32  whalBus_PhyRegRead (TI_HANDLE hWhalBus, UINT32 PhyRegAddr)
+{
+    UINT32  DataVal = 0;
+  #ifdef USE_SYNC_API
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    int NumRetries=1;
+    UINT32 data;
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, ACX_PHY_ADDR_REG, PhyRegAddr);
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, ACX_PHY_CTRL_REG, ACX_PHY_REG_RD_MASK);
+    os_StalluSec(pWhalBus->hOs, 10000);
+
+    /* wait for write complete */
+    TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,ACX_PHY_CTRL_REG,&data);
+    while ( data  && (NumRetries < WRITE_PHY_NUM_RETRIES))
+    {
+        NumRetries++;
+        WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("ACX_PHY_CTRL_REG Read, Addr - %#x  retry\n", PhyRegAddr));
+        os_StalluSec(pWhalBus->hOs, 10000);
+        TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,ACX_PHY_CTRL_REG,&data);
+    }
+
+    TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,ACX_PHY_DATA_REG,&DataVal);
+  #endif
+    return DataVal;
+}
+
+
+/*
+ * --------------------------------------------------------------
+ *                  Interrupt handler API
+ * --------------------------------------------------------------
+ */                  
+void whalBus_TNETWIF_HandleBusTxn_Complete  (TI_HANDLE hWhalBus)
+{
+    TNETWIF_BusTxn_Complete (((whalBus_T *)hWhalBus)->hTNETWIF);
+}
+
+void    whalBus_performHealthMonitorTest(TI_HANDLE hWhalBus, UINT32 test)
+{
+#ifdef TI_DBG
+    switch (test) {
+
+    case 1:
+        WLAN_OS_REPORT(("HAL Perform Health Monitor MBOX Test\n"));
+        break;
+#if 0   
+    case 2:
+        WLAN_OS_REPORT(("HAL Perform Health Monitor TX STUCK Test\n"));
+        whal_hwTx_performHealthMonitorTest(((whalBus_T *)hWhalBus)->pHwTx);
+        break;
+#endif
+    }
+#endif
+}
+
+/* Dummy function */
+/*
+ * --------------------------------------------------------------
+ *                  Debug API
+ * --------------------------------------------------------------
+ */              
+#ifdef TI_DBG
+void whalBus_PrintInfo(TI_HANDLE hWhalBus, UINT32 funcType, void *pParam)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    switch (funcType)
+    {
+    case BUS_PRINT_ARBITER:
+        TNETWArb_PrintStat (((TNETWIF_t*)pWhalBus->hTNETWIF)->hTNETWArb);
+        break;
+
+    default:
+        WLAN_OS_REPORT(("%s: Invalid function type: %d\n\n", __FUNCTION__, funcType));
+        break;
+    }
+}
+#endif
+
+
+
+/****************************************************************************
+ *                      whalBus_ReConfig()
+ ****************************************************************************
+ * DESCRIPTION: ReConfig the object (In case of recovery) 
+ * 
+ * INPUTS:  
+ *      hWhalBus        The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalBus_ReConfig(TI_HANDLE hWhalBus )
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    /*Add a function in HwAccess that Reconfig (SDIO_Stop/SDIO_Start) and also in SPI */
+    TNETWIF_ReConfig(pWhalBus->hTNETWIF);
+    return OK;
+}
+
+/****************************************************************************
+ *                      whalBus_TNETWIF_ElpCtrl_SetMode()
+ ****************************************************************************
+ * DESCRIPTION: wrapper function for the lower TNETWIF_ElpCtrl_Mode
+ * 
+ * INPUTS:  
+ *      hWhalBus        The current context handle
+ *      mode            The ElpCtrl mode
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalBus_TNETWIF_ElpCtrl_SetMode(TI_HANDLE hWhalBus, elpCtrl_Mode_e mode)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    
+    return TNETWIF_ElpCtrl_Mode(pWhalBus->hTNETWIF,mode);
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmBus.h b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmBus.h
new file mode 100644 (file)
index 0000000..7b2a479
--- /dev/null
@@ -0,0 +1,139 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  shmBus.h
+ *   PURPOSE: Shared memory Bus access object
+ *
+ ****************************************************************************/
+
+#ifndef _WHAL_SHM_BUS_H
+#define _WHAL_SHM_BUS_H
+
+#include "whalHwEeprom.h"
+#include "whalBus_Api.h"
+#include "TNETWIF.h"
+#include "whalTrace.h" 
+
+
+/* 
+ * Use this flag to optimize FW download.
+ * By default this flag is disabled, because the 
+ * FW image may be stored at ROM addresses
+ */
+#undef  USE_NO_CHUNK_COPY
+
+
+/* Firmware image load chunk size */
+#define CHUNK_SIZE          512
+
+
+/* CLASS whalBus */
+typedef struct _whalBus_T
+{
+    TI_HANDLE               hTNETWIF;
+    TI_HANDLE               hTnetwDrv;  
+    HwEeprom_T             *pHwEeprom;
+    WhalTrace_T            *pTrc;
+    TI_HANDLE               hOs;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hWhalCtrl;
+    UINT8                  *pFwBuf;       /* Firmware image ptr */
+    UINT32                  uFwLastAddr;  /* Firmware image length */
+    UINT8                  *pEEPROMBuf;   /* EEPROM image ptr */
+    UINT32                  uEEPROMLen;   /* EEPROM image length */
+    UINT8                  *pEEPROMCurPtr;
+    UINT32                  uEEPROMCurLen;
+    BootAttr_T              BootAttr;
+    TI_HANDLE               hHwCtrl;
+    TI_STATUS               DownloadStatus;
+    fnotify_t               fCb;          /* Upper module callback for the init stage */
+    TI_HANDLE               hCb;          /* Upper module handle for the init stage */
+    UINT32                  uInitStage;   /* Init stage */
+    UINT32                  uResetStage;  /* Reset statge */ 
+    UINT32                  uEEPROMStage; /* EEPROM burst stage */
+    UINT32                  uInitData;    /* Init state machine temporary data */
+    UINT32                  uElpCmd;      /* ELP command image */
+    UINT32                  uChipId;      /* Chip ID */
+    UINT32                  uBootData;    /* Boot state machine temporary data */
+    UINT32                  uSelfClearTime;
+    UINT8                   uEEPROMBurstLen;
+    UINT8                   uEEPROMBurstLoop;
+    UINT32                  uEEPROMRegAddr;
+    TI_STATUS               uEEPROMStatus;
+    UINT32                  uNVSStartAddr;
+    UINT32                  uNVSNumChar;
+    UINT32                  uNVSNumByte;
+    /* use a struct to write buffers on the bus - used for extra bytes reserving */
+    PADDING (UINT32         uNVSTempWord)
+    TI_STATUS               uNVSStatus;
+    UINT32                  uScrPad6;
+    UINT32                  uRefFreq; 
+    UINT32                  uInitSeqStage;
+    TI_STATUS               uInitSeqStatus;
+    UINT32                  uLoadStage;
+    UINT32                  uChunkNum;
+    UINT32                  uPartitionLimit;
+    UINT32                  uFinStage;
+    UINT32                  uFinData;
+    UINT32                  uFinLoop; 
+    /* Temporary buffer for FW chunk storage */
+  #ifdef USE_NO_CHUNK_COPY
+    UINT8                   auFwTmpBuf [TNETWIF_WRITE_OFFSET_BYTES];
+  #else
+    UINT8                   auFwTmpBuf [TNETWIF_WRITE_OFFSET_BYTES + CHUNK_SIZE];
+  #endif
+    /* size of the Fw image, retrieved from the image itself */         
+    UINT32                  uFwDataLen; 
+
+       BOOL                                    recoveryProcess;
+
+} whalBus_T;
+
+
+/* Debug */
+void shmDebug_registerDump(TI_HANDLE hWhalBus);
+int  shmDebug_PrintRxRegs(TI_HANDLE hWhalBus);
+int  shmDebug_PrintTxRegs(TI_HANDLE hWhalBus);
+int  shmDebug_PrintScrPadRegs(TI_HANDLE hWhalBus);
+int  shmDebug_PrintListRegs(TI_HANDLE hWhalBus, UINT32 RegAddr);
+void shmDebug_MemPrint(TI_HANDLE hWhalBus, UINT32 MemAddr);
+void whalBus_MemCopyFrom (TI_HANDLE hWhalBus, UINT8 *Dest, char *SrcOffset, int Len);
+void shmDebug_macRegisterDump(TI_HANDLE hWhalBus);
+void shmDebug_phyRegisterDump(TI_HANDLE hWhalBus);
+
+
+#endif /* _WHAL_SHM_BUS_H */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmDebug.c b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmDebug.c
new file mode 100644 (file)
index 0000000..007cd74
--- /dev/null
@@ -0,0 +1,493 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  shmDebug.c
+ *   PURPOSE: Handle Debug requests
+ *
+ ****************************************************************************/
+#include "whalCommon.h"
+#include "whalBus_Api.h"
+#include "shmBus.h"
+#include "TNETWIF.h"
+
+
+#ifdef USE_SYNC_API
+
+/****************************************************************************
+ *                      shmDebug_registerDump()
+ ****************************************************************************
+ * DESCRIPTION:
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: void
+ *
+ * NOTES:
+ ****************************************************************************/
+void shmDebug_registerDump(TI_HANDLE hWhalBus)
+{
+       shmDebug_macRegisterDump(hWhalBus);
+       shmDebug_phyRegisterDump(hWhalBus);
+}
+
+void shmDebug_phyRegisterDump(TI_HANDLE hWhalBus)
+{
+       UINT32 regIndex;
+       int regInterval;
+       UINT32  RegValue;
+       UINT32  phyRegMap[56] = {
+               0x0800, 0x0807, 0x1000, 0x100c, 0x1010, 0x1019, 0x1020, 0x1032,
+               0x1040, 0x104c, 0x1050, 0x1077, 0x1201, 0x1334, 0x1400, 0x143f,
+               0x1500, 0x153F, 0x1800, 0x1802, 0x1c00, 0x1cff, 0x1e00, 0x1eff,
+               0x2000, 0x20ff, 0x2840, 0x28b3, 0x2a00, 0x2a02, 0x2c01, 0x2c02,
+               0x2c10, 0x2c6f, 0x2d00, 0x2f3f, 0x3000, 0x30dd, 0x3100, 0x311f,
+               0x3200, 0x321f, 0x3030, 0x303f, 0x4800, 0x4bb8, 0x4bc0, 0x4bd7,
+               0x4be1, 0x4bed, 0x4bf0, 0x4d7f, 0x4e00, 0x4fe0, 0x4ff0, 0x4fff
+       };
+
+       WLAN_OS_REPORT(("shmDebug_registerDump : Dumping PHY registers \n"));
+       for (regInterval = 0; regInterval < 56; regInterval += 2)
+       {
+               WLAN_OS_REPORT(("shmDebug_registerDump : Dumping PHY registers from 0x%x to 0x%x\n",
+                                               phyRegMap[regInterval], phyRegMap[regInterval+1]));
+               for (regIndex = phyRegMap[regInterval]; regIndex <= phyRegMap[regInterval+1]; regIndex++)
+               {
+#if defined(TNETW1150)
+                       RegValue = whalBus_PhyRegRead(hWhalBus, regIndex+0x3c0000);
+#else
+                       RegValue = whalBus_PhyRegRead(hWhalBus, regIndex);
+#endif
+                       WLAN_OS_REPORT(("Phy addr = 0x%x, Phy data = 0x%x\n", regIndex, RegValue));
+               }
+       }
+
+       WLAN_OS_REPORT(("shmDebug_registerDump : FINISHED Dumping PHY registers \n"));
+}
+
+#if defined (TNETW1150)
+
+void shmDebug_macRegisterDump(TI_HANDLE hWhalBus)
+{
+       WLAN_OS_REPORT(("shmDebug_macRegisterDump : Not implemented in TNETW1150 \n"));
+}
+
+#else
+
+#define START_REG_ADDR 0x0
+#define LAST_REG_ADDR  0xa80
+
+void shmDebug_macRegisterDump(TI_HANDLE hWhalBus)
+{
+       whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+       UINT32 regIndex;
+       UINT32  RegValue;
+
+
+       WLAN_OS_REPORT(("shmDebug_registerDump : Dumping MAC registers \n"));
+
+       for (regIndex = START_REG_ADDR; regIndex < LAST_REG_ADDR; regIndex += 4)
+       {
+               RegValue = whalBus_MacRegRead(hWhalBus, regIndex);
+               WLAN_OS_REPORT(("Mac addr = 0x%x, Mac data = 0x%x\n", regIndex, RegValue));
+       }
+}
+
+#endif
+
+int shmDebug_PrintRxRegs(TI_HANDLE hWhalBus)
+{
+       whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("shmDebug_PrintRxRegs ----MAC--------------\n"));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_FRM_CNT      (0x%08X) = 0x%08X, 0x%08X\n", RX_FRM_CNT,
+         whalBus_MacRegRead(hWhalBus, RX_FRM_CNT), 
+                       whalBus_MacRegRead(hWhalBus, RX_FRM_CNT)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("CONS_FCS_ERR_CNT(0x%08X) = 0x%08X, 0x%08X\n", CONS_FCS_ERR_CNT,
+                       whalBus_MacRegRead(hWhalBus, CONS_FCS_ERR_CNT), 
+                       whalBus_MacRegRead(hWhalBus, CONS_FCS_ERR_CNT)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("FCS_ERR_CNT     (0x%08X) = 0x%08X, 0x%08X\n", FCS_ERR_CNT,
+                       whalBus_MacRegRead(hWhalBus, FCS_ERR_CNT), 
+                       whalBus_MacRegRead(hWhalBus, FCS_ERR_CNT)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PLCP_ERR_CNT    (0x%08X) = 0x%08X, 0x%08X\n", PLCP_ERR_CNT,
+                       whalBus_MacRegRead(hWhalBus, PLCP_ERR_CNT), 
+                       whalBus_MacRegRead(hWhalBus, PLCP_ERR_CNT)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_FRM_PTR      (0x%08X) = 0x%08X, 0x%08X\n", RX_FRM_PTR,
+                       whalBus_MacRegRead(hWhalBus, RX_FRM_PTR), 
+                       whalBus_MacRegRead(hWhalBus, RX_FRM_PTR)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_FRM_CTL      (0x%08X) = 0x%08X, 0x%08X\n", RX_FRM_CTL,
+                       whalBus_MacRegRead(hWhalBus, RX_FRM_CTL), 
+                       whalBus_MacRegRead(hWhalBus, RX_FRM_CTL)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_SEQ_CTL      (0x%08X) = 0x%08X, 0x%08X\n", RX_SEQ_CTL,
+                       whalBus_MacRegRead(hWhalBus, RX_SEQ_CTL), 
+                       whalBus_MacRegRead(hWhalBus, RX_SEQ_CTL)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_STATUS       (0x%08X) = 0x%08X, 0x%08X\n", RX_STATUS,
+                       whalBus_MacRegRead(hWhalBus, RX_STATUS), 
+                       whalBus_MacRegRead(hWhalBus, RX_STATUS)));
+
+#if defined (TNETW1150)
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_HEAD_PTR     (0x%08X) = 0x%08X, 0x%08X\n", RX_HEAD_PTR,
+                       whalBus_MacRegRead(hWhalBus, RX_HEAD_PTR), 
+                       whalBus_MacRegRead(hWhalBus, RX_HEAD_PTR)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_TAIL_PTR     (0x%08X) = 0x%08X, 0x%08X\n", RX_TAIL_PTR,
+                       whalBus_MacRegRead(hWhalBus, RX_TAIL_PTR), 
+                       whalBus_MacRegRead(hWhalBus, RX_TAIL_PTR)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("RX_CURR_PTR     (0x%08X) = 0x%08X, 0x%08X\n", RX_CURR_PTR,
+                       whalBus_MacRegRead(hWhalBus, RX_CURR_PTR), 
+                       whalBus_MacRegRead(hWhalBus, RX_CURR_PTR)));
+#endif
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("shmDebug_PrintRxRegs ----PHY--------------\n"));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_11A_HDR_ERR (0x%08X) = 0x%08X, 0x%08X\n", 0x3c400a,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c400a), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c400a)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_FSM_STATUS  (0x%08X) = 0x%08X, 0x%08X\n", 0x3c4017,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4017), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4017)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_BAD_PKT_CNT (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2010,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2010), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2010)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_RXT_CFG     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2002,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2002), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2002)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_LS_RAM_OVR  (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2020,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2020), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2020)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_LS_FFT_ERR  (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2027,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2027), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2027)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_DATA_STATE  (0x%08X) = 0x%08X, 0x%08X\n", 0x3c201f,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c201f), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c201f)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_SEQ_CFG     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c301a,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c301a), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c301a)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_SYM_NUM     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2805,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2805), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2805)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_RUNBUSY     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2800,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2800), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2800)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PTH_ACC_0   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2f00,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f00), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f00)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PTH_ACC_1   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2f01,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f01), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f01)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PTH_ACC_2   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2f02,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f02), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f02)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PTH_ACC_3   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2f03,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f03), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f03)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PTH_ACC_4   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2f04,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f04), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2f04)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PLCP_SIGNAL (0x%08X) = 0x%08X, 0x%08X\n", 0x3c4002,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4002), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4002)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_PLCP_LENGTH (0x%08X) = 0x%08X, 0x%08X\n", 0x3c4003,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4003), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4003)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_11B_HDR     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c400b,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c400b), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c400b)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_TRANS_LENGTH(0x%08X) = 0x%08X, 0x%08X\n", 0x3c4018,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4018), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c4018)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_FFT_START   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c1802,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1802), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1802)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_OUT_RAM_IACC(0x%08X) = 0x%08X, 0x%08X\n", 0x3c1E00,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1E00), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1E00)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_RLS_SLOPE   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c2807,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2807), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2807)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_RLS_SLOPE_SH(0x%08X) = 0x%08X, 0x%08X\n", 0x3c2808,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2808), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2808)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_RLS_INTERCEP(0x%08X) = 0x%08X, 0x%08X\n", 0x3c2809,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2809), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2809)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_CHANRESP_ICO(0x%08X) = 0x%08X, 0x%08X\n", 0x3c2840,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2840), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2840)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_CHANRESP_ICO(0x%08X) = 0x%08X, 0x%08X\n", 0x3c2880,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2880), 
+                       whalBus_PhyRegRead(hWhalBus, 0x3c2880)));
+
+       return OK;
+}
+
+int shmDebug_PrintTxRegs(TI_HANDLE hWhalBus)
+{
+       whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("shmDebug_PrintTxRegs ----MAC--------------\n"));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("TX_STATUS       (0x%08X) = 0x%08X, 0x%08X\n", TX_STATUS,
+                       whalBus_MacRegRead(hWhalBus, TX_STATUS),
+                       whalBus_MacRegRead(hWhalBus, TX_STATUS)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("TX_STATE        (0x%08X) = 0x%08X, 0x%08X\n", TX_STATE,
+                       whalBus_MacRegRead(hWhalBus, TX_STATE),
+                       whalBus_MacRegRead(hWhalBus, TX_STATE)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("NEXT_SEQ_NUM    (0x%08X) = 0x%08X, 0x%08X\n", NEXT_SEQ_NUM,
+                       whalBus_MacRegRead(hWhalBus, NEXT_SEQ_NUM),
+                       whalBus_MacRegRead(hWhalBus, NEXT_SEQ_NUM)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("BCN_SEQ_NUM     (0x%08X) = 0x%08X, 0x%08X\n", BCN_SEQ_NUM,
+                       whalBus_MacRegRead(hWhalBus, BCN_SEQ_NUM),
+                       whalBus_MacRegRead(hWhalBus, BCN_SEQ_NUM)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("For Ping/Pong/Pang registers use print register list in the \n"));
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("Addresses: 0x%08X/0x%08X/0x%08X\n", TX_PING0, TX_PONG0, TX_PANG0));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("shmDebug_PrintTxRegs ----PHY--------------\n"));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_TX_STATUS   (0x%08X) = 0x%08X, 0x%08X\n", 0x3c1002,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1002),
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1002)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_TX_MODE     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c1008,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1008),
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1008)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("PHY_TX_CTRL     (0x%08X) = 0x%08X, 0x%08X\n", 0x3c1001,
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1001),
+                       whalBus_PhyRegRead(hWhalBus, 0x3c1001)));
+
+       return OK;
+}
+
+int shmDebug_PrintScrPadRegs(TI_HANDLE hWhalBus)
+{
+       whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("shmDebug_PrintScrPadRegs ---------------------\n"));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD0        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD0,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD0),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD0)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD1        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD1,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD1),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD1)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD2        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD2,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD2),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD2)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD3        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD3,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD3),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD3)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD4        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD4,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD4),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD4)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD5        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD5,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD5),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD5)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD6        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD6,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD6),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD6)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD7        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD7,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD7),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD7)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD8        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD8,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD8),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD8)));
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("SCR_PAD9        (0x%08X) = 0x%08X, 0x%08X\n", SCR_PAD9,
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD9),
+                       whalBus_MacRegRead(hWhalBus, SCR_PAD9)));
+
+       return OK;
+}
+
+int shmDebug_PrintListRegs(TI_HANDLE hWhalBus, UINT32 RegAddr)
+{
+       whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+       
+       int i;
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+               ("shmDebug_PrintListRegs ---------------------\n"));
+
+       for (i=0; i<8; i++, RegAddr+=16)
+       {
+               WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+                       ("REGS (Base=0x%08X) = 0x%08X, 0x%08X, 0x%08X, 0x%08X\n", RegAddr,
+                               whalBus_MacRegRead(hWhalBus, RegAddr+0),
+                               whalBus_MacRegRead(hWhalBus, RegAddr+4),
+                               whalBus_MacRegRead(hWhalBus, RegAddr+8),
+                whalBus_MacRegRead(hWhalBus, RegAddr+12)));
+       }
+
+       return OK;
+}
+                            
+void shmDebug_MemPrint(TI_HANDLE hWhalBus, UINT32 MemAddr)
+{
+       whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+       UINT8 HostBuf[256];
+       UINT8 *pBuf;
+       int i;
+
+       whalBus_MemCopyFrom(hWhalBus, (UINT8*)MemAddr ,(char *)(&HostBuf[0]), 256);
+
+       WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                         ("shmDebug_MemPrint ========================================\n"));
+
+       for (i=0, pBuf=HostBuf; i<256; i+=16, pBuf+=16)
+       {
+               WLAN_REPORT_REPLY(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                                 ("PrintBuf: %08x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 
+                                                  MemAddr+i, 
+                                                  pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7], 
+                                                  pBuf[8], pBuf[9], pBuf[10], pBuf[11], pBuf[12], pBuf[13], pBuf[14], pBuf[15]));
+       }
+}
+
+#endif /* USE_SYNC_API */
+
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmFwCtrl.c b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmFwCtrl.c
new file mode 100644 (file)
index 0000000..946eb5a
--- /dev/null
@@ -0,0 +1,1802 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  ShmFwCtrl.c
+ *   PURPOSE: shared memory firmware control
+ *
+ ****************************************************************************/
+#include "whalCommon.h"
+#include "whalBus_Api.h"
+#include "shmBus.h"
+#include "TNETWIF.h"
+#include "whalHwAccess.h"
+#include "whalHwCtrl.h"
+#include "shmFwCtrl.h"
+#include "TNETW_Driver.h"
+#include "CmdMBox_api.h"
+#include "eventMbox_api.h"
+#include "FwEvent_api.h"
+
+
+/* Firmware image header size */
+#define FW_HDR_SIZE 8
+
+
+static TI_STATUS whal_FwCtrl_BootSm                 (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);
+static TI_STATUS whal_FwCtrl_ResetSm                (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);
+static TI_STATUS whal_FwCtrl_EepromlessStartBurstSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);                                                   
+static TI_STATUS whal_FwCtrl_InitSequenceSm         (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);
+static TI_STATUS whal_FwCtrl_LoadFwImageSm          (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);
+static TI_STATUS whal_FwCtrl_FinalizeDownloadSm     (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status);                                             
+#ifdef USE_SYNC_API
+static int       whal_FwCtrl_Reset                  (TI_HANDLE hWhalBus);
+#endif
+
+
+/* Handle return status inside a state machine */
+#define EXCEPT(pwhalbus,status)                                 \
+    switch (status) {                                           \
+        case OK:                                                \
+        case TNETWIF_COMPLETE:                                  \
+             break;                                             \
+        case TNETWIF_PENDING:                                   \
+             return TNETWIF_PENDING;                            \
+        default:                                                \
+             whal_hwCtrl_FinalizeOnFailure (pwhalbus->hHwCtrl); \
+             return TNETWIF_ERROR;                              \
+    }
+
+
+/* Handle return status inside an init sequence state machine  */
+#define EXCEPT_I(pwhalbus,status)                               \
+    switch (status) {                                           \
+        case OK:                                                \
+        case TNETWIF_COMPLETE:                                  \
+             break;                                             \
+        case TNETWIF_PENDING:                                   \
+             pwhalbus->uInitSeqStatus = status;                 \
+             return TNETWIF_PENDING;                            \
+        default:                                                \
+             whal_hwCtrl_FinalizeOnFailure (pwhalbus->hHwCtrl); \
+             return TNETWIF_ERROR;                              \
+    }
+
+
+/* Handle return status inside a load image state machine */
+#define EXCEPT_L(pwhalbus,status)                               \
+    switch (status) {                                           \
+        case OK:                                                \
+        case TNETWIF_COMPLETE:                                  \
+             break;                                             \
+        case TNETWIF_PENDING:                                   \
+             pwhalbus->DownloadStatus = status;                 \
+             return TNETWIF_PENDING;                            \
+        default:                                                \
+             pwhalbus->DownloadStatus = status;                 \
+             whal_hwCtrl_FinalizeOnFailure (pwhalbus->hHwCtrl); \
+             return TNETWIF_ERROR;                              \
+    }
+
+
+/****************************************************************************
+ *                      whalBus_FwCtrl_Boot()
+ ****************************************************************************
+ * DESCRIPTION: Download firmware code to the Hardware and run it
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whalBus_FwCtrl_Boot (TI_HANDLE hWhalBus, TI_HANDLE hHwCtrl, BootAttr_T *pBootAttr)
+{ 
+    whalBus_T *pWhalBus     = (whalBus_T *)hWhalBus;  
+    HwCtrl_T  *pHwCtrl      = (HwCtrl_T *)hHwCtrl;  
+                           
+    pWhalBus->hHwCtrl = hHwCtrl;
+
+    /* Store the pointer to the FW buffer for further use in FW download in part */
+    pWhalBus->pFwBuf = (UINT8 *)pHwCtrl->uFwBuf;
+    pWhalBus->uFwLastAddr = pHwCtrl->uFwAddr;
+    pWhalBus->pEEPROMBuf = (UINT8 *)pHwCtrl->uEEEPROMBuf;
+    pWhalBus->uEEPROMLen = pHwCtrl->uEEEPROMLen; 
+
+    /*
+     * Initialize the status of download to  pending 
+     * It will be set to TNETWIF_COMPLETE at the FinalizeDownload function 
+     */
+    pWhalBus->DownloadStatus = TNETWIF_PENDING;
+
+    /* Call the boot sequence state machine */
+    pWhalBus->uInitStage = 0;
+
+    os_memoryCopy (pWhalBus->hOs, &pWhalBus->BootAttr, pBootAttr, sizeof(BootAttr_T));
+
+    whal_FwCtrl_BootSm (hWhalBus, HAL_INIT_MODULE_ID, OK);
+
+    /*
+     * If it returns the status of the StartInstance only then we can here query for the download status 
+     * and then return the status up to the TNETW_Driver.
+     * This return value will go back up to the TNETW Driver layer so that the init from OS will know
+     * if to wait for the InitComplte or not in case of TNETWIF_ERROR.
+     * This value will always be pending since the SPI is ASYNC 
+     * and in SDIOa timer is set so it will be ASync also in anyway.
+     */
+    return pWhalBus->DownloadStatus;
+}
+
+
+ /****************************************************************************
+ * DESCRIPTION: Firmware boot state machine
+ * 
+ * INPUTS:  
+ *      TI_HANDLE hWhalBus  Handle to the Bus
+ *      UINT8 module_id     The module id of the Init process in the TNETWIF
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK 
+ ****************************************************************************/
+static TI_STATUS whal_FwCtrl_BootSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T  *pWhalBus = (whalBus_T *)hWhalBus;
+    BootAttr_T *pBootAttr;
+    UINT8 minorMinorE2Ver = 0;
+
+    EXCEPT (pWhalBus, status)
+
+    switch (pWhalBus->uInitStage)
+    {
+    case 0:  
+        pWhalBus->uInitStage ++;
+
+        pWhalBus->uChipId = 0;
+
+        /* Read the CHIP ID to get an indication that the bus is OK */
+        status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF, 
+                                     CHIP_ID, 
+                                     &pWhalBus->uChipId, 
+                                     module_id,
+                                     (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                     hWhalBus);
+        EXCEPT (pWhalBus, status)
+
+    case 1:
+        pWhalBus->uInitStage ++;
+
+        /* This is only sanity check that the HW exists, we can continue and fail on FwLoad */
+        if (pWhalBus->uChipId == CHIP_ID_1251_PG10)
+        {
+            WLAN_OS_REPORT(("Working on a 1251 PG 1.0 board.\n"));
+        }
+        else if (pWhalBus->uChipId == CHIP_ID_1251_PG11)
+        {
+            WLAN_OS_REPORT(("Working on a 1251 PG 1.1 board.\n"));
+        }
+        else if (pWhalBus->uChipId == CHIP_ID_1251_PG12)
+        {
+            WLAN_OS_REPORT(("Working on a 1251 PG 1.2 board.\n"));
+        }
+        else 
+        {
+            WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                               ("whalBus_FwCtrl_Boot: ERROR, Fail to identify Wlan Hardware card, ChipId(0x%x)=0x%x\n", 
+                               CHIP_ID, pWhalBus->uChipId));
+
+            WLAN_OS_REPORT (("Found unknown Chip Id = 0x%x\n", pWhalBus->uChipId));
+
+            /*
+             * NOTE: no exception because of forward compatibility
+             */
+        }
+    
+        /*
+         * Soft reset 
+         */
+        pWhalBus->uResetStage = 0;
+        pWhalBus->uSelfClearTime = 0;
+        pWhalBus->uBootData = 0;
+        status = whal_FwCtrl_ResetSm (pWhalBus, module_id, OK);    
+
+        EXCEPT (pWhalBus, status)
+
+    case 2:
+        pWhalBus->uInitStage ++;
+
+        WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, ("TNET SOFT-RESET\n"));                         
+
+        WLAN_OS_REPORT(("Starting to process NVS...\n"));
+
+        /*
+         * Start EEPROM/NVS burst (get RadioType)
+         */
+        if (pWhalBus->pEEPROMBuf) 
+        {
+            /* NVS file exists (EEPROM-less support) */
+            pWhalBus->uEEPROMCurLen = pWhalBus->uEEPROMLen;
+            pWhalBus->pEEPROMCurPtr = pWhalBus->pEEPROMBuf;
+            pWhalBus->uEEPROMStage = 0;
+
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                              ("whal_FwCtrl_EepromlessStartBurst: EEPROM Image addr=0x%x, EEPROM Len=0x0x%x\n", 
+                              pWhalBus->pEEPROMBuf, pWhalBus->uEEPROMLen));
+            status = whal_FwCtrl_EepromlessStartBurstSm (hWhalBus, module_id, OK);
+
+            EXCEPT (pWhalBus, status)
+        }
+
+    case 3: 
+        pWhalBus->uInitStage ++;
+
+        if (pWhalBus->pEEPROMBuf) 
+        {
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          ACX_EEPROMLESS_IND_REG, 
+                                          pWhalBus->uFwLastAddr,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                          hWhalBus);
+            EXCEPT (pWhalBus, status)
+        }
+
+    case 4:
+        pWhalBus->uInitStage ++;
+
+        if (pWhalBus->pEEPROMBuf) 
+        {
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG,
+                              ("DRIVER NVS BURST-READ\n"));
+        }
+
+        if (!pWhalBus->pEEPROMBuf) 
+        {
+            /*
+             * Start ACX EEPROM
+             */     
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          ACX_REG_EE_START, 
+                                          START_EEPROM_MGR,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                          hWhalBus);
+            EXCEPT (pWhalBus, status)
+        }
+
+    case 5:
+        pWhalBus->uInitStage ++;
+
+        if (!pWhalBus->pEEPROMBuf) 
+        {           
+            /*
+             * The stall is needed so the EEPROM NVS burst read will complete
+             */     
+            os_StalluSec (pWhalBus->hOs, 40000);
+
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          ACX_EEPROMLESS_IND_REG, 
+                                          USE_EEPROM,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                          hWhalBus);
+            EXCEPT (pWhalBus, status)
+        }
+
+    case 6:
+        pWhalBus->uInitStage ++;
+
+        if (!pWhalBus->pEEPROMBuf) 
+        {
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG,
+                              ("STARTING EEPROM NVS BURST-READ\n"));
+        }
+
+        /* Read the EEPROM parameters */
+        status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF, 
+                                     SCR_PAD2, 
+                                     &pWhalBus->uBootData,
+                                     module_id,
+                                     (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                     hWhalBus);
+        EXCEPT (pWhalBus, status)
+
+    case 7:
+        pWhalBus->uInitStage ++;
+
+        pBootAttr = &pWhalBus->BootAttr;
+        pBootAttr->radioType = (pWhalBus->uBootData & 0x0000FF00) >> 8;
+        pBootAttr->majorE2Ver = (pWhalBus->uBootData & 0x00FF0000) >> 16;
+
+        status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF,
+                                     SCR_PAD3,
+                                     &pWhalBus->uBootData,
+                                     module_id,
+                                     (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                     hWhalBus);
+        EXCEPT (pWhalBus, status)
+
+    case 8:
+        pWhalBus->uInitStage ++;
+
+        pBootAttr = &pWhalBus->BootAttr;
+        pBootAttr->minorE2Ver = (pWhalBus->uBootData & 0x00FF0000) >> 16;
+        minorMinorE2Ver = (pWhalBus->uBootData & 0xFF000000) >> 24;
+
+        if (pBootAttr->radioType == 0xffffffff)
+        {
+            WLAN_REPORT_FATAL_ERROR (pWhalBus->hReport, HAL_CTRL_MODULE_LOG,
+                                     ("whalBus_FwCtrl_Boot: error in RadioType\n"));
+            EXCEPT (pWhalBus, TNETWIF_ERROR)
+        }
+
+        WLAN_OS_REPORT(("NVS version %d.%d.%d found.\n", pBootAttr->majorE2Ver, pBootAttr->minorE2Ver, minorMinorE2Ver));
+        WLAN_OS_REPORT(("Radio type is 0x%X.\n", pBootAttr->radioType));
+
+        /* Call the restart sequence */
+        pWhalBus->uInitSeqStage = 0;
+        pWhalBus->uInitSeqStatus = TNETWIF_COMPLETE;
+        status = whal_FwCtrl_InitSequenceSm (hWhalBus, module_id, OK);
+
+        EXCEPT (pWhalBus, status)
+
+    case 9:
+        pWhalBus->uInitStage ++;
+
+        WLAN_OS_REPORT(("Finished processing NVS.\n"));
+
+        /* Download the firmware */
+        status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF,
+                                     ACX_REG_ECPU_CONTROL,
+                                     &pWhalBus->uBootData,
+                                     module_id,
+                                     (TNETWIF_callback_t)whal_FwCtrl_BootSm,
+                                     hWhalBus);
+        EXCEPT (pWhalBus, status)
+
+    case 10:
+        pWhalBus->uInitStage = 0;
+
+        if (pWhalBus->pFwBuf && (pWhalBus->uBootData & ECPU_CONTROL_HALT) != 0)
+        {
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG,
+                              ("CPU halt -> download code"));
+
+            /* Load firmware image */ 
+            pWhalBus->uLoadStage = 0;
+            status = whal_FwCtrl_LoadFwImageSm (pWhalBus, module_id, OK);
+
+            switch (status)
+            {
+            case TNETWIF_COMPLETE:
+                /*WLAN_OS_REPORT (("Firmware successfully downloaded.\n"));*/
+                break;
+            case TNETWIF_PENDING:
+                WLAN_OS_REPORT (("Starting to download firmware...\n"));
+                break;
+            default:
+                WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG, ("Firmware download failed!\n"));                                   
+                break;
+            }
+
+            EXCEPT (pWhalBus, status);
+        }   
+        else
+        {
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, ("Firmware not downloaded...\n"));
+
+            EXCEPT (pWhalBus, TNETWIF_ERROR)
+        }
+            
+    } /* Switch end */
+
+    return TNETWIF_COMPLETE;
+}                                                  
+    
+
+/****************************************************************************
+ *                      whal_FwCtrl_FinalizeDownloadSm()
+ ****************************************************************************
+ * DESCRIPTION: Run the Hardware firmware
+ *              Wait for Init Complete
+ *              Configure the Bus Access with Addresses available on the scratch pad register 
+ *              Change the SDIO/SPI partitions to be able to see all the memory addresses
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+static TI_STATUS whal_FwCtrl_FinalizeDownloadSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    #define FIN_LOOP 20000
+
+    EXCEPT (pWhalBus, status)
+
+    while (TRUE)
+    {
+        switch (pWhalBus->uFinStage)
+        {
+        case 0:
+            pWhalBus->uFinStage ++;
+
+            /*
+             * Run the firmware (I)
+             */
+            status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF, 
+                                         ACX_REG_ECPU_CONTROL, 
+                                         &pWhalBus->uFinData,
+                                         module_id,
+                                         (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm,
+                                         hWhalBus);
+            EXCEPT (pWhalBus, status);
+
+        case 1:
+            pWhalBus->uFinStage ++;
+
+            /*
+             * Run the firmware (II)
+             */
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          ACX_REG_ECPU_CONTROL, 
+                                          pWhalBus->uFinData & ~ECPU_CONTROL_HALT,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm,
+                                          hWhalBus);
+            EXCEPT (pWhalBus, status);
+
+        case 2:
+            pWhalBus->uFinStage ++;
+
+          #if defined(TNETW1150) && defined(RIVENDELL)    
+            /* (!!!1150) added when testing with the prateekai/rivendell */
+            WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                               ("whal_hwCtrl_Run: Only 1150 - wait 500 msec between FW download and run CPU\n"));
+            os_StalluSec (pWhalBus->hOs, 500000);
+          #endif
+
+            WLAN_OS_REPORT (("Firmware running.\n"));
+
+            /* 
+             * CHIP ID Debug
+             */     
+            status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF,
+                                         CHIP_ID,
+                                         &pWhalBus->uFinData,
+                                         module_id,
+                                         (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm,
+                                         hWhalBus);
+            EXCEPT (pWhalBus, status);
+
+        case 3:
+            pWhalBus->uFinStage ++;
+            pWhalBus->uFinLoop = 0;
+
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+                              ("CHIP ID IS %x\n", pWhalBus->uFinData));
+                   
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG, ("Wait init complete\n")); 
+
+        case 4:
+            /* 
+             * Wait for init complete 
+             */
+            if (pWhalBus->uFinLoop < FIN_LOOP)
+            {           
+                pWhalBus->uFinStage = 5;
+
+                os_StalluSec (pWhalBus->hOs, 50);
+
+                /* Read interrupt status register */
+                status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF, 
+                                             ACX_REG_INTERRUPT_NO_CLEAR, 
+                                             &pWhalBus->uFinData,
+                                             module_id,
+                                             (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm,
+                                             hWhalBus); 
+                EXCEPT (pWhalBus, status);
+            }
+            else
+                pWhalBus->uFinStage = 6;
+            continue;
+
+        case 5:
+            if (pWhalBus->uFinData == 0xffffffff) /* error */
+            {
+                WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                   ("Error reading hardware complete init indication\n"));
+
+                pWhalBus->DownloadStatus = TNETWIF_ERROR;
+                EXCEPT (pWhalBus, TNETWIF_ERROR);
+            }
+
+            if (IS_MASK_ON (pWhalBus->uFinData, ACX_INTR_INIT_COMPLETE))
+            {
+                pWhalBus->uFinStage = 6;
+
+                /* Interrupt ACK */
+                status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                              ACX_REG_INTERRUPT_ACK, 
+                                              ACX_INTR_INIT_COMPLETE,
+                                              module_id,
+                                              (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm,
+                                              hWhalBus); 
+                EXCEPT (pWhalBus, status);
+            }
+            else
+            {
+                pWhalBus->uFinStage = 4;
+                pWhalBus->uFinLoop ++;
+            }
+            continue;
+
+        case 6:               
+            pWhalBus->uFinStage = 7;
+
+            if (pWhalBus->uFinLoop >= FIN_LOOP)
+            {
+                WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                   ("Timeout waiting for the hardware to complete initialization\n"));
+
+                pWhalBus->DownloadStatus = TNETWIF_ERROR;
+                EXCEPT (pWhalBus, TNETWIF_ERROR);
+            }
+        
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, ("Firmware init complete...\n"));
+
+            /* 
+             * There are valid addresses of the command and event mailbox 
+             * on the scratch pad registers 
+             */
+            {
+                /* Hardware config command mail box */
+                TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)pWhalBus->hTnetwDrv;
+                status = CmdMBox_ConfigHw (pTnetwDrv->hCmdMBox,
+                                           module_id, 
+                                           (fnotify_t)whal_FwCtrl_FinalizeDownloadSm, 
+                                           hWhalBus);
+                EXCEPT (pWhalBus, status);
+            }
+            continue;
+
+        case 7:  
+            pWhalBus->uFinStage = 8;
+
+            {
+                /* Hardware config event mail box */
+                TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)pWhalBus->hTnetwDrv;
+                status = eventMbox_ConfigHw (pTnetwDrv->hEventMbox,
+                                             module_id,
+                                             (fnotify_t)whal_FwCtrl_FinalizeDownloadSm, 
+                                             hWhalBus);
+                EXCEPT (pWhalBus, status);
+            }
+            continue;
+
+        case 8: 
+            pWhalBus->uFinStage = 9;
+
+            /* Set the working partition to its "running" mode offset */
+          #if defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI)
+            status = TNETWIF_SetPartitionsOpt (pWhalBus->hTNETWIF, 
+                                               HW_ACCESS_WORKING, 
+                                               HW_ACCESS_WORK_PART0_ADDR,
+                                               module_id,
+                                               (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm, 
+                                               hWhalBus);
+             EXCEPT (pWhalBus, status);
+          #endif
+            continue;
+        
+        case 9:   
+            pWhalBus->uFinStage = 10;
+       
+            /* 
+             * In case of full asynchronous mode the firmware event must be ready 
+             * to receive event from the command mailbox
+             */
+            {
+                TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)pWhalBus->hTnetwDrv;
+                UINT32      uIntVect;
+
+                               if (pWhalBus->recoveryProcess == FALSE)
+                FwEvent_Config (pTnetwDrv->hFwEvent, pWhalBus->hTnetwDrv);
+
+              #if !defined(USE_SYNC_API)
+                             
+                /* This makes command mailbox to work in normal mode */
+                whalBus_ExitFromInitMode (hWhalBus); 
+
+                /* Enable command complete interrupt */
+                FwEvent_Enable (pTnetwDrv->hFwEvent, ACX_INTR_CMD_COMPLETE);
+
+                /* At the driver init the interrupts must be disabled */
+                os_enableIrq (pWhalBus->hOs);
+
+              #endif
+
+              #ifdef PRIODIC_INTERRUPT
+                           /* Enable periodic interrupts. It means that every period of time the FwEvent SM will be called */
+                os_periodicIntrTimerStart (pWhalBus->hOs);
+              #endif
+
+                uIntVect = FwEvent_GetEnabled (pTnetwDrv->hFwEvent);
+
+                /* Clearing all the interrupt status register sources */
+                status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                              ACX_REG_INTERRUPT_MASK, 
+                                              ~uIntVect,
+                                              module_id,
+                                              (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm, 
+                                              hWhalBus);
+            }
+
+            EXCEPT (pWhalBus, status);
+            continue;
+    
+        case 10:
+            pWhalBus->uFinStage = 11;
+
+            /*
+             * Setting the right operation of the interrupt
+             * bit 5 - enable interrupt
+             * bit 7 - active low 
+             */
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          HI_CFG, 
+                                          HI_CFG_DEF_VAL,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_FinalizeDownloadSm, 
+                                          hWhalBus);
+            EXCEPT (pWhalBus, status);
+            continue;
+
+        case 11:
+            pWhalBus->uFinStage = 0;
+
+          #ifdef DEBUG_INTERRUPTS_PRINT
+            WLAN_REPORT_INFORMATION (pHwIntr->hReport,
+                                     HAL_HW_CTRL_MODULE_LOG,
+                                     ("whal_hwIntr_EnableInterrupts(0x%08X)",
+                                     pHwIntr->InterruptEnabled));
+          #endif
+
+          #if defined(HAL_ON_WIN)
+            /* (!!!) Only in CardBus, add HostIfType parameter */
+            /* Enable interrupt on a CardBus */
+            TNETWIF_WriteRegSync (pWhalBus->hTNETWIF, FEMR, 0x8000);
+          #endif
+
+            /* 
+             * The last thing to be done after the upper layers have been called 
+             * is to send FINISH to the TNETWIF to end the init process 
+             */    
+            TNETWIF_Finish (pWhalBus->hTNETWIF, HAL_INIT_MODULE_ID, hWhalBus, NULL);
+
+            /* Call the whal_hwCtrl_FinalizeDownload of the upper layer to finalize the download process */
+            whal_hwCtrl_FinalizeDownload (pWhalBus->hHwCtrl, &pWhalBus->BootAttr);
+        
+            /* Set the Download Status to COMPLETE */
+            pWhalBus->DownloadStatus = TNETWIF_COMPLETE;
+
+            return TNETWIF_COMPLETE;
+
+        } /* End switch */
+
+    } /* End while */
+
+}
+
+
+#ifdef USE_SYNC_API
+
+/****************************************************************************
+ *                      whal_hwCtrl_Reset()
+ ****************************************************************************
+ * DESCRIPTION: Reset the Hardware
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static int whal_FwCtrl_Reset (TI_HANDLE hWhalBus)
+{
+#ifdef USE_SYNC_API
+
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    UINT32 data;
+
+#ifdef  TNETW1251
+
+    /***************************************************************/
+    /* SOFT RESET is done here - its a temporary fix */
+    /***************************************************************/
+    UINT32 SelfClearTime;
+
+    /*
+     * Perform Soft Reset
+     */
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF,  ACX_REG_SLV_SOFT_RESET, SLV_SOFT_RESET_BIT);
+
+    /* SOFT_RESET - Self clearing  */
+    for (SelfClearTime=0; SelfClearTime<SOFT_RESET_MAX_TIME; SelfClearTime+=SOFT_RESET_STALL_TIME)
+    {
+        TNETWIF_ReadRegSync(pWhalBus->hTNETWIF, ACX_REG_SLV_SOFT_RESET,&data);
+        if (( data & SLV_SOFT_RESET_BIT) == 0)
+            break;
+        os_StalluSec(pWhalBus->hOs, SOFT_RESET_STALL_TIME);     
+    }
+
+    WLAN_REPORT_INFORMATION(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_Reset: SOFT_RESET Self clearing time = %d (%d)\n", SelfClearTime, SOFT_RESET_MAX_TIME));
+    if (SelfClearTime >= SOFT_RESET_MAX_TIME)
+    {
+        WLAN_REPORT_FATAL_ERROR(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwCtrl_Reset: ACX_REG_SLV_SOFT_RESET - Self clearing timer expired !!!\n"));
+        return NOK;
+    }
+
+    /***************************************************************/
+    /* SOFT RESET is done here - its a temporary fix */
+    /***************************************************************/
+
+    /* Disable Rx/Tx */
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, ENABLE, 0x0);      /* disable TX,RX */ 
+
+    /* Auto Calibration on start Disable */
+    TNETWIF_WriteRegSync(pWhalBus->hTNETWIF, SPARE_A2, (UINT32)0xFFFF);
+
+#else /* TNETW1251 */
+    UINT32 SelfClearTime;
+
+    /*
+     * Halt the Acx Cpu
+     */
+    TNETWIF_RegIsBitSet(pWhalBus->hTNETWIF,  ACX_REG_ECPU_CONTROL, ECPU_CONTROL_HALT);
+
+    /*
+     * Reset the ACX cpu
+     */
+    TNETWIF_RegIsBitSet(pWhalBus->hTNETWIF,  ACX_REG_SLV_SOFT_RESET, SLV_SOFT_RESET_BIT);
+
+    /*
+     * Wait for Soft reset (Self clearing only in 1150)
+     */
+#if defined(TNETW1150)
+    /* SOFT_RESET - Self clearing only on 1150 */
+    for (SelfClearTime=0; SelfClearTime<SOFT_RESET_MAX_TIME; SelfClearTime+=SOFT_RESET_STALL_TIME)
+    {
+        os_StalluSec(pWhalBus->hOs, SOFT_RESET_STALL_TIME);
+        
+        if (((TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,ACX_REG_SLV_SOFT_RESET,&data)) & SLV_SOFT_RESET_BIT) == 0)
+            break;
+    }
+
+    WLAN_REPORT_INFORMATION(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_Reset: SOFT_RESET Self clearing time = %d (%d)\n", SelfClearTime, SOFT_RESET_MAX_TIME));
+    if (SelfClearTime >= SOFT_RESET_MAX_TIME)
+    {
+        WLAN_REPORT_FATAL_ERROR(pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwCtrl_Reset: ACX_REG_SLV_SOFT_RESET - Self clearing timer expired !!!\n"));
+        return NOK;
+    }
+#else
+    os_StalluSec(pWhalBus->hOs, 10000);
+    TNETWIF_RegResetBitVal(pWhalBus->hTNETWIF,  ACX_REG_SLV_SOFT_RESET, SLV_SOFT_RESET_BIT);
+#endif
+    
+    /*
+     * Start Acx Eeprom
+     */
+    TNETWIF_RegIsBitSet(pWhalBus->hTNETWIF,  ACX_REG_EE_START, START_EEPROM_MGR);
+
+    /* Do Not Reduce the StallSec time !!!!! */
+    os_StalluSec(pWhalBus->hOs, 40000);
+
+#endif /* TNETW1251 */
+
+#endif /* USE_SYNC_API*/
+
+    return OK;
+}
+
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_Reset()
+ ****************************************************************************
+ * DESCRIPTION: Reset hardware state machine
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static TI_STATUS whal_FwCtrl_ResetSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    /***************************************************************/
+    /* SOFT RESET is done here - its a temporary fix               */
+    /***************************************************************/
+
+    EXCEPT (pWhalBus, status);
+
+    switch (pWhalBus->uResetStage)
+    {
+    case 0:
+        /*
+         * Perform soft reset
+         */   
+        pWhalBus->uResetStage ++;
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      ACX_REG_SLV_SOFT_RESET, 
+                                      SLV_SOFT_RESET_BIT,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_ResetSm,
+                                      hWhalBus);
+        EXCEPT (pWhalBus, status);
+
+    case 1:
+        /* SOFT_RESET - self clearing */
+        while (pWhalBus->uSelfClearTime <  SOFT_RESET_MAX_TIME) 
+        {
+            if (pWhalBus->uSelfClearTime != 0)
+            {
+                if ((pWhalBus->uBootData & SLV_SOFT_RESET_BIT) == 0)
+                    break;
+                os_StalluSec (pWhalBus->hOs, SOFT_RESET_STALL_TIME);     
+            }
+
+            status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF, 
+                                         ACX_REG_SLV_SOFT_RESET,
+                                         &pWhalBus->uBootData,
+                                         module_id,
+                                         (TNETWIF_callback_t)whal_FwCtrl_ResetSm,
+                                         hWhalBus);
+
+            pWhalBus->uSelfClearTime += SOFT_RESET_STALL_TIME;
+
+            EXCEPT (pWhalBus, status);
+        }
+
+        pWhalBus->uResetStage ++;
+
+    case 2:
+        pWhalBus->uResetStage ++;
+
+        WLAN_REPORT_INFORMATION (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                 ("whal_hwCtrl_Reset: SOFT_RESET self clearing time = %d (%d)\n", 
+                                 pWhalBus->uSelfClearTime, SOFT_RESET_MAX_TIME));
+        if (pWhalBus->uSelfClearTime >= SOFT_RESET_MAX_TIME)
+        {
+            WLAN_REPORT_FATAL_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                     ("whal_hwCtrl_Reset: ACX_REG_SLV_SOFT_RESET - Self clearing timer expired !!!\n"));
+            EXCEPT (pWhalBus, TNETWIF_ERROR);
+        }
+
+    case 3:
+        pWhalBus->uResetStage ++;
+
+        /* Disable Rx/Tx */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      ENABLE, 
+                                      0x0,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_ResetSm,
+                                      hWhalBus);
+        EXCEPT (pWhalBus, status);
+
+    case 4:
+        pWhalBus->uResetStage ++;
+
+        /* Disable auto calibration on start */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      SPARE_A2, 
+                                      0xFFFF,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_ResetSm,
+                                      hWhalBus);
+        return status;
+
+    case 5:
+        pWhalBus->uResetStage = 0;
+
+        /* If the previous status was pending call the upper layer init state machine */
+        whal_FwCtrl_BootSm (hWhalBus, module_id, status);
+    }
+
+    return status;
+}
+
+
+/****************************************************************************
+ *                      whal_FwCtrl_Eepromless_StartBurst()
+ ****************************************************************************
+ * DESCRIPTION: prepare eepromless configuration before boot
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+static TI_STATUS whal_FwCtrl_EepromlessStartBurstSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T* pWhalBus = (whalBus_T *)hWhalBus;
+           
+    EXCEPT (pWhalBus, status);
+
+    while (TRUE)
+    {
+        switch (pWhalBus->uEEPROMStage)
+        {
+        case 0: 
+            if ((pWhalBus->uEEPROMRegAddr = pWhalBus->pEEPROMCurPtr[1]) & 1)
+            {
+                pWhalBus->uEEPROMRegAddr &= 0xfe;
+                pWhalBus->uEEPROMRegAddr |= (UINT32)pWhalBus->pEEPROMCurPtr[2] << 8;
+                pWhalBus->uEEPROMBurstLen = pWhalBus->pEEPROMCurPtr[0];
+                pWhalBus->pEEPROMCurPtr += 3;
+                pWhalBus->uEEPROMBurstLoop = 0; 
+                pWhalBus->uEEPROMStage = 1;
+            }
+            else
+            {
+                if (pWhalBus->pEEPROMCurPtr[0] == 0)
+                    pWhalBus->pEEPROMCurPtr += 7;
+                pWhalBus->uEEPROMCurLen -= pWhalBus->pEEPROMCurPtr - pWhalBus->pEEPROMBuf;
+                pWhalBus->uEEPROMCurLen = (pWhalBus->uEEPROMCurLen + NVS_DATA_BUNDARY_ALIGNMENT - 1) & 0xfffffffc;
+                pWhalBus->uEEPROMStage = 2;
+            }
+            continue;            
+
+        case 1: 
+            if (pWhalBus->uEEPROMBurstLoop < pWhalBus->uEEPROMBurstLen)
+            {
+                UINT32 val = (pWhalBus->pEEPROMCurPtr[0] | 
+                              (pWhalBus->pEEPROMCurPtr[1] << 8) | 
+                              (pWhalBus->pEEPROMCurPtr[2] << 16) | 
+                              (pWhalBus->pEEPROMCurPtr[3] << 24));
+
+                WLAN_REPORT_INIT (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                        ("NVS::BurstRead: *(%08x) = %x\n", pWhalBus->uEEPROMRegAddr, val));
+
+                status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                              pWhalBus->uEEPROMRegAddr, 
+                                              val,
+                                              module_id,
+                                              (TNETWIF_callback_t)whal_FwCtrl_EepromlessStartBurstSm,
+                                              hWhalBus); 
+                pWhalBus->uEEPROMStatus = status;
+                pWhalBus->uEEPROMRegAddr += 4;
+                pWhalBus->pEEPROMCurPtr += 4;
+                pWhalBus->uEEPROMStage = 1;
+                pWhalBus->uEEPROMBurstLoop ++;
+
+                EXCEPT (pWhalBus, status);
+            }
+            else
+                pWhalBus->uEEPROMStage = 0;
+            continue;
+
+        case 2: 
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                    ("Get NVS file information: NvsDataLen = %#x TableAddr %#x\n", pWhalBus->uEEPROMCurLen, pWhalBus->uFwLastAddr));
+            pWhalBus->uNVSStartAddr = pWhalBus->uFwLastAddr;
+            pWhalBus->uNVSNumChar = 0;
+            pWhalBus->uNVSNumByte = 0;
+            pWhalBus->uNVSTempWord = 0;
+            pWhalBus->uEEPROMStage = 3;
+    
+          #if defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI)
+            status = TNETWIF_SetPartitionsOpt (pWhalBus->hTNETWIF,
+                                               HW_ACCESS_DOWNLOAD, 
+                                               pWhalBus->uNVSStartAddr,
+                                               module_id,
+                                               (TNETWIF_callback_t)whal_FwCtrl_EepromlessStartBurstSm,
+                                               hWhalBus);
+            EXCEPT (pWhalBus, status);                   
+          #endif
+            continue;
+
+        case 3:
+            /*
+             * Download EEPROM data to ACX internal memory
+             */
+            if (pWhalBus->uNVSNumChar < pWhalBus->uEEPROMCurLen)
+            {
+                pWhalBus->uNVSTempWord |= (*pWhalBus->pEEPROMCurPtr) << (8 * pWhalBus->uNVSNumByte);
+                pWhalBus->pEEPROMCurPtr ++;
+                pWhalBus->uNVSNumChar ++;
+
+                if (++pWhalBus->uNVSNumByte > 3)
+                {
+                    pWhalBus->uEEPROMStage = 4;
+                    pWhalBus->uNVSTempWord = ENDIAN_HANDLE_LONG (pWhalBus->uNVSTempWord);                   
+                    WLAN_REPORT_INIT (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                        ("NVS::WriteTable: *(%08x) = %x\n", pWhalBus->uNVSStartAddr, pWhalBus->uNVSTempWord));
+                    status = TNETWIF_WriteMemOpt (pWhalBus->hTNETWIF, 
+                                                  pWhalBus->uNVSStartAddr, 
+                                                  PADWRITE (&pWhalBus->uNVSTempWord), 
+                                                  sizeof(pWhalBus->uNVSTempWord),
+                                                  module_id,
+                                                  (TNETWIF_callback_t)whal_FwCtrl_EepromlessStartBurstSm,
+                                                  hWhalBus);
+                    pWhalBus->uNVSStatus = status;
+
+                    EXCEPT (pWhalBus, status);
+                }
+            }
+            else
+            {
+                /* Call the upper level state machine */
+                if (pWhalBus->uEEPROMStatus == TNETWIF_PENDING || 
+                    pWhalBus->uNVSStatus == TNETWIF_PENDING)
+                    whal_FwCtrl_BootSm (hWhalBus, module_id, status);
+
+                return TNETWIF_COMPLETE;
+            }
+            continue;
+
+        case 4:
+            pWhalBus->uNVSStartAddr += 4;
+            pWhalBus->uNVSTempWord = 0;
+            pWhalBus->uNVSNumByte = 0;
+            pWhalBus->uEEPROMStage = 3;
+            continue; 
+           
+        } /* End switch */
+    } /* End while */
+
+}
+
+
+/****************************************************************************
+ *                      whal_FwCtrl_InitSequenceSm()
+ ****************************************************************************
+ * DESCRIPTION: the restart wakeup sequence state machine
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static TI_STATUS whal_FwCtrl_InitSequenceSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    static const UINT32 LUT [REF_FREQ_NUM][LUT_PARAM_NUM] = 
+    {   /* INTEGER_DIVIDER   FRACTIONAL_DIVIDER   ATTN_BB   ALPHA_BB   STOP_TIME_BB   BB_PLL_LOOP_FILTER */
+        {   83,             87381,                  0xB,        5,          0xF00,      3}, /* REF_FREQ_19_2*/
+        {   61,             141154,                 0xB,        5,          0x1450,     2}, /* REF_FREQ_26_0*/
+        {   41,             174763,                 0xC,        6,          0x2D00,     1}, /* REF_FREQ_38_4*/
+        {   40,             0,                      0xC,        6,          0x2EE0,     1}, /* REF_FREQ_40_0*/
+        {   47,             162280,                 0xC,        6,          0x2760,     1}  /* REF_FREQ_33_6        */
+    };
+    
+    EXCEPT_I (pWhalBus, status);
+
+    switch (pWhalBus->uInitSeqStage)
+    {
+    case 0:
+        pWhalBus->uInitSeqStage ++;
+
+        WLAN_REPORT_INIT(pWhalBus->hReport, HAL_CTRL_MODULE_LOG, ("Starting INIT sequence\n"));           
+
+        /* Read NVS params */
+        status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF,
+                                     SCR_PAD6,
+                                     &pWhalBus->uScrPad6,
+                                     module_id,
+                                     (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                     hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 1:
+        pWhalBus->uInitSeqStage ++;
+        /* Read ELP_CMD */
+        status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF,
+                                     ELP_CMD,
+                                     &pWhalBus->uElpCmd,
+                                     module_id,
+                                     (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                     hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 2: 
+        pWhalBus->uInitSeqStage ++;
+
+        pWhalBus->uRefFreq = pWhalBus->uScrPad6 & 0x000000FF;
+    
+        /******************** Set ELP configuration *********************/
+    
+        /*
+         * Set the BB Calibration time to be 300 usec (PLL_CAL_TIME)
+         */
+         status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                       PLL_CAL_TIME/*0x5810*/, 
+                                       0x9/*0x4*/,
+                                       module_id,
+                                       (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                       hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 3:
+        pWhalBus->uInitSeqStage ++;
+
+        /* PG 1.1 & 1.0: Set the clock buffer time to be 760 usec (CLK_BUF_TIME) */
+        if (pWhalBus->uChipId == CHIP_ID_1251_PG10 ||
+            pWhalBus->uChipId == CHIP_ID_1251_PG11)
+        {
+                       status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      CLK_BUF_TIME/*0x5818*/, 
+                                      0x19,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+               }
+        /* PG 1.2: Set the clock buffer time to be 210 usec (CLK_BUF_TIME) */
+               else
+               {
+                       status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      CLK_BUF_TIME/*0x5818*/, 
+                                      0x6,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+               }
+        EXCEPT_I (pWhalBus, status);
+
+    case 4:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set the clock detect feature to work in the restart wu procedure (ELP_CFG_MODE[14])
+         * &
+         * Select the clock source type (ELP_CFG_MODE[13:12] )
+         */  
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      ELP_CFG_MODE/*0x5804*/, 
+                                      ((pWhalBus->uScrPad6 & 0x0000FF00) << 4) | 0x00004000,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 5:
+        pWhalBus->uInitSeqStage ++;
+
+        /* PG 1.1 & 1.0 */
+        if (pWhalBus->uChipId == CHIP_ID_1251_PG10 ||
+            pWhalBus->uChipId == CHIP_ID_1251_PG11)
+        {
+            /* Do nothing */
+        }
+
+        /* PG 1.2: Enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */
+        else
+        {
+                       pWhalBus->uElpCmd |= 0x00000040;    
+
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          ELP_CMD/*0x5808*/, 
+                                          pWhalBus->uElpCmd,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                          hWhalBus);
+            EXCEPT_I (pWhalBus, status);
+        }
+
+
+    case 6:
+        pWhalBus->uInitSeqStage ++;
+
+        /* PG 1.1 & 1.0: set the BB PLL stable time to be 30usec (PLL_STABLE_TIME) */
+        if (pWhalBus->uChipId == CHIP_ID_1251_PG10 ||
+            pWhalBus->uChipId == CHIP_ID_1251_PG11)
+        {
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          CFG_PLL_SYNC_CNT/*0x5820*/, 
+                                          0x00,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                          hWhalBus);
+        }
+
+        /* PG 1.2: Set the BB PLL stable time to be 1000usec (PLL_STABLE_TIME) */
+        else
+        {
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          CFG_PLL_SYNC_CNT/*0x5820*/, 
+                                          0x20,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                          hWhalBus);
+        }
+
+        EXCEPT_I (pWhalBus, status);
+
+    case 7:
+        pWhalBus->uInitSeqStage ++;
+
+        /* PG 1.1 & 1.0 */
+        if (pWhalBus->uChipId == CHIP_ID_1251_PG10 ||
+            pWhalBus->uChipId == CHIP_ID_1251_PG11)
+        {
+            /* Do nothing */
+        }
+
+        /* PG 1.2: read clock request time */
+        else
+        {
+            status = TNETWIF_ReadRegOpt (pWhalBus->hTNETWIF, 
+                                         CLK_REQ_TIME/*0x5814*/, 
+                                         &pWhalBus->uInitData,
+                                         module_id,
+                                         (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                         hWhalBus);
+            EXCEPT_I (pWhalBus, status);
+        }
+
+    case 8:
+        pWhalBus->uInitSeqStage ++;
+
+        /* PG 1.1 & 1.0 */
+        if (pWhalBus->uChipId == CHIP_ID_1251_PG10 ||
+            pWhalBus->uChipId == CHIP_ID_1251_PG11)
+        {
+            /* Do nothing */
+        }
+
+        /* PG 1.2: set the clock request time to be [ref_clk_settling_time-1mS] 4ms */
+        else
+        {
+                       WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, 
+                               ("CLK_REQ_TIME: read = 0x%x write = 0x%x\n", 
+                               pWhalBus->uInitData,((pWhalBus->uInitData > 0x21) ? (pWhalBus->uInitData - 0x21) : 0 )));
+
+            status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                          CLK_REQ_TIME/*0x5814*/, 
+                                          ((pWhalBus->uInitData > 0x21) ? (pWhalBus->uInitData - 0x21) : 0 ),
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                          hWhalBus);
+            EXCEPT_I (pWhalBus, status);
+        }
+
+    case 9:
+        pWhalBus->uInitSeqStage ++;
+
+        /******************** Set BB PLL configurations in RF AFE *********************/
+
+        /*
+         * Set RF_AFE_REG_3
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x58CC, 
+                                      0x4B5, 
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 10:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set RF_AFE_REG_5
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x58D4, 
+                                      0x50/*0x150*/,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 11:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set RF_AFE_CTRL_REG_2
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x5948, 
+                                      0x11C001,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 12:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Change RF PLL and BB PLL divider for VCO clock  and adjust VCO bais current(RF_AFE_REG_13)
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x58F4, 
+                                      0x1E,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 13:
+        pWhalBus->uInitSeqStage ++;
+
+        /******************** Set BB PLL configurations *********************/
+    
+        /*
+         * Set integer divider according to Appendix C-BB PLL Calculations. 
+         * &
+         * Set dither scale to 0.
+         * &
+         * Enable complex zero
+         * &
+         * Set the location of complex zero
+         * &
+         * Set the order of the sigma delta to 2nd order
+         * &
+         *Disable the async load
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x5840, 
+                                      LUT[pWhalBus->uRefFreq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 14:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set fractional divider according to Appendix C-BB PLL Calculations
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x5844, 
+                                      LUT[pWhalBus->uRefFreq][LUT_PARAM_FRACTIONAL_DIVIDER],
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 15:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set the initial data for the sigma delta
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x5848, 
+                                      0x3039,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 16:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set the accumulator attenuation value
+         * &
+         * Set calibration loop1 (alpha)
+         * &
+         * Set calibration loop2 (beta)
+         * &
+         * Set calibration loop3 (gamma)
+         * &
+         * Set the VCO gain
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x5854, 
+                                      (LUT[pWhalBus->uRefFreq][LUT_PARAM_ATTN_BB] << 16) | (LUT[pWhalBus->uRefFreq][LUT_PARAM_ALPHA_BB] << 12) | 0x1,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 17:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set the calibration stop time after holdoff time expires
+         * &
+         * Set settling time HOLD_OFF_TIME_BB
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x5858, 
+                                      LUT[pWhalBus->uRefFreq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 18:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set BB PLL Loop filter capacitor3- BB_C3[2:0]
+         * &
+         * Set BB PLL constant leakage current to linearize PFD to 0uA- BB_ILOOPF[7:3]
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x58F8, 
+                                      LUT[pWhalBus->uRefFreq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 19:
+        pWhalBus->uInitSeqStage ++;
+
+        /*
+         * Set regulator output voltage for n divider to 1.35- BB_REFDIV[1:0]
+         * &
+         * Set Charge pump current- BB_CPGAIN[4:2]
+         * &
+         * Set BB PLL Loop filter capacitor2- BB_C2[7:5]
+         * &
+         * Set gain of BB PLL auto-call to normal mode- BB_CALGAIN_3DB[8]
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      0x58F0, 
+                                      0x29,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 20:
+        pWhalBus->uInitSeqStage ++;
+
+        /******************** Enable restart sequence *********************/
+    
+        /*
+         * Enable restart wakeup sequence (ELP_CMD[0])
+         */
+        status = TNETWIF_WriteRegOpt (pWhalBus->hTNETWIF, 
+                                      ELP_CMD/*0x5808*/, 
+                                      pWhalBus->uElpCmd | 0x1,
+                                      module_id,
+                                      (TNETWIF_callback_t)whal_FwCtrl_InitSequenceSm,
+                                      hWhalBus);
+        EXCEPT_I (pWhalBus, status);
+
+    case 21:      
+        pWhalBus->uInitSeqStage = 0;
+
+        os_StalluSec (pWhalBus->hOs, 2000);
+
+        WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, ("End INIT sequence\n"));            
+
+        /* Call upper layer state machine */ 
+        if (pWhalBus->uInitSeqStatus == TNETWIF_PENDING)
+            whal_FwCtrl_BootSm (hWhalBus, module_id, OK);
+
+    } /* End switch */
+
+    return TNETWIF_COMPLETE;
+}
+
+
+/****************************************************************************
+ *                      whal_FwCtrl_LoadFwImageSm()
+ ****************************************************************************
+ * DESCRIPTION: Load image from the host and download into the hardware 
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+
+#define ADDR_OFFS HW_ACCESS_DOWN_PART0_ADDR
+
+
+static TI_STATUS whal_FwCtrl_LoadFwImageSm (TI_HANDLE hWhalBus, UINT8 module_id, TI_STATUS status)
+{
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    EXCEPT_L (pWhalBus, status);
+
+    while (TRUE)
+    {
+        switch (pWhalBus->uLoadStage)
+        {
+        case 0:
+            pWhalBus->uLoadStage = 1; 
+            /* 
+             * Extract and calculate a length of the firmware image
+             * Needed to avoid DWORD alignment issues          
+             * Get the data length of the firmware image             
+             */ 
+            pWhalBus->uFwDataLen = (pWhalBus->pFwBuf[4] << 24) |
+                                   (pWhalBus->pFwBuf[5] << 16) |
+                                   (pWhalBus->pFwBuf[6] << 8 ) |
+                                   (pWhalBus->pFwBuf[7]);
+
+            /* Check the data length */
+            if ((pWhalBus->uFwDataLen % 4) != 0)
+            {
+                WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG, ("FW image length\n")); 
+            
+            }
+
+          #if defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI)
+            status = TNETWIF_SetPartitionsOpt (pWhalBus->hTNETWIF, 
+                                               HW_ACCESS_DOWNLOAD, 
+                                               ADDR_OFFS,
+                                               module_id,
+                                               (TNETWIF_callback_t)whal_FwCtrl_LoadFwImageSm,
+                                               hWhalBus);
+            EXCEPT_L (pWhalBus, status);
+          #endif
+            continue;
+
+        case 1:
+            pWhalBus->uLoadStage = 2;
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG,
+                              ("Image addr=0x%x, Len=0x%x\n", 
+                              pWhalBus->pFwBuf, pWhalBus->uFwLastAddr));
+       
+            pWhalBus->uChunkNum = 0;
+            pWhalBus->uPartitionLimit = HW_ACCESS_DOWN_PART0_SIZE;
+
+            WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG, ("DOWNLOADING !!!\n"));
+            continue;
+                    
+        case 2:
+
+            /* Retrieve the data that was saved for the last chunk */
+          #ifdef USE_NO_CHUNK_COPY
+            if (pWhalBus->uChunkNum > 0)
+                os_memoryCopy (pWhalBus->hOs,
+                               (void *)(pWhalBus->pFwBuf + FW_HDR_SIZE + (pWhalBus->uChunkNum - 1) * CHUNK_SIZE - TNETWIF_WRITE_OFFSET_BYTES),
+                               (void *)pWhalBus->auFwTmpBuf,
+                               TNETWIF_WRITE_OFFSET_BYTES);
+          #endif
+
+            /* Load firmware by chunks */
+            if (pWhalBus->uChunkNum < pWhalBus->uFwDataLen / CHUNK_SIZE)
+            {            
+                pWhalBus->uLoadStage = 3;
+
+              #if defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI)
+                /* Change partition */
+                if (ADDR_OFFS + (pWhalBus->uChunkNum + 2) * CHUNK_SIZE > pWhalBus->uPartitionLimit)
+                {                
+                    pWhalBus->uPartitionLimit = (ADDR_OFFS + pWhalBus->uChunkNum * CHUNK_SIZE) + HW_ACCESS_DOWN_PART0_SIZE;
+                    status = TNETWIF_SetPartitionsOpt (pWhalBus->hTNETWIF, 
+                                                       HW_ACCESS_DOWNLOAD, 
+                                                       ADDR_OFFS + pWhalBus->uChunkNum * CHUNK_SIZE,
+                                                       module_id,
+                                                       (TNETWIF_callback_t)whal_FwCtrl_LoadFwImageSm,
+                                                       hWhalBus);
+                    EXCEPT_L (pWhalBus, status);
+                                                     
+                    WLAN_REPORT_INIT (pWhalBus->hReport, HAL_CTRL_MODULE_LOG,
+                                      ("Change partition ADDR_OFFS = 0x%x\n", 
+                                      ADDR_OFFS + pWhalBus->uChunkNum * CHUNK_SIZE));
+                }
+              #endif
+            }
+            else
+                pWhalBus->uLoadStage = 4;
+            continue;
+
+        case 3:        
+            pWhalBus->uLoadStage = 2;
+
+            /* Write the data chunk of 512 bytes */
+
+          #ifdef USE_NO_CHUNK_COPY
+            /* 
+             * Save the chunk trailer bytes in the temporary buffer.
+             * The trailer space is used by the WSPI driver 
+             */
+            os_memoryCopy (pWhalBus->hOs,
+                           (void *)pWhalBus->auFwTmpBuf,
+                           (void *)(pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE - TNETWIF_WRITE_OFFSET_BYTES),
+                           TNETWIF_WRITE_OFFSET_BYTES);
+          #else
+            /* Copy image chunk to temporary buffer */
+            os_memoryCopy (pWhalBus->hOs,
+                           (void *)&pWhalBus->auFwTmpBuf[TNETWIF_WRITE_OFFSET_BYTES],
+                           (void *)(pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE),
+                           CHUNK_SIZE);
+          #endif 
+            
+            /* Load the chunk. Save TNETWIF_WRITE_OFFSET_BYTES space for WSPI bus command */
+            status = TNETWIF_WriteMemOpt (pWhalBus->hTNETWIF, 
+                                          ADDR_OFFS + pWhalBus->uChunkNum * CHUNK_SIZE,
+                                        #ifdef USE_NO_CHUNK_COPY
+                                          pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE - TNETWIF_WRITE_OFFSET_BYTES,
+                                        #else 
+                                          pWhalBus->auFwTmpBuf,
+                                        #endif
+                                          CHUNK_SIZE,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_LoadFwImageSm,
+                                          hWhalBus);
+
+            /* Increment chunk number */
+            pWhalBus->uChunkNum ++;
+
+            /* Log ERROR if the TNETWIF_WriteMemOpt returned ERROR */
+            if (status == TNETWIF_ERROR)
+            {
+                WLAN_REPORT_ERROR (pWhalBus->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                   ("TNETWIF_WriteMemOpt retruned status=0x%x\n", status));
+            } 
+
+            EXCEPT_L (pWhalBus, status);
+            continue;
+
+        case 4:    
+            pWhalBus->uLoadStage = 5;
+
+          #ifdef USE_NO_CHUNK_COPY
+            /* 
+             * Save the chunk trailer bytes in the temporary buffer.
+             * The trailer space is used by the WSPI driver 
+             */
+            os_memoryCopy (pWhalBus->hOs,
+                           (void *)pWhalBus->auFwTmpBuf,
+                           (void *)(pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE - TNETWIF_WRITE_OFFSET_BYTES),
+                           TNETWIF_WRITE_OFFSET_BYTES);
+          #else
+            /* Copy the last image chunk */
+            os_memoryCopy (pWhalBus->hOs,
+                           (void *)&pWhalBus->auFwTmpBuf[TNETWIF_WRITE_OFFSET_BYTES],
+                           (void *)(pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE),
+                           pWhalBus->uFwDataLen % CHUNK_SIZE);
+          #endif
+
+            /* Load the last chunk */
+            status = TNETWIF_WriteMemOpt (pWhalBus->hTNETWIF, 
+                                          ADDR_OFFS + pWhalBus->uChunkNum * CHUNK_SIZE,
+                                        #ifdef USE_NO_CHUNK_COPY
+                                          pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE - TNETWIF_WRITE_OFFSET_BYTES, 
+                                        #else
+                                          pWhalBus->auFwTmpBuf,
+                                        #endif
+                                          pWhalBus->uFwDataLen % CHUNK_SIZE,
+                                          module_id,
+                                          (TNETWIF_callback_t)whal_FwCtrl_LoadFwImageSm,
+                                          hWhalBus); 
+
+            EXCEPT_L (pWhalBus, status);
+            continue;
+
+        case 5:
+            pWhalBus->uLoadStage = 0;
+
+            /* The download has completed */ 
+            WLAN_OS_REPORT (("Finished downloading firmware.\n"));
+
+          #ifdef USE_NO_CHUNK_COPY
+            /* Retrieve the data that was saved for the last chunk */
+            os_memoryCopy (pWhalBus->hOs,
+                           (void *)(pWhalBus->pFwBuf + FW_HDR_SIZE + pWhalBus->uChunkNum * CHUNK_SIZE - TNETWIF_WRITE_OFFSET_BYTES),
+                           (void *)pWhalBus->auFwTmpBuf,
+                           TNETWIF_WRITE_OFFSET_BYTES);
+          #endif
+
+            /* Finalize download (run firmware) */
+            pWhalBus->uFinStage = 0;
+            status = whal_FwCtrl_FinalizeDownloadSm (hWhalBus, module_id, OK);
+
+            return status;
+
+        } /* End switch */
+
+    } /* End while */
+        
+}
+
+
+UINT32 whalBus_FwCtrl_GetRadioStandByState(TI_HANDLE hWhalBus)
+{
+  #ifdef USE_SYNC_API
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    UINT32     data;
+    
+    return TNETWIF_ReadRegSync (pWhalBus->hTNETWIF,GPIO_IN,&data);
+    
+  #else
+
+    return 0;
+
+  #endif
+}
+
+
+int whalBus_FwCtrl_Reset(TI_HANDLE hWhalBus)
+{   
+  #ifdef USE_SYNC_API
+
+    return whal_FwCtrl_Reset (hWhalBus);
+
+  #else
+
+    return OK;
+
+  #endif
+}
+
+
+int whalBus_FwCtrl_isCardIn(TI_HANDLE hWhalBus)
+{   
+  #ifdef USE_SYNC_API
+
+    /*
+    UINT32 ChipId;
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+    TNETWIF_ReadRegSync(pWhalBus->hTNETWIF,CHIP_ID,&ChipId)
+    ChipId = CHIP_ID_1X50;
+    */
+
+  #endif
+        
+    return TRUE;
+}
+
+void whalBus_FwCtrl_Halt(TI_HANDLE hWhalBus)
+{
+  #ifdef USE_SYNC_API
+    whalBus_T *pWhalBus = (whalBus_T *)hWhalBus;
+
+    /* Halt the firmware */
+    TNETWIF_RegIsBitSet(pWhalBus->hTNETWIF, ACX_REG_ECPU_CONTROL, ECPU_CONTROL_HALT);
+  #endif
+}
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmFwCtrl.h b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmFwCtrl.h
new file mode 100644 (file)
index 0000000..316c043
--- /dev/null
@@ -0,0 +1,121 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  ShmFwCtrl.h
+ *   PURPOSE: Firmware control  object
+ *
+ ****************************************************************************/
+
+#ifndef _SHM_FW_CTRL_H
+#define _SHM_FW_CTRL_H
+
+#define REF_FREQ_19_2                       0
+#define REF_FREQ_26_0                       1
+#define REF_FREQ_38_4                       2
+#define REF_FREQ_40_0                       3
+#define REF_FREQ_33_6                       4
+#define REF_FREQ_NUM                        5
+
+#define LUT_PARAM_INTEGER_DIVIDER           0
+#define LUT_PARAM_FRACTIONAL_DIVIDER        1
+#define LUT_PARAM_ATTN_BB                   2
+#define LUT_PARAM_ALPHA_BB                  3
+#define LUT_PARAM_STOP_TIME_BB              4
+#define LUT_PARAM_BB_PLL_LOOP_FILTER        5
+#define LUT_PARAM_NUM                       6
+
+#define ACX_EEPROMLESS_IND_REG              (SCR_PAD4)
+#define USE_EEPROM                          0
+#define SOFT_RESET_MAX_TIME                 1000000
+#define SOFT_RESET_STALL_TIME               1000
+#define NVS_DATA_BUNDARY_ALIGNMENT          4
+
+#define SHMFWCTRL_XTAL_USED                 0x3 
+#define SHMFWCTRL_XTAL_CLK_REQ_TIME         0x3E
+
+#define SHMFWCTRL_SCRPAD6_REF_FREQ_MASK 0x000000FF
+#define SHMFWCTRL_SCRPAD6_CLK_TYPE             0x0000FF00
+#define SHMFWCTRL_PLL_CAL_TIME                         0x5810
+#define SHMFWCTRL_PLL_CAL_TIME_VAL             0x9
+#define SHMFWCTRL_CLK_REQ_TIME                 0x5814
+#define SHMFWCTRL_CLK_BUF_TIME                 0x5818
+#define SHMFWCTRL_CLK_BUF_TIME_VAL             0x6
+#define SHMFWCTRL_PLL_STABLE_TIME              0x5820
+#define SHMFWCTRL_PLL_STABLE_TIME_VAL  0x0
+#define SHMFWCTRL_ELP_CFG_MODE                 0x5804
+#define SHMFWCTRL_ELP_CFG_MODE_CLK_DETECT      0x00004000
+#define SHMFWCTRL_RF_AFE_REG_3                 0x58CC
+#define SHMFWCTRL_RF_AFE_REG_3_VAL             0x4B5
+#define SHMFWCTRL_RF_AFE_REG_5                 0x58D4
+#define SHMFWCTRL_RF_AFE_REG_5_VAL             0x50
+#define SHMFWCTRL_RF_AFE_CTRL_REG_2            0x5948
+#define SHMFWCTRL_RF_AFE_CTRL_REG_2_VAL        0x11C001
+#define SHMFWCTRL_RF_AFE_REG_13                        0x58F4
+#define SHMFWCTRL_RF_AFE_REG_13_VAL            0x1E
+
+#define SHMFWCTRL_PLL_BB_REG_0                 0x5840
+#define SHMFWCTRL_PLL_BB_REG_0_VAL             0x00017000
+
+#define SHMFWCTRL_PLL_BB_REG_1                 0x5844
+
+#define SHMFWCTRL_PLL_BB_REG_2                 0x5848
+#define SHMFWCTRL_PLL_BB_REG_2_VAL             0x3039
+
+#define SHMFWCTRL_PLL_BB_REG_5                         0x5854
+#define SHMFWCTRL_PLL_BB_REG_5_VAL             0x1
+
+#define SHMFWCTRL_PLL_BB_REG_6                         0x5858
+#define SHMFWCTRL_PLL_BB_REG_6_VAL             0x000A0000
+
+#define SHMFWCTRL_RF_AFE_REG_14                        0x58F8
+#define SHMFWCTRL_RF_AFE_REG_14_VAL            0x00000030
+
+#define SHMFWCTRL_RF_AFE_REG_12                        0x58F0
+#define SHMFWCTRL_RF_AFE_REG_12_VAL            0x29
+
+#define SHMFWCTRL_ELP_CMD                                      0x5808
+#define SHMFWCTRL_ELP_CMD_VAL                  0x1
+
+#define SHMFWCTRL_XTAL_CLK_REQ_TIME_SHORT 0x3E
+#define SHMFWCTRL_XTAL_CLK_REQ_TIME_LONG 0xA4
+
+/************************************************************************
+ * external Functions
+ ************************************************************************/
+
+
+#endif /* _SHM_FW_CTRL_H */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmUtils.c b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmUtils.c
new file mode 100644 (file)
index 0000000..11cc5b3
--- /dev/null
@@ -0,0 +1,76 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  shmUtils.c
+ *   PURPOSE: shared memory bus access utilities
+ *
+ ****************************************************************************/
+#include "shmUtils.h"
+
+int busUtils_MacAddrCompare(char *Mac1, char *Mac2)
+{
+       register int MacSize=6;
+
+       while(MacSize--)
+               if (*Mac1++ != *Mac2++)
+                       return NOK;
+       return OK;
+}
+
+int busUtils_MacAddrCopy(char *Mac2, char *Mac1)
+{
+       register int MacSize=6;
+
+       while(MacSize--)
+               *Mac2++ = *Mac1++;
+       return OK;
+}
+
+void busUtils_PrintBuf(TI_HANDLE hReport, UINT8 *StrHead, UINT8 *pBuf, int Len)
+{
+       int i;
+
+       WLAN_OS_REPORT(("%s========================================\n", StrHead));
+
+       for (i=0; i<Len; i+=8, pBuf+=8)
+       {
+               WLAN_OS_REPORT(("whal_ParamsUtils_PrintBuf: %04x: %02x %02x %02x %02x %02x %02x %02x %02x\n", 
+                               i, pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7]));
+       }
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmUtils.h b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/shmUtils.h
new file mode 100644 (file)
index 0000000..e29e00d
--- /dev/null
@@ -0,0 +1,54 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  shmUtils.h
+ *   PURPOSE: shared memory component utilitis
+ *
+ ****************************************************************************/
+
+#ifndef _SHM_UTILS_H
+#define _SHM_UTILS_H
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "report.h"
+
+void busUtils_PrintBuf      (TI_HANDLE hReport, UINT8 *StrHead, UINT8 *pBuf, int Len);
+int  busUtils_MacAddrCompare(char *Mac1, char *Mac2);
+int  busUtils_MacAddrCopy   (char *Mac1, char *Mac2);
+
+#endif /* _SHM_UTILS_H */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalHwEeprom.c b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalHwEeprom.c
new file mode 100644 (file)
index 0000000..a64d7e6
--- /dev/null
@@ -0,0 +1,577 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*   MODULE:  whalHwEeprom.c                                              */ 
+/*   PURPOSE: Wlan hardware EEPROM access routines implemenatation        */
+/*                                                                        */
+/**************************************************************************/
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "whalHwEeprom.h"
+#include "TNETWIF.h"
+
+
+/****************************************************************************
+ *                      whal_hwEeprom_Create()
+ ****************************************************************************
+ * DESCRIPTION:        Create the wlan hardware eeprom access object
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The Created object
+ ****************************************************************************/
+HwEeprom_T *whal_hwEeprom_Create(TI_HANDLE hOs)
+{
+       HwEeprom_T *pObj;
+
+       pObj = os_memoryAlloc(hOs, sizeof(HwEeprom_T));
+       if (pObj == NULL)
+               return NULL;
+
+       os_memoryZero(hOs, pObj, sizeof(HwEeprom_T));
+
+       pObj->hOs = hOs;
+
+       return(pObj);
+}
+
+/****************************************************************************
+ *                      whal_hwEeprom_Destroy()
+ ****************************************************************************
+ * DESCRIPTION:        Destroy the object 
+ * 
+ * INPUTS:     
+ *             pHwEeprom               The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwEeprom_Destroy(HwEeprom_T *pHwEeprom)
+{
+       if (pHwEeprom)
+               os_memoryFree(pHwEeprom->hOs, pHwEeprom, sizeof(HwEeprom_T));
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwEeprom_Config()
+ ****************************************************************************
+ * DESCRIPTION:        Config the object 
+ * 
+ * INPUTS:     
+ *             pHwEeprom               The object to free
+ *             hTNETWIF                hardware access object
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwEeprom_Config(HwEeprom_T *pHwEeprom, TI_HANDLE hTNETWIF, TI_HANDLE hReport)
+{
+       pHwEeprom->hReport = hReport;
+       pHwEeprom->hTNETWIF = hTNETWIF;
+       return OK;
+}
+
+#ifdef USE_SYNC_API 
+/************************************************************************
+*        UINT32 whal_hwEepromReadByte(UINT16 wAddr,UINT8 *pbVal)       *
+*************************************************************************
+* DESCRIPTION:  Reads a single byte from EEPROM.                        *
+*                                                                       *
+* INPUT:        wAddr - 16-bits EEPROM addrress                         *
+*               pbVal - pointer the to output parameter - EEPROM value  *     
+*                                                                       *
+* OUTPUT:       *pbVal contains EEPROM value                            *   
+*                                                                       *
+* RETURN:       OK - successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromReadByte(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 *pbVal)
+{
+       UINT32 data;   
+       int i = 0x00;
+   
+
+    wAddr &= 0x07ff;
+    TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_EE_ADDR_REG,(UINT32)wAddr);
+    TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_EE_CTL_REG, EE_READ);
+    while((TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,ACX_EE_CTL_REG,&data) & EE_READ) != 0x00)
+    {
+        if(i++ > EEPROM_ACCESS_TO)
+        {
+            return NOK; /* timeout */
+        }
+    }
+    *pbVal = TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,ACX_EE_DATA_REG,&data) & 0xff;
+    return OK;
+}
+
+/************************************************************************
+*      UINT32 whal_hwEepromWriteByteNoUnp(UINT16 wAddr,UINT8 bVal)     *
+*************************************************************************
+* DESCRIPTION:  Writes a single byte to EEPROM                          *  
+*                                                                       *
+* INPUT:        wAddr - 16-bits EEPROM addrress                         *
+*               bVal  - new value                                       *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK - successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromWriteByteNoUnp(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 bVal)
+{
+   volatile int i=0;
+   UINT32 data;
+
+   wAddr &= 0x07ff;
+   TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_EE_ADDR_REG,(UINT32)wAddr);
+   TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_EE_DATA_REG,bVal);
+   TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_EE_CTL_REG, EE_WRITE);
+   while((TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,ACX_EE_CTL_REG,&data)& EE_WRITE) != 0x00)
+   {
+               volatile int y=0;
+
+       for( ; y<100; y++) {}
+      if(i++ > EEPROM_ACCESS_TO)
+      {
+          return NOK; /* timeout */
+      }
+   }
+
+   return OK;
+}
+
+/************************************************************************
+*           void whal_hwEepromProtect(void)                            *
+*************************************************************************
+* DESCRIPTION:  Set EEPROM write protection.                            *
+*               Inhibits writing to the EEPROM.                         *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       N/A                                                     *
+*************************************************************************/
+void whal_hwEepromProtect(HwEeprom_T *pHwEeprom)
+{
+   /* Set up write protect. Should be according to board type and SW patch
+      rather than according to Hardware EEPROM
+   */
+       TNETWIF_RegIsBitSet(pHwEeprom->hTNETWIF, ACX_GPIO_OUT_REG, 1ul << 9);
+}
+
+/************************************************************************
+*           void whal_hwEepromUnprotect(void)                          *
+*************************************************************************
+* DESCRIPTION:  Remove EEPROM write protection.                         *
+*               Enables writing to the EEPROM.                          *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       N/A                                                     *
+*************************************************************************/
+void whal_hwEepromUnprotect(HwEeprom_T *pHwEeprom)
+{
+    /* Turn off write protect. Should be according to board type and SW patch
+      rather than according to Hardware EEPROM
+   */
+       TNETWIF_RegResetBitVal(pHwEeprom->hTNETWIF, ACX_GPIO_OUT_REG, 1ul << 9);
+}
+
+/************************************************************************
+*          UINT32 whal_hwEepromWriteByte(UINT16 wAddr,UINT8 bVal)      *
+*************************************************************************
+* DESCRIPTION:  Writes a single byte to EEPROM                          *  
+*                                                                       *
+* INPUT:        wAddr - 16-bits EEPROM addrress                         *
+*               bVal  - new value                                       *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK - successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromWriteByte(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 bVal)
+{
+       UINT32 retCode;
+       
+   whal_hwEepromUnprotect(pHwEeprom);
+       os_StalluSec(pHwEeprom->hOs, 100000);
+       retCode = whal_hwEepromWriteByteNoUnp(pHwEeprom, wAddr, bVal);
+       os_StalluSec(pHwEeprom->hOs, 100000);
+       whal_hwEepromProtect(pHwEeprom);
+   return retCode;
+}
+
+/************************************************************************
+*           UINT32 whal_hwEepromGetCalValue(UINT8 *pbVal)              *
+*************************************************************************
+* DESCRIPTION:  Reads oscillator cal. value from EEPROM                 *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       pbVal - pointer to the output parameter                 *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromGetCalValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal)
+{
+    return whal_hwEepromReadByte(pHwEeprom, HW_EEPROM_OSC_ADDR,pbVal);
+}
+
+/************************************************************************
+*           UINT32 whal_hwEepromSetCalValue(UINT8 bVal)                *
+*************************************************************************
+* DESCRIPTION:  Writes new oscillator cal. value to EEPROM              *
+*                                                                       *
+* INPUT:        bVal - new oscillator cal. value                        *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout or invalid value                           *
+*************************************************************************/
+UINT32 whal_hwEepromSetCalValue(HwEeprom_T *pHwEeprom, UINT8 bVal)
+{
+   if(bVal > MAX_OSC_CAL)
+   {
+      return NOK;       
+   }
+   
+   return whal_hwEepromWriteByte(pHwEeprom, HW_EEPROM_OSC_ADDR,bVal);
+}
+
+/************************************************************************
+*           UINT32 whal_hwEepromGetBiasValue(UINT8 *pbVal)             *
+*************************************************************************
+* DESCRIPTION:  Reads bias value from EEPROM                            *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       pbVal - pointer to the output parameter                 *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromGetBiasValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal)
+{
+    return whal_hwEepromReadByte(pHwEeprom, HW_EEPROM_BIAS_ADDR,pbVal);
+}
+
+/************************************************************************
+*           UINT32 whal_hwEepromSetBiasValue(UINT8 bVal)               *
+*************************************************************************
+* DESCRIPTION:  Writes new bias value to EEPROM                         *
+*                                                                       *
+* INPUT:        bVal - new bias value                                   *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromSetBiasValue(HwEeprom_T *pHwEeprom, UINT8 bVal)
+{
+    return whal_hwEepromWriteByte(pHwEeprom, HW_EEPROM_BIAS_ADDR,bVal);
+}
+
+/************************************************************************
+*           UINT32 whal_hwEepromGetDACValue(UINT8 *pbVal)              *
+*************************************************************************
+* DESCRIPTION:  Reads DAC value from EEPROM                             *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       pbVal - pointer to the output parameter                 *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromGetDACValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal)
+{
+    return whal_hwEepromReadByte(pHwEeprom, HW_EEPROM_DAC_ADDR,pbVal);
+}
+
+/************************************************************************
+*           UINT32 whal_hwEepromSetDACValue(UINT8 bVal)                *
+*************************************************************************
+* DESCRIPTION:  Writes new DAC value to EEPROM                          *
+*                                                                       *
+* INPUT:        bVal - new DAC value                                    *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromSetDACValue(HwEeprom_T *pHwEeprom, UINT8 bVal)
+{
+    return whal_hwEepromWriteByte(pHwEeprom, HW_EEPROM_DAC_ADDR,bVal);
+}
+
+/************************************************************************
+*           int whal_hwEepromLoadBaseBandTable(void)                   *
+*************************************************************************
+* DESCRIPTION:  Loads BB registers table from EEPROM                    *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       N/A                                                     *
+*************************************************************************/
+int whal_hwEepromLoadBaseBandTable(HwEeprom_T *pHwEeprom)
+{
+   UINT8   bRegVal;
+   UINT16  wTableAddress;
+   UINT8   bNumberOfEntries;  
+   UINT16  wTableEnd;
+   UINT8   bEntrySize; 
+   UINT8   bbAddr;
+   UINT8   bbData;
+   int addr;
+
+   if(whal_hwEepromReadByte(pHwEeprom, 0x14a,&bRegVal) != OK)
+   {
+               return NOK;
+   }
+   
+   wTableAddress = bRegVal;
+   
+   if(whal_hwEepromReadByte(pHwEeprom, 0x14b,&bRegVal) != OK)
+   {
+               return NOK;
+   }
+   
+   wTableAddress |= bRegVal << 8;
+
+   if(whal_hwEepromReadByte(pHwEeprom, wTableAddress,&bRegVal) != OK)
+   {
+   }
+   
+   bNumberOfEntries = bRegVal;
+
+   if(whal_hwEepromReadByte(pHwEeprom, (UINT16)(wTableAddress+1),&bRegVal) != OK)
+   {
+      return NOK;
+   }
+
+   bEntrySize = bRegVal;
+   
+       WLAN_REPORT_INFORMATION(pHwEeprom->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("\tTable Address: 0x%x\n\tNumber of elements: 0x%x\n\tEntry Size: 0x%x\n",
+                        wTableAddress,bNumberOfEntries,bEntrySize));
+
+
+   wTableEnd = wTableAddress + (bEntrySize * (bNumberOfEntries + 1));
+   
+   for(addr = wTableAddress + 2; addr < wTableEnd; addr+= bEntrySize)
+   {
+      if(whal_hwEepromReadByte(pHwEeprom, (UINT16)addr,&bbAddr)!= OK)
+      {
+                       return NOK;         
+      }                        
+   
+      if(whal_hwEepromReadByte(pHwEeprom, (UINT16)(addr+1),&bbData)!= OK)
+      {
+         return NOK;         
+      }
+
+      /*
+      whal_hwWritePHYReg(bbAddr,bbData);
+      -- the follwing 3 statements do the same thing
+      */
+          TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_PHY_ADDR_REG, bbAddr);
+          TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_PHY_DATA_REG, bbData);
+          TNETWIF_WriteRegSync(pHwEeprom->hTNETWIF, ACX_PHY_CTRL_REG, 1 /* write */);
+   }
+   return OK;
+}/* END whal_hwEepromLoadBaseBandTable() */
+
+/************************************************************************
+*   UINT32 whal_hwEepromGetAGCCell(UINT8 bTableOffset, UINT8 *pbVal)   *
+*************************************************************************
+* DESCRIPTION:  Reads one cell from ACG table                           *
+*                                                                       *
+* INPUT:        bTableOffset - zero-based offset of the cell in AGC     *   
+*                              table                                    *
+* OUTPUT:       pbVal - pointer to the output parameter                 *       
+*                                                                       *
+* RETURN:       OK                                                      *
+*               NOK - EEPROM write error                                *
+*               INVALID_PARAMETER1 - invalid parameter 1                *  
+*************************************************************************/
+UINT32 whal_hwEepromGetAGCCell(HwEeprom_T *pHwEeprom, UINT8 bTableOffset, UINT8 *pbVal)
+{
+    if(bTableOffset > MAX_AGC_TABLE_ENTRIES)
+    {
+        *pbVal = 0x00;
+        return (UINT32)INVALID_PARAMETER1;
+    }
+
+    return whal_hwEepromReadByte(pHwEeprom, (UINT16)(HW_EEPROM_AGC_TABLE_ADDR+bTableOffset),pbVal);
+}
+/************************************************************************
+*   UINT32 whal_hwEepromSetAGCCell(UINT8 bTableOffset, UINT8 bVal)     *
+*************************************************************************
+* DESCRIPTION:  Writes one AGC table cell to EEPROM                     *
+*                                                                       *
+* INPUT:        bTableOffset - zero-based offset of the cell in AGC     *   
+*                              table                                    *
+*               bVal         - new cell value                           *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK                                                      *
+*               NOK - EEPROM write error                                *
+*               INVALID_PARAMETER1 - invalid parameter 1                *  
+*************************************************************************/
+UINT32 whal_hwEepromSetAGCCell(HwEeprom_T *pHwEeprom, UINT8 bTableOffset, UINT8 bVal)
+{
+    if(bTableOffset > MAX_AGC_TABLE_ENTRIES)
+    {
+        return (UINT32)INVALID_PARAMETER1;
+    }
+
+    return whal_hwEepromWriteByte(pHwEeprom, (UINT16)(HW_EEPROM_AGC_TABLE_ADDR+bTableOffset), bVal);
+} 
+
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetRadioTypeAndEEPROMversion()
+ ****************************************************************************
+ * DESCRIPTION:        
+ * 
+ * INPUTS:  None       
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwEeprom_GetRadioTypeAndEEPROMversion(HwEeprom_T *pHwEeprom, UINT32 *major, UINT32 *minor, UINT32 *bugfix)
+{
+       /*volatile */
+UINT32    radioType;
+
+       /*volatile */
+UINT32 eectl;
+       /* 
+        * Read major eeprom version - offset 5
+        */
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_ADDR, 5);
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_CTL,  0x2);
+       do 
+       {
+               TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_CTL,&eectl);
+               if (eectl == 0xffffffff)
+                       return -1;
+       } while (eectl &0x2); 
+       TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_DATA,major);
+       /* 
+        * Read minor eeprom version - offset 9 
+        */
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_ADDR, 9);
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_CTL,  0x2);
+       do 
+       {
+               TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_CTL,&eectl);
+               if (eectl == 0xffffffff)
+                       return -1;
+       } while (eectl &0x2); 
+       TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_DATA,minor);
+
+       /* 
+        * Read bugfix eeprom version - offset A 
+        */
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_ADDR, 0xA);
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_CTL,  0x2);
+       do 
+       {
+               TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_CTL,&eectl);
+               if (eectl == 0xffffffff)
+                       return -1;
+       } while (eectl &0x2); 
+       TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_DATA,bugfix);
+       
+       /* 
+        * Read radio type - offset 4 
+        */
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_ADDR, 4);
+       TNETWIF_WriteRegSync( pHwEeprom->hTNETWIF, EE_CTL,  0x2);
+       do 
+       {
+               TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_CTL,&eectl);
+               if (eectl == 0xffffffff)
+                       return -1;
+       } while (eectl &0x2); 
+
+       TNETWIF_ReadRegSync(pHwEeprom->hTNETWIF,EE_DATA,&radioType);
+
+       return(int)radioType;
+}
+
+void whal_hwEeprom_DumpEEPROM(HwEeprom_T *pHwEeprom)
+{
+       UINT16 wAddr;
+       UINT8  bVal;
+
+       WLAN_REPORT_REPLY(pHwEeprom->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("Dump EEPROM contents:"));
+       for ( wAddr = 0; wAddr < 0x2ff; wAddr++)
+       {
+               if (whal_hwEepromReadByte(pHwEeprom, wAddr, &bVal) == OK)
+               {
+                       WLAN_REPORT_REPLY(pHwEeprom->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                                         ("\tEEPROM 0x%04X:\t0x%02X.\n", wAddr, bVal));
+               } else
+               {
+                       WLAN_REPORT_REPLY(pHwEeprom->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                                         ("\tERROR: timeout"));
+               }
+       }
+}
+
+#endif /* USE_SYNC_API */
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalHwEeprom.h b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalHwEeprom.h
new file mode 100644 (file)
index 0000000..68012e9
--- /dev/null
@@ -0,0 +1,300 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*   MODULE:  whalHwEeprom.h                                              */
+/*   PURPOSE: Wlan hardware EEPROM access routines implemenatation        */
+/*                                                                        */
+/**************************************************************************/
+#ifndef _WHAL_HW_EEPROM_H
+#define _WHAL_HW_EEPROM_H
+
+#include "whalCommon.h"
+#include "TNETWIF.h"
+
+typedef struct _HwEeprom_T
+{
+       TI_HANDLE  hTNETWIF;
+       TI_HANDLE  hOs;
+       TI_HANDLE  hReport;
+} HwEeprom_T;
+
+extern HwEeprom_T *whal_hwEeprom_Create(TI_HANDLE hOs);
+extern int whal_hwEeprom_Destroy(HwEeprom_T *pHwEeprom);
+extern int whal_hwEeprom_Config (HwEeprom_T *pHwEeprom, TI_HANDLE hTNETWIF, TI_HANDLE hReport);
+
+#ifdef USE_SYNC_API
+
+extern int whal_hwEeprom_GetRadioTypeAndEEPROMversion(HwEeprom_T *pHwEeprom, UINT32 *major, UINT32 *minor, UINT32 *bugfix);
+
+/****************************
+ Offsets of Wlan Hardware data 
+ ****************************/
+#define HW_EEPROM_AGC_TABLE_ADDR   0x18C
+#define HW_EEPROM_DAC_ADDR         0x20D
+#define HW_EEPROM_BIAS_ADDR        0x20E    
+#define HW_EEPROM_OSC_ADDR         0x215
+#define MAX_AGC_TABLE_ENTRIES       128
+
+/*******************
+ EEPROM access APIs
+ *******************/
+#define MAX_OSC_CAL         15
+#define EEPROM_ACCESS_TO    10000   /* timeout counter */
+#define INVALID_PARAMETER1      -101
+
+
+
+
+
+
+
+/************************************************************************
+*        UINT32 whal_hwEepromReadByte(UINT16 wAddr,UINT8 *pbVal)       *
+*************************************************************************
+* DESCRIPTION:  Reads a single byte from EEPROM.                        *
+*                                                                       *
+* INPUT:        wAddr - 16-bits EEPROM addrress                         *
+*               pbVal - pointer the to output parameter - EEPROM value  *     
+*                                                                       *
+* OUTPUT:       *pbVal contains EEPROM value                            *   
+*                                                                       *
+* RETURN:       OK - successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32   whal_hwEepromReadByte(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 *pbVal);
+
+/************************************************************************
+*       UINT32 whal_hwEepromWriteByte(UINT16 wAddr,UINT8 bVal)         *
+*************************************************************************
+* DESCRIPTION:  Writes a single byte to EEPROM                          *  
+*                                                                       *
+* INPUT:        wAddr - 16-bits EEPROM addrress                         *
+*               bVal  - new value                                       *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK - successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromWriteByte(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 bVal);
+
+/************************************************************************
+*     UINT32 whal_hwEepromWriteByteNoUnp(UINT16 wAddr,UINT8 bVal)      *
+*************************************************************************
+* DESCRIPTION:  Writes a single byte to EEPROM. The caller must         *
+*               unprotect the EEPROM first. This is done for fast       *
+*               programming of several data bytes.                      *
+*                                                                       *
+* INPUT:        wAddr - 16-bits EEPROM addrress                         *
+*               bVal  - new value                                       *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK - successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromWriteByteNoUnp(HwEeprom_T *pHwEeprom, UINT16 wAddr,UINT8 bVal);
+
+/************************************************************************
+*           void whal_hwEepromProtect(void)                            *
+*************************************************************************
+* DESCRIPTION:  Set EEPROM write protection.                            *
+*               Inhibits writing to the EEPROM.                         *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       N/A                                                     *
+*************************************************************************/
+void      whal_hwEepromProtect(HwEeprom_T *pHwEeprom);
+
+/************************************************************************
+*           void whal_hwEepromUnprotect(void)                          *
+*************************************************************************
+* DESCRIPTION:  Remove EEPROM write protection.                         *
+*               Enables writing to the EEPROM.                          *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       N/A                                                     *
+*************************************************************************/
+void      whal_hwEepromUnprotect(HwEeprom_T *pHwEeprom);
+
+/*************************
+ EEPROM data manipulation
+ *************************/
+
+/************************************************************************
+*           UINT32 whal_hwEepromGetCalValue(UINT8 *pbVal)              *
+*************************************************************************
+* DESCRIPTION:  Reads oscillator cal. value from EEPROM                 *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       pbVal - pointer to the output parameter                 *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromGetCalValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal);
+
+/************************************************************************
+*           UINT32 whal_hwEepromSetCalValue(UINT8 bVal)                *
+*************************************************************************
+* DESCRIPTION:  Writes new oscillator cal. value to EEPROM              *
+*                                                                       *
+* INPUT:        bVal - new oscillator cal. value                        *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout or invalid value                           *
+*************************************************************************/
+UINT32 whal_hwEepromSetCalValue(HwEeprom_T *pHwEeprom, UINT8 bVal);
+
+/************************************************************************
+*           UINT32 whal_hwEepromGetBiasValue(UINT8 *pbVal)             *
+*************************************************************************
+* DESCRIPTION:  Reads bias value from EEPROM                            *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       pbVal - pointer to the output parameter                 *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromGetBiasValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal);
+
+/************************************************************************
+*           UINT32 whal_hwEepromSetBiasValue(UINT8 bVal)               *
+*************************************************************************
+* DESCRIPTION:  Writes new bias value to EEPROM                         *
+*                                                                       *
+* INPUT:        bVal - new bias value                                   *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromSetBiasValue(HwEeprom_T *pHwEeprom, UINT8 bVal);
+
+/************************************************************************
+*           UINT32 whal_hwEepromGetDACValue(UINT8 *pbVal)              *
+*************************************************************************
+* DESCRIPTION:  Reads DAC value from EEPROM                             *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       pbVal - pointer to the output parameter                 *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromGetDACValue(HwEeprom_T *pHwEeprom, UINT8 *pbVal);
+
+/************************************************************************
+*           UINT32 whal_hwEepromSetDACValue(UINT8 bVal)                *
+*************************************************************************
+* DESCRIPTION:  Writes new DAC value to EEPROM                          *
+*                                                                       *
+* INPUT:        bVal - new DAC value                                    *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK   successful                                         *
+*               NOK  timeout                                            *
+*************************************************************************/
+UINT32 whal_hwEepromSetDACValue(HwEeprom_T *pHwEeprom, UINT8 bVal);
+
+/************************************************************************
+*           int whal_hwEepromLoadBaseBandTable(void)                   *
+*************************************************************************
+* DESCRIPTION:  Loads BB registers table from EEPROM                    *
+*                                                                       *
+* INPUT:        N/A                                                     *
+*                                                                       *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       N/A                                                     *
+*************************************************************************/
+int            whal_hwEepromLoadBaseBandTable(HwEeprom_T *pHwEeprom);
+
+/************************************************************************
+*   UINT32 whal_hwEepromGetAGCCell(UINT8 bTableOffset, UINT8 *pbVal)   *
+*************************************************************************
+* DESCRIPTION:  Reads one cell from ACG table                           *
+*                                                                       *
+* INPUT:        bTableOffset - zero-based offset of the cell in AGC     *   
+*                              table                                    *
+* OUTPUT:       pbVal - pointer to the output parameter                 *       
+*                                                                       *
+* RETURN:       OK                                                      *
+*               NOK - EEPROM write error                                *
+*               INVALID_PARAMETER1 - invalid parameter 1                *  
+*************************************************************************/
+UINT32 whal_hwEepromGetAGCCell(HwEeprom_T *pHwEeprom, UINT8 bTableOffset, UINT8 *pbVal);
+
+/************************************************************************
+*   UINT32 whal_hwEepromSetAGCCell(UINT8 bTableOffset, UINT8 bVal)     *
+*************************************************************************
+* DESCRIPTION:  Writes one AGC table cell to EEPROM                     *
+*                                                                       *
+* INPUT:        bTableOffset - zero-based offset of the cell in AGC     *   
+*                              table                                    *
+*               bVal         - new cell value                           *
+* OUTPUT:       N/A                                                     *
+*                                                                       *
+* RETURN:       OK                                                      *
+*               NOK - EEPROM write error                                *
+*               INVALID_PARAMETER1 - invalid parameter 1                *  
+*************************************************************************/
+UINT32 whal_hwEepromSetAGCCell(HwEeprom_T *pHwEeprom, UINT8 bTableOffset, UINT8 bVal);
+
+
+void whal_hwEeprom_DumpEEPROM(HwEeprom_T *pHwEeprom);
+
+#endif /* USE_SYNC_API */
+
+
+#endif /* _WHAL_HW_EEPROM_H */
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalTrace.c b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalTrace.c
new file mode 100644 (file)
index 0000000..82f43a9
--- /dev/null
@@ -0,0 +1,293 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalTrace.c
+ *   PURPOSE: Trace on Rx/Tx packets
+ *   
+ ****************************************************************************/
+
+#include "whalCommon.h"
+#include "TNETWIF.h"
+#include "whalTrace.h"
+
+
+#define SEQUNCE_TRACE          
+
+#define TRACE_INTERRUPT                0x0001  /* Trace the recieved interupt only */
+#define TRACE_TX                       0x0002  /* Trace all Tx path (os ->>core ->> hal) */
+#define TRACE_RX                       0x0004  /* Trace all Rx path (hal ->> core ->> os) */
+#define TRACE_COPY_ONLY                0x0008  /* Trace the copy of data from and to the FW only  - for slave mode*/
+#define TRACE_BUG_ONLY         0x0010  /* Trace the ctrls that only presents an unexpected case*/
+#define TRACE_All                      0xffff  /* Trace all. */
+
+
+/****************************************************************************
+ *                      OBJECT DATA BASE
+ ****************************************************************************
+ *
+ *     TrcDb - Rx Trace buffer of 5000 packets
+ *
+ ****************************************************************************/
+int whal_tracePrintLine(WhalTrace_T *pTrc, int EventIndex);
+
+void local_string_copy(char *str1, char *str2, int size)
+{
+       int i;
+       for (i=0; i<size; i++)
+       {
+               str1[i] = str2[i];
+               if (str2[i] == 0)
+                       break;
+       }
+}
+/****************************************************************************
+ *                      whal_traceCreate()
+ ****************************************************************************
+ * DESCRIPTION:        Create the whal trace object
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The Created object
+ ****************************************************************************/
+WhalTrace_T *whal_traceCreate(TI_HANDLE hOs)
+{
+       WhalTrace_T *pObj;
+
+       pObj = os_memoryAlloc(hOs, sizeof(WhalTrace_T));
+       if (pObj == NULL)
+               return NULL;
+
+       os_memoryZero(hOs, pObj, sizeof(WhalTrace_T));
+
+       pObj->hOs = hOs;
+       pObj->hProtect = os_protectCreate(pObj->hOs);
+       if (pObj->hProtect == NULL)
+       {
+               whal_traceDestroy(pObj);
+               return NULL;
+       }
+
+       return(pObj);
+}
+
+/****************************************************************************
+ *                      whal_traceDestroy()
+ ****************************************************************************
+ * DESCRIPTION:        Destroy the object 
+ * 
+ * INPUTS:     
+ *             pTrc            The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_traceDestroy(WhalTrace_T *pTrc)
+{
+       if (pTrc == NULL)
+               return OK;
+
+       if (pTrc->hProtect)
+               os_protectDestroy(pTrc->hOs, pTrc->hProtect);
+       os_memoryFree(pTrc->hOs, pTrc, sizeof(WhalTrace_T));
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_traceConfig()
+ ****************************************************************************
+ * DESCRIPTION:        Config the object 
+ * 
+ * INPUTS:     
+ *             pTrc            The object
+ *             hReport         The reports objects
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_traceConfig(WhalTrace_T *pTrc, TI_HANDLE hTNETWIF, TI_HANDLE hReport)
+{
+       pTrc->hReport = hReport;
+       pTrc->hTNETWIF = hTNETWIF;
+       pTrc->Enable = 0; /*Hardcoded*/
+       pTrc->Idx = 0;
+       pTrc->Num = 0;
+       pTrc->MaxFreeBlks = 0;
+
+       /* configured the trace mask flag */
+       pTrc->traceMask = TRACE_BUG_ONLY;
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_traceAddTx()
+ ****************************************************************************
+ * DESCRIPTION:        Add Tx info line to the DB
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+
+#ifdef TNETW_MASTER_MODE
+
+int whal_traceAddTx(WhalTrace_T *pTrc, HwTxDesc_T *pHwTxDesc, char *Action)
+{
+       TRACER_EVENT *pEvt;
+       UINT32 FrameAddress;
+       DbTescriptor local_TxDesc;
+       TRACER_DATA     *pData;
+
+#ifdef SEQUNCE_TRACE
+       return 1;
+#endif
+       /* Dm: os_protectLock(pTrc->hOs, pTrc->hProtect); */
+
+       pEvt = &pTrc->Evt[pTrc->Idx];
+       pData = &pEvt->Info.TrcData;
+       
+       /*
+        * Common
+        */
+       local_string_copy(pEvt->Action, Action, TRACER_MAX_ACT_LEN-1);
+       local_string_copy(pEvt->Object, "Tx", TRACER_MAX_OBJ_LEN-1);
+
+    pEvt->TimStamp = os_timeStampUs(pTrc->hOs);
+
+       /* 
+        * Data
+        */
+       whal_hwTxDesc_Copy(pHwTxDesc, &local_TxDesc);
+
+       pData->MpduLen  = local_TxDesc.length;
+       pData->Ctl              = local_TxDesc.ctl;
+       pData->Rate             = (UINT16)local_TxDesc.rate;
+
+    pData->Status[0] = 0;
+       pData->Status[1] = 0;
+       pData->Status[3] = 0;
+
+    /*
+       pData->Status[0] = local_TxDesc.ctrl2;
+       pData->Status[1] = local_TxDesc.ackFailures;
+       pData->Status[3] = local_TxDesc.rtsFailures;
+    */
+
+       FrameAddress = 4+whal_hwTxDesc_GetAcxBufAddr(pHwTxDesc);
+       TNETWIF_ReadMemSync(pTrc->hTNETWIF,
+                                               (UINT32)((char *)FrameAddress),
+                                               (UINT8 *)((char *)&pData->FrameHeader),
+                                                 TRACER_HDR_LEN);
+
+       pData->FrameHeader.fc = ENDIAN_HANDLE_WORD(pData->FrameHeader.fc);
+       pData->FrameHeader.seqCtrl = ENDIAN_HANDLE_WORD(pData->FrameHeader.seqCtrl);
+       pData->FrameHeader.duration = ENDIAN_HANDLE_WORD(pData->FrameHeader.duration);
+       TNETWIF_ReadMemSync(pTrc->hTNETWIF,
+                                               (UINT32)((char *)FrameAddress+TRACER_HDR_LEN),
+                                               (UINT8 *)((char *)&pData->FrameData),
+                                                 4);
+
+
+       /* 
+        * Prepare next index
+        */
+       if (++pTrc->Idx >= TRACER_MAX_EVENTS)
+               pTrc->Idx = 0;
+
+       if (pTrc->Num < TRACER_MAX_EVENTS)
+               pTrc->Num++;
+
+       /* Dm: os_protectUnlock(pTrc->hOs, pTrc->hProtect); */
+
+       return(0);
+}
+
+#endif  /* TNETW_MASTER_MODE */
+
+
+/****************************************************************************
+ *                      whal_traceIsEnable()
+ ****************************************************************************
+ * DESCRIPTION:        return the enable value
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    Enable value
+ ****************************************************************************/
+int whal_traceIsEnable(WhalTrace_T *pTrc)
+{
+       return pTrc->Enable;
+}
+
+/****************************************************************************
+ *                      whal_traceEnable()
+ ****************************************************************************
+ * DESCRIPTION:        enable the tracing
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void whal_traceEnable(WhalTrace_T *pTrc, int val)
+{
+       pTrc->Enable = val;
+       
+       if(val == 1) /* Enable case*/
+       {
+               pTrc->MinNumDescriptorFree = 0xff;
+               pTrc->MacOccupiedDescriptor = 0;
+               pTrc->MaxClearDescriptor = 0;
+               pTrc->BugCounter = 0;
+               pTrc->reBug = 0;
+               pTrc->MaxFreeBlks = 0;
+       }
+
+       
+}
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalTrace.h b/sta_dk_4_0_4_32/common/src/BusAccess/Shm_Common/whalTrace.h
new file mode 100644 (file)
index 0000000..d207153
--- /dev/null
@@ -0,0 +1,136 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalTrace.h
+ *   PURPOSE: Trace on Rx/Tx packets
+ * 
+ ****************************************************************************/
+
+#ifndef _WHAL_TRACE_H
+#define _WHAL_TRACE_H
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+
+
+#ifndef TIWLN_WINCE30
+#define TRACER_MAX_EVENTS              2000
+#else
+#define TRACER_MAX_EVENTS              10
+#endif
+
+#define TRACER_MAX_ACT_LEN             5
+#define TRACER_MAX_OBJ_LEN             3
+#define TRACER_HDR_LEN                 2
+#define TRACER_MAX_STR_LEN             70
+
+
+
+typedef enum
+{
+       NUM_FREE_DESCRIPTOR,
+       DESCRIPTOR_OCCUPIED,
+       CLEAR_DESCRIPTORS,
+       FREE_BLOCKS,
+} varSetType_e;
+
+typedef struct
+{
+       UINT32                  time;
+       UINT16                  MpduLen;
+       UINT8                   Ctl;
+       UINT16                  Rate;
+       UINT8                   Status[4];
+       dot11_header_t  FrameHeader;
+       int                             FrameData;
+} TRACER_DATA;
+
+typedef struct
+{
+       char                    String[TRACER_MAX_STR_LEN];
+       int                             IntValue;
+} TRACER_CTRL;
+
+typedef struct
+{
+       UINT32                  TimStamp;
+       char                    Action[TRACER_MAX_ACT_LEN];
+       char                    Object[TRACER_MAX_OBJ_LEN];
+
+       union
+       {
+               TRACER_DATA             TrcData;
+               TRACER_CTRL             TrcCtrl;
+       }Info;
+
+} TRACER_EVENT;
+
+typedef struct _WhalTrace_T
+{
+       int Enable;
+       int Idx;
+       int Num;
+#ifdef TNETW_MASTER_MODE
+       TRACER_EVENT Evt[TRACER_MAX_EVENTS];
+#endif
+       void *hProtect;
+       short traceMask;
+
+       UINT8                   MinNumDescriptorFree;
+       UINT8                   MacOccupiedDescriptor;
+       UINT8                   MaxClearDescriptor;
+       UINT8                   MaxFreeBlks;
+       UINT8                   BugCounter;
+       UINT8                   reBug;
+
+
+       TI_HANDLE               hTNETWIF;
+
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+} WhalTrace_T;
+
+extern WhalTrace_T *whal_traceCreate(TI_HANDLE hOs);
+extern int whal_traceDestroy(WhalTrace_T *pTrc);
+extern int whal_traceConfig(WhalTrace_T *pTrc, TI_HANDLE hTNETWIF, TI_HANDLE hReport);
+#ifdef TNETW_MASTER_MODE
+extern int  whal_traceAddTx(WhalTrace_T *pTrc, HwTxDesc_T *pHwTxDesc, char *Action);
+#endif
+extern int  whal_traceIsEnable(WhalTrace_T *pTrc);
+extern void whal_traceEnable(WhalTrace_T *pTrc, int val);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/dot11h/spectrumMngmntMgr.c b/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/dot11h/spectrumMngmntMgr.c
new file mode 100644 (file)
index 0000000..a5e0d88
--- /dev/null
@@ -0,0 +1,574 @@
+/** \file spectrumMngmntMgr.c
+ *  
+ *
+ *  \see spectrumMngmntMgr.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************************************/
+/*                                                                                                                                                                                                     */
+/*             MODULE:         spectrumMngmntMgr.c                                                                                                                             */
+/*             PURPOSE:                                                                                                                        */
+/*                                                                                                                                                                                                     */
+/****************************************************************************************************/
+
+#include "report.h"
+#include "osApi.h"
+#include "paramIn.h"
+#include "utils.h"
+#include "802_11Defs.h"
+#include "siteMgrApi.h"
+#include "regulatoryDomainApi.h"
+#include "mlmeBuilder.h"
+#include "Ctrl.h"
+#include "spectrumMngmntMgr.h"
+
+#define RADAR_THRESHOLD_IN_PRECENTS              (5)
+#define DOT11H_REQUEST_IE_HDR_LEN          3
+#define DOT11H_REQUEST_IE_LEN              7
+#define DOT11_MEASUREMENT_REQUEST_ELE_ID (38)
+
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+
+/* The following function uses features from the old Measurement module. */
+/* It will have to be adapted to using the new Measurement Manager. */
+#if 0
+
+static void buildMapSubFieldForBasicReport(TI_HANDLE hMeasurementMgr, UINT8* map);
+
+#endif
+
+
+/********************************************************************************/
+/*                                             Internal Structures.                                                            */
+/********************************************************************************/
+typedef struct
+{
+    UINT8   dialogToken;
+    UINT8   activatioDelay;
+    UINT8   measurementOffset;
+} dot11hFrameReqHdr_t;
+
+typedef struct
+{
+    UINT8  IeId;
+    UINT8  Length;
+    UINT8  Token;
+} dot11hReqIEHdr_t;
+
+/********************************************************************************/
+/*                                             Interface functions Implementation.                                             */
+/********************************************************************************/
+
+/***************************************************************************
+ * NOTE: The next 3 functions represent the following situations: Receiving
+ *       of TPC request, receving Quite IE and receiving Switch Channel IE.
+ *       The Measurement SM should be updated to handle this states.
+ ***************************************************************************/
+
+
+/***********************************************************************
+ *                   measurementMgr_getBasicMeasurementParam                                                                   
+ ***********************************************************************
+DESCRIPTION:   
+                               
+                               
+INPUT:      hMeasurementMgr        -   MeasurementMgr Handle
+                       
+OUTPUT:                pAcxStatisitics     -   
+            pMediumOccupancy    -   
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+/* The following function uses features from the old Measurement module. */
+/* It will have to be adapted to using the new Measurement Manager. */
+#if 0
+
+TI_STATUS measurementMgr_getBasicMeasurementParam(TI_HANDLE hMeasurementMgr,
+                                                                                 acxStatisitcs_t*      pAcxStatisitics,
+                                                                                 mediumOccupancy_t* pMediumOccupancy)
+{
+
+       whalParamInfo_t whalParam;
+    measurementMgr_t *pMeasurementMgr = (measurementMgr_t*)hMeasurementMgr;
+
+       /* getting the ACX statisitc counters by calling the HAL */ 
+       whalParam.paramType = HAL_CTRL_ACX_STATISTICS_PARAM;
+       if( (status = whalCtrl_GetParam(pMeasurementMgr->hHalCtrl,&whalParam)) == OK)
+       {
+               pAcxStatisitics->FWpacketReceived = whalParam.content.acxStatisitics.FWpacketReceived;  
+               pAcxStatisitics->HALpacketReceived      = whalParam.content.acxStatisitics.HALpacketReceived;
+       }
+       
+       /*FIXME*/
+       WLAN_OS_REPORT(("-------------- FW total---------------, %d\n\n", 
+                    pAcxStatisitics->FWpacketReceived));
+       WLAN_OS_REPORT(("-------------- Driver Total---------------, %d\n\n", 
+                    pAcxStatisitics->HALpacketReceived));
+
+    /*******************************************************
+    * NOTE: If not using a call back function the required *
+    *       information will not be received               *
+    *******************************************************/
+       /* getting the Medium Occupancy by calling the HAL */ 
+       whalParam.paramType = HAL_CTRL_MEDIUM_OCCUPANCY_PARAM;
+    whalParam.content.interogateCmdCBParams.CB_Func = NULL;
+    whalParam.content.interogateCmdCBParams.CB_handle = hMeasurementMgr;
+    whalParam.content.interogateCmdCBParams.CB_buf = NULL;
+
+       if( (status = whalCtrl_GetParam(pMeasurementMgr->hHalCtrl,&whalParam)) == OK)
+       {
+        return status;
+       }
+
+       return status;
+}
+
+#endif
+
+/***********************************************************************
+ * NOTE: The next 4 functions (dot11h...) should be corrected according 
+ *       to the 802.11h standered.
+ ***********************************************************************/
+
+/************************************************************************
+*                                      measurementMgr_dot11hParserFrameReq                                     *
+************************************************************************
+DESCRIPTION: Frame Request Parser function, called by the Measurement 
+             object when a measurement request frame is received. 
+                               performs the following:
+                               -       Parsers the received frame request.
+                                       
+INPUT:      hMeasurementMgr - MeasurementMgr Handle
+                       pData                   - The frame request
+            dataLen         - The frame'sa length
+
+OUTPUT:                fraemReq        - The Parsered Frame Request
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS measurementMgr_dot11hParseFrameReq(TI_HANDLE hMeasurementMgr, 
+                                           UINT8 *pData, INT32 dataLen,
+                                           measurement_frameRequest_t *frameReq)
+{
+    dot11hFrameReqHdr_t     *dot11hFrameReqHdr;
+
+    dot11hFrameReqHdr = (dot11hFrameReqHdr_t*)pData;
+    
+    frameReq->hdr->dialogToken = (UINT16)dot11hFrameReqHdr->dialogToken;
+    frameReq->hdr->activatioDelay = dot11hFrameReqHdr->activatioDelay;
+    frameReq->hdr->measurementOffset = dot11hFrameReqHdr->measurementOffset;
+
+    frameReq->requests = pData + DOT11H_REQUEST_IE_HDR_LEN;
+    frameReq->requestsLen = dataLen - DOT11H_REQUEST_IE_HDR_LEN;
+
+    return OK;
+}
+
+/************************************************************************
+ *                                     measurementMgr_dot11hParserRequestIEHdr                         *
+ ************************************************************************
+DESCRIPTION: Spectrom Manager Request IE Header Parser function, 
+             called by the Request Handler object when inserting 
+             a request IE to the queue. 
+                               performs the following:
+                               -       Parsers the received request IE hdr.
+                                       
+INPUT:      hRequestHandler    -       Request Handler handle
+                       pData                   -       The request IE
+
+OUTPUT:                reqestLen           - The Request length
+            measurementToken    - The Request IE token
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS measurementMgr_dot11hParseRequestIEHdr(UINT8 *pData, UINT16 *reqestHdrLen,
+                                               UINT16 *measurementToken)
+{
+    dot11hReqIEHdr_t *dot11hReqIEHdr;
+    
+    dot11hReqIEHdr = (dot11hReqIEHdr_t*)pData;
+    
+    /* checking if received the correct information element ID */
+    if(dot11hReqIEHdr->IeId != DOT11_MEASUREMENT_REQUEST_ELE_ID)
+        return NOK;
+        
+    /* checking that len is valid */
+    if(dot11hReqIEHdr->Length != DOT11H_REQUEST_IE_LEN)
+        return NOK;
+    
+    *measurementToken = (UINT16)dot11hReqIEHdr->Token;
+    
+    *reqestHdrLen = DOT11H_REQUEST_IE_HDR_LEN;
+    
+    return OK;
+}
+
+/************************************************************************
+ *                                     measurementMgr_dot11hIsTypeValid                                        *
+ ************************************************************************
+DESCRIPTION: Spectrom Manager function that checks if the given 
+             measurement type is valid. 
+                                       
+INPUT:      hMeasurementMgr -  MeasurementMgr Handle
+            type                       -       The measurement type.
+            scanMode        -   The Measurement scan Mode.
+
+OUTPUT:                
+
+RETURN:     TRUE if type is valid, FALSE otherwise
+
+************************************************************************/
+BOOL measurementMgr_dot11hIsTypeValid(TI_HANDLE hMeasurementMgr, 
+                                   measurement_type_e type, 
+                                   measurement_scanMode_e scanMode)
+{
+    if(type != MSR_TYPE_BASIC_MEASUREMENT)
+        return FALSE;
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *                  measurementMgr_dot11hBuildRejectReport                                                     
+ ***********************************************************************
+DESCRIPTION:   Send reject measurement report frame Function.
+                The function does the following:
+                               -       checking the reason for reject.
+                               -       builds measurement report Frame.
+                               -       Calls the mlmeBuolder to allocate a mangement frame
+                                       and to transmit it.
+                               
+INPUT:      hMeasurementMgr -  MeasurementMgr Handle
+                       pRequestArr             -       Array of pointer to all measurement 
+                                                               request that should be rejected.
+                       numOfRequestsInParallel - indicates the number of 
+                                                               request that should be rejected.
+                       rejectReason    -       Indicated the rejection reason.
+
+OUTPUT:                None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS measurementMgr_dot11hBuildRejectReport(TI_HANDLE hMeasurementMgr,
+                                                                                       MeasurementRequest_t* pRequestArr[],
+                                                                                       UINT8   numOfRequestsInParallel,
+                                                                                       measurement_rejectReason_e      rejectReason)
+{
+       measurementMgr_t        *pMeasurementMgr         = (measurementMgr_t*)hMeasurementMgr;
+       MeasurementReportFrame_t        measurementReport;
+       UINT8                                           measurementMode = 0;
+
+       /* Building the measurement report frame contents */
+       measurementReport.actionField.category = CATAGORY_SPECTRUM_MANAGEMENT;
+       measurementReport.actionField.action = MEASUREMENT_REPORT;
+       measurementReport.dialogToken = (UINT8)pRequestArr[0]->frameToken;
+
+       measurementReport.measurementReportIE.hdr.eleId = DOT11_MEASUREMENT_REPORT_ELE_ID;
+       measurementReport.measurementReportIE.hdr.eleLen = DOT11_MIN_MEASUREMENT_REPORT_IE_LEN;
+       measurementReport.measurementReportIE.measurementToken = (UINT8)pRequestArr[0]->measurementToken;
+       measurementReport.measurementReportIE.measurementType = pRequestArr[0]->Type;
+       
+       /* Building the measurement mode bit field */
+
+       /* setting Parallel Bit */
+       if(numOfRequestsInParallel > 0 )
+               measurementMode |= 0x1;
+       
+       /* setting Incapable and Refused bits */
+       switch(rejectReason)
+       {
+               case MSR_REJECT_DTIM_OVERLAP:
+               case MSR_REJECT_DURATION_EXCEED_MAX_DURATION:
+               case MSR_REJECT_TRAFFIC_INTENSITY_TOO_HIGH:
+               case MSR_REJECT_SCR_UNAVAILABLE:
+               case MSR_REJECT_INVALID_CHANNEL:
+               case MSR_REJECT_NOISE_HIST_FAIL:
+               case MSR_REJECT_CHANNEL_LOAD_FAIL:
+               case MSR_REJECT_EMPTY_REPORT:
+               case MSR_REJECT_MAX_DELAY_PASSED:
+               case MSR_REJECT_INVALID_MEASUREMENT_TYPE:
+               {
+                       /* Setting the Refused bit */
+                       measurementMode |= 0x4;
+                       break;
+               }
+       
+               default:
+               {
+                       WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("Reject reason is not supported, %d\n\n", rejectReason));
+
+                       break;
+               }
+       }
+       
+       measurementReport.measurementReportIE.measurementMode = measurementMode;
+       WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+        ("Measurement was rejected due to %d,\n\n", rejectReason));
+
+       /* Note: The Measurement report reject frame body includes 8 UINT8 */
+       return mlmeBuilder_sendFrame(pMeasurementMgr->hMlme,ACTION,(UINT8*)&measurementReport,8,0);
+}
+
+
+/***********************************************************************
+ *                        measurementMgr_dot11hBuildReport                                                     
+ ***********************************************************************
+DESCRIPTION:   build measurement report Function.
+                The function does the following:
+                               -       builds measurement report IE.
+                               
+INPUT:      hMeasurementMgr -  MeasurementMgr Handle
+                       pRequestArr             -       Array of pointer to all measurement 
+                                                               request that should be reported.
+                       numOfRequestsInParallel - indicates the number of 
+                                                               request that should be reported.
+                       
+OUTPUT:                None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS measurementMgr_dot11hBuildReport(TI_HANDLE hMeasurementMgr, MeasurementRequest_t request, measurement_typeReply_t * reply)
+{
+       /*measurementMgr_t                              *pMeasurement    = (measurementMgr_t*)hMeasurementMgr;*/
+       MeasurementReportFrame_t        measurementReport;
+       UINT8                                           totalReportLen = 0;
+       UINT8                                           map = 0;
+       UINT8*                                          pMeasurReport = (UINT8 *)&(measurementReport.measurementReportIE.measurementReports[0]);
+
+       /* Building the measurement report frame contents */
+       measurementReport.actionField.category = CATAGORY_SPECTRUM_MANAGEMENT;
+       measurementReport.actionField.action = MEASUREMENT_REPORT;
+       measurementReport.dialogToken = (UINT8)request.frameToken;
+
+       measurementReport.measurementReportIE.hdr.eleId = DOT11_MEASUREMENT_REPORT_ELE_ID;
+       measurementReport.measurementReportIE.measurementToken = (UINT8)request.measurementToken;
+       
+       /* setting Parallel Bit in the measurement mode */
+       if(request.isParallel)
+               measurementReport.measurementReportIE.measurementMode = 0x1;
+       
+       measurementReport.measurementReportIE.measurementType = request.Type;
+       
+       
+       /* Building the reports included in the current measurement report IE */
+       /* Note: The current implementation supports only Basic Report */
+       if(request.Type == MSR_TYPE_BASIC_MEASUREMENT)
+       {               
+                       *pMeasurReport++ = request.channelNumber;
+                       *pMeasurReport++ = (UINT8)request.DurationTime;
+
+/* The following function uses features from the old Measurement module. */
+/* It will have to be adapted to using the new Measurement Manager. */
+#if 0
+                       /* building the map subfield */
+                       buildMapSubFieldForBasicReport(hMeasurementMgr,&map);
+#endif /* 0 */
+
+                       *pMeasurReport++ = map;
+                       totalReportLen += 3;
+       }
+       return OK;
+}
+
+/***********************************************************************
+ *                   measurementMgr_dot11hSendReportAndCleanObject                                                     
+ ***********************************************************************
+DESCRIPTION:   Send measurement report frame Function.
+                The function does the following:
+                               -       Calls the mlmeBuilder to allocate a mangement frame
+                                       and to transmit it.
+                               -       Cleans the Measurement Object and reset its Params.
+                               
+INPUT:      hMeasurementMgr -  MeasurementMgr Handle
+                       
+OUTPUT:                None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS measurementMgr_dot11hSendReportAndCleanObject(TI_HANDLE hMeasurementMgr)
+{
+    measurementMgr_t   *pMeasurementMgr = (measurementMgr_t*)hMeasurementMgr;
+       TI_STATUS               status;
+
+       /* Building the Report Frame Header */
+       /* TO DO */
+
+    if(pMeasurementMgr->frameLength != 0)
+    {
+        /* Setting the IE Length field */
+        /* TO DO */
+
+        /* Sending the Rport Frame */
+        status =  mlmeBuilder_sendFrame(pMeasurementMgr->hMlme,ACTION,
+                                        (UINT8*)&pMeasurementMgr->dot11hFrameReport,
+                                        sizeof(dot11_ACTION_FIELD_t) + sizeof(UINT8) + 
+                                        sizeof(dot11_eleHdr_t) + 
+                                        DOT11_MIN_MEASUREMENT_REPORT_IE_LEN + 
+                                        pMeasurementMgr->frameLength,0);
+        if(status != OK)
+            return status;
+        
+        /* clearing reports data base */
+        os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->dot11hFrameReport),
+            sizeof(MeasurementReportFrame_t));
+        pMeasurementMgr->frameLength = 0;
+               pMeasurementMgr->nextEmptySpaceInReport = 0;
+       }
+
+       /* Reset the Measurement Object Params */
+       pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
+       requestHandler_clearRequests(pMeasurementMgr->hRequestH);
+
+       return OK;
+}
+
+
+/********************************************************************************/
+/*                                             Internal functions Implementation.                                              */
+/********************************************************************************/
+
+
+
+/***********************************************************************
+ *                     buildMapSubFieldForBasicReport                                                                  
+ ***********************************************************************
+DESCRIPTION:   
+                               
+                               
+INPUT:      hMeasurementMgr -  MeasurementMgr Handle
+
+OUTPUT:                map             -   
+
+RETURN:     None
+************************************************************************/
+
+/* The following function uses features from the old Measurement module. */
+/* It will have to be adapted to using the new Measurement Manager. */
+#if 0
+
+static void buildMapSubFieldForBasicReport(TI_HANDLE hMeasurementMgr,UINT8* map)
+{
+
+
+       INT32   deltaHALReceivedPacked;
+       INT32   deltaFWReceivedPacked;
+       INT32   deltaFCSError;
+       INT32   periodTimeDelta;
+       INT32   occupancyDelta;
+    measurementMgr_t* pMeasurementMgr = (measurementMgr_t*)hMeasurementMgr;
+       
+       /* getting the AcxStatisitcs from the FW */
+    /* NOTE: The medium occupancy will not be updated - FIX */
+
+/* The following function uses features from the old Measurement module. */
+/* It will have to be adapted to using the new Measurement Manager. */
+#if 0
+       measurementMgr_getBasicMeasurementParam(hMeasurementMgr, &pMeasurementMgr->acxStatisticEnd,
+                                         &pMeasurementMgr->mediumOccupancyEnd);
+#endif
+
+       /* Calculating the delta for packetReceived from the HAL*/
+       deltaHALReceivedPacked = pMeasurementMgr->acxStatisticEnd.HALpacketReceived - 
+                             pMeasurementMgr->acxStatisticStart.HALpacketReceived; 
+       
+       if(deltaHALReceivedPacked < 0)
+               WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+        ("HAL delta packets is negative , %d\n\n", deltaHALReceivedPacked));
+       
+       if(deltaHALReceivedPacked != 0 )
+               *map = DOT11_BSS_ONLY;
+       else
+       {
+               /* Calculating the delta for FCS Error*/
+               deltaFWReceivedPacked = pMeasurementMgr->acxStatisticEnd.FWpacketReceived - 
+                                pMeasurementMgr->acxStatisticStart.FWpacketReceived;
+               
+               if(deltaFWReceivedPacked < 0)
+        {
+                       WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                ("FW delta packets is negative , %d\n\n", deltaFWReceivedPacked));
+        }
+
+               deltaFCSError = deltaFWReceivedPacked - deltaHALReceivedPacked;
+               
+               if(deltaFCSError < 0)
+        {
+                       WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+               ("FCS error is negative , %d\n\n", deltaFCSError));
+        }
+
+               if(deltaFCSError != 0 )
+                       *map = DOT11_OFDM_ONLY;
+               else
+               {
+                       /* Calculating the delta for Medium occupancy */
+                       occupancyDelta = pMeasurementMgr->mediumOccupancyEnd.MediumUsage - 
+                             pMeasurementMgr->mediumOccupancyStart.MediumUsage;
+
+                       if(occupancyDelta < 0)
+            {
+                               WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                    ("Medium Occupancy is negative , %d\n\n", occupancyDelta));
+            }
+
+                       periodTimeDelta = pMeasurementMgr->mediumOccupancyEnd.Period - 
+                              pMeasurementMgr->mediumOccupancyStart.Period;
+                       
+                       if(periodTimeDelta < 0)
+            {
+                               WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                    ("Period time delta is negative , %d\n\n", periodTimeDelta));
+            }
+                       
+                       if( ((occupancyDelta * 100) / periodTimeDelta)  > RADAR_THRESHOLD_IN_PRECENTS )
+                               *map = DOT11_RADAR_AND_UNIDENTIFIED;
+                       else
+                               *map = 0;
+               }
+       }
+
+       return;
+}
+
+#endif /* 0 */
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/measurementMgr.c b/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/measurementMgr.c
new file mode 100644 (file)
index 0000000..208ac78
--- /dev/null
@@ -0,0 +1,1242 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       measurementMgr.c                                                                                   */
+/*    PURPOSE: measurement Manager module file                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+
+
+
+#include "measurementMgr.h"
+#include "regulatoryDomainApi.h"
+#include "healthMonitor.h"
+#include "siteMgrApi.h"
+#include "utils.h"
+#include "TrafficMonitorAPI.h"
+#include "smeApi.h"
+#ifdef EXC_MODULE_INCLUDED
+ #include "excTSMngr.h"
+#endif
+
+
+
+/* allocation vector */
+#define MEASUREMENT_INIT_BIT                                                           (1)
+#define MEASUREMENT_ACTIVATION_DELAY_TIMER_INIT_BIT                    (2)
+#define MEASUREMENT_SM_INIT_BIT                             (3)
+#define MEASUREMENT_REQUEST_HANDLER_SUB_MODULE_INIT_BIT                (4)
+
+
+/* default measurement parameters */
+#define MEASUREMENT_CAPABILITIES_NONE                                  0x00
+#define MEASUREMENT_CAPABILITIES_DOT11H                                        0x01
+#define MEASUREMENT_CAPABILITIES_EXC_RM                                        0x02
+
+
+#define MEASUREMENT_BEACON_INTERVAL_IN_MICRO_SEC               1024
+#define MEASUREMENT_MSEC_IN_MICRO                       1000
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+
+static void measurementMgr_releaseModule(measurementMgr_t * pMeasurementMgr, UINT32 initVec);
+
+static BOOL measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr);
+
+static BOOL    measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr, MeasurementRequest_t *pRequestArr[], UINT8 numOfRequest);
+
+static void    measurementMgr_uponActivationDelayTimeout(TI_HANDLE Context);
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             Interface functions Implementation.                                             */
+/********************************************************************************/
+
+
+/**
+ * Creates the Measurement Manager moodule.
+ * 
+ * @param hOs A handle to the OS object.
+ *
+ * @date 16-Dec-2005
+ */
+TI_HANDLE measurementMgr_create(TI_HANDLE hOs)
+{
+       measurementMgr_t * pMeasurementMgr = NULL;
+       UINT32 initVec = 0;
+    TI_STATUS status;
+
+       /* allocating the MeasurementMgr object */
+       pMeasurementMgr = os_memoryAlloc(hOs, sizeof(measurementMgr_t));
+
+    if (pMeasurementMgr == NULL)
+               return NULL;
+
+    os_memoryZero(hOs, pMeasurementMgr, sizeof(measurementMgr_t));
+    pMeasurementMgr->hOs = hOs;
+
+       initVec |= (1 << MEASUREMENT_INIT_BIT);
+
+       
+       /* allocating the measurement Activation Delay timer */
+       pMeasurementMgr->pActivationDelayTimer = os_timerCreate(hOs, measurementMgr_uponActivationDelayTimeout, 
+                                                         pMeasurementMgr);
+       if (pMeasurementMgr->pActivationDelayTimer == NULL)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }
+
+       initVec |= (1<<MEASUREMENT_ACTIVATION_DELAY_TIMER_INIT_BIT);
+
+#ifdef EXC_MODULE_INCLUDED     
+       if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_BE] = 
+               os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_BE, pMeasurementMgr)) == NULL)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }
+
+       if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_BK] = 
+               os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_BK, pMeasurementMgr)) == NULL)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }
+       if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_VI] = 
+               os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_VI, pMeasurementMgr)) == NULL)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }
+       if ((pMeasurementMgr->pTsMetricsReportTimer[QOS_AC_VO] = 
+               os_timerCreate(hOs, measurementMgr_sendTSMReport_AC_VO, pMeasurementMgr)) == NULL)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }       
+#endif
+
+    /* creating the Measurement SM */
+    status = fsm_Create(pMeasurementMgr->hOs, &(pMeasurementMgr->pMeasurementMgrSm), 
+                        MEASUREMENTMGR_NUM_STATES , MEASUREMENTMGR_NUM_EVENTS);
+       if(status != OK)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }
+
+       initVec |= (1<<MEASUREMENT_SM_INIT_BIT);
+   
+       
+
+       /* creating the sub modules of measurement module */
+       
+       /* creating Request Handler sub module */
+       if( (pMeasurementMgr->hRequestH = requestHandler_create(hOs)) == NULL)
+       {
+               measurementMgr_releaseModule(pMeasurementMgr, initVec);
+               return NULL;
+       }
+       
+       initVec |= (1<<MEASUREMENT_REQUEST_HANDLER_SUB_MODULE_INIT_BIT);
+
+
+    return(pMeasurementMgr);
+}
+
+
+
+
+
+/**
+ * Configures the Measurement Manager module.
+ * 
+ * @param hXXXX Handles to other modules the Measurement Manager needs.
+ * @param pMeasurementInitParams A pointer to the measurement init parameters.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_config(TI_HANDLE      hMeasurementMgr,
+                                                               TI_HANDLE       hMacServices,
+                                                               TI_HANDLE       hRegulatoryDomain,
+                                                               TI_HANDLE       hExcMngr,
+                                                               TI_HANDLE       hSiteMgr,
+                                                               TI_HANDLE       hHalCtrl,
+                                                               TI_HANDLE       hMlme,
+                                TI_HANDLE      hTrafficMonitor,
+                                                               TI_HANDLE       hReport,
+                                                               TI_HANDLE       hOs,
+                                TI_HANDLE      hScr,
+                                TI_HANDLE      hHealthMonitor,
+                                                               TI_HANDLE       hApConn,
+                                                               TI_HANDLE       hTx,
+                                                               measurementInitParams_t * pMeasurementInitParams)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+       paramInfo_t param;
+    TI_STATUS status;  
+#ifdef EXC_MODULE_INCLUDED
+       UINT32 currAC;
+#endif
+       
+       /* Init Handlers */
+       pMeasurementMgr->hMacServices           = hMacServices;
+       pMeasurementMgr->hRegulatoryDomain      = hRegulatoryDomain;
+       pMeasurementMgr->hExcMngr                       = hExcMngr;
+       pMeasurementMgr->hSiteMgr                       = hSiteMgr;
+       pMeasurementMgr->hHalCtrl                       = hHalCtrl;
+       pMeasurementMgr->hMlme                          = hMlme;
+    pMeasurementMgr->hTrafficMonitor   = hTrafficMonitor;
+       pMeasurementMgr->hReport                        = hReport;
+       pMeasurementMgr->hOs                            = hOs;
+    pMeasurementMgr->hScr                              = hScr;
+    pMeasurementMgr->hHealthMonitor            = hHealthMonitor;
+       pMeasurementMgr->hApConn                        = hApConn;
+       pMeasurementMgr->hTx                            = hTx;
+
+    /* initialize variables to default values */
+    pMeasurementMgr->Enabled = TRUE;
+       pMeasurementMgr->Connected = FALSE;
+       pMeasurementMgr->Capabilities = MEASUREMENT_CAPABILITIES_NONE;
+       pMeasurementMgr->Mode = MSR_MODE_NONE;
+
+    /* Getting management capability status */
+       param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+       regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
+       if (param.content.spectrumManagementEnabled)
+       {
+               pMeasurementMgr->Capabilities |= MEASUREMENT_CAPABILITIES_DOT11H;
+       }
+    
+#ifdef EXC_MODULE_INCLUDED
+    /* Check in the Registry if the station supports EXC RM */
+    if (pMeasurementInitParams->excEnabled == EXC_MODE_ENABLED)
+    {
+        pMeasurementMgr->Capabilities |= MEASUREMENT_CAPABILITIES_EXC_RM;
+    }
+#endif
+
+    /* Init Functions */
+    pMeasurementMgr->parserFrameReq = NULL;
+    pMeasurementMgr->isTypeValid = NULL;
+    pMeasurementMgr->buildReport = NULL;
+    pMeasurementMgr->buildRejectReport = NULL;
+    pMeasurementMgr->sendReportAndCleanObj = NULL;
+    
+    /* initialize variables */ 
+    pMeasurementMgr->currentState = MEASUREMENTMGR_STATE_IDLE;
+    pMeasurementMgr->isModuleRegistered = FALSE;
+       pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
+    pMeasurementMgr->measuredChannelID = 0;
+       pMeasurementMgr->currentNumOfRequestsInParallel = 0;
+       
+    pMeasurementMgr->trafficIntensityThreshold = pMeasurementInitParams->trafficIntensityThreshold;
+    pMeasurementMgr->maxDurationOnNonServingChannel = pMeasurementInitParams->maxDurationOnNonServingChannel;
+
+    /* config sub modules */
+       RequestHandler_config(pMeasurementMgr->hRequestH, hReport, hOs);
+
+    /* Register to the SCR module */
+    scr_registerClientCB(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE, measurementMgr_scrResponseCB, pMeasurementMgr);
+
+#ifdef EXC_MODULE_INCLUDED
+       for (currAC = 0; currAC < MAX_NUM_OF_AC; currAC++)
+       {
+               pMeasurementMgr->isTsMetricsEnabled[currAC] = FALSE;
+               os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pTsMetricsReportTimer[currAC]);
+       }
+#endif
+
+       status = measurementMgrSM_config(hMeasurementMgr);   
+
+       if(status == OK)
+    {
+        WLAN_REPORT_INIT(hReport, MEASUREMENT_MNGR_MODULE_LOG,  
+                               ("%s: Measurement Manager configured successfully\n", __FUNCTION__));
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(hReport, MEASUREMENT_MNGR_MODULE_LOG,  
+                               ("%s: Measurement Manager configuration failed\n", __FUNCTION__));
+    }
+
+       return status;
+}
+
+
+
+
+
+/**
+ * Sets the specified Measurement Manager parameter.
+ *
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * @param pParam The parameter to set.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_setParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       switch (pParam->paramType)
+       {
+               case MEASUREMENT_ENABLE_DISABLE_PARAM:
+               {
+                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: MEASUREMENT_ENABLE_DISABLE_PARAM <- %d\n", __FUNCTION__, pParam->content.measurementEnableDisableStatus));
+
+                       if (pParam->content.measurementEnableDisableStatus)
+                       {
+                               measurementMgr_enable(pMeasurementMgr);
+                       }
+                       else
+                       {
+                               measurementMgr_disable(pMeasurementMgr);
+                       }
+
+                       break;
+               }
+
+               case MEASUREMENT_TRAFFIC_THRESHOLD_PARAM:
+               {
+                       if ((pParam->content.measurementTrafficThreshold >= MEASUREMENT_TRAFFIC_THRSHLD_MIN) &&
+                               (pParam->content.measurementTrafficThreshold <= MEASUREMENT_TRAFFIC_THRSHLD_MAX))
+                       {
+                               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                               ("%s: MEASUREMENT_TRAFFIC_THRESHOLD_PARAM <- %d\n", __FUNCTION__, pParam->content.measurementTrafficThreshold));
+
+                               pMeasurementMgr->trafficIntensityThreshold = pParam->content.measurementTrafficThreshold;
+                       }
+                       else
+                       {
+                               WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                               ("%s: Invalid value for MEASUREMENT_TRAFFIC_THRESHOLD_PARAM (%d)\n", __FUNCTION__, pParam->content.measurementTrafficThreshold));
+                       }
+        
+                       break;
+               }
+
+               
+               case MEASUREMENT_MAX_DURATION_PARAM:
+               {
+                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: MEASUREMENT_MAX_DURATION_PARAM <- %d\n", __FUNCTION__, pParam->content.measurementMaxDuration));
+
+                       pMeasurementMgr->maxDurationOnNonServingChannel = pParam->content.measurementMaxDuration;
+
+                       break;
+               }
+        
+
+               default:
+               {
+                       WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Specified parameter is not supported (%d)\n", __FUNCTION__, pParam->paramType));
+
+                       return PARAM_NOT_SUPPORTED;
+               }
+
+       }
+       
+       return OK;
+}
+
+
+
+
+
+/**
+ * Gets the specified parameter from the Measurement Manager.
+ *
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * @param pParam The parameter to get.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_getParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       switch(pParam->paramType)
+       {
+
+               case MEASUREMENT_GET_STATUS_PARAM:
+               {
+                       WLAN_OS_REPORT(("%s: \n\n", __FUNCTION__));
+                       WLAN_OS_REPORT(("MeasurementMgr Status Report:\n\n"));
+
+                       WLAN_OS_REPORT(("Current State: %d\n\n", pMeasurementMgr->currentState));
+
+                       WLAN_OS_REPORT(("Connected: %d\n", pMeasurementMgr->Connected));
+                       WLAN_OS_REPORT(("Enabled: %d\n\n", pMeasurementMgr->Enabled));
+
+                       WLAN_OS_REPORT(("Mode: %d\n", pMeasurementMgr->Mode));
+                       WLAN_OS_REPORT(("Capabilities: %d\n\n", pMeasurementMgr->Capabilities));
+
+                       WLAN_OS_REPORT(("current Frame Type: %d\n", pMeasurementMgr->currentFrameType));
+                       WLAN_OS_REPORT(("Measured Channel: %d\n", pMeasurementMgr->measuredChannelID));
+                       WLAN_OS_REPORT(("Serving Channel: %d\n", pMeasurementMgr->servingChannelID));
+                       WLAN_OS_REPORT(("Traffic Intensity Threshold: %d\n", pMeasurementMgr->trafficIntensityThreshold));
+                       WLAN_OS_REPORT(("Max Duration on Nonserving Channel: %d\n", pMeasurementMgr->maxDurationOnNonServingChannel));
+
+                       break;
+               }
+               
+
+               default:
+               {
+                       WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Specified parameter is not supported (%d)\n", __FUNCTION__, pParam->paramType));
+
+                       return PARAM_NOT_SUPPORTED;
+               }
+
+       }
+
+       return OK;
+}
+
+
+
+
+
+
+/**
+ * Signals the Measurement Manager that the STA is connected.
+ *
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_connected(TI_HANDLE hMeasurementMgr)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+    /* checking if measurement is enabled */
+       if (pMeasurementMgr->Mode == MSR_MODE_NONE)
+               return OK;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MeasurementMgr set to connected.\n", __FUNCTION__));
+
+    return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_CONNECTED, pMeasurementMgr);
+}
+
+
+
+
+
+/**
+ * Signals the Measurement Manager that the STA is disconnected.
+ *
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_disconnected(TI_HANDLE hMeasurementMgr)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MeasurementMgr set to disconnected.\n", __FUNCTION__));
+
+       return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                                                               MEASUREMENTMGR_EVENT_DISCONNECTED, pMeasurementMgr);
+}
+
+
+
+
+/**
+ * Enables the Measurement Manager module.
+ * 
+ * @date 10-Jan-2006
+ */
+TI_STATUS measurementMgr_enable(TI_HANDLE hMeasurementMgr)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MeasurementMgr set to enabled.\n", __FUNCTION__));
+
+       return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                                                               MEASUREMENTMGR_EVENT_ENABLE, pMeasurementMgr);
+}
+
+
+
+
+
+/**
+ * Disables the Measurement Manager module.
+ * 
+ * @date 10-Jan-2006
+ */
+TI_STATUS measurementMgr_disable(TI_HANDLE hMeasurementMgr)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MeasurementMgr set to disabled.\n", __FUNCTION__));
+
+       return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                                                               MEASUREMENTMGR_EVENT_DISABLE, pMeasurementMgr);
+}
+
+
+
+
+
+/**
+ * Destroys the Measurement Manager module.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_destroy(TI_HANDLE hMeasurementMgr)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+       UINT32 initVec;
+
+       if (pMeasurementMgr == NULL)
+               return OK;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MeasurementMgr is being destroyed\n", __FUNCTION__));
+
+       initVec = 0xFFFF;       /* release everything */
+
+       measurementMgr_releaseModule(pMeasurementMgr, initVec);
+
+       return OK;
+}
+
+
+
+
+
+
+/**
+ * Sets the Measurement Mode.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * @param capabilities The AP capabilities.
+ * @param pIeBuffer Pointer to the list of IEs.
+ * @param length Length of the IE list.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_setMeasurementMode(TI_HANDLE hMeasurementMgr, UINT16 capabilities, 
+                                         UINT8 * pIeBuffer, UINT16 length)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       /*
+        * 11h Measurement is not supported in the current version.
+        */
+/*     if( (pMeasurementMgr->Capabilities & MEASUREMENT_CAPABILITIES_DOT11H) &&
+        (capabilities & DOT11_SPECTRUM_MANAGEMENT) )
+    {
+        pMeasurementMgr->Mode = MSR_MODE_SPECTRUM_MANAGEMENT;
+    }
+    else
+    {
+*/
+#ifdef EXC_MODULE_INCLUDED
+
+        if(pMeasurementMgr->Capabilities & MEASUREMENT_CAPABILITIES_EXC_RM)
+        {
+                    pMeasurementMgr->Mode = MSR_MODE_EXC;
+        }
+        else
+#endif
+        {
+            pMeasurementMgr->Mode = MSR_MODE_NONE;
+        }
+
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MeasurementMgr mode changed to: %d\n", __FUNCTION__, pMeasurementMgr->Mode));
+    
+       return OK;
+}
+
+
+
+
+
+
+/**
+ * Called when a frame with type measurement request is received.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * @param frameType The frame type.
+ * @param dataLen The length of the frame.
+ * @param pData A pointer to the frame's content.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_receiveFrameRequest(TI_HANDLE hMeasurementMgr,
+                                                                                       measurement_frameType_e frameType,
+                                                                                       INT32 dataLen,
+                                                                                       UINT8 * pData)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+    measurement_frameRequest_t * frame = &(pMeasurementMgr->newFrameRequest);    
+       UINT16 currentFrameToken;
+       
+       /* checking if measurement is enabled */
+       if (pMeasurementMgr->Mode == MSR_MODE_NONE)
+               return NOK;
+
+       /* ignore broadcast/multicast request if unicast request is active */
+       if (frameType != MSR_FRAME_TYPE_UNICAST && pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
+    {
+        WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                  ("%s: Broadcast/Multicast measurement frame has been ignored\n", __FUNCTION__));
+
+               return MEASUREMENT_REQUEST_IGNORED;
+    }
+
+       /* ignore broadcast request if multicast request is active */
+       if (frameType == MSR_FRAME_TYPE_BROADCAST && pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_MULTICAST)
+    {
+        WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Broadcast measurement frame has been ignored\n", __FUNCTION__));
+        
+               return MEASUREMENT_REQUEST_IGNORED;
+    }
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Measurement frame received\n", __FUNCTION__));
+
+    /* Parsing the Frame Request Header */
+    pMeasurementMgr->parserFrameReq(hMeasurementMgr, pData, dataLen, 
+                                                                               frame);
+
+    frame->frameType = frameType;
+
+       /* checking if the received token frame is the same as the one that is being processed */
+       if ((requestHandler_getFrameToken(pMeasurementMgr->hRequestH, &currentFrameToken) == OK)
+               && (currentFrameToken == frame->hdr->dialogToken))
+       {
+               os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest, 
+                      sizeof(measurement_frameRequest_t));
+
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s: Measurement frame token %d is identical to current frame token - ignoring frame\n", __FUNCTION__, currentFrameToken));
+
+               return MEASUREMENT_REQUEST_IGNORED;
+       }
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Measurement frame token is %d\n", __FUNCTION__, frame->hdr->dialogToken));
+
+    /* Frame is Received for processing */
+    return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_FRAME_RECV, pMeasurementMgr);
+}
+
+
+
+
+
+/**
+ * Activates the next measurement request.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 16-Dec-2005
+ */
+TI_STATUS measurementMgr_activateNextRequest(TI_HANDLE hMeasurementMgr)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+       requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
+       MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
+       UINT8 numOfRequestsInParallel = 0;
+       BOOL valid;
+       UINT8 index;
+
+       /* Keep note of the time we started processing the request. this will be used */
+       /* to give the measurementSRV a time frame to perform the measurement operation */
+       pMeasurementMgr->currentRequestStartTime = os_timeStampMs(pMeasurementMgr->hOs);
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Timer started at %d, we have 20ms to begin measurement...\n", __FUNCTION__, 
+                                       pMeasurementMgr->currentRequestStartTime));
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Looking for a valid request\n", __FUNCTION__));
+
+       do
+       {
+               TI_STATUS status;
+
+               if (numOfRequestsInParallel != 0)
+               {
+                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Changing activeRequestID from %d to %d, and numOfWaitingRequests from %d to %d.\n", __FUNCTION__,
+                                                       pRequestH->activeRequestID, pRequestH->activeRequestID + numOfRequestsInParallel, pRequestH->numOfWaitingRequests, pRequestH->numOfWaitingRequests - numOfRequestsInParallel));
+               }
+
+               pRequestH->activeRequestID += numOfRequestsInParallel;
+        pRequestH->numOfWaitingRequests -= numOfRequestsInParallel;
+
+        for (index = 0; index < MAX_NUM_REQ; index++)
+        {
+            pRequestArr[index] = NULL;
+        }
+               numOfRequestsInParallel = 0;
+
+               /* Getting the next request/requests from the request handler */
+               status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, FALSE, pRequestArr, 
+                                                                                  &numOfRequestsInParallel);
+               
+               /* Checking if there are no waiting requests */
+               if (status != OK)
+               {
+            WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                   ("%s: There are no waiting requests in the queue\n", __FUNCTION__));
+
+                       return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr);
+               }
+
+        /* Checking validity of request/s */
+               valid = measurementMgr_isRequestValid(pMeasurementMgr, pRequestArr, 
+                                                               numOfRequestsInParallel);
+
+        /* Checking if the current request is Beacon Table */
+        if( (numOfRequestsInParallel == 1) && 
+            (pRequestArr[0]->Type == MSR_TYPE_BEACON_MEASUREMENT) &&
+            (pRequestArr[0]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE) )
+        {
+            WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Received Beacon Table request, building a report for it and continuing\n", __FUNCTION__));
+
+            pMeasurementMgr->buildReport(hMeasurementMgr, *(pRequestArr[0]), NULL);
+            valid = FALSE; /* In order to get the next request/s*/
+        }
+               
+       } while (valid == FALSE);
+    
+       
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Request(s) for activation:\n", __FUNCTION__));
+
+       for (index = 0; index < numOfRequestsInParallel; index++)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: \n\nRequest #%d:\n Type: %d\n Measured Channel: %d (Serving Channel: %d)\n Scan Mode: %d\n Duration: %d\n\n", __FUNCTION__, 
+                                               index+1, pRequestArr[index]->Type, pRequestArr[index]->channelNumber,
+                                               pMeasurementMgr->servingChannelID, pRequestArr[index]->ScanMode, pRequestArr[index]->DurationTime));
+       }
+
+       /* Ignore requests if traffic intensity is high */
+       if (measurementMgr_isTrafficIntensityHigherThanThreshold(pMeasurementMgr) == TRUE)
+       {
+        WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Traffic intensity too high, giving up...\n", __FUNCTION__));
+
+               measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_TRAFFIC_INTENSITY_TOO_HIGH);
+
+               return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr);
+       }
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Request is Valid, about to start\n", __FUNCTION__)); 
+    
+    pMeasurementMgr->measuredChannelID = pRequestArr[0]->channelNumber;
+  
+    /* Request resource from the SCR */
+    return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+        MEASUREMENTMGR_EVENT_REQUEST_SCR, pMeasurementMgr);    
+}      
+
+
+
+void measurementMgr_rejectPendingRequests(TI_HANDLE hMeasurementMgr, measurement_rejectReason_e rejectReason)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+       requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
+    MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
+       UINT8 numOfRequestsInParallel;
+
+       /* reject all pending measurement requests */
+       while (requestHandler_getNextReq(pMeasurementMgr->hRequestH, TRUE, 
+                               pRequestArr, &numOfRequestsInParallel) == OK)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Rejecting pending request (activeRequestID = %d)...\n", __FUNCTION__, pRequestH->activeRequestID));
+
+        pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr,
+                               numOfRequestsInParallel, rejectReason);
+
+               pRequestH->activeRequestID += numOfRequestsInParallel;
+       }
+}
+
+
+
+
+
+/********************************************************************************/
+/*                                             Callback functions Implementation.                                              */
+/********************************************************************************/
+
+
+/**
+ * The callback called by the MeasurementSRV module when then
+ * measurement operation has ended.
+ * 
+ * @param clientObj A handle to the Measurement Manager module.
+ * @param msrReply An array of replies sent by the MeasurementSRV module,
+ * where each reply contains the result of a single measurement request.
+ * 
+ * @date 01-Jan-2006
+ */
+void measurementMgr_MeasurementCompleteCB(TI_HANDLE clientObj, measurement_reply_t * msrReply)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) clientObj;
+    UINT8 index;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Building reports for measurement requests\n", __FUNCTION__));
+
+    /* build a report for each measurement request/reply pair */
+       for (index = 0; index < msrReply->numberOfTypes; index++)
+    {
+        pMeasurementMgr->buildReport(pMeasurementMgr, *(pMeasurementMgr->currentRequest[index]), &msrReply->msrTypes[index]);
+    }
+
+    measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                       MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);
+}
+
+
+/**
+ * The callback called when the SCR responds to the SCR request.
+ * 
+ * @param hClient A handle to the Measurement Manager module.
+ * @param requestStatus The request's status
+ * @param pendReason The reason of a PEND status.
+ * 
+ * @date 01-Jan-2006
+ */
+void measurementMgr_scrResponseCB(TI_HANDLE hClient, scr_clientRequestStatus_e requestStatus,
+                                                          scr_pendReason_e pendReason )
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hClient;
+       measurementMgrSM_Events event;
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: SCR callback entered\n", __FUNCTION__));  
+
+    /* If the SM is in a state where it waits for the CB, status of RUN */
+       /* results in the SM asking the measurementSRV to start measurement; */
+       /* otherwise we got an ABORT or a PEND reason worse than the one we */
+       /* got when calling the SCR, so the SM aborts the measurement */
+    if (pMeasurementMgr->currentState == MEASUREMENTMGR_STATE_WAITING_FOR_SCR)
+    {
+               if (requestStatus == SCR_CRS_RUN)
+               {
+                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Received SCR status RUN, running...\n", __FUNCTION__));
+
+                       event = MEASUREMENTMGR_EVENT_SCR_RUN;
+               }
+               else
+               {
+                       if (requestStatus == SCR_CRS_PEND)
+                       {
+                               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                               ("%s: Received SCR status PEND with reason %d, aborting...\n", __FUNCTION__, pendReason));
+                       }
+                       else
+                       {
+                               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                               ("%s: Received SCR status ABORT/FW_RESET, aborting...\n", __FUNCTION__));
+                       }
+
+                       event = MEASUREMENTMGR_EVENT_ABORT;
+               }
+       }
+       else
+       {       
+               /* This can only occur if FW reset occurs or when higher priority */
+               /* client is running in all these cases indicate ABORT event */
+
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: MeasurementMgrSM current state is %d (which isn't WAITING_FOR_SCR), aborting...\n", __FUNCTION__, pMeasurementMgr->currentState));
+
+               event = MEASUREMENTMGR_EVENT_ABORT;
+       }
+
+       measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+               event, pMeasurementMgr);
+}
+
+
+
+
+
+
+/**
+ * The callback called by the MLME.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 01-Jan-2006
+ */
+void measurementMgr_mlmeResultCB(TI_HANDLE hMeasurementMgr, macAddress_t * bssid, mlmeFrameInfo_t * frameInfo, 
+                                                                Rx_attr_t * pRxAttr, UINT8 * buffer, UINT16 bufferLength)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+
+       /* check whether the packet was received while the firmware was performing a beacon measurement */
+
+       BOOL receivedWhileMeasuring = ((pRxAttr->packetInfo & RX_PACKET_FLAGS_MEASURMENT) == RX_PACKET_FLAGS_MEASURMENT);
+
+    if (pMeasurementMgr == NULL || pRxAttr == NULL)
+    {
+        WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: MLME callback called with NULL object\n", __FUNCTION__)); 
+
+        return;
+    }
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MLME callback entered\n", __FUNCTION__));
+
+    /* save scan results in site manager */
+    siteMgr_updateSite(pMeasurementMgr->hSiteMgr, bssid, frameInfo, pRxAttr->channel, (radioBand_e)pRxAttr->band, receivedWhileMeasuring);
+
+    if (frameInfo->subType == PROBE_RESPONSE)
+    {
+        siteMgr_saveProbeRespBuffer(pMeasurementMgr->hSiteMgr, bssid, buffer, bufferLength);
+    }
+    else if (frameInfo->subType == BEACON)
+    {
+        siteMgr_saveBeaconBuffer(pMeasurementMgr->hSiteMgr, bssid, buffer, bufferLength);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Unknown frame subtype (%d)\n", __FUNCTION__, frameInfo->subType));        
+    }
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: MLME Frame: rcvWhileMeasuring = %d, Subtype = %d, MAC = %x-%x-%x-%x-%x-%x, RSSI = %d\n", 
+                                       __FUNCTION__, receivedWhileMeasuring, frameInfo->subType,
+                                       bssid->addr[0], bssid->addr[1], bssid->addr[2],
+                                       bssid->addr[3], bssid->addr[4], bssid->addr[5],
+                                       pRxAttr->Rssi));
+}
+
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             Internal functions Implementation.                                              */
+/********************************************************************************/
+
+
+/**
+ * Releases the module's allocated objects according to the given init vector.
+ * 
+ * @param pMeasurementMgr A handle to the Measurement Manager module.
+ * @param initVec The init vector with a bit set for each allocated object.
+ * 
+ * @date 01-Jan-2006
+ */
+static void measurementMgr_releaseModule(measurementMgr_t * pMeasurementMgr, UINT32 initVec)
+{
+#ifdef EXC_MODULE_INCLUDED
+       UINT32 currAC;
+#endif
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: InitVec = %d\n", __FUNCTION__, initVec));
+
+       if (initVec & (1 << MEASUREMENT_ACTIVATION_DELAY_TIMER_INIT_BIT))
+       {
+               os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
+               utils_nullTimerDestroy(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
+#ifdef EXC_MODULE_INCLUDED
+               for (currAC = 0; currAC < MAX_NUM_OF_AC; currAC++)
+               {
+                       if (pMeasurementMgr->pTsMetricsReportTimer[currAC] != NULL)
+                       {
+                               os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pTsMetricsReportTimer[currAC]);
+                               utils_nullTimerDestroy(pMeasurementMgr->hOs, pMeasurementMgr->pTsMetricsReportTimer[currAC]);
+                       }
+               }
+#endif
+       }
+
+    if (initVec & (1 << MEASUREMENT_SM_INIT_BIT))
+               fsm_Unload(pMeasurementMgr->hOs, pMeasurementMgr->pMeasurementMgrSm);
+    
+
+       if (initVec & (1 << MEASUREMENT_REQUEST_HANDLER_SUB_MODULE_INIT_BIT))
+               requestHandler_destroy(pMeasurementMgr->hRequestH);
+       
+
+       if (initVec & (1 << MEASUREMENT_INIT_BIT))
+               utils_nullMemoryFree(pMeasurementMgr->hOs, pMeasurementMgr, sizeof(measurementMgr_t));
+}
+
+
+
+
+
+/**
+ * Checks whether the traffic intensity, i.e. number of packets per seconds, is higher
+ * than the preconfigured threshold.
+ * 
+ * @param pMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @return True iff the traffic intensity is high
+ * 
+ * @date 01-Jan-2006
+ */
+static BOOL measurementMgr_isTrafficIntensityHigherThanThreshold(measurementMgr_t * pMeasurementMgr)
+{
+    BOOL trafficIntensityHigh = FALSE;
+    int pcksPerSec;
+
+    pcksPerSec = TrafficMonitor_GetFrameBandwidth(pMeasurementMgr->hTrafficMonitor);
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+               ("%s: pcksPerSec = %d\n", __FUNCTION__, pcksPerSec));   
+    
+    if (pcksPerSec >= pMeasurementMgr->trafficIntensityThreshold)
+        trafficIntensityHigh = TRUE;
+    
+    return trafficIntensityHigh;
+}
+
+
+
+
+/**
+ * Checks whether the given measurement request is valid.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * @param pRequestArr The measurement request.
+ * @param numOfRequest Number of type requests
+ * 
+ * @return True iff the request is valid
+ * 
+ * @date 01-Jan-2006
+ */
+static BOOL    measurementMgr_isRequestValid(TI_HANDLE hMeasurementMgr, MeasurementRequest_t *pRequestArr[],
+                                                  UINT8 numOfRequest)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+       UINT8                   requestIndex;
+       paramInfo_t             param;
+
+       /* Checking validity of the measured channel number */
+       param.content.channel = pRequestArr[0]->channelNumber;
+       param.paramType = REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED;
+       regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
+       if ( !param.content.bIsChannelSupprted  )
+    {
+        WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                   ("%s: Request rejected due to invalid channel\n", __FUNCTION__));
+
+        if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
+            pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest, 
+                                                                       MSR_REJECT_INVALID_CHANNEL);
+
+        return FALSE;
+    }
+    else
+    {
+        WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                   ("%s: Request channel is Valid\n", __FUNCTION__));
+    }
+       
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+               ("%s: Starting to check each request:\n", __FUNCTION__));
+
+    /* Check Validity of each request */
+       for (requestIndex = 0; requestIndex < numOfRequest; requestIndex++)
+       {
+           WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Checking request #%d:\n", __FUNCTION__, requestIndex+1));
+
+               /* Checking validity of the Request Type */
+        if (pMeasurementMgr->isTypeValid(hMeasurementMgr, pRequestArr[requestIndex]->Type, 
+                               pRequestArr[requestIndex]->ScanMode) == FALSE)
+        {
+            WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Request rejected due to invalid measurement type of request #%d (type = %d)\n", __FUNCTION__, requestIndex+1, pRequestArr[requestIndex]->Type));
+            
+            if(pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
+                pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest, 
+                                                                               MSR_REJECT_INVALID_MEASUREMENT_TYPE);
+
+            return FALSE;
+        }
+        else
+        {
+            WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: Measurement type of request #%d is supported (type = %d)\n", __FUNCTION__, requestIndex+1, pRequestArr[requestIndex]->Type));
+        }
+
+        /* For measurement types different than Beacon Table */
+        if ((pRequestArr[requestIndex]->Type != MSR_TYPE_BEACON_MEASUREMENT) || 
+            (pRequestArr[requestIndex]->ScanMode != MSR_SCAN_MODE_BEACON_TABLE))
+               {
+               /* Checking Measurement request's duration only when request is on a non-serving channel */
+            if (pMeasurementMgr->servingChannelID != pRequestArr[requestIndex]->channelNumber)
+                       {
+                               UINT8 dtimPeriod;
+                               UINT32 beaconInterval;
+                               UINT32 dtimDuration;
+
+
+                               /* Checking duration doesn't exceed given max duration */
+                               if (pRequestArr[requestIndex]->DurationTime > pMeasurementMgr->maxDurationOnNonServingChannel)
+                               {
+                                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                                       ("%s: Request #%d rejected because duration exceeds maximum duration\n", __FUNCTION__, requestIndex+1));
+
+                                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                                                       ("%s: Duration = %d, MaxDurationOnNonServingChannel = %d\n", __FUNCTION__, 
+                                                                       pRequestArr[requestIndex]->DurationTime,
+                                                                       pMeasurementMgr->maxDurationOnNonServingChannel));
+                
+                                       if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
+                                               pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest, 
+                                                               MSR_REJECT_DURATION_EXCEED_MAX_DURATION);
+                
+                                       return FALSE;
+                               }
+                               else
+                               {
+                                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                                       ("%s: Duration of request #%d doesn't exceed max duration\n", __FUNCTION__, requestIndex+1));
+                               }
+
+
+                               /* Checking DTIM */
+
+                               /* Getting the DTIM count */
+                               param.paramType = SITE_MGR_DTIM_PERIOD_PARAM;
+                               siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
+                               dtimPeriod = param.content.siteMgrDtimPeriod;
+
+                               /* Getting the beacon Interval */
+                               param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
+                               siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
+                               beaconInterval = param.content.beaconInterval;
+
+                               dtimDuration = beaconInterval * MEASUREMENT_BEACON_INTERVAL_IN_MICRO_SEC/MEASUREMENT_MSEC_IN_MICRO*dtimPeriod;
+                               if (pRequestArr[requestIndex]->DurationTime > dtimDuration)
+                               {
+                                       WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                                       ("%s: Request rejected due to DTIM overlap of request #%d\n", __FUNCTION__, requestIndex+1));
+                                                                       
+                                       WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                                       ("%s: Duration = %d, DTIM Duration = %d\n", __FUNCTION__, pRequestArr[requestIndex]->DurationTime, dtimDuration));
+        
+                                       if (pMeasurementMgr->currentFrameType == MSR_FRAME_TYPE_UNICAST)
+                                               pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequest, 
+                                                                                               MSR_REJECT_DTIM_OVERLAP);
+
+                                       return FALSE;
+                               }
+                               else
+                               {
+                                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                                       ("%s: DTIM of request #%d doesn't overlap\n", __FUNCTION__, requestIndex+1));
+                               }
+               }
+               }
+       }
+
+       return TRUE;
+}
+
+
+
+
+
+
+/**
+ * The callback called when the activation delay timer has ended.
+ * 
+ * @param Context A handle to the Measurement Manager module.
+ * 
+ * @date 01-Jan-2006
+ */
+static void    measurementMgr_uponActivationDelayTimeout(TI_HANDLE Context)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) Context;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Activation delay timeout callback entered\n", __FUNCTION__));
+
+    measurementMgr_activateNextRequest(Context);
+}
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/measurementMgrSM.c b/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/measurementMgrSM.c
new file mode 100644 (file)
index 0000000..3d8e48d
--- /dev/null
@@ -0,0 +1,1218 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**  
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**************************************************************************/
+/*                                                                                                                                               */
+/*             MODULE:         measurementMgrSM.c                                                                        */
+/*             PURPOSE:        Measurement Manager State Machine module interface.   */
+/*                                                                                                                                               */
+/**************************************************************************/
+
+
+
+#include "measurementMgrSM.h"
+#include "measurementMgr.h"
+#include "802_11Defs.h"
+#ifdef EXC_MODULE_INCLUDED
+ #include "excMngr.h"
+ #include "excRMMngr.h"
+#endif
+#include "spectrumMngmntMgr.h"
+#include "siteMgrApi.h"
+#include "MacServices_api.h"
+#include "healthMonitor.h"
+#include "regulatoryDomainApi.h"
+#include "whalCtrl_api.h"
+
+
+
+
+
+char * measurementMgr_stateDesc[MEASUREMENTMGR_NUM_STATES] =
+{  
+       "STATE_IDLE",
+    "STATE_PROCESSING_REQUEST",
+    "STATE_WAITING_FOR_SCR",
+    "STATE_MEASURING"
+};
+
+       
+char * measurementMgr_eventDesc[MEASUREMENTMGR_NUM_EVENTS] =
+{
+       "EVENT_CONNECTED",
+       "EVENT_DISCONNECTED",
+       "EVENT_ENABLE",
+       "EVENT_DISABLE",
+    "EVENT_FRAME_RECV",
+    "EVENT_SEND_REPORT",
+       "EVENT_REQUEST_SCR",
+    "EVENT_SCR_WAIT",
+    "EVENT_SCR_RUN",
+    "EVENT_ABORT",
+    "EVENT_COMPLETE",
+    "EVENT_FW_RESET"
+};
+
+
+
+
+/********************************************************************************/
+/*                                             MeasurementMgr SM Action Prototypes                                             */
+/********************************************************************************/
+
+static TI_STATUS measurementMgrSM_acUnexpected(void * pData);
+
+static TI_STATUS measurementMgrSM_acNop(void * pData);
+
+
+static TI_STATUS measurementMgrSM_acConnected(void * pData);
+
+static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData);
+
+static TI_STATUS measurementMgrSM_acEnable(void * pData);
+
+static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData);
+
+static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData);
+
+static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData);
+
+
+static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData);
+
+static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData);
+
+static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData);
+
+static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData);
+
+static TI_STATUS measurementMgrSM_acRequestSCR(void * pData);
+
+
+static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData);
+
+static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData);
+
+static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData);
+
+static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData);
+
+static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData);
+
+
+static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData);
+
+static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData);
+
+static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData);
+
+static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData);
+
+static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData);
+
+static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData);
+
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             Internal Functions Prototypes                                                   */
+/********************************************************************************/
+
+static void measurementMgrSM_resetParams(measurementMgr_t * pMeasurementMgr);
+
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             MeasurementMgr SM General Use Functions                                 */
+/********************************************************************************/
+
+
+/**
+ * Configures the Measurement Manager State Machine.
+ * 
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 01-Jan-2006
+ */
+TI_STATUS measurementMgrSM_config(TI_HANDLE hMeasurementMgr)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+    TI_STATUS status;
+
+    /* MeasurementMgr State Machine matrix */
+       fsm_actionCell_t measurementMgr_matrix[MEASUREMENTMGR_NUM_STATES][MEASUREMENTMGR_NUM_EVENTS] =
+       {
+               /* next state and actions for STATE_IDLE state */    
+               {
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acConnected},                              /* CONNECTED         */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromIdle},  /* DISCONNECTED      */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acEnable},                                 /* ENABLE            */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromIdle},               /* DISABLE           */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromIdle},   /* FRAME_RECV        */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acSendReportAndCleanObj},  /* SEND_REPORT       */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected},                             /* REQUEST_SCR       */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected},                             /* SCR_WAIT          */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected},                             /* SCR_RUN           */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected},                             /* ABORT             */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected},                             /* COMPLETE          */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acUnexpected}                              /* FW_RESET          */
+               },
+
+               /* next state and actions for STATE_PROCESSING_REQUEST state */    
+               {
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected},                       /* CONNECTED         */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromProcessingRequest},     /* DISCONNECTED      */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acNop},                                      /* ENABLE            */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromProcessingRequest},          /* DISABLE           */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromProcessingRequest},      /* FRAME_RECV        */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acSendReportAndCleanObj},                          /* SEND_REPORT       */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acRequestSCR},                          /* REQUEST_SCR       */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected},                       /* SCR_WAIT          */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected},                       /* SCR_RUN           */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromProcessingRequest},            /* ABORT             */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected},                       /* COMPLETE          */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acUnexpected}                        /* FW_RESET          */
+               },
+
+               /* next state and actions for STATE_WAITING_FOR_SCR state */    
+               {
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected},                                          /* CONNECTED         */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromWaitForSCR},                            /* DISCONNECTED      */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acNop},                                                         /* ENABLE            */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromWaitForSCR},                                         /* DISABLE           */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromWaitForSCR},     /* FRAME_RECV        */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected},                                          /* SEND_REPORT       */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected},                                          /* REQUEST_SCR       */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acNop},                                                         /* SCR_WAIT          */
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acStartMeasurement},                                          /* SCR_RUN           */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromWaitForSCR},                                           /* ABORT             */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected},                                          /* COMPLETE          */
+                       {MEASUREMENTMGR_STATE_WAITING_FOR_SCR, measurementMgrSM_acUnexpected}                                           /* FW_RESET          */
+               },
+
+               /* next state and actions for STATE_MEASURING state */    
+               {
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected},                                        /* CONNECTED         */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisconnected_fromMeasuring},                     /* DISCONNECTED      */
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acNop},                                                       /* ENABLE            */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acDisable_fromMeasuring},                          /* DISABLE           */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acFrameReceived_fromMeasuring},      /* FRAME_RECV        */
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected},                                        /* SEND_REPORT       */
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected},                                        /* REQUEST_SCR       */
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected},                                        /* SCR_WAIT          */
+                       {MEASUREMENTMGR_STATE_MEASURING, measurementMgrSM_acUnexpected},                                        /* SCR_RUN           */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acAbort_fromMeasuring},                            /* ABORT             */
+                       {MEASUREMENTMGR_STATE_PROCESSING_REQUEST, measurementMgrSM_acMeasurementComplete},      /* COMPLETE          */
+                       {MEASUREMENTMGR_STATE_IDLE, measurementMgrSM_acFirmwareReset}                                           /* FW_RESET          */
+               }
+
+       };
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Configured MeasurementMgr state machine\n", __FUNCTION__));
+       
+       status = fsm_Config(pMeasurementMgr->pMeasurementMgrSm, 
+                                               &measurementMgr_matrix[0][0], 
+                                               MEASUREMENTMGR_NUM_STATES, 
+                                               MEASUREMENTMGR_NUM_EVENTS, 
+                                               measurementMgrSM_event, pMeasurementMgr->hOs);
+
+       return status;
+}
+
+
+
+/**
+ * Raises a State Machine event in the Measurement Manager SM.
+ * 
+ * @param currentState A point to the member holding the SM's current state.
+ * @param event The event we want to raise.
+ * @param hMeasurementMgr A handle to the Measurement Manager module.
+ * 
+ * @date 05-Jan-2006
+ */
+TI_STATUS measurementMgrSM_event(UINT8 * currentState, UINT8 event, TI_HANDLE hMeasurementMgr)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr;
+       TI_STATUS status;
+       UINT8 nextState;
+
+       status = fsm_GetNextState(pMeasurementMgr->pMeasurementMgrSm, 
+                                                               *currentState, event, &nextState);
+
+       if (status != OK)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: State machine error, failed getting next state\n", __FUNCTION__));
+
+               return(NOK);
+       }
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: <%s, %s> --> %s\n", __FUNCTION__,
+                                  measurementMgr_stateDesc[*currentState],
+                                  measurementMgr_eventDesc[event],
+                                  measurementMgr_stateDesc[nextState]));
+
+       status = fsm_Event(pMeasurementMgr->pMeasurementMgrSm,
+                                               currentState, event, (void *) pMeasurementMgr);
+
+       return status;
+}
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                     MeasurementMgr SM Action Functions                                                      */
+/********************************************************************************/
+
+
+/********************************************************************************/
+/*                            IDLE State Actions                                */
+/********************************************************************************/
+
+/**
+ * Performs the required action when the Measurement Manager module has
+ * been advised that the station has connected to an AP.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acConnected(void * pData)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+       paramInfo_t param;
+
+#ifdef EXC_MODULE_INCLUDED
+       iappParsingRegistrationTable_t iappParsingRegistration;
+#endif
+
+       /* do nothing if we're already in connected mode */
+       if (pMeasurementMgr->Connected)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s: Connected flag already set\n", __FUNCTION__));
+
+               return OK;
+       }
+
+       pMeasurementMgr->Connected = TRUE;
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Connected flag has been set\n", __FUNCTION__));
+
+       /* get the current serving channel */
+       param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+       siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
+       pMeasurementMgr->servingChannelID = param.content.siteMgrCurrentChannel;
+           
+#ifdef EXC_MODULE_INCLUDED
+       if(pMeasurementMgr->Mode == MSR_MODE_EXC)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: MeasurementMgr set to EXC mode\n", __FUNCTION__));
+
+        if(pMeasurementMgr->isModuleRegistered == FALSE)
+        {
+            /* Registering to the excMngr */
+            iappParsingRegistration.handler = pMeasurementMgr;
+            iappParsingRegistration.iappParsingRegistrationProcedure = measurementMgr_excParse;
+
+            if (excMngr_registerForRecvIappPacket(pMeasurementMgr->hExcMngr,
+                               iappParsingRegistration, IAPP_RADIO_MEASUREMENT) != OK)
+            {
+                               WLAN_REPORT_WARNING(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                               ("%s: Could not register to receive IAPP packets\n", __FUNCTION__));
+
+                return NOK;
+            }
+
+            pMeasurementMgr->isModuleRegistered = TRUE;
+        }
+        
+        pMeasurementMgr->parserFrameReq = measurementMgr_excParseFrameReq;
+        pMeasurementMgr->isTypeValid = measurementMgr_excIsTypeValid;
+               pMeasurementMgr->buildReport = measurementMgr_excBuildReport;
+               pMeasurementMgr->buildRejectReport = measurementMgr_excBuildRejectReport;
+               pMeasurementMgr->sendReportAndCleanObj = measurementMgr_excSendReportAndCleanObject;
+        requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH, 
+                                                measurementMgr_excParseRequestIEHdr);
+       }
+       else
+#endif
+       {
+               if(pMeasurementMgr->Mode == MSR_MODE_SPECTRUM_MANAGEMENT)
+               {
+                       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                                       ("%s: MeasurementMgr set to Spectrum Management mode\n", __FUNCTION__));
+
+            /* NOTE: These 5 functions need to be corrected to fit the 802.11h standered */
+            pMeasurementMgr->parserFrameReq = measurementMgr_dot11hParseFrameReq;
+            pMeasurementMgr->isTypeValid = measurementMgr_dot11hIsTypeValid;
+                       pMeasurementMgr->buildReport = measurementMgr_dot11hBuildReport;
+                       pMeasurementMgr->buildRejectReport = measurementMgr_dot11hBuildRejectReport;
+                       pMeasurementMgr->sendReportAndCleanObj = measurementMgr_dot11hSendReportAndCleanObject;
+            requestHandler_setRequestParserFunction(pMeasurementMgr->hRequestH, 
+                                                    measurementMgr_dot11hParseRequestIEHdr);
+
+               }
+       }
+
+       return OK;
+}
+
+
+
+/**
+ * Called when the Measurement Manager has been advised that the station
+ * has disconnected from the AP.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acDisconnected_fromIdle(void * pData)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Connected flag unset\n", __FUNCTION__));
+
+       pMeasurementMgr->Connected = FALSE;
+
+       return OK;
+}
+
+
+
+/**
+ * Called when the Measurement Manager is enabled.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acEnable(void * pData)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Measurement Manager has been enabled\n", __FUNCTION__));
+
+       pMeasurementMgr->Enabled = TRUE;
+
+       return OK;
+}
+
+
+
+/**
+ * Called when the Measurement Manager is disabled.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acDisable_fromIdle(void * pData)
+{
+       measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Measurement Manager has been disabled\n", __FUNCTION__));
+
+       pMeasurementMgr->Enabled = FALSE;
+
+       return OK;
+}
+
+
+
+/**
+ * Called when the SM is in an idle state and we receive a new measurement frame.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acFrameReceived_fromIdle(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+    UINT16 activationDelay;
+    TI_STATUS status;
+    paramInfo_t param;
+    UINT16 tbtt;
+
+       /* handle frame request only if we're connected and measurement is enabled */
+       if (pMeasurementMgr->Connected == FALSE ||
+               pMeasurementMgr->Enabled == FALSE)
+       {
+        WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Frame received while SM is in disconnected/disabled state\n", __FUNCTION__));
+
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
+       }
+
+       /* Setting the frame Type */
+       pMeasurementMgr->currentFrameType = pMeasurementMgr->newFrameRequest.frameType;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Frame Type = %d\n", __FUNCTION__, pMeasurementMgr->currentFrameType));
+
+    /* Getting the Beacon Interval from the Site Mgr */
+    param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
+    status = siteMgr_getParam(pMeasurementMgr->hSiteMgr, &param);
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Failed to retrieve beacon interval - not connected?\n", __FUNCTION__));
+
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
+    }
+
+       /* converting beacon interval to msec */
+    tbtt = (param.content.beaconInterval * 1024) / 1000;       /* from TU to msec */   
+
+       /* Initializing Activation Delay Time */
+       activationDelay = pMeasurementMgr->newFrameRequest.hdr->activatioDelay;
+       activationDelay *= tbtt;    
+    /* Adding the Measurement Offset to the activation delay */
+       activationDelay += pMeasurementMgr->newFrameRequest.hdr->measurementOffset;
+
+    /* Inserting all received measurement requests into the queue */
+       status = requestHandler_insertRequests(pMeasurementMgr->hRequestH, 
+                                           pMeasurementMgr->Mode, 
+                                                                          pMeasurementMgr->newFrameRequest);
+
+    /* Clean New Frame Params */
+    os_memoryZero(pMeasurementMgr->hOs, &pMeasurementMgr->newFrameRequest, 
+                      sizeof(measurement_frameRequest_t));
+
+    if (status != OK)
+    {
+        pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
+
+               WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Could not insert request into the queue\n", __FUNCTION__));
+
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);
+    }
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: New frame has been inserted into the queue\n", __FUNCTION__));
+
+       /* If frame type isn't Unicast add to Activation Delay a random delay */
+       if ((pMeasurementMgr->currentFrameType != MSR_FRAME_TYPE_UNICAST) && (activationDelay > 0))
+       {
+               activationDelay += ((os_timeStampMs(pMeasurementMgr->hOs) % MSR_ACTIVATION_DELAY_RANDOM)
+                                                               + MSR_ACTIVATION_DELAY_OFFSET);
+       }
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Activation Delay in ms = %d\n", __FUNCTION__, activationDelay));
+
+       if (activationDelay > 0)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Going to wait for activation delay timer callback\n", __FUNCTION__));
+
+               /* Starting the Activation Delay Timer */
+               os_timerStart(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer, 
+                                         activationDelay, FALSE);
+
+               return OK;
+       }
+       else
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Activating the next request immediately without waiting for callback\n", __FUNCTION__));
+
+               /* Calling to schedule the first waiting request */
+               return measurementMgr_activateNextRequest(pData);
+       }
+}
+
+
+
+
+
+/********************************************************************************/
+/*                      PROCESSING_REQUEST State Actions                        */
+/********************************************************************************/
+
+/**
+ * Called when the station disconnects from the AP while processing
+ * a measurement request.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acDisconnected_fromProcessingRequest(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* Stopping the activationDelay Timer */
+    os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+               
+       pMeasurementMgr->Connected = FALSE;
+
+       return OK;
+}
+
+
+
+/**
+ * Called when the Measurement Manager module has been disable while
+ * processing a measurement request.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acDisable_fromProcessingRequest(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* Stopping the activationDelay Timer */
+    os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
+
+    /* Clear Measurement fields  */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+
+       pMeasurementMgr->Enabled = FALSE;
+
+    return OK;
+}
+
+
+
+/**
+ * Called when a frame has been received while we are processing another frame.
+ * In this case the older frame is discarded and the new frame is processed.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acFrameReceived_fromProcessingRequest(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* Stopping the activationDelay Timer */
+    os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+               
+       /* Process New Frame */
+       return measurementMgrSM_acFrameReceived_fromIdle(pData);
+}
+
+
+
+/**
+ * Sends measurement reports to the AP and cleans up the module.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acSendReportAndCleanObj(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Sending pending reports and cleaning up...\n", __FUNCTION__));
+
+    return pMeasurementMgr->sendReportAndCleanObj(pData);
+}
+
+
+
+/**
+ * Called when for some reason we abort while processing a request.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acAbort_fromProcessingRequest(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Entered\n", __FUNCTION__));
+
+    /* Stopping the activationDelay Timer */
+    os_timerStop(pMeasurementMgr->hOs, pMeasurementMgr->pActivationDelayTimer);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+    
+    return OK;
+}
+
+
+
+/**
+ * Called when we finished processing a request and want to request the SCR.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acRequestSCR(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+       scr_clientRequestStatus_e scrStatus;
+       scr_pendReason_e scrPendReason;
+
+       /* Request the channel */
+    scrStatus = scr_clientRequest(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE, &scrPendReason);
+       
+    if (scrStatus == SCR_CRS_RUN)
+    {  
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Received RUN response from SCR\n", __FUNCTION__));
+
+               /* The channel is allocated for the measurement */
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_SCR_RUN, pMeasurementMgr);    
+    }
+    else if ((scrStatus == SCR_CRS_PEND) && (scrPendReason == SCR_PR_DIFFERENT_GROUP_RUNNING))
+    {  
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Received PEND/DIFFGROUP response from SCR\n", __FUNCTION__));
+
+               /* No need to wait for the channel allocation */
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_ABORT, pMeasurementMgr);  
+    }
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Going to wait for SCR callback...\n", __FUNCTION__));
+
+       /* In all other cases wait for the callback function to be called */
+    return OK;
+}
+
+
+
+
+
+/********************************************************************************/
+/*                        WAIT_FOR_SCR State Actions                            */
+/********************************************************************************/
+
+
+/**
+ * Called if the station disconnects from the AP while waiting for a
+ * response from the SCR.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acDisconnected_fromWaitForSCR(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       /* Release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+
+       pMeasurementMgr->Connected = FALSE;
+
+    return OK;
+}
+
+
+
+/**
+ * Called if the Measurement Manager module is disabled while we are
+ * waiting for a response from the SCR.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acDisable_fromWaitForSCR(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       /* Release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+
+       pMeasurementMgr->Enabled = FALSE;
+
+    return OK;
+}
+
+
+
+/**
+ * Called if a frame is received after we requested the SCR for another frame. 
+ * In this case the older frame is discarded and the new frame is processed.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acFrameReceived_fromWaitForSCR(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       /* Release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+
+       /* Process New Frame */
+    return measurementMgrSM_acFrameReceived_fromIdle(pData);
+}
+
+
+
+/**
+ * Called if the SCR callbacked with a response other than RUN.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acAbort_fromWaitForSCR(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       /* Release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+       /* Build a reject report */
+       measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_SCR_UNAVAILABLE);
+
+       /* Clear Measurement fields */
+    pMeasurementMgr->sendReportAndCleanObj(pMeasurementMgr);
+
+    return OK;
+}
+
+
+
+/**
+ * Called when the SCR callbacks with a RUN response or if the SCR
+ * returned a RUN response when we requested it.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acStartMeasurement(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+       /* Cryptic: the first struct is the requestHandler request while */
+       /* the second one is the measurementSRV request */
+    MeasurementRequest_t * pRequestArr[MAX_NUM_REQ];
+       measurement_request_t request;
+
+    paramInfo_t        param;
+    UINT8 numOfRequestsInParallel;
+    UINT8 requestIndex;
+       UINT32 timePassed;
+       BOOL requestedBeaconMeasurement= FALSE;
+       TI_STATUS status;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Starting Measurement operation\n", __FUNCTION__));
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Suspending health monitor\n", __FUNCTION__));
+
+    /* Suspend periodic health test */
+    healthMonitor_suspendPeriodicTest(pMeasurementMgr->hHealthMonitor);
+
+       request.channel = pMeasurementMgr->measuredChannelID;
+       request.startTime = 0;  /* ignored by MeasurementSRV for now - for .11k */
+       request.numberOfTypes = 0;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Measured Channel = %d\n", __FUNCTION__, pMeasurementMgr->measuredChannelID));
+
+       param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+       param.content.channelCapabilityReq.channelNum = pMeasurementMgr->measuredChannelID;
+       param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+
+       if (pMeasurementMgr->measuredChannelID <= MAX_CHANNEL_IN_BAND_2_4)
+       {
+               request.band = RADIO_BAND_2_4_GHZ;
+               param.content.channelCapabilityReq.band = RADIO_BAND_2_4_GHZ;
+       }
+       else
+       {
+               request.band = RADIO_BAND_5_0_GHZ;
+               param.content.channelCapabilityReq.band = RADIO_BAND_5_0_GHZ;
+       }
+
+       regulatoryDomain_getParam(pMeasurementMgr->hRegulatoryDomain, &param);
+       
+    request.txPowerDbm = param.content.channelCapabilityRet.maxTxPowerDbm;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Querying Request Handler for the next request in the queue\n", __FUNCTION__));
+
+    /* Getting the next request/requests from the request handler */
+    status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TRUE, pRequestArr,
+        &numOfRequestsInParallel);
+
+       if (status != OK)
+       {       
+               WLAN_REPORT_ERROR(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s: Failed getting next request from Request Handler\n", __FUNCTION__));
+
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);  
+       }
+       
+       /* Save the number of requests in parallel so that once the */
+       /* measurement operation ends we can get rid of this amount of requests */
+       /* from the requestHandler */
+       pMeasurementMgr->currentNumOfRequestsInParallel = numOfRequestsInParallel;
+
+       for (requestIndex = 0; requestIndex < numOfRequestsInParallel; requestIndex++)
+       {
+        if (pRequestArr[requestIndex]->Type == MSR_TYPE_BEACON_MEASUREMENT)
+        {
+                       requestedBeaconMeasurement = TRUE;
+
+                       if (pRequestArr[requestIndex]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE)
+                       {
+                               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                                               ("%s: Beacon Table request encountered, building report now\n", __FUNCTION__));
+
+                               /* building Report for beacon table request */
+                               pMeasurementMgr->buildReport(pMeasurementMgr, *pRequestArr[requestIndex], NULL);
+
+                               continue;
+                       }
+        }
+
+        /* save the request so we can reference it when results arrive */
+        pMeasurementMgr->currentRequest[request.numberOfTypes] = pRequestArr[requestIndex];
+
+        /* add the measurement type to the request's list */
+               request.msrTypes[request.numberOfTypes].duration = pRequestArr[requestIndex]->DurationTime;
+               request.msrTypes[request.numberOfTypes].scanMode = pRequestArr[requestIndex]->ScanMode;
+               request.msrTypes[request.numberOfTypes].msrType = pRequestArr[requestIndex]->Type;
+
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s:\n\nMeasurement Request #%d Details: Type = %d, Duration = %d\n\n", __FUNCTION__,
+                                               request.numberOfTypes+1,
+                                               request.msrTypes[request.numberOfTypes].msrType,
+                                               request.msrTypes[request.numberOfTypes].duration));
+
+               request.numberOfTypes++;
+       }
+
+       if (requestedBeaconMeasurement == TRUE)
+       {
+        /* build a probe request template and send it to the HAL */
+        whalCtrl_setTemplate_t templateStruct;
+               probeReqTemplate_t probeReqTemplate;
+               ssid_t broadcastSSID;
+
+               /* register to MLME for Beacons/Probe Resp  */
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s: Registering at the MLME\n", __FUNCTION__));
+
+               mlmeParser_registerForBeaconAndProbeResp(pMeasurementMgr->hMlme, 
+                                                                                                measurementMgr_mlmeResultCB, 
+                                                                                                pMeasurementMgr);
+
+               templateStruct.pTemplate = (UINT8 *) &probeReqTemplate;
+               templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
+               broadcastSSID.len = 0;
+
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s: Sending probe request template...\n", __FUNCTION__));
+
+        buildProbeReqTemplate(pMeasurementMgr->hSiteMgr, &templateStruct, &broadcastSSID, request.band);
+               whalCtrl_SetTemplate(pMeasurementMgr->hHalCtrl, &templateStruct);
+       }
+
+       /* Check if the maximum time to wait for the measurement request to */
+       /* finish has already passed */
+       timePassed = os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime;
+       if (timePassed > MSR_START_MAX_DELAY)
+       {
+               WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                               ("%s: Maximum delay to perform measurement operation has passed (%d / %d)\n", __FUNCTION__,
+                                               MSR_START_MAX_DELAY, (os_timeStampMs(pMeasurementMgr->hOs) - pMeasurementMgr->currentRequestStartTime)));
+
+               pMeasurementMgr->buildRejectReport(pMeasurementMgr, pRequestArr, numOfRequestsInParallel, MSR_REJECT_MAX_DELAY_PASSED);
+
+        return measurementMgrSM_event((UINT8 *) &(pMeasurementMgr->currentState), 
+                               MEASUREMENTMGR_EVENT_COMPLETE, pMeasurementMgr);  
+       }
+
+       /* Yalla, start measuring */
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Finished preparing request. Handing over to MeasurementSRV...\n", __FUNCTION__));
+
+       MacServices_measurementSRV_startMeasurement(pMeasurementMgr->hMacServices,
+                                                                                               &request, 
+                                                                                               MSR_START_MAX_DELAY - timePassed,
+                                                                                               NULL, NULL,
+                                                                                               measurementMgr_MeasurementCompleteCB, pMeasurementMgr);
+
+       return OK;
+}
+
+
+
+
+
+
+/********************************************************************************/
+/*                          MEASURING State Actions                             */
+/********************************************************************************/
+
+
+static TI_STATUS measurementMgrSM_acDisconnected_fromMeasuring(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* resume the self test */
+    healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
+
+    /* stop receiving from the MLME */
+    mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
+
+    /* release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+               
+       pMeasurementMgr->Connected = FALSE;
+
+       return OK;
+}
+
+
+
+static TI_STATUS measurementMgrSM_acDisable_fromMeasuring(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* resume the self test */
+    healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
+
+    /* stop receiving from the MLME */
+    mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
+
+    /* release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+               
+       pMeasurementMgr->Enabled = FALSE;
+
+    return OK;    
+}
+
+
+
+static TI_STATUS measurementMgrSM_acFrameReceived_fromMeasuring(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* resume the self test */
+    healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
+
+    /* stop receiving from the MLME */
+    mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
+
+    /* release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+               
+       /* Process New Frame */
+       return measurementMgrSM_acFrameReceived_fromIdle(pData);
+}
+
+
+
+static TI_STATUS measurementMgrSM_acAbort_fromMeasuring(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    /* resume the self test */
+    healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
+
+    /* stop receiving from the MLME */
+    mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
+
+    /* release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+    /* Clear Measurement fields */
+    measurementMgrSM_resetParams(pMeasurementMgr);
+               
+    return OK;
+}
+
+
+
+/**
+ * Called when we finished a measurement request.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acMeasurementComplete(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+       requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH;
+
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Completing measurement operation and resuming normal behavior\n", __FUNCTION__));
+
+       /* advance the activeRequestID variable to get rid of the */
+       /* measurement requests we've already executed */
+       WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG,
+                       ("%s: Increasing activeRequestID from %d to %d.\n", __FUNCTION__, pRequestH->activeRequestID, pRequestH->activeRequestID + pMeasurementMgr->currentNumOfRequestsInParallel));
+
+       pRequestH->activeRequestID += pMeasurementMgr->currentNumOfRequestsInParallel;
+
+    /* resume the self test */
+    healthMonitor_resumePeriodicTest(pMeasurementMgr->hHealthMonitor);
+
+    /* stop receiving from the MLME */
+    mlmeParser_unregisterForBeaconAndProbeResp(pMeasurementMgr->hMlme);
+
+    /* release the SCR */
+       scr_clientComplete(pMeasurementMgr->hScr, SCR_CID_EXC_MEASURE);
+
+       /* Process New Frame */
+       return measurementMgr_activateNextRequest(pData);
+}
+
+
+
+/**
+ * Called when a firmware reset has been detected.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acFirmwareReset(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                ("%s: Firmware Reset!!\n", __FUNCTION__));
+
+       /* TODO */
+       
+    return OK;
+}
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             Miscellaneous State Actions                                                             */
+/********************************************************************************/
+
+/**
+ * Called when an unexpected event has been triggered.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acUnexpected(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                ("%s: Entered when state is %s\n", __FUNCTION__, measurementMgr_stateDesc[pMeasurementMgr->currentState]));
+
+       return OK;
+}
+
+/**
+ * A do nothing action.
+ * 
+ * @date 05-Jan-2006
+ */
+static TI_STATUS measurementMgrSM_acNop(void * pData)
+{
+    measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) pData;
+
+    WLAN_REPORT_INFORMATION(pMeasurementMgr->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                ("%s: Entered when state is %s\n", __FUNCTION__, measurementMgr_stateDesc[pMeasurementMgr->currentState]));
+
+       return OK;
+}
+
+
+
+
+
+
+
+
+/********************************************************************************/
+/*                                             Internal Functions Prototypes                                                   */
+/********************************************************************************/
+
+
+
+static void measurementMgrSM_resetParams(measurementMgr_t *pMeasurementMgr)
+{  
+       /* clear the waiting requests */
+       requestHandler_clearRequests(pMeasurementMgr->hRequestH);       
+
+       /* clearing reports data base */
+#ifdef EXC_MODULE_INCLUDED
+       os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->excFrameReport),
+                       sizeof(RM_report_frame_t));
+#endif
+    os_memoryZero(pMeasurementMgr->hOs,&(pMeasurementMgr->dot11hFrameReport),
+                       sizeof(MeasurementReportFrame_t));
+
+       pMeasurementMgr->frameLength = 0;
+       pMeasurementMgr->nextEmptySpaceInReport = 0;
+       pMeasurementMgr->measuredChannelID = 0;
+       pMeasurementMgr->currentFrameType = MSR_FRAME_TYPE_NO_ACTIVE;
+}
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/requestHandler.c b/sta_dk_4_0_4_32/common/src/Management/AirLink/Measurement/requestHandler.c
new file mode 100644 (file)
index 0000000..339c6ad
--- /dev/null
@@ -0,0 +1,621 @@
+/** \file RequestHandler.c
+ *  \brief RequestHandler module interface
+ *
+ *  \see RequestHandler.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**  
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************************************/
+/*                                                                                                                                                                                                     */
+/*             MODULE:         RequestHandler.c                                                                                                                                */
+/*             PURPOSE:        RequestHandler module interface.                                                                                                */
+/*                  This module handle the incoming measurement requests. The object handle                    */
+/*                                     data base that stores all measurement requests from the last incoming.                  */
+/*                                     This module export interface function for sceduling the next requests to be             */
+/*                                     executed and stores all relevent fields for constructing a measurement report.  */
+/*                                                                                                                                                                                                     */
+/****************************************************************************************************/
+#include "report.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "utils.h"
+#include "requestHandler.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "excRMMngrParam.h"
+#endif
+
+/* allocation vector */
+#define REQUEST_HANDLER_INIT_BIT               (1)
+
+#define DOT11_MEASUREMENT_REQUEST_ELE_ID (38)
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+static void release_module(requestHandler_t *pRequestHandler, UINT32 initVec);
+
+static TI_STATUS insertMeasurementIEToQueue(TI_HANDLE           hRequestHandler,
+                                                                                       UINT16                          frameToken,
+                                                                                       measurement_mode_e      measurementMode,
+                                                                                       UINT8                           *pData,
+                                            UINT8               *singelRequestLen);
+
+/********************************************************************************/
+/*                                             Interface functions Implementation.                                             */
+/********************************************************************************/
+
+
+/********************************************************************************
+ *                        requestHandler_create                                                                        *
+ ********************************************************************************
+DESCRIPTION: RequestHandler module creation function, called by the measurement in 
+                               creation phase. performs the following:
+
+                               -       Allocate the RequestHandler handle
+                                                                                                                                  
+INPUT:      hOs -      Handle to OS            
+
+OUTPUT:                
+
+RETURN:     Handle to the RequestHandler module on success, NULL otherwise
+************************************************************************/
+TI_HANDLE requestHandler_create(TI_HANDLE hOs)
+{
+       requestHandler_t                        *pRequestHandler = NULL;
+       UINT32                  initVec = 0;
+       
+       
+       /* allocating the RequestHandler object */
+       pRequestHandler = os_memoryAlloc(hOs,sizeof(requestHandler_t));
+
+       if (pRequestHandler == NULL)
+               return NULL;
+
+       initVec |= (1 << REQUEST_HANDLER_INIT_BIT);
+
+       return(pRequestHandler);
+}
+
+/************************************************************************
+ *                        requestHandler_config                                                *
+ ************************************************************************
+DESCRIPTION: RequestHandler module configuration function, called by the measurement
+                         in configuration phase. performs the following:
+                               -       Reset & initiailzes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       List of handles to be used by the module
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS RequestHandler_config(TI_HANDLE      hRequestHandler,
+                                               TI_HANDLE               hReport,
+                                               TI_HANDLE               hOs)
+{
+       requestHandler_t *pRequestHandler = (requestHandler_t *)hRequestHandler;
+       
+
+       /* init variables */
+    pRequestHandler->parserRequestIEHdr = NULL;
+       pRequestHandler->numOfWaitingRequests = 0;      /*      indicating empty data base      */
+       pRequestHandler->activeRequestID = -1;          /*                                                              */
+       pRequestHandler->hReport        = hReport;
+       pRequestHandler->hOs            = hOs;
+
+       /* Clearing the Request Array , mostly due to parallel bit */
+       os_memoryZero(pRequestHandler->hOs, pRequestHandler->reqArr, MAX_NUM_REQ * sizeof(MeasurementRequest_t));
+
+       WLAN_REPORT_INIT(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, ("%s: RequestHandler configured successfully\n", __FUNCTION__));
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        requestHandler_setParam                                                                      
+ ***********************************************************************
+DESCRIPTION: RequestHandler set param function, called by the following:
+                       -       config mgr in order to set a parameter receiving from 
+                               the OS abstraction layer.
+                       -       From inside the dirver  
+                                                                                                   
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       pParam                  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS requestHandler_setParam(TI_HANDLE    hRequestHandler,
+                                                                 paramInfo_t   *pParam)
+{
+       requestHandler_t *pRequestHandler = (requestHandler_t *)hRequestHandler;
+       
+       switch(pParam->paramType)
+       {
+/*     case RequestHandler_PARAM_TYPE:*/
+               
+       /*      break;*/
+               
+       default:
+               WLAN_REPORT_ERROR(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Set param, Params is not supported, %d\n\n", __FUNCTION__, pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+/*     return OK; - unreachable */
+}
+
+/***********************************************************************
+ *                        requestHandler_getParam                                                                      
+ ***********************************************************************
+DESCRIPTION: RequestHandler get param function, called by the following:
+                       -       config mgr in order to get a parameter from the OS a
+                               bstraction layer.
+                       -       From inside the dirver  
+                                                                                                   
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       pParam                  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS requestHandler_getParam(TI_HANDLE            hRequestHandler,
+                                                                 paramInfo_t   *pParam)
+{
+       requestHandler_t *pRequestHandler = (requestHandler_t *)hRequestHandler;
+/*     TI_STATUS                       status;*/
+       
+       switch(pParam->paramType)
+       {
+       /*case RequestHandler_PARAM:*/
+               
+               
+               /*return status;*/
+       
+       default:
+               WLAN_REPORT_ERROR(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Get param, Params is not supported, %d\n\n", __FUNCTION__, pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+/*     return OK; - unreachable */
+}
+
+/************************************************************************
+ *                        RequestHandler_destroy                                               *
+ ************************************************************************
+DESCRIPTION: RequestHandler module destroy function, called by the config 
+                        mgr in the destroy phase 
+                        performs the following:
+                        -      Free all memory aloocated by the module
+                                                                                                   
+INPUT:      hRequestHandler    -       RequestHandler handle.          
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS requestHandler_destroy(TI_HANDLE hRequestHandler)
+{
+       requestHandler_t * pRequestHandler = (requestHandler_t *)hRequestHandler;
+       UINT32 initVec;
+
+       if (pRequestHandler == NULL)
+               return OK;
+
+       initVec = 0xFFFF;
+       release_module(pRequestHandler, initVec);
+
+       return OK;
+}
+
+/************************************************************************
+ *                  requestHandler_insertRequests                                              *
+ ************************************************************************
+DESCRIPTION: RequestHandler module parsing function, called by the 
+                         measurement object when measuremnt request frame is received.
+                               performs the following:
+                               -       Parsers the measurement request frame.
+                               -       Inserts all requests into the queue.
+                               -       Initializes each request according to the its frame 
+                                       token, measurement token, measurement type, parallel,
+                                       channel number, duration time and scan mode.
+                               -       The function updates the numOfWaitingRequests variable
+                                       and set to zero the activeReqId.
+
+                        Note:  The activeReqId contains the index for the first request
+                                       that should be executed or to the current active request.
+
+INPUT:      hRequestHandler        -   RequestHandler handle.
+                       measurementMode     -   The MEasurement Object Mode.
+                       measurementFrameReq -   The New Frame request that was received.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS requestHandler_insertRequests(TI_HANDLE hRequestHandler,
+                                                                               measurement_mode_e measurementMode,
+                                                                               measurement_frameRequest_t measurementFrameReq)
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+    INT32               requestsLen = measurementFrameReq.requestsLen;
+    UINT8               singelRequestLen = 0;
+    UINT8               *requests = measurementFrameReq.requests;
+                   
+       if (requestsLen < 2)
+    {
+        WLAN_REPORT_ERROR(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Invalid length of the data.\n", __FUNCTION__));
+
+        return NOK;
+    }
+
+       /* Inserting all measurement request into the queues */
+       while (requestsLen > 0)
+       {
+               if(insertMeasurementIEToQueue(hRequestHandler, 
+                                       measurementFrameReq.hdr->dialogToken, 
+                                       measurementMode, 
+                                       requests,
+                                       &singelRequestLen) != OK )
+        {
+            requestHandler_clearRequests(hRequestHandler);
+                       return NOK;
+        }
+  
+               requestsLen -= singelRequestLen;
+               requests += singelRequestLen;
+      
+       }
+
+       pRequestHandler->activeRequestID = 0;
+       
+       WLAN_REPORT_INFORMATION(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Inserted into queue: activeRequestID = %d, numOfWaitingRequests = %d\n", __FUNCTION__,
+                                       pRequestHandler->activeRequestID, pRequestHandler->numOfWaitingRequests));
+
+       return OK;
+}
+
+/************************************************************************
+ *                  requestHandler_getNextReq                                                  *
+ ************************************************************************
+DESCRIPTION: RequestHandler module function for retrieving the requests that
+                               should be executed.
+                               performs the following:
+                               -       returns pointers to one request/several requests that
+                                       should be performed in parallel.
+                               Note: The function updates the numOfWaitingRequests internal
+                               varaible ONLY IF the returned request/s are going to be 
+                               executed immediatly (isForActivation = TRUE).
+
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       
+                       isForActivation -       A flag that indicates if the returned 
+                                                               request/s are going to be executed immediatly
+
+OUTPUT:                pRequest                -       pointer contains the address in which the 
+                                                               next requests for activation should be inserted.
+               
+                       numOfRequests   -       indicates how many requests should be activated
+                                                               in parallel.
+                       
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS requestHandler_getNextReq(TI_HANDLE hRequestHandler,
+                                                                       BOOL      isForActivation,
+                                                                       MeasurementRequest_t *pRequest[],
+                                                                       UINT8*    numOfRequests)
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+       UINT8                           requestIndex = pRequestHandler->activeRequestID;
+       UINT8                           loopIndex = 0;
+       
+       WLAN_REPORT_INFORMATION(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Looking for requests. activeRequestID = %d, numOfWaitingRequests = %d\n", __FUNCTION__,
+                                       pRequestHandler->activeRequestID, pRequestHandler->numOfWaitingRequests));
+
+       if(pRequestHandler->numOfWaitingRequests <= 0)
+               return NOK;
+
+       do{
+               pRequest[loopIndex] = &(pRequestHandler->reqArr[requestIndex]);
+               requestIndex++;
+               loopIndex++;
+       }
+       while ( (loopIndex < pRequestHandler->numOfWaitingRequests) && 
+            (pRequestHandler->reqArr[requestIndex].isParallel) );
+
+       *numOfRequests = loopIndex;
+
+       WLAN_REPORT_INFORMATION(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Found %d requests to execute in parallel.\n", __FUNCTION__, loopIndex));
+
+       if(isForActivation == TRUE)
+       {
+               pRequestHandler->numOfWaitingRequests -= loopIndex;
+
+               WLAN_REPORT_INFORMATION(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                               ("%s: Requests were queried for activation so decreasing numOfWaitingRequests to %d\n", __FUNCTION__, pRequestHandler->numOfWaitingRequests));
+       }
+
+       return OK;
+}
+
+/************************************************************************
+ *                  requestHandler_getCurrentExpiredReq                                        *
+ ************************************************************************
+DESCRIPTION: RequestHandler module function for retrieving the request that
+                               finished its execution.
+                               performs the following:
+                               -       returns pointers to the request that
+                                       finished its execution in.
+
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       requestIndex    -       Index of request in the queue
+                       
+OUTPUT:                pRequest                -       pointer contains the addresse of the 
+                                                               request that finished its execution.
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS requestHandler_getCurrentExpiredReq(TI_HANDLE hRequestHandler,
+                                                                                         UINT8 requestIndex,
+                                                                                         MeasurementRequest_t **pRequest)
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+       
+       requestIndex += pRequestHandler->activeRequestID;
+
+       *pRequest = &(pRequestHandler->reqArr[requestIndex]);
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                  requestHandler_clearRequests                                               *
+ ************************************************************************
+DESCRIPTION: RequestHandler module function for cleaning the data base.
+                               performs the following:
+                               -       Clears all requests from the queue by setting
+                                       the activeReqId and numOfWaitingRequests variables.
+                       Note:   The function does not actually zero all queue 
+                                       variables or destroy the object.
+
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       
+OUTPUT:                None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS requestHandler_clearRequests(TI_HANDLE hRequestHandler)
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+
+       pRequestHandler->numOfWaitingRequests = 0;
+       pRequestHandler->activeRequestID = -1;
+       
+       /* Clearing the Request Array , mostly due to parallel bit */
+       os_memoryZero(pRequestHandler->hOs,pRequestHandler->reqArr,
+                                 MAX_NUM_REQ * sizeof(MeasurementRequest_t));  
+       
+       WLAN_REPORT_INFORMATION(pRequestHandler->hReport, MEASUREMENT_MNGR_MODULE_LOG, 
+                       ("%s: Request queue has been cleared. activeRequestID = %d, numOfWaitingRequests = %d\n", __FUNCTION__,
+                                       pRequestHandler->activeRequestID, pRequestHandler->numOfWaitingRequests));
+
+       return OK;
+}
+
+
+       
+/************************************************************************
+ *                  requestHandler_getFrameToken                                               *
+ ************************************************************************
+DESCRIPTION: RequestHandler module function for getting the token of the 
+                               frame that is now being processed.
+
+INPUT:      hRequestHandler    -       RequestHandler handle.
+                       
+                       
+OUTPUT:                frameToken
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS requestHandler_getFrameToken(TI_HANDLE hRequestHandler,UINT16 *frameToken )
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+
+       if(pRequestHandler->activeRequestID == -1)
+               return NOK;
+
+       *frameToken = pRequestHandler->reqArr[0].frameToken;
+       
+       return OK;
+}
+
+/************************************************************************
+ *              requestHandler_setRequestParserFunction                                        *
+ ************************************************************************
+DESCRIPTION: RequestHandler module function for setting the function that
+             parasers a request IE.
+
+INPUT:      hRequestHandler    -       RequestHandler handle.
+            parserRequestIE -   A pointer to the function.
+                       
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/      
+TI_STATUS requestHandler_setRequestParserFunction(TI_HANDLE hRequestHandler, 
+                                                  parserRequestIEHdr_t parserRequestIEHdr)
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+
+    pRequestHandler->parserRequestIEHdr = parserRequestIEHdr;
+
+    return OK;
+}
+
+/********************************************************************************/
+/*                                             Internal functions Implementation.                                              */
+/********************************************************************************/
+
+/************************************************************************
+ *                  insertMeasurementIEToQueue                                                 *
+ ************************************************************************
+DESCRIPTION: The function inserts measurement request of one received 
+                               measurement request information element.
+
+INPUT:      hRequestHandler    -       A Handler to the Request Handler Object.
+                       frameToken              -       Frame token of the received frame in which
+                                                               This current measurement request IE is included.
+            measurementObjMode - EXC or SPECTRUM_MNGMNT
+                       dataLen                 -       pointer to the data length that is left.
+                       pData                   -       pointer to the data.
+                       
+OUTPUT:                singelRequestLen - The Length of the request that was inserted 
+                               to the queue.
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+static TI_STATUS insertMeasurementIEToQueue(TI_HANDLE           hRequestHandler,
+                                                                                       UINT16                          frameToken,
+                                                                                       measurement_mode_e      measurementObjMode,
+                                                                                       UINT8                           *pData,
+                                            UINT8               *singelRequestLen)
+{
+       requestHandler_t        *pRequestHandler = (requestHandler_t *)hRequestHandler;
+
+       UINT16          HeaderLen;
+       UINT8           measurementMode;
+       UINT8           parallelBit;
+       UINT8           enableBit;
+       UINT16          durationTime;
+    UINT16      measurementToken;
+       
+       MeasurementRequest_t    *pCurrRequest = &(pRequestHandler->reqArr[pRequestHandler->numOfWaitingRequests]);
+
+    if (pRequestHandler->parserRequestIEHdr(pData, &HeaderLen, &measurementToken) != OK)
+    {
+        return NOK;
+    }
+
+       pCurrRequest->frameToken = frameToken;  
+       pCurrRequest->measurementToken = measurementToken;
+
+    pData += HeaderLen;
+
+    /*** Getting the Measurement Mode ***/
+       measurementMode         = *pData++;
+
+       /* getting parallel bit */
+       parallelBit = measurementMode & 0x1;
+       
+    /* getting Enable bit */
+       enableBit = (measurementMode & 0x2)>>1;
+       
+    /* checking enable bit, the current implementation does not support 
+               enable bit which set to one, so there is no need to check request/report bits   */
+       if(enableBit == 1)
+               return OK;
+    
+    pCurrRequest->isParallel = parallelBit;
+
+
+    /* Getting the Measurement Mode */
+       pCurrRequest->Type = (measurement_type_e)(*pData++);
+
+       /* Inserting the request that is included in the current measurement request IE. */
+       pCurrRequest->channelNumber = *pData++;
+    
+       pCurrRequest->ScanMode = (measurement_scanMode_e)(*pData++); /* IN dot11h - Spare = 0 */
+
+    os_memoryCopy(pRequestHandler->hOs, &durationTime, pData, 2);
+    durationTime = ENDIAN_HANDLE_WORD(durationTime);
+       pCurrRequest->DurationTime = durationTime;
+       
+       *singelRequestLen = HeaderLen + 6;
+
+       pRequestHandler->numOfWaitingRequests ++;
+       
+       return OK;
+}
+
+
+/***********************************************************************
+ *                        release_module                                                                       
+ ***********************************************************************
+DESCRIPTION:   Called by the destroy function or by the create function 
+                               (on failure). Go over the vector, for each bit that is 
+                               set, release the corresponding module.
+                                                                                                   
+INPUT:      pRequestHandler    -       RequestHandler pointer.
+                       initVec                 -       Vector that contains a bit set for each 
+                                                               module thah had been initiualized
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void release_module(requestHandler_t *pRequestHandler, UINT32 initVec)
+{
+       
+       if ( initVec & (1 << REQUEST_HANDLER_INIT_BIT) )
+               utils_nullMemoryFree(pRequestHandler->hOs, pRequestHandler, 
+               sizeof(requestHandler_t));
+               
+       initVec = 0;
+}
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/SwitchChannel/SwitchChannel.c b/sta_dk_4_0_4_32/common/src/Management/AirLink/SwitchChannel/SwitchChannel.c
new file mode 100644 (file)
index 0000000..7856c8e
--- /dev/null
@@ -0,0 +1,1624 @@
+/** \file SwitchChannel.c
+ *  \brief SwitchChannel module interface
+ *
+ *  \see SwitchChannelApi.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**  
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************************************/
+/*                                                                                                                                                                                                     */
+/*             MODULE:         SwitchChannel.c                                                                                                                                                 */
+/*             PURPOSE:        SwitchChannel module interface.                                                                                                                 */
+/*                  This module perform SwitchChannel (Dynamic Frequency Selection)                                                    */
+/*                                             according to AP command. The object responsibles for switching channel after*/
+/*                                             the requires time and quieting the channel for the required duration            */
+/*                                             time.                                                                                                                                           */
+/****************************************************************************************************/
+#include "report.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "utils.h"
+#include "SwitchChannelApi.h"
+#include "DataCtrl_Api.h"
+#include "regulatoryDomainApi.h"
+#include "apConn.h"
+#include "siteMgrApi.h"
+#include "PowerMgr_API.h"
+#include "whalCtrl_api.h"
+#include "healthMonitor.h"
+#include "fsm.h"
+
+/* allocation vector */
+#define SC_INIT_BIT                                            (1)
+#define SC_SM_INIT_BIT                                 (2)
+
+#define SC_SWITCH_CHANNEL_CMD_LEN                              3
+#define SC_SWITCH_CHANNEL_MODE_NOT_TX_SUS              0
+#define SC_SWITCH_CHANNEL_MODE_TX_SUS                  1
+
+
+#define SC_CHANNEL_INVALID                     FALSE
+#define SC_CHANNEL_VALID                       TRUE
+
+/* Enumerations */
+
+/** state machine states */
+typedef enum 
+{
+       SC_STATE_IDLE           = 0,
+       SC_STATE_WAIT_4_CMD     = 1,
+       SC_STATE_WAIT_4_SCR     = 2,
+       SC_STATE_SC_IN_PROG     = 3,
+       SC_STATE_LAST           = 4
+} switchChannel_smStates;
+
+/** State machine events */
+typedef enum 
+{
+       SC_EVENT_START          = 0,
+       SC_EVENT_STOP           = 1,
+       SC_EVENT_SC_CMD         = 2,
+       SC_EVENT_SCR_RUN        = 3,
+       SC_EVENT_SCR_FAIL       = 4,
+       SC_EVENT_SC_CMPLT       = 5,
+       SC_EVENT_FW_RESET       = 6,
+       SC_EVENT_LAST           = 7
+} switchChannel_smEvents;
+
+
+#define SC_NUM_STATES          SC_STATE_LAST    
+#define SC_NUM_EVENTS          SC_EVENT_LAST   
+
+
+/* Structures */
+typedef struct 
+{
+
+       /* SwitchChannel parameters that can be configured externally */
+       BOOL            dot11SpectrumManagementRequired;
+
+       /* Internal SwitchChannel parameters */
+       switchChannel_smStates  currentState;
+       dot11_CHANNEL_SWITCH_t  curChannelSwitchCmdParams;
+       UINT32                                  SCRRequestTimestamp;
+       UINT8                                   currentChannel;
+       BOOL                                    switchChannelStarted;
+
+#ifdef TI_DBG
+       /* switchChannelCmd for debug */
+       dot11_CHANNEL_SWITCH_t  debugChannelSwitchCmdParams;
+       UINT8                                   ignoreCancelSwitchChannelCmd;
+#endif
+       
+       /* SwitchChannel SM */
+       fsm_stateMachine_t          *pSwitchChannelSm;
+
+       /* SwitchChannel handles to other objects */                                
+       TI_HANDLE       hHalCtrl;
+       TI_HANDLE       hSiteMgr;
+       TI_HANDLE               hSCR;
+       TI_HANDLE               hRegulatoryDomain;
+       TI_HANDLE               hPowerMngr;
+       TI_HANDLE               hApConn;
+       TI_HANDLE       hReport;
+       TI_HANDLE       hOs;
+    TI_HANDLE       hHealthMonitor;
+
+} switchChannel_t;
+
+
+
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+
+#ifdef REPORT_LOG
+
+static char *switchChannel_stateDesc[SC_NUM_STATES] = {  
+       "STATE_IDLE",              
+       "STATE_WAIT_4_CMD",             
+       "STATE_WAIT_4_SCR",     
+       "STATE_SC_IN_PROG"            
+};
+
+static char *switchChannel_eventDesc[SC_NUM_EVENTS] = {
+       "EVENT_START",        
+       "EVENT_STOP",             
+       "EVENT_SC_CMD",         
+       "EVENT_SCR_RUN",   
+       "EVENT_SCR_FAIL",
+       "EVENT_SC_CMPLT",
+    "EVENT_FW_RESET"
+};                           
+
+#endif
+
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+
+
+/* SM functions */
+static TI_STATUS switchChannel_smStartSwitchChannelCmd(void *pData);
+static TI_STATUS switchChannel_smReqSCR_UpdateCmd(void *pData);
+static TI_STATUS switchChannel_smSwitchChannelCmplt(void *pData);
+static TI_STATUS switchChannel_smFwResetWhileSCInProg(void *pData);
+static TI_STATUS switchChannel_smScrFailWhileWait4Scr(void *pData);
+static TI_STATUS switchChannel_smNop(void *pData);
+static TI_STATUS switchChannel_smUnexpected(void *pData);
+static TI_STATUS switchChannel_smStopWhileWait4Cmd(void *pData);
+static TI_STATUS switchChannel_smStopWhileWait4Scr(void *pData);
+static TI_STATUS switchChannel_smStopWhileSwitchChannelInProg(void *pData);
+static TI_STATUS switchChannel_smStart(void *pData);
+
+
+/* other functions */
+static void release_module(switchChannel_t *pSwitchChannel, UINT32 initVec);
+static TI_STATUS switchChannel_smEvent(UINT8 *currState, UINT8 event, void* data);
+static void switchChannel_zeroDatabase(switchChannel_t *pSwitchChannel);
+void switchChannel_SwitchChannelCmdCompleteReturn(TI_HANDLE hSwitchChannel);
+void switchChannel_scrStatusCB(TI_HANDLE hSwitchChannel, scr_clientRequestStatus_e requestStatus, 
+                                                 scr_pendReason_e pendReason );
+#ifdef TI_DBG
+static void switchChannel_recvCmd4Debug(TI_HANDLE hSwitchChannel, dot11_CHANNEL_SWITCH_t *channelSwitch, BOOL BeaconPacket, UINT8 channel);
+#endif
+
+
+/********************************************************************************/
+/*                                             Interface functions Implementation.                                             */
+/********************************************************************************/
+
+
+/************************************************************************
+ *                        switchChannel_create                                                 *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure is called by the config manager when the driver is created.
+* It creates the SwitchChannel object.
+*
+* \b ARGS:
+*
+*  I - hOs - OS context \n
+*
+* \b RETURNS:
+*
+*  Handle to the SwitchChannel object.
+*
+* \sa 
+*/
+TI_HANDLE switchChannel_create(TI_HANDLE hOs)
+{
+       switchChannel_t           *pSwitchChannel = NULL;
+       UINT32          initVec = 0;
+       TI_STATUS               status;
+
+       /* allocating the SwitchChannel object */
+       pSwitchChannel = os_memoryAlloc(hOs,sizeof(switchChannel_t));
+
+       if (pSwitchChannel == NULL)
+               return NULL;
+
+       initVec |= (1 << SC_INIT_BIT);
+
+       os_memoryZero(hOs, pSwitchChannel, sizeof(switchChannel_t));
+
+       pSwitchChannel->hOs = hOs;
+
+       status = fsm_Create(hOs, &pSwitchChannel->pSwitchChannelSm, SC_NUM_STATES, SC_NUM_EVENTS);
+       if (status != OK)
+       {
+               release_module(pSwitchChannel, initVec);
+           WLAN_OS_REPORT(("FATAL ERROR: switchChannel_create(): Error Creating pSwitchChannelSm - Aborting\n"));
+               return NULL;
+       }
+       initVec |= (1 << SC_SM_INIT_BIT);
+
+       return(pSwitchChannel);
+}
+
+/************************************************************************
+ *                        switchChannel_config                                                 *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure is called by the config manager when the driver is configured.
+* It initializes the SwitchChannel object's variables and handlers and creates the SwitchChannel SM.
+*
+* \b ARGS:
+*
+*  I - hSwitchChannel - SwitchChannel context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise
+*
+* \sa 
+*/
+TI_STATUS switchChannel_config(TI_HANDLE                               hSwitchChannel,
+                                                         TI_HANDLE                             hHalCtrl,
+                                                         TI_HANDLE                             hSiteMgr,
+                                                         TI_HANDLE                             hSCR,
+                                                         TI_HANDLE                                     hRegulatoryDomain,
+                                                         TI_HANDLE                                             hApConn,
+                                                         TI_HANDLE                             hReport,
+                                                         TI_HANDLE                             hOs,
+                              TI_HANDLE                     hHealthMonitor,
+                                                         SwitchChannelInitParams_t    *SwitchChannelInitParams)
+{
+       switchChannel_t       *pSwitchChannel = (switchChannel_t *)hSwitchChannel;
+       TI_STATUS   status;
+
+
+       /** Roaming State Machine matrix */
+       fsm_actionCell_t    switchChannel_SM[SC_NUM_STATES][SC_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {   {SC_STATE_WAIT_4_CMD, switchChannel_smStart},                               /* START        */
+                       {SC_STATE_IDLE, switchChannel_smNop},                                           /* STOP         */ 
+                       {SC_STATE_IDLE, switchChannel_smNop},                                           /* SC_CMD      */
+                       {SC_STATE_IDLE, switchChannel_smUnexpected},                            /* SCR_RUN      */ 
+                       {SC_STATE_IDLE, switchChannel_smUnexpected},                            /* SCR_FAIL     */
+                       {SC_STATE_IDLE, switchChannel_smUnexpected},                            /* SC_CMPLT    */
+                       {SC_STATE_IDLE, switchChannel_smUnexpected}                                     /* FW_RESET         */
+               },                                                                              
+
+               /* next state and actions for WAIT_4_CMD state */    
+               {   {SC_STATE_WAIT_4_CMD, switchChannel_smNop},                                         /* START        */
+                       {SC_STATE_IDLE, switchChannel_smStopWhileWait4Cmd},                         /* STOP         */ 
+                       {SC_STATE_WAIT_4_SCR, switchChannel_smReqSCR_UpdateCmd},                /* SC_CMD      */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smUnexpected},                              /* SCR_RUN      */ 
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smUnexpected},                          /* SCR_FAIL         */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smUnexpected},                              /* SC_CMPLT    */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smUnexpected}                   /* FW_RESET    */
+
+               },                                                                              
+
+               /* next state and actions for WAIT_4_SCR state */    
+               {   {SC_STATE_WAIT_4_SCR, switchChannel_smUnexpected},                              /* START        */
+                       {SC_STATE_IDLE, switchChannel_smStopWhileWait4Scr},                                     /* STOP         */
+                       {SC_STATE_WAIT_4_SCR, switchChannel_smNop},                                             /* SC_CMD      */
+                       {SC_STATE_SC_IN_PROG, switchChannel_smStartSwitchChannelCmd},       /* SCR_RUN      */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smScrFailWhileWait4Scr},        /* SCR_FAIL    */
+                       {SC_STATE_WAIT_4_SCR, switchChannel_smUnexpected} ,                                     /* SC_CMPLT    */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smUnexpected}                           /* FW_RESET    */
+
+               },                                                                              
+
+               /* next state and actions for switchChannel_IN_PROG state */
+               {   {SC_STATE_SC_IN_PROG, switchChannel_smUnexpected},                                   /* START        */
+                       {SC_STATE_IDLE, switchChannel_smStopWhileSwitchChannelInProg},           /* STOP         */
+                       {SC_STATE_SC_IN_PROG, switchChannel_smNop},                                          /* SC_CMD      */
+                       {SC_STATE_SC_IN_PROG, switchChannel_smUnexpected},                                       /* SCR_RUN      */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smUnexpected},                               /* SCR_FAIL    */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smSwitchChannelCmplt},                       /* SC_CMPLT    */
+                       {SC_STATE_WAIT_4_CMD, switchChannel_smFwResetWhileSCInProg}              /* FW_RESET    */
+
+               }                                                                             
+
+
+       }; 
+
+       status = fsm_Config(pSwitchChannel->pSwitchChannelSm, 
+                                               &switchChannel_SM[0][0], 
+                                               SC_NUM_STATES, 
+                                               SC_NUM_EVENTS, 
+                                               switchChannel_smEvent, pSwitchChannel->hOs);
+       if (status != OK)
+       {
+               return status;
+       }
+
+
+       /* init handlers */
+       pSwitchChannel->hHalCtrl  = hHalCtrl;
+       pSwitchChannel->hSiteMgr  = hSiteMgr;
+       pSwitchChannel->hSCR    = hSCR;
+       pSwitchChannel->hRegulatoryDomain= hRegulatoryDomain;
+       pSwitchChannel->hApConn     = hApConn;
+       pSwitchChannel->hReport   = hReport;
+       pSwitchChannel->hOs       = hOs;
+    pSwitchChannel->hHealthMonitor = hHealthMonitor;
+
+       /* init variables */
+       pSwitchChannel->dot11SpectrumManagementRequired = SwitchChannelInitParams->dot11SpectrumManagementRequired;
+       pSwitchChannel->currentState = SC_STATE_IDLE;
+       pSwitchChannel->currentChannel = 0;
+       pSwitchChannel->switchChannelStarted = FALSE;
+
+       /* register to SCR */
+       scr_registerClientCB(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL, 
+                                                switchChannel_scrStatusCB, pSwitchChannel);
+
+       /* register to Switch Channel Complete event in HAL */
+       whalCtrl_EventMbox_RegisterForEvent(pSwitchChannel->hHalCtrl, 
+                                                                               HAL_EVENT_SWITCH_CHANNEL_CMPLT, 
+                                                                               (void *)switchChannel_SwitchChannelCmdCompleteReturn, 
+                                                                               pSwitchChannel);
+
+       whalCtrl_EventMbox_Enable(pSwitchChannel->hHalCtrl, HAL_EVENT_SWITCH_CHANNEL_CMPLT);
+#ifdef TI_DBG
+       /* for debug */
+       pSwitchChannel->debugChannelSwitchCmdParams.hdr.eleId = CHANNEL_SWITCH_ANNOUNCEMENT_IE_ID;
+       pSwitchChannel->debugChannelSwitchCmdParams.hdr.eleLen = SC_SWITCH_CHANNEL_CMD_LEN;
+       pSwitchChannel->ignoreCancelSwitchChannelCmd = 0;
+#endif
+       WLAN_REPORT_INIT(hReport, SC_MODULE_LOG,  
+                                        (".....SwitchChannel configured successfully\n"));
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        switchChannel_stop                                                   *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure is called by the SME when the state is changed from CONNECTED.
+* It generates a STOP event to the SwitchChannel SM.
+*
+* \b ARGS:
+*
+*  I - hSwitchChannel - SwitchChannel context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise
+*
+* \sa 
+*/
+TI_STATUS switchChannel_stop(TI_HANDLE hSwitchChannel)
+{
+       switchChannel_t *pSwitchChannel = (switchChannel_t *)hSwitchChannel;
+
+       pSwitchChannel->switchChannelStarted = FALSE;
+       return (switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_STOP, pSwitchChannel));
+
+}
+
+/************************************************************************
+ *                        switchChannel_start                                                  *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure is called by the SME when the state is changed to CONNECTED.
+* It generates a START event to the SwitchChannel SM.
+*
+* \b ARGS:
+*
+*  I - hSwitchChannel - SwitchChannel context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise
+*
+* \sa 
+*/
+TI_STATUS switchChannel_start(TI_HANDLE hSwitchChannel)
+{
+       switchChannel_t *pSwitchChannel = (switchChannel_t *)hSwitchChannel;
+       pSwitchChannel->switchChannelStarted = TRUE;
+
+       return (switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_START, pSwitchChannel));
+
+}
+
+
+/************************************************************************
+ *                        switchChannel_unload                                                 *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure is called by the config manager when the driver is unloaded.
+* It frees any memory allocated and timers.
+*
+* \b ARGS:
+*
+*  I - hSwitchChannel - SwitchChannel context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise
+*
+* \sa 
+*/
+TI_STATUS switchChannel_unload(TI_HANDLE hSwitchChannel)
+{
+       UINT32              initVec;
+       switchChannel_t *pSwitchChannel = (switchChannel_t *)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+               return OK;
+
+       initVec = 0xff;
+       release_module(pSwitchChannel, initVec);
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        switchChannel_recvCmd                                                        *
+ ************************************************************************/
+/*DESCRIPTION: This function is called by MLME Parser upon receiving of
+                               Beacon, Probe Response or Action with Switch Channel command,
+                               or beacon/
+                               performs the following:
+                               -       Initializes the switching channel procedure.
+                               -       Setting timer to the actual switching time(if needed)
+                               
+INPUT:      hSwitchChannel             - SwitchChannel handle.
+                       switchMode                      - indicates whether to stop transmission
+                                                                   until the scheduled channel switch.
+                       newChannelNum           - indicates the number of the new channel.
+                       durationTime            - indicates the time (expressed in ms) until
+                                                                   the scheduled channel switch should accure.
+
+OUTPUT:                None
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+void switchChannel_recvCmd(TI_HANDLE hSwitchChannel, dot11_CHANNEL_SWITCH_t *channelSwitch, UINT8 channel)
+{
+
+       switchChannel_t             *pSwitchChannel = (switchChannel_t *)hSwitchChannel;
+       paramInfo_t                 param;
+
+       if (pSwitchChannel==NULL)
+       {
+               return;
+       }
+
+    param.paramType = REGULATORY_DOMAIN_DFS_CHANNELS_RANGE;
+    regulatoryDomain_getParam(pSwitchChannel->hRegulatoryDomain, &param);
+
+       if (!pSwitchChannel->dot11SpectrumManagementRequired ||
+        (channel < param.content.DFS_ChannelRange.minDFS_channelNum) ||
+        (channel > param.content.DFS_ChannelRange.maxDFS_channelNum))
+       {       /* Do not parse Switch Channel IE, when SpectrumManagement is disabled,
+            or the channel is non-DFS channel */
+               return;
+       }
+#ifdef TI_DBG
+    /* for debug purposes only */
+       if (pSwitchChannel->ignoreCancelSwitchChannelCmd != 0)
+    {
+        return;
+    }
+#endif
+
+       if (channelSwitch == NULL)
+       {   /* No SC IE, update regDomain */
+        param.paramType = REGULATORY_DOMAIN_UPDATE_CHANNEL_VALIDITY;
+        param.content.channel = channel;
+        regulatoryDomain_setParam(pSwitchChannel->hRegulatoryDomain, &param);
+       } 
+    else 
+       {   /* SC IE exists */
+               WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                               ("switchChannel_recvFrame, SwitchChannel cmd was found, channel no=%d, mode=%d, TBTT=%d \n",
+                                                                channelSwitch->channelNumber, channelSwitch->channelSwitchMode,
+                                                                channelSwitch->channelSwitchCount)); 
+
+               /* Checking channel number validity */
+        param.content.channel = channelSwitch->channelNumber;
+        param.paramType = REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED;
+        regulatoryDomain_getParam(pSwitchChannel->hRegulatoryDomain,&param);
+        if ( ( !param.content.bIsChannelSupprted )   || 
+                       (channelSwitch->channelSwitchCount == 0) || 
+                       (channelSwitch->channelSwitchMode == SC_SWITCH_CHANNEL_MODE_TX_SUS))
+               {   /* Trigger Roaming, if TX mode is disabled, the new channel number is invalid, 
+                or the TBTT count is 0 */
+            WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                    ("report Roaming trigger\n")); 
+                       if (channelSwitch->channelSwitchMode == SC_SWITCH_CHANNEL_MODE_TX_SUS) 
+                       {
+                               param.paramType = REGULATORY_DOMAIN_SET_CHANNEL_VALIDITY;
+                               param.content.channelValidity.channelNum = channel;
+                               param.content.channelValidity.channelValidity = FALSE;
+                               regulatoryDomain_setParam(pSwitchChannel->hRegulatoryDomain, &param);
+                       }
+            apConn_reportRoamingEvent(pSwitchChannel->hApConn, ROAMING_TRIGGER_SWITCH_CHANNEL, NULL);
+               }
+               else
+               {   /* Invoke Switch Channel command */
+            /* update the new SCC params */
+            pSwitchChannel->curChannelSwitchCmdParams.channelNumber = channelSwitch->channelNumber;
+            pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount = channelSwitch->channelSwitchCount;
+            pSwitchChannel->curChannelSwitchCmdParams.channelSwitchMode = channelSwitch->channelSwitchMode;
+            switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_SC_CMD, pSwitchChannel);
+               }
+
+       }
+
+}
+
+
+/************************************************************************
+ *                        switchChannel_powerSaveStatusReturn                  *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure is called when power save status is returned
+*
+* \b ARGS:
+*
+*  I/O - hSwitchChannel - SwitchChannel context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+void switchChannel_SwitchChannelCmdCompleteReturn(TI_HANDLE hSwitchChannel)
+{
+       switchChannel_t                 *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                         ("switchChannel_SwitchChannelCmdCompleteReturn \n"));
+
+       switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_SC_CMPLT, pSwitchChannel);
+
+}
+
+/************************************************************************
+ *                        switchChannel_enableDisableSpectrumMngmt                     *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* This procedure enables or disables the spectrum management
+*
+* \b ARGS:
+*
+*  I - hSwitchChannel - SwitchChannel context \n
+*  I - enableDisable - TRUE - Enable, FALSE - Disable
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+void switchChannel_enableDisableSpectrumMngmt(TI_HANDLE hSwitchChannel, BOOL enableDisable)
+{
+       switchChannel_t                 *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+
+       if (hSwitchChannel == NULL)
+       {
+               return;
+       }
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                         ("switchChannel_enableDisableSpectrumMngmt, enableDisable=%d \n", enableDisable));
+
+       pSwitchChannel->dot11SpectrumManagementRequired = enableDisable;
+
+       if (enableDisable)
+       {       /* Enable SC, if it was started invoke start event.
+                       otherwise, wait for a start event */
+               if (pSwitchChannel->switchChannelStarted)
+               {
+                       switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_START, pSwitchChannel);
+               }
+       }
+       else
+       {       /* Disable SC */
+               switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_STOP, pSwitchChannel);
+       }
+
+}
+
+
+
+/************************************************************************
+ *                        SwitchChannel internal functions                             *
+ ************************************************************************/
+
+/************************************************************************
+ *                        switchChannel_smEvent                                                        *
+ ************************************************************************/
+/**
+*
+* \b Description: 
+*
+* SwitchChannel state machine transition function
+*
+* \b ARGS:
+*
+*  I/O - currentState - current state in the state machine\n
+*  I   - event - specific event for the state machine\n
+*  I   - pData - Data for state machine action function\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS switchChannel_smEvent(UINT8 *currState, UINT8 event, void* data)
+{
+       TI_STATUS       status;
+       UINT8           nextState;
+       switchChannel_t           *pSwitchChannel = (switchChannel_t*)data;
+
+
+       status = fsm_GetNextState(pSwitchChannel->pSwitchChannelSm, *currState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pSwitchChannel->hReport, SC_MODULE_LOG, ("switchChannel_smEvent, fsm_GetNextState error\n"));
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                  ("<%s, %s> --> %s\n\n",
+                                       switchChannel_stateDesc[*currState],
+                                       switchChannel_eventDesc[event],
+                                       switchChannel_stateDesc[nextState]));
+
+       status = fsm_Event(pSwitchChannel->pSwitchChannelSm, currState, event, (void *)pSwitchChannel);
+
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pSwitchChannel->hReport, SC_MODULE_LOG, ("switchChannel_smEvent fsm_Event error\n"));
+               WLAN_REPORT_ERROR(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                 ("<%s, %s> --> %s\n\n",
+                                                  switchChannel_stateDesc[*currState],
+                                                  switchChannel_eventDesc[event],
+                                                  switchChannel_stateDesc[nextState]));
+
+       }
+       return status;
+
+}
+
+
+/************************************************************************
+ *                        switchChannel_smStart                                                        *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when the station becomes connected.
+ * update the current channel.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smStart(void *pData)
+{
+       switchChannel_t                       *pSwitchChannel = (switchChannel_t*)pData;
+       paramInfo_t                                     param;
+       /*scr_clientRequestStatus_e   scrStatus;*/
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+       
+       /* get the current channel number */
+       param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+       siteMgr_getParam(pSwitchChannel->hSiteMgr, &param);
+       pSwitchChannel->currentChannel = param.content.siteMgrCurrentChannel;
+       
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smStart, channelNo=%d\n",
+                                                        pSwitchChannel->currentChannel));
+       return OK;
+
+}
+
+/************************************************************************
+ *                        switchChannel_smReqSCR_UpdateCmd                             *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* Update the Switch Channel command parameters.
+ * Request SCR and wait for SCR return.
+ * if tx status suspend
+ *     update regulatory Domain
+ *     update tx
+ *     start periodic timer 
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smReqSCR_UpdateCmd(void *pData)
+{
+       switchChannel_t                       *pSwitchChannel = (switchChannel_t*)pData;
+       /*TI_STATUS                   status;*/
+       scr_clientRequestStatus_e   scrStatus;
+       scr_pendReason_e                        scrPendReason;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smReqSCR_UpdateCmd, channelNo=%d, TBTT = %d, Mode = %d\n",
+                                                        pSwitchChannel->curChannelSwitchCmdParams.channelNumber,
+                                                        pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount,
+                                                        pSwitchChannel->curChannelSwitchCmdParams.channelSwitchMode));
+
+
+       /* Save the TS when requesting SCR */
+       pSwitchChannel->SCRRequestTimestamp = os_timeStampMs(pSwitchChannel->hOs); 
+       
+       scrStatus = scr_clientRequest(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL, &scrPendReason);
+       if ((scrStatus != SCR_CRS_RUN) && (scrStatus != SCR_CRS_PEND))
+       {       
+               WLAN_REPORT_ERROR(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                       ("switchChannel_smReqSCR_UpdateCmd():Abort the switch channel, request Roaming, scrStatus=%d\n", scrStatus));
+               return (switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_SCR_FAIL, pSwitchChannel));
+
+       }
+    if (scrStatus == SCR_CRS_RUN)
+    {
+               switchChannel_scrStatusCB(pSwitchChannel, scrStatus, scrPendReason);
+    }
+    else if ((scrPendReason==SCR_PR_OTHER_CLIENT_RUNNING) ||
+         (scrPendReason==SCR_PR_DIFFERENT_GROUP_RUNNING) )
+    {   /* No use to wait for the SCR, invoke FAIL */
+               return (switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_SCR_FAIL, pSwitchChannel));
+    }
+    /* wait for the SCR callback function to be called */
+       return OK;
+
+}
+
+
+/************************************************************************
+ *                        switchChannel_scrStatusCB                                            *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called by the SCR when:
+ * the resource is reserved for the SwitchChannel - SCR_CRS_RUN
+ * recovery occurred - SCR_CRS_ABORT
+ * other = ERROR
+*
+* \b ARGS:
+*
+*  I   - hSwitchChannel - pointer to the SwitchChannel SM context  \n
+*  I   - requestStatus - the SCR request status  \n
+*  I   - pendReason - The SCR pend status in case of pend reply  \n
+*
+* \b RETURNS:
+*
+*  None.
+*
+* 
+*************************************************************************/
+void switchChannel_scrStatusCB(TI_HANDLE hSwitchChannel, scr_clientRequestStatus_e requestStatus, 
+                                                 scr_pendReason_e pendReason )
+{
+       switchChannel_t             *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+    switchChannel_smEvents      scEvent;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+
+       switch (requestStatus)
+       {
+    case SCR_CRS_RUN: 
+        scEvent = SC_EVENT_SCR_RUN;
+               break;
+    case SCR_CRS_FW_RESET:
+        scEvent = SC_EVENT_FW_RESET;
+               break;
+    case SCR_CRS_PEND:
+        scEvent = SC_EVENT_SCR_FAIL;
+        break;
+       case SCR_CRS_ABORT: 
+       default:
+               WLAN_REPORT_ERROR(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                          ("switchChannel_scrStatusCB scrStatus = %d, pendReason=%d\n", 
+                           requestStatus, pendReason));
+        scEvent = SC_EVENT_SCR_FAIL;
+               break;
+       }
+
+    switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, scEvent, pSwitchChannel);
+
+}
+
+
+
+/************************************************************************
+ *                        switchChannel_smStartSwitchChannelCmd                        *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called once SwitchChannel command was received and the SCR
+ * request returned with reason RUN. 
+ * In this case perform the following:
+ *  Set CMD to FW
+
+
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smStartSwitchChannelCmd(void *pData)
+{
+       switchChannel_t                                                         *pSwitchChannel = (switchChannel_t *)pData;
+       whalCtrl_switchChannelCmd_t     pSwitchChannelCmd;
+       UINT32                                                  switchChannelTimeDuration;
+       paramInfo_t                                             param;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+
+       param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
+       siteMgr_getParam(pSwitchChannel->hSiteMgr, &param);
+
+       switchChannelTimeDuration = pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount * param.content.beaconInterval * 1024 / 1000;
+       if (  (switchChannelTimeDuration!=0) &&
+               ((os_timeStampMs(pSwitchChannel->hOs) - pSwitchChannel->SCRRequestTimestamp) >= switchChannelTimeDuration ))
+       {       /* There's no time to perfrom the SCC, set the Count to 1 */
+        pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount = 1;
+       }
+
+    apConn_indicateSwitchChannelInProgress(pSwitchChannel->hApConn);
+
+    /* suspend self test to avoid wrong tx stuck indications */
+    healthMonitor_suspendPeriodicTest( pSwitchChannel->hHealthMonitor );
+
+       pSwitchChannelCmd.channelNumber = pSwitchChannel->curChannelSwitchCmdParams.channelNumber;
+       pSwitchChannelCmd.switchTime    = pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount;
+       pSwitchChannelCmd.txFlag                = pSwitchChannel->curChannelSwitchCmdParams.channelSwitchMode;
+       pSwitchChannelCmd.flush                 = 0;
+       whalCtrl_SwitchChannelCmd (pSwitchChannel->hHalCtrl, &pSwitchChannelCmd);
+       
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                         ("whalCtrl_SwitchChannelCmd:Set the cmd in HAL. Params:\n channelNumber=%d, switchTime=%d, txFlag=%d, flush=%d \n", 
+                                                          pSwitchChannelCmd.channelNumber,
+                                                          pSwitchChannelCmd.switchTime,
+                                                          pSwitchChannelCmd.txFlag,
+                                                          pSwitchChannelCmd.flush));
+
+       return OK;
+
+}
+
+/************************************************************************
+ *    switchChannel_smFwResetWhileSCInProg                     *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when Switch Channel command is cancelled. 
+ * In this case update TX nad regulatory Domain adn HAL.
+ * Release the SCR and exit PS.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smFwResetWhileSCInProg(void *pData)
+{
+       switchChannel_t          *pSwitchChannel = (switchChannel_t *)pData;
+       paramInfo_t          param;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                         ("switchChannel_smFwResetWhileSCInProg \n"));
+
+       /* Update new current channel */
+       param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+       param.content.siteMgrCurrentChannel = pSwitchChannel->curChannelSwitchCmdParams.channelNumber;
+       siteMgr_setParam(pSwitchChannel->hSiteMgr, &param);
+
+    apConn_indicateSwitchChannelFinished(pSwitchChannel->hApConn);
+
+    switchChannel_zeroDatabase(pSwitchChannel);
+
+    /* resume self test */
+    healthMonitor_resumePeriodicTest( pSwitchChannel->hHealthMonitor );
+
+    /* release the SCR */
+       scr_clientComplete(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL);
+       
+       return OK;
+
+}
+
+
+/************************************************************************
+ *                        switchChannel_smSwitchChannelCmplt                   *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when SwitchChannel command completed in FW.
+ * In this case release SCR and update current channel.
+ * If TX was sus, it will be enabled only after first Beacon is recieved.
+ * Exit PS.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smSwitchChannelCmplt(void *pData)
+{
+       switchChannel_t                         *pSwitchChannel = (switchChannel_t *)pData;
+       paramInfo_t             param;
+       
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+       
+       /* Update new current channel */
+       param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+       param.content.siteMgrCurrentChannel = pSwitchChannel->curChannelSwitchCmdParams.channelNumber;
+       siteMgr_setParam(pSwitchChannel->hSiteMgr, &param);
+
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smSwitchChannelCmplt, new channelNum = %d\n", pSwitchChannel->currentChannel));
+
+    apConn_indicateSwitchChannelFinished(pSwitchChannel->hApConn);
+    switchChannel_zeroDatabase(pSwitchChannel);
+
+    /* resume self test */
+    healthMonitor_resumePeriodicTest( pSwitchChannel->hHealthMonitor );
+
+       /* release the SCR */
+       scr_clientComplete(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL);
+
+       return OK;
+
+}
+
+
+/************************************************************************
+ *                        switchChannel_smScrFailWhileWait4Scr                 *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when recovery occurred, while waiting for SCR due
+ * to previous switch channel command. 
+ * Exit PS
+ * Release SCR. 
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smScrFailWhileWait4Scr(void *pData)
+{
+       switchChannel_t                       *pSwitchChannel = (switchChannel_t*)pData;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smScrFailWhileWait4Scr\n"));
+
+    switchChannel_zeroDatabase(pSwitchChannel);
+
+       /* release the SCR is not required !!! */
+       scr_clientComplete(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL);
+
+       return OK;
+}
+
+/************************************************************************
+ *                        switchChannel_smStopWhileWait4Cmd                            *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when the station becomes Disconnected and the current
+* state is Wait4Cmd. In this case perfrom:
+ * Stop the timer
+ * Enable TX if it was disabled
+ * Zero the current command parameters
+ * Stop the timer
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smStopWhileWait4Cmd(void *pData)
+{
+       switchChannel_t                       *pSwitchChannel = (switchChannel_t*)pData;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smStopWhileWait4Cmd\n"));
+
+       switchChannel_zeroDatabase(pSwitchChannel);
+       
+       return OK;
+}
+
+/************************************************************************
+ *                        switchChannel_smStopWhileWait4Scr                                    *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when the station becomes Disconnected and the current
+* state is Wait4Scr. In this case perfrom:
+ * Stop the timer
+ * Enable TX if it was disabled
+ * Zero the current command parameters
+ * Complete SCR
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smStopWhileWait4Scr(void *pData)
+{
+       switchChannel_t                       *pSwitchChannel = (switchChannel_t*)pData;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smStopWhileWait4Scr\n"));
+
+
+       switchChannel_zeroDatabase(pSwitchChannel);
+       
+       /* release the SCR */
+       scr_clientComplete(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL);
+
+       return OK;
+}
+
+/************************************************************************
+ *         switchChannel_smStopWhileSwitchChannelInProg                                        *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when the station becomes Disconnected and the current
+* state is SwitchChannelInProg. In this case perfrom:
+ * Stop the timer
+ * Enable TX if it was disabled
+ * Zero the current command parameters
+ * resume self test
+ * Complete SCR
+ * Exit PS
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*************************************************************************/
+static TI_STATUS switchChannel_smStopWhileSwitchChannelInProg(void *pData)
+{
+       switchChannel_t                       *pSwitchChannel = (switchChannel_t*)pData;
+
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       ("switchChannel_smStopWhileSwitchChannelInProg\n"));
+
+       /* Exit PS */
+       /*PowerMgr_exitFromDriverMode(pSwitchChannel->hPowerMngr, "SwitchChannel");*/
+
+    apConn_indicateSwitchChannelFinished(pSwitchChannel->hApConn);
+
+    whalCtrl_SwitchChannelCancelCmd (pSwitchChannel->hHalCtrl, pSwitchChannel->currentChannel);
+       switchChannel_zeroDatabase(pSwitchChannel);
+       
+    /* resume self test */
+    healthMonitor_resumePeriodicTest( pSwitchChannel->hHealthMonitor );
+
+       /* release the SCR */
+       scr_clientComplete(pSwitchChannel->hSCR, SCR_CID_SWITCH_CHANNEL);
+
+       return OK;
+}
+
+
+
+
+/************************************************************************
+ *                        switchChannel_zeroDatabase                                   *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called when the SwitchChannel internal database should be zero.
+ * The following parameters are zerod:
+ * SwitchChannelChannelRange - the timestamps and validity state of channels
+ * curChannelSwitchCmdParams - the current switch channel command parameters
+*
+* \b ARGS:
+*
+*  I   - pSwitchChannel - pointer to the SwitchChannel SM context  \n
+*  I   - channelNum - channel number  \n
+*  I   - timestamp - required timestamp  \n
+*
+* \b RETURNS:
+*
+*  None.
+*
+* 
+*************************************************************************/
+static void switchChannel_zeroDatabase(switchChannel_t *pSwitchChannel)
+{
+
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, ("switchChannel_zeroDatabase\n"));
+
+
+       pSwitchChannel->curChannelSwitchCmdParams.channelNumber = 0;
+       pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount = 0;
+       pSwitchChannel->curChannelSwitchCmdParams.channelSwitchMode = SC_SWITCH_CHANNEL_MODE_NOT_TX_SUS;
+       pSwitchChannel->currentChannel = 0;
+
+}
+
+/***********************************************************************
+ *                        release_module                               
+ ***********************************************************************/
+/* 
+DESCRIPTION:   Called by the destroy function or by the create function (on failure)
+                               Go over the vector, for each bit that is set, release the corresponding module.
+                                                                                                                                                                                                  
+INPUT:      pSwitchChannel     -       SwitchChannel pointer.
+                       initVec -       Vector that contains a bit set for each module thah had been initiualized
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void release_module(switchChannel_t *pSwitchChannel, UINT32 initVec)
+{
+    if (pSwitchChannel == NULL)
+    {
+        return;
+    }
+    if (initVec & (1 << SC_SM_INIT_BIT))
+       {
+               fsm_Unload(pSwitchChannel->hOs, pSwitchChannel->pSwitchChannelSm);
+       }
+
+       if (initVec & (1 << SC_INIT_BIT))
+       {
+               utils_nullMemoryFree(pSwitchChannel->hOs, pSwitchChannel, sizeof(switchChannel_t));
+       }
+
+       initVec = 0;
+}
+
+
+/**
+*
+* switchChannel_smNop - Do nothing
+*
+* \b Description: 
+*
+* Do nothing in the SM.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS switchChannel_smNop(void *pData)
+{
+       switchChannel_t       *pSwitchChannel;
+
+       pSwitchChannel = (switchChannel_t*)pData;
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+       WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                                       (" switchChannel_smNop\n"));
+
+       return OK;
+}
+
+/**
+*
+* switchChannel_smUnexpected - Unexpected event
+*
+* \b Description: 
+*
+* Unexpected event in the SM.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the SwitchChannel SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS switchChannel_smUnexpected(void *pData)
+{
+       switchChannel_t       *pSwitchChannel;
+
+       pSwitchChannel = (switchChannel_t*)pData;
+       if (pSwitchChannel == NULL)
+       {
+               return NOK;
+       }
+       WLAN_REPORT_ERROR(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                         (" switchChannel_smUnexpected, state = %d\n", pSwitchChannel->currentState));
+
+       return NOK;
+}
+
+/*******************************************************************************
+***********                                    Debug functions                                  ***********               
+*******************************************************************************/
+#ifdef TI_DBG
+
+/************************************************************************
+ *                        switchChannel_recvCmd                                                        *
+ ************************************************************************/
+/*DESCRIPTION: This function is called by MLME Parser upon receiving of
+                               Beacon, Probe Response or Action with Switch Channel command,
+                               or beacon/
+                               performs the following:
+                               -       Initializes the switching channel procedure.
+                               -       Setting timer to the actual switching time(if needed)
+                               
+INPUT:      hSwitchChannel                             -       SwitchChannel handle.
+                       switchMode                      - indicates whether to stop transmission
+                                                               until the scheduled channel switch.
+                       newChannelNum           - indicates the number of the new channel.
+                       durationTime            - indicates the time (expressed in ms) until
+                                                               the scheduled channel switch should accure.
+
+OUTPUT:                None
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static void switchChannel_recvCmd4Debug(TI_HANDLE hSwitchChannel, dot11_CHANNEL_SWITCH_t *channelSwitch, BOOL BeaconPacket, UINT8 channel)
+{
+
+       switchChannel_t             *pSwitchChannel = (switchChannel_t *)hSwitchChannel;
+       paramInfo_t                 param;
+
+       if (pSwitchChannel==NULL)
+       {
+               return;
+       }
+
+
+       /* The following is for debug purposes only
+               It will be operated when the Switch Channel cmd is opertated from debug CLI */
+       if (pSwitchChannel->ignoreCancelSwitchChannelCmd != 0)
+       {
+               if (pSwitchChannel->ignoreCancelSwitchChannelCmd == 1)
+               {
+            /* update the new SCC params */
+            pSwitchChannel->curChannelSwitchCmdParams.channelNumber = channelSwitch->channelNumber;
+            pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount = channelSwitch->channelSwitchCount;
+            pSwitchChannel->curChannelSwitchCmdParams.channelSwitchMode = channelSwitch->channelSwitchMode;
+            
+            pSwitchChannel->ignoreCancelSwitchChannelCmd = 2;
+               }
+               else if (channelSwitch->channelSwitchCount>0)
+               {
+                       channelSwitch->channelSwitchCount --;
+               }
+               else
+               {       
+                       pSwitchChannel->ignoreCancelSwitchChannelCmd = 0;
+               }
+
+
+        /* search in the buffer pointer to the beginning of the
+            Switch Cahnnel Announcement IE according to the IE ID */
+        
+        /* SC IE exists on the serving channel */
+        WLAN_REPORT_INFORMATION(pSwitchChannel->hReport, SC_MODULE_LOG, 
+                                ("switchChannel_recvFrame, SwitchChannel cmd was found, channel no=%d, mode=%d, TBTT=%d \n",
+                                 channelSwitch->channelNumber, channelSwitch->channelSwitchMode,
+                                 channelSwitch->channelSwitchCount)); 
+
+        /* Checking channel number validity */
+        param.content.channel = channelSwitch->channelNumber;
+        param.paramType = REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED;
+        regulatoryDomain_getParam(pSwitchChannel->hRegulatoryDomain,&param);
+        if (( !param.content.bIsChannelSupprted ) || 
+            (channelSwitch->channelSwitchCount == 0) || 
+            (channelSwitch->channelSwitchMode == SC_SWITCH_CHANNEL_MODE_TX_SUS))
+        {   /* Trigger Roaming, if TX mode is disabled, the new channel number is invalid, 
+                or the TBTT count is 0 */
+            apConn_reportRoamingEvent(pSwitchChannel->hApConn, ROAMING_TRIGGER_SWITCH_CHANNEL, NULL);
+        }
+        else
+        {   /* Invoke Switch Channel command */
+            /* update the new SCC params */
+            pSwitchChannel->curChannelSwitchCmdParams.channelNumber = channelSwitch->channelNumber;
+            pSwitchChannel->curChannelSwitchCmdParams.channelSwitchCount = channelSwitch->channelSwitchCount;
+            pSwitchChannel->curChannelSwitchCmdParams.channelSwitchMode = channelSwitch->channelSwitchMode;
+            switchChannel_smEvent((UINT8*)&pSwitchChannel->currentState, SC_EVENT_SC_CMD, pSwitchChannel);
+        }
+       }
+
+}
+
+void switchChannelDebug_setCmdParams(TI_HANDLE hSwitchChannel, SC_switchChannelCmdParam_e switchChannelCmdParam, UINT8 param)
+{
+       switchChannel_t       *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+       
+       switch (switchChannelCmdParam)
+       {
+       case SC_SWITCH_CHANNEL_NUM:
+               WLAN_OS_REPORT(("SwitchChannelDebug_setSwitchChannelCmdParams, channelNum=%d \n ", param));
+               pSwitchChannel->debugChannelSwitchCmdParams.channelNumber = param;
+               break;
+       case SC_SWITCH_CHANNEL_TBTT:
+               WLAN_OS_REPORT(("SwitchChannelDebug_setSwitchChannelCmdParams, channelSwitchCount=%d \n ", param));
+               pSwitchChannel->debugChannelSwitchCmdParams.channelSwitchCount = param;
+               break;
+       case SC_SWITCH_CHANNEL_MODE:
+               WLAN_OS_REPORT(("SwitchChannelDebug_setSwitchChannelCmdParams, channelSwitchMode=%d \n ", param));
+               pSwitchChannel->debugChannelSwitchCmdParams.channelSwitchMode = param;
+               break;
+       default:
+               WLAN_OS_REPORT(("ERROR: SwitchChannelDebug_setSwitchChannelCmdParams, wrong switchChannelCmdParam=%d \n ",
+                                               switchChannelCmdParam));
+                       break;
+       }
+
+}
+void switchChannelDebug_SwitchChannelCmdTest(TI_HANDLE hSwitchChannel, BOOL BeaconPacket)
+{
+       switchChannel_t       *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+       
+       WLAN_OS_REPORT(("SwitchChannelDebug_SwitchChannelCmdTest, BeaconPacket=%d \n cmd params: channelNumber=%d, channelSwitchCount=%d, channelSwitchMode=%d \n",
+                                       BeaconPacket,
+                                       pSwitchChannel->debugChannelSwitchCmdParams.channelNumber,
+                                       pSwitchChannel->debugChannelSwitchCmdParams.channelSwitchCount,
+                                       pSwitchChannel->debugChannelSwitchCmdParams.channelSwitchMode));
+
+
+       pSwitchChannel->ignoreCancelSwitchChannelCmd= 1;
+       switchChannel_recvCmd4Debug(hSwitchChannel, &pSwitchChannel->debugChannelSwitchCmdParams, BeaconPacket, pSwitchChannel->currentChannel);
+}
+
+void switchChannelDebug_CancelSwitchChannelCmdTest(TI_HANDLE hSwitchChannel, BOOL BeaconPacket)
+{
+
+       switchChannel_t       *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+       
+       WLAN_OS_REPORT(("SwitchChannelDebug_SwitchChannelCmdTest, BeaconPacket=%d \n",BeaconPacket));
+
+       pSwitchChannel->ignoreCancelSwitchChannelCmd= 0;
+       switchChannel_recvCmd4Debug(hSwitchChannel, NULL, BeaconPacket, pSwitchChannel->currentChannel);
+}
+
+
+void switchChannelDebug_printStatus(TI_HANDLE hSwitchChannel)
+{
+       switchChannel_t       *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+       
+       WLAN_OS_REPORT(("SwitchChannel debug params are: channelNumber=%d, channelSwitchCount=%d , channelSwitchMode=%d \n", 
+                                       pSwitchChannel->debugChannelSwitchCmdParams.channelNumber, 
+                                       pSwitchChannel->debugChannelSwitchCmdParams.channelSwitchCount,
+                                       pSwitchChannel->debugChannelSwitchCmdParams.channelSwitchMode));
+
+       WLAN_OS_REPORT(("SwitchChannel state=%d, currentChannel=%d \n", pSwitchChannel->currentState, pSwitchChannel->currentChannel));
+
+
+}
+
+void switchChannelDebug_setChannelValidity(TI_HANDLE hSwitchChannel, UINT8 channelNum, BOOL validity)
+{
+    paramInfo_t param;
+
+       switchChannel_t       *pSwitchChannel = (switchChannel_t*)hSwitchChannel;
+
+       if (pSwitchChannel == NULL)
+       {
+               return;
+       }
+
+    param.paramType = REGULATORY_DOMAIN_SET_CHANNEL_VALIDITY;
+    param.content.channelValidity.channelNum = channelNum;
+    param.content.channelValidity.channelValidity = validity;
+    regulatoryDomain_setParam(pSwitchChannel->hRegulatoryDomain, &param);
+
+}
+
+#endif
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/SwitchChannelApi.h b/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/SwitchChannelApi.h
new file mode 100644 (file)
index 0000000..6f5a355
--- /dev/null
@@ -0,0 +1,96 @@
+/** \file SwitchChannel.h
+ *  \brief SwitchChannel module interface header file
+ *
+ *  \see SwitchChannel.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       SwitchChannel.h                                                                                                         */
+/*    PURPOSE: SwitchChannel module inteerface header file                                                     */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __SWITCH_CHANNEL_H__
+#define __SWITCH_CHANNEL_H__
+
+#include "paramOut.h"
+
+
+TI_HANDLE switchChannel_create(TI_HANDLE hOs);
+
+TI_STATUS switchChannel_config(TI_HANDLE          hSwitchChannel,
+                                        TI_HANDLE          hHalCtrl,
+                                        TI_HANDLE          hSiteMgr,
+                                        TI_HANDLE          hSCR,
+                                        TI_HANDLE                      hRegulatoryDomain,
+                                        TI_HANDLE                      hApConn,
+                                        TI_HANDLE          hReport,
+                                        TI_HANDLE          hOs,
+                     TI_HANDLE          hHealthMonitor,
+                                        SwitchChannelInitParams_t    *SwitchChannelInitParams);
+
+TI_STATUS switchChannel_stop(TI_HANDLE hSwitchChannel);
+
+TI_STATUS switchChannel_start(TI_HANDLE hSwitchChannel);
+
+TI_STATUS switchChannel_unload(TI_HANDLE hSwitchChannel);
+
+void switchChannel_recvCmd(TI_HANDLE hSwitchChannel, dot11_CHANNEL_SWITCH_t *channelSwitch, UINT8 channel);
+
+void switchChannel_enableDisableSpectrumMngmt(TI_HANDLE hSwitchChannel, BOOL enableDisable);
+
+
+
+/* for debug */
+typedef enum
+{
+       SC_SWITCH_CHANNEL_NUM,
+       SC_SWITCH_CHANNEL_TBTT,
+       SC_SWITCH_CHANNEL_MODE
+} SC_switchChannelCmdParam_e;
+
+#ifdef TI_DBG
+
+void switchChannelDebug_switchChannelCmdTest(TI_HANDLE hSwitchChannel, BOOL BeaconPacket);
+void switchChannelDebug_CancelSwitchChannelCmdTest(TI_HANDLE hSwitchChannel, BOOL BeaconPacket);
+void switchChannelDebug_setChannelValidity(TI_HANDLE hSwitchChannel, UINT8 channelNum, BOOL validity);
+void switchChannelDebug_printStatus(TI_HANDLE hSwitchChannel);
+void switchChannelDebug_setCmdParams(TI_HANDLE hSwitchChannel, SC_switchChannelCmdParam_e switchChannelCmdParam, UINT8 param);
+void switchChannelDebug_SwitchChannelCmdTest(TI_HANDLE hSwitchChannel, BOOL BeaconPacket);
+#endif
+
+#endif /* __SWITCH_CHANNEL_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgr.h b/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgr.h
new file mode 100644 (file)
index 0000000..0b9c571
--- /dev/null
@@ -0,0 +1,164 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       measurementMgr.h                                                                                   */
+/*    PURPOSE: measurement Manager module header file                                     */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+
+
+
+#ifndef __MEASUREMENTMGR_H__
+#define __MEASUREMENTMGR_H__
+
+
+#include "report.h"
+#include "paramOut.h"
+#include "requestHandler.h"
+#include "measurementMgrSM.h"
+#ifdef EXC_MODULE_INCLUDED
+ #include "excRMMngrParam.h"
+#endif
+
+
+/* Functions Pointers Definitions */
+typedef TI_STATUS (*parserFrameReq_t)   (TI_HANDLE hMeasurementMgr, 
+                                         UINT8 *pData, INT32 dataLen,
+                                         measurement_frameRequest_t *frameReq);
+
+typedef BOOL (*isTypeValid_t)           (TI_HANDLE hMeasurementMgr, 
+                                         measurement_type_e type, 
+                                         measurement_scanMode_e scanMode);
+
+typedef TI_STATUS (*buildRejectReport_t) (TI_HANDLE hMeasurementMgr,
+                                                                                 MeasurementRequest_t *pRequestArr[],
+                                                                                 UINT8 numOfRequestsInParallel,
+                                                                                 measurement_rejectReason_e rejectReason);
+
+typedef TI_STATUS (*buildReport_t)             (TI_HANDLE hMeasurementMgr,
+                                                                                MeasurementRequest_t request,
+                                                                                measurement_typeReply_t * reply);
+
+typedef TI_STATUS (*sendReportAndCleanObj_t)(TI_HANDLE hMeasurementMgr);
+
+
+
+typedef struct 
+{
+
+    /* Timers */
+       void *                                          pActivationDelayTimer;
+
+
+    /* Methods */
+    parserFrameReq_t            parserFrameReq;
+    isTypeValid_t               isTypeValid;
+    buildRejectReport_t                        buildRejectReport;
+       buildReport_t                           buildReport;
+       sendReportAndCleanObj_t         sendReportAndCleanObj;
+
+
+    /* Data */
+    BOOL                                               Enabled;
+       BOOL                                            Connected;
+
+       UINT8                                           servingChannelID;
+       UINT8                                           measuredChannelID;
+
+       measurement_mode_e                      Mode;   
+       UINT8                                           Capabilities;
+       BOOL                        isModuleRegistered;
+
+       UINT16                                          trafficIntensityThreshold;
+    UINT16                      maxDurationOnNonServingChannel;
+
+
+    /* State Machine Params */
+    fsm_stateMachine_t *               pMeasurementMgrSm;
+    measurementMgrSM_States            currentState;
+
+       
+    /* Report Frame Params */
+#ifdef EXC_MODULE_INCLUDED
+       RM_report_frame_t                       excFrameReport;
+#endif
+       MeasurementReportFrame_t        dot11hFrameReport;
+       UINT16                                          nextEmptySpaceInReport;
+       UINT16                                          frameLength;
+
+
+    /* Request Frame Params */
+    MeasurementRequest_t *      currentRequest[MAX_NUM_REQ];
+       UINT8                                           currentNumOfRequestsInParallel;
+       measurement_frameType_e         currentFrameType;
+       UINT32                                          currentRequestStartTime;
+    measurement_frameRequest_t newFrameRequest;
+
+
+       /* EXC Traffic Stream Metrics measurement parameters */
+       void                                            *pTsMetricsReportTimer[MAX_NUM_OF_AC];
+       BOOL                                            isTsMetricsEnabled[MAX_NUM_OF_AC];
+
+       /* Handles to other modules */
+       TI_HANDLE                                       hRequestH;
+       TI_HANDLE                                       hMacServices;
+       TI_HANDLE                                       hRegulatoryDomain;
+       TI_HANDLE                                       hExcMngr;
+       TI_HANDLE                                       hSiteMgr;
+       TI_HANDLE                                       hHalCtrl;
+       TI_HANDLE                                       hMlme;
+    TI_HANDLE                   hTrafficMonitor;
+       TI_HANDLE                                       hReport;
+       TI_HANDLE                                       hOs;
+    TI_HANDLE                   hScr;
+    TI_HANDLE                   hHealthMonitor;
+    TI_HANDLE                   hApConn;
+    TI_HANDLE                   hTx;
+} measurementMgr_t;
+
+
+
+
+TI_STATUS measurementMgr_activateNextRequest(TI_HANDLE pContext);
+
+
+
+
+#endif /* __MEASUREMENTMGR_H__*/
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgrApi.h b/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgrApi.h
new file mode 100644 (file)
index 0000000..585f824
--- /dev/null
@@ -0,0 +1,113 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       measurementMgrApi.h                                                                                */
+/*    PURPOSE: Measurement Manager module interface header file                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+
+
+
+
+#ifndef __MEASUREMENTMGR_API_H__
+#define __MEASUREMENTMGR_API_H__
+
+
+
+
+#include "measurementTypes.h"
+#include "scrApi.h"
+#include "mlmeApi.h"
+
+
+
+
+
+
+
+TI_HANDLE measurementMgr_create(TI_HANDLE hOs);
+
+TI_STATUS measurementMgr_config(TI_HANDLE      hMeasurementMgr,
+                                                               TI_HANDLE       hMacServices,
+                                                               TI_HANDLE       hRegulatoryDomain,
+                                                               TI_HANDLE       hExcMngr,
+                                                               TI_HANDLE       hSiteMgr,
+                                                               TI_HANDLE       hHalCtrl,
+                                                               TI_HANDLE       hMlme,
+                                TI_HANDLE      hTrafficMonitor,
+                                                               TI_HANDLE       hReport,
+                                                               TI_HANDLE       hOs,
+                                TI_HANDLE      hScr,
+                                TI_HANDLE      hHealthMonitor,
+                                                               TI_HANDLE       hApConn,
+                                                               TI_HANDLE       hTx,
+                                                               measurementInitParams_t * pMeasurementInitParams);
+
+TI_STATUS measurementMgr_destroy(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgr_setParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam);
+
+TI_STATUS measurementMgr_getParam(TI_HANDLE hMeasurementMgr, paramInfo_t * pParam);
+
+TI_STATUS measurementMgr_connected(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgr_disconnected(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgr_enable(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgr_disable(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgr_setMeasurementMode(TI_HANDLE hMeasurementMgr, UINT16 capabilities, 
+                                                                                       UINT8 * pIeBuffer, UINT16 length);
+
+TI_STATUS measurementMgr_receiveFrameRequest(TI_HANDLE hMeasurementMgr, measurement_frameType_e frameType,
+                                                                                       INT32 dataLen, UINT8 * pData);
+
+void measurementMgr_rejectPendingRequests(TI_HANDLE hMeasurementMgr, measurement_rejectReason_e rejectReason);
+
+void measurementMgr_MeasurementCompleteCB(TI_HANDLE clientObj, measurement_reply_t * msrReply);
+
+void measurementMgr_scrResponseCB(TI_HANDLE hClient, scr_clientRequestStatus_e requestStatus,
+                                                               scr_pendReason_e pendReason);
+
+void measurementMgr_mlmeResultCB(TI_HANDLE hMeasurementMgr, macAddress_t * bssid, mlmeFrameInfo_t * frameInfo, 
+                                                                Rx_attr_t * pRxAttr, UINT8 * buffer, UINT16 bufferLength);
+
+
+#endif /* __MEASUREMENTMGR_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgrSM.h b/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/measurementMgrSM.h
new file mode 100644 (file)
index 0000000..652ac1e
--- /dev/null
@@ -0,0 +1,93 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       measurementMgrSM.h                                                                                 */
+/*    PURPOSE: measurement Manager module State Machine header file       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef __MEASUREMENTMGRSM_H__
+#define __MEASUREMENTMGRSM_H__
+
+#include "fsm.h"
+
+
+
+/** State machine states */
+typedef enum 
+{
+       MEASUREMENTMGR_STATE_IDLE                                       = 0,
+    MEASUREMENTMGR_STATE_PROCESSING_REQUEST            = 1,
+    MEASUREMENTMGR_STATE_WAITING_FOR_SCR               = 2,
+    MEASUREMENTMGR_STATE_MEASURING                             = 3,
+       MEASUREMENTMGR_STATE_LAST                                       = 4
+} measurementMgrSM_States;
+
+
+/** State machine events */
+typedef enum 
+{
+       MEASUREMENTMGR_EVENT_CONNECTED                          = 0,
+       MEASUREMENTMGR_EVENT_DISCONNECTED                       = 1,
+       MEASUREMENTMGR_EVENT_ENABLE                                     = 2,
+       MEASUREMENTMGR_EVENT_DISABLE                            = 3,
+    MEASUREMENTMGR_EVENT_FRAME_RECV                            = 4,
+    MEASUREMENTMGR_EVENT_SEND_REPORT                   = 5,
+       MEASUREMENTMGR_EVENT_REQUEST_SCR                        = 6,
+    MEASUREMENTMGR_EVENT_SCR_WAIT                              = 7,
+    MEASUREMENTMGR_EVENT_SCR_RUN                               = 8,
+    MEASUREMENTMGR_EVENT_ABORT                                 = 9,
+    MEASUREMENTMGR_EVENT_COMPLETE                              = 10,
+    MEASUREMENTMGR_EVENT_FW_RESET                              = 11,
+       MEASUREMENTMGR_EVENT_LAST                                       = 12
+} measurementMgrSM_Events;
+
+
+#define MEASUREMENTMGR_NUM_STATES              MEASUREMENTMGR_STATE_LAST        
+#define MEASUREMENTMGR_NUM_EVENTS              MEASUREMENTMGR_EVENT_LAST       
+
+
+
+
+TI_STATUS measurementMgrSM_config(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgrSM_event(UINT8 * currentState, UINT8 event, TI_HANDLE hMeasurementMgr);
+
+
+
+#endif /* __MEASUREMENTMGRSM_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/requestHandler.h b/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/requestHandler.h
new file mode 100644 (file)
index 0000000..48ecb51
--- /dev/null
@@ -0,0 +1,123 @@
+/** \file requestHandler.h
+ *  \brief Request Handler module interface header file
+ *
+ *  \see requestHandler.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       requestHandler.h                                                                                        */
+/*    PURPOSE: Request Handler module interface header file                            */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __REQUEST_HANDLER_H__
+#define __REQUEST_HANDLER_H__
+
+#include "paramOut.h"
+#include "802_11Defs.h"
+#include "measurementMgrApi.h"
+
+PACKED_STRUCT( MeasurementRequest_t    ,
+
+       measurement_type_e              Type;
+       BOOL                                    isParallel;     
+       UINT16                                  frameToken;     
+       UINT16                                  measurementToken;
+       UINT8                                   channelNumber;
+       UINT16                                  DurationTime;
+       UINT8                                   ActualDurationTime;
+       measurement_scanMode_e  ScanMode;
+);
+
+
+/* Functions Pointers Definitions */
+typedef TI_STATUS (*parserRequestIEHdr_t)   (UINT8 *pData, UINT16 *reqestLen,
+                                             UINT16 *measurementToken);
+
+typedef struct 
+{
+    /* Function to the Pointer */
+    parserRequestIEHdr_t   parserRequestIEHdr;
+
+    /* General Params */
+       MeasurementRequest_t    reqArr[MAX_NUM_REQ];
+       UINT8                           numOfWaitingRequests;   
+       INT8                            activeRequestID;
+
+    /* Handlers */
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hOs;
+} requestHandler_t;
+
+
+
+TI_HANDLE requestHandler_create(TI_HANDLE hOs);
+
+TI_STATUS RequestHandler_config(TI_HANDLE      hRequestHandler,
+                                                       TI_HANDLE               hReport,
+                                                       TI_HANDLE               hOs);
+
+TI_STATUS requestHandler_setParam(TI_HANDLE    hRequestHandler,
+                                                                 paramInfo_t   *pParam);
+
+TI_STATUS requestHandler_getParam(TI_HANDLE            hRequestHandler,
+                                                                                       paramInfo_t     *pParam);
+
+TI_STATUS requestHandler_destroy(TI_HANDLE hRequestHandler);
+
+TI_STATUS requestHandler_insertRequests(TI_HANDLE hRequestHandler,
+                                                                               measurement_mode_e measurementMode,
+                                                                               measurement_frameRequest_t measurementFrameReq);
+
+TI_STATUS requestHandler_getNextReq(TI_HANDLE hRequestHandler,
+                                                                       BOOL      isForActivation,
+                                                                       MeasurementRequest_t *pRequest[],
+                                                                       UINT8*    numOfRequests);
+
+TI_STATUS requestHandler_getCurrentExpiredReq(TI_HANDLE hRequestHandler,
+                                                                                         UINT8 requestIndex,
+                                                                                         MeasurementRequest_t **pRequest);
+
+TI_STATUS requestHandler_clearRequests(TI_HANDLE hRequestHandler);
+
+TI_STATUS requestHandler_getFrameToken(TI_HANDLE hRequestHandler,UINT16 *frameToken );
+
+TI_STATUS requestHandler_setRequestParserFunction(TI_HANDLE hRequestHandler, 
+                                                  parserRequestIEHdr_t parserRequestIEHdr);
+
+
+#endif /* __REQUEST_HANDLER_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/spectrumMngmntMgr.h b/sta_dk_4_0_4_32/common/src/Management/AirLink/inc/spectrumMngmntMgr.h
new file mode 100644 (file)
index 0000000..1de41fc
--- /dev/null
@@ -0,0 +1,100 @@
+/** \file spectrumMngmntMgr.h
+ *  \brief dot11h spectrum Management Meneger module interface header file
+ *
+ *  \see spectrumMngmntMgr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       spectrumMngmntMgr.h                                                                                     */
+/*    PURPOSE: dot11h spectrum Management Meneger module interface         */
+/*              header file                                                            */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __SPECTRUMMNGMNTMGR_H__
+#define __SPECTRUMMNGMNTMGR_H__
+
+#include "paramOut.h"
+#include "measurementMgr.h"
+#include "requestHandler.h"
+
+
+
+TI_STATUS measurementMgr_receiveQuietIE(TI_HANDLE hMeasurementMgr,
+                                                                 UINT8         quietCount,
+                                                                 UINT8         quietPeriod,
+                                                                 UINT16        quietDuration,
+                                                                 UINT16        quietOffset);
+
+
+TI_STATUS measurementMgr_receiveTPCRequest(TI_HANDLE hMeasurementMgr,
+                                                                               UINT8           dataLen,
+                                                                               UINT8           *pData);
+
+TI_STATUS measurementMgr_dot11hParseFrameReq(TI_HANDLE hMeasurementMgr, 
+                                           UINT8 *pData, INT32 dataLen,
+                                           measurement_frameRequest_t *frameReq);
+
+TI_STATUS measurementMgr_dot11hParseRequestIEHdr(UINT8 *pData, UINT16 *reqestHdrLen,
+                                               UINT16 *measurementToken);
+
+BOOL      measurementMgr_dot11hIsTypeValid(TI_HANDLE hMeasurementMgr, 
+                                         measurement_type_e type, 
+                                         measurement_scanMode_e scanMode);
+
+TI_STATUS measurementMgr_dot11hBuildReport(TI_HANDLE hMeasurementMgr, MeasurementRequest_t request, measurement_typeReply_t * reply);
+
+TI_STATUS measurementMgr_dot11hSendReportAndCleanObject(TI_HANDLE hMeasurementMgr);
+
+TI_STATUS measurementMgr_dot11hBuildRejectReport(TI_HANDLE hMeasurementMgr,
+                                                                                        MeasurementRequest_t *pRequestArr[],
+                                                                                        UINT8          numOfRequestsInParallel,
+                                                                                        measurement_rejectReason_e     rejectReason);
+
+
+/* The following function uses features from the old Measurement module. */
+/* It will have to be adapted to using the new Measurement Manager. */
+#if 0
+
+TI_STATUS measurementMgr_getBasicMeasurementParam(TI_HANDLE hMeasurementMgr,
+                                                                                 acxStatisitcs_t*      pAcxStatisitics,
+                                                                                 mediumOccupancy_t* pMediumOccupancy);
+#endif /* 0 */
+
+
+
+#endif /* __SPECTRUMMNGMNTMGR_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr.c b/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr.c
new file mode 100644 (file)
index 0000000..44d9224
--- /dev/null
@@ -0,0 +1,1596 @@
+/** \file PowerMgr.c
+ *  \brief This is the PowerMgr module implementation.
+ *  \author Assaf Azulay
+ *  \date 24-Oct-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  PowerMgr                                                      *
+ *   PURPOSE: PowerMgr Module implementation.                               *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "report.h"
+#include "PowerMgr.h"
+#include "PowerMgr_API.h"
+#include "TrafficMonitorAPI.h"
+#include "qosMngr_API.h"
+#include "siteMgrApi.h"
+#include "SoftGeminiApi.h"
+
+/*****************************************************************************
+ **         Defines                                                         **
+ *****************************************************************************/
+#define DEFAULT_LISTEN_INTERVAL (1)
+
+#define BET_DISABLE 0
+#define BET_ENABLE  1
+
+/*****************************************************************************
+ **         Private Function prototypes                                      **
+ *****************************************************************************/
+
+static void         powerSaveCompleteCB(TI_HANDLE hPowerMgr,UINT8 PSMode,UINT8 transStatus);
+static void         PowerMgrTMThresholdCrossCB( TI_HANDLE hPowerMgr, UINT32 cookie );
+static void         powerMgrDisableThresholdsIndications(TI_HANDLE hPowerMgr);
+static void         powerMgrEnableThresholdsIndications(TI_HANDLE hPowerMgr);
+static void         powerMgrStartAutoPowerMode(TI_HANDLE hPowerMgr);
+static void         powerMgrRetryPsTimeout(TI_HANDLE hPowerMgr);
+static void         powerMgrPowerProfileConfiguration(TI_HANDLE hPowerMgr, PowerMgr_PowerMode_e desiredPowerMode);
+static TI_STATUS    powerMgrSendMBXWakeUpConditions(TI_HANDLE hPowerMgr,UINT8 listenInterval, PowerMgr_TnetWakeOn_e tnetWakeupOn);
+static TI_STATUS    powerMgrNullPacketRateConfiguration(TI_HANDLE hPowerMgr);
+static PowerMgr_PowerMode_e powerMgrGetHighestPriority(TI_HANDLE hPowerMgr);
+static void         PowerMgr_setDozeModeInAuto(TI_HANDLE hPowerMgr,PowerMgr_PowerMode_e dozeMode);
+static void         PowerMgrConfigBetToFw( TI_HANDLE hPowerMgr, UINT32 cookie );
+static void         PowerMgr_PsPollFailureCB( TI_HANDLE hPowerMgr );
+static void         powerMgr_PsPollFailureTimeout(TI_HANDLE hPowerMgr);
+#ifdef CPU_LOAD
+       static void             powerMgr_CpuLoadTimeout(TI_HANDLE hPowerMgr);
+#endif
+static void powerMgr_SGSetUserDesiredwakeUpCond( TI_HANDLE hPowerMgr );
+
+
+/*****************************************************************************
+ **         Public Function prototypes                                      **
+ *****************************************************************************/
+
+
+/****************************************************************************************
+ *                        PowerMgr_create                                                           *
+ ****************************************************************************************
+DESCRIPTION: Creates the object of the power Manager. 
+                performs the following:
+                -   Allocate the Power Manager handle
+                -   Creates the retry timer
+                                                                                                                   
+INPUT:          - hOs - Handle to OS        
+OUTPUT:     
+RETURN:     Handle to the Power Manager module on success, NULL otherwise
+****************************************************************************************/
+TI_HANDLE PowerMgr_create(TI_HANDLE hOs)
+{
+
+    PowerMgr_t * pPowerMgr = NULL;
+    pPowerMgr = (PowerMgr_t*) os_memoryAlloc (hOs, sizeof(PowerMgr_t));
+    if ( pPowerMgr == NULL )
+    {
+        WLAN_OS_REPORT(("PowerMgr_create - Memory Allocation Error!\n"));
+        return NULL;
+    }
+
+    os_memoryZero (hOs, pPowerMgr, sizeof(PowerMgr_t));
+
+    pPowerMgr->hOS = hOs;
+
+    /*create the timers */
+    pPowerMgr->hRetryPsTimer = os_timerCreate(pPowerMgr->hOS,
+                                              powerMgrRetryPsTimeout,
+                                              pPowerMgr);
+
+    pPowerMgr->hPsPollFailureTimer = os_timerCreate(pPowerMgr->hOS,
+                                            powerMgr_PsPollFailureTimeout,
+                                            pPowerMgr);
+
+       #ifdef CPU_LOAD
+               pPowerMgr->hCpuLoadTimer = os_timerCreate(pPowerMgr->hOS,
+                                              powerMgr_CpuLoadTimeout,
+                                              pPowerMgr);
+       #endif
+
+
+    if ( (pPowerMgr->hPsPollFailureTimer == NULL) || (pPowerMgr->hRetryPsTimer == NULL) )
+    {
+        WLAN_OS_REPORT(("PowerMgr_create - Error in creating timer!\n"));
+        PowerMgr_destroy(pPowerMgr);
+        return NULL;
+    }
+
+    return pPowerMgr;
+
+}
+
+
+/****************************************************************************************
+*                        powerSrv_destroy                                                          *
+****************************************************************************************
+DESCRIPTION: Destroy the object of the power Manager.
+               -   delete Power Manager alocation
+               -   call the destroy function of the timer
+                                                                                                                  
+INPUT:          - hPowerMgr - Handle to the Power Manager   
+OUTPUT:     
+RETURN:    TI_STATUS - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS PowerMgr_destroy(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    if ( pPowerMgr->hRetryPsTimer != NULL )
+    {
+        os_timerDestroy(pPowerMgr->hOS,
+                        pPowerMgr->hRetryPsTimer);
+    }
+
+    if ( pPowerMgr->hPsPollFailureTimer != NULL )
+    {
+        os_timerDestroy(pPowerMgr->hOS,
+            pPowerMgr->hPsPollFailureTimer);
+    }
+    os_memoryFree(pPowerMgr->hOS , pPowerMgr , sizeof(PowerMgr_t));
+
+    return OK;
+}
+
+
+/****************************************************************************************
+*                        PowerMgr_init                                                         *
+****************************************************************************************
+DESCRIPTION: Power Manager init function, called in configure phase.
+                                                                                                                 
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+          - hReport           - Handle to report.
+          - hSiteMgr          - Handle to site manager
+          - trafficMonitor        - Handle to Trrafic monitor
+          - pPowerMgrInitParams - initi parameters
+
+
+OUTPUT:     
+RETURN:    TI_STATUS - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS PowerMgr_init(    TI_HANDLE               hPowerMgr,
+                            TI_HANDLE               hMacServices,
+                            TI_HANDLE               hReport,
+                            TI_HANDLE               hSiteMgr,
+                            TI_HANDLE               hWhalCtrl,
+                            TI_HANDLE               hTrafficMonitor,
+                            TI_HANDLE               hSoftGemini, 
+                            PowerMgrInitParams_t *  pPowerMgrInitParams)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    UINT8 index;
+    /* used to initialize the Traffic Monitor for Auto Ps events */
+    TrafficAlertRegParm_t tmRegParam;
+    TI_STATUS status;
+
+    pPowerMgr->hReport      = hReport;
+    pPowerMgr->hTrafficMonitor = hTrafficMonitor;
+    pPowerMgr->hSiteMgr         = hSiteMgr;
+    pPowerMgr->hWhalCtrl        = hWhalCtrl;
+    pPowerMgr->hMacServices= hMacServices;
+    pPowerMgr->hSoftGemini = hSoftGemini;
+    pPowerMgr->psEnable         = FALSE;
+
+    /* init power management options */
+    pPowerMgr->beaconListenInterval = pPowerMgrInitParams->beaconListenInterval;
+    pPowerMgr->dtimListenInterval = pPowerMgrInitParams->dtimListenInterval;
+    pPowerMgr->defaultPowerLevel =  pPowerMgrInitParams->defaultPowerLevel;
+    pPowerMgr->PowerSavePowerLevel =  pPowerMgrInitParams->PowerSavePowerLevel;
+    pPowerMgr->powerMngPriority  = POWER_MANAGER_USER_PRIORITY;
+    pPowerMgr->maxFullBeaconInterval = pPowerMgrInitParams->MaximalFullBeaconReceptionInterval;
+    pPowerMgr->PsPollDeliveryFailureRecoveryPeriod = pPowerMgrInitParams->PsPollDeliveryFailureRecoveryPeriod;
+
+    /*
+     set AUTO PS parameters 
+     */
+    pPowerMgr->autoModeInterval = pPowerMgrInitParams->autoModeInterval;
+    pPowerMgr->autoModeActiveTH = pPowerMgrInitParams->autoModeActiveTH;
+    pPowerMgr->autoModeDozeTH = pPowerMgrInitParams->autoModeDozeTH;
+    pPowerMgr->autoModeDozeMode = pPowerMgrInitParams->autoModeDozeMode;
+
+    /*
+     register threshold in the traffic monitor.
+     */
+
+       pPowerMgr->betEnable = pPowerMgrInitParams->BetEnable; /* save BET enable flag for CLI configuration */
+       pPowerMgr->betTrafficEnable = FALSE;                   /* starting without BET */
+
+    /* BET thresholds */
+    /* general parameters */
+    tmRegParam.Context = pPowerMgr;
+    tmRegParam.TimeIntervalMs = BET_INTERVAL_VALUE;
+    tmRegParam.Trigger = TRAFF_EDGE;
+    tmRegParam.MonitorType = TX_RX_ALL_802_11_DATA_FRAMES;
+    tmRegParam.CallBack = PowerMgrConfigBetToFw;
+
+    /* BET enable event */
+    tmRegParam.Direction = TRAFF_DOWN;
+    tmRegParam.Threshold = pPowerMgrInitParams->BetEnableThreshold;
+       pPowerMgr->BetEnableThreshold = pPowerMgrInitParams->BetEnableThreshold;
+    tmRegParam.Cookie = (UINT32)BET_ENABLE;
+    pPowerMgr->betEnableTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
+                                                             &tmRegParam,
+                                                             FALSE);
+    /* BET disable event */
+    tmRegParam.Direction = TRAFF_UP;
+    tmRegParam.Threshold = pPowerMgrInitParams->BetDisableThreshold;
+       pPowerMgr->BetDisableThreshold = pPowerMgrInitParams->BetDisableThreshold;
+    tmRegParam.Cookie = (UINT32)BET_DISABLE;
+    pPowerMgr->betDisableTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
+                                                             &tmRegParam,
+                                                             FALSE);
+
+    if ( (pPowerMgr->betDisableTMEvent == NULL) ||
+         (pPowerMgr->betEnableTMEvent == NULL) )
+    {
+        WLAN_REPORT_INIT(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                         ("PowerMgr_init - TM - ERROR registering BET events - ABROTING init!\n"));
+        return NOK;
+    }
+    /*
+    set the events as resets for one another
+    */
+    status = TrafficMonitor_SetRstCondition(hTrafficMonitor,
+                                            pPowerMgr->betDisableTMEvent,
+                                            pPowerMgr->betEnableTMEvent,
+                                            TRUE);
+    if ( status != OK )
+    {
+        WLAN_REPORT_INIT(pPowerMgr->hReport,
+                         POWER_MANAGER_MODULE_LOG,
+                         ("PowerMgr_init - PowerMgr_init - ERROR binding BET events - ABROTING init!\n"));
+        return NOK;
+    }
+
+    /* general parameters */
+    tmRegParam.Context = pPowerMgr;
+    tmRegParam.Cookie = (UINT32)POWER_MODE_ACTIVE;
+    tmRegParam.TimeIntervalMs = pPowerMgr->autoModeInterval;
+    tmRegParam.Trigger = TRAFF_EDGE;
+    tmRegParam.MonitorType = TX_RX_ALL_802_11_DATA_FRAMES;
+
+    /* Active threshold */
+    tmRegParam.CallBack = PowerMgrTMThresholdCrossCB;
+    tmRegParam.Direction = TRAFF_UP;
+    tmRegParam.Threshold = pPowerMgr->autoModeActiveTH;
+    pPowerMgr->passToActiveTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
+                                                             &tmRegParam,
+                                                             FALSE);
+    /* Doze threshold */
+    tmRegParam.Direction = TRAFF_DOWN;
+    tmRegParam.Threshold = pPowerMgr->autoModeDozeTH;
+    tmRegParam.Cookie = (UINT32)POWER_MODE_SHORT_DOZE; /* diffrentiation between long / short doze is done at the 
+                                                          CB, according to configuration at time of CB invokation */
+    pPowerMgr->passToDozeTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
+                                                           &tmRegParam,
+                                                           FALSE);
+
+    if ( (pPowerMgr->passToActiveTMEvent == NULL) ||
+         (pPowerMgr->passToDozeTMEvent == NULL) )
+    {
+        WLAN_REPORT_INIT(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                         ("PowerMgr_init - PowerMgr_init - ERROR registering Auto mode events - ABROTING init!\n"));
+        return NOK;
+    }
+
+    /*
+    set the events as resets for one another
+    */
+    status = TrafficMonitor_SetRstCondition(hTrafficMonitor,
+                                            pPowerMgr->passToActiveTMEvent,
+                                            pPowerMgr->passToDozeTMEvent,
+                                            TRUE);
+    if ( status != OK )
+    {
+        WLAN_REPORT_INIT(pPowerMgr->hReport,
+                         POWER_MANAGER_MODULE_LOG,
+                         ("PowerMgr_init - PowerMgr_init - ERROR binding Auto mode events - ABROTING init!\n"));
+        return NOK;
+    }
+
+    /*
+    configure the initialize power mode
+    */
+    pPowerMgr->desiredPowerModeProfile = pPowerMgrInitParams->powerMode;
+    for ( index = 0;index < POWER_MANAGER_MAX_PRIORITY;index++ )
+    {
+        pPowerMgr->powerMngModePriority[index].powerMode = pPowerMgr->desiredPowerModeProfile;
+        pPowerMgr->powerMngModePriority[index].priorityEnable = FALSE;
+    }
+    pPowerMgr->powerMngModePriority[POWER_MANAGER_USER_PRIORITY].priorityEnable = TRUE;
+    /* set the defualt power policy */
+    MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->defaultPowerLevel);
+
+    /* Register and Enable the PsPoll failure */
+    whalCtrl_EventMbox_RegisterForEvent( pPowerMgr->hWhalCtrl, 
+        HAL_EVENT_PSPOLL_DELIVERY_FAILURE,
+        (void *)PowerMgr_PsPollFailureCB, 
+        hPowerMgr );
+    whalCtrl_EventMbox_Enable( pPowerMgr->hWhalCtrl, HAL_EVENT_PSPOLL_DELIVERY_FAILURE );
+
+
+    WLAN_REPORT_INIT(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                     ("PowerMgr_init - PowerMgr Initialized\n"));
+
+    return OK;
+}
+
+/****************************************************************************************
+ *                        PowerMgr_startPS                                                          *
+ ****************************************************************************************
+DESCRIPTION: Start the power save algorithm of the driver and also the 802.11 PS.
+                                                                                                                   
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+
+OUTPUT:     
+RETURN:    TI_STATUS - OK or PENDING on success else NOK.\n
+****************************************************************************************/
+TI_STATUS PowerMgr_startPS(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+       int frameCount;
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgr_startPS - called\n"));
+
+
+    if ( pPowerMgr->psEnable == TRUE )
+    {
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("PowerMgr_startPS - PS mechanism is already Enable! Aborting psEnable=%d !\n",
+                           pPowerMgr->psEnable));
+        /*
+        this is a FATAL ERROR of the power manager!
+        already enable power-save! thus return OK, but there is an error in the upper
+        layer that call tp PowerMgr_startPS() twice - should know that power-save
+        is already enable therefor print the Error message.
+        or
+        the state machine while NOT in PS can be only in ACTIVE state and in some cases in
+        PS_PENDING state. therefore the state machine is out of sync from it logic!
+        */
+        return OK;
+    }
+
+    pPowerMgr->psEnable = TRUE;
+    /*set the correct rate after connection*/
+    powerMgrNullPacketRateConfiguration(hPowerMgr);
+    /*
+    if in auto mode then need to refer to the threshold cross indication from the traffic monitor,
+    else it need to refer to the configured power mode profile from the user.
+    */
+
+    pPowerMgr->desiredPowerModeProfile = powerMgrGetHighestPriority(hPowerMgr);
+
+    if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
+    {
+        powerMgrStartAutoPowerMode(hPowerMgr);
+    }
+    else /*not auto mode - according to the current profle*/
+    {
+        powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->desiredPowerModeProfile);
+    }
+
+       
+       if (pPowerMgr->betEnable)
+       {
+               TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
+                                                                          pPowerMgr->betEnableTMEvent);
+
+               TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
+                                                                          pPowerMgr->betDisableTMEvent);
+
+       
+               frameCount = TrafficMonitor_GetFrameBandwidth(pPowerMgr->hTrafficMonitor);
+       
+               if (frameCount < pPowerMgr->BetEnableThreshold) 
+               {
+                       pPowerMgr->betTrafficEnable = TRUE;
+               }
+               else if (frameCount > pPowerMgr->BetDisableThreshold) 
+               {
+                       pPowerMgr->betTrafficEnable = FALSE;
+        }
+
+               PowerMgrConfigBetToFw(hPowerMgr,pPowerMgr->betTrafficEnable);
+       }
+    
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        PowerMgr_stopPS                                                           *
+ ****************************************************************************************
+DESCRIPTION: Stop the power save algorithm of the driver and also the 802.11 PS.
+                                                                                                                               
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+
+OUTPUT:     
+RETURN:    TI_STATUS - OK or PENDING on success else NOK.\n
+****************************************************************************************/
+TI_STATUS PowerMgr_stopPS(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    /*TI_STATUS status;*/
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgr_stopPS - called\n"));
+
+    if ( pPowerMgr->psEnable == FALSE )
+    {
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMgr_stopPS - PS is already Disable! Aborting!\n"));
+        /*
+        Print Info message incase callng PowerMgr_stopPS() more than once in a row, without
+        calling to PowerMgr_startPS() in the middle.
+        this will return with OK and not doing the Stop action!
+        */
+        return OK;
+    }
+
+    pPowerMgr->psEnable = FALSE;
+    os_timerStop(pPowerMgr->hOS, pPowerMgr->hRetryPsTimer);
+
+    /* Check if PsPoll work-around is currently enabled */
+    if ( pPowerMgr->powerMngModePriority[POWER_MANAGER_PS_POLL_FAILURE_PRIORITY].priorityEnable == TRUE)
+    {
+        os_timerStop(pPowerMgr->hOS, pPowerMgr->hPsPollFailureTimer);
+        /* Exit the PsPoll work-around */
+        powerMgr_PsPollFailureTimeout( hPowerMgr );
+    }
+
+    if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
+    {
+        powerMgrDisableThresholdsIndications(hPowerMgr);
+    }
+
+    MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, POWER_SAVE_OFF, FALSE,NULL, NULL, NULL);
+
+    /* set the power policy of the system */
+    MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->defaultPowerLevel);
+
+       if (pPowerMgr->betEnable)
+       {
+               TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
+                                                                         pPowerMgr->betEnableTMEvent);
+
+               TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
+                                                                         pPowerMgr->betDisableTMEvent);
+       }
+
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        PowerMgr_getPsStatus                                                          *
+ ****************************************************************************************
+DESCRIPTION: returns the 802.11 power save status (enable / disable).
+                                                                                                                               
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+
+OUTPUT:     
+RETURN:    BOOLEAN - TRUE if enable else FALSE.\n
+****************************************************************************************/
+BOOLEAN PowerMgr_getPsStatus(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    return  MacServices_powerSrv_getPsStatus(pPowerMgr->hMacServices);
+
+}
+
+
+/****************************************************************************************
+ *                        PowerMgr_setPowerMode                                                         *
+ ****************************************************************************************
+DESCRIPTION: Configure of the PowerMode profile (auto / active / short doze / long doze).
+                                                                                                                               
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+            - thePowerMode      - the requested power mode (auto / active / short doze / long doze).
+OUTPUT:     
+RETURN:    TI_STATUS - OK on success else NOK.\n
+****************************************************************************************/
+TI_STATUS PowerMgr_setPowerMode(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    PowerMgr_PowerMode_e powerMode;
+
+    /*in this way we will run with the highest priority that is enabled*/
+    powerMode = powerMgrGetHighestPriority(hPowerMgr);
+
+    /* sanity checking */
+    if ( powerMode >= POWER_MODE_MAX)
+    {
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("PowerMgr_setPowerMode - unknown parameter: %d\n", powerMode));
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                             ("PowerMgr_setPowerMode, power mode = %d\n", powerMode) );
+
+    if ( pPowerMgr->desiredPowerModeProfile != powerMode )
+    {
+        PowerMgr_PowerMode_e previousPowerModeProfile;
+        previousPowerModeProfile = pPowerMgr->desiredPowerModeProfile;
+        pPowerMgr->desiredPowerModeProfile = powerMode;
+
+        if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
+        {
+            if ( pPowerMgr->psEnable == TRUE )
+            {
+                powerMgrStartAutoPowerMode(hPowerMgr);
+            }
+
+            /*
+            the transitions of state will be done according to the events from the
+            traffic monitor - therefor abort and wait event from the traffic monitor.
+            */
+            return OK;
+        }
+        else if ( previousPowerModeProfile == POWER_MODE_AUTO )
+        {
+            /*
+            if the old power mode is AUTO and the new power mode is NOT then need
+            to disable the thresholds indications from the traffic monitor.
+            */
+            powerMgrDisableThresholdsIndications(hPowerMgr);
+        }
+        if ( pPowerMgr->psEnable == TRUE )
+        {
+            powerMgrPowerProfileConfiguration(hPowerMgr, powerMode);
+        }
+    }
+    else
+    {
+        /*
+        the power mode is already configure to the module - don't need to do anything!
+        */
+        WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgr_setPowerMode - desiredPowerModeProfile == thePowerMode (=%d), ABORTING!\n",
+                             powerMode));
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        PowerMgr_reloadPowerMode                                      *
+ ****************************************************************************************
+DESCRIPTION: Sends the current power mode configuration to the firmware.                                                                                        
+INPUT:       - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:   
+****************************************************************************************/
+void PowerMgr_reloadPowerMode(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t * pPowerMgr = (PowerMgr_t *) hPowerMgr;
+
+    pPowerMgr->desiredPowerModeProfile = powerMgrGetHighestPriority(hPowerMgr);
+
+    if (pPowerMgr->psEnable == TRUE)
+    {
+        if (pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO)
+        {
+            powerMgrStartAutoPowerMode(hPowerMgr);
+        }
+        else
+        {
+            powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->desiredPowerModeProfile);
+        }
+    }
+}
+
+
+/****************************************************************************************
+ *                        PowerMgr_setDozeModeInAuto                                    *
+ ****************************************************************************************
+DESCRIPTION: Configure the doze mode (short-doze / long-doze) that auto mode will toggle between doze vs active.                                                                                        
+INPUT:      - hPowerMgr             - Handle to the Power Manager
+            - dozeMode      - the requested doze mode when Mgr is in Auto mode (short-doze / long-doze)
+OUTPUT:     
+RETURN:   
+****************************************************************************************/
+void PowerMgr_setDozeModeInAuto(TI_HANDLE hPowerMgr, PowerMgr_PowerMode_e dozeMode)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    PowerMgr_PowerMode_e powerMode = powerMgrGetHighestPriority(hPowerMgr);
+
+    /* check if we are trying to configure the same Doze mode */
+    if ( dozeMode != pPowerMgr->autoModeDozeMode )
+    {
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMgr_setDozeModeInAuto - autoModeDozeMode == %d \n",
+                                 dozeMode));
+
+        pPowerMgr->autoModeDozeMode = dozeMode;
+
+        /* in case we are already in Auto mode, we have to set the wake up condition MIB */
+        if ( powerMode == POWER_MODE_AUTO )
+        {
+            if ( dozeMode == POWER_MODE_SHORT_DOZE )
+            {
+                if ( pPowerMgr->beaconListenInterval > 1 )
+                {
+                    powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
+                }
+                else
+                {
+                    powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
+                }
+            }
+            else  /* POWER_MODE_LONG_DOZE */
+            {
+                if ( pPowerMgr->dtimListenInterval > 1 )
+                {
+                    powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
+                }
+                else
+                {
+                    powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
+                }
+            }
+
+            WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                    ("PowerMgr_setDozeModeInAuto - already in Auto\n"));
+        }
+    }
+    else
+    {
+        WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgr_setDozeModeInAuto - autoModeDozeMode == %d (same same ...)\n",
+                             dozeMode));
+    }
+}
+
+/****************************************************************************************
+ *                        PowerMgr_getPowerMode                                                         *
+ ****************************************************************************************
+DESCRIPTION: Get the current PowerMode of the PowerMgr module. 
+                                                                                                                               
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    PowerMgr_PowerMode_e - (auto / active / short doze / long doze).\n
+****************************************************************************************/
+PowerMgr_PowerMode_e PowerMgr_getPowerMode(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    return pPowerMgr->desiredPowerModeProfile;
+}
+
+
+/**
+ * \author Yossi Peery
+ * \date 2-August-2004\n
+ * \brief reset the power manager module due to recovry event.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * simulate the stop power save function without writing to the HW. just doing the
+ * logic parts of stop power save from the power manager to it state machine.
+ * the power controller and it state machine are reset in the whalCtrl recovry proccess.
+*/
+TI_STATUS PowerMgr_swReset(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgr_swReset() called\n"));
+
+
+    pPowerMgr->psEnable = FALSE;
+
+    if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
+    {
+        powerMgrDisableThresholdsIndications(hPowerMgr);
+    }
+    os_timerStop(pPowerMgr->hOS, pPowerMgr->hRetryPsTimer);
+    return OK;
+}
+
+TI_STATUS powerMgr_setParam(TI_HANDLE thePowerMgrHandle,
+                            paramInfo_t *theParamP)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)thePowerMgrHandle;
+
+    switch ( theParamP->paramType )
+    {
+    case POWER_MGR_POWER_MODE:
+        pPowerMgr->powerMngModePriority[theParamP->content.powerMngPowerMode.powerMngPriority].powerMode
+                        = theParamP->content.powerMngPowerMode.PowerMode;
+        PowerMgr_setPowerMode(thePowerMgrHandle);
+               if (pPowerMgr->betEnable)
+               {
+                       PowerMgrConfigBetToFw(thePowerMgrHandle, pPowerMgr->betTrafficEnable );
+               }
+        break;
+
+    case POWER_MGR_DISABLE_PRIORITY:
+        pPowerMgr->powerMngModePriority[theParamP->content.powerMngPriority].priorityEnable = FALSE;
+        PowerMgr_setPowerMode(thePowerMgrHandle);
+        break;
+
+    case POWER_MGR_ENABLE_PRIORITY:
+        pPowerMgr->powerMngModePriority[theParamP->content.powerMngPriority].priorityEnable = TRUE;
+        PowerMgr_setPowerMode(thePowerMgrHandle);
+        break;
+
+    case POWER_MGR_POWER_LEVEL_PS:
+        pPowerMgr->PowerSavePowerLevel = theParamP->content.PowerSavePowerLevel;
+        /* set the power policy of the system */
+               if (pPowerMgr->psEnable && (pPowerMgr->desiredPowerModeProfile!=POWER_MODE_AUTO))
+               {       /* If Connected  and not in AUTO mode */
+                       MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
+               }
+        break;
+
+    case POWER_MGR_POWER_LEVEL_DEFAULT:
+        pPowerMgr->defaultPowerLevel = theParamP->content.DefaultPowerLevel;
+               /* set the power policy of the system */
+               if (!pPowerMgr->psEnable)
+               {       /* If not Connected */
+                       MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->defaultPowerLevel);
+               }
+        break;
+
+    case POWER_MGR_POWER_LEVEL_DOZE_MODE:
+        PowerMgr_setDozeModeInAuto(thePowerMgrHandle,theParamP->content.powerMngDozeMode);
+               if (pPowerMgr->betEnable)
+               {
+                       PowerMgrConfigBetToFw(thePowerMgrHandle, pPowerMgr->betTrafficEnable );
+               }
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("PowerMgr_setParam - ERROR - Param is not supported, %d\n\n",
+                           theParamP->paramType));
+
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+
+
+TI_STATUS powerMgr_getParam(TI_HANDLE thePowerMgrHandle,
+                            paramInfo_t *theParamP)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)thePowerMgrHandle;
+
+    switch ( theParamP->paramType )
+    {
+    case POWER_MGR_POWER_MODE:
+        theParamP->content.PowerMode = PowerMgr_getPowerMode(thePowerMgrHandle);
+        break;
+
+    case POWER_MGR_POWER_LEVEL_PS:
+        theParamP->content.PowerSavePowerLevel = pPowerMgr->PowerSavePowerLevel;
+        break;
+
+    case POWER_MGR_POWER_LEVEL_DEFAULT:
+        theParamP->content.DefaultPowerLevel = pPowerMgr->defaultPowerLevel;
+        break;
+
+    case POWER_MGR_POWER_LEVEL_DOZE_MODE:
+        theParamP->content.powerMngDozeMode = pPowerMgr->autoModeDozeMode;
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("PowerMgr_getParam - ERROR - Param is not supported, %d\n\n",
+                           theParamP->paramType));
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+
+/*****************************************************************************
+ **         Private Function prototypes                                     **
+ *****************************************************************************/
+
+
+/****************************************************************************************
+ *                        powerSaveCompleteCB                                                       *
+ ****************************************************************************************
+DESCRIPTION: Callback for the Power server complete - gets the result of the request 
+              for PS or exit PS.
+                                                                                                                               
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+            - PSMode
+            - trasStatus            - result string form the FW.
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+static void powerSaveCompleteCB(TI_HANDLE hPowerMgr,UINT8 PSMode,UINT8 transStatus)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                             ("powerSaveCompleteCB, statud = %d\n", transStatus) );
+
+    /* Handling the event*/
+    switch ( (EventsPowerSave_e)transStatus )
+    {
+    case ENTER_POWER_SAVE_FAIL:
+    case EXIT_POWER_SAVE_FAIL:
+        pPowerMgr->lastPsTransaction = transStatus;
+        os_timerStart(pPowerMgr->hOS,
+                      pPowerMgr->hRetryPsTimer,
+                      RE_ENTER_PS_TIMEOUT,
+                      FALSE);
+        break;
+
+    case ENTER_POWER_SAVE_SUCCESS:
+        if ( (pPowerMgr->lastPowerModeProfile == POWER_MODE_SHORT_DOZE) ||
+             (pPowerMgr->lastPowerModeProfile == POWER_MODE_LONG_DOZE)  ||
+                        (pPowerMgr->lastPowerModeProfile == POWER_MODE_PS_ONLY))
+        {
+            MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
+        }
+
+    case EXIT_POWER_SAVE_SUCCESS:
+        break;
+
+    default:
+        WLAN_REPORT_ERROR( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                           ("powerSaveCompleteCB: invliad status: %d\n", transStatus) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Aug-2006\n
+ * \brief Power manager callback fro TM event notification
+ *
+ * Function Scope \e Public.\n
+ * \param hPowerMgr - handle to the power maanger object.\n
+ * \param cookie - values supplied during event registration (active / doze).\n
+ */
+static void PowerMgrTMThresholdCrossCB( TI_HANDLE hPowerMgr, UINT32 cookie )
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgrTMThresholdCrossCB - TM notified threshold crossed, cookie: %d\n",
+                             cookie));
+
+    /* sanity cehcking - TM notifications should only be received when PM is enabled and in auto mode */
+    if ( (pPowerMgr->psEnable == TRUE) && (pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO) )
+    {
+        switch ((PowerMgr_PowerMode_e)cookie)
+        {
+        case POWER_MODE_ACTIVE:
+            powerMgrPowerProfileConfiguration( hPowerMgr, POWER_MODE_ACTIVE );
+            break;
+
+        /* threshold crossed down - need to enter configured doze mode */
+        case POWER_MODE_SHORT_DOZE:
+            powerMgrPowerProfileConfiguration( hPowerMgr, pPowerMgr->autoModeDozeMode );
+            break;
+
+        default:
+            WLAN_REPORT_ERROR( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                               ("PowerMgrTMThresholdCrossCB: TM notification with invalid cookie: %d!\n",
+                                cookie) );
+            break;
+        }
+    }
+    else
+    {
+        WLAN_REPORT_ERROR( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                           ("PowerMgrTMThresholdCrossCB: TM motification when psEnable is :%d or desired profile is: %d\n",
+                            pPowerMgr->psEnable, pPowerMgr->desiredPowerModeProfile) );
+    }
+
+}
+
+/****************************************************************************************
+*                        powerMgrDisableThresholdsIndications                                           *
+*****************************************************************************************
+DESCRIPTION: This will send a disable message to the traffic monitor,
+                 to stop sending indications on threshold pass.
+
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+static void powerMgrDisableThresholdsIndications(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    /*
+    auto is not a static/fix state, else its a dynamic state that flows between
+    the 3 static/fix states: active, short-doze and long-doze.
+    */
+    TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
+                                  pPowerMgr->passToActiveTMEvent);
+
+    TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
+                                  pPowerMgr->passToDozeTMEvent);
+
+}
+
+
+/****************************************************************************************
+*                        powerMgrEnableThresholdsIndications                                            *
+*****************************************************************************************
+DESCRIPTION: TThis will send an enable message to the traffic monitor,
+                to start sending indications on threshold pass.
+
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+static void powerMgrEnableThresholdsIndications(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                             ("powerMgrEnableThresholdsIndications called\n") );
+    /*
+    auto is not a static/fix state, but rather a dynamic state that flows between
+    the 3 static/fix states: active, short-doze and long-doze.
+    */
+    TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
+                                   pPowerMgr->passToActiveTMEvent);
+
+    TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
+                                   pPowerMgr->passToDozeTMEvent);
+
+}
+
+
+/****************************************************************************************
+*                        powerMgrStartAutoPowerMode                                                 *
+*****************************************************************************************
+DESCRIPTION: configure the power manager to enter into AUTO power mode. 
+             The power manager will deside what power level will be applied 
+             acording to the traffic monitor.
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+static void powerMgrStartAutoPowerMode(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    int frameCount;
+
+    frameCount = TrafficMonitor_GetFrameBandwidth(pPowerMgr->hTrafficMonitor);
+
+    WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                             ("powerMgrStartAutoPowerMode: Starting auto power mode,"
+                              "frame count=%d, TH=%d\n", frameCount, pPowerMgr->autoModeActiveTH) );
+
+    /*Activates the correct profile*/
+    if ( frameCount >= pPowerMgr->autoModeActiveTH )
+    {
+        powerMgrPowerProfileConfiguration(hPowerMgr, POWER_MODE_ACTIVE);
+    }
+    else
+    {
+        powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->autoModeDozeMode);
+
+    }
+    /* Activates the Trafic monitoe Events*/        
+    powerMgrEnableThresholdsIndications(hPowerMgr);
+}
+
+/****************************************************************************************
+*                        powerMgrRetryPsTimeout                                                     *
+*****************************************************************************************
+DESCRIPTION: Retry function if a PS/exit PS request failed
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+static void powerMgrRetryPsTimeout(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    TI_STATUS powerStatus;
+
+    WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                             ("powerMgrRetryPsTimeout: timer expired.\n") );
+
+    if ( pPowerMgr->lastPsTransaction == ENTER_POWER_SAVE_FAIL )
+    {
+        powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, POWER_SAVE_ON, TRUE , hPowerMgr,powerSaveCompleteCB,NULL);/*NULL as GWSI callback*/
+        if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
+        {
+            if ( (pPowerMgr->lastPowerModeProfile == POWER_MODE_SHORT_DOZE) || 
+                 (pPowerMgr->lastPowerModeProfile == POWER_MODE_LONG_DOZE)  ||
+                                (pPowerMgr->lastPowerModeProfile == POWER_MODE_PS_ONLY))
+            {
+                MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);              
+            }
+        }
+    }
+    else
+    {
+        powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, POWER_SAVE_OFF, TRUE , hPowerMgr,powerSaveCompleteCB,NULL);/*NULL as GWSI callback*/
+    }
+
+}
+
+
+/****************************************************************************************
+*                        powerMgrPowerProfileConfiguration                                          *
+*****************************************************************************************
+DESCRIPTION: This function is the " builder " of the Power Save profiles. 
+             acording to the desired Power mode.
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+static void powerMgrPowerProfileConfiguration(TI_HANDLE hPowerMgr, PowerMgr_PowerMode_e desiredPowerMode)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    TI_STATUS powerStatus;
+
+    os_timerStop(pPowerMgr->hOS, pPowerMgr->hRetryPsTimer);
+
+       pPowerMgr->lastPowerModeProfile = desiredPowerMode;
+
+    switch ( desiredPowerMode )
+    {
+    case POWER_MODE_AUTO:
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMode==AUTO - This mode should not be sent to the GWSI - we send AUTO instead\n"));
+        break;
+
+    case POWER_MODE_ACTIVE:
+        /* set AWAKE through */
+        MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, POWERAUTHO_POLICY_AWAKE);
+        powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices,
+                                                     POWER_SAVE_OFF, 
+                                                     TRUE , 
+                                                     hPowerMgr,
+                                                     powerSaveCompleteCB,
+                                                     NULL);
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMode==ACTIVE\n"));
+        break;
+
+    case POWER_MODE_SHORT_DOZE:
+        if ( pPowerMgr->beaconListenInterval > 1 )
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
+        }
+        else
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
+        }
+
+        powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, 
+                                                     POWER_SAVE_ON, 
+                                                     TRUE , 
+                                                     hPowerMgr,
+                                                     powerSaveCompleteCB,
+                                                     NULL);
+        if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
+        {
+            MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
+        }
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMode==SHORT_DOZE\n"));
+        break;
+
+    case POWER_MODE_LONG_DOZE:
+        if ( pPowerMgr->dtimListenInterval > 1 )
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
+        }
+        else
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
+        }
+        powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, 
+                                                     POWER_SAVE_ON, 
+                                                     TRUE , 
+                                                     hPowerMgr,
+                                                     powerSaveCompleteCB,
+                                                     NULL);
+        if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
+        {
+            MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
+        }
+
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMode==LONG_DOZE\n"));
+        break;
+
+       case POWER_MODE_PS_ONLY:
+               /* When in SG PS mode, configure the user desired wake-up condition */
+               powerMgr_SGSetUserDesiredwakeUpCond(hPowerMgr);
+        powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, 
+                                                     POWER_SAVE_ON, 
+                                                     TRUE , 
+                                                     hPowerMgr,
+                                                     powerSaveCompleteCB,
+                                                     NULL);
+
+               /* In PS_ONLY we will use the last powerAutho policy of SHORT or LONG DOZE or ACTIVE */
+               if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
+               {
+                       MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
+               }
+
+        WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMode==PS_ONLY\n"));
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pPowerMgr->hReport,
+                          POWER_MANAGER_MODULE_LOG,
+                          ("PowerMgr_setWakeUpConfiguration - ERROR - PowerMode - unknown parameter: %d\n",
+                           desiredPowerMode));
+        return;
+    }
+
+}
+
+
+/****************************************************************************************
+*                        powerMgrSendMBXWakeUpConditions                                            *
+*****************************************************************************************
+DESCRIPTION: Tsend configuration of the power management option that holds in the command
+                mailbox inner sturcture.
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    TI_STATUS - OK on success else NOK.\n
+****************************************************************************************/
+static TI_STATUS powerMgrSendMBXWakeUpConditions(TI_HANDLE hPowerMgr,
+                                                 UINT8 listenInterval,
+                                                 PowerMgr_TnetWakeOn_e tnetWakeupOn)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    whalCtrl_powerMgmtConfig_t powerMgmtConfig;
+    TI_STATUS status = OK;
+
+    powerMgmtConfig.listenInterval = listenInterval;
+    powerMgmtConfig.tnetWakeupOn = tnetWakeupOn;
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("powerMgrSendMBXWakeUpConditions: listenInterval = %d, tnetWakeupOn = %d\n",
+                             listenInterval,tnetWakeupOn));
+
+    status = whalCtrl_wakeUpCondition(pPowerMgr->hWhalCtrl,
+                                      powerMgmtConfig);
+    if ( status != OK )
+    {
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("powerMgrSendMBXWakeUpConditions - Error in wae up condition IE!\n"));
+    }
+    return status;
+}
+
+
+
+
+static TI_STATUS powerMgrNullPacketRateConfiguration(TI_HANDLE hPowerMgr)
+{
+    paramInfo_t     param;
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    param.paramType = SITE_MGR_CURRENT_RATE_PAIR_PARAM;
+    if ( siteMgr_getParam(pPowerMgr->hSiteMgr, &param) == OK )
+    {
+        MacServices_powerSrv_SetRateModulation(pPowerMgr->hMacServices, (UINT16)param.content.siteMgrCurrentRateMask.basicRateMask);
+    }
+    else
+    {
+        MacServices_powerSrv_SetRateModulation(pPowerMgr->hMacServices, (DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER));
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("powerMgrNullPacketRateConfiguration: error - faild to set rate so default was seted!\n"));
+    }
+    return OK;
+
+}
+
+
+static PowerMgr_PowerMode_e powerMgrGetHighestPriority(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    int index;
+    for ( index = POWER_MANAGER_MAX_PRIORITY-1;index >= 0;index-- )
+    {
+        if ( pPowerMgr->powerMngModePriority[index].priorityEnable )
+        {
+
+            return pPowerMgr->powerMngModePriority[index].powerMode;
+        }
+
+    }
+
+    WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                      ("powerMgrGetHighestPriority - error - faild to get highest priority! sefault deseired mode was returned !!!\n"));
+    return pPowerMgr->desiredPowerModeProfile;
+}
+
+ /****************************************************************************************
+ *                        PowerMgr_notifyFWReset                                                                                                                       *
+ ****************************************************************************************
+DESCRIPTION: Notify the object of the power Manager about FW reset (recovery).
+                               -       call PowerSrv module to Set Ps Mode
+                               -       call PowerAutho Power Policy Update
+                                                                                                                                  
+INPUT:         - hPowerMgr - Handle to the Power Manager       
+OUTPUT:                
+RETURN:    TI_STATUS - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS PowerMgr_notifyFWReset(TI_HANDLE hPowerMgr)
+{
+       PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+       if (pPowerMgr->psEnable)
+       {
+               if (pPowerMgr->lastPowerModeProfile == POWER_MODE_SHORT_DOZE || 
+                       pPowerMgr->lastPowerModeProfile == POWER_MODE_LONG_DOZE)
+               {
+                       powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->lastPowerModeProfile);
+               }
+       }
+
+    return OK;
+}
+
+ /****************************************************************************************
+ *                        PowerMgrConfigBetToFw                                                                                                                        *
+ ****************************************************************************************
+DESCRIPTION: callback from TM event notification.
+                               -       call PowerSrv module to Set Ps Mode
+                               -       call PowerAutho Power Policy Update
+                                                                                                                                  
+INPUT:         - hPowerMgr - Handle to the Power Manager       
+                - BetEnable - cookie:values supplied during event registration
+OUTPUT:                
+RETURN:    None.
+****************************************************************************************/
+static void PowerMgrConfigBetToFw( TI_HANDLE hPowerMgr, UINT32 BetEnable )
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    UINT8 MaximumConsecutiveET;
+    UINT32 listenInterval;
+    paramInfo_t param;
+    UINT32 beaconInterval;
+    UINT32 dtimPeriod;
+    PowerMgr_PowerMode_e powerMode;
+
+    param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
+    siteMgr_getParam(pPowerMgr->hSiteMgr, &param);
+    beaconInterval = param.content.beaconInterval;
+
+    param.paramType = SITE_MGR_DTIM_PERIOD_PARAM;
+    siteMgr_getParam(pPowerMgr->hSiteMgr, &param);
+    dtimPeriod = param.content.siteMgrDtimPeriod;
+
+    /* get actual Power Mode */
+    if (pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO)
+    {
+        powerMode = pPowerMgr->autoModeDozeMode;
+    }
+    else
+    {
+        powerMode = pPowerMgr->lastPowerModeProfile;
+    }
+
+    /* calc ListenInterval */
+    if (powerMode == POWER_MODE_SHORT_DOZE)
+    {
+        listenInterval = beaconInterval * pPowerMgr->beaconListenInterval;
+    }
+    else if (powerMode == POWER_MODE_LONG_DOZE)
+    {
+        listenInterval = dtimPeriod * beaconInterval * pPowerMgr->dtimListenInterval;
+    }
+    else
+    {
+        listenInterval = beaconInterval;
+    }
+
+    if (listenInterval == 0)
+    {
+        WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                                ("PowerMgrConfigBetToFw: listenInterval is ZERO\n"));
+        return;
+    }
+
+    /* MaximumConsecutiveET = MaximalFullBeaconReceptionInterval / MAX( BeaconInterval, ListenInterval) */
+    MaximumConsecutiveET = pPowerMgr->maxFullBeaconInterval / listenInterval;
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                            ("PowerMgrConfigBetToFw:\n \
+                            Power Mode = %d\n \
+                            beaconInterval = %d\n \
+                            listenInterval = %d\n \
+                            Bet Enable = %d\n \
+                            MaximumConsecutiveET = %d\n",
+                            powerMode,
+                            beaconInterval,
+                            listenInterval,
+                            BetEnable,
+                            MaximumConsecutiveET));
+
+    pPowerMgr->betTrafficEnable = BetEnable; /* save BET enable flag for CLI configuration */
+
+    whalCtrl_setBetParams (pPowerMgr->hWhalCtrl, BetEnable, MaximumConsecutiveET);
+
+}
+
+
+/**
+ * \date 10-April-2007\n
+ * \brief Returns to the configured wakeup condition, when SG protective mode is done
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: void.\n
+ */
+static void powerMgr_SGSetUserDesiredwakeUpCond( TI_HANDLE hPowerMgr )
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+
+    if (pPowerMgr->psEnable) 
+    {
+      /* set wakeup condition according to user mode power save profile */
+      switch ( pPowerMgr->powerMngModePriority[ POWER_MANAGER_USER_PRIORITY ].powerMode )
+      {
+      case POWER_MODE_AUTO:
+        /*set wakeup condition according to doze mode in auto and wakup interval */
+        if ( pPowerMgr->autoModeDozeMode == POWER_MODE_SHORT_DOZE )
+        {
+            /* short doze */
+            if ( pPowerMgr->beaconListenInterval > 1 )
+            {
+                powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
+            }
+            else
+            {
+                powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
+            }
+        }
+        else
+        {
+            /* long doze */
+            if ( pPowerMgr->dtimListenInterval > 1 )
+            {
+                powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
+            }
+            else
+            {
+                powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
+            }
+        }
+        break;
+
+      case POWER_MODE_ACTIVE:
+        break;
+
+      case POWER_MODE_SHORT_DOZE:
+        if ( pPowerMgr->beaconListenInterval > 1 )
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
+        }
+        else
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
+        }
+        break;
+
+      case POWER_MODE_LONG_DOZE:
+        if ( pPowerMgr->dtimListenInterval > 1 )
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
+        }
+        else
+        {
+            powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
+        }
+        break;
+
+      default:
+        WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
+                          ("powerMgr_SGExitShortDoze - ERROR - PowerMode for user prioirty is: %d\n",
+                           pPowerMgr->powerMngModePriority[ POWER_MANAGER_USER_PRIORITY ].powerMode));
+      }
+    }/*end of if (psEnable)*/
+}
+
+
+
+/****************************************************************************************
+*                        PowerMgr_PsPollFailureCB                                                                                                                      *
+****************************************************************************************
+DESCRIPTION: Work around to solve AP bad behavior.
+         Some old AP's have trouble with Ps-Poll - The solution will be to exit PS for a 
+         period of time
+                                                                                                                              
+INPUT:         - hPowerMgr - Handle to the Power Manager       
+OUTPUT:                
+RETURN:    
+****************************************************************************************/
+static void PowerMgr_PsPollFailureCB( TI_HANDLE hPowerMgr )
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    if ( pPowerMgr->PsPollDeliveryFailureRecoveryPeriod )
+    {
+        paramInfo_t param;
+             
+        WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
+            ("%s Oh boy, AP is not answering Ps-Poll's. enter active PS for %d Ms\n",
+            __FUNCTION__, pPowerMgr->PsPollDeliveryFailureRecoveryPeriod));
+
+        /* Disable Soft Gemini */
+        SoftGemini_startPsPollFailure(pPowerMgr->hSoftGemini);
+
+        /*
+         * Set the system to Active power save 
+         */
+        param.paramType = POWER_MGR_POWER_MODE;
+        param.content.powerMngPowerMode.PowerMode = POWER_MODE_ACTIVE;
+        param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_PS_POLL_FAILURE_PRIORITY;
+        powerMgr_setParam(hPowerMgr,&param);
+        
+        param.paramType = POWER_MGR_ENABLE_PRIORITY;
+        param.content.powerMngPriority = POWER_MANAGER_PS_POLL_FAILURE_PRIORITY;
+        powerMgr_setParam(hPowerMgr,&param);
+
+        /*
+         * Set timer to exit the active mode
+         */
+        os_timerStart(pPowerMgr->hOS,
+            pPowerMgr->hPsPollFailureTimer,
+            pPowerMgr->PsPollDeliveryFailureRecoveryPeriod,
+            FALSE);
+    } 
+    else    /* Work-around is disabled */
+    {
+        WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
+            ("%s Oh boy, AP is not answering Ps-Poll's !!!\n",__FUNCTION__));
+    }
+
+}
+
+/****************************************************************************************
+*                        powerMgr_PsPollFailureTimeout                                                                 *
+****************************************************************************************
+DESCRIPTION: After the timeout of ps-poll failure - return to normal behavior
+                                                                                                                              
+INPUT:         - hPowerMgr - Handle to the Power Manager       
+OUTPUT:                
+RETURN:    
+****************************************************************************************/
+static void powerMgr_PsPollFailureTimeout(TI_HANDLE hPowerMgr)
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+    paramInfo_t param;
+
+    WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
+        ("%s \n",__FUNCTION__));
+    
+    /* disable Ps-Poll priority */
+    param.paramType = POWER_MGR_DISABLE_PRIORITY;
+    param.content.powerMngPriority = POWER_MANAGER_PS_POLL_FAILURE_PRIORITY;
+    powerMgr_setParam(hPowerMgr,&param);
+
+    /* return to normal Soft Gemini */
+    SoftGemini_endPsPollFailure(pPowerMgr->hSoftGemini);
+}
+
+void powerMgr_setCpuLoad(TI_HANDLE hPowerMgr, UINT32 uCpuLoad)
+{
+       #ifdef CPU_LOAD
+
+               PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+               
+               pPowerMgr->uCpuLoad = uCpuLoad;
+               WLAN_OS_REPORT(("\n PowerMgr_setCpuLoad - Cpu Load = %d \n",
+                                                  pPowerMgr->uCpuLoad));
+
+               if (pPowerMgr->uCpuLoad > 0) 
+               {
+                       os_timerStart(pPowerMgr->hOS,
+                                                 pPowerMgr->hCpuLoadTimer,
+                                                 RE_ENTER_CPU_LOAD_TIMEOUT,
+                                                 TRUE);
+               }
+               else
+               {
+                       os_timerStop(pPowerMgr->hOS, pPowerMgr->hCpuLoadTimer);
+               }
+       #endif
+}
+
+#ifdef CPU_LOAD
+       /****************************************************************************************
+       *                        powerMgr_CpuLoadTimeout                                                                        *
+       ****************************************************************************************
+       DESCRIPTION: After the timeout of cpu load - run in idle loop to simulate cpu load
+                                                                                                                                                                                                                                  
+       INPUT:          - hPowerMgr - Handle to the Power Manager       
+       OUTPUT:         
+       RETURN:    
+       ****************************************************************************************/
+       static void powerMgr_CpuLoadTimeout(TI_HANDLE hPowerMgr)
+       {
+               PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+               UINT32 uStallTime=0;
+               
+               WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
+                       ("CpuLoadTimeout : cpu= %d\n", pPowerMgr->uCpuLoad));
+
+               #ifdef _WINDOWS
+               #else
+                       while(uStallTime < (pPowerMgr->uCpuLoad * CPU_LOAD_MUL))
+                       {
+                               uStallTime++;
+                       }
+               #endif
+       }
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr.h b/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr.h
new file mode 100644 (file)
index 0000000..ce89404
--- /dev/null
@@ -0,0 +1,177 @@
+/** \file PowerMgr.h
+ *  \brief This is the Power Manager module private (internal).
+ *  \author Assaf Azulay
+ *  \date 24-Oct-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Power Manager                                                 *
+ *   PURPOSE: Power Manager Module private                                      *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _POWER_MGR_H_
+#define _POWER_MGR_H_
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "public_event_mbox.h"
+
+/*****************************************************************************
+ **         Constants                                                       **
+ *****************************************************************************/
+#define RE_ENTER_PS_TIMEOUT 10 /* mSec */
+
+#define BET_INTERVAL_VALUE 1000 /* mSec */
+
+#ifdef CPU_LOAD
+       #define CPU_LOAD_MUL    10000
+
+       #define RE_ENTER_CPU_LOAD_TIMEOUT 10 /*mSec */
+#endif
+
+/*****************************************************************************
+ **         Enumerations                                                    **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Typedefs                                                        **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+typedef struct
+{
+    PowerMgr_PowerMode_e powerMode;
+    BOOLEAN priorityEnable;
+} powerMngModePriority_t;
+
+
+
+/** \struct powerMgr_t
+ * this structure contain the data of the PowerMgr object.
+ */
+typedef struct
+{
+    TI_HANDLE                   hOS;                            /**< Handle to the OS object */
+    TI_HANDLE                   hMacServices;                   /**< Hnadle to the Mac services - Power Server object */
+    TI_HANDLE                   hReport;                        /**< Handle to the Report module */
+    TI_HANDLE                   hTrafficMonitor;                /**< Handle to the Traffic Monitor object */
+    TI_HANDLE                   hSiteMgr;                       /**< Handle to the Site Mgr object */
+    TI_HANDLE                   hWhalCtrl;                      /**< Handle to the whal control object */
+    TI_HANDLE                   hSoftGemini;
+    TI_HANDLE                   hRetryPsTimer;                  /**< Handle to the retry timer */
+    TI_HANDLE                   hPsPollFailureTimer;            /**< Handle to ps-poll failure timer */
+    PowerMgr_PowerMode_e        desiredPowerModeProfile;        /**< 
+                                                                 * The configure power mode to the system in the
+                                                                 * initialization function. This parameters is Saved
+                                                                 * for restart the module.
+                                                                 */
+    powerMngModePriority_t      powerMngModePriority[POWER_MANAGER_MAX_PRIORITY];                                                                           
+    PowerMgr_PowerMode_e        lastPowerModeProfile;           /**< 
+                                                                 * The last configured power mode. 
+                                                                 */
+    BOOLEAN                     psEnable;                       /**<
+                                                                 * The parameter holds the enable of the power save
+                                                                 * mechanism.
+                                                                 */
+    UINT16                      autoModeInterval;               /**<
+                                                                 * Time period (in ms) to test the current TP before
+                                                                 * changing the current power mode.
+                                                                 */
+    UINT16                      autoModeActiveTH;               /**< Threshold (in Bytes) for moving to Active mode */
+    UINT16                      autoModeDozeTH;                 /**< 
+                                                                 * Threshold (in Bytes) for moving to Short-Doze from
+                                                                 * active mode.
+                                                                 */
+    PowerMgr_PowerMode_e        autoModeDozeMode;               /**< 
+                                                                 * The power mode of doze (short-doze / long-doze) that
+                                                                 * auto mode will be toggle between doze vs active.
+                                                                 */
+    PowerMgr_Priority_e         powerMngPriority;               /**<
+                                                                 * the priority of the power manager - canbe - regular user (cli) or
+                                                                 * special user i.e Soft Gemini.
+                                                                 */
+    TI_HANDLE                   passToActiveTMEvent;            /**< 
+                                                                 * Traffic Monitor event (TrafficAlertElement) for
+                                                                 * the pass to active event from the traffic monitor.
+                                                                 */
+    TI_HANDLE                   passToDozeTMEvent;              /**<
+                                                                 * Traffic Monitor event (TrafficAlertElement) for
+                                                                 * the pass to short doze from active event from the
+                                                                 * traffic monitor.
+                                                                 */
+    TI_HANDLE                   betEnableTMEvent;               /**<
+                                                                 * Traffic Monitor event (TrafficAlertElement) for
+                                                                 * enabling BET.
+                                                                 */
+    TI_HANDLE                   betDisableTMEvent;               /**<
+                                                                 * Traffic Monitor event (TrafficAlertElement) for
+                                                                 * disabling BET.
+                                                                 */
+    UINT8                       beaconListenInterval;           /**< 
+                                                                 * specify how often the TNET wakes up to listen to
+                                                                 * beacon frames. the value is expressed in units of
+                                                                 * "beacon interval".
+                                                                 */
+    UINT8                       dtimListenInterval;             /**< specify how often the TNET wakes up to listen to
+                                                                 * dtim frames. the value is expressed in units of
+                                                                 * "dtim interval".
+                                                                 */                                                                          
+    powerAutho_PowerPolicy_e    defaultPowerLevel;              /**< Power level when PS not active */
+    powerAutho_PowerPolicy_e    PowerSavePowerLevel;            /**< Power level when PS active */
+    EventsPowerSave_e           lastPsTransaction;              /**< Last result of PS request */
+    UINT32                      maxFullBeaconInterval;          /**< Maximal time between full beacon reception */
+    UINT8                          betEnable;                      /**< last configuration of BET enable/disable */
+       UINT8                                           betTrafficEnable;
+       UINT8                                           BetEnableThreshold;
+       UINT8                                           BetDisableThreshold;
+
+
+    UINT32                      PsPollDeliveryFailureRecoveryPeriod; /* Time to exit PS after receiving PsPoll failure event */
+
+       UINT32                                          uCpuLoad;
+       TI_HANDLE                   hCpuLoadTimer;
+
+} PowerMgr_t;
+
+
+#endif /*  _POWER_MGR_H_  */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgrDbgPrint.c b/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgrDbgPrint.c
new file mode 100644 (file)
index 0000000..0dc15f0
--- /dev/null
@@ -0,0 +1,115 @@
+/** \file PowerMgrDbgPrint.c
+ *  \brief Includes primtoputs for debugging the power manager module.
+ *  \author Ronen Kalish
+ *  \date 29-Aug-2006
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __POWER_MGR_DBG_PRINT__
+#define __POWER_MGR_DBG_PRINT__
+
+#include "osTIType.h"
+#include "report.h"
+#include "PowerMgr.h"
+
+#ifdef TI_DBG
+
+#define MAX_DESC_LENGTH 32
+
+void powerMgrPrintPriorities( TI_HANDLE hPowerMgr, powerMngModePriority_t* pPriorities );
+
+
+static char booleanDesc[ 2 ][ MAX_DESC_LENGTH ] = {"no", "yes"};
+static char powerModeDesc[ POWER_MODE_MAX ][ MAX_DESC_LENGTH ] = 
+                        { "Auto", "Active", "Short doze", "Long doze", "PS only" };
+static char powerPolicyDesc[ POWERAUTHO_POLICY_NUM ][ MAX_DESC_LENGTH ] = 
+                        { "ELP", "PD", "AWAKE" };
+static char priorityDesc[ POWER_MANAGER_MAX_PRIORITY ][ MAX_DESC_LENGTH ] = 
+                        { "User priority", "Soft-Gemini priority" };
+static char psStatusDesc[ POWER_SAVE_STATUS_NUMBER ][ MAX_DESC_LENGTH ]=
+                        { "Enter fail", "Enter success", "Exit fail", "Exit succes" };
+
+/****************************************************************************************
+*                        PowerMgr_printObject                                                          *
+****************************************************************************************
+DESCRIPTION: print configuration of the PowerMgr object - use for debug!
+                                                                                                                              
+INPUT:          - hPowerMgr             - Handle to the Power Manager
+OUTPUT:     
+RETURN:    void.\n
+****************************************************************************************/
+void PowerMgr_printObject( TI_HANDLE hPowerMgr )
+{
+    PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
+
+    WLAN_OS_REPORT(("------------ Power Manager Object ------------\n\n"));
+    WLAN_OS_REPORT(("PS enabled: %s, desired power mode profile: %s, last power mode profile: %s\n",
+                    booleanDesc[ pPowerMgr->psEnable ], powerModeDesc[ pPowerMgr->desiredPowerModeProfile ],
+                    powerModeDesc[ pPowerMgr->lastPowerModeProfile ]));
+    WLAN_OS_REPORT(("Default power policy: %ss, PS power policy: %s\n", 
+                    powerPolicyDesc[ pPowerMgr->defaultPowerLevel ],
+                    powerPolicyDesc[ pPowerMgr->PowerSavePowerLevel ]));
+    WLAN_OS_REPORT(("Current priority: %s\n", priorityDesc[ pPowerMgr->powerMngPriority ]));
+    powerMgrPrintPriorities( hPowerMgr, pPowerMgr->powerMngModePriority );
+    WLAN_OS_REPORT(("\n------------ auto mode parameters ------------\n"));
+    WLAN_OS_REPORT(("Interval: %d, active threshold: %d, doze threshold: %d, doze mode: %s\n\n",
+                    pPowerMgr->autoModeInterval, pPowerMgr->autoModeActiveTH, pPowerMgr->autoModeDozeTH,
+                    powerModeDesc[ pPowerMgr->autoModeDozeMode ]));
+    WLAN_OS_REPORT(("Beacon listen interval:%d, DTIM listen interval:%d, last PS status: %s\n\n",
+                    pPowerMgr->beaconListenInterval, pPowerMgr->dtimListenInterval,
+                    psStatusDesc[ pPowerMgr->lastPsTransaction ]));
+    WLAN_OS_REPORT(("------------ Handles ------------\n"));
+    WLAN_OS_REPORT(("%-15s: 0x%x, %-15s:0x%x\n","hOS", pPowerMgr->hOS, "hMacServices", pPowerMgr->hMacServices));
+    WLAN_OS_REPORT(("%-15s: 0x%x, %-15s:0x%x\n","hReport", pPowerMgr->hReport, "hTrafficMonitor", pPowerMgr->hTrafficMonitor));
+    WLAN_OS_REPORT(("%-15s: 0x%x, %-15s:0x%x\n","hSiteMgr", pPowerMgr->hSiteMgr, "hWhalCtrl", pPowerMgr->hWhalCtrl));
+    WLAN_OS_REPORT(("%-15s: 0x%x, %-15s:0x%x\n","hRetryPsTimer", pPowerMgr->hRetryPsTimer, "hActiveTMEvent", pPowerMgr->passToActiveTMEvent));
+    WLAN_OS_REPORT(("%-15s: 0x%x\n", "hDozeTMEvent", pPowerMgr->passToDozeTMEvent));
+}
+
+void powerMgrPrintPriorities( TI_HANDLE hPowerMgr, powerMngModePriority_t* pPriorities )
+{
+    int i;
+
+    for ( i = 0; i < POWER_MANAGER_MAX_PRIORITY; i++ )
+    {
+        WLAN_OS_REPORT(("Priority: %-15s, enabled: %s, power mode: %s\n",
+                        priorityDesc[ i ], booleanDesc[ pPriorities[ i ].priorityEnable ],
+                         powerModeDesc[ pPriorities[ i ].powerMode ]));
+    }
+}
+#endif /* TI_DBG */
+
+#endif /* __POWER_MGR_DBG_PRINT__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr_API.h b/sta_dk_4_0_4_32/common/src/Management/PowerMgr/PowerMgr_API.h
new file mode 100644 (file)
index 0000000..d2a4152
--- /dev/null
@@ -0,0 +1,261 @@
+/** \file PowerMgr_API.h
+ *  \brief This is the Power Manager module API.
+ *  \author Yossi Peery
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Power Manager                                                 *
+ *   PURPOSE: Power Manager Module API                                      *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _POWER_MGR_API_H_
+#define _POWER_MGR_API_H_
+
+#include "osTIType.h"
+#include "paramOut.h"
+
+/*****************************************************************************
+ **         Constants                                                       **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Enumerations                                                    **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Typedefs                                                        **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         External data definitions                                       **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         External functions definitions                                  **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Public Function prototypes                                      **
+ *****************************************************************************/
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief Creates the object of the power Manager.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the OS.\n
+ * Return Value: TI_HANDLE - handle to the PowerMgr object.\n
+ */
+TI_HANDLE PowerMgr_create(TI_HANDLE theOsHandle);
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief Destroy the object of the power Manager.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ */
+TI_STATUS PowerMgr_destroy(TI_HANDLE thePowerMgrHandle);
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief Initialization of the PowerMgr module.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * 2) TI_HANDLE - handle to the Power Server object.\n
+ * 3) TI_HANDLE - handle to the Report object.\n
+ * 4) TI_HANDLE - handle to the TrafficMonitor object.\n
+ * 5) PowerMgrInitParams_t - the Power Manager initialize parameters.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ */
+TI_STATUS PowerMgr_init(    TI_HANDLE               hPowerMgr,
+                            TI_HANDLE               hPowerSRV,
+                            TI_HANDLE               hReport,
+                            TI_HANDLE               hSiteMgr,
+                            TI_HANDLE               hWhalCtrl,
+                            TI_HANDLE               hTrafficMonitor,
+                            TI_HANDLE               hSoftGemini,
+                            PowerMgrInitParams_t *  pPowerMgrInitParams);
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief Start the power save algorithm of the driver and also the 802.11 PS.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * PsEnable = true, and decide on the proper power mode.
+ */
+TI_STATUS PowerMgr_startPS(TI_HANDLE thePowerMgrHandle);
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief stop the power save algorithm of the driver and also the 802.11 PS.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * PsEnable = false, and set the power mode to active.
+ */
+TI_STATUS PowerMgr_stopPS(TI_HANDLE thePowerMgrHandle);
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief returns the 802.11 power save status (enable / disable).
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: BOOLEAN - TRUE if enable else FALSE.\n
+*/
+BOOLEAN PowerMgr_getPsStatus(TI_HANDLE thePowerMgrHandle);
+
+
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief Configure of the PowerMode (auto / active / short doze / long doze).
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * 2) PowerMgr_PowerMode_e - the requested power mode (auto / active / short doze / long doze).
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * desiredPowerModeProfile = PowerMode input parameter, and set the proper power mode.
+*/
+TI_STATUS PowerMgr_setPowerMode(TI_HANDLE thePowerMgrHandle);
+
+
+/**
+ * \brief Sends the current power mode configuration to the firmware.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+*/
+void PowerMgr_reloadPowerMode(TI_HANDLE hPowerMgr);
+
+
+/**
+ * \author Assaf Azulay
+ * \date 24-Oct-2005\n
+ * \brief Get the current PowerMode of the PowerMgr module.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: PowerMgr_PowerMode_e .\n
+ */
+PowerMgr_PowerMode_e PowerMgr_getPowerMode(TI_HANDLE thePowerMgrHandle);
+    
+/**
+ * \author Yossi Peery
+ * \date 2-August-2004\n
+ * \brief reset the power manager module due to recovry event.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * simulate the stop power save function without writing to the HW. just doing the
+ * logic parts of stop power save from the power manager to it state machine.
+ * the power controller and it state machine are reset in the whalCtrl recovry proccess.
+*/
+TI_STATUS PowerMgr_swReset(TI_HANDLE thePowerMgrHandle);
+
+
+
+TI_STATUS powerMgr_getParam(TI_HANDLE thePowerMgrHandle,
+                            paramInfo_t *theParamP);
+TI_STATUS powerMgr_setParam(TI_HANDLE thePowerMgrHandle,
+                            paramInfo_t *theParamP);
+
+
+/**
+ * \author Yossi Peery
+ * \date 20-July-2004\n
+ * \brief print configuration of the PowerMgr object - use for debug!
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerMgr object.\n
+ * Return Value: void.\n
+ */
+void PowerMgr_printObject(TI_HANDLE thePowerMgrHandle);
+
+TI_STATUS PowerMgr_notifyFWReset(TI_HANDLE hPowerMgr);
+
+
+
+void powerMgr_setCpuLoad(TI_HANDLE hPowerMgr, UINT32 uCpuLoad);
+
+void SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini);
+
+void SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini);
+
+#endif /*  _POWER_MGR_API_H_  */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr.h b/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr.h
new file mode 100644 (file)
index 0000000..5ca630e
--- /dev/null
@@ -0,0 +1,170 @@
+
+/** \file qosMngr.h
+ *  \brief QOS manager module internal header file
+ *
+ *  \see qosMngr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   qosMgr.h                                                   */
+/*    PURPOSE:  QOS manager module internal header file                    */
+/*                                                                         */
+/***************************************************************************/
+#ifndef __QOS_MNGR_H__
+#define __QOS_MNGR_H__
+
+#include "paramOut.h"
+#include "trafficAdmControl.h"
+
+/*
+ *          Defines
+ */
+
+#define QOS_MNGR_INIT_BIT_LOCAL_VECTOR     (0x01)
+#define QOS_MNGR_INIT_BIT_ADM_CTRL        (0x02)
+
+#define AC_PARAMS_AIFSN_MASK               (0x0f)
+#define AC_PARAMS_ACI_MASK                 (0x60)
+#define AC_PARAMS_CWMIN_MASK               (0x0f)
+#define AC_PARAMS_CWMAX_MASK               (0xf0)
+#define AC_PARAMS_ACM_MASK                 (0x10)
+
+
+#if 0
+#define PS_PARAMETERS_LEGACY                                   (0)
+#define PS_PARAMETERS_UPSD_TRIGGER_ENABLE_MASK (0x01)
+#define PS_PARAMETERS_UPSD_DELIVERY_ENABLE_MASK        (0x02)
+#define        PS_UPSD_TRIGER_AND_DELIVERY     (PS_PARAMETERS_UPSD_TRIGGER_ENABLE_MASK | PS_PARAMETERS_UPSD_DELIVERY_ENABLE_MASK)
+
+#define CONVERT_DRIVER_PS_MODE_TO_FW(PsMode_e) ((PsMode_e == UPSD) ? PS_UPSD_TRIGER_AND_DELIVERY : PS_PARAMETERS_LEGACY)
+#endif
+
+
+/*
+ *          Enumerations                                                    
+ */
+
+
+/*
+ *          Structures                                                      
+ */
+
+typedef struct 
+{
+       tspecInfo_t             currentTspecInfo[MAX_NUM_OF_AC];
+       tspecInfo_t             candidateTspecInfo[MAX_NUM_OF_AC];
+       UINT16                  totalAllocatedMediumTime;
+}resourceMgmt_t;
+
+/*
+ * per AC parameters
+ */
+typedef struct
+{
+       queueTrafficParams_t  QtrafficParams;    /* AC traffic confogiration params */
+    queueTrafficParams_t  QTrafficInitParams;/* for disconnect - defaults traffic params */
+       acQosParams_t         acQosParams;              
+       acQosParams_t         acQosInitParams;
+       AckPolicy_e       wmeAcAckPolicy;     /* ack policy per AC               */
+       PSScheme_e            currentWmeAcPsMode; /* current wme per ac power save mode */
+       PSScheme_e            desiredWmeAcPsMode; /* desired wme per ac power save mode */
+       admissionState_e        apInitAdmissionState; /* AC admission state              */
+       UINT32                  msduLifeTimeParam;    
+}acParams_t;
+
+
+typedef TI_STATUS (*qosMngrCallb_t) (TI_HANDLE hApConn, trafficAdmRequestStatus_e result);
+
+/*
+ *  qosMngr handle 
+ */
+
+typedef struct
+{
+    TI_HANDLE           hSiteMgr;
+    TI_HANDLE           hHalCtrl;
+    TI_HANDLE           hTxData;
+       TI_HANDLE                       hEvHandler;
+
+    TI_HANDLE           hMeasurementMngr;
+    TI_HANDLE           hSmeSm;
+    TI_HANDLE                  hCtrlData;
+    TI_HANDLE                  hMemMgr;
+    TI_HANDLE                  hExcMgr;
+
+    TI_HANDLE           hReport;
+    TI_HANDLE           hOs;
+
+    BOOL                WMEEnable;                           /* driver supports WME protocol       */
+    BOOL                WMESiteSupport;                      /* site support WME protocol          */
+    qosProtocols_e      activeProtocol;                      /* active protocol: EXC,WME or none.  */
+    BOOL                tagZeroConverHeader;                 /* converting tag zero headers        */
+       
+       UINT8                           qosPacketBurstEnable;                            /* Packet Burst is Enable or NOT      */
+       UINT32                          qosPacketBurstTxOpLimit;                         /* TxOp limit in case of NON_QOS */
+                                                                                                                        /* protocol and Packet Burst is Enable */
+
+       acParams_t          acParams[MAX_NUM_OF_AC];             /* per ac parameters                  */
+
+    BOOL                isConnected;                         /* Connected or not ?                       */
+       PSScheme_e                      desiredPsMode;                                           /* The desired PS mode of the station */
+       PSScheme_e                      currentPsMode;                                           /* The current PS mode of the station */
+       UINT8                           ApQosCapabilityParameters;
+       UINT8                           desiredMaxSpLen;
+       PSScheme_e                      desiredVoiceDeliveryProtocol;
+
+       headerConvetMode_e  headerConvetMode;
+       rxTimeOut_t         rxTimeOut;
+
+
+       /* traffic admission control parameters */
+       BOOL                            trafficAdmCtrlEnable;                            /* driver supports Admission control  */       
+       trafficAdmCtrl_t        *pTrafficAdmCtrl;                                        /* adm ctrl object */
+       resourceMgmt_t          resourceMgmtTable;
+    UINT8               QosNullDataTemplateUserPriority;     /* Holds the last User Priority set into the firmware in the QOS Null data template */
+
+       BOOL                            performTSPECRenegotiation;
+       BOOL                            voiceTspecConfigured;
+       BOOL                            videoTspecConfigured;
+       TI_HANDLE                       TSPECNegotiationResultModule;
+       qosMngrCallb_t          TSPECNegotiationResultCallb;
+       OS_802_11_QOS_TSPEC_PARAMS      tspecRenegotiationParams[MAX_NUM_OF_AC];
+} qosMngr_t;
+
+
+#endif /* QOS_MNGR_H */
diff --git a/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr_API.h b/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr_API.h
new file mode 100644 (file)
index 0000000..3335715
--- /dev/null
@@ -0,0 +1,145 @@
+/** \file qosMngr_API.h
+ *  \brief QOS manager module external header file
+ *
+ *  \see qosMngr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       qosMgr_API.h                                                                                       */
+/*    PURPOSE: QOS manager module external header file                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef __QOS_MNGR_API_H__
+#define __QOS_MNGR_API_H__
+
+#include "802_11Defs.h"
+
+#define MAX_NUM_OF_TID                                         16 
+#define FIRST_TID                                                      8
+#define USER_PRIORITY_4 (WMEQosTagToACTable[4])
+#define USER_PRIORITY_6 (WMEQosTagToACTable[6])
+
+
+typedef struct 
+{
+       acTrfcType_e            AC;
+       UINT8                           tid;
+       UINT8                           userPriority;
+       UINT16                          nominalMsduSize; /* in bytes */
+       UINT32                          meanDataRate;    /* bits per second */
+       UINT16                          surplausBwAllowance;
+       INT32                           minimumPHYRate;
+       UINT16                          mediumTime;
+       BOOL                            UPSDFlag;
+       streamDirection_e       streamDirection;
+       trafficAdmState_e       trafficAdmState;
+       UINT8                           statusCode;
+}tspecInfo_t;
+
+typedef enum 
+{
+       STATUS_TRAFFIC_ADM_REQUEST_ACCEPT       = 0,
+    STATUS_TRAFFIC_ADM_REQUEST_REJECT          = 1,
+       STATUS_TRAFFIC_ADM_REQUEST_TIMEOUT              = 2,
+} trafficAdmRequestStatus_e;
+
+
+TI_HANDLE qosMngr_create(TI_HANDLE hOs);
+
+TI_STATUS qosMngr_destroy(TI_HANDLE hQosMngr);
+
+TI_STATUS   qosMngr_config(TI_HANDLE                   hQosMngr,
+                                                  TI_HANDLE                    hHalCtrl,
+                                                  TI_HANDLE                    hSiteMgr,
+                                                  TI_HANDLE                    hReport,
+                                                  TI_HANDLE                    hOs,
+                           TI_HANDLE                hTxData,
+                           TI_HANDLE                hMeasurementMngr,
+                           TI_HANDLE                hSmeSm,
+                                                  TI_HANDLE                            hMemMgr,
+                                                  TI_HANDLE                            hCtrlData,
+                                                  TI_HANDLE                            hEvHandler,
+                                                  TI_HANDLE                            hExcMgr,
+                                                  QosMngrInitParams_t          *pQosMngrInitParams);
+
+TI_STATUS qosMngr_disconnect(TI_HANDLE hQosMngr);
+
+TI_STATUS qosMngr_connect(TI_HANDLE hQosMngr);
+
+TI_STATUS qosMngr_setParams(TI_HANDLE  hQosMngr,paramInfo_t *pParamInfo);
+
+TI_STATUS qosMngr_getParams(TI_HANDLE  hQosMngr,paramInfo_t *pParamInfo);
+
+TI_STATUS qosMngr_assocReqBuild(TI_HANDLE  hQosMngr, UINT8 *pQosIe, UINT8 *pLen);
+
+TI_STATUS qosMngr_setSite(TI_HANDLE hQosMngr, assocRsp_t *assocRsp);
+
+void      qosMngr_updateIEinfo(TI_HANDLE hQosMngr, UINT8 *pQosIeParams,qosProtocols_e qosSetProtocol);
+
+UINT8 qosMngr_evalSite(TI_HANDLE hQosMngr, BOOL siteAPSDSupport);
+
+TI_STATUS qosMngr_getQosCapabiltyInfeElement(TI_HANDLE  hQosMngr, UINT8 *pQosIe, UINT8 *pLen);
+
+TI_STATUS qosMngr_requestAdmission(TI_HANDLE                   hQosMngr, 
+                                   OS_802_11_QOS_TSPEC_PARAMS *addTspecParams);
+
+TI_STATUS qosMngr_deleteAdmission(TI_HANDLE hQosMngr, OS_802_11_QOS_DELETE_TSPEC_PARAMS *delAdmissionParams);
+
+TI_STATUS qosMngr_selectActiveProtocol(TI_HANDLE  hQosMngr);
+
+TI_STATUS qosMngr_setAcPsDeliveryMode(TI_HANDLE  hQosMngr);
+
+TI_STATUS qosMngr_sendUnexpectedTSPECResponseEvent(TI_HANDLE   hQosMngr,
+                                                                  tspecInfo_t  *pTspecInfo);
+
+TI_STATUS qosMngr_setAdmissionInfo(TI_HANDLE   hQosMngr, 
+                                                                  UINT8                acID,
+                                                                  tspecInfo_t  *pTspecInfo,
+                                                                  trafficAdmRequestStatus_e trafficAdmRequestStatus);
+
+
+
+TI_STATUS QosMngr_receiveActionFrames(TI_HANDLE hQosMngr, UINT8* pData, UINT8 action, UINT32 bodyLen);
+
+void qosMngr_checkTspecRenegResults(TI_HANDLE hQosMngr, assocRsp_t *assocRsp);
+
+UINT32 qosMngr_buildTSPec(TI_HANDLE hQosMngr, UINT32 user_priority, UINT8 *pQosIe);
+
+#endif /* __QOS_MNGR_API_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr_QueueMapping.h b/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/qosMngr_QueueMapping.h
new file mode 100644 (file)
index 0000000..ff4c8df
--- /dev/null
@@ -0,0 +1,92 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __qosMngr_Queue_Mapping_H__
+#define __qosMngr_Queue_Mapping_H__
+
+#include "paramOut.h"
+
+
+typedef enum
+{
+       NonQosTag0ToAC          = QOS_AC_BE,
+       NonQosTag1ToAC          = QOS_AC_BE,
+       NonQosTag2ToAC          = QOS_AC_BE,
+       NonQosTag3ToAC          = QOS_AC_BE,
+       NonQosTag4ToAC          = QOS_AC_BE,
+       NonQosTag5ToAC          = QOS_AC_BE,
+       NonQosTag6ToAC          = QOS_AC_BE,
+       NonQosTag7ToAC          = QOS_AC_BE,
+
+} NonQosTagToACTableDef_e;
+
+
+typedef enum
+{
+       WMEQosTag0ToAC          = QOS_AC_BE,
+       WMEQosTag1ToAC          = QOS_AC_BK,
+       WMEQosTag2ToAC          = QOS_AC_BK,
+       WMEQosTag3ToAC          = QOS_AC_BE,
+       WMEQosTag4ToAC          = QOS_AC_VI,
+       WMEQosTag5ToAC          = QOS_AC_VI,
+       WMEQosTag6ToAC          = QOS_AC_VO,
+       WMEQosTag7ToAC          = QOS_AC_VO,
+
+} WMEQosTagToACTableDef_e;
+
+
+
+/* EXC mapping:
+ * BK = Queue 0 
+ * BE = queue 1
+ * VI - queue 2
+ * VO - queue 3
+ */
+
+typedef enum
+{
+       EXCAc0ToQueueIndex              = 1,
+       EXCAc1ToQueueIndex              = 0,
+       EXCAc2ToQueueIndex              = 2,
+       EXCAc3ToQueueIndex              = 3,
+
+} EXCAcToQueueIndexDef_e;
+
+
+
+
+
+#endif /* __qosMngr_Queue_Mapping_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/trafficAdmControl.h b/sta_dk_4_0_4_32/common/src/Management/QOS/Inc/trafficAdmControl.h
new file mode 100644 (file)
index 0000000..7c05833
--- /dev/null
@@ -0,0 +1,143 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: admCtrl.c                                                                                                  */
+/*    PURPOSE: WSM/WME admission Control                                                          */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _ADM_CTRL_SM_H
+#define _ADM_CTRL_SM_H
+
+#include "fsm.h"
+#include "qosMngr_API.h"
+#include "mlmeApi.h"
+
+#define INITIAL_DIALOG_TOKEN   1
+
+/* state machine states */
+typedef enum 
+{
+       TRAFFIC_ADM_CTRL_SM_STATE_IDLE                  = 0,
+       TRAFFIC_ADM_CTRL_SM_STATE_WAIT                  = 1,
+} trafficAdmCtrl_smState_t;
+
+/* State machine inputs */
+typedef enum 
+{
+       TRAFFIC_ADM_CTRL_SM_EVENT_START                 = 0,
+       TRAFFIC_ADM_CTRL_SM_EVENT_STOP                  = 1,
+       TRAFFIC_ADM_CTRL_SM_EVENT_ACCEPT        = 2,
+    TRAFFIC_ADM_CTRL_SM_EVENT_REJECT           = 3,
+       TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT               = 4
+} trafficAdmCtrl_smEvents_t;
+
+
+typedef struct
+{
+       UINT8                                   tsInfo[3];
+       trafficAdmCtrl_smState_t        rafficAdmCtrlSmCurrState;
+}tidInfo_t;
+
+
+typedef struct
+{
+       TI_HANDLE                               hTxData;
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hOs;
+       TI_HANDLE                               hQosMngr;
+       TI_HANDLE                                       hCtrlData;
+       TI_HANDLE                                       hMemMgr;
+       TI_HANDLE                                       hExcMgr;
+
+       TI_HANDLE                               timer[MAX_NUM_OF_AC];
+       UINT8                                   currentState[MAX_NUM_OF_AC];
+       UINT8                                           dialogToken[MAX_NUM_OF_AC];
+
+       UINT8                                           dialogTokenCounter;
+
+
+       fsm_stateMachine_t              *pTrafficAdmCtrlSm;
+
+       UINT32                                  timeout;
+    BOOL                        useFixedMsduSize;
+
+
+} trafficAdmCtrl_t;
+
+
+
+
+TI_HANDLE trafficAdmCtrl_create(TI_HANDLE pOs);
+
+TI_STATUS trafficAdmCtrl_unload(TI_HANDLE hTrafficAdmCtrl);
+
+TI_STATUS trafficAdmCtrl_config(TI_HANDLE hTrafficAdmCtrl,
+                                               TI_HANDLE hTxData,
+                                               TI_HANDLE hReport,
+                                               TI_HANDLE hOs,
+                                               TI_HANDLE hQosMngr,
+                                               TI_HANDLE hCtrlData,
+                                               TI_HANDLE hMemMgr,
+                                               TI_HANDLE hExcMgr,
+                                               trafficAdmCtrlInitParams_t      *pTrafficAdmCtrlInitParams);
+
+TI_STATUS trafficAdmCtrl_setParam(TI_HANDLE hTrafficAdmCtrl, paramInfo_t       *pParam);
+
+TI_STATUS trafficAdmCtrl_getParam(TI_HANDLE hTrafficAdmCtrl, paramInfo_t       *pParam);
+
+TI_STATUS trafficAdmCtrl_startAdmRequest(TI_HANDLE     hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo);
+
+TI_STATUS trafficAdmCtrl_stopAdmRequest(TI_HANDLE hTrafficAdmCtrl, UINT8 tid);
+
+TI_STATUS trafficAdmCtrl_stop(TI_HANDLE hTrafficAdmCtrl);
+
+TI_STATUS trafficAdmCtrl_recv(TI_HANDLE hTrafficAdmCtrl, UINT8* pData, UINT8 action);
+
+TI_STATUS trafficAdmCtrl_sendDeltsFrame(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo, UINT8 reasonCode);
+
+void trafficAdmCtrl_print(trafficAdmCtrl_t *pTrafficAdmCtr);
+
+void trafficAdmCtrl_buildTSPec(trafficAdmCtrl_t        *pTrafficAdmCtrl, 
+                                                          tspecInfo_t          *pTSpecInfo, 
+                                                          UINT8                                *pDataBuff,
+                                                          UINT32                       *len);
+void trafficAdmCtrl_parseTspecIE(trafficAdmCtrl_t      *pTrafficAdmCtrl, 
+                                                                tspecInfo_t            *tsInfo, 
+                                                                dot11_WME_TSPEC_IE_t   *dot11_WME_TSPEC_IE);
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/QOS/qosMngr.c b/sta_dk_4_0_4_32/common/src/Management/QOS/qosMngr.c
new file mode 100644 (file)
index 0000000..05d9841
--- /dev/null
@@ -0,0 +1,3045 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 qosMngr.c
+ *  \brief QOS module interface
+ *
+ *  \see qosMngr.h
+ */
+
+/****************************************************************************************************/
+/*                                                                                                                                                                                                     */
+/*             MODULE:         qosMGr.c                                                                                                                                            */
+/*             PURPOSE:        QOS module interface.                                                                                                       */
+/*                  This module handles the QOS manager configuration.                                                         */
+/*                                                                                                                                                                                                     */
+/****************************************************************************************************/
+#include "report.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "utils.h"
+#include "siteMgrApi.h"
+#include "public_infoele.h"
+#include "whalCtrl_api.h"
+#include "qosMngr.h"
+#include "qosMngr_API.h"
+#include "qosMngr_QueueMapping.h"
+#include "smeSmApi.h"
+#include "EvHandler.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#include "excTSMngr.h"
+#endif
+
+static int NonQosTagToACTable[MAX_NUM_OF_802_1d_TAGS] = { NonQosTag0ToAC, NonQosTag1ToAC, NonQosTag2ToAC, NonQosTag3ToAC, NonQosTag4ToAC, NonQosTag5ToAC, NonQosTag6ToAC, NonQosTag7ToAC };
+
+/* This structure is now shared between the qosMngr and TxData to allow PS_POLL voice delivery mode for NON_QOS AP */
+int WMEQosTagToACTable[MAX_NUM_OF_802_1d_TAGS] = { WMEQosTag0ToAC, WMEQosTag1ToAC, WMEQosTag2ToAC, WMEQosTag3ToAC, WMEQosTag4ToAC, WMEQosTag5ToAC, WMEQosTag6ToAC, WMEQosTag7ToAC };
+
+/* This array is now shared between qosMngr and TxData */
+UINT8 wmeAcToUpIndex[MAX_NUM_OF_AC] = {0,1,4,6};
+
+/* Used to indicate no user priority is assigned for AC */
+#define INACTIVE_USER_PRIORITY 0xFF
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+static void release_module(qosMngr_t *pQosMngr, UINT32 initVec);
+static TI_STATUS verifyAndConfigTrafficParams(qosMngr_t *pQosMngr, queueTrafficParams_t *pQtrafficParams);
+static TI_STATUS verifyAndConfigQosParams(qosMngr_t *pQosMngr,acQosParams_t *pAcQosParams);
+static TI_STATUS getWMEInfoElement(qosMngr_t *pQosMngr,UINT8 *pWMEie,UINT8 *pLen);
+static TI_STATUS verifyWmeIeParams(qosMngr_t *pQosMngr,UINT8 *pQosIeParams);
+static TI_STATUS updateACParams(qosMngr_t *pQosMngr,ACParameters_t *pAcParams);
+static void      updateTagToAcTable(qosMngr_t *pQosMngr,acTrfcType_e *pProtocolTagToACTable);
+static TI_STATUS setWmeSiteParams(qosMngr_t *pQosMngr, UINT8 *pQosIeParams);
+void qosMngr_resetAdmCtrlParameters(TI_HANDLE hQosMngr);
+static TI_STATUS qosMngr_getCurrAcStatus(TI_HANDLE hQosMngr, OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams);
+static void deleteTspecConfiguration(qosMngr_t *pQosMngr, UINT8 acID);
+static void setNonQosAdmissionState(qosMngr_t *pQosMngr, UINT8 acID);
+static void qosMngr_storeTspecCandidateParams (tspecInfo_t *pCandidateParams, OS_802_11_QOS_TSPEC_PARAMS *pTSPECParams, UINT8 ac);
+
+/********************************************************************************
+ *                                                     qosMngr_create                                                                          *
+ ********************************************************************************
+DESCRIPTION: QOS module creation function, called by the config mgr in creation phase. 
+                               performs the following:
+                               - Allocate the QOS MNGR handle.                                                                                                                            
+INPUT:      hOs -                      Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the QOS MNGR module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE qosMngr_create(TI_HANDLE hOs)
+{
+       qosMngr_t               *pQosMngr = NULL;
+       UINT32                  initVec = 0;
+
+       if(!hOs)
+               return NULL;
+       
+       /* allocating the WME object */
+       pQosMngr = os_memoryAlloc(hOs,sizeof(qosMngr_t));
+
+       if (pQosMngr == NULL)
+               return NULL;
+
+       initVec |= (1 << QOS_MNGR_INIT_BIT_LOCAL_VECTOR);
+    
+       /* create admission control object */
+       pQosMngr->pTrafficAdmCtrl = trafficAdmCtrl_create(hOs);
+
+       if (pQosMngr->pTrafficAdmCtrl == NULL)
+       {
+               qosMngr_destroy(pQosMngr);
+               return NULL;
+       }
+
+       initVec |= (1 << QOS_MNGR_INIT_BIT_ADM_CTRL);
+
+       return(pQosMngr);
+}
+
+/************************************************************************
+ *                        qosMngr_destroy                                                          *
+ ************************************************************************
+DESCRIPTION: QOS MNGR module destroy function, called by the config mgr in
+                                the destroy phase 
+                                performs the following:
+                               -       Free all memory alocated by the module
+                               
+INPUT:      hQosMngr   -       QOS Manager handle.             
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS qosMngr_destroy(TI_HANDLE hQosMngr)
+{
+       UINT32                             initVec;
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       if (pQosMngr == NULL)
+               return OK;
+
+       initVec = 0xFFFF; 
+    release_module(pQosMngr, initVec);
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        release_module                                                                       
+ ***********************************************************************
+DESCRIPTION:   Called by the destroy function or by the create function (on failure)
+                               Go over the vector, for each bit that is set, release the corresponding module.
+                                                                                                   
+INPUT:      pQosMngr  -  QOS Mngr pointer.
+                       initVec   -      Vector that contains a bit set for each module thah had been initiualized
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+static void release_module(qosMngr_t *pQosMngr, UINT32 initVec)
+{
+       
+       if (initVec & (1 << QOS_MNGR_INIT_BIT_ADM_CTRL))
+               trafficAdmCtrl_unload(pQosMngr->pTrafficAdmCtrl);
+
+       if (initVec & (1 << QOS_MNGR_INIT_BIT_LOCAL_VECTOR))
+               utils_nullMemoryFree(pQosMngr->hOs, pQosMngr, sizeof(qosMngr_t));
+               
+       initVec = 0;
+}
+
+/************************************************************************
+ *                        qosMngr_config                                                               *
+ ************************************************************************
+DESCRIPTION: QOS Manager module configuration function, called by the config 
+                               mgr in configuration phase
+                               performs the following:
+                               -       Reset & initiailzes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+                   List of handles to be used by the module
+                       pQosMngrInitParams      -       Init table of the module.               
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS   qosMngr_config(TI_HANDLE                   hQosMngr,
+                                                  TI_HANDLE                    hHalCtrl,
+                                                  TI_HANDLE                    hSiteMgr,
+                                                  TI_HANDLE                    hReport,
+                                                  TI_HANDLE                    hOs,
+                           TI_HANDLE                hTxData,
+                           TI_HANDLE                hMeasurementMngr,
+                           TI_HANDLE                hSmeSm,
+                                                  TI_HANDLE                            hMemMgr,
+                                                  TI_HANDLE                            hCtrlData,
+                                                  TI_HANDLE                            hEvHandler,
+                                                  TI_HANDLE                            hExcMgr,
+                                                  QosMngrInitParams_t          *pQosMngrInitParams)
+{
+
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       paramInfo_t                       param;
+       UINT8                 acID;
+       TI_STATUS             status;
+
+    /* init handles */
+    pQosMngr->hOs       = hOs;
+    pQosMngr->hReport   = hReport;
+    pQosMngr->hSiteMgr  = hSiteMgr;
+    pQosMngr->hHalCtrl  = hHalCtrl;
+    pQosMngr->hTxData   = hTxData;
+    pQosMngr->hMeasurementMngr = hMeasurementMngr;
+    pQosMngr->hSmeSm = hSmeSm;
+    pQosMngr->hMemMgr   = hMemMgr;
+    pQosMngr->hCtrlData = hCtrlData;
+       pQosMngr->hEvHandler = hEvHandler;
+       pQosMngr->hExcMgr = hExcMgr;
+
+    pQosMngr->isConnected = FALSE;
+
+    /* init params */
+    pQosMngr->WMEEnable = pQosMngrInitParams->wmeEnable;
+    pQosMngr->trafficAdmCtrlEnable = pQosMngrInitParams->trafficAdmCtrlEnable;
+    pQosMngr->tagZeroConverHeader = pQosMngrInitParams->qosTagZeroConverHeader;
+       pQosMngr->qosPacketBurstEnable = pQosMngrInitParams->PacketBurstEnable;
+       pQosMngr->qosPacketBurstTxOpLimit = pQosMngrInitParams->PacketBurstTxOpLimit;
+       pQosMngr->desiredPsMode = pQosMngrInitParams->desiredPsMode;
+
+    pQosMngr->activeProtocol    = NONE_QOS;
+    pQosMngr->WMESiteSupport    = FALSE;
+
+       pQosMngr->desiredMaxSpLen       = pQosMngrInitParams->desiredMaxSpLen;
+       pQosMngr->desiredVoiceDeliveryProtocol = PS_SCHEME_LEGACY_PSPOLL;
+
+    pQosMngr->voiceTspecConfigured = FALSE;
+       pQosMngr->videoTspecConfigured = FALSE;
+    pQosMngr->performTSPECRenegotiation = FALSE;
+       pQosMngr->TSPECNegotiationResultCallb = NULL;
+       pQosMngr->TSPECNegotiationResultModule = NULL;
+
+    /* No template has been set for UPSD */
+    pQosMngr->QosNullDataTemplateUserPriority = 0xFF;
+
+       /* configure admission control parameters */
+       qosMngr_resetAdmCtrlParameters(pQosMngr);
+
+       status = trafficAdmCtrl_config(pQosMngr->pTrafficAdmCtrl,
+                                                               pQosMngr->hTxData,
+                                                               pQosMngr->hReport,
+                                                               pQosMngr->hOs,
+                                                               pQosMngr,
+                                                               pQosMngr->hCtrlData,
+                                                               pQosMngr->hMemMgr,
+                                                               pQosMngr->hExcMgr,
+                                                               &pQosMngrInitParams->trafficAdmCtrlInitParams);
+       if(status != OK)
+               return NOK;
+
+       /* 
+        * configure per AC traffic parameters
+        */
+    for(acID = FIRST_AC_INDEX;acID < MAX_NUM_OF_AC; acID++)
+       {
+               /*
+                * setting ac traffic params for TrafficCategoryCfg (TNET configuration 
+                * The parameters can be changed in run-time, so they are saved in "init params"
+                * for 'disconnecting' .
+                * the parameters being set in setSite; "select" phase.
+         */
+               pQosMngr->acParams[acID].QtrafficParams.queueID       = acID;
+               pQosMngr->acParams[acID].QtrafficParams.channelType   = CHANNEL_TYPE_EDCF;
+               pQosMngr->acParams[acID].QtrafficParams.tsid          = acID;
+               pQosMngr->acParams[acID].QtrafficParams.dot11EDCATableMSDULifeTime = 0;
+               pQosMngr->acParams[acID].QtrafficParams.psScheme      = PS_SCHEME_LEGACY;
+               pQosMngr->acParams[acID].QtrafficParams.ackPolicy     = pQosMngrInitParams->acAckPolicy[acID];
+               pQosMngr->acParams[acID].QtrafficParams.APSDConf[0]   = 0;
+               pQosMngr->acParams[acID].QtrafficParams.APSDConf[1]   = 0;
+
+
+               /* 
+                * Update the qTrafficInitParams as well 
+                */
+               os_memoryCopy(hOs,&(pQosMngr->acParams[acID].QTrafficInitParams),&(pQosMngr->acParams[acID].QtrafficParams),sizeof(queueTrafficParams_t));
+
+               /* will be config only after select */
+               verifyAndConfigTrafficParams(pQosMngr,&(pQosMngr->acParams[acID].QtrafficParams));
+               
+               /*
+                * setting ac QoS params for acQosParams (TNET configuration) 
+                * The parameters can be changed in run-time, so they are saved in "init params"
+                * for 'disconnecting'.
+                * the parameters being set in setSite; "select" phase.
+         */
+               pQosMngr->acParams[acID].acQosParams.ac        = acID;
+               pQosMngr->acParams[acID].acQosParams.aifsn     = AIFS_DEF;
+               pQosMngr->acParams[acID].acQosParams.cwMax     = CW_MAX_DEF;
+               pQosMngr->acParams[acID].acQosParams.cwMin     = CW_MIN_MAX;
+               pQosMngr->acParams[acID].acQosParams.txopLimit = QOS_TX_OP_LIMIT_DEF;
+               pQosMngr->acParams[acID].msduLifeTimeParam     = pQosMngrInitParams->MsduLifeTime[acID];
+
+               /* The protocol is NONE_QOS. If Packet Burst is Enable,            */
+               /* then, the BE queue is configured to the TxOP Limit of Packet burst */
+               /* (that is, 3 ms) and the txopContinuation is set to  qosPacketBurstEnable  */
+               /* The protocol is NONE_QOS. If Packet Burst is Enable,            */
+               /* then, the BE queue is configured to the TxOP Limit of Packet burst */
+               /* (that is, 3 ms) and the txopContinuation is set to  qosPacketBurstEnable  */
+
+               if (acID == QOS_AC_BE)  
+               {
+                       if (pQosMngr->qosPacketBurstEnable==TRUE)
+                       {
+                               pQosMngr->acParams[QOS_AC_BE].acQosParams.txopLimit = pQosMngr->qosPacketBurstTxOpLimit;
+                       }
+                       else 
+                       {
+                               pQosMngr->acParams[QOS_AC_BE].acQosParams.txopLimit = QOS_TX_OP_LIMIT_DEF;
+                       }
+               }
+
+               /* 
+                * Update the acQosInitParams as well 
+                */
+               os_memoryCopy(hOs,&(pQosMngr->acParams[acID].acQosInitParams),&(pQosMngr->acParams[acID].acQosParams),sizeof(acQosParams_t));
+
+               /* will be config only after select */
+               verifyAndConfigQosParams(hQosMngr,&(pQosMngr->acParams[acID].acQosParams));
+               
+               
+
+
+               /*
+                * setting ps mode per ac for protocol specific configuration.
+                */
+
+        /* validity check - allow to set the desired Ps mode per-AC to UPSD ONLY IF the station supports UPSD */
+        if ((pQosMngrInitParams->desiredPsMode == PS_SCHEME_UPSD_TRIGGER) && (pQosMngrInitParams->desiredWmeAcPsMode[acID] == PS_SCHEME_UPSD_TRIGGER))
+        {
+                       pQosMngr->acParams[acID].desiredWmeAcPsMode = PS_SCHEME_UPSD_TRIGGER;
+        }
+        else
+        {
+               pQosMngr->acParams[acID].desiredWmeAcPsMode = PS_SCHEME_LEGACY_PSPOLL;
+        }
+
+               pQosMngr->acParams[acID].currentWmeAcPsMode  = PS_SCHEME_LEGACY_PSPOLL; /* default configuration is legacy PS  for all queues */
+
+               /*
+                * configure TxData per AC params
+                */
+               param.content.txDataQosParams.acID                      = acID;
+               param.content.txDataQosParams.acTrfcCtrl.PsMode         = PS_SCHEME_LEGACY;
+               param.content.txDataQosParams.acTrfcCtrl.QueueIndex     = acID; 
+        param.content.txDataQosParams.acTrfcCtrl.TxQueueSize    = pQosMngrInitParams->TxQueueSize[acID];
+               param.content.txDataQosParams.acTrfcCtrl.QueueOvFlowPolicy = pQosMngrInitParams->QueueOvFlowPolicy[acID];                                     
+               param.content.txDataQosParams.acTrfcCtrl.MsduLifeTime   = pQosMngrInitParams->MsduLifeTime[acID];
+               param.content.txDataQosParams.acTrfcCtrl.ackPolicy      = ACK_POLICY_LEGACY; /* working with Non - Qos method */
+
+               param.paramType = TX_DATA_PS_MODE_PARAM;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               param.paramType = TX_DATA_CONFIG_TX_QUEUE_SIZE;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               param.paramType = TX_DATA_CONFIG_TX_QUEUE_OVFLOW_POLICY;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               param.paramType = TX_DATA_CONFIG_AC_MSDU_LIFE_TIME;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               param.paramType = TX_DATA_CONFIG_AC_ACK_POLICY;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+
+               /* setting wme Ack Policy */
+               pQosMngr->acParams[acID].wmeAcAckPolicy = pQosMngrInitParams->acAckPolicy[acID];
+
+               /* Set admission state per AC for non-QoS and update the Tx module. */
+               setNonQosAdmissionState(pQosMngr, acID);
+       }
+
+       pQosMngr->headerConvetMode = LEGACY_CONVERT;
+       param.content.txDataQosParams.qosParams.headerConverMode          = LEGACY_CONVERT;
+
+       /* Update the Tx tag to AC tables for legacy mode. */
+       updateTagToAcTable(pQosMngr, (acTrfcType_e *)NonQosTagToACTable);
+
+       
+       param.paramType = TX_DATA_CONVERT_HEADER_MODE;
+       txData_setParam(pQosMngr->hTxData,&param);
+
+       param.paramType = TX_DATA_CONVERT_TAG_ZERO_HEADER_MODE;
+    param.content.txDataQosParams.qosParams.convertTagZeroFrames = pQosMngrInitParams->qosTagZeroConverHeader;
+       txData_setParam(pQosMngr->hTxData,&param);
+
+       WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                 ("qosMngr_config : QoS configuration complete!")); 
+       
+
+    return OK;
+}
+
+/************************************************************************
+ *                    qosMngr_resetAdmCtrlParameters                   *
+ ************************************************************************
+DESCRIPTION: reset the admCtrl parameters
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+
+void qosMngr_resetAdmCtrlParameters(TI_HANDLE hQosMngr)
+{
+       UINT8 acID;
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       /* reset admission control parameters */
+       for(acID = FIRST_AC_INDEX ; acID < MAX_NUM_OF_AC ; acID++)
+       {
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].AC = (acTrfcType_e)acID;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority = INACTIVE_USER_PRIORITY; /* Setting invalid user Priority to prevent GET_TSPEC or DELETE */
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].nominalMsduSize = 0;
+        pQosMngr->resourceMgmtTable.currentTspecInfo[acID].minimumPHYRate = 0;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].meanDataRate = 0;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].surplausBwAllowance = 0;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].mediumTime = 0;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].UPSDFlag = 0;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].streamDirection = BI_DIRECTIONAL;
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].AC = (acTrfcType_e)acID;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].userPriority = INACTIVE_USER_PRIORITY; /* Setting invalid user Priority to prevent GET_TSPEC or DELETE */
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].nominalMsduSize = 0;
+        pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].minimumPHYRate = 0;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].meanDataRate = 0;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].surplausBwAllowance = 0;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].mediumTime = 0;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].UPSDFlag = 0;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].streamDirection = BI_DIRECTIONAL;
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+
+               pQosMngr->resourceMgmtTable.totalAllocatedMediumTime = 0;
+       }
+}
+
+
+/************************************************************************
+ *                        qosMngr_disconnect                                           *
+ ************************************************************************
+DESCRIPTION: the function is called upon driver disconnecting to reset all
+             QOS parameters to init values.
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_disconnect(TI_HANDLE hQosMngr)
+{
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       paramInfo_t                       param;
+       UINT8                 acID;
+       TI_STATUS             status;
+
+       if(hQosMngr == NULL)
+               return OK;
+
+       pQosMngr->activeProtocol    = NONE_QOS;
+    pQosMngr->WMESiteSupport    = FALSE;
+
+       /* clear admission control params */
+       qosMngr_resetAdmCtrlParameters(pQosMngr);
+       
+       trafficAdmCtrl_stop(pQosMngr->pTrafficAdmCtrl);
+
+       for(acID = FIRST_AC_INDEX;acID < MAX_NUM_OF_AC; acID++)
+       {
+
+               /* disable event in rate adaptation */
+               ctrlData_setTspecsRateEvent(pQosMngr->hCtrlData, acID, FALSE);
+
+        /* Disable medium time events in TX */
+               txData_setAdmisionCtrlParams(pQosMngr->hTxData, acID, 0 , 0, FALSE);
+
+               /* The protocol after disconnect is NONE_QOS. If Packet Burst is Enabled, the BE queue InitParams 
+                   is configured to the TxOP Limit of Packet burst  (that is, 3 ms) and the 
+                   txopContinuation is set to qosPacketBurstEnable. */
+               
+               if (acID == QOS_AC_BE)
+               {
+                       if (pQosMngr->qosPacketBurstEnable==TRUE)
+                       {
+                               pQosMngr->acParams[QOS_AC_BE].acQosInitParams.txopLimit = pQosMngr->qosPacketBurstTxOpLimit;
+                       }
+                       else 
+                       {
+                               pQosMngr->acParams[QOS_AC_BE].acQosInitParams.txopLimit = QOS_TX_OP_LIMIT_DEF;
+                       }
+               }
+               
+               /* Copy init traffic params (non-QoS defaults) to current traffic params, and config to HAL and TNET. */
+       os_memoryCopy(pQosMngr->hOs,&(pQosMngr->acParams[acID].acQosParams),&(pQosMngr->acParams[acID].acQosInitParams),sizeof(acQosParams_t));         
+
+               /* 
+                * Update the qTrafficInitParams as well 
+                */
+          os_memoryCopy(pQosMngr->hOs,&(pQosMngr->acParams[acID].QtrafficParams),&(pQosMngr->acParams[acID].QTrafficInitParams),sizeof(queueTrafficParams_t));
+
+
+
+          pQosMngr->acParams[acID].currentWmeAcPsMode  = PS_SCHEME_LEGACY_PSPOLL; /* default configuration is legacy PS  for all queues */
+
+           /*
+           * setting TxData params, only PS , Txoplimit and Admission State and AC status
+           * can be changed and reset to defaults.
+           */
+          param.content.txDataQosParams.acID                      = acID;
+          param.content.txDataQosParams.acTrfcCtrl.PsMode         = PS_SCHEME_LEGACY;
+          param.content.txDataQosParams.acTrfcCtrl.ackPolicy      = ACK_POLICY_LEGACY; /* working with Non - Qos method */
+          param.content.txDataQosParams.acTrfcCtrl.MsduLifeTime   = pQosMngr->acParams[acID].msduLifeTimeParam;
+
+          param.paramType = TX_DATA_CONFIG_AC_MSDU_LIFE_TIME;
+          txData_setParam(pQosMngr->hTxData, &param);
+
+          param.paramType = TX_DATA_PS_MODE_PARAM;
+          txData_setParam(pQosMngr->hTxData,&param);
+
+          param.paramType = TX_DATA_CONFIG_AC_ACK_POLICY;
+          txData_setParam(pQosMngr->hTxData,&param);
+
+          /* Set admission state per AC for non-QoS and update the Tx module. */
+          setNonQosAdmissionState(pQosMngr, acID);
+       }
+
+       /* 
+        * configure only BE AC 
+        * NOTE : this is done after "disconnect" or Init phase so those are defaults BE params 
+        */
+
+       /*
+        * configureQueue
+        */
+       status = verifyAndConfigTrafficParams(hQosMngr,&(pQosMngr->acParams[QOS_AC_BE].QtrafficParams));
+       if (status != OK)
+       {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                       ("qosMngr_setSite:failed to init NON_QOS Queue Traffic parameters!!!\n\n")); 
+                       return status;
+       }
+
+       /*
+        * configureAC
+        */
+
+       status = verifyAndConfigQosParams(hQosMngr,&(pQosMngr->acParams[QOS_AC_BE].acQosParams));
+       if (status != OK)
+       {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                       ("qosMngr_setSite:failed to init NON_QOS AC QoS parameters!!!\n\n")); 
+                       return status;
+       }
+
+
+       /*
+        * reset TxData globals parameters:  header converting to legacy and Tag to Ac table without
+        * QOS 
+        */
+       pQosMngr->headerConvetMode = LEGACY_CONVERT;
+       param.content.txDataQosParams.qosParams.headerConverMode          = LEGACY_CONVERT;
+
+
+
+       /* Update the Tx and HAL tag to AC tables for legacy mode. */
+       updateTagToAcTable(pQosMngr, (acTrfcType_e *)NonQosTagToACTable);
+
+
+       param.paramType = TX_DATA_CONVERT_HEADER_MODE;
+       txData_setParam(pQosMngr->hTxData,&param);
+
+
+    /* Update our internal state */
+    pQosMngr->isConnected = FALSE;
+
+    /* Mark that no Qos Null template is currently set into firmware */
+    pQosMngr->QosNullDataTemplateUserPriority = 0xFF;
+
+    pQosMngr->voiceTspecConfigured = FALSE;
+
+       pQosMngr->videoTspecConfigured = FALSE;
+
+    /* Mark that no Qos Null template is currently set into firmware */
+    pQosMngr->QosNullDataTemplateUserPriority = 0xFF;
+
+       WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                 ("qosMngr_disconnect : QoS disconnect complete!")); 
+
+#ifdef EXC_MODULE_INCLUDED
+       measurementMgr_stopTsMetrics(pQosMngr->hMeasurementMngr);
+#endif
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        qosMngr_connect                                      *
+ ************************************************************************
+DESCRIPTION: the function is called upon driver connection to inform all 
+             the other modules about the voice mode
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_connect(TI_HANDLE hQosMngr)
+{
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+    psPollTemplate_t        psPollTemplate;
+    whalCtrl_setTemplate_t  templateStruct;
+    QosNullDataTemplate_t  QosNullDataTemplate;
+    UINT8   acID,UPSDCnt=0;
+
+   if (pQosMngr->isConnected == TRUE)
+   {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, ("qosMngr_connect : Already connected !!!\n")); 
+     return OK;
+   }
+
+    /* Send PsPoll template to HAL */
+    
+    templateStruct.pTemplate = (UINT8 *)&psPollTemplate;
+    templateStruct.templateType = PS_POLL_TEMPLATE;
+    buildPsPollTemplate(pQosMngr->hSiteMgr, &templateStruct);
+    whalCtrl_SetTemplate(pQosMngr->hHalCtrl, &templateStruct);
+       
+    /* Update our internal state */
+    pQosMngr->isConnected = TRUE;
+
+    /* Set Qos-Null Data template into firmware */
+       for(acID = FIRST_AC_INDEX;acID < MAX_NUM_OF_AC; acID++)
+       {
+        /* Set QOS Null data template into the firmware (only if at least one AC is configured as UPSD )*/
+        if (pQosMngr->acParams[acID].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+        {
+           UPSDCnt++;
+           if ( pQosMngr->acParams[acID].apInitAdmissionState != ADMISSION_REQUIRED )
+           {
+            pQosMngr->QosNullDataTemplateUserPriority = wmeAcToUpIndex[acID];
+
+            templateStruct.pTemplate = (UINT8 *)&QosNullDataTemplate;
+            templateStruct.templateType = QOS_NULL_DATA_TEMPLATE;
+            buildQosNullDataTemplate(pQosMngr->hSiteMgr, &templateStruct,pQosMngr->QosNullDataTemplateUserPriority);
+            whalCtrl_SetTemplate(pQosMngr->hHalCtrl, &templateStruct);
+
+            WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+               ("setWmeSiteParams: Setting QOS Null data for UserPriority %d (belongs to AC %d)\n",wmeAcToUpIndex[acID],acID));
+
+            break; /* Only need to set ONE template, so after setting it, we can exit the loop */
+           }
+        }
+
+    }
+
+    /* If MAX_NUM_OF_AC (4) ACs were found as UPSD, but we still haven't configured any UP in the Qos Null data template, it must mean all ACs require admission - not valid*/
+    if ((pQosMngr->QosNullDataTemplateUserPriority == 0xFF) && (UPSDCnt == MAX_NUM_OF_AC))
+    {
+      WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, ("qosMngr_connect : QOS Null Data template not set since all ACs require admission !!!\n")); 
+       }
+
+       return OK;
+}
+
+/************************************************************************
+ *                        qosMngr_evalSite                                                 *
+ ************************************************************************
+DESCRIPTION: Evaluate the site for the selction algorithm
+                        In case the station is configure to work in UPSD mode
+                        prefer a site that support UPSD and return 1.
+                        All other case return 0.
+                                                                                                   
+INPUT:      siteAPSDSupport - the UPSD capabilit of the site
+
+OUTPUT:                 
+
+RETURN:     1 - evaluation is good...
+                       0 - evaluation can be better....
+
+************************************************************************/
+UINT8 qosMngr_evalSite(TI_HANDLE hQosMngr, BOOL siteAPSDSupport)
+{
+   qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+   if (pQosMngr->desiredPsMode == PS_SCHEME_UPSD_TRIGGER && siteAPSDSupport)
+   {
+               return 1;
+   }
+
+   return 0;
+}
+
+
+
+/************************************************************************
+ *                        qosMngr_getACparams                                      *
+ ************************************************************************
+DESCRIPTION: The function is an API for external modules to qet qos parameters
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+            pParamInfo           -  qos parameters information.
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_getParams(TI_HANDLE  hQosMngr,paramInfo_t *pParamInfo)
+{
+       acTrfcType_e           acID;
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       if(pQosMngr == NULL)
+               return NOK;
+
+       WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, ("qosMngr_getParams: %x\n", pParamInfo->paramType)); 
+
+       switch(pParamInfo->paramType)
+       {
+       case QOS_PACKET_BURST_ENABLE:
+               pParamInfo->content.qosPacketBurstEnb = pQosMngr->qosPacketBurstEnable;
+               break;
+       case QOS_MNGR_CURRENT_PS_MODE:
+               pParamInfo->content.currentPsMode = pQosMngr->currentPsMode;
+               break;
+
+    case QOS_MNGR_ACTIVE_PROTOCOL:
+       pParamInfo->content.qosSiteProtocol = pQosMngr->activeProtocol;
+       break;
+
+    case QOS_MNGR_GET_DESIRED_PS_MODE:
+        pParamInfo->content.qosDesiredPsMode.uDesiredPsMode = pQosMngr->desiredPsMode;
+               for(acID = FIRST_AC_INDEX; acID < MAX_NUM_OF_AC ; acID++ )
+                       pParamInfo->content.qosDesiredPsMode.uDesiredWmeAcPsMode[acID] = pQosMngr->acParams[acID].desiredWmeAcPsMode;
+        break;
+          
+       case QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC:
+       /* Check if voice call present. If so, store current TSPEC configuration */
+               pParamInfo->content.TspecConfigure.voiceTspecConfigure = (UINT8)pQosMngr->voiceTspecConfigured;
+               pParamInfo->content.TspecConfigure.videoTspecConfigure = (UINT8)pQosMngr->videoTspecConfigured;
+
+               WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, ("qosMngr_getParams: QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC=%d\n", pQosMngr->voiceTspecConfigured)); 
+
+               if (pQosMngr->voiceTspecConfigured == TRUE) 
+               {
+                       OS_802_11_QOS_TSPEC_PARAMS *pTspecParams;
+                       tspecInfo_t *pConfiguredParams;
+
+                       /* Store voice TSPEC params - must be configured */
+                       pTspecParams = &pQosMngr->tspecRenegotiationParams[USER_PRIORITY_6];
+                       pConfiguredParams = &pQosMngr->resourceMgmtTable.candidateTspecInfo[USER_PRIORITY_6];
+
+                       pTspecParams->uUserPriority = pConfiguredParams->userPriority;
+                       pTspecParams->uNominalMSDUsize = pConfiguredParams->nominalMsduSize;
+                       pTspecParams->uMeanDataRate = pConfiguredParams->meanDataRate;
+                       pTspecParams->uMinimumPHYRate = pConfiguredParams->minimumPHYRate;
+                       pTspecParams->uSurplusBandwidthAllowance = pConfiguredParams->surplausBwAllowance;
+                       pTspecParams->uAPSDFlag = pConfiguredParams->UPSDFlag;
+                       pTspecParams->uMediumTime = pConfiguredParams->mediumTime;
+               }
+               else
+               {
+                       pQosMngr->tspecRenegotiationParams[USER_PRIORITY_6].uUserPriority = MAX_USER_PRIORITY;
+               }
+
+               if (pQosMngr->videoTspecConfigured == TRUE) 
+               {
+                       OS_802_11_QOS_TSPEC_PARAMS *pTspecParams;
+                       tspecInfo_t *pConfiguredParams;
+
+                       /* Store signalling TSPEC params if configured in user priority 4 */
+                       pTspecParams = &pQosMngr->tspecRenegotiationParams[USER_PRIORITY_4];
+                       pConfiguredParams = &pQosMngr->resourceMgmtTable.candidateTspecInfo[USER_PRIORITY_4];
+
+                       pTspecParams->uUserPriority = pConfiguredParams->userPriority;
+                       pTspecParams->uNominalMSDUsize = pConfiguredParams->nominalMsduSize;
+                       pTspecParams->uMeanDataRate = pConfiguredParams->meanDataRate;
+                       pTspecParams->uMinimumPHYRate = pConfiguredParams->minimumPHYRate;
+                       pTspecParams->uSurplusBandwidthAllowance = pConfiguredParams->surplausBwAllowance;
+                       pTspecParams->uAPSDFlag = pConfiguredParams->UPSDFlag;
+                       pTspecParams->uMediumTime = pConfiguredParams->mediumTime;
+               }
+               else
+               {
+                       pQosMngr->tspecRenegotiationParams[USER_PRIORITY_4].uUserPriority = MAX_USER_PRIORITY;
+               }
+               break;
+
+       default:
+           WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_getParams Error: unknown paramType 0x%x!\n",pParamInfo->paramType)); 
+                       return (PARAM_NOT_SUPPORTED);
+/*             break; - unreachable */
+
+       }
+       return OK;
+}
+
+/************************************************************************
+ *                        qosMngr_setParams                                        *
+ ************************************************************************
+DESCRIPTION: The function is an API for external modules to set qos parameters
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+            pParamInfo           -  qos parameters information.
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_setParams(TI_HANDLE  hQosMngr,paramInfo_t *pParamInfo)
+{
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       paramInfo_t                        param;
+       whalParamInfo_t            whalParam;           
+       acTrfcType_e           acID;
+       TI_STATUS              status;
+
+       if(pQosMngr == NULL)
+               return NOK;
+
+       if(pParamInfo == NULL)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                       ("qosMngr_setParams :Error trying to set NULL params!\n")); 
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, ("qosMngr_setParams: %x\n", pParamInfo->paramType)); 
+
+       switch(pParamInfo->paramType)
+       {
+
+               case QOS_PACKET_BURST_ENABLE:
+
+                       if (pParamInfo->content.qosPacketBurstEnb > QOS_PACKET_BURST_ENABLE_MAX)
+                               return (PARAM_VALUE_NOT_VALID);
+                       
+                       /* No change */
+                       if (pParamInfo->content.qosPacketBurstEnb == pQosMngr->qosPacketBurstEnable)
+                               return OK;
+
+                       /* Update the qosPacketBurstEnable parameter */
+                       pQosMngr->qosPacketBurstEnable = pParamInfo->content.qosPacketBurstEnb;
+
+                       /* Packet burst enable changed from F to T */ 
+                       if (pParamInfo->content.qosPacketBurstEnb == TRUE)
+                       {
+                               /* Update the acTrafficInitParams of BE to the packet burst def*/
+                               pQosMngr->acParams[QOS_AC_BE].acQosInitParams.txopLimit = pQosMngr->qosPacketBurstTxOpLimit;
+                       
+                               /* Update the acTrafficParams of BE and the hal to the packet burst def*/
+                               if (pQosMngr->activeProtocol == NONE_QOS)
+                               {
+                                       pQosMngr->acParams[QOS_AC_BE].acQosParams.txopLimit = pQosMngr->qosPacketBurstTxOpLimit;
+                                       /* verify the parameters and update the hal */
+                                       status = verifyAndConfigQosParams(hQosMngr,&(pQosMngr->acParams[QOS_AC_BE].acQosParams));
+                                       if(status != OK)
+                                               return status;
+                               }
+                       }
+                               
+                       /* Packet burst enable changed from T to F*/ 
+                       else 
+                       {
+                               /* Update the acTrafficInitParams of BE to the AC def*/
+                               pQosMngr->acParams[QOS_AC_BE].acQosInitParams.txopLimit = QOS_TX_OP_LIMIT_DEF;
+                       
+                               /* Update the acTrafficParams of BE  and the hal to the AC def*/
+                               if (pQosMngr->activeProtocol == NONE_QOS)
+                               {
+                                       pQosMngr->acParams[QOS_AC_BE].acQosParams.txopLimit = QOS_TX_OP_LIMIT_DEF;
+                                       /* verify the parameters and update the hal */
+                                       status = verifyAndConfigQosParams(hQosMngr,&(pQosMngr->acParams[QOS_AC_BE].acQosParams));
+                                       if(status != OK)
+                                               return status;
+                               }
+                       }
+                       break;
+
+               case QOS_MNGR_SET_SITE_PROTOCOL:
+                       if(pParamInfo->content.qosSiteProtocol == WME)
+                               pQosMngr->WMESiteSupport = TRUE;
+                       else
+                               pQosMngr->WMESiteSupport = FALSE;
+               break;
+
+       case QOS_MNGR_SET_OS_PARAMS:
+               if((acTrfcType_e)pParamInfo->content.qosOsParams.acID > QOS_HIGHEST_AC_INDEX)
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                         ("qosMngr_setParams :Error  trying to set invalid acId: %d param",pParamInfo->content.qosOsParams.acID)); 
+
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+
+               if((pParamInfo->content.qosOsParams.VoiceDeliveryProtocol != TRUE) && (pParamInfo->content.qosOsParams.VoiceDeliveryProtocol != FALSE))
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_setParams :Error  trying to set invalid VoiceDeliveryProtocol: %d param",pParamInfo->content.qosOsParams.VoiceDeliveryProtocol)); 
+                       
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+               
+               if((pParamInfo->content.qosOsParams.VoiceDeliveryProtocol == TRUE) && ((PSScheme_e)pParamInfo->content.qosOsParams.PSDeliveryProtocol == PS_SCHEME_UPSD_TRIGGER))
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_setParams Error: trying to set invalid VoiceDeliveryProtocol == PS_POLL and PSDeliveryProtocol = UPSD\n")); 
+                       
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+
+               if((pParamInfo->content.qosOsParams.VoiceDeliveryProtocol == TRUE) && ((acTrfcType_e)pParamInfo->content.qosOsParams.acID !=  QOS_AC_VO))
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_setParams Error: trying to set invalid VoiceDeliveryProtocol == PS_POLL and AC != VOICE \n")); 
+                       
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+
+               if(((PSScheme_e)pParamInfo->content.qosOsParams.PSDeliveryProtocol != PS_SCHEME_LEGACY_PSPOLL) && ((PSScheme_e)pParamInfo->content.qosOsParams.PSDeliveryProtocol != PS_SCHEME_UPSD_TRIGGER))
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_setParams :Error trying to set invalid PSDeliveryProtocol: %d param\n",pParamInfo->content.qosOsParams.PSDeliveryProtocol)); 
+
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+
+               /* config tidConf */
+               acID = (acTrfcType_e)pParamInfo->content.qosOsParams.acID;
+
+        /* Convert TRUE/FALSE setting (from Utility Adapter) to PS_POLL or PS_NONE settings */
+        if (pParamInfo->content.qosOsParams.VoiceDeliveryProtocol == FALSE)
+        {
+           pParamInfo->content.qosOsParams.VoiceDeliveryProtocol = PS_SCHEME_LEGACY;
+        }
+        if (pParamInfo->content.qosOsParams.VoiceDeliveryProtocol == TRUE)
+        {
+           pParamInfo->content.qosOsParams.VoiceDeliveryProtocol = PS_SCHEME_LEGACY_PSPOLL;
+        }
+           
+
+               if( (pParamInfo->content.qosOsParams.PSDeliveryProtocol != pQosMngr->acParams[acID].desiredWmeAcPsMode) && 
+                       (pQosMngr->isConnected == TRUE) )
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_setParams :Error  trying to set new PS protocol while connected")); 
+                       
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+
+
+               /* UPSD_FW open in upsd integration */
+               /* set the current PS mode. In not connected state it is always Legacy since the currentPsMode only 
+                update after connection */
+               pQosMngr->acParams[acID].QtrafficParams.psScheme = pQosMngr->acParams[acID].currentWmeAcPsMode;
+               pQosMngr->acParams[acID].msduLifeTimeParam = pParamInfo->content.qosOsParams.MaxLifeTime;
+
+               status = verifyAndConfigTrafficParams(pQosMngr,&(pQosMngr->acParams[acID].QtrafficParams));
+               if(status != OK)
+                       return status;
+               
+               /* set txData Voice Delivery Protocol mode */
+               if(acID == QOS_AC_VO)
+                       pQosMngr->desiredVoiceDeliveryProtocol = pParamInfo->content.qosOsParams.VoiceDeliveryProtocol;
+
+               param.content.txDataQosParams.acID = acID;
+               param.content.txDataQosParams.acTrfcCtrl.PsMode = pParamInfo->content.qosOsParams.VoiceDeliveryProtocol;
+               param.paramType = TX_DATA_PS_MODE_PARAM;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               param.content.txDataQosParams.acTrfcCtrl.MsduLifeTime = pParamInfo->content.qosOsParams.MaxLifeTime;
+               param.paramType = TX_DATA_CONFIG_AC_MSDU_LIFE_TIME;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               /* synch psPoll mode with qosMngr */
+               /* Update the PsMode parameter */
+               pQosMngr->acParams[acID].desiredWmeAcPsMode = pParamInfo->content.qosOsParams.PSDeliveryProtocol;
+               break;
+
+       case QOS_MNGR_CURRENT_PS_MODE:
+               if( (pQosMngr->activeProtocol == WME) && (pQosMngr->desiredPsMode == PS_SCHEME_UPSD_TRIGGER) && (pParamInfo->content.currentPsMode == PS_SCHEME_UPSD_TRIGGER) )
+                       pQosMngr->currentPsMode = PS_SCHEME_UPSD_TRIGGER;
+               else
+                       pQosMngr->currentPsMode = PS_SCHEME_LEGACY_PSPOLL;
+               break;
+               
+    case QOS_MNGR_ADD_TSPEC_REQUEST:
+               pQosMngr->TSPECNegotiationResultCallb = NULL;
+               pQosMngr->TSPECNegotiationResultModule = NULL;
+               return (qosMngr_requestAdmission(hQosMngr,  &pParamInfo->content.qosAddTspecRequest));
+/*             break; - unreachable */
+               
+       case QOS_MNGR_RESEND_TSPEC_REQUEST:
+               WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                               ("qosMngr_setParams: QOS_MNGR_RESEND_TSPEC_REQUEST\n")); 
+               pQosMngr->TSPECNegotiationResultCallb = (qosMngrCallb_t)pParamInfo->content.qosRenegotiateTspecRequest.callback;
+               pQosMngr->TSPECNegotiationResultModule = pParamInfo->content.qosRenegotiateTspecRequest.handler; 
+               status = qosMngr_requestAdmission(hQosMngr,  &pQosMngr->tspecRenegotiationParams[USER_PRIORITY_6]);
+
+               if ((status == OK) && (pQosMngr->tspecRenegotiationParams[USER_PRIORITY_4].uUserPriority != MAX_USER_PRIORITY))
+               {
+                       status = qosMngr_requestAdmission(hQosMngr,  &pQosMngr->tspecRenegotiationParams[USER_PRIORITY_4]);
+               }
+               return (status);
+/*             break;  - unreachable */
+               
+    case QOS_MNGR_DEL_TSPEC_REQUEST:
+               return (qosMngr_deleteAdmission(hQosMngr, &pParamInfo->content.qosDelTspecRequest));
+/*             break; - unreachable */
+               
+    case QOS_MNGR_AC_STATUS:
+               return (qosMngr_getCurrAcStatus (hQosMngr,&pParamInfo->content.qosCurrentAcStatus));
+/*             break; - unreachable */
+
+    case QOS_MNGR_AP_QOS_PARAMETERS:  /* API GetAPQosParameters */
+               acID = (acTrfcType_e) pParamInfo->content.qosApQosParams.uAC;
+
+               if(acID > QOS_HIGHEST_AC_INDEX)
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                         ("qosMngr_setParams :Error  trying to set invalid acId: %d param\n",pParamInfo->content.qosApQosParams.uAC)); 
+
+                       return (PARAM_VALUE_NOT_VALID);
+               }
+               if(pQosMngr->isConnected == FALSE)
+               {
+                       return NOT_CONNECTED;
+               }
+               if(pQosMngr->activeProtocol == NONE_QOS)
+               {
+                       return NO_QOS_AP;
+               }
+               
+               pParamInfo->content.qosApQosParams.uAssocAdmissionCtrlFlag = pQosMngr->acParams[acID].apInitAdmissionState; /* admission flag */
+               pParamInfo->content.qosApQosParams.uAIFS = pQosMngr->acParams[acID].acQosParams.aifsn;
+               pParamInfo->content.qosApQosParams.uCwMin = (1 << pQosMngr->acParams[acID].acQosParams.cwMin)-1;
+               pParamInfo->content.qosApQosParams.uCwMax = (1 << pQosMngr->acParams[acID].acQosParams.cwMax)-1;
+               pParamInfo->content.qosApQosParams.uTXOPLimit = pQosMngr->acParams[acID].acQosParams.txopLimit << 5;
+
+               break;
+
+       case QOS_MNGR_OS_TSPEC_PARAMS: 
+
+               if( pParamInfo->content.qosTspecParameters.uUserPriority > MAX_USER_PRIORITY )
+               {       
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+               ("qosMngr_getTspecParams: userPriority > 7 -> Ignore !!!\n"));
+                       return NOK;
+               }
+
+               if(pQosMngr->isConnected == FALSE)
+               {       
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+               ("qosMngr_getTspecParams: Not connected - Ignoring request !!!\n"));
+                       return NOT_CONNECTED;
+               }
+
+               if(pQosMngr->activeProtocol == NONE_QOS)
+               {       
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+               ("qosMngr_getTspecParams: Not connected to QOS AP - Ignoring reqeust !!!\n"));
+                       return NO_QOS_AP;
+               }
+               
+               acID = (acTrfcType_e)WMEQosTagToACTable[pParamInfo->content.qosTspecParameters.uUserPriority];
+
+               /* check if signaling is already in process*/
+               if(pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState == AC_WAIT_ADMISSION)
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: AC = %d , TSPEC Signaling is in progress -> Ignoring request !!!\n",acID));
+                       return TRAFIC_ADM_PENDING;
+               }
+
+          /* check if UP is admitted or not */
+          if(pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority != pParamInfo->content.qosTspecParameters.uUserPriority)
+       {       
+                WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+            ("qosMngr_getTspecParams: user priority is not admitted. -> Ignore !!!\n"));
+                return USER_PRIORITY_NOT_ADMITTED;
+               }
+
+               pParamInfo->content.qosTspecParameters.uMeanDataRate = pQosMngr->resourceMgmtTable.currentTspecInfo[acID].meanDataRate;
+               pParamInfo->content.qosTspecParameters.uNominalMSDUsize = pQosMngr->resourceMgmtTable.currentTspecInfo[acID].nominalMsduSize;
+               pParamInfo->content.qosTspecParameters.uAPSDFlag  = pQosMngr->resourceMgmtTable.currentTspecInfo[acID].UPSDFlag;
+               pParamInfo->content.qosTspecParameters.uMinimumPHYRate  = pQosMngr->resourceMgmtTable.currentTspecInfo[acID].minimumPHYRate;
+               pParamInfo->content.qosTspecParameters.uSurplusBandwidthAllowance  = pQosMngr->resourceMgmtTable.currentTspecInfo[acID].surplausBwAllowance;
+               pParamInfo->content.qosTspecParameters.uMediumTime = pQosMngr->resourceMgmtTable.currentTspecInfo[acID].mediumTime;
+               break;
+
+       case QOS_SET_RATE_THRESHOLD: 
+
+               ctrlData_setTspecsRateThresholds(pQosMngr->hCtrlData,
+                                                                                       (UINT8)pParamInfo->content.QOSRateThreshold.uAC,
+                                                                                       (UINT8)pParamInfo->content.QOSRateThreshold.uHighThreshold,
+                                                                                       (UINT8)pParamInfo->content.QOSRateThreshold.uLowThreshold);
+
+               
+               /* If currently connected to a QOS AP , need to enable the TSPEc event upon the setting of the thresholds */
+               if(pQosMngr->activeProtocol == WME)
+               {
+                       ctrlData_setTspecsRateEvent(pQosMngr->hCtrlData, (UINT8)pParamInfo->content.QOSRateThreshold.uAC, TRUE);
+               }
+
+               break;
+
+       case QOS_GET_RATE_THRESHOLD:
+
+               /* SET operation is performed, but actually this is only for AC parameter transfer from Utility Adapter to driver, since copy
+             of user supplied block of data (and vice versa) is only performed in SetParam calls, the driver can also modify the supplied
+                 structure and thus return it to user mode */
+               ctrlData_getTspecsRateThresholds(pQosMngr->hCtrlData,
+                                                                       (UINT8)pParamInfo->content.QOSRateThreshold.uAC,
+                                                                       (UINT32*)&pParamInfo->content.QOSRateThreshold.uHighThreshold,
+                                                                       (UINT32*)&pParamInfo->content.QOSRateThreshold.uLowThreshold);
+
+               break;
+
+       case QOS_SET_RX_TIME_OUT:
+               if (pParamInfo->content.rxTimeOut.UPSD == 0)
+               {
+                               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                                 ("%s :Error trying to set invalid zero timeout for UPSD \n",__FUNCTION__)); 
+                               return PARAM_VALUE_NOT_VALID;
+                               
+               }
+               pQosMngr->rxTimeOut.psPoll = (UINT16)pParamInfo->content.rxTimeOut.psPoll;
+               pQosMngr->rxTimeOut.UPSD = (UINT16)pParamInfo->content.rxTimeOut.UPSD;
+
+
+               /* set RxTimeOut to FW */
+               whalParam.paramType     = HAL_CTRL_RX_TIME_OUT_PARAM;
+               whalParam.content.halCtrlRxTimeOut = pQosMngr->rxTimeOut;
+               whalCtrl_SetParam(pQosMngr->hHalCtrl,&whalParam); 
+               break;
+
+
+       case QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC:
+               if( pParamInfo->content.TspecConfigure.voiceTspecConfigure || pParamInfo->content.TspecConfigure.videoTspecConfigure)
+            pQosMngr->performTSPECRenegotiation = TRUE;
+               else
+                       pQosMngr->performTSPECRenegotiation = FALSE;
+
+          WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                          ("qosMngr_setParams: QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC=%d\n", pQosMngr->performTSPECRenegotiation)); 
+          break;
+
+       default:
+         WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("qosMngr_getParams Error: unknown paramType 0x%x!\n",pParamInfo->paramType)); 
+                       return (PARAM_NOT_SUPPORTED);
+/*             break; - unreachable */
+       }
+
+       return OK;
+
+
+}
+
+/************************************************************************
+ *                        verifyAndConfigTrafficParams                             *
+ ************************************************************************
+DESCRIPTION: The function verifies the parameters set by qosMngr to 
+             the queue traffic params in whalCtrl to be configured to TNET. 
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+            pAcTrafficParams     -  pointer to ac parameters.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static TI_STATUS verifyAndConfigTrafficParams(qosMngr_t *pQosMngr, queueTrafficParams_t *pQtrafficParams)
+{
+    whalParamInfo_t               whalParam;    
+    queueTrafficParams_t   queueTrafficParams;
+
+       if(pQtrafficParams->queueID >  MAX_NUM_OF_TX_QUEUES - 1)
+    {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigTrafficParams :Error  trying to set invalid queueID: %d param",pQtrafficParams->queueID)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+
+
+       if(pQtrafficParams->channelType > MAX_CHANNEL_TYPE)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigTrafficParams :Error  trying to set invalid channelType: %d param",pQtrafficParams->channelType)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+
+       }
+
+    /* TBD */
+       if(pQtrafficParams->tsid > AC_PARAMS_MAX_TSID)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigTrafficParams :Error  trying to set invalid tsid: %d param",pQtrafficParams->tsid)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+
+       }
+
+
+       if(pQtrafficParams->psScheme > MAX_PS_SCHEME)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigTrafficParams :Error  trying to set invalid psScheme: %d param",pQtrafficParams->psScheme)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+
+    /* TBD */
+#if 0
+       if(pQtrafficParams->APSDConf > MAX_APSD_CONF)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigTrafficParams :Error  trying to set invalid APSDConf: %d param",pQtrafficParams->APSDConf)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+#endif
+
+       if(pQtrafficParams->ackPolicy > MAX_ACK_POLICY)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigTrafficParams :Error  trying to set invalid ackPolicy: %d param",pQtrafficParams->ackPolicy)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+
+    /*
+     * Convert the QOS PS-scheme enum into the WHAL enum.
+     * NOTE: need to copy for not to change the QoS configuration
+     */
+    queueTrafficParams = *pQtrafficParams;
+
+    switch (queueTrafficParams.psScheme)
+    {
+    case PS_SCHEME_LEGACY:
+        queueTrafficParams.psScheme = PS_SCHEME_LEGACY;
+        break;
+    case PS_SCHEME_UPSD_TRIGGER:
+        queueTrafficParams.psScheme = PS_SCHEME_UPSD_TRIGGER;
+        break;
+    case PS_SCHEME_LEGACY_PSPOLL:
+        queueTrafficParams.psScheme = PS_SCHEME_LEGACY;
+        break;
+    case PS_SCHEME_SAPSD:
+        queueTrafficParams.psScheme = PS_SCHEME_SAPSD;
+        break;
+    }
+
+       whalParam.paramType = HAL_CTRL_QUEUES_PARAMS;
+       /* set parameters */
+       whalParam.content.pQueueTrafficParams = &queueTrafficParams;
+
+       return(whalCtrl_SetParam(pQosMngr->hHalCtrl, &whalParam));
+}
+
+/************************************************************************
+ *                        verifyAndConfigQosParams                         *
+ ************************************************************************
+DESCRIPTION: The function verifies the parameters set by qosMngr to 
+             the AC Qos params in whalCtrl to be configured to TNET. 
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+            pAcTrafficParams     -  pointer to ac parameters.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static TI_STATUS  verifyAndConfigQosParams(qosMngr_t *pQosMngr,acQosParams_t *pAcQosParams)
+{
+    whalParamInfo_t               whalParam;
+       acQosParams_t          acQosParams;
+
+       if(pAcQosParams->ac >  MAX_NUM_OF_AC - 1 )
+    {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigQosParams :Error  trying to set invalid ac : %d param",pAcQosParams->ac)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+ /*  verification is unnecessary due to limited range of pAcQosParams->aifsn data type (UINT8)
+       if(pAcQosParams->aifsn >  QOS_AIFS_MAX )
+    {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigQosParams :Error  trying to set invalid aifsn : %d param",pAcQosParams->aifsn)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+ */
+       if(pAcQosParams->cwMax >  QOS_CWMAX_MAX )
+    {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigQosParams :Error  trying to set invalid cwMax : %d param",pAcQosParams->cwMax)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+
+       if(pAcQosParams->cwMin >  QOS_CWMIN_MAX )
+    {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigQosParams :Error  trying to set invalid cwMax : %d param",pAcQosParams->cwMax)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+
+       if(pAcQosParams->txopLimit >  QOS_TX_OP_LIMIT_MAX )
+    {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                 ("verifyAndConfigQosParams :Error  trying to set invalid txopLimit : %d param",pAcQosParams->txopLimit)); 
+
+               return (PARAM_VALUE_NOT_VALID);
+       }
+
+
+       whalParam.paramType = HAL_CTRL_AC_PARAMS; 
+
+       acQosParams.ac = pAcQosParams->ac;
+       acQosParams.aifsn =  pAcQosParams->aifsn;
+
+       /* convert to TNET units */
+       acQosParams.cwMax =  (1 << pAcQosParams->cwMax) - 1; /* CwMax = 2^CwMax - 1*/
+       acQosParams.cwMin =  (1 << pAcQosParams->cwMin) - 1; /* CwMin = 2^CwMin - 1*/
+       acQosParams.txopLimit =  pAcQosParams->txopLimit << 5; /* in us */
+
+
+
+       /* set parameters */
+       whalParam.content.configureCmdCBParams.CB_buf = (UINT8*)&acQosParams;
+       whalParam.content.configureCmdCBParams.CB_Func = NULL;
+       whalParam.content.configureCmdCBParams.CB_handle = NULL;
+
+       return whalCtrl_SetParam(pQosMngr->hHalCtrl, &whalParam);
+}
+
+/************************************************************************
+ *                        qosMngr_selectActiveProtocol                                     *
+ ************************************************************************
+DESCRIPTION: The function is called in order to set the active protocol in
+             the qosMngr according to site capabilities and desired mode.
+             called from SystemConfig.
+                                                                                                   
+INPUT:      
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS qosMngr_selectActiveProtocol(TI_HANDLE  hQosMngr)
+{
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       /* decide qos protocol */
+       /* NOTE: if both exc qnd wme supported wme is chosen */
+       if(pQosMngr->WMESiteSupport && pQosMngr->WMEEnable)
+       {
+               pQosMngr->activeProtocol = WME;
+       }
+       else
+    {
+               pQosMngr->activeProtocol = NONE_QOS;
+       }
+       WLAN_REPORT_DEBUG_TX(pQosMngr->hReport,
+        (" qosMngr_selectActiveProtocol() : pQosMngr->activeProtocol %d\n",pQosMngr->activeProtocol));
+
+    return OK;
+}
+
+/************************************************************************
+ *                        qosMngr_setAcPsDeliveryMode                                      *
+ ************************************************************************
+DESCRIPTION: The function is called in order to set the upsd/ps_poll according 
+             to the desired and current upsd mode (per AC as well).
+             called from systemConfig.
+                                                                                                   
+INPUT:      
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS qosMngr_setAcPsDeliveryMode(TI_HANDLE  hQosMngr)
+{
+   UINT8 acID;
+   qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       /* in case the current PS mode is not UPSD  - the IE is empty */
+       if(pQosMngr->currentPsMode == PS_SCHEME_UPSD_TRIGGER)
+       {
+               for(acID = FIRST_AC_INDEX;acID < MAX_NUM_OF_AC; acID++)
+               {
+                       if(pQosMngr->acParams[acID].desiredWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+                       {
+                               pQosMngr->acParams[acID].currentWmeAcPsMode = PS_SCHEME_UPSD_TRIGGER;
+                       }
+               }
+    }
+       else {
+        paramInfo_t param;
+
+        // Setting params for PS Poll mode
+        // This was done to enable voice delivery protocol when the AP doesn't
+        // support UASPD.
+        // Note these values have been taken from the default value table in 
+        // TiCtrl.c -- see TiUAPSDConfig()
+        
+        os_memoryZero( pQosMngr->hOs, &param, sizeof(paramInfo_t) );
+        param.paramType = QOS_MNGR_SET_OS_PARAMS;
+
+        // Setting AC Best Effort settings
+        param.content.qosOsParams.acID = QOS_AC_BE;
+        param.content.qosOsParams.MaxLifeTime = 512;
+        param.content.qosOsParams.VoiceDeliveryProtocol = FALSE;
+        param.content.qosOsParams.PSDeliveryProtocol = PS_SCHEME_LEGACY_PSPOLL;
+        qosMngr_setParams( pQosMngr, &param );
+
+
+        // Setting AC Background settings
+        param.content.qosOsParams.acID = QOS_AC_BK;
+        param.content.qosOsParams.MaxLifeTime = 100;
+        param.content.qosOsParams.VoiceDeliveryProtocol = FALSE;
+        param.content.qosOsParams.PSDeliveryProtocol = PS_SCHEME_LEGACY_PSPOLL;
+        qosMngr_setParams( pQosMngr, &param );
+
+
+        // Setting AC Video settings
+        param.content.qosOsParams.acID = QOS_AC_VI;
+        param.content.qosOsParams.MaxLifeTime = 100;
+        param.content.qosOsParams.VoiceDeliveryProtocol = FALSE;
+        param.content.qosOsParams.PSDeliveryProtocol = PS_SCHEME_LEGACY_PSPOLL;
+        qosMngr_setParams( pQosMngr, &param );
+
+        // Setting AC Voice settings
+        param.content.qosOsParams.acID = QOS_AC_VO;
+        param.content.qosOsParams.MaxLifeTime = 60;
+        param.content.qosOsParams.VoiceDeliveryProtocol = TRUE;
+        param.content.qosOsParams.PSDeliveryProtocol = PS_SCHEME_LEGACY_PSPOLL;
+        qosMngr_setParams( pQosMngr, &param );
+    }
+       
+       return OK;
+
+}
+
+
+/************************************************************************
+ *                        qosMngr_getQosCapabiltyInfeElement                                       *
+ ************************************************************************
+DESCRIPTION: The function is called in order to build the Qos Capability
+                        IE for the associatiomn request.
+                                                                                                   
+INPUT:      
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS qosMngr_getQosCapabiltyInfeElement(TI_HANDLE  hQosMngr, UINT8 *pQosIe, UINT8 *pLen)
+{    
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       dot11_QOS_CAPABILITY_IE_t *dot11_QOS_CAPABILITY_IE = (dot11_QOS_CAPABILITY_IE_t *)pQosIe;
+       TI_STATUS status = OK;
+       UINT8   extraIeLen = 0;
+       
+       if(pQosMngr->activeProtocol == WME)
+       {
+               dot11_QOS_CAPABILITY_IE->hdr.eleId    = DOT11_QOS_CAPABILITY_ELE_ID;
+               dot11_QOS_CAPABILITY_IE->hdr.eleLen   = DOT11_QOS_CAPABILITY_ELE_LEN;
+               
+               /* The default configuration of QoS info Field is legacy PS for all ACs */
+               dot11_QOS_CAPABILITY_IE->QosInfoField = 0;
+               
+               /* in case the current PS mode is not UPSD  - the IE is empty */
+               if(pQosMngr->currentPsMode == PS_SCHEME_UPSD_TRIGGER)
+               {
+                       if(pQosMngr->acParams[QOS_AC_VO].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+                       {
+                               dot11_QOS_CAPABILITY_IE->QosInfoField |= (1 << AC_VO_APSD_FLAGS_SHIFT);
+                       }
+                       if(pQosMngr->acParams[QOS_AC_VI].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+                       {
+                               dot11_QOS_CAPABILITY_IE->QosInfoField |= (1 << AC_VI_APSD_FLAGS_SHIFT);
+                       }
+
+                       if(pQosMngr->acParams[QOS_AC_BK].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+                       {
+                               dot11_QOS_CAPABILITY_IE->QosInfoField |= (1 << AC_BK_APSD_FLAGS_SHIFT);
+                       }
+
+                       if(pQosMngr->acParams[QOS_AC_BE].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+                       {
+                               dot11_QOS_CAPABILITY_IE->QosInfoField |= (1 << AC_BE_APSD_FLAGS_SHIFT);
+                       }
+
+                       dot11_QOS_CAPABILITY_IE->QosInfoField |= (((pQosMngr->desiredMaxSpLen) & MAX_SP_LENGTH_MASK) << MAX_SP_LENGTH_SHIFT);
+
+            WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+               ("dot11_QOS_CAPABILITY_IE->QosInfoField = 0x%x\n",dot11_QOS_CAPABILITY_IE->QosInfoField));
+               }
+
+               *pLen = dot11_QOS_CAPABILITY_IE->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               
+#ifdef EXC_MODULE_INCLUDED
+               /* If required, add exc info-elements to the association request packets */
+               if (pQosMngr->performTSPECRenegotiation == TRUE)
+               {
+            WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+               ("qosMngr_getQosCapabiltyInfeElement: performing TSPEC renegotiation\n"));
+
+                       status = excMngr_getEXCQosIElements(pQosMngr->hExcMgr, (pQosIe+(*pLen)), &extraIeLen);
+               }
+#endif
+               *pLen += extraIeLen;
+       }
+       else
+       {
+               *pLen = 0;
+       }
+
+       return status;
+
+}
+/************************************************************************
+ *                        qosMngr_assocReqBuild                                    *
+ ************************************************************************
+DESCRIPTION: The function is called in order to build the assocReq IE for
+             the current site QOS protocol.
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_assocReqBuild(TI_HANDLE  hQosMngr, UINT8 *pQosIe, UINT8 *pLen)
+{
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       TI_STATUS               status;
+
+       
+       if(pQosMngr == NULL)
+       {
+               *pLen = 0;
+               return OK;
+       }       
+
+       /* building assocReq frame */
+       switch(pQosMngr->activeProtocol)
+       {
+       case WME:
+               status = getWMEInfoElement(pQosMngr,pQosIe,pLen);
+               if (status !=OK) 
+               {
+                       *pLen = 0;
+               }
+               break;
+
+       case NONE_QOS:
+                       *pLen = 0;
+                       return OK;
+/*             break; - unreachable */
+
+       default:
+                       *pLen = 0;
+               break;
+       }
+       
+       return OK;
+}
+
+/************************************************************************
+ *                        getWMEInfoElement                                        *
+ ************************************************************************
+DESCRIPTION: building WME IE.
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static TI_STATUS getWMEInfoElement(qosMngr_t *pQosMngr,UINT8 *pWMEie,UINT8 *pLen)
+{
+       dot11_WME_IE_t *pDot11_WME_IE = (dot11_WME_IE_t *)pWMEie;
+
+       pDot11_WME_IE->hdr.eleId         = DOT11_WME_ELE_ID;
+       pDot11_WME_IE->hdr.eleLen        = DOT11_WME_ELE_LEN;
+       pDot11_WME_IE->OUI[0]            = 0x00;
+       pDot11_WME_IE->OUI[1]            = 0x50;
+       pDot11_WME_IE->OUI[2]            = 0xf2;
+       pDot11_WME_IE->OUIType           = dot11_WME_OUI_TYPE;
+       pDot11_WME_IE->OUISubType        = dot11_WME_OUI_SUB_TYPE_IE;
+       pDot11_WME_IE->version           = dot11_WME_VERSION;
+       pDot11_WME_IE->ACInfoField       = 0;
+
+       if(pQosMngr->currentPsMode == PS_SCHEME_UPSD_TRIGGER)
+       {
+               if(pQosMngr->acParams[QOS_AC_VO].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+               {
+                       pDot11_WME_IE->ACInfoField |= (1 << AC_VO_APSD_FLAGS_SHIFT);
+               }
+               if(pQosMngr->acParams[QOS_AC_VI].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+               {
+                       pDot11_WME_IE->ACInfoField |= (1 << AC_VI_APSD_FLAGS_SHIFT);
+               }
+
+               if(pQosMngr->acParams[QOS_AC_BK].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+               {
+                       pDot11_WME_IE->ACInfoField |= (1 << AC_BK_APSD_FLAGS_SHIFT);
+               }
+
+               if(pQosMngr->acParams[QOS_AC_BE].currentWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER)
+               {
+                       pDot11_WME_IE->ACInfoField |= (1 << AC_BE_APSD_FLAGS_SHIFT);
+               }
+
+               pDot11_WME_IE->ACInfoField |= (((pQosMngr->desiredMaxSpLen) & MAX_SP_LENGTH_MASK) << MAX_SP_LENGTH_SHIFT);
+       }
+
+       *pLen = pDot11_WME_IE->hdr.eleLen + sizeof(dot11_eleHdr_t);
+
+       return OK;
+
+}
+
+/************************************************************************
+ *                        qosMngr_checkTspecRenegResults                       *
+ ************************************************************************
+DESCRIPTION: The function is called upon association response to check 
+            Tspec renegotiation results
+                                                                                                   
+INPUT:      hQosMngr     -     Qos Manager handle.
+            assocRsp      -  pointer to received IE parameters received 
+                                        in association response. 
+OUTPUT:                
+
+RETURN:     -
+
+************************************************************************/
+void qosMngr_checkTspecRenegResults(TI_HANDLE hQosMngr, assocRsp_t *assocRsp)
+{
+       tspecInfo_t     tspecInfo;
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+#ifdef EXC_MODULE_INCLUDED
+       UINT32 acCount;
+#endif
+
+       WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+          ("qosMngr_checkTspecRenegResults: performTSPECRenegotiation = %d, tspecParams received= %x\n",
+               pQosMngr->performTSPECRenegotiation, assocRsp->tspecVoiceParameters));
+
+       if (pQosMngr->performTSPECRenegotiation != TRUE)
+       {
+               /* If no re-negotiation was requested, no parsing shall be done */
+#ifdef EXC_MODULE_INCLUDED
+               measurementMgr_disableTsMetrics(pQosMngr->hMeasurementMngr, MAX_NUM_OF_AC);
+#endif
+               return;
+       }
+
+       if (assocRsp->tspecVoiceParameters == NULL && assocRsp->tspecSignalParameters == NULL)
+       {
+               /* The renegotiation request was ignored - update QoS Manager database */
+               qosMngr_setAdmissionInfo(pQosMngr, USER_PRIORITY_6, 
+                                                                &pQosMngr->resourceMgmtTable.candidateTspecInfo[USER_PRIORITY_6], 
+                                                                STATUS_TRAFFIC_ADM_REQUEST_REJECT);
+
+               if (pQosMngr->tspecRenegotiationParams[USER_PRIORITY_4].uUserPriority != MAX_USER_PRIORITY)
+               {
+                       qosMngr_setAdmissionInfo(pQosMngr, USER_PRIORITY_4, 
+                                                                        &pQosMngr->resourceMgmtTable.candidateTspecInfo[USER_PRIORITY_4], 
+                                                                        STATUS_TRAFFIC_ADM_REQUEST_REJECT);
+               }
+#ifdef EXC_MODULE_INCLUDED
+        measurementMgr_disableTsMetrics(pQosMngr->hMeasurementMngr, MAX_NUM_OF_AC);
+#endif
+               return;
+       }
+
+       if (assocRsp->tspecVoiceParameters != NULL)
+       {
+       /* The renogitaion was performed - update QoS Manager database */
+       pQosMngr->voiceTspecConfigured = TRUE;
+       trafficAdmCtrl_parseTspecIE(pQosMngr->pTrafficAdmCtrl, &tspecInfo, assocRsp->tspecVoiceParameters);
+
+       qosMngr_setAdmissionInfo(pQosMngr, tspecInfo.AC, &tspecInfo, STATUS_TRAFFIC_ADM_REQUEST_ACCEPT);
+       }
+
+       if (assocRsp->tspecSignalParameters != NULL)
+       {
+               /* Signal TSPEC was re-negotiated as well */
+               pQosMngr->videoTspecConfigured = TRUE;
+               trafficAdmCtrl_parseTspecIE(pQosMngr->pTrafficAdmCtrl, &tspecInfo, assocRsp->tspecSignalParameters);
+               qosMngr_setAdmissionInfo(pQosMngr, tspecInfo.AC, &tspecInfo, STATUS_TRAFFIC_ADM_REQUEST_ACCEPT);
+       }
+       else if (pQosMngr->tspecRenegotiationParams[USER_PRIORITY_4].uUserPriority != MAX_USER_PRIORITY) 
+       {
+               /* Signal TSPEC was not re-negotiated although requested to - ERROR */
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                                 ("qosMngr_setSite: Signal TSPEC was not re-negotiated while voice was \n"));
+               qosMngr_setAdmissionInfo(pQosMngr, USER_PRIORITY_4, 
+                                                                &pQosMngr->resourceMgmtTable.candidateTspecInfo[USER_PRIORITY_4], 
+                                                                STATUS_TRAFFIC_ADM_REQUEST_REJECT);
+       }
+
+#ifdef EXC_MODULE_INCLUDED
+       /* If EXC IEs are present for one or more ACs, update other modules with received parameters */
+       for (acCount = 0; acCount < MAX_NUM_OF_AC; acCount++)
+       {
+               excMngr_setEXCQoSParams(pQosMngr->hExcMgr, &assocRsp->excIEs[acCount], acCount);
+       }
+#endif
+}
+
+
+/************************************************************************
+ *                        qosMngr_setSite                                          *
+ ************************************************************************
+DESCRIPTION: The function is called upon association response to set site 
+             parameters.
+                                                                                                   
+INPUT:      hQosMngr     -     Qos Manager handle.
+            assocRsp      -  pointer to received IE parameters received 
+                                        in association response. 
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS qosMngr_setSite(TI_HANDLE hQosMngr, assocRsp_t *assocRsp)
+{
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       TI_STATUS  status;
+    paramInfo_t        param;
+
+       if(hQosMngr == NULL)
+        return NOK;
+
+       /* checking active protocol */
+       switch(pQosMngr->activeProtocol)
+       {
+               case WME:
+                       /* verify QOS protocol received in association response */
+                       status = verifyWmeIeParams(pQosMngr, (UINT8 *)assocRsp->WMEParams);
+                       if(status != OK)
+                       {
+                pQosMngr->activeProtocol = NONE_QOS;
+                WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                          ("qosMngr_setSite: setting active protocol WME params with non WME IE params frame, setting active protocol back to NONE \n"));
+                return NOK;
+                       }
+
+            status = setWmeSiteParams(pQosMngr, (UINT8 *)assocRsp->WMEParams);
+                       if (status != OK)
+                       {
+                pQosMngr->activeProtocol = NONE_QOS;
+                WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                          ("Warning: qosMngr_setSite-> failed to set AC WME parameters!!! , setting active protocol back to NONE\n"));
+                return NOK;
+                       }
+                       /* update siteMgr with recevied params */
+                       status = siteMgr_setWMEParamsSite(pQosMngr->hSiteMgr, assocRsp->WMEParams);
+                       if (status != OK)
+                       {
+                pQosMngr->activeProtocol = NONE_QOS;
+                WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                                    ("qosMngr_setSite:failed to init WME parameters!!! , setting active protocol back to NONE\n\n"));
+                return NOK;
+                       }
+
+                       break;
+
+       case NONE_QOS:
+
+                       /* Check if the packet burst is enable, if it is, 
+                       should update the BE parames and the hal to the packet burst def */
+                       if (pQosMngr->qosPacketBurstEnable == TRUE)
+                       {
+                               /* Update the acTrafficInitParams of BE to the packet burst def*/
+                               pQosMngr->acParams[QOS_AC_BE].acQosInitParams.txopLimit = pQosMngr->qosPacketBurstTxOpLimit;
+                               /* Update the acTrafficParams of BE to the packet burst def*/
+                               pQosMngr->acParams[QOS_AC_BE].acQosInitParams.txopLimit = pQosMngr->qosPacketBurstTxOpLimit;
+                               /* verify the parameters and update the hal */
+                               status = verifyAndConfigQosParams(hQosMngr,&(pQosMngr->acParams[QOS_AC_BE].acQosParams));
+                               if (status != OK)
+                               {
+                                       WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                                       ("qosMngr_setSite:failed to init NON_QOS parameters!!!\n\n")); 
+                                       return NOK;
+                               }
+                       }
+
+                       /* By setting the PS_MODE of QOS_AC_VO to desiredVoiceDeliveryProtocol, we enable sending PS_POLL packets by the txData module 
+                          Even though all user priorities are mapped to QOS_AC_BE, when txData checks if Ps_Poll is needed for AC_VO */
+                       param.content.txDataQosParams.acID = QOS_AC_VO;
+                       param.content.txDataQosParams.acTrfcCtrl.PsMode = pQosMngr->desiredVoiceDeliveryProtocol;
+                       param.paramType = TX_DATA_PS_MODE_PARAM;
+                       txData_setParam(pQosMngr->hTxData,&param);
+
+               break;
+
+       default:
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                                                       ("Warning: qosMngr_setSite NO active protocls To set \n")); 
+               break;
+       }
+
+       /* Check if TSPEC re-negotiation was performed, if so - look for results */
+       qosMngr_checkTspecRenegResults(pQosMngr, assocRsp);
+    return OK;
+
+}
+
+/************************************************************************
+ *                        qosMngr_updateIEinfo                                     *
+ ************************************************************************
+DESCRIPTION: The function is called upon run-time update of AC parameters
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+            pQosIeParams         -  pointer to received IE parameters received 
+                                               in beacon or probe response. 
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+void qosMngr_updateIEinfo(TI_HANDLE hQosMngr, UINT8 *pQosIeParams,qosProtocols_e qosSetProtocol)
+{
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       TI_STATUS  status;
+       dot11_WME_PARAM_t               *pWMEparams;
+
+
+
+       if(pQosMngr == NULL)
+               return;
+
+       /* checking active protocol */
+       switch(pQosMngr->activeProtocol)
+       {
+       case WME:
+               if(qosSetProtocol != WME)
+                       return;
+
+               if(pQosIeParams == NULL)
+               {
+                       WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("Warning: updateIEinfo -> trying to update WME parameters with NULL site parameters!!!\n"));
+                       return ;
+               }
+
+               /* verify QOS protocol received in update IE */
+               status = verifyWmeIeParams(pQosMngr,pQosIeParams);
+               if(status != OK)
+               {
+                       WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("Warning: updateIEinfo ->upadting active protocl WME params with non WME IE params frame !!!\n"));
+                       return ;
+               }
+               pWMEparams = (dot11_WME_PARAM_t *)pQosIeParams;
+
+               /* update AC params */
+               status = updateACParams(pQosMngr,&(pWMEparams->WME_ACParameteres));
+               if(status != OK)
+               {
+                       WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("updateIEinfo-> failed to update AC WME parameters!!!\n\n"));
+                       return ;
+               }
+               break;
+
+
+       default:
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("updateIEinfo-> trying to update qos paramters without active protocol !!!"));
+               break;
+       }
+}
+
+/************************************************************************
+ *                        qosMngr_buildTSPec                                       *
+ ************************************************************************/
+UINT32 qosMngr_buildTSPec(TI_HANDLE hQosMngr, UINT32 user_priority, UINT8 *pQosIe)
+{
+       qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       OS_802_11_QOS_TSPEC_PARAMS *pPreservedParams;
+       tspecInfo_t *pCandidateParams;
+       UINT32 ieLen;
+
+       pPreservedParams = &pQosMngr->tspecRenegotiationParams[user_priority];
+       pCandidateParams = &pQosMngr->resourceMgmtTable.candidateTspecInfo[user_priority];
+
+       if (pPreservedParams->uUserPriority != MAX_USER_PRIORITY)
+       {
+               qosMngr_storeTspecCandidateParams (pCandidateParams, pPreservedParams, user_priority);
+               pCandidateParams->trafficAdmState = AC_WAIT_ADMISSION;
+
+               trafficAdmCtrl_buildTSPec(pQosMngr->pTrafficAdmCtrl, pCandidateParams, pQosIe, &ieLen);
+               return ieLen;
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+/************************************************************************
+ *                        setWmeSiteParams                                         *
+ ************************************************************************
+DESCRIPTION: The function is called upon association response to set WME site 
+             parameters.
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+            pQosIeParams         -  pointer to received IE parameters received 
+                                               in association response. 
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static TI_STATUS setWmeSiteParams(qosMngr_t *pQosMngr, UINT8 *pQosIeParams)
+{
+       dot11_WME_PARAM_t  *pWMEparams = (dot11_WME_PARAM_t *)pQosIeParams;
+       TI_STATUS           status;         
+    paramInfo_t                        param;
+       UINT8               acID;
+
+       if (pQosIeParams == NULL)
+       {
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                       ("setWmeSiteParams: pQosIeParams is NULL !"));
+               return NOK;
+       }
+       
+       for(acID = FIRST_AC_INDEX;acID < MAX_NUM_OF_AC; acID++)
+       {
+               /* configure queue */
+               status = verifyAndConfigTrafficParams(pQosMngr,&(pQosMngr->acParams[acID].QtrafficParams));
+               if(status != OK)
+                       return status;
+
+
+
+               /* Enable event in rate adaptation */
+               ctrlData_setTspecsRateEvent(pQosMngr->hCtrlData, acID, TRUE);
+
+               /* ac powerSave protocol mode */
+               param.content.txDataQosParams.acID              = acID;
+               param.content.txDataQosParams.acTrfcCtrl.PsMode = pQosMngr->acParams[acID].currentWmeAcPsMode;
+               param.content.txDataQosParams.acTrfcCtrl.ackPolicy = pQosMngr->acParams[acID].wmeAcAckPolicy; /* working with Non - Qos method */
+               
+        /* In case QOS_AC_VO is not configured for UPSD, set it according to the desired voice delivery protocol, which can be either PS_POLL or PS_NONE */
+        if ((acID == QOS_AC_VO) && (pQosMngr->acParams[acID].currentWmeAcPsMode != PS_SCHEME_UPSD_TRIGGER))
+        {
+           param.content.txDataQosParams.acTrfcCtrl.PsMode = pQosMngr->desiredVoiceDeliveryProtocol;
+        }
+               
+               param.paramType = TX_DATA_PS_MODE_PARAM;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+               param.paramType = TX_DATA_CONFIG_AC_ACK_POLICY;
+               txData_setParam(pQosMngr->hTxData,&param);
+
+       }
+
+       /* update AC params */
+       status = updateACParams(pQosMngr,&(pWMEparams->WME_ACParameteres));
+       if(status != OK)
+               return status;
+
+
+       /* update per protocol params */
+
+       /* update header convert mode */
+       pQosMngr->headerConvetMode = QOS_CONVERT;
+       param.content.txDataQosParams.qosParams.headerConverMode = QOS_CONVERT;
+       param.paramType = TX_DATA_CONVERT_HEADER_MODE;
+       txData_setParam(pQosMngr->hTxData,&param);
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        updateACParams                                       *
+ ************************************************************************
+DESCRIPTION: the function is called upon QOS protocol updates paramters 
+             to TNET and TxData object 
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static TI_STATUS updateACParams(qosMngr_t *pQosMngr,ACParameters_t *pAcParams)
+{
+       UINT8               acID,i;
+       TI_STATUS           status;
+    QOS_AC_IE_ParametersRecord_t     *pACParameteresRecord;
+       paramInfo_t                         param;
+
+       /*
+        * For WME: setting ac traffic params (edcf etc')  
+        * in this order BE, BK , VI, VO .
+        */
+
+    pACParameteresRecord = (QOS_AC_IE_ParametersRecord_t *)pAcParams;
+
+       for(i = FIRST_AC_INDEX; i < MAX_NUM_OF_AC; i++, pACParameteresRecord++)
+       {
+               /* getting ac from ACI */
+               acID = (pACParameteresRecord->ACI_AIFSN & AC_PARAMS_ACI_MASK) >> 5;
+
+               /* edcf params */
+
+               pQosMngr->acParams[acID].acQosParams.ac                                    = acID;
+               pQosMngr->acParams[acID].acQosParams.aifsn                     = pACParameteresRecord->ACI_AIFSN & AC_PARAMS_AIFSN_MASK;
+               pQosMngr->acParams[acID].acQosParams.cwMin                     = pACParameteresRecord->ECWmin_ECWmax & AC_PARAMS_CWMIN_MASK;
+               pQosMngr->acParams[acID].acQosParams.cwMax                     = (pACParameteresRecord->ECWmin_ECWmax & AC_PARAMS_CWMAX_MASK) >> 4;
+               pQosMngr->acParams[acID].acQosParams.txopLimit                 = pACParameteresRecord->TXOPLimit;
+
+               status = verifyAndConfigQosParams(pQosMngr,&(pQosMngr->acParams[acID].acQosParams));
+               if(status != OK)
+                       return status;
+
+
+               /* UPSD configuration */
+               pQosMngr->acParams[acID].QtrafficParams.psScheme = pQosMngr->acParams[acID].currentWmeAcPsMode;
+               status = verifyAndConfigTrafficParams(pQosMngr,&(pQosMngr->acParams[acID].QtrafficParams));
+               if(status != OK)
+                       return status;
+
+
+               /* update admission state */
+               if(pACParameteresRecord->ACI_AIFSN & AC_PARAMS_ACM_MASK)
+               {
+                       pQosMngr->acParams[acID].apInitAdmissionState = ADMISSION_REQUIRED;
+                       param.content.txDataQosParams.qosParams.admissionRequired = ADMISSION_REQUIRED; 
+
+                       pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+                       param.content.txDataQosParams.qosParams.admissionState = AC_NOT_ADMITTED;
+               }
+               else
+               {
+                       pQosMngr->acParams[acID].apInitAdmissionState = ADMISSION_NOT_REQUIRED;
+                       param.content.txDataQosParams.qosParams.admissionRequired = ADMISSION_NOT_REQUIRED; 
+
+                       pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_ADMITTED;
+                       param.content.txDataQosParams.qosParams.admissionState = AC_ADMITTED;
+               }
+
+               param.content.txDataQosParams.acID = acID;
+               param.paramType = TX_DATA_AC_ADMISSION_STATE;
+               txData_setParam(pQosMngr->hTxData,&param);
+       }
+
+       /* Update the Tx and HAL tag to AC tables for WME mode. */
+       updateTagToAcTable(pQosMngr, (acTrfcType_e *)WMEQosTagToACTable);
+
+       return OK;
+}
+
+/************************************************************************
+ *                             updateTagToAcTable                          *
+ ************************************************************************
+DESCRIPTION: the function updates tag to AC index according to the delivered
+                        protocol tag to AC table (WME or legacy).
+                                                                                                   
+INPUT:      hQosMngr              -    Qos Manager handle.
+                       pProtocolTagToACTable  -  protocol tag to AC table.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+void updateTagToAcTable(qosMngr_t *pQosMngr,acTrfcType_e *pProtocolTagToACTable)
+{
+       paramInfo_t             param;
+
+       /* 
+        *  Update the Tx and HAL Tag to AC tables.
+        */
+       os_memoryCopy(pQosMngr->hOs,(param.content.txDataQosParams.qosParams.tag_ToAcClsfrTable),
+               pProtocolTagToACTable, sizeof(acTrfcType_e) * MAX_NUM_OF_802_1d_TAGS);
+
+       param.paramType = TX_DATA_TAG_TO_AC_CLASSIFIER_TABLE;
+       txData_setParam(pQosMngr->hTxData,&param);
+
+}
+
+
+/************************************************************************
+ *                        verifyWmeIeParams                                        *
+ ************************************************************************
+DESCRIPTION: verify WME IE.
+                                                                                                   
+INPUT:      hQosMngr            -      Qos Manager handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static TI_STATUS verifyWmeIeParams(qosMngr_t *pQosMngr,UINT8 *pQosIeParams)
+{
+       dot11_WME_IE_t  WMEie;
+       UINT8           Len;
+       dot11_WME_IE_t  *pWMERecvIe = (dot11_WME_IE_t  *)pQosIeParams;
+
+       if(pQosIeParams == NULL)
+       {
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("verifyWmeIeParams: FAILED"));
+               return NOK;
+       }
+
+
+       /* get WME IE */
+       getWMEInfoElement(pQosMngr,(UINT8 *)&WMEie,(UINT8 *)&Len);
+
+       if((WMEie.hdr.eleId != pWMERecvIe->hdr.eleId ) ||
+          (WMEie.OUI[0] != pWMERecvIe->OUI[0]) ||
+          (WMEie.OUI[1] != pWMERecvIe->OUI[1]) ||
+          (WMEie.OUI[2] != pWMERecvIe->OUI[2]) ||
+          (WMEie.OUIType != pWMERecvIe->OUIType))
+       {
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("verifyWmeIeParams: FAILED"));
+               return NOK;
+       }
+
+
+    if(WMEie.version != pWMERecvIe->version)
+          WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("WARNING: verifyWmeIeParams: Driver WME version: %d, Site WME version: %d",WMEie.version,pWMERecvIe->version));
+
+       /* compare assocRsp IE to WME IE (without acInfo field */
+       return OK;
+}
+
+
+/************************************************************************
+ *                    Admission Control Functions                          *
+ ************************************************************************/
+/************************************************************************
+ *                        qosMngr_requestAdmission                                     *
+ ************************************************************************
+DESCRIPTION: This function is API function for TSPEC request.
+
+INPUT:      hQosMngr            -      Qos Manager handle.
+                       addTspecParams           -  The Tspec Parameters
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_requestAdmission(TI_HANDLE                   hQosMngr, 
+                                   OS_802_11_QOS_TSPEC_PARAMS *addTspecParams)
+{
+
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       TI_STATUS       status;
+       UINT8           acID;
+               
+
+       /* check if STA is already connected to AP */
+       if(pQosMngr->isConnected == FALSE)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: Not connected - Ignoring request !!!\n"));
+               return NOT_CONNECTED;
+       }
+
+       /* check if AP support WME */
+       if(pQosMngr->activeProtocol != WME)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: Not connected to a QOS AP - Ignoring request !!!\n"));
+               return NO_QOS_AP;
+       }
+
+       /* check if Traffic Admission Control is enable */
+       if(pQosMngr->trafficAdmCtrlEnable == FALSE)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: Admission-Control is disabled - Ignoring request !!!\n"));
+               return ADM_CTRL_DISABLE;
+       }
+
+       /* check UP validity */
+       if( addTspecParams->uUserPriority > MAX_USER_PRIORITY)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("uUserPriority = %d > 7 !!!\n",addTspecParams->uUserPriority));
+               return NOK;
+       }
+
+       /* find acID from the user priority */
+       acID = WMEQosTagToACTable[addTspecParams->uUserPriority];
+
+       /* check if signaling is already in process for this AC */
+       if(pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState == AC_WAIT_ADMISSION)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: AC = %d , signaling is in process -> Ignore Request !!!\n",acID));
+               return TRAFIC_ADM_PENDING;
+       }
+       
+       /* check if AC is already admitted with other UP */
+       if( (pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState == AC_ADMITTED) &&
+               (pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority <= MAX_USER_PRIORITY) &&
+               (pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority != addTspecParams->uUserPriority) )
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                       ("qosMngr_requestAdmission: AC = %d , another UP (%d) on same AC is already admited -> Ignoring request !!!\n",
+                       acID, pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority));
+               return AC_ALREADY_IN_USE;
+       }
+
+       /* check msdu size validity */
+
+       if( (addTspecParams->uNominalMSDUsize & !FIX_MSDU_SIZE) > MAX_DATA_BODY_LENGTH)
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("uNominalMSDUsize = %d > 2312, !!!\n",addTspecParams->uNominalMSDUsize));
+               return NOK;
+       }
+       
+       /* check PS mode validity */
+       if( (addTspecParams->uAPSDFlag == PS_SCHEME_UPSD_TRIGGER) && (pQosMngr->currentPsMode != PS_SCHEME_UPSD_TRIGGER) )
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                       ("The STA's current status does not support UPSD -> Ignoring TSPEC request that has UPSD on !!!\n"));
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: UP = %d , acID = %d\n",addTspecParams->uUserPriority, acID));
+
+    /* The following code was removed since TX module is updated on UPSD/PS-POLL configuration of AC, and therefore will NOT
+       send PS-POLLs when QOS_AC_VO is configured for UPSD */
+#if 0
+       /* check PS mode validity for the voice queue*/
+    /* Do not allow CHANGING QOS_AC_VO currentPsMode to UPSD while the desiredVoiceDeliveryProtocol is enabled */
+       if( (acID == QOS_AC_VO) && 
+       ((addTspecParams->uAPSDFlag == UPSD) && (pQosMngr->acParams[acID].currentWmeAcPsMode != UPSD)) &&
+       (pQosMngr->desiredVoiceDeliveryProtocol == PS_POLL) )
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,
+                       ("The STA's current QOS_AC_VO configured to VoiceDeliveryProtocol,\n This configuration can not be in parallel with UPSD.\n In order to change the AC_VO to UPSD, user must first disable the VoiceDeliveryProtocol!!!\n"));
+               return NOK;
+       }
+#endif
+
+       /* set tspec parameters in candidateTspecInfo table */
+       qosMngr_storeTspecCandidateParams (&(pQosMngr->resourceMgmtTable.candidateTspecInfo[acID]), 
+                                                                               addTspecParams, (UINT8)acID);
+
+       /* Perhaps this should be done only if the request was successfully sent */
+       if (acID == QOS_AC_VO) 
+       {
+               pQosMngr->voiceTspecConfigured = TRUE;
+       }
+       
+       if (acID == QOS_AC_VI) 
+       {
+               pQosMngr->videoTspecConfigured = TRUE;
+       }
+
+       /* call TrafficAdmCtrl API function for the signaling proccess */
+       status = trafficAdmCtrl_startAdmRequest(pQosMngr->pTrafficAdmCtrl, &(pQosMngr->resourceMgmtTable.candidateTspecInfo[acID]));
+
+       if(status == OK)
+       {
+               /* request transmitted OK */
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState = AC_WAIT_ADMISSION;
+               WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: UP = %d , request OK !!!\n",addTspecParams->uUserPriority));
+       }
+       else
+       {
+               /* reaquest not transmitted OK */
+               pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("qosMngr_requestAdmission: UP = %d , request  NOT OK status=%d!!!\n",addTspecParams->uUserPriority, status));
+               return NOK;
+       }
+
+       return status;
+}
+
+/************************************************************************
+ *                        qosMngr_deleteAdmission                          *
+ ************************************************************************
+DESCRIPTION: This function is API fuunction for tspec delete.
+
+INPUT:      hQosMngr            -      Qos Manager handle.
+                       delAdmissionParams       -  
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS qosMngr_deleteAdmission(TI_HANDLE hQosMngr, OS_802_11_QOS_DELETE_TSPEC_PARAMS *delAdmissionParams)
+{
+
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+       UINT8           acID;
+       
+       /* check UP validity */
+       if( delAdmissionParams->uUserPriority > MAX_USER_PRIORITY )
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_deleteAdmission: userPriority > 7 -> Ignore !!!"));
+               return NOK;
+       }
+
+       /* check if STA is already connected to AP */
+       if(pQosMngr->isConnected == FALSE)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_deleteAdmission: pQosMngr->connected == FALSE -> Ignore !!!"));
+               return NOT_CONNECTED;
+       }
+
+       /* check if AP support WME */
+       if(pQosMngr->activeProtocol != WME)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_deleteAdmission: activeProtocol != WME -> Ignore !!!"));
+               return NO_QOS_AP;
+       }
+
+       /* find acID from the user priority */
+       acID = WMEQosTagToACTable[delAdmissionParams->uUserPriority];
+
+       /* check if tspec is already addmited for this AC */
+       if(pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState != AC_ADMITTED)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_deleteAdmission: AC is not ADMITED -> Ignore !!!"));
+               return NOK;
+       }
+
+       /* check if AC is already admited with the same UP */
+       if(pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority != delAdmissionParams->uUserPriority)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_deleteAdmission: user priority is invalid. -> Ignore !!!\n"));
+               return USER_PRIORITY_NOT_ADMITTED;
+       }
+
+       /* check if signaling is already in procces for this AC */
+       if(pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState == AC_WAIT_ADMISSION)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_deleteAdmission: AC is under negotiation -> Ignore !!!"));
+               return TRAFIC_ADM_PENDING;
+       }
+
+
+       
+       /* call TrafficAdmCtrl API function for the delete tspec */
+       trafficAdmCtrl_sendDeltsFrame(pQosMngr->pTrafficAdmCtrl, &(pQosMngr->resourceMgmtTable.currentTspecInfo[acID]), 
+                                                                               (UINT8)delAdmissionParams->uReasonCode );
+
+       
+       deleteTspecConfiguration(pQosMngr, acID);
+       
+       return OK;
+
+}
+/************************************************************************
+ *                        deleteTspecConfiguration                                 *
+ ************************************************************************
+DESCRIPTION: configure the driver and FW to default configuration after
+                        tspec deletion.
+
+INPUT:      hQosMngr                - Qos Manager handle.
+                       acID                                     - the AC of the Tspec to delete
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+static void deleteTspecConfiguration(qosMngr_t *pQosMngr, UINT8 acID)
+{
+   paramInfo_t param;
+
+    /* Zero Tspec parameters */
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].nominalMsduSize = 0;
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].minimumPHYRate = 0;
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].meanDataRate = 0;
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].surplausBwAllowance = 0;
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].mediumTime = 0;
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].UPSDFlag = 0;
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].streamDirection = BI_DIRECTIONAL;
+       
+       /* update total medium time */
+       pQosMngr->resourceMgmtTable.totalAllocatedMediumTime -= pQosMngr->resourceMgmtTable.currentTspecInfo[acID].mediumTime;
+       
+       
+       /* set params to TX */
+       /*------------------*/
+       /* disable TSRS for this ac */
+       param.content.txDataQosParams.acID = acID;
+       param.content.txDataQosParams.tsrsArrLen = 0;
+       param.paramType = CTRL_DATA_TSRS_PARAM;
+       ctrlData_setParam(pQosMngr->hCtrlData, &param);
+
+       /* restore default MSDU lifetime value */
+       param.content.txDataQosParams.acID = acID;
+       param.content.txDataQosParams.acTrfcCtrl.MsduLifeTime = pQosMngr->acParams[acID].msduLifeTimeParam;
+       param.paramType = TX_DATA_CONFIG_AC_MSDU_LIFE_TIME;
+       txData_setParam(pQosMngr->hTxData, &param);
+
+       /* stop TS metrix for this ac */
+#ifdef EXC_MODULE_INCLUDED
+       measurementMgr_disableTsMetrics(pQosMngr->hMeasurementMngr, acID);
+#endif
+
+       /* update medium time and rate adaptation event only when init admission bit was 0 */
+       if( pQosMngr->acParams[acID].apInitAdmissionState == ADMISSION_REQUIRED )
+       {
+               /* update currentTspecInfo parameters */
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+               
+               /* set params to TX */
+               txData_setAdmisionCtrlParams(pQosMngr->hTxData,
+                                                                       acID,
+                                                                       pQosMngr->resourceMgmtTable.currentTspecInfo[acID].mediumTime , 
+                                                                       pQosMngr->resourceMgmtTable.currentTspecInfo[acID].minimumPHYRate, FALSE);
+       }
+       else
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_ADMITTED;
+
+    /* After we have updated the TxData with the new status of the UP, we can zero the userPriority field */
+    pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority = INACTIVE_USER_PRIORITY;
+
+       /* set PS mode according to the PS mode from the association */
+    /* restore the current Ps mode per AC to UPSD ONLY IF both the station and AP support UPSD */
+    if ((pQosMngr->currentPsMode == PS_SCHEME_UPSD_TRIGGER) && (pQosMngr->acParams[acID].desiredWmeAcPsMode == PS_SCHEME_UPSD_TRIGGER))
+    {
+         pQosMngr->acParams[acID].currentWmeAcPsMode = PS_SCHEME_UPSD_TRIGGER;
+    }
+    else
+    {
+         pQosMngr->acParams[acID].currentWmeAcPsMode = PS_SCHEME_LEGACY_PSPOLL;
+    }
+
+       if(acID == QOS_AC_VO)
+       {
+               /* update TX with "new" PS Voice Delivery mode */
+               txData_setPsVoiceDeliveryMode(pQosMngr->hTxData,pQosMngr->acParams[QOS_AC_VO].currentWmeAcPsMode);
+               pQosMngr->voiceTspecConfigured = FALSE;
+       }
+       
+       if (acID == QOS_AC_VI) 
+       {
+               pQosMngr->videoTspecConfigured = FALSE;
+       }
+
+       /* UPSD_FW - open comment in UPSD FW integration */
+        
+       /* UPSD configuration */
+       pQosMngr->acParams[acID].QtrafficParams.psScheme = pQosMngr->acParams[acID].currentWmeAcPsMode;
+       verifyAndConfigTrafficParams(pQosMngr,&(pQosMngr->acParams[acID].QtrafficParams));
+
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: qosMngr_sendUnexpectedTSPECResponse
+Routine Description: send event to user application, informing of unexpected TSPEC response
+                                        which might imply loss of UPSD mode synch between AP and STA
+Arguments: pTspecInfo - contains unexpected TSPEC response information 
+Return Value:
+-----------------------------------------------------------------------------*/
+TI_STATUS qosMngr_sendUnexpectedTSPECResponseEvent(TI_HANDLE   hQosMngr,
+                                                                  tspecInfo_t  *pTspecInfo)
+{
+       OS_802_11_QOS_TSPEC_PARAMS addtsReasonCode;
+    qosMngr_t *pQosMngr =      (qosMngr_t *)hQosMngr;
+
+       /* set the event params */
+       addtsReasonCode.uAPSDFlag = pTspecInfo->UPSDFlag;
+       addtsReasonCode.uUserPriority = pTspecInfo->userPriority;
+       addtsReasonCode.uNominalMSDUsize = pTspecInfo->nominalMsduSize;
+       addtsReasonCode.uMeanDataRate = pTspecInfo->meanDataRate;       
+       addtsReasonCode.uMinimumPHYRate = pTspecInfo->minimumPHYRate;
+       addtsReasonCode.uSurplusBandwidthAllowance = pTspecInfo->surplausBwAllowance;
+       addtsReasonCode.uMediumTime = pTspecInfo->mediumTime;
+
+    addtsReasonCode.uReasonCode = pTspecInfo->statusCode + TSPEC_RESPONSE_UNEXPECTED;
+               
+       /* send event */
+       EvHandlerSendEvent(pQosMngr->hEvHandler, IPC_EVENT_TSPEC_STATUS, (UINT8*)(&addtsReasonCode), sizeof(OS_802_11_QOS_TSPEC_PARAMS));
+
+       return OK;
+}
+
+/************************************************************************
+ *                        qosMngr_setAdmissionInfo                      *
+ ************************************************************************
+DESCRIPTION: This function is API function.
+            the trafficAdmCtrl object calls this function in
+            order to update the QOSMngr on TSPEC request status
+
+INPUT:      hQosMngr                 - Qos Manager handle.
+            pTspecInfo               - The TSPEC Parameters
+            trafficAdmRequestStatus  - the status of the request
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS qosMngr_setAdmissionInfo(TI_HANDLE    hQosMngr, 
+                                   UINT8        acID,
+                                   tspecInfo_t  *pTspecInfo,
+                                   trafficAdmRequestStatus_e trafficAdmRequestStatus)
+{
+    UINT32                 actualMediumTime;
+    OS_802_11_QOS_TSPEC_PARAMS addtsReasonCode;
+    qosMngr_t *pQosMngr =  (qosMngr_t *)hQosMngr;
+    whalCtrl_setTemplate_t templateStruct;
+    QosNullDataTemplate_t  QosNullDataTemplate;
+
+    /* Check if the updated AC is in WAIT state */
+    if(pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState != AC_WAIT_ADMISSION)
+    {
+        WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+             ("qosMngr_setAdmissionInfo: acID = %d, trafficAdmState != WAIT. IGNORE !!!\n", acID)); 
+        
+        return NOK;
+    }
+
+    if (pQosMngr->TSPECNegotiationResultCallb != NULL)
+    {
+        pQosMngr->TSPECNegotiationResultCallb (pQosMngr->TSPECNegotiationResultModule, trafficAdmRequestStatus);
+        pQosMngr->TSPECNegotiationResultCallb = NULL;
+        pQosMngr->TSPECNegotiationResultModule = NULL;
+    }
+
+    switch(trafficAdmRequestStatus)
+    {
+    case STATUS_TRAFFIC_ADM_REQUEST_ACCEPT:
+        /* Received admission response with status accept */
+
+        WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                ("qosMngr_setAdmissionInfo: admCtrl status =  REQUEST_ACCEPT [ acID = %d, mediumTime = %d, minimumPHYRate = %d ]\n",
+                acID, pTspecInfo->mediumTime, pTspecInfo->minimumPHYRate)); 
+        
+        /* Set the event params */
+        addtsReasonCode.uAPSDFlag = pTspecInfo->UPSDFlag;
+        addtsReasonCode.uUserPriority = pTspecInfo->userPriority;
+        addtsReasonCode.uNominalMSDUsize = pTspecInfo->nominalMsduSize;
+        addtsReasonCode.uMeanDataRate = pTspecInfo->meanDataRate;   
+        addtsReasonCode.uMinimumPHYRate = pTspecInfo->minimumPHYRate;
+        addtsReasonCode.uSurplusBandwidthAllowance = pTspecInfo->surplausBwAllowance;
+        addtsReasonCode.uMediumTime = pTspecInfo->mediumTime;
+
+        /* Free the candidate parameters */
+        pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+
+        /* Validate tid matching */
+        if (pTspecInfo->tid == pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].tid)
+        {
+            addtsReasonCode.uReasonCode = ADDTS_RESPONSE_ACCEPT;
+            
+            /* Send event */
+            EvHandlerSendEvent (pQosMngr->hEvHandler, 
+                                IPC_EVENT_TSPEC_STATUS, 
+                                (UINT8*)&addtsReasonCode, 
+                                sizeof(OS_802_11_QOS_TSPEC_PARAMS));
+        }
+        else
+        {
+            addtsReasonCode.uReasonCode = ADDTS_RESPONSE_AP_PARAM_INVALID;
+            
+            /* Send event */
+            EvHandlerSendEvent (pQosMngr->hEvHandler, 
+                                IPC_EVENT_TSPEC_STATUS, 
+                                (UINT8*)&addtsReasonCode, 
+                                sizeof(OS_802_11_QOS_TSPEC_PARAMS));
+            return OK;
+        }
+
+        /* Update the current TSPEC parameters from the received TSPEC */
+        os_memoryCopy (pQosMngr->hOs, 
+                       &pQosMngr->resourceMgmtTable.currentTspecInfo[acID], 
+                       pTspecInfo, 
+                       sizeof(tspecInfo_t));
+
+        /* Set the TSPEC to admitted */
+        pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_ADMITTED;
+        
+        /* Update total medium time */
+        pQosMngr->resourceMgmtTable.totalAllocatedMediumTime += pTspecInfo->mediumTime;
+
+        /*
+         * Set QOS Null-data template into the firmware. 
+         * When a new TSPEC with UPSD is "accepted" by the AP, 
+         * we set the user priority of it into the firmware. 
+         * Since this AC is already ADMITTED (we are processing the successful response), 
+         * it is OK to set the qos null data template with this UP 
+         */
+        if (addtsReasonCode.uAPSDFlag == PS_SCHEME_UPSD_TRIGGER && 
+            pQosMngr->QosNullDataTemplateUserPriority == 0xFF)
+        {
+            /* Remember the user priority which we have set */
+            pQosMngr->QosNullDataTemplateUserPriority = (UINT8)addtsReasonCode.uUserPriority;
+
+            templateStruct.pTemplate = (UINT8 *)&QosNullDataTemplate;
+            templateStruct.templateType = QOS_NULL_DATA_TEMPLATE;
+            buildQosNullDataTemplate (pQosMngr->hSiteMgr, &templateStruct, pQosMngr->QosNullDataTemplateUserPriority);
+            whalCtrl_SetTemplate (pQosMngr->hHalCtrl, &templateStruct);
+
+            WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                ("qosMngr_setAdmissionInfo: Setting QOS null data for UserPriority=%d (due to TSPEC ACCEPT response)\n",
+                addtsReasonCode.uUserPriority));
+        }
+
+        /* Set params to TX */
+        /*------------------*/
+
+        /* Update medium time and rate adaptation event only when init admission bit was 0 */
+        if (pQosMngr->acParams[acID].apInitAdmissionState == ADMISSION_REQUIRED)
+        {
+            /* mediumTime is in units of 32uSec and we work in mSec */
+            actualMediumTime = (pTspecInfo->mediumTime * 32) / 1000;
+
+            /* Set TX params */
+            txData_setAdmisionCtrlParams (pQosMngr->hTxData,
+                                          acID,
+                                          actualMediumTime, 
+                                          pTspecInfo->minimumPHYRate, 
+                                          TRUE);
+        }
+        
+        {
+            PSScheme_e psMode = pTspecInfo->UPSDFlag ? PS_SCHEME_UPSD_TRIGGER 
+                                                     : PS_SCHEME_LEGACY_PSPOLL; 
+       
+            if (pQosMngr->acParams[acID].currentWmeAcPsMode != psMode)
+            {
+                TI_STATUS status;
+
+                pQosMngr->acParams[acID].currentWmeAcPsMode = psMode;
+
+                /* UPSD_FW - open comment in UPSD FW integration */
+                pQosMngr->acParams[acID].QtrafficParams.psScheme = pQosMngr->acParams[acID].currentWmeAcPsMode;
+                status = verifyAndConfigTrafficParams (pQosMngr, &pQosMngr->acParams[acID].QtrafficParams);
+                if (status != OK)
+                    return status;
+
+                if (acID == QOS_AC_VO)
+                {
+                    /* Update TX with "new" PS Voice Delivery mode */
+                    txData_setPsVoiceDeliveryMode (pQosMngr->hTxData, pQosMngr->acParams[QOS_AC_VO].currentWmeAcPsMode);
+                }
+            }
+        }   
+        break;
+
+    case STATUS_TRAFFIC_ADM_REQUEST_REJECT:
+        /* Received admission response with status reject */
+
+        WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+             ("qosMngr_setAdmissionInfo: admCtrl status = REQUEST_REJECT [ acID = %d ]\n", acID)); 
+        
+        /* Validate tid matching */
+        if (pTspecInfo->tid == pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].tid)
+        {
+            addtsReasonCode.uReasonCode = pTspecInfo->statusCode;
+        }
+        else
+        {
+            addtsReasonCode.uReasonCode = ADDTS_RESPONSE_AP_PARAM_INVALID;
+        }
+
+        // put the candidateTspec back to a previously accepted TSPEC if
+        // one exist.  This will prevent TI from sending same rejected
+        // TSPEC when roaming to another AP that has the same configuration
+        // as our current AP (under which case our the new AP will likely reject
+        // the TSPEC as well and we will not be able to roam
+        os_memoryCopy (pQosMngr->hOs, 
+                       &pQosMngr->resourceMgmtTable.candidateTspecInfo[acID], 
+                       &pQosMngr->resourceMgmtTable.currentTspecInfo[acID], 
+                       sizeof(tspecInfo_t));
+        if( pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].userPriority == INACTIVE_USER_PRIORITY ) {
+            if( acID == QOS_AC_VO ) pQosMngr->voiceTspecConfigured = FALSE;
+            else if( acID == QOS_AC_VI ) pQosMngr->voiceTspecConfigured = FALSE;
+        }
+
+
+        /* Send event to application */
+        addtsReasonCode.uAPSDFlag = pTspecInfo->UPSDFlag;
+        addtsReasonCode.uUserPriority = pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].userPriority;
+        addtsReasonCode.uNominalMSDUsize = pTspecInfo->nominalMsduSize;
+        addtsReasonCode.uMeanDataRate = pTspecInfo->meanDataRate;   
+        addtsReasonCode.uMinimumPHYRate = pTspecInfo->minimumPHYRate;
+        addtsReasonCode.uSurplusBandwidthAllowance = pTspecInfo->surplausBwAllowance;
+        addtsReasonCode.uMediumTime = pTspecInfo->mediumTime;
+    
+        EvHandlerSendEvent (pQosMngr->hEvHandler, 
+                            IPC_EVENT_TSPEC_STATUS, 
+                            (UINT8*)&addtsReasonCode, 
+                            sizeof(OS_802_11_QOS_TSPEC_PARAMS));       
+        break;
+
+    case STATUS_TRAFFIC_ADM_REQUEST_TIMEOUT:
+        WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+             ("qosMngr_setAdmissionInfo: admCtrl status = REQUEST_TIMEOUT [ acID = %d ]\n", acID)); 
+        
+        /* Free the candidate parameters */
+        pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+
+        /* Send event to application */
+        addtsReasonCode.uUserPriority = pQosMngr->resourceMgmtTable.candidateTspecInfo[acID].userPriority;
+        addtsReasonCode.uReasonCode = ADDTS_RESPONSE_TIMEOUT;
+        addtsReasonCode.uAPSDFlag = 0;
+        addtsReasonCode.uNominalMSDUsize = 0;
+        addtsReasonCode.uMeanDataRate = 0;  
+        addtsReasonCode.uMinimumPHYRate = 0;
+        addtsReasonCode.uSurplusBandwidthAllowance = 0;
+        addtsReasonCode.uMediumTime = 0;
+
+        EvHandlerSendEvent (pQosMngr->hEvHandler, 
+                            IPC_EVENT_TSPEC_STATUS, 
+                            (UINT8*)&addtsReasonCode, 
+                            sizeof(OS_802_11_QOS_TSPEC_PARAMS));       
+        break;
+       
+    default:
+        WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+            ("qosMngr_setAdmissionInfo: receive state from admCtrl = unknown !!! \n")); 
+        break;
+    }
+
+    return OK;  
+}
+
+/************************************************************************
+ *                    QosMngr_receiveActionFrames                       *
+ ************************************************************************
+DESCRIPTION: 
+                                                                                                 
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS QosMngr_receiveActionFrames(TI_HANDLE hQosMngr, UINT8* pData, UINT8 action, UINT32 bodyLen)
+{
+       UINT8                                   acID;
+       tsInfo_t                                tsInfo;
+       UINT8                                   userPriority;
+       dot11_WME_TSPEC_IE_t*   dot11_WME_TSPEC_IE;
+    OS_802_11_QOS_TSPEC_PARAMS addtsReasonCode;
+
+
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       /* check if STA is already connected to AP */
+       if( (pQosMngr->isConnected == FALSE) || 
+               (pQosMngr->activeProtocol != WME) || 
+               (pQosMngr->trafficAdmCtrlEnable == FALSE) )
+       {
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG,("QosMngr_receiveActionFrames:  Ignore  !!!"));
+               return NOK;
+       }
+
+       /* check DELTS action code */
+       if (action == DELTS_ACTION) 
+       {
+               /* parse the frame */
+               pData++;        /* DIALOG TOKEN  */
+               pData++;        /* STATUS CODE */
+
+#if 0 /*  Need to send TSPEC IE in DELTS or only the tsinfo ??*/
+               /*  only tsinfo   */
+               tsInfo.tsInfoArr[0] = *pData;
+               pData++;
+               tsInfo.tsInfoArr[1] = *pData;
+               pData++;
+               tsInfo.tsInfoArr[2] = *pData;
+               pData++;
+#else
+               /*  TSpec IE in DELTS*/
+               dot11_WME_TSPEC_IE = (dot11_WME_TSPEC_IE_t*)pData;
+               tsInfo.tsInfoArr[0] = dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[0];
+               pData++;
+               bodyLen--;
+               tsInfo.tsInfoArr[1] = dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[1];
+               pData++;
+               bodyLen--;
+               tsInfo.tsInfoArr[2] = dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[2];
+#endif
+               
+        userPriority = (((tsInfo.tsInfoArr[1]) & TS_INFO_1_USER_PRIORITY_MASK) >> USER_PRIORITY_SHIFT);
+               
+               acID = WMEQosTagToACTable[userPriority];
+               
+
+               WLAN_REPORT_INFORMATION(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("QosMngr_receiveActionFrames: DELTS [ acID = %d ] \n", acID)); 
+
+
+               /* check if this AC is admitted with the correct userPriority */
+               if( (pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState == AC_ADMITTED) &&
+                       ( pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority == userPriority) )
+               {
+                       deleteTspecConfiguration(pQosMngr, acID);
+
+            /* Send event to notify DEL_TS */
+            addtsReasonCode.uAPSDFlag = 0;
+                   addtsReasonCode.uUserPriority = userPriority;
+            addtsReasonCode.uReasonCode = TSPEC_DELETED_BY_AP;
+                   addtsReasonCode.uNominalMSDUsize = 0;
+                   addtsReasonCode.uMeanDataRate = 0;  
+                   addtsReasonCode.uMinimumPHYRate = 0;
+                   addtsReasonCode.uSurplusBandwidthAllowance = 0;
+                   addtsReasonCode.uMediumTime = 0;
+
+            EvHandlerSendEvent(pQosMngr->hEvHandler, IPC_EVENT_TSPEC_STATUS, (UINT8*)(&addtsReasonCode), sizeof(OS_802_11_QOS_TSPEC_PARAMS));
+               }
+               else
+               {
+                       WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+                               ("QosMngr_receiveActionFrames: DELTS [ acID = %d userPriority = %d  currentUserPriority = %d] Current State in not ADMITED !! \n", acID, userPriority,pQosMngr->resourceMgmtTable.currentTspecInfo[acID].userPriority)); 
+                       
+               }
+       }
+       /* if action code is ADDTS call trafficAdmCtrl object API function */
+       else if (action == ADDTS_RESPONSE_ACTION) 
+       {
+               if (trafficAdmCtrl_recv(pQosMngr->pTrafficAdmCtrl, pData, action) == OK)
+               {
+#ifdef EXC_MODULE_INCLUDED
+                       /* Check if EXC IEs present, if so, parse them and update relevant modules; 
+               skip the TSPEC IE;
+               do not forget 2 bytes of status and dialog code that must be skipped as well */
+                       EXCv4IEs_t                      excIE;
+                       UINT32                          readLen;
+
+                       excIE.edcaLifetimeParameter = NULL;
+                       excIE.trafficStreamParameter = NULL;
+                       excIE.tsMetrixParameter = NULL;
+
+                       userPriority = ((((dot11_WME_TSPEC_IE_t *)(pData+2))->tHdr.tsInfoField.tsInfoArr[1] & TS_INFO_1_USER_PRIORITY_MASK) >> USER_PRIORITY_SHIFT);
+                       acID = WMEQosTagToACTable[userPriority];
+
+                       readLen = ((dot11_eleHdr_t *)(pData+2))->eleLen;
+
+                       /* 4 stands for 1 byte of token+1 byte of status+1 byte of EID+1 byte of len */
+                       bodyLen = bodyLen - 4 - readLen; 
+                       pData = pData + 4 + readLen;
+
+                       while (bodyLen) 
+                       {
+                               mlmeParser_readExcOui(pData, bodyLen, &readLen, &excIE);
+                               bodyLen -= readLen;
+                               pData += readLen;
+                       }
+
+                       excMngr_setEXCQoSParams(pQosMngr->hExcMgr, &excIE, acID);
+#endif
+               }
+       }
+       else
+       {
+               WLAN_REPORT_WARNING(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("QosMngr_receiveActionFrames: Receive unknown action code = %d  -> Ignore !! \n",action));
+       }
+       
+       return OK;
+}
+
+/************************************************************************
+ *                        qosMngr_getCurrAcStatus                          *
+ ************************************************************************
+DESCRIPTION: This function is API fuunction for getting tha AC status .
+
+INPUT:      hQosMngr                - Qos Manager handle.
+                       pAcStatusParams
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS qosMngr_getCurrAcStatus(TI_HANDLE hQosMngr, OS_802_11_AC_UPSD_STATUS_PARAMS *pAcStatusParams)
+{
+    qosMngr_t *pQosMngr = (qosMngr_t *)hQosMngr;
+
+       /* check AC validity */
+       if( pAcStatusParams->uAC > MAX_NUM_OF_AC )
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_getCurrAcStatus: acID > 3 -> Ignore !!!"));
+               return NOK;
+       }
+
+       /* check if sta is connected to AP */
+       if(pQosMngr->isConnected == FALSE)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_getCurrAcStatus: pQosMngr->connected == FALSE -> Ignore !!!"));
+               return NOT_CONNECTED;
+       }
+       
+        /* check if AP support WME */
+       if(pQosMngr->activeProtocol != WME)
+       {       
+               WLAN_REPORT_ERROR(pQosMngr->hReport, QOS_MANAGER_MODULE_LOG, 
+           ("qosMngr_getCurrAcStatus: activeProtocol != WME -> Ignore !!!"));
+               return NO_QOS_AP;
+       }
+
+       pAcStatusParams->uCurrentUAPSDStatus = pQosMngr->acParams[pAcStatusParams->uAC].currentWmeAcPsMode;
+       pAcStatusParams->pCurrentAdmissionStatus = pQosMngr->resourceMgmtTable.currentTspecInfo[pAcStatusParams->uAC].trafficAdmState;
+
+       return OK;
+}
+
+
+
+/************************************************************************
+ *                        setNonQosAdmissionState                              *
+ ************************************************************************
+DESCRIPTION: This function resets the admission state variables as required
+                               for non-QoS mode and configures the Tx module.
+
+INPUT:      pQosMngr   - Qos Manager pointer.
+                       acId            - the AC to update.
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+
+static void setNonQosAdmissionState(qosMngr_t *pQosMngr, UINT8 acID)
+{
+       paramInfo_t     param;
+
+       if(acID == QOS_AC_BE)
+       {
+               pQosMngr->acParams[acID].apInitAdmissionState = ADMISSION_NOT_REQUIRED;
+               param.content.txDataQosParams.qosParams.admissionRequired = ADMISSION_NOT_REQUIRED; 
+               
+
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_ADMITTED;
+               param.content.txDataQosParams.qosParams.admissionState = AC_ADMITTED; 
+       }
+       else
+       {
+               pQosMngr->acParams[acID].apInitAdmissionState = ADMISSION_REQUIRED;
+               param.content.txDataQosParams.qosParams.admissionRequired = ADMISSION_REQUIRED; 
+               
+
+               pQosMngr->resourceMgmtTable.currentTspecInfo[acID].trafficAdmState = AC_NOT_ADMITTED;
+               param.content.txDataQosParams.qosParams.admissionState = AC_NOT_ADMITTED; 
+       }
+
+       param.content.txDataQosParams.acID = acID;
+       param.paramType = TX_DATA_AC_ADMISSION_STATE;
+       
+       txData_setParam(pQosMngr->hTxData,&param);
+}
+
+static void qosMngr_storeTspecCandidateParams (tspecInfo_t *pCandidateParams, OS_802_11_QOS_TSPEC_PARAMS *pTSPECParams, UINT8 ac)
+{
+       pCandidateParams->AC = (acTrfcType_e)ac;
+       pCandidateParams->tid = (UINT8)pTSPECParams->uUserPriority;
+       pCandidateParams->userPriority = (UINT8)pTSPECParams->uUserPriority;
+       pCandidateParams->meanDataRate = pTSPECParams->uMeanDataRate;
+       pCandidateParams->nominalMsduSize = (UINT16)pTSPECParams->uNominalMSDUsize;
+       pCandidateParams->UPSDFlag = (BOOL)pTSPECParams->uAPSDFlag;
+       pCandidateParams->surplausBwAllowance = (UINT16)pTSPECParams->uSurplusBandwidthAllowance;
+       pCandidateParams->minimumPHYRate = pTSPECParams->uMinimumPHYRate;
+       pCandidateParams->streamDirection = BI_DIRECTIONAL;
+       pCandidateParams->mediumTime = 0;
+}
diff --git a/sta_dk_4_0_4_32/common/src/Management/QOS/trafficAdmControl.c b/sta_dk_4_0_4_32/common/src/Management/QOS/trafficAdmControl.c
new file mode 100644 (file)
index 0000000..1a25ae4
--- /dev/null
@@ -0,0 +1,1458 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       admCtrlQos.c                                                                                       */
+/*    PURPOSE: WSM/WME admission Control                                                              */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+
+#include "DataCtrl_Api.h"
+
+#include "trafficAdmControl.h"
+#include "qosMngr_API.h"
+#include "TNETW_Driver_types.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#endif
+/* Constants */
+
+/** number of states in the state machine */
+#define        TRAFFIC_ADM_CTRL_SM_NUM_STATES          2
+
+/** number of events in the state machine */
+#define        TRAFFIC_ADM_CTRL_SM_NUM_EVENTS                  5
+
+extern int WMEQosTagToACTable[MAX_NUM_OF_802_1d_TAGS];
+
+PACKED_STRUCT( dot11_local_WME_TSPEC_IE_t,
+
+    UINT16     nominalMSDUSize;
+       UINT16  maximumMSDUSize;
+       UINT32  minimumServiceInterval;
+       UINT32  maximumServiceInterval;
+       UINT32  inactivityInterval;
+       UINT32  suspensionInterval;
+       UINT32  serviceStartTime;
+       UINT32  minimumDataRate;
+       UINT32  meanDataRate;
+       UINT32  peakDataRate;
+       UINT32  maximumBurstSize;
+       UINT32  delayBound;
+       UINT32  minimumPHYRate;
+       UINT16  surplusBandwidthAllowance;
+       UINT16  mediumTime;
+);
+
+typedef struct 
+{
+       TI_HANDLE hTrafficAdmCtrl;
+       tspecInfo_t *pTSpecInfo;
+       UINT8           acID;
+
+}fsmTSpecInfo_t;
+
+
+/* Timer functions */
+void trafficAdmCtrl_timeoutAcBE(TI_HANDLE hTrafficAdmCtrl);
+void trafficAdmCtrl_timeoutAcBK(TI_HANDLE hTrafficAdmCtrl);
+void trafficAdmCtrl_timeoutAcVI(TI_HANDLE hTrafficAdmCtrl);
+void trafficAdmCtrl_timeoutAcVO(TI_HANDLE hTrafficAdmCtrl);
+
+
+/* SM Functions */
+TI_STATUS trafficAdmCtrl_smEvent(trafficAdmCtrl_t *pAdmCtrlQos, UINT8 event, void *pData);
+
+TI_STATUS trafficAdmCtrl_smActionUnexpectedTspecResponse(fsmTSpecInfo_t *fsmTSpecInfo);        /*unxcepted*/
+TI_STATUS trafficAdmCtrl_smActionUnexpected(fsmTSpecInfo_t *fsmTSpecInfo);     /*unxcepted*/
+TI_STATUS trafficAdmCtrl_smActionNop(fsmTSpecInfo_t *fsmTSpecInfo);                    /*NOP*/
+TI_STATUS trafficAdmCtrl_smStart(fsmTSpecInfo_t *fsmTSpecInfo);                                /*EVENT_START*/
+TI_STATUS trafficAdmCtrl_smWaitStop(fsmTSpecInfo_t *fsmTSpecInfo);                     /*EVENT_STOP*/
+TI_STATUS trafficAdmCtrl_smWaitAccept(fsmTSpecInfo_t *fsmTSpecInfo);           /*EVENT_ACCEPT*/
+TI_STATUS trafficAdmCtrl_smWaitReject(fsmTSpecInfo_t *fsmTSpecInfo);           /*EVENT_REJECT*/
+TI_STATUS trafficAdmCtrl_smWaitTimeout(fsmTSpecInfo_t *fsmTSpecInfo);          /*EVENT_TIMEOUT*/
+
+
+
+TI_STATUS trafficAdmCtrl_sendAdmissionReq(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo);
+TI_STATUS trafficAdmCtrl_startTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, UINT8 acID);
+TI_STATUS trafficAdmCtrl_stopTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, UINT8 acID);
+
+
+TI_STATUS trafficAdmCtrl_buildFrameHeader(trafficAdmCtrl_t *hprafficAdmCtrl, mem_MSDU_T        *pMsdu);
+
+static TI_STATUS trafficAdmCtrl_tokenToAc (TI_HANDLE hTrafficAdmCtrl, UINT8 token, UINT8 *acID);
+
+/********************************************************************************
+ *                                                     trafficAdmCtrl_create                                                           *
+ ********************************************************************************
+DESCRIPTION: trafficAdmCtrl module creation function
+
+  INPUT:      hOs -                    Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the trafficAdmCtrl module on success, NULL otherwise
+
+************************************************************************/
+
+TI_HANDLE trafficAdmCtrl_create(TI_HANDLE hOs)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       TI_STATUS                       status;
+
+       /* allocate admission control context memory */
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)os_memoryAlloc(hOs, sizeof(trafficAdmCtrl_t));
+       if (pTrafficAdmCtrl == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));
+
+       pTrafficAdmCtrl->hOs = hOs;
+
+       /* allocate memory for admCtrlQos state machine */
+       status = fsm_Create(hOs, &pTrafficAdmCtrl->pTrafficAdmCtrlSm, TRAFFIC_ADM_CTRL_SM_NUM_STATES, TRAFFIC_ADM_CTRL_SM_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));
+               return NULL;
+       }
+
+       /* allocate OS timer AC BE */
+       pTrafficAdmCtrl->timer[QOS_AC_BE] = os_timerCreate(hOs, trafficAdmCtrl_timeoutAcBE, pTrafficAdmCtrl);
+       if (pTrafficAdmCtrl->timer[QOS_AC_BE] == NULL)
+       {
+               fsm_Unload(hOs, pTrafficAdmCtrl->pTrafficAdmCtrlSm);
+               os_memoryFree(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));          
+               return NULL;
+       }
+       /* allocate OS timer AC BK */
+       pTrafficAdmCtrl->timer[QOS_AC_BK] = os_timerCreate(hOs, trafficAdmCtrl_timeoutAcBK, pTrafficAdmCtrl);
+       if (pTrafficAdmCtrl->timer[QOS_AC_BK] == NULL)
+       {
+               fsm_Unload(hOs, pTrafficAdmCtrl->pTrafficAdmCtrlSm);
+               os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BE]);
+               os_memoryFree(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));          
+               return NULL;
+       }
+       /* allocate OS timer AC VI */
+       pTrafficAdmCtrl->timer[QOS_AC_VI] = os_timerCreate(hOs, trafficAdmCtrl_timeoutAcVI, pTrafficAdmCtrl);
+       if (pTrafficAdmCtrl->timer[QOS_AC_VI] == NULL)
+       {
+               fsm_Unload(hOs, pTrafficAdmCtrl->pTrafficAdmCtrlSm);
+               os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BE]);
+               os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BK]);
+               os_memoryFree(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));          
+               return NULL;
+       }
+       /* allocate OS timer AC VO   */
+       pTrafficAdmCtrl->timer[QOS_AC_VO] = os_timerCreate(hOs, trafficAdmCtrl_timeoutAcVO, pTrafficAdmCtrl);
+       if (pTrafficAdmCtrl->timer[QOS_AC_VO] == NULL)
+       {
+               fsm_Unload(hOs, pTrafficAdmCtrl->pTrafficAdmCtrlSm);
+               os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BE]);
+               os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BK]);
+               os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_VI]);
+               os_memoryFree(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));          
+               return NULL;
+       }
+
+       return pTrafficAdmCtrl;
+}
+/************************************************************************
+ *                        trafficAdmCtrl_unload                                                    *
+ ************************************************************************
+DESCRIPTION: trafficAdmCtrl module destroy function, 
+                               -       Free all memory alocated by the module
+                               
+INPUT:      hTrafficAdmCtrl    -       trafficAdmCtrl handle.          
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS trafficAdmCtrl_unload(TI_HANDLE hTrafficAdmCtrl)
+{
+    TI_STATUS                          status;
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       status = fsm_Unload(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->pTrafficAdmCtrlSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("ADM_CTRL_SM: Error releasing FSM memory \n"));
+       }
+       
+       /* free timers */
+       os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BE]);
+       os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_BK]);
+       os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_VI]);
+       os_timerDestroy(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[QOS_AC_VO]);
+       
+       os_memoryFree(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t));
+
+       return OK;
+}
+
+/************************************************************************
+ *                        trafficAdmCtrl_config                                                        *
+ ************************************************************************
+DESCRIPTION: trafficAdmCtrl module configuration function, 
+                               performs the following:
+                               -       Reset & initiailzes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hTrafficAdmCtrl             -      trafficAdmCtrl handle.
+                   List of handles to be used by the module
+                       pTrafficAdmCtrlInitParams       -       init parameters.                
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_config(TI_HANDLE hTrafficAdmCtrl,
+                                                       TI_HANDLE hTxData,
+                                                       TI_HANDLE hReport,
+                                                       TI_HANDLE hOs,
+                                                       TI_HANDLE hQosMngr,
+                                                       TI_HANDLE hCtrlData,
+                                                       TI_HANDLE hMemMgr,
+                                                       TI_HANDLE hExcMgr,
+                                                       trafficAdmCtrlInitParams_t      *pTrafficAdmCtrlInitParams)
+{
+       trafficAdmCtrl_t        *pTrafficAdmCtrl;
+       TI_STATUS                       status;
+       UINT8                   idx;
+
+       fsm_actionCell_t        trafficAdmCtrl_smMatrix[TRAFFIC_ADM_CTRL_SM_NUM_STATES][TRAFFIC_ADM_CTRL_SM_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {{TRAFFIC_ADM_CTRL_SM_STATE_WAIT, (fsm_Action_t)trafficAdmCtrl_smStart},                        /*EVENT_START*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionNop},            /*EVENT_STOP*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionUnexpectedTspecResponse}, /*EVENT_ACCEPT*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionUnexpectedTspecResponse}, /*EVENT_REJECT*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionUnexpected}, /*EVENT_TIMEOUT*/
+               },
+               /* next state and actions for WAIT state */
+               {{TRAFFIC_ADM_CTRL_SM_STATE_WAIT, (fsm_Action_t)trafficAdmCtrl_smActionUnexpected},     /*EVENT_START*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitStop},                     /*EVENT_STOP*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitAccept},           /*EVENT_ACCEPT*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitReject},           /*EVENT_REJECT*/
+                {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitTimeout},          /*EVENT_TIMEOUT*/
+               },
+       };
+       
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       pTrafficAdmCtrl->hTxData        = hTxData;
+       pTrafficAdmCtrl->hReport        = hReport;
+       pTrafficAdmCtrl->hOs            = hOs;
+       pTrafficAdmCtrl->hQosMngr       = hQosMngr;
+       pTrafficAdmCtrl->hCtrlData      = hCtrlData;
+       pTrafficAdmCtrl->hMemMgr        = hMemMgr;
+       pTrafficAdmCtrl->hExcMgr        = hExcMgr;
+
+       
+       /* configure state machine */
+       status = fsm_Config(pTrafficAdmCtrl->pTrafficAdmCtrlSm, &trafficAdmCtrl_smMatrix[0][0], 
+                                               TRAFFIC_ADM_CTRL_SM_NUM_STATES, TRAFFIC_ADM_CTRL_SM_NUM_EVENTS, NULL, hOs);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("TRAFFIC_ADM_CTRL_SM: fsm_Config - Error  \n"));
+
+               return NOK;
+       }
+
+       pTrafficAdmCtrl->timeout =  pTrafficAdmCtrlInitParams->trafficAdmCtrlResponseTimeout;
+    pTrafficAdmCtrl->useFixedMsduSize = pTrafficAdmCtrlInitParams->trafficAdmCtrlUseFixedMsduSize;
+
+       pTrafficAdmCtrl->dialogTokenCounter = INITIAL_DIALOG_TOKEN;
+       
+
+       for (idx=0; idx<MAX_NUM_OF_AC; idx++)
+               pTrafficAdmCtrl->dialogToken[idx] = 0;
+               
+
+       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("TRAFFIC ADM CTRL -  configuration completed ..... \n"));
+
+       return OK;
+}
+
+/************************************************************************
+ *                        FOR SM PRINTINGS                                                             *
+ ************************************************************************/
+
+#ifdef REPORT_LOG
+
+static char *admCtrlQosSMStateDesc[TRAFFIC_ADM_CTRL_SM_NUM_STATES] = { 
+               "TRAFFIC_ADM_CTRL_STATE_IDLE",
+               "TRAFFIC_ADM_CTRL_STATE_WAIT",
+       };
+       
+/* State machine inputs */
+static char *admCtrlQosSMEventDesc[TRAFFIC_ADM_CTRL_SM_NUM_EVENTS] = {
+               "TRAFFIC_ADM_CTRL_EVENT_START",
+               "TRAFFIC_ADM_CTRL_EVENT_STOP",
+               "TRAFFIC_ADM_CTRL_EVENT_ACCEPT",
+               "TRAFFIC_ADM_CTRL_EVENT_REJECT",
+               "TRAFFIC_ADM_CTRL_EVENT_TIMEOUT",
+       };
+
+#endif
+
+/************************************************************************
+ *                        trafficAdmCtrl_smEvent                                               *
+ ************************************************************************
+DESCRIPTION: trafficAdmCtrl SM general function
+                                                                                                   
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+                       event                           -       the event to the SM.
+                       pData                           -       handle to passing parameter                     
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smEvent(trafficAdmCtrl_t *pTrafficAdmCtrl, UINT8 event, void *pData)
+{
+       TI_STATUS               status;
+       UINT8                   nextState;
+       fsmTSpecInfo_t  *fsmTSpecInfo = (fsmTSpecInfo_t*)pData;
+       UINT8                   acID = fsmTSpecInfo->acID;
+
+       status = fsm_GetNextState(pTrafficAdmCtrl->pTrafficAdmCtrlSm, pTrafficAdmCtrl->currentState[acID], event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                                 ("ADM_CTRL: ERROR - failed getting next state \n"));
+
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                        ("ADM_CTRL acID = %d: <%s, %s> --> %s\n",acID,
+                                         admCtrlQosSMStateDesc[pTrafficAdmCtrl->currentState[acID] ],
+                                         admCtrlQosSMEventDesc[event],
+                                         admCtrlQosSMStateDesc[nextState]));
+
+       status = fsm_Event(pTrafficAdmCtrl->pTrafficAdmCtrlSm, &pTrafficAdmCtrl->currentState[acID], event, pData);
+
+       return(status);
+}
+
+
+/************************************************************************
+*                                                      state machine functions                                         *
+************************************************************************/
+/************************************************************************
+ *                        trafficAdmCtrl_smStart                                               *
+ ************************************************************************
+DESCRIPTION: the action function when event start ocuured on idle state 
+                               performs the following:
+                               -       send admision requestReset 
+                               -       start timer for the response.
+                                                                                                   
+INPUT:      fsmTSpecInfo - parameters for the request          
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smStart(fsmTSpecInfo_t *fsmTSpecInfo)         
+{
+       TI_STATUS                               status;
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       tspecInfo_t                             *pTSpecInfo;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+       pTSpecInfo = fsmTSpecInfo->pTSpecInfo;
+
+       /* send adm request frame */
+       status = trafficAdmCtrl_sendAdmissionReq(pTrafficAdmCtrl, pTSpecInfo);
+       if(status != OK)
+               return status;
+
+       /* init timer */
+       trafficAdmCtrl_startTimer(pTrafficAdmCtrl, pTSpecInfo->AC);
+
+       return OK;
+}
+/************************************************************************
+ *                        trafficAdmCtrl_smWaitStop                                            *
+ ************************************************************************
+DESCRIPTION: the action function when event stop ocuured on wait state 
+                               performs the following:
+                               -       stop timer.
+                                                                                                   
+INPUT:      fsmTSpecInfo - parameters of the request           
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smWaitStop(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       tspecInfo_t                             *pTSpecInfo;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+       pTSpecInfo = fsmTSpecInfo->pTSpecInfo;
+
+       /* stop timer */
+       trafficAdmCtrl_stopTimer(pTrafficAdmCtrl,fsmTSpecInfo->pTSpecInfo->AC);
+
+       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("TRAFFIC ADM CTRL -  AC = %d,    Stoped ..... \n", pTSpecInfo->AC));
+
+       
+       return OK;
+}
+/************************************************************************
+ *                        trafficAdmCtrl_smWaitAccept                                  *
+ ************************************************************************
+DESCRIPTION: the action function when event accept ocuured on wait state 
+                               performs the following:
+                               -       update the Qos Mngr of the status and the parameters
+                                                                                                   
+INPUT:      fsmTSpecInfo - parameters of the response          
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smWaitAccept(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       tspecInfo_t                             *pTSpecInfo;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+       pTSpecInfo = fsmTSpecInfo->pTSpecInfo;
+
+       /* update the QosMngr */
+       qosMngr_setAdmissionInfo(pTrafficAdmCtrl->hQosMngr, pTSpecInfo->AC, pTSpecInfo, STATUS_TRAFFIC_ADM_REQUEST_ACCEPT);
+
+       return OK;
+}
+/************************************************************************
+ *                        trafficAdmCtrl_smWaitReject                                  *
+ ************************************************************************
+DESCRIPTION: the action function when event reject ocuured on wait state 
+                               performs the following:
+                               -       update the Qos Mngr of the status and the parameters
+                                                                                                   
+INPUT:      fsmTSpecInfo - parameters of the response          
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS trafficAdmCtrl_smWaitReject(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       tspecInfo_t                             *pTSpecInfo;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+       pTSpecInfo = fsmTSpecInfo->pTSpecInfo;
+
+       /* update the QosMngr */
+       qosMngr_setAdmissionInfo(pTrafficAdmCtrl->hQosMngr, pTSpecInfo->AC, pTSpecInfo, STATUS_TRAFFIC_ADM_REQUEST_REJECT);
+
+       return OK;
+}
+/************************************************************************
+ *                        trafficAdmCtrl_smWaitTimeout                                 *
+ ************************************************************************
+DESCRIPTION: the action function when event timeout ocuured on wait state 
+                               performs the following:
+                               -       update the Qos Mngr of the status and the parameters
+                                                                                                   
+INPUT:      fsmTSpecInfo - parameters of the request           
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smWaitTimeout(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+
+       /* update the QosMngr */
+       qosMngr_setAdmissionInfo(pTrafficAdmCtrl->hQosMngr, fsmTSpecInfo->acID, NULL, STATUS_TRAFFIC_ADM_REQUEST_TIMEOUT);
+
+       return OK;
+}
+/************************************************************************
+ *               trafficAdmCtrl_smActionUnexpected                                             *
+ ************************************************************************
+DESCRIPTION:                                                 
+INPUT:      fsmTSpecInfo - tspec parameters    
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smActionUnexpected(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+
+       WLAN_REPORT_ERROR(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("TRAFFIC ADM CTRL -  AC = %d,    ActionUnexpected ..... \n", fsmTSpecInfo->acID));
+
+       return OK;
+}
+
+/************************************************************************
+ *               trafficAdmCtrl_smActionUnexpectedTspecResponse                        *
+ ************************************************************************
+DESCRIPTION:                                                 
+INPUT:      fsmTSpecInfo - tspec parameters    
+OUTPUT:                
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smActionUnexpectedTspecResponse(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       tspecInfo_t                             *pTSpecInfo;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+       pTSpecInfo = fsmTSpecInfo->pTSpecInfo;
+
+       /* Send event to user application - how come TSPEC response arrives without request ? */
+       qosMngr_sendUnexpectedTSPECResponseEvent (pTrafficAdmCtrl->hQosMngr,pTSpecInfo);
+
+       WLAN_REPORT_WARNING(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("TRAFFIC ADM CTRL -  AC = %d,    ActionUnexpected ..... \n", fsmTSpecInfo->acID));
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        trafficAdmCtrl_smActionNop                                   *
+ ************************************************************************
+DESCRIPTION:                                                 
+INPUT:      fsmTSpecInfo - tspec parameters    
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_smActionNop(fsmTSpecInfo_t *fsmTSpecInfo)
+{
+       trafficAdmCtrl_t                *pTrafficAdmCtrl;
+       tspecInfo_t                             *pTSpecInfo;
+
+       pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl);
+       pTSpecInfo = fsmTSpecInfo->pTSpecInfo;
+
+       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("TRAFFIC ADM CTRL -  AC = %d,    Action NOP..... \n", pTSpecInfo->AC));
+
+       return OK;
+}
+/************************************************************************
+ *                                                     API FUNCTIONS                                                   *
+ ************************************************************************
+ ************************************************************************/
+
+/************************************************************************
+ *                    trafficAdmCtrl_startAdmRequest                    *
+ ************************************************************************
+DESCRIPTION: start TSPEC signaling
+                                                                                                   
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+                       pTSpecInfo                      -       the TSPEC parameters
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_startAdmRequest(TI_HANDLE     hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo)
+{
+       TI_STATUS                       status;
+       fsmTSpecInfo_t          fsmTSpecInfo;
+
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       if (pTrafficAdmCtrl == NULL)
+               return NOK;
+
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = pTSpecInfo;
+       fsmTSpecInfo.acID = pTSpecInfo->AC;
+
+       /* send event START to SM */
+       status = trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_START, &fsmTSpecInfo);
+
+       return status;
+
+}
+/************************************************************************
+ *                    trafficAdmCtrl_stopAdmRequest                     *
+ ************************************************************************
+DESCRIPTION: stop specific tspec signaling
+                                                                                                   
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+                       acID                            -       the AC of the tspec to stop
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_stopAdmRequest(TI_HANDLE hTrafficAdmCtrl, UINT8 acID)
+{
+       TI_STATUS                       status;
+       trafficAdmCtrl_t        *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+       
+       tspecInfo_t                     pTSpecInfo;
+       fsmTSpecInfo_t          fsmTSpecInfo;
+
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = &pTSpecInfo;
+
+       fsmTSpecInfo.pTSpecInfo->AC = (acTrfcType_e)acID;
+       fsmTSpecInfo.acID = acID;
+
+       /* send event STOP to SM */
+       status = trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_STOP, &fsmTSpecInfo);
+       
+       return status;
+
+}
+/************************************************************************
+ *                    trafficAdmCtrl_stop                                           *
+ ************************************************************************
+DESCRIPTION: stop all tspecs and reset SM  
+                       called on disconnect
+                                                                                                 
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS trafficAdmCtrl_stop(TI_HANDLE        hTrafficAdmCtrl)
+{
+       UINT8                           acID;
+       UINT8                           idx;
+
+       trafficAdmCtrl_t        *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+       
+       tspecInfo_t                     pTSpecInfo;
+       fsmTSpecInfo_t          fsmTSpecInfo;
+
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = &pTSpecInfo;
+
+       /* clean all AC SM  */
+       for (acID = 0 ; acID < MAX_NUM_OF_AC ; acID++)
+       {
+               fsmTSpecInfo.pTSpecInfo->AC = (acTrfcType_e)acID;
+               fsmTSpecInfo.acID = acID;
+               trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_STOP, &fsmTSpecInfo);
+       }
+
+       pTrafficAdmCtrl->dialogTokenCounter = INITIAL_DIALOG_TOKEN;
+       
+       for (idx=0; idx<MAX_NUM_OF_AC; idx++)
+               pTrafficAdmCtrl->dialogToken[idx] = 0;
+
+       return OK;
+}
+
+/************************************************************************
+ *                    trafficAdmCtrl_recv                                           *
+ ************************************************************************
+DESCRIPTION: 
+                                                                                                 
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_recv(TI_HANDLE hTrafficAdmCtrl, UINT8* pData, UINT8 action)
+{
+       TI_STATUS                       status = OK;
+       UINT8                           statusCode;
+       UINT8                           dialogToken;
+       UINT8                           tacID;
+       tspecInfo_t                     tspecInfo;
+       fsmTSpecInfo_t          fsmTSpecInfo;
+
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       if (action == ADDTS_RESPONSE_ACTION) 
+       {
+               WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                                               ("action = 1 - ADDTS RESPONSE ACTION........!! \n"));
+
+               /* parsing the dialog token */
+               dialogToken = *pData;
+               pData++;
+               
+               /* in WME status code is 1 byte, in WSM is 2 bytes */
+               statusCode = *pData;
+               pData++;
+
+               tspecInfo.statusCode = statusCode;
+
+               WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                       ("dialogToken = %d ,  statusCode = %d \n",dialogToken, statusCode));
+
+               trafficAdmCtrl_parseTspecIE(pTrafficAdmCtrl, &tspecInfo, (dot11_WME_TSPEC_IE_t *)pData);
+
+               if (trafficAdmCtrl_tokenToAc (pTrafficAdmCtrl, dialogToken, &tacID) == NOK)
+               {
+                       WLAN_REPORT_WARNING(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                       ("dialog token Not found,  dialogToken = %d , \n",dialogToken));
+                       
+                       qosMngr_sendUnexpectedTSPECResponseEvent(pTrafficAdmCtrl->hQosMngr, &tspecInfo);
+               
+                       return NOK;
+               }
+               
+               /* validate dialog token matching */
+               if(pTrafficAdmCtrl->dialogToken[tspecInfo.AC] != dialogToken)
+               {
+                       WLAN_REPORT_WARNING(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                       ("dialog token mismatch,  dialogToken = %d ,  acID = %d \n",dialogToken, tspecInfo.AC));
+                       
+                       qosMngr_sendUnexpectedTSPECResponseEvent(pTrafficAdmCtrl->hQosMngr, &tspecInfo);
+               
+                       return NOK;
+               }
+
+               /* Stop the relevant Timer */
+               trafficAdmCtrl_stopTimer(pTrafficAdmCtrl, tspecInfo.AC);
+
+               fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+               fsmTSpecInfo.pTSpecInfo = &tspecInfo;
+
+               fsmTSpecInfo.acID = tspecInfo.AC;
+               
+               if(statusCode != ADDTS_STATUS_CODE_SUCCESS)
+               {
+                       /* admission reject */
+                       /********************/
+                       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                       ("***** admCtrlQos_recv: admission reject [ statusCode = %d ]\n",statusCode));
+                       
+                       
+                       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                       ("ADDTS Response (reject) userPriority = %d , \n", tspecInfo.userPriority));
+                       
+                       trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_REJECT, &fsmTSpecInfo);
+                       
+               }
+               else
+               {
+                       /* admission accept */
+                       /********************/
+                       
+                       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                               ("***** admCtrlQos_recv: admission accept [ statusCode = %d ]\n",statusCode));
+                       
+                       
+                       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                               ("ADDTS Response (accepted) userPriority = %d ,  \n", tspecInfo.userPriority));
+       
+                       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                               ("mediumTime = %d ,  surplusBandwidthAllowance = %d \n", ((dot11_WME_TSPEC_IE_t*)pData)->mediumTime, ((dot11_WME_TSPEC_IE_t*)pData)->surplusBandwidthAllowance));
+                       
+                       trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_ACCEPT, &fsmTSpecInfo);
+               }
+       }
+       else
+       {
+               status = NOK;
+               WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                       ("trafficAdmCtrl_recv: unknown action code = %d ,  \n",action));
+
+       }
+       return status;
+}
+/************************************************************************
+ *                    trafficAdmCtrl_recv                                           *
+ ************************************************************************
+DESCRIPTION: 
+                                                                                                 
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+
+
+TI_STATUS trafficAdmCtrl_sendDeltsFrame(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo, UINT8 reasonCode)
+{
+       TI_STATUS                       status = OK;
+       mem_MSDU_T                  *pMsdu;
+       char                            *pDataBuf;
+       UINT32                          totalLen = 0;
+       tsInfo_t                        tsInfo;
+        UINT32 tspecLen;
+
+
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                                               ("admCtrlQos_sendDeltsFrame: Enter....!! \n"));
+
+       /* GET NEW MSDU !!! */
+       status = wlan_memMngrAllocMSDU(pTrafficAdmCtrl->hMemMgr, &pMsdu, 2000 +TX_TOTAL_OFFSET_BEFORE_DATA, ADM_CTRL_QOS_MODULE);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+    /* 
+     * Set data offset before header builder, because it assumes it's already set
+     */
+    memMgr_BufOffset(pMsdu->firstBDPtr) = TX_TOTAL_OFFSET_BEFORE_DATA; 
+
+       status = trafficAdmCtrl_buildFrameHeader(pTrafficAdmCtrl, pMsdu);
+       if (status != OK)
+       {
+               wlan_memMngrFreeMSDU(pTrafficAdmCtrl->hMemMgr, pMsdu->handle);
+               return NOK;
+       }
+       pDataBuf = (memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr) + WLAN_HDR_LEN );
+
+
+       *pDataBuf = WME_CATAGORY_QOS;                           /* CATEGORY_QOS in WME = 17*/
+       pDataBuf++ ;
+       totalLen++;
+
+       *pDataBuf = DELTS_ACTION;                                       /* DELTS ACTION */
+       pDataBuf++ ;
+       totalLen++;
+
+       /* according to WMM Specification v1.1, section 2.2.10, dialog token = 0 in DELTS */
+       *pDataBuf = 0;          /* DIALOG_TOKEN */
+
+       pDataBuf++ ;
+       totalLen++;
+
+       /* according to WMM Specification v1.1, section 2.2.10, status = 0 in DELTS */
+       *pDataBuf = 0;                                  /* STATUS CODE = REASON CODE */
+       pDataBuf++ ;
+       totalLen++;
+       
+
+    /*
+     * WMM specification v1.1 specifie that DELTS must include at least
+     * a full TSPEC IE.  The format used by TI is following 802.11e format
+     * which does not include TSPEC IE but only TS info field
+     */
+    trafficAdmCtrl_buildTSPec(pTrafficAdmCtrl, pTSpecInfo, pDataBuf, &tspecLen);
+    totalLen += tspecLen;
+
+       tsInfo.tsInfoArr[0] = 0;
+       tsInfo.tsInfoArr[1] = 0;
+       tsInfo.tsInfoArr[2] = 0;
+
+       /* Build tsInfo  */
+    tsInfo.tsInfoArr[0] |=             ( (pTSpecInfo->userPriority) << TSID_SHIFT);
+
+       tsInfo.tsInfoArr[0] |=          (BI_DIRECTIONAL << DIRECTION_SHIFT);            /* bidirectional */
+       tsInfo.tsInfoArr[0] |=          (TS_INFO_0_ACCESS_POLICY_EDCA << ACCESS_POLICY_SHIFT);  /* EDCA */
+       
+       tsInfo.tsInfoArr[1] |=          (0 << AGGREGATION_SHIFT);
+       
+       tsInfo.tsInfoArr[1] |=          (pTSpecInfo->UPSDFlag << APSD_SHIFT);
+       
+       tsInfo.tsInfoArr[1] |=          (pTSpecInfo->userPriority << USER_PRIORITY_SHIFT);
+       tsInfo.tsInfoArr[1] |=          (NORMAL_ACKNOWLEDGEMENT << TSINFO_ACK_POLICY_SHIFT);
+       
+       tsInfo.tsInfoArr[2] |=          (NO_SCHEDULE << SCHEDULE_SHIFT);
+
+#if 0 /* Need to send TSPEC IE in DELTS or only the tsinfo*/
+
+       /* only tsinfo*/
+       
+       
+       *pDataBuf = tsInfo.tsInfoArr[0];
+       pDataBuf++;
+       totalLen++;
+
+       *pDataBuf = tsInfo.tsInfoArr[1];
+       pDataBuf++;
+       totalLen++;
+
+       *pDataBuf = tsInfo.tsInfoArr[2];
+       pDataBuf++;
+       totalLen++; 
+       
+#else
+
+       /*  send TSpec IE in DELTS*/
+
+       {
+               dot11_WME_TSPEC_IE_t*    dot11_WME_TSPEC_IE = (dot11_WME_TSPEC_IE_t*)pDataBuf;
+
+
+               dot11_WME_TSPEC_IE->tHdr.hdr.eleId =            WME_TSPEC_IE_ID;
+               dot11_WME_TSPEC_IE->tHdr.hdr.eleLen =   WME_TSPEC_IE_TSINFO_LEN;
+
+               dot11_WME_TSPEC_IE->tHdr.OUI[0] =               0x00;
+               dot11_WME_TSPEC_IE->tHdr.OUI[1] =               0x50;
+               dot11_WME_TSPEC_IE->tHdr.OUI[2] =               0xf2;
+               dot11_WME_TSPEC_IE->tHdr.oui_type =             WME_TSPEC_IE_OUI_TYPE;
+               dot11_WME_TSPEC_IE->tHdr.oui_subtype =  WME_TSPEC_IE_OUI_SUB_TYPE;
+               dot11_WME_TSPEC_IE->tHdr.version =              WME_TSPEC_IE_VERSION;
+               
+               dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[0] =     tsInfo.tsInfoArr[0];
+               dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[1] =     tsInfo.tsInfoArr[1];
+               dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[2] =     tsInfo.tsInfoArr[2];
+
+               totalLen+=sizeof(dot11_WME_TSPEC_IE_hdr_t);
+
+       }
+
+#endif
+
+
+       /*date MSDU parameters */
+       pMsdu->headerLen = WLAN_HDR_LEN;
+       pMsdu->dataLen += totalLen;
+       pMsdu->firstBDPtr->length = pMsdu->dataLen+TX_TOTAL_OFFSET_BEFORE_DATA;
+
+       
+       
+       /* send the packet to the TX */
+       pMsdu->qosTag = 0;
+       pMsdu->txFlags |= (TX_DATA_MGMT_MSDU);
+       status = txData_txSendMsdu(pTrafficAdmCtrl->hTxData, pMsdu);
+
+
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                                                     INTERNAL FUNCTIONS                                              *
+ ************************************************************************/
+/************************************************************************
+ *                    trafficAdmCtrl_startTimer                                    *
+ ************************************************************************
+DESCRIPTION: start a specific ac timer
+                                                                                                   
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+                       acID                            -       the AC of the timer
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_startTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, UINT8 acID)
+{
+       if (pTrafficAdmCtrl == NULL)
+               return NOK;
+       
+       os_timerStart(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[acID], pTrafficAdmCtrl->timeout, FALSE);
+
+       return OK;
+}
+/************************************************************************
+ *                    trafficAdmCtrl_stopTimer                             *
+ ************************************************************************
+DESCRIPTION: stop a specific ac timer
+                                                                                                   
+INPUT:      pTrafficAdmCtrl        -   trafficAdmCtr handle.
+                       acID                            -       the AC of the timer
+       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_stopTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, UINT8 acID)
+{
+       if (pTrafficAdmCtrl == NULL)
+               return NOK;
+       
+       os_timerStop(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->timer[acID]);
+
+       return OK;
+}
+
+/************************************************************************
+ *                                               AC timers functionc                               *
+ ************************************************************************/
+
+/* QOS_AC_BE */
+/*********/
+void trafficAdmCtrl_timeoutAcBE(TI_HANDLE hTrafficAdmCtrl)
+{
+       fsmTSpecInfo_t  fsmTSpecInfo;
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       
+       /* FSM Tspec Info Structure */
+       fsmTSpecInfo.acID = QOS_AC_BE;
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = NULL;
+
+       trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo);
+}
+
+/* QOS_AC_BK */
+/*********/
+void trafficAdmCtrl_timeoutAcBK(TI_HANDLE hTrafficAdmCtrl)
+{
+       fsmTSpecInfo_t  fsmTSpecInfo;
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       
+       /* FSM Tspec Info Structure */
+       fsmTSpecInfo.acID = QOS_AC_BK;
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = NULL;
+
+       trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo);
+
+}
+/* QOS_AC_VI\13 */
+/*********/
+void trafficAdmCtrl_timeoutAcVI(TI_HANDLE hTrafficAdmCtrl)
+{
+       fsmTSpecInfo_t  fsmTSpecInfo;
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       
+       /* FSM Tspec Info Structure */
+       fsmTSpecInfo.acID = QOS_AC_VI;
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = NULL;
+
+       trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo);
+
+}
+/* QOS_AC_VO */
+/*********/
+void trafficAdmCtrl_timeoutAcVO(TI_HANDLE hTrafficAdmCtrl)
+{
+       fsmTSpecInfo_t  fsmTSpecInfo;
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       
+       /* FSM Tspec Info Structure */
+       fsmTSpecInfo.acID = QOS_AC_VO;
+       fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl;
+       fsmTSpecInfo.pTSpecInfo = NULL;
+
+       trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo);
+
+}
+
+
+static TI_STATUS trafficAdmCtrl_tokenToAc (TI_HANDLE hTrafficAdmCtrl, UINT8 token, UINT8 *acID)
+{
+       UINT8 idx;
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       for (idx=0; idx<MAX_NUM_OF_AC; idx++)
+       {
+               if (pTrafficAdmCtrl->dialogToken[idx] == token)
+               {
+                       *acID = idx;
+                       return (OK);
+               }
+       }
+
+       return (NOK);
+
+}
+
+
+
+/************************************************************************
+ *              trafficAdmCtrl_buildFrameHeader                                                        *
+ ************************************************************************
+DESCRIPTION: build frame header 
+                                                                                                   
+INPUT:         
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_buildFrameHeader(trafficAdmCtrl_t *pTrafficAdmCtrl, mem_MSDU_T        *pMsdu)
+{
+       TI_STATUS                       status = OK;
+       paramInfo_t                 daParam, saParam;
+       dot11_mgmtHeader_t *pdot11Header;
+       bssType_e                       currBssType;
+       macAddress_t            currBssId;
+
+       pdot11Header = (dot11_mgmtHeader_t*)(memMgr_BufData(pMsdu->firstBDPtr)+ memMgr_BufOffset(pMsdu->firstBDPtr));
+       
+    /* Get the Destination MAC address */
+       daParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+       status = ctrlData_getParam(pTrafficAdmCtrl->hCtrlData, &daParam);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+    /* Get the Source MAC address */
+       saParam.paramType = CTRL_DATA_MAC_ADDRESS;
+       status = ctrlData_getParam(pTrafficAdmCtrl->hCtrlData, &saParam);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       /* receive BssId and Bss Type from control module */
+       ctrlData_getCurrBssTypeAndCurrBssId(pTrafficAdmCtrl->hCtrlData, &currBssId, &currBssType);
+       if (currBssType != BSS_INFRASTRUCTURE)
+    {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                 ("trafficAdmCtrl_buildFrameHeader: Error !! currBssType = BSS_INFRASTRUCTURE \n"));
+
+               return NOK;
+    }
+       /* infrastructure BSS */
+
+       /* copy BSSID */
+       MAC_COPY(pTrafficAdmCtrl->hOs,(&pdot11Header->BSSID),(&currBssId));
+       /* copy source mac address */
+       MAC_COPY(pTrafficAdmCtrl->hOs,(&pdot11Header->SA),(&saParam.content.ctrlDataCurrentBSSID));
+       /* copy destination mac address */
+       MAC_COPY(pTrafficAdmCtrl->hOs,(&pdot11Header->DA),(&daParam.content.ctrlDataCurrentBSSID));
+
+       /* set frame ctrl to mgmt action frame an to DS */
+       pdot11Header->fc = DOT11_FC_ACTION;
+
+       /* Update MSDU parameters */
+       pMsdu->headerLen = WLAN_HDR_LEN;
+       pMsdu->dataLen = WLAN_HDR_LEN;
+       pMsdu->firstBDPtr->length = WLAN_HDR_LEN;
+
+       return OK;
+}
+
+/************************************************************************
+ *                  trafficAdmCtrl_sendAdmissionReq                                            *
+ ************************************************************************
+DESCRIPTION: send admision request frame
+                                                                                                   
+INPUT:      hTrafficAdmCtrl             -      Qos Manager handle.
+                   pTSpecInfo                           -  tspec parameters
+                       
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS trafficAdmCtrl_sendAdmissionReq(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo)
+{
+       TI_STATUS                       status = OK;
+       mem_MSDU_T                  *pMsdu;
+       char                            *pDataBuf;
+       UINT32                          len;
+       UINT32                          totalLen = 0;
+
+       trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl;
+
+       WLAN_REPORT_INFORMATION(pTrafficAdmCtrl->hReport, TRAFFIC_ADM_CTRL_MODULE_LOG,
+                                                               ("admCtrlQos_smAdmissionReq: Enter....!! \n"));
+
+       /* GET NEW MSDU !!! */
+       status = wlan_memMngrAllocMSDU(pTrafficAdmCtrl->hMemMgr, &pMsdu, 2000 + TX_TOTAL_OFFSET_BEFORE_DATA, ADM_CTRL_QOS_MODULE);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+    /* 
+     * Set data offset before header builder, because it assumes it's already set
+     */
+       memMgr_BufOffset(pMsdu->firstBDPtr) = TX_TOTAL_OFFSET_BEFORE_DATA;      
+
+       status = trafficAdmCtrl_buildFrameHeader(pTrafficAdmCtrl, pMsdu);
+       if (status != OK)
+       {
+               wlan_memMngrFreeMSDU(pTrafficAdmCtrl->hMemMgr, pMsdu->handle);
+               return NOK;
+       }
+
+       pDataBuf = (memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr) + WLAN_HDR_LEN);
+
+       *pDataBuf = WME_CATAGORY_QOS;                   /* CATEGORY_QOS WME = 17*/
+       pDataBuf++ ;
+       totalLen++;
+
+       *pDataBuf = ADDTS_REQUEST_ACTION;               /* ADDTS request ACTION */
+       pDataBuf++ ;
+       totalLen++;
+
+       /* storing the dialog token for response validation */
+       pTrafficAdmCtrl->dialogToken[pTSpecInfo->AC] = pTrafficAdmCtrl->dialogTokenCounter++;   /* DIALOG_TOKEN */
+       *pDataBuf = pTrafficAdmCtrl->dialogToken[pTSpecInfo->AC];
+       pDataBuf++ ;
+       totalLen++;
+
+       /* in WME there is a staus code in ADDTS Request ??*/
+       *pDataBuf = ADDTS_STATUS_CODE_SUCCESS;  /* STATUS CODE */
+       pDataBuf++ ;
+       totalLen++;
+
+       trafficAdmCtrl_buildTSPec(pTrafficAdmCtrl, pTSpecInfo, (UINT8 *)pDataBuf, (UINT32*)&len);
+       pDataBuf+=len;
+       totalLen+=len;
+#ifdef EXC_MODULE_INCLUDED
+       excMngr_buildExcTS_IEs(pTrafficAdmCtrl->hExcMgr, (UINT8 *)pDataBuf, (UINT32*)&len, pTSpecInfo->userPriority);
+       pDataBuf+=len;
+       totalLen+=len;
+#endif
+       /* Update MSDU parameters */
+       pMsdu->headerLen = WLAN_HDR_LEN;
+       pMsdu->dataLen += totalLen;
+       pMsdu->firstBDPtr->length = pMsdu->dataLen + TX_TOTAL_OFFSET_BEFORE_DATA;
+       
+       /* send the packet to the TX */
+       pMsdu->qosTag = 0; 
+       pMsdu->txFlags |= (TX_DATA_MGMT_MSDU);
+
+       status = txData_txSendMsdu(pTrafficAdmCtrl->hTxData, pMsdu);
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        trafficAdmCtrl_buildTSPec                                                    *
+ ************************************************************************
+DESCRIPTION: build a tspec according to the tspec parameters
+                                                                                                   
+INPUT:      hTrafficAdmCtrl             -      Qos Manager handle.
+                   pTSpecInfo                           -  tspec parameters
+
+OUTPUT:                len                                              - the tspec frame len                          
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+void trafficAdmCtrl_buildTSPec(trafficAdmCtrl_t        *pTrafficAdmCtrl, 
+                                                          tspecInfo_t          *pTSpecInfo, 
+                                                          UINT8                        *pDataBuff,
+                                                          UINT32                       *len)
+{
+       tsInfo_t                        tsInfo;
+       dot11_WME_TSPEC_IE_t*    dot11_WME_TSPEC_IE = (dot11_WME_TSPEC_IE_t*)pDataBuff;
+    dot11_local_WME_TSPEC_IE_t   myLocal;
+
+       dot11_WME_TSPEC_IE->tHdr.hdr.eleId =    WME_TSPEC_IE_ID;
+       dot11_WME_TSPEC_IE->tHdr.hdr.eleLen =   WME_TSPEC_IE_LEN;
+
+       dot11_WME_TSPEC_IE->tHdr.OUI[0] =               0x00;
+       dot11_WME_TSPEC_IE->tHdr.OUI[1] =               0x50;
+       dot11_WME_TSPEC_IE->tHdr.OUI[2] =               0xf2;
+       dot11_WME_TSPEC_IE->tHdr.oui_type =             WME_TSPEC_IE_OUI_TYPE;
+       dot11_WME_TSPEC_IE->tHdr.oui_subtype =  WME_TSPEC_IE_OUI_SUB_TYPE;
+       dot11_WME_TSPEC_IE->tHdr.version =              WME_TSPEC_IE_VERSION;
+
+
+       tsInfo.tsInfoArr[0] = 0;
+       tsInfo.tsInfoArr[1] = 0;
+       tsInfo.tsInfoArr[2] = 0;
+
+       tsInfo.tsInfoArr[0] |=          ( (pTSpecInfo->userPriority) << TSID_SHIFT);
+       tsInfo.tsInfoArr[0] |=          (pTSpecInfo->streamDirection << DIRECTION_SHIFT);               /* bidirectional */
+
+       tsInfo.tsInfoArr[0] |=          (TS_INFO_0_ACCESS_POLICY_EDCA << ACCESS_POLICY_SHIFT);  /* EDCA */
+
+       tsInfo.tsInfoArr[1] |=          (0 << AGGREGATION_SHIFT);
+
+       tsInfo.tsInfoArr[1] |=          (pTSpecInfo->UPSDFlag << APSD_SHIFT);
+
+       tsInfo.tsInfoArr[1] |=          (pTSpecInfo->userPriority << USER_PRIORITY_SHIFT);
+       tsInfo.tsInfoArr[1] |=          (NORMAL_ACKNOWLEDGEMENT << TSINFO_ACK_POLICY_SHIFT);
+       
+       tsInfo.tsInfoArr[2] |=          (NO_SCHEDULE << SCHEDULE_SHIFT);
+
+       dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[0] =     tsInfo.tsInfoArr[0];
+       dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[1] =     tsInfo.tsInfoArr[1];
+       dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[2] =     tsInfo.tsInfoArr[2];
+    
+
+    myLocal.nominalMSDUSize =                  pTSpecInfo->nominalMsduSize;
+       myLocal.maximumMSDUSize =                       (pTSpecInfo->nominalMsduSize & 0x7fff);
+
+
+       myLocal.minimumServiceInterval =        0;
+       myLocal.maximumServiceInterval =        0;
+       myLocal.inactivityInterval =            0;
+       myLocal.suspensionInterval =            0xFFFFFFFF; /*disable*/
+       myLocal.serviceStartTime =                      0;
+       myLocal.minimumDataRate =                       pTSpecInfo->meanDataRate;
+       myLocal.meanDataRate =                          pTSpecInfo->meanDataRate;
+       myLocal.peakDataRate =                          pTSpecInfo->meanDataRate;
+       myLocal.maximumBurstSize =                      0;
+       myLocal.delayBound =                            0;
+       myLocal.minimumPHYRate =                        pTSpecInfo->minimumPHYRate;
+       myLocal.surplusBandwidthAllowance = pTSpecInfo->surplausBwAllowance;
+       myLocal.mediumTime =                            0;
+
+    os_memoryCopy (pTrafficAdmCtrl->hOs,(void *)&dot11_WME_TSPEC_IE->nominalMSDUSize,(void *)&myLocal.nominalMSDUSize,sizeof(dot11_WME_TSPEC_IE_t));
+
+       *len = sizeof(dot11_WME_TSPEC_IE_t);   
+}
+
+
+
+/************************************************************************
+ *                        trafficAdmCtrl_parseTspecIE                                  *
+ ************************************************************************
+DESCRIPTION: parses a tspec IE according to the tspec parameters
+                                                                                                   
+INPUT:      hTrafficAdmCtrl             -      Qos Manager handle.
+                   pTSpecInfo                           -  tspec parameters
+
+OUTPUT:                len                                              - the tspec frame len                          
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+void trafficAdmCtrl_parseTspecIE(trafficAdmCtrl_t      *pTrafficAdmCtrl, 
+                                                                tspecInfo_t            *pTSpecInfo, 
+                                                                dot11_WME_TSPEC_IE_t   *dot11_WME_TSPEC_IE)
+{
+       tsInfo_t                        tsInfo;
+       UINT8                           userPriority;
+       UINT8                           acID;
+       UINT8                           tid;
+       UINT8                           direction;
+       UINT8                           APSDbit;
+
+       tsInfo.tsInfoArr[0] = dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[0];
+       tsInfo.tsInfoArr[1] = dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[1];
+       tsInfo.tsInfoArr[2] = dot11_WME_TSPEC_IE->tHdr.tsInfoField.tsInfoArr[2];
+
+       userPriority = (((tsInfo.tsInfoArr[1]) & TS_INFO_1_USER_PRIORITY_MASK) >> USER_PRIORITY_SHIFT);
+
+       acID = WMEQosTagToACTable[userPriority];
+
+       tid =   (((tsInfo.tsInfoArr[0]) & TS_INFO_0_TSID_MASK) >> TSID_SHIFT);
+       APSDbit = (((tsInfo.tsInfoArr[1]) & TS_INFO_1_APSD_MASK) >> APSD_SHIFT);
+       direction = (((tsInfo.tsInfoArr[0]) & TS_INFO_0_DIRECTION_MASK) >> DIRECTION_SHIFT);
+
+       pTSpecInfo->AC = (acTrfcType_e)acID;
+       pTSpecInfo->userPriority = userPriority;
+       pTSpecInfo->nominalMsduSize = dot11_WME_TSPEC_IE->nominalMSDUSize;
+       pTSpecInfo->meanDataRate = dot11_WME_TSPEC_IE->meanDataRate;
+       
+       /* The surplus is transmitted in the 3 MSB of UINT16 */
+        pTSpecInfo->surplausBwAllowance = dot11_WME_TSPEC_IE->surplusBandwidthAllowance;
+
+       pTSpecInfo->minimumPHYRate = dot11_WME_TSPEC_IE->minimumPHYRate;
+       pTSpecInfo->mediumTime = dot11_WME_TSPEC_IE->mediumTime;
+       pTSpecInfo->UPSDFlag = APSDbit;
+       pTSpecInfo->streamDirection = (streamDirection_e)direction;
+       pTSpecInfo->tid = tid;
+}
+
+
+/*************************************************************************
+ *                                                                                                                                              *
+ *                                                     DEBUG FUNCTIONS                                                          *
+ *                                                                                                                                              *
+ *************************************************************************/
+void trafficAdmCtrl_print(trafficAdmCtrl_t *pTrafficAdmCtr)
+{
+       UINT32 acID;
+
+       WLAN_OS_REPORT(("     traffic Adm Ctrl  \n"));
+       WLAN_OS_REPORT(("-----------------------------------\n\n"));
+       WLAN_OS_REPORT(("timeout                   = %d\n",pTrafficAdmCtr->timeout));
+       WLAN_OS_REPORT(("dialogTokenCounter        = %d\n",pTrafficAdmCtr->dialogTokenCounter));
+
+       for (acID = 0 ; acID < MAX_NUM_OF_AC ; acID++)
+       {
+                       WLAN_OS_REPORT(("     AC = %d  \n",acID));
+                       WLAN_OS_REPORT(("----------------------\n"));
+                       WLAN_OS_REPORT(("currentState   = %s \n",admCtrlQosSMStateDesc[pTrafficAdmCtr->currentState[acID] ]));
+                       WLAN_OS_REPORT(("dialogToken    = %d \n",pTrafficAdmCtr->dialogToken[acID]));
+       }
+}
+       
diff --git a/sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr.c b/sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr.c
new file mode 100644 (file)
index 0000000..5e47eff
--- /dev/null
@@ -0,0 +1,417 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/*******************************************************************************/
+/*                                                                             */
+/*  MODULE:  recoveryMgr.c                                                     */
+/*  PURPOSE: The responsibility of RecoveryMgr module is to provide main API   */
+/*           to HelthMonitor that invokes the recovery process if failure is   */
+/*           detected. It performs disable/enable inputs from outside, calls   */
+/*           restart of TWD and informs STAD modules that recovery has been    */
+/*           performed.                                                        */
+/*                                                                             */
+/*******************************************************************************/
+
+#include "paramOut.h"
+#include "osApi.h"
+#include "DataCtrl_Api.h"
+#include "report.h"
+#include "recoveryMgr.h"
+#include "recoveryMgr_API.h"
+#include "TNETW_Driver_api.h"
+
+#include "healthMonitor.h"
+#include "PowerMgr_API.h"
+#include "siteMgrApi.h"
+#include "currBss.h"
+#include "whalCtrl.h"
+
+#include "TNETW_Driver.h"
+#include "TNETWIF.h"
+#include "SoftGeminiApi.h"
+
+/* static function */
+#ifdef USE_RECOVERY
+static void recoveryMgr_SM(TI_HANDLE hRecoveryMgr);
+static TI_STATUS recoveryMgr_notifyStadAboutRecovery(TI_HANDLE hRecoveryMgr);
+#endif /* USE_RECOVERY */
+
+/*******************************************************************************
+*                       PUBLIC  FUNCTIONS  IMPLEMENTATION                      *
+********************************************************************************/
+
+/*************************************************************************
+*                        recoveryMgr_create                              *
+**************************************************************************
+* DESCRIPTION:  This function initializes the RecoveryMgr module.
+*
+* INPUT:        hOs - handle to Os Abstraction Layer
+*               
+* RETURN:       Handle to the allocated RecoveryMgr module
+*************************************************************************/
+TI_HANDLE recoveryMgr_create(TI_HANDLE hOs)
+{
+#ifdef USE_RECOVERY
+    recoverMgr_t *hRecoveryMgr;
+
+    /* allocate RecoverMgr module */
+    hRecoveryMgr = os_memoryAlloc(hOs, (sizeof(recoverMgr_t)));
+
+    if(!hRecoveryMgr)
+    {
+        WLAN_OS_REPORT(("Error allocating the RecoverMgr Module\n"));
+        return NULL;
+    }
+
+    /* Reset RecoverMgr module */
+    os_memoryZero(hOs, hRecoveryMgr, (sizeof(recoverMgr_t)));
+
+    hRecoveryMgr->hOs = hOs;
+
+    return(hRecoveryMgr);
+#else
+    return NULL;
+#endif /* USE_RECOVERY */
+} /* recoveryMgr_create */
+
+
+
+/***************************************************************************
+*                           recoveryMgr_config                             *
+****************************************************************************
+* DESCRIPTION:  This function configures the recoveryMgr module
+*
+* RETURNS:      OK - Configuration successful
+*               NOK - Configuration unsuccessful
+***************************************************************************/
+TI_STATUS recoveryMgr_config(TI_HANDLE hRecoveryMgr,
+                             TI_HANDLE hReport,
+                             TI_HANDLE hTxData,
+                             TI_HANDLE hTnetwDrv,
+                             TI_HANDLE hScr, 
+                             TI_HANDLE hCurrBss,
+                             TI_HANDLE hPowerMgr,
+                             TI_HANDLE hHealthMonitor,
+                                                        TI_HANDLE hSoftGemini)
+{
+#ifdef USE_RECOVERY
+    recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+
+    /* configure modules handles */
+    pRecoverMgr->hReport = hReport;
+    pRecoverMgr->hTxData = hTxData;
+    pRecoverMgr->hTnetwDrv = hTnetwDrv;
+    pRecoverMgr->hScr = hScr;
+    pRecoverMgr->hCurrBss = hCurrBss;
+    pRecoverMgr->hPowerMgr = hPowerMgr;
+
+    pRecoverMgr->hHealthMonitor = hHealthMonitor;
+       pRecoverMgr->hSoftGemini = hSoftGemini;
+
+    pRecoverMgr->fRecoveryInProcess = FALSE;
+    pRecoverMgr->smState = REC_MGR_STATE_IDLE;
+    
+    WLAN_REPORT_INIT(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
+        (".....RecoveryMgr configured successfully\n"));
+#endif /* USE_RECOVERY */
+    return OK;
+} /* recoveryMgr_config */
+
+/***************************************************************************
+*                           recoveryMgr_destroy                            *
+****************************************************************************
+* DESCRIPTION:  This function unload the RecoverMgr module. It frees
+*               the RecoveryMgr module
+*
+* INPUTS:       hRecoveryMgr - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - Unload succesfull
+*               NOK - Unload unsuccesfull
+***************************************************************************/
+TI_STATUS recoveryMgr_destroy(TI_HANDLE hRecoveryMgr)
+{
+#ifdef USE_RECOVERY
+    recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+
+    /* free RecoverMgr Module */
+    os_memoryFree(pRecoverMgr->hOs, pRecoverMgr, sizeof(recoverMgr_t));
+#endif /* USE_RECOVERY */
+    return OK;
+}
+
+
+/**********************************************************************************************
+ *                  recoveryMgr_SM()
+ **********************************************************************************************
+ * DESCRIPTION:  
+   ============
+    This is the recoveryMgr state machine.
+    The inceptive event for RecoveryMgr SM is invoking the recovery process by HelthMonitor. 
+    After disabling Outside Inputs and starting TWD Restart, RecoveryMgr SM waits end of TWD Restart, 
+    then informs STAD about recovery and enables Outside Inputs. 
+    The SM supports both Sync and Async accesses to the HW.
+    It loops and progresses from state to state as long as the HW is accessed synchronously.
+    Once the access is Asynchronous (TNETWIF_PENDING), it exits and is called later
+      by the TNETWIF when the HW is ready.
+    That's why it uses unspecified-mode accesses (e.g. TNETWIF_ReadMemOpt) which
+      selects either Sync or Async automatically according to the platform and length.
+    Yet, the short transactions (EOB and Interrupt-Request 32 bit writes) are done using Sync 
+      access to simplify the SM 
+    NOTE: MCS projects may require full Sync/Async support, so the Sync accesses may need to be modified. 
+
+    NOTE:  The recoveryMgr-SM detailed description is provided in "CE-2.0 Recovery LLD.doc".
+
+ **********************************************************************************************/
+#ifdef USE_RECOVERY
+static void recoveryMgr_SM(TI_HANDLE hRecoveryMgr)
+{
+    recoverMgr_t        *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+    healthMonitor_t     *pHealthMonitor = (healthMonitor_t *)pRecoverMgr->hHealthMonitor;
+
+#ifdef TI_DBG
+    if (hRecoveryMgr == NULL)
+    {
+        WLAN_REPORT_ERROR(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,  
+                          ("recoveryMgr_SM(): ****  Called with NULL handle!!  ****\n"));
+        return;
+    }
+#endif /* TI_DBG */
+
+    WLAN_REPORT_INFORMATION(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,  
+                            ("recoveryMgr_SM(): smState=%d\n", pRecoverMgr->smState));
+
+    /* 
+     * Loop through the states sequence as long as the process is synchronous.
+     * Exit when finished or if an Asynchronous process is required. In this case
+     *   the SM process will be resumed later (called back by TNETWIF). 
+     */
+    switch (pRecoverMgr->smState)
+    {
+        
+        case REC_MGR_STATE_IDLE:
+            WLAN_REPORT_INFORMATION(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
+                                    (".....REC_MGR_STATE_IDLE\n"));
+
+            healthMonitor_suspendPeriodicTest(pRecoverMgr->hHealthMonitor);
+
+            /* disabling Outside Inputs and starting TWD Restart */
+            pRecoverMgr->fDisableInputsFromOs = TRUE;
+
+            /* suspend TX */
+            txData_stop(pHealthMonitor->hTxData);
+
+            /* Disabling the IRQ line so the recovery will be an atomic action */
+            os_disableIrq (pRecoverMgr->hOs);
+
+            pRecoverMgr->smState = REC_MGR_STATE_WAIT_TWD_RESTART;
+
+            TnetwDrv_StartRecovery(pRecoverMgr->hTnetwDrv, 
+                                   (void*)recoveryMgr_endOfRecovery, 
+                                   hRecoveryMgr);
+
+            return;
+
+        case REC_MGR_STATE_WAIT_TWD_RESTART:
+            WLAN_REPORT_INFORMATION(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
+                        (".....REC_MGR_STATE_WAIT_TWD_RESTART\n"));
+            /* informs STAD about recovery */
+            recoveryMgr_notifyStadAboutRecovery(hRecoveryMgr);
+
+            /* TX resume */
+            txData_startAfterRecovery(pHealthMonitor->hTxData);
+
+            pRecoverMgr->fDisableInputsFromOs = FALSE;
+
+            /* call inside CmdMBox_SetModeNormal */
+            whalCtrl_exitFromInitMode(((healthMonitor_t *)pRecoverMgr->hHealthMonitor)->hHalCtrl);
+
+            /* send the min power level to the FW */
+            MacServices_powerAutho_ExitFromInit(((TnetwDrv_t *)pRecoverMgr->hTnetwDrv)->hMacServices);
+
+                       /* Soft Gemini Section */
+                       SoftGemini_handleRecovery(pRecoverMgr->hSoftGemini);
+
+            WLAN_OS_REPORT((".....recoveryMgr: End Of Recovery\n"));
+
+            healthMonitor_resumePeriodicTest(pRecoverMgr->hHealthMonitor);
+
+            pRecoverMgr->fRecoveryInProcess = FALSE;
+
+            pRecoverMgr->smState = REC_MGR_STATE_IDLE;
+            return; /* recovery process ended */
+
+        default:
+                WLAN_REPORT_ERROR(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,  
+                    ("recoveryMgr_SM(): Unexpected state, smState=%d\n", pRecoverMgr->smState));
+            return;
+
+    }  /* switch (pRecoverMgr->smState) */
+} /* recoveryMgr_SM */
+#endif /* USE_RECOVERY */
+
+/***************************************************************************
+*                           recoveryMgr_recoveryProcess                    *
+****************************************************************************
+* DESCRIPTION:  Main interface that called if the WLAN driver detects error
+*               during the Monitoring process.
+*
+* INPUTS:       hRecoveryMgr - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - Recovery Process started
+*               NOK - Recovery cannot started because it's in process already
+***************************************************************************/
+TI_STATUS recoveryMgr_recoveryProcess(TI_HANDLE hRecoveryMgr)
+{
+#ifdef USE_RECOVERY
+    recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+    healthMonitor_t     *pHealthMonitor = (healthMonitor_t *)pRecoverMgr->hHealthMonitor;
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pHealthMonitor->hHalCtrl;
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+
+    if(!pWlanParams->RecoveryEnable)
+    {
+        WLAN_OS_REPORT(("recoveryMgr_recoveryProcess: Recovery is disabled in tiwlan.ini, abort recovery process\n"));
+        return OK;
+    }
+    else
+        WLAN_OS_REPORT((".....recoveryMgr_recoveryProcess\n"));
+
+    if(pRecoverMgr->fRecoveryInProcess == FALSE)
+    {
+        pHealthMonitor->numOfRecoveryPerformed++;
+        pRecoverMgr->fRecoveryInProcess = TRUE;
+        recoveryMgr_SM(hRecoveryMgr);
+        return OK;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,  
+            ("recoveryProcess(): ****  Recovery in process already!!  ****\n"));
+        return NOK;
+    }
+#else
+    return OK;
+#endif /* USE_RECOVERY */
+} /* recoveryMgr_recoveryProcess */
+
+
+
+
+/***************************************************************************
+*                           recoveryMgr_endOfRecovery                      *
+****************************************************************************
+* DESCRIPTION:  This function is the CB from the RecoveryCtrl that will 
+*               issue the "EndOfTwdRestart" event to the RecoveryMgr SM. 
+*               Indicates that TWD has performed its recovery.
+*
+* INPUTS:       hRecoveryMgr - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - succesfull
+*               NOK - unsuccesfull
+***************************************************************************/
+TI_STATUS recoveryMgr_endOfRecovery(TI_HANDLE hRecoveryMgr)
+{
+#ifdef USE_RECOVERY
+    recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+
+    WLAN_REPORT_INIT(pRecoverMgr->hReport, RECOVERY_MGR_MODULE_LOG,
+        (".....recoveryMgr_endOfRecovery\n"));
+
+    recoveryMgr_SM(hRecoveryMgr);
+#endif /* USE_RECOVERY */
+    return OK;
+} /* recoveryMgr_endOfRecovery */
+
+/***************************************************************************
+*                 recoveryMgr_notifyStadAboutRecovery                      *
+****************************************************************************
+* DESCRIPTION:  Inform STAD that recovery has been performed: inform TX, 
+*               SCR, Current BSS and Power Mgr about FW reset.
+*
+* INPUTS:       hRecoveryMgr - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - succesfull
+*               NOK - unsuccesfull
+***************************************************************************/
+#ifdef USE_RECOVERY
+static TI_STATUS recoveryMgr_notifyStadAboutRecovery(TI_HANDLE hRecoveryMgr)
+{
+    recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+    healthMonitor_t     *pHealthMonitor = (healthMonitor_t *)pRecoverMgr->hHealthMonitor;
+
+    txData_recoveryIndication (pHealthMonitor->hTxData);
+    TnetwDrv_RecoveryCtrlBlk(pHealthMonitor->hTnetwDrv);
+
+    scr_notifyFWReset( pRecoverMgr->hScr );
+    currBSS_performRecovery(pRecoverMgr->hCurrBss);
+    PowerMgr_notifyFWReset(pRecoverMgr->hPowerMgr);
+
+    return OK;
+} /* recoveryMgr_notifyStadAboutRecovery */
+#endif /* USE_RECOVERY */
+/***************************************************************************
+*                           recoveryMgr_recoveryProcess                    *
+****************************************************************************
+* DESCRIPTION:  check if Inputs From OS are Disabled.
+*
+* INPUTS:       hRecoveryMgr - the object
+*
+* OUTPUT:
+*
+* RETURN:       TRUE  - Inputs From OS are Disabled 
+*               FALSE - Inputs From OS are not Disabled
+***************************************************************************/
+BOOL recoveryMgr_areInputsFromOsDisabled(TI_HANDLE hRecoveryMgr)
+{
+#ifdef USE_RECOVERY
+    recoverMgr_t *pRecoverMgr = (recoverMgr_t *)hRecoveryMgr;
+
+    return (pRecoverMgr->fDisableInputsFromOs);
+#else
+    return FALSE;
+#endif /* USE_RECOVERY */
+} /* recoveryMgr_recoveryProcess */
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr.h b/sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr.h
new file mode 100644 (file)
index 0000000..b853f81
--- /dev/null
@@ -0,0 +1,81 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       recoveryMgr.h                                                                                  */
+/*    PURPOSE: RecoveryMgr module Header file                             */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _RECOVERY_MGR_H_
+#define _RECOVERY_MGR_H_
+
+#include "osTIType.h"
+
+/* State-Machine States */
+typedef enum
+{
+       REC_MGR_STATE_IDLE,             /*  */
+       REC_MGR_STATE_WAIT_TWD_RESTART  /*  */
+} recoveryMgrSmState_e;
+
+/* The module object. */
+typedef struct 
+{
+       /* Handles */
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hTxData;
+       TI_HANDLE hRxData;
+       TI_HANDLE hTnetwDrv;
+
+       TI_HANDLE hScr;
+       TI_HANDLE hCurrBss;
+       TI_HANDLE hPowerMgr;
+
+       /* temp hendles start */
+       TI_HANDLE hHealthMonitor;
+       TI_HANDLE hSoftGemini;
+       /* temp hendles end */
+
+       BOOL fRecoveryInProcess;
+       BOOL fDisableInputsFromOs;              /* Disable IOCTLs, Timers and Interrupts */
+       recoveryMgrSmState_e smState;                   /* The current state of the SM. */      
+
+} recoverMgr_t;
+
+
+
+#endif /* _RECOVERY_MGR_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr_API.h b/sta_dk_4_0_4_32/common/src/Management/RecoveryMgr/recoveryMgr_API.h
new file mode 100644 (file)
index 0000000..22af139
--- /dev/null
@@ -0,0 +1,62 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       recoveryMgr.h                                                                                  */
+/*    PURPOSE: RecoveryMgr module Header file                             */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _RECOVERY_MGR_API_H_
+#define _RECOVERY_MGR_API_H_
+
+#include "osTIType.h"
+
+TI_HANDLE recoveryMgr_create(TI_HANDLE hOs);
+TI_STATUS recoveryMgr_config(TI_HANDLE hRecoverMgr, 
+                                                        TI_HANDLE hReport, 
+                                                        TI_HANDLE hTxData, 
+                                                        TI_HANDLE hTnetwDrv,
+                                                        TI_HANDLE hScr, 
+                                                        TI_HANDLE hCurrBss,
+                                                        TI_HANDLE hPowerMgr,
+                                                        TI_HANDLE hHealthMonitor,
+                                                        TI_HANDLE hSoftGemini);
+TI_STATUS recoveryMgr_destroy(TI_HANDLE hRecoverMgr);
+TI_STATUS recoveryMgr_recoveryProcess(TI_HANDLE hRecoverMgr);
+TI_STATUS recoveryMgr_endOfRecovery(TI_HANDLE hRecoverMgr);
+BOOL recoveryMgr_areInputsFromOsDisabled(TI_HANDLE hRecoveryMgr);
+
+#endif /* _RECOVERY_MGR_API_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/SoftGemini/inc/SoftGeminiApi.h b/sta_dk_4_0_4_32/common/src/Management/SoftGemini/inc/SoftGeminiApi.h
new file mode 100644 (file)
index 0000000..9546ac0
--- /dev/null
@@ -0,0 +1,252 @@
+/** \file SoftGeminiApi.h
+ *  \brief BlueTooth-Wlan coexistence module interface header file
+ *
+ *  \see SoftGemini.c & SoftGemini.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       SoftGeminiApi.h                                                                                         */
+/*    PURPOSE: BlueTooth-Wlan coexistence module interface header file         */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __SOFT_GEMINI_API_H__
+#define __SOFT_GEMINI_API_H__
+
+#include "paramOut.h"
+
+
+/************************************************************************
+ *                        SoftGemini_create                                                                    *
+ ************************************************************************
+DESCRIPTION: SoftGemini module creation function, called by the config mgr in creation phase 
+                               performs the following:
+                               -       Allocate the SoftGemini handle
+                                                                                                                                  
+INPUT:      hOs -                      Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the SoftGemini module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE SoftGemini_create(TI_HANDLE hOs);
+
+
+/************************************************************************
+ *                        SoftGemini_config                                            *
+ ************************************************************************
+DESCRIPTION: SoftGemini module configuration function, called by the config mgr in configuration phase
+                               performs the following:
+                               -       Reset & initializes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle
+                       List of handles to be used by the module
+                       pSoftGeminiInitParams   -       Init table of the module.               
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_config(TI_HANDLE  hSoftGemini,
+                                                               TI_HANDLE               hCtrlData,
+                                                               TI_HANDLE               hHalCtrl,
+                                                               TI_HANDLE               hReport,
+                                                               TI_HANDLE               hSCR,
+                                                               TI_HANDLE               hPowerMgr,
+                                                               TI_HANDLE               hConfigMgr,
+                                                               TI_HANDLE               hScanCncn,
+                                                               TI_HANDLE               hCurrBss,
+                                                               TI_HANDLE               hEvHandler,
+                                                               SoftGeminiInitParams_t *pSoftGeminiInitParams);
+
+
+/************************************************************************
+ *                        SoftGemini_destroy                                                   *
+ ************************************************************************
+DESCRIPTION: SoftGemini module destroy function, called by the config mgr in the destroy phase 
+                               performs the following:
+                               -       Free all memory aloocated by the module
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.              
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_destroy(TI_HANDLE hSoftGemini);
+
+
+/***********************************************************************
+ *                        SoftGemini_setParam                                                                  
+ ***********************************************************************
+DESCRIPTION: SoftGemini set param function, called by the following:
+                       -       config mgr in order to set a parameter receiving from the OS abstraction layer.
+                       -       From inside the driver  
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_setParam(TI_HANDLE                hSoftGemini,
+                                                                                       paramInfo_t     *pParam);
+
+/***********************************************************************
+ *                        SoftGemini_getParam                                                                  
+ ***********************************************************************
+DESCRIPTION: SoftGemini get param function, called by the following:
+                       -       config mgr in order to get a parameter from the OS abstraction layer.
+                       -       From inside the dirver  
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+                       
+
+OUTPUT:                pParam  -       Pointer to the parameter                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_getParam(TI_HANDLE                hSoftGemini,
+                                                                                       paramInfo_t     *pParam);
+
+/***********************************************************************
+ *                        SoftGemini_printParams                                                                       
+ ***********************************************************************
+DESCRIPTION: prints soft gemini params
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+                       
+
+OUTPUT:        
+
+RETURN:     
+************************************************************************/
+
+void SoftGemini_printParams(TI_HANDLE hSoftGemini);
+
+/***********************************************************************
+ *                        SoftGeminiReconnect                                                                  
+ ***********************************************************************
+DESCRIPTION: causes driver to disconnect and reconnect to current AP
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+                       
+
+OUTPUT:        
+
+RETURN:     
+************************************************************************/
+
+
+
+/***************************************************************************
+*                                      SoftGemini_SenseIndicationCB                           *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called for sense mode indicaton from FW
+*                              (i.e. we are in SENSE mode and FW detects BT activity 
+*                              SenseModeEnable_Bit - Indicates that FW detected BT activity
+*                              SenseModeDisable_Bit - Indicates that FW doesn't detect BT activity for a period of time
+*
+* INPUTS:              pSoftGemini - the object
+* NOTE                 This function is located in the API for debug purposes
+***************************************************************************/
+void SoftGemini_SenseIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen );
+
+
+/***************************************************************************
+*                                      SoftGemini_ProtectiveIndicationCB                              *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called when FW starts Protective mode (i.e BT voice) 
+*
+*                              ProtectiveModeOn_Bit - FW is activated on protective mode (BT voice is running)
+*                              ProtectiveModeOff_Bit - FW is not activated on protective mode
+*
+* INPUTS:              pSoftGemini - the object
+* NOTE                 This function is located in the API for debug purposes
+***************************************************************************/
+
+void SoftGemini_ProtectiveIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen );
+
+
+/***************************************************************************
+*                                      SoftGemini_AvalancheIndicationCB                               *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called when 
+*                              FW detect that our current connection quality is reducing
+*                              (AP decrease his rates with his rate adaptation mechanism because
+*                              of BT activity) the solution is reconnect to the same AP
+*
+* INPUTS:              pSoftGemini - the object
+* NOTE                 This function is located in the API for debug purposes
+***************************************************************************/
+
+void SoftGemini_AvalancheIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen );
+
+
+/***************************************************************************
+*                                      SoftGemini_getSGMode                           *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called when 
+*                              Recovery was issued -to read the last soft gemini mode
+*
+* INPUTS:              pSoftGemini - the object
+*                      
+***************************************************************************/
+SoftGeminiEnableModes_e SoftGemini_getSGMode(TI_HANDLE hSoftGemini);
+
+TI_STATUS SoftGemini_handleRecovery(TI_HANDLE hSoftGemini);
+
+void SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini);
+
+void SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini);
+
+void SoftGemini_SetPSmode(TI_HANDLE hSoftGemini);
+
+void SoftGemini_unSetPSmode(TI_HANDLE hSoftGemini);
+
+
+#endif /* __SOFT_GEMINI_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/SoftGemini/src/SoftGemini.c b/sta_dk_4_0_4_32/common/src/Management/SoftGemini/src/SoftGemini.c
new file mode 100644 (file)
index 0000000..273a429
--- /dev/null
@@ -0,0 +1,1241 @@
+/** \file softGemini.c
+ *  \brief BlueTooth-Wlan coexistence module interface
+ *
+ *  \see softGemini.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**  
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************************************
+*                                                                                                                                                                                                      *
+*              MODULE:         softGemini.c                                                                                                                                    *
+*              PURPOSE:        BlueTooth-Wlan coexistence module interface.                                                    *
+*                                      This module handles all data base (and Fw setting accordingly)                                  *
+*                                      for Bluetooth-Wlan coexistence implementation.                                                                  *
+*                                                                                                                                                                                                      *
+****************************************************************************************************/
+
+#include "report.h"
+#include "osApi.h"
+#include "SoftGemini.h"
+#include "whalCtrl_api.h"
+#include "DataCtrl_Api.h"
+#include "scrApi.h"
+#include "PowerMgr_API.h"
+#include "srcApi.h"
+#include "ScanCncnApi.h"
+#include "currBss.h"
+#include "bssTypes.h"
+#include "EvHandler.h"
+
+
+#define SENSE_MODE_ENABLE              0x01
+#define SENSE_MODE_DISABLE             0x00
+#define PROTECTIVE_MODE_ON             0x01
+#define PROTECTIVE_MODE_OFF            0x00
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+
+static TI_STATUS SoftGemini_setEnableParam(TI_HANDLE hSoftGemini, SoftGeminiEnableModes_e SoftGeminiEnable, BOOL recovery);
+static TI_STATUS SoftGemini_setRateParam(TI_HANDLE hSoftGemini, UINT8 *pRates);
+static TI_STATUS SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini, SoftGeminiParam_t *SoftGeminiParam);
+static void SoftGemini_setConfigParam(TI_HANDLE hSoftGemini, UINT32 *param);
+static TI_STATUS SoftGemini_EnableDriver(TI_HANDLE hSoftGemini);
+static TI_STATUS SoftGemini_DisableDriver(TI_HANDLE hSoftGemini);
+static void SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini);
+static void SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini);
+static void SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini);
+static void SoftGemini_reconnect(TI_HANDLE hSoftGemini);
+static TI_STATUS SoftGemini_SetPS(SoftGemini_t *pSoftGemini);
+static TI_STATUS SoftGemini_unSetPS(SoftGemini_t       *pSoftGemini);
+
+#ifdef REPORT_LOG
+static char* SoftGemini_ConvertModeToString(SoftGeminiEnableModes_e SoftGeminiEnable);
+#endif
+
+/********************************************************************************/
+/*                                             Interface functions Implementation.                                             */
+/********************************************************************************/
+
+/************************************************************************
+ *                        SoftGemini_SetPSmode                                                                 *
+ ************************************************************************
+DESCRIPTION: SoftGemini module, called by the conn_Infra on connection
+                               performs the following:
+                               -       Enables SG if needed
+                                -       Enables the SG power mode                                                                                                                                 
+INPUT:      hSoftGemini -              Handle to SoftGemini            
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+void SoftGemini_SetPSmode(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+       if (pSoftGemini)
+       {
+               if (pSoftGemini->bDriverEnabled) 
+               {
+                       SoftGemini_SetPS(pSoftGemini);
+               }
+               if (pSoftGemini->bProtectiveMode) 
+               {
+                       SoftGemini_EnableProtectiveMode(hSoftGemini);
+               }
+       }
+       else WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("  SoftGemini_SetPSmode() - Error hSoftGemini= NULL \n"));
+}
+
+/************************************************************************
+ *                        SoftGemini_unSetPSmode                                                                       *
+ ************************************************************************
+DESCRIPTION: SoftGemini module, called by the conn_Infra after disconnecting 
+                               performs the following:
+                               -       Disables the SG
+                                -       Disables the SG power mode                                                                                                                                
+INPUT:      hSoftGemini -              Handle to SoftGemini            
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+void SoftGemini_unSetPSmode(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+    if (pSoftGemini)
+       {
+               if (pSoftGemini->bDriverEnabled) 
+               {
+                       SoftGemini_unSetPS(pSoftGemini);
+               }
+       }
+       else WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  (" SoftGemini_unSetPSmode() - Error hSoftGemini= NULL \n"));
+}
+
+/************************************************************************
+ *                        SoftGemini_create                                                                    *
+ ************************************************************************
+DESCRIPTION: SoftGemini module creation function, called by the config mgr in creation phase 
+                               performs the following:
+                               -       Allocate the SoftGemini handle
+                                                                                                                                  
+INPUT:      hOs -                      Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the SoftGemini module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE SoftGemini_create(TI_HANDLE hOs)
+{
+       SoftGemini_t                    *pSoftGemini = NULL;
+
+       /* allocating the SoftGemini object */
+       pSoftGemini = os_memoryAlloc(hOs,sizeof(SoftGemini_t));
+
+       if (pSoftGemini == NULL)
+               return NULL;                            
+
+       pSoftGemini->hOs = hOs;
+
+       return pSoftGemini;
+}
+
+/************************************************************************
+ *                        SoftGemini_config                                            *
+ ************************************************************************
+DESCRIPTION: SoftGemini module configuration function, called by the config mgr in configuration phase
+                               performs the following:
+                               -       Reset & initializes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle
+                       List of handles to be used by the module
+                       pSoftGeminiInitParams   -       Init table of the module.               
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+TI_STATUS SoftGemini_config(   TI_HANDLE               hSoftGemini,
+                                                               TI_HANDLE               hCtrlData,
+                                                               TI_HANDLE               hHalCtrl,
+                                                               TI_HANDLE               hReport,
+                                                               TI_HANDLE               hSCR,
+                                                               TI_HANDLE               hPowerMgr,
+                                                               TI_HANDLE               hConfigMgr,
+                                                               TI_HANDLE               hScanCncn,
+                                                               TI_HANDLE               hCurrBss,
+                                                               TI_HANDLE               hEvHandler,
+                                                               SoftGeminiInitParams_t *pSoftGeminiInitParams)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       TI_STATUS status;
+
+       /*******************/
+       /* init Handles */
+       /*****************/
+
+       pSoftGemini->hCtrlData  = hCtrlData;
+       pSoftGemini->hHalCtrl   = hHalCtrl;
+       pSoftGemini->hReport    = hReport;
+       pSoftGemini->hSCR       = hSCR;
+       pSoftGemini->hPowerMgr  = hPowerMgr;
+       pSoftGemini->hConfigMgr = hConfigMgr;
+       pSoftGemini->hScanCncn  = hScanCncn;
+       pSoftGemini->hCurrBss   = hCurrBss;
+       pSoftGemini->hEvHandler= hEvHandler;
+
+       /*************************************/
+       /* Getting SoftGemini init Params */
+       /***********************************/
+
+       SoftGemini_setRateParam(hSoftGemini,pSoftGeminiInitParams->SoftGeminiRate);
+       
+       /* read parameters for scan but no need to use them yet, only used when we enable/disable driver */
+       pSoftGemini->scanNumOfProbeRequest   = pSoftGeminiInitParams->scanNumOfProbeRequest;
+       pSoftGemini->scanCompensationPercent = pSoftGeminiInitParams->scanCompensationPercent;
+       pSoftGemini->scanCompensationMaxTime = pSoftGeminiInitParams->scanCompensationMaxTime;
+       pSoftGemini->BSSLossCompensationPercent = pSoftGeminiInitParams->BSSLossCompensationPercent;
+
+       os_memoryCopy(hSoftGemini,&pSoftGemini->SoftGeminiParam,&pSoftGeminiInitParams->SoftGeminiParam,sizeof(SoftGeminiParam_t));
+       /* Send the configuration to the FW */
+       status = SoftGemini_setParamsToFW(hSoftGemini, &pSoftGemini->SoftGeminiParam);
+
+       /*******************************/
+    /* register Indication interrupts  */
+       /*****************************/
+
+    whalCtrl_EventMbox_RegisterForEvent( pSoftGemini->hHalCtrl, 
+                                         HAL_EVENT_SOFT_GEMINI_SENSE,
+                                         (void *)SoftGemini_SenseIndicationCB, 
+                                         hSoftGemini );
+       whalCtrl_EventMbox_RegisterForEvent( pSoftGemini->hHalCtrl, 
+                                         HAL_EVENT_SOFT_GEMINI_PREDICTION,
+                                         (void *)SoftGemini_ProtectiveIndicationCB, 
+                                         hSoftGemini );
+
+       whalCtrl_EventMbox_RegisterForEvent( pSoftGemini->hHalCtrl, 
+                                         HAL_EVENT_SOFT_GEMINI_AVALANCHE,
+                                         (void *)SoftGemini_AvalancheIndicationCB, 
+                                         hSoftGemini );
+
+    whalCtrl_EventMbox_Enable( pSoftGemini->hHalCtrl, HAL_EVENT_SOFT_GEMINI_SENSE );
+
+       whalCtrl_EventMbox_Enable( pSoftGemini->hHalCtrl, HAL_EVENT_SOFT_GEMINI_PREDICTION );
+
+       whalCtrl_EventMbox_Enable( pSoftGemini->hHalCtrl, HAL_EVENT_SOFT_GEMINI_AVALANCHE );
+
+       /* On system initialization SG is disabled but later calls to SoftGemini_setEnableParam() */
+       pSoftGemini->bProtectiveMode = FALSE;   
+       pSoftGemini->SoftGeminiEnable = SG_DISABLE; 
+       pSoftGemini->bDriverEnabled = FALSE;
+    pSoftGemini->bPsPollFailureActive = FALSE;
+
+       if ((OK == status) && (pSoftGeminiInitParams->SoftGeminiEnable != SG_DISABLE))
+       {       /* called only if different than SG_DISABLE */
+               status = SoftGemini_setEnableParam(hSoftGemini, pSoftGeminiInitParams->SoftGeminiEnable, FALSE);
+       }
+
+       if (status == OK)
+       {
+               WLAN_REPORT_INIT(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("  SoftGemini_config() - configured successfully\n"));
+       }
+       else
+       {
+               WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("  SoftGemini_config() - Error configuring module \n"));
+       }
+
+       return status;
+}
+
+/************************************************************************
+ *                        SoftGemini_destroy                                                   *
+ ************************************************************************
+DESCRIPTION: SoftGemini module destroy function, called by the config mgr in the destroy phase 
+                               performs the following:
+                               -       Free all memory aloocated by the module
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.              
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_destroy(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+       if (pSoftGemini != NULL)
+       {
+               os_memoryFree( pSoftGemini->hOs, (TI_HANDLE)pSoftGemini , sizeof(SoftGemini_t));
+       }
+       
+       return OK;
+}
+
+
+/***********************************************************************
+ *                        SoftGemini_setParam                                                                  
+ ***********************************************************************
+DESCRIPTION: SoftGemini set param function, called by the following:
+                       -       config mgr in order to set a parameter receiving from the OS abstraction layer.
+                       -       From inside the driver  
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_setParam(TI_HANDLE        hSoftGemini,
+                                                                                       paramInfo_t     *pParam)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       TI_STATUS return_value = OK;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  SoftGemini_setParam() (0x%x)\n", pParam->paramType));
+       
+       switch(pParam->paramType)
+       {
+
+       case SOFT_GEMINI_SET_ENABLE:
+               
+               return_value = SoftGemini_setEnableParam(hSoftGemini,pParam->content.SoftGeminiEnable, FALSE);
+               break;
+
+       case SOFT_GEMINI_SET_RATE:
+               
+               return_value = SoftGemini_setRateParam(hSoftGemini, pParam->content.SoftGeminiRate);
+               break;
+               
+       case SOFT_GEMINI_SET_CONFIG:
+
+               /* copy new params to SoftGemini module */
+               SoftGemini_setConfigParam(hSoftGemini,pParam->content.SoftGeminiParamArray);
+       
+               /* set new params to FW */
+               return_value = SoftGemini_setParamsToFW(hSoftGemini, &(pSoftGemini->SoftGeminiParam));
+               break;
+               
+       default:
+               WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  SoftGemini_setParam(), Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return return_value;
+}
+
+/***********************************************************************
+ *                           SoftGemini_getParam                                                                       
+ ***********************************************************************
+DESCRIPTION: SoftGemini get param function, called by the following:
+                       -       config mgr in order to get a parameter from the OS abstraction layer.
+                       -       From inside the dirver  
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+                               
+
+OUTPUT:                pParam  -       Pointer to the parameter        
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS SoftGemini_getParam(TI_HANDLE                hSoftGemini,
+                                                                                       paramInfo_t     *pParam)
+{ 
+       SoftGemini_printParams(hSoftGemini);
+       
+       return OK;
+}
+
+
+/***************************************************************************
+*                                      SoftGemini_setEnableParam                                                      *
+****************************************************************************
+* DESCRIPTION: The function sets the  appropriate Enable value,
+*                              configures SCR , POWER MGR , DATA CTRL , FW.   
+*
+* INPUTS:              pSoftGemini - the object                
+***************************************************************************/
+static TI_STATUS SoftGemini_setEnableParam(TI_HANDLE hSoftGemini, SoftGeminiEnableModes_e SoftGeminiEnable, BOOL recovery)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       whalParamInfo_t param;
+       TI_STATUS return_value = OK;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  setSoftGeminiEnableParam() - Old value = %s, New value = %s\n",
+               SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable),SoftGemini_ConvertModeToString(SoftGeminiEnable)));
+
+
+    /*
+     * PsPoll work around is active. Just save the value and configure it later
+     */
+    if ( pSoftGemini->bPsPollFailureActive )
+    {
+        WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, 
+            ("  setSoftGeminiEnableParam() - while PsPollFailure is active\n"));
+
+        pSoftGemini->PsPollFailureLastEnableValue = SoftGeminiEnable;
+        return OK;
+    }
+
+       /**********************************/
+       /* Sanity check on enable values */
+       /********************************/
+
+       /*                              Old Value                                               New Value                   */        
+       /*                                      |                                                           |                       */        
+       /*                                 \|/                                                     \|/                      */        
+
+       if ((pSoftGemini->SoftGeminiEnable == SoftGeminiEnable) && !recovery)
+       {
+               WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("  %s - setting same value \n",__FUNCTION__));
+               return NOK;
+       }
+
+    
+       /*******************************/
+       /* Make the necessary actions */
+       /*****************************/
+       
+       switch (SoftGeminiEnable)
+       {
+       case SG_ENABLE:
+               
+               if (!pSoftGemini->bDriverEnabled)
+               {       
+                       SoftGemini_EnableDriver(hSoftGemini);
+               }
+               /* set FW with SG_ENABLE */ 
+               param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
+               param.content.SoftGeminiEnable = SG_ENABLE;
+               return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
+
+               /* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
+               pSoftGemini->btCoexStatus.state = TRUE;
+
+               break;
+
+       case SG_DISABLE:
+               
+               /* set FW with SG_DISABLE */
+               param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
+               param.content.SoftGeminiEnable = SG_DISABLE;
+               return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
+
+               if (pSoftGemini->bDriverEnabled)
+               {       
+                       SoftGemini_DisableDriver(hSoftGemini);
+               }
+               
+               /* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
+               pSoftGemini->btCoexStatus.state = FALSE;
+               
+               break;
+
+       case SG_SENSE_NO_ACTIVITY:
+
+               /* set FW with SG_SENSE_NO_ACTIVITY */
+               param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
+               param.content.SoftGeminiEnable = SG_SENSE_NO_ACTIVITY;
+               return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
+
+               if (pSoftGemini->bDriverEnabled)
+               {       
+                       SoftGemini_DisableDriver(hSoftGemini);
+               }
+
+               /* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
+               pSoftGemini->btCoexStatus.state = FALSE;
+               
+               break;
+
+       case SG_SENSE_ACTIVE:
+                               
+               if (!pSoftGemini->bDriverEnabled)
+               {       
+                       SoftGemini_EnableDriver(hSoftGemini); 
+               }
+               /* set FW with SG_SENSE_ACTIVE */ 
+               param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
+               param.content.SoftGeminiEnable = SG_SENSE_ACTIVE;
+               return_value = whalCtrl_SetParam(pSoftGemini->hHalCtrl, &param);
+       
+               /* Set SG status for the IPC_EVENT_BT_COEX_MODE event */
+               pSoftGemini->btCoexStatus.state = TRUE;
+       
+               break;
+
+       default:
+               WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s defualt :%d\n",__FUNCTION__,SoftGeminiEnable)); 
+               return NOK;
+/*             break; - unreachable*/
+       }
+
+       /* Pass to the new enable state */
+       pSoftGemini->SoftGeminiEnable = SoftGeminiEnable;
+
+       if (OK != return_value)
+       {
+               WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, 
+                       ("%s can't configure enable param to FW :%s\n",__FUNCTION__,SoftGemini_ConvertModeToString(SoftGeminiEnable))); 
+       }
+       else
+       {
+               EvHandlerSendEvent(pSoftGemini->hEvHandler, IPC_EVENT_BT_COEX_MODE, (UINT8*)&pSoftGemini->btCoexStatus, sizeof(btCoexStatus_t));
+       }
+       
+       return return_value;
+}
+
+/***************************************************************************
+*                                      SoftGemini_setConfigParam                                              *
+****************************************************************************
+* DESCRIPTION: The function sets params 
+*
+* INPUTS:              pSoftGemini - the object
+*                              param       - params to be configured   
+***************************************************************************/
+static void SoftGemini_setConfigParam(TI_HANDLE hSoftGemini, UINT32 *param)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       UINT32 i = 0;
+
+       pSoftGemini->SoftGeminiParam.wlanRxMinRateToRespectBtHp         = (UINT32)param[i++];
+       pSoftGemini->SoftGeminiParam.btHpMaxTime                                        = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.wlanHpMaxTime                                      = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.senseDisableTimer                          = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.protectiveRxTimeBeforeBtHp         = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.protectiveTxTimeBeforeBtHp         = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.protectiveRxTimeBeforeBtHpFastAp = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.protectiveTxTimeBeforeBtHpFastAp = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.protectiveWlanCycleTimeForFastAp = (UINT16)param[i++];
+    pSoftGemini->SoftGeminiParam.btAntiStarvationPeriod                          = (UINT16)param[i++];
+    pSoftGemini->SoftGeminiParam.timeoutNextBtLpPacket            = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.wakeUpTimeBeforeBeacon           = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.hpdmMaxGuardTime                            = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.timeoutNextWlanPacket           = (UINT16)param[i++];
+       pSoftGemini->SoftGeminiParam.sgAntennaType                                      = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.signalingType                                      = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.afhLeverageOn                                      = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.numberQuietCycle                           = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.maxNumCts                                          = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.numberOfWlanPackets                        = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.numberOfBtPackets                          = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.numberOfMissedRxForAvalancheTrigger = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.wlanElpHpSupport                           = (UINT8)param[i++];
+       pSoftGemini->SoftGeminiParam.btAntiStarvationNumberOfCyclesWithinThePeriod  = (UINT8)param[i++];
+    pSoftGemini->SoftGeminiParam.ackModeDuringBtLpInDualAnt     = (UINT8)param[i++];
+    pSoftGemini->SoftGeminiParam.allowPaSdToggleDuringBtActivityEnable = (UINT8)param[i++];
+       /* 
+        * Check if SG is Active and sgAutoModeNoCts was changed on the fly.
+        *  If so - update powerMgr.
+        */
+       pSoftGemini->SoftGeminiParam.sgAutoModeNoCts = (UINT8)param[i++];
+
+    if ( pSoftGemini->SoftGeminiEnable == SG_SENSE_ACTIVE || pSoftGemini->SoftGeminiEnable == SG_ENABLE )
+       {
+        if (pSoftGemini->SoftGeminiParam.sgAutoModeNoCts)
+               {
+                       /* Exit "Always PS" mode */
+                       SoftGemini_unSetPS(pSoftGemini);
+               } 
+               else /* Normal behavior - enter PS */
+               {
+                       SoftGemini_SetPS(pSoftGemini);
+               }
+       }
+
+       pSoftGemini->SoftGeminiParam.numOfBtHpRespectedReq = (UINT8)param[i++];
+
+}
+
+/***************************************************************************
+*                                      setSoftGeminiRateParam                                                 *
+****************************************************************************
+* DESCRIPTION: The function sets the Ctrl Data with the appropriate Rate value  
+*
+* INPUTS:              pSoftGemini - the object                
+***************************************************************************/
+static TI_STATUS SoftGemini_setRateParam(TI_HANDLE hSoftGemini, UINT8 *pRates)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       int i;
+       UINT32 supportedRates = 0;
+       paramInfo_t param;
+       rateMask_e supportedRatesArray[NUM_OF_RATES_IN_SG] = 
+       {DRV_RATE_MASK_1_BARKER,DRV_RATE_MASK_2_BARKER,DRV_RATE_MASK_5_5_CCK,DRV_RATE_MASK_6_OFDM,
+       DRV_RATE_MASK_9_OFDM,DRV_RATE_MASK_11_CCK,DRV_RATE_MASK_12_OFDM,DRV_RATE_MASK_18_OFDM,
+       DRV_RATE_MASK_22_PBCC,DRV_RATE_MASK_24_OFDM,DRV_RATE_MASK_36_OFDM,DRV_RATE_MASK_48_OFDM,DRV_RATE_MASK_54_OFDM};
+       
+       /* loop on all rates and mark the corresponding bit if the rate is enabled */ 
+       for (i = 0 ; i < NUM_OF_RATES_IN_SG ; i++) 
+       {
+               WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  
+                       (" %s rate %u = %u \n", __FUNCTION__, i,pRates[i])); 
+               pSoftGemini->SoftGeminiRate[i] = pRates[i];
+               
+               if (pRates[i] > 0)
+               {
+                       /* Store the minTxRate */
+                       if (!supportedRates)
+                       {
+                               pSoftGemini->btCoexStatus.minTxRate = (UINT8)supportedRatesArray[i];
+                       }
+                       
+                       supportedRates |= supportedRatesArray[i]; 
+               }       
+       }
+       
+       if ((supportedRates & DRV_RATE_MASK_1_BARKER) || (supportedRates & DRV_RATE_MASK_2_BARKER)) 
+       {
+               WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  
+                       (" %s Using rates 1 or 2 in Soft Gemini is not recommended !!!\n", __FUNCTION__)); 
+       }
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  
+               (" %s rateMask = 0x%x \n", __FUNCTION__,supportedRates)); 
+
+       param.paramType = CTRL_DATA_NEXT_RATE_MASK_FOR_CLIENT;
+       param.content.ctrlDataRateClassMask.clientID = SG_RATE_CLASS;
+       param.content.ctrlDataRateClassMask.clientRateMask = supportedRates;
+       ctrlData_setParam(pSoftGemini->hCtrlData,&param);
+
+       return OK;
+}
+
+/***************************************************************************
+*                                      SoftGemini_printParams                                                 *
+****************************************************************************
+* DESCRIPTION: Print SG Parameters.  
+*
+* INPUTS:              pSoftGemini - the object        
+***************************************************************************/
+void SoftGemini_printParams(TI_HANDLE hSoftGemini)
+{
+#ifdef REPORT_LOG
+
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       SoftGeminiParam_t *SoftGeminiParam = &pSoftGemini->SoftGeminiParam;
+       int i;
+
+       WLAN_OS_REPORT(("Rates starting from 1 to 54: \n")); 
+
+       for (i = 0 ; i < NUM_OF_RATES_IN_SG ; i++) 
+       {
+               WLAN_OS_REPORT((" rate[%u] = %u \n", i,pSoftGemini->SoftGeminiRate[i])); 
+       }
+
+       WLAN_OS_REPORT(("  wlanRxMinRateToRespectBtHp = %d\n", SoftGeminiParam->wlanRxMinRateToRespectBtHp)); 
+       WLAN_OS_REPORT(("  btHpMaxTime = %d\n", SoftGeminiParam->btHpMaxTime)); 
+       WLAN_OS_REPORT(("  wlanHpMaxTime = %d\n", SoftGeminiParam->wlanHpMaxTime)); 
+       WLAN_OS_REPORT(("  senseDisableTimer = %d\n", SoftGeminiParam->senseDisableTimer)); 
+       WLAN_OS_REPORT(("  protectiveRxTimeBeforeBtHp = %d\n", SoftGeminiParam->protectiveRxTimeBeforeBtHp)); 
+       WLAN_OS_REPORT(("  protectiveTxTimeBeforeBtHp = %d\n", SoftGeminiParam->protectiveTxTimeBeforeBtHp)); 
+       WLAN_OS_REPORT(("  protectiveRxTimeBeforeBtHpFastAp = %d\n", SoftGeminiParam->protectiveRxTimeBeforeBtHpFastAp)); 
+       WLAN_OS_REPORT(("  protectiveTxTimeBeforeBtHpFastAp = %d\n", SoftGeminiParam->protectiveTxTimeBeforeBtHpFastAp)); 
+       WLAN_OS_REPORT(("  protectiveWlanCycleTimeForFastAp = %d\n", SoftGeminiParam->protectiveWlanCycleTimeForFastAp)); 
+    WLAN_OS_REPORT(("  btAntiStarvationPeriod  = %d\n", SoftGeminiParam->btAntiStarvationPeriod)); 
+       WLAN_OS_REPORT(("  timeoutNextBtLpPacket = %d\n", SoftGeminiParam->timeoutNextBtLpPacket)); 
+    WLAN_OS_REPORT(("  wakeUpTimeBeforeBeacon = %d\n", SoftGeminiParam->wakeUpTimeBeforeBeacon)); 
+       WLAN_OS_REPORT(("  hpdmMaxGuardTime = %d\n", SoftGeminiParam->hpdmMaxGuardTime)); 
+       WLAN_OS_REPORT(("  timeoutNextWlanPacket = %d\n", SoftGeminiParam->timeoutNextWlanPacket)); 
+    WLAN_OS_REPORT(("  sgAntennaType = %d\n", SoftGeminiParam->sgAntennaType)); 
+    WLAN_OS_REPORT(("  signalingType = %d\n", SoftGeminiParam->signalingType)); 
+       WLAN_OS_REPORT(("  afhLeverageOn = %d\n", SoftGeminiParam->afhLeverageOn)); 
+    WLAN_OS_REPORT(("  numberQuietCycle = %d\n", SoftGeminiParam->numberQuietCycle)); 
+       WLAN_OS_REPORT(("  maxNumCts = %d\n", SoftGeminiParam->maxNumCts)); 
+       WLAN_OS_REPORT(("  numberOfWlanPackets = %d\n", SoftGeminiParam->numberOfWlanPackets)); 
+       WLAN_OS_REPORT(("  numberOfBtPackets = %d\n", SoftGeminiParam->numberOfBtPackets));     
+       WLAN_OS_REPORT(("  numberOfMissedRxForAvalancheTrigger = %d\n", SoftGeminiParam->numberOfMissedRxForAvalancheTrigger)); 
+       WLAN_OS_REPORT(("  wlanElpHpSupport = %d\n", SoftGeminiParam->wlanElpHpSupport)); 
+       WLAN_OS_REPORT(("  btAntiStarvationNumberOfCyclesWithinThePeriod = %d\n", SoftGeminiParam->btAntiStarvationNumberOfCyclesWithinThePeriod)); 
+    WLAN_OS_REPORT(("  ackModeDuringBtLpInDualAnt = %d\n", SoftGeminiParam->ackModeDuringBtLpInDualAnt)); 
+    WLAN_OS_REPORT(("  allowPaSdToggleDuringBtActivityEnable = %d\n", SoftGeminiParam->allowPaSdToggleDuringBtActivityEnable)); 
+       WLAN_OS_REPORT(("  sgAutoModeNoCts = %d\n", SoftGeminiParam->sgAutoModeNoCts)); 
+       WLAN_OS_REPORT(("  numOfBtHpRespectedReq = %d\n\n", SoftGeminiParam->numOfBtHpRespectedReq)); 
+
+       WLAN_OS_REPORT(("  Enable mode : %s\n", SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable))); 
+       WLAN_OS_REPORT(("  Driver Enabled : %s\n",(pSoftGemini->bDriverEnabled ? "YES" : "NO"))); 
+       WLAN_OS_REPORT(("  Protective mode : %s\n", (pSoftGemini->bProtectiveMode ? "ON" : "OFF"))); 
+    WLAN_OS_REPORT(("  PsPoll failure active : %s\n", (pSoftGemini->bPsPollFailureActive ? "YES" : "NO"))); 
+
+#endif
+}
+
+/***********************************************************************
+ *                        SoftGemini_reconnect                                                                 
+ ***********************************************************************
+DESCRIPTION: causes driver to disconnect and reconnect to current AP
+                                                                                                   
+INPUT:      hSoftGemini        -       SoftGemini handle.
+
+************************************************************************/
+
+void SoftGemini_reconnect(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       paramInfo_t     ssidParam;
+       paramInfo_t     param;
+       TI_STATUS       status;
+
+       /* Get current SSID; if we are not connected, there is nothing to do, return */
+       ssidParam.paramType = SITE_MGR_CURRENT_SSID_PARAM;
+       status =  configMgr_getParam(pSoftGemini->hConfigMgr, &ssidParam);
+       if (status != OK)
+       {
+               return;
+       }
+
+       /* Take care of scan enabled SME parameter: if is set to TRUE, set it to SKIP_ONCE */
+       param.paramType = SME_SCAN_ENABLED_PARAM;
+       configMgr_getParam(pSoftGemini->hConfigMgr, &param);
+
+       if (param.content.smeSMScanEnabled == SCAN_ENABLED) 
+       {
+               param.content.smeSMScanEnabled = SKIP_NEXT_SCAN;
+               configMgr_setParam(pSoftGemini->hConfigMgr, &param);
+       }
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s - reconnecting !!!\n",__FUNCTION__)); 
+
+       /* Re-set desired SSID */
+       ssidParam.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+       configMgr_setParam(pSoftGemini->hConfigMgr, &ssidParam);
+}
+
+/***************************************************************************
+*                                      SoftGemini_setParamsToFW                                                       *
+****************************************************************************
+* DESCRIPTION: The function sets the FW with the appropriate parameters set.  
+*
+* INPUTS:              pSoftGemini - the object
+*
+*
+* OUTPUT:                      
+* 
+* RETURNS:             
+***************************************************************************/
+static TI_STATUS SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini, SoftGeminiParam_t *SoftGeminiParam)
+{
+       SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       whalParamInfo_t whalParam;
+       
+       os_memoryCopy(pSoftGemini->hOs,&whalParam.content.SoftGeminiParam, SoftGeminiParam, sizeof(SoftGeminiParam_t));
+       whalParam.paramType = HAL_CTRL_SG_CONFIG_PARAM;
+       return whalCtrl_SetParam(pSoftGemini->hHalCtrl,&whalParam);
+}
+
+
+/***************************************************************************
+*                                      SoftGemini_EnableDriver                                *
+****************************************************************************
+* DESCRIPTION: Activated when SG is enabled (after CLI or FW command)
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+static TI_STATUS SoftGemini_EnableDriver(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       TI_STATUS return_value = OK;
+       paramInfo_t param;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__)); 
+
+       pSoftGemini->bDriverEnabled = TRUE;
+       
+       /* Set Always PS only if sgAutoModeNoCts is FALSE, i.e. normal operation */
+       if ( !pSoftGemini->SoftGeminiParam.sgAutoModeNoCts )
+       {
+               SoftGemini_SetPS(pSoftGemini);
+       }
+
+       /* set ctrlData to use SG rates */
+       param.paramType = CTRL_DATA_CURRENT_RATE_CLASS_CLIENT;
+       param.content.ctrlDataRateClassID = SG_RATE_CLASS;
+       ctrlData_setParam(pSoftGemini->hCtrlData,&param);
+
+       scr_setMode(pSoftGemini->hSCR, SCR_MID_SG);
+
+       return return_value;
+}
+
+/***************************************************************************
+*                                      SoftGemini_DisableDriver                               *
+****************************************************************************
+* DESCRIPTION: Activated when SG is disabled (after CLI or FW command)
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+static TI_STATUS SoftGemini_DisableDriver(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       TI_STATUS return_value = OK;
+       paramInfo_t param;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__)); 
+
+       pSoftGemini->bDriverEnabled = FALSE;
+
+       /* set ctrlData to use default rates */
+       param.paramType = CTRL_DATA_CURRENT_RATE_CLASS_CLIENT;
+       param.content.ctrlDataRateClassID = USER_RATE_CLASS;
+       ctrlData_setParam(pSoftGemini->hCtrlData,&param);
+
+       scr_setMode(pSoftGemini->hSCR, SCR_MID_NORMAL);
+       
+       /* unSet Always PS only if sgAutoModeNoCts is FALSE, i.e. normal operation */
+       if ( !pSoftGemini->SoftGeminiParam.sgAutoModeNoCts )
+       {
+               SoftGemini_unSetPS(pSoftGemini);
+       }
+
+       /* Undo the changes that were made when Protective mode was on */
+       if (pSoftGemini->bProtectiveMode)
+       {
+               SoftGemini_DisableProtectiveMode(hSoftGemini);
+       }
+       
+       return return_value;
+       
+}
+
+/***************************************************************************
+*                                      SoftGemini_SetPS                                                                   *
+****************************************************************************
+* DESCRIPTION: Set Always PS to PowerMgr
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+static TI_STATUS SoftGemini_SetPS(SoftGemini_t *pSoftGemini)
+{
+       paramInfo_t param;
+       bssEntry_t *pBssInfo=NULL;
+
+    if (pSoftGemini->hCurrBss)
+       {
+               pBssInfo = currBSS_getBssInfo(pSoftGemini->hCurrBss);
+       }
+       else WLAN_REPORT_ERROR(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("SoftGemini_SetPS: hCurrBss = NULL!!!\n")); 
+
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__)); 
+
+       if (pBssInfo)
+       {
+               if ((pBssInfo->band == RADIO_BAND_2_4_GHZ) && (!pSoftGemini->SoftGeminiParam.sgAutoModeNoCts))
+               {
+                       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, (" SG-setPS: band == RADIO_BAND_2_4_GHZ")); 
+               
+                       /* Set Params to Power Mgr for SG priority */
+                       param.paramType = POWER_MGR_POWER_MODE;
+                       param.content.powerMngPowerMode.PowerMode = POWER_MODE_PS_ONLY;
+                       param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
+                       powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
+               
+                       /* enable SG priority for Power Mgr */
+                       param.paramType = POWER_MGR_ENABLE_PRIORITY;
+                       param.content.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
+                       return powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
+               }
+               else WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, (" SG-setPS: band == RADIO_BAND_5_GHZ")); 
+       }
+       return OK;
+}
+
+/***************************************************************************
+*                                      SoftGemini_unSetPS                                                                 *
+****************************************************************************
+* DESCRIPTION: unSet Always PS to PowerMgr
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+static TI_STATUS SoftGemini_unSetPS(SoftGemini_t       *pSoftGemini)
+{
+       paramInfo_t param;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s, SG-unSetPS \n",__FUNCTION__)); 
+
+     /* disable SG priority for Power Mgr*/
+       param.paramType = POWER_MGR_DISABLE_PRIORITY;
+       param.content.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
+       return powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
+       
+}
+
+/***************************************************************************
+*                                      SoftGemini_EnableProtectiveMode                                *
+****************************************************************************
+* DESCRIPTION: Activated when FW inform us that protective mode is ON
+*                              
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+void SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       paramInfo_t     param;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__)); 
+
+       pSoftGemini->bProtectiveMode = TRUE;
+
+       /* set new configurations of SG roaming parameters */
+       currBSS_SGconfigureBSSLoss(pSoftGemini->hCurrBss,pSoftGemini->BSSLossCompensationPercent,TRUE);
+
+       /* set new configurations of scan to scancncn */
+       scanConcentrator_SGconfigureScanParams(pSoftGemini->hScanCncn,TRUE,pSoftGemini->scanNumOfProbeRequest,
+               pSoftGemini->scanCompensationMaxTime,pSoftGemini->scanCompensationPercent);
+
+    /* Call the power manager to enter short doze */
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, (" SoftGemini_EnableProtectiveMode set SD")); 
+
+       /* Set Params to Power Mgr for SG priority */
+       param.paramType = POWER_MGR_POWER_MODE;
+       param.content.powerMngPowerMode.PowerMode = POWER_MODE_SHORT_DOZE;
+       param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
+       powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
+}
+
+/***************************************************************************
+*                                      SoftGemini_DisableProtectiveMode                               *
+****************************************************************************
+* DESCRIPTION: Activated when FW inform us that protective mode is OFF or SG is disabled
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+void SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__)); 
+
+       pSoftGemini->bProtectiveMode = FALSE;
+
+       SoftGemini_RemoveProtectiveModeParameters(hSoftGemini);
+}
+
+/***************************************************************************
+*                                      SoftGemini_DisableProtectiveMode                               *
+****************************************************************************
+* DESCRIPTION: Called from SoftGemini_DisableProtectiveMode() when FW inform 
+*                              us that protective mode is OFF or SG is disabled, or from
+*                              SoftGemini_unSetPSmode() when driver disconnects from AP.
+*
+* INPUTS:              pSoftGemini - the object
+*      
+***************************************************************************/
+
+void SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       paramInfo_t     param;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s\n",__FUNCTION__)); 
+    
+       /* don't use the SG roaming parameters */
+       currBSS_SGconfigureBSSLoss(pSoftGemini->hCurrBss,0,FALSE);
+
+       /* don't use the SG scan parameters */
+       scanConcentrator_SGconfigureScanParams(pSoftGemini->hScanCncn,FALSE,0,0,0);
+
+    /* Call the power manager to exit short doze */
+       /* Set Params to Power Mgr for SG priority */
+       param.paramType = POWER_MGR_POWER_MODE;
+       param.content.powerMngPowerMode.PowerMode = POWER_MODE_PS_ONLY;
+       param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
+       powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
+}
+
+/***************************************************************************
+*                                      SoftGemini_SenseIndicationCB                           *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called for sense mode indication from FW
+*                              (i.e. we are in SENSE mode and FW detects BT activity )
+*                              SENSE_MODE_ENABLE - Indicates that FW detected BT activity
+*                              SENSE_MODE_DISABLE - Indicates that FW doesn't detect BT activity for a period of time
+*
+* INPUTS:              pSoftGemini - the object
+* NOTE                 This function is located in the API for debug purposes
+***************************************************************************/
+
+void SoftGemini_SenseIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen )
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s with 0x%x\n",__FUNCTION__,*str)); 
+
+       if ((SG_SENSE_NO_ACTIVITY == pSoftGemini->SoftGeminiEnable) && (SENSE_MODE_ENABLE == *str))
+       {
+               SoftGemini_setEnableParam(hSoftGemini, SG_SENSE_ACTIVE, FALSE);
+       }
+       else if ((SG_SENSE_ACTIVE == pSoftGemini->SoftGeminiEnable) && (SENSE_MODE_DISABLE == *str))
+       {
+               SoftGemini_setEnableParam(hSoftGemini, SG_SENSE_NO_ACTIVITY, FALSE);
+       }
+       else
+       {
+                       WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s : %s called when SG mode is %s ? \n",
+                               __FUNCTION__,SoftGemini_ConvertModeToString(((SENSE_MODE_ENABLE == *str) ? SG_SENSE_ACTIVE : SG_SENSE_NO_ACTIVITY))
+                               ,SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable))); 
+       }
+}
+
+/***************************************************************************
+*                                      SoftGemini_ProtectiveIndicationCB                              *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called when FW starts Protective mode (i.e BT voice) 
+*
+*                              PROTECTIVE_MODE_ON - FW is activated on protective mode (BT voice is running)
+*                              PROTECTIVE_MODE_OFF - FW is not activated on protective mode
+*
+* INPUTS:              pSoftGemini - the object
+* NOTE                 This function is located in the API for debug purposes
+***************************************************************************/
+
+void SoftGemini_ProtectiveIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen )
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s with 0x%x\n",__FUNCTION__,*str)); 
+
+       if ((SG_ENABLE == pSoftGemini->SoftGeminiEnable) ||
+               (SG_SENSE_ACTIVE == pSoftGemini->SoftGeminiEnable))
+       {
+               if ((!pSoftGemini->bProtectiveMode) && (PROTECTIVE_MODE_ON == *str))
+               {
+                       SoftGemini_EnableProtectiveMode(hSoftGemini);
+               }
+               else if ((pSoftGemini->bProtectiveMode) && (PROTECTIVE_MODE_OFF == *str))
+               {
+                       SoftGemini_DisableProtectiveMode(hSoftGemini);
+               }
+               else
+               {
+                       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s : Protective mode %s called when Protective mode is %s \n",
+                       __FUNCTION__,((PROTECTIVE_MODE_ON == *str) ? "ON" : "OFF"),((pSoftGemini->bProtectiveMode) ? "ON" : "OFF"))); 
+               }
+       }
+       else
+       {
+               WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s : Protective mode %s called when SG mode is %s ? \n",
+                       __FUNCTION__,((PROTECTIVE_MODE_ON == *str) ? "ON" : "OFF"),SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable))); 
+       }
+}
+
+/***************************************************************************
+*                                      SoftGemini_AvalancheIndicationCB                               *
+****************************************************************************
+* DESCRIPTION: This is the the function which is called when 
+*                              FW detect that our current connection quality is reducing
+*                              (AP decrease his rates with his rate adaptation mechanism because
+*                              of BT activity) the solution is reconnect to the same AP
+*
+* INPUTS:              pSoftGemini - the object
+* NOTE                 This function is located in the API for debug purposes
+***************************************************************************/
+
+void SoftGemini_AvalancheIndicationCB( TI_HANDLE hSoftGemini, char* str, UINT32 strLen )
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+       WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("%s \n",__FUNCTION__)); 
+
+       if ((SG_ENABLE == pSoftGemini->SoftGeminiEnable) ||
+               (SG_SENSE_ACTIVE == pSoftGemini->SoftGeminiEnable)) 
+       {
+               SoftGemini_reconnect(hSoftGemini);
+       }
+       else
+       {
+               WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  
+                       ("%s : Avalanche Avoidance called when SG mode is %s \n",
+                       __FUNCTION__,SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable))); 
+       }
+
+}
+
+/***************************************************************************
+*                                      SoftGemini_ConvertModeToString                                 *
+****************************************************************************/
+#ifdef REPORT_LOG
+
+char* SoftGemini_ConvertModeToString(SoftGeminiEnableModes_e SoftGeminiEnable)
+{
+       switch(SoftGeminiEnable)
+       {
+       case SG_ENABLE:                         return "SG_ENABLE";
+       case SG_DISABLE:                        return "SG_DISABLE";
+       case SG_SENSE_NO_ACTIVITY:  return "SG_SENSE_NO_ACTIVITY";
+       case SG_SENSE_ACTIVE:           return "SG_SENSE_ACTIVE";
+       default:
+               return "ERROR";
+       }
+}
+
+#endif
+
+/***************************************************************************
+*                                      SoftGemini_getSGMode                                                                           *
+****************************************************************************/
+SoftGeminiEnableModes_e SoftGemini_getSGMode(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       return pSoftGemini->SoftGeminiEnable;   
+}
+
+/***************************************************************************
+*                                      SoftGemini_handleRecovery                                                      *
+****************************************************************************
+* DESCRIPTION: The function reconfigures WHAL with the SG parameters.
+*
+* INPUTS:              pSoftGemini - the object                
+***************************************************************************/
+TI_STATUS SoftGemini_handleRecovery(TI_HANDLE hSoftGemini)
+{
+       SoftGemini_t    *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+       SoftGeminiEnableModes_e       realSoftGeminiEnableMode;
+
+       realSoftGeminiEnableMode = pSoftGemini->SoftGeminiEnable;
+    /* Disable the SG */
+    SoftGemini_setEnableParam(hSoftGemini, SG_DISABLE, TRUE);
+    WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("Disable SG \n")); 
+
+       pSoftGemini->SoftGeminiEnable = realSoftGeminiEnableMode;
+       /* Set enable param */
+       if (pSoftGemini->SoftGeminiEnable == SG_SENSE_ACTIVE)
+       {
+               pSoftGemini->SoftGeminiEnable = SG_SENSE_NO_ACTIVITY;
+       }
+    SoftGemini_setEnableParam(hSoftGemini, pSoftGemini->SoftGeminiEnable, TRUE);
+    WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  ("Set SG to-%d\n", pSoftGemini->SoftGeminiEnable)); 
+
+       /* Config the params to FW */
+       SoftGemini_setParamsToFW(hSoftGemini, &pSoftGemini->SoftGeminiParam);
+       /*SoftGemini_printParams(hSoftGemini);*/
+       return OK;
+}
+/***************************************************************************
+*                                      SoftGemini_startPsPollFailure                                          *
+****************************************************************************
+* DESCRIPTION: After Ps-Poll failure we disable the SG
+*
+* INPUTS:              pSoftGemini - the object                
+***************************************************************************/
+void SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini)
+{
+    SoftGemini_t       *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+    WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("%s\n",__FUNCTION__)); 
+
+    if ( !pSoftGemini->bPsPollFailureActive && !pSoftGemini->SoftGeminiParam.sgAutoModeNoCts)
+    {
+        pSoftGemini->PsPollFailureLastEnableValue = pSoftGemini->SoftGeminiEnable;
+
+        /* Disable SG if needed */
+        if ( pSoftGemini->SoftGeminiEnable != SG_DISABLE )
+        {      
+            SoftGemini_setEnableParam(hSoftGemini, SG_DISABLE, FALSE);
+        }
+
+        pSoftGemini->bPsPollFailureActive = TRUE;
+    }
+    else /* Calling SoftGemini_startPsPollFailure twice ? */
+    {
+        WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  
+            ("Calling  SoftGemini_startPsPollFailure while bPsPollFailureActive is TRUE\n")); 
+    }
+}
+
+/***************************************************************************
+*                                      SoftGemini_endPsPollFailure                                                *
+****************************************************************************
+* DESCRIPTION: Return to normal behavior after the PsPoll failure 
+*
+* INPUTS:              pSoftGemini - the object                
+***************************************************************************/
+void SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini)
+{
+    SoftGemini_t       *pSoftGemini = (SoftGemini_t *)hSoftGemini;
+
+    WLAN_REPORT_INFORMATION(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG, ("%s\n",__FUNCTION__)); 
+
+    if ( pSoftGemini->bPsPollFailureActive ) 
+    {
+        pSoftGemini->bPsPollFailureActive = FALSE;
+
+        /* return to previous value */
+        if ( pSoftGemini->PsPollFailureLastEnableValue != SG_DISABLE )
+        {
+            if ( pSoftGemini->PsPollFailureLastEnableValue == SG_SENSE_ACTIVE)
+            {
+                /* In this case Fw must get SG_SENSE_NO_ACTIVITY to start sensing again */    
+                pSoftGemini->PsPollFailureLastEnableValue = SG_SENSE_NO_ACTIVITY;
+            }
+
+            SoftGemini_setEnableParam(hSoftGemini, pSoftGemini->PsPollFailureLastEnableValue, FALSE);
+        }
+    }
+    else /* Calling SoftGemini_endPsPollFailure twice ? */
+    {
+        WLAN_REPORT_WARNING(pSoftGemini->hReport, SOFT_GEMINI_MODULE_LOG,  
+            ("Calling  SoftGemini_endPsPollFailure while bPsPollFailureActive is FALSE\n")); 
+    }
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/SoftGemini/src/SoftGemini.h b/sta_dk_4_0_4_32/common/src/Management/SoftGemini/src/SoftGemini.h
new file mode 100644 (file)
index 0000000..e8a5acf
--- /dev/null
@@ -0,0 +1,85 @@
+/** \file SoftGemini.h
+ *  \brief BlueTooth-Wlan coexistence module internal header file
+ *
+ *  \see SoftGemini.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       SoftGemini.h                                                                                            */
+/*    PURPOSE: BlueTooth-Wlan coexistence module internal header file                  */
+/*                                                                                                                                                     */
+/***************************************************************************/
+
+#ifndef __SOFT_GEMINI_H__
+#define __SOFT_GEMINI_H__
+
+#include "paramOut.h"
+#include "SoftGeminiApi.h"
+#include "softGeminiTypes.h"
+
+
+typedef struct 
+{
+       SoftGeminiEnableModes_e SoftGeminiEnable;                                               
+    SoftGeminiEnableModes_e PsPollFailureLastEnableValue;
+       UINT8                                   SoftGeminiRate[NUM_OF_RATES_IN_SG];             /* whether to use the specific rate arranged as
+                                                                                                                                           5.5,11,12,18,24,36,48,54 */
+       SoftGeminiParam_t               SoftGeminiParam;                                                /* for the FW */
+       UINT8                                   scanNumOfProbeRequest;                                  /* Probes to send on any scan when SG enabled */
+       UINT32                                  scanCompensationPercent;                                /* Percentage of increasing dwell time on each channel */
+       UINT32                                  scanCompensationMaxTime;                                /* Max value of increasing dwell time */
+       UINT32                                  BSSLossCompensationPercent;                             /* Percentage of increasing value of Beacon loss parameter */
+       BOOL                                    bProtectiveMode;
+       BOOL                                    bDriverEnabled;                                                 /* used to check if we should enable driver when we are switching different enable modes */
+    BOOL                                       bPsPollFailureActive;
+       btCoexStatus_t                  btCoexStatus;
+    TI_HANDLE                          hCtrlData;
+       TI_HANDLE                               hHalCtrl;
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hOs;
+       TI_HANDLE                               hSCR;
+       TI_HANDLE                               hPowerMgr;
+       TI_HANDLE                               hConfigMgr;
+       TI_HANDLE                               hScanCncn;
+       TI_HANDLE                               hCurrBss;
+       TI_HANDLE                               hEvHandler;
+} SoftGemini_t;
+
+#endif /* __SOFT_GEMINI_H__*/
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/apConn/apConn.c b/sta_dk_4_0_4_32/common/src/Management/apConn/apConn.c
new file mode 100644 (file)
index 0000000..26df7d9
--- /dev/null
@@ -0,0 +1,2732 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 apConn.c
+ *  \brief AP Connection
+ *
+ *  \see apConn.h
+ */
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  AP Connection                                                 *
+ *   PURPOSE:                                                               *
+ *   Roaming ability of eSTA is implemented by Roaming Manager Component and 
+ *   described in "Roaming Manager module LLD" document, and by 
+ *   AP Connection module. AP Connection module implemented as two sub-modules:
+ *   The major one is AP Connection, that is responsible for: 
+ *   - providing Roaming Manager with access to other parts of WLAN Driver, 
+ *   - implementing low levels of roaming mechanism.
+ *   Current BSS sub-module takes care of:
+ *   - maintaining database of current AP info,
+ *   - providing access to database of current AP info.
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+
+#include "paramIn.h"
+#include "report.h"
+#include "utils.h"
+
+#include "smeSmApi.h"
+#include "siteMgrApi.h"
+#include "smeApi.h"
+#include "PowerMgr_API.h"
+#include "TrafficMonitorAPI.h"
+#include "RateAdaptation.h"
+#include "qosMngr_API.h"
+#ifdef EXC_MODULE_INCLUDED
+ #include "excMngr.h"
+#endif
+#include "measurementMgrApi.h"
+#include "connApi.h"
+#include "EvHandler.h"
+#include "apConn.h"
+#include "currBss.h"
+#include "Ctrl.h"
+#include "fsm.h"
+#include "scrApi.h"
+#include "regulatoryDomainApi.h"
+
+/* Constants and macros */
+#ifdef TI_DBG
+ #define    AP_CONN_VALIDATE_HANDLE(hAPConnection)  \
+    if (hAPConnection == NULL)  \
+    {   \
+        WLAN_OS_REPORT(("FATAL ERROR: AP Connection context is not initiated\n"));  \
+        return NOK; \
+    }
+#else
+ #define    AP_CONN_VALIDATE_HANDLE(hAPConnection)
+#endif
+
+#define MAX_ROAMING_TRIGGERS  ROAMING_TRIGGER_LAST
+
+#define UPDATE_SEND_DEAUTH_PACKET_FLAG(roamingEventType) \
+            if ((roamingEventType >= ROAMING_TRIGGER_MAX_TX_RETRIES) && \
+                (roamingEventType != ROAMING_TRIGGER_SECURITY_ATTACK)) \
+            { \
+                pAPConnection->sendDeauthPacket = FALSE; \
+            } 
+
+/* Init bits */
+
+/* Enumerations */
+
+/**
+* AP Connection state machine states
+*/
+typedef enum
+{
+    AP_CONNECT_STATE_IDLE = 0,          /**< Initial state */
+    AP_CONNECT_STATE_WAIT_ROAM,         /**< Connected to AP, waiting for start roaming command */
+    AP_CONNECT_STATE_SWITCHING_CHANNEL, /**< Connected to AP, switch channel in progress */
+    AP_CONNECT_STATE_WAIT_CONNECT_CMD,  /**< SCR allocated, PS mode entered; wait for cmd from Roam Mngr */
+    AP_CONNECT_STATE_PREPARE_HAND_OFF,  /**< Request CCKM for new AP, wait for response */
+    AP_CONNECT_STATE_CONNECTING,        /**< Performing Connection to new AP; wait for response from Conn SM */
+    AP_CONNECT_STATE_DISCONNECTING,     /**< Wait for completion of current link disconnection */
+    AP_CONNECT_STATE_REESTABLISH_VOICE, /**< Wait for completion of voice TSPEC re-negotiation */
+    AP_CONNECT_STATE_LAST
+} apConn_smStates;
+
+
+/**
+* AP Connection state machine events
+*/
+typedef enum
+{
+    AP_CONNECT_EVENT_PREPARE_FOR_ROAMING= 0,/**< Sent by Roam MNGR when roaming event occurs */
+    AP_CONNECT_EVENT_FINISHED_OK,           /**< Indicates successful completion of request sent to Conn SM */
+    AP_CONNECT_EVENT_FINISHED_NOT_OK,       /**< Indicates unsuccessful completion of request sent to Conn SM */
+    AP_CONNECT_EVENT_RETAIN_CURRENT_AP,     /**< Sent by Roam MNGR when it wishes to give-up roaming */
+    AP_CONNECT_EVENT_START,                 /**< Sent by SME when first time link to AP is established */
+    AP_CONNECT_EVENT_START_ROAM,            /**< Sent by Roam MNGR when it wishes to roam to new AP */
+    AP_CONNECT_EVENT_START_SWITCH_CHANNEL,  /**< Sent by Switch channel module when starting switch channel process (tx enabled) */
+    AP_CONNECT_EVENT_FINISHED_SWITCH_CH,    /**< Sent by Switch channel module when finishing switch channel process (tx enabled) */
+    AP_CONNECT_EVENT_FINISHED_HAND_OVER,    /**< Sent by EXC module when finishing hand-over */
+    AP_CONNECT_EVENT_STOP,                  /**< Disconnect current link, send stop indication to other modules */
+    AP_CONNECT_EVENT_LAST
+} apConn_smEvents;
+
+#define AP_CONNECT_NUM_STATES       AP_CONNECT_STATE_LAST    
+#define AP_CONNECT_NUM_EVENTS       AP_CONNECT_EVENT_LAST   
+
+
+#ifdef REPORT_LOG
+
+/* Global variables */
+static char *apConn_stateDesc[AP_CONNECT_NUM_STATES] = {  
+        "APC_STATE_IDLE",              
+        "APC_STATE_WAIT_ROAM",                                                
+        "APC_STATE_SWITCHING_CHANNEL",                                         
+        "APC_STATE_WAIT_CONNECT_CMD",                                                  
+        "APC_STATE_PREPARE_HAND_OFF",
+        "APC_STATE_CONNECTING",
+        "APC_STATE_DISCONNECTING",
+        "APC_STATE_REESTABLISH_VOICE"
+    };
+    
+static char *apConn_eventDesc[AP_CONNECT_NUM_EVENTS] = {
+        "APC_EVENT_PREPARE_FOR_ROAMING", 
+        "APC_EVENT_FINISHED_OK",            
+        "APC_EVENT_FINISHED_NOT_OK",            
+        "APC_EVENT_RETAIN_CURRENT_AP",  
+        "APC_EVENT_START",             
+        "APC_EVENT_START_ROAM",             
+        "APC_EVENT_START_SWITCH_CHANNEL",             
+        "APC_EVENT_FINISHED_SWITCH_CHANNEL",             
+        "APC_EVENT_FINISHED_HAND_OVER",             
+        "APC_EVENT_STOP"                 
+    };
+                           
+#endif
+
+
+/* Typedefs */
+
+/* Structures */
+
+/**
+* AP Connection control block 
+* Following structure defines parameters that can be configured externally,
+* internal variables, AP Connection state machine and handlers of other modules
+* used by AP Connection module
+*/
+typedef struct _apConn_t
+{
+    /* AP Connection state machine */
+    fsm_stateMachine_t      *apConnSM;          /**< AP Connection module state machine */
+    apConn_smStates         currentState;       /**< AP Connection state machine current state */
+    
+    /* Internal parameters */
+    BOOL                    firstAttempt2Roam;  /**< TRUE if still connected to original AP, FALSE otherwise */
+    BOOL                    roamingEnabled;     /**< If FALSE, act like if no roaming callback registered. */
+    apConn_roamingTrigger_e roamReason;         /**< The most severe and recent reason for roaming */
+    APDisconnect_t          APDisconnect;       /**< The AP disconnect trigger extra information */
+    bssEntry_t              *newAP;             /**< Stores parameters of roaming candidate */
+    apConn_connRequest_e    requestType;        /**< Stores type of roaming request */
+    INT8                    rssiThreshold;      /**< Stores recently configured RSSI threshold */
+    UINT8                   snrThreshold;       /**< Stores recently configured SNR threshold */
+    UINT8                   txFailureThreshold; /**< Stores recently configured consec. no ack threshold */
+    UINT8                   lowRateThreshold;   /**< Stores recently configured consec. no ack threshold */
+    UINT32                  vsIElength;         /**< Length of vendor specific info-element for assoc req (if defined) */
+    char                    *vsIEbuf;           /**< Pointer to vendor specific info-element for assoc req (if defined) */
+    BOOL                    isRssiTriggerMaskedOut;
+    BOOL                    isSnrTriggerMaskedOut;
+    BOOL                    isConsTxFailureMaskedOut;
+    BOOL                    islowRateTriggerMaskedOut;
+    BOOL                    removeKeys;         /**< Indicates whether keys should be removed after disconnect or not */
+    BOOL                    ignoreDeauthReason0;/**< Indicates whether to ignore DeAuth with reason 0, required for Rogue AP test EXC-V2 */
+    BOOL                    sendDeauthPacket;   /**< Indicates whether to send DEAUTH packet when discommecting or not */
+    BOOL                    voiceTspecConfigured;/**< Shall be set to TRUE before roaming in case the TSPEC is configured */
+       BOOL                    videoTspecConfigured;/**< Shall be set to TRUE before roaming in case the TSPEC is configured */
+    BOOL                    reNegotiateTSPEC;   /**< Shall be set to TRUE before hand-over if requested by Roaming Manager */
+    BOOL                    resetReportedRoamingStatistics; /**< Shall be set to TRUE if starting to measure traffic */
+    UINT16                  lastRoamingDelay;
+    UINT32                  roamingStartedTimestamp;
+    UINT8                   roamingSuccesfulHandoverNum;
+    BOOL                    bNonRoamingDisAssocReason; /**< Indicate whether last disconnection was called from outside (SME) */            
+    /** Callback functions, registered by Roaming manager */
+    apConn_roamMngrCallb_t  roamEventCallb;         /**< roam event triggers */ 
+    apConn_roamMngrCallb_t  reportStatusCallb;      /**< connection status events  */
+    apConn_roamMngrCallb_t  returnNeighborApsCallb; /**< neighbor APs list update */
+    
+    /* Handlers of other modules used by AP Connection */
+    TI_HANDLE               hOs;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hCurrBSS;
+    TI_HANDLE               hRoamMng;
+    TI_HANDLE               hSme;
+    TI_HANDLE               hSiteMgr;
+    TI_HANDLE               hExcMngr;
+    TI_HANDLE               hConnSm;
+    TI_HANDLE               hPrivacy;
+    TI_HANDLE               hQos;
+    TI_HANDLE               hRateAdapt;
+    TI_HANDLE               hEvHandler; 
+    TI_HANDLE               hScr;   
+    TI_HANDLE               hAssoc;
+    TI_HANDLE               hRegulatoryDomain;
+    
+    /* Counters for statistics */
+    UINT32                  roamingTriggerEvents[MAX_ROAMING_TRIGGERS];
+    UINT32                  roamingSuccesfulHandoverTotalNum;   
+    UINT32                  roamingFailedHandoverNum;   
+    UINT32                  retainCurrAPNum;
+    UINT32                  disconnectFromRoamMngrNum;
+    UINT32                  stopFromSmeNum;
+} apConn_t;
+
+/* Internal functions prototypes */
+
+/* SM functions */
+static TI_STATUS apConn_smEvent(apConn_smStates *currState, UINT8 event, void* data);
+static TI_STATUS apConn_smNop(void *pData);
+static TI_STATUS apConn_smUnexpected(void *pData);
+static TI_STATUS apConn_startWaitingForTriggers(void *pData);
+static TI_STATUS apConn_connectedToNewAP(void *pData);
+static TI_STATUS apConn_configureDriverBeforeRoaming(void *pData);
+static TI_STATUS apConn_stopConnection(void *pData);
+static TI_STATUS apConn_invokeConnectionToNewAp(void *pData);
+static TI_STATUS apConn_reportDisconnected(void *pData);
+static TI_STATUS apConn_retainAP(void *pData);
+static TI_STATUS apConn_requestCCKM(void *pData);
+static TI_STATUS apConn_reportConnFail(void *pData);
+static TI_STATUS apConn_swChFinished(void *pData);
+static TI_STATUS apConn_handleTspecReneg (void *pData);
+
+/* other functions */
+#ifdef EXC_MODULE_INCLUDED
+static void apConn_calcNewTsf(apConn_t *hAPConnection, UINT8 *tsfTimeStamp, UINT32 newSiteOsTimeStamp, UINT32 beaconInterval);
+#endif
+static TI_STATUS apConn_qosMngrReportResultCallb (TI_HANDLE hApConn, trafficAdmRequestStatus_e result);
+static void      apConn_reportConnStatusToSME    (apConn_t *pAPConnection);
+
+
+/* Public functions implementation */
+
+/**
+*
+* apConn_create
+*
+* \b Description: 
+*
+* Create the AP Connection context: 
+* allocate memory for internal variables; 
+* create state machine.
+*
+* \b ARGS:
+*
+*  I   - hOs - OS handler
+*  
+* \b RETURNS:
+*
+* Pointer to the AP Connection on success, NULL on failure 
+* (unable to allocate memory or other error).
+*
+* \sa 
+*/
+TI_HANDLE apConn_create(TI_HANDLE hOs)
+{
+    TI_STATUS   status;
+    apConn_t    *pAPConnection;
+
+    if ((pAPConnection = os_memoryAlloc(hOs, sizeof(apConn_t))) != NULL)
+    {
+        pAPConnection->hOs = hOs;
+    
+        status = fsm_Create(hOs, &(pAPConnection->apConnSM), AP_CONNECT_NUM_STATES, AP_CONNECT_NUM_EVENTS);
+        if (status == OK) 
+        {
+            /* Succeeded to create AP Connection module context - return pointer to it */
+            return pAPConnection;
+        }
+        else /* Failed to create state machine */
+        {
+            WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error creating apConnSM - aborting\n"));
+            /* Free pre-allocated control block */
+            utils_nullMemoryFree(hOs, pAPConnection, sizeof(apConn_t));
+            return NULL;
+        }
+    }
+    else /* Failed to allocate control block */
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
+        return NULL;
+    }
+}
+
+/**
+*
+* apConn_unload
+*
+* \b Description: 
+*
+* Finish AP Connection module work:
+* release the allocation for state machine and internal variables.
+*
+* \b ARGS:
+*
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_unload(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    pAPConnection = (apConn_t *)hAPConnection;
+
+    /* Unload state machine */
+    fsm_Unload(pAPConnection->hOs, pAPConnection->apConnSM);
+
+    /* Free pre-allocated control block */
+    utils_nullMemoryFree(pAPConnection->hOs, pAPConnection, sizeof(apConn_t));
+
+    return OK;
+}
+
+/**
+*
+* apConn_config
+*
+* \b Description: 
+*
+* Prepare AP Connection module to work: initiate internal variables, start state machine
+*
+* \b ARGS:
+*
+*  I   - hCurrAP - Current BSS handle \n
+*  I   - hRoamMng - Roaming Manager handle  \n
+*  I   - hSme - SME context  \n
+*  I   - hPowerMgr - Power Manager context  \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS apConn_config(TI_HANDLE hAPConnection, 
+                        TI_HANDLE hReport,
+                        TI_HANDLE hCurrAP,
+                        TI_HANDLE hRoamMng,
+                        TI_HANDLE hSme,
+                        TI_HANDLE hSiteMgr,
+                        TI_HANDLE hExcMngr,
+                        TI_HANDLE hConnSm,
+                        TI_HANDLE hPrivacy,
+                        TI_HANDLE hQos,
+                        TI_HANDLE hCtrl,
+                        TI_HANDLE hEvHandler,
+                        TI_HANDLE hScr,
+                        TI_HANDLE hAssoc,
+                        TI_HANDLE hRegulatoryDomain,
+                        apConnParams_t *pApConnParams)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    TI_STATUS status;
+    UINT32  index;
+
+    /** State Machine matrix */
+    fsm_actionCell_t apConn_matrix[AP_CONNECT_NUM_STATES][AP_CONNECT_NUM_EVENTS] =
+    {
+        /* next state and actions for IDLE state */
+        {   {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* FINISHED_OK          */
+            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_WAIT_ROAM,apConn_startWaitingForTriggers},/* START                */ 
+            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* START_ROAM           */ 
+            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected},               /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_IDLE, apConn_smNop},                      /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_IDLE, apConn_smNop},                      /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_IDLE, apConn_smUnexpected}                /* STOP                 */
+        },                                                                              
+        /* next state and actions for WAIT_ROAM state */
+        {   {AP_CONNECT_STATE_WAIT_CONNECT_CMD,apConn_configureDriverBeforeRoaming},/* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_OK          */
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* START                */ 
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* START_ROAM           */ 
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smNop},     /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smUnexpected},      /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection} /* STOP                 */
+        },                                                                              
+        /* next state and actions for SWITCHING_CHANNEL state */
+        {   {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* FINISHED_OK          */
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* START                */ 
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* START_ROAM           */ 
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_swChFinished},  /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_smNop},                 /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_SWITCHING_CHANNEL, apConn_smUnexpected},  /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
+        },                                                                              
+        /* next state and actions for WAIT_CONNECT_CMD state */
+        {   {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_OK          */
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_WAIT_ROAM, apConn_retainAP},              /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* START                */ 
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_requestCCKM},    /* START_ROAM           */ 
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_smUnexpected},   /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
+        },                                                                              
+        /* next state and actions for PREPARE_HAND_OFF state */
+        {   {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* FINISHED_OK          */
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* START                */ 
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* START_ROAM           */ 
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_PREPARE_HAND_OFF, apConn_smUnexpected},   /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_CONNECTING, apConn_invokeConnectionToNewAp},/* FINISHED_HAND_OVER */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
+        },                                                                              
+        /* next state and actions for CONNECTING state */
+        {   {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_REESTABLISH_VOICE,apConn_handleTspecReneg},/* FINISHED_OK             */
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_reportConnFail}, /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* START                */ 
+            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* START_ROAM           */ 
+            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_CONNECTING, apConn_smUnexpected},         /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
+        },                                                                              
+        /* next state and actions for DISCONNECTING state */
+        {   {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_IDLE, apConn_reportDisconnected},     /* FINISHED_OK          */
+            {AP_CONNECT_STATE_IDLE, apConn_reportDisconnected},     /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smUnexpected},  /* START                */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* START_ROAM           */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_smNop},         /* STOP                 */
+        },                                                                             
+        /* next state and actions for REESTABLISH_VOICE state */
+        {   {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* PREPARE_FOR_ROAMING  */ 
+            {AP_CONNECT_STATE_WAIT_ROAM,apConn_connectedToNewAP},       /* FINISHED_OK          */
+            {AP_CONNECT_STATE_WAIT_CONNECT_CMD, apConn_reportConnFail}, /* FINISHED_NOT_OK      */
+            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* RETAIN_CURRENT_AP    */ 
+            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* START                */ 
+            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* START_ROAM           */ 
+            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* START_SWITCH_CHANNEL */ 
+            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* FINISHED_SWITCH_CH   */ 
+            {AP_CONNECT_STATE_REESTABLISH_VOICE, apConn_smUnexpected},  /* FINISHED_HAND_OVER   */ 
+            {AP_CONNECT_STATE_DISCONNECTING, apConn_stopConnection}     /* STOP                 */
+        }                                                                             
+    }; 
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    status = fsm_Config(pAPConnection->apConnSM, 
+                        (fsm_Matrix_t)&apConn_matrix[0][0], 
+                        AP_CONNECT_NUM_STATES, 
+                        AP_CONNECT_NUM_EVENTS, 
+                        (fsm_eventActivation_t)apConn_smEvent, 
+                        pAPConnection->hOs);
+
+
+    if (status == OK)
+    {
+        pAPConnection->currentState = AP_CONNECT_STATE_IDLE;
+        pAPConnection->firstAttempt2Roam = TRUE;
+        pAPConnection->hReport = hReport;
+        pAPConnection->hCurrBSS = hCurrAP;
+        pAPConnection->hRoamMng = hRoamMng;
+        pAPConnection->hSme = hSme;
+        pAPConnection->hSiteMgr = hSiteMgr;
+        pAPConnection->hExcMngr = hExcMngr;
+        pAPConnection->hConnSm = hConnSm;
+        pAPConnection->hPrivacy = hPrivacy;
+        pAPConnection->hQos = hQos;
+        pAPConnection->hRateAdapt = ((ctrlData_t *)hCtrl)->pRateAdaptation;
+        pAPConnection->hEvHandler = hEvHandler;
+        pAPConnection->hScr = hScr;
+        pAPConnection->hAssoc = hAssoc;
+        pAPConnection->hRegulatoryDomain = hRegulatoryDomain;
+
+        pAPConnection->roamingEnabled = TRUE;
+        pAPConnection->reportStatusCallb = NULL;
+        pAPConnection->roamEventCallb = NULL;
+        pAPConnection->returnNeighborApsCallb = NULL;
+        pAPConnection->ignoreDeauthReason0 = pApConnParams->ignoreDeauthReason0;
+
+        for (index=ROAMING_TRIGGER_NONE; index<ROAMING_TRIGGER_LAST; index++)
+        {
+            pAPConnection->roamingTriggerEvents[index] = 0;
+        }
+        pAPConnection->roamingSuccesfulHandoverNum = 0;
+        pAPConnection->roamingSuccesfulHandoverTotalNum = 0;
+        pAPConnection->roamingFailedHandoverNum = 0;
+        pAPConnection->retainCurrAPNum = 0;
+        pAPConnection->disconnectFromRoamMngrNum = 0;
+        pAPConnection->stopFromSmeNum = 0;
+        pAPConnection->txFailureThreshold = NO_ACK_DEFAULT_THRESHOLD;
+        pAPConnection->lowRateThreshold = LOW_RATE_DEFAULT_THRESHOLD;
+        pAPConnection->rssiThreshold = RSSI_DEFAULT_THRESHOLD;
+        pAPConnection->snrThreshold = SNR_DEFAULT_THRESHOLD;
+        pAPConnection->vsIElength = 0;
+        pAPConnection->isRssiTriggerMaskedOut = FALSE;
+        pAPConnection->isSnrTriggerMaskedOut = TRUE;
+        pAPConnection->islowRateTriggerMaskedOut = FALSE;
+        pAPConnection->isConsTxFailureMaskedOut = FALSE;
+        pAPConnection->removeKeys = TRUE;
+        pAPConnection->sendDeauthPacket = TRUE;       /* Default behavior is radio On - send DISASSOC frame */
+        pAPConnection->voiceTspecConfigured = FALSE;
+               pAPConnection->videoTspecConfigured = FALSE;
+        pAPConnection->resetReportedRoamingStatistics = FALSE;
+        pAPConnection->reNegotiateTSPEC = FALSE;
+        pAPConnection->bNonRoamingDisAssocReason = FALSE;
+
+        pAPConnection->roamingStartedTimestamp = 0;
+        pAPConnection->lastRoamingDelay = 0;
+        pAPConnection->roamingSuccesfulHandoverNum = 0;
+
+        return OK;
+    }
+    else/* Unable to configure State Machine */
+    {
+        WLAN_REPORT_ERROR(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("FATAL ERROR: apConn_config(): Failed to configure sm\n"));
+        return status;
+    }
+}
+
+
+/**
+*
+* apConn_isPsRequiredBeforeScan
+*
+* \b Description: 
+*
+* verify if the PS required before scan according if roaming triger is part of ROAMING_TRIGGER_LOW_QUALITY_GROUP 
+*
+* \b ARGS:
+*
+*  I   - hAPConnection - pointer to module\n
+*
+* \b RETURNS:
+*
+*  TRUE or FALSE.
+*
+* \sa 
+*/
+BOOLEAN apConn_isPsRequiredBeforeScan(TI_HANDLE hAPConnection)
+{
+    apConn_t * pAPConnection = (apConn_t *) hAPConnection;
+
+       /* check if part of ROAMING_TRIGGER_LOW_QUALITY_GROUP */
+       if (pAPConnection->roamReason <= ROAMING_TRIGGER_MAX_TX_RETRIES)
+               return TRUE;
+       else
+               return FALSE;
+}
+
+/**
+*
+* apConn_ConnCompleteInd
+*
+* \b Description: 
+*
+* Inform AP Connection about successful / unsuccessful completion 
+* of link establishing 
+*
+* \b ARGS:
+*
+*  I   - result - OK if successfully connected, NOK otherwise  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_ConnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, UINT32 uStatusCode)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    if (status == STATUS_SUCCESSFUL) 
+    {
+        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
+    }
+    else
+    {
+        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
+    }
+    return OK;
+}
+
+
+/**
+*
+* apConn_getRoamThresholds
+*
+* \b Description: 
+*
+* Used to query for the current roaming thresholds configuration
+*
+* \b ARGS:
+*
+*  I   - hAPConnection - pointer to module\n
+*  O   - pParam - pointer to buffer to store the thresholds\n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_getRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam)
+{
+    apConn_t * pAPConnection = (apConn_t *) hAPConnection;
+
+    pParam->lowRssiThreshold = pAPConnection->rssiThreshold;
+    pParam->lowSnrThreshold = pAPConnection->snrThreshold;
+    pParam->txRateThreshold = pAPConnection->lowRateThreshold;
+    pParam->dataRetryThreshold = pAPConnection->txFailureThreshold;
+
+    currBSS_getRoamingParams(pAPConnection->hCurrBSS, 
+                             &pParam->numExpectedTbttForBSSLoss, 
+                             &pParam->lowQualityForBackgroungScanCondition, 
+                             &pParam->normalQualityForBackgroungScanCondition,
+                             &pParam->rssiFilterWeight,
+                             &pParam->snrFilterWeight);
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_setRoamThresholds
+*
+* \b Description: 
+*
+* Used to configure roaming thresholds
+*
+* \b ARGS:
+*
+*  I   - pParam - pointer to type and details of configuration request\n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_setRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    /* If low quality trigger threshold is set to 0 - this is the request to ignore this trigger */
+    /* Otherwise store it */
+    if (pParam->lowRssiThreshold == (INT8)AP_CONNECT_TRIGGER_IGNORED) 
+    {
+        pAPConnection->isRssiTriggerMaskedOut = TRUE;
+        pParam->lowRssiThreshold = pAPConnection->rssiThreshold;
+    }
+    else
+    {
+        pAPConnection->isRssiTriggerMaskedOut = FALSE;
+        pAPConnection->rssiThreshold = pParam->lowRssiThreshold;
+    }
+
+    if (pParam->txRateThreshold == AP_CONNECT_TRIGGER_IGNORED) 
+    {
+        pAPConnection->islowRateTriggerMaskedOut = TRUE;
+        pParam->txRateThreshold = pAPConnection->lowRateThreshold;
+    }
+    else
+    {
+        pAPConnection->islowRateTriggerMaskedOut = FALSE;
+        pAPConnection->lowRateThreshold = pParam->txRateThreshold;
+    }
+
+    if (pParam->dataRetryThreshold == AP_CONNECT_TRIGGER_IGNORED) 
+    {
+        pAPConnection->isConsTxFailureMaskedOut = TRUE;
+        pParam->dataRetryThreshold = pAPConnection->txFailureThreshold;
+    }
+    else
+    {
+        pAPConnection->isConsTxFailureMaskedOut = FALSE;
+        pAPConnection->txFailureThreshold = pParam->dataRetryThreshold;
+    }
+
+    if (pParam->rssiFilterWeight == (UINT8)AP_CONNECT_TRIGGER_IGNORED) 
+    {
+        pParam->rssiFilterWeight = RSSI_DEFAULT_WEIGHT;
+    }
+
+    if (pParam->snrFilterWeight == (UINT8)AP_CONNECT_TRIGGER_IGNORED) 
+    {
+        pParam->snrFilterWeight = SNR_DEFAULT_WEIGHT;
+    }
+
+    pAPConnection->isSnrTriggerMaskedOut = FALSE;
+    pAPConnection->snrThreshold = pParam->lowSnrThreshold;
+
+    currBSS_updateRoamingTriggers(pAPConnection->hCurrBSS, pParam);
+
+    rateAdaptation_configLowRateThrsh(pAPConnection->hRateAdapt,pParam->txRateThreshold);
+
+    return OK;
+}
+
+/**
+*
+* apConn_registerRoamMngrCallb
+*
+* \b Description: 
+*
+* Used to store method of Roaming Manager in the internal database of AP Connection Module.
+* If this function was never called, any roaming event would cause disconnect.
+*
+* \b ARGS:
+*
+*  I   - callbackType - type of callback \n
+*  I   - callbackFunction - pointer to callback \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_registerRoamMngrCallb(TI_HANDLE hAPConnection, 
+                                       apConn_roamMngrCallb_t roamEventCallb,
+                                       apConn_roamMngrCallb_t reportStatusCallb,
+                                       apConn_roamMngrCallb_t returnNeighborApsCallb)
+{
+    apConn_t *pAPConnection;
+    apConn_connStatus_t reportStatus;
+    paramInfo_t param;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    pAPConnection = (apConn_t *)hAPConnection;
+
+    pAPConnection->roamEventCallb = roamEventCallb;
+    pAPConnection->reportStatusCallb = reportStatusCallb;
+    if ((pAPConnection->roamingEnabled) && (pAPConnection->currentState != AP_CONNECT_STATE_IDLE))
+    {
+        param.paramType   = ASSOC_ASSOCIATION_RESP_PARAM;
+
+        assoc_getParam(pAPConnection->hAssoc, &param);
+        reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
+        reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
+
+        reportStatus.status = CONN_STATUS_CONNECTED;
+        reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);  
+    }
+    ((apConn_t *)hAPConnection)->returnNeighborApsCallb = returnNeighborApsCallb;
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_unregisterRoamMngrCallb
+*
+* \b Description: 
+*
+* Used to Erase methods of Roaming Manager from the internal database of AP Connection
+* module. From the moment this function was called, any roaming event would cause disconnect.
+*
+* \b ARGS:
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_unregisterRoamMngrCallb(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+        pAPConnection = (apConn_t *)hAPConnection;
+
+        pAPConnection->roamEventCallb = NULL;
+        pAPConnection->reportStatusCallb = NULL;
+        pAPConnection->returnNeighborApsCallb = NULL;
+
+    if ((pAPConnection->currentState != AP_CONNECT_STATE_IDLE) && (pAPConnection->currentState != AP_CONNECT_STATE_WAIT_ROAM))
+    {
+        /* Roaming Manager is unregistering it's callbacks in the middle of roaming - disconnect */
+        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
+    }
+    return OK;
+}
+
+
+/**
+*
+* apConn_disconnect
+*
+* \b Description: 
+*
+* Roaming Manager calls this function when it fails to find candidate for roaming from
+* one hand, and the connection with current AP is not possible from another.
+*
+* \b ARGS:
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_disconnect(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    pAPConnection = (apConn_t *)hAPConnection;
+
+    UPDATE_SEND_DEAUTH_PACKET_FLAG(pAPConnection->roamReason);
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
+    pAPConnection->disconnectFromRoamMngrNum++;
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_getStaCapabilities
+*
+* \b Description: 
+*
+* Roaming Manager calls this function during selection of new candidate for roaming.
+* Returned are local Station capabilities (IEs) of quality and privacy, needed to
+* evaluate AP sites as suitable for roaming.
+*
+* \b ARGS:
+*
+*  O   - ie_list - station capabilities \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_getStaCapabilities(TI_HANDLE hAPConnection,
+                                    apConn_staCapabilities_t *ie_list)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    apConn_staCapabilities_t *pList;
+    paramInfo_t param;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+        pList = ie_list;
+
+    /* Get authentication suite type */
+    param.paramType = RSN_EXT_AUTHENTICATION_MODE;
+    rsn_getParam(pAPConnection->hPrivacy, &param);      
+
+    switch (param.content.rsnExtAuthneticationMode)
+    {
+        case RSN_EXT_AUTH_MODE_OPEN:
+            pList->authMode = os802_11AuthModeOpen;
+            break;
+        case RSN_EXT_AUTH_MODE_SHARED_KEY:
+            pList->authMode = os802_11AuthModeShared;
+            break;
+        case RSN_EXT_AUTH_MODE_AUTO_SWITCH:
+            pList->authMode = os802_11AuthModeAutoSwitch;
+            break;
+        case RSN_EXT_AUTH_MODE_WPA:
+            pList->authMode = os802_11AuthModeWPA;
+            break;
+        case RSN_EXT_AUTH_MODE_WPAPSK:
+            pList->authMode = os802_11AuthModeWPAPSK;
+            break;
+        case RSN_EXT_AUTH_MODE_WPANONE:
+            pList->authMode = os802_11AuthModeWPANone;
+            break;
+        case RSN_EXT_AUTH_MODE_WPA2:
+            pList->authMode = os802_11AuthModeWPA2;
+            break;
+        case RSN_EXT_AUTH_MODE_WPA2PSK:
+            pList->authMode = os802_11AuthModeWPA2PSK;
+            break;
+        default:
+            pList->authMode = os802_11AuthModeOpen;
+            break;
+    }
+
+    /* Get encryption type */
+    param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
+    rsn_getParam(pAPConnection->hPrivacy, &param);
+
+    switch (param.content.rsnEncryptionStatus)
+    {
+        case RSN_CIPHER_NONE:
+            pList->encryptionType = OS_ENCRYPTION_TYPE_NONE;
+            break;
+        case RSN_CIPHER_WEP:
+        case RSN_CIPHER_WEP104:
+            pList->encryptionType = OS_ENCRYPTION_TYPE_WEP;
+            break;
+        case RSN_CIPHER_TKIP:
+        case RSN_CIPHER_CKIP:
+            pList->encryptionType = OS_ENCRYPTION_TYPE_TKIP;
+            break;
+        case RSN_CIPHER_AES_WRAP:
+        case RSN_CIPHER_AES_CCMP:
+            pList->encryptionType = OS_ENCRYPTION_TYPE_AES;
+            break;
+        default:
+            pList->encryptionType = OS_ENCRYPTION_TYPE_NONE;
+            break;
+    }
+
+    /* Get supported rates */
+    param.paramType = SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM;
+    siteMgr_getParam(pAPConnection->hSiteMgr, &param);
+    os_memoryCopy(pAPConnection->hOs, (void *)param.content.siteMgrDesiredSupportedRateSet.ratesString, pList->rateMask, sizeof(OS_802_11_RATES_EX));
+    
+    /* Get mode: 2.4G, 5G or Dual */
+    param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
+    siteMgr_getParam(pAPConnection->hSiteMgr, &param);
+    pList->networkType = (OS_802_11_NETWORK_TYPE)param.content.siteMgrDot11Mode;
+    switch(param.content.siteMgrDot11Mode) 
+    {
+        case DOT11_B_MODE:
+            pList->networkType = os802_11DS;
+            break;
+        case DOT11_A_MODE:
+            pList->networkType = os802_11OFDM5;
+            break;
+        case DOT11_G_MODE:
+            pList->networkType = os802_11OFDM24;
+            break;
+        case DOT11_DUAL_MODE:
+            pList->networkType = os802_11Automode;
+            break;
+        default:
+            pList->networkType = os802_11DS;
+            break;
+    }
+
+
+    /* Get EXC status */
+#ifdef EXC_MODULE_INCLUDED
+    param.paramType = EXC_ENABLED;
+    excMngr_getParam(pAPConnection->hExcMngr, &param);
+    pList->excEnabled = (param.content.excEnabled==EXC_MODE_ENABLED)? TRUE : FALSE;
+#else
+    pList->excEnabled = FALSE;
+#endif
+
+    /* Get QoS type */
+    param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
+    qosMngr_getParams(pAPConnection->hQos, &param);
+    pList->qosEnabled = (param.content.qosSiteProtocol==NONE_QOS)? FALSE : TRUE;
+
+    pList->regDomain = REG_DOMAIN_FIXED;
+    /* Get regulatory domain type */
+    param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+    regulatoryDomain_getParam(pAPConnection->hRegulatoryDomain, &param);
+    if (param.content.spectrumManagementEnabled)
+    {   /* 802.11h is enabled (802.11h includes 802.11d) */
+        pList->regDomain = REG_DOMAIN_80211H;
+    }
+    else 
+    {
+    param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
+    regulatoryDomain_getParam(pAPConnection->hRegulatoryDomain, &param);
+        if (param.content.regulatoryDomainEnabled)
+        {   /* 802.11d is enabled */
+            pList->regDomain = REG_DOMAIN_80211D;
+        }
+    }
+    return OK;
+}
+
+
+/**
+*
+* apConn_connectToAP
+*
+* \b Description: 
+*
+* Roaming Manager calls this function when it has completed the process of selection
+* of new AP candidate for roaming. In addition, Roaming manager informs AP Connection
+* module whether this is new AP or the current one, and whether to perform full
+* roaming procedure or just to retain to current AP. 
+*
+* \b ARGS:
+*
+*  I   - requestType - Connect to new AP, current AP (retain to current AP or re-connect) \n
+*  I   - newAP - Pointer to parameters list of AP candidate for roaming \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_connectToAP(TI_HANDLE hAPConnection,
+                             bssEntry_t *newAP,
+                             apConn_connRequest_t *request,
+                             BOOL reNegotiateTspec)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    pAPConnection->requestType = request->requestType;
+
+    switch (request->requestType) 
+    {
+        case AP_CONNECT_RETAIN_CURR_AP:
+            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_RETAIN_CURRENT_AP, pAPConnection);
+            break;
+
+        case AP_CONNECT_FULL_TO_AP:
+            pAPConnection->removeKeys = TRUE;
+            pAPConnection->newAP = newAP;
+            pAPConnection->roamingFailedHandoverNum++;
+            pAPConnection->reNegotiateTSPEC = reNegotiateTspec;
+            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_ROAM, pAPConnection);
+            break;
+
+        case AP_CONNECT_FAST_TO_AP:
+        case AP_CONNECT_RECONNECT_CURR_AP:
+            pAPConnection->removeKeys = FALSE;
+            pAPConnection->newAP = newAP;
+            pAPConnection->roamingFailedHandoverNum++;
+            pAPConnection->reNegotiateTSPEC = reNegotiateTspec;
+            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_ROAM, pAPConnection);
+            break;
+
+        default:
+            break;
+    }
+
+    /* If there is vendor specific IE to attach to Assoc req, store it now */
+    if (request->dataBufLength > 0)
+    {
+        pAPConnection->vsIEbuf = request->dataBuf;
+        pAPConnection->vsIElength = request->dataBufLength;
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_getBSSParams
+*
+* \b Description: 
+*
+* Roaming Manager calls this function in order to evaluate the quality of new
+* AP candidates for roaming against the quality of current AP.
+* The function returns parameters of current AP.
+*
+* \b ARGS:
+*
+*  O   - currentAP - Pointer to parameters list of current AP \n
+*
+* \b RETURNS:
+*
+*  Pointer to current BSS parameters database if successful, NULL otherwise.
+*
+* \sa 
+*/
+bssEntry_t *apConn_getBSSParams(TI_HANDLE hAPConnection)
+{
+#ifdef TI_DBG
+    if (hAPConnection == NULL) /* Failed to allocate control block */
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
+        return NULL;
+    }
+#endif
+        
+    return currBSS_getBssInfo(((apConn_t *)hAPConnection)->hCurrBSS);
+}
+
+
+/**
+ *
+ * apConn_isSiteBanned
+ *
+ * \b Description: 
+ *
+ * Roaming Manager calls this function during selection of new candidate for roaming.
+ * Only APs which are not marked as banned are allowed to be selected.
+ *
+ * \b ARGS:
+ *
+ *  O   - givenAp - Pointer to BSSID to check if banned \n
+ *
+ * \b RETURNS:
+ *
+ *  TRUE if banned, FALSE otherwise.
+ *
+ * \sa 
+ */
+BOOL apConn_isSiteBanned(TI_HANDLE hAPConnection, macAddress_t * givenAp)
+{
+    apConn_t * pAPConnection = (apConn_t *) hAPConnection;
+
+    return rsn_isSiteBanned(pAPConnection->hPrivacy, *givenAp);
+}
+
+
+/**
+*
+* apConn_getPreAuthAPStatus
+*
+* \b Description: 
+*
+* Roaming Manager calls this function during selection of new candidate for roaming.
+* Among all APs with good quality, those who were pre-authenticated are preferred. 
+*
+* \b ARGS:
+*
+*  O   - givenAp - Pointer to BSSID to check the pre-authenticated status for \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+BOOL apConn_getPreAuthAPStatus(TI_HANDLE hAPConnection,
+                              macAddress_t *givenAp)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    paramInfo_t     param;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    param.paramType = RSN_PRE_AUTH_STATUS;
+    os_memoryCopy(pAPConnection->hOs, (void *)param.content.rsnApMac.addr, (void *)givenAp->addr, MAC_ADDR_LEN);
+    rsn_getParam(pAPConnection->hPrivacy, &param);
+
+    return param.content.rsnPreAuthStatus;
+}
+
+
+/**
+*
+* apConn_preAuthenticate
+*
+* \b Description: 
+*
+* Roaming Manager calls this function periodically in order to update the list
+* of pre-authenticated APs. The list is managed by WLAN driver and required
+* by Roaming Manager during selection of roaming candidate process.  
+*
+* \b ARGS:
+*
+*  I   - listAPs - List of APs to pre-authenticate \n
+*  I   - sizeOfList - Size of list of APs to pre-authenticate \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_preAuthenticate(TI_HANDLE hAPConnection, bssList_t *listAPs)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    bssidList4PreAuth_t apList;
+    UINT32              listIndex, apListIndex;
+    bssEntry_t          *pCurrentAP;
+    UINT8               *pRsnIEs;
+
+#ifdef TI_DBG
+    if ((hAPConnection == NULL) || (listAPs == NULL))
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: AP Connection context is not initiated\n"));
+        return NOK;
+    }
+        
+        WLAN_REPORT_INFORMATION(pAPConnection->hReport, SITE_MGR_MODULE_LOG, ("apConn_reserveResources \n"));
+#endif
+
+    for (listIndex=0, apListIndex=0; listIndex<listAPs->numOfEntries; listIndex++)
+    {
+        os_memoryCopy(pAPConnection->hOs, &(apList.bssidList[apListIndex].bssId), 
+                      (void *)listAPs->BSSList[listIndex].BSSID.addr, MAC_ADDR_LEN);
+
+        /* search in the buffer pointer to the beginning of the
+            RSN IE according to the IE ID */
+        if (!parseIeBuffer(pAPConnection->hOs, listAPs->BSSList[listIndex].pBuffer, listAPs->BSSList[listIndex].bufferLength, RSN_IE_ID, &pRsnIEs, NULL, 0))
+        {
+            WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                  ("apConn_preAuthenticate, no RSN IE was found \n")); 
+            WLAN_REPORT_HEX_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                  listAPs->BSSList[listIndex].pBuffer, listAPs->BSSList[listIndex].bufferLength); 
+
+            continue;
+        }
+
+        apList.bssidList[apListIndex].pRsnIEs = (dot11_RSN_t*)pRsnIEs;
+        apList.bssidList[apListIndex].rsnIeLen = apList.bssidList[apListIndex].pRsnIEs->hdr.eleLen+2;
+        apListIndex++;
+    }
+
+    /* Start pre-auth after any Conn succ (including first), 
+    and not only when a New BSSID was added, in order to save/refresh 
+    PMKID of the current AP.*/
+    {
+        /* Add the current BSSID to the list */
+        pCurrentAP = apConn_getBSSParams(pAPConnection);
+        os_memoryCopy(pAPConnection->hOs, &(apList.bssidList[apListIndex].bssId), 
+                      (void *)pCurrentAP->BSSID.addr, MAC_ADDR_LEN);
+        /* search in the buffer pointer to the beginning of the
+            RSN IE according to the IE ID */
+
+        if (!parseIeBuffer(pAPConnection->hOs, pCurrentAP->pBuffer, pCurrentAP->bufferLength, RSN_IE_ID, &pRsnIEs, NULL, 0))
+        {
+            WLAN_REPORT_ERROR(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                  ("apConn_preAuthenticate, no RSN IE was found in the current BSS, BSSID=0x%x-0x%x-0x%x-0x%x-0x%x-0x%x \n",
+                                   pCurrentAP->BSSID.addr[0], pCurrentAP->BSSID.addr[1], pCurrentAP->BSSID.addr[2], 
+                                   pCurrentAP->BSSID.addr[3], pCurrentAP->BSSID.addr[4], pCurrentAP->BSSID.addr[5])); 
+            HexDumpData(pCurrentAP->pBuffer, pCurrentAP->bufferLength);
+            apList.bssidList[apListIndex].pRsnIEs = NULL;
+            apList.bssidList[apListIndex].rsnIeLen = 0;
+        }
+        else
+        {
+            apList.bssidList[apListIndex].pRsnIEs = (dot11_RSN_t*)pRsnIEs;
+            apList.bssidList[apListIndex].rsnIeLen = apList.bssidList[apListIndex].pRsnIEs->hdr.eleLen+2;
+        }
+        apList.NumOfItems = apListIndex+1;
+        rsn_startPreAuth(pAPConnection->hPrivacy, &apList);
+    }
+    return OK;
+}
+
+
+/**
+*
+* apConn_prepareToRoaming
+*
+* \b Description: 
+*
+* Roaming Manager calls this function when roaming event is received and Roaming Manager
+* wishes to start the roaming process, thus want to prevent scan and measurement in the
+* system. The function will return OK if the allocation is performed, PEND if the
+* allocation is started, NOK in case the allocation is not possible.
+* In case of successful allocation, Roaming Manager will be informed via callback about
+* the end of the allocation.   
+*
+* \b ARGS:
+*
+*  I   - reason - the reason for roaming \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_prepareToRoaming(TI_HANDLE hAPConnection, apConn_roamingTrigger_e reason)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    pAPConnection->roamReason = reason;
+    
+    return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_PREPARE_FOR_ROAMING, pAPConnection);
+}
+
+/**
+*
+* apConn_indicateSwitchChannelInProgress
+*
+* \b Description: 
+*
+* This function is called when switch channel process is started; it will trigger 
+* AP Connection state machine from 'Wait for roaming start' to 'Switch channel in progress'
+* state.
+*
+* \b ARGS:
+*
+*  I   - reason - the reason for roaming \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_indicateSwitchChannelInProgress(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START_SWITCH_CHANNEL, pAPConnection);
+    return OK;
+}
+
+
+/**
+*
+* apConn_indicateSwitchChannelFinished
+*
+* \b Description: 
+*
+* This function is called when switch channel process is finished
+*
+* \b ARGS:
+*
+*  I   - reason - the reason for roaming \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_indicateSwitchChannelFinished(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_SWITCH_CH, pAPConnection);
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_start
+*
+* \b Description: 
+*
+* Called by SME module when new connection has been successfully established (first time connection)
+*
+* \b ARGS:
+*
+*  I   - isValidBSS - if FALSE, no roaming shall be performed, disconnect upon any roaming event; 
+*                   other parameters of current AP can be received from Current BSS module
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_start(TI_HANDLE hAPConnection, BOOLEAN roamingEnabled)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    pAPConnection->roamingEnabled = roamingEnabled;
+
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_START, pAPConnection);
+    return OK;
+}
+
+
+/**
+*
+* apConn_stop
+*
+* \b Description: 
+*
+* Called by SME module when current connection must be taken down
+* (due to driver download, connection failure or any other reason)
+*
+* \b ARGS:
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_stop(TI_HANDLE hAPConnection, BOOLEAN removeKeys, BOOLEAN immediateShutdown)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    pAPConnection->stopFromSmeNum++;
+    pAPConnection->removeKeys = removeKeys;
+    pAPConnection->sendDeauthPacket = !(immediateShutdown); /* If immediateShutdown is TRUE, no need to send DISASSOC frame - used during unload process */
+    pAPConnection->reNegotiateTSPEC = FALSE;
+    pAPConnection->voiceTspecConfigured = FALSE;
+       pAPConnection->videoTspecConfigured = FALSE;
+
+    /* Mark that the connection is stopped due to reason outside the scope of this module */
+    pAPConnection->bNonRoamingDisAssocReason = TRUE;
+
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
+    return OK;
+}
+
+
+/**
+*
+* apConn_reportRoamingEvent
+*
+* \b Description: 
+*
+* Called when one of roaming events occur
+*
+* \b ARGS:
+*
+*  I   - roamingEventType   
+*  I   - pRoamingEventData - in case of 'Tx rate' event, or AP disconnect
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_reportRoamingEvent(TI_HANDLE hAPConnection,
+                                    apConn_roamingTrigger_e roamingEventType,
+                                    roamingEventData_u *pRoamingEventData)
+{
+    apConn_t    *pAPConnection = (apConn_t *)hAPConnection; 
+    paramInfo_t  param;  /* parameter for retrieving BSSID */
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                          ("apConn_reportRoamingEvent, type=%d, cur_state=%d, roamingEnabled=%d, roamEventCallb=%p  \n", 
+                           roamingEventType, pAPConnection->currentState,
+                           pAPConnection->roamingEnabled, pAPConnection->roamEventCallb));
+
+    /* 1. Check if this is Rogue AP test case */
+    if (roamingEventType == ROAMING_TRIGGER_AP_DISCONNECT)
+    {   
+        if (pRoamingEventData != NULL)
+        {   /* Save the disconnect reason for future use */
+            pAPConnection->APDisconnect.uStatusCode     = pRoamingEventData->APDisconnect.uStatusCode;
+            pAPConnection->APDisconnect.bDeAuthenticate = pRoamingEventData->APDisconnect.bDeAuthenticate;
+        }
+        if ((pAPConnection->ignoreDeauthReason0) && (pRoamingEventData!=NULL) &&
+               (pAPConnection->APDisconnect.uStatusCode == 0))
+        {   /* This is required for Rogue AP test,
+                When Rogue AP due to invalid User name, deauth with reason 0 arrives before the Rogue AP,
+                and this EXC test fails.*/
+            WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                  ("apConn_reportRoamingEvent, Ignore DeAuth with reason 0 \n"));
+            return OK;
+        }
+        WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+              ("apConn_reportRoamingEvent, DeAuth with reason %d \n", pAPConnection->APDisconnect.uStatusCode));
+
+        if (pAPConnection->APDisconnect.uStatusCode == STATUS_CODE_802_1X_AUTHENTICATION_FAILED)
+        {
+          #ifdef EXC_MODULE_INCLUDED
+            TI_STATUS    status;
+
+            /* Raise the EAP-Failure as event */
+            status = excMngr_rogueApDetected (pAPConnection->hExcMngr, RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED);
+          #endif
+
+            
+            /* Remove AP from candidate list for a specified amount of time */
+            param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
+            siteMgr_getParam(pAPConnection->hSiteMgr, &param);
+            
+            WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
+                 ("current station is banned from the roaming candidates list for %d Ms\n",
+                  RSN_AUTH_FAILURE_TIMEOUT));
+
+            rsn_banSite(pAPConnection->hPrivacy, param.content.siteMgrDesiredBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_AUTH_FAILURE_TIMEOUT);
+        }
+
+    }
+
+    /* 2. Check if received trigger is masked out */
+    if (((pAPConnection->isConsTxFailureMaskedOut) && (roamingEventType == ROAMING_TRIGGER_MAX_TX_RETRIES)) ||
+        ((pAPConnection->isRssiTriggerMaskedOut)   && (roamingEventType == ROAMING_TRIGGER_LOW_QUALITY)) ||
+        ((pAPConnection->isSnrTriggerMaskedOut)    && (roamingEventType == ROAMING_TRIGGER_LOW_SNR)) ||
+        ((pAPConnection->islowRateTriggerMaskedOut)&& (roamingEventType == ROAMING_TRIGGER_LOW_TX_RATE)))
+    {
+        WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("apConn_reportRoamingEvent, trigger ignored \n"));
+        return OK;
+    }
+
+    /* 3.  Valid trigger received: */
+    /* 3a. Update statistics */
+    pAPConnection->roamingTriggerEvents[roamingEventType]++;
+
+    /* 3b. Store the most severe trigger */
+    if (pAPConnection->roamReason < roamingEventType)
+    {
+        pAPConnection->roamReason = roamingEventType;
+    }
+
+    /* 3c. Check if Roaming Manager is available */
+    if (((!pAPConnection->roamingEnabled) || (pAPConnection->roamEventCallb == NULL) ||
+          (pAPConnection->currentState == AP_CONNECT_STATE_IDLE))
+        && (roamingEventType > ROAMING_TRIGGER_LOW_QUALITY)
+        && (roamingEventType != ROAMING_TRIGGER_MAX_TX_RETRIES)) 
+        /* 
+         * The last condition was added so that MAX_TX_RETRIES would not cause a disconnect.
+         * This is done because the current default value for max TX retries is good enough for 
+         * roaming (i.e. it indicates a low quality AP), but would cause unnecessary disconnects
+         * if used when roaming is disabled
+         */
+    {
+        /* 'Any SSID' configured, meaning Roaming Manager is not allowed to perform roaming, 
+           or Roaming Manager is not registered for roaming events;
+           unless this is trigger to change parameters of background scan, disconnect the link */
+        WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("Disconnecting link due to roaming event: ev = %d\n", roamingEventType));
+
+        /*  Handle IBSS case TBD to remove 
+            Handle also the case where A first connection is in progress, and 
+            de-auth arrived. */
+        if (pAPConnection->currentState == AP_CONNECT_STATE_IDLE)
+        {
+            apConn_reportConnStatusToSME(pAPConnection);
+        }
+        else
+        {
+            /* Infra-structure BSS case - disconnect the link */
+            if (roamingEventType >= ROAMING_TRIGGER_AP_DISCONNECT)
+            {
+                pAPConnection->removeKeys = TRUE;
+            }
+            else
+            {
+                pAPConnection->removeKeys = FALSE;
+            }
+            UPDATE_SEND_DEAUTH_PACKET_FLAG(roamingEventType);
+            apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_STOP, pAPConnection);
+        }
+        return OK;
+    }
+
+    /* 4. Check if we are in the middle of switching channel */
+    if (pAPConnection->currentState == AP_CONNECT_STATE_SWITCHING_CHANNEL)
+    {
+        /* Trigger received in the middle of switch channel, continue without reporting Roaming Manager */
+        WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("Roaming event during switch channel: ev = %d\n", roamingEventType));
+        return OK;
+    }
+
+    if (roamingEventType == ROAMING_TRIGGER_LOW_QUALITY) 
+    {
+        EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_LOW_RSSI, NULL,0);
+    }
+    else if (roamingEventType == ROAMING_TRIGGER_LOW_SNR)
+    {
+        EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_LOW_SNR, NULL,0);
+    }
+
+    /* 5. Report Roaming Manager */
+    if ((pAPConnection->roamingEnabled == TRUE) && (pAPConnection->roamEventCallb != NULL))
+    {
+        WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("Roaming event raised: ev = %d\n", roamingEventType));
+        /* Report to Roaming Manager */
+        pAPConnection->roamEventCallb(pAPConnection->hRoamMng, &roamingEventType);
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_RoamHandoffFinished
+*
+* \b Description: 
+*
+* Called when EXC module receives response from the supplicant or recognizes 
+* timeout while waiting for the response 
+*
+* \b ARGS:
+*
+* \b RETURNS:
+*
+* \sa 
+*/
+void apConn_RoamHandoffFinished(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+#ifdef TI_DBG
+    if (hAPConnection == NULL) /* Failed to allocate control block */
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: apConn_create(): Error allocating cb - aborting\n"));
+        return;
+    }
+#endif
+
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_HAND_OVER, pAPConnection);
+}
+
+
+/**
+*
+* apConn_DisconnCompleteInd
+*
+* \b Description: 
+*
+* DISASSOCIATE Packet was sent - proceed with stopping the module
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_DisconnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, UINT32 uStatusCode)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    AP_CONN_VALIDATE_HANDLE(hAPConnection);
+
+    apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_updateNeighborAPsList
+*
+* \b Description: 
+*
+* Called by EXC Manager when Priority APs are found  
+*
+* \b ARGS:
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+void apConn_updateNeighborAPsList(TI_HANDLE hAPConnection, neighborAPList_t *pListOfpriorityAps)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    
+    if (pAPConnection->returnNeighborApsCallb != NULL )
+    {
+        pAPConnection->returnNeighborApsCallb(pAPConnection->hRoamMng, pListOfpriorityAps);
+    }
+}
+
+
+/**
+*
+* apConn_getRoamingStatistics
+*
+* \b Description: 
+*
+* Called from Measurement EXC sub-module when preparing TSM report to the AP. 
+*
+* \b ARGS: AP Connection handle
+*
+* \b RETURNS:
+*
+*  total number of successful roams
+*  delay of the latest successful roam
+*
+* \sa 
+*/
+void apConn_getRoamingStatistics(TI_HANDLE hAPConnection, UINT8 *roamingCount, UINT16 *roamingDelay)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    
+    /* Get (and clear) total number of successful roams */
+    *roamingCount = pAPConnection->roamingSuccesfulHandoverNum;
+    pAPConnection->roamingSuccesfulHandoverNum = 0;
+
+    /* Get delay of the latest roam */
+    *roamingDelay = pAPConnection->lastRoamingDelay;
+    pAPConnection->lastRoamingDelay = 0;
+}
+
+
+
+
+/**
+*
+* apConn_resetRoamingStatistics
+*
+* \b Description: 
+*
+* Called from Measurement EXC sub-module in order to re-start roaming statistics. 
+*
+* \b ARGS: AP Connection handle
+*
+* \b RETURNS:
+*
+*  total number of successful roams
+*  delay of the latest successful roam
+*
+* \sa 
+*/
+void apConn_resetRoamingStatistics(TI_HANDLE hAPConnection)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+    
+    pAPConnection->resetReportedRoamingStatistics = TRUE;
+    pAPConnection->roamingSuccesfulHandoverNum = 0;
+    pAPConnection->lastRoamingDelay = 0;
+}
+
+
+/**
+*
+* apConn_printStatistics
+*
+* \b Description: 
+*
+* Called by Site Manager when request to print statistics is requested from CLI  
+*
+* \b ARGS: AP Connection handle
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+void apConn_printStatistics(TI_HANDLE hAPConnection)
+{   
+    WLAN_OS_REPORT(("-------------- Roaming Statistics ---------------\n\n"));
+    WLAN_OS_REPORT(("- Low TX rate = %d\n",     ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_TX_RATE]));
+    WLAN_OS_REPORT(("- Low SNR = %d\n",         ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_SNR]));
+    WLAN_OS_REPORT(("- Low Quality = %d\n",     ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_LOW_QUALITY]));
+    WLAN_OS_REPORT(("- MAX TX retries = %d\n",  ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_MAX_TX_RETRIES]));
+    WLAN_OS_REPORT(("- BSS Loss TX = %d\n",     ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_BSS_LOSS]));
+    WLAN_OS_REPORT(("- Switch Channel = %d\n",  ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_SWITCH_CHANNEL]));
+    WLAN_OS_REPORT(("- AP Disconnect = %d\n",   ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_AP_DISCONNECT]));
+    WLAN_OS_REPORT(("- SEC attack = %d\n",      ((apConn_t *)hAPConnection)->roamingTriggerEvents[ROAMING_TRIGGER_SECURITY_ATTACK]));
+    WLAN_OS_REPORT(("\n"));
+    WLAN_OS_REPORT(("- Succesfull roaming = %d\n",                  ((apConn_t *)hAPConnection)->roamingSuccesfulHandoverTotalNum));
+    WLAN_OS_REPORT(("- Unsuccesfull roaming = %d\n",                ((apConn_t *)hAPConnection)->roamingFailedHandoverNum));
+    WLAN_OS_REPORT(("- Giving up roaming = %d\n",                   ((apConn_t *)hAPConnection)->retainCurrAPNum));
+    WLAN_OS_REPORT(("- Disconnect cmd from roaming manager = %d\n", ((apConn_t *)hAPConnection)->disconnectFromRoamMngrNum));
+    WLAN_OS_REPORT(("- Disconnect cmd from SME = %d\n",             ((apConn_t *)hAPConnection)->stopFromSmeNum));
+    WLAN_OS_REPORT(("\n"));
+}
+
+
+
+/**
+*
+* apConn_getVendorSpecificIE
+*
+* \b Description: 
+*
+* Called by Association SM when request to associate is built and sent to AP;
+* returns request updated with vendor specific info-element
+*
+* \b ARGS: 
+*
+*  I   - hAPConnection - AP Connection handle\n
+*  O   - pRequest - pointer to request buffer\n
+*  O   - len - size of returned IE\n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS apConn_getVendorSpecificIE(TI_HANDLE hAPConnection, UINT8 *pRequest, UINT32 *len)
+{
+    apConn_t *pAPConnection = (apConn_t *)hAPConnection;
+
+    if (pAPConnection->vsIElength > 0)
+    {
+        *len = pAPConnection->vsIElength;
+        os_memoryCopy(pAPConnection->hOs, pRequest, pAPConnection->vsIEbuf, pAPConnection->vsIElength);
+    }
+    else
+    {
+        *len = 0;
+    }
+    return OK;
+}
+
+
+/* Internal functions implementation */
+
+
+/**
+*
+* apConn_smEvent
+*
+* \b Description: 
+*
+* AP Connection state machine transition function
+*
+* \b ARGS:
+*
+*  I/O - currentState - current state in the state machine\n
+*  I   - event - specific event for the state machine\n
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_smEvent(apConn_smStates *currState, UINT8 event, void* data)
+{
+    TI_STATUS   status;
+    UINT8       nextState;
+    apConn_t    *pAPConnection;
+
+    pAPConnection = (apConn_t *)data;
+    status = fsm_GetNextState(pAPConnection->apConnSM, (UINT8)*currState, event, &nextState);
+    if (status == OK)
+    {
+        WLAN_REPORT_SM(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                                  ("<%s, %s> --> %s\n\n",
+                                   apConn_stateDesc[*currState],
+                                   apConn_eventDesc[event],
+                                   apConn_stateDesc[nextState]));
+
+        status = fsm_Event(pAPConnection->apConnSM, (UINT8 *)currState, event, pAPConnection);
+        return status;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, ("apConn_smEvent, fsm_GetNextState error\n"));
+        return status;
+    }
+}
+
+
+/**
+*
+* apConn_smNop - Do nothing
+*
+* \b Description: 
+*
+* Do nothing in the SM.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS apConn_smNop(void *pData)
+{
+        WLAN_REPORT_INFORMATION((((apConn_t *)pData)->hReport), ROAMING_MANAGER_MODULE_LOG, ("apConn_smNop\n"));
+        return OK;
+    }
+
+
+/**
+*
+* apConn_smUnexpected - Unexpected event
+*
+* \b Description: 
+*
+* Unexpected event in the SM.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* 
+*/
+static TI_STATUS apConn_smUnexpected(void *pData)
+{
+    WLAN_REPORT_INFORMATION(((apConn_t *)pData)->hReport, ROAMING_MANAGER_MODULE_LOG, ("apConn_smUnexpected\n"));
+    return NOK;
+}
+
+
+/**
+*
+* apConn_startWaitingForTriggers
+*
+* \b Description: 
+*
+* SME informs AP Connection module about successfull link establishment; start wiating for roaming triggers
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_startWaitingForTriggers(void *pData)
+{
+    apConn_t    *pAPConnection;
+    apConn_connStatus_t reportStatus;  
+    paramInfo_t param;
+
+    pAPConnection = (apConn_t *)pData;
+    
+    if ((pAPConnection->roamingEnabled) && (pAPConnection->reportStatusCallb != NULL))
+    {
+        param.paramType   = ASSOC_ASSOCIATION_RESP_PARAM;
+
+        assoc_getParam(pAPConnection->hAssoc, &param);
+        reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
+        reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
+
+        reportStatus.status = CONN_STATUS_CONNECTED;
+        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);   
+    }
+    pAPConnection->firstAttempt2Roam = TRUE;
+    pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
+    pAPConnection->removeKeys = TRUE;
+    pAPConnection->sendDeauthPacket = TRUE;
+    pAPConnection->reNegotiateTSPEC = FALSE;
+    pAPConnection->voiceTspecConfigured = FALSE;
+       pAPConnection->videoTspecConfigured = FALSE;
+    return OK;
+}
+
+
+/**
+*
+* apConn_connectedToNewAP
+*
+* \b Description: 
+*
+* After roaming was requested, Connection SM informs AP Connection module about
+* successful link re-establishment; start waiting for roaming triggers
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_connectedToNewAP(void *pData)
+{
+    apConn_t    *pAPConnection;
+    apConn_connStatus_t reportStatus; 
+    paramInfo_t param;
+
+    pAPConnection = (apConn_t *)pData;
+    
+    /* Configure SCR group back to connection */
+    scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECTED);
+
+    /* Erase vendor specific info-element if was defined for last AP Assoc request */
+    pAPConnection->vsIElength = 0;
+
+    /* TBD Notify Curr BSS module about update of current AP database */
+
+    if (pAPConnection->roamingFailedHandoverNum>0)
+    {
+        pAPConnection->roamingFailedHandoverNum--;
+    }
+    /* Report Roaming Manager */
+    if (pAPConnection->reportStatusCallb != NULL)
+    {
+        param.paramType   = ASSOC_ASSOCIATION_RESP_PARAM;
+
+        assoc_getParam(pAPConnection->hAssoc, &param);
+        reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
+        reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
+
+        reportStatus.status = CONN_STATUS_HANDOVER_SUCCESS;
+
+        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);   
+    }
+    pAPConnection->firstAttempt2Roam = TRUE;
+    pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
+    pAPConnection->roamingSuccesfulHandoverTotalNum++;
+    pAPConnection->removeKeys = TRUE;
+    pAPConnection->sendDeauthPacket = TRUE;
+    pAPConnection->reNegotiateTSPEC = FALSE;
+    pAPConnection->voiceTspecConfigured = FALSE;
+       pAPConnection->videoTspecConfigured = FALSE;
+
+    
+    if (!pAPConnection->resetReportedRoamingStatistics)
+    {
+        pAPConnection->roamingSuccesfulHandoverNum++;
+        pAPConnection->lastRoamingDelay = 
+            (UINT16)os_timeStampMs(pAPConnection->hOs) - pAPConnection->roamingStartedTimestamp;          
+    }
+    else
+    {
+        pAPConnection->resetReportedRoamingStatistics = FALSE;
+    }
+
+    /* Raise event of Roaming Completion */
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
+                            ("EvHandlerSendEvent -ROAMING_COMPLETE\n" ));
+    EvHandlerSendEvent(pAPConnection->hEvHandler, IPC_EVENT_ROAMING_COMPLETE, NULL, 0);
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_stopConnection
+*
+* \b Description: 
+*
+* Stop required before roaming was started
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_stopConnection(void *pData)
+{
+    apConn_t *pAPConnection;
+    disConnType_e disConnType;
+    pAPConnection = (apConn_t *)pData;
+    
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                    ("apConn_stopConnection, calls conn_stop, removeKeys=%d, sendDeauthPacket=%d \n", pAPConnection->removeKeys, pAPConnection->sendDeauthPacket));
+    
+    /* Erase vendor specific info-element if was defined for last AP Assoc request */
+    pAPConnection->vsIElength = 0;
+    
+    /* In case AP connection was stopped by SME, and radioOn is false, meaning immidiate shutdown is required without disassoc frame */
+    /* Otherwise, ask for normal disconnection with disassoc frame */
+    disConnType = (pAPConnection->sendDeauthPacket == TRUE) ? DISCONN_TYPE_DEAUTH : DISCONN_TYPE_IMMEDIATE;
+    
+    /* Stop Connection state machine - always immediate TBD */
+    conn_stop(pAPConnection->hConnSm, 
+              disConnType,
+              STATUS_UNSPECIFIED,
+              FALSE,   /* pAPConnection->removeKeys - for Roaming, do not remove the keys */              
+              apConn_DisconnCompleteInd,
+              pAPConnection);
+    
+    return OK;
+}
+
+
+/**
+*
+* apConn_reportDisconnected
+*
+* \b Description: 
+*
+* Moving from 'Disconnecting' state to 'Idle':
+*   RoamMgr.status("not-connected")
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_reportDisconnected(void *pData)
+{
+    apConn_t    *pAPConnection;
+    apConn_connStatus_t reportStatus; 
+
+    pAPConnection = (apConn_t *)pData;
+
+    if (pAPConnection->reportStatusCallb != NULL) 
+    {
+        reportStatus.status = CONN_STATUS_NOT_CONNECTED;
+        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);   
+    }
+    
+    pAPConnection->firstAttempt2Roam = TRUE;
+
+    /* Notify SME */
+    apConn_reportConnStatusToSME(pAPConnection);
+    
+    return OK;
+}
+
+
+/**
+*
+* apConn_retainAP
+*
+* \b Description: 
+*
+* Roaming Manager gives up on roaming.
+* Moving from 'Wait for connection command' back to 'Wait for roam started.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_retainAP(void *data)
+{
+    apConn_t    *pAPConnection;
+    apConn_connStatus_t reportStatus; 
+    paramInfo_t param;
+
+    pAPConnection = (apConn_t *)data;
+
+    /* Configure SCR group back to connection */
+    scr_setGroup (pAPConnection->hScr, SCR_GID_CONNECTED);
+
+    /* Report Roaming Manager */
+    if (pAPConnection->reportStatusCallb != NULL) 
+    {
+        param.paramType   = ASSOC_ASSOCIATION_RESP_PARAM;
+
+        assoc_getParam(pAPConnection->hAssoc, &param);
+        reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
+        reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
+
+        reportStatus.status = CONN_STATUS_HANDOVER_SUCCESS;
+
+        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);   
+    }
+    pAPConnection->retainCurrAPNum++;
+
+    pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
+    pAPConnection->removeKeys = TRUE;
+    pAPConnection->sendDeauthPacket = TRUE;
+    pAPConnection->reNegotiateTSPEC = FALSE;
+    pAPConnection->voiceTspecConfigured = FALSE;
+       pAPConnection->videoTspecConfigured = FALSE;
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_requestCCKM
+*
+* \b Description: 
+*
+* Roaming Manager requests to roaming.
+* Get CCKM (prepare hand-off).
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_requestCCKM(void *data)
+{
+    apConn_t    *pAPConnection;
+    TI_STATUS   status;
+
+        pAPConnection = (apConn_t *)data;
+    
+#ifdef EXC_MODULE_INCLUDED
+        /* Send request to EXC module */
+    apConn_calcNewTsf(pAPConnection, (UINT8 *)&(pAPConnection->newAP->lastRxTSF), pAPConnection->newAP->lastRxHostTimestamp, pAPConnection->newAP->beaconInterval);
+    status = excMngr_startCckm(pAPConnection->hExcMngr, &(pAPConnection->newAP->BSSID), (UINT8 *)&(pAPConnection->newAP->lastRxTSF));
+#else
+        status  = OK;
+        apConn_RoamHandoffFinished(pAPConnection);
+#endif
+        return status;
+    }
+
+
+#ifdef EXC_MODULE_INCLUDED
+/**
+*
+* calcNewTsfTimestamp - Calculates the TSF
+*
+* \b Description: 
+*
+* Calculates the TSF according to the delta of the TSF from the last Beacon/Probe Resp and the current time.
+*
+* \b ARGS:
+*
+*  I   - hRoamingMngr - pointer to the roamingMngr SM context  \n
+*  I/O - tsfTimeStamp - the TSF field in the site entry of the roaming candidate AP
+*  I   - newSiteOsTimeStamp - the TS field in the site entry of the roaming candidate AP
+*
+* \b RETURNS:
+*
+*  Nothing.
+*
+* 
+*/
+static void apConn_calcNewTsf(apConn_t *hAPConnection, UINT8 *tsfTimeStamp, UINT32 newSiteOsTimeStamp, UINT32 beaconInterval)
+{
+    apConn_t    *pAPConnection = hAPConnection;
+    UINT32      osTimeStamp = os_timeStampMs(pAPConnection->hOs);
+    UINT32      deltaTimeStamp; 
+    UINT32      tsfLsdw,tsfMsdw, newOsTimeStamp; 
+    UINT32      remainder;
+    UINT8       newTsfTimestamp[TIME_STAMP_LEN];
+
+    /* get the delta TS between the TS of the last Beacon/ProbeResp-from the site table
+    and the current TS */
+    deltaTimeStamp = osTimeStamp - newSiteOsTimeStamp;
+    tsfLsdw = *((UINT32*)&tsfTimeStamp[0]); 
+    tsfMsdw = *((UINT32*)&tsfTimeStamp[4]);
+    
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                            (" TSF time LSDW reversed=%x, TSF time MSDW reversed=%x\n", 
+                             tsfLsdw, tsfMsdw));
+
+    deltaTimeStamp = deltaTimeStamp*1000;/* from mSec to uSec*/
+    /* Before adding, save remainder */
+    remainder = tsfTimeStamp[3] + ((deltaTimeStamp & 0xff000000) >> 24);
+
+    /* The LS DW of the TS is the TSF taken from the last Beacon/Probe Resp
+        + the delta TS from the time the Beacon/Probe Resp arrive till now. */
+    newOsTimeStamp = deltaTimeStamp+tsfLsdw;
+
+    /* substracting one beacon interval */
+    newOsTimeStamp -= (beaconInterval * 1024); /* im usec */
+
+    /* save just for debug printout */
+    deltaTimeStamp +=osTimeStamp; /* uMsec */
+    /* update the LSB of the TSF */
+    newTsfTimestamp[0] = newOsTimeStamp & 0x000000ff;
+    newTsfTimestamp[1] = (newOsTimeStamp & 0x0000ff00) >> 8;
+    newTsfTimestamp[2] = (newOsTimeStamp & 0x00ff0000) >> 16;
+    newTsfTimestamp[3] = (newOsTimeStamp & 0xff000000) >> 24;
+
+    /* increase the MSB in case of overflow */
+    if (remainder > 0xff)
+    {
+        tsfMsdw++;
+        
+    }
+    /* update the MSB of the TSF */
+    newTsfTimestamp[4] = tsfMsdw & 0x000000ff;
+    newTsfTimestamp[5] = (tsfMsdw & 0x0000ff00) >> 8;
+    newTsfTimestamp[6] = (tsfMsdw & 0x00ff0000) >> 16;
+    newTsfTimestamp[7] = (tsfMsdw & 0xff000000) >> 24;
+
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                            (" NEW TSF time: reversedTsfTimeStamp= 0x%x, New deltaTimeStamp= 0x%x, \n remainder=0x%x, new tsfTimeStamp=%x-%x-%x-%x-%x-%x-%x-%x\n",  
+                             newOsTimeStamp, deltaTimeStamp, remainder,
+                             newTsfTimestamp[0], newTsfTimestamp[1], newTsfTimestamp[2], newTsfTimestamp[3], 
+                             newTsfTimestamp[4], newTsfTimestamp[5], newTsfTimestamp[6], newTsfTimestamp[7]));
+
+    os_memoryCopy(pAPConnection->hOs, tsfTimeStamp, newTsfTimestamp, TIME_STAMP_LEN);
+}
+#endif
+
+
+/**
+*
+* apConn_invokeConnectionToNewAp
+*
+* \b Description: 
+*
+* Got CCKM (hand-off), start re-connection to another AP
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_invokeConnectionToNewAp(void *data)
+{
+    apConn_t    *pAPConnection;
+    connType_e  connType;
+    paramInfo_t param;
+    UINT8   staPrivacySupported, apPrivacySupported;
+    BOOL    renegotiateTspec = FALSE;
+    
+    pAPConnection = (apConn_t *)data;
+
+    pAPConnection->roamingStartedTimestamp = os_timeStampMs(pAPConnection->hOs);
+
+    /* Check privacy compatibility */
+    param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
+    rsn_getParam(pAPConnection->hPrivacy, &param);
+
+    staPrivacySupported = (param.content.rsnEncryptionStatus == RSN_CIPHER_NONE) ? FALSE : TRUE;
+    apPrivacySupported  = ((pAPConnection->newAP->capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TRUE : FALSE;
+
+    if (staPrivacySupported != apPrivacySupported)
+    {
+        param.paramType = RSN_MIXED_MODE;
+        rsn_getParam(pAPConnection->hPrivacy, &param);
+
+        if (apPrivacySupported ||
+            (!param.content.rsnMixedMode && staPrivacySupported))
+        {
+            WLAN_REPORT_WARNING(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
+                                ("%s: failed privacy comparison %d vs. %d\n", __FUNCTION__, staPrivacySupported, apPrivacySupported));
+            return (apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection));
+        }
+    }
+
+    /* Update data info of desired AP; in case of first attempt to roam,
+       store previous primary site info */
+    if (siteMgr_overwritePrimarySite(pAPConnection->hSiteMgr, pAPConnection->newAP, pAPConnection->firstAttempt2Roam) != OK)
+    {
+        WLAN_REPORT_WARNING(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG,
+                            ("%s: failed to ovewrite Primary Site\n", __FUNCTION__));
+        return (apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection));
+    }
+
+    /* Update re-associate parameter of MLME */
+    if (pAPConnection->requestType == AP_CONNECT_FAST_TO_AP)
+    {
+        connType = CONN_TYPE_ROAM;
+    }
+    else
+    {
+        connType = CONN_TYPE_FIRST_CONN;
+    }
+
+#ifdef EXC_MODULE_INCLUDED
+    /* Check the need in TSPEC re-negotiation */
+    if ( (pAPConnection->voiceTspecConfigured || pAPConnection->videoTspecConfigured)
+                && pAPConnection->reNegotiateTSPEC )
+    {
+        /* If the candidate AP is at least EXCver4 AP, try to re-negotiate TSPECs */
+        if (excMngr_parseExcVer(pAPConnection->hExcMngr, 
+                                pAPConnection->newAP->pBuffer, 
+                                pAPConnection->newAP->bufferLength) >= 4)
+        {
+            renegotiateTspec = TRUE;
+        }
+    }
+#endif
+
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+                            ("%s: calls conn_start, removeKeys=%d, renegotiateTSPEC=%d\n", __FUNCTION__,
+                             pAPConnection->removeKeys, renegotiateTspec));
+
+    /* Start Connection state machine */
+    return conn_start(pAPConnection->hConnSm, 
+                      connType,
+                      apConn_ConnCompleteInd,
+                      pAPConnection,
+                      pAPConnection->removeKeys,
+                      renegotiateTspec);
+}
+
+
+/**
+*
+* apConn_reportConnFail
+*
+* \b Description: 
+*
+* Got 'Failed' indication from Connection state machine - inform Roaming Manager Module
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_reportConnFail(void *data)
+{
+    apConn_t *pAPConnection;
+    apConn_connStatus_t reportStatus; 
+    paramInfo_t param;
+
+    pAPConnection = (apConn_t *)data;
+
+    pAPConnection->firstAttempt2Roam = FALSE;
+    pAPConnection->resetReportedRoamingStatistics = FALSE;
+
+    /* Erase vendor specific info-element if was defined for last AP Assoc request */
+    pAPConnection->vsIElength = 0;
+
+    /* Report to Roaming Manager */
+    if (pAPConnection->reportStatusCallb != NULL)
+    {
+        param.paramType   = ASSOC_ASSOCIATION_RESP_PARAM;
+
+        assoc_getParam(pAPConnection->hAssoc, &param);
+        reportStatus.dataBuf = (char *)(param.content.applicationConfigBuffer.buffer);
+        reportStatus.dataBufLength = param.content.applicationConfigBuffer.bufferSize;
+
+        reportStatus.status = CONN_STATUS_HANDOVER_FAILURE;
+
+        pAPConnection->reportStatusCallb(pAPConnection->hRoamMng, &reportStatus);   
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_configureSCR
+*
+* \b Description: 
+*
+* Got 'Failed' indication from Connection state machine - inform Roaming Manager Module
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_configureDriverBeforeRoaming(void *pData)
+{
+    apConn_t    *pAPConnection = (apConn_t*)pData;
+    paramInfo_t param;
+    
+    /* Configure SCR group of allowed clients according to 'Roaming' rule */
+    scr_setGroup (pAPConnection->hScr, SCR_GID_ROAMING);
+    param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
+    qosMngr_getParams(pAPConnection->hQos, &param);
+    pAPConnection->voiceTspecConfigured = param.content.TspecConfigure.voiceTspecConfigure;  
+       pAPConnection->videoTspecConfigured = param.content.TspecConfigure.videoTspecConfigure;  
+    pAPConnection->resetReportedRoamingStatistics = FALSE;
+    return OK;
+}
+
+
+/**
+*
+* apConn_swChFinished
+*
+* \b Description: 
+*
+* Switch channel completed; if there were roaming Manager triggers meanwhile, 
+* inform Roaming Manager Module
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_swChFinished(void *pData)
+{
+    apConn_t *pAPConnection = (apConn_t *)pData;
+
+    /* Inform Current BSS module */
+    currBSS_restartRssiCounting(pAPConnection->hCurrBSS);
+
+    /* If there are unreported roaming triggers of 'No AP' type, 
+       report them now to roaming manager */
+    if (pAPConnection->roamReason >= ROAMING_TRIGGER_MAX_TX_RETRIES)
+    {
+        if ((pAPConnection->roamingEnabled == TRUE) && 
+            (pAPConnection->roamEventCallb != NULL))
+        {
+            /* Report to Roaming Manager */
+            pAPConnection->roamEventCallb(pAPConnection->hRoamMng, &pAPConnection->roamReason);
+        }
+    }
+    else
+    {
+        pAPConnection->roamReason = ROAMING_TRIGGER_NONE;
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* apConn_handleTspecReneg
+*
+* \b Description: 
+*
+* This function will be called when moving from CONNECTING state to 
+* START_TSPEC_RENEGOTIATION state. It checks if TSPEC re-negotiation was requested 
+* by roaming manager, if the TSPEC for voice was defined by user application, 
+* if the re-negotiation was performed during hand-over. 
+* If so, it will trigger moving to WAIT_ROAM state, otherwise it will start 
+* TSPEC negotiation, staying in the REESTABLISHING_VOICE state and waiting 
+* for results.
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_handleTspecReneg (void *pData)
+{
+    apConn_t *pAPConnection = (apConn_t *)pData;
+    paramInfo_t param;
+
+    if (pAPConnection->voiceTspecConfigured && pAPConnection->reNegotiateTSPEC)
+    {
+        param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
+        qosMngr_getParams(pAPConnection->hQos, &param);
+
+        if (param.content.TspecConfigure.voiceTspecConfigure == TRUE)
+        {
+            /* TSPEC is already configured, move to CONNECTED */
+            return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
+        }
+        else
+        {
+            param.paramType = QOS_MNGR_RESEND_TSPEC_REQUEST;
+            param.content.qosRenegotiateTspecRequest.callback = (void *)apConn_qosMngrReportResultCallb;
+            param.content.qosRenegotiateTspecRequest.handler = pData; 
+
+            if (qosMngr_setParams(pAPConnection->hQos, &param) != OK)
+            {
+                /* Re-negotiation of TSPEC cannot be performed */
+                return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
+            }
+            return OK;
+        }
+    }
+    else
+    {
+        /* No need to re-negotiate TSPEC, move to CONNECTED */
+        return apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
+    }
+}
+
+
+/**
+*
+* apConn_qosMngrReportResultCallb
+*
+* \b Description: 
+*
+* This function will be transferred to QoS manager upon request to start negotiation
+* of the TSPEC for voice and signaling, and will be called when the voice TSPEC
+* renegotiation is completed. The function will generate FINISHED_OK or 
+* FINISHED_NOK events to the state machine of AP Connection, triggering change of 
+* the current state.
+*
+* \b ARGS:
+*
+*  I   - hApConn - pointer to AP Connection context\n
+*  I   - result - returned by Traffic admission control\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static TI_STATUS apConn_qosMngrReportResultCallb (TI_HANDLE hApConn, trafficAdmRequestStatus_e result)
+{
+    apConn_t *pAPConnection = (apConn_t *)hApConn;
+
+    AP_CONN_VALIDATE_HANDLE(hApConn);
+
+    if (result == STATUS_TRAFFIC_ADM_REQUEST_ACCEPT) 
+    {
+        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_OK, pAPConnection);
+    }
+    else
+    {
+        apConn_smEvent(&(pAPConnection->currentState), AP_CONNECT_EVENT_FINISHED_NOT_OK, pAPConnection);
+    }
+    return OK;
+}
+
+/**
+*
+* apConn_reportConnStatusToSME
+*
+* \b Description: 
+*
+* Sends report to SME regarding the connection status
+*
+* \b ARGS:
+*
+*  I   - pAPConnection  - pointer to AP Connection context\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+static void apConn_reportConnStatusToSME (apConn_t *pAPConnection)
+{
+    WLAN_REPORT_INFORMATION(pAPConnection->hReport, ROAMING_MANAGER_MODULE_LOG, 
+        ("%s roamingTrigger = %d, APDisconnectStatusCode = %d, bNonRoamingDisAssocReason = %d\n",
+        __FUNCTION__, pAPConnection->roamReason, pAPConnection->APDisconnect.uStatusCode, 
+        pAPConnection->bNonRoamingDisAssocReason));
+
+    /* Check if an outside reason caused the disconnection. */
+    if (pAPConnection->bNonRoamingDisAssocReason)
+    {
+        pAPConnection->bNonRoamingDisAssocReason = FALSE;
+        smeSm_reportConnStatus(pAPConnection->hSme, STATUS_UNSPECIFIED, 0);
+    }
+    /* DisAssociation happened due to roaming trigger */
+    else if (pAPConnection->roamReason == ROAMING_TRIGGER_AP_DISCONNECT)
+    {   /* AP disconnect is a special case of the status delivered to SME */
+        mgmtStatus_e mgmtStatus = ( pAPConnection->APDisconnect.bDeAuthenticate ? STATUS_AP_DEAUTHENTICATE : STATUS_AP_DISASSOCIATE );
+        smeSm_reportConnStatus(pAPConnection->hSme, mgmtStatus, pAPConnection->APDisconnect.uStatusCode);
+    } 
+    else    /* Finally, just send the last roaming trigger */
+    {   
+        smeSm_reportConnStatus(pAPConnection->hSme, STATUS_ROAMING_TRIGGER, (UINT32)pAPConnection->roamReason);
+    }
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/apConn/apConn.h b/sta_dk_4_0_4_32/common/src/Management/apConn/apConn.h
new file mode 100644 (file)
index 0000000..3dd38b6
--- /dev/null
@@ -0,0 +1,129 @@
+/** \file apConn.h
+ *  \brief AP Connection Module API
+ *
+ *  \see apConn.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  AP Connection                                                    *
+ *   PURPOSE: AP Connection Module API                                         *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _AP_CONNECTION_H_
+#define _AP_CONNECTION_H_
+
+#include "802_11Defs.h"
+#include "apConnApi.h"
+
+/* Typedefs */
+/* This struct is used for ROAMING_TRIGGER_AP_DISCONNECT */
+typedef struct  
+{
+       UINT16 uStatusCode;             /* status code of deauth/disassoc packet                                   */
+       BOOL   bDeAuthenticate; /* Whether this packet is DeAuth ( if DisAssoc than FALSE) */
+} APDisconnect_t;
+
+typedef union
+{
+       APDisconnect_t APDisconnect;
+       rate_e             rate;
+} roamingEventData_u;
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+/* Called by Config Manager */
+TI_HANDLE apConn_create(TI_HANDLE hOs);
+TI_STATUS apConn_unload(TI_HANDLE hAPConnection);
+TI_STATUS apConn_config(TI_HANDLE hAPConnection, 
+                                               TI_HANDLE hReport,
+                                               TI_HANDLE hCurrAP,
+                        TI_HANDLE hRoamMng,
+                        TI_HANDLE hSme,
+                                               TI_HANDLE hSiteMgr,
+                                               TI_HANDLE hExcMngr,
+                                               TI_HANDLE hConnSm,
+                                               TI_HANDLE hPrivacy,
+                                               TI_HANDLE hQos,
+                                               TI_HANDLE hCtrl,
+                                               TI_HANDLE hEvHandler,
+                        TI_HANDLE hScr,
+                                               TI_HANDLE hAssoc,
+                                               TI_HANDLE hRegulatoryDomain,
+                        apConnParams_t *pApConnParams);
+
+/* Called by SME and Site Manager */
+TI_STATUS apConn_start(TI_HANDLE hAPConnection, BOOLEAN roamingEnabled);
+TI_STATUS apConn_stop(TI_HANDLE hAPConnection, BOOLEAN removeKeys, BOOLEAN radioOn);
+
+void apConn_printStatistics(TI_HANDLE hAPConnection);
+
+
+/* Called by Connection SM */
+TI_STATUS apConn_ConnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, UINT32 uStatusCode);
+
+TI_STATUS apConn_DisconnCompleteInd(TI_HANDLE hAPConnection, mgmtStatus_e status, UINT32 uStatusCode);
+
+/* Called by Current BSS, Rate Adaptation, RSN and other modules generating roaming events */
+TI_STATUS apConn_reportRoamingEvent(TI_HANDLE hAPConnection,
+                                                                       apConn_roamingTrigger_e roamingEventType,
+                                                                       roamingEventData_u *pRoamingEventData);
+
+/* Called by EXC Manager */
+void apConn_RoamHandoffFinished(TI_HANDLE hAPConnection);
+void apConn_getRoamingStatistics(TI_HANDLE hAPConnection, UINT8 *roamingCount, UINT16 *roamingDelay);
+void apConn_resetRoamingStatistics(TI_HANDLE hAPConnection);
+
+void apConn_updateNeighborAPsList(TI_HANDLE hAPConnection, neighborAPList_t *pListOfpriorityAps);
+
+/* Called by Switch Channel */
+TI_STATUS apConn_indicateSwitchChannelInProgress(TI_HANDLE hAPConnection);
+TI_STATUS apConn_indicateSwitchChannelFinished(TI_HANDLE hAPConnection);
+
+/* Called by Association SM */
+TI_STATUS apConn_getVendorSpecificIE(TI_HANDLE hAPConnection, UINT8 *pRequest, UINT32 *len);
+
+BOOLEAN apConn_isPsRequiredBeforeScan(TI_HANDLE hAPConnection);
+
+#endif /*  _AP_CONNECTION_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/inc/ScanCncnApi.h b/sta_dk_4_0_4_32/common/src/Management/scan/inc/ScanCncnApi.h
new file mode 100644 (file)
index 0000000..550b62d
--- /dev/null
@@ -0,0 +1,362 @@
+/** \file ScanCncnApi.h
+ *  \brief This file include public definitions for the scan concentrator module, comprising its API.
+ *  \author Ronen Kalish
+ *  \date 30-Dec-2004
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNAPI_H__
+#define __SCANCNCNAPI_H__
+
+#include "osApi.h"
+#include "scrApi.h"
+#include "paramOut.h"
+#include "mlmeApi.h"
+#include "MacServices_api.h"
+
+
+/** \enum connectionStatus_e
+ * \brief enumerates the different connection statuses
+ */
+typedef enum
+{
+    STA_CONNECTED = 0,              /**< the station is connected to an infrastructure BSS */
+    STA_NOT_CONNECTED,              /**< the station is not connected to an infrastructure BSS */
+    STA_IBSS                        /**< the station is participating in an IBSS */
+} connectionStatus_e;
+
+
+/** \enum scan_CncnClient_e
+ * \brief enumerates the different possible clients requesting scan from the scan concentrator
+ */
+typedef enum
+{
+    SCAN_SCC_ROAMING_IMMED = 0,     /**< immediate scan for roaming */
+    SCAN_SCC_ROAMING_CONT,          /**< continuous scan for roaming */
+    SCAN_SCC_DRIVER,                /**< driver (SME) scan */
+    SCAN_SCC_APP,                   /**< application (user) scan */
+    SCAN_SCC_NUM_OF_CLIENTS,        /**< number of clients */
+    SCAN_SCC_NO_CLIENT              /**< no client */
+} scan_CncnClient_e;
+
+/** \enum scan_cncnResultStatus_e
+ * \brief enumerates the different scan result statuses
+ */
+typedef enum 
+{
+    SCAN_CRS_RECEIVED_FRAME = 0,            /**< scan not yet completed, indicating a frame received during scan */
+    SCAN_CRS_SCAN_COMPLETE_OK,              /**< scan completed normally */
+    SCAN_CRS_SCAN_RUNNING,                  /**< scan initialized successfully and is now running */
+    SCAN_CRS_SCAN_FAILED,                   /**< 
+                                             * scan failed due to unexpected situation (SCR reject, no 
+                                             * channels available, scan SRV returned NOK, etc)
+                                             */
+    SCAN_CRS_SCAN_STOPPED,                  /**< scan stopped by user */
+    SCAN_CRS_TSF_ERROR,                     /**< TSF error (AP recovery) occurred (for SPS only */
+    SCAN_CRS_SCAN_ABORTED_FW_RESET,         /**< scan aborted due to FW reset */
+    SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY,  /**< scan aborted due to a higher priority client */
+    SCAN_CRS_NUM_OF_RES_STATUS              /**< number of possible result status */
+} scan_cncnResultStatus_e;
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/** \struct scan_frameInfo_t
+ * \brief contains a single frame information, returned by the result CB when a frame is available
+ */
+typedef struct
+{
+    macAddress_t*       bssId;              /* MAC address of the AP from which the frame was received */
+    mlmeFrameInfo_t*    parsedIEs;          /* parsed frame IEs */
+    radioBand_e         band;               /* band on which the frame was received */
+    UINT8               channel;            /* channel on which the frame was received */
+    UINT32              staTSF;             /* TSF of the station when the frame was received */
+    INT8                rssi;               /* RSSI level at which frame was received */
+    rate_e              rate;               /* bitrate at which frame was received */
+    UINT8*              buffer;             /* frame body */
+    UINT16              bufferLength;       /* frame body length */
+} scan_frameInfo_t;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+ /** \typedef scan_resultCB_t
+  * \brief Defines the function prototype for the scan result callback
+  * (notification by the scan concentrator to a client of either a scan
+  * termination or a result frame received).
+  */
+typedef void (*scan_resultCB_t) ( TI_HANDLE clientObj, scan_cncnResultStatus_e status,
+                                 scan_frameInfo_t* frameInfo, UINT16 SPSStatus );
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Creates the scan concentrator 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 scanConcentrator_create( TI_HANDLE hOS );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Finalizes the scan concentrator object (freeing system resources)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_release( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator object.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param hHalCtrl - handle to the Hal Ctrl object.\n
+ * \param hReport - handle to the Report object.\n
+ * \param hRegDomain - handle to the regulatory domain object.\n
+ * \param hSiteMngr - handle to the site manager object.\n
+ * \param hSCR - handle to the SCR object.\n
+ * \param hMacServices - handle to the MacServices object.\n
+ * \param hAPConn - handle to the AP connection object.\n
+ * \param hEventSRV - handle to the event SRV object.\n
+ * \param hMlme - handle to the MLME object.\n
+ * \param hCtrlData - handle to the data CTRL object.\n
+ * \param hHealthMonitor - handle to the health monitor object.\n
+ * \param pScanConcentratorInitParams - pointer to the init parameters structure.\n 
+ */
+void scanConcentrator_init( TI_HANDLE hScanCncn,
+                                                   TI_HANDLE hHalCtrl,
+                            TI_HANDLE hReport,
+                            TI_HANDLE hRegDomain,
+                            TI_HANDLE hSiteMngr,
+                            TI_HANDLE hSCR,
+                            TI_HANDLE hMacServices,
+                            TI_HANDLE hAPConn,
+                            TI_HANDLE hEventSRV,
+                            TI_HANDLE hMlme,
+                            TI_HANDLE hCtrlData,
+                                                       TI_HANDLE hHealthMonitor,
+                            scanConcentratorInitParams_t *pScanConcentratorInitParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief switch the connection mode to connected (infrastructure BSS)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_switchToConnected( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief switch the connection mode to not connected
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_switchToNotConnected( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief switch the connection mode to IBSS participation
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_switchToIBSS( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by a client to request a scan.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param client - the client ID.\n
+ * \return scan operation detailed result status.\n
+ * \retval SCAN_CRS_SCAN_RUNNING - scan started successfully and is now running.\n
+ * \retval SCAN_CRS_SCAN_FAILED - scan failed to start due to an unexpected error.\n
+ */
+scan_cncnResultStatus_e scanConcentrator_scan( TI_HANDLE hScanCncn, 
+                                               scan_CncnClient_e client, 
+                                               scan_Params_t* pScanParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by a client to stop a scan request in process. A client should ONLY stop its own request!
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param client - the client ID.\n
+ */
+void scanConcentrator_stopScan( TI_HANDLE hScanCncn, scan_CncnClient_e client );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Registers a scan result function for a specific client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param client - the client ID.\n
+ * \param scanResultCBFunc - the function to use.\n
+ * \param scanresultCBObj - the object to pass to the scan result CB function.\n
+ */
+void scanConcentrator_registerScanResultCB( TI_HANDLE hScanCncn, scan_CncnClient_e client,
+                                            scan_resultCB_t scanResultCBFunc, TI_HANDLE scanResultCBObj );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the scan SRV (after registration) to notify of a scan complete event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param SPSStatus - which channels were attempted (if SPS scan).\n
+ * \param bTSFError - whether a TSF error occurred (if SPS scan).\n
+ * \param  ScanStatus - return the status of the scan . \n
+ */
+void scanConcentrator_scanCompleteNotificationCB( TI_HANDLE hScanCncn, UINT16 SPSStatus, BOOLEAN bTSFError , TI_STATUS ScanStatus , TI_STATUS PSMode);
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the MLME parser to pass information received on a beacon or probe response.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param bssid - a pointer to the address of the AP sending this frame.\n
+ * \param frameInfo - the IE in the frame.\n
+ * \param pRxAttr - a pointer to TNET RX attributes struct.\n
+ * \param buffer - a pointer to the frame body.\n
+ * \param byfferLength - the frame body length.\n
+ */
+void scanConcentrator_mlmeResultCB( TI_HANDLE hScanCncn, macAddress_t* bssid, mlmeFrameInfo_t* frameInfo, 
+                                    Rx_attr_t* pRxAttr, UINT8* buffer, UINT16 bufferLength );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the immediate scan for roaming client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the continuous scan for roaming client status.\n
+ * \param pendReason - the reason for pend status, if the status is pend.\n
+ */
+void scanConcentrator_scrRoamingImmedCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                         scr_pendReason_e pendReason );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the continuous scan for roaming client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the continuous scan for roaming client status.\n
+ * \param pendReason - the reason for pend status, if the status is pend.\n
+ */
+void scanConcentrator_scrRoamingContCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                        scr_pendReason_e pendReason );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the Application scan client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the application scan status.\n
+ * \param pendReason - the reason for pend status, if the status is pend.\n
+ */
+void scanConcentrator_scrAppCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                scr_pendReason_e pendReason );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the driver scan client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the driver scan status.\n
+ */
+void scanConcentrator_scrDriverCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                   scr_pendReason_e pendReason );
+
+/**
+ * \author Yuval Adler\n
+ * \date 26-Jan-2006\n
+ * \brief enable/disable the use of SG parameters , and update parameters of next scans 
+ *             requests for minDwellTime,MaxDwellTime,numProbeReq  .\n
+ *                     this function is called when SG is enabled or disabled
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param bUseSGParams - whether to use the new parameters (TRUE when SG is enabled)
+ * \param probeReqNumber - 
+ * \param SGcompensationMaxTime - max value from which we won't increase dwelling time
+ * \param SGcompensationPercent - increasing dwell time in that percentage
+ */
+void scanConcentrator_SGconfigureScanParams( TI_HANDLE hScanCncn, BOOL bUseSGParams ,
+                                                                                        UINT8 probeReqNumber , UINT32 SGcompensationMaxTime, 
+                                                                                        UINT32 SGcompensationPercent);
+#endif /* __SCANCNCNAPI_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/inc/ScanCncnAppApi.h b/sta_dk_4_0_4_32/common/src/Management/scan/inc/ScanCncnAppApi.h
new file mode 100644 (file)
index 0000000..990ea6a
--- /dev/null
@@ -0,0 +1,120 @@
+/** \file ScanCncnAppApi.h
+ *  \brief This file include public definitions for the aplication scan requests adapter.\n
+ *  \author Ronen Kalish
+ *  \date 30-Jan-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNAPPAPI__
+#define __SCANCNCNAPPAPI__
+
+#include "paramOut.h"
+#include "ScanCncnApi.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+ /*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Jan-2005\n
+ * \brief Parses and executes a set param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pParam - the param to set.\n
+ * \return OK if the scan started successfuly, NOK otherwise.\n
+ */
+TI_STATUS scanConcentrator_setParam( TI_HANDLE hScanCncn, paramInfo_t *pParam );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Jan-2005\n
+ * \brief Parses and executes a get param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pParam - the param to get.\n
+ * \return always PARAM_NOT_SUPPORTED (not supposed to be called).\n
+ */
+TI_STATUS scanConcentrator_getParam( TI_HANDLE hScanCncn, paramInfo_t *pParam );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Jan-2005\n
+ * \brief Scan result callback for application scan.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param status - the scan result status (scan complete, result received etc.).\n
+ * \param frameInfo - a pointer to the structure holding all frame related info (in case a frame was received).\n
+ * \prama SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!).\n
+ */
+void scanConcentrator_appScanResultCB( TI_HANDLE hScanCncn, scan_cncnResultStatus_e status,
+                                       scan_frameInfo_t* frameInfo, UINT16 SPSStatus );
+
+#endif /* __SCANCNCNAPPAPI__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncn.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncn.c
new file mode 100644 (file)
index 0000000..cac71c3
--- /dev/null
@@ -0,0 +1,1613 @@
+/** \file ScanCncn.c
+ *  \brief This file include the scan concentrator module implementation
+ *  \author Ronen Kalish
+ *  \date 03-Jan-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanCncn.h"
+#include "ScanCncnAppSM.h"
+#include "ScanCncnDrvSM.h"
+#include "ScanCncnRoamingContSM.h"
+#include "ScanCncnRoamingImmedSM.h"
+#include "ScanCncnAppApi.h"
+#include "ScanCncnOidSM.h"  
+#include "report.h"
+#include "fsm.h"
+#include "scrApi.h"
+#include "paramIn.h"
+#include "regulatoryDomainApi.h"
+#include "siteMgrApi.h"
+#include "siteHash.h"
+#include "utils.h"
+#include "healthMonitor.h"
+
+/* static functions */
+static void scanConcentrator_SGupdateScanParams( TI_HANDLE hScanCncn, scan_Params_t* pScanParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Creates the scan concentrator 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 scanConcentrator_create( TI_HANDLE hOS )
+{
+    UINT16   initVector = 0;
+
+    /* allocate the scan concentrator object */
+    scanConcentrator_t *pScanConcentrator = os_memoryAlloc( hOS, sizeof(scanConcentrator_t) );
+    if ( NULL == pScanConcentrator )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to create scan concnetrator module\n") );
+        return NULL;
+    }
+    initVector |= (1 << SCAN_ALLOC_OBJECT);
+
+    /* store the OS handle */
+    pScanConcentrator->hOS = hOS;
+
+    /* create state machines */
+    if ( OK != fsm_Create( hOS, &(pScanConcentrator->clientSM[ SCAN_SCC_APP ]),
+                           APP_SCAN_NUM_OF_STATES, APP_SCAN_NUM_OF_EVENTS ) )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to allocate application scan state machine\n") );
+        scanConcentrator_freeMem( pScanConcentrator, initVector );
+        return NULL;
+    }
+    initVector |= (1 << SCAN_ALLOC_APP_SM);
+
+    if ( OK != fsm_Create( hOS, &(pScanConcentrator->clientSM[ SCAN_SCC_DRIVER ]),
+                           DRV_SCAN_NUM_OF_STATES, DRV_SCAN_NUM_OF_EVENTS ) )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to allocate driver scan state machine\n") );
+        scanConcentrator_freeMem( pScanConcentrator, initVector );
+        return NULL;
+    }
+    initVector |= (1 << SCAN_ALLOC_DRV_SM);
+
+    if ( OK != fsm_Create( hOS, &(pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_CONT ]),
+                           CONT_SCAN_NUM_OF_STATES, CONT_SCAN_NUM_OF_EVENTS ) )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to allocate continuous scan for roaming state machine\n") );
+        scanConcentrator_freeMem( pScanConcentrator, initVector );
+        return NULL;
+    }
+    initVector |= (1 << SCAN_ALLOC_CONT_SM);
+
+    if ( OK != fsm_Create( hOS, &(pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_IMMED ]),
+                           IMMED_SCAN_NUM_OF_STATES, IMMED_SCAN_NUM_OF_EVENTS ) )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to allocate immediate scan for roaming state machine\n") );
+        scanConcentrator_freeMem( pScanConcentrator, initVector );
+        return NULL;
+    }
+    initVector |= (1 << SCAN_ALLOC_IMMED_SM);
+       if ( OK != fsm_Create( hOS, &(pScanConcentrator->hOidSM), OID_SCAN_NUM_OF_STATES, OID_SCAN_NUM_OF_EVENTS) )
+       {
+        WLAN_OS_REPORT( ("ERROR: Failed to allocate OID scan state machine\n") );
+        scanConcentrator_freeMem( pScanConcentrator, initVector );
+        return NULL;
+       }
+    return pScanConcentrator;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Finalizes the scan concentrator object (freeing system resources)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_release( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_freeMem( hScanCncn, 0xffff );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-Jan-2005\n
+ * \brief Frees the scan concentrator memory, according to the init vector.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param initVec - a vector holding on bits for allocated components and off bits for non allocated components
+ */
+void scanConcentrator_freeMem( TI_HANDLE hScanCncn, UINT16 initVec )
+{
+    scanConcentrator_t *pScanConcentrator= (scanConcentrator_t*)hScanCncn;
+    
+    /* free state machines */
+    if ( initVec & (1<<SCAN_ALLOC_APP_SM) )
+    {
+        fsm_Unload( pScanConcentrator->hOS, pScanConcentrator->clientSM[ SCAN_SCC_APP ] );
+    }
+    if ( initVec & (1 << SCAN_ALLOC_DRV_SM) )
+    {
+        fsm_Unload( pScanConcentrator->hOS, pScanConcentrator->clientSM[ SCAN_SCC_DRIVER ] );
+    }
+    if ( initVec & (1 << SCAN_ALLOC_CONT_SM) )
+    {
+        fsm_Unload( pScanConcentrator->hOS, pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_CONT ] );
+    }
+    if ( initVec & (1 << SCAN_ALLOC_IMMED_SM) )
+    {
+        fsm_Unload( pScanConcentrator->hOS, pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_IMMED ] );
+    }
+       if ( initVec & (1 << SCAN_ALLOC_OID_SM) )
+       {
+               fsm_Unload( pScanConcentrator->hOS, pScanConcentrator->hOidSM );
+       }
+    /* free scan concentrator object */
+    if ( initVec & (1 << SCAN_ALLOC_OBJECT) )
+    {
+        os_memoryFree( pScanConcentrator->hOS, pScanConcentrator, sizeof(scanConcentrator_t) );
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator object.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param hHalCtrl - handle to the Hal Ctrl object.\n
+ * \param hReport - handle to the Report object.\n
+ * \param hRegDomain - handle to the regulatory domain object.\n
+ * \param hSiteMngr - handle to the site manager object.\n
+ * \param hSCR - handle to the SCR object.\n
+ * \param hMacServices - handle to the MacServices object.\n
+ * \param hAPConn - handle to the AP connection object.\n
+ * \param hEventSRV - handle to the event SRV object.\n
+ * \param hMlme - handle to the MLME object.\n
+ * \param hHealthMonitor - handle to the health monitor object.\n
+ * \param pScanConcentratorInitParams - pointer to the init parameters structure.\n
+ */
+void scanConcentrator_init( TI_HANDLE hScanCncn,
+                            TI_HANDLE hHalCtrl,
+                            TI_HANDLE hReport,
+                            TI_HANDLE hRegDomain,
+                            TI_HANDLE hSiteMngr,
+                            TI_HANDLE hSCR,
+                            TI_HANDLE hMacServices,
+                            TI_HANDLE hAPConn,
+                            TI_HANDLE hEventSRV,
+                            TI_HANDLE hMlme,
+                            TI_HANDLE hCtrlData,
+                            TI_HANDLE hHealthMonitor,
+                            scanConcentratorInitParams_t* pScanConcentratorInitParams )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    /* copy handles */
+    pScanConcentrator->hReport = hReport;
+    pScanConcentrator->hHalCtrl = hHalCtrl;
+    pScanConcentrator->hRegulatoryDomain = hRegDomain;
+    pScanConcentrator->hSiteManager = hSiteMngr;
+    pScanConcentrator->hSCR = hSCR;
+    pScanConcentrator->hMacServices = hMacServices;
+    pScanConcentrator->hAPConn = hAPConn;
+    pScanConcentrator->hEventSrv = hEventSRV;
+    pScanConcentrator->hMlme = hMlme;
+    pScanConcentrator->hCtrlData = hCtrlData;
+    pScanConcentrator->hHealthMonitor = hHealthMonitor;
+
+    /* copy registry values */
+    os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->initParams), pScanConcentratorInitParams,
+                   sizeof( scanConcentratorInitParams_t ) );
+
+    /* initialize state machines */
+    if ( OK != scanConcentratorAppSM_init( hScanCncn ) )
+    {
+        WLAN_REPORT_ERROR( hReport, SCAN_CNCN_MODULE_LOG, ("Error: application SM initialization failed.\n") );
+        return;
+    }
+
+    if ( OK != scanConcentratorDrvSM_init( hScanCncn ) )
+    {
+        WLAN_REPORT_ERROR( hReport, SCAN_CNCN_MODULE_LOG, ("Error: driver SM initialization failed.\n") );
+        return;
+    }
+
+    if ( OK != scanConcentratorRoamingContSM_init( hScanCncn ) )
+    {
+        WLAN_REPORT_ERROR( hReport, SCAN_CNCN_MODULE_LOG, ("Error: continuous scan for roaming SM initialization failed.\n") );
+        return;
+    }
+
+    if ( OK != scanConcentratorRoamingImmedSM_init( hScanCncn ) )
+    {
+        WLAN_REPORT_ERROR( hReport, SCAN_CNCN_MODULE_LOG, ("Error: immediate scan for roaming SM initialization failed.\n") );
+        return;
+    }
+       if ( OK != scanConcentratorOidSM_init( hScanCncn ) )
+       {
+        WLAN_REPORT_ERROR( hReport, SCAN_CNCN_MODULE_LOG, ("Error: OID scan SM initialization failed.\n") );
+        return;
+       }
+    /* register SCR callbacks */
+    scr_registerClientCB( pScanConcentrator->hSCR, SCR_CID_APP_SCAN, scanConcentrator_scrAppCB, hScanCncn );
+    scr_registerClientCB( pScanConcentrator->hSCR, SCR_CID_DRIVER_FG_SCAN, scanConcentrator_scrDriverCB, hScanCncn );
+    scr_registerClientCB( pScanConcentrator->hSCR, SCR_CID_CONT_SCAN, scanConcentrator_scrRoamingContCB, hScanCncn );
+    scr_registerClientCB( pScanConcentrator->hSCR, SCR_CID_IMMED_SCAN, scanConcentrator_scrRoamingImmedCB, hScanCncn );
+
+    /* register scan SRV scan complete CB */
+    MacServices_scanSRV_registerScanCompleteCB( hMacServices, scanConcentrator_scanCompleteNotificationCB, hScanCncn );
+
+    /* nullify other parameters */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_NO_CLIENT;
+    pScanConcentrator->connectionStatus = STA_NOT_CONNECTED;
+
+    /* bUseSGParams is TRUE only when SG module is enabled */
+    pScanConcentrator->bUseSGParams = FALSE;
+    
+    /* "register" the application scan result callback */
+    scanConcentrator_registerScanResultCB( hScanCncn, SCAN_SCC_APP, scanConcentrator_appScanResultCB, hScanCncn );
+    
+    WLAN_REPORT_INIT( hReport, SCAN_CNCN_MODULE_LOG,  (".....Scan concentrator configured successfully.\n"));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief switch the connection mode to connected (infrastructure BSS)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_switchToConnected( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Switching to connected state.\n") );
+    
+    /* change connection status to connected */
+    pScanConcentrator->connectionStatus = STA_CONNECTED;
+
+    /* Any running scans in other modes will be aborted (if needed) by the SCR (or have already been) */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief switch the connection mode to not connected
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_switchToNotConnected( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Switching to not connected state.\n") );
+
+    /* change connection status to connected */
+    pScanConcentrator->connectionStatus = STA_NOT_CONNECTED;
+
+    /* Any running scans in other modes will be aborted (if needed) by the SCR (or have already been) */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief switch the connection mode to IBSS participation
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentrator_switchToIBSS( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Switching to IBSS state.\n") );
+
+    /* change connection status to connected */
+    pScanConcentrator->connectionStatus = STA_IBSS;
+
+    /* Any running scans in other modes will be aborted (if needed) by the SCR (or have already been) */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by a client to request a scan.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param client - the client ID.\n
+ * \return scan operation detailed result status.\n
+ * \retval SCAN_CRS_SCAN_RUNNING - scan started successfully and is now running.\n
+ * \retval SCAN_CRS_SCAN_FAILED - scan failed to start due to an unexpected error.\n
+ */
+scan_cncnResultStatus_e scanConcentrator_scan( TI_HANDLE hScanCncn, 
+                                               scan_CncnClient_e client, 
+                                               scan_Params_t* pScanParams )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    whalCtrl_setTemplate_t  templateStruct;
+    probeReqTemplate_t      probeReqTemplate;
+    paramInfo_t             param;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Received scan request from client %d\n", client) );
+
+    /* sanity check verify that this is a known client */
+    if ( client >= SCAN_SCC_NUM_OF_CLIENTS)
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                             ("Scan request with illegal client %d, aborting request.\n", client) );
+        return SCAN_CRS_SCAN_FAILED;
+    }
+
+    /* scan requests with junk SSID (other than application scans) are rejected */
+    if ( (client == SCAN_SCC_DRIVER) &&
+         utils_isJunkSSID( &(pScanParams->desiredSsid) ) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Scan request with junk SSID from client %d.\n", client) );
+        return SCAN_CRS_SCAN_FAILED;
+    }
+
+#ifndef TI_DBG
+    /* in release mode, no channel expansion is done */
+    if ( 0 == pScanParams->numOfChannels )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Scan request with 0 channels from client:%d\n", client) );
+        return SCAN_CRS_SCAN_FAILED;
+    }
+#endif
+
+       /* Validate dwell times */
+       if ( pScanParams->scanType != SCAN_TYPE_SPS )
+       {
+               int channel;
+
+               for (channel = 0; channel < pScanParams->numOfChannels; ++channel)
+               {
+                       if (pScanParams->channelEntry[channel].normalChannelEntry.maxChannelDwellTime < 
+                               pScanParams->channelEntry[channel].normalChannelEntry.minChannelDwellTime)
+                       {
+                               WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                       ("%s: MaxChannelDwellTime must not be smaller than MinChannelDwellTime on channel %d!\n", __FUNCTION__, channel));
+
+                               return SCAN_CRS_SCAN_FAILED;
+                       }
+               }
+       }
+
+    /* Check if country code should be reset in RegDomain. This is done here in order to detect if country should be updated 
+       before the next scan. RegDomain will decide if country code should be deleted or remain the same. */
+    param.paramType = REGULATORY_DOMAIN_CHECK_COUNTRY_PARAM;
+    regulatoryDomain_setParam(pScanConcentrator->hRegulatoryDomain,&param);
+
+       WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,("SG=%d, scan band = %d \n",
+                                                                                                                                                          pScanConcentrator->bUseSGParams,
+                                                                                                                                                          pScanParams->band));
+    /* act according to client */
+    switch ( client )
+    {
+    case SCAN_SCC_APP:
+        /* check that the application state machine is in IDLE state 
+           (no more than one scan at a time per client is allowed). */
+        if ( APP_SCAN_STATE_IDLE != pScanConcentrator->clientSMState[ SCAN_SCC_APP ] )
+        {
+            return SCAN_CRS_SCAN_FAILED;
+        }
+        else
+        {
+            /* copy scan parameters to local buffer */
+            os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->clientScanParams[ SCAN_SCC_APP ]), 
+                           pScanParams, sizeof(scan_Params_t) );
+
+            /* ask the reg domain which channels are allowed for the requested scan type */
+            scanConcentrator_verifyChannelsWithRegDomain( hScanCncn, &(pScanConcentrator->clientScanParams[ SCAN_SCC_APP ]) );
+            /* if no channels are available for scan, return negative result */
+            if ( 0 == pScanConcentrator->clientScanParams[ SCAN_SCC_APP ].numOfChannels )
+            {
+                return SCAN_CRS_SCAN_FAILED;
+            }
+            
+            if ((pScanConcentrator->bUseSGParams) && (pScanConcentrator->clientScanParams[ SCAN_SCC_APP ].band == RADIO_BAND_2_4_GHZ))
+            {
+                               WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,("SG is pn && RADIO_BAND_2_4_GHZ \n"));
+                scanConcentrator_SGupdateScanParams(hScanCncn,&(pScanConcentrator->clientScanParams[ SCAN_SCC_APP ]));
+            }
+            
+            /* mark that a scan request is in progress (to avoid client re-entrance if the scan fail) */
+            pScanConcentrator->bInRequest = TRUE;
+
+            /* mark the scan result as OK (until other status will replace it) */
+            pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_COMPLETE_OK;
+
+            /* send probe request template */
+            if ( (SCAN_TYPE_NORMAL_ACTIVE == pScanParams->scanType) || 
+                 (SCAN_TYPE_TRIGGERED_ACTIVE == pScanParams->scanType) )
+            {
+
+                templateStruct.pTemplate = (UINT8 *)&probeReqTemplate;
+                templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
+                buildProbeReqTemplate( pScanConcentrator->hSiteManager, &templateStruct,  
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_APP ].desiredSsid),
+                                         pScanConcentrator->clientScanParams[ SCAN_SCC_APP ].band);
+                whalCtrl_SetTemplate( pScanConcentrator->hHalCtrl, &templateStruct);
+            }           
+
+            /* send a start scan event to the SM */
+            scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                           (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                           APP_SCAN_EVENT_START_SCAN );
+
+            /* mark that the scan request is no longer in progress */
+            pScanConcentrator->bInRequest = FALSE;
+
+            /* return scan result */
+            if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_APP ] )
+            {
+                return SCAN_CRS_SCAN_RUNNING;
+            }
+            else 
+            {
+                return pScanConcentrator->scanResult[ SCAN_SCC_APP ];
+            }
+        }
+/*        break; - unreachable */
+
+    case SCAN_SCC_DRIVER:
+        /* check that the driver state machine is in IDLE state 
+           (no more than one scan at a time per client is allowed)*/
+        if ( DRV_SCAN_STATE_IDLE != pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ] )
+        {
+            return SCAN_CRS_SCAN_FAILED;
+        }
+        else
+        {
+            /* copy scan parameters to local buffer */
+            os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ]), 
+                           pScanParams, sizeof(scan_Params_t) );
+
+            if ((pScanConcentrator->bUseSGParams) && (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].band == RADIO_BAND_2_4_GHZ))
+            {
+                               WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,("SG is pn && RADIO_BAND_2_4_GHZ \n"));
+                scanConcentrator_SGupdateScanParams(hScanCncn,&(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ]));
+            }
+
+            /* mark that a scan request is in progress (to avoid client re-entrance if the scan fail) */
+            pScanConcentrator->bInRequest = TRUE;
+
+            /* mark the scan result as OK (until other status will replace it) */
+            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_COMPLETE_OK;
+
+            /* send probe request template */
+            if ( (SCAN_TYPE_NORMAL_ACTIVE == pScanParams->scanType) || 
+                 (SCAN_TYPE_TRIGGERED_ACTIVE == pScanParams->scanType) )
+            {
+
+                templateStruct.pTemplate = (UINT8 *)&probeReqTemplate;
+                templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
+                buildProbeReqTemplate( pScanConcentrator->hSiteManager, &templateStruct,  
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].desiredSsid),
+                                         pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].band);
+                whalCtrl_SetTemplate( pScanConcentrator->hHalCtrl, &templateStruct);
+            }
+            /* send a start scan event to the SM */
+            scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                           (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                           DRV_SCAN_EVENT_START_SCAN );
+
+            /* mark that the scan request is no longer in progress */
+            pScanConcentrator->bInRequest = FALSE;
+
+            /* return scan result */
+            if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] )
+            {
+                return SCAN_CRS_SCAN_RUNNING;
+            }
+            else
+            {
+                return pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ];
+            }
+        }
+/*        break; - unreachable */
+
+    case SCAN_SCC_ROAMING_CONT:
+        /* check that the continuous roaming state machine is in IDLE state 
+           (no more than one scan at a time per client is allowed)*/
+        if ( CONT_SCAN_STATE_IDLE != pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ] )
+        {
+            return SCAN_CRS_SCAN_FAILED;
+        }
+        else
+        {
+            /* copy scan parameters to local buffer */
+            os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ]), 
+                           pScanParams, sizeof(scan_Params_t) );
+            
+            if ((pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].desiredSsid.len!=0) &&
+                ((pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].scanType == SCAN_TYPE_NORMAL_ACTIVE) ||
+                 (pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].scanType == SCAN_TYPE_TRIGGERED_ACTIVE)))
+            {
+                /* set the SSID of the current AP */
+                param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+                siteMgr_getParam( pScanConcentrator->hSiteManager, &param );
+                os_memoryCopy( pScanConcentrator->hOS, 
+                               &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].desiredSsid),
+                               &(param.content.siteMgrDesiredSSID),
+                               sizeof(ssid_t) );
+
+            }
+            WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                     ("CONT Scan: The scan SSID is %s\n", pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].desiredSsid.ssidString) );
+
+            /* ask the reg domain which channels are allowed for the requested scan type */
+            scanConcentrator_verifyChannelsWithRegDomain( hScanCncn, &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ]) );
+            /* if no channels are available for scan, return negative result */
+            if ( 0 == pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].numOfChannels )
+            {
+                return SCAN_CRS_SCAN_FAILED;
+            }
+
+            if ((pScanConcentrator->bUseSGParams) && (pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].band == RADIO_BAND_2_4_GHZ))
+            {
+                               WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,("SG is pn && RADIO_BAND_2_4_GHZ \n"));
+                scanConcentrator_SGupdateScanParams(hScanCncn,&(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ]));
+            }
+
+            /* mark that a scan request is in progress (to avoid client re-entrance if the scan fail) */
+            pScanConcentrator->bInRequest = TRUE;
+
+            /* mark the scan result as OK (until other status will replace it) */
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_COMPLETE_OK;
+
+            /* send probe request template */
+            if ( (SCAN_TYPE_NORMAL_ACTIVE == pScanParams->scanType) || 
+                 (SCAN_TYPE_TRIGGERED_ACTIVE == pScanParams->scanType) )
+            {
+
+                templateStruct.pTemplate = (UINT8 *)&probeReqTemplate;
+                templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
+                buildProbeReqTemplate( pScanConcentrator->hSiteManager, &templateStruct,  
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].desiredSsid),
+                                         pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].band);
+                whalCtrl_SetTemplate( pScanConcentrator->hHalCtrl, &templateStruct);
+            }
+
+            /* send a start scan event to the SM */
+            scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                                   (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                                   CONT_SCAN_EVENT_START_SCAN );
+
+            /* mark that the scan request is no longer in progress */
+            pScanConcentrator->bInRequest = FALSE;
+
+            /* return scan result */
+            if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] )
+            {
+                return SCAN_CRS_SCAN_RUNNING;
+            }
+            else
+            {
+                return pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ];
+            }
+        }
+/*        break; - unreachable */
+
+    case SCAN_SCC_ROAMING_IMMED:
+        /* check that the immediate roaming state machine is in IDLE state 
+           (no more than one scan at a time per client is allowed)*/
+        if ( IMMED_SCAN_STATE_IDLE != pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ] )
+        {
+            return SCAN_CRS_SCAN_FAILED;
+        }
+        else
+        {
+            
+            /* copy scan parameters to local buffer */
+            os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ]), 
+                     pScanParams, sizeof(scan_Params_t) );
+
+            /* set the SSID of the current AP */
+            param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+            siteMgr_getParam( pScanConcentrator->hSiteManager, &param );
+            os_memoryCopy( pScanConcentrator->hOS, 
+                   &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].desiredSsid),
+                   &(param.content.siteMgrDesiredSSID),
+                   sizeof(ssid_t) );
+            
+            /* ask the reg domain which channels are allowed for the requested scan type */
+            scanConcentrator_verifyChannelsWithRegDomain( hScanCncn, &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ]) );
+            /* if no channels are available for scan, return negative result */
+            if ( 0 == pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].numOfChannels )
+            {
+                return SCAN_CRS_SCAN_FAILED;
+            }
+
+            if ((pScanConcentrator->bUseSGParams) && (pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].band == RADIO_BAND_2_4_GHZ))
+            {
+                               WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,("SG is pn && RADIO_BAND_2_4_GHZ \n"));
+                scanConcentrator_SGupdateScanParams(hScanCncn,&(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ]));
+            }
+            
+            /* mark that a scan request is in progress (to avoid client re-entrance if the scan fail) */
+            pScanConcentrator->bInRequest = TRUE;
+
+            /* mark the scan result as OK (until other status will replace it) */
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_COMPLETE_OK;
+
+            /* send probe request template */
+            if ( (SCAN_TYPE_NORMAL_ACTIVE == pScanParams->scanType) || 
+                 (SCAN_TYPE_TRIGGERED_ACTIVE == pScanParams->scanType) )
+            {
+
+                templateStruct.pTemplate = (UINT8 *)&probeReqTemplate;
+                templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
+                buildProbeReqTemplate( pScanConcentrator->hSiteManager, &templateStruct,  
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].desiredSsid),
+                                         pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].band);
+                whalCtrl_SetTemplate( pScanConcentrator->hHalCtrl, &templateStruct);
+            }
+            
+            /* send a start scan event to the SM */
+            scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                    (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                    IMMED_SCAN_EVENT_START_SCAN );
+
+            /* mark that the scan request is no longer in progress */
+            pScanConcentrator->bInRequest = FALSE;
+
+            /* return scan result */
+            if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] )
+            {
+                return SCAN_CRS_SCAN_RUNNING;
+            }
+            else
+            {
+                return pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ];
+            }
+        }
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Scan request from unknown client:%d\n", client) );
+        return SCAN_CRS_SCAN_FAILED;
+/*        break; - unreachable */
+        
+    }
+
+/*    return SCAN_CRS_SCAN_RUNNING; - unreachable */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by a client to stop a scan request in process. A client should ONLY stop its own request!
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param client - the client ID.\n
+ */
+void scanConcentrator_stopScan( TI_HANDLE hScanCncn, scan_CncnClient_e client )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Received stop scan request from client %d\n", client) );
+
+    /* act according to client */
+    switch ( client )
+    {
+    case SCAN_SCC_APP:
+        /* if no previous error has occurred, change the state to stopped */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_APP ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_STOPPED;
+            /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+            when not (abort due to higher priority client) */
+            pScanConcentrator->bAbortOrStop = SCAN_CNCN_STOP;
+        }
+        else if (SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY != pScanConcentrator->scanResult[ SCAN_SCC_APP ])
+        {   /* In all scan failures, besides abort, indicate the flag as STOP */
+            /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+            when not (abort due to higher priority client) */
+            pScanConcentrator->bAbortOrStop = SCAN_CNCN_STOP;
+        }
+
+        /* send a stop scan event to the SM */
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_STOP_SCAN );
+        break;
+
+    case SCAN_SCC_DRIVER:
+        /* if no previous error has occurred, change the state to stopped */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_STOPPED;
+        }
+
+        /* send a stop scan event to the SM */
+        scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                       (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                       DRV_SCAN_EVENT_STOP_SCAN );
+        break;
+
+    case SCAN_SCC_ROAMING_CONT:
+        /* if no previous error has occurred, change the state to stopped */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_STOPPED;
+
+            /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+            when not (abort due to higher priority client) */
+            pScanConcentrator->bAbortOrStop = SCAN_CNCN_STOP;
+        }
+        else if (SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY != pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ])
+        {   /* In all scan failures, besides abort, indicate the flag as STOP */
+            /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+            when not (abort due to higher priority client) */
+            pScanConcentrator->bAbortOrStop = SCAN_CNCN_STOP;
+        }
+
+        /* send a stop scan event to the SM */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_STOP_SCAN );
+        break;
+
+    case SCAN_SCC_ROAMING_IMMED:
+        /* if no previous error has occurred, change the state to stopped */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_STOPPED;
+
+            /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+            when not (abort due to higher priority client) */
+            pScanConcentrator->bAbortOrStop = SCAN_CNCN_STOP;
+        }
+        else if (SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY != pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ])
+        {   /* In all scan failures, besides abort, indicate the flag as STOP */
+            /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+            when not (abort due to higher priority client) */
+            pScanConcentrator->bAbortOrStop = SCAN_CNCN_STOP;
+        }
+
+        /* send a stop scan event to the SM */
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_STOP_SCAN );
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                             ("Stop scan request with illegal client %d, aborting request.\n", client) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Registers a scan result function for a specific client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param client - the client ID.\n
+ * \param scanResultCBFunc - the function to use.\n
+ * \param scanresultCBObj - the object to pass to the scan result CB function.\n
+ */
+void scanConcentrator_registerScanResultCB( TI_HANDLE hScanCncn, scan_CncnClient_e client,
+                                            scan_resultCB_t scanResultCBFunc, TI_HANDLE scanResultCBObj )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    /* save the function and object pointers */
+    pScanConcentrator->scanResultCB[ client ] = scanResultCBFunc;
+    pScanConcentrator->scanResultCBObj[ client ] = scanResultCBObj;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the scan SRV (after registration) to notify of a scan complete event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param SPSStatus - which channels were attempted (if SPS scan).\n
+ * \param bTSFError - whether a TSF error occurred (if SPS scan).\n
+ * \param  ScanStatus - return the status of the scan . \n
+ */
+void scanConcentrator_scanCompleteNotificationCB( TI_HANDLE hScanCncn, UINT16 SPSStatus, BOOLEAN bTSFError , TI_STATUS ScanStatus , TI_STATUS PSMode )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+     /* start built-in test timer */
+    healthMonitor_resumePeriodicTest( pScanConcentrator->hHealthMonitor );
+
+#ifdef TI_DBG
+    /* check that current running client is valid */
+    if ( SCAN_SCC_NO_CLIENT == pScanConcentrator->currentRunningScanClient ) 
+    {
+        WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                           ("Scan complete called when current running client is invalid: %d\n", 
+                            pScanConcentrator->currentRunningScanClient) );
+        return;
+    }
+#endif
+    /* send a scan complete event to the running client (according to its type) */
+    switch ( pScanConcentrator->currentRunningScanClient )
+    {
+    case SCAN_SCC_APP:
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_SCAN_COMPLETE );
+        break;
+
+    case SCAN_SCC_DRIVER:
+        scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                       (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                       scanConcentrator_getNextDriverEvent( hScanCncn ) );
+        break;
+
+    case SCAN_SCC_ROAMING_CONT:
+        /* copy the SPS scan result (in case this was an SPS scan) */
+        pScanConcentrator->SPSScanResult = SPSStatus;
+
+        /* if A TSF error occurred (for non-SPS scans this value is always FALSE!), and no previous error occurred,
+           mark this error */
+        if ( (SCAN_CRS_SCAN_COMPLETE_OK == 
+                pScanConcentrator->scanResult[ pScanConcentrator->currentRunningScanClient ]) &&
+              (TRUE == bTSFError) )
+        {
+            pScanConcentrator->scanResult[ pScanConcentrator->currentRunningScanClient ] = SCAN_CRS_TSF_ERROR;
+        }
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_SCAN_COMPLETE );
+        break;
+
+    case SCAN_SCC_ROAMING_IMMED:
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_SCAN_COMPLETE );
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                             ("Scan complete notification with illegal client %d, aborting request.\n", pScanConcentrator->currentRunningScanClient) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the MLME parser to pass information received on a beacon or probe response.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param bssid - a pointer to the address of the AP sending this frame.\n
+ * \param frameInfo - the IE in the frame.\n
+ * \param pRxAttr - a pointer to TNET RX attributes struct.\n
+ * \param buffer - a pointer to the frame body.\n
+ * \param byfferLength - the frame body length.\n
+ */
+void scanConcentrator_mlmeResultCB( TI_HANDLE hScanCncn, macAddress_t* bssid, mlmeFrameInfo_t* frameInfo, 
+                                    Rx_attr_t* pRxAttr, UINT8* buffer, UINT16 bufferLength )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    paramInfo_t param;
+    scan_frameInfo_t scanFrameInfo;
+
+    /* verify that there is a running client (in case the result arrived after the scan complete event) */
+    switch (pScanConcentrator->currentRunningScanClient)
+    {
+    case SCAN_SCC_APP:
+        if ( APP_SCAN_STATE_IDLE == pScanConcentrator->clientSMState[ SCAN_SCC_APP ] )
+        {
+            return;
+        }
+        break;
+
+    case SCAN_SCC_DRIVER:
+        if ( DRV_SCAN_STATE_IDLE == pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ] )
+        {
+            return;
+        }
+        break;
+
+    case SCAN_SCC_ROAMING_CONT:
+        if ( CONT_SCAN_STATE_IDLE == pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ] )
+        {
+            return;
+        }
+        /* check that the SSID IE exists in the frame received */
+        if (frameInfo->content.iePacket.pSsid==NULL) 
+        {
+            /* Discard sites with no SID IE */
+            return;
+        }
+        /* check that scan results are not from current BSS */
+        param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+        ctrlData_getParam( pScanConcentrator->hCtrlData, &param );
+        if (( 0 == os_memoryCompare( pScanConcentrator->hOS, 
+                                    (void *)&(bssid->addr[ 0 ]), 
+                                    (void *)&(param.content.ctrlDataCurrentBSSID.addr[ 0 ]), 
+                                    MAC_ADDR_LEN ) ) ||
+            (( os_memoryCompare( pScanConcentrator->hOS, 
+                                (PUINT8)frameInfo->content.iePacket.pSsid->serviceSetId, 
+                                (PUINT8)pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].desiredSsid.ssidString, 
+                                    pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].desiredSsid.len )) &&
+             pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ].scanType != SCAN_TYPE_SPS) )
+        {
+            /* reply from current site - discard it (by returning w/o notifying the scan manager */
+            /* Also discard sites with different SSID than the desired */
+            WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                     ("Cont scan: discarding frame from SSID: %s, BSSID: %2x:%2x:%2x:%2x:%2x:%2x, because SSID different from desired or from current AP!\n",
+                                      frameInfo->content.iePacket.pSsid->serviceSetId, bssid->addr[ 0 ],
+                                      bssid->addr[ 1 ], bssid->addr[ 2 ], bssid->addr[ 3 ],
+                                      bssid->addr[ 4 ], bssid->addr[ 5 ]) );
+            return;
+        }
+
+        break;
+
+    case SCAN_SCC_ROAMING_IMMED:
+        if ( IMMED_SCAN_STATE_IDLE == pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ] )
+        {
+            return;
+        }
+        /* check that the SSID IE exists in the frame received */
+        if (frameInfo->content.iePacket.pSsid==NULL) 
+        {
+            /* Discard sites with no SID IE */
+            return;
+        }
+        /* check that scan results are not from current BSS */
+        param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+        ctrlData_getParam( pScanConcentrator->hCtrlData, &param );
+        if (( 0 == os_memoryCompare( pScanConcentrator->hOS, 
+                                    (PUINT8)&(bssid->addr[ 0 ]), 
+                                    (PUINT8)&(param.content.ctrlDataCurrentBSSID.addr[ 0 ]), 
+                                    MAC_ADDR_LEN ) ) ||
+            ( os_memoryCompare( pScanConcentrator->hOS, 
+                                (PUINT8)frameInfo->content.iePacket.pSsid->serviceSetId, 
+                                (PUINT8)pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].desiredSsid.ssidString, 
+                                    pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].desiredSsid.len )))
+
+        {
+            /* reply from current site - discard it (by returning w/o notifying the scan manager */
+            /* Also discard sites with different SSID than the desired */
+            WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                     ("Immed scan: discarding frame from SSID: %s, BSSID: %2x:%2x:%2x:%2x:%2x:%2x, because SSID different from desired or from current AP!\n",
+                                      frameInfo->content.iePacket.pSsid->serviceSetId, bssid->addr[ 0 ],
+                                      bssid->addr[ 1 ], bssid->addr[ 2 ], bssid->addr[ 3 ],
+                                      bssid->addr[ 4 ], bssid->addr[ 5 ]) );
+            return;
+        }
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                             ("Scan result with illegal client %d, aborting request.\n", pScanConcentrator->currentRunningScanClient) );
+        return;
+/*        break; - unreachable */
+    }
+
+    /* build the scan frame info object */
+    scanFrameInfo.bssId = bssid;
+    scanFrameInfo.band = (radioBand_e)pRxAttr->band;
+    scanFrameInfo.channel = pRxAttr->channel;
+    scanFrameInfo.parsedIEs = frameInfo;
+    scanFrameInfo.rate = pRxAttr->Rate;
+    scanFrameInfo.rssi = pRxAttr->Rssi;
+    scanFrameInfo.staTSF = pRxAttr->TimeStamp;
+    scanFrameInfo.buffer = buffer;
+    scanFrameInfo.bufferLength = bufferLength;
+
+    /* call the client result CB, according to the running client type */
+    if ( NULL != pScanConcentrator->scanResultCB[ pScanConcentrator->currentRunningScanClient ] )
+    {
+        pScanConcentrator->scanResultCB[ pScanConcentrator->currentRunningScanClient ]( 
+            pScanConcentrator->scanResultCBObj[ pScanConcentrator->currentRunningScanClient ],
+            SCAN_CRS_RECEIVED_FRAME,
+            &scanFrameInfo,
+            0xffff ); /* SPS status is only valid on SPS scan complete */
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the immediate scan for roaming client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the continuous scan for roaming client status.\n
+ */
+void scanConcentrator_scrRoamingImmedCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                         scr_pendReason_e pendReason )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Immed. romaing CB called by SCR. Status is: %d, pend reason: %d.\n", 
+                              requestStatus, pendReason) );
+
+    /* act according to the request staus */
+    switch ( requestStatus )
+    {
+    case SCR_CRS_RUN:
+        /* send an SCR run event to the SM */
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_SCR_RUN );
+        break;
+
+    case SCR_CRS_PEND:
+        /* if pending reason has changed to different group - send a reject event 
+           (should only happen when pending) */
+        if ( SCR_PR_DIFFERENT_GROUP_RUNNING == pendReason )
+        {
+            /* send an SCR reject event to the SM - would not scan when not performing roaming */
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_FAILED;
+            scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                    (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                    IMMED_SCAN_EVENT_SCR_REJECT );            
+        }
+        else
+        {
+            /* send an SCR pend event to the SM */
+            scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                    (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                    IMMED_SCAN_EVENT_SCR_PEND );
+        }
+        break;
+
+    case SCR_CRS_FW_RESET:
+        /* if no previous error has occurred, change the state to FW reset */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_ABORTED_FW_RESET;
+        }
+
+         /* start built-in test timer */
+        healthMonitor_resumePeriodicTest( pScanConcentrator->hHealthMonitor );
+
+        /* send a FW reset event to the SM */
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_FW_RESET );
+        break;
+
+    case SCR_CRS_ABORT:
+        /* This should never happen, report error */
+    default:
+        WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Illegal SCR request status: %d.\n", requestStatus) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the continuous scan for roaming client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the continuous scan for roaming client status.\n
+ */
+void scanConcentrator_scrRoamingContCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                        scr_pendReason_e pendReason )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Cont. romaing CB called by SCR. Status is: %d, pend reason: %d.\n", 
+                              requestStatus, pendReason) );
+
+    /* act according to the request staus */
+    switch ( requestStatus )
+    {
+    case SCR_CRS_RUN:
+        /* send an SCR run event to the SM */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_SCR_RUN );
+        break;
+
+    case SCR_CRS_PEND:
+        /* if pending reason has changed to different group - send a reject event 
+           (should only happen when pending) */
+        if ( SCR_PR_DIFFERENT_GROUP_RUNNING == pendReason )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_FAILED;
+            /* send an SCR reject event to the SM - would not scan when not connected */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_SCR_REJECT );
+        }
+        else
+        {
+            /* send an SCR pend event to the SM */
+            scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                                   (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                                   CONT_SCAN_EVENT_SCR_PEND );
+        }
+        break;
+
+    case SCR_CRS_FW_RESET:
+        /* if no previous error has occurred, change the state to FW reset */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_ABORTED_FW_RESET;
+        }
+
+         /* start built-in test timer */
+        healthMonitor_resumePeriodicTest( pScanConcentrator->hHealthMonitor );
+
+        /* send a FW reset event to the SM */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_FW_RESET );
+        break;
+
+    case SCR_CRS_ABORT:
+        /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+           when not (abort due to higher priority client) */
+
+        pScanConcentrator->bAbortOrStop = SCAN_CNCN_ABORT;
+
+        /* if no previous error has occurred, change the state to abort (according to reason) */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY;
+        }
+
+        /* send an abort scan event to the SM */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_ABORT_SCAN );
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Illegal SCR request status: %d.\n", requestStatus) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the Application scan client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the application scan status.\n
+ * \param pendReason - the reason for pend status, if the status is pend.\n
+ */
+void scanConcentrator_scrAppCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                scr_pendReason_e pendReason )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("App. CB called by SCR. Status is: %d, pend reason: %d.\n", 
+                              requestStatus, pendReason) );
+    
+    /* act according to the request staus */
+    switch ( requestStatus )
+    {
+    /* Note: pend is not handled because application scan cancel its scan request when it receives pend
+       as the SCR request result, and thus it is assumed that the application scan request will never be
+       pending */
+
+    case SCR_CRS_RUN:
+        /* send an SCR run event to the SM */
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_SCR_RUN );
+        break;
+
+    case SCR_CRS_FW_RESET:
+        /* if no previous error has occurred, change the state to FW reset */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_APP ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_ABORTED_FW_RESET;
+        }
+
+         /* start built-in test timer */
+        healthMonitor_resumePeriodicTest( pScanConcentrator->hHealthMonitor );
+
+        /* send a FW reset event to the SM */
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_FW_RESET );
+        break;
+
+    case SCR_CRS_ABORT:  
+        /* set the abort or stop flag (to identify when to exit driver mode (stop) and
+           when not (abort due to higher priority client) */
+
+        pScanConcentrator->bAbortOrStop = SCAN_CNCN_ABORT;
+
+        /* if no previous error has occurred, change the state to abort (according to reason) */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_APP ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY;
+        }
+
+        /* send an abort scan event to the SM */
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_ABORT_SCAN );
+        break;
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Illegal SCR request status: %d.\n", requestStatus) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Called by the SCR (after registration) to notify the scan concentrator of a status change
+ * \brief for the driver scan client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param requestStatus - the driver scan status.\n
+ * \param pendReason - the reason for pend status, if the status is pend.\n
+ */
+void scanConcentrator_scrDriverCB( TI_HANDLE hScanCncn, scr_clientRequestStatus_e requestStatus,
+                                   scr_pendReason_e pendReason )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Driver CB called by SCR. Status is: %d, pend reason: %d.\n",
+                              requestStatus, pendReason) );
+
+    /* act according to the request staus */
+    switch ( requestStatus )
+    {
+    case SCR_CRS_RUN:
+        /* send the next event to the SM */
+        scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                       (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                       scanConcentrator_getNextDriverEvent( hScanCncn ) );
+        break;
+
+    case SCR_CRS_PEND:
+        /* a pend event should only be sent when the SM is waiting for the SCR */
+        if ( pendReason == SCR_PR_DIFFERENT_GROUP_RUNNING )
+        {
+            /* send a reject event - should not perform scan if not in connecting mode */
+            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_FAILED;
+        scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                       (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                       DRV_SCAN_EVENT_SCR_REJECT );
+        }
+        else
+        {
+            /* send a pend event */
+            scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                           (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                           DRV_SCAN_EVENT_SCR_PEND );            
+        }
+        break;
+
+    case SCR_CRS_FW_RESET:
+        /* if no previous error has occurred, change the state to FW reset */
+        if ( SCAN_CRS_SCAN_COMPLETE_OK == pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] )
+        {
+            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_ABORTED_FW_RESET;
+        }
+
+        /* start built-in test timer */
+        healthMonitor_resumePeriodicTest( pScanConcentrator->hHealthMonitor );
+
+        /* send a FW reset event to the SM */
+        scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                       (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                       DRV_SCAN_EVENT_FW_RESET );
+        break;
+    
+    case SCR_CRS_ABORT:
+    /* This should never happen, report error */
+    default:
+        WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("Illegal SCR request status: %d.\n", requestStatus) );
+        break;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Jan-2005\n
+ * \brief Verifies that specified channels are allowed for the specified scan type, and removes those that are not.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pScanParams - a pointer to the structure holding the scan params (inc. channels and scan type).\n
+ */
+void scanConcentrator_verifyChannelsWithRegDomain( TI_HANDLE hScanCncn, scan_Params_t* pScanParams )
+{
+    paramInfo_t     param;
+    UINT8           i,j,k;
+    UINT8           tempChannelList[ SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND ];
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    /* if no channels were given by the user, get all channels from reg domain */
+    if ( 0 == pScanParams->numOfChannels )
+    {
+        /* SPS cannot be performed when the user does not define the channels! */
+        if ( SCAN_TYPE_SPS != pScanParams->scanType )
+        {
+            UINT validChannelsCnt=0;
+            
+            /* extract the channel list (channel numbers) from the bitmap */
+            i = SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND;
+            /*scanConcentrator_ExtractBitmapToList( pScanParams->band, &(tmpChannelBitmap[0]), &(tempChannelList[0]), &i );*/
+
+            param.paramType = REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS;
+            param.content.siteMgrRadioBand = pScanParams->band;
+            /*param.content.supportedChannels.listOfChannels = tempChannelList;*/
+            regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain, &param );
+            i = param.content.supportedChannels.sizeOfList;
+            if (i > SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND)
+            {
+                i = SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND;
+            }
+            os_memoryCopy(pScanConcentrator->hOS, tempChannelList, param.content.supportedChannels.listOfChannels, i);
+            /* add default values to channels extracted from the bitmap */
+            for ( j = 0; j < i; j++ )
+            {
+
+                param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+                param.content.channelCapabilityReq.band = pScanParams->band;
+                if ( (pScanParams->scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                     (pScanParams->scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+                     (pScanParams->scanType == SCAN_TYPE_SPS) )
+                {
+                    param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+                }
+                else
+                {
+                    param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+                }
+                param.content.channelCapabilityReq.channelNum = tempChannelList[ j ];
+                regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain, &param );
+                if (param.content.channelCapabilityRet.channelValidity == TRUE)
+                {
+                    /* add the channel ID */
+                    pScanParams->channelEntry[ j ].normalChannelEntry.channel = tempChannelList[ j ];
+                    /* add other default parameters */
+                    pScanParams->channelEntry[ j ].normalChannelEntry.minChannelDwellTime = 
+                        SCAN_DEFAULT_MIN_CHANNEL_DWELL_TIME;
+                    pScanParams->channelEntry[ j ].normalChannelEntry.maxChannelDwellTime = 
+                        SCAN_DEFAULT_MAX_CHANNEL_DWELL_TIME;
+                    pScanParams->channelEntry[ j ].normalChannelEntry.earlyTerminationEvent =  
+                        SCAN_DEFAULT_EARLY_TERMINATION_EVENT;
+                    pScanParams->channelEntry[ j ].normalChannelEntry.ETMaxNumOfAPframes = 
+                        SCAN_DEFAULT_EARLY_TERMINATION_NUM_OF_FRAMES;
+                    pScanParams->channelEntry[ j ].normalChannelEntry.txPowerDbm = param.content.channelCapabilityRet.maxTxPowerDbm;
+
+                    /* Fill broadcast BSSID */
+                    for ( k = 0; k < 6; k++ )
+                    {
+                        pScanParams->channelEntry[ j ].normalChannelEntry.bssId.addr[ k ] = 0xff;
+                    }
+
+                    validChannelsCnt++;
+                }
+            }
+            pScanParams->numOfChannels = validChannelsCnt;
+        }
+    }
+    /* channels were supplied by user - must verify that all of them are allowed */
+    else
+    {
+        /* check channels */
+        for ( i = 0; i < pScanParams->numOfChannels; )
+        { /* Note that i is only increased when channel is valid - if channel is invalid, another 
+             channel is copied in its place, and thus the same index should be checked again. However,
+             since the number of channels is decreased, the loop end condition is getting nearer! */
+            
+            param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+            param.content.channelCapabilityReq.band = pScanParams->band;
+            if ( (pScanParams->scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                 (pScanParams->scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+                 (pScanParams->scanType == SCAN_TYPE_SPS) )
+            {
+                param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+            }
+            else
+            {
+                param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+            }
+            
+            /* SPS scan */
+            if ( SCAN_TYPE_SPS == pScanParams->scanType )
+            {
+                param.content.channelCapabilityReq.channelNum = pScanParams->channelEntry[ i ].SPSChannelEntry.channel;
+                regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain, &param );
+                if (!param.content.channelCapabilityRet.channelValidity)
+                {   /* channel not allowed - copy the rest of the channel in its place */
+                    os_memoryCopy( pScanConcentrator->hOS, &(pScanParams->channelEntry[ i ]),
+                                   &(pScanParams->channelEntry[ i + 1 ]), sizeof(scan_SPSChannelEntry_t) * 
+                                                                          (pScanParams->numOfChannels - i - 1) );
+                    pScanParams->numOfChannels--;
+                }
+                else
+                {
+                    i += 1;
+                }
+                
+            }
+            /* all other scan types */
+            else
+            {
+                param.content.channelCapabilityReq.channelNum = pScanParams->channelEntry[ i ].normalChannelEntry.channel;
+                regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain, &param );
+                if (!param.content.channelCapabilityRet.channelValidity)
+                {   /* channel not allowed - copy the rest of the channel in its place */
+                    os_memoryCopy( pScanConcentrator->hOS, &(pScanParams->channelEntry[ i ]),
+                                   &(pScanParams->channelEntry[ i + 1 ]), sizeof(scan_normalChannelEntry_t) * 
+                                                                          (pScanParams->numOfChannels - i - 1) );
+                    pScanParams->numOfChannels--;
+                }
+                else
+                {
+                    pScanParams->channelEntry[i].normalChannelEntry.txPowerDbm = 
+                                                       MIN( param.content.channelCapabilityRet.maxTxPowerDbm, 
+                                                               pScanParams->channelEntry[i].normalChannelEntry.txPowerDbm ); 
+
+                    i += 1;
+                }
+            }
+        }
+    }
+}
+
+/**
+ * \author Yuval Adler\n
+ * \date 26-Jan-2006\n
+ * \brief enable/disable the use of SG parameters , and update parameters of next scans 
+ *      requests for minDwellTime,MaxDwellTime,numProbeReq  .\n
+ *          this function is called when SG is enabled or disabled from the SoftGemini module
+ *          The compensation is needed since BT Activity holds the antenna and over-ride Scan activity
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param bUseSGParams - whether to use the new parameters (TRUE when SG is enabled)
+ * \param probeReqNumber - 
+ * \param SGcompensationMaxTime - max value from which we won't increase dwelling time
+ * \param SGcompensationPercent - increasing dwell time in that percentage
+ */
+void scanConcentrator_SGconfigureScanParams( TI_HANDLE hScanCncn, BOOL bUseSGParams ,
+                                             UINT8 probeReqNumber , UINT32 SGcompensationMaxTime, 
+                                             UINT32 SGcompensationPercent) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    pScanConcentrator->bUseSGParams            = bUseSGParams;
+    pScanConcentrator->SGnumOfProbeRequest     = probeReqNumber;
+    pScanConcentrator->SGcompensationMaxTime   = SGcompensationMaxTime;
+    pScanConcentrator->SGcompensationPercent   = SGcompensationPercent;
+
+    WLAN_REPORT_INFORMATION(pScanConcentrator->hReport,SCAN_CNCN_MODULE_LOG,
+            ("%s: bUseSGParams = %d, numOfProbeRequest = %d, compensationMaxTime = %d, SGcompensationPercent = %d\n "
+            ,__FUNCTION__,pScanConcentrator->bUseSGParams,pScanConcentrator->SGnumOfProbeRequest,
+            pScanConcentrator->SGcompensationMaxTime,pScanConcentrator->SGcompensationPercent));
+}
+
+/**
+ * \author Yuval Adler\n
+ * \date 26-Jan-2006\n
+ * \brief update minDwellTime,MaxDwellTime,numProbeReq according to SG module request .\n
+ *          this function is called when SG is enabled.
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pScanParams - a pointer to the structure holding the scan params .\n
+ */
+void scanConcentrator_SGupdateScanParams( TI_HANDLE hScanCncn, scan_Params_t* pScanParams ) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    UINT8 i;
+    UINT32 tempTime;
+
+    /* for each channel increase the min and max dwell time */
+    for ( i = 0 ; i < pScanParams->numOfChannels ; i++)
+    {       
+        if (pScanConcentrator->SGcompensationMaxTime >
+            pScanParams->channelEntry[i].normalChannelEntry.minChannelDwellTime)
+        {
+            tempTime = ((pScanParams->channelEntry[i].normalChannelEntry.minChannelDwellTime) * 
+                ( 100 + pScanConcentrator->SGcompensationPercent)) / 100 ;
+
+            if (tempTime > pScanConcentrator->SGcompensationMaxTime)
+            {
+                tempTime = pScanConcentrator->SGcompensationMaxTime;
+            }
+            pScanParams->channelEntry[i].normalChannelEntry.minChannelDwellTime = tempTime;
+        }
+
+        if (pScanConcentrator->SGcompensationMaxTime > 
+                pScanParams->channelEntry[i].normalChannelEntry.maxChannelDwellTime)
+        {
+            tempTime = ((pScanParams->channelEntry[i].normalChannelEntry.maxChannelDwellTime) * 
+                ( 100 + pScanConcentrator->SGcompensationPercent)) / 100 ;
+                    
+            if (tempTime > pScanConcentrator->SGcompensationMaxTime)
+            {
+                tempTime = pScanConcentrator->SGcompensationMaxTime;
+            }
+            pScanParams->channelEntry[i].normalChannelEntry.maxChannelDwellTime = tempTime;
+        }
+        WLAN_REPORT_INFORMATION(pScanConcentrator->hReport,SCAN_CNCN_MODULE_LOG,
+                ("%s new parmas : channel = %d  MaxDwellTime = %d MinDwellTime = %d\n"
+                ,__FUNCTION__,i,pScanParams->channelEntry[i].normalChannelEntry.maxChannelDwellTime,
+                pScanParams->channelEntry[i].normalChannelEntry.minChannelDwellTime));
+    }
+
+    /* update ProbeReqNumber only if it is larger than 0 and smaller than the new value */
+    if ((pScanParams->probeReqNumber > 0) && 
+        (pScanConcentrator->SGnumOfProbeRequest > pScanParams->probeReqNumber))
+    {
+        pScanParams->probeReqNumber = pScanConcentrator->SGnumOfProbeRequest;
+    }
+
+    WLAN_REPORT_INFORMATION(pScanConcentrator->hReport,SCAN_CNCN_MODULE_LOG,
+        ("%s number of Probe requests = %d\n",__FUNCTION__,pScanParams->probeReqNumber));
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncn.h b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncn.h
new file mode 100644 (file)
index 0000000..10df17f
--- /dev/null
@@ -0,0 +1,280 @@
+/** \file ScanCncn.h
+ *  \brief This file include private definitions for the scan concentrator module.
+ *  \author Ronen Kalish
+ *  \date 30-Dec-2004
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCN_H__
+#define __SCANCNCN_H__
+
+#include "osApi.h"
+#include "MacServices_api.h" 
+#include "ScanCncnApi.h"
+#include "fsm.h"
+#include "ScanCncnDrvSM.h"
+
+
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/* allocation vector */
+#define SCAN_ALLOC_OBJECT           0
+#define SCAN_ALLOC_APP_SM           1
+#define SCAN_ALLOC_DRV_SM           2
+#define SCAN_ALLOC_CONT_SM          3
+#define SCAN_ALLOC_IMMED_SM         4
+#define SCAN_ALLOC_OID_SM                      5  
+
+/* Used in parameter: bAbortOrStop in scanConcentrator_t. */
+#define SCAN_CNCN_ABORT         FALSE
+#define SCAN_CNCN_STOP          TRUE
+
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct scanConcentrator_t
+ * \brief This structure contains the scan concentrator object data
+ */
+typedef struct
+{
+    /* handles to other modules */
+    TI_HANDLE               hOS;                    /**< OS object handle */
+       TI_HANDLE                               hHalCtrl;                               /**< Hal Ctrl object handle */
+    TI_HANDLE               hReport;                /**< report object handle */
+    TI_HANDLE               hRegulatoryDomain;      /**< regulatory domain object handle */
+    TI_HANDLE               hSiteManager;           /**< site manager object handle */
+    TI_HANDLE               hSCR;                   /**< SCR object handle */
+    TI_HANDLE               hMacServices;           /**< Mac SRV object handle */
+    TI_HANDLE               hAPConn;                /**< AP connection object handle */
+    TI_HANDLE               hEventSrv;              /**< Event SRV object handle */
+    TI_HANDLE               hMlme;                  /**< MLME object handle */
+    TI_HANDLE               hCtrlData;              /**< Data CTRL object handle (for retrieving current BSSID) */
+       TI_HANDLE                               hHealthMonitor;                 /**< Health Monitor , Originally at scanSrv */
+
+    /* Scan complete callbacks */ 
+    scan_resultCB_t         scanResultCB[ SCAN_SCC_NUM_OF_CLIENTS ];          /**< 
+                                                                               * scan complete callback function 
+                                                                               * pointers, for various clients
+                                                                               */
+    TI_HANDLE               scanResultCBObj[ SCAN_SCC_NUM_OF_CLIENTS ];       /**< 
+                                                                               * scan complete callback objects,
+                                                                               * for various clients
+                                                                               */
+    scan_cncnResultStatus_e scanResult[ SCAN_SCC_NUM_OF_CLIENTS ];            /**< 
+                                                                               * clients' scan results, used to
+                                                                               * keep information when abort or
+                                                                               * stop or requested or a FW reset
+                                                                               * occurs
+                                                                               */
+    UINT16                  SPSScanResult;                                    /**< 
+                                                                               * Indicated which channels were
+                                                                               * actually scanned (valid only
+                                                                               * for SPS scan */
+
+    /* state machines */
+    fsm_stateMachine_t*     clientSM[ SCAN_SCC_NUM_OF_CLIENTS ];              /**< 
+                                                                               * state machines for different
+                                                                               * scan types
+                                                                               */
+    UINT8                   clientSMState[ SCAN_SCC_NUM_OF_CLIENTS ];         /**< 
+                                                                               * state machine current states 
+                                                                               * for different scan types
+                                                                               */
+
+    /* Scan requests */
+    scan_CncnClient_e       currentRunningScanClient;                         /**< 
+                                                                               * the current client for which
+                                                                               * a scan is in progress
+                                                                               */
+    scan_Params_t           clientScanParams[ SCAN_SCC_NUM_OF_CLIENTS ];      /**<
+                                                                               * scan parameters copy for 
+                                                                               * different clients
+                                                                               */
+    scan_Type_e             drvScanRequestType;                               /**<
+                                                                               * the scan type requested by the
+                                                                               * driver scan. Saved if a passive
+                                                                               * scan is done before the requested
+                                                                               * scan type
+                                                                               */
+    ssid_t                  drvScanSsid;                                      /**<
+                                                                               * the desired SSID requested by the 
+                                                                               * driver scan. Saved to allow replacing
+                                                                               * original with broadcast for passive
+                                                                               * scan, to find country IE in any beacon
+                                                                               */
+    UINT32                  drvScanMinDwellTime[ SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND ];
+                                                                              /**<
+                                                                               * The min dwell time for all channels
+                                                                               * requested by driver scan. Saved if a
+                                                                               * passive scan is performed before the
+                                                                               *requested scan type.
+                                                                               */
+    UINT32                  drvScanMaxDwellTime[ SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND ];
+                                                                              /**<
+                                                                               * The max dwell time for all channels
+                                                                               * requested by driver scan. Saved if a
+                                                                               * passive scan is performed before the
+                                                                               *requested scan type.
+                                                                               */
+    BOOLEAN                 bAbortOrStop;                                     /**<
+                                                                               * FLASE if the cancel reason is
+                                                                               * abort (from SCR), TRUE if stop
+                                                                               * (from requesting client)
+                                                                               */
+    BOOLEAN                 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)
+                                                                               */
+    BOOLEAN                                    bUseSGParams;                                                                     /**<
+                                                                                                                                                          * Indicates whether to use the new params
+                                                                                                                                                          * of the soft gemini module. This parameter
+                                                                                                                                                          * is TRUE when SG is enabled and FALSE otherwise
+                                                                                                                                                          */
+       UINT32                                  SGcompensationPercent;                                                    /**<
+                                                                                                                                                          * the percentage of increasing the dwell time
+                                                                                                                                                          * on each channel when SG is enabled (that is 
+                                                                                                                                                          * bUseSGParams == TRUE)
+                                                                                                                                                          */
+       UINT32                                  SGcompensationMaxTime;                                                    /**<
+                                                                                                                                                          * maximum time in microsecond from which we 
+                                                                                                                                                          * won't increase the dwelling time on the 
+                                                                                                                                                          * channel when SG is enabled
+                                                                                                                                                          */
+       UINT8                                   SGnumOfProbeRequest;                                                      /**<
+                                                                                                                                                          * number of Probes to send
+                                                                                                                                                          * when SG is enabled
+                                                                                                                                                          */   
+               
+    /* connection status */
+    connectionStatus_e      connectionStatus;   /**< the current connection status - connected / not connected / IBSS */
+    scanConcentratorInitParams_t    initParams; /**< 
+                                                 * parameters read from the registry (min and max dwell time
+                                                 * for driver passive scan
+                                                 */
+/* OID scan SM */
+       fsm_stateMachine_t*             hOidSM;                         /**< Handle to the OID scan SM - patch for WinCE support */
+       UINT8                               oidSMState;                 /**< current state for the OID scan SM - patch for WinCE support */
+       scan_Params_t                   oidScanParams;          /**< Storage spcae for OID scan parameters */
+       BOOLEAN                                 bOidScanRunning;        /**< Inidcates whether an OID scan is currently taking place */
+       UINT32                                  oidScanLastTimeStamp; /**< The last time at which an OID scan was performed */
+} scanConcentrator_t;
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-Jan-2005\n
+ * \brief Frees the scan concentrator memory, according to the init vector.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param initVec - a vector holding on bits for allocated components and off bits for non allocated components
+ */
+void scanConcentrator_freeMem( TI_HANDLE hScanCncn, UINT16 initVec );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Jan-2005\n
+ * \brief Verifies that specified channels are allowed for the specified scan type, and removes those that are not.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pScanParams - a pointer to the structure holding the scan params (inc. channels and scan type)
+ */
+void scanConcentrator_verifyChannelsWithRegDomain( TI_HANDLE hScanCncn, scan_Params_t* pScanParams );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Jan-2005\n
+ * \brief Verifies if a certain channel is allowed according to the given bitmap.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pScanParams - a pointer to the structure holding the scan params (inc. channels and scan type)
+ * \return TRUE if the channel is allowed, FALSE otherwise.\n
+ */
+BOOLEAN scanConcentrator_isChannelAllowed( UINT8 channel, UINT8* pChannelBitmap );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-Jan-2005\n
+ * \brief Extracts channel indexes from the bitmap to the list.
+ *
+ * Function Scope \e Private.\n
+ * \param band - the band at which the scan is to be performed (to limit max channel number)
+ * \param pChannelBitmap - the channel bitmap (input).\n
+ * \param pChannelBitmap - the channel list (output).\n
+ * \param pNumOfChannels - the number of channels (input - size of channel list, output - actual number of channels).\n
+ */
+void scanConcentrator_ExtractBitmapToList( radioBand_e band, UINT8* pChannelBitmap,
+                                           UINT8* pChannelList, UINT8* pNumOfChannels );
+
+#endif /* __SCANCNCN_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppApi.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppApi.c
new file mode 100644 (file)
index 0000000..d37467d
--- /dev/null
@@ -0,0 +1,213 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 ScanCncnAppApi.c
+ *  \brief This file include implementation of application scan requests adapter.\n
+ *  \author Ronen Kalish
+ *  \date 30-Jan-2005
+ */
+
+#include "ScanCncnAppApi.h"
+#include "ScanCncn.h"
+#include "EvHandler.h"
+#include "report.h"
+#include "smeApi.h"
+#include "siteMgrApi.h"
+#include "ScanCncnOidSM.h"
+
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Jan-2005\n
+ * \brief Parses and executes a set param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pParam - the param to set.\n
+ * \return OK if the scan started successfully, NOK otherwise.\n
+ */
+TI_STATUS scanConcentrator_setParam( TI_HANDLE hScanCncn, paramInfo_t *pParam )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t *)hScanCncn;
+       scan_Params_t* pScanParam; 
+       UINT32 currentTimeStamp;
+
+    switch ( pParam->paramType )
+    {
+       case SCAN_CNCN_START_APP_SCAN:
+               pScanParam = pParam->content.pScanParams;
+               /*
+                * Prepare scan complete's aging, by increasing the scanned sites 
+                * scan attemps counter. The counter will be checked upon scan complete,  
+                * and the sites with no update scan results will be dropped.   
+                */
+               siteMgr_setNotReceivedParameter( pScanConcentrator->hSiteManager, &(pScanParam->desiredSsid), pScanParam->band );
+        
+               if ( SCAN_CRS_SCAN_RUNNING != 
+                scanConcentrator_scan( hScanCncn, SCAN_SCC_APP, pScanParam ) )
+        {
+            /* Scan was not started successfully, send a scan complete event to the user */
+            EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
+            return NOK;
+        }
+        break;
+
+    case SCAN_CNCN_STOP_APP_SCAN:
+        scanConcentrator_stopScan( hScanCncn, SCAN_SCC_APP );
+        break;
+       case SCAN_CNCN_BSSID_LIST_SCAN_PARAM:
+               /* check if OID scans are enabled in the registry */
+               if ( 0 == pScanConcentrator->initParams.minimumDurationBetweenOidScans )
+               {
+                       WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                                                        ("Received OID scan request when OID scans are disabled, quitting...\n") );
+                       return OK; /* TODO ronen: return correct Windows value */
+               }
+
+               /* check if the last OID scan didn't start at a shorter duration than the configured minimum */
+               currentTimeStamp = os_timeStampMs( pScanConcentrator->hOS );
+               if ( (currentTimeStamp - pScanConcentrator->oidScanLastTimeStamp) < 
+                        (pScanConcentrator->initParams.minimumDurationBetweenOidScans * 1000) ) /*converted to ms */
+               {
+                       WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                                                        ("Last OID scan performed at:%d, now is:%d, min duration is %d, too early for another scan!\n", \
+                                                                         pScanConcentrator->oidScanLastTimeStamp, currentTimeStamp, pScanConcentrator->initParams.minimumDurationBetweenOidScans) );
+                       return OK; /* TODO ronen: return correct Windows value */
+               }
+
+               /* mark that an OID scan process has started */
+               pScanConcentrator->bOidScanRunning = TRUE;
+               pScanConcentrator->oidScanLastTimeStamp = currentTimeStamp;
+               WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                                                ("Starting OID scan process...\n") );
+
+               /* and actually start the scan */
+               scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_START_SCAN );
+               break;
+        
+    default:
+           WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                           ("Set param, Params is not supported:%d\n\n", pParam->paramType) );
+           return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Jan-2005\n
+ * \brief Parses and executes a get param command.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param pParam - the param to get.\n
+ * \return always PARAM_NOT_SUPPORTED (not supposed to be called).\n
+ */
+TI_STATUS scanConcentrator_getParam( TI_HANDLE hScanCncn, paramInfo_t *pParam )
+{
+    return PARAM_NOT_SUPPORTED;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 30-Jan-2005\n
+ * \brief Scan result callback for application scan.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param status - the scan result status (scan complete, result received etc.).\n
+ * \param frameInfo - a pointer to the structure holding all frame related info (in case a frame was received).\n
+ * \prama SPSStatus - a bitmap indicating on which channels scan was attempted (valid for SPS scan only!).\n
+ */
+void scanConcentrator_appScanResultCB( TI_HANDLE hScanCncn, scan_cncnResultStatus_e status,
+                                       scan_frameInfo_t* frameInfo, UINT16 SPSStatus )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    switch ( status )
+       {
+       case SCAN_CRS_RECEIVED_FRAME:
+        /* forward scan results to site manager, like in the good old days... */
+        siteMgr_updateSite( pScanConcentrator->hSiteManager, frameInfo->bssId, 
+                            frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE );
+        if ( BEACON == frameInfo->parsedIEs->subType )
+        {
+            siteMgr_saveBeaconBuffer( pScanConcentrator->hSiteManager, frameInfo->bssId, 
+                                      frameInfo->buffer, frameInfo->bufferLength );
+        }
+        else
+        {
+            siteMgr_saveProbeRespBuffer( pScanConcentrator->hSiteManager, frameInfo->bssId,
+                                         frameInfo->buffer, frameInfo->bufferLength );
+        }              
+               break;
+
+       case SCAN_CRS_SCAN_COMPLETE_OK:
+               siteMgr_removeNotReceivedSites( pScanConcentrator->hSiteManager );
+
+       /* There's no break on purpose! */
+               /* if the current running app scan is an OID scan, send a scan complete event to its state machine */
+               if ( TRUE == pScanConcentrator->bOidScanRunning )
+               {
+                       scanConcentratorOidSM_SMEvent(hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_COMPLETE );
+               }
+               else
+               {
+                       /* send a scan complete event to the user */
+                       EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
+               }
+               break;
+       case SCAN_CRS_TSF_ERROR:
+       case SCAN_CRS_SCAN_STOPPED:
+       case SCAN_CRS_SCAN_RUNNING:
+       case SCAN_CRS_SCAN_FAILED:
+       case SCAN_CRS_SCAN_ABORTED_HIGHER_PRIORITY:
+       case SCAN_CRS_SCAN_ABORTED_FW_RESET:
+       case SCAN_CRS_NUM_OF_RES_STATUS:
+       default:
+        /* The scan was finished, send a scan complete event to the user
+                  (regardless of why the scan was completed) */
+               if ( TRUE == pScanConcentrator->bOidScanRunning )
+               {
+                       scanConcentratorOidSM_SMEvent(hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+               }
+               else
+               {
+        EvHandlerSendEvent( pScanConcentrator->hEventSrv, IPC_EVENT_SCAN_COMPLETE, NULL, 0 );
+               }
+               break;
+       }
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppSM.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppSM.c
new file mode 100644 (file)
index 0000000..495cd85
--- /dev/null
@@ -0,0 +1,466 @@
+/** \file ScanCncnAppSM.c
+ *  \brief This file include the scan concentrator application SM module implementation
+ *  \author Ronen Kalish
+ *  \date 03-Jan-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanCncnAppSM.h"
+#include "MacServices_api.h" 
+#include "report.h"
+#include "healthMonitor.h"
+
+static TI_STATUS actionUnexpected( TI_HANDLE hScanCncn );
+static TI_STATUS actionNop( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator application SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_init( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    fsm_actionCell_t    smMatrix[ APP_SCAN_NUM_OF_STATES ][ APP_SCAN_NUM_OF_EVENTS ] =
+       {
+               /* next state and actions for IDLE state */
+               {       
+            {APP_SCAN_STATE_SCR_REQUEST, scanConcentratorAppSM_requestSCR},              /*"START_SCAN",*/
+                       {APP_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {APP_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_PEND",  */
+            {APP_SCAN_STATE_IDLE, actionNop},                                            /*"STOP_SCAN"*/
+            {APP_SCAN_STATE_IDLE, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {APP_SCAN_STATE_IDLE, actionUnexpected},                                     /*"FW_RESET"*/
+            {APP_SCAN_STATE_IDLE, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+               },
+
+               /* next state and actions for SCR_REQUEST state */
+               {       
+            {APP_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"START_SCAN",*/
+                       {APP_SCAN_STATE_SCANNING, scanConcentratorAppSM_startScan},                  /*"SCR_RUN",*/
+                       {APP_SCAN_STATE_IDLE, scanConcentratorAppSM_scanRejected},                   /*"SCR_PEND",  */
+            {APP_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"STOP_SCAN"*/
+            {APP_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {APP_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"FW_RESET"*/
+            {APP_SCAN_STATE_SCR_REQUEST, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for SCANNING state */
+               {       
+            {APP_SCAN_STATE_SCANNING, actionUnexpected},                                    /*"START_SCAN",*/
+                       {APP_SCAN_STATE_SCANNING, actionUnexpected},                                    /*"SCR_RUN",*/
+                       {APP_SCAN_STATE_SCANNING, actionUnexpected},                                    /*"SCR_PEND",  */
+            {APP_SCAN_STATE_STOPPING, scanConcentratorAppSM_abortScan},                  /*"STOP_SCAN"*/
+            {APP_SCAN_STATE_STOPPING, scanConcentratorAppSM_abortScan},                  /*"ABORT_SCAN"*/
+            {APP_SCAN_STATE_SCANNING, scanConcentratorAppSM_recoveryDuringScan},         /*"FW_RESET"*/
+            {APP_SCAN_STATE_IDLE, scanConcentratorAppSM_scanComplete}                    /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for STOPPING state */
+               {       
+            {APP_SCAN_STATE_STOPPING, actionUnexpected},                                    /*"START_SCAN",*/
+                       {APP_SCAN_STATE_STOPPING, actionUnexpected},                                    /*"SCR_RUN",*/
+                       {APP_SCAN_STATE_STOPPING, actionUnexpected},                                    /*"SCR_PEND",  */
+            {APP_SCAN_STATE_STOPPING, actionNop},                                        /*"STOP_SCAN"*/
+            {APP_SCAN_STATE_STOPPING, actionNop},                                        /*"ABORT_SCAN"*/
+            {APP_SCAN_STATE_STOPPING, scanConcentratorAppSM_recoveryDuringScan},         /*"FW_RESET"*/
+            {APP_SCAN_STATE_IDLE, scanConcentratorAppSM_scanComplete}                    /*"SCAN_COMPLETE"*/
+               }
+    };
+
+    /* initialize current state */
+    pScanConcentrator->clientSMState[ SCAN_SCC_APP ] = APP_SCAN_STATE_IDLE;
+
+    /* configure the state machine */
+       return fsm_Config( pScanConcentrator->clientSM[ SCAN_SCC_APP ], (fsm_Matrix_t)smMatrix, 
+                       APP_SCAN_NUM_OF_STATES, APP_SCAN_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)scanConcentratorAppSM_SMEvent, pScanConcentrator->hOS );
+}
+
+
+#ifdef REPORT_LOG
+
+/* state descriptions, for state machine logging */
+static char stateDesc[ APP_SCAN_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] = 
+{
+    "STATE_IDLE",
+       "STATE_SCR_REQUEST",
+       "STATE_SCANNING",
+       "STATE_STOPPING"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ APP_SCAN_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] = 
+{
+    "EVENT_START_SCAN",
+    "EVENT_SCR_RUN",
+    "EVENT_SCR_PEND",
+    "EVENT_STOP_SCAN",
+    "EVENT_ABORT_SCAN",
+    "EVENT_FW_RESET",
+    "EVENT_SCAN_COMPLETE"
+};
+
+#endif
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current App SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_SMEvent( TI_HANDLE hScanCncn, scan_appSMStates_e* currentState, 
+                                         scan_appSMEvents_e event )
+{
+    scanConcentrator_t *pScanConcentrator = (scanConcentrator_t *)hScanCncn;
+       TI_STATUS status = OK;
+       UINT8 nextState;
+
+    /* obtain the next state */
+       status = fsm_GetNextState( pScanConcentrator->clientSM[ SCAN_SCC_APP ], *(UINT8*)currentState,
+                                (UINT8)event, &nextState );
+       if ( status != OK )
+       {
+               WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Failed getting application scan next state.\n") );
+               return NOK;
+       }
+
+    /* report the move */
+    WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                    ("APP SCAN: <%s, %s> --> %s\n\n",
+                    stateDesc[*((UINT8*)currentState)],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+
+    /* move */
+    return fsm_Event( pScanConcentrator->clientSM[ SCAN_SCC_APP ], (UINT8*)currentState, (UINT8)event, hScanCncn );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_requestSCR( TI_HANDLE hScanCncn )
+{
+    scr_clientRequestStatus_e scrReplyStatus;
+       scr_pendReason_e scrPendReason;
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: Requesting SCR.\n") );
+    
+    /* request the SCR as application scan client, and act according to return status */
+    switch ( scrReplyStatus = scr_clientRequest( pScanConcentrator->hSCR, SCR_CID_APP_SCAN, &scrPendReason ) )
+    {
+    case SCR_CRS_PEND:
+        /* send a pend event to the SM */
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("APP SM: SCR pending, pend reason: %d.\n", scrPendReason) );
+               pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_FAILED;
+        return scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                              (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                              APP_SCAN_EVENT_SCR_PEND );
+/*        break; - unreachable */
+
+    case SCR_CRS_RUN:
+        /* send a run event to the SM */
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("APP SM: SCR acquired.\n") );
+        return scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                              (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                              APP_SCAN_EVENT_SCR_RUN );
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: SCR returned unrecognized status: %d.\n", scrReplyStatus) );
+        /* Notify scan complete to recover from this error */
+               pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_FAILED;
+        scanConcentratorAppSM_SMEvent( hScanCncn,
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_SCAN_COMPLETE );
+        
+        return NOK;
+/*        break; - unreachable */
+    }
+
+ /*   return OK; - unreachable */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a SCR run event (starts the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_startScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    TI_STATUS status;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: Sending scan command to scan SRV.\n") );
+
+    /* mark that this scan is currently running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_APP;
+
+    /* register for scan results with the MLME parser */
+    if ( OK != (status = mlmeParser_registerForBeaconAndProbeResp( pScanConcentrator->hMlme, 
+                                                                   scanConcentrator_mlmeResultCB, 
+                                                                   hScanCncn )) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: MLME result registration failed.\n") );
+
+        /* mark the return status */
+        pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_FAILED;
+
+        /* could not start scan, send a scan complete event */
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_SCAN_COMPLETE );
+
+        return NOK;
+    }
+       
+        /* stop built-in test timer, to avoid TX stuck due to heavy traffic and unknown scan result time originally at scanSrv*/
+       healthMonitor_suspendPeriodicTest( pScanConcentrator->hHealthMonitor );
+
+    /* call the scan SRV start scan - enter driver mode (PS) only if station is connected */
+    if ( OK != (status = MacServices_scanSRV_scan( pScanConcentrator->hMacServices, 
+                                              &(pScanConcentrator->clientScanParams[ SCAN_SCC_APP ]),
+                                              FALSE,
+                                              (STA_CONNECTED == pScanConcentrator->connectionStatus ? TRUE : FALSE),
+                                              FALSE,
+                                              POWER_SAVE_ON, /* this parameter is used only when driver mode requested */
+                                              (STA_CONNECTED == pScanConcentrator->connectionStatus ? TRUE : FALSE),
+                                                                                         NULL,NULL)))
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: scan SRV returned status %d, quitting app scan.\n", status) );
+
+        /* mark the return status */
+        pScanConcentrator->scanResult[ SCAN_SCC_APP ] = SCAN_CRS_SCAN_FAILED;
+
+           /* unregister at the MLME for scan result frames */
+        mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+        /* could not start scan, send a scan complete event */
+        scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                       (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                       APP_SCAN_EVENT_SCAN_COMPLETE );
+
+        return NOK;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles an abort scan event (call the scan SRV stop)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_abortScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: aborting scan.\n") );
+    
+    /* call the scan SRV stop scan. Whether to exit driver mode depends on the connection status
+       (scan when not connected or in IBSS does not request PS) and on the flag set by the
+       scan concentrator API functions (abort or stop)*/
+    if ( pScanConcentrator->connectionStatus != STA_CONNECTED )
+    {
+        MacServices_scanSRV_stopScan( pScanConcentrator->hMacServices, FALSE , NULL , NULL );
+    }
+    else
+    {
+        BOOLEAN  bSendNullData = (pScanConcentrator->bAbortOrStop == SCAN_CNCN_STOP) ? TRUE : FALSE;
+        MacServices_scanSRV_stopScan( pScanConcentrator->hMacServices,  bSendNullData, NULL , NULL );
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (releases the SCR and call the scan complete CB)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_scanComplete( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: Scan is complete.\n") );
+
+       /* unregister at the MLME for scan result frames */
+    mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+    /* mark that this scan is no longer running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_NO_CLIENT;
+
+    /* release the SCR with the client ID used for request */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_APP_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_APP ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_APP ],
+                                                         pScanConcentrator->scanResult[ SCAN_SCC_APP ],
+                                                         NULL, 0xffff );    
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_recoveryDuringScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: Recovery occured!.\n") );
+    
+    /* reset the scan SRV */
+    MacServices_scanSRV_stopOnFWReset( pScanConcentrator->hMacServices );
+
+    /* send a scan complete event to the SM */
+    return scanConcentratorAppSM_SMEvent( hScanCncn, 
+                                          (scan_appSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_APP ]),
+                                          APP_SCAN_EVENT_SCAN_COMPLETE );    
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan actually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_scanRejected( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("APP SM: Scan is rejected.\n") );
+
+    /* release the SCR with the client ID used for request */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_APP_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_APP ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_APP ],
+                                                         pScanConcentrator->scanResult[ SCAN_SCC_APP ],
+                                                         NULL, 0xffff );    
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-Jan-2005\n
+ * \brief Handles an unexpected event.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionUnexpected( TI_HANDLE hScanCncn ) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                                       ("Application scan state machine error, unexpected Event, state=%d\n\n",
+                                        pScanConcentrator->clientSMState[SCAN_SCC_APP]) );
+       
+    return 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 hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionNop( TI_HANDLE hScanCncn )
+{
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppSM.h b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnAppSM.h
new file mode 100644 (file)
index 0000000..15b2f6a
--- /dev/null
@@ -0,0 +1,203 @@
+/** \file ScanCncnAppSM.h
+ *  \brief This file include definitions for the scan concentrator Application SM module.
+ *  \author Ronen Kalish
+ *  \date 02-Jan-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNAPPSM_H__
+#define __SCANCNCNAPPSM_H__
+
+#include "osApi.h"
+#include "ScanCncn.h"
+#include "fsm.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scan_appSMEvents_e
+ * \brief enumerates the different application scan SM events
+ */
+typedef enum
+{
+    APP_SCAN_EVENT_START_SCAN = 0,
+    APP_SCAN_EVENT_SCR_RUN,
+    APP_SCAN_EVENT_SCR_PEND,
+    APP_SCAN_EVENT_STOP_SCAN,
+    APP_SCAN_EVENT_ABORT_SCAN,
+    APP_SCAN_EVENT_FW_RESET,
+    APP_SCAN_EVENT_SCAN_COMPLETE,
+    APP_SCAN_NUM_OF_EVENTS
+} scan_appSMEvents_e;
+
+/** \enum scan_appSMStates_e
+ * \brief enumerates the different application scan SM states
+ */
+typedef enum
+{
+       APP_SCAN_STATE_IDLE = 0,
+       APP_SCAN_STATE_SCR_REQUEST,
+       APP_SCAN_STATE_SCANNING,
+       APP_SCAN_STATE_STOPPING,
+       APP_SCAN_NUM_OF_STATES
+} scan_appSMStates_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator application SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_init( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current App SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_SMEvent( TI_HANDLE hScanCncn, scan_appSMStates_e* currentState, 
+                                         scan_appSMEvents_e event );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_requestSCR( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a SCR run event (starts the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_startScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles an abort scan event (call the scan SRV stop)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_abortScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (releases the SCR and call the scan complete CB)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_scanComplete( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_recoveryDuringScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan acrually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorAppSM_scanRejected( TI_HANDLE hScanCncn );
+
+#endif /* __SCANCNCNAPPSM_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnDrvSM.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnDrvSM.c
new file mode 100644 (file)
index 0000000..cd8b6ba
--- /dev/null
@@ -0,0 +1,789 @@
+/** \file ScanCncnDrvSM.c
+ *  \brief This file include the scan concentrator driver state machine module implementation
+ *  \author Ronen Kalish
+ *  \date 03-Jan-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanCncnDrvSM.h"
+#include "MacServices_api.h" 
+#include "report.h"
+#include "siteMgrApi.h"
+#include "utils.h"
+#include "regulatoryDomainApi.h"
+#include "healthMonitor.h"
+
+
+static TI_STATUS actionUnexpected( TI_HANDLE hScanCncn );
+static TI_STATUS actionNop( TI_HANDLE hScanCncn );
+
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator driver SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_init( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    fsm_actionCell_t    smMatrix[ DRV_SCAN_NUM_OF_STATES ][ DRV_SCAN_NUM_OF_EVENTS ] =
+       {
+               /* next state and actions for IDLE state */
+               {       
+            {DRV_SCAN_STATE_SCR_REQUEST, scanConcentratorDrvSM_requestSCR},              /*"START_SCAN",*/
+                       {DRV_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {DRV_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {DRV_SCAN_STATE_IDLE, actionUnexpected},                                     /*"PASSIVE_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, actionUnexpected},                                     /*"ACTIVE_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, actionUnexpected},                                     /*"FW_RESET"*/
+            {DRV_SCAN_STATE_IDLE, actionNop},                                            /*"STOP_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+               },
+
+               /* next state and actions for SCR_REQUEST state */
+               {       
+            {DRV_SCAN_STATE_SCR_REQUEST, actionUnexpected},                              /*"START_SCAN",*/
+                       {DRV_SCAN_STATE_SCR_WAIT, actionNop},                                        /*"SCR_PEND",  */
+                       {DRV_SCAN_STATE_IDLE, scanConcentratorDrvSM_scanRejected},                   /*"SCR_REJECT",*/
+            {DRV_SCAN_STATE_PASSIVE_SCANNING, scanConcentratorDrvSM_passiveScan},        /*"PASSIVE_SCAN"*/
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, scanConcentratorDrvSM_activeScan},          /*"ACTIVE_SCAN"*/
+            {DRV_SCAN_STATE_SCR_REQUEST, actionUnexpected},                              /*"ABORT_SCAN"*/
+            {DRV_SCAN_STATE_SCR_REQUEST, actionUnexpected},                              /*"FW_RESET"*/
+            {DRV_SCAN_STATE_SCR_REQUEST, actionUnexpected},                              /*"STOP_SCAN"*/
+            {DRV_SCAN_STATE_SCR_REQUEST, actionUnexpected}                               /*"SCAN_COMPLETE"*/
+               },
+
+               /* next state and actions for SCR_WAIT state */
+               {       
+            {DRV_SCAN_STATE_SCR_WAIT, actionUnexpected},                                 /*"START_SCAN",*/
+                       {DRV_SCAN_STATE_SCR_WAIT, actionNop},                                        /*"SCR_PEND",  */
+                       {DRV_SCAN_STATE_IDLE, scanConcentratorDrvSM_scanRejected},                   /*"SCR_REJECT",*/
+            {DRV_SCAN_STATE_PASSIVE_SCANNING, scanConcentratorDrvSM_passiveScan},        /*"PASSIVE_SCAN"*/
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, scanConcentratorDrvSM_activeScan},          /*"ACTIVE_SCAN"*/
+            {DRV_SCAN_STATE_SCR_WAIT, actionUnexpected},                                 /*"ABORT_SCAN"*/
+            {DRV_SCAN_STATE_SCR_WAIT, actionUnexpected},                                 /*"FW_RESET"*/
+            {DRV_SCAN_STATE_IDLE, scanConcentratorDrvSM_scanRejected},                   /*"STOP_SCAN"*/
+            {DRV_SCAN_STATE_SCR_WAIT, actionUnexpected}                                  /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for PASSIVE_SCANNING state */
+               {       
+            {DRV_SCAN_STATE_PASSIVE_SCANNING, actionUnexpected},                               /*"START_SCAN",*/
+                       {DRV_SCAN_STATE_PASSIVE_SCANNING, actionUnexpected},                               /*"SCR_PEND",  */
+                       {DRV_SCAN_STATE_PASSIVE_SCANNING, actionUnexpected},                               /*"SCR_REJECT",*/
+            {DRV_SCAN_STATE_PASSIVE_SCANNING, actionUnexpected},                               /*"PASSIVE_SCAN"*/
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, scanConcentratorDrvSM_activeScan},          /*"ACTIVE_SCAN"*/
+            {DRV_SCAN_STATE_STOPPING, scanConcentratorDrvSM_abortScan},                  /*"ABORT_SCAN"*/
+            {DRV_SCAN_STATE_PASSIVE_SCANNING, scanConcentratorDrvSM_recoveryDuringScan}, /*"FW_RESET"*/
+            {DRV_SCAN_STATE_STOPPING, scanConcentratorDrvSM_abortScan},                  /*"STOP_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, scanConcentratorDrvSM_scanComplete}                    /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for ACTIVE_SCANNING state */
+               {       
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, actionUnexpected},                                     /*"START_SCAN",*/
+                       {DRV_SCAN_STATE_ACTIVE_SCANNING, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {DRV_SCAN_STATE_ACTIVE_SCANNING, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, actionUnexpected},                                     /*"PASSIVE_SCAN"*/
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, actionUnexpected},                                     /*"ACTIVE_SCAN"*/
+            {DRV_SCAN_STATE_STOPPING, scanConcentratorDrvSM_abortScan},                  /*"ABORT_SCAN"*/
+            {DRV_SCAN_STATE_ACTIVE_SCANNING, scanConcentratorDrvSM_recoveryDuringScan},  /*"FW_RESET"*/
+            {DRV_SCAN_STATE_STOPPING, scanConcentratorDrvSM_abortScan},                  /*"STOP_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, scanConcentratorDrvSM_scanComplete}                    /*"SCAN_COMPLETE"*/
+
+               },
+
+        /* next state and actions for STOPPING state */
+               {       
+            {DRV_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"START_SCAN",*/
+                       {DRV_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {DRV_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {DRV_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"PASSIVE_SCAN"*/
+            {DRV_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"ACTIVE_SCAN"*/
+            {DRV_SCAN_STATE_STOPPING, actionNop},                                        /*"ABORT_SCAN"*/
+            {DRV_SCAN_STATE_STOPPING, scanConcentratorDrvSM_recoveryDuringScan},         /*"FW_RESET"*/
+            {DRV_SCAN_STATE_STOPPING, actionNop},                                        /*"STOP_SCAN"*/
+            {DRV_SCAN_STATE_IDLE, scanConcentratorDrvSM_scanComplete}                    /*"SCAN_COMPLETE"*/
+               }
+    };
+
+    /* initialize current state */
+    pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ] = DRV_SCAN_STATE_IDLE;
+
+    /* configure the state machine */
+       return fsm_Config( pScanConcentrator->clientSM[ SCAN_SCC_DRIVER ], (fsm_Matrix_t)smMatrix, 
+                       DRV_SCAN_NUM_OF_STATES, DRV_SCAN_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)scanConcentratorDrvSM_SMEvent, pScanConcentrator->hOS );
+}
+
+
+#ifdef REPORT_LOG
+
+/* state descriptions, for state machine logging */
+static char stateDesc[ DRV_SCAN_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] = 
+{
+    "STATE_IDLE",
+    "STATE_SCR_REQUEST",
+    "STATE_SCR_WAIT",
+    "STATE_PASSIVE_SCANNING",
+    "STATE_ACTIVE_SCANNING",
+    "STATE_STOPPING"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ DRV_SCAN_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] = 
+{
+    "EVENT_START_SCAN",
+    "EVENT_SCR_PEND",
+    "EVENT_SCR_REJECT",
+    "EVENT_PASSIVE_SCAN",
+    "EVENT_ACTIVE_SCAN",
+    "EVENT_ABORT_SCAN",
+    "EVENT_FW_RESET",
+    "EVENT_STOP_SCAN",
+    "EVENT_SCAN_COMPLETE"
+};
+
+#endif
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current driver SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_SMEvent( TI_HANDLE hScanCncn, scan_drvSMStates_e* currentState, 
+                                         scan_drvSMEvents_e event )
+{
+    scanConcentrator_t *pScanConcentrator = (scanConcentrator_t *)hScanCncn;
+       TI_STATUS status = OK;
+       UINT8 nextState;
+
+    /* obtain the next state */
+       status = fsm_GetNextState( pScanConcentrator->clientSM[ SCAN_SCC_DRIVER ], *(UINT8*)currentState,
+                               (UINT8)event, &nextState );
+       if ( status != OK )
+       {
+               WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Failed getting driver scan next state.\n") );
+               return NOK;
+       }
+
+    /* report the move */
+    WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                    ("DRIVER SCAN: <%s, %s> --> %s\n\n",
+                    stateDesc[*((UINT8*)currentState)],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+
+    /* move */
+    return fsm_Event( pScanConcentrator->clientSM[ SCAN_SCC_DRIVER ], (UINT8*)currentState, (UINT8)event, hScanCncn );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_requestSCR( TI_HANDLE hScanCncn )
+{
+    scr_clientRequestStatus_e scrReplyStatus;
+    scr_pendReason_e scrPendReason;
+       scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: Requesting SCR.\n") );
+
+    /* request the SCR as driver client, and act according to return status */
+    switch (  scrReplyStatus = scr_clientRequest( pScanConcentrator->hSCR, SCR_CID_DRIVER_FG_SCAN, &scrPendReason ) )
+    {
+    case SCR_CRS_PEND:
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("DRV SM: SCR pending, pend reason: %d.\n", scrPendReason) );
+        
+        /* check the pending reason */
+        if ( SCR_PR_DIFFERENT_GROUP_RUNNING == scrPendReason )
+        {
+            /* send a reject event to the SM - would not scan if not in connecting mode! */
+            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_FAILED; 
+            return scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                                  (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                                  DRV_SCAN_EVENT_SCR_REJECT );
+        }
+        else
+        {
+            /* send a pend event to the SM */
+            return scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                                  (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                                   DRV_SCAN_EVENT_SCR_PEND );
+        }
+ /*       break; - unreachable */
+
+    case SCR_CRS_RUN:
+        /* send an event to the SM */
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("DRV SM: SCR acquired.\n") );
+        return scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                              (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                              scanConcentrator_getNextDriverEvent( hScanCncn ) );
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: SCR returned unrecognized status: %d.\n", scrReplyStatus) );
+               pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_FAILED;
+        scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                       (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                       DRV_SCAN_EVENT_SCAN_COMPLETE );
+        return NOK;
+/*        break; - unreachable */
+    }
+
+ /*   return OK; - unreachable */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a FW reset event (by calling the complete CB)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_callCompleteCB( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: calling complete CB.\n") );
+
+    /* mark that no scan is currently running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_NO_CLIENT;
+
+    /* notify scan complete to scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_DRIVER ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_DRIVER ],
+                                                        pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ],
+                                                        NULL, 0xffff );
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a passive scan event (by starting a passive scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_passiveScan( TI_HANDLE hScanCncn )
+{
+    TI_STATUS status;
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    int i;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: Sending passive scan command to scan SRV.\n") );
+
+    /* mark that this scan is currently running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_DRIVER;
+
+    /* if the requested scan type is not passive in the first place, change it to passive */
+    pScanConcentrator->drvScanRequestType = pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType;
+    if ( (SCAN_TYPE_NORMAL_ACTIVE == pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType) ||
+         (SCAN_TYPE_TRIGGERED_ACTIVE == pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType) )
+    {
+        pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType = SCAN_TYPE_NORMAL_PASSIVE;
+        
+        /* save requested SSID, and write broadcast SSID instead. This is done to find ANY beacon for .11d
+           and .11h, in case the desired SSID is not being broadcast in beacons */
+        os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->drvScanSsid), 
+                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].desiredSsid), sizeof(ssid_t) );
+        pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].desiredSsid.len = 0;
+
+        /* save max and min dwell time for all channels, and replace them with default values */
+        for ( i = 0; i < pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].numOfChannels; i++ )
+        {
+            pScanConcentrator->drvScanMaxDwellTime[ i ] = 
+                pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.maxChannelDwellTime;
+            pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 
+                pScanConcentrator->initParams.passiveScanDwellTime;
+            pScanConcentrator->drvScanMinDwellTime[ i ] = 
+                pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.minChannelDwellTime;
+            pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 
+                pScanConcentrator->initParams.passiveScanDwellTime;
+                       if (pScanConcentrator->bUseSGParams)
+                       {
+                               /* increasing dwell time in case BT is active to compensate loss of dwelling time */
+                               pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.minChannelDwellTime =
+                                       (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.minChannelDwellTime * 
+                                       (100 + pScanConcentrator->SGcompensationPercent)) / 100;
+                               pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.maxChannelDwellTime =
+                                       (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.maxChannelDwellTime * 
+                                       (100 + pScanConcentrator->SGcompensationPercent)) / 100;
+                               WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("SoftGemini compensation time for channel %d : min = %d, max = %d  .\n",
+                                                        i,pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.minChannelDwellTime,
+                                                        pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.maxChannelDwellTime) );
+               
+                       }
+        }
+    }
+
+    /* ask the reg domain which channels are allowed for the requested scan type */
+    scanConcentrator_verifyChannelsWithRegDomain( hScanCncn, &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ]) );
+
+    /* if no channels are available for scan, return negative result */
+    if ( 0 == pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].numOfChannels )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: No cahnnels available for passive scan, quitting.\n") );
+        scanConcentratorDrvSM_handleScanError( hScanCncn );
+        return NOK;
+    }
+
+    /* register for scan results with the MLME parser */
+    if ( OK != (status = mlmeParser_registerForBeaconAndProbeResp( pScanConcentrator->hMlme, 
+                                                                   scanConcentrator_mlmeResultCB, 
+                                                                   hScanCncn )) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: MLME result registration failed.\n") );
+        scanConcentratorDrvSM_handleScanError( hScanCncn );
+        return NOK;
+    }
+
+        /* stop built-in test timer, to avoid TX stuck due to heavy traffic and unknown scan result time originally at scanSrv*/
+       healthMonitor_suspendPeriodicTest( pScanConcentrator->hHealthMonitor );
+
+    /* call the scan SRV start scan */
+    if ( OK != (status = MacServices_scanSRV_scan( pScanConcentrator->hMacServices, 
+                                              &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ]),
+                                              FALSE,
+                                              FALSE,
+                                              FALSE,
+                                              POWER_SAVE_KEEP_CURRENT,
+                                              FALSE ,
+                                                                                         NULL,NULL)) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: scan SRV returned status %d, quitting driver passive scan.\n", status) );
+
+        /* unregister at the MLME for scan result frames */
+        mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+        scanConcentratorDrvSM_handleScanError( hScanCncn );
+        return NOK;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles an active scan event (by starting an active scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_activeScan( TI_HANDLE hScanCncn )
+{
+    TI_STATUS status;
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: Sending active scan command to scan SRV.\n") );
+
+    /* mark that this scan is currently running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_DRIVER;
+
+    /* ask the reg domain which channels are allowed for the requested scan type */
+    scanConcentrator_verifyChannelsWithRegDomain( hScanCncn, &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ]) );
+
+    /* if no channels are available for scan, return negative result */
+    if ( 0 == pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].numOfChannels )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: No cahnnels available for active scan, quitting.\n") );
+        scanConcentratorDrvSM_handleScanError( hScanCncn );
+        return NOK;
+    }
+
+
+    /* register for scan results with the MLME parser */
+    if ( OK != mlmeParser_registerForBeaconAndProbeResp( pScanConcentrator->hMlme, 
+                                                         scanConcentrator_mlmeResultCB, 
+                                                         hScanCncn ) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: MLME result registration failed.\n") );
+        scanConcentratorDrvSM_handleScanError( hScanCncn );
+        return NOK;
+    }
+
+       /* stop built-in test timer, to avoid TX stuck due to heavy traffic and unknown scan result time originally at scanSrv*/
+       healthMonitor_suspendPeriodicTest( pScanConcentrator->hHealthMonitor );
+
+    if ( OK != (status = MacServices_scanSRV_scan( pScanConcentrator->hMacServices, 
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ]),
+                                       FALSE,
+                                       FALSE,
+                                       FALSE,
+                                       POWER_SAVE_KEEP_CURRENT,
+                                       FALSE ,
+                                                                          NULL,NULL)) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: scan SRV returned status %d, quitting driver active scan.\n", status) );
+           /* unregister at the MLME for scan result frames */
+        mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+        scanConcentratorDrvSM_handleScanError( hScanCncn );
+        return NOK;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles an abort scan or stop scan event (by stopping the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_abortScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: aborting scan.\n") );
+
+    /* call the scan SRV stop scan (don't exit driver mode, as it wasn't entered for driver scan */
+    MacServices_scanSRV_stopScan( pScanConcentrator->hMacServices, FALSE , NULL , NULL );
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_recoveryDuringScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: Recovery occured!.\n") );
+    
+    /* reset the scan SRV */
+    MacServices_scanSRV_stopOnFWReset( pScanConcentrator->hMacServices );
+
+    /* send a scan complete event to the SM */
+    return scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                          (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                          DRV_SCAN_EVENT_SCAN_COMPLETE );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (by releasing the SCR and calling the scan complete CB)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_scanComplete( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: Scan is complete.\n") );
+
+       /* unregister at the MLME for scan result frames */
+    mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+    /* mark that this scan is no longer running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_NO_CLIENT;
+
+    /* release the SCR */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_DRIVER_FG_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_DRIVER ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_DRIVER ],
+                                                            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ],
+                                                            NULL, 0xffff );    
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan actually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_scanRejected( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: Scan is Rejected.\n") );
+
+    /* release the SCR */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_DRIVER_FG_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_DRIVER ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_DRIVER ],
+                                                            pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ],
+                                                            NULL, 0xffff );    
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-Jan-2005\n
+ * \brief Handles an unexpected event.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionUnexpected( TI_HANDLE hScanCncn ) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Driver scan state machine error, unexpected Event, state=%d\n\n",
+                                                                                                                                         pScanConcentrator->clientSMState[SCAN_SCC_DRIVER] ) );
+       
+    return 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 hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionNop( TI_HANDLE hScanCncn )
+{
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Jan-2005\n
+ * \brief Determines the next event to send to the driver SM (when a scan can be run)\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return the next event to use with the driver SM.\n
+ */
+scan_drvSMEvents_e scanConcentrator_getNextDriverEvent( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    paramInfo_t         param;
+    BOOL                is_801_11d_enabled, is_801_11h_enabled;
+    int                                        i;
+
+    /* getting regulatory Domain status - is 802.11d enabled ? */
+    param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
+    regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain,&param );
+    is_801_11d_enabled = param.content.regulatoryDomainEnabled;
+
+    param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+    regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain,&param );
+       is_801_11h_enabled = param.content.spectrumManagementEnabled;
+
+    /* The next event (or rather, scan type) is determined according to the driver SM state.
+       The order is passive-active, when either the active or passive scan can be eliminated (but the order is kept).
+     */
+    switch (pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ])
+    {
+    /* active scan already performed, send a scan complete event */
+    case DRV_SCAN_STATE_ACTIVE_SCANNING:
+    /* Stop or abort is in progress, also send a scan complete event */
+    case DRV_SCAN_STATE_STOPPING:
+        return DRV_SCAN_EVENT_SCAN_COMPLETE;
+/*        break; - unreachable */
+
+    /* passive scan already performed, check if active scan is needed. */
+    case DRV_SCAN_STATE_PASSIVE_SCANNING:
+        /* first, restore the user requested scan type, */
+        pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType = pScanConcentrator->drvScanRequestType;
+        /* the user desired SSID */
+        os_memoryCopy( pScanConcentrator->hOS, &(pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].desiredSsid),
+                       &(pScanConcentrator->drvScanSsid), sizeof(ssid_t) );
+        /* and dwell times for all channels */
+        for ( i = 0; i < pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].numOfChannels; i++ )
+        {
+            pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 
+                pScanConcentrator->drvScanMaxDwellTime[ i ];
+            pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 
+                pScanConcentrator->drvScanMinDwellTime[ i ];
+        }
+
+        /* send scan complete event if:
+           1. The requested scan type is passive
+           2. .11d is enabled and no country IE is available
+         */
+
+               /* Get country code status */
+               param.paramType                  = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
+               param.content.eRadioBand = pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].band;
+               regulatoryDomain_getParam(pScanConcentrator->hRegulatoryDomain,&param);
+               
+        if ( (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+             (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+             (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType == SCAN_TYPE_SPS) ||
+             ((TRUE == is_801_11d_enabled) && 
+              ( !param.content.bIsCountryFound )) )
+        {
+            return DRV_SCAN_EVENT_SCAN_COMPLETE;
+        }
+        /* otherwise, send active scan event */
+        else
+        {
+            /* Very ugly - but nowhere better to do it...
+               If we continue to active scan after passive scan, we are already registered
+               in the MLME parser. We MUST unregister here, or else the registration at
+               the active scan call will fail */
+            mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+            return DRV_SCAN_EVENT_ACTIVE_SCAN;
+        }
+/*        break; - unreachable */
+
+    /* no scan already performed, any scan can be issued */
+    case DRV_SCAN_STATE_SCR_WAIT:
+    case DRV_SCAN_STATE_SCR_REQUEST:
+        /* do a passive scan if:
+           1. it was requested
+           2. .11d is enabled and country is unknown
+           3. .11h is enabled and the scan is on A band (always perform passive before active, to validate channels)
+         */
+
+               /* Get country code status */
+               param.paramType                  = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
+               param.content.eRadioBand = pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].band ;
+               regulatoryDomain_getParam(pScanConcentrator->hRegulatoryDomain,&param);
+
+        if ( (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+             (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+             (pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].scanType == SCAN_TYPE_SPS) ||
+             ((TRUE == is_801_11d_enabled) && 
+              (!param.content.bIsCountryFound)) ||
+             ((TRUE == is_801_11h_enabled) && 
+              (RADIO_BAND_5_0_GHZ == pScanConcentrator->clientScanParams[ SCAN_SCC_DRIVER ].band)) )
+        {
+            return DRV_SCAN_EVENT_PASSIVE_SCAN;
+        }
+        /* else, do an active scan if
+         */
+        else
+        {
+            return DRV_SCAN_EVENT_ACTIVE_SCAN;
+        }
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("DRV SM: State %d is invalid to obtain next event", pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]) );
+        break;
+    }
+
+    return DRV_SCAN_EVENT_SCAN_COMPLETE;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 07-Feb-2005\n
+ * \brief Handles an error during scan operation
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentratorDrvSM_handleScanError( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    
+    /* mark the return status */
+    pScanConcentrator->scanResult[ SCAN_SCC_DRIVER ] = SCAN_CRS_SCAN_FAILED;
+
+    /* send a scan complete event */
+    scanConcentratorDrvSM_SMEvent( hScanCncn, 
+                                   (scan_drvSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_DRIVER ]),
+                                   DRV_SCAN_EVENT_SCAN_COMPLETE );
+}
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnDrvSM.h b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnDrvSM.h
new file mode 100644 (file)
index 0000000..7f47605
--- /dev/null
@@ -0,0 +1,250 @@
+/** \file ScanCncnDrvSM.h
+ *  \brief This file include definitions for the scan concentrator Driver SM module.
+ *  \author Ronen Kalish
+ *  \date 02-Jan-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNDRVSM_H__
+#define __SCANCNCNDRVSM_H__
+
+#include "osApi.h"
+#include "ScanCncn.h"
+#include "fsm.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scan_drvSMEvents_e
+ * \brief enumerates the different driver scan SM events
+ */
+typedef enum
+{
+    DRV_SCAN_EVENT_START_SCAN = 0,
+    DRV_SCAN_EVENT_SCR_PEND,
+    DRV_SCAN_EVENT_SCR_REJECT,
+    DRV_SCAN_EVENT_PASSIVE_SCAN,
+    DRV_SCAN_EVENT_ACTIVE_SCAN,
+    DRV_SCAN_EVENT_ABORT_SCAN,
+    DRV_SCAN_EVENT_FW_RESET,
+    DRV_SCAN_EVENT_STOP_SCAN,
+    DRV_SCAN_EVENT_SCAN_COMPLETE,
+    DRV_SCAN_NUM_OF_EVENTS
+} scan_drvSMEvents_e;
+
+/** \enum scan_drvSMEvents_e
+ * \brief enumerates the different driver scan SM states
+ */
+typedef enum
+{
+    DRV_SCAN_STATE_IDLE = 0,
+    DRV_SCAN_STATE_SCR_REQUEST,
+    DRV_SCAN_STATE_SCR_WAIT,
+    DRV_SCAN_STATE_PASSIVE_SCANNING,
+    DRV_SCAN_STATE_ACTIVE_SCANNING,
+    DRV_SCAN_STATE_STOPPING,
+    DRV_SCAN_NUM_OF_STATES
+} scan_drvSMStates_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator driver SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_init( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current driver SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_SMEvent( TI_HANDLE hScanCncn, scan_drvSMStates_e* currentState, 
+                                         scan_drvSMEvents_e event );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_requestSCR( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a FW reset event (by calling the complete CB)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_callCompleteCB( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a passive scan event (by starting a passive scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_passiveScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles an active scan event (by starting an active scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_activeScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles an abort scan or stop scan event (by stopping the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_abortScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_recoveryDuringScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (by releasing the SCR and calling the scan complete CB)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_scanComplete( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan acrually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorDrvSM_scanRejected( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 09-Jan-2005\n
+ * \brief Determines the next event to send to the driver SM (when a scan can be run)\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return the next event to use with the driver SM.\n
+ */
+scan_drvSMEvents_e scanConcentrator_getNextDriverEvent( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 07-Feb-2005\n
+ * \brief Handles an error during scan operation
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ */
+void scanConcentratorDrvSM_handleScanError( TI_HANDLE hScanCncn );
+
+#endif /* __SCANCNCNDRVSM_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnOidSM.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnOidSM.c
new file mode 100644 (file)
index 0000000..7a8100b
--- /dev/null
@@ -0,0 +1,501 @@
+/** \file ScanCncnOidSM.c
+ *  \brief This file include the scan concentrator OID request SM module implementation
+ *  \author Ronen Kalish
+ *  \date 11-May-2006
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanCncnOidSM.h"
+#include "ScanCncn.h"
+#include "report.h"
+#include "osApi.h"
+#include "fsm.h"
+#include "siteMgrApi.h"
+#include "regulatoryDomainApi.h"
+
+static TI_STATUS actionUnexpected( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-May-2006\n
+ * \brief Initialize the scan concentrator OID scan SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_init( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    fsm_actionCell_t    smMatrix[ OID_SCAN_NUM_OF_STATES ][ OID_SCAN_NUM_OF_EVENTS ] =
+       {
+               /* next state and actions for IDLE state */
+               {       
+            {OID_SCAN_STATE_SCAN_ON_G, scanConcentratorOidSM_actionStartGScan},         //"START_SCAN",
+                       {OID_SCAN_STATE_IDLE, actionUnexpected},                                    //"SCAN_COMPLETE",  
+                       {OID_SCAN_STATE_IDLE, actionUnexpected},                                    //"SCAN_FAILED",
+               },
+
+               /* next state and actions for SCAN_ON_G state */
+               {       
+            {OID_SCAN_STATE_SCAN_ON_G, actionUnexpected},                               //"START_SCAN",
+                       {OID_SCAN_STATE_SCAN_ON_A, scanConcentratorOidSM_actionStartAScan},         //"SCAN_COMPLETE",  
+                       {OID_SCAN_STATE_SCAN_ON_A, scanConcentratorOidSM_actionStartAScan},         //"SCAN_FAILED",
+               },
+
+               /* next state and actions for SCAN_ON_A state */
+               {       
+            {OID_SCAN_STATE_SCAN_ON_A, actionUnexpected},                               //"START_SCAN",
+                       {OID_SCAN_STATE_IDLE, scanConcentratorOidSM_actionCleanup},                 //"SCAN_COMPLETE",  
+                       {OID_SCAN_STATE_IDLE, scanConcentratorOidSM_actionCleanup},                                     //"SCAN_FAILED",
+               }
+    };
+
+    /* initialize current state */
+    pScanConcentrator->oidSMState = OID_SCAN_STATE_IDLE;
+       pScanConcentrator->bOidScanRunning = FALSE;
+       pScanConcentrator->oidScanLastTimeStamp = 0;
+
+    /* configure the state machine */
+       return fsm_Config( pScanConcentrator->hOidSM, (fsm_Matrix_t)smMatrix, 
+                       OID_SCAN_NUM_OF_STATES, OID_SCAN_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)scanConcentratorOidSM_SMEvent, pScanConcentrator->hOS );
+}
+
+#ifdef REPORT_LOG
+/* state descriptions, for state machine logging */
+static char stateDesc[ OID_SCAN_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] =
+{
+    "STATE_IDLE",
+    "STATE_SCAN_ON_G",
+    "STATE_SCAN_ON_A"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ OID_SCAN_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] =
+{
+    "EVENT_START_SCAN",
+    "EVENT_SCAN_COMPLETE",
+    "EVENT_SCAN_FAILED"
+};
+#endif
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current OID request SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_SMEvent( TI_HANDLE hScanCncn, scan_oidSMStates_e* currentState, 
+                                         scan_oidSMEvents_e event )
+{
+    scanConcentrator_t *pScanConcentrator = (scanConcentrator_t *)hScanCncn;
+       TI_STATUS status = OK;
+       UINT8 nextState;
+
+    /* obtain the next state */
+       status = fsm_GetNextState( pScanConcentrator->hOidSM, (UINT8)*currentState, 
+                               (UINT8)event, &nextState );
+       if ( status != OK )
+       {
+               WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Failed getting OID scan next state.\n") );
+               return NOK;
+       }
+
+    /* report the move */
+    WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                    ("OID SCAN: <%s, %s> --> %s\n\n",
+                    stateDesc[(UINT8)*currentState],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+
+    /* move */
+    return fsm_Event( pScanConcentrator->hOidSM, (UINT8*)currentState, (UINT8)event, hScanCncn );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief SM action - starts a scan on G band
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_actionStartGScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+       paramInfo_t         param;
+       int                                     validChannelsCount;
+       BOOL                            regulatoryDomainEnabled;
+
+       /* if the STA is not configured for G band or dual band, send a scan complete event to the SM */
+       param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
+       siteMgr_getParam( pScanConcentrator->hSiteManager, &param );
+       if ( (DOT11_G_MODE != param.content.siteMgrDot11Mode) && (DOT11_DUAL_MODE != param.content.siteMgrDot11Mode) )
+       {
+               WLAN_REPORT_INFORMATION( pScanConcentrator->hOS, SCAN_CNCN_MODULE_LOG,
+                                                                ("Scan OID SM: STA does not work on 2.4 GHz, continuing to 5.0 GHz scan\n") );
+               scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+               return OK;
+       }
+
+       /* build scan command header */
+       pScanConcentrator->oidScanParams.band = RADIO_BAND_2_4_GHZ;
+       pScanConcentrator->oidScanParams.desiredSsid.len = 0;
+       pScanConcentrator->oidScanParams.desiredSsid.ssidString[ 0 ] = '\0'; /* broadcast scan */
+       pScanConcentrator->oidScanParams.Tid = 0;
+
+       /* query the regulatory domain if 802.11d is in use */
+       param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
+       regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain,&param );
+       regulatoryDomainEnabled = param.content.regulatoryDomainEnabled;
+
+       /* Get country code status */
+       param.paramType                  = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
+       param.content.eRadioBand = RADIO_BAND_2_4_GHZ;
+       regulatoryDomain_getParam(pScanConcentrator->hRegulatoryDomain,&param);
+
+       /* scan type is passive if 802.11d is enabled and country IE was not yet found, active otherwise */
+       if ( (TRUE == regulatoryDomainEnabled) && 
+                (FALSE == param.content.bIsCountryFound) )
+       {
+               pScanConcentrator->oidScanParams.scanType = SCAN_TYPE_NORMAL_PASSIVE;
+       }
+       else
+       {
+               pScanConcentrator->oidScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
+               /* also set number and rate of probe requests */
+               pScanConcentrator->oidScanParams.probeReqNumber = SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_G;
+               pScanConcentrator->oidScanParams.probeRequestRate = SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_G;
+       }
+
+       /* add supported channels on G */
+       if ( SCAN_TYPE_NORMAL_PASSIVE == pScanConcentrator->oidScanParams.scanType )
+       {
+               validChannelsCount = scanConcentratorOidSM_FillAllAvailableChannels( hScanCncn, RADIO_BAND_2_4_GHZ, SCAN_TYPE_NORMAL_PASSIVE,
+                                       &(pScanConcentrator->oidScanParams.channelEntry[0]),
+                                                                                                                                                        SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_G,
+                                                                                                                                                        SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_G,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_G,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_G );
+       }
+       else
+       {
+               validChannelsCount = scanConcentratorOidSM_FillAllAvailableChannels( hScanCncn, RADIO_BAND_2_4_GHZ, SCAN_TYPE_NORMAL_ACTIVE,
+                                       &(pScanConcentrator->oidScanParams.channelEntry[0]),
+                                                                                                                                                        SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_G,
+                                                                                                                                                        SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_G,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_G,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_G );
+       }
+       pScanConcentrator->oidScanParams.numOfChannels = validChannelsCount;
+
+       /* check that some channels are available */
+       if ( validChannelsCount > 0 )
+       {
+               scan_cncnResultStatus_e res;
+               
+               /*
+                * Prepare scan complete's aging, by increasing the scanned sites 
+                * scan attemps counter. The counter will be checked upon scan complete,  
+                * and the sites with no update scan results will be dropped.   
+                */
+               siteMgr_setNotReceivedParameter( pScanConcentrator->hSiteManager, &(pScanConcentrator->oidScanParams.desiredSsid), 
+                                                RADIO_BAND_2_4_GHZ );
+
+               /* send command to scan concentrator APP SM */
+               res = scanConcentrator_scan(hScanCncn, SCAN_SCC_APP, &(pScanConcentrator->oidScanParams) );
+
+               /* if scan failed, send scan failed event to the SM */
+               if ( SCAN_CRS_SCAN_RUNNING != res )
+               {
+                       scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+               }
+       }
+       else
+       {
+               /* no channels to scan, send a scan failed event */
+               scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+       }
+
+       return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief SM action - starts a scan on A band
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_actionStartAScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+       paramInfo_t         param;
+       int                                     validChannelsCount;
+       BOOL                            regulatoryDomainEnabled;
+
+       /* if the STA is not configured for G band or dual band, send a scan complete event to the SM */
+       param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
+       siteMgr_getParam( pScanConcentrator->hSiteManager, &param );
+       if ( (DOT11_A_MODE != param.content.siteMgrDot11Mode) && (DOT11_DUAL_MODE != param.content.siteMgrDot11Mode) )
+       {
+               WLAN_REPORT_INFORMATION( pScanConcentrator->hOS, SCAN_CNCN_MODULE_LOG,
+                                                                ("Scan OID SM: STA does not work on 5.0 GHz, quitting\n") );
+               scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+               return OK;
+       }
+
+       /* build scan command header */
+       pScanConcentrator->oidScanParams.band = RADIO_BAND_5_0_GHZ;
+       pScanConcentrator->oidScanParams.desiredSsid.len = 0;
+       pScanConcentrator->oidScanParams.desiredSsid.ssidString[ 0 ] = '\0'; /* broadcast scan */
+       pScanConcentrator->oidScanParams.Tid = 0;
+
+       /* query the regulatory domain if 802.11d is in use */
+       param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
+       regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain,&param );
+       regulatoryDomainEnabled = param.content.regulatoryDomainEnabled;
+
+       /* Get country code status */
+       param.paramType                  = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
+       param.content.eRadioBand = RADIO_BAND_5_0_GHZ;
+       regulatoryDomain_getParam(pScanConcentrator->hRegulatoryDomain,&param);
+
+       /* scan type is passive if 802.11d is enabled and country IE was not yet found, active otherwise */
+       if ( (TRUE == regulatoryDomainEnabled) && 
+                (FALSE == param.content.bIsCountryFound) )
+       {
+               pScanConcentrator->oidScanParams.scanType = SCAN_TYPE_NORMAL_PASSIVE;
+       }
+       else
+       {
+               pScanConcentrator->oidScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
+               /* also set number and rate of probe requests */
+               pScanConcentrator->oidScanParams.probeReqNumber = SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_A;
+               pScanConcentrator->oidScanParams.probeRequestRate = SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_A;
+       }
+
+       /* add supported channels on G */
+       if ( SCAN_TYPE_NORMAL_PASSIVE == pScanConcentrator->oidScanParams.scanType )
+       {
+               validChannelsCount = scanConcentratorOidSM_FillAllAvailableChannels( hScanCncn, RADIO_BAND_5_0_GHZ, SCAN_TYPE_NORMAL_PASSIVE,
+                                       &(pScanConcentrator->oidScanParams.channelEntry[0]),
+                                                                                                                                                        SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_A,
+                                                                                                                                                        SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_A,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_A,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_A );
+       }
+       else
+       {
+               validChannelsCount = scanConcentratorOidSM_FillAllAvailableChannels( hScanCncn, RADIO_BAND_5_0_GHZ, SCAN_TYPE_NORMAL_ACTIVE,
+                                       &(pScanConcentrator->oidScanParams.channelEntry[0]),
+                                       SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_A,
+                                                                                                                                                        SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_A,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_A,
+                                                                                                                                                        SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_A );
+       }
+       pScanConcentrator->oidScanParams.numOfChannels = validChannelsCount;
+
+       /* check that some channels are available */
+       if ( validChannelsCount > 0 )
+       {
+               scan_cncnResultStatus_e res;
+
+               /*
+                * Prepare scan complete's aging, by increasing the scanned sites 
+                * scan attemps counter. The counter will be checked upon scan complete,  
+                * and the sites with no update scan results will be dropped.   
+                */
+               siteMgr_setNotReceivedParameter( pScanConcentrator->hSiteManager, &(pScanConcentrator->oidScanParams.desiredSsid), 
+                                                RADIO_BAND_5_0_GHZ );
+
+      /* send command to scan concentrator APP SM */
+               res = scanConcentrator_scan(hScanCncn, SCAN_SCC_APP, &(pScanConcentrator->oidScanParams) );
+
+               /* if scan failed, send scan failed event to the SM */
+               if ( SCAN_CRS_SCAN_RUNNING != res )
+               {
+                       scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+               }
+       }
+       else
+       {
+               /* no channels to scan, send a scan failed event */
+               scanConcentratorOidSM_SMEvent( hScanCncn, (scan_oidSMStates_e*)&(pScanConcentrator->oidSMState), OID_SCAN_EVENT_SCAN_FAILED );
+       }
+
+       return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-May-2006\n
+ * \brief SM action - Cleans up an OID scan operation
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_actionCleanup( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t*        pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+       /* mark that OID scan process is no longer running */
+       pScanConcentrator->bOidScanRunning = FALSE;
+
+
+       return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-May-2006\n
+ * \brief Fills a chhanel array with valid channels (and their params) according to band and scan type\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param band - band to extract channels for.\n
+ * \param scanType - scan type tp ectract channels for.\n
+ * \param channelArray - where to store allowed channels information.\n
+ * \param maxDwellTime - maximum dwell time value to be used for each channel.\n
+ * \param minDwellTime - minimum dwell time value to be used for each channel.\n
+ * \param ETCondition - early termination condition value to be used for each channel.\n
+ * \param ETFrameNumber - early termination frame number value to be used for each channel.\n
+ * \return Number of allowed channels (that were placed in the given channels array).\n
+ */
+UINT32 scanConcentratorOidSM_FillAllAvailableChannels( TI_HANDLE hScanCncn, radioBand_e band, scan_Type_e scanType,
+                                                                                                          scan_channelEntry_u* channelArray, UINT32 maxDwellTime,
+                                                                                                          UINT32 minChannelTime, scan_ETCondition_e ETCondition,
+                                                                                                          UINT8 ETFrameNumber )
+{
+    scanConcentrator_t*        pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+       int                                     i, j, allowedChannelsCount, validChannelsCnt = 0;
+       paramInfo_t                     param;
+       UINT8                                   tempChannelList[ SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND ];
+       /* get the numnber of supported channels for this band */
+       param.paramType = REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS;
+       param.content.siteMgrRadioBand = band;
+       regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain, &param );
+       allowedChannelsCount = param.content.supportedChannels.sizeOfList;
+
+       /* for the time being don't scan more channels than fit in one command */
+       if ( allowedChannelsCount > SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND )
+       {
+               allowedChannelsCount = SCAN_MAX_NUM_OF_NORMAL_CHANNELS_PER_COMMAND;
+       }
+
+       /* Copy allowed channels to reuse param var */
+       os_memoryCopy( pScanConcentrator->hOS, tempChannelList,
+                       param.content.supportedChannels.listOfChannels, allowedChannelsCount );
+
+       /* preapre the param var to request channel allowance for the requested scan type */
+       param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+       param.content.channelCapabilityReq.band = band;
+
+       /* add default values to channels allowed for the requested scan type and band */
+       for ( i = 0; i < allowedChannelsCount; i++ )
+       {
+               /* get specific channel allowance for scan type */
+               if ( (scanType == SCAN_TYPE_NORMAL_PASSIVE) ||
+                        (scanType == SCAN_TYPE_TRIGGERED_PASSIVE) ||
+                        (scanType == SCAN_TYPE_SPS) )
+               {
+                       param.content.channelCapabilityReq.scanOption = PASSIVE_SCANNING;
+               }
+               else
+               {
+                       param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+               }
+               param.content.channelCapabilityReq.channelNum = tempChannelList[ i ];
+
+               regulatoryDomain_getParam( pScanConcentrator->hRegulatoryDomain, &param );
+               if ( TRUE == param.content.channelCapabilityRet.channelValidity )
+               {
+                       /* add the channel ID */
+                       channelArray[ validChannelsCnt ].normalChannelEntry.channel = tempChannelList[ i ];
+
+                       /* add other default parameters */
+                       channelArray[ validChannelsCnt ].normalChannelEntry.minChannelDwellTime = minChannelTime;
+                       channelArray[ validChannelsCnt ].normalChannelEntry.maxChannelDwellTime = maxDwellTime;
+                       channelArray[ validChannelsCnt ].normalChannelEntry.earlyTerminationEvent = ETCondition;
+                   channelArray[ validChannelsCnt ].normalChannelEntry.ETMaxNumOfAPframes = ETFrameNumber;
+                       channelArray[ validChannelsCnt ].normalChannelEntry.txPowerDbm  = 
+                               param.content.channelCapabilityRet.maxTxPowerDbm;
+                       /* Fill broadcast BSSID */
+                       for ( j = 0; j < 6; j++ )
+                       {
+                               channelArray[ validChannelsCnt ].normalChannelEntry.bssId.addr[ j ] = 0xff;
+                       }
+                       validChannelsCnt++;
+               }
+       }
+
+       /* return the number of channels that are actually allowed for the requested scan type on the requested band */
+       return validChannelsCnt;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-Jan-2005\n
+ * \brief Handles an unexpected event.\n
+
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionUnexpected( TI_HANDLE hScanCncn ) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("OID scan state machine error, unexpected Event\n\n") );
+       
+    return OK;
+}
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnOidSM.h b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnOidSM.h
new file mode 100644 (file)
index 0000000..dbc44cc
--- /dev/null
@@ -0,0 +1,208 @@
+/** \file ScanCncnOidSM.h
+ *  \brief This file include definitions for the scan concentrator OID request SM module.
+ *  \author Ronen Kalish
+ *  \date 11-May-2006
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNOIDSM_H__
+#define __SCANCNCNOIDSM_H__
+
+#include "osTIType.h"
+#include "osApi.h"
+
+#include "scanTypes.h"
+#include "commonTypes.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+#define SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_G                                          DRV_RATE_MASK_2_BARKER
+#define SCAN_OID_DEFAULT_PROBE_REQUEST_RATE_A                                          DRV_RATE_6M
+#define SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_G                                                3
+#define SCAN_OID_DEFAULT_PROBE_REQUEST_NUMBER_A                                                3
+#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_G                                      100000
+#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_PASSIVE_A                                      100000
+#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_G                                       25000
+#define SCAN_OID_DEFAULT_MAX_DWELL_TIME_ACTIVE_A                                       25000
+#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_G                                      100000
+#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_PASSIVE_A                                      100000
+#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_G                                       5000
+#define SCAN_OID_DEFAULT_MIN_DWELL_TIME_ACTIVE_A                                       5000
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_G                     SCAN_ET_COND_BEACON
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_PASSIVE_A                     SCAN_ET_COND_BEACON
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_G                      SCAN_ET_COND_ANY_FRAME
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_EVENT_ACTIVE_A                      SCAN_ET_COND_ANY_FRAME
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_G                     2
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_PASSIVE_A                     2
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_G                      3
+#define SCAN_OID_DEFAULT_EARLY_TERMINATION_COUNT_ACTIVE_A                      3
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scan_oidSMEvents_e
+ * \brief enumerates the different scan OID request SM events
+ */
+typedef enum
+{
+    OID_SCAN_EVENT_START_SCAN = 0,
+    OID_SCAN_EVENT_SCAN_COMPLETE,
+    OID_SCAN_EVENT_SCAN_FAILED,
+    OID_SCAN_NUM_OF_EVENTS
+} scan_oidSMEvents_e;
+
+/** \enum scan_oidSMStates_e
+ * \brief enumerates the different scan OID request SM states
+ */
+typedef enum
+{
+    OID_SCAN_STATE_IDLE = 0,
+    OID_SCAN_STATE_SCAN_ON_G,
+       OID_SCAN_STATE_SCAN_ON_A,
+    OID_SCAN_NUM_OF_STATES
+} scan_oidSMStates_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief Initialize the scan concentrator OID request SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_init( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current OID request SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_SMEvent( TI_HANDLE hScanCncn, scan_oidSMStates_e* currentState, 
+                                         scan_oidSMEvents_e event );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief SM action - starts a scan on G band
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_actionStartGScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-May-2006\n
+ * \brief SM action - starts a scan on A band
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_actionStartAScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-May-2006\n
+ * \brief SM action - Cleans up an OID scan operation
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorOidSM_actionCleanup( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 14-May-2006\n
+ * \brief Fills a chhanel array with valid channels (and their params) according to band and scan type\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param band - band to extract channels for.\n
+ * \param scanType - scan type tp ectract channels for.\n
+ * \param channelArray - where to store allowed channels information.\n
+ * \param maxDwellTime - maximum dwell time value to be used for each channel.\n
+ * \param minDwellTime - minimum dwell time value to be used for each channel.\n
+ * \param ETCondition - early termination condition value to be used for each channel.\n
+ * \param ETFrameNumber - early termination frame number value to be used for each channel.\n
+ * \return Number of allowed channels (that were placed in the given channels array).\n
+ */
+UINT32 scanConcentratorOidSM_FillAllAvailableChannels( TI_HANDLE hScanCncn, radioBand_e band, scan_Type_e scanType,
+                                                                                                          scan_channelEntry_u* channelArray, UINT32 maxDwellTime,
+                                                                                                          UINT32 minChannelTime, scan_ETCondition_e ETCondition,
+                                                                                                          UINT8 ETFrameNumber );
+
+#endif /* __SCANCNCNOIDSM_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingContSM.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingContSM.c
new file mode 100644 (file)
index 0000000..cd75795
--- /dev/null
@@ -0,0 +1,488 @@
+/** \file ScanCncnRoamingContSM.c
+ *  \brief This file include the scan concentrator continuous scan for roaming module implementation
+ *  \author Ronen Kalish
+ *  \date 03-Jan-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanCncnRoamingContSM.h"
+#include "MacServices_api.h" 
+#include "report.h"
+#include "siteMgrApi.h"
+#include "healthMonitor.h"
+
+static TI_STATUS actionUnexpected( TI_HANDLE hScanCncn );
+static TI_STATUS actionNop( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator continuous scan for roaming SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_init( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    fsm_actionCell_t    smMatrix[ CONT_SCAN_NUM_OF_STATES ][ CONT_SCAN_NUM_OF_EVENTS ] =
+       {
+               /* next state and actions for IDLE state */
+               {       
+            {CONT_SCAN_STATE_SCR_REQUEST, scanConcentratorRoamingContSM_requestSCR},      /*"START_SCAN",*/
+                       {CONT_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {CONT_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {CONT_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {CONT_SCAN_STATE_IDLE, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {CONT_SCAN_STATE_IDLE, actionUnexpected},                                     /*"FW_RESET"*/
+            {CONT_SCAN_STATE_IDLE, actionNop},                                            /*"STOP_SCAN"*/
+            {CONT_SCAN_STATE_IDLE, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+            
+               },
+
+               /* next state and actions for SCR_REQUEST state */
+               {       
+            {CONT_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"START_SCAN",*/
+            {CONT_SCAN_STATE_SCANNING, scanConcentratorRoamingContSM_startScan},          /*"SCR_RUN",*/
+                       {CONT_SCAN_STATE_SCR_WAIT, actionNop},                                        /*"SCR_PEND",  */
+                       {CONT_SCAN_STATE_IDLE, scanConcentratorRoamingContSM_scanRejected},           /*"SCR_REJECT",*/
+            {CONT_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {CONT_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"FW_RESET"*/
+            {CONT_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"STOP_SCAN"*/
+            {CONT_SCAN_STATE_SCR_REQUEST, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+               },
+
+               /* next state and actions for SCR_WAIT state */
+               {       
+            {CONT_SCAN_STATE_SCR_WAIT, actionUnexpected},                                     /*"START_SCAN",*/
+                       {CONT_SCAN_STATE_SCANNING, scanConcentratorRoamingContSM_startScan},          /*"SCR_RUN",*/
+                       {CONT_SCAN_STATE_SCR_WAIT, actionNop},                                        /*"SCR_PEND",  */
+                       {CONT_SCAN_STATE_IDLE, scanConcentratorRoamingContSM_scanRejected},           /*"SCR_REJECT",*/
+            {CONT_SCAN_STATE_SCR_WAIT, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {CONT_SCAN_STATE_SCR_WAIT, actionUnexpected},                                     /*"FW_RESET"*/
+            {CONT_SCAN_STATE_IDLE, scanConcentratorRoamingContSM_scanRejected},           /*"STOP_SCAN"*/
+            {CONT_SCAN_STATE_SCR_WAIT, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for SCANNING state */
+        {       
+            {CONT_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"START_SCAN",*/
+                       {CONT_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {CONT_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {CONT_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {CONT_SCAN_STATE_STOPPING, scanConcentratorRoamingContSM_abortScan},          /*"ABORT_SCAN"*/
+            {CONT_SCAN_STATE_SCANNING, scanConcentratorRoamingContSM_recoveryDuringScan}, /*"FW_RESET"*/
+            {CONT_SCAN_STATE_STOPPING, scanConcentratorRoamingContSM_abortScan},          /*"STOP_SCAN"*/
+            {CONT_SCAN_STATE_IDLE, scanConcentratorRoamingContSM_scanComplete}            /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for STOPPING state */
+               {       
+            {CONT_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"START_SCAN",*/
+                       {CONT_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {CONT_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {CONT_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {CONT_SCAN_STATE_STOPPING, actionNop},                                        /*"ABORT_SCAN"*/
+            {CONT_SCAN_STATE_STOPPING, scanConcentratorRoamingContSM_recoveryDuringScan}, /*"FW_RESET"*/
+            {CONT_SCAN_STATE_STOPPING, actionNop},                                        /*"STOP_SCAN"*/
+            {CONT_SCAN_STATE_IDLE, scanConcentratorRoamingContSM_scanComplete}            /*"SCAN_COMPLETE"*/
+               }
+    };
+
+    /* initialize current state */
+    pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ] = CONT_SCAN_STATE_IDLE;
+
+    /* configure the state machine */
+       return fsm_Config( pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_CONT ], (fsm_Matrix_t)smMatrix, 
+                       CONT_SCAN_NUM_OF_STATES, CONT_SCAN_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)scanConcentratorRoamingContSM_SMEvent, pScanConcentrator->hOS );
+}
+
+
+#ifdef REPORT_LOG
+
+/* state descriptions, for state machine logging */
+static char stateDesc[ CONT_SCAN_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] = 
+{
+    "STATE_IDLE",
+    "STATE_SCR_REQUEST",
+    "STATE_SCR_WAIT",
+    "STATE_SCANNING",
+    "STATE_STOPPING"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ CONT_SCAN_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] = 
+{
+    "EVENT_START_SCAN",
+    "EVENT_SCR_RUN",
+    "EVENT_SCR_PEND",
+    "EVENT_SCR_REJECT",
+    "EVENT_ABORT_SCAN",
+    "EVENT_FW_RESET",
+    "EVENT_STOP_SCAN",
+    "EVENT_SCAN_COMPLETE"
+};
+
+#endif
+
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current continuous scan for roaming SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_SMEvent( TI_HANDLE hScanCncn, scan_contSMStates_e* currentState, 
+                                                 scan_contSMEvents_e event )
+{
+    scanConcentrator_t *pScanConcentrator = (scanConcentrator_t *)hScanCncn;
+       TI_STATUS status = OK;
+       UINT8 nextState;
+
+    /* obtain the next state */
+       status = fsm_GetNextState( pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_CONT ], *(UINT8*)currentState, (UINT8)event, &nextState );
+       if ( status != OK )
+       {
+               WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Failed getting continuous scan for roaming next state.\n") );
+               return NOK;
+       }
+
+    /* report the move */
+    WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                    ("CONT ROAMING SCAN: <%s, %s> --> %s\n\n",
+                    stateDesc[(UINT8)*currentState],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+
+    /* move */
+    return fsm_Event( pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_CONT ], (UINT8*)currentState, 
+                      (UINT8)event, hScanCncn );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_requestSCR( TI_HANDLE hScanCncn )
+{
+    scr_clientRequestStatus_e scrReplyStatus;
+       scr_pendReason_e scrPendReason;
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: Requesting SCR.\n") );
+
+    /* request the SCR as continuous roaming client, and act according to return status */
+    switch ( scrReplyStatus = scr_clientRequest( pScanConcentrator->hSCR, SCR_CID_CONT_SCAN, &scrPendReason ) )
+    {
+    case SCR_CRS_PEND:
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("CONT SM: SCR pending, pend Reason: %d.\n", scrPendReason) );
+        
+        if ( SCR_PR_DIFFERENT_GROUP_RUNNING == scrPendReason )
+        {
+            /* send a reject event to the SM - will not scan if not in connected group */
+                       pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_FAILED;
+                       return scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                                          (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                                          CONT_SCAN_EVENT_SCR_REJECT );
+        }
+        else
+        {
+        /* send a pend event to the SM */
+        return scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                                      (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                                      CONT_SCAN_EVENT_SCR_PEND );
+        }
+/*        break; - unreachable */
+
+    case SCR_CRS_RUN:
+        /* send a run event to the SM */
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("CONT SM: SCR acquired.\n") );
+        return scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                                      (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                                      CONT_SCAN_EVENT_SCR_RUN );
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: SCR returned unrecognized status: %d.\n", scrReplyStatus) );
+        /* Notify scan complete to recover from this error */
+               pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_FAILED;
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn,
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_SCAN_COMPLETE );
+        return NOK;
+/*        break; - unreachable */
+    }
+
+ /*   return OK; - unreachable */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a SCR run event (by starting the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_startScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    TI_STATUS status;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: Sending scan command to scan SRV.\n") );
+
+    /* mark that this scan is currently running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_ROAMING_CONT;
+
+    /* register for scan results with the MLME parser */
+    if ( OK != mlmeParser_registerForBeaconAndProbeResp( pScanConcentrator->hMlme, 
+                                                         scanConcentrator_mlmeResultCB, 
+                                                         hScanCncn ) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: MLME result registration failed.\n") );
+
+        /* mark the return status */
+        pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_FAILED;
+
+        /* could not start scan, send a scan complete event */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_SCAN_COMPLETE );
+
+        return NOK;
+    }
+
+        /* stop built-in test timer, to avoid TX stuck due to heavy traffic and unknown scan result time originally at scanSrv*/
+       healthMonitor_suspendPeriodicTest( pScanConcentrator->hHealthMonitor );
+
+    /* call the scan SRV start scan */
+    if ( OK != (status = MacServices_scanSRV_scan( pScanConcentrator->hMacServices, 
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_CONT ]),
+                                       FALSE,
+                                       TRUE,
+                                       FALSE,
+                                       POWER_SAVE_ON,
+                                       TRUE ,
+                                                                          NULL,NULL)) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: scan SRV returned status %d, quitting continuous scan.\n", status) );
+
+        /* mark the return status */
+        pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ] = SCAN_CRS_SCAN_FAILED;
+
+           /* unregister at the MLME for scan result frames */
+        mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+        /* could not start scan, send a scan complete event */
+        scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                               (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                               CONT_SCAN_EVENT_SCAN_COMPLETE );
+        
+        return NOK;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a stop scan or abort scan event (by stopping the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_abortScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    BOOLEAN  bSendNullData;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: aborting scan.\n") );
+    bSendNullData = (pScanConcentrator->bAbortOrStop == SCAN_CNCN_STOP) ? TRUE : FALSE;
+
+    /* call the scan SRV stop scan */
+    MacServices_scanSRV_stopScan( pScanConcentrator->hMacServices, bSendNullData, NULL , NULL  );
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_recoveryDuringScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: Recovery occured!.\n") );
+    
+    /* reset the scan SRV */
+    MacServices_scanSRV_stopOnFWReset( pScanConcentrator->hMacServices );
+
+    /* send a scan complete event to the SM */
+    return scanConcentratorRoamingContSM_SMEvent( hScanCncn, 
+                                                  (scan_contSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_CONT ]),
+                                                  CONT_SCAN_EVENT_SCAN_COMPLETE );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (by releasing the SCR and calling the scan complete CB).
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_scanComplete( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: Scan is complete.\n") );
+
+       /* unregister at the MLME for scan result frames */
+    mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+    /* mark that this scan is no longer running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_NO_CLIENT;
+
+    /* release the SCR */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_CONT_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_ROAMING_CONT ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_ROAMING_CONT ],
+                                                                  pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ],
+                                                                  NULL, pScanConcentrator->SPSScanResult );
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan actually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_scanRejected( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("CONT SM: Scan is rejected.\n") );
+
+    /* release the SCR */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_CONT_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_ROAMING_CONT ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_ROAMING_CONT ],
+                                                                  pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_CONT ],
+                                                                  NULL, pScanConcentrator->SPSScanResult );
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-Jan-2005\n
+ * \brief Handles an unexpected event.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionUnexpected( TI_HANDLE hScanCncn ) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, ("Continuous scan for roaming state machine error, unexpected Event, state=%d\n\n",
+                                                                                                                                                 pScanConcentrator->clientSMState[SCAN_SCC_ROAMING_CONT]) );
+       
+    return 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 hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionNop( TI_HANDLE hScanCncn )
+{
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingContSM.h b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingContSM.h
new file mode 100644 (file)
index 0000000..9bd3812
--- /dev/null
@@ -0,0 +1,205 @@
+/** \file ScanCncnRoamingContSM.h
+ *  \brief This file include definitions for the scan concentrator continuous scan for roaming SM module.
+ *  \author Ronen Kalish
+ *  \date 02-Jan-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNROAMINGCONTSM_H__
+#define __SCANCNCNROAMINGCONTSM_H__
+
+#include "osApi.h"
+#include "ScanCncn.h"
+#include "fsm.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scan_contSMEvents_e
+ * \brief enumerates the different continuous scan for roaming SM events
+ */
+typedef enum
+{
+    CONT_SCAN_EVENT_START_SCAN = 0,
+    CONT_SCAN_EVENT_SCR_RUN,
+    CONT_SCAN_EVENT_SCR_PEND,
+    CONT_SCAN_EVENT_SCR_REJECT,
+    CONT_SCAN_EVENT_ABORT_SCAN,
+    CONT_SCAN_EVENT_FW_RESET,
+    CONT_SCAN_EVENT_STOP_SCAN,
+    CONT_SCAN_EVENT_SCAN_COMPLETE,
+    CONT_SCAN_NUM_OF_EVENTS
+} scan_contSMEvents_e;
+
+/** \enum scan_contSMEvents_e
+ * \brief enumerates the different continuous scan for roaming SM states
+ */
+typedef enum
+{
+    CONT_SCAN_STATE_IDLE = 0,
+    CONT_SCAN_STATE_SCR_REQUEST,
+    CONT_SCAN_STATE_SCR_WAIT,
+    CONT_SCAN_STATE_SCANNING,
+    CONT_SCAN_STATE_STOPPING,
+    CONT_SCAN_NUM_OF_STATES
+} scan_contSMStates_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator continuous scan for roaming SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_init( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current continuous scan for roaming SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_SMEvent( TI_HANDLE hScanCncn, scan_contSMStates_e* currentState, 
+                                         scan_contSMEvents_e event );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_requestSCR( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scr run event (by starting the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_startScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a stop scan or abort scan event (by stopping the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_abortScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_recoveryDuringScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (by releasing the SCR and calling the scan complete CB).
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_scanComplete( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan acrually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingContSM_scanRejected( TI_HANDLE hScanCncn );
+
+#endif /* __SCANCNCNROAMINGCONTSM_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingImmedSM.c b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingImmedSM.c
new file mode 100644 (file)
index 0000000..6bfba09
--- /dev/null
@@ -0,0 +1,498 @@
+/** \file ScanCncnRoamingImmedSM.c
+ *  \brief This file include the scan concentrator immediate scan for roaming module implementation
+ *  \author Ronen Kalish
+ *  \date 03-Jan-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanCncnRoamingImmedSM.h"
+#include "MacServices_api.h" 
+#include "report.h"
+#include "siteMgrApi.h"
+#include "healthMonitor.h"
+
+static TI_STATUS actionUnexpected( TI_HANDLE hScanCncn );
+static TI_STATUS actionNop( TI_HANDLE hScanCncn );
+
+extern BOOLEAN apConn_isPsRequiredBeforeScan(TI_HANDLE hAPConnection);
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator immediate scan for roaming SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_init( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    fsm_actionCell_t    smMatrix[ IMMED_SCAN_NUM_OF_STATES ][ IMMED_SCAN_NUM_OF_EVENTS ] =
+       {
+               /* next state and actions for IDLE state */
+               {       
+            {IMMED_SCAN_STATE_SCR_REQUEST, scanConcentratorRoamingImmedSM_requestSCR},     /*"START_SCAN",*/
+                       {IMMED_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {IMMED_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {IMMED_SCAN_STATE_IDLE, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {IMMED_SCAN_STATE_IDLE, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {IMMED_SCAN_STATE_IDLE, actionUnexpected},                                     /*"FW_RESET"*/
+            {IMMED_SCAN_STATE_IDLE, actionNop},                                            /*"STOP_SCAN"*/
+            {IMMED_SCAN_STATE_IDLE, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+           
+               },
+
+               /* next state and actions for SCR_REQUEST state */
+               {       
+            {IMMED_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"START_SCAN",*/
+            {IMMED_SCAN_STATE_SCANNING, scanConcentratorRoamingImmedSM_startScan},         /*"SCR_RUN",*/
+                       {IMMED_SCAN_STATE_SCR_WAIT, actionNop},                                        /*"SCR_PEND",  */
+                       {IMMED_SCAN_STATE_IDLE, scanConcentratorRoamingImmedSM_scanRejected},          /*"SCR_REJECT",*/
+            {IMMED_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"ABORT_SCAN"*/
+            {IMMED_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"FW_RESET"*/
+            {IMMED_SCAN_STATE_SCR_REQUEST, actionUnexpected},                                     /*"STOP_SCAN"*/
+            {IMMED_SCAN_STATE_SCR_REQUEST, actionUnexpected}                                      /*"SCAN_COMPLETE"*/
+               },
+
+               /* next state and actions for SCR_WAIT state */
+               {       
+            {IMMED_SCAN_STATE_SCR_WAIT, actionUnexpected},                                      /*"START_SCAN",*/
+                       {IMMED_SCAN_STATE_SCANNING, scanConcentratorRoamingImmedSM_startScan},         /*"SCR_RUN",*/
+                       {IMMED_SCAN_STATE_SCR_WAIT, actionNop},                                        /*"SCR_PEND",  */
+                       {IMMED_SCAN_STATE_IDLE, scanConcentratorRoamingImmedSM_scanRejected},          /*"SCR_REJECT",*/
+            {IMMED_SCAN_STATE_SCR_WAIT, actionUnexpected},                                      /*"ABORT_SCAN"*/
+            {IMMED_SCAN_STATE_SCR_WAIT, actionUnexpected},                                      /*"FW_RESET"*/
+            {IMMED_SCAN_STATE_IDLE, scanConcentratorRoamingImmedSM_scanRejected},          /*"STOP_SCAN"*/
+            {IMMED_SCAN_STATE_SCR_WAIT, actionUnexpected}                                       /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for SCANNING state */
+        {       
+            {IMMED_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"START_SCAN",*/
+                       {IMMED_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {IMMED_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {IMMED_SCAN_STATE_SCANNING, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {IMMED_SCAN_STATE_STOPPING, scanConcentratorRoamingImmedSM_abortScan},         /*"ABORT_SCAN"*/
+            {IMMED_SCAN_STATE_SCANNING, scanConcentratorRoamingImmedSM_recoveryDuringScan},/*"FW_RESET"*/
+            {IMMED_SCAN_STATE_STOPPING, scanConcentratorRoamingImmedSM_abortScan},         /*"STOP_SCAN"*/
+            {IMMED_SCAN_STATE_IDLE, scanConcentratorRoamingImmedSM_scanComplete}           /*"SCAN_COMPLETE"*/
+               },
+
+        /* next state and actions for STOPPING state */
+               {       
+            {IMMED_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"START_SCAN",*/
+                       {IMMED_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_RUN",*/
+                       {IMMED_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_PEND",  */
+                       {IMMED_SCAN_STATE_STOPPING, actionUnexpected},                                     /*"SCR_REJECT",*/
+            {IMMED_SCAN_STATE_STOPPING, actionNop},                                        /*"ABORT_SCAN"*/
+            {IMMED_SCAN_STATE_STOPPING, scanConcentratorRoamingImmedSM_recoveryDuringScan},/*"FW_RESET"*/
+            {IMMED_SCAN_STATE_STOPPING, actionNop},                                        /*"STOP_SCAN"*/
+            {IMMED_SCAN_STATE_IDLE, scanConcentratorRoamingImmedSM_scanComplete}           /*"SCAN_COMPLETE"*/
+               }
+    };
+
+    /* initialize current state */
+    pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ] = IMMED_SCAN_STATE_IDLE;
+
+    /* configure the state machine */
+       return fsm_Config( pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_IMMED ], (fsm_Matrix_t)smMatrix, 
+                       IMMED_SCAN_NUM_OF_STATES, IMMED_SCAN_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)scanConcentratorRoamingImmedSM_SMEvent, pScanConcentrator->hOS );
+}
+
+
+#ifdef REPORT_LOG
+
+/* state descriptions, for state machine logging */
+static char stateDesc[ IMMED_SCAN_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] = 
+{
+    "STATE_IDLE",
+    "STATE_SCR_REQUEST",
+    "STATE_SCR_WAIT",
+    "STATE_SCANNING",
+    "STATE_STOPPING"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ IMMED_SCAN_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] = 
+{
+    "EVENT_START_SCAN",
+    "EVENT_SCR_RUN",
+    "EVENT_SCR_PEND",
+    "EVENT_SCR_REJECT",
+    "EVENT_ABORT_SCAN",
+    "EVENT_FW_RESET",
+    "EVENT_STOP_SCAN",
+    "EVENT_SCAN_COMPLETE"
+};
+
+#endif
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current immediate scan for roaming SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_SMEvent( TI_HANDLE hScanCncn, scan_immedSMStates_e* currentState, 
+                                                  scan_immedSMEvents_e event )
+{
+    scanConcentrator_t *pScanConcentrator = (scanConcentrator_t *)hScanCncn;
+       TI_STATUS status = OK;
+       UINT8 nextState;
+
+    /* obtain the next state */
+       status = fsm_GetNextState( pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_IMMED ], 
+                 *(UINT8*)currentState, (UINT8)event, &nextState );  
+       if ( status != OK )
+       {
+               WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                        ("Failed getting immediate scan for roaming next state.\n") );
+               return NOK;
+       }
+
+    /* report the move */
+    WLAN_REPORT_SM( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                    ("IMMED ROAMING SCAN: <%s, %s> --> %s\n\n",
+                    stateDesc[(UINT8)*currentState],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+
+    /* move */
+    return fsm_Event( pScanConcentrator->clientSM[ SCAN_SCC_ROAMING_IMMED ], (UINT8*)currentState, 
+                      (UINT8)event, hScanCncn );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_requestSCR( TI_HANDLE hScanCncn )
+{
+    scr_clientRequestStatus_e scrReplyStatus;
+       scr_pendReason_e scrPendReason;
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: Requesting SCR.\n") );
+
+    /* request the SCR as immediate roaming client, and act according to return status */
+    switch ( scrReplyStatus = scr_clientRequest( pScanConcentrator->hSCR, SCR_CID_IMMED_SCAN, &scrPendReason ) )
+    {
+    case SCR_CRS_PEND:
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("IMMED SM: SCR pending, pend Reason: %d.\n", scrPendReason) );
+        
+        if ( SCR_PR_DIFFERENT_GROUP_RUNNING == scrPendReason )
+        {
+            /* send a reject event to the SM - will not scan if not in connected group */
+                       pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_FAILED;
+                       return scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                           (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                           IMMED_SCAN_EVENT_SCR_REJECT );
+        }
+        else
+        {
+            /* send a pend event to the SM */
+            return scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                           (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                           IMMED_SCAN_EVENT_SCR_PEND );
+        }
+/*        break; - unreachable */
+
+    case SCR_CRS_RUN:
+        /* send a run event to the SM */
+        WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                                 ("IMMED SM: SCR acquired.\n") );
+        return scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                       (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                       IMMED_SCAN_EVENT_SCR_RUN );
+/*        break; - unreachable */
+
+    default:
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: SCR returned unrecognized status: %d.\n", scrReplyStatus) );
+               pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_FAILED;
+        /* Notify scan complete to recover from this error */
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn,
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_SCAN_COMPLETE );
+        return NOK;
+/*        break;  - unreachable */
+    }
+
+/*    return OK; - unreachable */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a SCR run event (by starting the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_startScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    TI_STATUS status;
+    BOOLEAN psRequest;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: Sending scan command to scan SRV.\n") );
+
+    /* mark that this scan is currently running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_ROAMING_IMMED;
+
+    /* register for scan results with the MLME parser */
+    if ( OK != mlmeParser_registerForBeaconAndProbeResp( pScanConcentrator->hMlme, 
+                                                         scanConcentrator_mlmeResultCB, 
+                                                         hScanCncn ) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: MLME result registration failed.\n") );
+
+        /* mark the return status */
+        pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_FAILED;
+
+        /* could not start scan, send a scan complete event */
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_SCAN_COMPLETE );
+
+        return NOK;
+    }
+
+        /* stop built-in test timer, to avoid TX stuck due to heavy traffic and unknown scan result time originally at scanSrv*/
+       healthMonitor_suspendPeriodicTest( pScanConcentrator->hHealthMonitor );
+
+       psRequest = apConn_isPsRequiredBeforeScan(pScanConcentrator->hAPConn);
+
+    /* call the scan SRV start scan */
+    if ( OK != (status = MacServices_scanSRV_scan( pScanConcentrator->hMacServices, 
+                                       &(pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ]),
+                                       ( (SCAN_TYPE_TRIGGERED_ACTIVE == pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].scanType) ||
+                                         (SCAN_TYPE_TRIGGERED_PASSIVE == pScanConcentrator->clientScanParams[ SCAN_SCC_ROAMING_IMMED ].scanType) 
+                                         ? FALSE : TRUE ), /* Triggered scan cannot be high priority */
+                                       TRUE,
+                                       TRUE,
+                                                                          ( psRequest ? POWER_SAVE_ON : POWER_SAVE_KEEP_CURRENT ),
+                                       psRequest,
+                                                                          NULL,NULL)) )
+    {
+        WLAN_REPORT_WARNING( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: scan SRV returned status %d, quitting immediate scan.\n", status) );
+
+        /* mark the return status */
+        pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ] = SCAN_CRS_SCAN_FAILED;
+
+           /* unregister at the MLME for scan result frames */
+        mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+        /* could not start scan, send a scan complete event */
+        scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                IMMED_SCAN_EVENT_SCAN_COMPLETE );
+        
+        return NOK;
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a stop scan or abort scan event (by stopping the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_abortScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+    BOOLEAN     bSendNullData;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: aborting scan.\n") );
+
+    bSendNullData = (pScanConcentrator->bAbortOrStop == SCAN_CNCN_STOP) ? TRUE : FALSE;
+
+    /* call the scan SRV stop scan */
+    MacServices_scanSRV_stopScan( pScanConcentrator->hMacServices, bSendNullData , NULL , NULL );
+    
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_recoveryDuringScan( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: Recovery occured!.\n") );
+    
+    /* reset the scan SRV */
+    MacServices_scanSRV_stopOnFWReset( pScanConcentrator->hMacServices );
+
+    /* send a scan complete event to the SM */
+    return scanConcentratorRoamingImmedSM_SMEvent( hScanCncn, 
+                                                   (scan_immedSMStates_e*)&(pScanConcentrator->clientSMState[ SCAN_SCC_ROAMING_IMMED ]),
+                                                   IMMED_SCAN_EVENT_SCAN_COMPLETE );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (by releasing the SCR and calling the scan complete CB).
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_scanComplete( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: Scan is complete.\n") );
+
+       /* unregister at the MLME for scan result frames */
+    mlmeParser_unregisterForBeaconAndProbeResp( pScanConcentrator->hMlme );
+
+    /* mark that this scan is no longer running */
+    pScanConcentrator->currentRunningScanClient = SCAN_SCC_NO_CLIENT;
+
+    /* release the SCR */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_IMMED_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_ROAMING_IMMED ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_ROAMING_IMMED ],
+                                                                   pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ],
+                                                                   NULL, 0xffff );
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan actually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_scanRejected( TI_HANDLE hScanCncn )
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_INFORMATION( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG,
+                             ("IMMED SM: Scan is rejected.\n") );
+
+    /* release the SCR */
+    scr_clientComplete( pScanConcentrator->hSCR, SCR_CID_IMMED_SCAN );
+
+    /* notify the scan complete to the scan mngr */
+    if ( FALSE == pScanConcentrator->bInRequest )
+    {
+        pScanConcentrator->scanResultCB[ SCAN_SCC_ROAMING_IMMED ]( pScanConcentrator->scanResultCBObj[ SCAN_SCC_ROAMING_IMMED ],
+                                                                   pScanConcentrator->scanResult[ SCAN_SCC_ROAMING_IMMED ],
+                                                                   NULL, 0xffff );
+    }
+
+    return OK;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 11-Jan-2005\n
+ * \brief Handles an unexpected event.\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionUnexpected( TI_HANDLE hScanCncn ) 
+{
+    scanConcentrator_t* pScanConcentrator = (scanConcentrator_t*)hScanCncn;
+
+    WLAN_REPORT_ERROR( pScanConcentrator->hReport, SCAN_CNCN_MODULE_LOG, 
+                    ("Immediate scan for roaming state machine error, unexpected Event, state=%d\n\n",
+                                        pScanConcentrator->clientSMState[SCAN_SCC_ROAMING_IMMED]) );
+       
+    return 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 hScanCncn - handle to the scan concentrator object.\n
+ * \return always OK.\n
+ */
+TI_STATUS actionNop( TI_HANDLE hScanCncn )
+{
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingImmedSM.h b/sta_dk_4_0_4_32/common/src/Management/scan/scanCncn/ScanCncnRoamingImmedSM.h
new file mode 100644 (file)
index 0000000..46bf2a1
--- /dev/null
@@ -0,0 +1,205 @@
+/** \file ScanCncnRoamingImmedSM.h
+ *  \brief This file include definitions for the scan concentrator immediate scan for roaming SM module.
+ *  \author Ronen Kalish
+ *  \date 02-Jan-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANCNCNROAMINGIMMEDSM_H__
+#define __SCANCNCNROAMINGIMMEDSM_H__
+
+#include "osApi.h"
+#include "ScanCncn.h"
+#include "fsm.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scan_immedSMEvents_e
+ * \brief enumerates the different immediate scan for roaming SM events
+ */
+typedef enum
+{
+    IMMED_SCAN_EVENT_START_SCAN = 0,
+    IMMED_SCAN_EVENT_SCR_RUN,
+    IMMED_SCAN_EVENT_SCR_PEND,
+    IMMED_SCAN_EVENT_SCR_REJECT,
+    IMMED_SCAN_EVENT_ABORT_SCAN,
+    IMMED_SCAN_EVENT_FW_RESET,
+    IMMED_SCAN_EVENT_STOP_SCAN,
+    IMMED_SCAN_EVENT_SCAN_COMPLETE,
+    IMMED_SCAN_NUM_OF_EVENTS
+} scan_immedSMEvents_e;
+
+/** \enum scan_immedSMEvents_e
+ * \brief enumerates the different immediate scan for roaming SM states
+ */
+typedef enum
+{
+    IMMED_SCAN_STATE_IDLE = 0,
+    IMMED_SCAN_STATE_SCR_REQUEST,
+    IMMED_SCAN_STATE_SCR_WAIT,
+    IMMED_SCAN_STATE_SCANNING,
+    IMMED_SCAN_STATE_STOPPING,
+    IMMED_SCAN_NUM_OF_STATES
+} scan_immedSMStates_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Initialize the scan concentrator immediate scan for roaming SM.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_init( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief Processes an event.
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \param currentState - the current immediate scan for roaming SM state.\n
+ * \param event - the event to handle.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_SMEvent( TI_HANDLE hScanCncn, scan_immedSMStates_e* currentState, 
+                                                  scan_immedSMEvents_e event );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a start scan event (by requesting the SCR)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_requestSCR( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a SCR run event (by starting the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_startScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a stop scan or abort scan event (by stopping the actual scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_abortScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 10-July-2005\n
+ * \brief SM action - handles a recovery event (calls the scan SRV abort on FW reset and than finishes scan)
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_recoveryDuringScan( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan complete event (by releasing the SCR and calling the scan complete CB).
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_scanComplete( TI_HANDLE hScanCncn );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 02-Jan-2005\n
+ * \brief SM action - handles a scan reject event (abort scan before scan acrually started)\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScanCncn - handle to the scan concentrator object.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanConcentratorRoamingImmedSM_scanRejected( TI_HANDLE hScanCncn );
+
+#endif /* __SCANCNCNROAMINGIMMEDSM_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.c
new file mode 100644 (file)
index 0000000..3d751e9
--- /dev/null
@@ -0,0 +1,1243 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+#include "osTIType.h"
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "whalBus_Api.h"
+#include "CmdMBox_api.h"
+#include "CmdQueue_api.h"
+#include "CmdQueue.h"
+
+#ifdef TI_DBG
+static char *StateString[CMDQUEUE_STATE_NUM] = {
+       "CMDQUEUE_STATE_IDLE",  /* 0 */
+       "CMDQUEUE_STATE_SEND_CMD_v",  /* 1 */
+       "CMDQUEUE_STATE_WAIT_SEND_CMPLT",  /* 2 */
+       "CMDQUEUE_STATE_INTERROGATE_v",  /* 3 */
+       "CMDQUEUE_STATE_WAIT_RESULT",  /* 4 */
+       "CMDQUEUE_STATE_FINISH_v",  /* 5 */
+};
+
+static char *EventString[CMDQUEUE_EVENT_NUM] = {
+       "CMDQUEUE_EVENT_RUN",  /* 1 */
+       "CMDQUEUE_EVENT_SEND_CMPLT",  /* 2 */
+       "CMDQUEUE_EVENT_RESULT_RECEIVED",  /* 3 */
+};
+
+#endif /* TI_DBG */
+
+
+/****************************************************************************
+ *                      CmdQueue_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the CmdQueue object
+ *
+ * INPUTS:  TI_HANDLE *hOs
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: The Created object
+ *****************************************************************************/
+TI_HANDLE CmdQueue_Create(TI_HANDLE hOs)
+{
+    
+    CmdQueue_T  *pObj;
+
+    pObj = os_memoryAlloc(hOs, sizeof(CmdQueue_T));
+    if (pObj == NULL)
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: CmdQueue_Create(): Error Creating CmdQueue - Aborting\n"));
+        return NULL;
+    }
+
+    /* reset control module control block */
+    os_memoryZero(hOs, pObj, sizeof(CmdQueue_T));
+    pObj->hOs = hOs;
+    
+    return(pObj);   
+}
+
+
+/****************************************************************************
+ *                      CmdQueue_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object
+ *
+ * INPUTS:  hCmdQueue   The object to free
+ *  
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_Destroy(TI_HANDLE hCmdQueue)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+
+       /* free context */
+       os_memoryFree(pCmdQueue->hOs, pCmdQueue, sizeof(CmdQueue_T));
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      CmdQueue_Config()
+ ****************************************************************************
+ * DESCRIPTION: Config the CmdQueue object
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int CmdQueue_Config (TI_HANDLE hCmdQueue, TI_HANDLE hCmdMBox, TI_HANDLE hReport)                                                       
+{
+    CmdQueue_T* pCmdQueue = (CmdQueue_T*) hCmdQueue;
+
+    pCmdQueue->Head = 0;
+    pCmdQueue->Tail = 0;
+    pCmdQueue->NumberOfCommandInQueue = 0;
+    pCmdQueue->MaxNumberOfCommandInQueue = 0;
+    pCmdQueue->State = CMDQUEUE_STATE_IDLE;
+    pCmdQueue->CmdCompleteGenericCB_Func = NULL;
+    pCmdQueue->CmdCompleteGenericCB_Arg = NULL;
+    pCmdQueue->FailureCB = NULL;
+    pCmdQueue->FailureCbHandle = NULL;
+    pCmdQueue->SM_RC = 0;
+    pCmdQueue->hReport = hReport;
+    pCmdQueue->hCmdMBox = hCmdMBox;
+    pCmdQueue->ErrorFlag = FALSE;
+
+    /*
+     * NOTE: don't set NumberOfRecoveryNodes = 0; 
+     *       its value is used by recovery process
+     */
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      CmdQueue_StartReconfig()
+ ****************************************************************************
+ * DESCRIPTION: Restart the module for recovery. Clean the queue but save al the CB in the queue.
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_StartReconfig(TI_HANDLE hCmdQueue)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       int CurrentCmdindex;
+       int first  = pCmdQueue->Head;
+       CmdQueue_CmdNode_T* pHead ;
+       CmdQueue_RecoveryNode_T* pRecoveryNode;
+       
+       /* 
+       stop the SM
+       */
+       pCmdQueue->State = CMDQUEUE_STATE_IDLE;
+
+       WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                                                               ("CmdQueue_Clean: Cleaning CmdQueue Queue"));
+    
+       /*
+       Save The Call Back Function in the Queue in order the return them after the recovery 
+       with on error status 
+       */ 
+
+       /* Clean The Command Call Back Counter */ 
+       pCmdQueue->NumberOfRecoveryNodes = 0;
+       pRecoveryNode = &pCmdQueue->RecoveryQueue[pCmdQueue->NumberOfRecoveryNodes];
+       for(CurrentCmdindex = 0 ; CurrentCmdindex < pCmdQueue->NumberOfCommandInQueue ; CurrentCmdindex++)
+       {
+               pHead  =  &pCmdQueue->CmdQueue[first];
+
+               if(pHead->CB_Func != NULL)
+               { /*Copy the interrogate CB and the interrogate data buffer pointer */
+                       pRecoveryNode->CB_Func = pHead->CB_Func;
+                       pRecoveryNode->CB_Arg = pHead->CB_Arg;
+                       pRecoveryNode->interrogateParamsBuf = pHead->interrogateParamsBuf;
+                       pCmdQueue->NumberOfRecoveryNodes++;
+                       pRecoveryNode = &pCmdQueue->RecoveryQueue[pCmdQueue->NumberOfRecoveryNodes];
+               }               
+               first++;
+               if(first == CMDQUEUE_QUEUE_DEPTH)
+                       first = 0;
+       }
+
+       /*
+       init the queue
+       */
+       pCmdQueue->Head = 0;
+    pCmdQueue->Tail = 0;
+    pCmdQueue->NumberOfCommandInQueue = 0;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      CmdQueue_EndReconfig()
+ ****************************************************************************
+ * DESCRIPTION: Call the stored CB to end the recovery of the MBox queue
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_EndReconfig(TI_HANDLE hCmdQueue)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       
+       int     Cbindex;
+       CmdQueue_RecoveryNode_T *pHead;
+
+       for(Cbindex = 0; Cbindex < pCmdQueue->NumberOfRecoveryNodes; Cbindex++)
+       {
+               pHead  =  &pCmdQueue->RecoveryQueue[Cbindex];
+
+               if(pHead->interrogateParamsBuf)
+               {
+                       ((CmdQueue_InterrogateCB_t)pHead->CB_Func)(pHead->CB_Arg, CMD_STATUS_FW_RESET,pHead->interrogateParamsBuf);
+               }
+               else
+               {
+                       ((CmdQueue_CB_t)pHead->CB_Func)(pHead->CB_Arg, CMD_STATUS_FW_RESET);
+               }
+       }
+
+       pCmdQueue->NumberOfRecoveryNodes = 0;
+       
+       return OK;
+}
+
+/****************************************************************************
+ *                 CmdQueue_RegisterCmdCompleteGenericCB()
+ ****************************************************************************
+ * DESCRIPTION: Register for a call back to be called when Command Complete
+ *              Occur and the CmdMboxCB was NULL
+ *
+ * RETURNS:None
+ ****************************************************************************/
+int                                    CmdQueue_RegisterCmdCompleteGenericCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       
+       if ((CB_Func == NULL) || (CB_handle == NULL))
+       {
+               WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, ("CmdQueue_RegisterCmdCompleteGenericCB: NULL parameter\n"));
+               return NOK;
+       }
+
+       pCmdQueue->CmdCompleteGenericCB_Func = (CmdQueue_GenericCB_t)CB_Func;
+       pCmdQueue->CmdCompleteGenericCB_Arg = CB_handle;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      CmdQueue_RegisterForErrorCB()
+ ****************************************************************************
+ * DESCRIPTION: Register for a call back to be called when an Error (Timeout)
+ *              Occur
+ *
+ * RETURNS:None
+ ****************************************************************************/
+int                                    CmdQueue_RegisterForErrorCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       
+       if ((CB_Func == NULL) || (CB_handle == NULL))
+       {
+               WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, ("CmdQueue_RegisterForErrorCB: NULL parameters\n"));
+               return NOK;
+       }
+
+       pCmdQueue->FailureCbHandle = CB_handle;
+       pCmdQueue->FailureCB = (CmdQueue_CB_t)CB_Func;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      CmdQueue_CmdConfigure()
+ ****************************************************************************
+ * DESCRIPTION: Send configure command with its information element parameter
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_CmdConfigure(TI_HANDLE hCmdQueue, void *MboxBuf,UINT32 ParamsLen)
+{
+       int status;
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+
+       CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
+       
+       status = CmdQueue_Push(pCmdQueue, CMD_CONFIGURE,
+                                                       (UINT8*)MboxBuf, ParamsLen,
+                                                       NULL, NULL, NULL);
+       
+       CMDQUEUE_CONVERT_RC(status);
+}
+
+/****************************************************************************
+ *                      CmdQueue_CmdConfigureWithCb()
+ ****************************************************************************
+ * DESCRIPTION: Send configure command with its information element parameter
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_CmdConfigureWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
+                                                                                                                       void *CB_Func, TI_HANDLE CB_handle)
+{
+
+       int status;
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+
+       CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
+       
+       status = CmdQueue_Push(pCmdQueue, CMD_CONFIGURE,
+                                                       (UINT8*)MboxBuf, ParamsLen,
+                                                       CB_Func, CB_handle, NULL);
+       
+       CMDQUEUE_CONVERT_RC(status);
+}
+
+
+#if 0
+
+/*
+ * NOTE: The following function may NOT be used in fully asynchronous mode.
+ *       Its source code remained only for easier backword rollback
+ */
+
+/****************************************************************************
+ *                      CmdQueue_CmdInterrogate()
+ ****************************************************************************
+ * DESCRIPTION: Send interrogate command with its information element parameter
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_CmdInterrogate(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       int status = OK;
+
+       CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
+
+       status = CmdQueue_Push(pCmdQueue, CMD_INTERROGATE,
+                                                       (UINT8*)MboxBuf, ParamsLen,
+                                                       NULL, NULL, (UINT8*)MboxBuf);
+
+       /* 
+       cause we called an interrogate cmd without a CB function then the Cmd needs to be finished 
+       in this context 
+       */
+       if (status == TNETWIF_PENDING)
+       {
+               WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                       ("CmdQueue_CmdInterrogate:Cmd INTERROGATE ,MboxBuf = 0x%x, Len = %d \n"
+                       , MboxBuf, ParamsLen));
+       }
+
+       CMDQUEUE_CONVERT_RC(status);
+}
+#endif
+
+
+/****************************************************************************
+ *                      CmdQueue_CmdInterrogateWithCb()
+ ****************************************************************************
+ * DESCRIPTION: Send interrogate command with its information element parameter
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_CmdInterrogateWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
+                                                                                                                       void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       int status;
+
+       CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
+       
+       if((CB_Func == NULL) || (CB_handle == NULL) || (CB_Buf == NULL))
+       {
+               WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, 
+                       ("CmdQueue_CommandWithCb: NULL parameters\n"));
+               return NOK;
+       }
+
+       status = CmdQueue_Push(pCmdQueue, CMD_INTERROGATE,
+                                                       (UINT8*)MboxBuf, ParamsLen,
+                                                       CB_Func, CB_handle, (UINT8*)CB_Buf);    
+
+       CMDQUEUE_CONVERT_RC(status);
+}
+
+/***************************************************************************
+ *                      CmdQueue_Command()
+ ****************************************************************************
+ * DESCRIPTION: Send command to the wlan hardware command mailbox
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_Command(TI_HANDLE hCmdQueue, Command_e MboxCmdType, char *MboxBuf, UINT32 ParamsLen)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)   hCmdQueue;
+       int status;
+
+       CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
+       
+       status = CmdQueue_Push(pCmdQueue, MboxCmdType,
+                                                       (UINT8*)MboxBuf, ParamsLen,
+                                                       NULL, NULL, NULL);
+
+       CMDQUEUE_CONVERT_RC(status);
+}
+
+/****************************************************************************
+ *                      CmdQueue_CommandWithCb()
+ ****************************************************************************
+ * DESCRIPTION: Send command with CB to the wlan hardware command mailbox
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                                    CmdQueue_CommandWithCb(TI_HANDLE hCmdQueue, Command_e MboxCmdType, void *MboxBuf, UINT32 ParamsLen, 
+                                                                                                                       void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
+       int status;
+
+       CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
+       
+       if(((CB_Func != NULL) && (CB_handle == NULL)) || ((CB_Func == NULL) && (CB_handle != NULL)))
+       {
+               WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, 
+                       ("CmdQueue_CommandWithCb: NULL Object with none NULL CB\n"));           
+               return NOK;
+       }
+
+       status = CmdQueue_Push(pCmdQueue, MboxCmdType,
+                                                       (UINT8*)MboxBuf, ParamsLen,
+                                                       CB_Func, CB_handle, (UINT8*)CB_Buf);    
+
+       CMDQUEUE_CONVERT_RC(status);
+}
+
+
+/****************************************************************************
+ *                      CmdQueue_Push()
+ ****************************************************************************
+ * DESCRIPTION: Push the command Node to the Queue with its information element parameter
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: NOK OK
+ ****************************************************************************/
+int                            CmdQueue_Push(CmdQueue_T  *pCmdQueue, Command_e  cmdType,
+                                                                               UINT8* pParamsBuf, UINT32 paramsLen,
+                                                                               void *CB_Func, TI_HANDLE CB_Arg, UINT8* pCB_Buf)
+{
+
+#ifdef TI_DBG
+
+       /*
+       check if Queue is Full
+       */
+       if(pCmdQueue->NumberOfCommandInQueue == CMDQUEUE_QUEUE_DEPTH)
+       {
+               WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                       ("CmdQueue_Push: ** ERROR ** The Queue is full\n"
+                        "CmdType = %s %s , Len = %d   InfoElemId = 0x%x\n",
+                        CmdQueue_GetCmdString(cmdType),
+                        CmdQueue_GetIEString( cmdType,*(UINT16 *)pParamsBuf), paramsLen, *(UINT16 *)pParamsBuf));
+               return  NOK;
+       }
+#endif /* TI_DBG*/
+
+    /* initializes the last Node in the Queue with the arrgs */
+       pCmdQueue->CmdQueue[pCmdQueue->Tail].cmdType   = cmdType;
+       pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsLen = paramsLen;
+       pCmdQueue->CmdQueue[pCmdQueue->Tail].CB_Func = CB_Func;
+       pCmdQueue->CmdQueue[pCmdQueue->Tail].CB_Arg = CB_Arg;   
+       if(cmdType == CMD_INTERROGATE)
+       {
+               os_memoryCopy(pCmdQueue->hOs, pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsBuf, pParamsBuf, CMDQUEUE_INFO_ELEM_HEADER_LEN);
+       }
+       else
+               os_memoryCopy(pCmdQueue->hOs, pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsBuf, pParamsBuf, paramsLen);
+       pCmdQueue->CmdQueue[pCmdQueue->Tail].interrogateParamsBuf = pCB_Buf;
+            
+       /*advance the Queue tail*/
+       pCmdQueue->Tail++;
+       if(pCmdQueue->Tail == CMDQUEUE_QUEUE_DEPTH)
+               pCmdQueue->Tail = 0;
+    
+       /* update counters */
+       pCmdQueue->NumberOfCommandInQueue++;
+#ifdef TI_DBG    
+       if(pCmdQueue->MaxNumberOfCommandInQueue < pCmdQueue->NumberOfCommandInQueue)
+               pCmdQueue->MaxNumberOfCommandInQueue = pCmdQueue->NumberOfCommandInQueue;         
+#endif /* TI_DBG*/
+         
+    WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
+            ("CmdQueue_Push: CmdType = %s (%s(%d))\n"
+                       "Len = %d, NumOfCmd = %d \n",
+                       CmdQueue_GetCmdString(cmdType),
+                       (pParamsBuf) ?  CmdQueue_GetIEString(cmdType,*(UINT16 *)pParamsBuf):"",                 
+                       (pParamsBuf) ?  *(UINT16 *)pParamsBuf:0,                        
+                       paramsLen, pCmdQueue->NumberOfCommandInQueue));
+
+       /*if Queue has only one command trigger the send command form Queue */  
+       if (pCmdQueue->NumberOfCommandInQueue == 1)
+       {
+               return (CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_RUN));
+       }
+       else
+               return (OK);            
+}
+
+/****************************************************************************
+ *                     CmdQueue_SM()
+ ****************************************************************************
+ * DESCRIPTION: inplement the CmdQueue SM
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                 CmdQueue_SM(CmdQueue_T* pCmdQueue,CmdQueue_SMEvents_e event)
+{   
+    int rc = OK;
+    int breakWhile = FALSE;
+    CmdQueue_CmdNode_T* pHead;
+    TI_STATUS status;
+    
+    while(!breakWhile)
+    {
+            WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
+            ("CmdQueue_SM: state = %s (%d) event = %s(%d), rc = %d\n",
+            StateString[pCmdQueue->State],
+            pCmdQueue->State,
+            EventString[event],
+            event,rc));
+
+        switch(pCmdQueue->State)
+        {
+            /***************************************
+            CMDQUEUE_STATE_IDLE
+            ***************************************/
+            case CMDQUEUE_STATE_IDLE:
+                switch(event)
+                {
+                    case CMDQUEUE_EVENT_RUN:
+                        pCmdQueue->State = CMDQUEUE_STATE_SEND_CMD_v;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_IDLE\n",event));        
+                            return NOK;                     
+                }
+                break;
+
+            /***************************************
+            CMDQUEUE_STATE_SEND_CMD_v
+            ***************************************/
+            case CMDQUEUE_STATE_SEND_CMD_v:
+                pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
+
+                WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
+                    ("CmdQueue_SM: Send Cmd: CmdType = %s(%s)\n"
+                               "Len = %d, NumOfCmd = %d \n",
+                               CmdQueue_GetCmdString(pHead->cmdType),
+                           (pHead->paramsBuf) ?  CmdQueue_GetIEString(pHead->cmdType,*(UINT16 *)pHead->paramsBuf):"",
+                           pHead->paramsLen, pCmdQueue->NumberOfCommandInQueue));
+                
+#ifdef TI_DBG
+                pCmdQueue->CmdSendCounter++;
+#endif /* TI_DBG    */
+                pCmdQueue->State = CMDQUEUE_STATE_INTERROGATE_v;
+                    
+                    /* send the command to TNET */
+                if(pHead->cmdType == CMD_INTERROGATE)
+                    rc = CmdMBox_SendCmd(pCmdQueue->hCmdMBox, 
+                            pHead->cmdType, 
+                            pHead->paramsBuf, 
+                            CMDQUEUE_INFO_ELEM_HEADER_LEN); 
+                else
+                    rc = CmdMBox_SendCmd(pCmdQueue->hCmdMBox, 
+                            pHead->cmdType, 
+                            pHead->paramsBuf, 
+                            pHead->paramsLen);
+                
+                if(rc == TNETWIF_PENDING)
+                {
+                    if(pCmdQueue->SM_RC)
+                    {                       
+                        rc = pCmdQueue->SM_RC;
+                    }
+                    pCmdQueue->State = CMDQUEUE_STATE_WAIT_SEND_CMPLT;
+                    breakWhile = TRUE;
+                }
+                else
+                {                   
+                    breakWhile = TRUE;
+                }
+                break;
+
+            /***************************************
+            CMDQUEUE_STATE_WAIT_SEND_CMPLT
+            ***************************************/
+            case CMDQUEUE_STATE_WAIT_SEND_CMPLT:
+                switch(event)
+                {
+                    case CMDQUEUE_EVENT_SEND_CMPLT:
+#ifdef TI_DBG    
+                            pCmdQueue->CmdCompltCounter++;
+#endif /* TI_DBG                        */
+                        pCmdQueue->State = CMDQUEUE_STATE_INTERROGATE_v;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_WAIT_SEND_CMPLT\n",event));     
+                            return NOK;
+                }
+                break;
+
+            /***************************************
+            CMDQUEUE_STATE_INTERROGATE_v
+            ***************************************/
+            case CMDQUEUE_STATE_INTERROGATE_v:
+                pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
+                    rc = CmdMBox_GetResult(pCmdQueue->hCmdMBox,
+                            pHead->interrogateParamsBuf, pHead->paramsLen, (UINT32*)&status);
+                    if(rc == TNETWIF_PENDING)
+                    {
+                        pCmdQueue->State = CMDQUEUE_STATE_WAIT_RESULT;
+                        breakWhile = TRUE;
+                    }
+                    else
+                    {
+                        if(status != OK)
+                        {
+                            pCmdQueue->ErrorFlag = TRUE;
+                            return OK;
+                        }
+                        pCmdQueue->State = CMDQUEUE_STATE_FINISH_v;
+                    }
+                break;
+
+            /***************************************
+            CMDQUEUE_STATE_WAIT_RESULT
+            ***************************************/
+            case CMDQUEUE_STATE_WAIT_RESULT:                
+                switch(event)
+                {
+                    case CMDQUEUE_EVENT_RESULT_RECEIVED:
+                        rc = TNETWIF_COMPLETE;
+                        pCmdQueue->State = CMDQUEUE_STATE_FINISH_v;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_WAIT_RESULT\n",event));     
+                            return NOK;
+                }
+                break;
+
+            /***************************************
+            CMDQUEUE_STATE_FINISH_v
+            ***************************************/
+            case CMDQUEUE_STATE_FINISH_v:
+            {
+                Command_e cmdType;
+                UINT16        uParam;
+                void *fCb, *hCb, *pCb;
+
+                pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
+
+                /* Keep callback parameters in temporary variables */
+                cmdType = pHead->cmdType;
+                uParam  = *(UINT16 *)pHead->paramsBuf;
+                fCb = pHead->CB_Func;
+                hCb = pHead->CB_Arg;
+                pCb = pHead->interrogateParamsBuf;
+
+                /* 
+                 * Delete the command from the queue before calling a callback 
+                 * because there may be nested calls inside a callback
+                 */
+                pCmdQueue->Head ++;
+                if (pCmdQueue->Head >= CMDQUEUE_QUEUE_DEPTH)
+                    pCmdQueue->Head = 0;                
+                pCmdQueue->NumberOfCommandInQueue --;                
+
+                /* Check if queue is empty to send the next command */
+                if (pCmdQueue->NumberOfCommandInQueue > 0)               
+                {
+                    pCmdQueue->SM_RC = rc;
+                    pCmdQueue->State = CMDQUEUE_STATE_SEND_CMD_v;
+                }
+                else   
+                {   
+                    pCmdQueue->SM_RC = 0;
+                    pCmdQueue->State = CMDQUEUE_STATE_IDLE;
+                    breakWhile = TRUE;
+                }
+
+                /*
+                 * Call the user callback after deleting the command from the queue 
+                 * because there may be nested calls inside a callback
+                 */
+                status = CmdMBox_GetStatus(pCmdQueue->hCmdMBox);
+                if (fCb)
+                {   
+                    if(pCb)
+                    {
+                        ((CmdQueue_InterrogateCB_t)fCb) (hCb, status, pCb); 
+                    }
+                    else
+                    {
+                        ((CmdQueue_CB_t)fCb) (hCb, status);
+                    }
+                }
+                else
+                {
+                    /* Call the generic callback */
+                    if (pCmdQueue->CmdCompleteGenericCB_Func)
+                    {
+                        pCmdQueue->CmdCompleteGenericCB_Func (pCmdQueue->CmdCompleteGenericCB_Arg,                             
+                                                              cmdType, 
+                                                              uParam, 
+                                                              status);
+                    }
+                }
+            }               
+                break;
+
+            default:
+                WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+                    ("CmdQueue_SM: ** ERROR **  No such state (%d)\n",pCmdQueue->State));       
+                    return NOK;
+        }
+    }
+            WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
+                             ("CmdQueue_SM: rc = %d\n",rc));
+
+    return rc;
+}
+
+/*******************************************************************************************************
+ *                     CmdQueue_SendCmplt()
+ ******************************************************************************************************
+ * DESCRIPTION: This function is the CB from the CmdMBox that will issue the "SendCmplt" event to 
+ *                             the CmdQueue SM. Indicates that the Cmd was transferred to the FW.
+ *
+ * RETURNS: OK
+ *************************************************************************************************/
+int                    CmdQueue_SendCmplt(TI_HANDLE hCmdQueue)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
+    
+       /* call the SM for further execution */
+       return CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_SEND_CMPLT);
+}
+
+/*******************************************************************************************************
+ *                     CmdQueue_ResultReceived()
+ ******************************************************************************************************
+ * DESCRIPTION: This function is the CB from the CmdMBox that will issue the "ResultReceived" 
+ *                             event to the CmdQueue SM. Indicates that the Cmd's results were read from 
+ *                             the FW.
+ *
+ * RETURNS: OK
+ *************************************************************************************************/
+int                                    CmdQueue_ResultReceived(TI_HANDLE hCmdQueue, UINT32 status)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
+
+       /* call the SM for further execution */
+       return CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_RESULT_RECEIVED);
+}
+
+/****************************************************************************
+ *                      CmdQueue_TimeOut()
+ ****************************************************************************
+ * DESCRIPTION: Called when a command timeout occur
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ******************************************************************************/
+int                    CmdQueue_Error(TI_HANDLE hCmdQueue)
+{
+       
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;         
+
+#ifdef TI_DBG
+       CmdQueue_CmdNode_T* pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];      
+       UINT32 TimeStamp = os_timeStampMs(pCmdQueue->hOs);
+       
+       WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+               ("CmdQueue_Error: **ERROR**  Command Occured \n"
+               "                                        Cmd = %s %s , Len = %d \n "
+                       "                                        NumOfCmd = %d \n"
+                       "                                        MAC TimeStamp on timeout = %d\n ",
+               CmdQueue_GetCmdString(pHead->cmdType), 
+               CmdQueue_GetIEString(pHead->cmdType, *(UINT16 *)pHead->paramsBuf),
+               pHead->paramsLen, 
+               pCmdQueue->NumberOfCommandInQueue, 
+               TimeStamp));
+#endif
+
+       /* Print The command that was sent before the timeout occur */
+       CmdQueue_PrintHistory(pCmdQueue, CMDQUEUE_HISTORY_DEPTH);
+
+       /* preform Recovery */
+#ifdef TI_DBG
+       if(pCmdQueue->FailureCB)
+#endif         
+       pCmdQueue->FailureCB(pCmdQueue->FailureCbHandle,NOK);
+
+       return OK;
+
+       }
+
+/****************************************************************************
+ *                      CmdQueue_Print()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: 
+ ****************************************************************************/
+void                                   CmdQueue_Print(TI_HANDLE hCmdQueue)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue; 
+       
+       WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+               ("------------- CmdQueue Queue -------------------\n"));
+    
+       WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+               ("CmdQueue_Print:The Max NumOfCmd in Queue was = %d\n",
+               pCmdQueue->MaxNumberOfCommandInQueue));
+       WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+               ("CmdQueue_Print:The Current NumOfCmd in Queue = %d\n",
+               pCmdQueue->NumberOfCommandInQueue));
+#ifdef TI_DBG
+       WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+               ("CmdQueue_Print:The Total number of Cmd send from Queue= %d\n",
+               pCmdQueue->CmdSendCounter));
+       WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
+               ("CmdQueue_Print:The Total number of Cmd Completed interrupt= %d\n",
+               pCmdQueue->CmdCompltCounter));
+#endif
+
+       CmdQueue_PrintQueue(pCmdQueue);
+}
+
+/****************************************************************************
+ *                      CmdQueue_PrintQueue()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: 
+ ****************************************************************************/
+void                           CmdQueue_PrintQueue(CmdQueue_T  *pCmdQueue)
+{
+       int CurrentCmdindex;
+       int first  = pCmdQueue->Head;
+       CmdQueue_CmdNode_T* pHead;
+       int NumberOfCommand = pCmdQueue->NumberOfCommandInQueue;
+
+       WLAN_OS_REPORT(("CmdQueue_PrintQueue \n"));
+
+       for(CurrentCmdindex = 0 ; CurrentCmdindex < NumberOfCommand ; CurrentCmdindex++)
+       {
+               pHead = &pCmdQueue->CmdQueue[first];
+#ifdef TI_DBG
+               WLAN_OS_REPORT(("Cmd index %d CmdType = %s %s, Len = %d, Place in Queue = %d \n",
+                       CurrentCmdindex, 
+                       CmdQueue_GetCmdString(pHead->cmdType),
+                       CmdQueue_GetIEString(pHead->cmdType, (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)) ? *(UINT16 *)pHead->paramsBuf : 0)),
+                       pHead->paramsLen, 
+                       first));    
+#else
+               WLAN_OS_REPORT(("Cmd index %d CmdType = %d %d, Len = %d, Place in Queue = %d \n",
+                       CurrentCmdindex, 
+                       pHead->cmdType,
+                       (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)||
+                      (pHead->cmdType == CMD_READ_MEMORY)||(pHead->cmdType == CMD_WRITE_MEMORY)) ? *(UINT16 *)pHead->paramsBuf : 0),
+                       pHead->paramsLen, 
+                       first));    
+#endif
+
+               first++;
+               if(first == CMDQUEUE_QUEUE_DEPTH)
+                       first = 0;
+       }
+}
+
+/****************************************************************************
+ *                      CmdQueue_PrintHistory()
+ ****************************************************************************
+ * DESCRIPTION: print the last command according to a value
+ *
+ * INPUTS:  NunOfCmd : the number of the last command to print 
+ *
+ ****************************************************************************/
+void                                   CmdQueue_PrintHistory(TI_HANDLE hCmdQueue, int NunOfCmd)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue; 
+       int CurrentCmdindex;
+       int first  = pCmdQueue->Head;
+       CmdQueue_CmdNode_T* pHead ;
+
+    WLAN_OS_REPORT(("--------------- CmdQueue_PrintHistory of %d -------------------\n",NunOfCmd));
+       
+       for(CurrentCmdindex = 0 ; CurrentCmdindex < NunOfCmd ; CurrentCmdindex++)
+       {
+               pHead  =  &pCmdQueue->CmdQueue[first];
+
+#ifdef TI_DBG
+               WLAN_OS_REPORT(("Cmd index %d CmdType = %s %s, Len = %d, Place in Queue = %d \n",
+                       CurrentCmdindex, 
+                       CmdQueue_GetCmdString(pHead->cmdType),
+                       CmdQueue_GetIEString(pHead->cmdType, (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)) ? *(UINT16 *)pHead->paramsBuf : 0)),
+                       pHead->paramsLen, 
+                       first));
+#else
+               WLAN_OS_REPORT(("Cmd index %d CmdType = %d %d, Len = %d, Place in Queue = %d \n",
+                       CurrentCmdindex, 
+                       pHead->cmdType,
+                       (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)||
+                      (pHead->cmdType == CMD_READ_MEMORY)||(pHead->cmdType == CMD_WRITE_MEMORY)) ? *(UINT16 *)pHead->paramsBuf : 0),
+                       pHead->paramsLen, 
+                       first));
+#endif
+
+               if(first == 0)
+                       first = CMDQUEUE_QUEUE_DEPTH-1;
+               else
+                       first--;
+       }
+
+       WLAN_OS_REPORT(("-----------------------------------------------------------------------\n"));
+
+}
+
+/****************************************************************************
+ *                      CmdQueue_GetMaxNumberOfCommands()
+ ****************************************************************************
+ * DESCRIPTION: returns maximum number of commands (ever) in CmdQueue queue
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: maximum number of commands (ever) in mailbox queue
+ ****************************************************************************/
+int                                    CmdQueue_GetMaxNumberOfCommands (TI_HANDLE hCmdQueue)
+{
+       CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
+
+       return (pCmdQueue->MaxNumberOfCommandInQueue);
+}
+
+#ifdef REPORT_LOG
+
+/****************************************************************************
+ *                      CmdQueue_GetCmdString()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: 
+ ****************************************************************************/
+char*                  CmdQueue_GetCmdString(int MboxCmdType)
+{
+       switch (MboxCmdType)
+       {
+               case 0: return "CMD_RESET";
+               case 1: return "CMD_INTERROGATE"; 
+               case 2: return "CMD_CONFIGURE";
+               case 3: return "CMD_ENABLE_RX";
+               case 4: return "CMD_ENABLE_TX";
+               case 5: return "CMD_DISABLE_RX";
+               case 6: return "CMD_DISABLE_TX";        
+               case 8: return "CMD_SCAN";
+               case 9: return "CMD_STOP_SCAN"; 
+               case 10: return "CMD_VBM";
+               case 11: return "CMD_START_JOIN";       
+               case 12: return "CMD_SET_KEYS"; 
+               case 13: return "CMD_READ_MEMORY";      
+               case 14: return "CMD_WRITE_MEMORY";
+               case 19: return "CMD_BEACON";
+               case 20: return "CMD_PROBE_RESP";       
+               case 21: return "CMD_NULL_DATA";        
+               case 22: return "CMD_PROBE_REQ";        
+               case 23: return "CMD_TEST";             
+               case 27: return "CMD_ENABLE_RX_PATH";
+               case 28: return "CMD_NOISE_HIST";       
+               case 29: return "CMD_RX_RESET"; 
+               case 30: return "CMD_PS_POLL";  
+               case 31: return "CMD_QOS_NULL_DATA";    
+               case 32: return "CMD_LNA_CONTROL";      
+               case 33: return "CMD_SET_BCN_MODE";     
+               case 34: return "CMD_MEASUREMENT";      
+               case 35: return "CMD_STOP_MEASUREMENT";
+               case 36: return "CMD_DISCONNECT";               
+               case 37: return "CMD_SET_PS_MODE";              
+               case 38: return "CMD_CHANNEL_SWITCH";   
+               case 39: return "CMD_STOP_CHANNEL_SWICTH";
+               case 40: return "CMD_AP_DISCOVERY";
+               case 41: return "CMD_STOP_AP_DISCOVERY";
+               case 42: return "CMD_SPS_SCAN";                 
+               case 43: return "CMD_STOP_SPS_SCAN";            
+               case 45: return "CMD_HEALTH_CHECK";             
+               default: return " *** Error No Such CMD **** ";
+       }
+};
+
+/****************************************************************************
+ *                      CmdQueue_GetErrorString()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: 
+ ****************************************************************************/
+char*            CmdQueue_GetErrorString(CommandStatus_e MboxError)
+{
+    switch (MboxError)
+    {
+    case CMD_MAILBOX_IDLE:
+        return "CMD_MAILBOX_IDLE";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_SUCCESS:
+        return "CMD_STATUS_SUCCESS";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_UNKNOWN_CMD:
+        return "CMD_STATUS_UNKNOWN_CMD";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_UNKNOWN_IE:
+        return "CMD_STATUS_UNKNOWN_IE";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_RX_BUSY:
+        return "CMD_STATUS_RX_BUSY";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_INVALID_PARAM:
+        return "CMD_STATUS_INVALID_PARAM";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_TEMPLATE_TOO_LARGE:
+        return "CMD_STATUS_TEMPLATE_TOO_LARGE";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_OUT_OF_MEMORY:
+        return "CMD_STATUS_OUT_OF_MEMORY";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_STA_TABLE_FULL:
+        return "CMD_STATUS_STA_TABLE_FULL";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_RADIO_ERROR:
+        return "CMD_STATUS_RADIO_ERROR";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_WRONG_NESTING:
+        return "CMD_STATUS_WRONG_NESTING";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_TIMEOUT:
+        return "CMD_STATUS_TIMEOUT";
+        /* break; to avoid compilation warning */
+
+    case CMD_STATUS_FW_RESET:
+        return "CMD_STATUS_FW_RESET";
+        /* break; to avoid compilation warning */
+
+    default:
+        return "Unrecognized error code";
+        /* break; to avoid compilation warning */
+    }
+}
+
+
+/****************************************************************************
+ *                      CmdQueue_GetIEString()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: 
+ ****************************************************************************/
+char*                  CmdQueue_GetIEString(int MboxCmdType, UINT16 Id)
+{
+       if( MboxCmdType== CMD_INTERROGATE || MboxCmdType == CMD_CONFIGURE)      
+       {
+               switch (Id)
+               {
+               case ACX_WAKE_UP_CONDITIONS:            return " (ACX_WAKE_UP_CONDITIONS)";
+               case ACX_MEM_CFG:                                       return " (ACX_MEM_CFG)";                 
+               case ACX_SLOT:                                          return " (ACX_SLOT) ";                    
+               case ACX_QUEUE_HEAD:                            return " (ACX_QUEUE_HEAD)";     
+               case ACX_AC_CFG:                                        return " (ACX_AC_CFG) ";                  
+               case ACX_MEM_MAP:                                       return " (ACX_MEM_MAP)";
+               case ACX_AID:                                           return " (ACX_AID)";
+               case ACX_RADIO_PARAM:                           return " (ACX_RADIO_PARAM)";          
+               case ACX_CFG:                                           return " (ACX_CFG) ";                  
+        case ACX_FW_REV:                                       return " (ACX_FW_REV) ";                  
+        case ACX_FCS_ERROR_CNT:                        return " (ACX_FCS_ERROR_CNT) ";               
+        case ACX_MEDIUM_USAGE:                                 return " (ACX_MEDIUM_USAGE) ";                  
+               case ACX_RX_CFG:                                        return " (ACX_RX_CFG) ";                  
+               case ACX_TX_QUEUE_CFG:                          return " (ACX_TX_QUEUE_CFG) "; 
+               case ACX_BSS_IN_PS:                             return " (ACX_BSS_IN_PS) ";
+               case ACX_STATISTICS:                            return " (ACX_STATISTICS) ";
+               case ACX_FEATURE_CFG:                           return " (ACX_FEATURE_CFG) ";                    
+               case ACX_MISC_CFG:                                      return " (ACX_MISC_CFG) ";               
+               case ACX_TID_CFG:                                       return " (ACX_TID_CFG) ";                    
+               case ACX_CAL_ASSESSMENT:                        return " (ACX_CAL_ASSESSMENT) ";            
+               case ACX_BEACON_FILTER_OPT:             return " (ACX_BEACON_FILTER_OPT) ";                                                                                                                               
+               case ACX_LOW_RSSI:                                      return " (ACX_LOW_RSSI)";              
+        case ACX_NOISE_HIST:                           return " (ACX_NOISE_HIST)";           
+               case ACX_HDK_VERSION:                           return " (ACX_HDK_VERSION)";         
+               case ACX_PD_THRESHOLD:                          return " (ACX_PD_THRESHOLD) ";                 
+               case ACX_DATA_PATH_PARAMS:                      return " (ACX_DATA_PATH_PARAMS) ";                
+       case ACX_CCA_THRESHOLD:                                 return " (ACX_CCA_THRESHOLD)";            
+               case ACX_EVENT_MBOX_MASK:                       return " (ACX_EVENT_MBOX_MASK) ";
+#ifdef FW_RUNNING_AS_AP                            
+               case ACX_DTIM_PERIOD:                           return " (ACX_DTIM_PERIOD) ";            
+#else
+               case ACX_WR_TBTT_AND_DTIM:                      return " (ACX_WR_TBTT_AND_DTIM) ";  
+#endif
+               case ACX_ACI_OPTION_CFG:                        return " (ACX_ACI_OPTION_CFG) ";                
+        case ACX_GPIO_CFG:                                     return " (ACX_GPIO_CFG) ";  
+        case ACX_GPIO_SET:                                     return " (ACX_GPIO_SET) ";  
+               case ACX_PM_CFG:                                        return " (ACX_PM_CFG) ";
+               case ACX_CONN_MONIT_PARAMS:             return " (ACX_CONN_MONIT_PARAMS) ";
+               case ACX_AVERAGE_RSSI:                          return " (ACX_AVERAGE_RSSI) ";
+               case ACX_CONS_TX_FAILURE:                       return " (ACX_CONS_TX_FAILURE) ";
+               case ACX_BCN_DTIM_OPTIONS:                      return " (ACX_BCN_DTIM_OPTIONS) ";                             
+               case ACX_SG_ENABLE:                             return " (ACX_SG_ENABLE) ";                                       
+               case ACX_SG_CFG:                                        return " (ACX_SG_CFG) ";                                       
+               case ACX_ANTENNA_DIVERSITY_CFG:         return " (ACX_ANTENNA_DIVERSITY_CFG) ";                                      
+               case ACX_LOW_SNR:                                       return " (ACX_LOW_SNR) ";
+               case ACX_BEACON_FILTER_TABLE:           return " (ACX_BEACON_FILTER_TABLE) ";
+               case ACX_ARP_IP_FILTER:                         return " (ACX_ARP_IP_FILTER) ";
+               case ACX_ROAMING_STATISTICS_TBL:        return " (ACX_ROAMING_STATISTICS_TBL) ";  
+               case ACX_RATE_POLICY:                           return " (ACX_RATE_POLICY) ";  
+               case ACX_CTS_PROTECTION:                        return " (ACX_CTS_PROTECTION) ";  
+               case ACX_SLEEP_AUTH:                            return " (ACX_SLEEP_AUTH) ";  
+               case ACX_PREAMBLE_TYPE:                         return " (ACX_PREAMBLE_TYPE) ";  
+               case ACX_ERROR_CNT:                             return " (ACX_ERROR_CNT) ";  
+               case ACX_FW_GEN_FRAME_RATES:            return " (ACX_FW_GEN_FRAME_RATES) ";  
+               case ACX_IBSS_FILTER:                           return " (ACX_IBSS_FILTER) ";  
+               case ACX_SERVICE_PERIOD_TIMEOUT:        return " (ACX_SERVICE_PERIOD_TIMEOUT) ";  
+               case ACX_TSF_INFO:                                      return " (ACX_TSF_INFO) ";  
+               case ACX_CONFIG_PS_WMM:                         return " (ACX_CONFIG_PS_WMM) "; 
+               case ACX_ENABLE_RX_DATA_FILTER:         return " (ACX_ENABLE_RX_DATA_FILTER) ";
+               case ACX_SET_RX_DATA_FILTER:            return " (ACX_SET_RX_DATA_FILTER) ";
+               case ACX_GET_DATA_FILTER_STATISTICS:return " (ACX_GET_DATA_FILTER_STATISTICS) ";
+               case ACX_POWER_LEVEL_TABLE:             return " (ACX_POWER_LEVEL_TABLE) ";
+               case ACX_BET_ENABLE:                            return " (ACX_BET_ENABLE) ";
+               case DOT11_STATION_ID:                          return " (DOT11_STATION_ID) ";
+               case DOT11_RX_MSDU_LIFE_TIME:           return " (DOT11_RX_MSDU_LIFE_TIME) ";
+               case DOT11_CUR_TX_PWR:                          return " (DOT11_CUR_TX_PWR) ";
+               case DOT11_DEFAULT_KEY:                         return " (DOT11_DEFAULT_KEY) ";
+               case DOT11_RX_DOT11_MODE:                       return " (DOT11_RX_DOT11_MODE) ";
+               case DOT11_RTS_THRESHOLD:                       return " (DOT11_RTS_THRESHOLD) ";
+               case DOT11_GROUP_ADDRESS_TBL:           return " (DOT11_GROUP_ADDRESS_TBL) ";  
+               
+               default:        return " *** Error No Such IE **** ";
+               }
+       }
+       return "";
+}
+#endif /* REPORT_LOG */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.h
new file mode 100644 (file)
index 0000000..9f76f80
--- /dev/null
@@ -0,0 +1,157 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/*********************************************************************************/
+/*                                                                                */
+/*   MODULE:  CmdQueue.h                                                */
+/*   PURPOSE: CmdQueue internal H file                                                                                   */
+/*                                                                                */
+/**********************************************************************************/
+#ifndef _CMDQUEUE_H_
+#define _CMDQUEUE_H_
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+
+/*****************************************************************************
+ **         Defines                                                           **
+ *****************************************************************************/
+#define CMDQUEUE_QUEUE_DEPTH          50
+#define CMDQUEUE_HISTORY_DEPTH        5
+#define CMDQUEUE_INFO_ELEM_HEADER_LEN 4
+
+#define CMDQUEUE_CONVERT_RC(rc) \
+       if((rc == TNETWIF_OK)||(rc == TNETWIF_COMPLETE)||(rc == TNETWIF_PENDING)||(rc == OK)) \
+               return OK; \
+       else \
+               return NOK \
+
+#define CHECK_ERROR_FLAG(flag) \
+       if(flag == TRUE) \
+               return OK; \
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+typedef enum 
+{
+       CMDQUEUE_EVENT_RUN,
+       CMDQUEUE_EVENT_SEND_CMPLT,
+       CMDQUEUE_EVENT_RESULT_RECEIVED,
+       CMDQUEUE_EVENT_NUM,
+} CmdQueue_SMEvents_e;
+
+typedef enum 
+{
+       CMDQUEUE_STATE_IDLE,
+       CMDQUEUE_STATE_SEND_CMD_v,
+       CMDQUEUE_STATE_WAIT_SEND_CMPLT,
+       CMDQUEUE_STATE_INTERROGATE_v,
+       CMDQUEUE_STATE_WAIT_RESULT,
+       CMDQUEUE_STATE_FINISH_v,
+       CMDQUEUE_STATE_NUM,
+} CmdQueue_SMStates_e;
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+/*  CmdQueue Node */
+typedef struct 
+{
+       Command_e               cmdType;                /* Command Type Config/interrogat ... */
+       UINT32                          paramsLen; 
+       void*                           CB_Func;
+       TI_HANDLE                       CB_Arg;
+       UINT8                           paramsBuf[MAX_CMD_PARAMS]; /* param for config */
+       UINT8*                          interrogateParamsBuf; /* A returned value Buffer */     
+}CmdQueue_CmdNode_T;
+
+/*  Saved CallBack Node In case of Recovery*/
+typedef struct 
+{
+       void*                           CB_Func;
+       TI_HANDLE                       CB_Arg;
+       UINT8*                          interrogateParamsBuf; /* A returned value Buffer */             
+}CmdQueue_RecoveryNode_T;
+
+/* MailBox Queue */
+
+typedef struct _CmdQueue_T
+{      
+       /* handles */
+       TI_HANDLE                               hOs;
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hCmdMBox;
+
+       /* SM */
+       CmdQueue_SMStates_e             State;
+       CmdQueue_GenericCB_t    CmdCompleteGenericCB_Func;
+       TI_HANDLE                               CmdCompleteGenericCB_Arg;
+       CmdQueue_CB_t                   FailureCB;
+       TI_HANDLE                               FailureCbHandle;
+
+       /* queues */
+       CmdQueue_CmdNode_T              CmdQueue[CMDQUEUE_QUEUE_DEPTH]; 
+       CmdQueue_RecoveryNode_T RecoveryQueue[CMDQUEUE_QUEUE_DEPTH];
+
+       /* CmdQueue indexes & counters */
+       int                                             Head;
+       int                                             Tail;
+       int                                             NumberOfCommandInQueue;
+       int                                             MaxNumberOfCommandInQueue;
+       int                                             NumberOfRecoveryNodes;  
+#ifdef TI_DBG
+       UINT32                                  CmdSendCounter;
+       UINT32                                  CmdCompltCounter;
+#endif
+
+       int                                             SM_RC;
+       /* error handling */
+       int                                             ErrorFlag;
+}CmdQueue_T; 
+
+/*****************************************************************************
+ **         Internal functions definitions                                  **
+ *****************************************************************************/
+int                            CmdQueue_SM(CmdQueue_T* pCmdQueue,CmdQueue_SMEvents_e event);
+int                            CmdQueue_Push(CmdQueue_T  *pCmdQueue, Command_e  cmdType,
+                                                                               UINT8* pParamsBuf, UINT32 paramsLen,
+                                                                               void *CB_Func, TI_HANDLE CB_Arg, UINT8* pCB_Buf);
+void                   CmdQueue_PrintQueue(CmdQueue_T  *pCmdQueue);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Export_Inc/CmdQueue_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Export_Inc/CmdQueue_api.h
new file mode 100644 (file)
index 0000000..ce97420
--- /dev/null
@@ -0,0 +1,98 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/*********************************************************************************/
+/*                                                                                */
+/*   MODULE:  CmdQueue_api.h                                                */
+/*   PURPOSE: CmdQueue api                                                                                       */
+/*                                                                                */
+/**********************************************************************************/
+#ifndef _CMDQUEUE_API_H_
+#define _CMDQUEUE_API_H_
+
+#include "whalCommon.h"
+#include "public_commands.h"
+
+/*****************************************************************************
+ **         Defines                                                           **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Types                                                      **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         APIs definitions                                  **
+ *****************************************************************************/
+
+TI_HANDLE                      CmdQueue_Create(TI_HANDLE hOS);
+int                                    CmdQueue_Destroy(TI_HANDLE hCmdQueue);
+int                                    CmdQueue_Config(TI_HANDLE hCmdQueue, TI_HANDLE hCmdMBox,
+                                                                                       TI_HANDLE hReport);
+int                                    CmdQueue_StartReconfig(TI_HANDLE hCmdQueue);
+int                                    CmdQueue_EndReconfig(TI_HANDLE hCmdQueue);
+int                                    CmdQueue_RegisterCmdCompleteGenericCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle);
+int                                    CmdQueue_RegisterForErrorCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle);
+int                                    CmdQueue_CmdConfigure(TI_HANDLE hCmdQueue, void *MboxBuf,UINT32 ParamsLen);
+int                                    CmdQueue_CmdConfigureWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
+                                                                                                                       void *CB_Func, TI_HANDLE CB_handle);
+int                                    CmdQueue_CmdInterrogate(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen);
+int                                    CmdQueue_CmdInterrogateWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
+                                                                                                                       void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf);
+int                                    CmdQueue_Command(TI_HANDLE hCmdQueue, Command_e MboxCmdType, char *MboxBuf, UINT32 ParamsLen);
+int                                    CmdQueue_CommandWithCb(TI_HANDLE hCmdQueue, Command_e MboxCmdType, void *MboxBuf, UINT32 ParamsLen, 
+                                                                                                                       void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf);
+int                                    CmdQueue_GetMaxNumberOfCommands (TI_HANDLE hCmdQueue);
+void                                   CmdQueue_Print(TI_HANDLE hCmdQueue);
+void                                   CmdQueue_PrintHistory(TI_HANDLE hCmdQueue, int NunOfCmd);
+int                                    CmdQueue_ResultReceived(TI_HANDLE hCmdQueue, UINT32 status);
+int                                    CmdQueue_Error  (TI_HANDLE hCmdQueue);
+int                                    CmdQueue_SendCmplt(TI_HANDLE hCmdQueue);
+#ifdef REPORT_LOG
+char*               CmdQueue_GetIEString(int MboxCmdType, UINT16 Id);
+char*               CmdQueue_GetCmdString(int MboxCmdType);
+char*               CmdQueue_GetErrorString(CommandStatus_e MboxError);
+#endif /* REPORT_LOG */
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Export_Inc/recoveryCtrl_API.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/Export_Inc/recoveryCtrl_API.h
new file mode 100644 (file)
index 0000000..0d32ef2
--- /dev/null
@@ -0,0 +1,71 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       recoveryCtrl.h                                                                                 */
+/*    PURPOSE: recoveryCtrl module Header file                             */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _RECOVERY_CTRL_API_H_
+#define _RECOVERY_CTRL_API_H_
+
+#include "osTIType.h"
+
+TI_HANDLE recoveryCtrl_create(TI_HANDLE hOs);
+TI_STATUS recoveryCtrl_config(TI_HANDLE hRecoveryCtrl, 
+                                                         TI_HANDLE hReport,
+                                                         TI_HANDLE hTNETWIF,
+                                                         TI_HANDLE hTxXfer,     
+                                                         TI_HANDLE hRxXfer,     
+                                                         TI_HANDLE hTxResult,   
+                                                         TI_HANDLE hMacServices,
+                                                         TI_HANDLE hTxCtrlBlk,  
+                                                         TI_HANDLE hTxHwQueue,  
+                                                         TI_HANDLE hHalCtrl,    
+                                                         TI_HANDLE hHwIntr,     
+                                                         TI_HANDLE hWhalParams, 
+                                                         TI_HANDLE hCmdQueue,   
+                                                         TI_HANDLE hFwEvent,    
+                                                         TI_HANDLE hCmdMBox,
+                                                         TI_HANDLE hHwInit);
+
+TI_STATUS recoveryCtrl_destroy(TI_HANDLE hRecoverCtrl);
+TI_STATUS recoveryCtrl_restartTWD(TI_HANDLE hRecoverCtrl,void *endOfRecoveryCB, TI_HANDLE hRecoveryMgr);
+TI_STATUS recoveryCtrl_CB(TI_HANDLE hRecoveryCtrl);
+
+
+
+#endif /* _RECOVERY_CTRL_API_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.c
new file mode 100644 (file)
index 0000000..50b5ba2
--- /dev/null
@@ -0,0 +1,603 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/*******************************************************************************/
+/*                                                                             */
+/*  MODULE:  recoveryCtrl.c                                                     */
+/*  PURPOSE: The responsibility of RecoveryCtrl module is to provide main API   */
+/*           to HelthMonitor that invokes the recovery process if failure is   */
+/*           detected. It performs disable/enable inputs from outside, calls   */
+/*           restart of TWD and informs STAD modules that recovery has been    */
+/*           performed.                                                        */
+/*                                                                             */
+/*******************************************************************************/
+
+#include "paramOut.h"
+#include "osApi.h"
+#include "report.h"
+#include "recoveryCtrl.h"
+#include "recoveryCtrl_API.h"
+
+#include "TNETWIF.h"
+#include "PowerAuthorization.h"
+#include "ScanSrv.h"
+#include "MeasurementSrv.h"
+#include "PowerSrv_API.h"
+#include "FwEvent_api.h"
+#include "rxXfer_api.h"
+#include "MacServices.h"
+#include "txHwQueue_api.h"
+#include "txXfer_api.h"
+#include "txResult_api.h"
+#include "CmdMBox_api.h"
+#include "CmdQueue_api.h"
+#include "whalParams.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+
+#include "TNETWArb.h"
+#include "ElpCtrl.h"
+#include "HwInit_api.h"
+
+/* static function */
+#ifdef USE_RECOVERY
+static void recoveryCtrl_SM(TI_HANDLE hRecoveryCtrl);
+static int recoveryCtrl_ReConfig (TI_HANDLE hRecoveryCtrl);
+static int recoveryCtrl_ReJoinBss(TI_HANDLE hRecoveryCtrl);
+#endif /* USE_RECOVERY */
+
+/*******************************************************************************
+*                       PUBLIC  FUNCTIONS  IMPLEMENTATION                      *
+********************************************************************************/
+
+
+/*************************************************************************
+*                        recoveryCtrl_create                              *
+**************************************************************************
+* DESCRIPTION:  This function initializes the RecoveryCtrl module.
+*
+* INPUT:        hOs - handle to Os Abstraction Layer
+*               
+* RETURN:       Handle to the allocated RecoveryCtrl module
+*************************************************************************/
+TI_HANDLE recoveryCtrl_create(TI_HANDLE hOs)
+{
+#ifdef USE_RECOVERY
+    recoveryCtrl_t *hRecoveryCtrl;
+
+    /* allocate RecoverCtrl module */
+    hRecoveryCtrl = os_memoryAlloc(hOs, (sizeof(recoveryCtrl_t)));
+
+    if(!hRecoveryCtrl)
+    {
+        WLAN_OS_REPORT(("Error allocating the RecoverCtrl Module\n"));
+        return NULL;
+    }
+
+    /* Reset RecoverCtrl module */
+    os_memoryZero(hOs, hRecoveryCtrl, (sizeof(recoveryCtrl_t)));
+
+    hRecoveryCtrl->hOs = hOs;
+
+    return(hRecoveryCtrl);
+#else
+    return NULL;
+#endif /* USE_RECOVERY */
+} /* recoveryCtrl_create */
+
+
+/***************************************************************************
+*                           recoveryCtrl_config                             *
+****************************************************************************
+* DESCRIPTION:  This function configures the recoveryCtrl module
+*
+* RETURNS:      OK - Configuration successful
+*               NOK - Configuration unsuccessful
+***************************************************************************/
+TI_STATUS recoveryCtrl_config(TI_HANDLE hRecoveryCtrl, 
+                              TI_HANDLE hReport,
+                              TI_HANDLE hTNETWIF,
+                              TI_HANDLE hTxXfer,     
+                              TI_HANDLE hRxXfer,     
+                              TI_HANDLE hTxResult,   
+                              TI_HANDLE hMacServices,
+                              TI_HANDLE hTxCtrlBlk,  
+                              TI_HANDLE hTxHwQueue,  
+                              TI_HANDLE hHalCtrl,    
+                              TI_HANDLE hHwIntr,     
+                              TI_HANDLE hWhalParams, 
+                              TI_HANDLE hCmdQueue,   
+                              TI_HANDLE hFwEvent,    
+                              TI_HANDLE hCmdMBox,
+                              TI_HANDLE hHwInit)
+{
+#ifdef USE_RECOVERY
+    recoveryCtrl_t *pRecoveryCtrl = (recoveryCtrl_t *)hRecoveryCtrl;
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    MacServices_t *pMacServices = (MacServices_t*)hMacServices;
+
+    /* configure modules handles */
+    pRecoveryCtrl->hReport = hReport;
+    pRecoveryCtrl->hTNETWIF = hTNETWIF;    
+    pRecoveryCtrl->hTxXfer = hTxXfer;
+    pRecoveryCtrl->hRxXfer = hRxXfer;     
+    pRecoveryCtrl->hTxResult = hTxResult;   
+    pRecoveryCtrl->hMacServices = hMacServices;
+    pRecoveryCtrl->hTxCtrlBlk = hTxCtrlBlk;  
+    pRecoveryCtrl->hTxHwQueue = hTxHwQueue;  
+    pRecoveryCtrl->hHalCtrl = hHalCtrl;    
+    pRecoveryCtrl->hHwIntr = hHwIntr;     
+    pRecoveryCtrl->hWhalParams = hWhalParams; 
+    pRecoveryCtrl->hCmdQueue = hCmdQueue;   
+    pRecoveryCtrl->hFwEvent = hFwEvent;    
+    pRecoveryCtrl->hCmdMBox = hCmdMBox;    
+    pRecoveryCtrl->hHwInit = hHwInit;
+    pRecoveryCtrl->hTNETWArb = pTNETWIF->hTNETWArb;
+
+    pRecoveryCtrl->hELPCtrl = pTNETWIF->hELPCtrl;
+    pRecoveryCtrl->hScanSRV = pMacServices->hScanSRV;
+    pRecoveryCtrl->hMeasurementSRV = pMacServices->hMeasurementSRV;
+    pRecoveryCtrl->hPowerSrv = pMacServices->hPowerSrv;
+    pRecoveryCtrl->hPowerAutho = pMacServices->hPowerAutho;
+
+    /* pRecoveryCtrl->hRecoveryMgr will be initialized while calling to recoveryCtrl_restartTWD() */
+
+    pRecoveryCtrl->smState = REC_CTRL_STATE_IDLE;
+    
+    WLAN_REPORT_INIT(pRecoveryCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,
+        ("RecoveryCtrl configured successfully\n"));
+#endif /* USE_RECOVERY */
+    return OK;
+} /* recoveryCtrl_config */
+
+
+/***************************************************************************
+*                           recoveryCtrl_destroy                            *
+****************************************************************************
+* DESCRIPTION:  This function unload the RecoverCtrl module. 
+*
+* INPUTS:       hRecoveryCtrl - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - Unload succesfull
+*               NOK - Unload unsuccesfull
+***************************************************************************/
+TI_STATUS recoveryCtrl_destroy(TI_HANDLE hRecoveryCtrl)
+{
+#ifdef USE_RECOVERY
+    recoveryCtrl_t *pRecoveryCtrl = (recoveryCtrl_t *)hRecoveryCtrl;
+
+    /* free RecoverCtrl Module */
+    os_memoryFree(pRecoveryCtrl->hOs, pRecoveryCtrl, sizeof(recoveryCtrl_t));
+#endif /* USE_RECOVERY */
+    return OK;
+}
+
+/**********************************************************************************************
+ *                  recoveryCtrl_SM()
+ **********************************************************************************************
+ * DESCRIPTION:  
+   ============
+    This is the recoveryCtrl state machine.
+    The inceptive event for RecoveryCtrl SM is invoking the restart of TWD by RecoveryMgr;
+    Perform ASYNC restart of BusTxn (if not idle then wait until end of current txn and 
+    Invoke CB upon TxnComplete) and FW Download;
+    HwInit module performs HW Init process;
+    Call RecoverMgr CB endOfRecovery() at the end of TWD restart
+
+    The SM supports both Sync and Async accesses to the HW.
+    It loops and progresses from state to state as long as the HW is accessed synchronously.
+    Once the access is Asynchronous (TNETWIF_PENDING), it exits and is called later
+      by the TNETWIF when the HW is ready.
+    That's why it uses unspecified-mode accesses (e.g. TNETWIF_ReadMemOpt) which
+      selects either Sync or Async automatically according to the platform and length.
+    Yet, the short transactions (EOB and Interrupt-Request 32 bit writes) are done using Sync 
+      access to simplify the SM 
+    NOTE: MCS projects may require full Sync/Async support, so the Sync accesses may need to be modified. 
+
+    NOTE:  The recoveryCtrl-SM detailed description is provided in "CE-2.0 Recovery LLD.doc".
+
+ **********************************************************************************************/
+#ifdef USE_RECOVERY
+static void recoveryCtrl_SM(TI_HANDLE hRecoveryCtrl)
+{
+    recoveryCtrl_t *pRecoveryCtrl = (recoveryCtrl_t *)hRecoveryCtrl;
+    TI_STATUS tnetwifStatus = TNETWIF_ERROR; /* Last HW operation status: Complete (Sync) or Pending (Async). */
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pRecoveryCtrl->hHalCtrl;
+
+#ifdef TI_DBG
+    if (hRecoveryCtrl == NULL)
+    {
+        WLAN_REPORT_ERROR(pRecoveryCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,  
+            ("recoveryCtrl_SM(): ****  Called with NULL handle!!  ****\n"));
+        return;
+    }
+#endif
+    
+    /* 
+     * Loop through the states sequence as long as the process is synchronous.
+     * Exit when finished or if an Asynchronous process is required. In this case
+     *   the SM process will be resumed later (called back by TNETWIF). 
+     */
+    while (1)
+    {
+        switch (pRecoveryCtrl->smState)
+        {
+            case REC_CTRL_STATE_IDLE:
+                FwEvent_Stop(pRecoveryCtrl->hFwEvent);
+
+                tnetwifStatus = TNETWIF_COMPLETE;
+
+                pRecoveryCtrl->smState = REC_CTRL_STATE_WAIT_END_CURR_TXN;
+                break;
+
+            case REC_CTRL_STATE_WAIT_END_CURR_TXN:
+                TNETWArb_Recovery(pRecoveryCtrl->hTNETWArb, pRecoveryCtrl->hELPCtrl);
+
+                elpCtrl_Stop(pRecoveryCtrl->hELPCtrl);
+                CmdMBox_Restart(pRecoveryCtrl->hCmdMBox);
+                CmdQueue_StartReconfig(pRecoveryCtrl->hCmdQueue);
+
+                pRecoveryCtrl->smState = REC_CTRL_STATE_INIT_CMPLT;
+                tnetwifStatus = hwInit_recovery(pRecoveryCtrl->hHwInit, (TI_HANDLE)(pWhalCtrl->pHwCtrl), (void*)recoveryCtrl_SM, hRecoveryCtrl);
+                return;
+    
+            case REC_CTRL_STATE_INIT_CMPLT:
+                elpCtrl_Start(pRecoveryCtrl->hELPCtrl);
+
+                /* reconfig FW */
+                recoveryCtrl_ReConfig(hRecoveryCtrl);
+
+                pRecoveryCtrl->smState = REC_CTRL_STATE_END_RECONFIG;
+                whal_hwInfoElemMiscTableGet (pWhalCtrl->pHwCtrl->pHwMboxConfig, 
+                                                    &pWhalCtrl->misc,
+                                                    (void *)recoveryCtrl_SM,
+                                                    hRecoveryCtrl);
+                return;
+
+            case REC_CTRL_STATE_END_RECONFIG:
+                powerAutho_Restart(pRecoveryCtrl->hMacServices);
+                RxXfer_ReStart(pRecoveryCtrl->hRxXfer);
+                scanSRV_restart(pRecoveryCtrl->hScanSRV);
+                measurementSRV_restart(pRecoveryCtrl->hMeasurementSRV);
+                powerSrv_restart(pRecoveryCtrl->hPowerSrv);
+
+                /*Change the State of the mboxQueue and the interrupt Module */
+/* moved later              whalCtrl_exitFromInitMode(pRecoveryCtrl->hHalCtrl);*/ /* call inside CmdMBox_SetModeNormal */
+
+                /* 
+                Indicates the MboxQueue that Reconfig Ended in Order To Call the CallBacks
+                That Was saved before the recovery process started 
+                */
+                CmdQueue_EndReconfig(pRecoveryCtrl->hCmdQueue);
+
+                pRecoveryCtrl->smState = REC_CTRL_STATE_IDLE;
+
+                /* call End Of Recovery CB */
+                pRecoveryCtrl->endOfRecoveryCB(pRecoveryCtrl->hRecoveryMgr);
+
+                return; /* recovery process ended */
+    
+            default:
+                WLAN_REPORT_ERROR(pRecoveryCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,  
+                        ("recoveryCtrl_SM(): Unexpected state, smState=%d\n", pRecoveryCtrl->smState));
+                return;
+
+        }  /* switch (pRecoveryCtrl->smState) */
+
+        WLAN_REPORT_INFORMATION(pRecoveryCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,  
+            ("recoveryCtrl_SM(): smState=%d\n", pRecoveryCtrl->smState));
+
+        /* 
+         * If the last HW access request was pended, exit the SM (Asynchronous process).
+         * The SM will be called back when the HW access is done.
+         * Also reset the Sync flag to notify that the Xfer wasn't completed in the SendPacket context.
+         */
+        if (tnetwifStatus == TNETWIF_PENDING)
+        {
+            return;  /**********    Exit State Machine (to be called back by TNETWIF)   **********/
+        }
+
+#ifdef TI_DBG
+        else if (tnetwifStatus == TNETWIF_ERROR)
+        {
+            WLAN_REPORT_ERROR(pRecoveryCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,  
+                ("recoveryCtrl_SM(): Unexpected state, smState=%d\n", pRecoveryCtrl->smState));
+            return;
+        }
+#endif /* TI_DBG */
+    }  /* while (1) */
+} /* recoveryCtrl_SM */
+#endif /* USE_RECOVERY */
+
+/***************************************************************************
+*                           recoveryCtrl_restartTWD                        *
+****************************************************************************
+* DESCRIPTION:  Start TWD recovery. Restart TWD from bottom up.
+*               Init HW: (using HW init module in FW Transfer component).
+*               Reconfigure FW.
+*
+* INPUTS:       hRecoveryCtrl - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - succesfull
+*               NOK - unsuccesfull
+***************************************************************************/
+TI_STATUS recoveryCtrl_restartTWD(TI_HANDLE hRecoveryCtrl,void *endOfRecoveryCB, TI_HANDLE hRecoveryMgr)
+{
+#ifdef USE_RECOVERY
+    recoveryCtrl_t *pRecoveryCtrl = (recoveryCtrl_t *)hRecoveryCtrl;
+
+    /* register RecoveryMgr handle and endOfRecoveryCB*/
+    pRecoveryCtrl->hRecoveryMgr = hRecoveryMgr;
+    pRecoveryCtrl->endOfRecoveryCB = (EndOfRecoveryCB_t)endOfRecoveryCB;
+
+    recoveryCtrl_SM(hRecoveryCtrl);
+#endif /* USE_RECOVERY */
+    return OK;
+}
+
+#ifdef USE_RECOVERY
+int recoveryCtrl_ReConfig (TI_HANDLE hRecoveryCtrl)
+{
+    recoveryCtrl_t *pRecoveryCtrl = (recoveryCtrl_t *)hRecoveryCtrl;
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pRecoveryCtrl->hHalCtrl;
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+    whalParamInfo_t param;
+    DmaParams_T     *pDmaParams     = whal_ParamsGetDmaParams(pWhalCtrl->pWhalParams);
+
+    int index = 0;
+    int Stt;
+    
+    if(!pWlanParams->RecoveryEnable)
+    {
+        WLAN_OS_REPORT(("whalCtrl_ReConfig: Recovery is disabled in registry, abort recovery process\n"));
+        return OK;
+    }
+
+    FwEvent_SetHwInfo (pWhalCtrl->hFwEvent, &(pWhalCtrl->pHwCtrl->DataPathParams));
+    txXfer_restart(pWhalCtrl->hTxXfer); 
+    txResult_restart(pWhalCtrl->hTxResult); 
+
+    txXfer_setHwInfo (pWhalCtrl->hTxXfer, &(pWhalCtrl->pHwCtrl->DataPathParams));    
+
+    txResult_setHwInfo (pWhalCtrl->hTxResult, &(pWhalCtrl->pHwCtrl->DataPathParams));
+
+    rxXfer_SetDoubleBufferAddr (pWhalCtrl->hRxXfer, &(pWhalCtrl->pHwCtrl->DataPathParams)); 
+
+    /* Provide number of HW Tx-blocks and descriptors to Tx-HW-Queue module */
+    txHwQueue_setHwInfo (pWhalCtrl->hTxHwQueue, pDmaParams);
+
+    whalSecur_HwEncDecrEnable (pWhalCtrl->pWhalSecurity, 1);
+
+    /*send the table regardless to the state */
+    whal_hwCtrl_SetBeaconFilterIETable(pWhalCtrl->pHwCtrl, 
+                                       &pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.numberOfIEs, 
+                                       pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETable, 
+                                       &pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETableSize );
+
+    /*
+     * ReConfig the wlan hardware Queues according to the required Quality Of Service.
+     */
+    /* Reconfig Roaming thresholds */
+    /* SNR */
+    whalCtrl_SetSNRParamsCmd (pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+
+    /* RSSI */
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,
+                            ("\n SetRSSIParamsCmd :\n \
+                              RSSIthreshold = %d\n \
+                              RSSIFilterWeight = %d\n \
+                              RSSIFilterDepth = %d \n ",
+                              pWhalCtrl->pWhalParams->WlanParams.roamTriggers.rssiThreshold,
+                              pWhalCtrl->pWhalParams->WlanParams.roamTriggers.rssiFilterWeight,
+                              pWhalCtrl->pWhalParams->WlanParams.roamTriggers.rssiFilterDepth));
+    whalCtrl_SetRSSIParamsCmd(pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+
+    /* Max consecutive NACK */
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,
+                            ("\n SetMaxTxRetryParamsCmdCmd :\n \
+                              maxTxRetry = %d \n ",
+                              pWhalCtrl->pWhalParams->WlanParams.roamTriggers.maxTxRetry));
+    whalCtrl_SetMaxTxRetryParamsCmd(pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+    /* Out of sync */
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,
+                            ("\n whalCtrl_SetBssLossTsfThresholdParamsCmd :\n \
+                              BssLossTimeout = %d\n \
+                              TsfMissThreshold = %d \n ",
+                              pWhalCtrl->pWhalParams->WlanParams.roamTriggers.BssLossTimeout,
+                              pWhalCtrl->pWhalParams->WlanParams.roamTriggers.TsfMissThreshold));
+    whalCtrl_SetBssLossTsfThresholdParamsCmd(pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+
+    whalCtrl_setBetParams(pWhalCtrl,
+                          pWhalCtrl->pWhalParams->WlanParams.BetEnable, 
+                          pWhalCtrl->pWhalParams->WlanParams.MaximumConsecutiveET);
+
+    whalCtrl_setRxDataFiltersParams(pWhalCtrl, 
+                                    pWhalCtrl->pWhalParams->WlanParams.rxFilterDefaultEnable, 
+                                    pWhalCtrl->pWhalParams->WlanParams.rxFilterDefaultAction);
+
+    for (index = 0; index < MAX_DATA_FILTERS; index++)
+    {
+        if (pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterCommand == ADD_FILTER)
+        {
+            whalCtrl_setRxDataFilter(pWhalCtrl, 
+                                     index,
+                                     pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterCommand,
+                                     pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterAction,
+                                     pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterNumFieldPatterns, 
+                                     pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterLenFieldPatterns, 
+                                     pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterFieldPatterns);
+        }
+    }
+
+#ifdef BTH_COEXISTENCE /* it's solution for collision of BTH and WLAN (by Gemini protocol), we don't need it */
+    /* Soft Gemini Section */
+    /* ReConfig the BTH enable */
+    param.paramType = HAL_CTRL_SG_ENABLE_PARAM;
+    param.content.SoftGeminiEnable = pWhalCtrl->pWhalParams->WlanParams.SoftGeminiEnable;
+    whalCtrl_SetParam(pRecoveryCtrl->hHalCtrl, &param);
+
+    /* ReConfig the BTH config */
+    param.paramType = HAL_CTRL_SG_CONFIG_PARAM;
+    os_memoryCopy(pWhalCtrl->hOs, &param.content.SoftGeminiParam, &pWhalCtrl->pWhalParams->WlanParams.SoftGeminiParams, sizeof(SoftGeminiParam_t));
+    whalCtrl_SetParam(pRecoveryCtrl->hHalCtrl, &param);
+#endif
+
+
+#ifdef DO_CALIBRATION_IN_DRIVER
+    /* Perform single calibration for APP scan usage. */
+    whalCtrl_sendRadioAction(pWhalCtrl ,MANUAL_CALIB);
+#endif/* O_CALIBRATION_IN_DRIVER */
+    /*
+     * JOIN (use the local parameters), otherwize the CORE will reconnect
+     */
+    if (pWlanParams->bJoin)
+    {
+        /* set TxRatePolicy */
+        param.paramType = HAL_CTRL_TX_RATE_CLASS_PARAMS;
+        param.content.pTxRatePlicy = &pWhalCtrl->pWhalParams->BssInfoParams.TxRateClassParams;
+    
+        whalCtrl_SetParam(pRecoveryCtrl->hHalCtrl,&param);
+        
+        Stt = recoveryCtrl_ReJoinBss(hRecoveryCtrl);
+        if (Stt != OK)
+        {
+            WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,
+                ("whalCtrl_ReConfig: recoveryCtrl_ReJoinBss failed\n"));
+            return NOK;
+        }
+        whal_hwCtrl_AidSet (pWhalCtrl->pHwCtrl, pWhalCtrl->pWhalParams->WlanParams.Aid);
+        
+    
+        /* Slot time must be setting after doing join */
+        whal_hwCtrl_SetSlotTime(pWhalCtrl->pHwCtrl, (slotTime_e)pWhalCtrl->pWhalParams->WlanParams.SlotTime);               
+
+            /* Reconfig security keys, default key Id and encryption/decryption control to the FW*/
+        if (whalSecur_KeysReconfig (pWhalCtrl->pWhalSecurity) != OK)
+        {
+            WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, RECOVERY_CTRL_MODULE_LOG,
+                ("whalCtrl_ReConfig: ## whalSecur_KeysReconfig failed\n"));
+            return NOK;
+        }
+    }
+
+    return (OK);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : recoveryCtrl_ReJoinBss
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+
+int recoveryCtrl_ReJoinBss (TI_HANDLE hRecoveryCtrl)
+{
+    recoveryCtrl_t *pRecoveryCtrl = (recoveryCtrl_t *)hRecoveryCtrl;
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pRecoveryCtrl->hHalCtrl;
+    BssInfoParams_T *pBssInfoParams = &pWhalCtrl->pWhalParams->BssInfoParams;
+    TemplateListParams_T *pWhalTemplates = &pWhalCtrl->pWhalParams->TemplateList;
+    HwMboxCmd_T *pHwCmd = whal_hwCtrl_GetMboxCmd(pWhalCtrl->pHwCtrl);
+
+    /*
+     * set the templates 
+     */
+
+    if (pWhalTemplates->Beacon.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->Beacon.Buffer, 
+                                               (UINT16)pWhalTemplates->Beacon.Size,
+                                               CMD_BEACON,
+                                               NULL,
+                                               NULL);
+    
+    if (pWhalTemplates->ProbeResp.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->ProbeResp.Buffer, 
+                                               (UINT16)pWhalTemplates->ProbeResp.Size,
+                                               CMD_PROBE_RESP,
+                                               NULL,
+                                               NULL);
+
+    if (pWhalTemplates->ProbeReq.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->ProbeReq.Buffer, 
+                                               (UINT16)pWhalTemplates->ProbeReq.Size,
+                                               CMD_PROBE_REQ,
+                                               NULL,
+                                               NULL);
+    
+    if (pWhalTemplates->NullData.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->NullData.Buffer, 
+                                               (UINT16)pWhalTemplates->NullData.Size,
+                                               CMD_NULL_DATA,
+                                               NULL,
+                                               NULL);
+    
+    if (pWhalTemplates->PsPoll.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->PsPoll.Buffer, 
+                                               (UINT16)pWhalTemplates->PsPoll.Size,
+                                               CMD_PS_POLL,
+                                               NULL,
+                                               NULL);
+
+    if (pWhalTemplates->QosNullData.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->QosNullData.Buffer,
+                                               (UINT16)pWhalTemplates->QosNullData.Size,
+                                               CMD_QOS_NULL_DATA,
+                                               NULL,
+                                               NULL);
+
+
+    /*
+     * call the hardware to start/join the bss 
+     */
+    return whal_hwCtrl_StartJoin(pWhalCtrl->pHwCtrl, (bssType_e)pBssInfoParams->ReqBssType, NULL, NULL);
+
+}
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.h
new file mode 100644 (file)
index 0000000..55181b2
--- /dev/null
@@ -0,0 +1,99 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       recoveryMgr.h                                                                                  */
+/*    PURPOSE: RecoveryMgr module Header file                             */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _RECOVERY_CTRL_H_
+#define _RECOVERY_CTRL_H_
+
+#include "osTIType.h"
+
+
+/* State-Machine States */
+typedef enum
+{
+       REC_CTRL_STATE_IDLE,                            /*  */
+       REC_CTRL_STATE_WAIT_END_CURR_TXN,       /*  */
+       REC_CTRL_STATE_INIT_CMPLT,                      /*  */
+       REC_CTRL_STATE_END_RECONFIG
+} recoveryCtrlSmState_e;
+
+/* Callback function definition for EndOfRecovery */
+typedef void (* EndOfRecoveryCB_t)(TI_HANDLE CBObj);
+
+/* The module object. */
+typedef struct 
+{
+       /* Handles */
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hTNETWIF;
+       TI_HANDLE hTxXfer;
+       TI_HANDLE hRxXfer;
+       TI_HANDLE hTxResult;
+       TI_HANDLE hMacServices;
+       TI_HANDLE hTxCtrlBlk;
+       TI_HANDLE hTxHwQueue;
+       TI_HANDLE hHalCtrl;
+       TI_HANDLE hHalRx;       
+       TI_HANDLE hHwIntr;
+       TI_HANDLE hWhalParams;          
+       TI_HANDLE hCmdQueue;
+       TI_HANDLE hFwEvent;
+       TI_HANDLE hCmdMBox;
+       TI_HANDLE hHwInit;
+
+       TI_HANDLE hTNETWArb;//hBusArbiter;
+       TI_HANDLE hBusTxn;
+       TI_HANDLE hELPCtrl;
+
+       TI_HANDLE hScanSRV;
+       TI_HANDLE hMeasurementSRV;
+       TI_HANDLE hPowerSrv;
+       TI_HANDLE hPowerAutho;
+
+       TI_HANDLE hRecoveryMgr;
+       EndOfRecoveryCB_t endOfRecoveryCB;              /* EndOfRecovery callback */
+               
+       recoveryCtrlSmState_e smState;                  /* The current state of the SM. */      
+
+} recoveryCtrl_t;
+
+
+#endif /* _RECOVERY_CTRL_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.c
new file mode 100644 (file)
index 0000000..3ba1466
--- /dev/null
@@ -0,0 +1,996 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:    TNETW_Driver.c
+ *   PURPOSE:   TNETW_Driver layer used to handle the MAC Services 
+ *              and the HAL Modules 
+ *
+ ****************************************************************************/
+
+#include "commonTypes.h"
+#include "report.h"
+#include "TNETW_Driver_api.h"
+#include "MacServices_api.h"
+#include "txCtrlBlk_api.h"
+#include "txHwQueue_api.h"
+#include "txXfer_api.h"
+#include "txResult_api.h"
+#include "rxXfer_api.h"
+#include "TNETWIF.h"
+#include "FwEvent_api.h"
+#include "CmdMBox_api.h"
+#include "CmdQueue_api.h"
+#include "eventMbox_api.h"
+#ifdef TI_DBG
+#include "DebugTraceXfer_api.h"
+#endif /* TI_DBG */
+#include "osApi.h"
+#include "TNETW_Driver.h"
+#include "recoveryCtrl_API.h"
+#include "HwInit_api.h"
+
+static TI_STATUS TnetwDrv_SetInitParams (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams);
+
+#ifdef GWSI_LIB
+void GWSI_FinalizeDownload(TI_HANDLE hGwsiMgr, TI_STATUS eStatus);
+#endif
+
+void TnetwDrv_TxXferDone (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk);
+void TnetwDrv_TxComplete (TI_HANDLE hTnetwDrv, TxResultDescriptor_t *pTxResultInfo);
+void TnetwDrv_TxXferDebug (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo);
+static void TnetwDrv_ConfigureCb (TI_HANDLE hTnetwDrv);
+static void TnetwDrv_ConfigureCb1 (TI_HANDLE hTnetwDrv);
+
+
+/****************************************************************************/
+
+
+/****************************************************************************/
+/*                      TnetwDrv_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the Module
+ *
+ * INPUTS:  Handle to the OS
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: Handle to the module on success or NULL on failure 
+ ****************************************************************************/
+TI_HANDLE TnetwDrv_Create (TI_HANDLE hOs)
+{
+    TnetwDrv_t *pTnetwDrv;
+
+    /* Allocate the TNETW_Driver module */
+    pTnetwDrv = (TnetwDrv_t *)os_memoryAlloc (hOs, sizeof(TnetwDrv_t));
+    if (pTnetwDrv == NULL)
+        return NULL;
+
+    os_memoryZero (hOs, pTnetwDrv, sizeof(TnetwDrv_t));
+
+    pTnetwDrv->hOs = hOs;
+
+    /* Create the HAL Ctrl module */
+    pTnetwDrv->hHalCtrl = whalCtrl_Create(hOs);
+    if (pTnetwDrv->hHalCtrl == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv whalCtrl_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    pTnetwDrv->hTNETWIF = whalCtrl_GetTnetwifHandle (pTnetwDrv->hHalCtrl);
+
+    /* Create the MAC Services module */
+    pTnetwDrv->hMacServices = MacServices_create(hOs);
+    if (pTnetwDrv->hMacServices == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv MacServices_create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    /* Create the Ctrl module */
+    pTnetwDrv->hCmdQueue = CmdQueue_Create(hOs);
+    if (pTnetwDrv->hCmdQueue == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv CmdQueue_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    /* 
+     * Create the FW-Transfer modules:
+     */
+
+    pTnetwDrv->hTxXfer = txXfer_Create(hOs);
+    if (pTnetwDrv->hTxXfer == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv txXfer_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    pTnetwDrv->hTxResult = txResult_Create(hOs);
+    if (pTnetwDrv->hTxResult == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv txResult_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    pTnetwDrv->hRxXfer = rxXfer_Create(hOs);
+    if (pTnetwDrv->hRxXfer == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv rxXfer_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    pTnetwDrv->hFwEvent = FwEvent_Create(hOs);
+    if (pTnetwDrv->hFwEvent == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv FwEvent_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    pTnetwDrv->hEventMbox = eventMbox_Create(hOs);
+    if (pTnetwDrv->hEventMbox == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv eventMbox_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+#ifdef TI_DBG
+    pTnetwDrv->hDebugTrace = debugTrace_Create(hOs);
+    if (pTnetwDrv->hDebugTrace == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv debugTrace_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+#endif /* TI_DBG */
+
+    pTnetwDrv->hCmdMBox = CmdMBox_Create(hOs);
+    if (pTnetwDrv->hCmdMBox == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv CmdMBox_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    /* 
+     * Create the Data-Services modules:
+     */
+
+    pTnetwDrv->hTxCtrlBlk = txCtrlBlk_Create(hOs);
+    if (pTnetwDrv->hTxCtrlBlk == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv txCtrlBlk_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+    pTnetwDrv->hTxHwQueue = txHwQueue_Create(hOs);
+    if (pTnetwDrv->hTxHwQueue == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv txHwQueue_Create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    pTnetwDrv->hRecoveryCtrl = recoveryCtrl_create(hOs);
+#ifdef USE_RECOVERY
+    if (pTnetwDrv->hRecoveryCtrl == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv recoveryCtrl_create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+#endif /* USE_RECOVERY */
+    pTnetwDrv->hHwInit = hwInit_create(hOs);
+#ifdef USE_RECOVERY
+    if (pTnetwDrv->hHwInit == NULL)
+    {
+        WLAN_OS_REPORT(("TnetwDrv hwInit_create failed!!!\n"));
+        TnetwDrv_Destroy((TI_HANDLE)pTnetwDrv);
+        return NULL;
+    }
+#endif /* USE_RECOVERY */
+    pTnetwDrv->bRecoveryFlag = FALSE; /* init value is not Recovery */
+#endif
+    WLAN_INIT_REPORT (("TnetwDrv_Create: CREATED !!!\n"));
+
+    return (TI_HANDLE)pTnetwDrv;
+}
+
+
+
+/****************************************************************************/
+/*                      TnetwDrv_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Clear The module
+ *
+ * INPUTS:  Handle to the module
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+void TnetwDrv_Destroy (TI_HANDLE hTnetwDrv)
+{
+
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+    
+    WLAN_INIT_REPORT(("TnetwDrv_Destroy !!!\n"));
+    if (pTnetwDrv == NULL) 
+    {
+        return;
+    }
+
+    /* free the hal ctrl */
+    if (pTnetwDrv->hHalCtrl != NULL)
+    {
+        whalCtrl_Destroy(pTnetwDrv->hHalCtrl);
+        pTnetwDrv->hHalCtrl = NULL;
+    }
+    WLAN_INIT_REPORT(("TNETW_Driver_Destroy hHalCtrl released!!!\n"));
+    
+    /* free the MAC Services */
+    if (pTnetwDrv->hMacServices != NULL)
+    {
+        MacServices_destroy(pTnetwDrv->hMacServices);
+        pTnetwDrv->hMacServices = NULL;
+    }
+    WLAN_INIT_REPORT(("TNETW_Driver_Destroy hMacServices released!!!\n"));
+    
+    /*
+     * Free the Ctrl modules
+     */
+    if (pTnetwDrv->hCmdQueue != NULL)
+    {
+        CmdQueue_Destroy(pTnetwDrv->hCmdQueue);
+        pTnetwDrv->hCmdQueue = NULL;
+    }
+
+    /* 
+     * Free the FW-Transfer modules:
+     */
+
+    if (pTnetwDrv->hTxXfer != NULL)
+    {
+        txXfer_Destroy(pTnetwDrv->hTxXfer);
+        pTnetwDrv->hTxXfer = NULL;
+    }
+
+    if (pTnetwDrv->hTxResult != NULL)
+    {
+        txResult_Destroy(pTnetwDrv->hTxResult);
+        pTnetwDrv->hTxResult = NULL;
+    }
+
+    if (pTnetwDrv->hRxXfer != NULL)
+    {
+        rxXfer_Destroy(pTnetwDrv->hRxXfer);
+        pTnetwDrv->hRxXfer = NULL;
+    }
+
+    if (pTnetwDrv->hEventMbox != NULL) 
+    {
+        eventMbox_Destroy(pTnetwDrv->hEventMbox);
+        pTnetwDrv->hEventMbox = NULL;
+    }
+
+#ifdef TI_DBG
+    if (pTnetwDrv->hDebugTrace != NULL) 
+    {
+        debugTrace_Destroy(pTnetwDrv->hDebugTrace);
+        pTnetwDrv->hDebugTrace = NULL;
+    }
+#endif /* TI_DBG */
+
+    if (pTnetwDrv->hFwEvent != NULL)
+    {
+        FwEvent_Destroy(pTnetwDrv->hFwEvent);
+        pTnetwDrv->hFwEvent = NULL;
+    }
+
+    if (pTnetwDrv->hCmdMBox != NULL)
+    {
+        CmdMBox_Destroy(pTnetwDrv->hCmdMBox);
+        pTnetwDrv->hCmdMBox = NULL;
+    }
+
+    /* 
+     * Free the Data-Services modules:
+     */
+
+    if (pTnetwDrv->hTxCtrlBlk != NULL)
+    {
+        txCtrlBlk_Destroy(pTnetwDrv->hTxCtrlBlk);
+        pTnetwDrv->hTxCtrlBlk = NULL;
+    }
+
+    if (pTnetwDrv->hTxHwQueue != NULL)
+    {
+        txHwQueue_Destroy(pTnetwDrv->hTxHwQueue);
+        pTnetwDrv->hTxHwQueue = NULL;
+    }
+    
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    if (pTnetwDrv->hRecoveryCtrl != NULL)
+    {
+        recoveryCtrl_destroy(pTnetwDrv->hRecoveryCtrl);
+        pTnetwDrv->hRecoveryCtrl = NULL;
+    }
+
+    if (pTnetwDrv->hHwInit != NULL)
+    {
+        hwInit_destroy(pTnetwDrv->hHwInit);
+        pTnetwDrv->hHwInit = NULL;
+    }
+#endif
+    
+    /* free the TNETW driver */
+    if ( NULL != pTnetwDrv->pInitTableCopy )
+    {
+        os_memoryFree( pTnetwDrv->hOs, pTnetwDrv->pInitTableCopy, sizeof(TnetwDrv_InitParams_t) );
+        pTnetwDrv->pInitTableCopy = NULL;
+    }
+
+    os_memoryFree(pTnetwDrv->hOs, (TI_HANDLE)pTnetwDrv, sizeof(TnetwDrv_t));
+    pTnetwDrv = NULL;
+    
+    WLAN_INIT_REPORT(("TNETW_Driver_Destroy pTNETW_Driver released!!!\n"));
+    
+    return;
+}
+
+
+/****************************************************************************/
+/*                      TnetwDrv_Init()
+ ****************************************************************************
+ * DESCRIPTION: TNETW Driver Init
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TnetwDrv_Init (TI_HANDLE hTnetwDrv, TI_HANDLE hReport, TI_HANDLE hMemMgr, TI_HANDLE hUser, UINT32 *pFWImage, TnetwDrv_InitParams_t* pInitParams, TnetDrv_callback_t fUserConf)
+{ 
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+    whalCtrl_config_t       whalCtrl_config;
+    TI_STATUS               status;
+
+    pTnetwDrv->bInitSuccess = FALSE;
+    pTnetwDrv->hUser = hUser;
+    pTnetwDrv->fUserConf = fUserConf;
+    pTnetwDrv->hReport = hReport;
+    pTnetwDrv->hMemMgr = hMemMgr;
+    pTnetwDrv->hWhalParams = whalCtrl_GetWhalParams (pTnetwDrv->hHalCtrl);
+    
+    WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
+        ("TnetwDrv_Init %x\n",hReport));
+
+    if (NULL != pInitParams)
+    {       
+        if (OK != TnetwDrv_SetInitParams (hTnetwDrv, (TnetwDrv_InitParams_t *)pInitParams))
+        {
+            TnetwDrv_Destroy (hTnetwDrv);
+            return NOK;
+        }
+    }
+    
+    /* 
+     * Configure the HAL Ctrl 
+     */
+    whalCtrl_config.hMemMgr             = hMemMgr;
+    whalCtrl_config.hReport             = hReport;
+    whalCtrl_config.hFwEvent            = pTnetwDrv->hFwEvent;
+    whalCtrl_config.hRxXfer             = pTnetwDrv->hRxXfer;
+    whalCtrl_config.hTxXfer             = pTnetwDrv->hTxXfer;
+    whalCtrl_config.hTxHwQueue          = pTnetwDrv->hTxHwQueue;
+    whalCtrl_config.hTxResult           = pTnetwDrv->hTxResult;
+    whalCtrl_config.hEventMbox          = pTnetwDrv->hEventMbox;
+
+        /* CB at the end of TnetwDrv_Configure(). not called if no registration was done */
+        pTnetwDrv->fConfigureCmplteteCB     = NULL;
+        pTnetwDrv->hConfigureCompleteOBj    = NULL;
+    pTnetwDrv->fConfigureEndCB = TnetwDrv_ConfigureCb1;
+    pTnetwDrv->fConfigureEndObj= hTnetwDrv;
+    
+    whalCtrl_config.hCmdQueue           = pTnetwDrv->hCmdQueue;
+#ifdef TI_DBG
+    whalCtrl_config.hDebugTrace         = pTnetwDrv->hDebugTrace;
+#endif /* TI_DBG */
+
+    /* Call the config func */
+    if ((status = whalCtrl_Config (pTnetwDrv->hHalCtrl, hTnetwDrv, &whalCtrl_config, pFWImage)) == TNETWIF_ERROR)
+    {
+        WLAN_OS_REPORT(("TNETW_Driver whalCtrl_Config failed!!!\n"));
+        TnetwDrv_Destroy (hTnetwDrv);
+        return NOK;
+    }
+
+    return status;
+}
+
+
+/****************************************************************************
+ * DESCRIPTION: Configure the TNET Driver Module callback
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: OK if succeeded, NOK if failed in HW configuration. 
+ ****************************************************************************/
+void TnetwDrv_ConfigureCb (TI_HANDLE hTnetwDrv)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+    /* Configure the Tx-HW-Queue module */
+    txHwQueue_Config (pTnetwDrv->hTxHwQueue, pTnetwDrv->pInitTableCopy);
+    
+    /* Configure the TX XFER module */
+    txXfer_config(pTnetwDrv->hTxXfer, pTnetwDrv->pInitTableCopy);
+    
+    /* Configure the MAC services */ 
+    MacServices_config (pTnetwDrv->hMacServices, pTnetwDrv->pInitTableCopy);
+    
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    recoveryCtrl_config(pTnetwDrv->hRecoveryCtrl, 
+                        pTnetwDrv->hReport,
+                        pTnetwDrv->hTNETWIF,
+                        pTnetwDrv->hTxXfer,     
+                        pTnetwDrv->hRxXfer,     
+                        pTnetwDrv->hTxResult,   
+                        pTnetwDrv->hMacServices,
+                        pTnetwDrv->hTxCtrlBlk,  
+                        pTnetwDrv->hTxHwQueue,  
+                        pTnetwDrv->hHalCtrl,    
+                        pTnetwDrv->hHwIntr,     
+                        pTnetwDrv->hWhalParams, 
+                        pTnetwDrv->hCmdQueue,   
+                        pTnetwDrv->hFwEvent,    
+                        pTnetwDrv->hCmdMBox,
+                        pTnetwDrv->hHwInit);
+
+    hwInit_config(pTnetwDrv->hHwInit, pTnetwDrv->hReport, pTnetwDrv->hTNETWIF);
+#endif
+    /* Register the Data Path callback functions */
+    TnetwDrv_Register_CB (pTnetwDrv, TNETW_DRIVER_TX_XFER_SEND_PKT_TRANSFER, (void *)TnetwDrv_TxXferDone, hTnetwDrv);
+
+    /* Register the send packet debug callback */
+  #ifdef TI_DBG
+    TnetwDrv_Register_CB (pTnetwDrv, TNETW_DRIVER_TX_XFER_SEND_PKT_DEBUG, (void *)TnetwDrv_TxXferDebug, hTnetwDrv);
+  #endif
+
+    /* Register the send packet complete callback */
+    TnetwDrv_Register_CB (pTnetwDrv, TNETW_DRIVER_TX_RESULT_SEND_PKT_COMPLETE, (void *)TnetwDrv_TxComplete, hTnetwDrv);
+
+    /* Call user application configuration callback */
+    if (pTnetwDrv->fUserConf)
+        (*pTnetwDrv->fUserConf) (pTnetwDrv->hUser);
+
+}
+
+/****************************************************************************
+ * DESCRIPTION: Configure the TNET Driver Module callback
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: OK if succeeded, NOK if failed in HW configuration. 
+ ****************************************************************************/
+void TnetwDrv_ConfigureCb1 (TI_HANDLE hTnetwDrv)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+        /* if the configure complete function was registered, we call it here - end of TnetwDrv_Configure stage */
+    if (pTnetwDrv->fConfigureCmplteteCB) 
+    {
+        pTnetwDrv->fConfigureCmplteteCB(pTnetwDrv->hConfigureCompleteOBj);
+    }   
+
+#ifndef GWSI_LIB
+    /* 
+        * This will be the last thing that will be done here so all the download 
+        * will go back down to HALto send FINISH to TNETWIF where it began 
+        */
+        os_Complete (pTnetwDrv->hOs);    
+#endif
+
+}
+
+
+
+/****************************************************************************
+ * DESCRIPTION: Configure the TNET Driver Module
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: OK if succeeded, NOK if failed in HW configuration. 
+ ****************************************************************************/
+TI_STATUS TnetwDrv_Configure (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+    TnetwDrv_InitParams_t* pInitParam;
+    if (pTnetwDrv->bInitSuccess)
+    {
+        /* If called with init params as null - it means that this is a recovery */    
+        if (NULL != pInitParams)
+        {       
+            if (OK != TnetwDrv_SetInitParams (hTnetwDrv, pInitParams))
+            {
+                return NOK;
+            }
+        }
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+        if(pTnetwDrv->bRecoveryFlag == TRUE)
+            pInitParam = NULL;
+        else
+#endif
+            pInitParam = pTnetwDrv->pInitTableCopy;
+
+
+        /* If it's recovery call function with NULL instead of ini-file params */
+        if (whalCtrl_ConfigHw (pTnetwDrv->hHalCtrl, 
+                               pInitParam, 
+                               (void *)TnetwDrv_ConfigureCb,
+                               hTnetwDrv) != OK)
+        {
+            WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("\n.....WhalCtrl configuration failure \n"));
+            return NOK;
+        }
+
+        return OK;
+    }
+
+    return NOK;
+}
+
+
+/****************************************************************************
+ *                      TnetwDrv_FinalizeDownload()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the remaining initialization after the downloaD HAS FINISHED 
+                Register the ERRORS indications events to the FW
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS TnetwDrv_FinalizeDownload (TI_HANDLE hTnetwDrv)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+    /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
+    WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
+                ("hTNETW_Driver %x!!!!!\n", hTnetwDrv));
+
+    /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
+    WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
+        ("Call MacServices_init!!!!!\n"));
+
+    /*
+     * Initialize the FW-Transfer modules
+     */
+    txXfer_init (pTnetwDrv->hTxXfer, pTnetwDrv->hReport, pTnetwDrv->hTNETWIF, pTnetwDrv->hTxResult);
+    txResult_init (pTnetwDrv->hTxResult, pTnetwDrv->hReport, pTnetwDrv->hTNETWIF, pTnetwDrv->hFwEvent);
+    rxXfer_Config (pTnetwDrv->hRxXfer, pTnetwDrv->hFwEvent, pTnetwDrv->hMemMgr, pTnetwDrv->hReport,pTnetwDrv->hTNETWIF);
+        
+#ifdef TI_DBG
+    debugTrace_Config (pTnetwDrv->hDebugTrace,
+                       pTnetwDrv->hWhalParams,
+                       pTnetwDrv->hReport,
+                       pTnetwDrv->hMemMgr,
+                       pTnetwDrv->hTNETWIF,
+                       pTnetwDrv->hFwEvent);
+#endif /* TI_DBG */
+    
+    /* 
+     * Initialize the MAC Services 
+     */
+    MacServices_init (pTnetwDrv->hMacServices,
+                      pTnetwDrv->hReport,
+                      pTnetwDrv->hHalCtrl);
+
+    /*
+     * Initialize the Data-Services modules
+     */
+    txCtrlBlk_init (pTnetwDrv->hTxCtrlBlk, pTnetwDrv->hReport);
+    txHwQueue_init (pTnetwDrv->hTxHwQueue, pTnetwDrv->hReport, pTnetwDrv->hWhalParams);
+
+    /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
+    WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
+        ("Before sending the Init Complet callback !!!!!\n"));
+
+    /* Sign that init has succeeded */
+    pTnetwDrv->bInitSuccess = TRUE;    
+
+    /* When working with GWSI Call the Init Complete callback */
+#ifdef GWSI_LIB
+    /*
+     * The callback function does not need the handle of the GWSI 
+     * since it takes it from the global handle 
+     */
+    GWSI_FinalizeDownload (pTnetwDrv->hUser, OK);
+    /* 
+     * When working with CORE call the os_Init_Complete 
+     * that will release the OS semaphore that the
+     * user is lock on it in the esta_drb to go on call the next stage 
+     */
+#else 
+    /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
+    WLAN_REPORT_INIT(pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG,
+        ("Call os_Complete !!!!!\n"));
+    
+    /* Start configuring driver */
+    if (TnetwDrv_Configure (hTnetwDrv, NULL) != OK)
+    {
+        WLAN_REPORT_ERROR (pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                           ("TnetwDrv_FinalizeDownload: configuration failure!\n"));
+    }
+
+#endif
+
+    return TNETWIF_COMPLETE;
+}
+
+
+/****************************************************************************
+ *                      TnetwDrv_FinalizeOnFailue()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the initialization upon failure 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS TnetwDrv_FinalizeOnFailure (TI_HANDLE hTNETW_Driver)
+{
+    TnetwDrv_t  *pTnetwDrv = (TnetwDrv_t *)hTNETW_Driver;
+
+#ifdef GWSI_LIB
+
+    /* Stop Init phase of GWSI and return TNETWIF_ERROR */
+    GWSI_FinalizeDownload (pTnetwDrv->hUser, TNETWIF_ERROR);
+
+    /* When working with CORE call the os_Init_Complete that will release the OS semaphore taht the
+    user is lock on it in the esta_drb to go on call the next stage */
+
+#else 
+
+    /* Here at the end call the Initialize Complete callback that will release the user Init semaphore */
+    WLAN_REPORT_INIT (pTnetwDrv->hReport, HAL_CTRL_MODULE_LOG, ("Call os_Complete !!!!!\n"));           
+
+    /* 
+     * This will be the last thing that will be done here so all the download 
+     * will go back down to HAL to send FINISH to TNETWIF where it began 
+     */
+    os_Complete (pTnetwDrv->hOs);    
+
+#endif
+
+    return TNETWIF_COMPLETE;
+}
+
+
+/****************************************************************************/
+/*                      TNETW_Driver_Register_CB()
+ ****************************************************************************
+ * DESCRIPTION: Register the MAC Services and the HAL modules callbacks
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:
+ *
+ * RETURNS: 
+ ****************************************************************************/
+void TnetwDrv_Register_CB (TI_HANDLE hTnetwDrv,tiUINT32 EventID,void *CBFunc, void *pData)
+{
+
+    TnetwDrv_t * pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+    WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG, ("TnetwDrv_Register_CB (Value = 0x%x)\n", EventID));
+
+    /* First detect which module is the owner */
+    switch((tiUINT16)(EventID & TNETW_DRIVER_CB_MODULE_OWNER_MASK))
+    {
+
+    case  TNETW_DRIVER_TX_XFER_OWNER:
+        EventID &= TNETW_DRIVER_CB_TYPE_MASK;
+        WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_TX_XFER_OWNER\n"));
+        txXfer_RegisterCB(pTnetwDrv->hTxXfer, EventID, CBFunc, pData);
+        break;
+
+    case  TNETW_DRIVER_TX_RESULT_OWNER:
+        EventID &= TNETW_DRIVER_CB_TYPE_MASK;
+        WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_TX_RESULT_OWNER\n"));
+        txResult_RegisterCB(pTnetwDrv->hTxResult, EventID, CBFunc, pData);
+        break;
+
+    case TNETW_DRIVER_RX_XFER_OWNER:
+        EventID &= TNETW_DRIVER_CB_TYPE_MASK;
+        WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_RX_XFER_OWNER\n"));
+        rxXfer_Register_CB(pTnetwDrv->hRxXfer, EventID,CBFunc,pData);
+        break;
+
+    case TNETW_DRIVER_HAL_CTRL_OWNER:
+        EventID &= TNETW_DRIVER_CB_TYPE_MASK;
+        whalCtrl_Register_CB(pTnetwDrv->hHalCtrl, EventID,CBFunc,pData);
+        break;
+    case TNETW_DRIVER_MAC_SERVICES_OWNER:
+        switch (EventID & TNETW_DRIVER_CB_TYPE_MASK)
+        {
+        case HAL_EVENT_SCAN_CMPLT:
+            MacServices_scanSRV_registerScanCompleteCB(pTnetwDrv->hMacServices, (scan_srvCompleteCB_t)CBFunc, pData);
+            break;
+        default:
+            WLAN_REPORT_WARNING(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TNETW_DRIVER_MAC_SERVICES_OWNER - Illegal value\n"));        
+        }
+        break;
+
+    case TNETW_DRIVER_TWD_OWNER:    
+        WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB: TNETW_DRIVER_TWD_OWNER\n"));
+        pTnetwDrv->fConfigureCmplteteCB  = (TnetDrv_callback_t)CBFunc;
+        pTnetwDrv->hConfigureCompleteOBj = (TI_HANDLE)pData;    
+        break;
+
+    default:
+        if (EventID == HAL_INTERNAL_EVENT_FAILURE)
+        {
+
+
+            /* register the Hal failure event callback  including the RX
+                 in the Hal Cttl the errors are :   
+                MBOX_FAILURE,
+                    BUS_ERROR,
+                DEVICE_ERROR,
+                DISCONNECT_TIMEOUT,*/
+                
+                
+            
+            EventID &= TNETW_DRIVER_CB_TYPE_MASK;
+            whalCtrl_Register_CB(pTnetwDrv->hHalCtrl, EventID,CBFunc,pData);
+
+            /* register the Elp controller failure event callback to the TNET interface
+                HW_AWAKE_FAILURE*/
+            TNETWIF_RegisterFailureEventCB(pTnetwDrv->hTNETWIF,CBFunc,pData);
+            
+            /* register the Mac services failure events callbacks 
+                POWER_SAVE_FAILURE,
+                MEASUREMENT_FAILURE,
+                NO_SCAN_COMPLETE_FAILURE,*/
+            MacServices_registerFailureEventCB(pTnetwDrv->hMacServices, CBFunc, pData);
+
+
+            /* register the TX failure call back in the  Xfer
+                TX_STUCK,*/
+            txXfer_RegisterFailureEventCB(pTnetwDrv->hTxXfer, CBFunc, pData);
+            
+            
+        }
+        else
+        WLAN_REPORT_WARNING(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,("TnetwDrv_Register_CB - Illegal value\n"));       
+
+    }
+    return;
+}
+
+/****************************************************************************/
+/*                      TnetwDrv_SetInitParams()
+ ****************************************************************************/
+static TI_STATUS TnetwDrv_SetInitParams (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams)
+{
+    TnetwDrv_t * pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;        
+    TnetwDrv_InitParams_t *pInitTableCopy;
+    UINT32       index;
+    
+    pInitTableCopy = pTnetwDrv->pInitTableCopy = os_memoryAlloc (pTnetwDrv->hOs, sizeof(TnetwDrv_InitParams_t));
+    if (pTnetwDrv->pInitTableCopy != NULL)
+    {
+        os_memoryZero (pTnetwDrv->hOs, pTnetwDrv->pInitTableCopy, sizeof(TnetwDrv_InitParams_t));
+        /* Copy the init info to the buffer */
+        os_memoryCopy (pTnetwDrv->hOs, pTnetwDrv->pInitTableCopy, pInitParams, sizeof(TnetwDrv_InitParams_t));
+        /* Change the Severity table to character */ 
+        for (index = 0; index < sizeof(((report_t *)pTnetwDrv->hReport)->SeverityTable); index++)
+        {
+            pInitTableCopy->reportParams.SeverityTable[index] += '0';
+        }
+        /* Change the module table to character */ 
+        for (index = 0; index < sizeof(((report_t *)pTnetwDrv->hReport)->ModuleTable); index++)
+        {
+            pInitTableCopy->reportParams.ModuleTable[index] += '0';
+        }
+    }   
+    else
+    {
+        WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                          ("TnetwDrv_SetInitParams: unable to allocate init params buffer!\n") );
+        return NOK;
+    }
+
+    return OK;
+}
+
+/****************************************************************************/
+/*                      TnetwDrv_GetInitParams()
+ ****************************************************************************/
+void TnetwDrv_GetInitParams (TI_HANDLE hTnetwDrv, UINT8 *pcommand, UINT16 *OutBufLen)
+{   
+    TnetwDrv_t * pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;        
+
+    if (pTnetwDrv->pInitTableCopy)
+    {
+        *(UINT32 *)pcommand = sizeof(TnetwDrv_InitParams_t);
+        pcommand += sizeof(UINT32);
+        os_memoryCopy(NULL, (void *)pcommand, (void *)pTnetwDrv->pInitTableCopy, sizeof(TnetwDrv_InitParams_t));
+    }
+    else
+    {
+        /* The table information is not available */
+        *(UINT32 *)pcommand = 0;
+        WLAN_OS_REPORT(("TNETW_Driver_GetInitParams :ERROR Getting Buffer for the INI File !!!\n"));
+    }              
+
+    *OutBufLen = (sizeof(TnetwDrv_InitParams_t) + sizeof(UINT32));
+}
+
+
+
+/****************************************************************************/
+/*                      TnetwDrv_PrintInfo()
+ ****************************************************************************
+ * DESCRIPTION:  Call the requested print function.
+ ****************************************************************************/
+void  TnetwDrv_PrintInfo (TI_HANDLE hTnetwDrv, TnetwDrv_PrintInfoType_e printInfo)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+    switch(printInfo) 
+    {
+        case TNETW_DRV_PRINT_TX_CTRL_BLK_TBL:
+            txCtrlBlk_printTable(pTnetwDrv->hTxCtrlBlk);
+            break;
+
+        case TNETW_DRV_PRINT_TX_HW_QUEUE_INFO:
+            txHwQueue_printInfo(pTnetwDrv->hTxHwQueue);
+            break;
+
+        case TNETW_DRV_PRINT_TX_XFER_INFO:
+            txXfer_printInfo(pTnetwDrv->hTxXfer);
+            break;
+
+        case TNETW_DRV_PRINT_TX_RESULT_INFO:
+            txResult_printInfo(pTnetwDrv->hTxResult);
+            break;
+
+        case TNETW_DRV_CLEAR_TX_RESULT_INFO:
+            txResult_clearInfo(pTnetwDrv->hTxResult);
+            break;
+
+        default:
+            WLAN_REPORT_ERROR( pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                               ("$s: invalid print info request code: %d\n", __FUNCTION__, printInfo) );
+    }
+}
+
+
+
+
+/****************************************************************************/
+/*                      TnetwDrv_TEMP_GetHandles()
+ ****************************************************************************
+ * DESCRIPTION:  
+       TEMPORARY!! - untill the new TNETW-Driver architecture is completed!!
+
+       In the new architecture all external calls to the driver will be through  
+         the hTnetwDrv handle.
+
+       Called by the driver creation process.
+       Gets the TNETW-Driver modules handles needed externally.
+****************************************************************************/
+void  TnetwDrv_TEMP_GetHandles(TI_HANDLE hTnetwDrv, TI_HANDLE *pHalCtrl, TI_HANDLE *pMacServices)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+    *pHalCtrl       = pTnetwDrv->hHalCtrl;
+    *pMacServices   = pTnetwDrv->hMacServices;
+}
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+/****************************************************************************/
+/*                      TnetwDrv_StartRecovery()
+ ****************************************************************************
+ * DESCRIPTION: 
+          API function called by RecoverMgr to start TWD recovery process 
+****************************************************************************/
+void TnetwDrv_StartRecovery(TI_HANDLE hTnetwDrv, void *endOfRecoveryCB, TI_HANDLE hRecoveryMgr)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+    pTnetwDrv->bRecoveryFlag = TRUE; 
+    recoveryCtrl_restartTWD(pTnetwDrv->hRecoveryCtrl, endOfRecoveryCB, hRecoveryMgr);
+
+}
+
+/****************************************************************************/
+/*                      TnetwDrv_InitHw_FinalizeDownload()
+ ****************************************************************************
+ * DESCRIPTION: 
+          API function called by RecoverMgr to start TWD recovery process 
+****************************************************************************/
+TI_STATUS TnetwDrv_InitHw_FinalizeDownload(TI_HANDLE hTnetwDrv)
+{
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+    if (pTnetwDrv->bRecoveryFlag)
+    {
+        pTnetwDrv->bRecoveryFlag = FALSE;
+        return InitHw_FinalizeDownload(pTnetwDrv->hHwInit);
+    }
+    else
+    {
+        return TnetwDrv_FinalizeDownload(hTnetwDrv);
+    }
+}
+#endif
+
+#ifdef GWSI_SPI_TEST
+
+TI_HANDLE TnetwDrv_GetTnetwifHandle (TI_HANDLE hTnetwDrv)
+{
+       return ((TnetwDrv_t *)hTnetwDrv)->hTNETWIF;
+}
+
+#endif /* GWSI_SPI_TEST */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.h
new file mode 100644 (file)
index 0000000..e5a1e89
--- /dev/null
@@ -0,0 +1,152 @@
+/** \file TNETW_Driver.h
+ *  \brief TNETW Driver include file
+ *
+ *  \see TNETW_Driver.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   TNETW_Driver.h                                              */
+/*    PURPOSE:  TNETW Driver include file                                   */
+/*                                                                          */
+/***************************************************************************/
+
+
+#ifndef TNETW_DRIVER_H
+#define TNETW_DRIVER_H
+
+
+#include "TNETW_Driver_types.h"
+#include "whalCtrl_api.h"
+
+
+
+#define TNETW_DRIVER_CB_MODULE_OWNER_MASK   0xff00
+#define TNETW_DRIVER_CB_TYPE_MASK           0x00ff
+
+#define SHIFT_BETWEEN_TU_AND_USEC  10  /* Shift factor to conver between TU (1024 uSec) and uSec. */
+
+
+/* TNETW-Driver object */
+typedef struct T_TnetwDrv_t
+{
+    TI_HANDLE           hOs;
+    TI_HANDLE           hUser;
+    TI_HANDLE           hReport;
+    TI_HANDLE           hMemMgr;
+    TI_HANDLE           hMacServices;
+    TI_HANDLE           hHalCtrl;
+    TI_HANDLE           hTxCtrlBlk;
+    TI_HANDLE           hTxHwQueue;
+    TI_HANDLE           hTNETWIF;
+    TI_HANDLE           hHwIntr;
+    TI_HANDLE           hWhalParams;
+
+    /* 
+     * Ctrl modules:
+     */
+    TI_HANDLE           hCmdQueue;
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    TI_HANDLE           hRecoveryCtrl;
+#endif
+
+    /* 
+     * FW-Transfer modules:
+     */
+    TI_HANDLE           hTxXfer;
+    TI_HANDLE           hTxResult;
+    TI_HANDLE           hRxXfer;
+    TI_HANDLE           hFwEvent;
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    TI_HANDLE           hHwInit;
+    BOOL                bRecoveryFlag;/*if true it means that we are in recovery process*/
+#endif
+    TI_HANDLE           hCmdMBox;
+    TI_HANDLE           hEventMbox;
+
+    void               *pInitTableCopy;
+
+    /* Init success flag */
+    BOOL                bInitSuccess;
+
+    /* User application configuration callback */
+    TnetDrv_callback_t  fUserConf;
+
+    /* CB at the end of TnetwDrv_Configure(). not called if no registration was done */
+    TnetDrv_callback_t  fConfigureCmplteteCB;
+    TI_HANDLE           hConfigureCompleteOBj;  
+
+    /* CB at the end of TnetwDrv_Configure(). not called if no registration was done */
+    TnetDrv_callback_t      fConfigureEndCB;
+    TI_HANDLE           fConfigureEndObj;   
+
+#ifdef TI_DBG  /* Just for debug. */
+    TI_HANDLE           hDebugTrace;
+
+    UINT32 dbgPktSeqNum[MAX_NUM_OF_TX_QUEUES];          /* Packets sequence counter per queue. */
+    /* Tx counters per queue:*/
+    UINT32 dbgCountSentPackets[MAX_NUM_OF_TX_QUEUES];   /* Count packets sent from upper driver. */
+    UINT32 dbgCountQueueAvailable[MAX_NUM_OF_TX_QUEUES];/* Count packets sent and queue not busy. */
+    UINT32 dbgCountXferDone[MAX_NUM_OF_TX_QUEUES];      /* Count XferDone return values from Xfer. */
+    UINT32 dbgCountXferSuccess[MAX_NUM_OF_TX_QUEUES];   /* Count Success return values from Xfer. */
+    UINT32 dbgCountXferPending[MAX_NUM_OF_TX_QUEUES];   /* Count Pending return value from Xfer. */
+    UINT32 dbgCountXferError[MAX_NUM_OF_TX_QUEUES];     /* Count Error return value from Xfer. */
+    UINT32 dbgCountXferDoneCB[MAX_NUM_OF_TX_QUEUES];    /* Count XferDone callback calls. */
+    UINT32 dbgCountTxCompleteCB[MAX_NUM_OF_TX_QUEUES];  /* Count TxComplete callback calls. */
+#endif
+    
+} TnetwDrv_t;
+
+
+void TnetwDrv_TxXferDone(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk);
+void TnetwDrv_TxComplete(TI_HANDLE hTnetwDrv, TxResultDescriptor_t *pTxResultInfo);
+void TnetwDrv_TxXferDebug (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo);
+void TnetwDrv_RecoveryCtrlBlk(TI_HANDLE hTnetwDrv);
+
+
+/* External Functions Prototypes */
+
+void  SendPacketTransfer (TI_HANDLE hUser, UINT32 aPacketId);
+void  SendPacketDebug (TI_HANDLE hUser, UINT32 aPacketId, UINT32 uDebugInfo);
+void  SendPacketComplete (TI_HANDLE hUser, systemStatus_e aStatus, UINT32 aPacketId, UINT32 aRate, 
+                                 UINT8 aAckFailures, UINT32 durationInAir, UINT32 fwHandlingTime, UINT32 mediumDelay);
+
+
+
+
+#endif /* TNETW_DRIVER_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver_Tx.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver_Tx.c
new file mode 100644 (file)
index 0000000..f2a23cc
--- /dev/null
@@ -0,0 +1,584 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:   TNETW_Driver_Tx.c
+ *
+ *   PURPOSE:  TNETW_Driver Tx API functions needed externally to the driver.
+ *
+ ****************************************************************************/
+
+#include "whalParams.h"
+#include "report.h"
+#include "TNETW_Driver_api.h"
+#include "txCtrlBlk_api.h"
+#include "txHwQueue_api.h"
+#include "txXfer_api.h"
+#include "txResult_api.h"
+#include "TNETW_Driver.h"
+
+
+static systemStatus_e ConvertTxResultStatus(TxDescStatus_enum txResultStatus);
+
+
+/****************************************************************************
+ *                                     Tx Control Block API functions                                                  *
+ ****************************************************************************/
+
+txCtrlBlkEntry_t *TnetwDrv_txCtrlBlk_alloc(TI_HANDLE hTnetwDrv)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       return txCtrlBlk_alloc(pTnetwDrv->hTxCtrlBlk);
+}
+
+
+void TnetwDrv_txCtrlBlk_free(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pCurrentEntry)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       txCtrlBlk_free(pTnetwDrv->hTxCtrlBlk, pCurrentEntry);
+}
+
+
+txCtrlBlkEntry_t *TnetwDrv_txCtrlBlk_GetPointer(TI_HANDLE hTnetwDrv, UINT8 descId)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       return txCtrlBlk_GetPointer(pTnetwDrv->hTxCtrlBlk, descId);
+}
+
+
+
+/****************************************************************************
+ *                                             Tx HW Queue API functions                                                       *
+ ****************************************************************************/
+
+TI_STATUS  TnetwDrv_txHwQueue_alloc(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       return txHwQueue_alloc(pTnetwDrv->hTxHwQueue, pPktCtrlBlk);
+}
+
+
+TI_STATUS  TnetwDrv_txHwQueue_free(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       return txHwQueue_free(pTnetwDrv->hTxHwQueue, pPktCtrlBlk);
+}
+
+
+UINT8  TnetwDrv_txHwQueue_GetUsedHwBlks(TI_HANDLE hTnetwDrv, int TxQid)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       return txHwQueue_GetUsedHwBlks(pTnetwDrv->hTxHwQueue, TxQid);
+}
+
+
+
+/****************************************************************************
+ *                                                     Tx Xfer API functions                                                   *
+ ****************************************************************************/
+
+systemStatus_e TnetwDrv_txXfer_sendPacket(TI_HANDLE hTnetwDrv, 
+                               const void      *aFrame,                /* Pointer to the packet content. points to */
+                                            /* the place that the actual packet begins. */
+                                            /* a size of TX_TOTAL_OFFSET_BEFORE_DATA    */
+                                            /* must be saved before that pointer        */
+                               UINT16          aLength,                /* MSDU length from first byte of MAC           */
+                                                                                       /*   header to last byteof frame body.          */
+                               UINT8           aQueueId,               /* Tx queue as defined in ConfigureQueue.       */
+                               UINT8           aTxRateClassId, /* Tx rate class ID     defined in txRatePolicy.*/
+                               UINT16          aMaxTransmitRate,/* A bit mask that specifies the initial       */
+                                                                                       /*     (highest) rate to use.                           */
+                               BOOL            aMore,                  /* Tells if there is another packet     coming  */
+                                                                                       /*   shortly after this one.                            */
+                               UINT32          aPacketId,              /* Packet identifier used as a context by       */
+                                                                                       /*   the host driver.                                   */
+                               UINT8          aPowerLevel,     /* Transmission power level.                            */
+                               UINT32          aExpiryTime,    /* Time left for this MSDU to live.                     */
+                               void                 *aReserved)        /* Optional parameters pointer.                         */
+
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+       TxDescCtrl_t txAttr, *pTxAttr = &txAttr;  /* A union for setting the txAttr bit fields. */
+    dot11_header_t      *pDot11Hdr;
+       systemStatus_e      status;
+       txCtrlBlkEntry_t    *pPktCtrlBlk;
+    WhalParams_T *pWhalParams = (WhalParams_T *)(pTnetwDrv->hWhalParams);
+    BOOL                bIsMultiCastAndIBSS; /* used for the Ack policy */
+       
+#ifdef TI_DBG
+       /* If queue number is invalid return ERROR. */
+       if (aQueueId >= MAX_NUM_OF_TX_QUEUES)
+       {
+               WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                       ("TnetwDrv_txXfer_sendPacket(): Invalid aQueueId = %d !!!\n", aQueueId));
+               return SEND_PACKET_ERROR;
+       }
+#endif
+
+       /*****************************************************************************************/
+       /*  1) Allocates a Control-Block for the packet Tx parameters and descriptor.            */
+       /*****************************************************************************************/
+
+       pPktCtrlBlk = TnetwDrv_txCtrlBlk_alloc(pTnetwDrv);
+
+#ifdef TI_DBG
+       pTnetwDrv->dbgCountSentPackets[aQueueId]++;     /* Count packets sent from upper driver. */
+#endif 
+       /* If null entry (not expected to happen) return ERROR. */
+       if (!pPktCtrlBlk)
+       {
+#ifdef TI_DBG
+               WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                       ("TnetwDrv_txXfer_sendPacket(): Tx Ctrl-Blk allocation failed!!!\n"));
+#endif
+               return SEND_PACKET_ERROR;
+       }
+       
+       /*****************************************************************************************/
+       /*  2) Set the packet control block parameters (including descriptor structure).         */
+       /*****************************************************************************************/
+       
+       /* Note that the following params are currently not used:       aMore, aPowerLevel, aReserved. */
+       
+       /* Note that the following descriptor params are for future use, so they are left zeroed:
+                pktType and xferPadding fields in txAttr, and tid. */
+
+       /* Note that the other params are set later in the Tx process (e.g. fragThresh and numMemBlks). */
+
+    /* aFrame points to the start of the data, but we need to reserve place for descriptor + TNETWIF_WRITE_OFFSET_BYTES */
+       pPktCtrlBlk->txPktParams.pFrame = (void*)((UINT8 *)aFrame - TX_TOTAL_OFFSET_BEFORE_DATA);
+
+       pPktCtrlBlk->txDescriptor.length = aLength;
+       pPktCtrlBlk->txDescriptor.xmitQueue = aQueueId;
+       pPktCtrlBlk->txDescriptor.rate = aMaxTransmitRate;
+       pPktCtrlBlk->txPktParams.packetId = aPacketId;
+       pPktCtrlBlk->txDescriptor.expiryTime = aExpiryTime << SHIFT_BETWEEN_TU_AND_USEC;  /* Convert TUs to microseconds. */
+
+       pDot11Hdr = (dot11_header_t*)(aFrame); /* aFrame points to the start of the data */
+       pPktCtrlBlk->txPktParams.headerFrameCtrl = pDot11Hdr->fc;  /* Save frame-control field from MAC header. */
+
+       /* Set descriptor control bit-mask fields and write the whole word to the descriptor. */
+       *(uint16 *)pTxAttr = 0; /* Clear temporary union. */
+       txAttr.ratePolicy = aTxRateClassId;
+
+    /* Configure the Ack policy */
+    bIsMultiCastAndIBSS = ((BSS_INDEPENDENT == (bssType_e)(whal_ParamsGetReqBssType(pWhalParams)))
+                            && (MAC_MULTICAST(GET_DA_FROM_DOT11_HEADER_T(pDot11Hdr))));
+    txAttr.ackPolicy = TnetwDrv_txGetAckPolicy(pTnetwDrv, aQueueId , bIsMultiCastAndIBSS);
+
+       if (IS_QOS_FRAME(pDot11Hdr->fc))  /* Check if frame is QoS-Data or QoS-Null. */
+               txAttr.qosFrame = 1;
+
+       /* if this is a management frame, request immediate TX complete indication */
+       if ( (pDot11Hdr->fc & DOT11_FC_TYPE_MASK) == DOT11_FC_TYPE_MGMT )
+       {
+               txAttr.txCmpltRequired = 1;
+       }
+
+       pPktCtrlBlk->txDescriptor.txAttr = *(uint16 *)pTxAttr; 
+
+       pPktCtrlBlk->txPktParams.flags = 0; 
+
+
+       /************************************************************************************************/
+       /*  3) Call HwQueue for Hw resources allocation. If not available free CtrlBlk and return BUSY. */
+       /************************************************************************************************/
+
+       /* Note that the HwQueue calls first the fragThreshold and numMemBlks calculation. */
+
+       if ( TnetwDrv_txHwQueue_alloc(pTnetwDrv, pPktCtrlBlk) != OK )
+       {
+               TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
+               return SEND_PACKET_BUSY;
+       }
+
+#ifdef TI_DBG  
+       /* Just for debug, write per queue sequence number to packet ctrl-blk (after allocation success!). */
+       pTnetwDrv->dbgPktSeqNum[aQueueId]++;
+       pPktCtrlBlk->txPktParams.dbgPktSeqNum = pTnetwDrv->dbgPktSeqNum[aQueueId];
+
+       pTnetwDrv->dbgCountQueueAvailable[aQueueId]++;  /* Count packets sent and queue not busy. */
+#endif
+       
+
+       /*****************************************************************************************/
+       /*  4) Copy the descriptor to the frame .                      */
+       /*****************************************************************************************/
+
+    os_memoryCopy(pTnetwDrv->hOs, (void *)((UINT8*)aFrame - sizeof(DbTescriptor)), &(pPktCtrlBlk->txDescriptor), sizeof(DbTescriptor));
+
+
+       /*****************************************************************************************/
+       /*  5) Call the Tx-Xfer to start packet transfer to the FW and return its result.        */
+       /*****************************************************************************************/
+       
+       status = txXfer_sendPacket(pTnetwDrv->hTxXfer, pPktCtrlBlk);
+       
+       /* If the packet was transfered in this context and Tx-complete already occured, free the ctrl-blk. */
+       if (status == SEND_PACKET_XFER_DONE)
+       {
+               if (pPktCtrlBlk->txPktParams.flags & TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED)
+                       TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
+               else
+                       pPktCtrlBlk->txPktParams.flags |= TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED;
+       }
+
+#ifdef TI_DBG  
+       if (status == SEND_PACKET_XFER_DONE)
+               pTnetwDrv->dbgCountXferDone[aQueueId]++;        
+       else if (status == SEND_PACKET_SUCCESS)
+               pTnetwDrv->dbgCountXferSuccess[aQueueId]++;     
+       else if (status == SEND_PACKET_PENDING)
+               pTnetwDrv->dbgCountXferPending[aQueueId]++;     
+       else
+               pTnetwDrv->dbgCountXferError[aQueueId]++;       
+#endif
+       
+
+       return status;
+}
+
+
+
+
+/****************************************************************************
+ *                             Tx API functions needed for GWSI interface                                      *
+ ****************************************************************************/
+
+UINT8  TnetwDrv_txGetAckPolicy(TI_HANDLE hTnetwDrv, int TxQid ,  BOOL bIsMultiCastAndIBSS)
+{
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+       WhalParams_T *pWhalParams = (WhalParams_T *)(pTnetwDrv->hWhalParams);
+
+    /* If we are in IBSS and we are transmitting a Multicast/Broadcast frame -> we don't expect an Ack packet */
+    if (bIsMultiCastAndIBSS)
+    {
+        return ACK_POLICY_NO_ACK;
+    }
+
+       return (pWhalParams->QueuesParams.queues[TxQid].ackPolicy);
+}
+
+/*************************************************************************
+*                        TnetwDrv_TxXferDone                                 *
+**************************************************************************
+* DESCRIPTION:  
+  ============
+       Called  upon Xfer-Done of transmitted packet.
+       Calls the upper driver's Xfer-Done handler.
+
+*
+* INPUT:     hDummyHandle - Just to support the CB API.
+*                       pPktCtrlBlk -  The packet's control block pointer.  
+*              
+* OUTPUT:
+*
+* RETURN:       
+
+*************************************************************************/
+void TnetwDrv_TxXferDone(TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+       /* Make a working copy of TNETDriver Handle */
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+
+#ifdef TI_DBG
+       pTnetwDrv->dbgCountXferDoneCB[pPktCtrlBlk->txDescriptor.xmitQueue]++;
+#endif 
+       /* If the pointed entry is already free, print error and exit (not expected to happen). */
+       if (pPktCtrlBlk->pNextFreeEntry != NULL)
+       {
+#ifdef TI_DBG  
+               WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                       ("TnetwDrv_TxXferDone(): Pkt already free!!, DescID=%d, dbgPktSeqNum=%d, flags=%d, packetId=0x%x, Queue=%d\n", 
+                       pPktCtrlBlk->txDescriptor.descID, pPktCtrlBlk->txPktParams.dbgPktSeqNum, pPktCtrlBlk->txPktParams.flags, 
+                       pPktCtrlBlk->txPktParams.packetId, pPktCtrlBlk->txDescriptor.xmitQueue));
+#endif                 
+               return;
+       }
+
+       /* If Tx-complete already occurred, free the ctrl-blk. */
+       /* Note that this may happen when the Xfer-SM delays the Xfer-Done (for pipeline sequence). */
+       if (pPktCtrlBlk->txPktParams.flags & TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED)
+               TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
+       else
+               pPktCtrlBlk->txPktParams.flags |= TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED;
+       
+       /* Call the upper driver's Xfer-Done handler with the packet-ID. */
+       /* Note that depending on the type of compilation, the upper layers vary: */
+       /* It may be either CoreAdaptTx or GWSIAdaptTx */
+       /* Both functions are called the same */
+       SendPacketTransfer (pTnetwDrv->hUser, pPktCtrlBlk->txPktParams.packetId);
+}
+
+
+
+/*************************************************************************
+*                        TnetwDrv_TxComplete                                 *
+**************************************************************************
+* DESCRIPTION:  
+  ============
+       Called upon Tx-complete of transmitted packet.
+       Handles it as follows:
+       1) Update the HwQueue to free queue resources.
+       2) Call the upper driver's tx-complete handler.
+       3) Free the packet's Control-Block if Xfer-Done already occured.
+
+*
+* INPUT:   hDummyHandle -  Just to support the CB API.
+*                 pTxResultInfo - The packet's Tx result information.    
+*              
+* OUTPUT:
+*
+* RETURN:       
+
+*************************************************************************/
+void TnetwDrv_TxComplete(TI_HANDLE hTnetwDrv, TxResultDescriptor_t *pTxResultInfo)
+{
+       txCtrlBlkEntry_t *pPktCtrlBlk;
+       /* Make a working copy of TNETDriver Handle */
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+
+       /* Get the packet's control block pointer by the descId index. */
+       pPktCtrlBlk = TnetwDrv_txCtrlBlk_GetPointer(pTnetwDrv, pTxResultInfo->descID);
+
+#ifdef TI_DBG
+       WLAN_REPORT_INFORMATION(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+               ("TnetwDrv_TxComplete(): DescID=%d, dbgPktSeqNum=%d, flags=%d, packetId=0x%x, Queue=%d\n", 
+               pTxResultInfo->descID, pPktCtrlBlk->txPktParams.dbgPktSeqNum, pPktCtrlBlk->txPktParams.flags, 
+               pPktCtrlBlk->txPktParams.packetId, pPktCtrlBlk->txDescriptor.xmitQueue));
+
+       pTnetwDrv->dbgCountTxCompleteCB[pPktCtrlBlk->txDescriptor.xmitQueue]++;
+#endif 
+       /* If the pointed entry is already free, print error and exit (not expected to happen). */
+       if (pPktCtrlBlk->pNextFreeEntry != NULL)
+       {
+#ifdef TI_DBG  
+               WLAN_REPORT_ERROR(pTnetwDrv->hReport, TNETW_DRV_MODULE_LOG,
+                       ("TnetwDrv_TxComplete(): Pkt already free!!, DescID=%d, dbgPktSeqNum=%d, flags=%d, packetId=0x%x, Queue=%d\n", 
+                       pTxResultInfo->descID, pPktCtrlBlk->txPktParams.dbgPktSeqNum, pPktCtrlBlk->txPktParams.flags, 
+                       pPktCtrlBlk->txPktParams.packetId, pPktCtrlBlk->txDescriptor.xmitQueue));
+#endif                 
+               return;
+       }
+
+       /* Update the HwQueue to free queue resources. */
+       TnetwDrv_txHwQueue_free(pTnetwDrv, pPktCtrlBlk);
+
+       /* @@@ Note: Add Security Sequence Number handling. */
+       /* Update the TKIP/AES sequence-number according to the Tx data packet security-seq-num. */
+       /* Note: The FW always provides the last used seq-num so no need to check if the current 
+                        packet is data and WEP is on. */
+       whalCtrl_updateSecuritySeqNum(pTnetwDrv->hHalCtrl, pTxResultInfo->lsbSecuritySequenceNumber);
+
+       /* Call the upper driver's tx-complete handler. */
+       /* Note that depending on the type of compilation, the upper layeres varry: */
+       /* It may be either CoreAdaptTx or GWSIAdaptTx */
+       /* Both functions are called the same */
+       SendPacketComplete (pTnetwDrv->hUser,
+                        ConvertTxResultStatus((TxDescStatus_enum)pTxResultInfo->status), 
+                                           pPktCtrlBlk->txPktParams.packetId, 
+                                           pTxResultInfo->actualRate,
+                                           pTxResultInfo->ackFailures,
+                                           (UINT32)pTxResultInfo->mediumUsage,
+                                           pTxResultInfo->fwHandlingTime,
+                                           pTxResultInfo->mediumDelay);
+
+       /* If Xfer-Done already occured, free the ctrl-blk (otherwise Xfer-Done will do it). */
+       /* Note that the Xfer-SM may delay the Xfer-Done (for pipeline sequence). */
+       if (pPktCtrlBlk->txPktParams.flags & TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED)
+               TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
+       else
+               pPktCtrlBlk->txPktParams.flags |= TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED;
+}
+
+
+/*************************************************************************
+*                        TnetwDrv_RecoveryCtrlBlk                        *
+**************************************************************************
+* DESCRIPTION:  
+  ============
+       Called upon recovery.
+       Handles it as follows:
+       1) Update the HwQueue to free queue resources.
+       3) Free the packet's Control-Block if Xfer-Done already occured.
+
+*
+* INPUT:   hDummyHandle -  Just to support the CB API.
+*              
+* OUTPUT:
+*
+* RETURN:       
+
+*************************************************************************/
+void TnetwDrv_RecoveryCtrlBlk(TI_HANDLE hTnetwDrv)
+{
+       txCtrlBlkEntry_t *pPktCtrlBlk;
+       /* Make a working copy of TNETDriver Handle */
+       TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+       UINT32 entry;
+    const UINT32 MAX_CTRL_BLK_ENTRY = 64;
+
+       for (entry = 0; entry < MAX_CTRL_BLK_ENTRY-1; entry++)
+       {
+               /* Get the packet's control block pointer by the descId index. */
+               pPktCtrlBlk = TnetwDrv_txCtrlBlk_GetPointer(pTnetwDrv, entry);
+               if (pPktCtrlBlk->pNextFreeEntry == NULL)
+               {
+                       TnetwDrv_txHwQueue_free(pTnetwDrv, pPktCtrlBlk);
+                       TnetwDrv_txCtrlBlk_free(pTnetwDrv, pPktCtrlBlk);
+               }
+       }
+}
+
+
+/*************************************************************************
+*                        TnetwDrv_TxXferDebug                                *
+**************************************************************************
+* DESCRIPTION:  
+  ============
+    Called upon issuing interrupt to firmware.
+    Calls the upper driver's Xfer-Debug handler.
+
+*
+* INPUT:     hDummyHandle - Just to support the CB API.
+*            pPktCtrlBlk  - The packet's control block pointer.  
+             uDebugInfo   - Additional debug info
+*              
+* OUTPUT:
+*
+* RETURN:       
+
+*************************************************************************/
+#ifdef TI_DBG
+void TnetwDrv_TxXferDebug (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo)
+{   
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+       /* Call the upper driver's Xfer-Done handler with the packet-ID. */
+       /* Note that depending on the type of compilation, the upper layeres varry: */
+       /* It may be either CoreAdaptTx or GWSIAdaptTx */
+       /* Both functions are called the same */
+    SendPacketDebug (pTnetwDrv->hUser, pPktCtrlBlk->txPktParams.packetId, uDebugInfo);
+}
+#endif
+
+
+/****************************************************************************
+ *                      ConvertTxResultStatus
+ ****************************************************************************
+ * DESCRIPTION: Convert the status bit field in the TxDone descriptor, indexed
+ *                             by the given index, to a driver status bit field
+ *                     
+ * INPUTS:     txResultStatus - Status value received from the FW
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The converted value 
+ ****************************************************************************/
+systemStatus_e ConvertTxResultStatus(TxDescStatus_enum txResultStatus)
+{
+       /* Convert Tx-Result from FW to GWSI values. */
+       /* Note: only 1 bit in the entire status field should be set */
+       switch (txResultStatus)
+       {
+               case TX_SUCCESS:
+                       return SEND_COMPLETE_SUCCESS;
+
+               case TX_RETRY_EXCEEDED:
+                       return SEND_COMPLETE_RETRY_EXCEEDED;
+
+               case TX_TIMEOUT:
+                       return SEND_COMPLETE_LIFETIME_EXCEEDED;
+
+               default:
+                       return SEND_COMPLETE_NO_LINK;
+       }
+}
+
+
+/****************************************************************************
+ *                      TnetwDrv_printInfo()
+ ****************************************************************************
+ * DESCRIPTION:         Print the txXfer object main fields.
+ ****************************************************************************/
+void TnetwDrv_printInfo(TI_HANDLE hTnetwDrv)
+{
+#ifdef TI_DBG
+    TnetwDrv_t *pTnetwDrv = (TnetwDrv_t *)hTnetwDrv;
+    int qIndex;
+
+    WLAN_OS_REPORT(("TNETW Driver  Tx Counters per Queue:\n"));
+    WLAN_OS_REPORT(("===========================\n"));
+
+    WLAN_OS_REPORT(("-------------- packets sent from upper driver ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountSentPackets[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- packets sent and queue not busy ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountQueueAvailable[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- XferDone value returned from Xfer ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferDone[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- Success value returned from Xfer ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferSuccess[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- Pending value returned from Xfer ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferPending[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- Error value returned from Xfer ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferError[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- XferDone callback calls ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountXferDoneCB[qIndex]));
+
+    WLAN_OS_REPORT(("-------------- TxComplete callback calls ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTnetwDrv->dbgCountTxCompleteCB[qIndex]));
+#endif /* TI_DBG */
+}
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.c
new file mode 100644 (file)
index 0000000..eff2ea0
--- /dev/null
@@ -0,0 +1,286 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txCtrlBlk.c
+ *   
+ *   PURPOSE: Maintains active packets Tx attributes table (including descriptor). 
+ * 
+ *      DESCRIPTION:  
+ *   ============
+ *             This module allocates and frees table entry for each packet in the Tx
+ *             process (from sendPkt by upper driver until Tx-complete).
+ *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "txCtrlBlk_api.h"
+
+#include "txCtrlBlk.h"  /* Local definitions */
+
+
+
+/****************************************************************************
+ *                      txCtrlBlk_Create()
+ ****************************************************************************
+ * DESCRIPTION:        Create the Tx control block table object 
+ * 
+ * INPUTS:     hOs
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The Created object
+ ****************************************************************************/
+TI_HANDLE txCtrlBlk_Create(TI_HANDLE hOs)
+{
+       txCtrlBlkObj_t *pTxCtrlBlk;
+
+       pTxCtrlBlk = os_memoryAlloc(hOs, sizeof(txCtrlBlkObj_t));
+       if (pTxCtrlBlk == NULL)
+               return NULL;
+
+       os_memoryZero(hOs, pTxCtrlBlk, sizeof(txCtrlBlkObj_t));
+
+       pTxCtrlBlk->hOs = hOs;
+
+       return( (TI_HANDLE)pTxCtrlBlk );
+}
+
+
+
+
+/****************************************************************************
+ *                      txCtrlBlk_Destroy()
+ ****************************************************************************
+ * DESCRIPTION:        Destroy the Tx control block table object 
+ * 
+ * INPUTS:     hTxCtrlBlk - The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+TI_STATUS txCtrlBlk_Destroy(TI_HANDLE hTxCtrlBlk)
+{
+       txCtrlBlkObj_t *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+
+       if (pTxCtrlBlk)
+               os_memoryFree(pTxCtrlBlk->hOs, pTxCtrlBlk, sizeof(txCtrlBlkObj_t));
+
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *               txCtrlBlk_init()
+ ****************************************************************************
+   DESCRIPTION:         Initialize the Tx control block module.
+ ****************************************************************************/
+TI_STATUS txCtrlBlk_init(TI_HANDLE hTxCtrlBlk, TI_HANDLE hReport)
+{
+       txCtrlBlkObj_t *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+       
+       pTxCtrlBlk->hReport = hReport;
+       
+       txCtrlBlk_restart(hTxCtrlBlk);
+
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *               txCtrlBlk_restart()
+ ****************************************************************************
+   DESCRIPTION:         
+   ============
+        Restarts the Tx-control-block table.
+        Should be called upon init, disconnect and recovery!!
+ ****************************************************************************/
+TI_STATUS txCtrlBlk_restart(TI_HANDLE hTxCtrlBlk)
+{
+       UINT8 entry;
+       txCtrlBlkObj_t *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+
+       /* For all entries, write the entry index in the descriptor and the next entry address
+                in the next free entery pointer. */
+       for(entry = 0; entry < CTRL_BLK_ENTRIES_NUM; entry++)
+       {
+               pTxCtrlBlk->TxCtrlBlkTbl[entry].txDescriptor.descID = entry;
+               pTxCtrlBlk->TxCtrlBlkTbl[entry].pNextFreeEntry = &(pTxCtrlBlk->TxCtrlBlkTbl[entry + 1]);
+       }
+
+       /* Write null in the next-free index of the last entry. */
+       pTxCtrlBlk->TxCtrlBlkTbl[CTRL_BLK_ENTRIES_NUM - 1].pNextFreeEntry = NULL;
+
+#ifdef TI_DBG
+       pTxCtrlBlk->numUsedEntries = 0;
+#endif
+
+       return OK;
+}
+
+
+
+
+
+/****************************************************************************
+ *                                     txCtrlBlk_alloc()
+ ****************************************************************************
+ * DESCRIPTION:         
+       Allocate a free control-block entry for the current Tx packet's parameters
+         (including the descriptor structure).
+       Note that entry 0 in the list is never allocated and points to the
+         first free entry.
+ ****************************************************************************/
+txCtrlBlkEntry_t *txCtrlBlk_alloc(TI_HANDLE hTxCtrlBlk)
+{
+       txCtrlBlkObj_t   *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+       txCtrlBlkEntry_t *pCurrentEntry; /* The pointer of the new entry allocated for the packet. */
+       txCtrlBlkEntry_t *pFirstFreeEntry; /* The first entry just points to the first free entry. */ 
+
+       pFirstFreeEntry = &(pTxCtrlBlk->TxCtrlBlkTbl[0]); 
+       pCurrentEntry = pFirstFreeEntry->pNextFreeEntry; /* Get free entry. */
+
+       /* If no free entries, print error (not expected to happen) and return NULL. */
+       if (pCurrentEntry == NULL)
+       {
+#ifdef TI_DBG
+               WLAN_REPORT_ERROR(pTxCtrlBlk->hReport, TX_CTRL_BLK_MODULE_LOG,
+                       ("txCtrlBlk_alloc():  No free entry,  UsedEntries=%d\n", pTxCtrlBlk->numUsedEntries));
+#endif
+               return NULL;
+       }
+#ifdef TI_DBG
+       pTxCtrlBlk->numUsedEntries++;
+#endif
+
+       /* Link the first entry to the next free entry. */
+       pFirstFreeEntry->pNextFreeEntry = pCurrentEntry->pNextFreeEntry;
+       
+       /* Clear the next-free-entry index just as an indication that our entry is not free. */
+       pCurrentEntry->pNextFreeEntry = 0;
+
+       return pCurrentEntry;
+}
+
+
+
+
+/****************************************************************************
+ *                                     txCtrlBlk_free()
+ ****************************************************************************
+ * DESCRIPTION:        
+       Link the freed entry after entry 0, so now it is the first free entry to
+         be allocated.
+ ****************************************************************************/
+void txCtrlBlk_free(TI_HANDLE hTxCtrlBlk, txCtrlBlkEntry_t *pCurrentEntry)
+{
+       txCtrlBlkObj_t   *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+       txCtrlBlkEntry_t *pFirstFreeEntry = &(pTxCtrlBlk->TxCtrlBlkTbl[0]);
+
+       /* If the pointed entry is already free, print error and exit (not expected to happen). */
+       if (pCurrentEntry->pNextFreeEntry != 0)
+       {
+#ifdef TI_DBG  
+               WLAN_REPORT_ERROR(pTxCtrlBlk->hReport, TX_CTRL_BLK_MODULE_LOG,
+                       ("txCtrlBlk_free(): Entry %d alredy free, UsedEntries=%d\n", 
+                       pCurrentEntry->txDescriptor.descID, pTxCtrlBlk->numUsedEntries));
+#endif                 
+               return;
+       }
+#ifdef TI_DBG  
+       pTxCtrlBlk->numUsedEntries--;
+#endif
+
+       /* Link the freed entry between entry 0 and the next free entry. */
+       pCurrentEntry->pNextFreeEntry   = pFirstFreeEntry->pNextFreeEntry;
+       pFirstFreeEntry->pNextFreeEntry = pCurrentEntry;
+}
+
+
+
+
+/****************************************************************************
+ *                                     txCtrlBlk_GetPointer()
+ ****************************************************************************
+ * DESCRIPTION:         
+       Return a pointer to the control block entry of the requested packet.
+       Used upon tx-complete to retrieve info after getting the descId from the FW.
+ ****************************************************************************/
+txCtrlBlkEntry_t *txCtrlBlk_GetPointer(TI_HANDLE hTxCtrlBlk, UINT8 descId)
+{
+       txCtrlBlkObj_t *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+       return ( &(pTxCtrlBlk->TxCtrlBlkTbl[descId]) );
+}
+
+
+
+
+/****************************************************************************
+ *                      txCtrlBlk_printTable()
+ ****************************************************************************
+ * DESCRIPTION:         Print the txCtrlBlk table main fields.
+ ****************************************************************************/
+void txCtrlBlk_printTable(TI_HANDLE hTxCtrlBlk)
+{
+#ifdef TI_DBG    
+       txCtrlBlkObj_t *pTxCtrlBlk = (txCtrlBlkObj_t *)hTxCtrlBlk;
+       UINT8 entry;
+
+       WLAN_OS_REPORT((" Tx-Control-Block Information,  UsedEntries=%d\n", pTxCtrlBlk->numUsedEntries));
+       WLAN_OS_REPORT(("==============================================\n"));
+       
+       for(entry = 0; entry < CTRL_BLK_ENTRIES_NUM; entry++)
+       {
+               WLAN_OS_REPORT(("Entry %d: DescID=%d, NextEntry=0x%x, PktID=0x%x, PktLen=%d, FragThresh=%d, NumBlks=%d, FC=0x%x, Flags=0x%x\n", 
+                       entry, 
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txDescriptor.descID,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].pNextFreeEntry,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txPktParams.packetId,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txDescriptor.length,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txDescriptor.fragThreshold,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txDescriptor.numMemBlks,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txPktParams.headerFrameCtrl,
+                       pTxCtrlBlk->TxCtrlBlkTbl[entry].txPktParams.flags));
+       }
+#endif /* TI_DBG */
+}
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.h
new file mode 100644 (file)
index 0000000..b4a570f
--- /dev/null
@@ -0,0 +1,71 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       txCtrlBlk.h                                                                                            */
+/*    PURPOSE: Tx control block module Header file                                                */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _TX_CTRL_BLK_H_
+#define _TX_CTRL_BLK_H_
+
+
+#include "TNETW_Driver_types.h"
+
+
+/* 4 [access catigories] * 16 [firmware queue length] */
+#define CTRL_BLK_ENTRIES_NUM   64
+
+
+/* The TxCtrlBlk module object - contains the control-block table. */
+typedef struct
+{
+       TI_HANDLE  hOs;
+       TI_HANDLE  hReport;
+
+       txCtrlBlkEntry_t  TxCtrlBlkTbl[CTRL_BLK_ENTRIES_NUM]; /* The table of control-block entries. */
+
+#ifdef TI_DBG  /* Just for debug. */
+       UINT8   numUsedEntries;  
+#endif
+
+} txCtrlBlkObj_t;
+
+
+
+#endif
+               
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.c
new file mode 100644 (file)
index 0000000..f878f73
--- /dev/null
@@ -0,0 +1,560 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txHwQueue.c
+ *   
+ *   PURPOSE: manage the wlan hardware Tx memory blocks allocation per queue. 
+ * 
+ *      DESCRIPTION:  
+ *   ============
+ *             This module is responsible for the HW Tx resources allocation (except
+ *               the HW double buffer).
+ *             The HW Tx resources are allocated and freed in the driver by pure
+ *               calculations without accessing the FW. This is done by tracking the 
+ *             resources allocation and freeing, and checking against thresholds before 
+ *               each allocation.
+ ****************************************************************************/
+
+#ifdef _WINDOWS
+#endif 
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "whalCtrl_api.h"
+#include "whalParams.h"
+#include "txCtrlBlk_api.h"
+#include "txHwQueue_api.h"
+
+#include "txHwQueue.h"  /* Local definitions */
+
+
+
+
+
+/****************************************************************************
+ *                      txHwQueue_Create()
+ ****************************************************************************
+ * DESCRIPTION:        Create the Tx buffers pool object 
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The Created object
+ ****************************************************************************/
+TI_HANDLE txHwQueue_Create(TI_HANDLE hOs)
+{
+       TxHwQueueObj_t *pTxHwQueue;
+
+       pTxHwQueue = os_memoryAlloc(hOs, sizeof(TxHwQueueObj_t));
+       if (pTxHwQueue == NULL)
+               return NULL;
+
+       os_memoryZero(hOs, pTxHwQueue, sizeof(TxHwQueueObj_t));
+
+       pTxHwQueue->hOs = hOs;
+
+       return( (TI_HANDLE)pTxHwQueue );
+}
+
+/****************************************************************************
+ *                      txHwQueue_Destroy()
+ ****************************************************************************
+ * DESCRIPTION:        Destroy the Tx buffers pool object 
+ * 
+ * INPUTS:     hTxHwQueue - The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+TI_STATUS txHwQueue_Destroy(TI_HANDLE hTxHwQueue)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+
+       if (pTxHwQueue)
+               os_memoryFree(pTxHwQueue->hOs, pTxHwQueue, sizeof(TxHwQueueObj_t));
+
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *               txHwQueue_init()
+ ****************************************************************************
+
+  DESCRIPTION: Initialize module handles.
+
+ ****************************************************************************/
+TI_STATUS txHwQueue_init(TI_HANDLE hTxHwQueue, TI_HANDLE hReport, TI_HANDLE hWhalParams)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       
+       pTxHwQueue->hReport = hReport;
+       pTxHwQueue->pWhalParams = (WhalParams_T *)hWhalParams;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      txHwQueue_Config()
+ ****************************************************************************
+ * DESCRIPTION:        Configure the Tx buffers pool object 
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    
+ ****************************************************************************/
+TI_STATUS txHwQueue_Config(TI_HANDLE hTxHwQueue, TnetwDrv_InitParams_t *pInitParams)
+{
+       UINT8                   acID;
+       
+       /* Configure queue parameters to Tx-HW queue module */
+       for(acID = 0 ; acID < MAX_NUM_OF_AC ; acID++)
+       {
+               txHwQueue_configQueue(  hTxHwQueue, 
+                                                               acID, 
+                                                               pInitParams->whalCtrl_init.TxBlocksLowPercentPerAc[acID],
+                                                               pInitParams->whalCtrl_init.TxBlocksHighPercentPerAc[acID]);
+       }
+       
+       return OK;
+}
+
+
+/****************************************************************************
+ *                                     txHwQueue_setHwInfo()
+ ****************************************************************************
+
+  DESCRIPTION: 
+  
+       Called after the HW configuration in the driver init or recovery process.
+       Configure Tx HW information, including Tx-HW-blocks number, and per queue
+         Tx-descriptors number. Than, restart the module variables.
+
+ ****************************************************************************/
+TI_STATUS txHwQueue_setHwInfo(TI_HANDLE hTxHwQueue, DmaParams_T *pDmaParams) 
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       int TxQid;
+       
+       pTxHwQueue->NumBlocks = pDmaParams->NumTxBlocks - 1; /* One block must be always free for FW use. */
+       
+       /* Get the Tx descriptors number per queue. */
+       for(TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES ; TxQid++)
+               pTxHwQueue->TxHwQueueInfo[TxQid].numDescriptors = pDmaParams->TxNumDesc[TxQid];
+
+       /* Restart the module variables. */
+       txHwQueue_restart(hTxHwQueue);
+       
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *               txHwQueue_configQueue()
+ ****************************************************************************
+   DESCRIPTION:        
+   
+   Configure Tx HW queue blocks accounting parameters used in the allocate and free 
+     procedures in this module.
+
+       Two thresholds are defined per queue:
+       a)      TxBlocksLowPercentPerQueue[queue] - The lower threshold is the minimal number of 
+               Tx blocks guaranteed for each queue.
+               The sum of all low thresholds should be less than 100%.
+       b)      TxBlocksHighPercentPerQueue[queue] - The higher threshold is the maximal number of
+               Tx blocks that may be allocated to the queue.
+               The extra blocks above the low threshold can be allocated when needed only 
+               if they are currently available and are not needed in order to guarantee
+               the other queues low threshold.
+               The sum of all high thresholds should be more than 100%.
+               
+ ****************************************************************************/
+TI_STATUS txHwQueue_configQueue(TI_HANDLE hTxHwQueue, UINT8 TxQid,
+                                                               UINT16 percentOfBlockLowThreshold, UINT16 percentOfBlockHighThreshold)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       txHwQueueInfo_t *pQueueInfo = &(pTxHwQueue->TxHwQueueInfo[TxQid]);
+       
+       /* Calculate queue's blocks high threshold:  maximum number that may be allocated to it. */
+       pQueueInfo->numBlocksHighThreshold = percentOfBlockHighThreshold * pTxHwQueue->NumBlocks / 100;
+
+       /* Calculate queue's blocks low threshold:  minimum number that must be reserved for it. */
+       pQueueInfo->numBlocksLowThreshold = percentOfBlockLowThreshold * pTxHwQueue->NumBlocks / 100;
+
+       /* Set the threshold for low block resources:  when the next packet may not have enough blocks. */
+       if (pQueueInfo->numBlocksLowThreshold > MAX_BLKS_PER_PKT)
+               pQueueInfo->lowResourceThresh = pQueueInfo->numBlocksLowThreshold - MAX_BLKS_PER_PKT;
+       else
+               pQueueInfo->lowResourceThresh = 0;
+
+       pQueueInfo->numBlocksUsed = 0;
+       pQueueInfo->numPackets = 0;
+
+       /* Since no blocks are used yet, reserved blocks number equals to the low threshold. */
+       pQueueInfo->numBlocksReserved = pQueueInfo->numBlocksLowThreshold;
+
+       /* Accumulate total reserved blocks. */
+       pTxHwQueue->TotalBlocksReserved += pQueueInfo->numBlocksReserved;
+       
+       WLAN_REPORT_INIT(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,
+               ("txHwQueue_configQueue(): HighThresh=%d, LowThresh=%d, LowRsrcThresh=%d, TotalReserved=%d\n", 
+               pQueueInfo->numBlocksHighThreshold, pQueueInfo->numBlocksLowThreshold, 
+               pQueueInfo->lowResourceThresh, pTxHwQueue->TotalBlocksReserved));
+
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *               txHwQueue_restart()
+ ****************************************************************************
+   DESCRIPTION:         
+   ============
+        Restarts the Tx-HW-Queue module.
+        Should be called upon disconnect and recovery!!
+ ****************************************************************************/
+TI_STATUS txHwQueue_restart(TI_HANDLE hTxHwQueue)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       txHwQueueInfo_t *pQueueInfo;
+       int TxQid;
+       
+       /* All blocks are free at restart.
+               Note that free means all blocks that are currently not in use, 
+               while reserved are a part of the free blocks that are the summary of all queues reserved blocks.
+               Each queue may take from the reserved part only up to its own reservation (according to
+               its low threshold). */
+
+       pTxHwQueue->NumFree = pTxHwQueue->NumBlocks;
+       pTxHwQueue->TotalBlocksReserved = 0;
+
+       for(TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES ; TxQid++)
+       {
+               pQueueInfo = &(pTxHwQueue->TxHwQueueInfo[TxQid]);
+               pQueueInfo->numBlocksUsed = 0;
+               pQueueInfo->numPackets = 0;
+
+               /* Since no blocks are used yet, reserved blocks number equals to the low threshold. */
+               pQueueInfo->numBlocksReserved = pQueueInfo->numBlocksLowThreshold;
+
+               /* Accumulate total reserved blocks. */
+               pTxHwQueue->TotalBlocksReserved += pQueueInfo->numBlocksReserved;
+       }
+
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *                                     txHwQueue_alloc()
+ ****************************************************************************
+ * DESCRIPTION:        
+   ============
+   If the required blocks are available for the queue and there is an available
+     descriptor, update the blocks and descriptor allocation and return OK.
+   Else, return NOK.
+   If the queue's reaources (blocks) are low, indicate in the descriptor to get
+     Tx-complete from FW immediately.
+ ****************************************************************************/
+TI_STATUS txHwQueue_alloc(TI_HANDLE hTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       UINT8 numBlksToAlloc; /* The number of blocks required for the current packet. */
+       UINT8 maxAllowed; /* Max blocks that may be currently allocated to this Queue to obey the high threshold.*/
+       UINT8 maxAvailable; /* Max blocks that are currently free and not reserved for other Queues. */
+       UINT8 reserved; /* How many blocks are reserved to this Queue before this allocation. */
+       txHwQueueInfo_t *pQueueInfo = &(pTxHwQueue->TxHwQueueInfo[pPktCtrlBlk->txDescriptor.xmitQueue]);
+
+
+       /***********************************************************************/
+       /*  Calculate packet fragmentation threshold and required HW blocks.   */
+       /***********************************************************************/
+
+       txHwQueueCalc_BlocksNum(hTxHwQueue, pPktCtrlBlk);
+
+
+       /***********************************************************************/
+       /*            Check if the required resources are available            */
+       /***********************************************************************/
+
+       /* If all queue's descriptors are occupied, return BUSY. */
+       if (pQueueInfo->numPackets == pQueueInfo->numDescriptors)
+       {
+               WLAN_REPORT_INFORMATION(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+                       ("txHwQueue_alloc(): No Descriptors, Queue=%d, Descriptors=%d, Packets=%d\n", 
+                       pPktCtrlBlk->txDescriptor.xmitQueue, pQueueInfo->numDescriptors, pQueueInfo->numPackets));
+               return NOK;
+       }
+
+       reserved = pQueueInfo->numBlocksReserved;
+       numBlksToAlloc = pPktCtrlBlk->txDescriptor.numMemBlks;
+
+       /* Calculate how far we are from this Queue's high threshold limit (allowed = highThresh - used). */
+       maxAllowed = pQueueInfo->numBlocksHighThreshold - pQueueInfo->numBlocksUsed;
+       
+       /* Calculate how many buffers are available for this Queue: the total free buffers minus the buffers
+            that are reserved for other Queues (all reserved minus this Queue's reserved). */
+       maxAvailable = pTxHwQueue->NumFree - (pTxHwQueue->TotalBlocksReserved - reserved);
+
+       /* If we need more blocks than are allowed or available, return BUSY. */
+       if (numBlksToAlloc > min(maxAllowed, maxAvailable))
+       {
+               WLAN_REPORT_INFORMATION(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+                       ("txHwQueue_alloc(): No Hw-Blocks, Queue=%d, Req-blks=%d , Free=%d, Used=%d, available=%d\n",
+                         pPktCtrlBlk->txDescriptor.xmitQueue, numBlksToAlloc, pTxHwQueue->NumFree, pQueueInfo->numBlocksUsed, maxAvailable));
+               return NOK;
+       }
+
+       /***********************************************************************/
+       /*                    Allocate required resources                      */
+       /***********************************************************************/
+
+       /* Update number of packets in FW (for descriptors allocation check). */
+       pQueueInfo->numPackets++;
+
+       
+       /* If we are currently using less than the low threshold (i.e. we have some reserved blocks), 
+               blocks allocation should reduce the reserved blocks number as follows:
+       */
+       if (reserved)
+       {
+
+               /* If adding the allocated blocks to the used blocks will pass the low-threshold,
+                       only the part up to the low-threshold is subtracted from the reserved blocks.
+                       This is because blocks are reserved for the Queue only up to its low-threshold. 
+                       
+                     0   old used                    low      new used       high
+                         |######|                         |          |            |
+                         |######|                         |          |            |
+                                 <------------ allocated ----------->
+                                 <----- old reserved ---->
+                                                new reserved = 0     (we passed the low threshold)
+               */
+               if (numBlksToAlloc > reserved)
+               {
+                       pQueueInfo->numBlocksReserved = 0;
+                       pTxHwQueue->TotalBlocksReserved -= reserved; /* reduce change from total reserved.*/
+               }
+
+
+               /* Else, if allocating less than reserved,
+                       the allocated blocks are subtracted from the reserved blocks:
+                       
+                     0   old used       new used               low      high
+                         |######|               |                   |        |
+                         |######|               |                   |        |
+                                 <- allocated ->
+                                 <--------- old reserved ---------->
+                                                <-- new reserved -->
+               */
+               else
+               {
+                       pQueueInfo->numBlocksReserved -= numBlksToAlloc;
+                       pTxHwQueue->TotalBlocksReserved -= numBlksToAlloc; /* reduce change from total reserved.*/
+               }
+       }
+
+
+       /* Update total free blocks and Queue used blocks with the allocated blocks number. */
+       pTxHwQueue->NumFree -= numBlksToAlloc;
+       pQueueInfo->numBlocksUsed += numBlksToAlloc;
+
+       /* If this queue has low resources (blocks or descriptors), set descriptor flag to get Tx-Complete from FW. */
+       if ( (pQueueInfo->numBlocksUsed > pQueueInfo->lowResourceThresh) ||
+                (pQueueInfo->numPackets == pQueueInfo->numDescriptors - 1) )
+       {
+               #ifdef _WINDOWS
+               #else
+                 pPktCtrlBlk->txDescriptor.txAttr |= TX_COMPLETE_REQUIRED_BIT;  
+               #endif
+       }
+
+       WLAN_REPORT_INFORMATION(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+               ("txHwQueue_alloc(): SUCCESS,  Queue=%d, Req-blks=%d , Free=%d, Used=%d, LowResources=%d\n",
+                 pPktCtrlBlk->txDescriptor.xmitQueue, numBlksToAlloc, pTxHwQueue->NumFree, 
+                 pQueueInfo->numBlocksUsed, (pQueueInfo->numBlocksUsed > pQueueInfo->lowResourceThresh)));
+
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *                                     txHwQueue_free()
+ ****************************************************************************
+ * DESCRIPTION:        Decrement the number of used descriptors and used data blks 
+                               for the specific queue.
+ ****************************************************************************/
+TI_STATUS txHwQueue_free(TI_HANDLE hTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       UINT8 numBlksToFree; /* The number of blocks freed by the current packet. */
+       UINT8 lowThreshold;  /* Minimum blocks that are guaranteed for this Queue. */
+       UINT8 newUsed; /* Blocks that are used by this Queue after freeing these blocks. */
+       UINT8 newReserved; /* How many blocks are reserved to this Queue after freeing. */
+       txHwQueueInfo_t *pQueueInfo = &(pTxHwQueue->TxHwQueueInfo[pPktCtrlBlk->txDescriptor.xmitQueue]);
+       
+       numBlksToFree = pPktCtrlBlk->txDescriptor.numMemBlks;
+
+       /* Update number of packets in FW (for descriptors allocation check). */
+       pQueueInfo->numPackets--;
+
+#ifdef TI_DBG  /* Debug Counters */
+       /* Sanity check: make sure we don't free more blocks than are in use. */
+       if (numBlksToFree > pQueueInfo->numBlocksUsed)
+       {
+               WLAN_REPORT_ERROR(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,
+               ("txHwQueue_free():  Try to free more blks than used: Queue %d, free %d, used %d\n",
+                       pPktCtrlBlk->txDescriptor.xmitQueue, numBlksToFree, pQueueInfo->numBlocksUsed));
+               return NOK;
+       }
+#endif
+       
+       /* Update total free blocks and Queue used blocks with the freed blocks number. */
+       pTxHwQueue->NumFree += numBlksToFree;
+       pQueueInfo->numBlocksUsed -= numBlksToFree;
+
+
+       lowThreshold = pQueueInfo->numBlocksLowThreshold;
+       newUsed = pQueueInfo->numBlocksUsed;
+
+       
+       /* If after freeing the blocks we are using less than the low threshold, 
+               update total reserved blocks number as follows:
+          (note: if we are above the low threshold after freeing the blocks we still have no reservation.)
+       */
+       if (newUsed < lowThreshold)
+       {
+               newReserved = lowThreshold - newUsed;
+               pQueueInfo->numBlocksReserved = newReserved;
+
+               
+               /* If freeing the blocks reduces the used blocks from above to below the low-threshold,
+                       only the part from the low-threshold to the new used number is added to the 
+                       reserved blocks (because blocks are reserved for the Queue only up to its low-threshold):
+                       
+                     0        new used               low            old used         high
+                         |###########|####################|################|             |
+                         |###########|####################|################|             |
+                                      <-------------- freed -------------->
+                                      <-- new reserved -->
+                                                old reserved = 0
+               */
+               if (numBlksToFree > newReserved)
+                       pTxHwQueue->TotalBlocksReserved += newReserved; /* Add change to total reserved.*/
+
+
+               /* Else, if we were under the low-threshold before freeing these blocks,
+                       all freed blocks are added to the reserved blocks: 
+                       
+                     0             new used          old used             low               high
+                         |################|#################|                  |                  |
+                         |################|#################|                  |                  |
+                                           <---- freed ---->
+                                                             <- old reserved ->
+                                           <---------- new reserved ---------->
+               */
+               else
+                       pTxHwQueue->TotalBlocksReserved += numBlksToFree; /* Add change to total reserved.*/
+       }
+       
+       return OK;
+}
+
+
+
+
+/****************************************************************************
+ *                                     txHwQueue_GetUsedHwBlks()
+ ****************************************************************************
+ * DESCRIPTION:         Provide the number of used HW Tx blocks of the given Queue.
+ ****************************************************************************/
+UINT8 txHwQueue_GetUsedHwBlks(TI_HANDLE hTxHwQueue, int TxQid)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       return (pTxHwQueue->TxHwQueueInfo[TxQid].numBlocksUsed);
+}
+
+
+
+
+/****************************************************************************
+ *                      txHwQueue_printInfo()
+ ****************************************************************************
+ * DESCRIPTION:        Print the Hw Queue current information
+ ****************************************************************************/
+void txHwQueue_printInfo(TI_HANDLE hTxHwQueue)
+{
+#ifdef TI_DBG    
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+       int TxQid;
+
+       /* Print the Tx-HW-Queue information: */
+    WLAN_OS_REPORT(("Hw-Queues Information:\n"));
+    WLAN_OS_REPORT(("======================\n"));
+    WLAN_OS_REPORT(("Total Blocks:                     %d\n", pTxHwQueue->NumBlocks));
+    WLAN_OS_REPORT(("Total Free Blocks:                %d\n", pTxHwQueue->NumFree));
+    WLAN_OS_REPORT(("Total Reserved Blocks: %d\n\n", pTxHwQueue->TotalBlocksReserved));
+
+       for(TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
+       {
+               WLAN_OS_REPORT(("Queue %d: Used=%d, Reserved=%d, LowThresh=%d, HighThresh=%d, LowRsrcThresh=%d, NumDesc=%d, UsedDesc=%d\n", 
+                       TxQid,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].numBlocksUsed,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].numBlocksReserved,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].numBlocksLowThreshold,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].numBlocksHighThreshold,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].lowResourceThresh,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].numDescriptors,
+                       pTxHwQueue->TxHwQueueInfo[TxQid].numPackets));
+       }
+#endif /* TI_DBG */
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.h
new file mode 100644 (file)
index 0000000..c7cd309
--- /dev/null
@@ -0,0 +1,90 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txHwQueue.h
+ *
+ *   PURPOSE: hardware Tx queues management object
+ * 
+ ****************************************************************************/
+
+#ifndef _TX_HW_QUEUE_H
+#define _TX_HW_QUEUE_H
+
+
+#include "whalParams.h"
+#include "TNETW_Driver_types.h"
+#include "txHwQueue_api.h"
+
+
+#define MAX_BLKS_PER_PKT               16              /* Max number of Tx HW blocks that may be required for one packet. */
+#define MAX_FRAG_THRESHOLD             4096
+
+
+/* Per Queue HW blocks accounting data: */
+typedef struct
+{
+    UINT8      numBlocksHighThreshold; /* The maximum HW blocks that can be allocated for this Queue. */
+    UINT8   numBlocksLowThreshold;     /* The minimum HW blocks that must be reserved for this Queue. */
+    UINT8   numBlocksUsed;                     /* The number of HW blocks that are currently allocated for this Queue. */
+    UINT8   numBlocksReserved;         /* The number of HW blocks currently reserved for this Queue (to guarentee the low threshold). */
+       UINT8   lowResourceThresh;              /* Above this blocks number we need to request tx-complete from FW. */
+       UINT8   numDescriptors;                 /* The number of descriptors in the FW per this Queue. */
+       UINT8   numPackets;                             /* The current number of packets in the FW per this Queue. */
+}txHwQueueInfo_t; 
+
+typedef struct
+{
+       TI_HANDLE  hOs;
+       TI_HANDLE  hReport;
+       WhalParams_T *pWhalParams;
+       
+       UINT32  NumBlocks;              /* The total number of Tx blocks                */
+       UINT32  NumFree;                /* Total number of free HW blocks               */    
+       UINT32  TotalBlocksReserved; /* Total number of free but reserved HW blocks */
+       
+       txHwQueueInfo_t  TxHwQueueInfo[MAX_NUM_OF_TX_QUEUES]; 
+
+} TxHwQueueObj_t;
+
+
+/* Queue-Calc public functions: */
+extern  void  txHwQueueCalc_BlocksNum(TI_HANDLE hTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk);
+
+
+
+
+#endif  /* _TX_HW_QUEUE_H */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.c
new file mode 100644 (file)
index 0000000..08d757f
--- /dev/null
@@ -0,0 +1,363 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txHwQueueCalc.c
+ *   
+ *   PURPOSE: 
+ *             Calculates the fragmentation threshold and number of HW memory blocks
+ *               required for the transmitted packet.
+ * 
+ *      DESCRIPTION:  
+ *   ============
+ *             This is a sub-module of the Tx-HW-Queue module.
+ *             When the Tx-HW-Queue is requested to allocate HW resources for a Tx 
+ *               packet (see txHwQueue_alloc()), it first calls this module to get
+ *               the number of HW memory blocks required for the packet.
+ *             First the fragmentation threshold is calculated, and then the number
+ *               blocks. Both values are written in the provided control block of
+ *               the packet (in the descriptor structure to be copied to the FW).
+ *
+ ****************************************************************************/
+
+#include "public_types.h"
+#include "802_11Defs.h"
+#include "ratesTypes.h"
+#include "whalCommon.h"
+#include "whalParams.h"
+#include "whalCtrl_api.h"
+#include "txHwQueue_api.h"  
+#include "utils.h"
+#include "txHwQueue.h"         /* Local definitions */
+#include "txHwQueueCalc.h"  /* Local definitions */
+
+
+
+
+/****************************************************************************
+ *                      txHwQueueCalc_BlocksNum()  
+ ****************************************************************************
+ * DESCRIPTION:        
+ * ============
+ *     Calculate the fragmentation threshold and the number of HW blocks
+ *       required for the whole FW Tx processing of the packet.
+ *
+ ****************************************************************************/
+void txHwQueueCalc_BlocksNum(TI_HANDLE hTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+       TxHwQueueObj_t *pTxHwQueue = (TxHwQueueObj_t *)hTxHwQueue;
+    UINT16 memBlocks;
+    UINT16 numMpdus;
+    UINT16 numMemBlocksPerFullFrag;
+    UINT16 payloadDataLen;
+    UINT16 fragThreshold;
+
+       /* Calculate the fragmentation threshold. */
+       fragThreshold = CalcFragThreshold(pTxHwQueue, pPktCtrlBlk);
+
+    payloadDataLen  = pPktCtrlBlk->txDescriptor.length + MAX_MSDU_SECURITY_LENGTH; 
+
+    if (payloadDataLen > fragThreshold)
+       {
+#ifdef TI_DBG
+        if (fragThreshold == 0)
+        {
+            WLAN_OS_REPORT(("ERROR !!!!!!!!! fragThreshold==0 !!!!!!"));
+            return;
+        }
+#endif
+
+               numMemBlocksPerFullFrag = ((fragThreshold + MAX_MPDU_HEADER_AND_SECURITY) / HW_BLOCK_SIZE) + 1;
+        numMpdus = payloadDataLen / fragThreshold;
+        memBlocks = numMpdus * numMemBlocksPerFullFrag;
+        payloadDataLen -= numMpdus * fragThreshold;
+               numMpdus++;
+       }
+       else
+       {
+               numMemBlocksPerFullFrag = 0;
+               memBlocks = 0;
+               numMpdus = 1;
+       }
+
+    memBlocks += (payloadDataLen / HW_BLOCK_SIZE) + 1;
+
+       /* If fragmentation needed, add spare blocks for FW internal copy purposes. */
+    if (numMpdus > 1)
+        memBlocks += min(numMpdus, numMemBlocksPerFullFrag); 
+
+  #ifdef TI_DBG
+    if (memBlocks > 255)
+        WLAN_REPORT_ERROR (pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+            ("txHwQueueCalc_BlocksNum(): number of required blocks is bigger than 255 = %d\n", memBlocks));
+  #endif
+
+       /* Copy the frag-threshold and HW blocks number to the descriptor. */
+    pPktCtrlBlk->txDescriptor.numMemBlks = (UINT8)memBlocks;
+       pPktCtrlBlk->txDescriptor.fragThreshold = fragThreshold;
+
+       WLAN_REPORT_INFORMATION(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+               ("txHwQueueCalc_BlocksNum(): FragThresh=%d, NumBlks=%d, NumMpdus=%d, DataLen=%d\n",
+                 fragThreshold, memBlocks, numMpdus, payloadDataLen));
+}
+
+
+
+
+/****************************************************************************
+ *               CalcFragThreshold()
+ ****************************************************************************
+   DESCRIPTION:  Calculates the frag threshold per frame according to the frag threshold 
+                  defined by the user and the TxOp fragmentation (if WME is used).
+
+   PARAMETERS:   pTxHwQueue - The module object.
+                                pPktCtrlBlk    - The current packet control block (including descriptor).
+   
+   RETURNS:      The final fragmentation threshold.
+ ****************************************************************************/
+static UINT16 CalcFragThreshold(TxHwQueueObj_t *pTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+    UINT32 txOpLimit;
+    UINT16 fragThreshold, uMaxHdrLen;
+    WlanParams_T *pWlanParams = &(pTxHwQueue->pWhalParams->WlanParams);
+    dot11_header_t *pDot11Hdr = (dot11_header_t*)((UINT8 *)pPktCtrlBlk->txPktParams.pFrame + TX_TOTAL_OFFSET_BEFORE_DATA);
+
+    /* 
+     *       It is prohibited by the standard to fragment multicast/broadcast 
+     *       frames both in Infrastructure and Independent BSS types
+     */
+    
+    /* check for multicast packet in the destination address (address1 or address3)*/
+    if (MAC_MULTICAST(GET_DA_FROM_DOT11_HEADER_T(pDot11Hdr))) 
+            return MAX_FRAG_THRESHOLD;
+
+    /* For 4X don't fragment (use max frag threshold). */
+    if (pWlanParams->Enable4x)
+        return MAX_FRAG_THRESHOLD;
+
+    /* Non-QOS mode */
+    if (IS_LEGACY_DATA (pPktCtrlBlk->txPktParams.headerFrameCtrl))
+    {
+        /* use "legacy" mode for the WLAN header length */ 
+        uMaxHdrLen = WLAN_HDR_LEN;
+        /* Use "legacy" fragmentation */
+        fragThreshold = pWlanParams->FragmentThreshold;
+    } 
+
+    /* QOS mode */
+    else
+    {
+        uMaxHdrLen = WLAN_QOS_HDR_LEN;
+
+        txOpLimit = pTxHwQueue->pWhalParams->AcParams.ac[pPktCtrlBlk->txDescriptor.xmitQueue].txopLimit;
+
+        if (txOpLimit == 0)
+        {
+            /* 
+             * If working in WME and TXOP limit is not set for this AC - 
+             * Use "legacy" fragmentation and substract the over head of the QoS header
+             */
+            /* TODO yuval - check why 2 is needed */
+            fragThreshold = pWlanParams->FragmentThreshold - DIFF_HEADER_LENGTH_LEGACY_TO_QOS;
+        }
+        else
+
+        {
+            /*
+             * If TXOP-limit value is set (may require fragmentation for the time limit) -
+             * calculate the fragmentation threshold for the given TXOP-limit
+             */
+            fragThreshold = GetTxOpFragThreshold (pTxHwQueue, pPktCtrlBlk, txOpLimit, pWlanParams);
+        }
+    }
+
+    /* If the frag threshold is below minimal frag, use minimal frag threshold */
+    if (fragThreshold < MIN_FRAG_THRESH)
+        fragThreshold = MIN_FRAG_THRESH;
+
+    /* Subtract header length and CRC length */
+    fragThreshold -= uMaxHdrLen + FCS_LENGTH;
+
+    /* Return the frag threshold. */
+    /* Note that security overheads are excluded as they are allowed to exceed the time limit. */
+    return fragThreshold;
+}
+
+
+
+
+
+/****************************************************************************
+ *                      GetTxOpFragThreshold()
+ ****************************************************************************
+   DESCRIPTION:  Calculates the fragmentation threshold caused by the TxOpLimit.
+
+   PARAMETERS:   pTxHwQueue - The module object.
+                                pPktCtrlBlk    - The current packet control block (including descriptor structure).
+   
+   RETURNS:      The fragmentation threshold calculated for the TXOP limit.
+ ****************************************************************************/
+static UINT16 GetTxOpFragThreshold(TxHwQueueObj_t *pTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk, 
+                                                                  UINT16 txOpLimit, WlanParams_T *pWlanParams)
+{
+    UINT16  fragDataTime; 
+       UINT16  txOpFragThresh; 
+       UINT16  plcpHdrTimeBRate;
+       UINT16  plcpHdrTime;
+       UINT16  durationOverhead;
+       UINT16  rateMbps; 
+    rate_e     initialRate;
+       BOOL    rtsSet;
+       rate_e  ctrlFrameRate = pTxHwQueue->pWhalParams->BssInfoParams.txCtrlFrmRateDriverFormat;
+       uint8   ackPolicy;
+
+       initialRate = ConvertRateTnetToDriver(pPktCtrlBlk->txDescriptor.rate);
+
+#ifdef TI_DBG
+       if (initialRate == DRV_RATE_INVALID)
+       {
+               WLAN_REPORT_ERROR(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+                       ("GetTxOpFragThreshold(): Unexpected Tx-Rate = %d\n", initialRate));
+       }
+#endif
+
+    rateMbps = TxMemCalcRateValueTable[initialRate]; /* Convert from driver enum to Mbps value */
+
+    /* Set the PLCP header time for B rates according to the preamble type. */
+       if ( (pWlanParams->preamble == PREAMBLE_LONG) || (initialRate == DRV_RATE_1M) )
+        plcpHdrTimeBRate = LONG_PREAMBLE_MICROSECONDS;
+    else
+        plcpHdrTimeBRate = SHORT_PREAMBLE_MICROSECONDS;
+
+       /* Get PLCP header duration overhead. */
+       if (initialRate >= DRV_RATE_6M) /* If it's an OFDM rate. */
+               plcpHdrTime = OFDM_PLCP_HDR_MICROSECONDS;
+    else
+        plcpHdrTime = plcpHdrTimeBRate;
+
+       durationOverhead = plcpHdrTime;
+       
+       /* Add ACK overhead if not using No-ACK. */
+       {    
+        TxDescCtrl_t tmpTxDesc;
+        COPY_UNALIGNED_LONG(&tmpTxDesc, &(pPktCtrlBlk->txDescriptor.txAttr));
+        ackPolicy = tmpTxDesc.ackPolicy;
+    }
+    if ( !ackPolicy )
+       {
+        durationOverhead += TxMemCalcAckDurationTable[initialRate] + plcpHdrTime; 
+               if (initialRate >= DRV_RATE_6M)
+                   durationOverhead += OFDM_SIGNAL_EXT_MICROSECONDS; /* If OFDM add SIFS extra 6 uSec. */
+    }
+
+       /* If packet length bigger than RTS threshold, add RTS time to the duration overhead. */
+    if (pPktCtrlBlk->txDescriptor.length > pWlanParams->RtsThreshold)
+       {
+        durationOverhead += RTS_FRAG_DATA_TIME;
+               rtsSet = TRUE;
+       }
+       else
+               rtsSet = FALSE;
+
+       /* If protection CTS required for OFDM packet or RTS needed, add CTS time to duration overhead. */
+    if ( (pWlanParams->CtsToSelf && (initialRate >= DRV_RATE_6M))  ||  rtsSet )
+        durationOverhead += TxMemCalcAckDurationTable[ctrlFrameRate] + plcpHdrTimeBRate;
+       
+       /* If the TXOP time is longer than the packet overheads, get the delta (fragment body time). */
+    if (txOpLimit > durationOverhead)
+        fragDataTime = txOpLimit - durationOverhead;
+       
+       /* Else, Can't get into the TXOP limit time. The minimal frag threshold (256) will be used. */
+    else
+               fragDataTime = 0;  
+
+       /* Calculate the fragmentation threshold in data bytes from the required duration and rate. */
+    txOpFragThresh = fragDataTime * rateMbps / BIT_TO_BYTE_FACTOR;
+
+    /* If rate is 5.5M, a value of 55 is used so compensate for the 10 times factor. */
+    if (rateMbps == 55) 
+        txOpFragThresh = txOpFragThresh / 10;
+
+    /* Firmware requires the fragmentation threshold to be an EVEN number */
+    txOpFragThresh &= ~1;
+
+       WLAN_REPORT_INFORMATION(pTxHwQueue->hReport, TX_HW_QUEUE_MODULE_LOG,  
+               ("GetTxOpFragThreshold(): FragThresh=%d, Rate=%d, TXOP=%d, Overhead=%d, NoACK=%d, CTS=%d, RTS=%d\n",
+                 txOpFragThresh, initialRate, txOpLimit, durationOverhead, ackPolicy,
+                 pWlanParams->CtsToSelf, rtsSet));
+    
+    return (txOpFragThresh);
+}
+
+
+
+
+/****************************************************************************
+ *                      ConvertRateTnetToDriver
+ ****************************************************************************
+ * DESCRIPTION: Convert the given rate from TNET format (Tx-descriptor) to driver format.
+ *                     
+ * INPUTS:     txDescRate - Rate value in Tx-descriptor format
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The converted rate in driver format. 
+ ****************************************************************************/
+static rate_e ConvertRateTnetToDriver (UINT16 tnetRate)
+{
+       switch (tnetRate)
+       {
+               case HW_BIT_RATE_1MBPS:         return DRV_RATE_1M;
+               case HW_BIT_RATE_2MBPS:         return DRV_RATE_2M;
+               case HW_BIT_RATE_5_5MBPS:       return DRV_RATE_5_5M;
+               case HW_BIT_RATE_6MBPS:         return DRV_RATE_6M;
+               case HW_BIT_RATE_9MBPS:         return DRV_RATE_9M;
+               case HW_BIT_RATE_11MBPS:        return DRV_RATE_11M;
+               case HW_BIT_RATE_12MBPS:        return DRV_RATE_12M;
+               case HW_BIT_RATE_18MBPS:        return DRV_RATE_18M;
+               case HW_BIT_RATE_22MBPS:        return DRV_RATE_22M;
+               case HW_BIT_RATE_24MBPS:        return DRV_RATE_24M;
+               case HW_BIT_RATE_36MBPS:        return DRV_RATE_36M;
+               case HW_BIT_RATE_48MBPS:        return DRV_RATE_48M;
+               case HW_BIT_RATE_54MBPS:        return DRV_RATE_54M;
+
+               default:                                        return DRV_RATE_INVALID;
+       }
+}
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.h
new file mode 100644 (file)
index 0000000..6a54bd2
--- /dev/null
@@ -0,0 +1,126 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txHwQueueCalc.h
+ *
+ *   PURPOSE: Tx HW blocks and fragmentation threshold calculations module internal definitions.
+ * 
+ ****************************************************************************/
+
+#ifndef _TX_HW_QUEUE_MEM_CALC_H
+#define _TX_HW_QUEUE_MEM_CALC_H
+
+
+#include "whalParams.h"
+#include "TNETW_Driver_types.h"
+#include "802_11Defs.h"
+
+#define HW_BLOCK_SIZE                  252   /* The net size per HW block (without block header). */
+#define RTS_FRAG_DATA_TIME      248
+
+#define MIN_FRAG_THRESH                        256
+
+#define FCS_LENGTH                                             4
+#define MAX_MSDU_SECURITY_LENGTH               16 /* RSN + MIC = 8 + 8 = 16 bytes (worst case - AES). */
+#define MAX_MPDU_SECURITY_LENGTH               16 /* RSN + MIC = 8 + 8 = 16 bytes (worst case - AES). */
+#define DIFF_HEADER_LENGTH_LEGACY_TO_QOS (WLAN_QOS_HDR_LEN - WLAN_HDR_LEN)
+#define MAX_MPDU_HEADER_AND_SECURITY   (WLAN_QOS_HDR_LEN + MAX_MPDU_SECURITY_LENGTH)
+
+#define OFDM_PLCP_HDR_MICROSECONDS      24
+#define SHORT_PREAMBLE_MICROSECONDS     96
+#define LONG_PREAMBLE_MICROSECONDS      192
+#define B_SIFS_MICROSECONDS             10
+#define OFDM_SIGNAL_EXT_MICROSECONDS    6
+#define NONOFDM_SHORT_DURATION_MICROSECONDS  (B_SIFS_MICROSECONDS + SHORT_PREAMBLE_MICROSECONDS)
+#define NONOFDM_LONG_DURATION_MICROSECONDS   (B_SIFS_MICROSECONDS + LONG_PREAMBLE_MICROSECONDS)
+
+
+
+/* The ACK duration in air (in uSec) per Tx rate,
+        including MAC header + SIFS, and excluding PLCP header. */
+const UINT8 TxMemCalcAckDurationTable[] =
+{
+       0,              /* Auto (not used in this module)*/
+    B_SIFS_MICROSECONDS + 112,    /* 1 Mbps */
+    B_SIFS_MICROSECONDS + 56,     /* 2 Mbps*/
+    B_SIFS_MICROSECONDS + 20,     /* 5.5 Mbps*/
+    B_SIFS_MICROSECONDS + 10,     /* 11 Mbps*/
+    B_SIFS_MICROSECONDS + 4,      /* 22 Mbps*/
+    B_SIFS_MICROSECONDS + 19,     /* 6 Mbps*/
+    B_SIFS_MICROSECONDS + 12,     /* 9 Mbps*/
+    B_SIFS_MICROSECONDS + 6,      /* 18 Mbps*/
+    B_SIFS_MICROSECONDS + 4,      /* 22 Mbps*/
+    B_SIFS_MICROSECONDS + 4,      /* 24 Mbps*/
+    B_SIFS_MICROSECONDS + 4,      /* 36 Mbps*/
+    B_SIFS_MICROSECONDS + 4,      /* 48 Mbps, standard says ack at 36 Mbps*/
+    B_SIFS_MICROSECONDS + 4       /* 54 Mbps, standard says ack at 36 Mbps*/
+};
+
+
+/* Translate rate code to bit rate in Mbps (5.5M has a factor of 10). */
+const UINT8 TxMemCalcRateValueTable[] =
+{
+       0,              /* Auto (not used in this module)*/
+    1,         /* 1 Mbps */
+    2,         /* 2 Mbps*/
+    55,                /* 5.5 Mbp*/
+    11,                /* 11 Mbps*/
+    22,                /* 22 Mbps*/
+    6,         /* 6 Mbps*/
+    9,         /* 9 Mbps*/
+    12,                /* 18 Mbps*/
+    18,                /* 22 Mbps*/
+    24,                /* 24 Mbps*/
+    36,                /* 36 Mbps*/
+    48,                /* 48 Mbps*/
+    54         /* 54 Mbps*/
+};
+
+
+
+/* Module local functions. */
+
+static UINT16 CalcFragThreshold(TxHwQueueObj_t *pTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk);
+static UINT16 GetTxOpFragThreshold(TxHwQueueObj_t *pTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk, 
+                                                                  UINT16 txOpLimit, WlanParams_T *pWlanParams);
+static rate_e ConvertRateTnetToDriver (UINT16 tnetRate);
+
+
+
+#endif /* _TX_HW_QUEUE_MEM_CALC_H */
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/inc/txCtrlBlk_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/inc/txCtrlBlk_api.h
new file mode 100644 (file)
index 0000000..8243f45
--- /dev/null
@@ -0,0 +1,64 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       txCtrlBlk_api.h                                                                                        */
+/*    PURPOSE: Tx control block module API.                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _TX_CTRL_BLK_API_H_
+#define _TX_CTRL_BLK_API_H_
+
+
+#include "TNETW_Driver_types.h"
+
+
+/* Public Function Definitions */
+
+TI_HANDLE      txCtrlBlk_Create(TI_HANDLE hOs);
+TI_STATUS      txCtrlBlk_Destroy(TI_HANDLE hTxCtrlBlk);
+TI_STATUS      txCtrlBlk_init(TI_HANDLE hTxCtrlBlk, TI_HANDLE hReport);
+TI_STATUS      txCtrlBlk_restart(TI_HANDLE hTxCtrlBlk);
+txCtrlBlkEntry_t *txCtrlBlk_alloc(TI_HANDLE hTxCtrlBlk);
+void           txCtrlBlk_free(TI_HANDLE hTxCtrlBlk, txCtrlBlkEntry_t *pCurrentEntry);
+txCtrlBlkEntry_t *txCtrlBlk_GetPointer(TI_HANDLE hTxCtrlBlk, UINT8 descId);
+void           txCtrlBlk_printTable(TI_HANDLE hTxCtrlBlk);
+
+
+
+#endif  /* _TX_CTRL_BLK_API_H_ */
+               
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/inc/txHwQueue_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Data_Srv/inc/txHwQueue_api.h
new file mode 100644 (file)
index 0000000..39ec9fa
--- /dev/null
@@ -0,0 +1,72 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txHwQueue_api.h
+ *
+ *   PURPOSE: HW Tx Queue module API.
+ * 
+ ****************************************************************************/
+
+#ifndef _TX_HW_QUEUE_API_H
+#define _TX_HW_QUEUE_API_H
+
+
+#include "TNETW_Driver_types.h"
+
+
+
+/* Public Function Definitions */
+
+TI_HANDLE      txHwQueue_Create(TI_HANDLE hOs);
+TI_STATUS      txHwQueue_Destroy(TI_HANDLE hTxHwQueue);
+TI_STATUS      txHwQueue_init(TI_HANDLE hTxHwQueue, TI_HANDLE hReport, TI_HANDLE hWhalParams);
+TI_STATUS      txHwQueue_Config(TI_HANDLE hTxHwQueue, TnetwDrv_InitParams_t *pInitParams);
+TI_STATUS      txHwQueue_setHwInfo(TI_HANDLE hTxHwQueue, DmaParams_T *pDmaParams);
+TI_STATUS      txHwQueue_configQueue(TI_HANDLE hTxHwQueue, UINT8 TxQid,
+                                       UINT16 percentOfBlockLowThreshold, UINT16 percentOfBlockHighThreshold);
+TI_STATUS      txHwQueue_restart(TI_HANDLE hTxHwQueue);
+TI_STATUS      txHwQueue_alloc(TI_HANDLE hTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk);
+TI_STATUS      txHwQueue_free(TI_HANDLE hTxHwQueue, txCtrlBlkEntry_t *pPktCtrlBlk);
+UINT8          txHwQueue_GetUsedHwBlks(TI_HANDLE hTxHwQueue, int TxQid);
+void           txHwQueue_printInfo(TI_HANDLE hTxHwQueue);
+
+
+#endif /* _TX_HW_QUEUE_API_H */
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Export_Inc/TNETW_Driver_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Export_Inc/TNETW_Driver_api.h
new file mode 100644 (file)
index 0000000..845e798
--- /dev/null
@@ -0,0 +1,114 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   TNETW-Driver                                                */
+/*                                                                          */
+/*    PURPOSE:  Driver API functions prototypes.                            */
+/*                                                                          */
+/***************************************************************************/
+
+#ifndef TNETW_DRIVER_API_H
+#define TNETW_DRIVER_API_H
+
+
+#include "commonTypes.h"
+#include "TNETW_Driver_types.h"
+#include "802_11Defs.h"
+
+/************************************************************************
+                TNETW-Driver  Common  API  Functions
+************************************************************************/
+
+/* Functions that handle common procedures for multiple driver modules (mainly initialization). */
+TI_HANDLE   TnetwDrv_Create              (TI_HANDLE hOs);
+TI_STATUS   TnetwDrv_Init                (TI_HANDLE hTnetwDrv, TI_HANDLE hReport, TI_HANDLE hMemMgr, TI_HANDLE hUser, UINT32 *pFWImage, TnetwDrv_InitParams_t* pInitParams, TnetDrv_callback_t fUserConf);
+TI_STATUS   TnetwDrv_Configure           (TI_HANDLE hTnetwDrv, TnetwDrv_InitParams_t* pInitParams);
+void        TnetwDrv_Destroy             (TI_HANDLE hTnetwDrv);
+void        TnetwDrv_Register_CB         (TI_HANDLE hTnetwDrv,tiUINT32 EventID,void *CBFunc, void *pData);
+void        TnetwDrv_GetInitParams       (TI_HANDLE hTnetwDrv, UINT8 *pcommand, UINT16 *OutBufLen);
+void        TnetwDrv_PrintInfo           (TI_HANDLE hTnetwDrv, TnetwDrv_PrintInfoType_e printInfo);
+TI_STATUS   TnetwDrv_FinalizeDownload    (TI_HANDLE hTnetwDrv);
+TI_STATUS   TnetwDrv_FinalizeOnFailure   (TI_HANDLE hTnetwDrv);
+
+
+/*  TEMPORARY!! - untill the new TNETW-Driver architecture is completed!!  */
+void        TnetwDrv_TEMP_GetHandles     (TI_HANDLE hTnetwDrv, TI_HANDLE *pHalCtrl, TI_HANDLE *pMacServices);
+
+#ifdef GWSI_SPI_TEST
+TI_HANDLE TnetwDrv_GetTnetwifHandle (TI_HANDLE hTnetwDrv);
+#endif /* GWSI_SPI_TEST */
+
+/************************************************************************
+                TNETW-Driver  Tx  API  Functions
+************************************************************************/
+
+txCtrlBlkEntry_t   *TnetwDrv_txCtrlBlk_alloc         (TI_HANDLE hTnetwDrv);
+void                TnetwDrv_txCtrlBlk_free          (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pCurrentEntry);
+txCtrlBlkEntry_t   *TnetwDrv_txCtrlBlk_GetPointer    (TI_HANDLE hTnetwDrv, UINT8 descId);
+TI_STATUS           TnetwDrv_txHwQueue_alloc         (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk);
+TI_STATUS           TnetwDrv_txHwQueue_free          (TI_HANDLE hTnetwDrv, txCtrlBlkEntry_t *pPktCtrlBlk);
+UINT8               TnetwDrv_txHwQueue_GetUsedHwBlks (TI_HANDLE hTnetwDrv, int TxQid);
+UINT8               TnetwDrv_txGetAckPolicy          (TI_HANDLE hTnetwDrv, int TxQid, BOOL bIsMultiCastAndIBSS);
+void                TnetwDrv_printInfo               (TI_HANDLE hTnetwDrv);
+
+systemStatus_e      TnetwDrv_txXfer_sendPacket       (TI_HANDLE hTnetwDrv, 
+                const void  *aFrame,        /* Pointer to the packet content. points to */
+                                            /* the place that the actual packet begins. */
+                                            /* a size of TX_TOTAL_OFFSET_BEFORE_DATA    */
+                                            /* must be saved before that pointer        */
+                UINT16      aLength,        /* MSDU length from first byte of MAC       */
+                                            /*   header to last byteof frame body.      */
+                UINT8       aQueueId,       /* Tx queue as defined in ConfigureQueue.   */
+                UINT8       aTxRateClassId, /* Tx rate class ID defined in txRatePolicy.*/
+                UINT16      aMaxTransmitRate,/* A bit mask that specifies the initial   */
+                                            /*     (highest) rate to use.               */
+                BOOL        aMore,          /* Tells if there is another packet coming  */
+                                            /*   shortly after this one.                */
+                UINT32      aPacketId,      /* Packet identifier used as a context by   */
+                                            /*   the host driver.                   */
+                UINT8       aPowerLevel,    /* Transmission power level.                */
+                UINT32      aExpiryTime,    /* Time left for this MSDU to live.         */
+                void        *aReserved);    /* Optional parameters pointer.             */
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+void TnetwDrv_StartRecovery(TI_HANDLE hTnetwDrv, void *endOfRecoveryCB, TI_HANDLE hRecoveryMgr);
+TI_STATUS TnetwDrv_InitHw_FinalizeDownload(TI_HANDLE hTnetwDrv);
+#endif
+
+#endif  /* TNETW_DRIVER_TYPES_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/Export_Inc/TNETW_Driver_types.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/Export_Inc/TNETW_Driver_types.h
new file mode 100644 (file)
index 0000000..eaa1d2e
--- /dev/null
@@ -0,0 +1,201 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       TNETW-Driver                                                                                            */
+/*                                                                                                                                                     */
+/*    PURPOSE: Driver constants and type definitions                                           */
+/*                                                                                                                                                     */
+/***************************************************************************/
+
+#ifndef TNETW_DRIVER_TYPES_H
+#define TNETW_DRIVER_TYPES_H
+
+
+#include "commonTypes.h"
+#include "whalCtrl_api.h"
+#include "public_descriptors.h"   /* The FW Tx-Descriptor and Tx-Result structures are used to ensure
+                                                                          FW compatibility and to avoid conversions in the data path. */
+#if defined(HW_ACCESS_WSPI)
+/* Read data offset */
+#define TNETWIF_READ_OFFSET_BYTES  8
+
+/* Write data offset */
+#define TNETWIF_WRITE_OFFSET_BYTES 4
+#else
+#define TNETWIF_READ_OFFSET_BYTES  0
+#define TNETWIF_WRITE_OFFSET_BYTES 0
+#endif
+/* Tx packet offset before the actual data */
+#define TX_TOTAL_OFFSET_BEFORE_DATA (TNETWIF_WRITE_OFFSET_BYTES + sizeof(DbTescriptor)) 
+
+/* Tx packet Control-Block flags bit-mask. */
+#define TX_CTRL_BLK_FLAGS_XFER_DONE_ISSUED             0x0001  /* Xfer-Done already issued to upper driver. */
+#define TX_CTRL_BLK_FLAGS_TX_COMPLETE_ISSUED   0x0002  /* Tx-Complete already issued to upper driver. */
+
+
+/* TNETW Driver Callback Module owner */
+typedef enum
+{
+    TNETW_DRIVER_TX_XFER_OWNER                 = 0x0100,
+       TNETW_DRIVER_RX_XFER_OWNER                      = 0x0200,
+       TNETW_DRIVER_HAL_CTRL_OWNER                     = 0x0300,
+       TNETW_DRIVER_MAC_SERVICES_OWNER         = 0x0400,
+    TNETW_DRIVER_TX_RESULT_OWNER               = 0x0500,
+       TNETW_DRIVER_TWD_OWNER                          = 0x0600,
+
+    TNETW_DRIVER_LAST_OWNER                            = TNETW_DRIVER_TWD_OWNER
+
+}   TNETW_DRIVER_CB_ModuleOwner_e;
+
+
+/* TxXfer MODULE Callbacks */
+#define  TX_XFER_SEND_PKT_TRANSFER             0x01   
+#define  TX_XFER_SEND_PKT_DEBUG         0x02
+
+/* TxResult MODULE Callbacks */
+#define  TX_RESULT_SEND_PKT_COMPLETE   0x01
+
+
+
+/* TNETW Driver Callback ID */
+typedef enum
+{
+       /* Internal Failure Event Callbacks */
+       TNETW_DRIVER_EVENT_FAILURE                                      =   HAL_INTERNAL_EVENT_FAILURE, 
+
+       /* MAC Services Event Callbacks */
+       TNETW_DRIVER_EVENT_SCAN_COMPLETE                        = TNETW_DRIVER_MAC_SERVICES_OWNER | HAL_EVENT_SCAN_CMPLT,         /* WHAL HW EVENT MBOX */
+       TNETW_DRIVER_EVENT_PS_MODE_COMPLETE                     = TNETW_DRIVER_MAC_SERVICES_OWNER | HAL_EVENT_PS_REPORT,          /* WHAL HW EVENT MBOX */
+       TNETW_DRIVER_EVENT_MEASUREMENT_COMPLETE         = TNETW_DRIVER_MAC_SERVICES_OWNER | HAL_EVENT_MEASUREMENT_COMPLETE,       /* WHAL HW EVENT MBOX */
+
+
+       /* Ctrl Event Callbacks */
+       TNETW_DRIVER_EVENT_MEASUREMENT_START            =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_MEASUREMENT_START, 
+       TNETW_DRIVER_EVENT_CALIB_CMPLT                          =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_CALIB_CMPLT, 
+       TNETW_DRIVER_EVENT_RSSI_LEVEL                           =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_RSSI_LEVEL, 
+       TNETW_DRIVER_EVENT_PS_REPORT                            =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_PS_REPORT,
+       TNETW_DRIVER_EVENT_SYNCHRONIZATION_TIMEOUT      =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_SYNCHRONIZATION_TIMEOUT, 
+       TNETW_DRIVER_EVENT_HEALTH_REPORT                        =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_HEALTH_REPORT,
+       TNETW_DRIVER_EVENT_ACI                                          =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_ACI, 
+       TNETW_DRIVER_EVENT_DEBUG_MESSAGE                        =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_DEBUG_MESSAGE, 
+       TNETW_DRIVER_EVENT_MAC_STATUS                           =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_MAC_STATUS,
+       TNETW_DRIVER_EVENT_DISCONNECT_COMPLETE          =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_DISCONNECT_COMPLETE,
+       TNETW_DRIVER_EVENT_JOIN_CMPLT                           =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_JOIN_CMPLT,
+       TNETW_DRIVER_EVENT_SWITCH_CHANNEL_CMPLT         =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_SWITCH_CHANNEL_CMPLT,
+       TNETW_DRIVER_EVENT_BSS_LOSE                                     =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_BSS_LOSE,
+       TNETW_DRIVER_EVENT_MAX_TX_RETRY                         =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_MAX_TX_RETRY,
+       TNETW_DRIVER_EVENT_AP_DISCOVERY_COMPLETE        =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_AP_DISCOVERY_COMPLETE,
+       TNETW_DRIVER_EVENT_SPS_SCAN_CMPLT                       =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_SPS_SCAN_CMPLT, 
+       TNETW_DRIVER_EVENT_BSS_REGAIN                           =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_BSS_REGAIN,
+       TNETW_DRIVER_EVENT_RSSI_LEVEL_REGAIN            =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_RSSI_LEVEL_REGAIN, 
+       TNETW_DRIVER_EVENT_BT_COEX_SENSE                        =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_SOFT_GEMINI_SENSE,           
+       TNETW_DRIVER_EVENT_BT_COEX_PROTECTIVE_MODE      =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_SOFT_GEMINI_PREDICTION,
+       TNETW_DRIVER_EVENT_BT_COEX_AVALANCHE            =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_EVENT_SOFT_GEMINI_AVALANCHE,
+       TNETW_DRIVER_COMMAND_COMPLETE                           =  TNETW_DRIVER_HAL_CTRL_OWNER | HAL_INT_COMMAND_COMPLETE,      
+       
+       /* Tx Data Path Callbacks */
+    TNETW_DRIVER_TX_XFER_SEND_PKT_TRANSFER             =  TNETW_DRIVER_TX_XFER_OWNER   | TX_XFER_SEND_PKT_TRANSFER,   /* TxXfer MODULE */
+    TNETW_DRIVER_TX_RESULT_SEND_PKT_COMPLETE   =  TNETW_DRIVER_TX_RESULT_OWNER | TX_RESULT_SEND_PKT_COMPLETE, /* TxResult MODULE */
+    TNETW_DRIVER_TX_XFER_SEND_PKT_DEBUG         =  TNETW_DRIVER_TX_XFER_OWNER   | TX_XFER_SEND_PKT_DEBUG,      /* TxXfer MODULE */
+
+       /* Rx Data Path Callbacks */
+    TNETW_DRIVER_RX_RECEIVE_PACKET                             =  TNETW_DRIVER_RX_XFER_OWNER | HAL_INT_RECEIVE_PACKET,                 /* WHAL RX MODULE */
+    TNETW_DRIVER_RX_REQUEST_FOR_BUFFER                 =  TNETW_DRIVER_RX_XFER_OWNER | HAL_INT_REQUEST_FOR_BUFFER,             /* WHAL RX MODULE */
+
+}TnetwDrv_CB_ID_e;
+
+
+
+/* TNETW Driver print functions codes. */
+typedef enum
+{
+       TNETW_DRV_PRINT_TX_CTRL_BLK_TBL,
+       TNETW_DRV_PRINT_TX_HW_QUEUE_INFO,
+       TNETW_DRV_PRINT_TX_XFER_INFO,
+       TNETW_DRV_PRINT_TX_RESULT_INFO,
+       TNETW_DRV_CLEAR_TX_RESULT_INFO
+}TnetwDrv_PrintInfoType_e;
+
+
+
+/* Tx Control-Block Packet parameters that are not included in the Tx-descriptor. */
+typedef struct
+{
+       const void *pFrame;             /* Points to the whole packet including Tx-Descriptor + MAC-Header + Data. */
+       UINT32 packetId;                /* The packet ID used by the upper driver to identify it when called back. */
+       UINT16 headerFrameCtrl; /* The Frame Control field from the MAC header. */
+       UINT16 flags;                   /* See TX_CTRL_BLK_FLAGS_xxxx above. */
+
+#ifdef TI_DBG
+       UINT32 dbgPktSeqNum;    /* Packets sequence counter per queue. */
+#endif
+
+} TxPktParams_t;
+
+
+/* 
+ * txCtrlBlkEntry_t:
+ * =================
+ * Contains the Tx packet parameters required for the Tx process, including
+ *   the Tx descriptor and the attributes required for HW-queue calculations.
+ * Allocated for each packet sent from the upper driver and freed upon Tx-complete.
+ * The entry index is the descriptor-ID written in the descriptor and copied back in 
+ *   the tx-complete results.
+ */
+typedef struct _txCtrlBlkEntry_t
+{
+       struct _txCtrlBlkEntry_t * pNextFreeEntry;      /* Pointer to the next free entry. */
+       
+       DbTescriptor  txDescriptor; /* The packet descriptor copied to the FW. */
+
+       TxPktParams_t   txPktParams;  /* Per packet parameters not included in the descriptor. */
+
+} txCtrlBlkEntry_t;
+
+
+typedef void (*TnetDrv_callback_t)(TI_HANDLE CB_Handle); 
+
+/* Data path constant parametrs */
+#define  DP_RX_PACKET_RING_CHUNK_SIZE 1600
+#define  DP_TX_PACKET_RING_CHUNK_SIZE 1600 
+#define  DP_RX_PACKET_RING_CHUNK_NUM 2 
+#define  DP_TX_PACKET_RING_CHUNK_NUM 2
+#define  DP_TX_COMPLETE_TIME_OUT 20
+
+#endif  /* TNETW_DRIVER_TYPES_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.c
new file mode 100644 (file)
index 0000000..8bb0381
--- /dev/null
@@ -0,0 +1,1253 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  CmdMBox.c
+ *   PURPOSE: Handle the wlan hardware command mailbox
+ *   
+ ****************************************************************************/
+#include "osTIType.h"
+#include "whalCommon.h"
+#include "TNETWIF.h"
+#include "whalHwDefs.h"
+#include "FwEvent_api.h"
+#include "CmdQueue_api.h"
+#include "CmdMBox_api.h"
+#include "CmdMBox.h"
+#include "tnetwCommon.h"
+#include "osApi.h"
+
+/* Check if HostIfReg is On. This function is used on SDIO only. */
+int CmdMbox_CheckAndAck(TI_HANDLE hTNETWIF, UINT32 Intr);
+
+#define CMDMBOX_DEBUG_PRINT 0
+
+#ifdef REPORT_LOG
+#define CMDMBOX_CHECK_STATUS \
+    switch (pCmdMBox->HW_CmdMBox.cmdStatus) \
+    { \
+       case CMD_STATUS_SUCCESS: \
+               { \
+                       WLAN_REPORT_INFORMATION(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG, \
+                              ("CMD_MBOX: CMD_STATUS_SUCCESS\n")); \
+                       break; \
+               } \
+       case CMD_STATUS_REJECT_MEAS_SG_ACTIVE: \
+               { \
+                       WLAN_REPORT_INFORMATION(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG, \
+                              ("CMD_MBOX: ERROR: CMD_STATUS_REJECT_MEAS_SG_ACTIVE received\n")); \
+            break; \
+               } \
+       case CMD_MAILBOX_IDLE: \
+       case CMD_STATUS_UNKNOWN_CMD: \
+       case CMD_STATUS_UNKNOWN_IE: \
+    case CMD_STATUS_RX_BUSY: \
+    case CMD_STATUS_INVALID_PARAM: \
+    case CMD_STATUS_TEMPLATE_TOO_LARGE: \
+    case CMD_STATUS_OUT_OF_MEMORY: \
+    case CMD_STATUS_STA_TABLE_FULL: \
+       case CMD_STATUS_RADIO_ERROR: \
+       case CMD_STATUS_WRONG_NESTING: \
+               { \
+                       /* print the error */ \
+            WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG, \
+                              ("%s: ERROR: %s (%d), command: %s (%d), IE: %s (%d)\n", \
+                               __FUNCTION__, CmdQueue_GetErrorString(pCmdMBox->HW_CmdMBox.cmdStatus), \
+                               pCmdMBox->HW_CmdMBox.cmdStatus, \
+                               CmdQueue_GetCmdString(pCmdMBox->HW_CmdMBox.cmdID), \
+                               pCmdMBox->HW_CmdMBox.cmdID, \
+                               CmdQueue_GetIEString(pCmdMBox->HW_CmdMBox.cmdID, *(UINT16*)&(pCmdMBox->HW_CmdMBox.parameters)), \
+                               *(UINT16*)&(pCmdMBox->HW_CmdMBox.parameters))); \
+                       /* continue as if the command succedded */ \
+                       pCmdMBox->HW_CmdMBox.cmdStatus = (uint16)CMD_STATUS_SUCCESS; \
+                       break; \
+               } \
+    case CMD_STATUS_TIMEOUT: \
+       case CMD_STATUS_FW_RESET: \
+       default: \
+        /* if the FW is not responding, start recovery */ \
+        { \
+            CmdQueue_Error(pCmdMBox->hCmdQueue); \
+                       break; \
+        } \
+       } /* end of switch */
+#else
+#define CMDMBOX_CHECK_STATUS \
+    switch (pCmdMBox->HW_CmdMBox.cmdStatus) \
+    { \
+       case CMD_STATUS_SUCCESS: \
+               { \
+                       break; \
+               } \
+       case CMD_STATUS_REJECT_MEAS_SG_ACTIVE: \
+               { \
+            break; \
+               } \
+       case CMD_MAILBOX_IDLE: \
+       case CMD_STATUS_UNKNOWN_CMD: \
+       case CMD_STATUS_UNKNOWN_IE: \
+    case CMD_STATUS_RX_BUSY: \
+    case CMD_STATUS_INVALID_PARAM: \
+    case CMD_STATUS_TEMPLATE_TOO_LARGE: \
+    case CMD_STATUS_OUT_OF_MEMORY: \
+    case CMD_STATUS_STA_TABLE_FULL: \
+       case CMD_STATUS_RADIO_ERROR: \
+       case CMD_STATUS_WRONG_NESTING: \
+               { \
+                       /* continue as if the command succedded */ \
+                       pCmdMBox->HW_CmdMBox.cmdStatus = (uint16)CMD_STATUS_SUCCESS; \
+                       break; \
+               } \
+    case CMD_STATUS_TIMEOUT: \
+       case CMD_STATUS_FW_RESET: \
+       default: \
+        /* if the FW is not responding, start recovery */ \
+        { \
+            CmdQueue_Error(pCmdMBox->hCmdQueue); \
+                       break; \
+        } \
+       } /* end of switch */
+#endif /* REPORT_LOG */
+
+
+#if CMDMBOX_DEBUG_PRINT
+static char *StateString_array[16] = {
+    "CMDMBOX_STATE_SENDCMD_NORMAL_IDLE",  /* 0 */
+    "CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS",  /* 1 */
+    "CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF",  /* 2 */
+    "CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v",  /* 3 */
+    "CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG",  /* 4 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE",  /* 5 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS",  /* 6 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_BUF",  /* 7 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v",  /* 8 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG",  /* 9 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v",  /* 10 */
+    "CMDMBOX_STATE_SENDCMD_BLOCKING_FINISH_v",  /* 11 */
+    "CMDMBOX_STATE_GETRESULT_NORMAL_IDLE",  /* 12 */
+    "CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN",  /* 13 */
+    "CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE",  /* 14 */
+    "CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN",  /* 15 */  
+};
+static char *StateString[NUM_COMMANDS];
+
+static char *EventString[CMDMBOX_EVENT_NUM] = {
+    "CMDMBOX_EVENT_SEND_CMD",  /* 1 */
+    "CMDMBOX_EVENT_CMD_CMPLT",  /* 2 */
+    "CMDMBOX_EVENT_BUS_READY",  /* 3 */
+    "CMDMBOX_EVENT_TXN_CMPLT",  /* 4 */
+    "CMDMBOX_EVENT_GET_RESULT",  /* 5 */
+};
+
+#endif
+
+/****************************************************************************
+ *                      CmdMBox_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the mailbox object
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+TI_HANDLE       CmdMBox_Create(TI_HANDLE hOs)
+{
+    CmdMBox_T *pObj;
+
+    pObj = os_memoryAlloc (hOs, sizeof(CmdMBox_T));
+    if (pObj == NULL)
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: CmdMBox_Create(): Error Creating CmdMBox - Aborting\n"));
+        return NULL;
+    }
+
+    /* reset control module control block */
+    os_memoryZero(hOs, pObj, sizeof(CmdMBox_T));
+    pObj->hOs = hOs;
+
+    /* allocates Timer to use for CmdMBox timeout*/
+    pObj->hTimer = os_timerCreate(hOs, CmdMBox_TimeOut, pObj);
+    if (pObj->hTimer == NULL)
+    {
+        CmdMBox_Destroy(pObj);
+        WLAN_OS_REPORT(("FATAL ERROR: CmdMBox_Create(): Error Creating CmdMBox Timer- Aborting\n"));
+        return NULL;
+    }
+
+#if CMDMBOX_DEBUG_PRINT
+    StateString[0] = StateString_array[0];
+    StateString[1] = StateString_array[1];
+    StateString[2] = StateString_array[2];
+    StateString[3] = StateString_array[3];
+    StateString[4] = StateString_array[4];
+    StateString[10] = StateString_array[5];
+    StateString[11] = StateString_array[6];
+    StateString[12] = StateString_array[7];
+    StateString[13] = StateString_array[8];
+    StateString[14] = StateString_array[9];
+    StateString[15] = StateString_array[10];
+    StateString[16] = StateString_array[11];
+    StateString[20] = StateString_array[12];
+    StateString[21] = StateString_array[13];
+    StateString[30] = StateString_array[14];
+    StateString[31] = StateString_array[15];
+#endif
+
+    return(pObj);
+}
+
+/****************************************************************************
+ *                      CmdMBox_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object 
+ * 
+ * INPUTS:  
+ *      hCmdMBox        The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int             CmdMBox_Destroy(TI_HANDLE hCmdMBox)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+
+    /* free timer */
+    if (pCmdMBox->hTimer)
+        utils_nullTimerDestroy(pCmdMBox->hOs, pCmdMBox->hTimer);
+    
+    /* free context */
+       os_memoryFree(pCmdMBox->hOs, pCmdMBox, sizeof(CmdMBox_T));
+    
+    return OK;
+}
+
+/****************************************************************************
+ *                      CmdMBox_Config()
+ *****************************************************************************
+ * DESCRIPTION: Configure the object 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int CmdMBox_Config (TI_HANDLE hCmdMBox, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent, TI_HANDLE hCmdQueue, TI_HANDLE hReport)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    
+    pCmdMBox->hReport = hReport;
+    pCmdMBox->hTNETWIF = hTNETWIF;
+    pCmdMBox->hFwEvent = hFwEvent;
+    pCmdMBox->hCmdQueue = hCmdQueue;
+    
+    pCmdMBox->GetResultNormal_State = CMDMBOX_STATE_GETRESULT_NORMAL_IDLE;
+    pCmdMBox->GetResultBlocking_State = CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE;
+    pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_IDLE;
+    pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE;
+    pCmdMBox->ActiveSM = NULL;  
+    
+  #ifdef USE_SYNC_API /* Blocking mode is using Synch IF  */
+    pCmdMBox->SendCmdSM = CmdMBox_SM_SendCmdBlocking;
+    pCmdMBox->GetResultSM = CmdMBox_SM_GetResultBlocking;   
+  #else
+    pCmdMBox->SendCmdSM = CmdMBox_SM_SendCmdNormal;
+    pCmdMBox->GetResultSM = CmdMBox_SM_GetResultNormal; 
+  #endif
+
+    pCmdMBox->CmdMBox_FW_address = 0;
+    pCmdMBox->GetResult_ParamsBuf = NULL;
+    pCmdMBox->GetResult_ParamsLen = 0;
+   
+    os_timerStop (pCmdMBox->hOs, pCmdMBox->hTimer);
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      CmdMBox_ConfigCb()
+ ****************************************************************************
+ * DESCRIPTION: Configure the mailbox address callback
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static void CmdMBox_ConfigHwCb (TI_HANDLE hCmdMBox, UINT8 module_id, TI_STATUS status)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+
+    WLAN_REPORT_INIT (pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,  
+                      ("CmdMBox_ConfigHw: CmdMBox FW address = 0x%x\n", 
+                      pCmdMBox->CmdMBox_FW_address));
+
+    /* Call upper layer callback */
+    pCmdMBox->fCb (pCmdMBox->hCb, module_id, OK);
+}
+
+
+/****************************************************************************
+ *                      CmdMBox_ConfigHw()
+ ****************************************************************************
+ * DESCRIPTION: Configure the mailbox address 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS CmdMBox_ConfigHw (TI_HANDLE hCmdMBox, UINT8 module_id, fnotify_t fCb, TI_HANDLE hCb)
+{
+    CmdMBox_T *pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    int        status;
+
+    pCmdMBox->fCb = (TNETWIF_callback_t)fCb;
+    pCmdMBox->hCb = hCb;
+
+    /* 
+     * Get the command mailbox address
+     */
+    status = TNETWIF_ReadRegOpt (pCmdMBox->hTNETWIF, 
+                                 REG_COMMAND_MAILBOX_PTR, 
+                                 &pCmdMBox->CmdMBox_FW_address,
+                                 module_id,
+                                 CmdMBox_ConfigHwCb,
+                                 hCmdMBox);
+
+    switch (status)
+    {
+    case TNETWIF_ERROR:
+        WLAN_REPORT_FATAL_ERROR (pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,  
+                                 ("CmdMBox_ConfigHw: ERROR reading Mailbox addresses (0x%x) !!!\n", 
+                                 pCmdMBox->CmdMBox_FW_address ));
+        break;
+
+    case TNETWIF_COMPLETE:
+        WLAN_REPORT_INIT (pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,  
+                          ("CmdMBox_ConfigHw: CmdMBox FW address = 0x%x\n", 
+                          pCmdMBox->CmdMBox_FW_address));
+        break;
+    }
+       
+    return (TI_STATUS)status;
+}
+
+/****************************************************************************
+ *                      CmdMBox_SetMode()
+ ****************************************************************************
+ * DESCRIPTION: Set the operational mode from blocking to normal
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int CmdMBox_SetModeNormal (TI_HANDLE hCmdMBox)
+{
+  #if defined(USE_SYNC_API)
+
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+
+    /* Set the state to NORMAL */
+    pCmdMBox->SendCmdSM = CmdMBox_SM_SendCmdNormal;
+    pCmdMBox->GetResultSM = CmdMBox_SM_GetResultNormal; 
+    
+    FwEvent_Enable (pCmdMBox->hFwEvent, ACX_INTR_CMD_COMPLETE);
+    
+    WLAN_REPORT_INFORMATION (pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+            ("CmdMBox_SetMode: CmdMBox mode is now NORMAL"));       
+
+
+  #endif
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      CmdMBox_Reconfig()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                 CmdMBox_Restart(TI_HANDLE hCmdMBox)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    
+    return CmdMBox_Config(hCmdMBox, pCmdMBox->hTNETWIF, pCmdMBox->hFwEvent, pCmdMBox->hCmdQueue, pCmdMBox->hReport);
+}
+
+
+/****************************************************************************
+ *                      CmdMBox_SendCmd()
+ ****************************************************************************
+ * DESCRIPTION: Try to send the Command to the Mailbox
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                 CmdMBox_SendCmd(TI_HANDLE hCmdMBox, Command_e cmdType, UINT8* pParamsBuf, UINT32 paramsLen)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    
+    /* prepare the Cmd Hw template */
+    pCmdMBox->HW_CmdMBox.cmdID = cmdType;
+    pCmdMBox->HW_CmdMBox.cmdStatus = OK; 
+    os_memoryCopy(pCmdMBox->hOs, (void*)pCmdMBox->HW_CmdMBox.parameters, (void*)pParamsBuf, paramsLen);
+    /* must make sure that the length is multiple of 32bit */
+    if(paramsLen&0x3)
+        paramsLen  = (paramsLen + 4) & 0xFFFFFFFC;  
+    pCmdMBox->CmdLen = paramsLen + CMDMBOX_HEADER_LEN;  
+
+    pCmdMBox->ActiveSM = pCmdMBox->SendCmdSM;
+    return  pCmdMBox->ActiveSM(hCmdMBox, CMDMBOX_EVENT_SEND_CMD);
+}
+
+/****************************************************************************
+ *                      CmdMBox_GetResult()
+ ****************************************************************************
+ * DESCRIPTION: Get result of the Cmd
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int                 CmdMBox_GetResult(TI_HANDLE hCmdMBox, UINT8* pParamsBuf, UINT32 paramsLen, UINT32* pStatus)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    int rc;
+
+    pCmdMBox->GetResult_ParamsBuf = pParamsBuf;
+    pCmdMBox->GetResult_ParamsLen= paramsLen;
+    
+
+    pCmdMBox->ActiveSM = pCmdMBox->GetResultSM;
+    rc = pCmdMBox->ActiveSM(hCmdMBox, CMDMBOX_EVENT_GET_RESULT);
+
+       if (pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_SUCCESS || pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_REJECT_MEAS_SG_ACTIVE) 
+               {
+                       *pStatus = OK;
+               }
+               else
+               {
+                       *pStatus = NOK;
+               }
+    return rc;
+}
+
+/****************************************************************************
+ *                      CmdMBox_CmdCmplt()
+ ****************************************************************************
+ * DESCRIPTION: CallBack for command complete interrupt
+ * 
+ * INPUTS:  CbFunc  The Callback will be called we upon command complete interrupt 
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+TI_STATUS  CmdMBox_CmdCmplt(TI_HANDLE hCmdMBox)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    TI_STATUS  rc;
+
+    pCmdMBox->ActiveSM = pCmdMBox->SendCmdSM;
+    rc = (TI_STATUS)pCmdMBox->ActiveSM (hCmdMBox, CMDMBOX_EVENT_CMD_CMPLT);
+    if (rc == TNETWIF_COMPLETE)
+        rc = TNETWIF_OK;
+    return rc;
+}
+
+/****************************************************************************
+ *                      CmdMBox_TxnCmplt()
+ ****************************************************************************
+ * DESCRIPTION: CallBack for Txn complete
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void                CmdMBox_TxnCmplt(TI_HANDLE hCmdMBox, UINT8 module_id ,TI_STATUS status)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    
+    pCmdMBox->ActiveSM(hCmdMBox, CMDMBOX_EVENT_TXN_CMPLT);
+}
+
+/****************************************************************************
+ *                      CmdMBox_BusReady()
+ ****************************************************************************
+ * DESCRIPTION: CallBack for Txn complete
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void                CmdMBox_BusReady(TI_HANDLE hCmdMBox, UINT8 module_id ,TI_STATUS status)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    
+    pCmdMBox->ActiveSM(hCmdMBox, CMDMBOX_EVENT_BUS_READY);
+}
+
+/****************************************************************************
+ *                      CmdMBox_SM_GetResultNormal()
+ ****************************************************************************
+ * DESCRIPTION: CmdMBox SM
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int             CmdMBox_SM_GetResultNormal(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event)
+{
+    int rc = OK;
+    BOOLEAN breakWhile = FALSE;
+    
+    while(!breakWhile)
+    {
+#if CMDMBOX_DEBUG_PRINT
+        WLAN_OS_REPORT(("CmdMBox_SM_GetResultNormal: state = %s (%d) event = %s(%d)\n",
+            StateString[pCmdMBox->GetResultNormal_State],
+            pCmdMBox->GetResultNormal_State,
+            EventString[event],
+            event));
+#endif
+        switch(pCmdMBox->GetResultNormal_State)
+        {
+            /***************************************
+            CMDMBOX_STATE_GETRESULT_NORMAL_IDLE
+            ***************************************/
+            case CMDMBOX_STATE_GETRESULT_NORMAL_IDLE:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_GET_RESULT:
+
+                        /* read the results */
+                        if(pCmdMBox->GetResult_ParamsBuf)
+                        {                       
+                            /* need to read the results also */
+                            rc = TNETWIF_ReadMemOpt (pCmdMBox->hTNETWIF, 
+                                                     pCmdMBox->CmdMBox_FW_address, 
+                                                     PADREAD (&pCmdMBox->HW_CmdMBox), 
+                                                     pCmdMBox->GetResult_ParamsLen + CMDMBOX_HEADER_LEN,
+                                                     FW_EVENT_MODULE_ID, 
+                                                     CmdMBox_TxnCmplt, 
+                                                     pCmdMBox);
+                        }
+                        else
+                        {
+                            /* need to read the status only */                          
+                            rc = TNETWIF_ReadMemOpt (pCmdMBox->hTNETWIF, 
+                                                     pCmdMBox->CmdMBox_FW_address, 
+                                                     PADREAD (&pCmdMBox->HW_CmdMBox), 
+                                                     CMDMBOX_HEADER_LEN,
+                                                     FW_EVENT_MODULE_ID, 
+                                                     CmdMBox_TxnCmplt, 
+                                                     pCmdMBox);
+                        }                       
+
+                        if(rc == TNETWIF_PENDING)
+                        {
+                            pCmdMBox->GetResultNormal_State = CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN;
+                        }
+                        else
+                        {
+
+                            /* check the status */
+                            CMDMBOX_CHECK_STATUS;                           
+
+                            /* 
+                            if GetResult_ParamsBuf is NULL then we only need to check the status and then 
+                            we don't need to copy the results 
+                            */
+                            if(pCmdMBox->GetResult_ParamsBuf)
+                            {
+                                /* copy the results to the caller buffer */
+                                os_memoryCopy(pCmdMBox->hOs, (void*)pCmdMBox->GetResult_ParamsBuf, (void*)pCmdMBox->HW_CmdMBox.parameters, pCmdMBox->GetResult_ParamsLen);
+                            }
+                            
+                            pCmdMBox->GetResultNormal_State = CMDMBOX_STATE_GETRESULT_NORMAL_IDLE;
+                        }               
+                        breakWhile = TRUE;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_GetResultNormal: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_GETRESULT_NORMAL_IDLE\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN
+            ***************************************/
+            case CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_TXN_CMPLT:
+
+                        /* check the status */
+                        CMDMBOX_CHECK_STATUS;
+
+                        /* 
+                        if GetResult_ParamsBuf is NULL then we only need to check the status and then 
+                        we don't need to copy the results 
+                        */
+                        if(pCmdMBox->GetResult_ParamsBuf)
+                        {
+                            /* copy the results to the caller buffer */
+                            os_memoryCopy(pCmdMBox->hOs, (void*)pCmdMBox->GetResult_ParamsBuf, (void*)pCmdMBox->HW_CmdMBox.parameters, pCmdMBox->GetResult_ParamsLen);
+                        }
+                        
+                        /* call the CmdQueue CB */
+                        if (pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_SUCCESS || pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_REJECT_MEAS_SG_ACTIVE) 
+                                               {
+                                                       CmdQueue_ResultReceived(pCmdMBox->hCmdQueue, OK);
+                                               }
+                                               else
+                                               {
+                                                       CmdQueue_ResultReceived(pCmdMBox->hCmdQueue, NOK);
+                                               }
+                        
+                        FwEvent_EventComplete(pCmdMBox->hFwEvent, TNETWIF_OK);
+                        pCmdMBox->GetResultNormal_State = CMDMBOX_STATE_GETRESULT_NORMAL_IDLE;
+                        return OK;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_GetResultNormal: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN\n",event));     
+                            return NOK;
+                }
+/*                break;  */
+            default:
+                WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                    ("CmdMBox_SM_GetResultNormal: ** ERROR **  No such state (%d)\n",pCmdMBox->GetResultNormal_State));     
+                    return NOK;
+        }
+    }
+       
+    return rc;
+    
+}
+
+
+#ifdef USE_SYNC_API
+
+/****************************************************************************
+ *                      CmdMBox_SM_GetResultBlocking()
+ ****************************************************************************
+ * DESCRIPTION: CmdMBox SM
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int             CmdMBox_SM_GetResultBlocking(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event)
+{
+    int rc = OK;
+    BOOLEAN breakWhile = FALSE;
+    
+    while(!breakWhile)
+    {
+#if CMDMBOX_DEBUG_PRINT
+        WLAN_OS_REPORT(("CmdMBox_SM_GetResultBlocking: state = %s (%d) event = %s(%d)\n",
+            StateString[pCmdMBox->GetResultBlocking_State],
+            pCmdMBox->GetResultBlocking_State,
+            EventString[event],
+            event));
+#endif
+        switch(pCmdMBox->GetResultBlocking_State)
+        {
+            /***************************************
+            CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE
+            ***************************************/
+            case CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_GET_RESULT:
+                        /* read the results */
+                        if(pCmdMBox->GetResult_ParamsBuf)
+                        {
+                            /* need to read the results also */
+                            rc = TNETWIF_ReadMemSync (pCmdMBox->hTNETWIF, 
+                                                      pCmdMBox->CmdMBox_FW_address, 
+                                                      PADREAD(&pCmdMBox->HW_CmdMBox), 
+                                                      pCmdMBox->GetResult_ParamsLen + CMDMBOX_HEADER_LEN);
+                        }
+                        else
+                        {
+                            rc = TNETWIF_ReadMemSync (pCmdMBox->hTNETWIF, 
+                                                      pCmdMBox->CmdMBox_FW_address, 
+                                                      PADREAD (&pCmdMBox->HW_CmdMBox), 
+                                                      CMDMBOX_HEADER_LEN);                         
+                        }
+
+                        if(rc == TNETWIF_PENDING)
+                        {
+                            pCmdMBox->GetResultBlocking_State = CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN;
+                        }
+                        else
+                        {
+                            /* check the status */
+                            CMDMBOX_CHECK_STATUS;
+
+                            /* 
+                            if GetResult_ParamsBuf is NULL then we only need to check the status and then 
+                            we don't need to copy the results 
+                            */
+                            if(pCmdMBox->GetResult_ParamsBuf)
+                            {
+                                /* copy the results to the caller buffer */
+                                os_memoryCopy(pCmdMBox->hOs, (void*)pCmdMBox->GetResult_ParamsBuf, (void*)pCmdMBox->HW_CmdMBox.parameters, pCmdMBox->GetResult_ParamsLen);
+                            }               
+                        }               
+                        breakWhile = TRUE;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_GetResultBlocking: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN
+            ***************************************/
+            case CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN:
+                switch(event)
+                {
+                               case CMDMBOX_EVENT_TXN_CMPLT:
+                                               
+                        /* check the status */
+                        CMDMBOX_CHECK_STATUS;
+
+                        /* 
+                        if GetResult_ParamsBuf is NULL then we only need to check the status and then 
+                        we don't need to copy the results 
+                        */
+                        if(pCmdMBox->GetResult_ParamsBuf)
+                        {
+                            /* copy the results to the caller buffer */
+                            os_memoryCopy(pCmdMBox->hOs, (void*)pCmdMBox->GetResult_ParamsBuf, (void*)pCmdMBox->HW_CmdMBox.parameters, pCmdMBox->GetResult_ParamsLen);
+                        }
+
+                        /* call the CmdQueue CB */
+                                               if (pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_SUCCESS || pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_REJECT_MEAS_SG_ACTIVE) 
+                                               {
+                                                       CmdQueue_ResultReceived(pCmdMBox->hCmdQueue, OK);
+                                               }
+                                               else
+                                               {
+                                                       CmdQueue_ResultReceived(pCmdMBox->hCmdQueue, NOK);
+                                               }
+                        
+
+                        pCmdMBox->GetResultBlocking_State = CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE;
+                        breakWhile = TRUE;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_GetResultBlocking: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN\n",event));     
+                            return NOK;
+                }
+                break;
+            default:
+                WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                    ("CmdMBox_SM_GetResultBlocking: ** ERROR **  No such state (%d)\n",pCmdMBox->GetResultBlocking_State));     
+                    return NOK;
+        }
+    }
+    return rc;
+    
+}
+
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      CmdMBox_SM_SendCmdNormal()
+ ****************************************************************************
+ * DESCRIPTION: CmdMBox SM
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int             CmdMBox_SM_SendCmdNormal(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event)
+{
+    int rc = OK;
+    BOOLEAN breakWhile = FALSE;
+    
+    while(!breakWhile)
+{
+#if CMDMBOX_DEBUG_PRINT
+        WLAN_OS_REPORT(("CmdMBox_SM_SendCmdNormal: state = %s (%d) event = %s(%d) rc = %d\n",
+            StateString[pCmdMBox->SendCmdNormal_State],
+            pCmdMBox->SendCmdNormal_State,
+            EventString[event],
+            event,rc));
+#endif
+        switch(pCmdMBox->SendCmdNormal_State)
+        {
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_NORMAL_IDLE
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_NORMAL_IDLE:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_SEND_CMD:                                            
+                        pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS;
+                        /* ask for the bus */
+                        TNETWIF_Start (pCmdMBox->hTNETWIF,   HAL_CMD_MODULE_ID, 
+                            pCmdMBox, CmdMBox_BusReady);        
+                        rc = TNETWIF_PENDING;
+                        breakWhile = TRUE;
+                        break;
+                    case CMDMBOX_EVENT_CMD_CMPLT:
+                        /* stop timeout timer */
+                        os_timerStop(pCmdMBox->hOs, pCmdMBox->hTimer);
+
+                        /* call the CmdQueue CB */
+                        rc = CmdQueue_SendCmplt(pCmdMBox->hCmdQueue);                       
+                        breakWhile = TRUE;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdNormal: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_NORMAL_IDLE\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_BUS_READY:                       
+                        /* write the Cmd - subtract offset for the bus reserved place */
+            rc = TNETWIF_WriteMemOpt (pCmdMBox->hTNETWIF, 
+                                                  pCmdMBox->CmdMBox_FW_address, 
+                                                  PADWRITE (&pCmdMBox->HW_CmdMBox), 
+                                                  pCmdMBox->CmdLen,
+                                                  HAL_CMD_MODULE_ID, 
+                                                  CmdMBox_TxnCmplt, 
+                                                  pCmdMBox);
+            if(rc == TNETWIF_PENDING)
+                     {
+                            pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF;  
+                            breakWhile = TRUE;
+                     }
+                     else
+                     {
+                            pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v;                              
+                    }
+                     break;
+                        default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                                ("CmdMBox_SM_SendCmdNormal: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_TXN_CMPLT:                       
+                        pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v;                          
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdNormal: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v:
+                /* start timeout timer */
+#ifdef DM_USE_WORKQUEUE
+                os_timerStart(pCmdMBox->hOs, pCmdMBox->hTimer,
+                      CMDMBOX_WAIT_TIMEOUT * 2, FALSE); /* Dm: Wait for 1000 ms */
+#else
+                os_timerStart(pCmdMBox->hOs, pCmdMBox->hTimer,
+                      CMDMBOX_WAIT_TIMEOUT, FALSE);
+#endif
+
+                /* write the FW trigger */
+                rc = TNETWIF_WriteRegOpt (pCmdMBox->hTNETWIF, 
+                                          ACX_REG_INTERRUPT_TRIG, 
+                                          INTR_TRIG_CMD,
+                                          HAL_CMD_MODULE_ID, 
+                                          CmdMBox_TxnCmplt, 
+                                          pCmdMBox);
+                if(rc == TNETWIF_PENDING)
+                {
+                    pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG;
+                }
+                else
+                {
+                    pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_IDLE;
+                    /* release the bus resource*/
+                    TNETWIF_Finish (pCmdMBox->hTNETWIF, HAL_CMD_MODULE_ID, NULL, NULL);
+                }
+                breakWhile = TRUE;
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_TXN_CMPLT:                       
+                        pCmdMBox->SendCmdNormal_State = CMDMBOX_STATE_SENDCMD_NORMAL_IDLE;                          
+                        /* release the bus resource*/
+                        TNETWIF_Finish (pCmdMBox->hTNETWIF, HAL_CMD_MODULE_ID, NULL, NULL);
+            rc = OK;
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdNormal: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG\n",event));        
+                            return NOK;
+                }
+                breakWhile = TRUE;
+                break;
+            default:
+                WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                    ("CmdMBox_SM_SendCmdNormal: ** ERROR **  No such state (%d)\n",pCmdMBox->SendCmdNormal_State));     
+                    return NOK;
+        }
+    }
+#if CMDMBOX_DEBUG_PRINT
+        WLAN_OS_REPORT(("CmdMBox_SM_SendCmdNormal return = %d\n",rc));
+#endif
+    return rc;
+    
+}
+
+
+#ifdef USE_SYNC_API
+
+/****************************************************************************
+ *                      CmdMBox_SM_SendCmdBlocking()
+ ****************************************************************************
+ * DESCRIPTION: CmdMBox SM
+ * 
+ * INPUTS:  
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int             CmdMBox_SM_SendCmdBlocking(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event)
+{
+    int rc = OK;
+    BOOLEAN breakWhile = FALSE;
+    BOOLEAN CmdCmpltFlag = FALSE;
+
+    static UINT32 timeoutCounterExpire;
+    static UINT32 timeoutCounter;
+    
+    while(!breakWhile)
+    {
+#if CMDMBOX_DEBUG_PRINT
+        WLAN_OS_REPORT(("CmdMBox_SM_SendCmdBlocking: state = %s (%d) event = %s(%d) rc = %d\n",
+            StateString[pCmdMBox->SendCmdBlocking_State],
+            pCmdMBox->SendCmdBlocking_State,
+            EventString[event],
+            event,rc));
+#endif
+        switch(pCmdMBox->SendCmdBlocking_State)
+        {
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_SEND_CMD:                        
+
+                        pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS;
+                       
+                        /* use the bus directly - it's O.K. since it's the init phase */
+                        event = CMDMBOX_EVENT_BUS_READY;
+
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdBlocking: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_BUS_READY:  
+                        /* write the Cmd */
+                        rc = TNETWIF_WriteMemSync (pCmdMBox->hTNETWIF, 
+                                                   pCmdMBox->CmdMBox_FW_address, 
+                                                   PADWRITE (&pCmdMBox->HW_CmdMBox), 
+                                                   pCmdMBox->CmdLen);
+
+                        pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v;
+
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdBlocking: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_BUF
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_BUF:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_TXN_CMPLT:                       
+                        pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v;                          
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdBlocking: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_BUF\n",event));     
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v:
+                /* init timeout counter */              
+                timeoutCounterExpire = (CMDMBOX_WAIT_TIMEOUT*CMDMBOX_US_TO_MS)/CMDMBOX_WAIT_CMPLT_STALL_TIME;
+                timeoutCounter = 0;
+
+                /* write the FW trigger */
+                if(pCmdMBox->useOpt) 
+                rc = TNETWIF_WriteRegOpt  (pCmdMBox->hTNETWIF, 
+                                               ACX_REG_INTERRUPT_TRIG, 
+                                               INTR_TRIG_CMD,
+                                               HAL_CMD_MODULE_ID, 
+                                               CmdMBox_TxnCmplt, 
+                                               pCmdMBox);
+                else
+                    rc = TNETWIF_WriteRegSync (pCmdMBox->hTNETWIF, 
+                                               ACX_REG_INTERRUPT_TRIG, 
+                                               INTR_TRIG_CMD);
+               
+                if(rc == TNETWIF_PENDING)
+                {
+                    pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG;
+                    breakWhile = TRUE;
+                }
+                else
+                {
+                    pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG:
+                switch(event)
+                {
+                    case CMDMBOX_EVENT_TXN_CMPLT:                       
+                        pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v;                          
+                        break;
+                    default:
+                        WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                            ("CmdMBox_SM_SendCmdBlocking: ** ERROR **  No such event (%d) for state CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG\n",event));        
+                            return NOK;
+                }
+                break;
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v:                               
+                /* check CmdCmplt */
+                /* the following function is done in synchronize mode */
+                timeoutCounter++;
+                CmdCmpltFlag = CmdMbox_CheckAndAck(pCmdMBox->hTNETWIF, ACX_INTR_CMD_COMPLETE);
+                pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_FINISH_v;
+                break;
+
+            /***************************************
+            CMDMBOX_STATE_SENDCMD_BLOCKING_FINISH_v
+            ***************************************/
+            case CMDMBOX_STATE_SENDCMD_BLOCKING_FINISH_v:                               
+                /* check CmdCmplt */
+                if(CmdCmpltFlag == FALSE)
+                {
+                    /* check timeout counter */
+                    if(timeoutCounter == timeoutCounterExpire)
+                        CmdMBox_TimeOut(pCmdMBox);
+                        
+                    pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v;
+                    os_StalluSec(pCmdMBox->hOs, CMDMBOX_WAIT_CMPLT_STALL_TIME);
+                }
+                else
+                {
+                    /* stop timeout timer */
+                    os_timerStop(pCmdMBox->hOs, pCmdMBox->hTimer);
+
+                    pCmdMBox->SendCmdBlocking_State = CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE;
+                    
+                    /* call the CmdQueue CB */
+                    rc = CmdQueue_SendCmplt(pCmdMBox->hCmdQueue);
+                    breakWhile = TRUE;
+                }
+                break;
+            default:
+                WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+                    ("CmdMBox_SM_SendCmdBlocking: ** ERROR **  No such state (%d)\n",pCmdMBox->SendCmdBlocking_State));     
+                    return NOK;
+        }
+    }
+#if CMDMBOX_DEBUG_PRINT
+        WLAN_OS_REPORT(("CmdMBox_SM_SendCmdBlocking rc = %d\n",rc));
+#endif
+    return rc;
+}
+#endif /* USE_SYNC_API */
+/****************************************************************************
+ *                      CmdMBox_TimeOut()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK, ERROR
+ ****************************************************************************/
+void            CmdMBox_TimeOut(TI_HANDLE hCmdMBox)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    
+    WLAN_REPORT_ERROR(pCmdMBox->hReport, CMD_MBOX_MODULE_LOG,
+            ("CmdMBox_TimeOut: Timeout occured in CmdMBox\n"));
+
+    /* call error CB */
+    CmdQueue_Error(pCmdMBox->hCmdQueue);
+    
+    return;
+}
+
+/****************************************************************************
+ *                      CmdMbox_CheckAndAck()
+ ****************************************************************************
+ * DESCRIPTION: Check if HostIfReg is On
+ *              This function is used on SDIO only.
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK, ERROR
+ ****************************************************************************/
+
+int CmdMbox_CheckAndAck (TI_HANDLE hTNETWIF, UINT32 Intr)
+{
+  #ifdef USE_SYNC_API
+
+    UINT32 Reg_IntrNoClear;
+
+    TNETWIF_ReadRegSync(hTNETWIF,ACX_REG_INTERRUPT_NO_CLEAR, &Reg_IntrNoClear);  
+    
+    if (IS_MASK_ON (Reg_IntrNoClear, Intr))
+    {
+        TNETWIF_WriteRegSync (hTNETWIF, ACX_REG_INTERRUPT_ACK, Intr);
+        return 1;
+    }
+
+  #endif /* USE_SYNC_API */
+
+    return 0;   
+}
+
+TI_STATUS CmdMBox_GetStatus(TI_HANDLE hCmdMBox)
+{
+    CmdMBox_T* pCmdMBox = (CmdMBox_T*)hCmdMBox;
+    TI_STATUS Status;
+    Status = (pCmdMBox->HW_CmdMBox.cmdStatus == CMD_STATUS_SUCCESS) ? OK : NOK;
+
+       switch (pCmdMBox->HW_CmdMBox.cmdStatus)
+    { 
+               case CMD_STATUS_SUCCESS: 
+               {
+            Status = OK;
+                       break;
+               }
+               case CMD_STATUS_REJECT_MEAS_SG_ACTIVE:
+               { 
+                       Status = SG_REJECT_MEAS_SG_ACTIVE;
+            break;
+               }
+               case CMD_MAILBOX_IDLE: 
+               case CMD_STATUS_UNKNOWN_CMD: 
+               case CMD_STATUS_UNKNOWN_IE: 
+               case CMD_STATUS_RX_BUSY: 
+               case CMD_STATUS_INVALID_PARAM: 
+               case CMD_STATUS_TEMPLATE_TOO_LARGE: 
+               case CMD_STATUS_OUT_OF_MEMORY: 
+               case CMD_STATUS_STA_TABLE_FULL: 
+               case CMD_STATUS_RADIO_ERROR: 
+               case CMD_STATUS_WRONG_NESTING: 
+        case CMD_STATUS_TIMEOUT: 
+               case CMD_STATUS_FW_RESET: 
+               default: 
+        { 
+            Status = NOK;
+                       break; 
+        }
+       } /* end of switch */
+
+    WLAN_REPORT_INFORMATION(pCmdMBox->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s - TI_STATUS = %s(%d) <= pCmdMBox->HW_CmdMBox.cmdStatus = %d\n", __FUNCTION__, 
+        (Status==OK)?"OK":"NOK",Status, pCmdMBox->HW_CmdMBox.cmdStatus));
+
+    return Status;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.h
new file mode 100644 (file)
index 0000000..0d7c8e8
--- /dev/null
@@ -0,0 +1,167 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*********************************************************************************/
+/*                                                                                */
+/*   MODULE:  CmdMBox.h                                                       */
+/*   PURPOSE: Acx mailbox object api                                              */
+/*                                                                                */
+/**********************************************************************************/
+#ifndef _CMDMBOX_H_
+#define _CMDMBOX_H_
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+
+/*****************************************************************************
+ **         Defines                                                        **
+ *****************************************************************************/
+ /* wait for a Mail box command to complete  */
+#define CMDMBOX_WAIT_TIMEOUT    500 /* ms */
+
+#define CMDMBOX_HEADER_LEN 4
+#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
+#define CMDMBOX_WAIT_CMPLT_STALL_TIME 50 /* us */
+#define CMDMBOX_US_TO_MS 1000
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+typedef enum 
+{
+    CMDMBOX_EVENT_SEND_CMD,
+    CMDMBOX_EVENT_CMD_CMPLT,
+    CMDMBOX_EVENT_BUS_READY,
+    CMDMBOX_EVENT_TXN_CMPLT,
+    CMDMBOX_EVENT_GET_RESULT,
+    CMDMBOX_EVENT_NUM,
+} CmdMBox_SMEvents_e;
+
+typedef enum 
+{
+    CMDMBOX_STATE_SENDCMD_NORMAL_IDLE = 0,
+    CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS,
+    CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF,
+    CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v,
+    CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG,
+} CmdMBox_SMStates_SendCmd_Normal_e;
+
+typedef enum 
+{
+    CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE = 10,
+    CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS,
+    CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_BUF,
+    CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v,
+    CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG,
+    CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v,
+    CMDMBOX_STATE_SENDCMD_BLOCKING_FINISH_v,
+} CmdMBox_SMStates_SendCmd_Blocking_e;
+
+typedef enum 
+{
+    CMDMBOX_STATE_GETRESULT_NORMAL_IDLE = 20,
+    CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN,
+} CmdMBox_SMStates_GetResult_Normal_e;
+
+typedef enum 
+{
+    CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE = 30,
+    CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN,
+    CMDMBOX_STATE_NUM,
+} CmdMBox_SMStates_GetResult_Blocking_e;
+
+/*****************************************************************************
+ **         Types                                                    **
+ *****************************************************************************/
+typedef struct _CmdMBox_T CmdMBox_T; 
+typedef int (*SM_Func_t)(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+struct _CmdMBox_T
+{   
+    /* handles */
+    TI_HANDLE               hOs;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hTNETWIF;
+    TI_HANDLE               hFwEvent;
+    TI_HANDLE               hTimer; 
+    TI_HANDLE               hCmdQueue;
+
+    /* SM */
+    CmdMBox_SMStates_GetResult_Normal_e     GetResultNormal_State;
+    CmdMBox_SMStates_GetResult_Blocking_e   GetResultBlocking_State;
+    CmdMBox_SMStates_SendCmd_Normal_e   SendCmdNormal_State;
+    CmdMBox_SMStates_SendCmd_Blocking_e SendCmdBlocking_State;
+    SM_Func_t               ActiveSM;
+    SM_Func_t               SendCmdSM;
+    SM_Func_t               GetResultSM;    
+
+    /* HW params */
+    /* use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (Command_t  HW_CmdMBox)
+    
+    UINT32                  CmdMBox_FW_address;
+    UINT32                  CmdLen;
+
+    UINT8*                  GetResult_ParamsBuf;
+    UINT32                  GetResult_ParamsLen;
+
+    BOOLEAN                 useOpt;
+    
+    TNETWIF_callback_t      fCb;
+    TI_HANDLE               hCb;
+};
+
+/*****************************************************************************
+ **         Internal functions definitions                                  **
+ *****************************************************************************/
+int             CmdMBox_SM_GetResultNormal(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
+int             CmdMBox_SM_GetResultBlocking(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
+int             CmdMBox_SM_SendCmdNormal(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
+int             CmdMBox_SM_SendCmdBlocking(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
+
+/*****************************************************************************
+ **         CB functions definitions                                  **
+ *****************************************************************************/
+void            CmdMBox_TimeOut(TI_HANDLE hCmdMBox);
+void                CmdMBox_TxnCmplt(TI_HANDLE hCmdMBox, UINT8 module_id ,TI_STATUS status);
+void                CmdMBox_BusReady(TI_HANDLE hCmdMBox, UINT8 module_id ,TI_STATUS status);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/DebugTrace_Xfer/DebugTraceXfer.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/DebugTrace_Xfer/DebugTraceXfer.c
new file mode 100644 (file)
index 0000000..8d5f40f
--- /dev/null
@@ -0,0 +1,662 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifdef TI_DBG
+
+#include "FwEvent_api.h"
+#include "whalParams.h"
+#include "DebugTraceXfer_api.h"
+#include "report.h"
+#include "whalBus_Defs.h"
+#include "TNETWIF.h"
+#include "utils.h"
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+#include "memMngrEx.h"
+#endif
+#include "whalCommon.h"
+
+
+
+/*****************************************************************************
+ **         UDP Packet Build                                                **
+ *****************************************************************************/
+#define Ether_Type  0x0800  /* For IP Protocol */
+
+ /* This is an Ethernet Version 2 frame: 14 Byte */
+typedef struct {
+  UINT8    ether_dst[6];
+  UINT8    ether_src[6];
+  UINT16   ether_Type;  
+} etherHeader;
+
+
+#define IP_Version    0x45   /* IP Ver - 4 Length Of IP Header 5 UINT32 (20 Byte) */
+#define IP_TimeToLive 128    /* limit the number of Router Hops  */
+#define IP_Protocol   0x11   /* UDP protocol */
+    
+ /* This is an IP frame: 20 Byte */
+typedef struct 
+{
+    UINT8   IpVer;
+    UINT8   TypeOfService;
+    UINT16  Totallen;
+    UINT16  Indentification;
+    UINT16  FragOffset;
+    UINT8   TimeToLive; 
+    UINT8   protocol;
+    UINT16  csum;
+    UINT8   src[4];
+    UINT8   dst[4];
+} ipstruct; 
+
+#define Source_Port 0
+#define Destination_Port 5555
+
+ /* This is a UDP frame: 8 Byte */
+typedef struct {
+  UINT16    src_port;
+  UINT16    dst_port;
+  UINT16    UDP_len;    
+  UINT16    UDP_Csum;    
+} UDPStruct;
+
+ /* This is a Trace Frame:*/
+#pragma pack(1)
+typedef struct {
+  etherHeader  Ether_Header;
+  ipstruct     IP_Header;
+  UDPStruct    UDP_Header;  
+} TraceFrame;
+#pragma pack()
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+typedef enum
+{
+    DEBUG_TRACE_STATE_IDLE,
+    DEBUG_TRACE_STATE_READ_BUF,
+    DEBUG_TRACE_STATE_ACK_EVENT
+} debugTraceState_e;
+/*
+ *  DebugTraceXfer: The Debug Trace Object 
+ */
+typedef struct 
+{
+    TraceFrame      FrameHeader; /* Do Not Change Place */
+
+    /* use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (UINT32  debugWords[TRACE_BUFFER_MAX_SIZE * 2])   /* *2 for the 2 buffers */
+
+    BOOL            bDoPrint; 
+    BOOL            bUdpSend; 
+    BOOL            bSync;  /* indicate if we are in Synch bus or not */
+
+    UINT32          TraceBufferSize;
+    
+    UINT32          BufferOffset[2];    /* holds the offset of Buffer A and Buffer B */
+    UINT8           currBuffer;         /* switch between 0 and 1 according to the buffer used */
+    
+    debugTraceState_e state;
+    TI_STATUS       returnValue;
+
+    TI_HANDLE       hOs;
+    TI_HANDLE       hReport;
+    TI_HANDLE       hFwEvent;
+    TI_HANDLE       hMemMgr;
+    TI_HANDLE       hTNETWIF;
+} DebugTrace_t;
+
+/****************************************************************************
+ *                      static function declaration
+ ****************************************************************************/
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+static void debugTrace_BuildFrame(DebugTrace_t *pDebugTrace, UINT8* MacAddress);
+#endif
+static void debugTrace_StateMachine(TI_HANDLE hDebugTrace,UINT8 module_id ,TI_STATUS status);
+
+/****************************************************************************
+ *                      debugTrace_Create()
+ *****************************************************************************  
+ * DESCRIPTION: Create
+ * 
+ * INPUTS:
+ *
+ * RETURNS: 
+ *
+ *****************************************************************************/
+TI_HANDLE debugTrace_Create(TI_HANDLE hOs)
+{
+    DebugTrace_t *pDebugTrace;
+
+    pDebugTrace = os_memoryAlloc(hOs, sizeof(DebugTrace_t));
+    if (pDebugTrace == NULL)
+    {
+        WLAN_OS_REPORT(("debugTrace_Create: Error Creating Trace Buffer \n"));
+        return NULL;
+    }
+
+    os_memoryZero(hOs, pDebugTrace, sizeof(DebugTrace_t));
+
+    pDebugTrace->hOs = hOs;
+
+    return((TI_HANDLE)pDebugTrace);
+}
+
+/****************************************************************************
+ *                      debugTrace_Destroy()
+ *****************************************************************************  
+ * DESCRIPTION: Destroy
+ * 
+ * INPUTS:  
+ *
+ * RETURNS: 
+ *
+ *****************************************************************************/
+void debugTrace_Destroy(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    if (pDebugTrace)
+    {
+        os_memoryFree(pDebugTrace->hOs, pDebugTrace, sizeof(DebugTrace_t));
+    }
+}
+
+/****************************************************************************
+ *                      debugTrace_Config()
+ *****************************************************************************  
+ * DESCRIPTION: Config
+ * 
+ * INPUTS:  
+ *
+ * RETURNS: 
+ *
+ *****************************************************************************/
+void debugTrace_Config(TI_HANDLE hDebugTrace, TI_HANDLE hWhalParams, TI_HANDLE hReport,
+                        TI_HANDLE hMemMgr, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+    
+    pDebugTrace->hReport  = hReport;
+    pDebugTrace->hMemMgr  = hMemMgr;
+    pDebugTrace->hTNETWIF = hTNETWIF;
+    pDebugTrace->hFwEvent = hFwEvent;
+
+    /* next 2 parameters are TRUE & FALSE by default but can be changed in run time */
+    pDebugTrace->bUdpSend  = FALSE;
+    pDebugTrace->bDoPrint  = TRUE;
+    pDebugTrace->TraceBufferSize = whal_ParamsGetTraceBufferSize(hWhalParams); 
+    pDebugTrace->currBuffer = 0;
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    /* Build Frame to be send to the OS */
+    debugTrace_BuildFrame(pDebugTrace, whal_ParamsGetSrcMac(hWhalParams));
+#endif
+
+    /* Enable Trace Interrupts  - actual interrupts will be raised only after init phase */
+    FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_A);
+    FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_B);
+}
+
+ /****************************************************************************
+ *                      debugTrace_ConfigHw()
+ *****************************************************************************  
+ * DESCRIPTION: Initialize the address to read the buffer from the FW
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_ConfigHw(TI_HANDLE hDebugTrace,UINT32 TraceAddA, UINT32 TraceAddB)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    pDebugTrace->BufferOffset[0] = TraceAddA;  
+    pDebugTrace->BufferOffset[1] = TraceAddB;  
+    
+    WLAN_REPORT_INIT(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("debugTrace_ConfigHw: Buffer A offSet =0x%x, Buffer B offSet =0x%x, TraceBufferSize = %d \n"
+        ,pDebugTrace->BufferOffset[0], pDebugTrace->BufferOffset[1],pDebugTrace->TraceBufferSize));
+
+}
+
+/****************************************************************************
+ *                      debugTrace_Event()
+ *****************************************************************************  
+ * DESCRIPTION: Called upon an interrupt of debug trace kind.
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+TI_STATUS debugTrace_Event(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    WLAN_REPORT_INFORMATION(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG,
+        (" debugTrace_Event: Reading from Buffer %d \n",pDebugTrace->currBuffer));
+
+    /* assume that we are in synch bus until otherwise is proven */
+    pDebugTrace->bSync = TRUE;
+
+    debugTrace_StateMachine(pDebugTrace,0,(TI_STATUS)0);
+
+    return pDebugTrace->returnValue;
+}
+
+
+/****************************************************************************
+ *                      debugTrace_StateMachine()
+ ****************************************************************************
+ * DESCRIPTION: Manage the Debug trace state machine 
+ *
+ *              The SM is running one event at a time (buffer A or B) .
+ *              The order of the states is always the same: IDLE --> READ_BUF --> ACK_EVENT
+ *              The difference is whether we are using Synch or Asynch API.
+ *              In the Synch case (SDIO) we are looping in the while-loop till we return to IDLE, and we return
+ *              to FwEvent module a TNETWIF_OK status.
+ *              In the Asynch case we use the SM CB to return to the SM after each Asynch call
+ *              (In that case the return status is TNETWIF_PENDING, and we are waiting for the CB).
+ *              In the Asynch case the FwEvent module gets TNETWIF_PENDING in return, and waits for 
+ *              the FwEvent_EventComplete() call in order to move the FwEvent SM.
+ * 
+ * INPUTS:  hFwEvent - The object
+ *          module_id - not used (for CB API only)
+ *          status    - not used (for CB API only) 
+ *      
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF_PENDING in case of Async and TNETWIF_OK on Sync 
+ ****************************************************************************/
+static void debugTrace_StateMachine(TI_HANDLE hDebugTrace,UINT8 module_id ,TI_STATUS status)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    pDebugTrace->returnValue = OK;
+
+    while(pDebugTrace->returnValue != TNETWIF_PENDING)
+    {
+        switch(pDebugTrace->state)
+        {
+            case DEBUG_TRACE_STATE_IDLE:
+
+                pDebugTrace->returnValue = TNETWIF_ReadMemOpt (pDebugTrace->hTNETWIF,
+                                                               pDebugTrace->BufferOffset[pDebugTrace->currBuffer],
+                                                               PADREAD (pDebugTrace->debugWords),
+                                                               pDebugTrace->TraceBufferSize,
+                                                               FW_EVENT_MODULE_ID,
+                                                               debugTrace_StateMachine,
+                                                               pDebugTrace);
+
+                pDebugTrace->state = DEBUG_TRACE_STATE_READ_BUF;
+            
+                break;
+
+            case DEBUG_TRACE_STATE_READ_BUF:
+                /* Now, handle the buffer */
+                /* Print on every Trace */
+                if(pDebugTrace->bDoPrint)
+                {
+                    debugTrace_Print(pDebugTrace);
+                }   
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+                /* Handle The Trace */
+                if(pDebugTrace->bUdpSend)
+                {
+                    debugTrace_handleBuffer(hDebugTrace);
+                }
+#endif
+
+                /*Trigger the FW when finishing handle the event */
+                pDebugTrace->returnValue = TNETWIF_WriteRegOpt(pDebugTrace->hTNETWIF, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_DEBUG_ACK,
+                                                FW_EVENT_MODULE_ID,debugTrace_StateMachine,pDebugTrace);
+
+                pDebugTrace->state = DEBUG_TRACE_STATE_ACK_EVENT;
+
+                break;
+
+            case DEBUG_TRACE_STATE_ACK_EVENT:
+
+                /* Handling of the event is done. Now switch to the next buffer for the next time */ 
+                pDebugTrace->currBuffer = (++pDebugTrace->currBuffer) & 0x1; /* &0x1 is %2 */
+                    
+                if (FALSE  == pDebugTrace->bSync ) 
+                {
+                    /* Async bus - call FwEvent for notifying the completion */
+                    FwEvent_EventComplete(pDebugTrace->hFwEvent, TNETWIF_OK);
+                }
+                else    /* This is the Sync case and we return TNETWIF_OK */
+                {
+                    pDebugTrace->returnValue = TNETWIF_OK;
+                }
+                /* Exit SM */
+                pDebugTrace->state = DEBUG_TRACE_STATE_IDLE;
+                return;
+
+/*                break; */
+
+            default:
+                WLAN_REPORT_ERROR(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG, 
+                    ("debugTrace_StateMachine: unKnown state !!!\n"));
+
+                break;
+        }
+    }
+    /* if we are here - we got TNETWIF_PENDING, so we are in Async mode */
+    pDebugTrace->bSync = FALSE;
+
+    if (pDebugTrace->returnValue == TNETWIF_ERROR) 
+    {
+        WLAN_REPORT_ERROR(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG, 
+                ("debugTrace_StateMachine: rc = TNETWIF_ERROR in state %d  \n",pDebugTrace->state));
+    }
+}
+
+ /****************************************************************************
+ *                      debugTrace_Disable()
+ *****************************************************************************  
+ * DESCRIPTION: disable receiving interrupts of this kind (debug trace)
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_Disable(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    FwEvent_Disable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_A);
+    FwEvent_Disable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_B);
+    
+    WLAN_REPORT_INFORMATION(pDebugTrace->hReport, HAL_HW_CTRL_MODULE_LOG, 
+                            ("whal_DebugTrace_t_Disable: Trace Disable \n"));
+
+}
+
+ /****************************************************************************
+ *                      debugTrace_Enable()
+ *****************************************************************************  
+ * DESCRIPTION: Enables receiving interrupts of this kind (debug trace)
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_Enable(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_A);
+    FwEvent_Enable(pDebugTrace->hFwEvent, ACX_INTR_TRACE_B);
+
+    WLAN_REPORT_INFORMATION(pDebugTrace->hReport, HAL_CTRL_MODULE_LOG, 
+                            ("whal_DebugTrace_tEnable: Trace Enable \n"));
+}
+
+ /****************************************************************************
+ *                      debugTrace_Print()
+ *****************************************************************************  
+ * DESCRIPTION: Print the current buffer
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_Print(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    UINT32 index;
+
+    WLAN_OS_REPORT(("Trace buffer size = %d\n",pDebugTrace->TraceBufferSize));
+
+    for(index = 0; index < pDebugTrace->TraceBufferSize / 4 ; index+=2)
+    {
+        WLAN_OS_REPORT(("0x%08X 0x%08X\n",
+                        pDebugTrace->debugWords[index],
+                        pDebugTrace->debugWords[index+1]));
+    }
+}
+
+ /****************************************************************************
+ *                      debugTrace_EnablePrint()
+ *****************************************************************************  
+ * DESCRIPTION: enable printing on each interrupt
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_EnablePrint(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    pDebugTrace->bDoPrint = TRUE;
+
+    WLAN_OS_REPORT(("whal_DebugTrace_t_EnablePrint: Print Enabled \n"));
+
+}
+
+ /****************************************************************************
+ *                      debugTrace_DisablePrint()
+ *****************************************************************************  
+ * DESCRIPTION: disable printing on each interrupt
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_DisablePrint(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    pDebugTrace->bDoPrint = FALSE;
+
+    WLAN_OS_REPORT(("whal_DebugTrace_t_DisablePrint: Print Disabled \n"));
+
+}
+
+ /****************************************************************************
+ *                      debugTrace_UdpEnable()
+ *****************************************************************************  
+ * DESCRIPTION: enable sending udp on each interrupt
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_UdpEnable(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    pDebugTrace->bUdpSend = TRUE;
+
+    WLAN_OS_REPORT(("whal_DebugTrace_t_UdpEnable: Enable UDP trace send\n"));
+}
+
+ /****************************************************************************
+ *                      debugTrace_UdpDisable()
+ *****************************************************************************  
+ * DESCRIPTION: disable sending udp on each interrupt
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_UdpDisable(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+
+    pDebugTrace->bUdpSend = FALSE;
+
+    WLAN_OS_REPORT(("whal_DebugTrace_t_UdpEnable: Disable UDP trace send\n"));
+
+}
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+ /****************************************************************************
+ *                      debugTrace_handleBuffer()
+ *****************************************************************************  
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hDebugTrace - Debug Trace object
+ *
+ * RETURNS:  
+ *
+ *****************************************************************************/
+void debugTrace_handleBuffer(TI_HANDLE hDebugTrace)
+{
+    DebugTrace_t *pDebugTrace = (DebugTrace_t *)hDebugTrace;
+    mem_MSDU_T *pMsdu;
+    mem_BD_T *pBd;
+    UINT8    *srcDataPtr;
+    int Stt;
+    int AcxMpduLen;
+
+    /* The Msdu Len should be The IP total Length + the Ethernet header length */
+    AcxMpduLen = wlan_ntohs(pDebugTrace->FrameHeader.IP_Header.Totallen) 
+                    + sizeof(pDebugTrace->FrameHeader.Ether_Header);
+
+    /*
+     * allocate host msdu
+     */
+    Stt = wlan_memMngrAllocMSDU(pDebugTrace->hMemMgr, &pMsdu, AcxMpduLen, TRACE_BUFFER_MODULE);
+    if (Stt != OK)
+    {
+        WLAN_REPORT_ERROR(pDebugTrace->hReport, HAL_HW_DATA_MODULE_LOG,  
+            ("whal_DebugTrace_t_handleBuffer: wlan_memMngrAllocMSDU error\n"));
+        return ;
+    }
+
+    /* set the lastBDPtr */
+    pBd = pMsdu->firstBDPtr;
+    while (pBd->nextBDPtr != NULL)
+        pBd = pBd->nextBDPtr;
+    
+    pMsdu->lastBDPtr = pBd;
+
+    /* Get the Address of the Data filed in the Msdu */
+    srcDataPtr = (UINT8 *)memMgr_MsduHdrAddr(pMsdu);
+
+    /* Copy the Frame Header */
+    os_memoryCopy(pDebugTrace->hOs, srcDataPtr, &pDebugTrace->FrameHeader, sizeof(pDebugTrace->FrameHeader));
+    
+    /* Copy the Trace Data */
+    os_memoryCopy(pDebugTrace->hOs, srcDataPtr + sizeof(pDebugTrace->FrameHeader), pDebugTrace->debugWords, pDebugTrace->TraceBufferSize);
+
+    memMgr_BufLength(pMsdu->firstBDPtr) = AcxMpduLen;
+    
+    pMsdu->dataLen = AcxMpduLen;
+
+    /* send the packet to the OS */
+    os_receivePacket(pDebugTrace->hOs, pMsdu, (UINT16)pMsdu->dataLen);
+}
+
+ /****************************************************************************
+ *                      debugTrace_BuildFrame()
+ *****************************************************************************  
+ * DESCRIPTION: Build the Trace Frame to be send to the OS
+ * 
+ * INPUTS:  pDebugTrace - Debug Trace object
+ *          MacAddress  - for the Ethernet Header
+ * RETURNS:  
+ *
+ *****************************************************************************/
+static void debugTrace_BuildFrame(DebugTrace_t *pDebugTrace, UINT8* MacAddress)
+{
+    TraceFrame *Frame =  &pDebugTrace->FrameHeader;
+    UINT32 i;
+    UINT16 local_csum = 0;
+    UINT16 *pShortData = (UINT16 *)&Frame->IP_Header;
+
+    /*
+     *  Calculate each Frame Length
+     */
+    /* UDP length should Be !024 of Trace Buffet Size + 8 Byte of UDP header 1032) */   
+    Frame->UDP_Header.UDP_len = wlan_htons(pDebugTrace->TraceBufferSize + sizeof(Frame->UDP_Header));
+
+    /* IP length should Be UDP length + IP header  */   
+    Frame->IP_Header.Totallen = wlan_htons(wlan_htons(Frame->UDP_Header.UDP_len) + sizeof(Frame->IP_Header));
+
+    /*
+     * initialize the Ethernet Header
+     */
+    os_memoryCopy(pDebugTrace->hOs, (UINT8 *)Frame->Ether_Header.ether_dst, 
+                  MacAddress, 6);
+                     
+    Frame->Ether_Header.ether_Type  = wlan_htons (Ether_Type); 
+    
+    /*
+     *  initialize the IP Header
+     */
+    Frame->IP_Header.IpVer = IP_Version;
+
+    Frame->IP_Header.TimeToLive = IP_TimeToLive;
+
+    Frame->IP_Header.protocol = IP_Protocol;
+    
+    /* Set the Local host IP */
+    Frame->IP_Header.dst[0] = Frame->IP_Header.src[0] = 127;
+    Frame->IP_Header.dst[1] = Frame->IP_Header.src[1] = 0 ;
+    Frame->IP_Header.dst[2] = Frame->IP_Header.src[2] = 0;
+    Frame->IP_Header.dst[3] = Frame->IP_Header.src[3] = 1;
+
+    /* calculate check sum on words of 16 bits */
+    for (i=0; i<sizeof(Frame->IP_Header)/2; i++)
+        local_csum += pShortData[i];
+
+    Frame->IP_Header.csum = 0xFFFF - local_csum;
+
+    /*
+     *  initialize the UDP Header
+     */ 
+    Frame->UDP_Header.src_port = wlan_htons( Source_Port );
+    Frame->UDP_Header.dst_port = wlan_htons( Destination_Port );
+}
+#endif /* !defined(GWSI_DRIVER) && !defined(GWSI_LIB) */
+
+#endif /* TI_DBG */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/EventMbox/eventMbox.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/EventMbox/eventMbox.c
new file mode 100644 (file)
index 0000000..54f405e
--- /dev/null
@@ -0,0 +1,759 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  EventMbox.c : event Mail Box
+ *   PURPOSE: Handle any event interrupt from the FW 
+ *
+ ****************************************************************************/
+
+#include "commonTypes.h"
+#include "FwEvent_api.h"
+#include "whalBus_Api.h"
+#include "eventMbox_api.h"
+#include "whalCtrl_api.h"
+#include "TNETWIF.h"
+
+
+/*******************************************************************************
+ *
+ *                               Macros                                   
+ *
+ *******************************************************************************/
+#define IS_EVENT_BIT_ON(EvVector,EvBit)  (  (EvBit) == ( (EvVector) &  (EvBit) ) )
+#define IS_EVENT_BIT_OFF(EvVector,EvBit) ( ~(EvBit) == ( (EvVector) | ~(EvBit) ) )
+
+#define SET_EVENT_BIT(EvVector,EvBit)    ( (EvVector) |=  (EvBit) ) 
+#define CLEAR_EVENT_BIT(EvVector,EvBit)  ( (EvVector) &= ~(EvBit) )
+
+#define EVENT_REPORT_SIZE 80
+
+#define EVMBX_DBG 1
+
+
+/*****************************************************************************
+ **         Enumerations                                                    **
+ *****************************************************************************/
+
+typedef enum
+{
+    EVENT_MBOX_STATE_IDLE,
+    EVENT_MBOX_STATE_READ_BUF,
+    EVENT_MBOX_STATE_ACK_EVENT
+} EventMboxState_e;
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+/*
+ * Definition for the Event Table
+ */
+typedef struct 
+{
+    /* Event bit mask */
+    UINT32              bitMask;
+    /* Event trace string */
+    char*               str; 
+    /* Event data length */  
+    UINT8               dataLen;
+} EventEntry_t;
+
+
+/*
+ * Event callback structure
+ */
+typedef struct
+{ 
+    /* Event callback function */
+    void*               fCb;
+    /* Event callback module handle */
+    TI_HANDLE           hCb;
+    /* Event data offset */
+    UINT8*              pDataOffs;
+    /* Event callback counter */
+    UINT32              uCount;
+} EventCB_t;
+
+
+/*
+ *  Event Mailbox object
+ */
+typedef struct 
+{
+    /* Offset for event A (0) or event B (1) */
+    UINT32              offset[2];        
+    /* 0 or 1 according to event A or B */
+    UINT32              currentEvent;           
+    /* Event mail box state machine state */
+    EventMboxState_e    state;
+    /* Return value */
+    TI_STATUS           returnValue;
+    /* Init complete flag */
+    BOOL                bInitComplete;
+    /* Indicate if we are in synchronous bus or not */
+    BOOL                bSync;  
+    /* Callback table */
+    EventCB_t           cbTable[MAX_NUM_OF_EVENT];
+    /* Use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (EventMailBox_t  CompoundEvent)
+
+    /* Handles */
+    TI_HANDLE           hFwEvent; 
+    TI_HANDLE           hTNETWIF;
+    TI_HANDLE           hOs;
+    TI_HANDLE           hReport;
+    TI_HANDLE           hWhalCtrl;
+#ifdef TI_DBG
+    /* Count the compound event */
+    UINT32              uCompounEvCount; 
+    /* Count the total number of event sending in the compound */
+    UINT32              uTotalEvCount;   
+#endif /* TI_DBG */
+
+    TNETWIF_callback_t  fCb;
+    TI_HANDLE           hCb;
+} EventMbox_t;
+
+/********************************************************************************/
+/*                      Internal functions prototypes.                          */
+/********************************************************************************/
+
+static void eventMbox_HandleEvent  (TI_HANDLE hEventMbox);
+static void eventMbox_StateMachine (TI_HANDLE hEventMbox, UINT8 module_id, TI_STATUS status);
+static void eventMbox_InitCbTable  (TI_HANDLE hEventMbox);
+
+
+static const EventEntry_t eventTable [MAX_NUM_OF_EVENT] =
+{   
+/*==================================================================================
+|                                                                                  |
+|                                     EVENT TABLE                                  |
+|                                                                                  |
+ ===================================================================================
+| Id  |     Event Mask Bit                    |   Event String            | Length |
+ ===================================================================================*/
+
+/*0*/ { MEASUREMENT_START_EVENT_ID,             "MEASUREMENT START "      , 0},       
+/*1*/ { SCAN_COMPLETE_EVENT_ID ,                "SCAN CMPLT "             , 3},                          
+/*2*/ { CALIBRATION_COMPLETE_EVENT_ID,          "CALIB CMPLT "            , 0},                                           
+/*3*/ { ROAMING_TRIGGER_LOW_RSSI_EVENT_ID ,     "RSSI LEVEL "             , 1},      
+/*4*/ { PS_REPORT_EVENT_ID,                     "PS_REPORT "              , 1},
+/*5*/ { SYNCHRONIZATION_TIMEOUT_EVENT_ID,       "SYNCHRONIZATION TIMEOUT ", 0}, 
+/*6*/ { HEALTH_REPORT_EVENT_ID,                 "HEALTH REPORT "          , 2},  
+/*7*/ { ACI_DETECTION_EVENT_ID ,                "ACI INDICATION "         , 2},     
+/*8*/ { DEBUG_REPORT_EVENT_ID,                  "DEBUG REPORT "           , 8},   
+/*9*/ { MAC_STATUS_EVENT_ID,                    "MAC STATUS "             , 8},    
+/*10*/{ DISCONNECT_EVENT_COMPLETE_ID,           "DISCONNECT COMPLETE "    , 0},
+/*11*/{ JOIN_EVENT_COMPLETE_ID,                 "JOIN CMPLT "             , 0},
+/*12*/{ CHANNEL_SWITCH_COMPLETE_EVENT_ID,       "SWITCH CHANNEL CMPLT "   , 0},
+/*13*/{ BSS_LOSE_EVENT_ID,                      "BSS LOST "               , 0},
+/*14*/{ ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID,  "MAX TX RETRY "           , 0},
+/*15*/{ MEASUREMENT_COMPLETE_EVENT_ID,          "BSS LOSE "               , 0},
+/*16*/{ AP_DISCOVERY_COMPLETE_EVENT_ID,         "MAX TX RETRY "           , 0},
+/*17*/{ SCHEDULED_SCAN_COMPLETE_EVENT_ID,       "SPS SCAN CMPLT "         , 3},
+/*18*/{ REGAINED_BSS_EVENT_ID,                  "REGAINED BSS "           , 0},
+/*19*/{ ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID, "REGAINED RSSI "          , 1},
+/*20*/{ ROAMING_TRIGGER_LOW_SNR_EVENT_ID,       "LOW SNR "                , 1},
+/*21*/{ SOFT_GEMINI_SENSE_EVENT_ID,             "SOFT GEMINI SENSE "      , 1},
+/*22*/{ SOFT_GEMINI_PREDICTION_EVENT_ID,        "SOFT GEMINI PREDICTION " , 1},
+/*23*/{ SOFT_GEMINI_AVALANCHE_EVENT_ID,         "SOFT GEMINI AVALANCHE "  , 0},
+/*24*/{ PLT_RX_CALIBRATION_COMPLETE_EVENT_ID,   "PLT RX CALIBR. COMPLETE ", 0},
+/*25*/{ PSPOLL_DELIVERY_FAILURE_EVENT_ID,       "PS-POLL DELIVERY FAILURE", 0},
+/*26*/{ RESET_BSS_EVENT_ID,                     "EVENT RESET BSS "        , 0},
+/*27*/{ EVENT_MBOX_ALL_EVENT_ID,                "ALL EVENTS "             , 0}, 
+
+};
+
+/********************************************************************************/
+/*                   functions implementation                                   */
+/********************************************************************************/
+
+
+/****************************************************************************
+ *                      eventMbox_InitCbTable()
+ ****************************************************************************
+ * DESCRIPTION: Initialization of callback table
+ * 
+ * INPUTS:  hEventMbox       eventMbox module handle
+ *
+ * RETURNS: none
+ ****************************************************************************/
+void eventMbox_InitCbTable (TI_HANDLE hEventMbox)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    UINT32       EvID;
+
+    for (EvID = 0; EvID < MAX_NUM_OF_EVENT; EvID++)
+    {
+        pEventMbox->cbTable[EvID].pDataOffs = (UINT8*)&pEventMbox->CompoundEvent;
+    }
+
+    pEventMbox->cbTable[ 3].pDataOffs += offsetof (EventMailBox_t, averageRssiLevel);
+    pEventMbox->cbTable[ 4].pDataOffs += offsetof (EventMailBox_t, psStatus);
+    pEventMbox->cbTable[ 6].pDataOffs += offsetof (EventMailBox_t, healthReport);
+    pEventMbox->cbTable[ 7].pDataOffs += offsetof (EventMailBox_t, badFFTCorrelationCounter);
+    pEventMbox->cbTable[ 8].pDataOffs += offsetof (EventMailBox_t, debugReport);
+    pEventMbox->cbTable[ 9].pDataOffs += offsetof (EventMailBox_t, consFcsErrCnt);
+    pEventMbox->cbTable[17].pDataOffs += offsetof (EventMailBox_t, scheduledScanStatus);
+    pEventMbox->cbTable[19].pDataOffs += offsetof (EventMailBox_t, averageRssiLevel);
+    pEventMbox->cbTable[20].pDataOffs += offsetof (EventMailBox_t, averageSNRLevel);
+    pEventMbox->cbTable[21].pDataOffs += offsetof (EventMailBox_t, softGeminiSenseInfo);
+    pEventMbox->cbTable[22].pDataOffs += offsetof (EventMailBox_t, softGeminiProtectiveInfo);
+}
+
+
+/****************************************************************************
+ *                      eventMbox_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the Bus Access mailbox object
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+TI_HANDLE eventMbox_Create (TI_HANDLE hOs)
+{
+    EventMbox_t *pEventMbox;
+
+    pEventMbox = os_memoryAlloc (hOs, sizeof(EventMbox_t));
+    if (pEventMbox == NULL)
+    {
+        WLAN_OS_REPORT (("eventMbox_Create: Error creating EventMbox object\n"));
+        return NULL;
+    }
+
+    os_memoryZero (hOs, pEventMbox, sizeof(EventMbox_t));
+
+    pEventMbox->hOs = hOs;
+    pEventMbox->CompoundEvent.eventsMask = EVENT_MBOX_ALL_EVENT_ID;
+
+    return (TI_HANDLE)pEventMbox;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object 
+ *
+ ****************************************************************************/
+void eventMbox_Destroy (TI_HANDLE hEventMbox)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+
+    if (pEventMbox)
+    {
+        os_memoryFree (pEventMbox->hOs, pEventMbox, sizeof(EventMbox_t));
+    }
+}
+
+
+/****************************************************************************
+ *                      eventMbox_Config()
+ ****************************************************************************
+ * DESCRIPTION: Configure the object 
+ * 
+ * INPUTS: pEventMbox   this
+ *         pHwIntr          Interrupt Object object
+ *         hReport          Report Object
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+void eventMbox_Config (TI_HANDLE hEventMbox, TI_HANDLE hTNETWIF, TI_HANDLE hHwIntr, 
+                       TI_HANDLE hReport,    TI_HANDLE hFwEvent, TI_HANDLE hWhalCtrl)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+
+    pEventMbox->hTNETWIF = hTNETWIF;
+    pEventMbox->hReport = hReport;
+    pEventMbox->hFwEvent = hFwEvent;
+    pEventMbox->hWhalCtrl = hWhalCtrl;
+    pEventMbox->hReport = hReport;
+
+    pEventMbox->state = EVENT_MBOX_STATE_IDLE;   
+    pEventMbox->bInitComplete = FALSE;
+    pEventMbox->CompoundEvent.eventsVector = 0;
+    pEventMbox->currentEvent = 0;
+
+    /* 
+     * NOTE: don't set eventsMask = 0xffffffff;
+     *       its value is used after recovery has finished
+     */
+   
+    /* Init callback table */
+    eventMbox_InitCbTable (hEventMbox); 
+}
+
+
+/****************************************************************************
+ *                      eventMbox_InitComplete()
+ ****************************************************************************
+ * DESCRIPTION: ReConfigure the object, Send the Mask Vector to the FW 
+ * 
+ * INPUTS:  pEventMbox      this
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+void eventMbox_InitComplete (TI_HANDLE hEventMbox)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    
+    WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        ("eventMbox_InitComplete: mask=0x%x\n", pEventMbox->CompoundEvent.eventsMask));
+
+    pEventMbox->bInitComplete = TRUE;
+
+    /* Enable Events Interrupts */
+    FwEvent_Enable (pEventMbox->hFwEvent, ACX_INTR_EVENT_A);
+    FwEvent_Enable (pEventMbox->hFwEvent, ACX_INTR_EVENT_B);
+
+    whalCtrl_SetInfoElemEventMask (pEventMbox->hWhalCtrl, pEventMbox->CompoundEvent.eventsMask);
+}
+
+/****************************************************************************
+ *                      eventMbox_Stop()
+ ****************************************************************************
+ * DESCRIPTION:        Stop the object while recovery until Init Complete.
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int eventMbox_Stop(TI_HANDLE hEventMbox)
+{
+       EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+
+       pEventMbox->state = EVENT_MBOX_STATE_IDLE;   
+       pEventMbox->CompoundEvent.eventsVector = 0;
+       pEventMbox->currentEvent = 0;
+       pEventMbox->bInitComplete = FALSE;
+
+       return OK;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_ConfigCb()
+ ****************************************************************************
+ * DESCRIPTION:Read the SRAM Event mailbox address callback
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+static void eventMbox_ConfigCb (TI_HANDLE hEventMbox, UINT8 module_id, TI_STATUS status)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+
+    pEventMbox->offset[1] = pEventMbox->offset[0] + sizeof(EventMailBox_t); 
+    WLAN_REPORT_INIT (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,  
+                      ("eventMbox_ConfigCb: event A offset=0x%x, event B offset=0x%x, sizeof=%d\n",
+                      pEventMbox->offset[0], pEventMbox->offset[1], sizeof(EventMailBox_t)));
+
+    /* Call upper layer callback */
+    pEventMbox->fCb (pEventMbox->hCb, module_id, OK);
+}
+
+
+/****************************************************************************
+ *                      eventMbox_ConfigHw()
+ ****************************************************************************
+ * DESCRIPTION:Read the SRAM Event mailbox address 
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+TI_STATUS eventMbox_ConfigHw (TI_HANDLE hEventMbox, UINT8 module_id, fnotify_t fCb, TI_HANDLE hCb)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    TI_STATUS    status;
+
+    pEventMbox->fCb = (TNETWIF_callback_t)fCb;
+    pEventMbox->hCb = hCb;
+
+    /* 
+     * Get the event mailbox pointer
+     */
+    status = TNETWIF_ReadRegOpt (pEventMbox->hTNETWIF, 
+                                 REG_EVENT_MAILBOX_PTR,
+                                 &pEventMbox->offset[0],
+                                 module_id, 
+                                 eventMbox_ConfigCb,
+                                 hEventMbox);
+
+    if (status == TNETWIF_COMPLETE)
+    {
+        pEventMbox->offset[1] = pEventMbox->offset[0] + sizeof(EventMailBox_t);  
+
+        WLAN_REPORT_INIT (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,  
+                          ("eventMbox_ConfigHw: event A offset=0x%x, event B offset=0x%x, sizeof=%d\n",
+                          pEventMbox->offset[0], pEventMbox->offset[1], sizeof(EventMailBox_t)));
+    }
+    
+    return status;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_RegisterEventCB()
+ ****************************************************************************
+ * DESCRIPTION: register callback function for Events
+ *
+ * INPUTS:  EvID    Event ID
+ *          fCb     Call Back
+ *          hCb     Call Back Handle
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int eventMbox_RegisterEventCB (TI_HANDLE hEventMbox, UINT32 EvID, void* fCb, TI_HANDLE hCb)                                    
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+        
+    if (fCb == NULL || hCb == NULL)
+    { 
+        WLAN_REPORT_ERROR (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_RegisterEventCB: NULL parameters\n"));
+        return NOK;
+    }
+
+    if (EvID >= HAL_EVENT_ALL)
+    {
+        WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_RegisterEventCB: invalid ID\n"));
+        return NOK;
+    }
+
+    pEventMbox->cbTable[EvID].fCb = fCb;
+    pEventMbox->cbTable[EvID].hCb = hCb;
+
+    WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        ("eventMbox_RegisterEventCB: EVENT %s has registered\n", eventTable[EvID].str));
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_EvMask()
+ ****************************************************************************
+ * DESCRIPTION: The function Mask the Event in the Local Mask Vector 
+ *              And in the FW Mask Vector
+ *
+ * INPUTS:  Evid:   The Event ID
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int eventMbox_EvMask (TI_HANDLE hEventMbox, UINT32 EvID)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    UINT32      *pEvMask = (UINT32*)&pEventMbox->CompoundEvent.eventsMask;
+
+    if (EvID >= HAL_EVENT_ALL)
+    {
+        WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_EvMask: invalid ID\n"));
+        return NOK;
+    }
+
+    *pEvMask |= eventTable[EvID].bitMask;
+
+    WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        ("eventMbox_EvMask: EVENT %s is masked\n", eventTable[EvID].str));
+
+    if (pEventMbox->bInitComplete == TRUE)
+    {
+        whalCtrl_SetInfoElemEventMask (pEventMbox->hWhalCtrl, *pEvMask);
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_EvUnMask()
+ ****************************************************************************
+ * DESCRIPTION: The function UnMask the Event in the Local Mask Vector 
+ *              And in the FW Mask Vector
+ *
+ * INPUTS:  Evid:   The Event ID
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int eventMbox_EvUnMask (TI_HANDLE hEventMbox, UINT32 EvID)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    UINT32      *pEvMask = (UINT32*)&pEventMbox->CompoundEvent.eventsMask;
+    
+    if (EvID >= HAL_EVENT_ALL)
+    {
+        WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, ("eventMbox_EvUnMask: invalid ID\n"));
+        return NOK;
+    }
+
+    *pEvMask &= ~eventTable[EvID].bitMask;
+
+    WLAN_REPORT_INFORMATION (pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        ("eventMbox_EvUnMask: EVENT %s is unmasked\n", eventTable[EvID].str));
+
+    if (pEventMbox->bInitComplete == TRUE)
+    {
+         whalCtrl_SetInfoElemEventMask (pEventMbox->hWhalCtrl, *pEvMask);
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_Event()
+ *****************************************************************************  
+ * DESCRIPTION: Called when Event A or B interrupt occur
+ * 
+ * INPUTS:  hEventMbox - The object
+ *
+ * RETURNS: TNETWIF_PENDING in case of Async and TNETWIF_OK on Sync 
+ *
+ *****************************************************************************/
+TI_STATUS eventMbox_Event (TI_HANDLE hEventMbox)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    
+    /* Assume the driver is synchronous until opposite is proven */
+    pEventMbox->bSync = TRUE;
+
+    eventMbox_StateMachine (pEventMbox, FW_EVENT_MODULE_ID, OK);
+
+    return pEventMbox->returnValue;
+}
+
+
+/********************************************************************************/
+/*                      Internal functions implementation.                      */
+/********************************************************************************/
+
+/****************************************************************************
+ *                      eventMbox_StateMachine()
+ ****************************************************************************
+ * DESCRIPTION: Manage the EventMbox state machine 
+ *
+ *              The SM is running one event at a time (A or B) .
+ *              The order of the states is always the same: IDLE --> READ_BUF --> ACK_EVENT
+ *              The difference is whether we are using Synch or Asynch API.
+ *              In the Synch case (SDIO) we are looping in the while-loop till we return to IDLE, and we return
+ *              to FwEvent module a TNETWIF_OK status.
+ *              In the Asynch case we use the SM CB to return to the SM after each Asynch call
+ *              (In that case the return status is TNETWIF_PENDING, and we are waiting for the CB).
+ *              In the Asynch case the FwEvent module gets TNETWIF_PENDING in return, and waits for 
+ *              the FwEvent_EventComplete() call in order to move the FwEvent SM.
+ * 
+ * INPUTS:  hFwEvent - The object
+ *          module_id - not used (for CB API only)
+ *          status    - not used (for CB API only) 
+ *      
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF_PENDING in case of Async and TNETWIF_OK on Sync 
+ ****************************************************************************/
+static void eventMbox_StateMachine (TI_HANDLE hEventMbox, UINT8 module_id, TI_STATUS status)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+
+    pEventMbox->returnValue = OK;
+
+    while (pEventMbox->returnValue != TNETWIF_PENDING)
+    {
+        switch (pEventMbox->state)
+        {
+            case EVENT_MBOX_STATE_IDLE:
+
+                pEventMbox->returnValue = TNETWIF_ReadMemOpt (pEventMbox->hTNETWIF,
+                                                              pEventMbox->offset[pEventMbox->currentEvent],
+                                                              PADREAD (&pEventMbox->CompoundEvent),
+                                                              EVENT_REPORT_SIZE,
+                                                              FW_EVENT_MODULE_ID,
+                                                              eventMbox_StateMachine,
+                                                              hEventMbox);
+
+                pEventMbox->state = EVENT_MBOX_STATE_READ_BUF;
+            
+                break;
+
+            case EVENT_MBOX_STATE_READ_BUF:
+
+                /* Notify The appropriate layer about the incoming event */
+                eventMbox_HandleEvent (hEventMbox);
+
+                /* Trigger the FW when finishing handle the event */
+                pEventMbox->returnValue = TNETWIF_WriteRegOpt (pEventMbox->hTNETWIF, 
+                                                               ACX_REG_INTERRUPT_TRIG, 
+                                                               INTR_TRIG_EVENT_ACK,
+                                                               FW_EVENT_MODULE_ID,
+                                                               eventMbox_StateMachine,
+                                                               hEventMbox);
+
+                pEventMbox->state = EVENT_MBOX_STATE_ACK_EVENT;
+
+                break;
+
+            case EVENT_MBOX_STATE_ACK_EVENT:
+
+                /* Handling of the event is done. Switch to the next buffer for the next time */ 
+                pEventMbox->currentEvent = 1 - pEventMbox->currentEvent; 
+                    
+                if (FALSE == pEventMbox->bSync) 
+                {   
+                    /* Asynchronous bus - call FwEvent for notifying the completion */
+                    FwEvent_EventComplete (pEventMbox->hFwEvent, TNETWIF_OK);
+                }
+                else    
+                {
+                    /* This is the Sync case and we return TNETWIF_OK */
+                    pEventMbox->returnValue = TNETWIF_OK;
+                }
+                /* Exit SM */
+                pEventMbox->state = EVENT_MBOX_STATE_IDLE;
+                return;
+
+            default:
+                WLAN_REPORT_ERROR(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG, 
+                    ("eventMbox_StateMachine: unknown state !!!\n"));
+                break;
+        }
+    }
+
+    /* If we are here - we got TNETWIF_PENDING, so we are in asynchronous mode */
+    pEventMbox->bSync = FALSE;
+}
+
+
+/****************************************************************************
+ *                      eventMbox_HandleEvent()
+ ****************************************************************************
+ * DESCRIPTION: The functions reads the parameters in the Event mailBox
+ *              and activates the appropriate CallBack function.
+ *
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK. 
+ ****************************************************************************/
+static void eventMbox_HandleEvent (TI_HANDLE hEventMbox)
+{
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    EventCB_t   *pEventCb;
+    UINT32       EvID;
+    UINT32       EvMask   = pEventMbox->CompoundEvent.eventsMask;
+    UINT32       EvVector = pEventMbox->CompoundEvent.eventsVector;
+
+#ifdef TI_DBG
+    pEventMbox->uCompounEvCount++;
+#endif /* TI_DBG */
+    
+#if EVMBX_DBG
+    WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+                             ("eventMbox_HandleEvent: Event Vector = 0x%x\n", EvVector));
+#endif
+    
+    /*
+    Handle  Events
+    */
+    for (EvID = 0; EvID < HAL_EVENT_ALL; EvID++)
+    {
+        pEventCb = &pEventMbox->cbTable[EvID];
+        /* Check if the Event Bit in the vector in set */
+        if (IS_EVENT_BIT_ON (EvVector, eventTable[EvID].bitMask))
+        {   
+#ifdef TI_DBG
+            pEventMbox->uTotalEvCount++;
+#endif /* TI_DBG */
+            pEventCb->uCount++;
+            /* Check if the Mask Bit in the Mask vector in off */
+            if (IS_EVENT_BIT_OFF (EvMask, eventTable[EvID].bitMask))
+            { 
+#if EVMBX_DBG
+                WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+                                        ("eventMbox_HandleEvent: EVENT %s has occurred\n", eventTable[EvID].str));
+#endif
+                if (pEventCb->fCb != NULL)
+                {                  
+                    if (eventTable[EvID].dataLen)
+                    {
+                        ((whal_hwMboxDataEvCB)pEventCb->fCb) (pEventCb->hCb,
+                                                              (char *)pEventMbox->cbTable[EvID].pDataOffs,
+                                                              eventTable[EvID].dataLen);
+                    }
+                    else
+                    {
+                        ((whal_hwMboxEvCB)pEventCb->fCb) (pEventCb->hCb);
+                    }
+                }        
+            }    
+        } 
+    } /*End for*/
+}   
+
+
+/*
+ *  eventMbox_Print: print the Event Mailbox statistic :Number 890
+ */
+void eventMbox_Print (TI_HANDLE hEventMbox)
+{
+#ifdef TI_DBG
+    EventMbox_t *pEventMbox = (EventMbox_t *)hEventMbox;
+    UINT32 i;
+    UINT32 EvMask   = pEventMbox->CompoundEvent.eventsMask;
+    UINT32 EvVector = pEventMbox->CompoundEvent.eventsVector;
+
+    WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        ("------------------------- EventMbox  Print ----------------------------\n"));
+
+    WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        (" eventMbox_HandleEvent: Event Vector = 0x%x\n", EvVector));
+    WLAN_REPORT_INFORMATION(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        (" eventMbox_HandleEvent: Event Mask = 0x%x\n", EvMask));
+    WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        (" Total Number Of Compound Event = %d: \n", pEventMbox->uCompounEvCount));
+    WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        (" Total Number Of Events = %d: \n", pEventMbox->uTotalEvCount));
+    WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,("\t\t\t\t *** Event Counters *** :\n"));
+    for (i = 0; i < HAL_EVENT_ALL; i++)
+    {
+        WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+            (" %d) Event Name = EVENT %s, Number of Event = %d\n",
+            i, eventTable[i].str, pEventMbox->cbTable[i].uCount));
+    }
+
+    WLAN_REPORT_REPLY(pEventMbox->hReport, EVENT_MBOX_MODULE_LOG,
+        ("------------------------- EventMbox  Print End ----------------------------\n"));
+#endif /* TI_DBG */
+}
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.c
new file mode 100644 (file)
index 0000000..df05208
--- /dev/null
@@ -0,0 +1,1058 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  FwEvent.c
+ *   
+ *   PURPOSE: Handle firmware events
+ * 
+ *   DESCRIPTION:  
+ *   ============
+ *      Call the appropriate event handler.
+ *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "tnetwCommon.h"
+#include "TNETWIF.h"
+#include "TNETWArb.h"
+#include "txResult_api.h"
+#include "osApi.h"
+#include "whalBus_Api.h"
+#include "CmdMBox_api.h"
+#include "TNETW_Driver.h"
+#include "whalCtrl.h"
+#include "shmBus.h"
+#include "rxXfer_api.h" 
+#include "FwEvent.h" 
+#include "eventMbox_api.h"
+
+#ifdef TI_DBG
+#include "DebugTraceXfer_api.h"
+#endif /* TI_DBG */
+
+/* for debug only */
+#undef  DEBUG_INTERRUPTS_PRINT
+
+/********************* static function declerations *************************/
+static void FwEvent_ReadRegCB (TI_HANDLE hFwEvent, UINT8 moduleID, TI_STATUS status);
+static void FwEvent_WriteMaskCB (TI_HANDLE hFwEvent, UINT8 moduleID, TI_STATUS status);
+static void FwEvent_WriteMuxCB (TI_HANDLE hFwEvent, UINT8 moduleID, TI_STATUS status);
+static void FwEvent_UpdateRxBits (TI_HANDLE hFwEvent);
+
+/* Client info structure */
+typedef struct 
+{
+    /* Client event bit in interrupt status register */
+    UINT32       event;
+    /* Client handler */
+    TI_STATUS  (*func) (TI_HANDLE hclient);
+    /* Client corresponding trace message */
+    char        *trace; 
+} FwClient_t;
+
+
+/* 
+ * NOTE: Register clients in order of their priorities.
+ *       The command mailbox priority is higher than that of event mailbox. 
+ *       This ensures the command complete callback always arrives before event.  
+ */
+static const FwClient_t fwClient [MAX_EVENT_NUM] =
+{
+    { ACX_INTR_RX0_DATA,     rxXfer_RxEvent,         "ACX_INTR_RX0_DATA"     }, 
+    { ACX_INTR_TX_RESULT,    txResult_TxCmpltIntrCB, "ACX_INTR_TX_RESULT"    }, 
+    { ACX_INTR_RX1_DATA,     rxXfer_RxEvent,         "ACX_INTR_RX1_DATA"     }, 
+    { ACX_INTR_CMD_COMPLETE, CmdMBox_CmdCmplt,       "ACX_INTR_CMD_COMPLETE" }, 
+    { ACX_INTR_EVENT_A,      eventMbox_Event,        "ACX_INTR_EVENT_A"      }, 
+    { ACX_INTR_EVENT_B,      eventMbox_Event,        "ACX_INTR_EVENT_B"      }, 
+  #ifdef TI_DBG
+    { ACX_INTR_TRACE_A,      debugTrace_Event,       "ACX_INTR_TRACE_A"      }, 
+    { ACX_INTR_TRACE_B,      debugTrace_Event,       "ACX_INTR_TRACE_B"      }, 
+  #endif
+};
+
+
+/****************************************************************************
+*                      FwEvent_Create()
+****************************************************************************
+* DESCRIPTION: Create the FwEvent module object 
+* 
+* INPUTS:  None
+* 
+* OUTPUT:  None
+* 
+* RETURNS: The Created object
+****************************************************************************/
+TI_HANDLE FwEvent_Create (TI_HANDLE hOs)
+{
+    FwEventObj_t *pFwEvent;
+
+    pFwEvent = os_memoryAlloc (hOs, sizeof(FwEventObj_t));
+    if (pFwEvent == NULL)
+    {
+        return NULL;
+    }
+
+    os_memoryZero (hOs, pFwEvent, sizeof(FwEventObj_t));
+
+    pFwEvent->hOs = hOs;
+
+    return (TI_HANDLE)pFwEvent;
+} /* FwEvent_Create() */
+
+
+/****************************************************************************
+*                      FwEvent_Destroy()
+****************************************************************************
+* DESCRIPTION: Destroy the FwEvent module object 
+* 
+* INPUTS:  hFwEvent - The object to free
+* 
+* OUTPUT:  None
+* 
+* RETURNS: OK 
+****************************************************************************/
+TI_STATUS FwEvent_Destroy (TI_HANDLE hFwEvent)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    if (pFwEvent)
+    {
+        os_memoryFree (pFwEvent->hOs, pFwEvent, sizeof(FwEventObj_t));
+    }
+
+    return TNETWIF_OK;
+} /* FwEvent_Destroy() */
+
+
+/****************************************************************************
+*                      FwEvent_Config()
+****************************************************************************
+* DESCRIPTION: Config the FwEvent module object 
+* 
+* INPUTS:  hTNETW_Driver - TNETW Driver handle
+*          hhFwEvent     - FwEvent handle;
+* 
+* OUTPUT:  None
+* 
+* RETURNS: None
+****************************************************************************/
+VOID FwEvent_Config (TI_HANDLE hFwEvent, TI_HANDLE hTnetwDrv)
+{
+    FwEventObj_t  *pFwEvent     = (FwEventObj_t *)hFwEvent;
+    TnetwDrv_t    *pTnetwDrv    = (TnetwDrv_t *)hTnetwDrv;
+
+    pFwEvent->hOs               = pTnetwDrv->hOs;
+    pFwEvent->hReport           = pTnetwDrv->hReport;
+    pFwEvent->hTNETWIF          = pTnetwDrv->hTNETWIF;
+
+    /* Register clients in order of their priorities */
+    pFwEvent->hClient[0]        = pTnetwDrv->hRxXfer;
+    pFwEvent->hClient[1]        = pTnetwDrv->hTxResult;
+    pFwEvent->hClient[2]        = pTnetwDrv->hRxXfer;
+    pFwEvent->hClient[3]        = pTnetwDrv->hCmdMBox;
+    pFwEvent->hClient[4]        = pTnetwDrv->hEventMbox;
+    pFwEvent->hClient[5]        = pTnetwDrv->hEventMbox;
+#ifdef TI_DBG
+    pFwEvent->hClient[6]        = pTnetwDrv->hDebugTrace;
+    pFwEvent->hClient[7]        = pTnetwDrv->hDebugTrace;
+#endif /* TI_DBG */
+
+    pFwEvent->FwEventState      = FW_EVENT_STATE_IDLE;
+    pFwEvent->EventMask         = 0;
+
+    /* Setting the RxControlAddr to 0 indicates that it shouldn't be used */
+    pFwEvent->RxControlAddr     = 0;
+    pFwEvent->uNumOfRxHandled   = 0;
+    /* Before reading the first Fw Rx counters act like there's no Rx. This is done for the init phase */
+    pFwEvent->uFwRxCounter      = 0;
+} /* FwEvent_Config() */
+
+
+/****************************************************************************
+*                      FwEvent_SetHwInfo()
+****************************************************************************
+* DESCRIPTION: Set the rx control address. This is the register to be read 
+                for the Fw Rx counters. Before this function is called we don't
+                use that variable.
+* 
+* INPUTS:  hFwEvent         - FwEvent handle;
+*          pDataPathParams  - struct to read the Address from
+*
+* OUTPUT:  None
+* 
+* RETURNS: None
+****************************************************************************/
+void FwEvent_SetHwInfo (TI_HANDLE hFwEvent, ACXDataPathParamsResp_t *pDataPathParams)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    pFwEvent->RxControlAddr = pDataPathParams->rxControlAddr;
+
+    WLAN_REPORT_INFORMATION (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+        ("%s: RxControlAddr=0x%x\n", __FUNCTION__, pFwEvent->RxControlAddr));
+}
+
+
+/****************************************************************************
+ *                      FwEvent_CallHandler()
+ ****************************************************************************
+ * DESCRIPTION: Call FwEvent client's event handler 
+ * 
+ * INPUTS:  hFwEvent - The object
+
+
+
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: NOK, TNETWIF_COMPLETE, TNETWIF_PENDING 
+ ****************************************************************************/
+static TI_STATUS FwEvent_CallHandler (TI_HANDLE hFwEvent)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+    TI_STATUS     rc;
+
+    if (pFwEvent->EventVector == 0)
+    { 
+        return NOK;
+    }
+
+    while ((pFwEvent->EventNum < MAX_EVENT_NUM) &&
+           (pFwEvent->EventVector & fwClient[pFwEvent->EventNum].event) == 0)
+        pFwEvent->EventNum ++; 
+
+    if (pFwEvent->EventNum < MAX_EVENT_NUM)
+    {
+        /* Negate corresponding bit in event vector */
+        pFwEvent->EventVector &= ~fwClient[pFwEvent->EventNum].event;
+
+        /* Call client handler */
+        rc = fwClient[pFwEvent->EventNum].func (pFwEvent->hClient[pFwEvent->EventNum]);
+
+        WLAN_REPORT_INFORMATION (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+            ("FwEvent_CallHandler: %s, return=%u\n", fwClient[pFwEvent->EventNum].trace, rc));
+
+        return rc;
+    }
+
+    return NOK;
+
+} /* FwEvent_CallHandler */
+
+
+/****************************************************************************
+ *                      FwEvent_StateMachine()
+ ****************************************************************************
+ * DESCRIPTION: Manage the FwEvent state machine 
+ * 
+ * INPUTS:  hFwEvent - The object
+ *          rc       - Code passed FwEvent_EventComplete(), either  OK or MORE
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None 
+ ****************************************************************************/
+static void FwEvent_StateMachine (TI_HANDLE hFwEvent, systemStatus_e rc)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    while (rc != TNETWIF_PENDING)
+    {       
+        switch (pFwEvent->FwEventState)
+        {      
+            case FW_EVENT_STATE_WAIT_BUS_I:
+                pFwEvent->PendingEvent = FALSE;
+                pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_MASK;
+                /* 
+                 * We reach this state after TNETWIF_Start CB
+                 * mask the interrupts in the FW 
+                 */
+                rc = TNETWIF_WriteRegOpt (pFwEvent->hTNETWIF,
+                                          HINT_MASK,
+                                          ACX_INTR_ALL,
+                                          FW_EVENT_MODULE_ID,
+                                          FwEvent_WriteMaskCB,
+                                          hFwEvent);
+
+                break;
+
+            case FW_EVENT_STATE_WAIT_MASK:  
+                pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_UNMUX;
+                if (OK == TNETWIF_UnMux (pFwEvent->hTNETWIF))
+                {
+                    rc = TNETWIF_WriteELPOpt (pFwEvent->hTNETWIF, 
+                                              0x1,/*ELPCTRL_WAKE_UP*/
+                                              FW_EVENT_MODULE_ID,
+                                              FwEvent_WriteMuxCB, 
+                                              hFwEvent,
+                                              TRUE);              
+                }
+                else
+                {
+                    rc = TNETWIF_COMPLETE;
+                } 
+                break;
+
+            case FW_EVENT_STATE_WAIT_UNMUX:
+            case FW_EVENT_STATE_WAIT_BUS_II:
+                pFwEvent->LoopCounter++;
+                /* Read the rx counters if the Address was configured */
+                if (pFwEvent->RxControlAddr)
+                {
+                pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_HINT_READ;
+                }
+                /* Rx Address was not configured yet. Jump over the read counters state */
+                else    
+                {
+                    pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_READ_COUNTERS;
+                }
+                /* 
+                 * We reach this state after TNETWIF_Start CB
+                 * mask the interrupts in the FW 
+                 */
+                rc = TNETWIF_ReadRegOpt (pFwEvent->hTNETWIF, 
+                                         ACX_REG_INTERRUPT_CLEAR, 
+                                         &pFwEvent->EventVector,
+                                         FW_EVENT_MODULE_ID,
+                                         FwEvent_ReadRegCB,
+                                         hFwEvent);
+
+                break;      
+
+            case FW_EVENT_STATE_WAIT_HINT_READ:
+                /* 
+                 * Read Fw rx counters. This is needed due to a BUG in the Rx bits which causes to loose bits in the
+                 * EventVector, and therefore we can't relay on the HINT read. The BUG is Fw/Hw related
+                 */ 
+                pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_READ_COUNTERS;
+
+                rc = TNETWIF_ReadMemOpt (pFwEvent->hTNETWIF, 
+                                         pFwEvent->RxControlAddr, 
+                                         PADREAD (&pFwEvent->uFwRxCounter),
+                                         sizeof(UINT32),
+                                         FW_EVENT_MODULE_ID,
+                                         FwEvent_ReadRegCB,
+                                         hFwEvent);
+
+                break;     
+
+            case FW_EVENT_STATE_WAIT_READ_COUNTERS:
+                            
+                WLAN_REPORT_INFORMATION(pFwEvent->hReport,FW_EVENT_MODULE_LOG,
+                    ("Reading HostIntRegister = 0x%x, FwRxCounter = 0x%x DriverRxCounter = 0x%x\n", 
+                    pFwEvent->EventVector, pFwEvent->uFwRxCounter, pFwEvent->uNumOfRxHandled));
+                /* 
+                 * Mask unwanted interrupts. 
+                 */
+                pFwEvent->EventVector &= pFwEvent->EventMask;
+                
+                /* Work-around: check if there's a missing Rx bit (or 2 bits) in the Register */
+                FwEvent_UpdateRxBits (hFwEvent);
+                
+                if (pFwEvent->EventVector == 0)
+                {
+                                  #ifdef LEVEL_IRQ
+                                       /* if working level sensitive mode we must first enable IRQ source */
+                                       os_enableIrq(pFwEvent->hOs);
+                                  #endif
+                    pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_UNMASK;
+                    /* Unmask the interrupts in the FW */ 
+                    rc = TNETWIF_WriteRegOpt (pFwEvent->hTNETWIF,
+                                              HINT_MASK,
+                                              ~pFwEvent->EventMask,
+                                              FW_EVENT_MODULE_ID,
+                                              FwEvent_WriteMaskCB,
+                                              hFwEvent);    
+                }
+                else
+                {
+                    pFwEvent->FwEventState = FW_EVENT_STATE_HANDLE_EVENT;
+
+                    rc = TNETWIF_COMPLETE;
+                }
+              
+                break;
+
+            case FW_EVENT_STATE_HANDLE_EVENT:                           
+                if ((rc = FwEvent_CallHandler (hFwEvent)) == NOK)
+                {      
+                    /* All events have been handled, break the loop */
+                    if (pFwEvent->LoopCounter < NUM_OF_READ_REG_LOOPS)
+                    {
+                        /* Restart */
+                        pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_BUS_II;
+                        rc = TNETWIF_Restart (pFwEvent->hTNETWIF, 
+                                              FW_EVENT_MODULE_ID, 
+                                              hFwEvent, 
+                                              FwEvent_BusReadyCB);
+                    }
+                    else    
+                    {
+                                          #ifdef LEVEL_IRQ
+                                               /* if working level sensitive mode we must first enable IRQ source */
+                                               os_enableIrq(pFwEvent->hOs);
+                                          #endif
+                        /* Unmask the interrupts in the FW */ 
+                        pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_UNMASK;                                
+                        rc = TNETWIF_WriteRegOpt (pFwEvent->hTNETWIF,
+                                                  HINT_MASK,
+                                                  ~pFwEvent->EventMask,
+                                                  FW_EVENT_MODULE_ID,
+                                                  FwEvent_WriteMaskCB,
+                                                  hFwEvent);
+                    }                   
+                }
+                break;
+
+            case FW_EVENT_STATE_WAIT_UNMASK:
+                /* We get here after unmask CB */
+                if (pFwEvent->PendingEvent)
+                {
+                    pFwEvent->PendingEvent = FALSE;
+                    pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_BUS_I;
+                    TNETWIF_Restart (pFwEvent->hTNETWIF, 
+                                     FW_EVENT_MODULE_ID, 
+                                     hFwEvent, 
+                                     FwEvent_BusReadyCB);                     
+                }
+                else
+                {
+                    pFwEvent->FwEventState = FW_EVENT_STATE_IDLE;
+                    TNETWIF_Finish (pFwEvent->hTNETWIF, FW_EVENT_MODULE_ID, NULL, NULL);
+                }
+                rc = TNETWIF_PENDING;
+                break;
+
+            case FW_EVENT_STATE_IDLE:
+            default:
+                WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                                   ("FwEvent_StateMachine - invalid state\n"));
+                rc = TNETWIF_PENDING;
+                break;
+                    
+        } /* switch */
+
+        if (TNETWIF_ERROR == rc)
+        {
+            WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                               ("FwEvent_StateMachine rc = TNETWIF_ERROR !!! in state = %d\n",
+                               pFwEvent->FwEventState));
+        }
+
+    } /* while */
+
+} /* FwEvent_StateMachine() */
+
+
+/****************************************************************************
+ *                      FwEvent()
+ ****************************************************************************
+ * DESCRIPTION: Start FwEvent 
+ * 
+ * INPUTS:  hFwEvent - The object 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK - if in Idle NOK - else
+ ****************************************************************************/
+TI_STATUS FwEvent (TI_HANDLE hFwEvent)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    /* NOTE: pFwEvent may be uninitialized at init stage */
+    if (pFwEvent != NULL)
+    {
+        if (pFwEvent->FwEventState == FW_EVENT_STATE_IDLE)
+        {
+            pFwEvent->IntrState = STATE_DPC;
+            pFwEvent->EventVector  = 0;
+            pFwEvent->LoopCounter  = 0;
+            pFwEvent->FwEventState = FW_EVENT_STATE_WAIT_BUS_I;
+
+            /* NOTE: hTNETWIF may be uninitialized at init */
+            if (pFwEvent->hTNETWIF != NULL)
+            {
+                TNETWIF_Start (pFwEvent->hTNETWIF, FW_EVENT_MODULE_ID, hFwEvent, FwEvent_BusReadyCB);                   
+            }
+        }
+        else if (pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_UNMASK)
+        {
+            pFwEvent->LoopCounter = 0;
+            /*
+             * If an interrupt receiving while unmasking the previous, sign it as pending and exit. 
+             * It will be handled in the next iteration after Restart.
+             */ 
+            pFwEvent->PendingEvent = TRUE;
+        }
+        else
+        {       
+            WLAN_REPORT_WARNING (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                                 ("FwEvent() entering SM not in Idle !!! state: %d\n",
+                                 pFwEvent->FwEventState));
+            
+            return NOK;
+        }
+    }
+
+    return OK;
+} /* FwEvent() */
+
+
+/****************************************************************************
+ *                      FwEvent_BusReadyCB()
+ ****************************************************************************
+ * DESCRIPTION: FwEvent_BusReadyCB 
+ * 
+ * INPUTS:  hFwEvent - The object
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void FwEvent_BusReadyCB (TI_HANDLE hFwEvent, UINT8 module_id, TI_STATUS status)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    if (pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_BUS_I ||
+        pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_BUS_II)
+    {
+        /*
+         * NOTE: init the EventNum here for it take effect both for Start and Restart
+         */
+        pFwEvent->EventNum = 0;
+        FwEvent_StateMachine (hFwEvent, TNETWIF_NONE);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                           ("FwEvent_BusReadyCB() state(%d) is not FW_EVENT_STATE_READ_REG\n",
+                           pFwEvent->FwEventState));
+    }
+} /* FwEvent_BusReadyCB() */
+
+
+/****************************************************************************
+ *                      FwEvent_WriteMaskCB()
+ ****************************************************************************
+ * DESCRIPTION: Write Mask CB 
+ * 
+ * INPUTS:  hFwEvent - The object
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void FwEvent_WriteMaskCB (TI_HANDLE hFwEvent, UINT8 moduleID, TI_STATUS status)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    if (pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_MASK ||
+        pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_UNMASK)
+    {
+        FwEvent_StateMachine (hFwEvent, TNETWIF_NONE);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                           ("FwEvent_WriteMaskCB() shouldn't be called with state(%d)\n",
+                           pFwEvent->FwEventState));
+    }
+} /* FwEvent_WriteMaskCB() */
+
+
+/****************************************************************************
+ *                      FwEvent_WriteMuxCB()
+ ****************************************************************************
+ * DESCRIPTION: Write Mask CB 
+ * 
+ * INPUTS:  hFwEvent - The object
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void FwEvent_WriteMuxCB (TI_HANDLE hFwEvent, UINT8 moduleID, TI_STATUS status)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    if (pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_UNMUX)        
+    {
+        FwEvent_StateMachine (hFwEvent, TNETWIF_NONE);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                           ("FwEvent_WriteMaskCB() shouldn't be called with state(%d)\n",
+                           pFwEvent->FwEventState));
+    }
+} /* FwEvent_WriteMaskCB() */
+
+
+/****************************************************************************
+ *                      FwEvent_ReadRegCB()
+ ****************************************************************************
+ * DESCRIPTION: FwEvent_ReadRegCB 
+ * 
+ * INPUTS:  hFwEvent - The object
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void FwEvent_ReadRegCB (TI_HANDLE hFwEvent, UINT8 moduleID, TI_STATUS status)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+        
+    if ((pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_HINT_READ) || 
+        (pFwEvent->FwEventState == FW_EVENT_STATE_WAIT_READ_COUNTERS))
+    {
+        FwEvent_StateMachine (hFwEvent, TNETWIF_NONE);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                           ("FwEvent_ReadRegCB() is in state(%d)\n",
+                           pFwEvent->FwEventState));
+    }
+} /* FwEvent_BusReadyCB() */
+
+
+/****************************************************************************
+ *                      FwEvent_UpdateRxBits()
+ ****************************************************************************
+ * DESCRIPTION: Update the EventVector according to the Fw counter of Rx.
+ *              The Rx bits from the EventVector are ignored and instead we are
+ *              using the Fw counters in order to decide how many Rx should we read.
+ *              Using this method is due to a Hw/Fw bug in which we miss some of the 
+ *              Rx bits in the EventVector.
+ * 
+ * INPUTS:  pFwEvent - The object
+ * 
+ * OUTPUT:  pFwEvent->EventVector - Add Rx bit if needed
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void FwEvent_UpdateRxBits (TI_HANDLE hFwEvent)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+    UINT32 uFwDriverDiff = pFwEvent->uFwRxCounter - pFwEvent->uNumOfRxHandled;
+    
+    /* use only the last 4 bits since the Fw is using 4 bits */
+    uFwDriverDiff &= 0xf;   
+
+    /* Use the diff to add the number of bits needed for handling */
+    switch (uFwDriverDiff) 
+    {
+    case 0: 
+        /* Erase Rx bits */
+        pFwEvent->EventVector &= ~ACX_INTR_RX0_DATA;
+        pFwEvent->EventVector &= ~ACX_INTR_RX1_DATA;
+        break;
+    case 1: 
+        /* Add only one bit */
+        pFwEvent->EventVector |=  ACX_INTR_RX0_DATA; 
+        pFwEvent->EventVector &= ~ACX_INTR_RX1_DATA;
+        break;
+    case 2: 
+        /* Add the 2 bits */
+        pFwEvent->EventVector |=  ACX_INTR_RX0_DATA; 
+        pFwEvent->EventVector |= ACX_INTR_RX1_DATA;
+        break;
+    default: 
+        /*
+         * This is a very bad case were there is no synchronization between Driver & FW. In order to recover from this 
+         * state we will use the the EventVector "as-is" and hope for the best... 
+         */
+        WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+            ("%s Fw = 0x%x Dr = 0x%x\n", __FUNCTION__, pFwEvent->uFwRxCounter, pFwEvent->uNumOfRxHandled)); 
+
+        break;
+    }
+
+    /* This will make sure that next time we will be synchronized with the Fw */
+    pFwEvent->uNumOfRxHandled = pFwEvent->uFwRxCounter; 
+
+}
+
+/****************************************************************************
+ *                      FwEvent_EventComplete()
+ ****************************************************************************
+ * DESCRIPTION: FwEvent_EventComplete 
+ * 
+ * INPUTS:  hFwEvent - The object
+ *          rc - OK or MORE
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void FwEvent_EventComplete (TI_HANDLE hFwEvent, systemStatus_e rc)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    if (pFwEvent->FwEventState == FW_EVENT_STATE_HANDLE_EVENT)
+    {
+        FwEvent_StateMachine (hFwEvent,rc);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+                           ("FwEvent_EventComplete() state(%d) is not FW_EVENT_STATE_PENDING\n",
+                           pFwEvent->FwEventState));
+    }
+} /* FwEvent_EventComplete() */
+
+
+/****************************************************************************
+ *                      FwEvent_Enable()
+ ****************************************************************************
+ * DESCRIPTION: enable specific interrupt
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:
+ ****************************************************************************/
+void  FwEvent_Enable (TI_HANDLE hFwEvent, UINT32 uEventMask)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+    
+    pFwEvent->EventMask |= uEventMask;
+
+    WLAN_REPORT_INFORMATION (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+         ("%s: EventMask = 0x%x\n", __FUNCTION__, pFwEvent->EventMask));
+}
+
+
+/****************************************************************************
+ *                      FwEvent_Disable()
+ ****************************************************************************
+ * DESCRIPTION: disables specific interrupt
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:
+ ****************************************************************************/
+void  FwEvent_Disable (TI_HANDLE hFwEvent, UINT32 uEventMask)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+    
+    pFwEvent->EventMask &= ~uEventMask;
+
+    WLAN_REPORT_INFORMATION (pFwEvent->hReport, FW_EVENT_MODULE_LOG,
+         ("%s: EventMask = 0x%x\n", __FUNCTION__, pFwEvent->EventMask));
+}
+
+
+/****************************************************************************
+ *                      FwEvent_GetEnabled()
+ ****************************************************************************
+ * DESCRIPTION: returns interrupt enabled bit mask
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:
+ ****************************************************************************/
+UINT32 FwEvent_GetEnabled (TI_HANDLE hFwEvent)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+    
+    return pFwEvent->EventMask;
+}
+
+/******************************************************************************************************
+*
+*   Functions originally located at whalHwIntr.c - Not used in the current version and might be removed
+*
+*******************************************************************************************************/
+
+
+/****************************************************************************
+ *                      FwEvent_EnableInterrupts()
+ ****************************************************************************
+ * DESCRIPTION: Enable interrupts
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * NOTE: Originally located at whalHwIntr.c .
+ ****************************************************************************/
+void FwEvent_EnableInterrupts (TI_HANDLE hFwEvent)
+{
+#ifdef USE_SYNC_API
+
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    /* Clearing all the interrupt status register sources */
+    TNETWIF_WriteRegSync (pFwEvent->hTNETWIF, ACX_REG_INTERRUPT_MASK, ~pFwEvent->EventMask);
+    
+    /*
+     * Setting the right operation of the interrupt
+     * bit 5 - enable interrupt
+     * bit 7 - active low 
+     */
+    TNETWIF_WriteRegSync (pFwEvent->hTNETWIF, HI_CFG, HI_CFG_DEF_VAL);
+
+  #ifdef DEBUG_INTERRUPTS_PRINT
+    WLAN_REPORT_INFORMATION (pFwEvent->hReport,
+                             FW_EVENT_MODULE_LOG,
+                             ("FwEvent_EnableInterrupts(0x%08X)",
+                             pFwEvent->EventMask));
+  #endif /* DEBUG_INTERRUPTS_PRINT */
+
+  #if defined(HAL_ON_WIN)
+    /* (!!!) only in CardBus, add HostIfType parameter */
+    /* Enable Interrupt on a CardBus */
+    TNETWIF_WriteRegSync (pFwEvent->hTNETWIF, FEMR, 0x8000);
+  #endif
+
+#endif /* USE_SYNC_API */
+
+}
+
+/****************************************************************************
+ *                      FwEvent_DisableInterrupts()
+ ****************************************************************************
+ * DESCRIPTION: Disable interrupts
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS:
+ ****************************************************************************/
+void FwEvent_DisableInterrupts (TI_HANDLE hFwEvent)
+{   
+#ifdef USE_SYNC_API
+
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    TNETWIF_WriteRegSync (pFwEvent->hTNETWIF, ACX_REG_INTERRUPT_MASK, ACX_INTR_ALL );
+
+  #ifdef DEBUG_INTERRUPTS_PRINT
+    WLAN_REPORT_INFORMATION (pFwEvent->hReport,
+                             FW_EVENT_MODULE_LOG,
+                             ("FwEvent_DisableInterrupts(0x%08X)",
+                             ACX_INTR_ALL));
+  #endif /* DEBUG_INTERRUPTS_PRINT */
+
+#endif /* USE_SYNC_API */
+}
+
+
+/****************************************************************************
+ *                      FwEvent_CheckInterrupts()
+ ****************************************************************************
+ * DESCRIPTION: Check if there is interrupts (only unmasked)
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: 0 - no interrupts, otherwise - there are interrupts
+ ****************************************************************************/
+UINT32 FwEvent_CheckInterrupts (TI_HANDLE hFwEvent)
+{
+#ifdef USE_SYNC_API
+
+    FwEventObj_t     *pFwEvent  = (FwEventObj_t *)hFwEvent;
+    register UINT32 CurrentIntr;
+    UINT32 interruptRegVal;
+    register UINT32 maskInterruptVal;
+  #ifdef DEBUG_INTERRUPTS_PRINT
+    UINT32 endReg;
+  #endif /* DEBUG_INTERRUPTS_PRINT */
+
+    if (pFwEvent->IntrState != STATE_OPERATIONAL)
+    {
+        /*
+        ISR can't be called till the state will be operational again because the ISR
+        disable the interrupts of the TNET thus if this function is called then it need
+        to return 0!!!
+        */
+  #ifdef DEBUG_INTERRUPTS_PRINT
+        WLAN_REPORT_WARNING (pFwEvent->hReport,
+                             FW_EVENT_MODULE_LOG,
+                             ("FwEvent_CheckInterrupts() - state isn't STATE_OPERATIONAL (=%d) - ABRTING!\n",
+                             pFwEvent->IntrState));
+  #endif /* DEBUG_INTERRUPTS_PRINT */
+    }
+
+  #ifdef HW_ACCESS_DEBUG_ACCESS_VIOLATION
+    whal_hwAccess_setOverrideElpCheck ((TI_HANDLE)pFwEvent->hTNETWIF, TRUE);                                      
+  #endif /* HW_ACCESS_DEBUG_ACCESS_VIOLATION */
+
+    /*read the status register*/
+    TNETWIF_ReadRegSync (pFwEvent->hTNETWIF, ACX_REG_INTERRUPT_NO_CLEAR, &interruptRegVal);
+    
+    CurrentIntr = interruptRegVal;
+
+    /* 0xFFFF means that the card is disconnected !!! */
+    if ((CurrentIntr & 0xffff) == 0xffff) /* error */
+        CurrentIntr = 0;
+
+    /* check with the interrupt mask register */
+    maskInterruptVal = pFwEvent->EventMask;
+    CurrentIntr &= maskInterruptVal;
+    if (interruptRegVal != CurrentIntr)
+    {
+  #ifdef DEBUG_INTERRUPTS_PRINT
+        WLAN_REPORT_ERROR(pFwEvent->hReport,
+                          FW_EVENT_MODULE_LOG,
+                          ("%s(%d) - interrupt vector include masked interrupts\n.\
+                          interruptRegVal   = 0x%08X\n\
+                          hwMaskInterruptVal= 0x%08X\n\
+                          swMaskInterruptVal= 0x%08X\n\
+                          currrentInt       = 0x%08X\n\
+                          diverse           = 0x%08X\n\
+                          IntrState         = %d\n",
+                          __FILE__,__LINE__,
+                          interruptRegVal,
+                          maskInterruptVal,
+                          pFwEvent->EventMask,
+                          CurrentIntr,
+                          (CurrentIntr ^ interruptRegVal),
+                          pFwEvent->IntrState));
+  #endif /* DEBUG_INTERRUPTS_PRINT */
+    }
+
+  #ifdef ACK_ON_CHECK_PHASE
+    /* set ACK to the interrupts on the check phase */
+    if (CurrentIntr != 0)
+    {
+        /* Save the occurring interrupts - to handle interrupt routine */
+        pFwEvent->SaveIntrValue |= CurrentIntr;
+        HW_INTR_ACK(pFwEvent->hTNETWIF, CurrentIntr);
+        /*
+        state is now wait for DPC
+        */
+        pFwEvent->IntrState = STATE_WAIT_FOR_DPC;
+    }
+  #endif /* ACK_ON_CHECK_PHASE */
+
+  #ifdef DEBUG_INTERRUPTS_PRINT
+
+    TNETWIF_ReadRegSync (pFwEvent->hTNETWIF, ACX_REG_INTERRUPT_NO_CLEAR, &endReg);
+    WLAN_REPORT_INFORMATION(pFwEvent->hReport,
+                            FW_EVENT_MODULE_LOG,
+                            ("%s(%d) - finish ISR ,endReg... \n.\
+                            Intr   = 0x%08X\n",
+                            __FILE__,__LINE__,
+                            endReg));
+  #endif /* DEBUG_INTERRUPTS_PRINT */
+
+  #ifdef HW_ACCESS_DEBUG_ACCESS_VIOLATION
+    whal_hwAccess_setOverrideElpCheck ((TI_HANDLE)pFwEvent->hTNETWIF, FALSE);                                  
+  #endif /* HW_ACCESS_DEBUG_ACCESS_VIOLATION */
+
+    /* (!!!1150) Reset the interrupt line*/
+    TNETWIF_WriteRegSync (pFwEvent->hTNETWIF, PCI_STATUS_CLR_REG, 0x80000000 /*v2p_intr was asserted*/);
+
+    return CurrentIntr;
+
+#else
+
+    return 0;
+
+#endif /* USE_SYNC_API */
+}
+
+
+/****************************************************************************
+ *                      FwEvent_ChangeState()
+ ****************************************************************************
+ * DESCRIPTION: Disable interrupts
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS:
+ ****************************************************************************/
+void FwEvent_ChangeState (TI_HANDLE hFwEvent, int State)
+{
+    FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+    pFwEvent->IntrState = State;
+}
+
+
+/****************************************************************************
+ *                      FwEvent_StateChanged()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *              StateChanged - change mask notification and 
+ *                              interrupt acknowledge. Used for SDIO driver
+ *
+ * RETURNS: None 
+ ****************************************************************************/
+void FwEvent_StateChanged (TI_HANDLE hFwEvent)      
+{
+  #ifdef USE_SYNC_API
+    FwEventObj_t *pFwEvent  = (FwEventObj_t *)hFwEvent;
+
+    TNETWIF_WriteRegSync (pFwEvent->hTNETWIF, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_STATE_CHANGED);
+  #endif
+}
+
+/****************************************************************************
+ *                      FwEvent_Stop()
+ ****************************************************************************
+ * DESCRIPTION:        Stop & reser FwEvent (called by the recovery)
+ * 
+ * INPUTS:     
+ *                     hhFwEvent - FwEvent handle;
+ *
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+VOID  FwEvent_Stop(TI_HANDLE hFwEvent)
+{
+       FwEventObj_t *pFwEvent = (FwEventObj_t *)hFwEvent;
+
+       pFwEvent->FwEventState  = FW_EVENT_STATE_IDLE;
+
+       /* Setting the RxControlAddr to 0 indicates that it shouldn't be used */
+       pFwEvent->RxControlAddr     = 0;
+       pFwEvent->uNumOfRxHandled   = 0;
+       /* Before reading the first Fw Rx counters act like there's no Rx. This is done for the init phase */
+       pFwEvent->uFwRxCounter      = 0;
+
+} /* FwEvent_Stop() */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.h
new file mode 100644 (file)
index 0000000..27adc81
--- /dev/null
@@ -0,0 +1,95 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   FwEvent.h                                                  */
+/*    PURPOSE:  Handle firmware events.                                    */
+/*                                                                         */
+/***************************************************************************/
+#ifndef _FW_EVENT_
+#define _FW_EVENT_
+
+#include "FwEvent_api.h"
+
+#define NUM_OF_READ_REG_LOOPS      1
+
+#ifdef TI_DBG
+  #define MAX_EVENT_NUM            8
+#else
+  #define MAX_EVENT_NUM            6
+#endif
+
+typedef enum
+{
+    FW_EVENT_STATE_IDLE,    
+    FW_EVENT_STATE_WAIT_BUS_I,
+    FW_EVENT_STATE_WAIT_BUS_II,
+    FW_EVENT_STATE_WAIT_MASK,   
+    FW_EVENT_STATE_WAIT_UNMUX,
+    FW_EVENT_STATE_WAIT_HINT_READ,
+    FW_EVENT_STATE_WAIT_READ_COUNTERS,
+    FW_EVENT_STATE_HANDLE_EVENT,
+    FW_EVENT_STATE_WAIT_UNMASK
+} FwEventState_e;
+
+
+/* The FwEvent module object. */
+typedef struct 
+{
+    FwEventState_e  FwEventState;           /* State machine state */
+    UINT32          EventVector;            /* Read interrupt status vector */ 
+    UINT32          EventMask;              /* Static interrupt event mask */
+    UINT32          EventNum;               /* Event interrupt counter */
+    UINT32          IntrState;              /* Interrupt state */
+    BOOL            PendingEvent;           /* Pending event indicator */
+    UINT32          LoopCounter;   
+
+    /* The next 3 variables are used for a work around solution of mismatch between Fw & Driver events */
+    UINT32          RxControlAddr;
+    UINT32          uNumOfRxHandled;
+    /* use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (UINT32          uFwRxCounter)
+    
+
+    TI_HANDLE       hOs;                    /* OS handle */
+    TI_HANDLE       hReport;                /* Report handle */
+    TI_HANDLE       hTNETWIF;               /* TNETWIF handle */
+    TI_HANDLE       hClient [MAX_EVENT_NUM];/* Array of client handles */
+
+} FwEventObj_t; 
+
+#endif  /* _FW_EVENT_ */
+        
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/HwInit/HwInit.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/HwInit/HwInit.c
new file mode 100644 (file)
index 0000000..e5cc2be
--- /dev/null
@@ -0,0 +1,308 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/*******************************************************************************/
+/*                                                                             */
+/*  MODULE:  hwInit.c                                                          */
+/*  PURPOSE: HwInit module manages the init process of the TNETW, included     */
+/*           firmware download process. It shall perform Hard Reset the chip   */
+/*           if possible (this will require a Reset line to be connected to    */
+/*           the host); Start InterfaceCtrl; Download NVS and FW               */
+/*                                                                             */
+/*                                                                             */
+/*******************************************************************************/
+
+#include "paramOut.h"
+#include "osApi.h"
+#include "report.h"
+#include "HwInit.h"
+#include "HwInit_api.h"
+
+#include "whalCommon.h"
+#include "whalBus_Api.h"
+#include "shmBus.h"
+
+#include "FwEvent_api.h"
+#include "TNETWIF.h"
+#include "shmFwCtrl.h"
+#include "TNETW_Driver.h"
+#include "TNETW_Driver_api.h"
+#include "whalHwCtrl.h"
+
+#include "whalHwAccess.h"
+#include "eventMbox_api.h"
+
+/* static function */
+#ifdef USE_RECOVERY
+static TI_STATUS InitHw_StartInit(TI_HANDLE hHwCtrl);
+#endif /* USE_RECOVERY */
+
+/*******************************************************************************
+*                       PUBLIC  FUNCTIONS  IMPLEMENTATION                      *
+********************************************************************************/
+
+
+/*************************************************************************
+*                        hwInit_create                              *
+**************************************************************************
+* DESCRIPTION:  This function initializes the HwInit module.
+*
+* INPUT:        hOs - handle to Os Abstraction Layer
+*               
+* RETURN:       Handle to the allocated HwInit module
+*************************************************************************/
+TI_HANDLE hwInit_create(TI_HANDLE hOs)
+{
+#ifdef USE_RECOVERY
+    hwInit_t *hHwInit;
+
+    /* allocate HwInit module */
+    hHwInit = os_memoryAlloc(hOs, (sizeof(hwInit_t)));
+
+    if(!hHwInit)
+    {
+        WLAN_OS_REPORT(("Error allocating the HwInit Module\n"));
+        return NULL;
+    }
+
+    /* Reset HwInit module */
+    os_memoryZero(hOs, hHwInit, (sizeof(hwInit_t)));
+
+    hHwInit->hOs = hOs;
+
+    return(hHwInit);
+#else
+    return NULL;
+#endif /* USE_RECOVERY */
+} /* hwInit_create */
+
+
+/***************************************************************************
+*                           hwInit_config                             *
+****************************************************************************
+* DESCRIPTION:  This function configures the hwInit module
+*
+* RETURNS:      OK - Configuration successful
+*               NOK - Configuration unsuccessful
+***************************************************************************/
+TI_STATUS hwInit_config(TI_HANDLE hHwInit,
+                        TI_HANDLE hReport,
+                        TI_HANDLE hTNETWIF)
+{
+#ifdef USE_RECOVERY
+    hwInit_t *pHwInit = (hwInit_t *)hHwInit;
+
+    /* configure modules handles */
+    pHwInit->hReport = hReport;
+    pHwInit->hTNETWIF = hTNETWIF;
+
+    pHwInit->smState = HW_INIT_STATE_IDLE;
+    
+    WLAN_REPORT_INIT(pHwInit->hReport, HW_INIT_MODULE_LOG,
+        (".....HwInit configured successfully\n"));
+#endif /* USE_RECOVERY */
+    return OK;
+    
+} /* hwInit_config */
+
+
+/***************************************************************************
+*                           hwInit_destroy                            *
+****************************************************************************
+* DESCRIPTION:  This function unload the HwInit module. 
+*
+* INPUTS:       hHwInit - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - Unload succesfull
+*               NOK - Unload unsuccesfull
+***************************************************************************/
+TI_STATUS hwInit_destroy(TI_HANDLE hHwInit)
+{
+#ifdef USE_RECOVERY
+    hwInit_t *pHwInit = (hwInit_t *)hHwInit;
+
+    /* free HwInit Module */
+    os_memoryFree(pHwInit->hOs, pHwInit, sizeof(hwInit_t));
+#endif /* USE_RECOVERY */
+    return OK;
+}
+
+/***************************************************************************
+*                           hwInit_recovery                                *
+****************************************************************************
+* DESCRIPTION:  Start HW init process after recovery. 
+*
+* INPUTS:       hHwInit - the object
+*
+* OUTPUT:
+*
+* RETURNS:      
+*    TNETWIF_COMPLETE - if completed, i.e. Synchronous mode.
+*    TNETWIF_PENDING  - if pending, i.e. Asynchronous mode (callback function will be called). 
+***************************************************************************/
+#ifdef USE_RECOVERY
+TI_STATUS hwInit_recovery(TI_HANDLE hHwInit, TI_HANDLE hHwCtrl, void *funcCB, TI_HANDLE hRecoveryCtrl)
+{
+    hwInit_t *pHwInit = (hwInit_t *)hHwInit;
+    HwCtrl_T *pHwCtrl = (HwCtrl_T *)hHwCtrl;
+
+    pHwInit->hHwCtrl = hHwCtrl;
+    pHwInit->recoveryProcess = TRUE;
+    pHwInit->hRecoveryCtrl = hRecoveryCtrl;
+    pHwInit->endOfHwInitCB = (EndOfHwInitCB_t)funcCB;
+
+    eventMbox_Stop(pHwCtrl->hEventMbox);
+
+    TNETWIF_Start (pHwInit->hTNETWIF, HAL_INIT_MODULE_ID, hHwCtrl, (TNETWIF_callback_t)InitHw_StartInit);
+
+    return TNETWIF_PENDING;
+}
+#endif /* USE_RECOVERY */
+
+/****************************************************************************
+ *                      InitHw_FinalizeDownload()
+ ****************************************************************************
+ * DESCRIPTION: Different FinalizeDownload for Init and Recovery. (Don't call
+ *              for "config" functions after recovery).
+ * 
+ * INPUTS:  hHwInit - the object    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS InitHw_FinalizeDownload(TI_HANDLE hHwInit)
+{
+#ifdef USE_RECOVERY
+    hwInit_t *pHwInit = (hwInit_t *)hHwInit;
+    TI_STATUS status;
+
+    status = (TI_STATUS)whal_hwCtrl_ConfigHw(pHwInit->hHwCtrl, (void *)pHwInit->endOfHwInitCB, pHwInit->hRecoveryCtrl, TRUE);
+    if (status != OK)
+    {
+        WLAN_REPORT_INFORMATION (pHwInit->hReport, HW_INIT_MODULE_LOG,
+            ("InitHw_FinalizeDownload: whal_hwCtrl_ConfigHw failed\n"));
+        return TNETWIF_ERROR;
+    }
+#endif /* USE_RECOVERY */
+    return TNETWIF_COMPLETE;
+
+}
+
+
+/****************************************************************************
+ *                      InitHw_StartInit()
+ ****************************************************************************
+ * DESCRIPTION: start init process for recovery
+ * 
+ * INPUTS:  hHwInit - the object    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+#ifdef USE_RECOVERY
+static TI_STATUS InitHw_StartInit(TI_HANDLE hHwCtrl)
+{
+    HwCtrl_T *pHwCtrl = (HwCtrl_T *)hHwCtrl;
+    WlanParams_T *pWlanParams;
+    BootAttr_T BootAttr;
+    TI_STATUS retStatus;
+
+    whalBus_T *pWhalBus;
+    PUINT8  FwBuf, EEpromBuf;
+    UINT32  FwSize, EEpromSize;
+    UINT32 *pWLAN_Images[4];
+
+    pWlanParams = whal_ParamsGetWlanParams(pHwCtrl->pWhalParams);
+
+    BootAttr.MacClock          = pWlanParams->MacClock;
+    BootAttr.ArmClock          = pWlanParams->ArmClock;
+
+    {
+        /* Get the FW image */
+        os_getFirmwareImage (pHwCtrl->hOs, &FwBuf, &FwSize, 0);
+        os_getRadioImage (pHwCtrl->hOs, &EEpromBuf, &EEpromSize, 0);
+        pWhalBus = (whalBus_T *)pHwCtrl->hWhalBus;
+        pWLAN_Images[0] = (UINT32 *)FwBuf;
+        pWLAN_Images[1] = (UINT32 *)FwSize;
+        pWLAN_Images[2] = (UINT32 *)EEpromBuf;
+        pWLAN_Images[3] = (UINT32 *)EEpromSize;
+    
+        pHwCtrl->uFwBuf = (UINT32)pWLAN_Images[0]; /* Firmware Image ptr */ 
+        pHwCtrl->uFwAddr = (UINT32)pWLAN_Images[1]; /* Firmware Image length */
+        pHwCtrl->uEEEPROMBuf = (UINT32)pWLAN_Images[2]; /* EEPROM Image ptr */
+        pHwCtrl->uEEEPROMLen = (UINT32)pWLAN_Images[3]; /* EEPROM Image length */    
+    }
+
+    /* Reset the TNETW by the reset line */
+    WLAN_OS_REPORT(("HARD RESET before\n"));
+    os_hardResetTnetw ();
+    WLAN_OS_REPORT(("HARD RESET after\n"));
+
+    pWhalBus->recoveryProcess = TRUE;
+
+    /* SDIO_enumerate */
+    {
+        TNETWIF_t *pTNETWIF = (TNETWIF_t *)(pWhalBus->hTNETWIF);
+        whal_hwAccess_ReConfig(pTNETWIF->hHwAccess); /* SDIO enumerate*/
+    }
+    /* set the working partition to its "running" mode offset */
+#if (defined(HW_ACCESS_SDIO)|defined(HW_ACCESS_WSPI))
+
+    TNETWIF_SetPartitions (pWhalBus->hTNETWIF, HW_ACCESS_DOWNLOAD, HW_ACCESS_DOWN_PART0_ADDR);
+
+#endif
+    TNETWIF_RegSetBitVal(pWhalBus->hTNETWIF,  ACX_REG_ECPU_CONTROL, ECPU_CONTROL_HALT);
+
+    retStatus = whalBus_FwCtrl_Boot (pHwCtrl->hWhalBus, (TI_HANDLE)pHwCtrl, &BootAttr);
+
+    /* release FW and NVS images */
+    /*
+     * Note: This is done assuming the boot process is complelty synchronous!!!
+     * Also, this is not done in GWSI becaues in GWSI these functions are not defined,
+     * because the load process is different. This has also to be fixed...
+     */
+    os_closeFirmwareImage (pHwCtrl->hOs);
+    os_closeRadioImage (pHwCtrl->hOs);
+
+    return(retStatus);
+}
+#endif /* USE_RECOVERY */
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/HwInit/HwInit.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/HwInit/HwInit.h
new file mode 100644 (file)
index 0000000..c1a1095
--- /dev/null
@@ -0,0 +1,85 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       HwInit.h                                                                                       */
+/*    PURPOSE: HwInit module Header file                             */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _HW_INIT_H_
+#define _HW_INIT_H_
+
+#include "osTIType.h"
+
+
+/* State-Machine States */
+typedef enum
+{
+       HW_INIT_STATE_IDLE,                             /*  */
+       HW_INIT_STATE_WAIT_BUS, /*  */
+       HW_INIT_STATE_DL_FW_CMPLT                       /*  */
+} hwInitSmState_e;
+
+/* Callback function definition for EndOfRecovery */
+typedef void (* EndOfHwInitCB_t)(TI_HANDLE CBObj);
+
+/* The module object. */
+typedef struct 
+{
+       /* Handles */
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hRecoveryCtrl;
+       TI_HANDLE hWhalBus;
+       TI_HANDLE hHwCtrl;
+       TI_HANDLE hTNETWIF;
+       TI_HANDLE hBusTxn;
+
+       EndOfHwInitCB_t endOfHwInitCB;
+       BOOL recoveryProcess;
+               
+       hwInitSmState_e smState;                        /* The current state of the SM. */      
+
+       PUINT8                                  FwBuf;          /* Firmware Image ptr */
+       UINT32                                  FwLastAddr;     /* Firmware Image length */
+       PUINT8                                  EEPROMBuf;      /* EEPROM Image ptr */
+       UINT32                                  EEPROMLen; /* EEPROM Image length */
+
+
+} hwInit_t;
+
+
+#endif /* _HW_INIT_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.c
new file mode 100644 (file)
index 0000000..564a56c
--- /dev/null
@@ -0,0 +1,747 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  rxXfer.c
+ *
+ *   PURPOSE: Rx Xfer module implementation.Responsible for reading Rx from the FW
+ *              and forward it to the upper layers.
+ * 
+ ****************************************************************************/
+
+#include "RxXfer.h"
+#include "utils.h"
+#include "report.h"
+#include "shmUtils.h"
+#include "FwEvent_api.h"
+#include "tnetwCommon.h"
+#include "whalBus_Defs.h"
+
+#define PLCP_HEADER_LENGTH 8
+
+/************************ static function declaration *****************************/
+
+static void      rxXfer_StateMachine (TI_HANDLE hRxXfer, UINT8 module_id, TI_STATUS status);
+static TI_STATUS rxXfer_ReadHeader (RxXfer_t *pRxXfer);
+static TI_STATUS rxXfer_ReadBody (RxXfer_t *pRxXfer);
+static void      rxXfer_ForwardCB (RxXfer_t *pRxXfer);
+static TI_STATUS rxXfer_AckRx (RxXfer_t *pRxXfer);
+static void      rxXfer_ConvertDescFlagsToAppFlags (UINT16 descRxFlags, UINT32 *aFlags, TI_STATUS *pPacketStatus);
+
+
+/****************************************************************************
+ *                      RxXfer_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the RxXfer module object 
+ * 
+ * INPUTS:  None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+TI_HANDLE rxXfer_Create (TI_HANDLE hOs)
+{
+    RxXfer_t *pRxXfer;
+
+    pRxXfer = os_memoryAlloc (hOs, sizeof(RxXfer_t));
+    if (pRxXfer == NULL)
+        return NULL;
+
+    /* For all the counters */
+    os_memoryZero (hOs, pRxXfer, sizeof(RxXfer_t));
+
+    pRxXfer->hOs = hOs;
+
+    return (TI_HANDLE)pRxXfer;
+}
+
+
+/****************************************************************************
+ *                      RxXfer_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the RxXfer module object 
+ * 
+ * INPUTS:  hRxXfer - The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+void rxXfer_Destroy (TI_HANDLE hRxXfer)
+{
+    RxXfer_t *pRxXfer = (RxXfer_t *)hRxXfer;
+
+    if (pRxXfer)
+    {
+        os_memoryFree (pRxXfer->hOs, pRxXfer, sizeof(RxXfer_t));
+    }
+} /* RxXfer_Destroy() */
+
+
+/****************************************************************************
+ *                      RxXfer_Config()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the FwEvent module object 
+ * 
+ * INPUTS:      hRxXfer       - FwEvent handle;
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void rxXfer_Config(TI_HANDLE hRxXfer,
+                   TI_HANDLE hFwEvent, 
+                   TI_HANDLE hMemMgr,
+                   TI_HANDLE hReport,
+                   TI_HANDLE hTNETWIF)
+{
+    RxXfer_t  *pRxXfer      = (RxXfer_t *)hRxXfer;
+
+    pRxXfer->hFwEvent       = hFwEvent;
+    pRxXfer->hMemMgr        = hMemMgr;
+    pRxXfer->hReport        = hReport;
+    pRxXfer->hTNETWIF       = hTNETWIF;
+
+    pRxXfer->state          = RX_XFER_STATE_IDLE;
+    pRxXfer->currBuffer     = 0;        /* first buffer to read from */
+    pRxXfer->lastPacketId   = 0;
+
+    FwEvent_Enable (pRxXfer->hFwEvent, ACX_INTR_RX0_DATA);
+    FwEvent_Enable (pRxXfer->hFwEvent, ACX_INTR_RX1_DATA);
+    
+#ifdef TI_DBG   
+    rxXfer_ClearStats (pRxXfer);
+#endif
+}
+
+
+/****************************************************************************
+ *                      rxXfer_Register_CB()
+ ****************************************************************************
+ * DESCRIPTION: Register the function to be called for received Rx
+ *              or the function to be called for request for buffer
+ * 
+ * INPUTS:      hRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void rxXfer_Register_CB (TI_HANDLE hRxXfer, tiUINT32 CallBackID, void *CBFunc, TI_HANDLE CBObj)
+{
+    RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
+
+    WLAN_REPORT_INFORMATION (pRxXfer->hReport, HAL_RX_MODULE_LOG, ("rxXfer_Register_CB (Value = 0x%x)\n", CallBackID));
+
+    switch(CallBackID)
+    {
+    case HAL_INT_RECEIVE_PACKET:
+        pRxXfer->ReceivePacketCB = (packetReceiveCB_t)CBFunc;
+        pRxXfer->ReceivePacketCB_handle = CBObj;
+        break;
+
+    case HAL_INT_REQUEST_FOR_BUFFER:       
+        pRxXfer->RequestForBufferCB = (requestForBufferCB_t)CBFunc;
+        pRxXfer->RequestForBufferCB_handle = CBObj;
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pRxXfer->hReport, HAL_RX_MODULE_LOG, ("rxXfer_Register_CB - Illegal value\n"));
+        return;
+    }
+}
+
+
+/****************************************************************************
+ *                      rxXfer_SetDoubleBufferAddr()
+ ****************************************************************************
+ * DESCRIPTION: Store the addresses of the Double Buffer 
+ * 
+ * INPUTS:      hRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void rxXfer_SetDoubleBufferAddr (TI_HANDLE hRxXfer, ACXDataPathParamsResp_t *pDataPathParams)
+{
+    RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
+
+    pRxXfer->doubleBuffer[0] = pDataPathParams->rxPacketRingAddr;
+    pRxXfer->doubleBuffer[1] = pDataPathParams->rxPacketRingAddr + pDataPathParams->rxPacketRingChunkSize;
+} 
+
+
+/****************************************************************************
+ *                      rxXfer_RxEvent()
+ ****************************************************************************
+ * DESCRIPTION: Called upon Rx event from the FW.calls the SM  
+ * 
+ * INPUTS:      hRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF_OK in case of Synch mode, or TNETWIF_PENDING in case of Asynch mode
+ *          (when returning TNETWIF_PENDING, FwEvent module expects the FwEvent_EventComplete()
+ *          function call to finish the Rx Client handling 
+ *
+ ****************************************************************************/
+TI_STATUS rxXfer_RxEvent (TI_HANDLE hRxXfer)
+{
+    RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
+
+    if (RX_XFER_STATE_IDLE != pRxXfer->state)
+    {
+        WLAN_REPORT_ERROR(pRxXfer->hReport,HAL_RX_MODULE_LOG,
+            ("rxXfer_RxEvent called in state %d !!!\n",pRxXfer->state));
+        return TNETWIF_ERROR;
+    }
+
+    WLAN_REPORT_INFORMATION (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+        ("rxXfer_RxEvent Calling rxXfer_StateMachine : currBuffer = %d \n",
+        pRxXfer->currBuffer));
+
+  #ifdef TI_DBG
+    if (pRxXfer->currBuffer == 0)     
+        pRxXfer->DbgStats.numIrq0 ++;
+    else
+        pRxXfer->DbgStats.numIrq1 ++;
+  #endif
+
+    /* Assume that we are in synch bus until otherwise is proven */
+    pRxXfer->bSync = TRUE;
+    /* The packet status is OK unless we receive error */
+    pRxXfer->packetStatus = OK;
+
+    rxXfer_StateMachine (hRxXfer, 0, OK);
+    
+    return pRxXfer->returnValue;
+}
+
+
+/****************************************************************************
+ *                      rxXfer_StateMachine()
+ ****************************************************************************
+ * DESCRIPTION: SM for handling Synch & Asynch read of RX from the HW.
+ *              The flow of the SM is by that order:
+ *              IDLE -> READING_HDR -> READING_PKT -> EXIT
+ *              On synch mode - each state is called in the same context in the while loop.
+ *              On Asynch mode - each state returns TNETWIF_PENDING and exits the SM.The CB of
+ *              each Asynch is the SM, that will continue the Rx handling.
+ *
+ * INPUTS:      hRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:      pRxXfer->returnValue is TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+static void rxXfer_StateMachine (TI_HANDLE hRxXfer, UINT8 module_id, TI_STATUS status)
+{
+    RxXfer_t* pRxXfer = (RxXfer_t *)hRxXfer;
+
+    pRxXfer->returnValue = OK;
+    
+    /*
+     * This while loop will continue till the exit or when waiting for the CB due to
+     * memory transfer operation pending for DMA to complete   
+     */
+    while (TNETWIF_PENDING != pRxXfer->returnValue)
+    {
+        WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("Rx SM: state = %d, rc = %d\n",
+            pRxXfer->state, pRxXfer->returnValue));
+    
+        switch(pRxXfer->state) 
+        {
+        case RX_XFER_STATE_IDLE:
+            pRxXfer->state = RX_XFER_STATE_READING_HDR;
+            pRxXfer->returnValue = rxXfer_ReadHeader (pRxXfer);
+            break;
+
+        case RX_XFER_STATE_READING_HDR:
+            pRxXfer->state = RX_XFER_STATE_READING_PKT;
+            pRxXfer->returnValue = rxXfer_ReadBody (pRxXfer);
+            break;
+
+        case RX_XFER_STATE_READING_PKT:
+            pRxXfer->state = RX_XFER_STATE_EXITING;
+            rxXfer_ForwardCB(pRxXfer);
+            pRxXfer->returnValue = rxXfer_AckRx (pRxXfer);
+            break;
+
+        case RX_XFER_STATE_EXITING:
+            pRxXfer->state = RX_XFER_STATE_IDLE;
+            if (FALSE == pRxXfer->bSync)
+            {   
+                /* Async bus - call FwEvent for notifying the completion */
+                FwEvent_EventComplete (pRxXfer->hFwEvent, TNETWIF_OK);
+            }
+            else    
+            {
+                /* This is the sync case - we should return TNETWIF_OK */
+                pRxXfer->returnValue = TNETWIF_OK;
+            }
+
+            return;
+
+        default:
+            WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+                               ("rxXfer_StateMachine Unknown state = %d\n",
+                               pRxXfer->state));
+        }
+
+        if (TNETWIF_ERROR == pRxXfer->returnValue)
+        {   
+            WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+                ("rxXfer_StateMachine returning TNETWIF_ERROR in state %d. Next packet will be discarded!!!\n",pRxXfer->state));
+
+            /* Next packet will be marked as NOK and will be discarded */
+            pRxXfer->packetStatus = NOK;
+        }
+    }
+
+    /* If we are here - we got TNETWIF_PENDING, so we are in Async mode */
+    pRxXfer->bSync = FALSE;
+}
+
+
+/****************************************************************************
+ *                      rxXfer_ReadHeader()
+ ****************************************************************************
+ * DESCRIPTION: Read the packet header (descriptor)
+ *
+ * INPUTS:      pRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:      
+ * 
+ * RETURNS:     TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
+ ****************************************************************************/
+TI_STATUS rxXfer_ReadHeader(RxXfer_t *pRxXfer)
+{
+    WLAN_REPORT_DEBUG_RX(pRxXfer->hReport, 
+                        ("rxXfer_readHeader: Before Read Memory Addr from DB No %d Addr %x !!!! \n",pRxXfer->currBuffer,pRxXfer->doubleBuffer[pRxXfer->currBuffer]));
+
+    return TNETWIF_ReadMemOpt (pRxXfer->hTNETWIF, 
+                               pRxXfer->doubleBuffer[pRxXfer->currBuffer], 
+                               PADREAD (&pRxXfer->rxDescriptor),
+                               RX_DESCRIPTOR_SIZE,
+                               FW_EVENT_MODULE_ID,
+                               rxXfer_StateMachine,
+                               (TI_HANDLE)pRxXfer);
+}
+
+
+/****************************************************************************
+ *                      rxXfer_ReadBody()
+ ****************************************************************************
+ * DESCRIPTION: Read the packet body
+ *
+ * INPUTS:      pRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:      
+ * 
+ * RETURNS:     TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
+ ****************************************************************************/
+TI_STATUS rxXfer_ReadBody (RxXfer_t *pRxXfer)
+{
+    UINT32  uCurrPacketId;             /* Current packet ID */
+    UINT32  uLastPacketIdIncremented;  /* The last received packet-ID incremented with modulo */
+    UINT32  uAlignToWord;              /* Used to align the length of the packet to a WORD */ 
+
+       /* Check for correct length of Rx Descriptor */
+    if (pRxXfer->rxDescriptor.length <= PLCP_HEADER_LENGTH || 
+        pRxXfer->rxDescriptor.length > (MAX_DATA_BODY_LENGTH + PLCP_HEADER_LENGTH))
+    {
+        WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+             ("rxXfer_ReadBody: RxLength not correct! rxDescriptor.length=%d\n",         
+             pRxXfer->rxDescriptor.length));
+        return TNETWIF_ERROR;
+    }
+
+    pRxXfer->rxDescriptor.length = pRxXfer->rxDescriptor.length - PLCP_HEADER_LENGTH;
+
+    uCurrPacketId = (pRxXfer->rxDescriptor.flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT;
+
+    uLastPacketIdIncremented = (pRxXfer->lastPacketId + 1) % (RX_MAX_PACKET_ID + 1);
+
+    if (uCurrPacketId == uLastPacketIdIncremented)
+    {
+        pRxXfer->lastPacketId = uLastPacketIdIncremented;
+
+#ifdef GWSI_RECORDING
+        WLAN_REPORT_GWSI_RECORDING(pRxXfer->hReport, ("GWSI Recording, rxXfer_ReadBody (request for buffer), Length = 0x%x\n", pRxXfer->rxDescriptor.length));
+#endif /* GWSI_RECORDING */
+    }
+    else
+    {
+       WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+            ("rxXfer_ReadBody: Packet ID mismatch! CurrPacketId=%d, lastPacketId=%d\n",         
+            uCurrPacketId, pRxXfer->lastPacketId));
+#ifdef TI_DBG
+        pRxXfer->DbgStats.numPacketsDroppedPacketIDMismatch++;
+        rxXfer_PrintStats ((TI_HANDLE)pRxXfer);
+#endif
+        /* Reset the lastPacketId to be synchronized on the Current Packet ID read from the FW */
+        pRxXfer->lastPacketId = uCurrPacketId;
+    }
+
+    /*
+     * Add uAlignToWord to the body length since we have to read buffers from the FW in 4 bytes chunks.
+     * NOTE: The size of the buffer is aligned to 4, but the packet itself is not.
+     * Releasing the memory must be done with the actual size allocated and not the size of the packet 
+     */
+    uAlignToWord = 4 - (pRxXfer->rxDescriptor.length & 0x3); /* (&0x3) is equal to (% 4) */
+    uAlignToWord = (uAlignToWord == 4) ? 0 : uAlignToWord;
+
+    /* 
+     * Requesting buffer from the upper layer memory manager. 
+     * Add the align to word and offset for the access to the bus 
+        * Also send the encryption status of the packet. It is used only for GWSI alignment.
+     */
+    pRxXfer->pPacketBuffer = (void *)pRxXfer->RequestForBufferCB (
+        pRxXfer->RequestForBufferCB_handle,
+        pRxXfer->rxDescriptor.length + uAlignToWord + TNETWIF_READ_OFFSET_BYTES,
+               ((pRxXfer->rxDescriptor.flags & RX_DESC_ENCRYPTION_MASK) >> RX_DESC_FLAGS_ENCRYPTION));
+
+    if (pRxXfer->pPacketBuffer != NULL)
+    {
+        WLAN_REPORT_DEBUG_RX (pRxXfer->hReport,
+            (" rxXfer_ReadBody() : packetLength %d uAligntoWord = %d\n",
+                         pRxXfer->rxDescriptor.length, uAlignToWord));
+
+#ifdef TI_DBG
+        pRxXfer->DbgStats.numPacketsRead++;
+        pRxXfer->DbgStats.numBytesRead += pRxXfer->rxDescriptor.length;
+#endif
+
+        /* Read the packet and return TNETWIF_OK or TNETWIF_PENDING */
+        return TNETWIF_ReadMemOpt (pRxXfer->hTNETWIF,
+                                   pRxXfer->doubleBuffer[pRxXfer->currBuffer] + RX_DESCRIPTOR_SIZE + 20,
+                                   (UINT8 *)pRxXfer->pPacketBuffer,
+                                   (UINT32)pRxXfer->rxDescriptor.length + uAlignToWord,
+                                   FW_EVENT_MODULE_ID,
+                                   rxXfer_StateMachine,
+                                   (TI_HANDLE)pRxXfer);
+    
+    }
+    /* If no buffer could be allocated */
+    else   
+    {
+        WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+            ("rxXfer_RecvOnePacket:  pRxXfer->rxDescriptor %x NULL !!!! \n",pRxXfer->pPacketBuffer));
+
+#ifdef TI_DBG
+        pRxXfer->DbgStats.numPacketsDroppedNoMem++;
+#endif
+    }
+    
+    return TNETWIF_ERROR;
+}
+
+
+/****************************************************************************
+ *                      rxXfer_ForwardCB()
+ ****************************************************************************
+ * DESCRIPTION: Parse the Packet with the descriptor and forward the results and
+ *              the packet to the registered CB
+ *
+ * INPUTS:      pRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:      
+ * 
+ * RETURNS:     
+ ****************************************************************************/
+void rxXfer_ForwardCB (RxXfer_t *pRxXfer)
+{
+    UINT32            aFlags = 0;
+    rate_e            eRate = DRV_RATE_AUTO;
+    rxXfer_Reserved_t Reserved;
+    RxIfDescriptor_t *pRxParams = &pRxXfer->rxDescriptor;
+
+    WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("rxXfer_ForwardCB ENTERING\n"));
+   
+    eRate = ConvertHwRateToDrvRate(pRxParams->rate, (BOOL)(OFDM_RATE_BIT & pRxParams->modPre));
+
+    WLAN_REPORT_DEBUG_RX (pRxXfer->hReport,
+        (" rxXfer_ForwardCB() HwRate = %d, modPre = %d eRate = %d:\n",pRxParams->rate,pRxParams->modPre,eRate));
+
+    if ( eRate == DRV_RATE_AUTO)
+    {
+        WLAN_REPORT_ERROR (pRxXfer->hReport, HAL_RX_MODULE_LOG,
+            ("rxXfer_ForwardCB:  Received wrong rate from Hw = 0x%x, modPre = 0x%x\n",
+            pRxParams->rate,pRxParams->modPre));
+    }
+    
+    Reserved.packetType = (rxPacketType_e)pRxParams->type;
+    Reserved.rssi       = pRxParams->rssi;
+    Reserved.SNR        = pRxParams->snr;
+    Reserved.band       = pRxParams->band;
+    Reserved.TimeStamp  = pRxParams->timestamp;
+
+    if (pRxXfer->packetStatus == OK)
+    {
+        /* Get the mac header from the TNETWIF_READ_OFFSET_BYTES in the packet Buffer */
+        dot11_header_t *pMacHdr = (dot11_header_t *)((UINT8*)pRxXfer->pPacketBuffer + TNETWIF_READ_OFFSET_BYTES);
+      #ifdef GWSI_RECORDING
+        static  char TempString[(1600 * 2) + 1];
+      #endif /* GWSI_RECORDING */
+
+        /* Handle endian for the frame control fields */
+        pMacHdr->fc       = ENDIAN_HANDLE_WORD(pMacHdr->fc);
+        pMacHdr->duration = ENDIAN_HANDLE_WORD(pMacHdr->duration);
+        pMacHdr->seqCtrl  = ENDIAN_HANDLE_WORD(pMacHdr->seqCtrl);
+
+        rxXfer_ConvertDescFlagsToAppFlags (pRxParams->flags, &aFlags, &pRxXfer->packetStatus);
+
+      #ifdef GWSI_RECORDING
+        convert_hex_to_string ((UINT8*)pRxXfer->pPacketBuffer + TNETWIF_READ_OFFSET_BYTES, TempString, pRxParams->length);
+
+        WLAN_REPORT_GWSI_RECORDING (pRxXfer->hReport, 
+                                    ("GWSI Recording, rxXfer_RecvPacketCB, aStatus = 0x%x, aRate = 0x%x, aRCPI = 0x%x, aFlags = 0x%x\n", 
+                                    pRxXfer->packetStatus, aRate, pRxParams->rcpi, aFlags));
+        WLAN_REPORT_GWSI_RECORDING (pRxXfer->hReport, 
+                                    ("GWSI Recording, rxXfer_RecvPacketCB, aLength = 0x%x, aFrame = %s\n", 
+                                    pRxParams->length, TempString));    
+      #endif /* GWSI_RECORDING */
+    }
+
+    /* Set the packet to upper layer. packet is starting after TNETWIF_READ_OFFSET_BYTES bytes */
+    pRxXfer->ReceivePacketCB (pRxXfer->ReceivePacketCB_handle,
+                              pRxXfer->packetStatus,
+                              (const void*)pRxXfer->pPacketBuffer,
+                              pRxParams->length,
+                              (UINT32)eRate,
+                              pRxParams->rcpi,
+                              pRxParams->chanNum,
+                              (void *)&Reserved,
+                              aFlags);
+}
+
+
+/****************************************************************************
+ *                      rxXfer_AckRx()
+ ****************************************************************************
+ * DESCRIPTION: Set Ack to the FW that the buffer was read
+ *
+ * INPUTS:      pRxXfer       - RxXfer handle;
+ * 
+ * OUTPUT:      
+ * 
+ * RETURNS:     TNETWIF_OK in synch mode and TNETWIF_PENDING in Asynch mode.
+ ****************************************************************************/
+TI_STATUS rxXfer_AckRx (RxXfer_t *pRxXfer)
+{
+    TI_STATUS status;
+
+    /* Ack on the opposite buffer since we changed it in rxXfer_ForwardCB() */
+    if (pRxXfer->currBuffer == 0)
+    {
+        WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("Ack on Rx 0\n"));
+      
+      #ifdef TI_DBG
+        pRxXfer->DbgStats.numAck0 ++;
+      #endif
+
+        status = TNETWIF_WriteRegOpt (pRxXfer->hTNETWIF, 
+                                      ACX_REG_INTERRUPT_TRIG, 
+                                      INTR_TRIG_RX_PROC0,
+                                      FW_EVENT_MODULE_ID,
+                                      rxXfer_StateMachine,
+                                      (TI_HANDLE)pRxXfer);
+    }
+    else 
+    {
+        WLAN_REPORT_DEBUG_RX (pRxXfer->hReport, ("Ack on Rx 1\n"));
+
+      #ifdef TI_DBG
+        pRxXfer->DbgStats.numAck1 ++;
+      #endif
+
+        status = TNETWIF_WriteRegOpt (pRxXfer->hTNETWIF, 
+                                      ACX_REG_INTERRUPT_TRIG_H, 
+                                      INTR_TRIG_RX_PROC1,
+                                      FW_EVENT_MODULE_ID,
+                                      rxXfer_StateMachine,
+                                      (TI_HANDLE)pRxXfer);
+    }
+
+    /* Calculate the next buffer to read from (0 or 1) */
+    pRxXfer->currBuffer = 1 - pRxXfer->currBuffer;
+
+    return status;
+}
+
+
+/****************************************************************************
+ *                      rxXfer_ConvertDescFlagsToAppFlags()
+ ****************************************************************************
+ * DESCRIPTION: Add some spacing before capital letters and you'll figure it out ...
+ *
+ * INPUTS:      descRxFlags   - Bits as received from Fw
+ * 
+ * OUTPUT:      aFlags        - converted bits to our definition    
+ *              pPacketStatus - changed status if an error was indicated
+ * RETURNS:     
+ ****************************************************************************/
+static void  rxXfer_ConvertDescFlagsToAppFlags (UINT16 descRxFlags, UINT32 *aFlags, TI_STATUS *pPacketStatus)
+{
+    UINT32 flags = 0;
+
+    if (descRxFlags & RX_DESC_MATCH_RXADDR1)
+    {
+        flags |= RX_PACKET_FLAGS_MATCH_RXADDR1;
+    }
+
+    if (descRxFlags & RX_DESC_MCAST)
+    {
+        flags |= RX_PACKET_FLAGS_GROUP_ADDR;
+    }
+
+    if (descRxFlags & RX_DESC_STAINTIM)
+    {
+        flags |= RX_PACKET_FLAGS_STAINTIM;
+    }
+
+    if (descRxFlags & RX_DESC_VIRTUAL_BM)
+    {
+        flags |= RX_PACKET_FLAGS_VIRTUAL_BM;
+    }
+
+    if (descRxFlags & RX_DESC_BCAST)
+    {
+        flags |= RX_PACKET_FLAGS_BCAST;
+    }
+
+    if (descRxFlags & RX_DESC_MATCH_SSID)
+    {
+        flags |= RX_PACKET_FLAGS_MATCH_SSID;
+    }
+
+    if (descRxFlags & RX_DESC_MATCH_BSSID)
+    {
+        flags |= RX_PACKET_FLAGS_MATCH_BSSID;
+    }
+
+    flags |= (descRxFlags & RX_DESC_ENCRYPTION_MASK) << RX_PACKET_FLAGS_ENCRYPTION_SHIFT_FROM_DESC;
+
+    if (descRxFlags & RX_DESC_MEASURMENT)
+    {
+        flags |= RX_PACKET_FLAGS_MEASURMENT;
+    }
+
+    if (descRxFlags & RX_DESC_MIC_FAIL)
+    {
+        *pPacketStatus = RX_MIC_FAILURE_ERROR;
+    }
+
+    if (descRxFlags & RX_DESC_DECRYPT_FAIL)
+    {
+        *pPacketStatus = RX_DECRYPT_FAILURE;
+    }
+
+    *aFlags = flags;
+}
+
+#ifdef TI_DBG
+/****************************************************************************
+ *                      rxXfer_ClearStats()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *
+ * INPUTS:  
+ *          pRxXfer The object
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK. 
+ ****************************************************************************/
+void rxXfer_ClearStats (TI_HANDLE hRxXfer)
+{
+    RxXfer_t * pRxXfer = (RxXfer_t *)hRxXfer;
+
+    os_memoryZero (pRxXfer->hOs, &pRxXfer->DbgStats, sizeof(RxXferStats_T));
+}
+
+
+/****************************************************************************
+ *                      rxXfer_PrintStats()
+ ****************************************************************************
+ * DESCRIPTION: .
+ *
+ * INPUTS:  
+ *          pRxXfer The object
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK. 
+ ****************************************************************************/
+void rxXfer_PrintStats (TI_HANDLE hRxXfer)
+{
+    RxXfer_t * pRxXfer = (RxXfer_t *)hRxXfer;
+    
+    WLAN_OS_REPORT(("Number of packets read: %d, number of bytes read:%d\n",
+                    pRxXfer->DbgStats.numPacketsRead, pRxXfer->DbgStats.numBytesRead));
+    WLAN_OS_REPORT(("Number of frames dropped due to no memory:%d, Number of frames dropped due to packet ID mismatch:%d\n",
+                    pRxXfer->DbgStats.numPacketsDroppedNoMem, pRxXfer->DbgStats.numPacketsDroppedPacketIDMismatch));
+    WLAN_OS_REPORT(("Number of irq0:%u, ack0:%d\n",
+                    pRxXfer->DbgStats.numIrq0, pRxXfer->DbgStats.numAck0));
+    WLAN_OS_REPORT(("Number of irq1:%u, ack1:%d\n",
+                    pRxXfer->DbgStats.numIrq1, pRxXfer->DbgStats.numAck1));
+}
+#endif
+
+/****************************************************************************
+ *                      RxXfer_ReStart()
+ ****************************************************************************
+ * DESCRIPTION:        RxXfer_ReStart the RxXfer module object (called by the recovery)
+ * 
+ * INPUTS:     hRxXfer - The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    NONE 
+ ****************************************************************************/
+
+VOID RxXfer_ReStart(TI_HANDLE hRxXfer)
+{
+       RxXfer_t * pRxXfer = (RxXfer_t *)hRxXfer;
+
+       pRxXfer->state          = RX_XFER_STATE_IDLE;
+       pRxXfer->currBuffer     = 0;        /* first buffer to read from */
+       pRxXfer->lastPacketId   = 0;
+       
+} /* RxXfer_ReStart() */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.h
new file mode 100644 (file)
index 0000000..66b6309
--- /dev/null
@@ -0,0 +1,109 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  rxXfer.h
+ *
+ *   PURPOSE: Rx Xfer module header file.
+ * 
+ ****************************************************************************/
+
+#ifndef _RX_XFER_H
+#define _RX_XFER_H
+
+#include "rxXfer_api.h"
+#include "whalBus_Defs.h"
+#include "TNETWIF.h"
+#include "public_descriptors.h"
+
+#define RX_DESCRIPTOR_SIZE (sizeof(RxIfDescriptor_t))
+
+typedef struct 
+{
+    UINT32      numPacketsRead;
+    UINT32      numBytesRead;
+    UINT32      numPacketsDroppedNoMem;
+    UINT32      numPacketsDroppedPacketIDMismatch;
+    UINT32      numIrq0;
+    UINT32      numIrq1;
+    UINT32      numAck0;
+    UINT32      numAck1;
+} RxXferStats_T;
+
+typedef enum
+{
+    RX_XFER_STATE_IDLE,
+    RX_XFER_STATE_READING_HDR,
+    RX_XFER_STATE_READING_PKT,
+    RX_XFER_STATE_EXITING       /* Sending Ack to the FW at the end of the packet read */
+} RxXferState_e;
+
+typedef struct 
+{
+    TI_HANDLE               hOs;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hTNETWIF;
+    TI_HANDLE               hFwEvent;
+    TI_HANDLE               hMemMgr;
+
+    RxXferState_e           state;
+    TI_STATUS               returnValue;
+
+    /* address of the 2 buffers in the Double Buffer */
+    UINT32                  doubleBuffer[2];
+    UINT32                  currBuffer; 
+    UINT32                  lastPacketId;
+    UINT32                  rxPathStatus;
+
+    /* use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (RxIfDescriptor_t rxDescriptor)
+           
+    void                    *pPacketBuffer;
+    packetReceiveCB_t       ReceivePacketCB;
+    TI_HANDLE               ReceivePacketCB_handle;
+    requestForBufferCB_t    RequestForBufferCB;
+    TI_HANDLE               RequestForBufferCB_handle;  
+    BOOL                    bSync;                        /* indicate if we are in Synch bus or not */
+    TI_STATUS               packetStatus;                 /* OK unless an error occurred ... */
+
+#ifdef TI_DBG
+    RxXferStats_T           DbgStats;
+#endif /* TI_DBG */
+
+} RxXfer_t;
+
+
+#endif /* _RX_XFER_H */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Result/txResult.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Result/txResult.c
new file mode 100644 (file)
index 0000000..79cfab4
--- /dev/null
@@ -0,0 +1,569 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txResult.c
+ *   
+ *   PURPOSE:  Handle packets Tx results upon Tx-complete from the FW. 
+ * 
+ *   DESCRIPTION:  
+ *   ============
+ *      This module is called upon Tx-complete from FW. 
+ *      It retrieves the transmitted packets results from the FW TxResult table and
+ *        calls the upper layer callback function for each packet with its results.
+ *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "whalCommon.h"
+#include "TNETWIF.h"
+#include "whalHwDefs.h"
+#include "txResult_api.h"
+#include "TNETW_Driver_types.h"
+#include "FwEvent_api.h"
+#include "txResult.h"  /* Local definitions */
+/****************** static function decleration *****************************************/
+static void txResult_handleNewEntries(txResultObj_t *pTxResult);
+static void txResult_StateMachine(TI_HANDLE hTxResult,UINT8 module_id ,TI_STATUS status);
+static TI_STATUS txResult_writeNewEntries(txResultObj_t *pTxResult,UINT8 currBuffer);
+
+
+/****************************************************************************
+ *                      txResult_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the Tx-Result object 
+ * 
+ * INPUTS:  hOs
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+TI_HANDLE txResult_Create(TI_HANDLE hOs)
+{
+    txResultObj_t *pTxResult;
+
+    pTxResult = os_memoryAlloc(hOs, sizeof(txResultObj_t));
+    if (pTxResult == NULL)
+        return NULL;
+
+    os_memoryZero(hOs, pTxResult, sizeof(txResultObj_t));
+
+    pTxResult->hOs = hOs;
+
+    return( (TI_HANDLE)pTxResult );
+}
+
+
+/****************************************************************************
+ *                      txResult_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the Tx-Result object 
+ * 
+ * INPUTS:  hTxResult - The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS txResult_Destroy(TI_HANDLE hTxResult)
+{
+    txResultObj_t *pTxResult = (txResultObj_t *)hTxResult;
+
+    if (pTxResult)
+        os_memoryFree(pTxResult->hOs, pTxResult, sizeof(txResultObj_t));
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *               txResult_init()
+ ****************************************************************************
+   DESCRIPTION:  
+   ============
+     Initialize the txResult module.
+ ****************************************************************************/
+TI_STATUS txResult_init(TI_HANDLE hTxResult, TI_HANDLE hReport, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent)
+{
+    txResultObj_t *pTxResult = (txResultObj_t *)hTxResult;
+
+    pTxResult->hReport = hReport;
+    pTxResult->hTNETWIF = hTNETWIF;
+    pTxResult->hFwEvent = hFwEvent;
+
+    txResult_restart(pTxResult);
+
+#ifdef TI_DBG
+    os_memoryZero( pTxResult->hOs, &(pTxResult->txCompleteDepthHistogram), sizeof(UINT32) * FW_TX_CMPLT_BLOCK_SIZE );
+#endif
+
+    FwEvent_Enable(pTxResult->hFwEvent, ACX_INTR_TX_RESULT);
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *               txResult_restart()
+ ****************************************************************************
+   DESCRIPTION:  
+   ============
+     Restarts the Tx-Result module.
+     Should be called upon init and recovery!!
+     Shouldn't be called upon disconnect, since the FW provides Tx-Complete
+       for all pending packets in FW!!
+ ****************************************************************************/
+TI_STATUS txResult_restart(TI_HANDLE hTxResult)
+{
+    txResultObj_t *pTxResult = (txResultObj_t *)hTxResult;
+
+    pTxResult->TxCmpltStartPointIterator = 0;
+    
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      txResult_setHwInfo()
+ ****************************************************************************
+ * DESCRIPTION:  
+ *      Called after the HW configuration upon init or recovery.
+ *      Store the Tx-result table HW address.
+ *          
+ * INPUTS:  
+ *      hTxXfer             The object
+ *      pDataPathParams     Pointer to the HW Addresses
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None 
+ ****************************************************************************/
+void  txResult_setHwInfo(TI_HANDLE hTxResult, ACXDataPathParamsResp_t *pDataPathParams)
+{
+    txResultObj_t *pTxResult = (txResultObj_t *)hTxResult;
+
+    pTxResult->txResultTableAddr = pDataPathParams->txCompleteAddr;
+
+    /* Print of the Tx Result Table address */
+    WLAN_REPORT_INFORMATION(pTxResult->hReport, TX_RESULT_MODULE_LOG, 
+         ("Get Tx-Result-Table HW-Addr:  0x%x\n", pTxResult->txResultTableAddr));
+} 
+
+
+/****************************************************************************
+ *                      txResult_TxCmpltIntrCB()
+ ****************************************************************************
+ * DESCRIPTION:   
+ * ============
+ *  Called upon Tx-complete interrupt from the FW.
+ * 
+ * INPUTS:  TI_HANDLE  hTxResult - the txResult object handle.
+ *  
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF_OK in Synch mode or TNETWIF_PENDING on Asynch mode.                     
+ ***************************************************************************/
+
+#if FW_TX_CMPLT_BLOCK_SIZE & (FW_TX_CMPLT_BLOCK_SIZE - 1)
+  #error "FW_TX_CMPLT_BLOCK_SIZE must be power of 2"
+#endif
+
+TI_STATUS txResult_TxCmpltIntrCB (TI_HANDLE hTxResult)
+{
+    txResultObj_t *pTxResult = (txResultObj_t *)hTxResult;
+
+    if (TX_RESULT_STATE_IDLE != pTxResult->state)
+    {
+        WLAN_REPORT_ERROR(pTxResult->hReport,TX_RESULT_MODULE_LOG,
+            ("rxXfer_RxEvent called in state %d !!!\n",pTxResult->state));
+        return TNETWIF_ERROR;
+    }
+    
+    /* assume that we are in synch bus until otherwise is proven */
+    pTxResult->bSync = TRUE;
+
+    /*                              0,OK has no meaning */
+    txResult_StateMachine(hTxResult,0,OK);
+    
+    return pTxResult->returnValue;
+}
+
+
+/****************************************************************************
+ *                      txResult_StateMachine()
+ ****************************************************************************
+ * DESCRIPTION:     main SM of the module.called in IDLE state by txResult_TxCmpltIntrCB() on 
+ *                  Tx Complete interrupt from the FW.
+ *                  Reads all Tx-Result cyclic table from the FW.
+ *                  Goes over the valid entries (containing unread Tx-results) and calls the 
+ *                  upper layer callback function for each packet with its results.
+ *                  At the end - writes all new results back to the FW
+ *                  The flow of the SM is by that order:
+ *                  IDLE -> READING -> WRITING1 -> WRITING2 -> EXIT
+ *                  On synch mode - each state is called in the same context in the while loop.
+ *                  On Asynch mode - each state returns TNETWIF_PENDING and exits the SM.The CB of
+ *                  each Asynch is the SM, that will continue the handling.
+ *
+ *  
+ *          
+ * INPUTS:  module_id   - not used (for prototype only).
+ *          status      - not used (for prototype only).
+ *
+ * OUTPUT:  returnValue     - This parameter is used to indicate the FwEvent mosule about the status of
+ *                              the client.if (returnValue == TNETWIF_OK) than client finished working (synch mode)
+ *                              if (returnValue == TNETWIF_PENDING) than FwEvent module is waiting to be notified
+ *                              that client finished the handling (Asynch mode)
+ * 
+ * RETURNS: None 
+ ****************************************************************************/
+static void txResult_StateMachine(TI_HANDLE hTxResult,UINT8 module_id ,TI_STATUS status)
+{
+    txResultObj_t *pTxResult = (txResultObj_t *)hTxResult;
+
+    pTxResult->returnValue = OK;
+     /* this while loop will continue till the exit or when waiting for the CB due to
+        memory transfer operation pending for DMA to complete   */
+    while (TNETWIF_PENDING != pTxResult->returnValue)
+    {
+        WLAN_REPORT_INFORMATION(pTxResult->hReport,TX_RESULT_MODULE_LOG,
+            ("txResult SM: state = %d, rc = %d, Buffers = %d\n",
+            pTxResult->state,pTxResult->returnValue,pTxResult->numOfBuffers));
+
+        switch(pTxResult->state) 
+        {
+        case TX_RESULT_STATE_IDLE:
+             /* Read all Tx-Result table from the FW (Synch or Asynch) */
+            pTxResult->returnValue = TNETWIF_ReadMemOpt (pTxResult->hTNETWIF, 
+                                                         pTxResult->txResultTableAddr, 
+                                                         PADREAD (pTxResult->TxCmpltAttr), 
+                                                         FW_TX_CMPLT_BLOCK_SIZE * sizeof(TxResultDescriptor_t),
+                                                         FW_EVENT_MODULE_ID,
+                                                         txResult_StateMachine,hTxResult);
+
+            pTxResult->state = TX_RESULT_STATE_READING;
+            break;
+
+        case TX_RESULT_STATE_READING:
+            /* process the new table and call the upper layers to handle results. 
+               Also update numOfBuffers & entry (from, to) */
+            txResult_handleNewEntries(pTxResult);
+
+            if (TX_RESULT_NO_BUFFER == pTxResult->numOfBuffers) 
+            {   /* no need to write to FW - exit SM */
+                pTxResult->state = TX_RESULT_STATE_EXIT;
+            }
+            else
+            {   
+                pTxResult->state = TX_RESULT_STATE_WRITING1;
+            }
+            break;
+        case TX_RESULT_STATE_WRITING1:
+
+            pTxResult->returnValue = txResult_writeNewEntries(pTxResult,0);
+            if (TX_RESULT_ONE_BUFFER == pTxResult->numOfBuffers) 
+            {   /* only one write was needed - exit SM */
+                pTxResult->state = TX_RESULT_STATE_EXIT;
+            }
+            else
+            {
+                pTxResult->state = TX_RESULT_STATE_WRITING2;
+            }
+            break;
+
+        case TX_RESULT_STATE_WRITING2:
+
+            pTxResult->returnValue = txResult_writeNewEntries(pTxResult,1);
+
+            pTxResult->state = TX_RESULT_STATE_EXIT;
+            break;
+
+        case TX_RESULT_STATE_EXIT:
+
+            if (FALSE == pTxResult->bSync)
+            {   /* Async bus - call FwEvent for notifying the completion */
+                FwEvent_EventComplete(pTxResult->hFwEvent, TNETWIF_OK);
+            }
+            else    /* This is the synch case - we should return TNETWIF_OK */
+            {
+                pTxResult->returnValue = TNETWIF_OK;
+            }
+            pTxResult->state = TX_RESULT_STATE_IDLE;
+
+            return;
+
+        default:
+            WLAN_REPORT_ERROR(pTxResult->hReport,HAL_TX_MODULE_LOG,("rxXfer_StateMachine Unknown state = %d\n",
+                pTxResult->state));
+        }
+    }
+
+    /* if we are here - we got TNETWIF_PENDING, so we are in Async mode */
+    pTxResult->bSync = FALSE;
+
+    if (TNETWIF_ERROR == pTxResult->returnValue)
+    {   
+        WLAN_REPORT_ERROR(pTxResult->hReport,TX_RESULT_MODULE_LOG,
+            ("txResult_StateMachine returning TNETWIF_ERROR in state %d !!!\n",pTxResult->state));
+    }
+}
+
+
+/****************************************************************************
+ *                      txResult_handleNewEntries()
+ ****************************************************************************
+ * DESCRIPTION:   
+ * ============
+ *      Goes over the valid entries (containing unread Tx-results) and calls the 
+ *      upper layer callback function for each packet with its results.
+ *
+ * INPUTS:  TI_HANDLE  hTxResult - the txResult object handle.
+ *  
+ * OUTPUT:  1) number of buffers to write on .  (The case of 2 buffers can happen
+ *          in case of wrap around - and we need 2 different writes to FW)
+ *
+ *          2) start-end address of the buffers to be written
+ * 
+ * RETURNS: 
+ ***************************************************************************/
+static void txResult_handleNewEntries(txResultObj_t *pTxResult)
+{   
+    TxResultDescriptor_t *pCurrentEntry; /* Points to the current table entry */                       
+    UINT32 uIndex;                       /* The current table entry */
+    UINT32 uNumOfTxComplete;             /* Counts contiguous valid entries (i.e. waiting for host read) */
+    UINT32 uLoopCount;                   /* Used only to prevent endless loop */
+
+    uIndex = pTxResult->TxCmpltStartPointIterator;
+    uNumOfTxComplete = 0;
+
+    /* Begin the loop only from the point where the last Tx Complete was received before */
+    for (uLoopCount = uNumOfTxComplete = 0; uLoopCount < FW_TX_CMPLT_BLOCK_SIZE; uLoopCount ++)
+    {
+        /*
+         * Update current entry.
+         * Take into account that uIndex may be 16, so make & 0xf
+         */
+        pCurrentEntry = &pTxResult->TxCmpltAttr[uIndex & (FW_TX_CMPLT_BLOCK_SIZE - 1)];
+
+        WLAN_REPORT_INFORMATION(pTxResult->hReport, TX_RESULT_MODULE_LOG,  
+            ("Tx Result Entry %d: Done1/2=%d/%d, DescID=%d, Status=%d, Rate=%d, Duration=%d, Retries=%d, HandleTime=%d, SecurNum=%d\n", 
+            uIndex, pCurrentEntry->done1, pCurrentEntry->done2, pCurrentEntry->descID, pCurrentEntry->status, 
+            pCurrentEntry->actualRate, pCurrentEntry->mediumUsage, pCurrentEntry->ackFailures, 
+            pCurrentEntry->fwHandlingTime, pCurrentEntry->lsbSecuritySequenceNumber));
+
+        /* If the current entry contains fresh Tx-result information */
+        if (pCurrentEntry->done1 == 1 && pCurrentEntry->done2 == 1)
+        {
+            /* Call GWSI Tx-complete callback with current entry pointer. */
+            /* It is assumed that the entry is only accessed in this context and only for reading. */
+            pTxResult->sendPacketCompleteCB (pTxResult->sendPacketCompleteHandle, pCurrentEntry);
+            
+            /* Clear entry */
+            pCurrentEntry->done1 = 0;
+            pCurrentEntry->done2 = 0;
+
+            /* Increment the index to point to next entry (wrap around is handled below) */
+            if (uIndex >= FW_TX_CMPLT_BLOCK_SIZE) 
+                uIndex = 1;
+            else
+                uIndex ++;
+
+            uNumOfTxComplete ++;
+        }
+        else
+            break;
+    }
+
+#ifdef TI_DBG
+    /* Update the TX result depth histogram */
+    pTxResult->txCompleteDepthHistogram [uNumOfTxComplete] ++;
+#endif
+    
+    /* Copy the handled entries back to FW to clear them */
+    if (uNumOfTxComplete)
+    {
+        /* No wrap. Make only 1 write */
+        if (uIndex > pTxResult->TxCmpltStartPointIterator)
+        {
+            pTxResult->entry[0].from = pTxResult->TxCmpltStartPointIterator;
+            pTxResult->entry[0].to = uIndex;
+            pTxResult->numOfBuffers = TX_RESULT_ONE_BUFFER;
+        }
+        /* Wrap. Make 2 writes */
+        else if (uIndex < pTxResult->TxCmpltStartPointIterator)
+        {
+            pTxResult->entry[0].from = pTxResult->TxCmpltStartPointIterator;
+            pTxResult->entry[0].to = FW_TX_CMPLT_BLOCK_SIZE;
+            pTxResult->entry[1].from = 0; 
+            pTxResult->entry[1].to = uIndex; 
+            pTxResult->numOfBuffers = TX_RESULT_TWO_BUFFERS;
+        }
+        /* Wrap, all 16 descriptors are filled. Make 1 write from index 0 */
+        else
+        {        
+            pTxResult->entry[0].from = 0;
+            pTxResult->entry[0].to = FW_TX_CMPLT_BLOCK_SIZE;
+            pTxResult->numOfBuffers = TX_RESULT_ONE_BUFFER;
+        }
+
+    }
+    else /* no new entry - no need to write buffers */
+    {
+        pTxResult->numOfBuffers = TX_RESULT_NO_BUFFER;
+    }
+    /*
+     * Update start point iterator.
+     * Take into account that uIndex may be 16, so make & 0xf
+     */
+    pTxResult->TxCmpltStartPointIterator = uIndex & (FW_TX_CMPLT_BLOCK_SIZE - 1);
+}
+
+
+/****************************************************************************
+ *                      txResult_writeNewEntries()
+ ****************************************************************************
+ * DESCRIPTION:   
+ * ============
+ *              Clears the read entries in the FW. 
+ *              
+ *
+ * INPUTS:  pTxResult - the txResult object handle.
+ *          currBuffer - number of buffer to write on (0 or 1)
+ *  
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF_OK in case of Synch call, TNETWIF_PENDING in case of Asynch call
+ *
+ * NOTE: please note that we are running over the last WORD before the first entry
+ *          since we need to save this place for the bus handling
+ ***************************************************************************/
+static TI_STATUS txResult_writeNewEntries(txResultObj_t *pTxResult,UINT8 currBuffer)
+{
+    /* 
+     * Write to firmware - NOTE: that we are running over the last WORD before the first entry
+     * since we need to save this place for the bus handling
+     */
+    return TNETWIF_WriteMemOpt (pTxResult->hTNETWIF,
+                                pTxResult->txResultTableAddr + pTxResult->entry[currBuffer].from * sizeof(TxResultDescriptor_t),
+                                PADWRITE (&pTxResult->TxCmpltAttr[pTxResult->entry[currBuffer].from]),
+                                (pTxResult->entry[currBuffer].to - pTxResult->entry[currBuffer].from) * sizeof(TxResultDescriptor_t),
+                                FW_EVENT_MODULE_ID,
+                                txResult_StateMachine,
+                                (TI_HANDLE)pTxResult);
+
+}
+
+/****************************************************************************
+ *                      txResult_RegisterCB()
+ ****************************************************************************
+ * DESCRIPTION:  Register the upper driver Tx-Result callback functions.
+ ****************************************************************************/
+void txResult_RegisterCB(TI_HANDLE hTxResult, tiUINT32 CallBackID, void *CBFunc, TI_HANDLE CBObj)
+{
+    txResultObj_t* pTxResult = (txResultObj_t*)hTxResult;
+
+    switch(CallBackID)
+    {
+        /* Set Tx-Complete callback */
+        case TX_RESULT_SEND_PKT_COMPLETE:
+            pTxResult->sendPacketCompleteCB = (SendPacketCompleteCB_t)CBFunc;
+            pTxResult->sendPacketCompleteHandle = CBObj;
+            break;
+
+        default:
+            WLAN_REPORT_ERROR(pTxResult->hReport, TX_RESULT_MODULE_LOG, ("txResult_RegisterCB - Illegal value\n"));
+            return;
+    }
+}
+
+
+/****************************************************************************
+ *                      txResult_RegisterCB()
+ ****************************************************************************
+ * DESCRIPTION:  Prints TX result debig information.
+ ****************************************************************************/
+void txResult_printInfo(TI_HANDLE hTxResult)
+{
+#ifdef TI_DBG
+    txResultObj_t* pTxResult = (txResultObj_t*)hTxResult;
+
+    WLAN_OS_REPORT(("Tx-Result Module Information:\n"));
+    WLAN_OS_REPORT(("=============================\n\n"));
+
+    WLAN_OS_REPORT(("        FW result array depth histogram:\n"));
+    WLAN_OS_REPORT(("        --------------------------------\n\n"));
+    WLAN_OS_REPORT((" depth: %8d %8d %8d %8d %8d %8d\n", 0, 1, 2, 3, 4, 5));
+    WLAN_OS_REPORT((" INTR:  %8d %8d %8d %8d %8d %8d\n\n",
+                    pTxResult->txCompleteDepthHistogram[ 0 ],
+                    pTxResult->txCompleteDepthHistogram[ 1 ],
+                    pTxResult->txCompleteDepthHistogram[ 2 ],
+                    pTxResult->txCompleteDepthHistogram[ 3 ],
+                    pTxResult->txCompleteDepthHistogram[ 4 ],
+                    pTxResult->txCompleteDepthHistogram[ 5 ]));
+    WLAN_OS_REPORT((" depth: %8d %8d %8d %8d %8d %8d\n", 6, 7, 8, 9, 10, 11));
+    WLAN_OS_REPORT((" INTR:  %8d %8d %8d %8d %8d %8d\n\n",
+                    pTxResult->txCompleteDepthHistogram[ 6 ],
+                    pTxResult->txCompleteDepthHistogram[ 7 ],
+                    pTxResult->txCompleteDepthHistogram[ 8 ],
+                    pTxResult->txCompleteDepthHistogram[ 9 ],
+                    pTxResult->txCompleteDepthHistogram[ 10 ],
+                    pTxResult->txCompleteDepthHistogram[ 11 ]));
+    WLAN_OS_REPORT((" depth: %8d %8d %8d %8d %8d\n", 12, 13, 14, 15, 16));
+    WLAN_OS_REPORT((" INTR:  %8d %8d %8d %8d %8d\n\n",
+                    pTxResult->txCompleteDepthHistogram[ 12 ],
+                    pTxResult->txCompleteDepthHistogram[ 13 ],
+                    pTxResult->txCompleteDepthHistogram[ 14 ],
+                    pTxResult->txCompleteDepthHistogram[ 15 ],
+                    pTxResult->txCompleteDepthHistogram[ 16 ]));
+#endif
+}
+
+/****************************************************************************
+ *                      txResult_RegisterCB()
+ ****************************************************************************
+ * DESCRIPTION:  Prints TX result debig information.
+ ****************************************************************************/
+void txResult_clearInfo(TI_HANDLE hTxResult)
+{
+#ifdef TI_DBG
+    txResultObj_t* pTxResult = (txResultObj_t*)hTxResult;
+
+    os_memoryZero( pTxResult->hOs, pTxResult->txCompleteDepthHistogram, sizeof(UINT32) * FW_TX_CMPLT_BLOCK_SIZE );
+#endif
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Result/txResult.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Result/txResult.h
new file mode 100644 (file)
index 0000000..9e3e83f
--- /dev/null
@@ -0,0 +1,109 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   txResult.h                                                 */
+/*                                                                         */
+/*    PURPOSE:  Handle packets Tx results upon Tx-complete from the FW.    */
+/*                                                                         */
+/***************************************************************************/
+#ifndef _TX_RESULT_H_
+#define _TX_RESULT_H_
+
+
+#include "public_descriptors.h"
+
+
+
+/* Callback function definition for Tx sendPacketComplete */
+typedef void (* SendPacketCompleteCB_t)(TI_HANDLE CBObj, TxResultDescriptor_t *pTxResultInfo);
+
+typedef enum
+{
+    TX_RESULT_STATE_IDLE,
+    TX_RESULT_STATE_READING,
+    TX_RESULT_STATE_WRITING1,
+    TX_RESULT_STATE_WRITING2,
+    TX_RESULT_STATE_EXIT
+} TxResultState_e;
+
+typedef enum
+{
+    TX_RESULT_NO_BUFFER = 0,
+    TX_RESULT_ONE_BUFFER = 1,
+    TX_RESULT_TWO_BUFFERS = 2
+} TxResultNumOfBuffers_e;
+
+typedef struct 
+{ 
+  UINT32 from; 
+  UINT32 to; 
+} TxResultEntry_t;
+
+/* The TxResult module object. */
+typedef struct
+{
+
+    TI_HANDLE               hOs;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hTNETWIF;
+    TI_HANDLE               hFwEvent;
+
+    TI_STATUS               returnValue;                            /* used the return code to the FwEvent module */
+    TxResultState_e         state;                                  /* current state of SM */
+    
+    /* use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (TxResultDescriptor_t TxCmpltAttr[FW_TX_CMPLT_BLOCK_SIZE])   
+                                                                                                                                       /* The FW result table image from last read. */
+
+    BOOL                    bSync;                                  /* indicate if we are in Synch bus or not */
+    UINT32                  TxCmpltStartPointIterator;              /* Saves the last FW table index we got result-info from. */
+    SendPacketCompleteCB_t  sendPacketCompleteCB;                   /* Tx-Complete callback function */
+    TI_HANDLE               sendPacketCompleteHandle;               /* Tx-Complete callback function handle */
+    UINT32                  txResultTableAddr;                      /* The HW Tx-Result Table address. */
+    TxResultEntry_t         entry[2];                               /* address of start-end points of the new entries */
+    TxResultNumOfBuffers_e  numOfBuffers;                           /* indicate how many buffers should be written to FW */
+#ifdef TI_DBG
+    UINT32                  txCompleteDepthHistogram[ FW_TX_CMPLT_BLOCK_SIZE + 1 ];
+                                                                    /* The depth of the TX result array on INTR */
+#endif
+} txResultObj_t;
+
+
+
+#endif  /* _TX_RESULT_H_  */
+        
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.c
new file mode 100644 (file)
index 0000000..2df9a1f
--- /dev/null
@@ -0,0 +1,922 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txXfer.c
+ *   
+ *   PURPOSE: Handle Tx frame transfer to the firmware in slave double-buffer scheme. 
+ * 
+ *   DESCRIPTION:  
+ *   ============
+ *      This module gets the upper driver's Tx packets after FW resources were
+ *        allocated for it, and handles its transfer to the FW double-buffer.
+ *      It can handle two packets at a time, thus providing a pipe-line behavior.
+ *      It is planned to start an asynchronous copy of one packet to the FW,
+ *        and immediately indicate the upper layer to start handling the next
+ *        packet transmission in parallel.
+ *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "paramIn.h"
+#include "commonTypes.h"
+#include "TNETWIF.h"
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "txXfer_api.h"
+#include "txXfer.h"  /* Local definitions */
+
+
+/****************************************************************************
+ *                      txXfer_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the Xfer module object 
+ * 
+ * INPUTS:  None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+TI_HANDLE txXfer_Create(TI_HANDLE hOs)
+{
+    txXferObj_t *pTxXfer;
+
+    pTxXfer = os_memoryAlloc(hOs, sizeof(txXferObj_t));
+    if (pTxXfer == NULL)
+    {
+        return NULL;
+    }
+
+    os_memoryZero(hOs, pTxXfer, sizeof(txXferObj_t));
+
+    pTxXfer->hOs = hOs;
+
+    return (TI_HANDLE)pTxXfer;
+}
+
+
+/****************************************************************************
+ *                      txXfer_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the Xfer module object 
+ * 
+ * INPUTS:  hTxXfer - The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS txXfer_Destroy(TI_HANDLE hTxXfer)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    if (pTxXfer)
+    {
+        os_memoryFree(pTxXfer->hOs, pTxXfer, sizeof(txXferObj_t));
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *               txXfer_init()
+ ****************************************************************************
+   DESCRIPTION:  
+   ============
+     Initialize the Xfer module.
+ ****************************************************************************/
+TI_STATUS txXfer_init(TI_HANDLE hTxXfer, TI_HANDLE hReport, TI_HANDLE hTNETWIF, TI_HANDLE hTxResult)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    pTxXfer->hReport = hReport;
+    pTxXfer->hTNETWIF = hTNETWIF;
+    pTxXfer->hTxResult = hTxResult;
+    pTxXfer->sendPacketTransferCB = NULL;
+    pTxXfer->sendPacketDebugCB = NULL;
+
+    return txXfer_restart(pTxXfer);
+}
+
+/****************************************************************************
+ *               txXfer_config()
+ ****************************************************************************
+ * DESCRIPTION:  
+ *      Configures the TX XFER module with initialization parameters.
+ *          
+ * INPUTS:  
+ *      hTxXfer             The object
+ *      pInitParams         initialization parameters values
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None 
+ ****************************************************************************/
+void txXfer_config(TI_HANDLE hTxXfer, TnetwDrv_InitParams_t *pInitParams)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    pTxXfer->timeToTxStuckMs = pInitParams->txXferInitParams.timeToTxStuckMs;
+}
+
+
+/****************************************************************************
+ *                      txXfer_setHwInfo()
+ ****************************************************************************
+ * DESCRIPTION:  
+ *      Called after the HW configuration upon init or recovery.
+ *      Store the HW addresses of the Double Buffer and the Tx-status.
+ *          
+ * INPUTS:  
+ *      hTxXfer             The object
+ *      pDataPathParams     Pointer to the Double Buffer Address
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None 
+ ****************************************************************************/
+void  txXfer_setHwInfo(TI_HANDLE hTxXfer, ACXDataPathParamsResp_t *pDataPathParams)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    pTxXfer->dblBufAddr[0] = pDataPathParams->txPacketRingAddr;
+    pTxXfer->dblBufAddr[1] = pDataPathParams->txPacketRingAddr + pDataPathParams->txPacketRingChunkSize;
+    pTxXfer->txPathStatusAddr = pDataPathParams->txControlAddr;
+    
+    /* Print of the Tx double buffer address */
+    WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG, 
+        ("TX DOUBLE BUFFER Addresses: Buf_0 = 0x%x,   Buf_1 = 0x%x\n", 
+        pTxXfer->dblBufAddr[0], pTxXfer->dblBufAddr[1]));
+} 
+
+
+
+
+    
+/****************************************************************************
+ *               txXfer_restart()
+ ****************************************************************************
+   DESCRIPTION:  
+   ============
+     Restarts the Xfer module.
+     Should be called upon init and recovery!!
+ ****************************************************************************/
+TI_STATUS txXfer_restart(TI_HANDLE hTxXfer)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    /* Initialize module variables. */
+    pTxXfer->txXferState = TX_XFER_STATE_IDLE;
+    pTxXfer->numBufferedPkts = 0;
+    pTxXfer->xferDonePostponed = FALSE;
+    pTxXfer->bRecovery = FALSE;
+    pTxXfer->dataInCount = 0;
+    pTxXfer->hwStatusReadLoopCount = 0;
+
+    return OK;
+}
+
+
+
+
+/****************************************************************************
+ *                  txXfer_sendPacket()
+ ****************************************************************************
+ * DESCRIPTION: 
+   ============
+    Handle sent packet according to the number of packets already in the Xfer buffers:
+      If no buffered pkts:
+        If in IDLE state, update state to WAIT_BUS and request the bus.
+        Return SEND_PACKET_SUCCESS.
+      If one buffered pkt, just buffer the request and return SEND_PACKET_PENDING (can't get more).
+      If two buffered pkts, return SEND_PACKET_ERROR (not expected to get more packets).
+ ****************************************************************************/
+systemStatus_e txXfer_sendPacket(TI_HANDLE hTxXfer, txCtrlBlkEntry_t *pPktCtrlBlk)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+    TI_STATUS tnetwifStatus;
+
+#ifdef TI_DBG
+    pTxXfer->sendPacketCount++;
+#endif
+
+    /* Handle sent packet according to the number of packets already in the Xfer buffers. */
+    switch(pTxXfer->numBufferedPkts) 
+    {
+
+        /* No buffered pkts. */ 
+        case 0:
+
+            pTxXfer->numBufferedPkts = 1;    
+            pTxXfer->pPktCtrlBlk[0] = pPktCtrlBlk;    /* Save the first pkt Ctrl-Blk pointer. */
+            
+            /* If in IDLE state, update state to WAIT_BUS and request the bus. */
+            if (pTxXfer->txXferState == TX_XFER_STATE_IDLE)
+            {
+                WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                    ("txXfer_sendPacket(): First Pkt, IDLE-STATE, Start Bus-Wait\n"));
+
+                /* Note: Update the Xfer-SM state before calling the TNETWIF because it will call the
+                         SM immediately if the bus is available. */
+                pTxXfer->txXferState = TX_XFER_STATE_WAIT_BUS;    
+                
+                /* Set to detect if the Xfer proces is completed in this context (returns XFER_DONE). */
+                pTxXfer->syncXferIndication = TRUE; 
+                
+                tnetwifStatus = TNETWIF_Start(pTxXfer->hTNETWIF, TX_XFER_MODULE_ID, pTxXfer, xferStateMachine);
+
+                if (pTxXfer->bRecovery)
+                    return SEND_PACKET_RECOVERY;
+
+#ifdef TI_DBG
+                if (tnetwifStatus == TNETWIF_COMPLETE)
+                {
+                    pTxXfer->busStartSyncCount++;
+                }
+                else if (tnetwifStatus == TNETWIF_PENDING)
+                {
+                    pTxXfer->busStartAsyncCount++;
+                } 
+                else
+                {
+                    WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                                      ("txXfer_sendPacket(): TNETWIF_Start returned error=%d\n", tnetwifStatus));
+                }
+#endif
+
+                /* If the Xfer was completed in this context (Synchronous), return XFER_DONE. */
+                /* Note: In this case xferDone callback will not be called!  */
+                if (pTxXfer->syncXferIndication)
+                {
+                    pTxXfer->syncXferIndication = FALSE;
+
+                    if (tnetwifStatus == TNETWIF_COMPLETE) /* The SM was called from the Start function. */
+                    {
+#ifdef TI_DBG
+                        pTxXfer->xferDoneSyncCount++;
+                        WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                            ("txXfer_sendPacket(): Xfer Completed in upper driver context\n"));
+#endif
+                        return SEND_PACKET_XFER_DONE;  /* Xfer can get another packet. */
+                    }
+                }
+            }
+            else
+            {
+                WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                    ("txXfer_sendPacket(): First Pkt, not IDLE-STATE, XferState=%d\n", pTxXfer->txXferState));
+            }
+
+            /* If the Xfer wasn't completed in this context (Asynchronous), return SUCCESS
+                (xferDone callback will be called). */
+            return SEND_PACKET_SUCCESS;  /* Xfer can get another packet. */
+
+
+
+        /* If one buffered pkt, just buffer the request and return SEND_PACKET_PENDING (can't get more). */
+        case 1:
+
+            if (pTxXfer->bRecovery)
+            {
+                return SEND_PACKET_RECOVERY;
+            }
+
+            else
+            {
+                WLAN_REPORT_INFORMATION (pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                    ("txXfer_sendPacket(): Second Pkt Buffered, XferState=%d\n", pTxXfer->txXferState));
+
+                pTxXfer->numBufferedPkts = 2;  /* We now have two packets handled in the Xfer. */
+                pTxXfer->pPktCtrlBlk[1] = pPktCtrlBlk;  /* Save the second pkt Ctrl-Blk pointer. */
+
+                return SEND_PACKET_PENDING;  /* Xfer can't get further packets. */
+            }
+
+
+        /* If two buffered pkts, return SEND_PACKET_ERROR (not expected to get more packets). */
+        default:
+            
+            WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                ("txXfer_sendPacket(): Two Pkts Allready Buffered, XferState=%d, xferDonePostponed=%d, numPkts=%d\n",
+                pTxXfer->txXferState, pTxXfer->xferDonePostponed, pTxXfer->numBufferedPkts));
+
+            return SEND_PACKET_ERROR;
+    }
+}
+
+
+#define MAX_RECOVERY_LOOPS 1000
+
+
+/****************************************************************************
+ *                  xferStateMachine()
+ ****************************************************************************
+ * DESCRIPTION:  
+   ============
+    This is the Xfer process state machine.
+    It handles the transfer of packets sent by the upper driver to the HW via TNETWIF.
+   
+    The SM supports both Sync and Async accesses to the HW.
+    It loops and progresses from state to state as long as the HW is accessed synchronously.
+    Once the access is Asynchronous (TNETWIF_PENDING), it exits and is called later
+      by the TNETWIF when the HW is ready.
+    That's why it uses only unspecified-mode accesses (e.g. TNETWIF_ReadMemOpt) which
+      selects either Sync or Async automatically according to the platform.
+
+    When the SM is active (not in IDLE state), it has either one or two packets buffered.
+    This enables (in Async access) pipeline behavior, where one packet is transfered to 
+      the HW, and the other is being processed from the upper driver to the Xfer in parallel.
+
+
+    The SM steps are:
+    =================
+
+Event:     Send-Pkt       Bus-Ready         HW-Buffer-Ready         Xfer-Done             Trigger-Done
+               |              |                    |                    |                       |
+               V              V                    V                    V                       V
+State:  IDLE ----> WAIT_BUS ----> WAIT_HW_BUFFER ----> WAIT_XFER_DONE ----> WAIT_TRIGGER_DONE ----> IDLE
+                       |                                                             |  
+                       |                                                             |  
+                        <---------<---------<---------<---------<---------<----------
+                                             Pending-Packet (*)
+
+  (*) When a packet transfer is finished but another packet is already waiting in the Xfer 
+        for processing, the Xfer will postpone the Xfer-Done indication of the first packet 
+        until it has started the second one's transfer to the HW.
+        It will request "Bus Restart" in order to prevent nesting and enable bus allocation
+          to other tasks.
+
+ ****************************************************************************/
+static void xferStateMachine(TI_HANDLE hTxXfer, UINT8 module_id, TI_STATUS status)
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+    TI_STATUS tnetwifStatus;
+
+#ifdef TI_DBG
+    if (hTxXfer == NULL)
+    {
+        WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+            ("xferStateMachine(): ****  Called with NULL handle!!  ****\n"));
+        return;
+    }
+#endif
+    
+    /* 
+     * Loop through the states sequence as long as the process is synchronous.
+     * Exit when finished or if an Asynchronous process is required. In this case
+     *   the SM process will be resumed later (called back by TNETWIF). 
+     */
+    while (1)
+    {
+        switch (pTxXfer->txXferState)
+        {
+            
+            case TX_XFER_STATE_WAIT_BUS:
+
+                /* Call debug callback */
+                if (pTxXfer->sendPacketDebugCB)
+                { 
+                    pTxXfer->sendPacketDebugCB (pTxXfer->sendPacketDebugHandle, 
+                                                pTxXfer->pPktCtrlBlk[0], 
+                                                pTxXfer->txXferState);
+                }
+
+                /* We now own the bus, so request to read HW-Tx-Status and go to WAIT_HW_BUFFER state. */
+                pTxXfer->txXferState = TX_XFER_STATE_WAIT_HW_BUFFER;
+
+                /* also mark the time at which the first attemot is done */
+                pTxXfer->TimeStampFirstHwBufferRead = os_timeStampMs( pTxXfer->hOs );
+
+                tnetwifStatus = TNETWIF_ReadMemOpt (pTxXfer->hTNETWIF, 
+                                                    pTxXfer->txPathStatusAddr, 
+                                                    PADREAD (&pTxXfer->hwTxPathStatusRead), 
+                                                    sizeof(UINT32), 
+                                                    TX_XFER_MODULE_ID,
+                                                    xferStateMachine, 
+                                                    pTxXfer);
+                
+                break;
+
+
+                
+            case TX_XFER_STATE_WAIT_HW_BUFFER:
+
+                /* Call debug callback */
+                if (pTxXfer->sendPacketDebugCB)
+                {
+                    pTxXfer->sendPacketDebugCB (pTxXfer->sendPacketDebugHandle, 
+                                                pTxXfer->pPktCtrlBlk[0], 
+                                                pTxXfer->txXferState);
+                }
+                
+                /* We now have the HW-Tx-Status read, so check if there are HW buffers available. */
+                if (hwBuffersOccupied(pTxXfer) < DP_TX_PACKET_RING_CHUNK_NUM)
+                {
+                    /* Handle actual packet transfer to HW buffer. */
+                    tnetwifStatus = transferPacket(pTxXfer);
+
+                    pTxXfer->txXferState = TX_XFER_STATE_WAIT_XFER_DONE; 
+
+                    /* 
+                     * If we've postponed the Xfer-Done callback of the previous transfered 
+                     *   packet, call it now in parallel with the Xfer of the current packet.
+                     * Note that all variables are updated before calling the XferDone, since
+                     *   it may be used to send another packet.
+                     * The current transfered packet pointer is moved to the first buffer.
+                     */
+                    if (pTxXfer->xferDonePostponed)
+                    {
+                        txCtrlBlkEntry_t *pPostponedPktCtrlBlk = pTxXfer->pPktCtrlBlk[0];
+                        pTxXfer->numBufferedPkts = 1;
+                        pTxXfer->pPktCtrlBlk[0] = pTxXfer->pPktCtrlBlk[1];
+                        pTxXfer->xferDonePostponed = FALSE;
+                        pTxXfer->sendPacketTransferCB(pTxXfer->sendPacketTransferHandle, pPostponedPktCtrlBlk);
+#ifdef TI_DBG
+                        pTxXfer->xferDoneCallCBCount++;
+#endif
+                    }
+                    pTxXfer->hwStatusReadLoopCount = 0;
+#ifdef TI_DBG
+                    pTxXfer->hwBufferReadCount++;
+#endif
+                }
+
+                /* If HW buffer isn't available, try reading the status again (loop on same state). */
+                else
+                {
+                    tnetwifStatus = TNETWIF_ReadMemOpt (pTxXfer->hTNETWIF, 
+                                                        pTxXfer->txPathStatusAddr, 
+                                                        PADREAD (&pTxXfer->hwTxPathStatusRead), 
+                                                        sizeof(UINT32), 
+                                                        TX_XFER_MODULE_ID,
+                                                        xferStateMachine, 
+                                                        pTxXfer);
+
+#ifdef TI_DBG
+                    /* For Debug:  Update counters */
+                    pTxXfer->hwBufferFullCount++;
+                    pTxXfer->hwBufferReadCount++;
+#endif
+                    /* Detect endless loop and perform recovery if needed */
+                    pTxXfer->hwStatusReadLoopCount++;
+                    if (os_timeStampMs (pTxXfer->hOs) - pTxXfer->TimeStampFirstHwBufferRead > 
+                        pTxXfer->timeToTxStuckMs)
+                    {
+                        WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                            ("xferStateMachine(): Looping too long for Tx-Status, LastTxStatus=%d\n",   
+                            pTxXfer->hwTxPathStatusRead));
+                        WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,
+                                          ("Loop count=%d, First time stamp:%d, current time stamp:%d\n",
+                                           pTxXfer->hwStatusReadLoopCount, pTxXfer->TimeStampFirstHwBufferRead,
+                                           os_timeStampMs( pTxXfer->hOs )) );
+                            
+                      #ifdef USE_RECOVERY     
+                        pTxXfer->bRecovery = TRUE;         
+                        /* Error Reporting - if after a configurable interval we could not 
+                           transfer data a recovery will be called */
+                        if (pTxXfer->failureEventFunc)
+                        {
+                            pTxXfer->failureEventFunc(pTxXfer->failureEventObj, TX_STUCK);
+                        }
+
+                        return;
+                      #endif
+                    }         
+                }
+                
+                break;
+
+            case TX_XFER_STATE_WAIT_XFER_DONE:
+
+                /* Call debug callback */
+                if (pTxXfer->sendPacketDebugCB)
+                {
+                    pTxXfer->sendPacketDebugCB (pTxXfer->sendPacketDebugHandle, 
+                                                pTxXfer->pPktCtrlBlk[0], 
+                                                pTxXfer->txXferState);
+                }
+                
+                /* Now the last packet transfer to the HW is finished, so we issue a trigger to the FW. */
+
+                {
+                    UINT32 txInterruptRegAddress;
+                    UINT32 txInterruptRegData;
+
+                    /* Set the Tx-interrupt address and value according to the
+                         HW buffer used for the last transfer. */
+                    if (pTxXfer->dataInCount & 0x1)
+                    {
+                        txInterruptRegAddress = ACX_REG_INTERRUPT_TRIG_H;
+                        txInterruptRegData = INTR_TRIG_TX_PROC1;
+                    }
+                    else
+                    {
+                        txInterruptRegAddress = ACX_REG_INTERRUPT_TRIG;
+                        txInterruptRegData = INTR_TRIG_TX_PROC0;
+                    }                   
+
+                    /* Call debug callback */
+                    if (pTxXfer->sendPacketDebugCB)
+                    {
+                        pTxXfer->sendPacketDebugCB (pTxXfer->sendPacketDebugHandle, 
+                                                    pTxXfer->pPktCtrlBlk[0], 
+                                                    0);
+                    }
+
+                    /* Issue the Tx interrupt trigger to the FW. */   
+                    tnetwifStatus = TNETWIF_WriteRegOpt(pTxXfer->hTNETWIF, 
+                                                        txInterruptRegAddress, 
+                                                        txInterruptRegData, 
+                                                        TX_XFER_MODULE_ID,
+                                                        xferStateMachine, 
+                                                        pTxXfer);
+
+                    /* Increment the transfered packets counter modulo 16 (as FW data-out counter). */ 
+                    pTxXfer->dataInCount = (pTxXfer->dataInCount + 1) & TX_STATUS_DATA_OUT_COUNT_MASK;
+
+                    pTxXfer->txXferState = TX_XFER_STATE_WAIT_TRIGGER_DONE; 
+                }   
+                
+                break;
+               
+            case TX_XFER_STATE_WAIT_TRIGGER_DONE:
+
+                /* Call debug callback */
+                if (pTxXfer->sendPacketDebugCB)
+                {
+                    pTxXfer->sendPacketDebugCB (pTxXfer->sendPacketDebugHandle, 
+                                                pTxXfer->pPktCtrlBlk[0], 
+                                                pTxXfer->txXferState);
+                }
+
+                /* Now the HW Tx trigger is done so we can continue to the next packet if waiting. */
+
+                /* If we don't have another packet pending for transfer. */
+                if (pTxXfer->numBufferedPkts == 1)
+                {
+                    pTxXfer->numBufferedPkts = 0;
+
+                    /*
+                     * Call the XferDone callback, but only if we are not in the original 
+                     *   SendPacket context (i.e. completely synchronous). 
+                     * This is to avoid nesting, since the callback may start another SendPacket.
+                     */
+                    if (!pTxXfer->syncXferIndication)
+                    {
+#ifdef TI_DBG
+                        pTxXfer->xferDoneCallCBCount++;
+                        WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                            ("sendPacketTransferCB: CB_Func=0x%x, CB_Handle=0x%x\n", 
+                            pTxXfer->sendPacketTransferCB, pTxXfer->sendPacketTransferHandle));
+#endif
+                        pTxXfer->sendPacketTransferCB(pTxXfer->sendPacketTransferHandle, pTxXfer->pPktCtrlBlk[0]);
+                    }
+
+                    /* If still no packet was sent, release bus (Finish), set IDLE state and exit. */ 
+                    if (pTxXfer->numBufferedPkts == 0)
+                    {
+                        pTxXfer->txXferState = TX_XFER_STATE_IDLE; 
+                        TNETWIF_Finish (pTxXfer->hTNETWIF, TX_XFER_MODULE_ID, pTxXfer, NULL);
+                        
+                        WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                            ("txXferSM Finished -> IDLE: NumPkts=%d, XferDonePostponed=%d, SyncIndication=%d\n", 
+                            pTxXfer->numBufferedPkts, pTxXfer->xferDonePostponed, pTxXfer->syncXferIndication));
+
+                        return;   /************    Exit State Machine (back to IDLE)   ************/
+                    }
+
+                    /* 
+                     * A new packet was sent (in XferDone callback), so request the bus again using Restart.
+                     * This will call the SM later, and start the process again from WAIT_BUS state.
+                     */
+                    else
+                    {
+                        pTxXfer->txXferState = TX_XFER_STATE_WAIT_BUS; 
+                        tnetwifStatus = TNETWIF_Restart(pTxXfer->hTNETWIF, TX_XFER_MODULE_ID, pTxXfer, xferStateMachine);
+#ifdef TI_DBG
+                        pTxXfer->busRestartCount++;
+#endif
+                    }
+                }
+
+                /*
+                 * We have another packet pending.
+                 * So to enable parallel processing, we postpone the XferDone callback (just set flag).
+                 * Thus, we'll start first the new packet transfer and only than call the postponed
+                 *   XferDone (see WAIT_HW_BUFFER state), which may start another SendPacket in 
+                 *   parallel to the HW transfer.
+                 * Note that we request the bus again using Restart (to avoid nesting or bus starvation).
+                 * This will call the SM later, and start the process again from WAIT_BUS state.
+                 */
+                else
+                {
+                    pTxXfer->xferDonePostponed = TRUE;
+                    pTxXfer->txXferState = TX_XFER_STATE_WAIT_BUS; 
+                    tnetwifStatus = TNETWIF_Restart(pTxXfer->hTNETWIF, TX_XFER_MODULE_ID, pTxXfer, xferStateMachine);
+#ifdef TI_DBG
+                    pTxXfer->busRestartCount++;
+                    pTxXfer->xferDonePostponeCount++;
+#endif
+                }
+
+                break;
+
+                
+                
+            default:
+                    WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                        ("xferStateMachine(): Unexpected state, txXferState=%d, NumPkts=%d\n",  
+                        pTxXfer->txXferState, pTxXfer->numBufferedPkts));
+                    
+                return;
+
+        }  /* switch (pTxXfer->txXferState) */
+
+        WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+            ("txXferSM(): SmState=%d, NumPkts=%d, XferDonePostponed=%d, TnetwIfStatus=%d, SyncIndication=%d, HwTxStatus=0x%x, DataInCount=0x%x\n", 
+            pTxXfer->txXferState, pTxXfer->numBufferedPkts, pTxXfer->xferDonePostponed, 
+            tnetwifStatus, pTxXfer->syncXferIndication, pTxXfer->hwTxPathStatusRead, pTxXfer->dataInCount));
+
+        /* 
+         * If the last HW access request was pended, exit the SM (Asynchronous process).
+         * The SM will be called back when the HW access is done.
+         * Also reset the Sync flag to notify that the Xfer wasn't completed in the SendPacket context.
+         */
+        if (tnetwifStatus == TNETWIF_PENDING)
+        {
+            pTxXfer->syncXferIndication = FALSE;
+
+            return;  /**********    Exit State Machine (to be called back by TNETWIF)   **********/
+        }
+
+#ifdef TI_DBG
+        else if (tnetwifStatus == TNETWIF_ERROR)
+        {
+            WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG,  
+                ("txXferSM TNETWIF_ERROR: SmState=%d, NumPkts=%d, XferDonePostponed=%d, TnetwIfStatus=%d, SyncIndication=%d, HwTxStatus=0x%x, DataInCount=0x%x\n", 
+                pTxXfer->txXferState, pTxXfer->numBufferedPkts, pTxXfer->xferDonePostponed, 
+                tnetwifStatus, pTxXfer->syncXferIndication, pTxXfer->hwTxPathStatusRead, pTxXfer->dataInCount));
+            return;
+        }
+#endif
+
+    }  /* while (1) */
+
+}
+
+
+
+
+/****************************************************************************
+ *                  hwBuffersOccupied()
+ ****************************************************************************
+ * DESCRIPTION: 
+   ============
+   Return the number of occupied buffers in the HW Tx double buffer, based on
+     the last read of the HW Tx path status.
+ ****************************************************************************/
+static UINT32 hwBuffersOccupied(txXferObj_t *pTxXfer)
+{
+    UINT32 dataOutCount = pTxXfer->hwTxPathStatusRead & TX_STATUS_DATA_OUT_COUNT_MASK;
+
+    /* Return the difference between the packets transfered to the double buffer (by host)
+        and the packets copied from it (by FW). The else is for counter wrap around. */
+    
+    if (pTxXfer->dataInCount >= dataOutCount)
+    {
+        return pTxXfer->dataInCount - dataOutCount;
+    }
+    else
+    {
+        return pTxXfer->dataInCount + TX_STATUS_DATA_OUT_COUNT_MASK + 1 - dataOutCount;
+    }
+}
+
+
+
+
+/****************************************************************************
+ *                  transferPacket()
+ ****************************************************************************
+ * DESCRIPTION: 
+   ============
+   Handle the current packet transfer to the HW Tx double buffer.
+   Return the transfer status:
+     TNETWIF_COMPLETE - if completed, i.e. Synchronous mode.
+     TNETWIF_PENDING  - if pending, i.e. Asynchronous mode (callback function will be called). 
+
+    
+   If the packet was pending during disconnect, notify the TxResult to issue Tx-Complete,
+     and return TNETWIF_COMPLETE, since we don't transfer it to the FW.
+
+ ****************************************************************************/
+static TI_STATUS transferPacket(txXferObj_t *pTxXfer)
+{
+    UINT16 XferLength;  /* The actual length of the transfer. */
+    txCtrlBlkEntry_t *pPktCtrlBlk;  /* The packet control block pointer. */
+    TI_STATUS status; 
+    
+    /* Get the current packet control-block pointer. If we've postponed the last packet Xfer-Done (i.e.
+        was transfered but still buffered) than our current packet is the second one. */
+    pPktCtrlBlk = pTxXfer->pPktCtrlBlk[ ((pTxXfer->xferDonePostponed) ? 1 : 0) ];
+
+    /* Get the packet length, add descriptor length and align upward to 32 bit. */
+    XferLength = (pPktCtrlBlk->txDescriptor.length + sizeof(DbTescriptor) + ALIGN_32BIT_MASK) & ~ALIGN_32BIT_MASK; 
+
+    /* Initiate the packet transfer. The status indicates if Sync or Async mode was used!! */
+    status = TNETWIF_WriteMemOpt (pTxXfer->hTNETWIF,  
+                                  pTxXfer->dblBufAddr[pTxXfer->dataInCount & 0x1], 
+                                  (UINT8 *)(pPktCtrlBlk->txPktParams.pFrame), 
+                                  XferLength, 
+                                  TX_XFER_MODULE_ID,
+                                  xferStateMachine, 
+                                  pTxXfer);
+
+#ifdef TI_DBG
+    WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG, 
+        ("transferPacket(): Status=%d, XferLength=%d, DataInCount=0x%x, pPktCtrlBlk=0x%x, dbgPktSeqNum=%d, Expiry=%d\n", 
+        status, XferLength, pTxXfer->dataInCount, pPktCtrlBlk, pPktCtrlBlk->txPktParams.dbgPktSeqNum,
+        pPktCtrlBlk->txDescriptor.expiryTime));
+
+    if (status == TNETWIF_COMPLETE)
+    {
+        pTxXfer->pktTransferSyncCount++;
+    }
+    else if (status == TNETWIF_PENDING)
+    {
+        pTxXfer->pktTransferAsyncCount++;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG, 
+            ("transferPacket - TNETWIF_ERROR: Status=%d, XferLength=%d, DataInCount=0x%x, pPktCtrlBlk=0x%x, dbgPktSeqNum=%d, Expiry=%d\n", 
+            status, XferLength, pTxXfer->dataInCount, pPktCtrlBlk, pPktCtrlBlk->txPktParams.dbgPktSeqNum,
+            pPktCtrlBlk->txDescriptor.expiryTime));
+    }
+#endif
+
+    /* Return the transfer status:
+         TNETWIF_COMPLETE - if completed, i.e. Synchronous mode.
+         TNETWIF_PENDING  - if pending, i.e. Asynchronous mode (callback function will be called). 
+    */
+    return status;
+}
+
+
+
+
+/****************************************************************************
+ *                      txXfer_RegisterCB()
+ ****************************************************************************
+ * DESCRIPTION:  Register the upper driver Xfer callback functions.
+ ****************************************************************************/
+void txXfer_RegisterCB(TI_HANDLE hTxXfer, tiUINT32 CallBackID, void *CBFunc, TI_HANDLE CBObj)
+{
+    txXferObj_t* pTxXfer = (txXferObj_t*)hTxXfer;
+
+    WLAN_REPORT_INFORMATION(pTxXfer->hReport, TNETW_XFER_MODULE_LOG, 
+        ("txXfer_RegisterCB(): CallBackID=%d, CBFunc=0x%x, CBObj=0x%x\n", CallBackID, CBFunc, CBObj));
+
+    switch(CallBackID)
+    {
+        /* Set Transfer-Done callback */
+        case TX_XFER_SEND_PKT_TRANSFER:
+            pTxXfer->sendPacketTransferCB = (SendPacketTranferCB_t)CBFunc;
+            pTxXfer->sendPacketTransferHandle = CBObj;
+            break;
+
+        case TX_XFER_SEND_PKT_DEBUG:
+            pTxXfer->sendPacketDebugCB = (SendPacketDebugCB_t)CBFunc;
+            pTxXfer->sendPacketDebugHandle = CBObj;
+            break;
+
+        default:
+            WLAN_REPORT_ERROR(pTxXfer->hReport, TNETW_XFER_MODULE_LOG, ("txXfer_RegisterCB - Illegal value\n"));
+            break;
+    }
+}
+
+
+
+/****************************************************************************************
+ *                        txXfer_RegisterFailureEventCB                                                 *
+ ****************************************************************************************
+DESCRIPTION: Registers a failure event callback for scan error notifications.
+                
+                                                                                                                   
+INPUT:      - hTxXfer       - handle to the xfer object.        
+            - failureEventCB    - the failure event callback function.\n
+            - hFailureEventObj - handle to the object passed to the failure event callback function.
+
+OUTPUT: 
+RETURN:    void.
+****************************************************************************************/
+
+void txXfer_RegisterFailureEventCB( TI_HANDLE hTxXfer, 
+                                     void * failureEventCB, TI_HANDLE hFailureEventObj )
+{
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    pTxXfer->failureEventFunc   = (failureEventCB_t)failureEventCB;
+    pTxXfer->failureEventObj    = hFailureEventObj;
+}
+
+/****************************************************************************
+ *                      txXfer_printInfo()
+ ****************************************************************************
+ * DESCRIPTION:  Print the txXfer object main fields.
+ ****************************************************************************/
+void txXfer_printInfo(TI_HANDLE hTxXfer)
+{
+#ifdef TI_DBG
+    txXferObj_t *pTxXfer = (txXferObj_t *)hTxXfer;
+
+    WLAN_OS_REPORT(("Tx-Xfer Module Information:\n"));
+    WLAN_OS_REPORT(("===========================\n"));
+
+    switch (pTxXfer->txXferState)
+    {
+        case TX_XFER_STATE_IDLE:                
+            WLAN_OS_REPORT(("State = IDLE\n")); 
+            break;
+
+        case TX_XFER_STATE_WAIT_BUS:
+            WLAN_OS_REPORT(("State = WAIT_BUS\n")); 
+        break;
+
+        case TX_XFER_STATE_WAIT_HW_BUFFER:
+            WLAN_OS_REPORT(("State = WAIT_HW_BUFFER\n"));   
+        break;
+
+        case TX_XFER_STATE_WAIT_XFER_DONE:
+            WLAN_OS_REPORT(("State = WAIT_XFER_DONE\n"));   
+        break;
+
+        case TX_XFER_STATE_WAIT_TRIGGER_DONE:
+            WLAN_OS_REPORT(("State = WAIT_TRIGGER_DONE\n"));    
+        break;
+
+        default:
+            WLAN_OS_REPORT(("State = UNKNOWN !!\n"));
+        break;
+    }
+    
+    WLAN_OS_REPORT(("numBufferedPkts    = %d\n", pTxXfer->numBufferedPkts));
+    WLAN_OS_REPORT(("xferDonePostponed  = %d\n", pTxXfer->xferDonePostponed));
+    WLAN_OS_REPORT(("syncXferIndication = %d\n", pTxXfer->syncXferIndication));
+    WLAN_OS_REPORT(("pPktCtrlBlk[0]     = 0x%x\n", pTxXfer->pPktCtrlBlk[0]));
+    WLAN_OS_REPORT(("pPktCtrlBlk[1]     = 0x%x\n", pTxXfer->pPktCtrlBlk[1]));
+    WLAN_OS_REPORT(("hwTxPathStatusRead = 0x%x\n", pTxXfer->hwTxPathStatusRead));
+    WLAN_OS_REPORT(("dataInCount        = 0x%x\n", pTxXfer->dataInCount));
+    WLAN_OS_REPORT(("txPathStatusAddr   = 0x%x\n", pTxXfer->txPathStatusAddr));
+    WLAN_OS_REPORT(("dblBufAddr[0]      = 0x%x\n", pTxXfer->dblBufAddr[0]));
+    WLAN_OS_REPORT(("dblBufAddr[1]      = 0x%x\n\n", pTxXfer->dblBufAddr[1]));
+    
+    WLAN_OS_REPORT(("hwBufferReadCount      = %d\n", pTxXfer->hwBufferReadCount));
+    WLAN_OS_REPORT(("hwBufferFullCount      = %d\n", pTxXfer->hwBufferFullCount));
+    WLAN_OS_REPORT(("sendPacketCount        = %d\n", pTxXfer->sendPacketCount));
+    WLAN_OS_REPORT(("busStartSyncCount      = %d\n", pTxXfer->busStartSyncCount));
+    WLAN_OS_REPORT(("busStartAsyncCount     = %d\n", pTxXfer->busStartAsyncCount));
+    WLAN_OS_REPORT(("pktTransferSyncCount   = %d\n", pTxXfer->pktTransferSyncCount));
+    WLAN_OS_REPORT(("pktTransferAsyncCount  = %d\n", pTxXfer->pktTransferAsyncCount));
+    WLAN_OS_REPORT(("busRestartCount        = %d\n", pTxXfer->busRestartCount));
+    WLAN_OS_REPORT(("xferDonePostponeCount  = %d\n", pTxXfer->xferDonePostponeCount));
+    WLAN_OS_REPORT(("xferDoneSyncCount      = %d\n", pTxXfer->xferDoneSyncCount));
+    WLAN_OS_REPORT(("xferDoneCallCBCount    = %d\n", pTxXfer->xferDoneCallCBCount));
+#endif /* TI_DBG */
+}
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.h
new file mode 100644 (file)
index 0000000..1714b01
--- /dev/null
@@ -0,0 +1,134 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   txXfer.h                                                   */
+/*    PURPOSE:  Tx-Xfer module Header file - slave-mode, double-buffer     */
+/*                                                                         */
+/***************************************************************************/
+#ifndef _TX_XFER_H_
+#define _TX_XFER_H_
+
+
+#include "TNETW_Driver_types.h"
+
+
+#define MAX_XFER_BUFFERS                2       /* The number of frames that can be handled in 
+                                                    the XFER module at a time. */
+#define TX_STATUS_DATA_OUT_COUNT_MASK   0x000F  /* Tx status register mask of the FW counter of
+                                                    packets copied from its Tx double buffer. */
+#define ALIGN_32BIT_MASK                0x3     /* Masked LS bits for 32 bit aligned addresses or lengths.*/
+
+
+typedef enum
+{
+    TX_XFER_STATE_IDLE,
+    TX_XFER_STATE_WAIT_BUS,
+    TX_XFER_STATE_WAIT_HW_BUFFER,
+    TX_XFER_STATE_WAIT_XFER_DONE,
+    TX_XFER_STATE_WAIT_TRIGGER_DONE
+} TxXferState_e;
+
+
+/* Callback function definition for Tx sendPacketTranfer */
+typedef void (* SendPacketTranferCB_t)(TI_HANDLE CBObj, txCtrlBlkEntry_t *pPktCtrlBlk);
+typedef void (* SendPacketDebugCB_t)  (TI_HANDLE CBObj, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo);
+
+
+/* The TxXfer module object. */
+typedef struct 
+{
+    TI_HANDLE  hOs;
+    TI_HANDLE  hReport;
+    TI_HANDLE  hTNETWIF;
+    TI_HANDLE  hTxResult;
+
+    UINT32 numBufferedPkts; /* The number of packets buffered in the Xfer module (0, 1 or 2). */
+    BOOL xferDonePostponed; /* Indicates if postponed the last Xfer-Done event to the upper driver. */
+    BOOL syncXferIndication; /* Cleared once the sendPkt sequence is broken to Async mode. */
+    TxXferState_e txXferState; /* The current state of the Xfer state machine. */
+    txCtrlBlkEntry_t *pPktCtrlBlk[MAX_XFER_BUFFERS]; /* The pointers to the transfered packets ctrl-blk. */
+    UINT32 dataInCount;  /* The number of packets transfered to FW modulu 16. */
+    SendPacketTranferCB_t sendPacketTransferCB; /* Xfer-Done callback */
+    TI_HANDLE sendPacketTransferHandle;         /* Xfer-Done callback handle */
+    SendPacketDebugCB_t sendPacketDebugCB;      /* Xfer-Debug callback */
+    TI_HANDLE sendPacketDebugHandle;            /* Xfer-Debug callback handle */
+    UINT32 dblBufAddr[DP_TX_PACKET_RING_CHUNK_NUM];  /* The HW Tx double buffer. */
+    UINT32 txPathStatusAddr;  /* The HW Tx status register address. */
+
+    /* use a struct to read buffers from the bus - used for extra bytes reserving */
+    PADDING (UINT32 hwTxPathStatusRead) /* Saves the last read from the HW Tx-Path-Status. */
+
+    /*Error handling*/
+    failureEventCB_t        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 */
+
+    UINT32 hwStatusReadLoopCount; /* Count loops of HW status polling to detect endless loop. */
+    UINT32 timeToTxStuckMs;       /* The time (in msec) from first attempt to get a HW buffer status
+                                    until recovery is triggered */
+    UINT32 TimeStampFirstHwBufferRead;
+                                    /* Time stamp at the first attempt to read the HW buffer status */
+    BOOL   bRecovery;             /* Recovery indicator */  
+
+#ifdef TI_DBG  /* Debug Counters */
+    UINT32 hwBufferReadCount;     /* Count total number of HW-Tx-Status Reads. */
+    UINT32 hwBufferFullCount;     /* Count total number of status reads where the HW Xfer buffers were full. */
+    UINT32 sendPacketCount;       /* Count number of SendPacket calls from upper driver. */
+    UINT32 busStartSyncCount;     /* Count number of calls to arbiter bus Start request returned Complete. */
+    UINT32 busStartAsyncCount;    /* Count number of calls to arbiter bus Start request returned Pending. */
+    UINT32 pktTransferSyncCount;  /* Count number of transfered packets in sync mode. */
+    UINT32 pktTransferAsyncCount; /* Count number of transfered packets in sync mode. */
+    UINT32 busRestartCount;       /* Count number of calls to arbiter bus Restart request. */
+    UINT32 xferDonePostponeCount; /* Count number of postponed XferDone calls. */
+    UINT32 xferDoneSyncCount;     /* Count number of XferDone synchronous event. */
+    UINT32 xferDoneCallCBCount;   /* Count number of XferDone synchronous event. */
+#endif
+
+} txXferObj_t;
+
+
+
+/* Local function definitions */
+static void         xferStateMachine(TI_HANDLE hTxXfer, UINT8 module_id, TI_STATUS status);
+static UINT32       hwBuffersOccupied(txXferObj_t *pTxXfer);
+static TI_STATUS    transferPacket(txXferObj_t *pTxXfer);
+
+
+
+#endif  /* _TX_XFER_H_ */
+        
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/CmdMBox_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/CmdMBox_api.h
new file mode 100644 (file)
index 0000000..ca2285a
--- /dev/null
@@ -0,0 +1,76 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/*********************************************************************************/
+/*                                                                                */
+/*   MODULE:  CmdMBox_api.h                                            */
+/*   PURPOSE: CmdMBox api h file                                       */
+/*                                                                                     */
+/**********************************************************************************/
+#ifndef _CMDMBOX_API_H_
+#define _CMDMBOX_API_H_
+
+#include "whalCommon.h"
+#include "public_commands.h"
+
+/*****************************************************************************
+ **         Defines                                                           **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Types                                                      **
+ *****************************************************************************/
+typedef int (*CmdMBox_CB_t )(TI_HANDLE objectHandle);
+
+
+/*****************************************************************************
+ **         API functions definitions                                  **
+ *****************************************************************************/
+TI_HANDLE       CmdMBox_Create(TI_HANDLE hOs);
+int             CmdMBox_Destroy(TI_HANDLE hCmdMBox);
+int             CmdMBox_Config(TI_HANDLE hCmdMBox, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent, TI_HANDLE hCmdQueue, TI_HANDLE hReport);
+TI_STATUS       CmdMBox_ConfigHw(TI_HANDLE hCmdMBox, UINT8 module_id, fnotify_t fCb, TI_HANDLE hCb);
+int             CmdMBox_SetModeNormal(TI_HANDLE hCmdMBox);
+int             CmdMBox_Restart(TI_HANDLE hCmdMBox);
+int             CmdMBox_SendCmd(TI_HANDLE hCmdMBox, Command_e cmdType, UINT8* pParamsBuf, UINT32 paramsLen);
+int             CmdMBox_GetResult(TI_HANDLE hCmdMBox, UINT8* pParamsBuf, UINT32 paramsLen, UINT32* status);
+TI_STATUS       CmdMBox_CmdCmplt(TI_HANDLE hCmdMBox);
+TI_STATUS       CmdMBox_GetStatus(TI_HANDLE hCmdMBox);
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/DebugTraceXfer_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/DebugTraceXfer_api.h
new file mode 100644 (file)
index 0000000..2b86533
--- /dev/null
@@ -0,0 +1,78 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*********************************************************************************/
+/*                                                                                */
+/*   MODULE:  DebugTraceXfer_api.h                                                                                               */
+/*   PURPOSE: Handle The FW Debug Messages                                                                               */
+/*                                                                                */
+/**********************************************************************************/
+#ifdef TI_DBG
+
+#ifndef _DEBUG_TRCAE_XFER_API_H
+#define _DEBUG_TRCAE_XFER_API_H
+
+
+TI_HANDLE debugTrace_Create    (TI_HANDLE hOS);
+
+void debugTrace_Destroy                (TI_HANDLE hDebugTrace);
+
+void debugTrace_Config(TI_HANDLE hDebugTrace, TI_HANDLE hWhalParams, TI_HANDLE hReport,
+                                          TI_HANDLE hMemMgr, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent);
+
+void debugTrace_ConfigHw       (TI_HANDLE hDebugTrace,UINT32 TraceAddA, UINT32 TraceAddB);
+
+TI_STATUS debugTrace_Event     (TI_HANDLE hDebugTrace);
+
+void debugTrace_Disable                (TI_HANDLE hDebugTrace);
+
+void debugTrace_Enable         (TI_HANDLE hDebugTrace);
+
+void debugTrace_Print          (TI_HANDLE hDebugTrace);
+
+void debugTrace_EnablePrint    (TI_HANDLE hDebugTrace);
+
+void debugTrace_DisablePrint(TI_HANDLE hDebugTrace);
+
+void debugTrace_handleBuffer(TI_HANDLE hDebugTrace);
+
+void debugTrace_UdpEnable      (TI_HANDLE hDebugTrace);
+
+void debugTrace_UdpDisable     (TI_HANDLE hDebugTrace);
+
+#endif /* _DEBUG_TRCAE_XFER_API_H */
+
+#endif /* TI_DBG */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/FwEvent_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/FwEvent_api.h
new file mode 100644 (file)
index 0000000..4054617
--- /dev/null
@@ -0,0 +1,84 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  FwEvent_api.h
+ *
+ *   PURPOSE: Firmware Event module API.
+ * 
+ ****************************************************************************/
+
+#ifndef _FW_EVENT_API_H
+#define _FW_EVENT_API_H
+
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "public_infoele.h"
+
+/* Public Function Definitions */
+
+TI_HANDLE       FwEvent_Create(TI_HANDLE hOs);
+TI_STATUS       FwEvent_Destroy(TI_HANDLE hFwEvent);
+void            FwEvent_BusReadyCB(TI_HANDLE hFwEvent,UINT8 module_id, TI_STATUS status);
+void            FwEvent_EventComplete(TI_HANDLE hFwEvent, systemStatus_e rc);
+TI_STATUS       FwEvent(TI_HANDLE hFwEvent);
+void            FwEvent_Config(TI_HANDLE hFwEvent, TI_HANDLE hTnetwDrv);
+void            FwEvent_Enable(TI_HANDLE hFwEvent, UINT32 uEventMask);
+void            FwEvent_Disable(TI_HANDLE hFwEvent, UINT32 uEventMask);
+UINT32          FwEvent_GetEnabled(TI_HANDLE hFwEvent);
+void                   FwEvent_SetHwInfo(TI_HANDLE hFwEvent, ACXDataPathParamsResp_t *pDataPathParams);
+
+/****************************************************************
+*
+*   Functions originally located at whalHwIntr.c 
+*
+*****************************************************************/
+void            FwEvent_EnableInterrupts (TI_HANDLE hFwEvent);
+void            FwEvent_DisableInterrupts(TI_HANDLE hFwEvent); 
+UINT32          FwEvent_CheckInterrupts  (TI_HANDLE hFwEvent);
+void            FwEvent_ChangeState      (TI_HANDLE hFwEvent, int State);
+void            FwEvent_StateChanged     (TI_HANDLE hFwEvent);
+void            FwEvent_Stop             (TI_HANDLE hFwEvent);
+
+#endif /* _FW_EVENT_API_H */
+
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/HwInit_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/HwInit_api.h
new file mode 100644 (file)
index 0000000..29676ff
--- /dev/null
@@ -0,0 +1,54 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       HwInit.h                                                                                       */
+/*    PURPOSE: HwInit module Header file                             */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _HW_INIT_API_H_
+#define _HW_INIT_API_H_
+
+#include "osTIType.h"
+
+TI_HANDLE hwInit_create(TI_HANDLE hOs);
+TI_STATUS hwInit_config(TI_HANDLE hHwInit, TI_HANDLE hReport, TI_HANDLE hTntewDrv);
+TI_STATUS hwInit_destroy(TI_HANDLE hHwInit);
+TI_STATUS hwInit_recovery(TI_HANDLE hHwInit, TI_HANDLE hHwCtrl, void *funcCB, TI_HANDLE hRecoveryCtrl);
+TI_STATUS hwInit_hwCtrl_Initiate(TI_HANDLE hHwInit, TI_HANDLE hHwCtrl);
+TI_STATUS InitHw_FinalizeDownload(TI_HANDLE hHwInit);
+
+#endif /* _HW_INIT_API_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/eventMbox_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/eventMbox_api.h
new file mode 100644 (file)
index 0000000..e42e304
--- /dev/null
@@ -0,0 +1,78 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  eventMbox_api.h : event Mail Box API
+ *   PURPOSE: Notify EventMbox in case of an incoming event from the FW
+ *
+ ****************************************************************************/
+#ifndef _EVENT_MBOX_API_H
+#define _EVENT_MBOX_API_H
+
+/*
+ *     whal_hwMboxDataEvCB : This Call back is for EventMbox Client 
+ *                                               that expect an event with Data associated  
+ *                                               str:     The Data String
+ *                                               strLen : The Length of the Data
+ */
+typedef void (*whal_hwMboxDataEvCB)(void *pObj, char* str, UINT32 strLen);
+
+/*
+ *     whal_hwMboxDataEvCB : This Call back is for EventMbox Client 
+ *                                               that expect an event without any Data
+ */
+typedef void (*whal_hwMboxEvCB)(void *pObj);
+
+
+/*****************************************************************************
+ **         API                                                                                               **
+ *****************************************************************************/
+
+TI_HANDLE eventMbox_Create          (TI_HANDLE hOs);
+void      eventMbox_Destroy         (TI_HANDLE hEventMbox);
+void      eventMbox_Config          (TI_HANDLE hEventMbox, TI_HANDLE hTNETWIF, TI_HANDLE hHwIntr, 
+                                                        TI_HANDLE hReport, TI_HANDLE hFwEvent, TI_HANDLE hWhalCtrl);
+TI_STATUS eventMbox_ConfigHw        (TI_HANDLE hEventMbox, UINT8 module_id, fnotify_t fCb, TI_HANDLE hCb);
+void      eventMbox_InitComplete    (TI_HANDLE hEventMbox);
+int       eventMbox_RegisterEventCB (TI_HANDLE hEventMbox, UINT32 EvID, void* CbFunc, TI_HANDLE CbObj);
+TI_STATUS eventMbox_Event           (TI_HANDLE hEventMbox);
+int       eventMbox_EvMask          (TI_HANDLE hEventMbox, UINT32 EvID);
+int       eventMbox_EvUnMask        (TI_HANDLE hEventMbox, UINT32 EvID);
+void      eventMbox_Print           (TI_HANDLE hEventMbox);
+
+int eventMbox_Stop(TI_HANDLE hEventMbox);
+
+#endif /* _EVENT_MBOX_API_H */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/rxXfer_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/rxXfer_api.h
new file mode 100644 (file)
index 0000000..c64db5c
--- /dev/null
@@ -0,0 +1,86 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  rxXfer_api.h
+ *
+ *   PURPOSE: Rx Xfer module API.
+ * 
+ ****************************************************************************/
+
+#ifndef _RX_XFER_API_H
+#define _RX_XFER_API_H
+
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "public_infoele.h"
+
+/* Public Function Definitions */
+
+
+TI_HANDLE                      rxXfer_Create(TI_HANDLE hOs);
+
+void                           rxXfer_Destroy(TI_HANDLE hRxXfer);
+
+void                           rxXfer_Config( TI_HANDLE hRxXfer,
+                                                                  TI_HANDLE hFwEvent, 
+                                                                  TI_HANDLE hMemMgr,
+                                                                  TI_HANDLE hReport,
+                                                                  TI_HANDLE hTNETWIF);
+
+TI_STATUS                      rxXfer_RxEvent(TI_HANDLE hRxXfer);
+
+void                           rxXfer_Register_CB(TI_HANDLE hRxXfer,tiUINT32 CallBackID,void *CBFunc,TI_HANDLE CBObj);
+
+void                           rxXfer_SetDoubleBufferAddr(TI_HANDLE hRxXfer, ACXDataPathParamsResp_t *pDataPathParams);
+
+#ifdef TI_DBG
+
+void rxXfer_ClearStats( TI_HANDLE hRxXfer );
+
+void rxXfer_PrintStats( TI_HANDLE hRxXfer );
+
+
+#endif /* TI_DBG */
+VOID RxXfer_ReStart(TI_HANDLE hRxXfer);
+
+
+#endif /* _RX_XFER_API_H */
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/txResult_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/txResult_api.h
new file mode 100644 (file)
index 0000000..13f1c41
--- /dev/null
@@ -0,0 +1,68 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txResult_api.h
+ *
+ *   PURPOSE: Tx result module API.
+ * 
+ ****************************************************************************/
+
+#ifndef _TX_RESULT_API_H
+#define _TX_RESULT_API_H
+
+
+#include "public_infoele.h"
+
+
+#define FW_TX_CMPLT_BLOCK_SIZE         16      /* Number of rows in the FW Tx-Result table */
+
+
+/* Public Function Definitions */
+
+TI_HANDLE      txResult_Create(TI_HANDLE hOs);
+TI_STATUS      txResult_Destroy(TI_HANDLE hTxResult);
+TI_STATUS      txResult_init(TI_HANDLE hTxResult, TI_HANDLE hReport, TI_HANDLE hTNETWIF, TI_HANDLE hFwEvent);
+TI_STATUS      txResult_restart(TI_HANDLE hTxResult);
+void           txResult_setHwInfo(TI_HANDLE hTxResult, ACXDataPathParamsResp_t *pDataPathParams);
+void           txResult_RegisterCB(TI_HANDLE hTxResult, tiUINT32 CallBackID, void *CBFunc, TI_HANDLE CBObj);
+void           txResult_printInfo(TI_HANDLE hTxResult);
+void           txResult_clearInfo(TI_HANDLE hTxResult);
+TI_STATUS   txResult_TxCmpltIntrCB (TI_HANDLE hTxResult);
+
+
+#endif /* _TX_RESULT_API_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/txXfer_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/FW_Transfer/inc/txXfer_api.h
new file mode 100644 (file)
index 0000000..323c0dd
--- /dev/null
@@ -0,0 +1,70 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  txXfer_api.h
+ *
+ *   PURPOSE: Tx Xfer module API.
+ * 
+ ****************************************************************************/
+
+#ifndef _TX_XFER_API_H
+#define _TX_XFER_API_H
+
+
+#include "public_infoele.h"
+#include "TNETW_Driver_types.h"
+
+
+/* Public Function Definitions */
+
+TI_HANDLE       txXfer_Create(TI_HANDLE hOs);
+TI_STATUS       txXfer_Destroy(TI_HANDLE hTxXfer);
+TI_STATUS       txXfer_init(TI_HANDLE hTxXfer, TI_HANDLE hReport, TI_HANDLE hTNETWIF, TI_HANDLE hTxResult);
+void                   txXfer_config(TI_HANDLE hTxXfer, TnetwDrv_InitParams_t *pInitParams);
+TI_STATUS       txXfer_restart(TI_HANDLE hTxXfer);
+void            txXfer_setHwInfo(TI_HANDLE hTxXfer, ACXDataPathParamsResp_t *pDataPathParams);
+systemStatus_e  txXfer_sendPacket(TI_HANDLE hTxXfer, txCtrlBlkEntry_t *pPktCtrlBlk);
+void            txXfer_RegisterCB(TI_HANDLE hTxResult, tiUINT32 CallBackID, void *CBFunc, TI_HANDLE CBObj);
+void            txXfer_printInfo(TI_HANDLE hTxXfer);
+void            txXfer_RegisterFailureEventCB( TI_HANDLE hTxXfer, void * failureEventCB, TI_HANDLE hFailureEventObj );
+
+
+#endif /* _TX_XFER_API_H */
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/MacServices_api.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/MacServices_api.h
new file mode 100644 (file)
index 0000000..a93a1f8
--- /dev/null
@@ -0,0 +1,589 @@
+/** \file MacServicesApi.h
+ *  \brief This file include public definitions for the MacServices module, comprising its API.
+ *  \author Yuval Adler
+ *  \date 6-Oct-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __MACSERVICESAPI_H__
+#define __MACSERVICESAPI_H__
+
+#include "commonTypes.h"
+#include "osApi.h"
+/*#include "whalCtrl_api.h"*/
+#include "scanTypes.h"
+#include "measurementTypes.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+typedef enum 
+{
+       POWERAUTHO_AWAKE_NOT_REQUIRED   = 0,
+       POWERAUTHO_AWAKE_REQUIRED               = 1
+} MacServices_powerAutho_AwakeRequired_e;
+
+typedef enum 
+{
+       POWERAUTHO_AWAKE_REASON_CONNECTION = 0,
+       POWERAUTHO_AWAKE_REASON_FIRST_BEACON    ,
+       POWERAUTHO_AWAKE_REASON_OUT_OS_SYNC,
+       POWERAUTHO_AWAKE_REASON_IBSS
+} MacServices_powerAutho_AwakeReason_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+ /** \typedef scan_srvCompleteCB_t
+  * \brief Defines the function prototype for the scan complete callback
+  */
+typedef void (*scan_srvCompleteCB_t) ( TI_HANDLE clientObj, UINT16 SPSStatus, BOOLEAN TSFError , TI_STATUS ScanStatus , TI_STATUS PSMode);
+
+/** \typedef measurement_srvCompleteCB_t
+ * \brief Defines the function prototype for the measurement complete callback
+ */
+typedef void (*measurement_srvCompleteCB_t)( TI_HANDLE clientObj, measurement_reply_t* msrReply );
+
+typedef void (*CmdResponseCB_t )(TI_HANDLE objectHandle,UINT16 MboxStatus);
+
+
+/*Power server callbacks*/
+typedef void (*MacServices_powerSaveCmdResponseCB_t )(TI_HANDLE cmdResponseHandle,UINT8 MboxStatus);
+/*typedef void (*powerSaveCmdResponseCB_t )(TI_HANDLE cmdResponseHandle,UINT8 MboxStatus);*/
+
+typedef void (*MacServices_powerSaveCmpltCB_t )(TI_HANDLE powerSaveCmpltHandle,UINT8 PSMode,UINT8 transStatus);
+/*typedef void (*powerSaveCmpltCB_t )(TI_HANDLE powerSaveCmpltHandle,UINT8 PSMode,UINT8 transStatus);*/
+
+
+
+
+
+/*
+ ***********************************************************************
+ *     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 hHalCtrl - handle to the HAL ctrl object.\n
+ * \param hHealthMonitor - can be send as NULL. \n
+ */
+void MacServices_init( TI_HANDLE hMacServices, TI_HANDLE hReport, TI_HANDLE hHalCtrl);
+
+void MacServices_config( TI_HANDLE hMacServices,TnetwDrv_InitParams_t *pInitParams);
+
+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, 
+                                     scan_srvCompleteCB_t 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 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 OK if successful (various, TBD codes if not).\n
+ */
+TI_STATUS MacServices_scanSRV_scan( TI_HANDLE hMacServices, scan_Params_t *scanParams, BOOLEAN bHighPriority,
+                        BOOLEAN bDriverMode, BOOLEAN bScanOnDriverModeError, 
+                                               PowerMgr_802_11_PsMode_e psRequest, BOOLEAN bSendNullData,
+                                               CmdResponseCB_t 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 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 OK if successful (various, TBD codes if not).\n
+ */
+TI_STATUS MacServices_scanSRV_stopScan( TI_HANDLE hMacServices, BOOLEAN bSendNullData , CmdResponseCB_t 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 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, UINT8 PSMode,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, 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 );
+
+#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 - OK / PENDING / 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,
+                                                                       PowerMgr_802_11_PsMode_e        psMode,
+                                                                       BOOL                                            sendNullDataOnExit,
+                                                                       void *                                          powerSaveCompleteCBObject,
+                                                                       MacServices_powerSaveCmpltCB_t                          powerSaveCompleteCB,
+                                                                       MacServices_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 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 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,
+                                                                       PowerMgr_802_11_PsMode_e        psMode,
+                                                                       BOOL                                            sendNullDataOnExit,
+                                                                       void *                                          powerSaveCBObject,
+                                                                       MacServices_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 - OK on success else 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,
+                                                                       BOOL                                            sendNullDataOnExit,
+                                                                       void *                                                  powerSaveCBObject,
+                                                                       MacServices_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 
+ * BOOLEAN - thre is in PS false otherwise.\n
+*/
+BOOLEAN 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) UINT16           - desierd rate .\n
+ * Return Value:\n 
+ * void.\n
+*/
+void MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices, 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: UINT16                - desierd rate .\n
+ * void.\n
+*/
+UINT16 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 OK if successful (various, TBD codes if not).\n
+ */ 
+TI_STATUS MacServices_measurementSRV_startMeasurement( TI_HANDLE hMacServices, 
+                                                       measurement_request_t* pMsrRequest,
+                                                                                                          UINT32 timeToRequestExpiryMs,
+                                                       CmdResponseCB_t cmdResponseCBFunc,
+                                                       TI_HANDLE cmdResponseCBObj,
+                                                       measurement_srvCompleteCB_t 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 OK if successful (various, TBD codes if not).\n
+ */
+TI_STATUS MacServices_measurementSRV_stopMeasurement( TI_HANDLE hMacServices,
+                                                                                                         BOOLEAN bSendNullData,
+                                                      CmdResponseCB_t 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, UINT8 PSMode,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, 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, 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, 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 );
+
+/**
+ * \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 );
+
+
+/**
+ * \author Victor Eisikovits\n
+ * \date 24-Nov-2005\n
+ * \brief updates the PowerPolicy and calcs the new MinPowerPolicy of the sustem
+ *
+ * Function Scope \e Public.\n
+ * \param      hMacServices - the handle to the MacServices module.
+ *                     aPowerPolicy - the new power policy.
+ */
+int MacServices_powerAutho_PowerPolicyUpdate(TI_HANDLE hMacServices, powerAutho_PowerPolicy_e aPowerPolicy);
+
+/**
+ * \author Victor Eisikovits\n
+ * \date 24-Nov-2005\n
+ * \brief send the min power level to the FW for the first time
+ *
+ * Function Scope \e Public.\n
+ * \param      hMacServices - the handle to the MacServices module.
+ */
+int MacServices_powerAutho_ExitFromInit(TI_HANDLE hMacServices);
+
+/**
+ * \author Victor Eisikovits\n
+ * \date 24-Nov-2005\n
+ * \brief updates the AwakeRequired and calcs the new MinPowerPolicy of the sustem
+ *
+ * Function Scope \e Public.\n
+ * \param      hMacServices - the handle to the MacServices module.
+ *                     aAwakeRequired - the awake required parameter,
+ *                             can be according to the enum required or not_required.  
+ */
+int MacServices_powerAutho_AwakeRequiredUpdate(TI_HANDLE hMacServices, MacServices_powerAutho_AwakeRequired_e aAwakeRequired, MacServices_powerAutho_AwakeReason_e aAwakeReason);
+
+int MacServices_powerAutho_EndRecovery(TI_HANDLE hMacServices);
+
+int powerAutho_Restart(TI_HANDLE hPowerAutho);
+
+#endif /* __MACSERVICESAPI_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/measurementSrvDbgPrint.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/measurementSrvDbgPrint.h
new file mode 100644 (file)
index 0000000..fd34059
--- /dev/null
@@ -0,0 +1,102 @@
+/** \file MeasurementSrv.h
+ *  \brief This file include definitions for the measurmeent SRV module debug print functions.
+ *  \author Ronen Kalish
+ *  \date 23-december-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#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, measurement_request_t *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, measurement_typeRequest_t* pMsrTypeRequest );
+
+#endif /* __MEASUREMENT_SRV__SBG_PRINT_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/measurementTypes.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/Export_Inc/measurementTypes.h
new file mode 100644 (file)
index 0000000..ab85aa0
--- /dev/null
@@ -0,0 +1,206 @@
+/** \file measurementTypes.h
+ *  \brief This file include data types definitions for the measurment SRV module.
+ *  \author Ronen Kalish
+ *  \date 08-November-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __MEASUREMENT_TYPES_H__
+#define __MEASUREMENT_TYPES_H__
+
+#include "osTIType.h"
+#include "ratesTypes.h"
+#include "osDot11.h"
+
+
+/*
+ ***********************************************************************
+ *  Constant definitions.
+ ***********************************************************************
+ */
+
+#define NOISE_HISTOGRAM_LENGTH              8
+#define MAX_NUM_OF_MSR_TYPES_IN_PARALLEL    3
+
+/* The size of the time frame in which we must start the */
+/* measurement request or give up */
+#define MSR_START_MAX_DELAY                 50
+
+/* In non unicast measurement requests a random delay */
+/* between 4 and 40 milliseconds */
+#define MSR_ACTIVATION_DELAY_RANDOM         36
+#define MSR_ACTIVATION_DELAY_OFFSET         4
+
+
+
+ /*
+ ***********************************************************************
+ *  Enums.
+ ***********************************************************************
+ */
+
+/** \enum measurement_type_e
+ * \brief enumerates the different measurement types
+ */
+typedef enum 
+{
+    MSR_TYPE_BASIC_MEASUREMENT              = 0,
+    MSR_TYPE_CCA_LOAD_MEASUREMENT           = 1,
+    MSR_TYPE_NOISE_HISTOGRAM_MEASUREMENT    = 2,
+    MSR_TYPE_BEACON_MEASUREMENT             = 3,
+    MSR_TYPE_FRAME_MEASUREMENT              = 4,
+    MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES       = 5
+} measurement_type_e;
+
+
+/** \enum measurement_scanMode_e
+ * \brief enumerates the different scan modes available for beacon measurement
+ */
+typedef enum
+{
+    MSR_SCAN_MODE_PASSIVE               = 0,
+    MSR_SCAN_MODE_ACTIVE                = 1,
+    MSR_SCAN_MODE_BEACON_TABLE          = 2,
+    MSR_SCAN_MODE_MAX_NUM_OF_SCAN_MODES = 3,
+} measurement_scanMode_e;
+
+
+typedef enum 
+{
+    MSR_FRAME_TYPE_NO_ACTIVE                = 0,
+    MSR_FRAME_TYPE_BROADCAST                = 1,
+    MSR_FRAME_TYPE_MULTICAST                = 2,
+    MSR_FRAME_TYPE_UNICAST                  = 3
+} measurement_frameType_e;
+
+
+typedef enum
+{
+    MSR_MODE_NONE                = 0,
+    MSR_MODE_EXC                 = 1,
+    MSR_MODE_SPECTRUM_MANAGEMENT = 2,
+} measurement_mode_e;
+
+typedef enum 
+{
+    MSR_REJECT_OTHER_REASON = 1, 
+    MSR_REJECT_INVALID_MEASUREMENT_TYPE,
+    MSR_REJECT_DTIM_OVERLAP,
+    MSR_REJECT_DURATION_EXCEED_MAX_DURATION,
+    MSR_REJECT_TRAFFIC_INTENSITY_TOO_HIGH,
+    MSR_REJECT_SCR_UNAVAILABLE,
+    MSR_REJECT_MAX_DELAY_PASSED,
+    MSR_REJECT_INVALID_CHANNEL,
+    MSR_REJECT_NOISE_HIST_FAIL,
+    MSR_REJECT_CHANNEL_LOAD_FAIL,
+    MSR_REJECT_EMPTY_REPORT,
+} measurement_rejectReason_e;
+
+ /*
+ ***********************************************************************
+ *  Unions.
+ ***********************************************************************
+ */
+
+/** \union measurement_replyValue_u
+ * \brief enumerates the different measurement types
+ */
+typedef union
+{
+    UINT8                                   CCABusyFraction;
+    UINT8                                   RPIDensity[ NOISE_HISTOGRAM_LENGTH ];   
+} measurement_replyValue_u;
+
+/***********************************************************************
+ *  Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct scan_normalChannelEntry_t
+ * \brief This structure contains single channel parameters for normal scan operation (inc. triggered)
+ */
+typedef struct
+{
+    measurement_type_e                      msrType;
+    measurement_scanMode_e                  scanMode;
+    UINT32                                  duration;
+    UINT8                                   reserved;
+} measurement_typeRequest_t;
+
+typedef struct
+{
+    radioBand_e                             band;
+    UINT8                                   channel;
+    UINT64                                  startTime;
+    UINT8                                   txPowerDbm;
+    UINT8                                   numberOfTypes;
+    measurement_typeRequest_t               msrTypes[ MAX_NUM_OF_MSR_TYPES_IN_PARALLEL ];
+} measurement_request_t;
+
+
+typedef struct
+{
+    measurement_type_e                      msrType;
+    UINT8                                   status;
+    measurement_replyValue_u                replyValue;
+    UINT8                                   reserved;
+} measurement_typeReply_t;
+
+typedef struct 
+{
+    UINT8                                   numberOfTypes;
+    measurement_typeReply_t                 msrTypes[ MAX_NUM_OF_MSR_TYPES_IN_PARALLEL ];
+} measurement_reply_t;
+
+PACKED_STRUCT( measurement_frameHdr_t ,
+
+    UINT16                                  dialogToken;
+    UINT8                                   activatioDelay;
+    UINT8                                   measurementOffset;
+);
+
+PACKED_STRUCT( measurement_frameRequest_t ,
+
+    measurement_frameHdr_t                  *hdr; 
+    measurement_frameType_e                 frameType;
+    UINT8                                   *requests;
+    INT32                                   requestsLen;
+);
+
+
+
+#endif /* __MEASUREMENT_TYPES_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/inc/MacServices.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/inc/MacServices.h
new file mode 100644 (file)
index 0000000..bc0aa05
--- /dev/null
@@ -0,0 +1,54 @@
+/** \file MacServices.h
+ *  \brief This file include internal definitions for the MacServices module
+ *  \author Yuval Adler
+ *  \date 6-Oct-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef __MACSERVICES_H__
+#define __MACSERVICES_H__
+
+typedef struct 
+{
+       TI_HANDLE hOS;
+       TI_HANDLE hScanSRV;
+    TI_HANDLE hMeasurementSRV;
+       TI_HANDLE hPowerSrv;
+       TI_HANDLE hPowerAutho;
+} MacServices_t ;
+
+#endif /* __MACSERVICES_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/inc/PowerAuthorization.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/inc/PowerAuthorization.h
new file mode 100644 (file)
index 0000000..5af75d6
--- /dev/null
@@ -0,0 +1,74 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**********************************************************************************/
+/*                                                                                */
+/*   MODULE:  PowerAuthorization.h                                                */
+/*   PURPOSE: PowerAuthorization api file                                                                                */
+/*                                                                                */
+/**********************************************************************************/
+#ifndef _POWER_AUTHORIZATION_H_
+#define _POWER_AUTHORIZATION_H_
+
+/*****************************************************************************
+ **         MACRO                                                             **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Types                                                             **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         External functions definitions                                  **
+ *****************************************************************************/
+TI_HANDLE powerAutho_Create(TI_HANDLE hOs);
+
+int powerAutho_Destroy(TI_HANDLE hPowerAutho);
+
+int powerAutho_Configure(TI_HANDLE hPowerAutho, TI_HANDLE hReport, TI_HANDLE hHalCtrl, powerAutho_PowerPolicy_e aPowerPolicy);
+
+
+#endif /* _POWER_AUTHORIZATION_H_ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MacServices.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MacServices.c
new file mode 100644 (file)
index 0000000..1fcb778
--- /dev/null
@@ -0,0 +1,359 @@
+/** \file MacServices.c
+ *  \brief This file include public definitions for the scan SRV module, comprising its API.
+ *  \author Yuval Adler
+ *  \date 6-Oct-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "report.h"
+#include "ScanSrv.h"
+#include "MeasurementSrv.h"
+#include "MacServices.h"
+#include "PowerSrv_API.h"
+#include "PowerAuthorization.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->hPowerAutho = 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;
+    }
+
+    /* create the powerAuthorization handle */  
+    pMacServices->hPowerAutho = powerAutho_Create(hOS);
+    if ( NULL == pMacServices->hPowerAutho )
+    {
+        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->hPowerAutho)
+        powerAutho_Destroy(pMacServices->hPowerAutho);
+
+    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 hHalCtrl) 
+{
+    MacServices_t *pMacServices = (MacServices_t*)hMacServices;
+    MacServices_scanSRV_init(hMacServices,hReport, hHalCtrl);
+    powerAutho_Configure(pMacServices->hPowerAutho, hReport, hHalCtrl, POWERAUTHO_POLICY_AWAKE);
+    MacServices_measurementSRV_init( pMacServices->hMeasurementSRV, hReport, hHalCtrl, pMacServices->hPowerSrv );
+    
+    if ( powerSrv_init( pMacServices->hPowerSrv,
+                            hReport,
+                    hHalCtrl) != OK )
+    {
+        
+        WLAN_OS_REPORT(("\n.....PowerSRV_init configuration failure \n"));
+        /*return 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, TnetwDrv_InitParams_t *pInitParams) 
+{
+    MacServices_t *pMacServices = (MacServices_t*)hMacServices;
+
+    
+    if (powerSrv_config(pMacServices->hPowerSrv,&pInitParams->PowerSrvInitParams)       !=      OK)
+    {
+        WLAN_OS_REPORT(("\n.....PowerSRV_config failure \n"));
+
+    }
+
+       MacServices_scanSrv_config( pMacServices, &(pInitParams->scanSrvInitParams) );
+}
+
+/****************************************************************************************
+ *                        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 - OK / PENDING / NOK.
+****************************************************************************************/
+
+TI_STATUS MacServices_powerSrv_SetPsMode(   TI_HANDLE   hMacServices,
+                                                    PowerMgr_802_11_PsMode_e    psMode,
+                                    BOOL                        sendNullDataOnExit,
+                                        void *                      powerSaveCompleteCBObject,
+                                        MacServices_powerSaveCmpltCB_t              powerSaveCompleteCB,
+                                        MacServices_powerSaveCmdResponseCB_t    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 - OK / PENDING / NOK.
+****************************************************************************************/
+TI_STATUS MacServices_powerSrv_ReservePS(   TI_HANDLE               hMacServices,
+                                    PowerMgr_802_11_PsMode_e psMode,
+                                    BOOL                    sendNullDataOnExit,
+                                    void *                  powerSaveCBObject,
+                                    MacServices_powerSaveCmpltCB_t      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 - OK / PENDING / NOK.
+****************************************************************************************/
+
+TI_STATUS MacServices_powerSrv_ReleasePS(   TI_HANDLE                   hMacServices,
+                                    BOOL                        sendNullDataOnExit,
+                                    void *                          powerSaveCBObject,
+                                    MacServices_powerSaveCmpltCB_t              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:    BOOLEAN - true if the SM is in PS state -  false otherwise
+****************************************************************************************/
+BOOLEAN 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:    BOOLEAN - true if the SM is in PS state -  false otherwise
+****************************************************************************************/
+void MacServices_powerSrv_SetRateModulation(TI_HANDLE hMacServices, UINT16  rate)
+{
+MacServices_t *pMacServices = (MacServices_t*)hMacServices;
+powerSrv_SetRateModulation( pMacServices->hPowerSrv,   rate);
+}
+UINT16 MacServices_powerSrv_GetRateModulation(TI_HANDLE hMacServices)
+{
+MacServices_t *pMacServices = (MacServices_t*)hMacServices;
+return powerSrv_GetRateModulation( pMacServices->hPowerSrv);
+}
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.c
new file mode 100644 (file)
index 0000000..c45e2c7
--- /dev/null
@@ -0,0 +1,1160 @@
+/** \file measurementSrv.c
+ *  \brief This file include the measurement SRV interface functions implementation.
+ *  \author Ronen Kalish
+ *  \date 09-November-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "measurementTypes.h"
+#include "MeasurementSrv.h"
+#include "MeasurementSrvSM.h"
+#include "report.h"
+#include "whalCtrl_api.h"
+#include "osApi.h"
+#include "MacServices.h"
+#include "paramIn.h"
+#include "public_event_mbox.h"
+#include "measurementSrvDbgPrint.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;
+    int i;
+
+    /* 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 ( 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;
+    }
+
+    /* allocate the timers */
+    pMeasurementSRV->hStartStopTimer = 
+        os_timerCreate( hOS, MacServices_measurementSRV_startStopTimerExpired, (TI_HANDLE)pMeasurementSRV );
+    if ( NULL == pMeasurementSRV->hStartStopTimer )
+    {
+        WLAN_OS_REPORT(("Failed to create measurement SRV FW guard timer.\n"));
+        MacServices_measurementSRV_destroy( pMeasurementSRV );
+        return NULL;
+    }
+
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        pMeasurementSRV->hRequestTimer[ i ]
+            = os_timerCreate( hOS, MacServices_measurementSRV_requestTimerExpired, (TI_HANDLE)pMeasurementSRV );
+        if ( NULL == pMeasurementSRV->hRequestTimer[ i ] )
+        {
+            WLAN_OS_REPORT(("Failed to create measurement SRV request timers.\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 hHALCtrl - handle to the HAL CTRL object.\n
+ * \param hPowerSaveSRV - handle to the power save SRV object.\n
+ */
+void MacServices_measurementSRV_init( TI_HANDLE hMeasurementSRV, TI_HANDLE hReport, TI_HANDLE hHALCtrl,
+                                      TI_HANDLE hPowerSaveSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       int i;
+
+    /* store handles */
+    pMeasurementSRV->hReport = hReport;
+    pMeasurementSRV->hHalCtrl = hHALCtrl;
+    pMeasurementSRV->hPowerSaveSRV = hPowerSaveSRV;
+
+    /* Initialize the state machine */
+    measurementSRVSM_init( hMeasurementSRV );
+
+    /* mark that all timers are not running */
+    pMeasurementSRV->bStartStopTimerRunning = FALSE;
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        pMeasurementSRV->bRequestTimerRunning[ i ] = FALSE;
+    }
+
+    /* register HAL callbacks */
+    /* Register and Enable the Measure Start event in HAL */
+    whalCtrl_EventMbox_RegisterForEvent( pMeasurementSRV->hHalCtrl, 
+                                         HAL_EVENT_MEASUREMENT_START,
+                                         (void *)MacServices_measurementSRV_measureStartCB, 
+                                         hMeasurementSRV );
+    whalCtrl_EventMbox_Enable( pMeasurementSRV->hHalCtrl, HAL_EVENT_MEASUREMENT_START );
+
+    /* Register and Enable the Measurement Complete event in HAL.
+    This event will be received when the Measurement duration expired,
+    or after Stop Measure command. */
+    whalCtrl_EventMbox_RegisterForEvent( pMeasurementSRV->hHalCtrl,
+                                         HAL_EVENT_MEASUREMENT_COMPLETE,
+                                         (void *)MacServices_measurementSRV_measureCompleteCB,
+                                         hMeasurementSRV );
+    whalCtrl_EventMbox_Enable( pMeasurementSRV->hHalCtrl, HAL_EVENT_MEASUREMENT_COMPLETE );
+
+    /* Register and Enable the AP Discovery Complete event in HAL */
+    whalCtrl_EventMbox_RegisterForEvent( pMeasurementSRV->hHalCtrl, 
+                                         HAL_EVENT_AP_DISCOVERY_COMPLETE, 
+                                         (void *)MacServices_measurementSRV_apDiscoveryCompleteCB, 
+                                         hMeasurementSRV );
+    whalCtrl_EventMbox_Enable( pMeasurementSRV->hHalCtrl, HAL_EVENT_AP_DISCOVERY_COMPLETE);
+
+
+    WLAN_REPORT_INIT( hReport, MEASUREMENT_SRV_MODULE_LOG,  (".....Measurement SRV configured successfully.\n") );
+}
+
+/**
+ * \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;
+       int i;
+
+       /* if a timer is running, stop it */
+       if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
+       {
+               os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+               pMeasurementSRV->bStartStopTimerRunning = FALSE;
+       }
+       for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+       {
+               if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+               {
+                       os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+                       pMeasurementSRV->bRequestTimerRunning[ i ] = FALSE;
+               }
+       }
+
+
+    /* Initialize the state machine */
+       /* initialize current state */
+       pMeasurementSRV->SMState = MSR_SRV_STATE_IDLE;
+
+    /* mark that all timers are not running */
+    pMeasurementSRV->bStartStopTimerRunning = FALSE;
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        pMeasurementSRV->bRequestTimerRunning[ i ] = 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;
+    int 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 ( NULL != pMeasurementSRV->hRequestTimer[ i ] )
+        {
+            if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+            {
+                os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+            }
+            os_timerDestroy( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+        }
+    }
+    if ( NULL != pMeasurementSRV->hStartStopTimer )
+    {
+        if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
+        {
+            os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+        }
+        os_timerDestroy( pMeasurementSRV->hOS, 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 OK if successful (various, TBD codes if not).\n
+ */ 
+TI_STATUS MacServices_measurementSRV_startMeasurement( TI_HANDLE hMacServices, 
+                                                       measurement_request_t* pMsrRequest,
+                                                                                                          UINT32 timeToRequestExpiryMs,
+                                                       CmdResponseCB_t cmdResponseCBFunc,
+                                                       TI_HANDLE cmdResponseCBObj,
+                                                       measurement_srvCompleteCB_t cmdCompleteCBFunc,
+                                                       TI_HANDLE cmdCompleteCBObj )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV;
+       int i;
+
+#ifdef TI_DBG
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: Received measurement request.\n", __FUNCTION__) );
+       measurementSRVPrintRequest( (TI_HANDLE)pMeasurementSRV, pMsrRequest );
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("time to expiry: %d ms, cmd response CB: 0x%x, cmd response handle: 0x%x\n",
+                                                         timeToRequestExpiryMs,
+                                                         cmdResponseCBFunc,
+                                                         cmdResponseCBObj) );
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("cmd complete CB: 0x%x, cmd complete handle: 0x%x\n",
+                                                         cmdCompleteCBFunc,
+                                                         cmdCompleteCBObj) );
+#endif
+
+       /* mark that request is in progress */
+    pMeasurementSRV->bInRequest = TRUE;
+
+       /* mark to send NULL data when exiting driver mode (can be changed to FALSE
+          only when explictly stopping the measurement */
+       pMeasurementSRV->bSendNullDataWhenExitPs = TRUE;
+
+    /* Nullify return status */
+    pMeasurementSRV->returnStatus = OK;
+
+    /* copy request parameters */
+    os_memoryCopy( pMeasurementSRV->hOS, (void *)&(pMeasurementSRV->msrRequest), (void *)pMsrRequest, 
+                   sizeof(measurement_request_t) );
+
+       /* 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 = 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 = 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 OK if successful (various, TBD codes if not).\n
+ */
+TI_STATUS MacServices_measurementSRV_stopMeasurement( TI_HANDLE hMacServices,
+                                                                                                         BOOLEAN bSendNullData,
+                                                      CmdResponseCB_t cmdResponseCBFunc,
+                                                      TI_HANDLE cmdResponseCBObj )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)((MacServices_t*)hMacServices)->hMeasurementSRV;
+    
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: Received measurement stop request.\n", __FUNCTION__) );
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("Send null data:%s, cmd response CB: 0x%x, cmd response handle: 0x%x\n",
+                                                         (TRUE == bSendNullData ? "Yes" : "No"),
+                                                         cmdResponseCBFunc,
+                                                         cmdResponseCBObj) );
+
+       /* store callbacks */
+    pMeasurementSRV->commandResponseCBFunc = cmdResponseCBFunc;
+    pMeasurementSRV->commandResponseCBObj = cmdResponseCBObj;
+
+       /* store NULL data indication */
+       pMeasurementSRV->bSendNullDataWhenExitPs = bSendNullData;
+
+    /* mark that current return status is OK */
+    pMeasurementSRV->returnStatus = OK;
+
+       /* mark that a stop request is in progress */
+       pMeasurementSRV->bInRequest = 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 = 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;
+    int i;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: Received FW reset indication.\n", __FUNCTION__) );
+
+       /* if a timer is running, stop it */
+    if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
+    {
+        os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+        pMeasurementSRV->bStartStopTimerRunning = FALSE;
+    }
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+        {
+            os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+            pMeasurementSRV->bRequestTimerRunning[ i ] = 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, UINT8 PSMode, UINT8 psStatus )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: Power save SRV CB called. PS mode:%d status: %d\n", 
+                                                         __FUNCTION__, PSMode, psStatus) );
+
+       /* if driver mode entry succeedded */
+    if ( ENTER_POWER_SAVE_SUCCESS == psStatus )
+    {
+        WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                                                                ("%s: PS successful.\n", __FUNCTION__) );
+
+        /* send a RIVER_MODE_SUCCESS event */
+        measurementSRVSM_SMEvent( (TI_HANDLE)pMeasurementSRV, &(pMeasurementSRV->SMState), 
+                                  MSR_SRV_EVENT_DRIVER_MODE_SUCCESS );
+    }
+    /* driver mode entry failed */
+    else
+    {
+        WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                                ("%s: PS failed, status %d.\n", __FUNCTION__, psStatus) );
+
+        /* Set the return status to 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;
+
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+        ("%s: measure start CB called.\n", __FUNCTION__) ); 
+       
+       /* stop the FW guard timer */
+       os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+       pMeasurementSRV->bStartStopTimerRunning = 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;
+
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                             ("%s: measure complete CB called.\n", __FUNCTION__));
+       
+       /* stop the FW guard timer */
+       os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+       pMeasurementSRV->bStartStopTimerRunning = 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;
+
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                             ("%s: AP Discovery complete CB called.\n", __FUNCTION__) ); 
+#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
+ */
+void MacServices_measurementSRV_startStopTimerExpired( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    int i;
+
+    WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                       ("%s: FW guard timer expired.\n", __FUNCTION__) );
+
+    /* mark that the FW guard timer is not running */
+    pMeasurementSRV->bStartStopTimerRunning = FALSE;
+
+    /* if any other timer is running - stop it */
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+        {
+            os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+            pMeasurementSRV->bRequestTimerRunning[ i ] = 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
+ */
+void MacServices_measurementSRV_requestTimerExpired( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    int 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 */
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: Request timer expired and request index from findMinDuration is -1?!?", __FUNCTION__) );
+               return;
+       }
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: request timer expired, request index: %d.\n", __FUNCTION__, requestIndex) );
+
+       /* mark that the timer is not running and that this request has completed */
+    pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = 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:
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: measure type %d not supported for request %d\n", 
+                                                       __FUNCTION__, 
+                                                       pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].msrType,
+                                                       requestIndex) );
+               break;
+    }
+
+       /* if no measurement are running and no CBs are pending, send ALL TYPES COMPLETE event */
+       if ( 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 TRUE if a beacon measurement is part of current request, FALSE otherwise.\n
+ */
+BOOLEAN measurementSRVIsBeaconMeasureIncluded( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    int i;
+
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        if ( MSR_TYPE_BEACON_MEASUREMENT == pMeasurementSRV->msrRequest.msrTypes[ i ].msrType )
+        {
+            return TRUE;
+        }
+    }
+    return 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
+ */
+int measurementSRVFindMinDuration( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    int i, minIndex;
+       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 ( 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, int requestIndex )
+{
+       measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       int status;
+
+
+       WLAN_REPORT_INFORMATION(pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                       ("%s: Sending AP Discovery Stop to the HAL...", __FUNCTION__) );
+
+       /* send stop AP discovery command */
+       status = whalCtrl_ApDiscoveryStop( pMeasurementSRV->hHalCtrl );
+       if ( OK != status )
+       {
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: status %d received from whalCtrl_ApDiscoveryStop\n", __FUNCTION__, 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, int requestIndex )
+{
+       measurementSRV_t*               pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       whalParamInfo_t                 whalParam;
+       TI_STATUS               status;
+
+    /* Getting the Medium Occupancy Register */
+       whalParam.paramType = HAL_CTRL_MEDIUM_OCCUPANCY_PARAM;
+    whalParam.content.interogateCmdCBParams.CB_Func = (void *)MacServices_measurementSRV_channelLoadParamCB;
+    whalParam.content.interogateCmdCBParams.CB_handle = hMeasurementSRV;
+    whalParam.content.interogateCmdCBParams.CB_buf = (UINT8*)(&(pMeasurementSRV->mediumOccupancyResults));
+       status = whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &whalParam );
+
+       if ( status != OK )
+    {
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: whalCtrl_GetParam returned status %d\n", __FUNCTION__, status) );
+
+               /* mark that the specific measurment type has failed */
+               pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = 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, int requestIndex )
+{
+    measurementSRV_t               *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       whalParamInfo_t             whalParam;
+    whalCtrl_noiseHistogram_t   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 = (TI_STATUS)whalCtrl_NoiseHistogramCmd( pMeasurementSRV->hHalCtrl, &pNoiseHistParams );
+    
+    if ( OK != status )
+       {
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: whalCtrl_NoiseHistogramCmd returned status %d\n", __FUNCTION__, status) );
+
+               /* mark that the specific measurment type has failed */
+               pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = NOK;
+
+               /* if all measurement types has finished, an event will be send by request timer expired */
+       }
+
+       /* Get measurement results */
+       whalParam.paramType = HAL_CTRL_NOISE_HISTOGRAM_PARAM;
+    whalParam.content.interogateCmdCBParams.CB_Func = (void *)MacServices_measurementSRV_noiseHistCallBack;
+    whalParam.content.interogateCmdCBParams.CB_handle = hMeasurementSRV;
+    whalParam.content.interogateCmdCBParams.CB_buf = (UINT8*)(&(pMeasurementSRV->noiseHistogramResults));
+       status = whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &whalParam );
+
+    if ( OK == status )
+    {
+               /* setting On the Waitng for Noise Histogram Results Bit */
+               pMeasurementSRV->pendingParamCBs |= MSR_SRV_WAITING_NOISE_HIST_RESULTS;
+
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                                                                ("%s: sent noise histogram stop command.\n",
+                                                                 __FUNCTION__) );
+       }
+    else
+    {
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: whalCtrl_GetParam returned status %d\n", __FUNCTION__, status) );
+
+               /* mark that the specific measurment type has failed */
+               pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = 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, 
+                                                                                                       UINT8* CB_buf )
+{
+    measurementSRV_t       *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    UINT32                  mediumUsageInMs, periodInMs;
+       int                                     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;
+       }
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: Channel load CB called, status:%d\n", __FUNCTION__, status) );
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n",
+                                                         CB_buf, &(pMeasurementSRV->mediumOccupancyResults)) );
+       WLAN_REPORT_HEX_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, CB_buf, sizeof(mediumOccupancy_t) );
+
+       /* 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 */
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: request index from measurementSRVFindIndexByType is -1?!?", __FUNCTION__) );
+               return;
+       }
+
+       if ( (OK == status) && (0 != pMeasurementSRV->mediumOccupancyResults.Period) )
+       {               
+               /* calculate results */
+               mediumUsageInMs = pMeasurementSRV->mediumOccupancyResults.MediumUsage / 1000;
+               periodInMs      = pMeasurementSRV->mediumOccupancyResults.Period / 1000;
+
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                                                                ("%s: MediumUsage = %d Period = %d\n", 
+                                                                 __FUNCTION__,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
+       {
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: channel load failed. Status=%d, period=%d\n",
+                                                       __FUNCTION__,
+                                                       status,
+                                                       pMeasurementSRV->mediumOccupancyResults.Period) );
+
+               /* mark result status */
+               pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = NOK;
+       }
+       
+       /* if no measurement are running and no CBs are pending, 
+          send ALL TYPES COMPLETE event */
+       if ( 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, 
+                                                                                                       UINT8* CB_buf )
+{
+#ifdef TI_DBG
+    measurementSRV_t *pMeasurementSRV = (measurementSRV_t*) hMeasurementSRV;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                       ("%s: Dummy Channel Load callback called (status = %d)\n", __FUNCTION__, 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, 
+                                                                                                  UINT8* CB_buf )
+{
+    measurementSRV_t               *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       UINT8                           index;
+    UINT32                      sumOfSamples;
+    int                                                        requestIndex;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: noise histogram CB called, status: %d\n", __FUNCTION__, status) );
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("result address (reported): 0x%x, result address (assumed): 0x%x, results (reported):\n",
+                                                         CB_buf, &(pMeasurementSRV->noiseHistogramResults)) );
+       WLAN_REPORT_HEX_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, CB_buf, sizeof(noiseHistogramResults_t) );
+
+       /* 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 */
+               WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                  ("%s: request index from measurementSRVFindIndexByType is -1?!?", __FUNCTION__) );
+               return;
+       }
+
+       if ( OK == status )
+       {
+               sumOfSamples = pMeasurementSRV->noiseHistogramResults.numOfLostCycles;
+               
+               /* Print For Debug */
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                       ("%s: numOfLostCycles = %d "
+                        "numOfTxHwGenLostCycles = %d numOfRxLostCycles = %d numOfExceedLastThresholdLostCycles = %d\n", 
+                       __FUNCTION__,
+                       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 */
+                       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                               ("%s: Counter #%d = %x\n", 
+                               __FUNCTION__, index, pMeasurementSRV->noiseHistogramResults.counters[index]));
+               }
+               
+               /* If there weren't enough samples --> Reject the Request */
+               if ( (sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles) < 
+                               NOISE_HISTOGRAM_THRESHOLD )
+               {
+                       WLAN_REPORT_WARNING( pMeasurementSRV->hReport,  MEASUREMENT_SRV_MODULE_LOG,
+                                                                ("%s: noise histogram CB, rejecting request because %d samples received.\n",
+                                                                 __FUNCTION__,
+                                                                 sumOfSamples - pMeasurementSRV->noiseHistogramResults.numOfLostCycles) );
+
+                       /* set negative result status */
+                       pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = 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;
+                       }
+
+                       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                                        ("%s: Valid noise histogram reply. RPIDensity: %d %d %d %d %d %d %d %d\n",
+                                                                         __FUNCTION__,
+                                                                         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
+       {
+               WLAN_REPORT_WARNING( pMeasurementSRV->hReport,  MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("%s: noise histogram CB with status: %d, rejecting request.\n",
+                                                         __FUNCTION__, status) );
+               /* set negative result status */
+               pMeasurementSRV->msrReply.msrTypes[ requestIndex ].status = NOK;
+       }
+       
+       /* if no measurement are running and no CBs are pending, 
+          send ALL TYPES COMPLETE event */
+       if ( 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)
+ */
+BOOLEAN measurementSRVIsMeasurementComplete( TI_HANDLE hMeasurementSRV )
+{
+       measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       int i;
+
+       /* verify that no request is currently running */
+       for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
+       {
+               if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+               {
+                       return FALSE;
+               }
+       }
+
+       /* verify that no CBs are pending */
+       if ( 0 != (pMeasurementSRV->pendingParamCBs & 
+                          (MSR_SRV_WAITING_CHANNEL_LOAD_RESULTS | MSR_SRV_WAITING_NOISE_HIST_RESULTS)) )
+       {
+               return FALSE;
+       }
+
+       return 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
+ */
+int measurementSRVFindIndexByType( TI_HANDLE hMeasurementSRV, measurement_type_e type )
+{
+       measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       int 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  = (failureEventCB_t)failureEventCB;
+    pMeasurementSRV->failureEventObj   = hFailureEventObj;
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.h
new file mode 100644 (file)
index 0000000..6d47998
--- /dev/null
@@ -0,0 +1,322 @@
+/** \file MeasurementSrv.h
+ *  \brief This file include private definitions for the Measurement SRV module.
+ *  \author Ronen Kalish
+ *  \date 08-November-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __MEASUREMENT_SRV_H__
+#define __MEASUREMENT_SRV_H__
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "measurementTypes.h"
+#include "MacServices_api.h"
+#include "fsm.h"
+#include "whalCtrl_api.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
+{
+       mediumOccupancy_t                       mediumOccupancyResults; /**< channel load results buffer */
+    noiseHistogramResults_t     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           hHalCtrl;                       /**< HAL ctrl object handle */
+    /* CB functions and objects */                                                        
+    measurement_srvCompleteCB_t measurmentCompleteCBFunc;
+                                                        /**< 
+                                                         * upper layer (measurement manager) measurement complete 
+                                                         * callback function
+                                                         */
+       TI_HANDLE           measurementCompleteCBObj;       /**< 
+                                                         * upper layer (measurement manager) measurement complete
+                                                         * callback object
+                                                         */
+       
+       CmdResponseCB_t         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 
+                                                                                                                */
+
+       failureEventCB_t                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 */
+    BOOLEAN             bRequestTimerRunning[ MAX_NUM_OF_MSR_TYPES_IN_PARALLEL ];
+                                                        /**< Indicates whether each request timer is running */
+    TI_HANDLE           hStartStopTimer;                /**< Timer for start / stop commands guard */
+    BOOLEAN             bStartStopTimerRunning;         /**< 
+                                                         * Indicates whether the start / stop command guard
+                                                         * timer is running
+                                                         */
+    /* Misc stuff */
+    BOOLEAN             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.
+                                                         */
+    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 */
+    measurement_request_t   msrRequest;                 /**< measurement request parameters */
+       measurement_reply_t             msrReply;                                       /**< measurement reply values */
+       UINT32                                  requestRecptionTimeStampMs;     /**< The time in which the request was received. */
+       UINT32                                  timeToRequestExpiryMs;          /**<
+                                                                                                                * The duration (in ms) from request receiption
+                                                                                                                * until it should actually start. Request is
+                                                                                                                * discarded if a longer period is required
+                                                                                                                */
+       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 hHALCtrl - handle to the HAL CTRL object.\n
+ * \param hPowerSaveSRV - handle to the power save SRV object.\n
+ */
+void MacServices_measurementSRV_init( TI_HANDLE hMeasurementSRV, TI_HANDLE hReport, TI_HANDLE hHALCtrl,
+                                      TI_HANDLE hPowerSaveSRV );
+
+/**
+ * \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 TRUE if a beacon measurement is part of current request, FALSE otherwise.\n
+ */
+BOOLEAN 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
+ */
+int 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, int 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, int 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, int 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)
+ */
+BOOLEAN 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
+ */
+int measurementSRVFindIndexByType( TI_HANDLE hMeasurementSRV, measurement_type_e 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/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.c
new file mode 100644 (file)
index 0000000..48afa46
--- /dev/null
@@ -0,0 +1,1148 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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
+ */
+
+#include "MeasurementSrvSM.h"
+#include "MeasurementSrv.h"
+#include "PowerSrv_API.h"
+#include "osApi.h"
+#include "report.h"
+#include "commonTypes.h"
+#include "fsm.h"
+#include "tnetwCommon.h"
+#include "paramIn.h"
+#include "public_commands.h"
+
+TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv );
+TI_STATUS actionNop( TI_HANDLE hMeasurementSrv );
+
+/**
+ * \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 OK if successful, 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, 
+                       (UINT8)MSR_SRV_NUM_OF_STATES, (UINT8)MSR_SRV_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)measurementSRVSM_SMEvent, pMeasurementSRV->hOS );
+}
+
+#ifdef TI_DBG
+/* state descriptions, for state machine logging */
+static char stateDesc[ MSR_SRV_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] = 
+{
+    "STATE_IDLE\0",
+    "STATE_WAIT_FOR_DRIVER_MODE\0",
+    "STATE_WAIT_FOR_MEASURE_START\0",
+    "STATE_MEASURE_IN_PROGRESS\0",
+    "STATE_WAIT_FOR_MEASURE_STOP\0"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ MSR_SRV_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] = 
+{
+    "EVENT_MEASURE_START_REQUEST\0",
+    "EVENT_DRIVER_MODE_SUCCESS\0",
+    "EVENT_DRIVER_MODE_FAILURE\0",
+    "EVENT_START_SUCCESS\0",
+    "EVENT_START_FAILURE\0",
+    "EVENT_ALL_TYPES_COMPLETE\0",
+    "EVENT_STOP_COMPLETE\0",
+    "EVENT_STOP_REQUEST\0",
+};
+#endif /* TI_DBG */
+
+/**
+ * \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 OK if successful, 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 = OK;
+    UINT8 nextState;
+
+    /* obtain the next state */
+    status = fsm_GetNextState( pMeasurementSRV->SM, (UINT8)*currentState, (UINT8)event, &nextState );
+    if ( status != OK )
+    {
+        WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                ("%s: State machine error, failed getting next state\n", __FUNCTION__) );
+        return NOK;
+    }
+
+#ifdef TI_DBG
+    /* report the move */
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+            ("%s: <%s, %s> --> %s\n", __FUNCTION__,
+                    stateDesc[(UINT8)*currentState],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+#endif
+
+    /* move */
+    return fsm_Event( pMeasurementSRV->SM, (UINT8*)currentState, (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 OK.\n
+ */
+TI_STATUS measurementSRVSM_requestDriverMode( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t    *pMeasurementSRV  = (measurementSRV_t*)hMeasurementSRV;
+    TI_STATUS           PSStatus;
+    whalParamInfo_t     paramInfo;
+
+    /* get the current channel */
+    paramInfo.paramType = HAL_CTRL_CURRENT_CHANNEL;
+    whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &paramInfo );
+    
+    /* 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,
+                                       TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB );
+    }
+    else
+    {
+        /* Switch Power Save SRV to driver mode with PS mode */      
+        PSStatus = powerSrv_ReservePS( pMeasurementSRV->hPowerSaveSRV, POWER_SAVE_ON,
+                                       TRUE, hMeasurementSRV, MacServices_measurementSRV_powerSaveCB );
+    }
+
+    switch (PSStatus)
+    {
+        case POWER_SAVE_802_11_IS_CURRENT:
+            WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                                     ("%s: Driver mode entered successfully\n",__FUNCTION__) );
+            /* send a power save success event */
+            return measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
+                                             MSR_SRV_EVENT_DRIVER_MODE_SUCCESS );
+/*            break; */
+    
+        case PENDING:
+        case OK:
+            WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                     ("%s: Driver mode pending\n", __FUNCTION__) );
+            break;
+        
+        default: /* Error */
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                               ("%s: Error %d when requesting driver mode\n",__FUNCTION__,PSStatus) );
+
+            /* Set the return status to NOK */
+            pMeasurementSRV->returnStatus = PSStatus;
+
+            /* send a power save failure event */
+            measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
+                                      MSR_SRV_EVENT_DRIVER_MODE_FAILURE );
+            break;
+    }
+    
+    return 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 OK.\n
+ */
+TI_STATUS measurementSRVSM_requestMeasureStart( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t                    *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    whalCtrl_MeasurementParameters_t    pMeasurementCmd;
+    TI_STATUS                           status;
+    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 )
+    {
+        int i;
+
+        WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                           ("%s: request time has expired, request expiry time:%d, current time:%d\n",
+                            __FUNCTION__,
+                            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 = NOK;
+        }
+
+        /* send a measurement complete event */
+        measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
+                                  MSR_SRV_EVENT_STOP_COMPLETE );
+        
+        return OK;
+    }
+
+    pMeasurementCmd.channel = pMeasurementSRV->msrRequest.channel;
+    pMeasurementCmd.band = pMeasurementSRV->msrRequest.band;
+    pMeasurementCmd.duration = 0; /* Infinite */
+
+    if ( measurementSRVIsBeaconMeasureIncluded( hMeasurementSRV ) )
+    {  /* Beacon Measurement is one of the types */
+
+               /* get the current channel */
+               whalParamInfo_t                                         paramInfo;
+
+               paramInfo.paramType = HAL_CTRL_CURRENT_CHANNEL;
+               whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &paramInfo );
+
+               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 = (TI_STATUS)whalCtrl_measurementCmd( pMeasurementSRV->hHalCtrl, &pMeasurementCmd,
+                                      (void *)measurementSRVSM_requestMeasureStartResponseCB, 
+                                      pMeasurementSRV );
+    
+    if ( OK != status )
+    {
+        WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                           ("%s: Failed to send measurement start command, statud=%d,\n",
+                            __FUNCTION__, 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 );
+    }
+
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                             ("%s: measure start command sent. Params:\n channel=%d, band=%d, duration=%d, \n configOptions=0x%x, filterOptions=0x%x, status=%d, \n",
+                             __FUNCTION__,
+                             pMeasurementCmd.channel,
+                             pMeasurementCmd.band,
+                             pMeasurementCmd.duration,
+                             pMeasurementCmd.ConfigOptions,
+                             pMeasurementCmd.FilterOptions,
+                             status) );
+
+    /* start the FW guard timer */
+    pMeasurementSRV->bStartStopTimerRunning = TRUE;
+    os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer, MSR_FW_GUARD_TIME, FALSE );
+  
+    return 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 OK.\n
+ */
+TI_STATUS measurementSRVSM_startMeasureTypes( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t                    *pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    UINT8                               requestIndex, rangeIndex;
+    INT8                                rangeUpperBound;
+    whalParamInfo_t                     whalParam;
+    TI_STATUS                           status;
+    whalCtrl_noiseHistogram_t           pNoiseHistParams;
+    whalCtrl_ApDiscoveryParameters_t    pApDiscoveryParams;
+    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 )
+    {
+        int i;
+
+        WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                           ("%s: request time has expired, request expiry time:%d, current time:%d\n",
+                            __FUNCTION__,
+                            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 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 */
+            whalParam.paramType = HAL_CTRL_MEDIUM_OCCUPANCY_PARAM;
+            whalParam.content.interogateCmdCBParams.CB_Func = (void *)MacServices_measurementSRV_dummyChannelLoadParamCB;
+            whalParam.content.interogateCmdCBParams.CB_handle = hMeasurementSRV;
+            whalParam.content.interogateCmdCBParams.CB_buf = 
+                    (UINT8*)(&(pMeasurementSRV->mediumOccupancyResults));
+            status = whalCtrl_GetParam( pMeasurementSRV->hHalCtrl, &whalParam );
+            if( OK == status  )
+            {
+                WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                                         ("%s: Medium Usage has been nullified, starting timer.\n", __FUNCTION__) );
+
+                /* Start Timer */
+                os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ requestIndex ],
+                               pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration, FALSE );
+                pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TRUE;
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                   ("%s: whalCtrl_GetParam (for channel load) returned status %d\n", __FUNCTION__, 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 = whalCtrl_convertRSSIToRxLevel( pMeasurementSRV->hHalCtrl, -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 */
+            WLAN_REPORT_INFORMATION(pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                    ("%s:Noise histogram Measurement Ranges:\n%d %d %d %d %d %d %d %d\n", __FUNCTION__,
+                            (INT8) pNoiseHistParams.ranges[0], (INT8) pNoiseHistParams.ranges[1],
+                            (INT8) pNoiseHistParams.ranges[2], (INT8) pNoiseHistParams.ranges[3],
+                            (INT8) pNoiseHistParams.ranges[4], (INT8) pNoiseHistParams.ranges[5],
+                            (INT8) pNoiseHistParams.ranges[6], (INT8) pNoiseHistParams.ranges[7]));
+
+            /* Send a Start command to the FW */
+            status = (TI_STATUS)whalCtrl_NoiseHistogramCmd( pMeasurementSRV->hHalCtrl, &pNoiseHistParams );
+
+            if ( OK == status )
+            {
+                /* Print for Debug */
+                WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                                         ("%s: Sent noise histogram command. Starting timer\n",
+                                          __FUNCTION__) );
+
+                /* Start Timer */
+                os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ requestIndex ], 
+                               pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration, FALSE );
+                pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TRUE;
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                   ("%s: whalCtrl_NoiseHistogramCmd returned status %d\n", __FUNCTION__, 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 and scan mode go into the scan option field */
+            if ( RADIO_BAND_5_0_GHZ == pMeasurementSRV->msrRequest.band )
+            {
+                pApDiscoveryParams.scanOptions |= SCAN_5GHZ_BAND;
+            }
+
+            if ( MSR_SCAN_MODE_PASSIVE == pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].scanMode )
+            {
+                pApDiscoveryParams.scanOptions |= SCAN_PASSIVE;
+            }
+
+            /* Send AP Discovery command */
+            status = (TI_STATUS)whalCtrl_ApDiscoveryCmd( pMeasurementSRV->hHalCtrl, &pApDiscoveryParams );
+
+            if ( OK == status )
+            {
+                WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                          ("%s: AP discovery command sent. Params:\n scanDuration=%d, scanOptions=%d,"
+                           "numOfProbRqst=%d, txdRateSet=%d, txPowerDbm=%d, configOptions=%d, filterOptions=%d\n"
+                           "Starting timer...\n", 
+                          __FUNCTION__,
+                          pApDiscoveryParams.scanDuration, pApDiscoveryParams.scanOptions,
+                          pApDiscoveryParams.numOfProbRqst, pApDiscoveryParams.txdRateSet,
+                          pApDiscoveryParams.txPowerDbm, pApDiscoveryParams.ConfigOptions,
+                          pApDiscoveryParams.FilterOptions) );
+        
+                /* Start Timer */
+                os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ requestIndex ], 
+                               pMeasurementSRV->msrRequest.msrTypes[ requestIndex ].duration, FALSE);
+                pMeasurementSRV->bRequestTimerRunning[ requestIndex ] = TRUE;
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                   ("%s: whalCtrl_ApDiscoveryCmd returned status %d\n", __FUNCTION__, status) );
+            }
+            break;
+
+        case MSR_TYPE_BASIC_MEASUREMENT: /* not supported in current implemntation */
+        case MSR_TYPE_FRAME_MEASUREMENT: /* not supported in current implemntation */
+        default:
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                               ("%s: Measurement type %d is not supported\n", 
+                               __FUNCTION__, 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 ( TRUE == measurementSRVIsMeasurementComplete( hMeasurementSRV ) )
+    {
+        /* send the event */
+        measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), 
+                                  MSR_SRV_EVENT_ALL_TYPES_COMPLETE );
+    }
+
+    return 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 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 ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
+    {
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,  ("***** STOP TIMER 6 *****\n") );
+        os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+        pMeasurementSRV->bStartStopTimerRunning = FALSE;
+    }
+
+    /* Send Measurement Stop command to the FW */
+    status = (TI_STATUS)whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl, 
+                                       (void *) pMeasurementSRV->commandResponseCBFunc,
+                                       pMeasurementSRV->commandResponseCBObj );
+
+    pMeasurementSRV->commandResponseCBFunc = NULL;
+    pMeasurementSRV->commandResponseCBObj = NULL;
+    
+    if ( OK != status )
+    {
+        WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                           ("%s: Failed to send measurement stop command, statud=%d,\n",
+                            __FUNCTION__, status) );
+
+        /* send a measurement complete event - since it can't be stopped */
+        measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState), MSR_SRV_EVENT_STOP_COMPLETE );
+        return OK;
+    }
+
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                             ("%s: measure stop command sent.\n", __FUNCTION__) );
+
+    /* start the FW guard timer */
+    pMeasurementSRV->bStartStopTimerRunning = TRUE;
+    os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer, MSR_FW_GUARD_TIME, FALSE );
+
+    return 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 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, OK );
+    }
+
+    /* call the complete CB */
+    if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
+    {
+        pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, 
+                                                   &(pMeasurementSRV->msrReply) );
+    }
+
+    return 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 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 ( FALSE == pMeasurementSRV->bInRequest )
+    {
+        WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                           ("%s: stop from wait for driver mode: not within a request context?!? \n", __FUNCTION__) );
+
+        /* 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 )
+        {
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                               ("%s: stop from wait for driver mode: command response CB is not NULL?!? \n", __FUNCTION__) );
+            pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, OK );
+
+            pMeasurementSRV->commandResponseCBFunc = NULL;
+            pMeasurementSRV->commandResponseCBObj = NULL;
+        }
+        /* call the complete CB */
+        if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
+        {
+            /* mark that all types has failed */
+            int i;
+            for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+            {
+                pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
+            }
+            /* call the complete CB */
+            pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, 
+                                                       &(pMeasurementSRV->msrReply) );
+        }
+        else
+        {
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: stop from wait for driver mode and response CB is NULL!!!\n",
+                                __FUNCTION__) );
+        }
+    }
+    /* 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) */
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: stop from wait for driver mode - within request context and command response is not NULL?!?\n", __FUNCTION__) );
+
+            whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl, (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 */
+            int i;
+            for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+            {
+                pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
+            }
+            /* call the complete CB */
+            pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, 
+                                                       &(pMeasurementSRV->msrReply) );
+        }
+    }
+
+    return 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 OK.\n
+ */
+TI_STATUS measurementSRVSM_stopFromWaitForMeasureStart( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    int i;
+
+    /* mark that all types has failed */
+    for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
+    {
+        pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
+    }
+
+    /* call the ordinary stop function (will send a measure stop command to FW) */
+    measurementSRVSM_requestMeasureStop( hMeasurementSRV );
+
+    return 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 OK.\n
+ */
+TI_STATUS measurementSRVSM_stopFromMeasureInProgress( TI_HANDLE hMeasurementSRV )
+{
+    measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+    whalCtrl_noiseHistogram_t   pNoiseHistParams;
+    TI_STATUS                   status;
+    int                         i;
+
+    /* stop all running measure types */
+    for ( i = 0; i < pMeasurementSRV->msrRequest.numberOfTypes; i++ )
+    {
+        if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+        {
+            /* stop timer */
+            os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+            pMeasurementSRV->bRequestTimerRunning[ i ] = FALSE;
+
+            /* if necessary, stop measurement type */
+            switch ( pMeasurementSRV->msrRequest.msrTypes[ i ].msrType )
+            {
+            case MSR_TYPE_BEACON_MEASUREMENT:
+                /* send stop AP discovery command */
+                status = (TI_STATUS)whalCtrl_ApDiscoveryStop( pMeasurementSRV->hHalCtrl );
+                if ( OK != status )
+                {
+                    WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                       ("%s: whalCtrl_ApDiscoveryStop returned status %d\n", __FUNCTION__, 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 = (TI_STATUS)whalCtrl_NoiseHistogramCmd( pMeasurementSRV->hHalCtrl, &pNoiseHistParams );
+
+                if ( OK != status )
+                {
+                    WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                       ("%s: whalCtrl_NoiseHistogramCmd returned status %d\n", __FUNCTION__, 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:
+                WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                   ("%s: unsupported measurement type: %d\n",
+                                    __FUNCTION__,
+                                    pMeasurementSRV->msrRequest.msrTypes[ i ].msrType) );
+                break;
+            }
+
+            /* mark that measurement has failed */
+            pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
+        }
+    }
+
+    /* Send Measurement Stop command to the FW */
+    status = (TI_STATUS)whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl,
+                                       (void *)pMeasurementSRV->commandResponseCBFunc,
+                                       pMeasurementSRV->commandResponseCBObj );
+
+    pMeasurementSRV->commandResponseCBFunc = NULL;
+    pMeasurementSRV->commandResponseCBObj = NULL;
+    
+    if ( OK != status )
+    {
+        WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                           ("%s: Failed to send measurement stop command, statud=%d,\n",
+                            __FUNCTION__, status) );
+
+        /* send a measurement complete event - since it can't be stopped */
+        measurementSRVSM_SMEvent( hMeasurementSRV, &(pMeasurementSRV->SMState),
+                                  MSR_SRV_EVENT_STOP_COMPLETE );
+        return OK;
+    }
+
+    WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                             ("%s: measure stop command sent.\n") );
+
+    /* start the FW guard timer */
+    pMeasurementSRV->bStartStopTimerRunning = TRUE;
+    os_timerStart( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer, MSR_FW_GUARD_TIME, FALSE );
+
+    return 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 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 ( FALSE == pMeasurementSRV->bInRequest )
+    {
+        /* if a response CB is available (GWSI) call it */
+        if ( NULL != pMeasurementSRV->commandResponseCBFunc )
+        {
+            pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, NOK );
+        }
+
+        /* if a complete CB is available (both GWSI and TI driver), call it */
+        if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
+        {
+            /* mark that all types has failed */
+            int i;
+            for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+            {
+                pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
+            }
+            /* call the complete CB */
+            pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, 
+                                                       &(pMeasurementSRV->msrReply) );
+        }
+        else
+        {
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: driver mode failure and complete CB is NULL!!!\n",
+                                __FUNCTION__) );
+        }
+    }
+
+    return 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 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 ( FALSE == pMeasurementSRV->bInRequest )
+    {
+        /* if a response CB is available (GWSI) call it */
+        if ( NULL != pMeasurementSRV->commandResponseCBFunc )
+        {
+            pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, NOK );
+        }
+
+        /* if a complete CB is available (both GWSI and TI driver), call it */
+        if ( NULL != pMeasurementSRV->measurmentCompleteCBFunc )
+        {
+            /* mark that all types has failed */
+            int i;
+            for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+            {
+                pMeasurementSRV->msrReply.msrTypes[ i ].status = NOK;
+            }
+            /* call the complete CB */
+            pMeasurementSRV->measurmentCompleteCBFunc( pMeasurementSRV->measurementCompleteCBObj, 
+                                                       &(pMeasurementSRV->msrReply) );
+        }
+        else
+        {
+            WLAN_REPORT_ERROR( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: Start measurement failure and response and complete CBs are NULL!!!\n",
+                                __FUNCTION__) );
+        }
+    }
+
+    return OK;
+}
+
+
+
+void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, UINT16 uMboxStatus)
+{
+       measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       int i;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: FW has responded with CMD_STATUS = %d\n",
+                                __FUNCTION__, uMboxStatus) );
+
+       if (uMboxStatus == OK) 
+       {
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: FW has responded with CMD_STATUS_SUCCESS!\n",
+                                __FUNCTION__) );
+
+               if ( NULL != pMeasurementSRV->commandResponseCBFunc )
+        {
+            pMeasurementSRV->commandResponseCBFunc( pMeasurementSRV->commandResponseCBObj, OK );
+        }
+       }
+       else
+       {
+               if (uMboxStatus == SG_REJECT_MEAS_SG_ACTIVE) 
+               {
+                       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: FW has responded with CMD_STATUS_REJECT_MEAS_SG_ACTIVE!\n",
+                                __FUNCTION__) );
+               }
+
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                               ("%s: FW has responded with CMD_STATUS NOK!!!\n",
+                                __FUNCTION__) );
+
+
+               /* if a timer is running, stop it */
+               if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
+               {
+                       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,  ("***** STOP TIMER 8 *****\n") );
+                       os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+                       pMeasurementSRV->bStartStopTimerRunning = FALSE;
+               }
+               for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+               {
+                       if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+                       {
+                               os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+                               pMeasurementSRV->bRequestTimerRunning[ i ] = 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 OK.\n
+ */
+TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hMeasurementSrv )
+{
+    measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv;
+
+    WLAN_REPORT_WARNING( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                         ("%s: sending unnecessary stop measurement command to FW...\n", __FUNCTION__) );
+
+    /* send a stop command to FW, to obtain a different context in ehich to cal the command response CB */
+    whalCtrl_measurementStop( pMeasurementSRV->hHalCtrl, (void *)pMeasurementSRV->commandResponseCBFunc,
+                              pMeasurementSRV->commandResponseCBObj );
+
+    pMeasurementSRV->commandResponseCBFunc = NULL;
+    pMeasurementSRV->commandResponseCBObj = NULL;
+
+    return 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 OK.\n
+ */
+TI_STATUS actionUnexpected( TI_HANDLE hMeasurementSrv ) 
+{
+    measurementSRV_t *pMeasurementSRV = (measurementSRV_t*)hMeasurementSrv;
+    int i;
+
+    WLAN_REPORT_SM( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG, 
+                    ("%s: measurement SRV state machine error, unexpected Event\n", __FUNCTION__) );
+
+    if ( TRUE == pMeasurementSRV->bStartStopTimerRunning )
+    {
+               WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,  ("***** STOP TIMER 7 *****\n") );
+        os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hStartStopTimer );
+        pMeasurementSRV->bStartStopTimerRunning = FALSE;
+    }
+
+    for ( i = 0; i < MAX_NUM_OF_MSR_TYPES_IN_PARALLEL; i++ )
+    {
+        if ( TRUE == pMeasurementSRV->bRequestTimerRunning[ i ] )
+        {
+            os_timerStop( pMeasurementSRV->hOS, pMeasurementSRV->hRequestTimer[ i ] );
+            pMeasurementSRV->bRequestTimerRunning[ i ] = 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 = NOK;
+    
+    return 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 OK.\n
+ */
+TI_STATUS actionNop( TI_HANDLE hMeasurementSrv )
+{   
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.h
new file mode 100644 (file)
index 0000000..35c12fb
--- /dev/null
@@ -0,0 +1,267 @@
+/** \file MeasurementSrv.h
+ *  \brief This file include private definitions for the Measurement SRV state machine.
+ *  \author Ronen Kalish
+ *  \date 08-November-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __MEASUREMENT_SRV_SM_H__
+#define __MEASUREMENT_SRV_SM_H__
+
+#include "osTIType.h"
+#include "commonTypes.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 OK if successful, 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 OK if successful, 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 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 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 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 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 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 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 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 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 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 OK.\n
+ */
+TI_STATUS measurementSRVSM_measureStartFailure( TI_HANDLE hMeasurementSRV );
+
+
+void measurementSRVSM_requestMeasureStartResponseCB(TI_HANDLE hMeasurementSRV, UINT16 uMboxStatus);
+
+/**
+ * \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 OK.\n
+ */
+TI_STATUS measurementSRVSRVSM_dummyStop( TI_HANDLE hmeasurementSrv );
+
+#endif /* __MEASUREMENT_SRV_SM_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/measurementSrvDbgPrint.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/MeasurementSRV/measurementSrvDbgPrint.c
new file mode 100644 (file)
index 0000000..cadf4c2
--- /dev/null
@@ -0,0 +1,119 @@
+/** \file measurementSrvDbgPrint.c
+ *  \brief This file include variuos measurement SRV debug print facilities
+ *  \author Ronen Kalish
+ *  \date 23-December-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "MeasurementSrvSM.h"
+#include "MeasurementSrv.h"
+#include "measurementSrvDbgPrint.h"
+#include "report.h"
+
+#ifdef TI_DBG    
+static char bandDesc[ RADIO_BAND_NUM_OF_BANDS ][ MAX_DESC_STRING_LEN ] =
+{
+       "2.4 GHz",
+       "5.0 GHz"
+};
+
+static char measurementTypeDesc[ MSR_TYPE_MAX_NUM_OF_MEASURE_TYPES ][ MAX_DESC_STRING_LEN ] =
+{
+       "basic measurement",
+       "channel load measurement",
+       "noise histogram measurement",
+       "beacon measurement",
+       "frame measurement"
+};
+
+static char measurementScanModeTypeDesc[ MSR_SCAN_MODE_MAX_NUM_OF_SCAN_MODES ][ MAX_DESC_STRING_LEN ] =
+{
+       "scan mode passive",
+       "scan mode active",
+       "scan mode beacon table"
+};
+#endif /* TI_DBG */
+
+/** 
+ * \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, measurement_request_t *pMsrRequest )
+{
+#ifdef TI_DBG    
+       measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+       int i;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("Measurement request:\n") );
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("band: %s, channel:%d, TX power level: %d, start time: %x-%x\n", 
+                                                         bandDesc[ 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, measurement_typeRequest_t* pMsrTypeRequest )
+{
+#ifdef TI_DBG    
+       measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;
+
+       WLAN_REPORT_INFORMATION( pMeasurementSRV->hReport, MEASUREMENT_SRV_MODULE_LOG,
+                                                        ("Measurement type request: type: %s, duration:%d, scan mode: %s, reserved: %d\n", 
+                                                         measurementTypeDesc[ pMsrTypeRequest->msrType ], pMsrTypeRequest->duration,
+                                                         measurementScanModeTypeDesc[ pMsrTypeRequest->scanMode ], pMsrTypeRequest->reserved) );
+#endif /* TI_DBG */
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization.c
new file mode 100644 (file)
index 0000000..fe9471a
--- /dev/null
@@ -0,0 +1,333 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/**********************************************************************************/
+/*                                                                                */
+/*   MODULE:  PowerAuthorization.c                                                */
+/*   PURPOSE: PowerAuthorization implementation module                                                   */
+/*                                                                                */
+/**********************************************************************************/
+#include "whalCtrl_api.h"
+#include "report.h"
+#include "MacServices_api.h"
+#include "MacServices.h"
+#include "PowerAuthorization.h"
+#include "PowerAuthorization_internal.h"
+
+/****************************************************************************
+ *                      powerAutho_Create()
+ ****************************************************************************
+ * DESCRIPTION:        
+ * 
+ * INPUTS:     hOs - the handle to the OS layer
+ *                     hReport - the handle to the report module
+ *                     hELPCtrl - the handle to the ELPCtrl module
+ *             
+ * 
+ * OUTPUT:     the context of the PowerAuthorization module
+ * 
+ * RETURNS:    the context of the PowerAuthorization module (NULL if error)
+ ****************************************************************************/
+TI_HANDLE powerAutho_Create(TI_HANDLE hOs)
+{               
+       powerAutho_t *pObj;
+
+       pObj = os_memoryAlloc(hOs, sizeof(powerAutho_t));
+       if (pObj == NULL)
+       {
+               WLAN_OS_REPORT(("FATAL ERROR: powerAutho_Create(): Error allocating context\n"));
+               return NULL;            
+       }
+
+       os_memoryZero(hOs, pObj, sizeof(powerAutho_t));
+
+       pObj->hOs = hOs;
+       pObj->hReport = NULL;
+       pObj->hHalCtrl = NULL;
+
+       /* set as 'before init complete' */
+       pObj->initComplete = FALSE; 
+       
+       pObj->m_AwakeRequired = 0;
+       pObj->m_PowerPolicy = POWERAUTHO_POLICY_PD;
+       pObj->m_MinPowerLevel = POWERAUTHO_POLICY_PD;
+
+       return pObj;
+}
+
+
+/****************************************************************************
+ *                      powerAutho_Destroy()
+ ****************************************************************************
+ * DESCRIPTION:        
+ * 
+ * INPUTS:     hPowerAutho - the handle to the PowerAuthorization module.
+ *             
+ * 
+ * OUTPUT:     
+ * 
+ * RETURNS:    OK
+ ****************************************************************************/
+int powerAutho_Destroy(TI_HANDLE hPowerAutho)
+{                      
+       powerAutho_t *pPowerAutho = (powerAutho_t*)hPowerAutho;
+
+       if (pPowerAutho)
+               os_memoryFree(pPowerAutho->hOs, pPowerAutho, sizeof(powerAutho_t));
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      powerAutho_Configure()
+ ****************************************************************************
+ * DESCRIPTION:        
+ * 
+ * INPUTS:     hPowerAutho - the handle to the PowerAuthorization module.
+ *                     aPowerPolicy - the power policy to configure.
+ *             
+ * 
+ * OUTPUT:     
+ * 
+ * RETURNS:    OK
+ ****************************************************************************/
+int powerAutho_Configure(TI_HANDLE hPowerAutho, TI_HANDLE hReport, TI_HANDLE hHalCtrl, powerAutho_PowerPolicy_e aPowerPolicy)
+{
+       powerAutho_t *pPowerAutho = (powerAutho_t*)hPowerAutho;
+
+       pPowerAutho->m_PowerPolicy = aPowerPolicy;
+
+       pPowerAutho->m_ElpCtrl_Mode_LUT[POWERAUTHO_POLICY_AWAKE] =      ELPCTRL_MODE_KEEP_AWAKE;
+       pPowerAutho->m_ElpCtrl_Mode_LUT[POWERAUTHO_POLICY_PD] =         ELPCTRL_MODE_KEEP_AWAKE;
+       pPowerAutho->m_ElpCtrl_Mode_LUT[POWERAUTHO_POLICY_ELP] =        ELPCTRL_MODE_NORMAL;
+
+       pPowerAutho->hReport = hReport;
+       pPowerAutho->hHalCtrl = hHalCtrl;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      powerAutho_PowerPolicyUpdate()
+ ****************************************************************************
+ * DESCRIPTION:        updates the PowerPolicy and calcs the new MinPowerPolicy of the sustem
+ * 
+ * INPUTS:     hMacServices - the handle to the MacServices module.
+ *                     aPowerPolicy - the new power policy.
+ *             
+ * 
+ * OUTPUT:     none
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int MacServices_powerAutho_PowerPolicyUpdate(TI_HANDLE hMacServices, powerAutho_PowerPolicy_e aPowerPolicy)
+{
+       powerAutho_t *pPowerAutho = (powerAutho_t*)(((MacServices_t*)hMacServices)->hPowerAutho);
+
+       WLAN_REPORT_INFORMATION (pPowerAutho->hReport,ELP_MODULE_LOG,
+                                                                       ("MacServices_powerAutho_PowerPolicyUpdate: PowerPolicy = %d\n",aPowerPolicy));
+
+       pPowerAutho->m_PowerPolicy = aPowerPolicy;
+
+       return powerAutho_CalcMinPowerLevel(pPowerAutho);       
+}
+
+/****************************************************************************
+ *                      powerAutho_AwakeRequiredUpdate()
+ ****************************************************************************
+ * DESCRIPTION:        updates the AwakeRequired and calcs the new MinPowerPolicy of the sustem
+ * 
+ * INPUTS:     hMacServices - the handle to the MacServices module.
+ *                     aAwakeRequired - the awake required parameter,
+ *                             can be according to the enum required or not_required.  
+ *                     aAwakeReason - the reason that the HW is required
+ * 
+ * OUTPUT:     none
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int MacServices_powerAutho_AwakeRequiredUpdate(TI_HANDLE hMacServices, MacServices_powerAutho_AwakeRequired_e aAwakeRequired, MacServices_powerAutho_AwakeReason_e aAwakeReason)
+{
+       powerAutho_t *pPowerAutho = (powerAutho_t*)(((MacServices_t*)hMacServices)->hPowerAutho);
+
+       if(aAwakeRequired == POWERAUTHO_AWAKE_REQUIRED)
+       {
+               pPowerAutho->m_AwakeRequired |= (1<<aAwakeReason);
+       }
+       else
+       { /* aAwakeRequired == POWERAUTHO_AWAKE_NOT_REQUIRED*/
+               pPowerAutho->m_AwakeRequired &= ~(1<<aAwakeReason);
+       }
+       
+       WLAN_REPORT_INFORMATION (pPowerAutho->hReport,ELP_MODULE_LOG,
+                                                                       ("MacServices_powerAutho_AwakeRequiredUpdate: awake required sent %d (reason %d) and the updated is %d\n", aAwakeRequired, aAwakeReason, pPowerAutho->m_AwakeRequired));
+       
+       return powerAutho_CalcMinPowerLevel(pPowerAutho);       
+}
+
+/****************************************************************************
+ *                      powerAutho_CalcMinPowerLevel()
+ ****************************************************************************
+ * DESCRIPTION:        calculate the min power level
+ * 
+ * INPUTS:     hPowerAutho - the handle to the PowerAuthorization module.
+ * 
+ * OUTPUT:     none
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int powerAutho_CalcMinPowerLevel(TI_HANDLE hPowerAutho)
+{
+       powerAutho_t *pPowerAutho = (powerAutho_t*)hPowerAutho;
+       powerAutho_PowerPolicy_e newMinPowerLevel;
+       whalParamInfo_t ParamInfo;
+
+       /* calc the new MinPowerLevel */
+       if(pPowerAutho->m_AwakeRequired >  0)
+               newMinPowerLevel = POWERAUTHO_POLICY_AWAKE;
+       else
+               newMinPowerLevel = pPowerAutho->m_PowerPolicy;
+
+       /* check if the MinPowerLevel changed */
+       if(pPowerAutho->m_MinPowerLevel != newMinPowerLevel)
+       {
+               WLAN_REPORT_INFORMATION (pPowerAutho->hReport,ELP_MODULE_LOG,
+                                                                       ("powerAutho_CalcMinPowerLevel - new MinPowerLevel is = %d\n",newMinPowerLevel));
+                       
+               pPowerAutho->m_MinPowerLevel = newMinPowerLevel;
+
+               /* we do the update of the FW only after the init complete*/
+               if(pPowerAutho->initComplete == TRUE)
+               {
+                       /* Update interface mode */
+                       whalCtrl_ElpCtrl_SetMode(pPowerAutho->hHalCtrl, pPowerAutho->m_ElpCtrl_Mode_LUT[newMinPowerLevel]);
+
+                       /* Send MIB with PowerPolicy */
+                       ParamInfo.paramType = (UINT32)HAL_CTRL_MIN_POWER_LEVEL;
+                       ParamInfo.paramLength = sizeof(powerAutho_PowerPolicy_e);
+                       ParamInfo.content.minPowerPolicy = newMinPowerLevel;
+                       whalCtrl_SetParam(pPowerAutho->hHalCtrl, &ParamInfo);
+            return OK;
+               }
+       }
+
+       return TNETWIF_COMPLETE;        
+}
+
+/****************************************************************************
+ *                      powerAutho_PowerPolicyUpdate()
+ ****************************************************************************
+ * DESCRIPTION:        send the min power level to the FW for the first time
+ * 
+ * INPUTS:     hMacServices - the handle to the MacServices module.
+ *             
+ * 
+ * OUTPUT:     none
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int MacServices_powerAutho_ExitFromInit(TI_HANDLE hMacServices)
+{
+       powerAutho_t *pPowerAutho = (powerAutho_t*)(((MacServices_t*)hMacServices)->hPowerAutho);
+       whalParamInfo_t ParamInfo;
+
+       WLAN_REPORT_INFORMATION (pPowerAutho->hReport,ELP_MODULE_LOG,
+                                                                       ("MacServices_powerAutho_ExitFromInit: PowerPolicy = %d\n",pPowerAutho->m_MinPowerLevel ));
+       /* set as 'after init complete' */
+       pPowerAutho->initComplete = TRUE;
+
+       /* Update interface mode */
+       whalCtrl_ElpCtrl_SetMode(pPowerAutho->hHalCtrl, pPowerAutho->m_ElpCtrl_Mode_LUT[pPowerAutho->m_MinPowerLevel]);
+
+       /* Send MIB with PowerPolicy */
+       ParamInfo.paramType = (UINT32)HAL_CTRL_MIN_POWER_LEVEL;
+       ParamInfo.paramLength = sizeof(powerAutho_PowerPolicy_e);
+       ParamInfo.content.minPowerPolicy = pPowerAutho->m_MinPowerLevel;
+       whalCtrl_SetParam(pPowerAutho->hHalCtrl, &ParamInfo);
+
+       return OK;
+}
+
+
+/****************************************************************************
+ *                      MacServices_powerAutho_Endrecovery()
+ ****************************************************************************
+ * DESCRIPTION:        initialize module after recovery
+ * 
+ * INPUTS:     hMacServices - the handle to the MacServices module.
+ *             
+ * 
+ * OUTPUT:     none
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int powerAutho_Restart(TI_HANDLE hMacServices)
+{                      
+       powerAutho_t *pPowerAutho = (powerAutho_t*)(((MacServices_t*)hMacServices)->hPowerAutho);
+
+               /* set as 'before init complete' */
+       pPowerAutho->initComplete = FALSE; 
+       
+       pPowerAutho->m_PowerPolicy = POWERAUTHO_POLICY_AWAKE;
+       pPowerAutho->m_MinPowerLevel = POWERAUTHO_POLICY_AWAKE;
+
+
+       return pPowerAutho->m_MinPowerLevel;
+}
+
+
+/****************************************************************************
+ *                      MacServices_powerAutho_Endrecovery()
+ ****************************************************************************
+ * DESCRIPTION:        updates the PowerPolicy and calcs the new MinPowerPolicy of the sustem
+ * 
+ * INPUTS:     hMacServices - the handle to the MacServices module.
+ *             
+ * 
+ * OUTPUT:     none
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int MacServices_powerAutho_EndRecovery(TI_HANDLE hMacServices)
+{
+       powerAutho_t *pPowerAutho = (powerAutho_t*)(((MacServices_t*)hMacServices)->hPowerAutho);
+
+       WLAN_REPORT_INFORMATION (pPowerAutho->hReport,ELP_MODULE_LOG,
+                                                                       ("MacServices_powerAutho_Endrecovery: PowerPolicy = %d\n",pPowerAutho->m_PowerPolicy));
+
+       return powerAutho_CalcMinPowerLevel(pPowerAutho);       
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization_internal.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization_internal.h
new file mode 100644 (file)
index 0000000..7dfe57f
--- /dev/null
@@ -0,0 +1,90 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**********************************************************************************/
+/*                                                                                */
+/*   MODULE:  PowerAuthorization_internal.h                                                */
+/*   PURPOSE: PowerAuthorization internal definition file                                                                                */
+/*                                                                                */
+/**********************************************************************************/
+#ifndef _POWER_AUTHORIZATION_INTERNAL_H_
+#define _POWER_AUTHORIZATION_INTERNAL_H_
+
+/*****************************************************************************
+ **         MACRO                                                             **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Types                                                             **
+ *****************************************************************************/
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+typedef struct _powerAutho_t
+{
+       /* Internal variables and configurable parameters */
+       powerAutho_PowerPolicy_e m_PowerPolicy; /* the last set PowerPolicy */
+       INT32 m_AwakeRequired;
+       /* 
+       the power policy that was configured to the FW after call to powerAutho_CalcMinPowerLevel 
+       */
+       powerAutho_PowerPolicy_e m_MinPowerLevel; 
+
+       /* Look Up Table that sets for each MinPolicyLevel the ElpCtrl mode */
+       elpCtrl_Mode_e m_ElpCtrl_Mode_LUT[POWERAUTHO_POLICY_NUM];
+       
+       /* Handlers of other modules used */
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hHalCtrl;
+
+       int initComplete;
+       
+} powerAutho_t;
+
+
+/*****************************************************************************
+ **         Internal functions definitions                                  **
+ *****************************************************************************/
+int powerAutho_CalcMinPowerLevel(TI_HANDLE hPowerAutho);
+
+#endif /* _POWER_AUTHORIZATION_INTERNAL_H_ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.c
new file mode 100644 (file)
index 0000000..6267afb
--- /dev/null
@@ -0,0 +1,823 @@
+/** \file powerSrv.c
+ *  \brief This is the powerSrv module implementation.
+ *  \author Assaf Azulay
+ *  \date 19-Oct-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                                                           *
+ *   MODULE:  powerSrv                                                                                  *
+ *   PURPOSE: powerSrv Module implementation.                                                   *
+ *                                                                                                              *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "commonTypes.h"
+#include "report.h"
+#include "PowerSrv.h"
+#include "PowerSrv_API.h"
+#include "PowerSrvSM.h"
+#include "whalCtrl_api.h"
+#include "public_event_mbox.h"
+
+
+/*****************************************************************************
+ **         Defines                                                         **
+ *****************************************************************************/
+
+
+
+/****************************************************************************************
+**         Private Function prototypes                                                                              **
+****************************************************************************************/
+static void     powerSrv802_11PsReport  (TI_HANDLE hPowerSrv, char* str , UINT32 strLen);
+TI_STATUS   powerSrvProcessRequest  (TI_HANDLE hPowerSrv, powerSrvMode_e requestMode);
+void powerSrvCreatePssRequest (TI_HANDLE                    hPowerSrv,
+                               powerSrvMode_e              requestMode,
+                               powerSrvRequestState_e      requestState,
+                               PowerMgr_802_11_PsMode_e    psMode,
+                               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(("%s(%d) - Memory Allocation Error!\n",__FILE__,__LINE__));
+        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(("%s(%d) - Error in create PowerSrvSM module!\n",__FILE__,__LINE__));
+        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 - OK on success else 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));
+
+    WLAN_OS_REPORT(("%s(%d) - powerSrv destroyed\n",__FILE__,__LINE__));
+
+    return 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.        
+            - hPowerSrvSM       - handle to the PowerSrvSM object.
+            - hReport           - handle to the Report object.
+            - hWhalCtrl         - handle to the WhalCtrl object.    
+
+OUTPUT: 
+RETURN:    TI_STATUS - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS powerSrv_init(    TI_HANDLE           hPowerSrv,
+                            TI_HANDLE           hReport,
+                            TI_HANDLE          hWhalCtrl)
+{
+    powerSrv_t* pPowerSrv = (powerSrv_t*)hPowerSrv;
+
+
+    pPowerSrv->hReport  = hReport;
+    pPowerSrv->hWhalCtrl= hWhalCtrl;
+
+    /*
+    init PowerSrv state machine.
+    */
+    powerSrvSM_init(    pPowerSrv->hPowerSrvSM,
+                        hReport,
+                        hWhalCtrl);
+    pPowerSrv->currentMode = USER_MODE;
+
+    /*init all request with init values*/
+    powerSrvCreatePssRequest(hPowerSrv,
+                             USER_MODE,
+                             HANDLED_REQUEST,
+                             POWER_SAVE_OFF,
+                             FALSE,
+                             NULL,
+                             NULL,
+                             NULL);
+    powerSrvCreatePssRequest(hPowerSrv,
+                             DRIVER_MODE,
+                             HANDLED_REQUEST,
+                             POWER_SAVE_OFF,
+                             FALSE,
+                             NULL,
+                             NULL,
+                             NULL);
+    pPowerSrv->userLastRequestMode = (powerSrvMode_e)POWER_SAVE_OFF;
+    pPowerSrv->pCurrentRequest  = & pPowerSrv->userRequest;
+
+    /*
+    register for Event 
+    */
+    whalCtrl_EventMbox_RegisterForEvent(hWhalCtrl,
+                                        HAL_EVENT_PS_REPORT,
+                                        (void *)powerSrv802_11PsReport,
+                                        hPowerSrv);
+
+    whalCtrl_EventMbox_Enable(          hWhalCtrl,
+                                        HAL_EVENT_PS_REPORT);
+
+
+    WLAN_REPORT_INIT(pPowerSrv->hReport, POWER_MANAGER_MODULE_LOG,
+                     ("%s(%d) - powerSrv Initialized \n",__FILE__,__LINE__));
+
+    return 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 - OK on success else 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;
+       os_timerStop( pPowerSrvSM->hOS, pPowerSrvSM->hTimer );
+
+    /*init all request with init values*/
+    powerSrvCreatePssRequest(hPowerSrv,
+                                                       USER_MODE,
+                                                       HANDLED_REQUEST,
+                                                       POWER_SAVE_OFF,
+                                                       FALSE,
+                                                       NULL,
+                                                       NULL,
+                                                       NULL);
+    powerSrvCreatePssRequest(hPowerSrv,
+                                                       DRIVER_MODE,
+                                                       HANDLED_REQUEST,
+                                                       POWER_SAVE_OFF,
+                                                       FALSE,
+                                                       NULL,
+                                                       NULL,
+                                                       NULL);
+//adi CE20    pPowerSrv->userLastRequest       = pPowerSrv->userRequest;
+       pPowerSrv->userLastRequestMode = (powerSrvMode_e)POWER_SAVE_OFF;//WL403
+    pPowerSrv->pCurrentRequest         = & pPowerSrv->userRequest;
+
+       /*
+       register for Event 
+       */
+       whalCtrl_EventMbox_RegisterForEvent(pPowerSrv->hWhalCtrl,
+                                                                               HAL_EVENT_PS_REPORT,
+                                                                               (void *)powerSrv802_11PsReport,
+                                                                               hPowerSrv);
+
+       whalCtrl_EventMbox_Enable(                      pPowerSrv->hWhalCtrl,
+                                                                               HAL_EVENT_PS_REPORT);
+
+
+    return 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 - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS powerSrv_config(  TI_HANDLE               hPowerSrv,
+                            PowerSrvInitParams_t *  pPowerSrvInitParams)
+{
+    powerSrv_t* pPowerSrv = (powerSrv_t*)hPowerSrv;
+
+    /*
+    config PowerSrv state machine.
+    */
+    powerSrvSM_config(   pPowerSrv->hPowerSrvSM,
+                         pPowerSrvInitParams);
+
+    return 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 - OK / PENDING / NOK.
+****************************************************************************************/
+TI_STATUS powerSrv_SetPsMode(   TI_HANDLE                   hPowerSrv,
+                                PowerMgr_802_11_PsMode_e    psMode,
+                                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 = 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 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 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 - OK / PENDING / NOK.
+****************************************************************************************/
+TI_STATUS powerSrv_ReservePS(   TI_HANDLE               hPowerSrv,
+                                PowerMgr_802_11_PsMode_e psMode,
+                                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 - OK / PENDING / NOK.
+****************************************************************************************/
+TI_STATUS powerSrv_ReleasePS(   TI_HANDLE                   hPowerSrv,
+                                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 == PENDING )
+    {
+        powerSrvCreatePssRequest(hPowerSrv,
+                                 DRIVER_MODE,
+                                 HANDLED_REQUEST,
+                                 POWER_SAVE_OFF,
+                                 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 = (PowerMgr_802_11_PsMode_e)pPowerSrv->userLastRequestMode;
+    }
+
+
+
+    status = powerSrvProcessRequest(hPowerSrv,pPowerSrv->driverRequest.requestMode);
+    /*if the request was not executed we should not change the mode*/
+    if ( status != 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:    BOOLEAN - true if the SM is in PS state -  false otherwise
+****************************************************************************************/
+BOOLEAN 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:    BOOLEAN - true if the SM is in PS state -  false otherwise
+****************************************************************************************/
+void powerSrv_SetRateModulation(TI_HANDLE hPowerSrv, 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
+ */
+UINT16 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 whal 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 , UINT32 strLen)
+{
+    powerSrv_t *                    pPowerSrv = (powerSrv_t*)hPowerSrv;
+    UINT8                       PowerSaveStatus;
+    PowerMgr_802_11_PsMode_e    currentPsMode;
+    TI_STATUS                       status = OK;
+
+    /*copy the event*/
+    os_memoryCopy(pPowerSrv->hOS, (void *)&PowerSaveStatus, (void *)str, strLen);
+
+    WLAN_REPORT_INFORMATION( pPowerSrv->hReport, POWER_SERVER_MODULE_LOG,
+                             ("PS callback with status: %d\n", PowerSaveStatus) );
+
+    /* Handling the event*/
+    switch ( (EventsPowerSave_e)PowerSaveStatus )
+    {
+    case ENTER_POWER_SAVE_FAIL:
+    case EXIT_POWER_SAVE_FAIL:
+        WLAN_REPORT_WARNING( pPowerSrv->hReport, POWER_SERVER_MODULE_LOG,
+                             ("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:
+        WLAN_REPORT_ERROR( pPowerSrv->hReport, POWER_SERVER_MODULE_LOG,
+                           ("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 - OK / PENDING / 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 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,
+                               PowerMgr_802_11_PsMode_e    psMode,
+                               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 = (failureEventCB_t)failureEventCB;
+    pPowerSrv->failureEventObj  = hFailureEventObj;
+
+    /* register the failure event CB also with the PS SM */
+    powerSrvSM_RegisterFailureEventCB( pPowerSrv->hPowerSrvSM, failureEventCB, hFailureEventObj );
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.h
new file mode 100644 (file)
index 0000000..53020e7
--- /dev/null
@@ -0,0 +1,195 @@
+/** \file powerSrv.h
+ *  \brief This is the Power Manager module private (internal).
+ *  \author Yaron Menashe
+ *  \date 27-Apr-2004
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Power Manager                                                 *
+ *   PURPOSE: Power Manager Module private                                      *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _POWER_SRV_H_
+#define _POWER_SRV_H_
+
+#include "osTIType.h"
+#include "commonTypes.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;
+       PowerMgr_802_11_PsMode_e        psMode;
+       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                       hWhalCtrl;                      /**< Handle to the power controller object via the WhalCtrl.
+                                                                                        * Need for configure the desired power mode policy in the system.
+                                                                                        */
+                                                                                        
+       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
+                                                                                       */
+       
+       failureEventCB_t                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/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.c
new file mode 100644 (file)
index 0000000..f3d37f8
--- /dev/null
@@ -0,0 +1,870 @@
+/** \file PowerSrvSM.c
+ *  \brief This is the PowerSrvSM module implementation.
+ *  \author Assaf Azulay
+ *  \date 19-OCT-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  PowerSrvSM                                                    *
+ *   PURPOSE: PowerSrvSM Module implementation.                             *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "commonTypes.h"
+#include "fsm.h"
+#include "report.h"
+#include "PowerSrvSM.h"
+#include "whalCtrl_api.h"
+
+
+/*****************************************************************************
+ **         Defines                                                         **
+ *****************************************************************************/
+
+
+
+/*****************************************************************************
+ **         structs                                                         **
+ *****************************************************************************/
+#ifdef TI_DBG
+static char stateDesc[POWER_SRV_SM_STATE_NUM][MAX_DESC_STRING_LEN] =
+{
+    "POWER_SRV_STATE_ACTIVE ",
+    "POWER_SRV_STATE_PEND_PS" ,
+    "POWER_SRV_STATE_PS" ,
+    "POWER_SRV_STATE_PEND_ACTIVE" ,
+    "POWER_SRV_STATE_ERROR_ACTIVE"
+};
+
+
+
+static char eventDesc[POWER_SRV_SM_EVENT_NUM][MAX_DESC_STRING_LEN] =
+{
+    "POWER_SRV_EVENT_REQUEST_ACTIVE" , 
+    "POWER_SRV_EVENT_REQUEST_PS" ,
+    "POWER_SRV_EVENT_SUCCESS",
+    "POWER_SRV_EVENT_FAIL" ,
+
+};
+#endif /* TI_DBG */
+/*****************************************************************************
+ **         Private Function prototypes                                     **
+ *****************************************************************************/
+
+static TI_STATUS powerSrvSmSMEvent(UINT8* pCurrentState,
+                                   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, BOOLEAN PS_disableEnable);
+
+/***************************************************************************************
+ **         Public Function prototypes                                      **
+ ****************************************************************************************/
+
+/****************************************************************************************
+*                               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.
+OUTPUT:    None
+RETURN:    None
+****************************************************************************************/
+void powerSrvSMTimerExpired( TI_HANDLE hPowerSrvSM )
+{
+       PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+
+       /* Print an error message */
+       WLAN_REPORT_ERROR( pPowerSrvSM->hReport, POWER_SERVER_MODULE_LOG,
+               ("%s(%d) - PS guard timer expired!\n",
+               __FILE__,__LINE__));
+
+       /* Call the error notification callback (triggering recovery) */
+       pPowerSrvSM->failureEventCB( pPowerSrvSM->hFailureEventObj ,POWER_SAVE_FAILURE );
+}
+
+/****************************************************************************************
+ *                        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",__FILE__,__LINE__));
+        return NULL;
+    }
+
+    os_memoryZero (hOsHandle, pPowerSrvSM, sizeof(PowerSrvSM_t));
+
+    pPowerSrvSM->hOS = hOsHandle;
+
+    /* create the generic state-machine */
+    status = fsm_Create(hOsHandle,
+                        &pFsm,
+                        (UINT8)POWER_SRV_SM_STATE_NUM,
+                        (UINT8)POWER_SRV_SM_EVENT_NUM);
+    if ( status != OK )
+    {
+        WLAN_OS_REPORT(("%s(%d) - Error in create FSM!\n",__FILE__,__LINE__));
+        powerSrvSM_destroy(pPowerSrvSM);
+        return NULL;
+    }
+
+    /* create the timer */
+    pPowerSrvSM->hTimer = os_timerCreate( hOsHandle, powerSrvSMTimerExpired, (TI_HANDLE)pPowerSrvSM );
+    if ( NULL == pPowerSrvSM->hTimer )
+    {
+        WLAN_OS_REPORT( ("%s(%d) - Failed to create Power Save SRV timer\n", __FILE__,__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 - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS powerSrvSM_destroy(TI_HANDLE hPowerSrvSM)
+{
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+
+    TI_HANDLE osHandle = pPowerSrvSM->hOS;
+
+    /* free the timer */
+    if ( NULL != pPowerSrvSM->hTimer )
+    {
+        os_timerDestroy( osHandle, pPowerSrvSM->hTimer );
+    }
+
+    /* 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));
+
+    WLAN_OS_REPORT(("%s(%d) - PowerSrvSM destroyed\n",__FILE__,__LINE__));
+
+    return 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.
+           - hWhalCtrl         - handle to the WhalCtrl object.    
+
+OUTPUT: 
+RETURN:    TI_STATUS - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS powerSrvSM_init(TI_HANDLE hPowerSrvSM,
+                          TI_HANDLE hReport,
+                          TI_HANDLE hWhalCtrl)
+{
+    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}
+
+        },
+
+    };
+
+    fsm_Config(pPowerSrvSM->hFSM,
+               (fsm_Matrix_t)smMatrix,
+               POWER_SRV_SM_STATE_NUM,
+               POWER_SRV_SM_EVENT_NUM,
+               powerSrvSmSMEvent,
+               pPowerSrvSM->hOS);
+
+    pPowerSrvSM->hReport = hReport;
+    pPowerSrvSM->hWhalCtrl = hWhalCtrl;
+
+
+
+    /*
+    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); 
+
+
+
+
+
+    WLAN_REPORT_INIT(pPowerSrvSM->hReport,
+                     POWER_SERVER_MODULE_LOG,
+                     ("%s(%d) - PowerSrvSM Initialized\n",__FILE__,__LINE__));
+
+
+    return 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 - OK on success else NOK.
+****************************************************************************************/
+TI_STATUS powerSrvSM_config(TI_HANDLE hPowerSrvSM,
+                            PowerSrvInitParams_t *pPowerSrvInitParams)
+{
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+
+    /*
+    init PowerMgmtConfigration
+    */
+    pPowerSrvSM->hangOverPeriod =   pPowerSrvInitParams->hangOverPeriod;
+    pPowerSrvSM->numNullPktRetries =    pPowerSrvInitParams->numNullPktRetries;
+
+    return 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 whal control.
+            
+
+OUTPUT: 
+RETURN:    TI_STATUS OK / PENDING / 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 :
+
+        WLAN_REPORT_INFORMATION(pPowerSrvSM->hReport,
+                                POWER_SERVER_MODULE_LOG,
+                                ("powerSrvSM_SMApi(%d) called - legal input parameter.",theSMEvent));
+        break;
+
+    default:
+        WLAN_REPORT_WARNING(pPowerSrvSM->hReport,
+                            POWER_SERVER_MODULE_LOG,
+                            ("powerSrvSM_SMApi(%d) called, \
+                             input parameter is illegal.",theSMEvent));
+        return NOK;
+    }
+
+
+    status = powerSrvSmSMEvent((UINT8*)&pPowerSrvSM->currentState,
+                               (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 -  OK
+****************************************************************************************/
+TI_STATUS powerSrvSm_setSmRequest(TI_HANDLE hPowerSrvSM,powerSrvRequest_t* pSmRequest)
+{
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+    pPowerSrvSM->pSmRequest = pSmRequest;
+    return 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, 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
+****************************************************************************************/
+
+UINT16 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 WhalCtrl is 0x%08X\n", pPowerSrvSM->hWhalCtrl));
+
+    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 - OK / 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, 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 - OK / 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, 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 - OK / NOK
+****************************************************************************************/
+
+static TI_STATUS powerSrvSmDoUpdateRequest(TI_HANDLE hPowerSrvSM)
+{
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+
+    /* request has completed - stop the guard timer */
+    os_timerStop( pPowerSrvSM->hOS, pPowerSrvSM->hTimer );
+
+    /*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 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 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 - 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 - OK
+****************************************************************************************/
+static TI_STATUS powerSrvSMActionUnexpected(TI_HANDLE hPowerSrvSM)
+{
+#ifdef TI_DBG
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+
+    WLAN_REPORT_ERROR(pPowerSrvSM->hReport,
+                      POWER_SERVER_MODULE_LOG,
+                      ("called: powerSrvSMActionUnexpected"));
+#endif /* TI_DBG */
+
+    return 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(UINT8* pCurrentState,
+                                   UINT8 event,
+                                   TI_HANDLE hPowerSrvSM)
+{
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+    TI_STATUS status = OK;
+    UINT8 nextState;
+
+    status = fsm_GetNextState((fsm_stateMachine_t*)pPowerSrvSM->hFSM,
+                              (UINT8)pPowerSrvSM->currentState,
+                              event,
+                              &nextState);
+    if ( status != OK )
+    {
+        WLAN_REPORT_SM(pPowerSrvSM->hReport,
+                       POWER_SERVER_MODULE_LOG,
+                       ("PowerSrvSM - State machine error, failed getting next state\n"));
+        return(status);
+    }
+
+
+#ifdef TI_DBG
+    WLAN_REPORT_SM(pPowerSrvSM->hReport,
+                   POWER_SERVER_MODULE_LOG,
+                   ("PowerSrvSM <state[%s] event[%s]> --> state[%s]\n\n",
+                    stateDesc[*pCurrentState],
+                    eventDesc[event],
+                    stateDesc[nextState]));
+#endif
+
+    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, BOOLEAN PS_disableEnable)
+{
+    PowerSrvSM_t *pPowerSrvSM = (PowerSrvSM_t*)hPowerSrvSM;
+    whalCtrl_powerSaveParams_t 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;
+    powerSaveParams.powerSavecmdResponseCB  = pPowerSrvSM->pSmRequest->powerSaveCmdResponseCB;
+    if ( pPowerSrvSM->pSmRequest->powerSaveCmdResponseCB == NULL )
+    {
+        powerSaveParams.powerSaveCBObject       =  NULL; /*in order to not set to the Mailbox a response CB*/
+    }
+    else
+    {
+        powerSaveParams.powerSaveCBObject       = pPowerSrvSM->pSmRequest->powerSaveCBObject;       
+    }
+
+    /* start the FW guard timer, which is used to protect from FW stuck */
+   os_timerStart( pPowerSrvSM->hOS, pPowerSrvSM->hTimer, POWER_SAVE_GUARD_TIME_MS, 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 = whalCtrl_powerMgmtConfig(pPowerSrvSM->hWhalCtrl,
+                                      &powerSaveParams);
+    if ( status != OK )
+    {
+        WLAN_REPORT_ERROR(pPowerSrvSM->hReport,
+                          POWER_SERVER_MODULE_LOG,
+                          ("%s(%d) - Error in configuring Power Manager paramters!\n",
+                           __FILE__,__LINE__));
+    }
+
+    return status;
+}
+
+/****************************************************************************************
+ *                        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 = (failureEventCB_t)failureEventCB;
+    pPowerSrvSM->hFailureEventObj = hFailureEventObj;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.h
new file mode 100644 (file)
index 0000000..5f3336f
--- /dev/null
@@ -0,0 +1,280 @@
+/** \file PowerSrvSM.h
+ *  \brief This is the PowerSrv module API.
+ *  \author Assaf Azulay
+ *  \date 6-Oct-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                                                        *
+ *   MODULE:  PowerSrv                                                                              *
+ *   PURPOSE: Power Server State machine API                                                    *
+ *                                                                                                              *
+ ****************************************************************************/
+
+#ifndef _POWER_SRV_SM_H_
+#define _POWER_SRV_SM_H_
+
+#include "commonTypes.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               hWhalCtrl;                  /**< 
+                                                         * Handle to the power controller object via the WhalCtrl.
+                                                         * 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;                     /**< 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. */
+
+    UINT8                   hangOverPeriod;             /**< parameter for the FW */
+
+    UINT8                   numNullPktRetries;          /**< parameter for the FW */
+    
+    UINT16                  NullPktRateModulation;      /**< parameter for the FW */
+
+    failureEventCB_t        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 - OK on success else 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 whalCtrl object.
+ * 4) PowerSrvInitParams_t - the Power Server initialize parameters.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ */
+TI_STATUS powerSrvSM_init(TI_HANDLE hPowerSrvSM,
+                                        TI_HANDLE hReport,
+                                     TI_HANDLE hWhalCtrl);
+
+TI_STATUS powerSrvSM_config(TI_HANDLE hPowerSrvSM,
+                          PowerSrvInitParams_t *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: 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 -  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, UINT16 rateModulation);
+
+/**
+ * \brief sets rate modulation
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerSrvSM object.\n* 
+ * Return Value: UINT16 Rate.\n
+ */
+UINT16 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/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv_API.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv_API.h
new file mode 100644 (file)
index 0000000..c83cd12
--- /dev/null
@@ -0,0 +1,282 @@
+/** \file powerSrv_API.h
+ *  \brief This is the Power Manager module API.
+ *  \author Yaron Menashe
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Power Server                                                 *
+ *   PURPOSE: Power Server Module API                                      *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _POWER_SRV_API_H_
+#define _POWER_SRV_API_H_
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "MacServices_api.h"
+
+/*****************************************************************************
+ **         Constants                                                       **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Enumerations                                                    **
+ *****************************************************************************/
+
+
+
+/*****************************************************************************
+ **         Typedefs                                                        **
+ *****************************************************************************/
+/*typedef void (*powerSaveCmdResponseCB_t )(TI_HANDLE cmdResponseHandle,UINT8 MboxStatus);*/
+typedef MacServices_powerSaveCmdResponseCB_t powerSaveCmdResponseCB_t;
+/*typedef void (*powerSaveCmpltCB_t )(TI_HANDLE powerSaveCmpltHandle,UINT8 PSMode,UINT8 transStatus);*/
+typedef MacServices_powerSaveCmpltCB_t 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 - OK on success else 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
+ * 2) TI_HANDLE - handle to the powerSrvSM object.\n
+ * 3) TI_HANDLE - handle to the Report object.\n
+ * 4) TI_HANDLE - handle to the WhalCtrl object.\n
+ * 5) powerSrvInitParams_t - the Power Manager initialize parameters.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ */
+TI_STATUS powerSrv_init(TI_HANDLE                      hPowerSrv,
+                                                       TI_HANDLE                       hReport,
+                                                    TI_HANDLE                  hWhalCtrl);
+
+
+TI_STATUS powerSrv_config(TI_HANDLE                            hPowerSrv,
+                                         PowerSrvInitParams_t *        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 - OK / PENDING / 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,
+                                                                       PowerMgr_802_11_PsMode_e        psMode,
+                                                                       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 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 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,
+                                                                       PowerMgr_802_11_PsMode_e psMode,
+                                                                       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 - OK on success else 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,
+                                                                       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 
+ * BOOLEAN - thre is in PS false otherwise.\n
+*/
+BOOLEAN 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) UINT16           - desierd rate .\n
+ * Return Value:\n 
+ * void.\n
+*/
+void powerSrv_SetRateModulation(TI_HANDLE hPowerSrv, 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: UINT16                - desierd rate .\n
+ * void.\n
+*/
+UINT16 powerSrv_GetRateModulation(TI_HANDLE hPowerSrv);
+
+TI_STATUS powerSrv_restart(    TI_HANDLE hPowerSrv);
+
+#endif /*  _POWER_SRV_API_H_  */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.c
new file mode 100644 (file)
index 0000000..9d25c2e
--- /dev/null
@@ -0,0 +1,715 @@
+/** \file ScanSrv.c
+ *  \brief This file include the scan SRV module implementation
+ *  \date 30-Dec-2004
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "report.h"
+#include "ScanSrv.h"
+#include "ScanSrvSM.h"
+#include "utils.h"
+#include "MacServices.h"
+#include "MacServices_api.h"
+#include "whalCtrl_api.h"
+#include "public_event_mbox.h"
+
+/**
+ * \author Yuval Adler\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;
+    }
+
+    /* allocate the state machine */
+    if ( 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;
+    }
+    /* create the timer */
+    pScanSRV->timer = os_timerCreate( hOS, MacServices_scanSRV_scanTimerExpired, pScanSRV );
+    if ( NULL == pScanSRV->timer )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to create timer for scan SRV module") );
+        fsm_Unload( hOS, pScanSRV->SM );
+        os_memoryFree( hOS, pScanSRV, sizeof(scanSRV_t) );
+        return NULL;
+    }
+
+    /* store the OS handle */
+    pScanSRV->hOS = hOS;
+
+    return pScanSRV;
+}
+
+/**
+ * \author Yuval Adler\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 */
+    os_timerStop( pScanSRV->hOS, pScanSRV->timer );
+    os_timerDestroy( pScanSRV->hOS, pScanSRV->timer );
+    
+    /* free memory */
+    fsm_Unload( pScanSRV->hOS, pScanSRV->SM );
+    os_memoryFree( pScanSRV->hOS, (TI_HANDLE)pScanSRV , sizeof(scanSRV_t) );
+}
+
+/**
+ * \author Yuval Adler\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 hReport - handle to the report object.\n
+ * \param hHalCtrl - handle to the HAL ctrl object.\n
+  */
+void MacServices_scanSRV_init( TI_HANDLE hMacServices, TI_HANDLE hReport,  TI_HANDLE hHalCtrl)
+{
+    MacServices_t* pMacServices =  (MacServices_t*)hMacServices;
+    scanSRV_t *pScanSRV =  pMacServices->hScanSRV;
+
+    /* store handles */
+    pScanSRV->hHalCtrl = hHalCtrl;
+    pScanSRV->hReport = hReport;
+    pScanSRV->hPowerSrv = pMacServices->hPowerSrv;
+    pScanSRV->commandResponseFunc = NULL;
+    pScanSRV->commandResponseObj = NULL;  
+
+    /* init state machine */
+    scanSRVSM_init( (TI_HANDLE) pScanSRV );
+
+    /* register our scan complete handler to the HAL events mailbox */
+    whalCtrl_EventMbox_RegisterForEvent( pScanSRV->hHalCtrl, HAL_EVENT_SCAN_CMPLT, 
+                                         (void *)MacServices_scanSRV_scanCompleteCB, (TI_HANDLE)pScanSRV ); 
+    whalCtrl_EventMbox_RegisterForEvent( pScanSRV->hHalCtrl, HAL_EVENT_SPS_SCAN_CMPLT, 
+                                         (void *)MacServices_scanSRV_scanCompleteCB, (TI_HANDLE)pScanSRV );
+
+    /* init other stuff */
+    pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0;
+
+    WLAN_REPORT_INIT( hReport, SCAN_SRV_MODULE_LOG,  (".....Scan SRV configured successfully.\n"));
+}
+
+/**
+ * \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 ( TRUE == pScanSRV->bTimerRunning )
+    {
+        os_timerStop( pScanSRV->hOS, pScanSRV->timer );
+        pScanSRV->bTimerRunning = FALSE;
+    }
+}
+
+/**
+ * \author Ronen Kalish\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, scanSrvInitParams_t* 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;
+    whalCtrl_SetSplitScanTimeOut (pScanSRV->hHalCtrl, pScanSRV->uTriggeredScanTimeOut);
+}
+
+/**
+ * \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, 
+                                     scan_srvCompleteCB_t 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  = (failureEventCB_t)failureEventCB;
+    pScanSRV->failureEventObj   = hFailureEventObj;
+}
+
+/**
+ * \author Yuval Adler\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,UINT16 MboxStatus)
+{
+    scanSRV_t* pScanSRV = (scanSRV_t*)hScanSrv;
+    UINT16 responseStatus;
+    CmdResponseCB_t CB_Func;
+    TI_HANDLE  CB_Handle;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("%s status %u\n",__FUNCTION__,MboxStatus) );
+
+    /* set response to OK or NOK */
+    responseStatus = ((MboxStatus > 0) ? NOK : 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 ( OK != responseStatus )
+    {
+        WLAN_REPORT_ERROR( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                           ("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 );
+    }
+}
+
+/**
+ * \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 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 OK if successful (various, TBD codes if not).\n
+ */
+TI_STATUS MacServices_scanSRV_scan( TI_HANDLE hMacServices, scan_Params_t *scanParams, BOOLEAN bHighPriority,
+                        BOOLEAN bDriverMode, BOOLEAN bScanOnDriverModeError, 
+                        PowerMgr_802_11_PsMode_e psRequest, BOOLEAN bSendNullData,
+                        CmdResponseCB_t commandResponseFunc, TI_HANDLE commandResponseObj)
+{
+   scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
+
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("Scan request received.\n") );
+
+    /* sanity check - scan can only start if the scan SRV is idle */
+    if ( SCAN_SRV_STATE_IDLE != pScanSRV->SMState )
+    {
+        WLAN_REPORT_WARNING( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("Scan request while scan is running!\n") );
+        return NOK;
+    }
+
+    /* Response function for GWSI only. In Legacy run we get NULL and never use it. */
+    pScanSRV->commandResponseFunc = commandResponseFunc;
+    pScanSRV->commandResponseObj  = commandResponseObj;
+
+    pScanSRV->bInRequest = TRUE;
+    pScanSRV->returnStatus = OK;
+
+    /* copy scan paramaters */
+    pScanSRV->scanParams = scanParams;
+    pScanSRV->bHighPriority = bHighPriority;
+    pScanSRV->bScanOnDriverModeFailure = bScanOnDriverModeError;
+    pScanSRV->bSendNullData = bSendNullData;
+    pScanSRV->psRequest = psRequest;
+
+    if ( SCAN_TYPE_SPS == scanParams->scanType )
+    {
+        pScanSRV->bSPSScan = TRUE;
+
+    }
+    else
+    {
+        pScanSRV->bSPSScan = FALSE;
+    }
+
+
+    /* check whether the scan will overlap DTIM frame */
+    if ( (FALSE == bHighPriority) && (TRUE == bDriverMode) )
+    {
+        pScanSRV->bDtimOverlapping = FALSE;
+    }
+    else
+    {
+        pScanSRV->bDtimOverlapping = 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 = FALSE;
+
+    /* if required to enter driver mode */
+    if ( TRUE == bDriverMode )
+    {
+        pScanSRV->bExitFromDriverMode = 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 = 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 = FALSE;
+    
+    return pScanSRV->returnStatus;
+}
+
+/**
+ * \author Ronen Kalish\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 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 OK if successful (various, TBD codes if not).\n
+ */
+TI_STATUS MacServices_scanSRV_stopScan( TI_HANDLE hMacServices, BOOLEAN bSendNullData, CmdResponseCB_t ScanCommandResponseCB, TI_HANDLE CB_handle )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)((MacServices_t*)hMacServices)->hScanSRV;
+    int stopScanStatus;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("Stop scan request received.\n") );
+
+    /* update the driver mode exit flag */
+    pScanSRV->bSendNullData = bSendNullData;
+
+    if ( TRUE == pScanSRV->bSPSScan )
+    {
+        stopScanStatus = whalCtrl_StopSPSScan( pScanSRV->hHalCtrl , (void *)ScanCommandResponseCB, CB_handle);
+    }
+    else
+    {
+        stopScanStatus = whalCtrl_StopScan( pScanSRV->hHalCtrl,(void *)ScanCommandResponseCB, CB_handle);
+    }
+
+    if (OK != stopScanStatus)
+    {
+        return NOK;
+    }
+    /* send a stop scan event */
+    return scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_STOP_SCAN );
+}
+
+/**
+ * \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 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;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("FW reset notification received.\n") );
+
+    /* mark the return status */
+    pScanSRV->returnStatus = NOK;
+
+    /* send a FW reset event */
+    return scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_FW_RESET );
+}
+
+/**
+ * \author Ronen Kalish\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, UINT8 PSMode,UINT8 psStatus )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("PS Call Back status %d .\n",psStatus) );
+
+    /* if driver mode enter/exit succeedded */
+    if ( (ENTER_POWER_SAVE_SUCCESS == psStatus) || (EXIT_POWER_SAVE_SUCCESS == psStatus) )
+    {
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("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 ( (TRUE == pScanSRV->bScanOnDriverModeFailure) && ( ENTER_POWER_SAVE_FAIL == psStatus) )
+    {
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("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) 
+        {
+            WLAN_REPORT_WARNING( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("PS enter failed . quiting scan .\n") );
+            /* Set the return status  */
+            pScanSRV->returnStatus = NOK;
+        }
+
+        /* send a PS FAIL event */
+        scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL );
+    }
+}
+
+
+/**
+ * \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, UINT32 strLen )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("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 ( FALSE == pScanSRV->bNoScanCompleteFlag )
+    {
+        pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0;
+    }
+
+    /* copy scan results according to scan type (only meaningful for SPS scan) */
+    if ( FALSE == pScanSRV->bSPSScan ) 
+    {
+        /* normal scan - no result is available */
+        pScanSRV->bTSFError = FALSE;
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                                 ("Normal scan completed.\n") );
+    }
+    else
+    {
+        /* SPS scan - first byte indicates whether a TSF error (AP recovery) occured */
+        if ( 0 != str[ 0 ] )
+        {
+            pScanSRV->bTSFError = TRUE;
+        }
+        else
+        {
+            pScanSRV->bTSFError = FALSE;
+        }
+
+        /* next two bytes indicates on which channels scan was attempted */
+/*        pScanSRV->SPSScanResult = ENDIAN_HANDLE_WORD( *((UINT16*)&(str[ 1 ])) ); */
+
+/* Swap of aligned UINT16* */
+        COPY_UNALIGNED_WORD(&pScanSRV->SPSScanResult, &str[1]);
+        pScanSRV->SPSScanResult = ENDIAN_HANDLE_WORD( pScanSRV->SPSScanResult );
+
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                                 ("SPS scan completed. TSF error: %s, SPS result: %x\n",
+                                  (TRUE == pScanSRV->bTSFError ? "Yes": "No"), pScanSRV->SPSScanResult) );
+    }
+
+    /* send a SCAN_COMPLETE event  */
+    scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE );
+}
+
+/**
+ * \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 )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSRV;
+
+    /* mark that no scan complete occured (see sanSRV_scan for more detailed explanation) */
+    pScanSRV->bNoScanCompleteFlag = TRUE;
+
+    /* send a TIMER_EXPIRED event */
+    scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_TIMER_EXPIRED );
+}
+
+/**
+ * \author Ronen Kalish\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)
+ */
+UINT32 MacServices_scanSRVcalculateScanTimeout( TI_HANDLE hScanSRV, scan_Params_t* scanParams, BOOLEAN bConsiderDTIM )
+{
+    UINT32 i, dtimPeriod, beaconInterval,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 */
+        beaconInterval = whalCtrl_GetBeaconInterval(pScanSRV->hHalCtrl);
+        beaconInterval = MacServices_scanSRVConvertTUToMsec( beaconInterval );
+        dtimPeriod = whalCtrl_GetDtimCount(pScanSRV->hHalCtrl);
+        dtimPeriod = beaconInterval*dtimPeriod; 
+    }
+    else
+    {
+        dtimPeriod = 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) + dtimPeriod + 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) + dtimPeriod + 
+                  ((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:
+        WLAN_REPORT_ERROR( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                             ("Trying to calculate timeout for undefined scan type %d\n", scanParams->scanType) );
+        break;
+    }
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                         ("scanSRVcalculateScanTimeout, timeout = %d\n", timeout) );
+
+    return timeout;
+}
+
+/**
+ * \author Ronen Kalish\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
+ */
+UINT32 MacServices_scanSRVConvertTUToMsec( UINT32 tu )
+{
+    return (tu * 1024) / 1000;
+}
+
+#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
+ * \return always 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/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.h
new file mode 100644 (file)
index 0000000..48bce0d
--- /dev/null
@@ -0,0 +1,297 @@
+/** \file ScanSrv.h
+ *  \brief This file include private definitions for the scan SRV module.
+ *  \author Ronen Kalish
+ *  \date 29-Dec-2004
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANSRV_H__
+#define __SCANSRV_H__
+
+#include "MacServices_api.h"
+#include "fsm.h"
+#include "whalCtrl_api.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           hHalCtrl;                       /**< HAL ctrl object handle */
+    scan_srvCompleteCB_t scanCompleteNotificationFunc;  /**< 
+                                                         * upper layer (scan concentrator) scan complete 
+                                                         * callback function
+                                                         */
+    TI_HANDLE           scanCompleteNotificationObj;    /**< 
+                                                         * upper layer (scan concentrator) scan complete
+                                                         * callback function
+                                                         */
+    
+    CmdResponseCB_t     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 
+                                                         */
+    failureEventCB_t    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 
+                                                         */
+    UINT16              SPSScanResult;                  /**< 
+                                                         * bitmap indicating which channels were scanned
+                                                         * in an SPS scan
+                                                         */
+    BOOLEAN             bTSFError;                      /** indicates whether a TSF error occured */                                                        /**< 
+                                                         * scan result: indicates a TSF error event and 
+                                                         * which channels were scanned in SPS
+                                                         */
+    BOOLEAN             bDtimOverlapping;               /**< Indicates whether the scan is overlapping DTIM */
+    BOOLEAN             bExitFromDriverMode;            /**< 
+                                                         * Indicates whether to exit driver mode once scan 
+                                                         * is finished
+                                                         */
+    BOOLEAN             bSendNullData;                  /**< 
+                                                         * Indicates whether to send Null data when exiting driver  
+                                                         * mode once scan is finished
+                                                         */
+    BOOLEAN             bScanOnDriverModeFailure;       /**< 
+                                                         * Indicates whether to scan if driver mode entry
+                                                         * wasn't successful
+                                                         */
+    BOOLEAN             bHighPriority;                  /**<
+                                                         * Indicates whether to request high priority 
+                                                         * (overlapping DTIM) scan
+                                                         */
+    BOOLEAN             bSPSScan;                       /**< 
+                                                         * whether the running scan type is SPS (TRUE)
+                                                         * or something else (FALSE). Used to stop a
+                                                         * running scan.
+                                                         */
+    scan_Params_t*      scanParams;                     /**< scan parameters */
+    TI_HANDLE           timer;                          /**< scan operation timer */
+    BOOLEAN             bTimerRunning;                  /**< whether the above timer is running */
+    BOOLEAN             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
+                                                         */
+    PowerMgr_802_11_PsMode_e psRequest;                 /**< 
+                                                         * Indicates if PS was requested or not
+                                                         * for current scan
+                                                         */
+       UINT32                                  numberOfNoScanCompleteToRecovery;
+                                                                                                               /**< 
+                                                                                                                * The number of consecutive no scan complete
+                                                                                                                * that will trigger a recovery notification
+                                                                                                                */
+       UINT32                                  currentNumberOfConsecutiveNoScanCompleteEvents;
+                                                                                                               /**<
+                                                                                                                * The number of consecutivre no scan complete 
+                                                                                                                * events at present
+                                                                                                                */
+    BOOLEAN                 bNoScanCompleteFlag;        /**<
+                                                         * Indicates if the last event was start scan
+                                                         * (true) or no scan complete (false) to be able
+                                                         * to nullify correctly the above counter */
+    UINT32                                     uTriggeredScanTimeOut;      /**<
+                                                         * Time out for starting triggered scan between 
+                                                         * 2 channels */
+} scanSRV_t;
+
+/*
+ ***********************************************************************
+ *  External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *  External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Yuval Adler\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 );
+
+/**
+ * \author Yuval Adler\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 );
+
+/**
+ * \author Yuval Adler\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 hReport - handle to the report object.\n
+ * \param hPowerMngr - handle to the power manager object.\n
+ * \param hHalCtrl - handle to the HAL ctrl object.\n
+  */
+void MacServices_scanSRV_init( TI_HANDLE hMacServices, TI_HANDLE hReport, TI_HANDLE hHalCtrl);
+
+/**
+ * \author Ronen Kalish\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, scanSrvInitParams_t* pInitParams );
+
+/**
+ * \author Ronen Kalish\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)
+ */
+UINT32 MacServices_scanSRVcalculateScanTimeout( TI_HANDLE hScanSrv, scan_Params_t* scanParams, BOOLEAN bConsiderDTIM );
+
+/**
+ * \author Ronen Kalish\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
+ */
+UINT32 MacServices_scanSRVConvertTUToMsec( UINT32 tu );
+
+/**
+ * \author Yuval Adler\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,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/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.c
new file mode 100644 (file)
index 0000000..680df3f
--- /dev/null
@@ -0,0 +1,620 @@
+/** \file ScanSrvSM.c
+ *  \brief This file include the scan SRV Sm implementation
+ *  \author Ronen Kalish
+ *  \date 10-Jan-2005 
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "ScanSrvSM.h"
+#include "ScanSrv.h"
+#include "report.h"
+#include "MacServices_api.h"
+#include "utils.h"
+#include "PowerSrv_API.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 OK if successful, 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, actionNop},                                             /*"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, 
+                       (UINT8)SCAN_SRV_NUM_OF_STATES, (UINT8)SCAN_SRV_NUM_OF_EVENTS, 
+                       (fsm_eventActivation_t)scanSRVSM_SMEvent, pScanSRV->hOS );
+}
+
+#ifdef TI_DBG
+/* state descriptions, for state machine logging */
+static char stateDesc[ SCAN_SRV_NUM_OF_STATES ][ MAX_DESC_STRING_LEN ] = 
+{
+    "STATE_IDLE\0",
+    "STATE_PS_WAIT\0",
+    "STATE_SCANNING\0",
+    "STATE_STOPPING\0",
+    "STATE_PS_EXIT\0"
+};
+
+/* event descriptions, for state machine logging */
+static char eventDesc[ SCAN_SRV_NUM_OF_EVENTS ][ MAX_DESC_STRING_LEN ] = 
+{
+    "EVENT_REQUEST_PS\0",
+    "EVENT_PS_FAIL\0",
+    "EVENT_PS_SUCCESS\0",
+    "EVENT_PS_PEND\0",
+    "EVENT_STOP_SCAN\0",
+    "EVENT_FW_RESET\0",
+    "EVENT_TIMER_EXPIRED\0",
+    "EVENT_SCAN_COMPLETE\0",
+};
+#endif /* TI_DBG */
+/**
+ * \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 OK if successful, 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 = OK;
+    UINT8 nextState;
+
+    /* obtain the next state */
+    status = fsm_GetNextState( pScanSRV->SM, (UINT8)*currentState, (UINT8)event, &nextState );
+    if ( status != OK )
+    {
+        WLAN_REPORT_ERROR(pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                          ("Failed getting scan SRV next state. state = %d event = %d\n",
+            (UINT8)*currentState,(UINT8)event));
+        return NOK;
+    }
+
+#ifdef TI_DBG
+    /* report the move */
+    WLAN_REPORT_SM( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                    ("SCAN SRV: <%s, %s> --> %s\n\n",
+                    stateDesc[(UINT8)*currentState],
+                    eventDesc[(UINT8)event],
+                    stateDesc[nextState]) );
+#endif
+
+    /* move */
+    return fsm_Event( pScanSRV->SM, (UINT8*)currentState, (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 OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanSRVSM_requestPS( TI_HANDLE hScanSrv )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+    TI_STATUS psStatus;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("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 */
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                                 ("Driver mode successful, continuing to scan.\n") );
+        return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS );
+/*        break; */
+
+    /* if pending */
+    case PENDING:
+    case OK:
+        /* send a PS_PEND event */
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                                 ("Driver mode pending, Waiting.\n") );
+        return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_PEND );
+/*        break; */
+
+    /* if not successful */
+    default:
+
+        /* mark not to exit from driver mode (no entry was performed) */
+        pScanSRV->bExitFromDriverMode = FALSE;
+
+        /* if still wishing to scan */
+        if ( pScanSRV->bScanOnDriverModeFailure )
+        {
+            /* send a PS_SUCCESS event - scan will proceed regardless of the error */
+            WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                                    ("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 = NOK;
+            /* send a PS_FAIL event */
+            WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                                    ("Driver mode failed, aborting scan.\n") );
+            scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL );
+        }
+        break;
+    }
+
+    return 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 OK if successful, NOK otherwise.\n
+ */
+
+TI_STATUS scanSRVSM_releasePS( TI_HANDLE hScanSrv )
+{
+      scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+      TI_STATUS psStatus;
+    
+     /* stop timer */
+    if ( TRUE == pScanSRV->bTimerRunning )
+    {
+        os_timerStop( pScanSRV->hOS, pScanSRV->timer );
+        pScanSRV->bTimerRunning = FALSE;
+    }
+  
+    /* if exit from driver mode requested, do so */
+    if ( TRUE == pScanSRV->bExitFromDriverMode )
+    {
+        /* here we need to get an answer if we succeeded to exit driver mode */
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+            ("%s: Releasing Driver mode from Power Srv.\n", __FUNCTION__) );
+        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 */
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+            ("%s: Driver mode exit successful, scan done.\n", __FUNCTION__) );
+        return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_SUCCESS );
+/*        break; */
+        
+        /* if pending */
+    case PENDING:
+    case OK:
+        /* stay in the PS_EXIT state */
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+            ("%s: Driver mode exit pending, Waiting.\n", __FUNCTION__) );
+        break; 
+        
+        /* if not successful */
+    default:
+        
+        /* send a PS_FAIL event */
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                ("%s: Driver mode exit failed, scan done.", __FUNCTION__) );
+        return scanSRVSM_SMEvent( hScanSrv, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_PS_FAIL );
+
+    }
+
+    return 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 OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanSRVSM_startActualScan( TI_HANDLE hScanSrv )
+{ 
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+
+    /* start the timer */
+    pScanSRV->bTimerRunning = TRUE;
+    os_timerStart( pScanSRV->hOS, pScanSRV->timer, 
+                   MacServices_scanSRVcalculateScanTimeout( hScanSrv, pScanSRV->scanParams, !pScanSRV->bDtimOverlapping ), FALSE );
+    
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("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 = (TI_STATUS)whalCtrl_StartSPSScan( pScanSRV->hHalCtrl, pScanSRV->scanParams , (void *)MacServices_scanSRVCommandMailBoxCB, hScanSrv);
+    }
+    else
+    {    
+        pScanSRV->returnStatus = (TI_STATUS)whalCtrl_StartScan( pScanSRV->hHalCtrl, pScanSRV->scanParams, pScanSRV->bHighPriority , (void *)MacServices_scanSRVCommandMailBoxCB, hScanSrv );
+    }
+    /* if scan request failed */
+    if ( OK != pScanSRV->returnStatus )
+    {
+        WLAN_REPORT_ERROR( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                           ("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 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 OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanSRVSM_notifyScanComplete( TI_HANDLE hScanSrv )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+    CmdResponseCB_t 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 ( 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 OK */
+            CB_Func(CB_Handle, OK);
+             
+        }
+        /* if function returns TRUE than we are in PS mode , else - not */
+        PSMode = ((TRUE == powerSrv_getPsStatus(pScanSRV->hPowerSrv)) ? POWER_SAVE_802_11_SUCCESS : POWER_SAVE_802_11_FAIL);
+
+        WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("scanSRVSM_notifyScanComplete status = 0x%x PSMode = 0x%x\n",pScanSRV->returnStatus,PSMode) );
+
+
+        pScanSRV->scanCompleteNotificationFunc( pScanSRV->scanCompleteNotificationObj, 
+                                                pScanSRV->SPSScanResult, pScanSRV->bTSFError,pScanSRV->returnStatus, PSMode );
+    }
+    return 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 OK if successful, 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 )
+    {
+        WLAN_REPORT_ERROR( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, 
+                           ("%s: Timer expired. Starting recovery process.\n", __FUNCTION__) );
+
+        pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents = 0;
+
+        /* mark the return status */
+        pScanSRV->returnStatus = NOK;
+
+        /* mark that the timer is no longer running */
+        pScanSRV->bTimerRunning = FALSE;
+
+        /* call the recovery module */
+        pScanSRV->failureEventFunc(pScanSRV->failureEventObj ,NO_SCAN_COMPLETE_FAILURE);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                           ("%s: Timer expired. consecutive failures:%d, threshold:%d, still not calling recovery.\n", 
+                            __FUNCTION__, pScanSRV->currentNumberOfConsecutiveNoScanCompleteEvents,
+                            pScanSRV->numberOfNoScanCompleteToRecovery) );
+
+        /* send a top scan command, which can help solving the FW bug described above */
+        if ( FALSE == pScanSRV->bSPSScan )
+        {
+            whalCtrl_StopScan( pScanSRV->hHalCtrl ,NULL, NULL );
+        }
+        else
+        {
+            whalCtrl_StopSPSScan( pScanSRV->hHalCtrl ,NULL, NULL );
+        }
+
+        /* imitate a scan complete event to the SM */
+        pScanSRV->bTSFError = FALSE;
+        pScanSRV->SPSScanResult = 0xffff;
+        scanSRVSM_SMEvent( (TI_HANDLE)pScanSRV, (scan_SRVSMStates_e*)&pScanSRV->SMState, SCAN_SRV_EVENT_SCAN_COMPLETE );
+    }
+
+    return 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 OK if successful, NOK otherwise.\n
+ */
+static TI_STATUS scanSRVSM_PsFailWhileScanning( TI_HANDLE hScanSrv )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("scanSRVSM_PsFailWhileScanning. Indicate not to Enter PS.\n") );
+
+    pScanSRV->bExitFromDriverMode = FALSE;
+
+    return 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 OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanSRVSM_handleRecovery( TI_HANDLE hScanSrv )
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+
+    WLAN_REPORT_INFORMATION( pScanSRV->hReport, SCAN_SRV_MODULE_LOG, ("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 ( TRUE == pScanSRV->bTimerRunning )
+    {
+        os_timerStop( pScanSRV->hOS, pScanSRV->timer );
+        pScanSRV->bTimerRunning = FALSE;
+    }
+    else
+    {
+        /* shouldn't happen - only called if timer is supposedly running */
+        WLAN_REPORT_WARNING( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                             ("SM: External FW reset in state %d and timer is not running?", pScanSRV->SMState) );
+    }
+
+    return 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 OK.\n
+ */
+static TI_STATUS actionUnexpected( TI_HANDLE hScanSrv ) 
+{
+    scanSRV_t *pScanSRV = (scanSRV_t*)hScanSrv;
+
+    WLAN_REPORT_ERROR( pScanSRV->hReport, SCAN_SRV_MODULE_LOG,
+                       ("Scan SRV state machine error, unexpected Event, state=%d\n\n", pScanSRV->SMState) );
+
+    if ( pScanSRV->bTimerRunning )
+    {
+        os_timerStop( pScanSRV->hOS, pScanSRV->timer );
+        pScanSRV->bTimerRunning = 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 = NOK;
+    
+    return 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 OK.\n
+ */
+static TI_STATUS actionNop( TI_HANDLE hScanSrv )
+{   
+    return OK;
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.h
new file mode 100644 (file)
index 0000000..e0f544e
--- /dev/null
@@ -0,0 +1,214 @@
+/** \file ScanSrvSM.h
+ *  \brief This file include definitions for the scan SRV SM module.
+ *  \author Ronen Kalish
+ *  \date 10-Jan-2005
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCANSRVSM_H__
+#define __SCANSRVSM_H__
+
+#include "commonTypes.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 OK if successful, 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 OK if successful, 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 OK if successful, 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 OK if successful, 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 OK if successful, 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 OK if successful, 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 OK if successful, 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 OK if successful, 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 OK if successful, NOK otherwise.\n
+ */
+TI_STATUS scanSRVSM_handleRecovery( TI_HANDLE hScanSrv );
+
+#endif /* __SCANSRVSM_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/tiwlanspi.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/tiwlanspi.c
new file mode 100644 (file)
index 0000000..85fe033
--- /dev/null
@@ -0,0 +1,38 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifdef _WINDOWS
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/whalHwAccess.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/whalHwAccess.c
new file mode 100644 (file)
index 0000000..500a11a
--- /dev/null
@@ -0,0 +1,2896 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**     
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/****************************************************************************
+ *
+ *   MODULE:  hwAccess.c
+ *   PURPOSE: Support access to the wlan hardware registers and memory
+ *
+ *  Direct Slave mode:   
+ *  -----------------
+ *
+ *      1. 08 bit function 
+ *              - access 16 bit (WA100 has no access to 8 bits)
+ *              - set/get the relevant byte according to the address (odd or even)
+ *              + ((char *)&DataShort)[Addr&0x1]
+ *              - no endian handle 
+ *      2. 16 bit function 
+ *              - access 16 bit 
+ *              - short endian handle 
+ *      3. 32 bit function 
+ *              - access 32 bit 
+ *              - long endian handle 
+ *      4. buffers copy to (stream of bytes)
+ *              - addresses must be even
+ *              - copy buffer as stream of 16 bits (in case of src/dst address ends with 0x2)
+ *              - handle case of more bytes to copy
+ *              * TempWord = (*shortDest & 0x00ff) | (*shortSrc & 0xff00);
+ *              - no endian handle 
+ *      5. registers
+ *              - access 32 bit 
+ *              - long endian handle 
+ *              - no use of wlan hardware capability to swap endian
+ *
+ *  Indirect Slave mode:
+ *  -------------------
+ *
+ *      1. 08 bit function 
+ *              - access 16 bit (WA100 has no access to 8 bits)
+ *              - set/get the relevant byte according to the address (odd or even)
+ *              + ((char *)&DataLong)[Addr&0x3]
+ *              - no endian handle  
+ *      2. 16 bit function 
+ *              - access 32 bit (set addr reg , get data reg) 
+ *              - set/get the relevant short according to the address (00 or 02) 
+ *              + ((short *)&DataLong)[(Addr>>1)&0x1])
+ *              - short endian handle 
+ *      3. 32 bit function 
+ *              - access 32 bit (set addr reg , get data reg) 
+ *              - long endian handle 
+ *      4. buffers copy to (stream of bytes)
+ *              - addresses must be even
+ *              - handle case of dest(wlan hardware) address ends with 0x2 - read 32 from 0x0, set only high short
+ *              - now the dest(wlan hardware) address is long address
+ *              - use Auto Increment Mode
+ *              - copy buffer as stream of 16 bits (in case of source address ends with 0x2)
+ *              - handle case of more bytes to copy
+ *              * i=0..Len&3 ==> ((char *)&DataLong)[i] = ((char *)shortSrc)[i]
+ *              - no endian handle 
+ *      5. buffers copy from (stream of bytes)
+ *              - addresses must be even
+ *              - handle case of source(wlan hardware) address ends with 0x2 - read 32 from 0x0, set only high short
+ *              - now the source(wlan hardware) address is long address
+ *              - use Auto Increment Mode
+ *              - copy buffer as stream of 16 bits (in case of dest address ends with 0x2)
+ *              - handle case of more bytes to copy
+ *              * i=0..Len&3 ==> ((char *)shortDest)[i] = ((char *)&DataLong)[i]
+ *              - no endian handle 
+ *      6. registers
+ *              - access 32 bit 
+ *              - long endian handle 
+ *              - no use of wlan hardware capability to swap endian
+ *
+ ****************************************************************************/
+#include "osTIType.h"
+#include "osApi.h"
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#ifdef HW_ACCESS_SDIO 
+
+  #ifndef _WINDOWS  /*Linux, Symbian, RVCT */
+
+#include "mmc_omap_api.h"
+#include "mmc_tnetw1150_api.h"
+
+  #else /* ifdef _WINDOWS */
+  #endif /* ifdef _WINDOWS */
+
+#elif HW_ACCESS_WSPI
+
+#include "wspi.h" 
+
+#endif
+#include "TNETWIF.h"
+#include "whalHwAccess.h"
+
+/* #define __HWACCESS_DEBUG__ */
+
+/*
+ * Define this flag to support SDIO asynchronous mode
+ */
+#undef HW_ACCESS_SDIO_ASYNC_SUPPORT
+
+
+/************************************************************************
+ * Types
+ ************************************************************************/
+typedef struct _HWAccess_CB_T
+{
+    HwAccess_callback_t CBFunc;
+    void* CBArg;
+} HWAccess_CB_T;
+
+typedef void (*HwAccessErrorHandle)(TI_HANDLE theObjectHandle,char* Report , UINT32 strLen);
+
+typedef  struct _partition_t
+{
+    UINT32 size;
+    UINT32 start;
+} partition_t;
+
+
+/* HwAccess context */
+typedef struct _HwAccess_T_new
+{
+    void       *hProtect;
+
+    TI_HANDLE   hOs;           
+    TI_HANDLE   hReport;
+
+#if (defined(HW_ACCESS_SDIO)|defined(HW_ACCESS_WSPI))
+    TI_HANDLE   hDriver;
+    UINT32      MemRegionAddr;
+    UINT32      RegisterRegionAddr;
+    UINT32      workingPartUpperLimit;
+    UINT32      registerPartUpperLimit;
+#else /* HW_ACCESS_CARDBUS */   
+    UINT32      RegBaseAddr;
+    UINT32      MemBaseAddr;
+#endif
+
+    HWAccess_CB_T CB;
+    
+    UINT8       AsyncMode;
+
+    UINT32      uBusError;
+    HwAccessErrorHandle hwAccesserror_Cb;
+    TI_HANDLE   hBackReference;
+
+    PADDING (partition_t partition [2])
+
+} HwAccess_T_new;
+
+
+/************************************************************************
+ * Defines
+ ************************************************************************/
+
+#ifdef HW_ACCESS_WSPI
+
+/*
+ *  Converts status from WSPI into TI_STATUS
+ */
+#define WSPI2TNETWIF(pHwAccess,status,addr)                                   \
+    switch(status)  {                                                         \
+        case WSPI_TXN_PENDING:  status = TNETWIF_PENDING; break;              \
+        case WSPI_TXN_COMPLETE: status = TNETWIF_COMPLETE; break;             \
+        default:                                                              \
+            WLAN_REPORT_ERROR (pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,    \
+                               ("whal_hwAccess: Error in read/write async, addr=0x%08x status=%d\n", \
+                               addr, status));                                \
+            status = TNETWIF_ERROR; break;                                    \
+}
+              
+/* 
+* Indicate the index position at which we should check if the HW is up - 
+* i.e. (buf[HW_ACCESS_WSPI_FIXED_BUSY_LEN] & 0x1 == TRUE)
+*/
+#ifdef TNETW1251
+#define HW_ACCESS_WSPI_FIXED_BUSY_LEN       ((TNETWIF_READ_OFFSET_BYTES - 4 ) / sizeof(UINT32))
+#else
+#define HW_ACCESS_WSPI_FIXED_BUSY_LEN       0
+#endif
+
+#endif /* HW_ACCESS_WSPI */
+
+#define HW_ACCESS_WSPI_INIT_CMD_MASK        0
+
+#define HW_ACCESS_WSPI_ALIGNED_SIZE         4
+#define HW_ACCESS_NUM_OF_BIT_IN_BYTE        8
+
+#define HW_ACCESS_REGISTER_SIZE             4
+
+
+/* ELP CTRL  register */
+#define HW_ACCESS_ELP_CTRL_REG_ADDR         0x1FFFC
+
+
+#define HW_ACCESS_1_BYTE_REMINDE_MASK       0x000000FF
+#define HW_ACCESS_2_BYTE_REMINDE_MASK       0x0000FFFF
+#define HW_ACCESS_3_BYTE_REMINDE_MASK       0x00FFFFFF
+
+/* translation registers */
+#define HW_ACCESS_PART0_SIZE_ADDR           0x1FFC0
+#define HW_ACCESS_PART0_START_ADDR          0x1FFC4
+#define HW_ACCESS_PART1_SIZE_ADDR           0x1FFC8
+#define HW_ACCESS_PART1_START_ADDR          0x1FFCC
+
+
+/************************************************************************
+ * Macros
+ ************************************************************************/
+#define EXTRACT_BYTE_FROM_WORD(DataShort, Addr)     (((char *)&DataShort)[((int)Addr)&0x1])
+#define EXTRACT_BYTE_FROM_LONG(DataLong, Addr)      (((char *)&DataLong )[((int)Addr)&0x3])
+#define EXTRACT_WORD_FROM_LONG(DataLong, Addr)      (((short *)&DataLong)[(((int)Addr>>1))&0x1])
+#define EXTRACT_BYTE_LONG(DataLong, i)              (((char *)&DataLong)[i])
+
+#define HW_MEM_SHORT(pHwAccess, Addr)  (*(volatile UINT16 *)(pHwAccess->MemBaseAddr + (UINT32)(Addr)))
+#define HW_MEM_LONG(pHwAccess, Addr)   (*(volatile UINT32 *)(pHwAccess->MemBaseAddr + (UINT32)(Addr)))
+
+#define TRANSLATE_ADDRESS_MEM(addr) ((addr) - pHwAccess->MemRegionAddr)
+#define TRANSLATE_ADDRESS_REG(addr) ((addr) + pHwAccess->RegisterRegionAddr)
+
+#if 1 /* 0 */
+    #if (defined(HW_ACCESS_SDIO)|defined(HW_ACCESS_WSPI)) /* 1 */
+        void HW_REG_LONG_WRITE(HwAccess_T_new *pHwAccess, UINT32 RegAddr, UINT32 BitVal);
+        void HW_REG_LONG_READ(HwAccess_T_new *pHwAccess, UINT32 RegAddr, UINT32 *Val);
+    #else /* 1 */
+        #define HW_REG_SHORT_WRITE(pHwAccess, Addr, Data) ((*(volatile UINT16 *)(pHwAccess->RegBaseAddr + (UINT32)(Addr))) = (UINT16)(Data))
+        #define HW_REG_SHORT_READ(pHwAccess, Addr, Data)  ((*(Data)) = (*(volatile UINT16 *)(pHwAccess->RegBaseAddr + (UINT32)(Addr))) )
+        #ifdef NOT_SUPPORT_32_BIT_ACCESS_COMMAND /* for example: iPAQ model 38xx */ /* 2 */
+            #define HW_REG_LONG_WRITE(pHwAccess, Addr, Data)  HW_REG_SHORT_WRITE(pHwAccess, Addr, Data); HW_REG_SHORT_WRITE(pHwAccess, Addr+2, ((UINT16)(Data>>16)))
+            #define HW_REG_LONG_READ(pHwAccess, Addr, pData)   HW_REG_SHORT_READ(pHwAccess, Addr, pData); HW_REG_SHORT_READ(pHwAccess, Addr+2, ((UINT16 *)pData+1))
+        #else /* 2 */
+            #define HW_REG_LONG_WRITE(pHwAccess, Addr, Data)  ((*(volatile UINT32 *)(pHwAccess->RegBaseAddr + (UINT32)(Addr))) = (UINT32)(Data))
+            #define HW_REG_LONG_READ(pHwAccess, Addr, Data)   ((*(Data)) = (*(volatile UINT32 *)(pHwAccess->RegBaseAddr + (UINT32)(Addr))) )
+        #endif /* 2 */
+    #endif /* 1 */
+#else  /* 0 */
+#endif /* 0 */
+
+
+
+/************************************************************************
+ * Functions
+ ************************************************************************/
+
+#if !defined(HW_ACCESS_SDIO) && !defined(HW_ACCESS_WSPI)
+static void whal_hwAccess_DirectCopy_new(HwAccess_T_new *pHwAccess, UINT8* Dest, UINT8* Src, UINT32 Len);
+#endif
+#ifdef HW_ACCESS_SDIO
+static void sdio_transaction_notify_read(struct SDIO_Request *req, int status);
+static void sdio_transaction_notify_write(struct SDIO_Request *req, int status);
+static void sdio_transaction_error(struct SDIO_Request *req, int stat);
+#ifdef CONFIG_ASYNC_API
+static void sdio_async_transaction_notify(struct SDIO_Request *req, int status);
+static void sdio_async_transaction_error(struct SDIO_Request *req, int status);
+#endif
+#endif
+
+/* 
+** Read/Write interface
+**----------------------------
+**
+** the memory space shell be divided to 2 Partions: Memory, and Registers.
+** 1.   The memory Region will be set at init to point to the FW Ram, 
+**      and after FW init complete, the Memory Region will be set to point the Packet Ram.
+** 2.   Registry Region.
+** 
+** 
+*/
+
+/************************************************************************
+ * new API
+ ************************************************************************/
+
+
+
+/****************************************************************************
+ *                      whal_hwAccess_Create
+ ****************************************************************************
+ * DESCRIPTION: create the HwAccess module. allocate the module context and create the sublayers
+ *
+ * INPUTS:  hOs - handle to the OS module
+ *
+ * OUTPUT:  TI_HANDLE - the handle to the context that was created
+ *
+ * RETURNS: NULL = failure.
+ *          otherwise = success
+ ****************************************************************************/
+TI_HANDLE   whal_hwAccess_Create(TI_HANDLE hOs)
+{
+    HwAccess_T_new *pHwAccess;
+    int status = OK;
+#ifdef HW_ACCESS_SDIO
+    SDIO_ConfigParams configParams;
+#endif  
+    pHwAccess = os_memoryAlloc(hOs, sizeof(HwAccess_T_new));
+    if (pHwAccess == NULL)
+        return NULL;
+    
+    os_memoryZero(hOs, pHwAccess, sizeof(HwAccess_T_new));
+    
+    pHwAccess->hOs = hOs;
+
+    pHwAccess->hProtect = os_protectCreate(pHwAccess->hOs);
+    if (pHwAccess->hProtect == NULL)
+    {
+        whal_hwAccess_Destroy(pHwAccess);
+        return NULL;
+    }
+    
+#ifdef HW_ACCESS_SDIO
+
+    pHwAccess->AsyncMode = FALSE;
+    
+    os_memoryZero(hOs, &configParams, sizeof(SDIO_ConfigParams));
+    configParams.fnotify_read = sdio_transaction_notify_read; 
+    configParams.fnotify_write = sdio_transaction_notify_write; 
+    configParams.ferror = sdio_transaction_error;  
+    configParams.fconfig_peripheral = SDIO_TNETWConfig; 
+    configParams.fconvert = NULL;
+    configParams.owner = pHwAccess;
+
+    status = SDIO_Init(&configParams, &pHwAccess->hDriver); 
+    
+#elif HW_ACCESS_WSPI
+
+    pHwAccess->AsyncMode = TRUE;
+
+    pHwAccess->hDriver = WSPI_Open (pHwAccess->hOs);
+    status = pHwAccess->hDriver == NULL;    
+    
+#else
+
+    pHwAccess->AsyncMode = FALSE;
+    
+#endif
+
+    if (status != 0) 
+    {
+        if (pHwAccess->hProtect)
+            os_protectDestroy(pHwAccess->hOs, pHwAccess->hProtect);
+        os_memoryFree(pHwAccess->hOs, pHwAccess, sizeof(HwAccess_T_new));
+        return NULL;
+    }
+    
+    return pHwAccess;
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_Destroy
+ ****************************************************************************
+ * DESCRIPTION: destroy the module. deallocate the cmodule context.
+ *
+ * INPUTS:  hHwAccess - handle to the module context
+ *
+ * OUTPUT:  none.
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_Destroy(TI_HANDLE hHwAccess)
+{
+    HwAccess_T_new *pHwAccess = (HwAccess_T_new*)hHwAccess;
+
+    if (pHwAccess)
+    {
+#ifdef HW_ACCESS_SDIO
+
+        SDIO_Stop(pHwAccess->hDriver, 0);
+        SDIO_Shutdown(pHwAccess->hDriver);  
+
+#elif HW_ACCESS_WSPI
+
+        WSPI_Close(pHwAccess->hDriver);
+
+#endif      
+    
+    
+        if (pHwAccess->hProtect)
+            os_protectDestroy(pHwAccess->hOs, pHwAccess->hProtect);
+        os_memoryFree(pHwAccess->hOs, pHwAccess, sizeof(HwAccess_T_new));       
+    }
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwAccess_Config
+ ****************************************************************************
+ * DESCRIPTION: config the module.
+ *
+ * INPUTS:  hHwAccess   - handle to the module context
+ *          hReport     - handle to report module context that is used when we output debug messages
+ *
+ * OUTPUT:  none.
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_Config(TI_HANDLE hHwAccess, TI_HANDLE hReport,UINT32 RegBaseAddr, UINT32 MemBaseAddr, HwAccess_callback_t CBFunc,void* CBArg)
+{
+    HwAccess_T_new *pHwAccess = (HwAccess_T_new*) hHwAccess;
+    int status = OK;
+
+#ifdef HW_ACCESS_WSPI
+    WSPIConfig_t wspi_config;        
+#endif
+
+    pHwAccess->hReport = hReport;
+
+#ifdef GWSI_SPI_TEST
+       /* For GWSI_API_TEST this parameter should be maximum allowed because we don't use setPartition */
+       pHwAccess->workingPartUpperLimit = 0xFFFFFFFF;
+#endif /* GWSI_API_TEST */
+    /*
+    Wait 200 usec for memory repair process to finish and device is ready.
+    */
+    os_StalluSec(pHwAccess->hOs, 200);
+    
+    pHwAccess->CB.CBFunc = CBFunc;
+    pHwAccess->CB.CBArg = CBArg;
+
+#ifdef HW_ACCESS_SDIO
+
+    pHwAccess->RegisterRegionAddr = HW_ACCESS_DOWN_PART0_SIZE;
+    pHwAccess->MemRegionAddr = HW_ACCESS_DOWN_PART0_ADDR;
+    pHwAccess->uBusError = 0;
+
+    status = SDIO_Start (pHwAccess->hDriver);
+
+    status = (status == SDIO_SUCCESS) ? TNETWIF_COMPLETE : TNETWIF_ERROR;
+
+#elif HW_ACCESS_WSPI
+
+    wspi_config.isFixedAddress = FALSE;
+    wspi_config.fixedBusyLength = HW_ACCESS_WSPI_FIXED_BUSY_LEN;
+    wspi_config.mask = HW_ACCESS_WSPI_INIT_CMD_MASK;
+        
+    status = WSPI_Configure (pHwAccess->hDriver, 
+                             pHwAccess->hReport, 
+                             &wspi_config, 
+                             (WSPI_CB_T*)&pHwAccess->CB);
+
+       WSPI_SetErrLog(pHwAccess->hDriver, TNETWIF_printErrorLog);
+
+    WSPI2TNETWIF (pHwAccess, status, 0x0);
+
+#else /* HW_ACCESS_CARDBUS */   
+    pHwAccess->RegBaseAddr = RegBaseAddr;
+    pHwAccess->MemBaseAddr = MemBaseAddr;       
+#endif
+
+    return status;
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_ReConfig()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+int whal_hwAccess_ReConfig(TI_HANDLE hHwAccess)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+
+#ifdef _WINDOWS
+#else /* _WINDOWS */
+    /* unbclock the access to the bus */
+    pHwAccess->uBusError = 0;
+
+#ifdef HW_ACCESS_SDIO
+    SDIO_Stop (pHwAccess->hDriver, 0);
+    SDIO_Start (pHwAccess->hDriver);
+#elif HW_ACCESS_WSPI
+    /* TODO*/
+#endif
+#endif /* _WINDOWS */
+    return OK;
+}
+
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      whal_hwAccess_WriteELP
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously to the TNET ELP register (1byte)
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE * - the HwAccess context
+ *          data - UINT8 - the data to write
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_WriteELP (TI_HANDLE hHwAccess, UINT32 data)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+#ifdef HW_ACCESS_SDIO
+    status = SDIO_TNETW_Set_ELP_Reg(pHwAccess->hDriver, HW_ACCESS_ELP_CTRL_REG_ADDR, data);
+#elif HW_ACCESS_WSPI
+    status = WSPI_WriteSync (pHwAccess->hDriver, HW_ACCESS_ELP_CTRL_REG_ADDR, (UINT8*)&data, HW_ACCESS_REGISTER_SIZE); 
+#endif
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwAccess_WriteReg_ELP: Error in ELP reg write status=%d\n",
+                          status));
+        return NOK; 
+    }
+
+    return OK;
+}
+#endif /* USE_SYNC_API */
+
+/****************************************************************************
+ *                      whal_hwAccess_WriteELPAsync
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is always 4bytes cause this is the size of the TNET registers
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE * - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *          bMore - indicate whether more txn on the bus are about to happen (FALSE only when setting
+ *                  the HW to sleep).
+ *
+ * OUTPUT:  none                                                                
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_WriteELPAsync (TI_HANDLE hHwAccess, UINT32 data, BOOL bCb, BOOL bMore)
+{
+#if defined(HW_ACCESS_SDIO)
+  #if defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+
+    #error "SDIO asynchronous mode is not supported"
+
+    /* Not implemented yet */
+    return OK;
+
+  #else
+
+     /* Just call to synchronous API */
+    return (whal_hwAccess_WriteELP (hHwAccess, data) == OK) ? 
+           TNETWIF_COMPLETE :
+           TNETWIF_ERROR;
+
+
+  #endif
+
+#else /* HW_ACCESS_WSPI */
+
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    WSPI_CB_T Cb = { NULL, NULL }, *pCb;
+    int status;
+
+    pCb = (bCb) ? ((WSPI_CB_T*)&pHwAccess->CB) : &Cb;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    /* since we are writing a register - no extra space is needed */
+    status = WSPI_WriteAsync (pHwAccess->hDriver, 
+                              HW_ACCESS_ELP_CTRL_REG_ADDR, 
+                              (UINT8*)&data, 
+                              HW_ACCESS_REGISTER_SIZE,
+                              pCb,
+                              bMore,
+                              FALSE);   
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    WSPI2TNETWIF (pHwAccess, status, HW_ACCESS_ELP_CTRL_REG_ADDR);
+
+    return status;
+
+#endif
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_ReadELPAsync
+ ****************************************************************************
+ * DESCRIPTION: Read the ELP register
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE * - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer to read data into
+ *          bMore - indicate whether more txn on the bus are about to happen (FALSE only when setting
+ *                  the HW to sleep).
+ *
+ * OUTPUT:  none                                                                
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_ReadELPAsync (TI_HANDLE hHwAccess, UINT8 *data, BOOL bCb, BOOL bMore)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status;      
+
+#ifdef HW_ACCESS_SDIO
+
+       #ifndef _WINDOWS
+       status = SDIO_TNETW_Get_ELP_Reg(pHwAccess->hDriver, HW_ACCESS_ELP_CTRL_REG_ADDR, (UINT32*)data);
+       #else
+       #endif
+
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                       ("whal_hwAccess_ReadELPAsync: Error in ELP reg raed status=%d\n",
+                       status));
+               return TNETWIF_ERROR; 
+       }
+       return TNETWIF_COMPLETE;
+
+#else /* HW_ACCESS_WSPI */
+        
+        os_profile (pHwAccess->hOs, 2, 0);
+        
+        /* In registers we don't save place */
+        status = WSPI_ReadAsync (pHwAccess->hDriver, 
+            HW_ACCESS_ELP_CTRL_REG_ADDR, 
+            (UINT8*)data, 
+            HW_ACCESS_REGISTER_SIZE,
+            (WSPI_CB_T*)&pHwAccess->CB,
+            TRUE,
+            FALSE);   
+        
+        os_profile (pHwAccess->hOs, 3, 0);
+        
+        WSPI2TNETWIF (pHwAccess, status, HW_ACCESS_ELP_CTRL_REG_ADDR);
+        
+        return status;
+        
+#endif
+}
+
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      whal_hwAccess_ReadMem_Align
+ ****************************************************************************
+ * DESCRIPTION: read data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data specified is rounded up so the length will be multiple of 4 (bytes)
+ *
+ * INPUTS:  hHwAccess - the handle of HwAccess module
+ *          addr - UINT32 - the address offset inside the TNET
+ *          len - int - the length of the data to read
+ *
+ * OUTPUT:  data - UINT8* - a pointer to the buffer to fill with the read data
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_ReadMem_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{                                                          
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+#ifdef HW_ACCESS_SDIO
+    struct SDIO_Request request;
+#endif
+    
+    /* round up the length so it will be multiple of 4bytes */
+    if(len&0x3)
+        len = (len&0xFFFFFFFC)+4;
+
+#ifdef HW_ACCESS_SDIO
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMem_Align: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    request.buffer = data; /* Pointer to the data buffer aligned address.  */
+    request.buffer_len = len; /* Data buffer length in bytes */ 
+    request.status = SDIO_Request_None;
+    request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+    request.acquire_window = 0;  /*Time out value is not set*/
+    request.block_len = 0;       /*Block length. Assigned by driver*/
+    request.physical_buffer = 0; /*Physical address of data buffer is not set*/
+    request.owner = (SDIO_Owner) pHwAccess;
+    request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+    request.access_flag = 1;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = SDIO_SyncRead(pHwAccess->hDriver, &request);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    
+#elif HW_ACCESS_WSPI    
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMem_Align: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_ReadSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr),data,len);    
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+#else
+    whal_hwAccess_DirectCopy_new(pHwAccess, data, (UINT8*)addr, len);
+#endif
+
+    if (status != OK)
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_ReadMem_Align: Error in read, addr=0x%08x status=%d\n",
+                             addr, status));
+
+#ifdef HW_ACCESS_SDIO
+    if (pHwAccess->uBusError)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_ReadMem_Align: SDIO Error status=%d\n",
+        request.status));
+        if (pHwAccess->hwAccesserror_Cb) 
+        {
+            UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+            pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,(char*)&failure_reason,2);
+        }
+        else
+            pHwAccess->uBusError = 0;
+    }
+#endif
+
+    return status;
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_WriteMem_Align
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously to the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data specified is rounded up so the length will be multiple of 4 (bytes)
+ *
+ * INPUTS:  hHwAccess - the handle of HwAccess module
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *          len - int - the length of the data to read
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_WriteMem_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+#ifdef HW_ACCESS_SDIO
+    struct SDIO_Request request;
+#endif
+    
+    /* round the length so it will be multiple of 4bytes */
+    if(len&0x3)
+        len = (len&0xFFFFFFFC)+4;
+    
+#ifdef HW_ACCESS_SDIO
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteMem_Align: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+    
+    request.buffer = data; /* Pointer to the data buffer aligned address.  */
+    request.buffer_len = len; /* Data buffer length in bytes */ 
+    request.status = SDIO_Request_None;
+    request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+    request.acquire_window = 0;  /*Time out value is not set*/
+    request.block_len = 0;       /*Block length. Assigned by driver*/
+    request.physical_buffer = 0; /*Physical address of data buffer is not set*/
+    request.owner = (SDIO_Owner) pHwAccess;
+    request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+    request.access_flag = 0;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = SDIO_SyncWrite(pHwAccess->hDriver, &request);  
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+#elif HW_ACCESS_WSPI
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteMem_Align: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_WriteSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr),data,len);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+                
+#else
+    whal_hwAccess_DirectCopy_new(pHwAccess, (UINT8*)addr, data, len);
+#endif
+
+    if (status != OK)
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_WriteMem_Align: Error in write, addr=0x%08x status=%d\n",
+                             addr, status));
+
+#ifdef HW_ACCESS_SDIO
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_WriteMem_Align: SDIO Error in write status=%d\n",
+        request.status));
+        if (pHwAccess->hwAccesserror_Cb) 
+        {
+            UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+            pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,(char*)&failure_reason,2);
+        }
+        else 
+            pHwAccess->uBusError = 0;
+    }
+#endif
+
+    return status;
+}
+#endif /* USE_SYNC_API */
+
+/****************************************************************************
+ *                      whal_hwAccess_ReadMemAsync_Align
+ ****************************************************************************
+ * DESCRIPTION: read data asynchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data specified is rounded up so the length will be multiple of 4 (bytes)
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  hHwAccess - the handle of HwAccess module
+ *          addr - UINT32 - the address offset inside the TNET
+ *          len - int - the length of the data to read
+ *          CB - HWAccess_CB_T* - a pointer to a structure that holds the CB function and the passed arg.
+ *
+ * OUTPUT:  data - UINT8* - a pointer to the buffer to fill with the read data
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_ReadMemAsync_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{       
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+
+    /* Round the length so it will be multiple of 4bytes */
+    if ((len & 0x3) != 0)
+        len = (len & ~3) + 4;
+
+    /* Check address */
+    if (addr + len > pHwAccess->workingPartUpperLimit || addr < pHwAccess->MemRegionAddr)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMemAsync_Align: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+#if defined(HW_ACCESS_SDIO)
+
+  #if defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+    {   
+        struct SDIO_Request request;    
+        int status = OK;
+
+        request.buffer = data; /* Pointer to the data buffer aligned address.  */
+        request.buffer_len = len; /* Data buffer length in bytes */ 
+        request.status = SDIO_Request_None;
+        request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+        request.acquire_window = 0;  /*Time out value is not set*/
+        request.block_len = 0;       /*Block length. Assigned by driver*/
+        request.physical_buffer = 0; /*Physical address of data buffer is not set*/
+        request.owner = (SDIO_Owner) pHwAccess;
+        request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+        request.access_flag = 1;
+        request.fnotify = sdio_async_transaction_notify; /* completion notification */
+        request.ferror = sdio_async_transaction_error; /* error notification */
+
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        status = SDIO_AsyncRead (pHwAccess->hDriver, &request);  
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_ReadMemAsync_Align: Error in read async, addr=0x%08x status=%d\n",
+                             addr, status));
+            return TNETWIF_ERROR;
+        }
+
+        if (pHwAccess->uBusError)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                              ("whal_hwAccess_ReadMemAsync_Align: SDIO Error status=%d\n",
+                              request.status));
+            if (pHwAccess->hwAccesserror_Cb) 
+            {
+                UINT16 failure_reason = HEALTH_REPORT_BUS_ERROR;
+                pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,&failure_reason,2);
+            }
+            else
+                pHwAccess->uBusError = 0;
+        }
+
+        return TNETWIF_COMPLETE;
+    }
+
+  #else
+
+    return TNETWIF_COMPLETE;
+  
+  #endif
+            
+#else /*HW_ACCESS_WSPI*/
+    {
+        int status;
+        
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        status = WSPI_ReadAsync (pHwAccess->hDriver,
+                                 TRANSLATE_ADDRESS_MEM(addr),
+                                 data,
+                                 len,
+                                 (WSPI_CB_T*)&pHwAccess->CB,
+                                 TRUE,
+                                 0);
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        WSPI2TNETWIF (pHwAccess, status, addr);
+
+        return status; 
+    }
+  
+#endif
+}
+
+/****************************************************************************                       
+ *                      whal_hwAccess_WriteAsync_Align
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data specified is rounded up so the length will be multiple of 4 (bytes)
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  pHwAccess - HwAccess_T* - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *          Len - int - the length of the data to read
+ *          CB - HWAccess_CB_T* - a pointer to a structure that holds the CB function and the passed arg.
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+ int         whal_hwAccess_WriteMemAsync_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{           
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+
+    /* Round the length so it will be multiple of 4bytes */
+    if ((len & 0x3) != 0)
+        len = (len & ~3) + 4;
+
+    /* Check address */
+    if (addr + len > pHwAccess->workingPartUpperLimit || addr < pHwAccess->MemRegionAddr)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwAccess_WriteMemAsync_Align: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+                          addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+#if defined(HW_ACCESS_SDIO)
+
+  #if defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+    {    
+        struct SDIO_Request request;    
+        int status = OK;
+
+        request.buffer = data; /*Pointer to the data buffer aligned address*/
+        request.buffer_len = len; /*Data buffer length in bytes*/ 
+        request.status = SDIO_Request_None;
+        request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+        request.acquire_window = 0;  /* Time out value is not set */
+        request.block_len = 0;       /* Block length. Assigned by driver */
+        request.physical_buffer = 0; /* Physical address of data buffer is not set */
+        request.owner = (SDIO_Owner) pHwAccess;
+        request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+        request.access_flag = 0;
+        request.fnotify = sdio_async_transaction_notify; /* completion notification */
+        request.ferror = sdio_async_transaction_error; /* error notification */
+
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        status = SDIO_AsyncWrite (pHwAccess->hDriver, &request);    
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                              ("whal_hwAccess_WriteMemAsync_Align: Error in write async, addr=0x%08x status=%d\n",
+                              addr, status));
+
+            return TNETWIF_ERROR; 
+        }
+
+        return TNETWIF_COMPLETE;
+    }
+
+  #else
+
+    return TNETWIF_COMPLETE;
+
+  #endif
+            
+#else /*HW_ACCESS_WSPI*/
+    {
+        int status;
+
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        status = WSPI_WriteAsync (pHwAccess->hDriver,
+                                  TRANSLATE_ADDRESS_MEM(addr),
+                                  data,
+                                  len,
+                                  (WSPI_CB_T*)&pHwAccess->CB,
+                                  TRUE,
+                                  FALSE);   
+
+        os_profile (pHwAccess->hOs, 3, 0);
+            
+        WSPI2TNETWIF (pHwAccess, status, addr);
+
+        return status;
+    }
+#endif
+}
+
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      whal_hwAccess_ReadMem
+ ****************************************************************************
+ * DESCRIPTION: read data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is checked and the remnant (length%4) is completed with read-modify
+ *
+ * INPUTS:  pHwAccess - HwAccess_T* - the HwAccess context
+ *          AddrOffset - UINT32 - the address offset inside the TNET
+ *          Len - int - the length of the data to read
+ *
+ * OUTPUT:  data - UINT8* - a pointer to the buffer to fill with the read data
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_ReadMem(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{
+    int status = OK;    
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+
+#ifdef HW_ACCESS_SDIO
+    struct SDIO_Request request;
+#elif HW_ACCESS_WSPI
+    int reminder = len%HW_ACCESS_WSPI_ALIGNED_SIZE;
+    int tempLen = len - reminder;
+    UINT32 mask = 0;
+    status = whal_hwAccess_ReadMemAsync(hHwAccess, addr, data, len);
+    if (status == TNETWIF_COMPLETE)
+    {
+        status = OK;
+    }
+    return status;
+#endif
+
+    /* access is blocked */
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_CTRL_MODULE_LOG,
+                              ("Bus is blocked \n"));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+#ifdef __HWACCESS_DEBUG__
+    /* check address alignment */
+    if(addr & 0x3)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMem: addr is not aligned 0x%x\n",
+            addr));     
+    }
+    
+#endif
+        
+#ifdef HW_ACCESS_SDIO
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMem: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    request.buffer = data; /* Pointer to the data buffer aligned address.  */
+    request.buffer_len = len; /* Data buffer length in bytes */ 
+    request.status = SDIO_Request_None;
+    request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+    request.acquire_window = 0;  /*Time out value is not set*/
+    request.block_len = 0;       /*Block length. Assigned by driver*/
+    request.physical_buffer = 0; /*Physical address of data buffer is not set*/
+    request.owner = (SDIO_Owner) pHwAccess;
+    request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+    request.access_flag = 1;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = SDIO_SyncRead(pHwAccess->hDriver, &request);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_ReadMem: SDIO Error in read\n"));
+        return status;
+    }
+
+#elif HW_ACCESS_WSPI 
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMem: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+    
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    /* read the aligned size */
+    status = WSPI_ReadSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr),data,tempLen);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_ReadMem: WSPI Error in read\n"));
+        return status;
+    }
+    
+    /* read the non aligned reminder */
+    if(reminder)
+    {
+        UINT32 tempVal = 0;     
+        
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        /* read the extra data*/
+        status |= WSPI_ReadSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr+tempLen),(UINT8*)&tempVal,HW_ACCESS_WSPI_ALIGNED_SIZE);
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_ReadMem: WSPI Error in read\n"));
+            return status;
+        }
+        
+        /* extract the relevant data */
+        switch(reminder) 
+        {
+            case 1:
+                mask = HW_ACCESS_1_BYTE_REMINDE_MASK;
+                break;
+            case 2:
+                mask = HW_ACCESS_2_BYTE_REMINDE_MASK;
+                break;
+            case 3:
+                mask = HW_ACCESS_3_BYTE_REMINDE_MASK;
+                break;
+        }                           
+        *(UINT32*)&data[tempLen] &= ~mask;
+        *(UINT32*)&data[tempLen] |= tempVal & mask;
+    }
+
+#else
+    whal_hwAccess_DirectCopy_new(pHwAccess, data, (UINT8*)(pHwAccess->MemBaseAddr+addr), len);
+#endif
+
+#ifdef HW_ACCESS_SDIO
+    if (pHwAccess->uBusError)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_ReadMem: SDIO Error status=%d\n",
+        request.status));
+        if (pHwAccess->hwAccesserror_Cb) 
+        {
+            UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+            pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,(char*)&failure_reason,2);
+        }
+        else
+            pHwAccess->uBusError = 0;
+    }
+#endif
+
+    return OK;
+}
+
+
+
+/****************************************************************************
+ *                      whal_hwAccess_WriteMem
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously to the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is checked and the remnant (length%4) is completed with read-modify-write
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE* - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *          Len - int - the length of the data to read
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_WriteMem(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{                                                         
+    int status = OK;    
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    
+#ifdef HW_ACCESS_SDIO
+    struct SDIO_Request request;
+#elif HW_ACCESS_WSPI    
+    int reminder = len % HW_ACCESS_WSPI_ALIGNED_SIZE;
+    int tempLen = len - reminder;
+    UINT32 mask = 0;
+    status = whal_hwAccess_WriteMemAsync(hHwAccess, addr, data,  len);
+    if (status == TNETWIF_COMPLETE)
+    {
+        status = OK;
+    }
+    return status;
+#endif
+
+    /* access is blocked */
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_CTRL_MODULE_LOG,
+                              ("Bus is blocked \n"));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+#ifdef __HWACCESS_DEBUG__
+    /* check address alignment */
+    if(addr & 0x3)
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteMem: addr is not aligned 0x%x\n",
+            addr));
+#endif
+    
+#ifdef HW_ACCESS_SDIO                                       
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteMem: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    request.buffer = data; /* Pointer to the data buffer aligned address.  */
+    request.buffer_len = len; /* Data buffer length in bytes */ 
+    request.status = SDIO_Request_None;
+    request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+    request.acquire_window = 0;  /*Time out value is not set*/
+    request.block_len = 0;       /*Block length. Assigned by driver*/
+    request.physical_buffer = 0; /*Physical address of data buffer is not set*/
+    request.owner = (SDIO_Owner) pHwAccess;
+    request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+    request.access_flag = 0;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = SDIO_SyncWrite(pHwAccess->hDriver, &request);  
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_WriteMem: SDIO Error in write (%d)\n", status));
+        return status;
+    }
+
+#elif HW_ACCESS_WSPI
+
+    /* check address */
+    if (((addr+len) > pHwAccess->workingPartUpperLimit) || (addr < pHwAccess->MemRegionAddr))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteMem: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    /* write the aligned size */
+    status = WSPI_WriteSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr),data,tempLen);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_WriteMem: WSPI Error in write\n"));
+        return status;
+    }
+    
+    /* read the non aligned reminder */
+    if(reminder)
+    {
+        UINT32 tempVal;     
+        
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        /* read the extra data*/
+        status |= WSPI_ReadSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr + tempLen),(UINT8*)&tempVal,HW_ACCESS_WSPI_ALIGNED_SIZE);
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_WriteMem: WSPI Error in read\n"));
+            return status;
+        }
+        
+        /* extract the relevant data */
+        switch(reminder) 
+        {
+            case 1:
+                mask = HW_ACCESS_1_BYTE_REMINDE_MASK;
+                break;
+            case 2:
+                mask = HW_ACCESS_2_BYTE_REMINDE_MASK;
+                break;
+            case 3:
+                mask = HW_ACCESS_3_BYTE_REMINDE_MASK;
+                break;
+        }
+
+        tempVal &= ~mask;
+        tempVal |= *(UINT32*)&data[tempLen] & mask;
+
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        /* write the modified extra data */
+        status = WSPI_WriteSync(pHwAccess->hDriver,TRANSLATE_ADDRESS_MEM(addr + tempLen),(UINT8*)&tempVal,HW_ACCESS_WSPI_ALIGNED_SIZE);     
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwAccess_WriteMem: WSPI Error in write\n"));
+            return status;
+        }                                       
+    }   
+            
+#else
+    whal_hwAccess_DirectCopy_new(pHwAccess, (UINT8*)(pHwAccess->MemBaseAddr+addr), data, len);
+#endif
+
+#ifdef HW_ACCESS_SDIO
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_WriteMem: SDIO Error in write status=%d\n",
+        request.status));
+        if (pHwAccess->hwAccesserror_Cb) 
+        {
+            UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+            pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,(char*)&failure_reason,2);
+        }
+        else 
+            pHwAccess->uBusError = 0;
+
+    }
+#endif
+    return OK;
+}
+#endif /* USE_SYNC_API */ 
+
+
+/****************************************************************************
+ *                      whal_hwAccess_WriteMemAsync
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is checked and the remnant (length%4) is completed with read-modify-write
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE* - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *          Len - int - the length of the data to read
+ *          CB - HWAccess_CB_T* - a pointer to a structure that holds the CB function and the passed arg.
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+TI_STATUS           whal_hwAccess_WriteMemAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{   
+#if defined(HW_ACCESS_SDIO) && !defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+
+    /* Just call to synchronous API - add the offset that was added to the WSPI bus - only if it was reserved*/
+    return (whal_hwAccess_WriteMem (hHwAccess, addr, data + TNETWIF_WRITE_OFFSET_BYTES, len) == OK) 
+               ? TNETWIF_COMPLETE
+               : TNETWIF_ERROR;   
+
+#else
+
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+
+    /* Access is blocked */
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_CTRL_MODULE_LOG,
+                          ("Bus is blocked \n"));
+        return (TI_STATUS)ERROR_HW_ACCEESS_ADDR;
+    }
+
+    /* Check length */
+    if ((len & 0x3) != 0)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwAccess_WriteMemAsync: Error in length = %d\n",
+                          len));
+        return (TI_STATUS)ERROR_HW_ACCEESS_LEN;
+    }
+
+    /* Check address */
+    if (addr + len > pHwAccess->workingPartUpperLimit || 
+        addr < pHwAccess->MemRegionAddr)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwAccess_WriteMemAsync: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+                          addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return (TI_STATUS)ERROR_HW_ACCEESS_ADDR;
+    }
+
+#if defined(HW_ACCESS_SDIO)
+    {
+        struct SDIO_Request request;    
+
+        request.buffer = data + TNETWIF_WRITE_OFFSET_BYTES; /*Pointer to the data buffer aligned address*/
+        request.buffer_len = len; /*Data buffer length in bytes*/ 
+        request.status = SDIO_Request_None;
+        request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+        request.acquire_window = 0;  /* Time out value is not set */
+        request.block_len = 0;       /* Block length. Assigned by driver */
+        request.physical_buffer = 0; /* Physical address of data buffer is not set */
+        request.owner = (SDIO_Owner) pHwAccess;
+        request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+        request.access_flag = 0;
+        request.fnotify = sdio_async_transaction_notify; /* completion notification */
+        request.ferror = sdio_async_transaction_error; /* error notification */
+
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        status = SDIO_AsyncWrite (pHwAccess->hDriver, &request); 
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                              ("whal_hwAccess_WriteMemAsync: Error in write async, addr=0x%08x status=%d\n",
+                              addr, status));
+            return TNETWIF_ERROR;
+        }
+
+        if (pHwAccess->uBusError) 
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteMemAsync: SDIO Error in write status=%d\n",
+            request.status));
+            if (pHwAccess->hwAccesserror_Cb) 
+            {
+                UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+                pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,&failure_reason,2);
+            }
+            else 
+                pHwAccess->uBusError = 0;
+        
+        }
+
+        return TNETWIF_COMPLETE;
+    }
+        
+#elif defined(HW_ACCESS_WSPI)
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_WriteAsync (pHwAccess->hDriver,
+                              TRANSLATE_ADDRESS_MEM(addr),
+                              data,
+                              len,
+                              (WSPI_CB_T*)&pHwAccess->CB,
+                              TRUE, 
+                              TRUE); /* place is always reserved in write mem operation */   
+
+    os_profile (pHwAccess->hOs, 3, 0);
+                
+    WSPI2TNETWIF (pHwAccess, status, addr);
+
+    return (TI_STATUS)status;
+
+#else
+
+    /* By now since the CB is a SYNCH interface then call the SYNCH interface */
+    whal_hwAccess_DirectCopy_new(pHwAccess, (UINT8*)(pHwAccess->MemBaseAddr+addr), data, len);
+
+    return OK;
+
+#endif
+
+#endif
+}
+
+
+/****************************************************************************
+ *                      whal_hwAccess_ReadMemAsync
+ ****************************************************************************
+ * DESCRIPTION: read data asynchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is checked and the remnant (length%4) is completed with read-modify
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE* - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          Len - int - the length of the data to read
+ *          CB - HWAccess_CB_T* - a pointer to a structure that holds the CB function and the passed arg.
+ *
+ * OUTPUT:  data - UINT8* - a pointer to the buffer to fill with the read data
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_ReadMemAsync (TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len)
+{
+#if defined(HW_ACCESS_SDIO) && !defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)  
+  
+    /* Just call to synchronous API - add the offset that was added to the WSPI bus */
+    return (whal_hwAccess_ReadMem (hHwAccess, addr, data  + TNETWIF_READ_OFFSET_BYTES, len) == OK)
+               ? TNETWIF_COMPLETE
+               : TNETWIF_ERROR;
+
+#else
+
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+
+    /* Access is blocked */
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_CTRL_MODULE_LOG,
+                              ("Bus is blocked \n"));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    /* Check length */
+    if ((len & 0x3) != 0)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMemAsync: Error in length = %d\n",
+            len));
+        return ERROR_HW_ACCEESS_LEN;
+    }
+    
+    /* Check address */
+    if (addr + len > pHwAccess->workingPartUpperLimit || 
+        addr < pHwAccess->MemRegionAddr)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadMemAsync: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->MemRegionAddr, pHwAccess->workingPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+#if defined(HW_ACCESS_SDIO)
+    {
+        struct SDIO_Request request;    
+
+        request.buffer = data + TNETWIF_READ_OFFSET_BYTES; /*Pointer to the data buffer aligned address*/
+        request.buffer_len = len; /*Data buffer length in bytes*/ 
+        request.status = SDIO_Request_None;
+        request.peripheral_addr = (SDIO_Address)TRANSLATE_ADDRESS_MEM(addr); /*SDIO peripheral address*/
+        request.acquire_window = 0;  /* Time out value is not set */
+        request.block_len = 0;       /* Block length. Assigned by driver */
+        request.physical_buffer = 0; /* Physical address of data buffer is not set */
+        request.owner = (SDIO_Owner) pHwAccess;
+        request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+        request.access_flag = 0;
+        request.fnotify = sdio_async_transaction_notify; /* completion notification */
+        request.ferror = sdio_async_transaction_error; /* error notification */
+
+        os_profile (pHwAccess->hOs, 2, 0);
+
+        status = SDIO_AsyncRead (pHwAccess->hDriver, &request);  
+
+        os_profile (pHwAccess->hOs, 3, 0);
+
+        if (status != OK)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                              ("whal_hwAccess_ReadMemAsync: Error in write async, addr=0x%08x status=%d\n",
+                              addr, status));
+            return TNETWIF_ERROR;
+        }
+
+        if (pHwAccess->uBusError)
+        {
+            WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                              ("whal_hwAccess_ReadMemAsync: SDIO Error in write SrcOffset=0x%08x status=%d\n",
+                              SrcOffset, request.status));
+            if (pHwAccess->hwAccesserror_Cb) 
+            {
+                UINT16 failure_reason = HEALTH_REPORT_BUS_ERROR;
+                pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,&failure_reason,2);
+            }
+            else
+                pHwAccess->uBusError = 0;
+        }
+
+        return TNETWIF_COMPLETE;
+    }
+            
+#elif HW_ACCESS_WSPI
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_ReadAsync (pHwAccess->hDriver, 
+                             TRANSLATE_ADDRESS_MEM(addr), 
+                             data, 
+                             len, 
+                             (WSPI_CB_T*)&pHwAccess->CB,
+                             TRUE,
+                             TRUE); /* place is always reserved in readMem */    
+            
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    WSPI2TNETWIF (pHwAccess, status, addr);
+
+    return status;
+
+#endif
+
+#endif
+}
+
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      whal_hwAccess_ReadReg
+ ****************************************************************************
+ * DESCRIPTION: read data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is always 4bytes cause this is the size of the TNET registers
+ *
+ * INPUTS:  pHwAccess - HwAccess_T_new* - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          Len - int - the length of the data to read
+ *
+ * OUTPUT:  data - UINT8* - a pointer to the buffer to fill with the read data
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_ReadReg(TI_HANDLE hHwAccess, UINT32 addr, UINT32* data)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+
+#ifdef HW_ACCESS_SDIO
+    struct SDIO_Request request;
+
+    /* check address */
+    if (addr > pHwAccess->registerPartUpperLimit)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadReg: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->RegisterRegionAddr, pHwAccess->registerPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    request.buffer = (UINT8*)data; /*Pointer to the data buffer aligned address.*/
+    request.buffer_len = HW_ACCESS_REGISTER_SIZE; /*Data buffer length in bytes*/ 
+    request.status = SDIO_Request_None;
+    request.peripheral_addr = TRANSLATE_ADDRESS_REG(addr); 
+    request.acquire_window = 0;  /* Time out value is not set */
+    request.block_len = 0;       /* Block length. Assigned by driver */
+    request.owner = (SDIO_Owner) pHwAccess;
+    request.physical_buffer = 0; /* Physical address of data buffer is not set */
+    request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+    request.access_flag = 1;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = SDIO_SyncRead(pHwAccess->hDriver, &request);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+
+#elif HW_ACCESS_WSPI
+
+    status = whal_hwAccess_ReadRegAsync(hHwAccess, addr, data);
+    if (status == TNETWIF_COMPLETE)
+    {
+        status = OK;
+    }
+    return status;
+    /* check address */
+    if ((addr > pHwAccess->registerPartUpperLimit) || (addr < 0))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadReg: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->RegisterRegionAddr, pHwAccess->registerPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_ReadSync(pHwAccess->hDriver, TRANSLATE_ADDRESS_REG(addr), (UINT8*)data, HW_ACCESS_REGISTER_SIZE);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+#else
+
+    HW_REG_LONG_READ(pHwAccess,addr,data);
+
+#endif
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_ReadReg: Error in reg read RegAddr=0x%08x status=%d\n",
+        addr, status));
+        
+    }
+
+#ifdef HW_ACCESS_SDIO           
+    if (pHwAccess->uBusError)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_ReadReg: SDIO Error status=%d\n",
+        request.status));
+        if (pHwAccess->hwAccesserror_Cb) 
+        {
+            UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+            pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,(char *)&failure_reason,2);
+        }
+        else
+            pHwAccess->uBusError = 0;
+    }
+#endif
+    return status;
+}
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      whal_hwAccess_Stop()
+ ****************************************************************************
+ * DESCRIPTION: stops the bus driver
+ * 
+ * INPUTS:  None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+int whal_hwAccess_Stop(TI_HANDLE hHwAccess)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+
+    /* unbclock the access to the bus */
+    pHwAccess->uBusError = 0;
+
+#ifdef HW_ACCESS_SDIO
+    SDIO_Stop(pHwAccess->hDriver,0);
+#elif defined (HW_ACCESS_WSPI)
+    /* TODO*/
+#endif
+    return OK;
+}
+
+
+#ifdef USE_SYNC_API
+
+/****************************************************************************
+ *                      whal_hwAccess_WriteReg
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously to the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is always 4bytes cause this is the size of the TNET registers
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE * - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *          Len - int - the length of the data to read
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_WriteReg(TI_HANDLE hHwAccess, UINT32 addr, UINT32 data)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status = OK;
+
+#ifdef HW_ACCESS_SDIO
+    struct SDIO_Request request;
+
+    /* check address */
+    if (addr > pHwAccess->registerPartUpperLimit)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteReg: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->RegisterRegionAddr, pHwAccess->registerPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    request.buffer = (UINT8*)&data; /*Pointer to the data buffer aligned address.*/
+    request.buffer_len = HW_ACCESS_REGISTER_SIZE; /*Data buffer length in bytes*/ 
+    request.status = SDIO_Request_None;
+    request.peripheral_addr = TRANSLATE_ADDRESS_REG(addr);
+    request.acquire_window = 0;  /* Time out value is not set */
+    request.block_len = 0;       /* Block length. Assigned by driver */
+    request.owner = (SDIO_Owner) pHwAccess;
+    request.physical_buffer = 0; /* Physical address of data buffer is not set */
+    request.mode = MMC_DEV_BYTE_INCREMENTAL_MODE;
+    request.access_flag = 0;
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = SDIO_SyncWrite(pHwAccess->hDriver, &request);
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+#elif HW_ACCESS_WSPI
+    status = whal_hwAccess_WriteRegAsync(hHwAccess, addr,  data);
+    if (status == TNETWIF_COMPLETE)
+    {
+        status = OK;
+    }
+    return status;
+    /* check address */
+    if ((addr > pHwAccess->registerPartUpperLimit) || (addr < 0))
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteReg: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->RegisterRegionAddr, pHwAccess->registerPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_WriteSync(pHwAccess->hDriver, TRANSLATE_ADDRESS_REG(addr), (UINT8*)&data, HW_ACCESS_REGISTER_SIZE); 
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+#else
+
+    HW_REG_LONG_WRITE(pHwAccess, addr, data);
+
+#endif
+
+    if (status != OK)
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_WriteReg: Error in reg write RegAddr=0x%08x status=%d\n",
+        addr, status));
+
+#ifdef HW_ACCESS_SDIO
+    if (pHwAccess->uBusError) 
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwAccess_WriteReg: SDIO Error in write status=%d\n",
+        request.status));
+        if (pHwAccess->hwAccesserror_Cb) 
+        {
+            UINT8 failure_reason = HEALTH_REPORT_BUS_ERROR;
+            pHwAccess->hwAccesserror_Cb(pHwAccess->hBackReference,(char *)&failure_reason,2);
+        }
+        else 
+            pHwAccess->uBusError = 0;
+    
+    }
+#endif
+    return status;
+}
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      whal_hwAccess_ReadRegAsync
+ ****************************************************************************
+ * DESCRIPTION: read data asynchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is always 4bytes cause this is the size of the TNET registers
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE * - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *
+ * OUTPUT:  data - UINT8* - a pointer to the buffer to fill with the read data
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_ReadRegAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT32* data)
+{
+#if defined(HW_ACCESS_SDIO)
+  #if defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+
+    #error "SDIO asynchronous mode is not supported"
+
+    /* Not implemented yet */
+    return OK;
+
+  #else
+
+    /* Just call to synchronous API */
+    return (whal_hwAccess_ReadReg (hHwAccess, addr, data) == OK) 
+               ? TNETWIF_COMPLETE
+               : TNETWIF_ERROR;
+
+  #endif
+
+#else /* HW_ACCESS_WSPI */
+
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status;
+
+    /* Check address */
+    if (addr > pHwAccess->registerPartUpperLimit)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_ReadRegAsync: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->RegisterRegionAddr, pHwAccess->registerPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    /* In registers we don't save place */
+    status = WSPI_ReadAsync (pHwAccess->hDriver, 
+                             TRANSLATE_ADDRESS_REG(addr), 
+                             (UINT8*)data, 
+                             HW_ACCESS_REGISTER_SIZE,
+                             (WSPI_CB_T*)&pHwAccess->CB,
+                             TRUE,
+                             FALSE);   
+
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    WSPI2TNETWIF (pHwAccess, status, addr);
+
+    return status;
+
+#endif
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_WriteRegAsync
+ ****************************************************************************
+ * DESCRIPTION: write data synchronously from the TNET using the defined access (WSPI/SDIO). 
+ *              the length of data is always 4bytes cause this is the size of the TNET registers
+ *              the function is passed a call-back function that will be called after the read request ends.
+ *
+ * INPUTS:  pHwAccess - TI_HANDLE * - the HwAccess context
+ *          addr - UINT32 - the address offset inside the TNET
+ *          data - UINT8* - a pointer to the buffer that holds the data to write
+ *
+ * OUTPUT:  none                                                                
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int         whal_hwAccess_WriteRegAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT32 data)
+{
+#if defined(HW_ACCESS_SDIO)
+  #if defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+
+    #error "SDIO asynchronous mode is not supported"
+
+    /* Not implemented yet */
+    return OK;
+
+  #else
+
+    /* Just call to synchronous API */
+    return (whal_hwAccess_WriteReg (hHwAccess, addr, data) == OK)
+               ? TNETWIF_COMPLETE 
+               : TNETWIF_ERROR;
+
+  #endif
+
+#else /* HW_ACCESS_WSPI */
+
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)hHwAccess;
+    int status;
+
+    /* Check address */
+    if (addr > pHwAccess->registerPartUpperLimit)
+    {
+        WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwAccess_WriteRegAsync: Error in addr 0x%x (lower:0x%x,upper:0x%x)\n",
+            addr, pHwAccess->RegisterRegionAddr, pHwAccess->registerPartUpperLimit));
+        return ERROR_HW_ACCEESS_ADDR;
+    }
+
+    os_profile (pHwAccess->hOs, 2, 0);
+
+    status = WSPI_WriteAsync (pHwAccess->hDriver, 
+                              TRANSLATE_ADDRESS_REG(addr), 
+                              (UINT8*)&data, 
+                              HW_ACCESS_REGISTER_SIZE,
+                              (WSPI_CB_T*)&pHwAccess->CB,
+                              TRUE,
+                              FALSE);   
+    os_profile (pHwAccess->hOs, 3, 0);
+
+    WSPI2TNETWIF (pHwAccess, status, addr);
+
+    return status;
+#endif
+}
+
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      whal_hwAccess_SetPartitions
+ ****************************************************************************
+ * DESCRIPTION: the client always sees two partitions
+ *              1 - the working partition that the client access it with mem functions (for this partition the client supplies the base address)
+ *              2 - the registers partition that is always set on HW_ACCESS_REG_ADDR and its size is HW_ACCESS_REG_SIZE.
+ *
+ * INPUTS:  pHwAccess - a pointer to the module context
+ *          partitionMode - the mode to set the partitions
+ *          partition_start - the start address of the working partition
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_SetPartitions (TI_HANDLE hHwAccess, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start)
+{                                   
+    HwAccess_T_new *pHwAccess = (HwAccess_T_new*) hHwAccess;
+    int status = OK;
+
+#ifdef HW_ACCESS_SDIO   
+    SDIO_TNETWConfigParams sdioConfParam;
+    Peripheral_ConfigParams *cfg;
+#endif
+
+    pHwAccess->partition[0].size  = 0;
+    pHwAccess->partition[0].start = partition_start;
+    pHwAccess->partition[1].size  = 0;
+    pHwAccess->partition[1].start = 0;
+
+    switch(partitionMode)
+    {
+        case HW_ACCESS_DOWNLOAD:
+            pHwAccess->partition[0].size  = HW_ACCESS_MEMORY_MAX_RANGE - HW_ACCESS_DOWN_PART1_SIZE;
+            pHwAccess->partition[1].start = HW_ACCESS_DOWN_PART1_ADDR;
+            pHwAccess->partition[1].size  = HW_ACCESS_DOWN_PART1_SIZE;
+            break;
+        case HW_ACCESS_WORKING:
+            pHwAccess->partition[0].size  = HW_ACCESS_MEMORY_MAX_RANGE - HW_ACCESS_WORK_PART1_SIZE;
+            pHwAccess->partition[1].start = HW_ACCESS_WORK_PART1_ADDR;
+            pHwAccess->partition[1].size  = HW_ACCESS_WORK_PART1_SIZE;          
+            break;
+    }
+
+#if (defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI))
+    /* guarantee that the working partition wont overlap the registers partition */
+    if((pHwAccess->partition[0].start + pHwAccess->partition[0].size) > pHwAccess->partition[1].start)
+        pHwAccess->partition[0].size =  pHwAccess->partition[1].start -  pHwAccess->partition[0].start;
+
+    /* guarantee that the working partition won't exceed the packet RAM */
+    if((pHwAccess->partition[0].start + pHwAccess->partition[0].size) > HW_ACCESS_PRAM_MAX_RANGE)
+        pHwAccess->partition[0].size =  HW_ACCESS_PRAM_MAX_RANGE -  pHwAccess->partition[0].start;
+
+    pHwAccess->workingPartUpperLimit = pHwAccess->partition[0].start + pHwAccess->partition[0].size;
+    pHwAccess->registerPartUpperLimit = pHwAccess->partition[1].size;
+
+    pHwAccess->RegisterRegionAddr = pHwAccess->partition[0].size;
+    pHwAccess->MemRegionAddr = pHwAccess->partition[0].start;  
+
+#ifdef HW_ACCESS_SDIO
+
+    os_memoryZero (pHwAccess->hOs, &sdioConfParam, sizeof(SDIO_TNETWConfigParams));
+    sdioConfParam.num_of_parts = 2;
+    sdioConfParam.map_reg[0].reg_size   = pHwAccess->partition[0].size;
+    sdioConfParam.map_reg[0].scr_offset = pHwAccess->partition[0].start;
+    sdioConfParam.map_reg[1].reg_size   = pHwAccess->partition[1].size;
+    sdioConfParam.map_reg[1].scr_offset = pHwAccess->partition[1].start;
+
+    status = SDIO_TNETWInit(&sdioConfParam);    
+    status = (status == SDIO_SUCCESS) ? SDIO_TNETWConfig(pHwAccess->hDriver, &cfg) : status;  
+    status = (status == SDIO_SUCCESS) ? TNETWIF_COMPLETE : TNETWIF_ERROR;
+
+#elif HW_ACCESS_WSPI
+    /* 
+     * IMPORTANT NOTE (TODO): the ASYNC API is used here assuming the call will always
+     * be completed synchronously. This is done because only the Async API is wokring
+     * in 4.0.4. In future versions, the whole recovery process should be made asynchronous.
+     */
+    /* May use only one write because the addresses in the firmware are sequential */
+    status = WSPI_WriteAsync (pHwAccess->hDriver, 
+                              HW_ACCESS_PART0_SIZE_ADDR, 
+                              PADWRITE (pHwAccess->partition), 
+                              sizeof(partition_t) * 2,
+                              (WSPI_CB_T*)&pHwAccess->CB,
+                              TRUE, TRUE);
+
+    WSPI2TNETWIF (pHwAccess, status, HW_ACCESS_PART0_SIZE_ADDR);
+#endif
+
+#endif
+    
+    return status;
+}
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      whal_hwAccess_SetPartitionsAsync
+ ****************************************************************************
+ * DESCRIPTION: the client always sees two partitions
+ *              1 - the working partition that the client access it with mem functions (for this partition the client supplies the base address)
+ *              2 - the registers partition that is always set on HW_ACCESS_REG_ADDR and its size is HW_ACCESS_REG_SIZE.
+ *
+ * INPUTS:  pHwAccess - a pointer to the module context
+ *          partitionMode - the mode to set the partitions
+ *          partition_start - the start address of the working partition
+ *
+ * OUTPUT:  none
+ *
+ * RETURNS: one of the error codes (0 => OK)
+ ****************************************************************************/
+int whal_hwAccess_SetPartitionsAsync (TI_HANDLE hHwAccess, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start)
+{
+    HwAccess_T_new *pHwAccess = (HwAccess_T_new*) hHwAccess;
+    int status = OK;
+
+#ifdef HW_ACCESS_SDIO 
+    SDIO_TNETWConfigParams sdioConfParam;
+    Peripheral_ConfigParams *cfg;
+#endif
+
+    pHwAccess->partition[0].size  = 0;
+    pHwAccess->partition[0].start = partition_start;
+    pHwAccess->partition[1].size  = 0;
+    pHwAccess->partition[1].start = 0;
+
+    switch(partitionMode)
+    {
+        case HW_ACCESS_DOWNLOAD:
+            pHwAccess->partition[0].size  = HW_ACCESS_MEMORY_MAX_RANGE - HW_ACCESS_DOWN_PART1_SIZE;
+            pHwAccess->partition[1].start = HW_ACCESS_DOWN_PART1_ADDR;
+            pHwAccess->partition[1].size  = HW_ACCESS_DOWN_PART1_SIZE;
+            break;
+        case HW_ACCESS_WORKING:
+            pHwAccess->partition[0].size  = HW_ACCESS_MEMORY_MAX_RANGE - HW_ACCESS_WORK_PART1_SIZE;
+            pHwAccess->partition[1].start = HW_ACCESS_WORK_PART1_ADDR;
+            pHwAccess->partition[1].size  = HW_ACCESS_WORK_PART1_SIZE;          
+            break;
+    }
+
+#if (defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI))
+    /* guarantee that the working partition wont overlap the registers partition */
+    if((pHwAccess->partition[0].start + pHwAccess->partition[0].size) > pHwAccess->partition[1].start)
+        pHwAccess->partition[0].size =  pHwAccess->partition[1].start -  pHwAccess->partition[0].start;
+    
+    /* guarantee that the working partition won't exceed the packet RAM */
+    if((pHwAccess->partition[0].start + pHwAccess->partition[0].size) > HW_ACCESS_PRAM_MAX_RANGE)
+        pHwAccess->partition[0].size =  HW_ACCESS_PRAM_MAX_RANGE -  pHwAccess->partition[0].start;
+
+    pHwAccess->workingPartUpperLimit = pHwAccess->partition[0].start + pHwAccess->partition[0].size;
+    pHwAccess->registerPartUpperLimit = pHwAccess->partition[1].size;
+
+    pHwAccess->RegisterRegionAddr = pHwAccess->partition[0].size;
+    pHwAccess->MemRegionAddr = pHwAccess->partition[0].start;  
+
+#ifdef HW_ACCESS_SDIO
+
+    os_memoryZero (pHwAccess->hOs, &sdioConfParam, sizeof(SDIO_TNETWConfigParams));
+    sdioConfParam.num_of_parts = 2;
+    sdioConfParam.map_reg[0].reg_size   = pHwAccess->partition[0].size;
+    sdioConfParam.map_reg[0].scr_offset = pHwAccess->partition[0].start;
+    sdioConfParam.map_reg[1].reg_size   = pHwAccess->partition[1].size;
+    sdioConfParam.map_reg[1].scr_offset = pHwAccess->partition[1].start;
+
+    status = SDIO_TNETWInit(&sdioConfParam);    
+    status = (status == SDIO_SUCCESS) ? SDIO_TNETWConfig(pHwAccess->hDriver, &cfg) : status;  
+    status = (status == SDIO_SUCCESS) ? TNETWIF_COMPLETE : TNETWIF_ERROR;
+
+#elif HW_ACCESS_WSPI
+
+    /* May use only one write because the addresses in the firmware are sequential */
+    status = WSPI_WriteAsync (pHwAccess->hDriver, 
+                              HW_ACCESS_PART0_SIZE_ADDR, 
+                              PADWRITE (pHwAccess->partition), 
+                              sizeof(partition_t) * 2,
+                              (WSPI_CB_T*)&pHwAccess->CB,
+                              TRUE,
+                              TRUE);   
+
+    WSPI2TNETWIF (pHwAccess, status, HW_ACCESS_PART0_SIZE_ADDR);
+
+#endif
+
+#endif
+    
+    return status;
+}
+
+
+#if !defined(HW_ACCESS_SDIO) && !defined(HW_ACCESS_WSPI)
+/****************************************************************************
+ *                      whal_hwAccess_DirectCopy_new()
+ ****************************************************************************
+ * DESCRIPTION: Direct Copy sequence of bytes to/from the hardware
+ * 
+ * INPUTS:
+ *      pHwAccess   The object
+ *      Dest        Destination address
+ *      Src         Source address
+ *      Len         The length of the data to copy
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static void whal_hwAccess_DirectCopy_new(HwAccess_T_new *pHwAccess, UINT8* Dest, UINT8* Src, UINT32 Len)
+{
+
+#ifdef NOT_SUPPORT_08_BIT_ACCESS_COMMAND
+
+    /* first see if dest addr is 4 bytes 
+       align if not we are using local copy and not 
+       os_memoryCopy 
+     */
+    if(((UINT32)Dest & 0x00000001))
+    {
+    /* TBD - Currently unaligned destination address is not handled.
+       it means that CKIP will not work currently.
+    */
+        
+    }else
+    if(((UINT32)Dest & 0x00000002))
+    {
+    register volatile unsigned short *shortDest = (volatile unsigned short *)Dest;
+    register volatile unsigned short *shortSrc = (unsigned short *)Src;
+    register int Size = Len >> 1;
+
+    unsigned short TempWord;
+    while (Size--)
+        *shortDest++ = *shortSrc++;
+
+    if (Len&1)
+    {
+        TempWord = ENDIAN_HANDLE_WORD((*shortSrc & 0x00ff) | (*shortDest & 0xff00));
+        *shortDest = TempWord;
+    }
+    }else
+    {
+        /* The address line A0 is not connected 
+           For arm/linux sake not 2, but 4-alignment is enforced.
+           (Linux memcpy uses longs copy logic)
+        */ 
+        int Len1 = Len & 0xfffffffc;
+
+        os_memoryCopy(pHwAccess->hOs, (void*)Dest, (void*)Src, Len1);
+
+        if (Len1 != Len)
+        {
+            int ShortSize=Len1 >> 1;
+            volatile unsigned short *shortDest = ((unsigned short *)Dest) + ShortSize;
+            volatile unsigned short *shortSrc =  ((unsigned short *)Src) + ShortSize;
+                if (Len - Len1 >= 2)
+                    *shortDest++ = *shortSrc++;
+                if (Len & 1)
+                    *shortDest = ENDIAN_HANDLE_WORD((*shortSrc & 0x00ff) | (*shortDest & 0xff00));
+        }
+    }          
+
+#else
+    os_memoryCopy(pHwAccess->hOs, (void*)Dest, (void*)Src, Len);
+#endif
+}
+#endif
+
+#ifdef HW_ACCESS_SDIO
+
+/* callback notify read/write transaction function */
+static void sdio_transaction_notify_read(struct SDIO_Request *req, int status)
+{
+}
+
+static void sdio_transaction_notify_write(struct SDIO_Request *req, int status)
+{
+}
+
+/* callback notify error read/write transaction function */
+static void sdio_transaction_error(struct SDIO_Request *req, int stat)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)req->owner;
+
+    WLAN_REPORT_ERROR (pHwAccess->hReport, HAL_CTRL_MODULE_LOG, ("sdio_transaction_error\n"));                    
+
+    pHwAccess->uBusError = 1;
+}
+
+
+#if defined(HW_ACCESS_SDIO_ASYNC_SUPPORT)
+
+static void sdio_async_transaction_notify(struct SDIO_Request *req, int status)
+{   
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)req->owner;
+
+    /* call the CB */
+    pHwAccess->CB.CBFunc(pHwAccess->CB.CBArg,status);
+
+    WLAN_REPORT_INFORMATION(pHwAccess->hReport,
+                            HAL_HW_CTRL_MODULE_LOG,
+                            ("sdio_async_transaction_notify - request=%p, buf=%p, sdio_addr=0x%08lx, len=%u\n",
+                            req, req->buffer, req->peripheral_addr, req->block_len));
+
+}
+
+/* callback notify error read/write transaction function */
+static void sdio_async_transaction_error(struct SDIO_Request *req, int status)
+{
+    HwAccess_T_new* pHwAccess = (HwAccess_T_new*)req->owner;
+
+    WLAN_REPORT_ERROR(pHwAccess->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                    ("sdio_async_transaction_error: request=%p, buf=%p, sdio_addr=0x%08lx, len=%u\n", 
+                    req, req->buffer, req->peripheral_addr, req->block_len));
+}
+
+#endif /*HW_ACCESS_SDIO_ASYNC_SUPPORT*/
+
+#endif /*HW_ACCESS_SDIO*/
+
+TI_STATUS whal_hwAccess_RegisterForErrorCB(TI_HANDLE hHwAccess,
+                                                 void* CbFunc,
+                                                 TI_HANDLE CbObj)
+{
+    HwAccess_T_new *pHwAccess = (HwAccess_T_new *)hHwAccess;
+    pHwAccess->hwAccesserror_Cb = (HwAccessErrorHandle)CbFunc;
+    pHwAccess->hBackReference = CbObj;
+    return OK;
+}
+
+
+/***********************************************************/
+
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      whal_hwAccess_RegSetBitVal()
+ ****************************************************************************
+ * DESCRIPTION: wlan hardware registers bits access 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+void whal_hwAccess_RegSetBitVal(TI_HANDLE hHwAccess, UINT32 RegAddr, UINT32 BitVal)
+{
+    UINT32 rVal;
+
+    whal_hwAccess_ReadReg(hHwAccess,RegAddr,&rVal);
+    rVal |= BitVal;
+    whal_hwAccess_WriteReg(hHwAccess, RegAddr, rVal);
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_RegResetBitVal()
+ ****************************************************************************
+ * DESCRIPTION: wlan hardware registers bits access 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+void whal_hwAccess_RegResetBitVal(TI_HANDLE hHwAccess, UINT32 RegAddr, UINT32 BitVal)
+{
+    UINT32 rVal;
+
+    whal_hwAccess_ReadReg(hHwAccess,RegAddr,&rVal);
+    rVal &= ~BitVal;
+    whal_hwAccess_WriteReg(hHwAccess, RegAddr, rVal);
+}
+
+/****************************************************************************
+ *                      whal_hwAccess_RegIsBitSet()
+ ****************************************************************************
+ * DESCRIPTION: wlan hardware registers bits access 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwAccess_RegIsBitSet(TI_HANDLE hHwAccess, UINT32 RegAddr, UINT32 BitVal)
+{
+    UINT32 RegVal;
+
+    whal_hwAccess_ReadReg(hHwAccess,RegAddr,&RegVal);
+    if (RegVal & BitVal)
+        return 1;
+
+    return 0;
+}
+
+
+/****************************************************************************
+ *                      whal_hwAccess_(Get/Set/SetBits/ResetBits)U08()
+ ****************************************************************************
+ * DESCRIPTION: wlan hardware memory access to bytes
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+UINT8 whal_hwAccess_GetU08(TI_HANDLE hHwAccess, UINT32 Addr)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+    UINT32 SrcOffset ;
+    UINT16 DataShort;
+
+    SrcOffset = (Addr & 0xfffffffe);        
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)SrcOffset),(UINT8*)((char *)&DataShort),sizeof(UINT16));
+    return (EXTRACT_BYTE_FROM_WORD(DataShort, Addr));
+
+#else /* HW_ACCESS_SDIO */
+
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));   
+    return (data & 0x000000FF);
+
+#endif /* HW_ACCESS_SDIO */
+
+ }
+
+void whal_hwAccess_SetU08(TI_HANDLE hHwAccess, UINT32 Addr, UINT8 Val)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT16 DataShort;
+
+    sdioAddr = (Addr & 0xfffffffe);
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT16));        
+    EXTRACT_BYTE_FROM_WORD(DataShort, Addr) = Val;  
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT16));
+
+#else /* HW_ACCESS_SDIO */
+
+    UINT32 data = 0;
+    
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));   
+    data &= 0xFFFFFF00;
+    data |= Val;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    
+#endif /* HW_ACCESS_SDIO */
+    
+ }
+
+
+void whal_hwAccess_ResetU08_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT8 BitsVal)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT16 DataShort;
+
+    sdioAddr = (Addr & 0xfffffffe);
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT16));
+    EXTRACT_BYTE_FROM_WORD(DataShort, Addr) &= ~BitsVal;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT16));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));       
+    data &= ~BitsVal;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));  
+
+#endif /* HW_ACCESS_SDIO */
+            
+ }
+
+/****************************************************************************
+ *                      whal_hwAccess_(Get/Set/SetBits/ResetBits)U16()
+ ****************************************************************************
+ * DESCRIPTION: wlan hardware memory access to shorts
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+UINT16 whal_hwAccess_GetU16(TI_HANDLE hHwAccess, UINT32 Addr)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;    
+    UINT16 DataShort;
+
+    sdioAddr = Addr;
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT16));
+
+    return (ENDIAN_HANDLE_WORD(DataShort));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));   
+    return (data & 0x0000FFFF);
+
+#endif /* HW_ACCESS_SDIO */
+        
+ }
+
+void whal_hwAccess_SetU16(TI_HANDLE hHwAccess, UINT32 Addr, UINT16 Val)
+{
+
+    
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT16 sdioVal;
+
+    sdioAddr = (Addr & 0xfffffffe);
+    sdioVal = ENDIAN_HANDLE_WORD(Val);
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&sdioVal),sizeof(UINT16));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+    UINT32 sdioAddr;
+
+    sdioAddr = (Addr & 0xfffffffc);
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)sdioAddr,(UINT8*)&data,sizeof(data));
+
+    if((Addr&0x3) == 2)
+    {
+        data &= 0x0000FFFF;
+        data |= ((UINT32)Val)<<16;
+    }
+    else
+    {
+        data &= 0xFFFF0000;
+        data |= Val;
+    }
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)sdioAddr,(UINT8*)&data,sizeof(data));  
+    
+#endif /* HW_ACCESS_SDIO */
+        
+ }
+
+void whal_hwAccess_SetU16_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT16 Val)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT16 sdioVal;   
+
+    sdioAddr = Addr;
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&sdioVal),sizeof(UINT16));
+    sdioVal |= ENDIAN_HANDLE_WORD(Val);
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&sdioVal),sizeof(UINT16));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    data |= Val;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    
+#endif /* HW_ACCESS_SDIO */
+        
+ }
+
+void whal_hwAccess_ResetU16_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT16 Val)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT16 sdioVal;
+
+    sdioAddr = Addr;
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&sdioVal),sizeof(UINT16));
+    sdioVal &= ~ENDIAN_HANDLE_WORD(Val);
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&sdioVal),sizeof(UINT16));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    data &= ~Val;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    
+#endif /* HW_ACCESS_SDIO */
+
+ }
+
+/****************************************************************************
+ *                      whal_hwAccess_(Get/Set/SetBits/ResetBits)U32()
+ ****************************************************************************
+ * DESCRIPTION: wlan hardware memory access to longs
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+UINT32 whal_hwAccess_GetU32(TI_HANDLE hHwAccess, UINT32 Addr)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 DataLong;
+    UINT32 sdioAddr;
+
+    sdioAddr = Addr;    
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataLong),sizeof(UINT32));
+    return (ENDIAN_HANDLE_LONG(DataLong));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    return data;
+    
+#endif /* HW_ACCESS_SDIO */
+    
+ }
+
+
+void whal_hwAccess_SetU32(TI_HANDLE hHwAccess, UINT32 Addr, UINT32 Val)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT32 sdioVal;
+
+    sdioAddr = Addr;
+    sdioVal = ENDIAN_HANDLE_WORD(Val);
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&sdioVal),sizeof(UINT32));
+
+#else /* HW_ACCESS_SDIO */
+    
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&Val,sizeof(Val));    
+    
+#endif /* HW_ACCESS_SDIO */
+        
+ }
+
+void whal_hwAccess_SetU32_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT32 Val)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT32 DataShort;
+    
+    sdioAddr = (Addr & 0xfffffffe);
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT32));
+    DataShort |= ENDIAN_HANDLE_LONG(Val);
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT32));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    data |= Val;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));  
+    
+#endif /* HW_ACCESS_SDIO */
+    
+ }
+
+void whal_hwAccess_ResetU32_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT32 Val)
+{
+
+
+#ifdef HW_ACCESS_SDIO
+
+    UINT32 sdioAddr;
+    UINT32 DataShort;
+
+    sdioAddr = (Addr & 0xfffffffe);
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT32));
+    DataShort &= ~ENDIAN_HANDLE_LONG(Val);      
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)((char *)sdioAddr),(UINT8*)((char *)&DataShort),sizeof(UINT32));
+
+#else /* HW_ACCESS_SDIO */
+    
+    UINT32 data = 0;
+
+    whal_hwAccess_ReadMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));
+    data &= ~Val;
+    whal_hwAccess_WriteMem(hHwAccess,(UINT32)Addr,(UINT8*)&data,sizeof(data));  
+    
+#endif /* HW_ACCESS_SDIO */
+        
+ }
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      whal_hwAccess_Print()
+ ****************************************************************************
+ * DESCRIPTION: Print interrupts information
+ * 
+ * INPUTS:  None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+void whal_hwAccess_Print(TI_HANDLE hHwAccess)
+{
+    /* will be in use only if a print function will be neaded.
+    HwAccess_T_new *pHwAccess = (HwAccess_T_new*) hHwAccess;
+    */
+    WLAN_OS_REPORT(("whal_hwAccess_Print ----------------------------\n")); 
+    WLAN_OS_REPORT(("    NOTHING RIGHTNOW\n")); 
+}
+
+/************************************************************************
+ * Internal functions
+ ************************************************************************/
+
+#ifdef HW_ACCESS_SDIO
+  TI_STATUS whal_hwAccess_RecreateInterface(TI_HANDLE hHwAccess)
+  {
+      SDIO_ConfigParams configParams;
+      HwAccess_T_new *pHwAccess = (HwAccess_T_new*)hHwAccess;
+      SDIO_Status   status;
+  
+     os_memoryZero( pHwAccess->hOs, &configParams, sizeof(SDIO_ConfigParams));
+      configParams.fnotify_read = sdio_transaction_notify_read; 
+      configParams.fnotify_write = sdio_transaction_notify_write; 
+      configParams.ferror = sdio_transaction_error;  
+      configParams.fconfig_peripheral = SDIO_TNETWConfig; 
+      configParams.fconvert = NULL;
+      configParams.owner = pHwAccess;
+  
+      status = SDIO_Init(&configParams, &pHwAccess->hDriver);   
+    
+      return (status == SDIO_SUCCESS) ? OK : NOK;
+  }
+#elif defined (HW_ACCESS_WSPI)
+  TI_STATUS whal_hwAccess_RecreateInterface(TI_HANDLE hHwAccess)
+  {
+      HwAccess_T_new *pHwAccess = (HwAccess_T_new*)hHwAccess;
+      int             status;
+
+      /* re-configure the WSPi interface, using NULL to keep old parameters */
+      status = WSPI_Configure (pHwAccess->hDriver , NULL, NULL, NULL);
+
+#ifndef _WINDOWS
+      WSPI2TNETWIF (pHwAccess, status, 0x0);
+         return (TI_STATUS)status;
+#else
+#endif
+  }
+#else   /* ifdef HW_ACCESS_SDIO */
+  TI_STATUS whal_hwAccess_RecreateInterface(TI_HANDLE hHwAccess)
+  {
+      TI_STATUS status = NOK;
+
+    /*#error whal_hwAccess_RecreateInterface function is not implemented for HW interface other than SDIO.*/
+
+      return (status);
+  }
+#endif  /* ifdef HW_ACCESS_SDIO */
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/wspi.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/wspi.c
new file mode 100644 (file)
index 0000000..ead29f4
--- /dev/null
@@ -0,0 +1,1433 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/****************************************************************************
+ *
+ *   MODULE:  wspi.c
+ *   PURPOSE: 
+ *
+ ****************************************************************************/
+
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "whalCommon.h"
+#include "spi_api.h"
+#include "wspi.h"
+
+/* WSPI INIT CMD 
+-----------------------------------------------------------------
+| start |  tx   |                command                        |
+-----------------------------------------------------------------
+    47      46      45                                      40
+
+-----------------------------------------------------------------
+|                           reserve                             |
+-----------------------------------------------------------------
+    39                                                      32
+
+-----------------------------------------------------------------
+|                           reserve                             |
+-----------------------------------------------------------------
+    31                                                      24
+
+-----------------------------------------------------------------
+|           reserve              |  1250 |   fixed busy length  | 
+-----------------------------------------------------------------
+    23                                                      16
+                                                                                    
+-----------------------------------------------------------------
+| fixed |       |       |       |       |       |       |       |
+| busy  | iod   |   ip  |   cs  |   ws  |   bs  |  de   | wspi  |
+| enable|       |       |       |       |       |       |       |
+-----------------------------------------------------------------
+    15      14      13      12      11      10      9       8
+
+-----------------------------------------------------------------
+|                         CRC7                            | end |
+-----------------------------------------------------------------
+    7                                               1        0
+*/
+
+#define WSPI_SIZEOF_UINT32          sizeof (UINT32)
+
+#define WSPI_INIT_CMD_CRC_LEN       5
+
+#define WSPI_INIT_CMD_START         0x00
+#define WSPI_INIT_CMD_TX            0x40
+#define WSPI_INIT_CMD_BYPASS_BIT    0x80 /* the extra bypass bit is sampled by the TNET as '1' */
+#define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07
+#define WSPI_INIT_CMD_EN_FIXEDBUSY  0x80
+#define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00
+#define WSPI_INIT_CMD_IOD           0x40
+#define WSPI_INIT_CMD_IP            0x20
+#define WSPI_INIT_CMD_CS            0x10
+#define WSPI_INIT_CMD_WS            0x08
+#define WSPI_INIT_CMD_WSPI          0x01
+#define WSPI_INIT_CMD_END           0x01  
+#define WSPI_INIT_CMD_CRC_INPUT_LEN 40
+
+#define PRINT_TEST_REGION_SIZE      100
+#define PRINT_TEST_REGION_START     0x305674 /* the device ID register */
+#define PRINT_TEST_SIZE_REG         0x1FFC0
+#define PRINT_TEST_ADDR_REG         0x1FFC4
+
+
+/* WSPI CMD                                                                         
+-----------------------------------------------------------------
+| start |  tx   | fixed |         byte length                   |
+-----------------------------------------------------------------
+    31      30      29      28                              24
+
+-----------------------------------------------------------------
+|                           byte length                 |   a16 |
+-----------------------------------------------------------------
+    23                                              17      16
+
+-----------------------------------------------------------------
+|                           byte address                        |
+-----------------------------------------------------------------
+    15                                                      8
+
+-----------------------------------------------------------------
+|                           byte address                        | 
+-----------------------------------------------------------------
+    7                                                       0
+*/
+
+
+/* The 31's bit in the WSPI cmd is read bit */
+#define WSPI_CMD_READ                 0x40000000 
+#define WSPI_CMD_WRITE                0x00000000
+#define WSPI_CMD_FIXED                0x20000000
+#define WSPI_CMD_BYTE_LENGTH          0x1FFE0000 
+#define WSPI_CMD_BYTE_LENGTH_OFFSET   17
+#define WSPI_CMD_BYTE_ADDR            0x0001FFFF 
+
+
+#define WSPI_FIXED_BUSY_TIMEOUT       100
+#define WSPI_SYNC_OVER_ASYNC_TIMEOUT  100
+
+
+/* For FixedBusy Handle */
+#define NOT_IN_USE                                       0
+
+static UINT8 WSPI_GenerateCRC7 (UINT8* bits, UINT32 len);
+#ifndef USE_WRITE_READ_API
+static void  WSPI_WriteCmdCb      (TI_HANDLE hWSPI, int status);
+#endif
+static void  WSPI_ReadDataCb      (TI_HANDLE hWSPI, int status);
+#ifdef USE_SYNC_API
+#ifdef USE_SYNC_OVER_ASYNC
+static void  WSPI_SyncOverAsyncCb (TI_HANDLE hWSPI, int status);
+#endif
+#endif 
+static void  WSPI_ReadAsyncCb      (TI_HANDLE hWSPI, int status);
+static void  WSPI_ConfigureResetCb (TI_HANDLE hWSPI, int status);
+
+#ifdef TI_DBG
+       int DebugFixedBusy[10];
+#endif
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_Open
+ *
+ * Input    :   none
+ *
+ * Output   :   void**  phWSPI - a pointer to the handle of the WSPI
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * Note(s)  :   allocates the WSPI driver context and creates the SPI sublayer
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE WSPI_Open (TI_HANDLE hOs)
+{   
+    WSPI_t* pWSPI;
+
+    /* Allocate WSPI memory */
+    pWSPI = (WSPI_t *) os_memoryAlloc (hOs, sizeof(WSPI_t));
+    if (pWSPI == NULL)
+    {
+        return NULL;
+    }
+   
+    pWSPI->hOs = hOs;
+    pWSPI->pTempBuf = 0;
+       pWSPI->pExtraFixedBusyBuf = 0;
+        
+    /* Call to SPI_Open */
+    pWSPI->hSPI = SPI_Open ();   
+
+    return (TI_HANDLE)pWSPI;
+}
+    
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_Close
+ *
+ * Input    :   void* hWSPI - the WSPI handle
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * Note(s)  :   frees the WSPI driver context and closes the SPI sublayer
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_Close (TI_HANDLE hWSPI)
+{
+    WSPI_t* pWSPI = (WSPI_t*)hWSPI;
+
+    /* Call SPI_Close */
+    SPI_Close (pWSPI->hSPI);
+
+    /* Free temporary buffer */
+    if (pWSPI->pTempBuf)
+    {
+        os_memoryFree (pWSPI->hOs, pWSPI->pTempBuf, WSPI_NO_EXTRA_ALLOC_SIZE + pWSPI->uFixedBusyBytes);
+    }
+
+
+       if (pWSPI->pExtraFixedBusyBuf)
+    {
+        os_memoryFree (pWSPI->hOs, pWSPI->pExtraFixedBusyBuf, WSPI_EXTRA_BUFFER_ALLOC_SIZE);
+    }
+
+    /* Free allocated memory */
+    os_memoryFree (pWSPI->hOs, hWSPI, sizeof(WSPI_t));
+
+    return WSPI_OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_Configure
+ *
+ * Input    :   void* hWSPI - the WSPI handle
+ *              const WSPIConfig_t* aConfig -  a structure that holds the configuration data 
+                WSPI_CB_T* cb - callback 
+ *
+ * Output   :   
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * Note(s)  :   1. configures the SPI sublayer
+ *              2. sends the WSPI init word
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_Configure (TI_HANDLE hWSPI, TI_HANDLE hReport, const WSPIConfig_t* aConfig, WSPI_CB_T* cb)
+{
+    WSPI_t *pWSPI = (WSPI_t*)hWSPI;
+    int i;
+    
+       #ifdef TI_DBG
+               for (i=0;i<10;i++) 
+               {
+                       DebugFixedBusy[i] = 0;
+               }
+       #endif
+    
+    /* 
+     * This function is called during initialization and recovery. In recovery,
+     * The old values are used, so there's no need to re-configure everything again.
+     */
+    if (NULL != aConfig)
+    {
+    /* Set WSPI_t parameters */
+    pWSPI->uConfigMask = aConfig->mask;
+    pWSPI->bFixedAddr = aConfig->isFixedAddress; 
+    pWSPI->uFixedBusyLen = aConfig->fixedBusyLength;   
+    pWSPI->uFixedBusyBytes = pWSPI->uFixedBusyLen * 4 + 4;
+    /* Will be set to TRUE only when no extra bytes were allocated */
+    pWSPI->bUseTempBuf = FALSE; 
+    pWSPI->fErr = 0;  
+    pWSPI->hReport = hReport; 
+    /* Save CB for the WSPI_ConfigureResetCb() */
+    pWSPI->fCb = cb->CBFunc;
+    pWSPI->pCb = cb->CBArg;
+
+    /* Allocate the temporary buffer that will hold buffers with no extra room */
+    if (pWSPI->uFixedBusyLen != 0)  
+    {
+        if ((pWSPI->pTempBuf = os_memoryAlloc (pWSPI->hOs, WSPI_NO_EXTRA_ALLOC_SIZE + pWSPI->uFixedBusyBytes)) == NULL)
+        {
+            return WSPI_ERR_ALLOC_MEM;
+        }
+    }
+    }
+    
+       /* Allocate the temporary buffer that will hold buffers with no extra room */
+       if ((pWSPI->pExtraFixedBusyBuf = os_memoryAlloc (pWSPI->hOs, WSPI_EXTRA_BUFFER_ALLOC_SIZE)) == NULL)
+    {
+        return WSPI_ERR_ALLOC_MEM;
+    }
+       pWSPI->ExtraBufLength = 0;
+
+    /* This CMD is used to reset the HW SM */
+    for (i = 0; i < WSPI_INIT_CMD_LEN; i++)
+    {
+        pWSPI->auInitCmd[i] = 0xff;
+    }
+    
+    /* Write the reset CMD */
+    pWSPI->returnStatus =  SPI_Write (pWSPI->hSPI, pWSPI->auInitCmd, WSPI_INIT_CMD_LEN, (request_callback_t)WSPI_ConfigureResetCb, hWSPI, 1);
+    if (pWSPI->returnStatus == SPI_TXN_COMPLETE)
+    {
+               /* Note that in the next function call, pWSPI->returnStatus is going to be changed */
+        WSPI_ConfigureResetCb(hWSPI, OK);
+    }
+
+    return (pWSPI->returnStatus == SPI_TXN_COMPLETE ? WSPI_TXN_COMPLETE : 
+                       (pWSPI->returnStatus == SPI_TXN_PENDING ? WSPI_TXN_PENDING : WSPI_ERR_UNKNOWN));
+}
+
+static void WSPI_ConfigureResetCb (TI_HANDLE hWSPI, int status)
+{ 
+    WSPI_t *pWSPI = (WSPI_t*)hWSPI;
+    UINT8   auCRCBuffer [WSPI_INIT_CMD_CRC_LEN];
+
+    /*
+     * Set WSPI_INIT_COMMAND       
+     * the data is being send from the MSB to LSB
+     */
+    pWSPI->auInitCmd[2] = 0xff;
+    pWSPI->auInitCmd[3] = 0xff;
+    pWSPI->auInitCmd[1] = WSPI_INIT_CMD_START | WSPI_INIT_CMD_TX;
+    pWSPI->auInitCmd[0] = 0;
+    pWSPI->auInitCmd[7] = 0;
+    pWSPI->auInitCmd[6] = 
+        (pWSPI->uConfigMask << 3) | (pWSPI->uFixedBusyLen & WSPI_INIT_CMD_FIXEDBUSY_LEN);
+    pWSPI->auInitCmd[5] = 
+        ((pWSPI->uFixedBusyLen == 0) ? 
+            WSPI_INIT_CMD_DIS_FIXEDBUSY : 
+            WSPI_INIT_CMD_EN_FIXEDBUSY) 
+        | WSPI_INIT_CMD_IOD 
+        | WSPI_INIT_CMD_IP 
+        | WSPI_INIT_CMD_CS 
+       #ifndef SPI_16_BIT
+        | WSPI_INIT_CMD_WS
+       #endif
+        | WSPI_INIT_CMD_WSPI;
+
+    auCRCBuffer[0] = pWSPI->auInitCmd[1];
+    auCRCBuffer[1] = pWSPI->auInitCmd[0];
+    auCRCBuffer[2] = pWSPI->auInitCmd[7];
+    auCRCBuffer[3] = pWSPI->auInitCmd[6];
+    auCRCBuffer[4] = pWSPI->auInitCmd[5]; 
+
+    pWSPI->auInitCmd[4] = 
+        (WSPI_GenerateCRC7 (auCRCBuffer, WSPI_INIT_CMD_CRC_INPUT_LEN) << 1) 
+        | WSPI_INIT_CMD_END;   
+   
+    pWSPI->returnStatus = SPI_Write (pWSPI->hSPI, pWSPI->auInitCmd, WSPI_INIT_CMD_LEN, pWSPI->fCb, pWSPI->pCb, 1);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_ReadSync
+ *
+ * Input    :   void* hWSPI    - the WSPI handle
+ *              UINT32 address - the address (in bytes) in the firmware to read the data from
+ *              UINT32 length  - the number of bytes to read
+ *              WSPI_CB_T cb   - callback parameters
+ *              BOOL bMore     - more read/write transaction will follow   
+ *
+ * Output   :   UINT8* data - the buffer to put the read data
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * Note(s)  :   1. set the WSPI cammand+address word
+ *              2. send the WSPIcammand+address word
+ *              3. read the fixed busy
+ *              4. read the data
+ *              5. check that the fixed busy was OK
+ *
+ *              because of the TNET state machine the data is always sent and only after 
+ *              we read it we validate that it's OK
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_ReadSync (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length)
+{
+  #ifdef USE_SYNC_OVER_ASYNC
+    
+    WSPI_t    *pWSPI = (WSPI_t*)hWSPI;
+    WSPI_CB_T  cb = { (request_callback_t)WSPI_SyncOverAsyncCb, hWSPI };
+    UINT32        i, timeout;
+
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+      
+    /* Set the sync flag */
+    pWSPI->bSyncFlag = 0;
+        
+    WSPI_ReadAsync (hWSPI, address, data, length, &cb, 1, 0);
+
+    /* Wait to end of the asynchronous read */
+    timeout = WSPI_SYNC_OVER_ASYNC_TIMEOUT * length;
+    for (i = 0; i < timeout; i++)
+    {
+        if (pWSPI->bSyncFlag)
+        {
+            break;
+        }
+    }
+    if (i == timeout)
+    {
+        /* Reached the timeout criteria without ending the asynchronous read */
+        WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("WSPI ASYNC READ DIDN'T FINISH\n")); 
+                       
+        return  WSPI_ERR_ASYNC_TIMEOUT;
+    }
+
+    return WSPI_OK;
+
+  #else /* USE_SYNC_OVER_ASYNC */
+
+    WSPI_t* pWSPI = (WSPI_t*)hWSPI;
+    UINT32     i;
+    UINT32  uFixedBusy;
+    int     ret = WSPI_OK;
+
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+         
+    /*****************************/
+    /* Write the command+address */
+    /*****************************/
+    pWSPI->uCmd = WSPI_CMD_READ;
+
+    /* Set bFixedAddr */
+    if (pWSPI->bFixedAddr)
+    {
+        pWSPI->uCmd |= WSPI_CMD_FIXED;   
+    }
+    
+    /* Set length */
+    pWSPI->uCmd |= (length << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+    /* Set address */
+    pWSPI->uCmd |= address & WSPI_CMD_BYTE_ADDR;        
+    
+    /* Write command+address */
+    ret |= SPI_WriteSync (pWSPI->hSPI, (UINT8*)&pWSPI->uCmd, WSPI_SIZEOF_UINT32);   
+
+    if (pWSPI->uFixedBusyLen == 0)
+    {
+        /* 1150 */
+        /* For 1150 read until we get the not-busy word */
+        for (i = 0; i < WSPI_FIXED_BUSY_TIMEOUT; i++)  
+        {
+            ret |= SPI_ReadSync (pWSPI->hSPI, (UINT8*)&uFixedBusy, WSPI_SIZEOF_UINT32); 
+            if ((uFixedBusy & 0x1) != 0)
+            {
+                break;
+            }
+        }
+        
+        if (i == WSPI_FIXED_BUSY_TIMEOUT)
+        {
+            WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("WSPI FIXED BUSY (SYNC)\n")); 
+                               
+            return WSPI_ERR_BUS_BUSY;
+        }
+    }
+    else
+    {
+        /* 1251 */
+        /* For 1251 read the predefined number of busy words and at the end the not-busy word */  
+        for (i = 0; i < pWSPI->uFixedBusyLen; i++) 
+            ret |= SPI_ReadSync (pWSPI->hSPI, (UINT8*)&uFixedBusy, WSPI_SIZEOF_UINT32);
+        ret |= SPI_ReadSync (pWSPI->hSPI, (UINT8*)&uFixedBusy, WSPI_SIZEOF_UINT32);
+    }
+
+    /* Read data */
+    ret |= SPI_ReadSync (pWSPI->hSPI, data, length);
+
+    if (pWSPI->uFixedBusyLen)
+    { 
+        /* 1251 */
+        /* Check the fixed busy */
+        if (!(uFixedBusy & 0x1))
+        {
+            WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("WSPI FIXED BUSY (SYNC)\n")); 
+                               
+            ret = WSPI_ERR_BUS_BUSY;        
+        }
+    }
+
+    return ret; 
+  #endif
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_ReadAsync
+ *
+ * Input    :   void* hWSPI    - the WSPI handle
+ *              UINT32 address - the address (in bytes) in the firmware to read the data from
+ *              UINT32 length  - the number of bytes to read
+ *              WSPI_CB_T cb   - callback parameters
+ *              BOOL bMore     - more read/write transaction will follow   
+ *              BOOL bSpaceReserved 
+ *                             - extra space padding has been reserved by an upper layer
+ *
+ * Output   :   UINT8* data    - the buffer to put the read data
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_ReadAsyncOld (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length, WSPI_CB_T* cb, BOOL bMore, BOOL bSpaceReserved)
+{
+    WSPI_t       *pWSPI = (WSPI_t*)hWSPI;
+    int           ret = WSPI_OK;
+
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+
+    /*
+     * Pass to the CB function of the read data also the fixed busy response so
+     * to put all the required data in subsequent places in the buffer of the WSPI context 
+     * first the fixed busy, second the CBFunc, third the CBArg
+     * here we guarantee that the data will be sequential
+     */  
+
+    /*****************************/
+    /* Write the command+address */
+    /*****************************/
+    pWSPI->uCmd = WSPI_CMD_READ;
+
+    /* Set bFixedAddr */
+    if (pWSPI->bFixedAddr)
+    {
+        pWSPI->uCmd |= WSPI_CMD_FIXED;   
+    }
+    
+    /* Set the length */
+    pWSPI->uCmd |= (length << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+    /* Set the address */
+    pWSPI->uCmd |= address & WSPI_CMD_BYTE_ADDR;        
+    
+    /* Write command+address */
+    ret |= SPI_WriteSync (pWSPI->hSPI, (UINT8*)&pWSPI->uCmd, WSPI_SIZEOF_UINT32);   
+
+    if (pWSPI->uFixedBusyLen == 0)
+    {
+        UINT32 uFixedBusy, i;
+        /* 1150 */
+        /* For 1150 read until we get the not-busy word */
+        for (i = 0; i < WSPI_FIXED_BUSY_TIMEOUT; i++)  
+        {
+            ret |= SPI_ReadSync (pWSPI->hSPI, (UINT8*)&uFixedBusy, WSPI_SIZEOF_UINT32);     
+            if ((uFixedBusy & 0x1) != 0)
+            {
+                break;
+            }
+        }
+        
+        if (i == WSPI_FIXED_BUSY_TIMEOUT)
+        {
+            WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("WSPI FIXED BUSY (ASYNC)\n")); 
+
+            if (pWSPI->fErr) 
+            { 
+                (*pWSPI->fErr) (); 
+            }
+
+            return WSPI_ERR_BUS_BUSY;
+        }
+    }
+    else
+    {
+        UINT32 uFixedBusy, i;
+        /* 1251 */
+        /* For 1251 read the predefined number of busy words and at the end the not-busy word */  
+        for (i = 0; i < pWSPI->uFixedBusyLen; i++) 
+            ret |= SPI_ReadSync (pWSPI->hSPI, (UINT8*)&uFixedBusy, WSPI_SIZEOF_UINT32);
+        ret |= SPI_ReadSync (pWSPI->hSPI, (UINT8*)&pWSPI->uFixedBusy, WSPI_SIZEOF_UINT32);
+    }  
+
+    /* Read the data */
+    pWSPI->fCb = cb->CBFunc;
+    pWSPI->pCb = cb->CBArg;
+
+    /* Tell the lower machine to start executing after this submission */  
+    ret |= SPI_Read (pWSPI->hSPI, 
+                     data + bSpaceReserved * pWSPI->uFixedBusyBytes, 
+                     length, 
+                     WSPI_ReadAsyncCb, 
+                     pWSPI, 
+                     1);
+   
+    return ret; 
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_WriteSync
+ *
+ * Input    :   void* hWSPI - the WSPI handle
+ *              UINT32 address - the address (in bytes) in the firmware to read the data from
+ *              UINT8* data - the buffer that holds the data to write
+ *              UINT32 length - the number of bytes to read
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * Note(s)  :   1. set the WSPI cammand+address word
+ *              2. send the WSPIcammand+address word
+ *              3. send the data 
+ *
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_WriteSync (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length)
+{
+  #ifdef USE_SYNC_OVER_ASYNC
+    
+    WSPI_t*   pWSPI = (WSPI_t*)hWSPI;
+    WSPI_CB_T cb = { (request_callback_t)WSPI_SyncOverAsyncCb, hWSPI };
+    int       i, timeout;
+
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+        
+    /* Set the sync flag */
+    pWSPI->bSyncFlag = 0;
+        
+    WSPI_WriteAsync (hWSPI, address, data, length, &cb, 1, 0);
+
+    /* Wait to end of the asynchronous write */
+    timeout = WSPI_SYNC_OVER_ASYNC_TIMEOUT * length;
+    for (i = 0; i < timeout; i++)
+    {
+        if (pWSPI->bSyncFlag)
+        {
+            break;
+        }
+    }
+    if (i == timeout)
+    {
+        /* Reached the timeout criteria without ending the asynchronous write */
+        WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("WSPI ASYNC WRITE DIDN'T END\n")); 
+                           
+        return  WSPI_ERR_ASYNC_TIMEOUT;
+    }
+
+    return WSPI_OK;
+
+  #else
+
+    WSPI_t* pWSPI = (WSPI_t*)hWSPI;
+    int     ret = WSPI_OK;
+      
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+
+    /*****************************/
+    /* Write the command+address */
+    /*****************************/
+    pWSPI->uCmd = WSPI_CMD_WRITE;
+
+    /* Set bFixedAddr */
+    if (pWSPI->bFixedAddr)
+    {
+        pWSPI->uCmd |= WSPI_CMD_FIXED;
+    }
+        
+    /* Set length */
+    pWSPI->uCmd |= ((UINT32)length << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+    /* Set address */
+    pWSPI->uCmd |= address & WSPI_CMD_BYTE_ADDR;        
+    
+    /* Write */
+    ret |= SPI_WriteSync (pWSPI->hSPI, (UINT8*)&pWSPI->uCmd, WSPI_SIZEOF_UINT32);  
+
+    /**************/
+    /* Write data */
+    /**************/
+    ret |= SPI_WriteSync (pWSPI->hSPI, data, length);   
+    
+    return ret; 
+
+  #endif
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_ReadAsync
+ *
+ * Input    :   void* hWSPI    - the WSPI handle
+ *              UINT32 address - the address (in bytes) in the firmware to read the data from
+ *              UINT32 length  - the number of bytes to read
+ *              WSPI_CB_T cb   - callback parameters
+ *              BOOL bMore     - more read/write transaction will follow   
+ *              BOOL bSpaceReserved 
+ *                             - extra space padding has been reserved by an upper layer
+ *
+ * Output   :   UINT8* data    - the buffer to put the read data
+ *
+ * ReturnVal:   one of the error codes (zero is success)
+ *
+ * Note(s)  :   1. set the WSPI cammand+address word
+ *              2. set the command+address request struct
+ *              3. submit the request
+ *              4. set the read fixed busy request struct
+ *              5. submit the request
+ *              6. set the read data request struct
+ *              7. submit the request with execute flag
+ *
+ *              the fixed response is read into the buffer of the WSPI context
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_ReadAsync (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length, WSPI_CB_T* cb, BOOL bMore, BOOL bSpaceReserved)                   
+{
+    WSPI_t       *pWSPI = (WSPI_t*)hWSPI;
+    int           status;
+        
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+    
+    /* Save parameters */
+    pWSPI->length = (UINT32)length; 
+    pWSPI->data = data;
+    pWSPI->bMore = bMore; 
+    pWSPI->bSpaceReserved = bSpaceReserved;
+    pWSPI->fCb = cb->CBFunc;
+    pWSPI->pCb = cb->CBArg;
+
+    /**********************************/
+    /* Prepare the CMD for the SM use */
+    /**********************************/
+    pWSPI->uCmd = WSPI_CMD_READ;
+
+    /* Set bFixedAddr */
+    if (pWSPI->bFixedAddr)
+    {
+        pWSPI->uCmd |= WSPI_CMD_FIXED;   
+    }
+    
+    /* Set length */
+    pWSPI->uCmd |= ((UINT32)length << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+    /* Set address */
+    pWSPI->uCmd |= address & WSPI_CMD_BYTE_ADDR;        
+    
+  #ifdef USE_WRITE_READ_API
+
+    if (bSpaceReserved)
+    {
+        /* Indicate that that the temporary buffer is NOT used */
+        pWSPI->bUseTempBuf = 0;
+    }
+
+    else
+    {
+        if (pWSPI->length <= WSPI_NO_EXTRA_ALLOC_SIZE)
+        {   
+            /* Indicate that that the temporary buffer is used */
+            data = pWSPI->pTempBuf;
+            pWSPI->bUseTempBuf = 1;
+        }
+        else
+        {
+            WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("No space reserved for command\n"));
+                               
+            return WSPI_ERR_UNKNOWN;
+        }
+    }
+
+    status = SPI_WriteRead (pWSPI->hSPI,
+                            (UINT8*)&pWSPI->uCmd,
+                            WSPI_SIZEOF_CMD,
+                            data,
+                            length + pWSPI->uFixedBusyBytes,
+                            WSPI_ReadDataCb,
+                            pWSPI,
+                            bMore);
+
+    /* In case of synchronous transaction completion call read callback explicitly */
+    if (SPI_TXN_COMPLETE == status)
+    {
+        pWSPI->fCb = NULL;
+        WSPI_ReadDataCb (hWSPI, status);
+    }
+
+    return status;
+
+  #else
+
+    /* Write command and indicate that more is ON */
+    status = SPI_Write (pWSPI->hSPI, 
+                        (UINT8*)&pWSPI->uCmd,
+                        WSPI_SIZEOF_CMD,
+                        WSPI_WriteCmdCb, 
+                        hWSPI, 
+                        1);  
+
+    /* Don't pend, call directly to the callback */
+    if (SPI_TXN_COMPLETE == status) 
+    {
+        WSPI_WriteCmdCb (hWSPI, WSPI_OK);
+        /* WSPI_WriteCmdCb updates the pWSPI->status */
+        return pWSPI->status;
+    }
+
+    return status;
+
+  #endif
+}
+
+
+#ifndef USE_WRITE_READ_API
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_WriteCmdCb
+ *
+ * Input    :   void* hWSPI - the WSPI handle
+ *              int status  - SPI request status 
+ *
+ * Note(s)  :   CB from writing CMD in WSPI_ReadAsync().
+ *              Read the data according to bSpaceReserved (indicates whether extra bytes were allocated
+ *              in the buffer for the FixedBusyWord).
+ *              if (!bSpaceReserved) but the length is short (WSPI_NO_EXTRA_ALLOC_SIZE) than copy it to 
+ *              temporary file and read the data
+ *              else - ERROR !
+ * -----------------------------------------------------------------------------
+ */
+void WSPI_WriteCmdCb (TI_HANDLE hWSPI, int status)
+{
+    WSPI_t *pWSPI = (WSPI_t*)hWSPI;
+
+    /* Extra room was saved - set the pointer as is */
+    if (pWSPI->bSpaceReserved)
+    {
+        /* Indicate that that the temporary buffer is NOT used */
+        pWSPI->bUseTempBuf = 0;
+
+        /* Execute read with extra fixed busy bytes */  
+        pWSPI->status = SPI_Read (pWSPI->hSPI, 
+                                  pWSPI->data, 
+                                  pWSPI->length + pWSPI->uFixedBusyBytes, 
+                                  WSPI_ReadDataCb, 
+                                  hWSPI,
+                                  pWSPI->bMore); 
+    }
+
+    /* 
+     * This case is used for handling buffers which have no extra room for the fixed busy words.
+     * Use a temporary buffer and than copy the results            
+     */
+    else if (pWSPI->length <= WSPI_NO_EXTRA_ALLOC_SIZE)
+    {   
+        /* Indicate that that the temporary buffer is used */
+        pWSPI->bUseTempBuf = 1;
+        
+        /* Read fixed busy words and a data in one transaction */ 
+        pWSPI->status = SPI_Read (pWSPI->hSPI, 
+                                  pWSPI->pTempBuf, 
+                                  pWSPI->length + pWSPI->uFixedBusyBytes, 
+                                  WSPI_ReadDataCb, 
+                                  hWSPI,
+                                  pWSPI->bMore); 
+    }
+    else    
+    {
+        WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("No space reserved command\n"));                          
+    }
+    
+    /* Check the return status; if not pending - call directly */
+    if (SPI_TXN_COMPLETE == pWSPI->status)
+    {   
+        WSPI_ReadDataCb (hWSPI, WSPI_OK);
+    }
+}
+#endif
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_ReadDataCb
+ *
+ * Input    :   void* hWSPI - the WSPI handle
+ *              int status  - SPI request status 
+ *
+ * Note(s)  :   CB from WSPI_WriteCmdCb().
+ *              Copy the data if needed and call original CB
+ * -----------------------------------------------------------------------------
+ */
+void WSPI_ReadDataCb (TI_HANDLE hWSPI, int status)
+{
+    WSPI_t *pWSPI = (WSPI_t*)hWSPI;
+    UINT32 *pRbuf;
+
+    /* If we are using the temp buffer and its fixedBusyWord is OK */
+    pRbuf = (pWSPI->bUseTempBuf) ? (UINT32 *)pWSPI->pTempBuf 
+                                 : (UINT32 *)pWSPI->data;
+
+    /* No fixed busy */
+    if ((pRbuf[pWSPI->uFixedBusyLen] & 0x1) != 0)
+    {
+        /* Copy data to the original buffer */
+        if (pWSPI->bUseTempBuf)
+        {
+          #if WSPI_NO_EXTRA_ALLOC_SIZE == 4 /* used for optimization */
+            /* In case the data size is 4 bytes copy it directly from the temp buffer */
+            *((UINT32*)pWSPI->data) = pRbuf[pWSPI->uFixedBusyLen + 1];
+          #else
+            os_memoryCopy (pWSPI->hOs, pWSPI->data, &pRbuf[pWSPI->uFixedBusyLen + 1], pWSPI->length);            
+          #endif 
+        }
+
+        /* Call user callback */
+        if (pWSPI->fCb != NULL)
+        {
+            pWSPI->fCb (pWSPI->pCb, 0);
+        } 
+    }
+    /* Handle fixed busy */
+    else
+    {
+               WLAN_REPORT_WARNING (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, 
+                       ("WSPI FIXED BUSY (READ CALLBACK) Cmd = 0x%x, data pointer = %p data = 0x%x length = %d\n",
+                       pWSPI->uCmd, pRbuf, pRbuf[pWSPI->uFixedBusyLen + 1], pWSPI->length));
+
+               WSPI_HandleFixedBusy(hWSPI, pRbuf);
+    }       
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function :   WSPI_ReadDataAfterNotBusyCb
+*
+* Input    :   void* hWSPI - the WSPI handle
+*              int status  - Not in use.
+*
+* Note(s)  :   Called from WSPI_HandleFixedBusy after the last read operation had the ~busy
+*                              word, but some of the data is missing
+* -----------------------------------------------------------------------------
+*/
+void WSPI_ReadDataAfterNotBusyCb (TI_HANDLE hWSPI, int status)
+{
+       WSPI_t  *pWSPI = (WSPI_t*)hWSPI;
+       UINT32 *pRbuf;
+       UINT32 iExtraBufByteLength = pWSPI->ExtraBufLength*WSPI_SIZEOF_UINT32;
+       UINT32 iTotalLength                = pWSPI->length + pWSPI->uFixedBusyBytes;
+
+       /* If we are using the temp buffer and its fixedBusyWord is OK */
+       pRbuf = (pWSPI->bUseTempBuf) ? (UINT32 *)pWSPI->pTempBuf : (UINT32 *)pWSPI->data;
+
+       if (pWSPI->bUseTempBuf)
+       {
+          #if WSPI_NO_EXTRA_ALLOC_SIZE == 4 /* used for optimization */
+               /* In case the data size is 4 bytes copy it directly from the temp buffer */
+               *((UINT32*)pWSPI->data) = *((UINT32*)pWSPI->pExtraFixedBusyBuf);
+          #else
+               os_memoryCopy (pWSPI->hOs, pWSPI->data, &(pRbuf[pWSPI->uFixedBusyLen + 1 + pWSPI->ExtraBufLength]), pWSPI->length - iExtraBufByteLength);            
+               os_memoryCopy (pWSPI->hOs, &(pWSPI->data[pWSPI->length - iExtraBufByteLength]), pWSPI->pExtraFixedBusyBuf, iExtraBufByteLength);            
+          #endif 
+       }
+       else
+       {
+               os_memoryCopy(pWSPI->hOs, pRbuf,  &(pRbuf[pWSPI->ExtraBufLength]),iTotalLength - iExtraBufByteLength);
+               pWSPI->data = (UINT8*)pRbuf;
+               os_memoryCopy (pWSPI->hOs, &(pWSPI->data[iTotalLength - iExtraBufByteLength]), pWSPI->pExtraFixedBusyBuf, iExtraBufByteLength);            
+       }
+
+       /* Call user callback */
+       if (pWSPI->fCb != NULL)
+       {
+               pWSPI->fCb (pWSPI->pCb, 0);
+       }
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function :   WSPI_ReadNotBusyAndDataCb
+*
+* Input    :   void* hWSPI - the WSPI handle
+*              int status  - Not in use.
+*
+* Note(s)  :   Called from WSPI_HandleFixedBusy after the last read operation had no response
+*                          from the CHIP. i.e. the ~busy word is missing too
+* -----------------------------------------------------------------------------
+*/
+void WSPI_ReadNotBusyAndDataCb (TI_HANDLE hWSPI, int status)
+{
+       WSPI_t  *pWSPI = (WSPI_t*)hWSPI;
+       int i = 0;
+
+       if ( pWSPI->bUseTempBuf )
+       {
+               while (i < (WSPI_EXTRA_READ_AFTER_NO_RESPONSE) )
+               {
+                       /* Check if this is the ~busy word */
+                       if ( (*(UINT32*)(pWSPI->pExtraFixedBusyBuf + i)) & 0x1 )
+                       {       
+                               /* we have reached the fixed busy word */
+                          #if WSPI_NO_EXTRA_ALLOC_SIZE == 4 /* used for optimization */
+                               /* In case the data size is 4 bytes copy it directly from the temp buffer */
+                               *((UINT32*)pWSPI->data) = *((UINT32*)(pWSPI->pExtraFixedBusyBuf+i+4));
+                          #else
+                               os_memoryCopy (pWSPI->hOs, pWSPI->data, &(pWSPI->pTempBuf[pWSPI->uFixedBusyLen + 1 + pWSPI->ExtraBufLength]), pWSPI->length - iExtraBufByteLength);            
+                               os_memoryCopy (pWSPI->hOs, &(pWSPI->data[pWSPI->length - iExtraBufByteLength]), pWSPI->pExtraFixedBusyBuf, iExtraBufByteLength);            
+                          #endif 
+
+                               if (pWSPI->fCb != NULL)
+                               {
+                                       pWSPI->fCb (pWSPI->pCb, 0);
+                               }
+                               return;
+                       }
+                       i+=4;
+               }
+       }
+       /* Oh boy, We couldn't find the ~Busy word */
+       WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, 
+               ("WSPI FIXED BUSY (READ CALLBACK) Cmd = 0x%x, length = %d\n",
+               pWSPI->uCmd,pWSPI->length));
+
+       if (pWSPI->fErr) 
+       {
+               (*pWSPI->fErr) ();
+       }
+       if (pWSPI->fCb != NULL)
+       {
+               pWSPI->fCb (pWSPI->pCb, WSPI_ERR_BUS_BUSY);
+       }
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_HandleFixedBusy
+ *
+ * Input    :   void* hWSPI - the WSPI handle
+ *              UINT32 *pRbuf  - The temp read buffer 
+ *
+ * Note(s)  :   Called from WSPI_ReadDataCb() when a Fixed_Busy error accurse.
+ *              Shifting the data to the expected place and reading the missing data
+ * -----------------------------------------------------------------------------
+ */
+void WSPI_HandleFixedBusy(TI_HANDLE hWSPI, UINT32 *pRbuf)
+{
+       WSPI_t  *pWSPI = (WSPI_t*)hWSPI;
+    UINT8   iTotalLength = pWSPI->length + pWSPI->uFixedBusyBytes;
+       UINT8   iExtraBufByteLength = 0;
+       int             status;
+
+       pWSPI->ExtraBufLength = 0;
+
+       /* Find the Data beginning */
+       while (((pRbuf[pWSPI->uFixedBusyLen + pWSPI->ExtraBufLength] & 0x1) == 0) &&
+                  ((pWSPI->uFixedBusyBytes + (pWSPI->ExtraBufLength * WSPI_SIZEOF_UINT32))  < iTotalLength) &&
+                  ((pWSPI->ExtraBufLength * WSPI_SIZEOF_UINT32 ) < WSPI_EXTRA_BUFFER_ALLOC_SIZE )) 
+       {
+               pWSPI->ExtraBufLength++;
+       }
+
+       #ifdef TI_DBG
+               if (pWSPI->ExtraBufLength > 0) 
+               {
+                       DebugFixedBusy[pWSPI->ExtraBufLength - 1]++;
+               }
+       #endif
+    
+       /* if we had less then WSPI_EXTRA_BUFFER_ALLOC_SIZE FixedBusy words */
+       if ((pRbuf[pWSPI->uFixedBusyLen + pWSPI->ExtraBufLength] & 0x1) != 0)
+       {
+               iExtraBufByteLength = pWSPI->ExtraBufLength*WSPI_SIZEOF_UINT32;
+
+               /* Execute read with extra fixed busy bytes and without CMD*/  
+               status = SPI_WriteRead(pWSPI->hSPI,
+                                                               NULL,
+                                                               0, 
+                                                               pWSPI->pExtraFixedBusyBuf, 
+                                                               iExtraBufByteLength, 
+                                                               WSPI_ReadDataAfterNotBusyCb,
+                                                               pWSPI,
+                                                               1);
+        /* In case of synchronous transaction call the handling function implicitly */
+               if (SPI_TXN_COMPLETE == status)
+               {
+                       WSPI_ReadDataAfterNotBusyCb(hWSPI, OK);
+               }
+       }
+       /* In the next case we try to read again even though the SPI line doesn't indicate any response  */
+       else if ( pWSPI->bUseTempBuf )
+       {       /* This case is handled for TempBuf only */ 
+               /* Execute read without CMD */  
+               status = SPI_WriteRead(pWSPI->hSPI,
+                                                               NULL,
+                                                               0, 
+                                                               pWSPI->pExtraFixedBusyBuf, 
+                                                               WSPI_EXTRA_READ_AFTER_NO_RESPONSE, 
+                                                               WSPI_ReadNotBusyAndDataCb,
+                                                               pWSPI,
+                                                               1);
+               /* In case of synchronous transaction call the handling function implicitly */
+               if (SPI_TXN_COMPLETE == status)
+               {
+                       WSPI_ReadNotBusyAndDataCb(hWSPI, OK);
+               }
+       }
+       else    /* Recovery from this one can be done by adjusting the length */
+       {
+               WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, 
+                       ("WSPI FIXED BUSY (READ CALLBACK) Cmd = 0x%x, data pointer = %p data = 0x%x length = %d\n",
+                       pWSPI->uCmd, pRbuf, pRbuf[pWSPI->uFixedBusyLen + 1],pWSPI->length));
+
+        if (pWSPI->fErr) 
+        {
+            (*pWSPI->fErr) ();
+        }
+
+        if (pWSPI->fCb != NULL)
+        {
+            pWSPI->fCb (pWSPI->pCb, WSPI_ERR_BUS_BUSY);
+        }
+    }       
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_WriteAsync
+ *
+ * Input    :   void* hWSPI    - the WSPI handle
+ *              UINT32 address - the address (in bytes) in the firmware to read the data from
+ *              UINT8* data    - the buffer that holds the data to write
+ *              UINT32 length  - the number of bytes to read
+ *              WSPI_CB_T cb   - callback parameters
+ *              BOOL bMore     - more read/write transaction will follow   
+ *              BOOL bSpaceReserved 
+                               - extra space padding has been reserved by an upper layer
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   WSPI_Status_e
+ *
+ * Note(s)  :   1. set the WSPI cammand+address word
+ *              2. set the command+address request struct
+ *              3. submit the request
+ *              4. set the write data request struct
+ *              5. submit the request with execute flag
+ *
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_WriteAsyncOld (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length, WSPI_CB_T* cb, BOOL bMore, BOOL bSpaceReserved)
+{
+    WSPI_t       *pWSPI = (WSPI_t*) hWSPI;
+    int           ret = WSPI_OK;
+
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+        
+    /*****************************/
+    /* Write the command+address */
+    /*****************************/
+    pWSPI->uCmd = WSPI_CMD_WRITE;
+
+    /* Set bFixedAddr */
+    if (pWSPI->bFixedAddr)
+    {
+        pWSPI->uCmd |= WSPI_CMD_FIXED;
+    } 
+        
+    /* Set the length */
+    pWSPI->uCmd |= ((UINT32)length << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+    /* Set the address */
+    pWSPI->uCmd |= address & WSPI_CMD_BYTE_ADDR;        
+    
+    /* Write */
+    ret |= SPI_WriteSync (pWSPI->hSPI, (UINT8*)&pWSPI->uCmd, WSPI_SIZEOF_UINT32);  
+
+    /******************/
+    /* Write the data */
+    /******************/
+
+    /* Tell the lower machine to start executing after this submission */   
+    ret |= SPI_Write (pWSPI->hSPI, 
+                      data + bSpaceReserved * WSPI_SIZEOF_CMD, 
+                      length, 
+                      cb->CBFunc, 
+                      cb->CBArg, 
+                      1); 
+
+    return ret; 
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_WriteAsync
+ *
+ * Input    :   void* hWSPI    - the WSPI handle
+ *              UINT32 address - the address (in bytes) in the firmware to read the data from
+ *              UINT8* data    - the buffer that holds the data to write
+ *              UINT32 length  - the number of bytes to read
+ *              WSPI_CB_T cb   - callback parameters
+ *              BOOL bMore     - more read/write transaction will follow   
+ *              BOOL bSpaceReserved 
+                               - extra space padding has been reserved by an upper layer
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   WSPI_Status_e
+ *
+ * Note(s)  :   3 options are checked in this function:
+ *              1) (bSpaceReserved == TRUE)
+ *                  write the command and the data in one chunk
+ *              2) else (length <= WSPI_NO_EXTRA_ALLOC_SIZE)
+ *                  copy Command + data to tempBuffer and write it in one chunk
+ *              3) else - error !!!
+ *
+ * -----------------------------------------------------------------------------
+ */
+int WSPI_WriteAsync (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length, WSPI_CB_T* cb, BOOL bMore, BOOL bSpaceReserved)                    
+{
+    WSPI_t       *pWSPI = (WSPI_t*) hWSPI;
+    int           status;
+
+    if (length == 0) 
+    {
+        return WSPI_ERR_WRONG_LENGTH;
+    }
+
+    /*****************************/
+    /* Write the command+address */
+    /*****************************/
+    pWSPI->uCmd = WSPI_CMD_WRITE;
+
+    /* Set bFixedAddr */
+    if (pWSPI->bFixedAddr)
+    {
+        pWSPI->uCmd |= WSPI_CMD_FIXED;
+    }
+        
+    /* Set the length */
+    pWSPI->uCmd |= (length << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
+    /* Set the address */
+    pWSPI->uCmd |= address & WSPI_CMD_BYTE_ADDR;        
+
+    if (bSpaceReserved)
+    {
+        /* If extra place was saved, transfer command and data in one transaction */
+        *(UINT32*)data = pWSPI->uCmd;
+        
+         status = SPI_Write (pWSPI->hSPI, 
+                             data, 
+                             length + WSPI_SIZEOF_CMD, 
+                             cb->CBFunc, 
+                             cb->CBArg, 
+                             bMore); 
+    }
+
+    /* If extra room was not saved for the command use temporary buffer */       
+    else if (length <= WSPI_NO_EXTRA_ALLOC_SIZE)
+    {
+      #if WSPI_NO_EXTRA_ALLOC_SIZE == 4 /* used for optimization */
+        /* Copy data to the temporary buffer */
+        *((UINT32*)(pWSPI->pTempBuf + WSPI_SIZEOF_CMD)) = *((UINT32*)data);
+      #else
+        os_memoryCopy (pWSPI->hOs, pWSPI->pTempBuf + WSPI_SIZEOF_CMD, data, length);            
+      #endif 
+    
+        /* Put the command at the beginning of the temporary buffer */
+        *((UINT32*)pWSPI->pTempBuf) = pWSPI->uCmd;
+
+        status = SPI_Write (pWSPI->hSPI, 
+                            pWSPI->pTempBuf, 
+                            length + WSPI_SIZEOF_CMD, 
+                            cb->CBFunc, 
+                            cb->CBArg, 
+                            bMore); 
+    }
+    else 
+    {   
+        WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("No space reserved for command\n"));
+                           
+        return WSPI_ERR_UNKNOWN;
+    }
+
+    return status; 
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_GenerateCRC7
+ *
+ * Input    :   UINT8* bits - a string that holds the bits, in the order from the first to last
+ *              UINT32 len - the number of bits
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   UINT8 - the CRC word
+ *
+ * Note(s)  :   calculates the CRC7 for the WSPI init command
+ * -----------------------------------------------------------------------------
+ */
+static UINT8 WSPI_GenerateCRC7 (UINT8* bits, UINT32 len)
+{
+    UINT8 CRC, CRC0, CRC1, CRC2, CRC3, CRC4, CRC5, CRC6;
+    UINT8 bit, temp;
+    UINT32   i;
+
+    CRC0 = CRC1 = CRC2 = CRC3 = CRC4 = CRC5 = CRC6 = 0;
+
+    /* Calculate the CRC with the formula : G(x) = x^7 + x^3 + 1 */
+    for (i = 0; i < len; i++)
+    {
+        bit = (bits[i / 8] & (1 << (7 - (i % 8)))) >> (7 - (i % 8));
+        temp = CRC6;        
+        CRC6 = CRC5;
+        CRC5 = CRC4;
+        CRC4 = CRC3;
+        CRC3 = CRC2;
+        CRC2 = CRC1;
+        CRC1 = CRC0;
+        CRC0 = temp ^ bit;
+        CRC3 = CRC0 ^ CRC3;
+    }
+
+    CRC = CRC0;
+    CRC |= CRC1 << 1;
+    CRC |= CRC2 << 2;
+    CRC |= CRC3 << 3;
+    CRC |= CRC4 << 4;
+    CRC |= CRC5 << 5;
+    CRC |= CRC6 << 6; 
+
+    return CRC;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_ReadAsyncCb
+ *
+ * Input    :   void* handle - a handle that was passed to the asynchronous request (usually the WSPI handle)
+ *              int status - the status of the SPI request
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   none
+ *
+ * Note(s)  :   this is a temp function for passing as a CB function to the SPI layer for checking the async mechanism
+ * -----------------------------------------------------------------------------
+ */
+static void WSPI_ReadAsyncCb (void* hWSPI, int status)
+{
+    WSPI_t *pWSPI = (WSPI_t*) hWSPI;
+    /* Check the fixed busy word */
+    if ((pWSPI->uFixedBusy & 0x1) != 0) 
+    {
+        pWSPI->fCb (pWSPI->pCb, 0);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pWSPI->hReport, HAL_HW_CTRL_MODULE_LOG, ("WSPI FIXED BUSY (CALLBACK)\n"));
+
+        if (pWSPI->fErr) 
+        {
+            (*pWSPI->fErr) ();
+        }
+
+        pWSPI->fCb (pWSPI->pCb, -1);
+    }               
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function :   WSPI_SyncOverAsyncCb
+ *
+ * Input    :   void* handle - a handle that was passed to the asynchronous request
+ *              int status - the status that the SPI request ended
+ *
+ * Output   :   none
+ *
+ * ReturnVal:   none
+ *
+ * Note(s)  :   this function just sets a flag so the sync SPI read/write function 
+ *              can return
+ * -----------------------------------------------------------------------------
+ */
+#ifdef USE_SYNC_OVER_ASYNC
+static void WSPI_SyncOverAsyncCb (void* hWSPI, int status)
+{
+    WSPI_t* pWSPI = (WSPI_t*) hWSPI;
+
+  #ifdef USE_SPI_DEBUG  
+    {
+        SPI_t *pSPI = (SPI_t*) pWSPI->hSPI;
+        pSPI->stat.uNumOfSyncOverAsync ++;
+    }
+  #endif
+
+    pWSPI->bSyncFlag = 1;
+}
+#endif
+
+
+void WSPI_SetErrLog (void* hWSPI, void (*fErr)(void))
+{
+    WSPI_t* pWSPI = (WSPI_t*) hWSPI;
+
+    pWSPI->fErr = fErr;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/wspi.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/BusTxn/wspi.h
new file mode 100644 (file)
index 0000000..c83f5d8
--- /dev/null
@@ -0,0 +1,160 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+                                 
+#ifndef _WSPI_H_
+#define _WSPI_H_
+
+
+/*
+ * Define this flag to use write-read SPI driver API
+ */
+#define USE_WRITE_READ_API
+
+/*
+ * Define this flag to use sync-over-async mode
+ */
+#undef  USE_SYNC_OVER_ASYNC
+
+
+/* Return codes */
+typedef enum 
+{
+    WSPI_OK                =  0,
+    WSPI_TXN_COMPLETE      =  0,
+    WSPI_TXN_PENDING       =  1,
+    WSPI_ERR_UNKNOWN       = -1,
+    WSPI_ERR_BUS_BUSY      = -2,
+    WSPI_ERR_QUEUE_FULL    = -3,
+    WSPI_ERR_ALLOC_MEM     = -4,
+    WSPI_ERR_ASYNC_TIMEOUT = -5, 
+    WSPI_ERR_WRONG_LENGTH  = -6,
+
+} WSPI_Status_e; 
+
+
+typedef struct _WSPI_CB_t
+{
+    void (*CBFunc) (void *data, int status);
+       void  *CBArg;
+
+} WSPI_CB_T;
+
+
+typedef struct _WSPIConfig_t
+{
+       int isFixedAddress;
+       int fixedBusyLength;
+       UINT8 mask;
+
+} WSPIConfig_t;
+
+
+/* WSPI API */
+TI_HANDLE WSPI_Open       (TI_HANDLE hOs);
+int       WSPI_Close      (TI_HANDLE hWSPI);
+int       WSPI_Configure  (TI_HANDLE hWSPI, TI_HANDLE hReport, const WSPIConfig_t* aConfig, WSPI_CB_T* CB);
+int       WSPI_ReadAsync  (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length, WSPI_CB_T* CB, BOOL bMore, BOOL bSpaceReserved);  
+int       WSPI_WriteAsync (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length, WSPI_CB_T* CB, BOOL bMore, BOOL bSpaceReserved);
+void     WSPI_HandleFixedBusy(TI_HANDLE hWSPI, UINT32 *pRbuf);
+#ifdef USE_SYNC_API
+int       WSPI_ReadSync   (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length);
+int       WSPI_WriteSync  (TI_HANDLE hWSPI, UINT32 address, UINT8* data, UINT32 length);
+#endif
+void WSPI_SetErrLog (void* hWSPI, void (*fErr)(void));
+
+
+
+/* Size of WSPI command */
+#define WSPI_SIZEOF_CMD             4
+
+/* Used to decide whether we want to use the temp buffer in order to read/write the data */ 
+#define WSPI_NO_EXTRA_ALLOC_SIZE    4 
+
+/* Init command length */
+#define WSPI_INIT_CMD_LEN           8
+
+/* Size of extra buffer size :                                                                                                                                                         */
+/* NumOfExtraFixedBusy * WordLen + DataLost(beacuse of fixed busy) * WordLen  = 10 * 4 + 10 * 4  = 80  */
+#define WSPI_EXTRA_BUFFER_ALLOC_SIZE    80
+
+/* Define the number of bytes to be read after FIXED BUSY error without the ~Busy word */
+#define WSPI_EXTRA_READ_AFTER_NO_RESPONSE (28 - WSPI_NO_EXTRA_ALLOC_SIZE)
+
+/* WSPI handle */
+typedef struct _WSPI_t
+{       
+    TI_HANDLE           hOs;              /* OS wrapper */ 
+    TI_HANDLE           hReport;          /* Report handler */ 
+    TI_HANDLE           hSPI;             /* SPI driver handle */
+    BOOL                bFixedAddr;       /* use fixed address */
+    UINT32              uFixedBusyLen;    /* number of fixed busy cycles */
+    UINT32              uFixedBusyBytes;  /* number of fixed busy bytes */ 
+    UINT32              uFixedBusy;       /* fixed busy buffer */
+    UINT8               uConfigMask;      /* configurable Mask for the Init CMD */
+    UINT32              uCmd;             /* command word */
+    UINT8               auInitCmd [WSPI_INIT_CMD_LEN]; 
+                                          /* init command buffer */
+    UINT8*              pTempBuf;         /* used for buffers with no extra room for command/fixed busy */
+    UINT8*              data;             /* save the pointer to the data for read */
+    UINT32              length;           /* save length of the buffer to be read */
+    void              (*fCb) (void *data, int status);  
+                                          /* callback function */          
+    void               *pCb;              /* callback argument */
+    WSPI_Status_e       status;           /* holds the current status */
+    BOOL                bSpaceReserved;   /* extra room was saved for the fixed busy or command */
+    BOOL                bMore;            /* indicate whether more use of the SPI is about to take place */
+    BOOL                bUseTempBuf;      /* use temporary buffer */
+    void              (*fErr) (void);     /* user debug error handler */ 
+
+       UINT8*              pExtraFixedBusyBuf; 
+                                                                                 /* used for a seconed SPI read */
+                                                                                 /* for calls that returend with more FixedBusy words than allowed */
+       UINT32              ExtraBufLength;   /* save length of the extra buffer to be read */
+       int                                     returnStatus;     /* return status for SPI_XXX functions. Note that return status is from type int */
+
+  #ifdef USE_SYNC_OVER_ASYNC
+    /*
+     * NOTE: This flag MUST be volatile because its value is changed
+     *       in the context of ISR. So, the compiler is prohibited
+     *       to make register optimization inside the routine it polls for 
+     */
+    volatile int        bSyncFlag;
+  #endif
+   
+} WSPI_t;
+
+
+#endif /* _WSPI_H_ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/ELP_Controller/ElpCtrl.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/ELP_Controller/ElpCtrl.c
new file mode 100644 (file)
index 0000000..6261abd
--- /dev/null
@@ -0,0 +1,617 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**********************************************************************************/
+/*                                                                                */
+/*   MODULE:  ElpCtrl.c                                                           */
+/*   PURPOSE: ELP controller implementation module                                    */
+/*                                                                                */
+/**********************************************************************************/
+#include "osApi.h"
+#include "whalBus_Api.h"  
+#include "fsm.h"
+#include "TNETWIF.h"
+#include "whalHwAccess.h"
+#include "ElpCtrl.h"
+/* #include <linux/timer.h> */
+
+/* Healthy timer timeout in milliseconds */
+#define ELPCTRL_TIMER_TIMEOUT 100
+
+
+typedef enum 
+{
+    ELPS_AWAKE,
+    ELPS_ASLEEP,
+    ELPS_WAKING_UP_WRITE,
+    ELPS_WAKING_UP_READ,
+    ELPS_WAKING_UP_MUX
+
+} elpCtrl_State_e;
+
+
+typedef struct _elpCtrl_t
+{       
+    TI_HANDLE               hOs;
+    TI_HANDLE               hTNETWIF;
+    TI_HANDLE               hTNETWArb;
+    
+    TNETWIF_callback_t      fCb;
+    elpCtrl_Mode_e          mode;
+    elpCtrl_State_e         state; 
+    UINT32                  uElpRegister;
+    BOOL                    bExitWakeUpSeq;
+    BOOL                    bMuxBackNeeded;
+       BOOL                                    bSynch;
+    TI_STATUS               eReturnValue;
+
+    failureEventCB_t        fFail;    /* upper layer failure event callback.
+                                       * called when the scan command has been timer expiry */
+    TI_HANDLE               hFail;    /* object parameter passed to the fFail
+                                                  * when it is called */
+    TI_HANDLE               hTimer;
+
+} elpCtrl_t;
+
+/****************************************************************************
+*                      elpCtrl_TimerTimeout()
+****************************************************************************
+* DESCRIPTION: 
+* 
+* INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+*      
+* OUTPUT:  
+* 
+* RETURNS: OK
+****************************************************************************/
+void elpCtrl_TimerTimeout (TI_HANDLE hElpCtrl)
+{
+       elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+       /* 
+       * Error Reporting and Recovery
+       * This Timeout means that we failed to wake up the FW 
+       * so the only way out of it is to restart the device - by recovery
+       */
+       /* WLAN_OS_REPORT (("elpCtrl_TimerTimeout - ELP timeout timer expired! %lu\n", jiffies)); */
+    WLAN_OS_REPORT (("elpCtrl_TimerTimeout - ELP timeout timer expired!\n"));
+
+       if (pElpCtrl->fFail)
+               pElpCtrl->fFail (pElpCtrl->hFail, HW_AWAKE_FAILURE);
+}
+
+/****************************************************************************
+ *                      elpCtrl_Create()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hOs - the handle to the OS layer
+ *          hReport - the handle to the report module 
+ *      
+ * 
+ * OUTPUT:  the context of the ElpCtrl module
+ * 
+ * RETURNS: the context of the ElpCtrl module (NULL if error)
+ ****************************************************************************/
+TI_HANDLE elpCtrl_Create (TI_HANDLE hOs)
+{
+    elpCtrl_t *pElpCtrl;
+
+    /* Create context */
+    pElpCtrl = os_memoryAlloc (hOs, sizeof(elpCtrl_t));
+    if (pElpCtrl == NULL)
+    {
+        WLAN_OS_REPORT (("%s: Error allocating object\n", __FUNCTION__));
+        return NULL;        
+    }
+    os_memoryZero (hOs, pElpCtrl, sizeof(elpCtrl_t));
+
+    pElpCtrl->hOs = hOs;
+   
+    /* Create timer */
+    pElpCtrl->hTimer = os_timerCreate (hOs, elpCtrl_TimerTimeout, pElpCtrl);
+    if (pElpCtrl->hTimer == NULL)
+    {
+        WLAN_OS_REPORT (("%s: Error in creating timer\n", __FUNCTION__));
+        elpCtrl_Destroy (pElpCtrl);
+        return NULL;
+    }
+
+    return pElpCtrl;
+}
+
+
+/****************************************************************************
+ *                      elpCtrl_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ *      
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK
+ ****************************************************************************/
+int elpCtrl_Destroy (TI_HANDLE hElpCtrl)
+{           
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    if (pElpCtrl)
+    {
+        if (NULL != pElpCtrl->hTimer)
+        {
+            os_timerDestroy (pElpCtrl->hOs, pElpCtrl->hTimer);
+        }
+
+        os_memoryFree (pElpCtrl->hOs, pElpCtrl, sizeof(elpCtrl_t));
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      elpCtrl_Configure()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module
+ *          hTNETWIF - the handle to the TNETWIF module
+ *          fCb      - ELP asynchronous operation default callback
+ *      
+ * OUTPUT:  
+ * 
+ * RETURNS: ELPCTRL_COMPLETE - if succeeded (sync.)
+ *          ELPCTRL_PENDING  - if succeeded (async.)
+ *          ELPCTRL_ERROR    - if failed
+ ****************************************************************************/
+int elpCtrl_Configure (TI_HANDLE hElpCtrl, TI_HANDLE hTNETWIF, TNETWIF_callback_t fCb)
+{
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+  
+    pElpCtrl->state = ELPS_AWAKE;
+    pElpCtrl->mode = ELPCTRL_MODE_KEEP_AWAKE;
+    pElpCtrl->hTNETWIF = hTNETWIF;
+    pElpCtrl->hTNETWArb = ((TNETWIF_t *)hTNETWIF)->hTNETWArb;
+    pElpCtrl->fCb = fCb;
+    pElpCtrl->bMuxBackNeeded = FALSE;
+    return ELPCTRL_COMPLETE;
+}
+/****************************************************************************
+ *                      elpCtrl_wakeUpSeqSM()
+ ****************************************************************************
+ * DESCRIPTION: SM for handling Synch & Asynch wake up sequence.
+ *              The flow of the SM is by that order:
+ *              WRITE (wake up) -> READ (elp) -> if awake - exit. else WRITE (mux)
+ *
+ * OUTPUT:      
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+static void elpCtrl_wakeUpSeqSM (TI_HANDLE hElpCtrl, UINT8 module_id, TI_STATUS status)
+{
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+    
+    /* Check if Arbiter announced that interrupt occurred (i.e. no need for wake up sequence) */
+    if (pElpCtrl->bExitWakeUpSeq)
+    {     
+        /* Fw is up - we should imitate TXN_COMPLETE to announce that we are done */
+        pElpCtrl->state = ELPS_AWAKE;
+        /* set TXN_COMPLETE to ArbiterSM - Note: It could only happen in Asynch IF */
+        pElpCtrl->fCb (pElpCtrl->hTNETWArb, DEFAULT_MODULE_ID, OK);
+        return;
+    }
+
+    pElpCtrl->eReturnValue = OK;
+
+    /*
+     * This while loop will continue till the exit or when waiting for the CB due to
+     * memory transfer operation pending for DMA to complete   
+     */
+    while (TNETWIF_PENDING != pElpCtrl->eReturnValue)
+    {
+        switch(pElpCtrl->state) 
+        {
+        case ELPS_ASLEEP:
+
+            pElpCtrl->state = ELPS_WAKING_UP_WRITE;
+            pElpCtrl->eReturnValue = TNETWIF_WriteELPOpt (pElpCtrl->hTNETWIF, 
+                                                            ELPCTRL_WAKE_UP, 
+                                                            DEFAULT_MODULE_ID,
+                                                            elpCtrl_wakeUpSeqSM, 
+                                                            hElpCtrl,
+                                                            TRUE);
+            break;
+
+        
+        case ELPS_WAKING_UP_WRITE:
+
+            pElpCtrl->state = ELPS_WAKING_UP_READ;
+            pElpCtrl->eReturnValue = TNETWIF_ReadELPOpt (pElpCtrl->hTNETWIF, 
+                                                            (UINT8*)&pElpCtrl->uElpRegister, 
+                                                            DEFAULT_MODULE_ID,
+                                                            elpCtrl_wakeUpSeqSM,
+                                                            hElpCtrl,
+                                                            TRUE);
+            break;
+
+        case ELPS_WAKING_UP_READ:
+
+            /* Check whether Muxing is needed */
+            if (pElpCtrl->uElpRegister & ELPCTRL_WLAN_READY)
+            {
+                /* Fw is up, but no WLAN_READY interrupt will occur (since we disabled the mux) */
+                pElpCtrl->state = ELPS_AWAKE;
+                /* 
+                                * set TXN_COMPLETE to ArbiterSM only if we are not working in synchronize IF 
+                                *  In synch IF we set the TXN_COMPLETE at the end of this function
+                                */
+                               if ( !pElpCtrl->bSynch)
+                               {
+                                       pElpCtrl->fCb (pElpCtrl->hTNETWArb, DEFAULT_MODULE_ID, OK);
+                               }
+            } 
+            else /* Fw is asleep - Mux to WLAN_READY and let arbiter wait for interrupt */
+            {
+                               pElpCtrl->state = ELPS_WAKING_UP_MUX;
+                pElpCtrl->bMuxBackNeeded = TRUE;
+#ifdef DM_USE_WORKQUEUE
+                /* printk("TI: %s:\t%lu - start timeout 1000 ms\n", __FUNCTION__, jiffies); */
+                os_timerStart (pElpCtrl->hOs, pElpCtrl->hTimer, ELPCTRL_TIMER_TIMEOUT * 10, FALSE);
+#else
+                os_timerStart (pElpCtrl->hOs, pElpCtrl->hTimer, ELPCTRL_TIMER_TIMEOUT, FALSE);
+#endif
+                /* 
+                 * Mux to WLAN_READY and let the Arbiter wait for Txn complete 
+                 */
+                pElpCtrl->eReturnValue = TNETWIF_WriteELPOpt (pElpCtrl->hTNETWIF,  
+                                        ELPCTRL_WAKE_UP_WLAN_READY, 
+                                        DEFAULT_MODULE_ID,
+                                        pElpCtrl->fCb, 
+                                        pElpCtrl->hTNETWArb,
+                                        TRUE);
+                               if(TNETWIF_PENDING == pElpCtrl->eReturnValue)
+                               {
+                    /* If we are here then we are not using Synch IF */
+                                       pElpCtrl->bSynch = FALSE;
+                               }
+
+                               /* The previous states was async and now it sync */
+                               if((TNETWIF_COMPLETE == pElpCtrl->eReturnValue) && (pElpCtrl->bSynch == FALSE))
+                               {
+                                          pElpCtrl->fCb (pElpCtrl->hTNETWArb, DEFAULT_MODULE_ID, OK);
+                               }
+             }
+    
+             return;
+
+        default:
+            
+            WLAN_OS_REPORT(("Error: %s state = %d\n", __FUNCTION__, pElpCtrl->state));
+            
+        }
+    }
+       /* If we are here then we are not using Synch IF */
+       pElpCtrl->bSynch = FALSE;
+}
+
+/****************************************************************************
+ *                      elpCtrl_Wake()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module
+ *          bHwAvail - TRUE if HW is available           
+ *      
+ * OUTPUT:  
+ * 
+ * RETURNS: TNETWIF_COMPLETE | TNETWIF_PENDING
+ ****************************************************************************/
+int elpCtrl_Wake (TI_HANDLE hElpCtrl, BOOL bHwAvail)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+    int rc = ELPCTRL_AWAKE;
+
+    if (pElpCtrl->state == ELPS_ASLEEP)
+    {           
+        if (bHwAvail == FALSE)
+        {
+            /* 
+             * Wake up the FW without mux. The mux will be done only if the FW is asleep. This is done due to a race 
+             * condition in the Fw, which causes 2 interrupts in the driver - one of them is not needed
+             */  
+            pElpCtrl->bExitWakeUpSeq = FALSE;
+                       pElpCtrl->bSynch                 = TRUE;
+
+            elpCtrl_wakeUpSeqSM (hElpCtrl, DEFAULT_MODULE_ID, OK);
+
+            /* 
+             * In Synch IF we send won't send TXN_COMPLETE from elpCtrl so we should 
+                        * indicate the arbiter to roll forward its SM. 
+             */
+            rc = ((pElpCtrl->bSynch) ? ELPCTRL_WLAN_RDY_COMPLETE : ELPCTRL_COMPLETE);
+        }
+        else
+        {
+            pElpCtrl->state = ELPS_AWAKE;
+
+            if (TNETWIF_WriteELPOpt (pElpCtrl->hTNETWIF, 
+                                     ELPCTRL_WAKE_UP, 
+                                     DEFAULT_MODULE_ID,
+                                     pElpCtrl->fCb, 
+                                     pElpCtrl->hTNETWArb,
+                                     TRUE) == TNETWIF_COMPLETE)
+            {
+                rc = ELPCTRL_WLAN_RDY_COMPLETE; 
+            }
+            else
+            {
+                rc = ELPCTRL_WLAN_RDY;
+            }
+        }
+    }   
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      elpCtrl_Sleep()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: TNETWIF_PENDING | TNETWIF_COMPLETE
+ ****************************************************************************/
+int elpCtrl_Sleep (TI_HANDLE hElpCtrl)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+    int rc = TNETWIF_COMPLETE;
+
+    if (pElpCtrl->state == ELPS_AWAKE && pElpCtrl->mode == ELPCTRL_MODE_NORMAL)
+    {
+        pElpCtrl->state = ELPS_ASLEEP;
+
+        /* IRQ_SRC(0) WLAN_WUP(0) - 'more' flag is FALSE since the HW is going to sleep */
+        rc = TNETWIF_WriteELPOpt (pElpCtrl->hTNETWIF, 
+                                  ELPCTRL_SLEEP, 
+                                  DEFAULT_MODULE_ID,
+                                  pElpCtrl->fCb, 
+                                  pElpCtrl->hTNETWArb,
+                                  FALSE);
+    }
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      elpCtrl_Unmux()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: TNETWIF_PENDING | TNETWIF_COMPLETE
+ ****************************************************************************/
+int elpCtrl_UnMux (TI_HANDLE hElpCtrl)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+    int rc = (pElpCtrl->bMuxBackNeeded ? OK : NOK);
+
+
+    pElpCtrl->bMuxBackNeeded = FALSE;
+
+    return rc;
+}
+
+/****************************************************************************
+ *                      elpCtrl_ReceivedIRQ()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: TNETWIF_PENDING | TNETWIF_COMPLETE
+ ****************************************************************************/
+void elpCtrl_ReceivedIRQ (TI_HANDLE hElpCtrl)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    if (pElpCtrl->state == ELPS_WAKING_UP_MUX)
+    {
+        pElpCtrl->state = ELPS_AWAKE;
+        /* printk("TI: %s:\t%lu - stop timeout\n", __FUNCTION__, jiffies); */
+        os_timerStop (pElpCtrl->hOs, pElpCtrl->hTimer);
+    }
+
+    return;
+}
+
+/****************************************************************************
+ *                      elpCtrl_Mode()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ *      
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: ELPCTRL_COMPLETE 
+ ****************************************************************************/
+int elpCtrl_Mode (TI_HANDLE hElpCtrl, elpCtrl_Mode_e mode)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    pElpCtrl->mode = mode;
+
+    return ELPCTRL_COMPLETE;
+}
+
+/****************************************************************************
+ *                      elpCtrl_isIRQComing()
+ ****************************************************************************
+ * DESCRIPTION: Check if IRQ is about to come from Fw - depending on the ELP state
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ *      
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: TRUE - IRQ will arrive from WLAN_READY. FALSE - Otherwise 
+ ****************************************************************************/
+BOOL elpCtrl_isIRQComing (TI_HANDLE hElpCtrl)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    return (pElpCtrl->state == ELPS_WAKING_UP_MUX ? TRUE : FALSE);
+}
+
+/****************************************************************************
+ *                      elpCtrl_exitWakeUpSeq()
+ ****************************************************************************
+ * DESCRIPTION: Mark that exit from wake up sequence is needed and return if 
+ *                wake up is already over.
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ *      
+ * 
+ * OUTPUT:  bExitWakeUpSeq = TRUE
+ * 
+ * RETURNS: TRUE - IRQ will arrive from WLAN_READY. FALSE - Otherwise 
+ ****************************************************************************/
+elpCtrl_e elpCtrl_exitWakeUpSeq (TI_HANDLE hElpCtrl)
+{   
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    if (pElpCtrl->state == ELPS_AWAKE)
+    {   /* We are already awake */
+        return ELPCTRL_AWAKE;
+    }
+    else /* Still in wake up sequence */
+    {
+        pElpCtrl->bExitWakeUpSeq = TRUE;
+        return ELPCTRL_ASLEEP;
+    }
+}
+
+/****************************************************************************************
+ *                       elpCtrl_RegisterFailureEventCB                                                 *
+ ****************************************************************************************
+DESCRIPTION: Registers a failure event callback for Hw available               
+                                                                                                                   
+INPUT:      - hElpCtrl  - handle to the Elp Ctrl object.        
+            - fCb       - the failure event callback function.\n
+            - hCb       - handle to the object passed to the failure event callback function.
+
+OUTPUT: 
+
+RETURN:    void.
+****************************************************************************************/
+
+void elpCtrl_RegisterFailureEventCB (TI_HANDLE hElpCtrl, void *fCb, TI_HANDLE hCb)
+{
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    pElpCtrl->fFail = (failureEventCB_t)fCb;
+    pElpCtrl->hFail  = hCb;
+}
+
+/****************************************************************************
+ *                      elpCtrl_Stop()
+ ****************************************************************************
+ * DESCRIPTION: Stop ElpCtrl module before Recovery.
+ *              Move to "open": MODE_KEEP_AWAKE + STATE_ON
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK
+ ****************************************************************************/
+int elpCtrl_Stop(TI_HANDLE hElpCtrl)
+{
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    /* set the init state */
+    pElpCtrl->mode =  ELPCTRL_MODE_KEEP_AWAKE;
+    pElpCtrl->state = ELPS_AWAKE;
+
+    /* printk("TI: %s:\t%lu - stop timeout\n", __FUNCTION__, jiffies); */
+    os_timerStop (pElpCtrl->hOs, pElpCtrl->hTimer);
+    
+    return OK;
+}
+
+/****************************************************************************
+ *                      elpCtrl_Start()
+ ****************************************************************************
+ * DESCRIPTION: Stop ElpCtrl module before Recovery.
+ *              Move to "open": MODE_KEEP_AWAKE + STATE_ON
+ * 
+ * INPUTS:  hElpCtrl - the handle to the ElpCtrl module.
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK
+ ****************************************************************************/
+int elpCtrl_Start(TI_HANDLE hElpCtrl)
+{
+    elpCtrl_t *pElpCtrl = (elpCtrl_t*)hElpCtrl;
+
+    /* Set: SCR = 1 and WUP = 1. The pattern is 101 */
+    /* NOTE: no callback needed */
+    /* IRQ_SRC(1) WLAN_WUP(1)*/
+    TNETWIF_WriteELPOpt (pElpCtrl->hTNETWIF, 
+                         ELPCTRL_WAKE_UP, 
+                         DEFAULT_MODULE_ID,
+                         NULL, 
+                         NULL,
+                         TRUE);
+
+    
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Export_Inc/TNETWIF.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Export_Inc/TNETWIF.h
new file mode 100644 (file)
index 0000000..5bdcf48
--- /dev/null
@@ -0,0 +1,214 @@
+/** \file GWSI_Synchronizer.h
+ *  \brief GWSI Synchronizer include file
+ *
+ *  \see GWSI_Synchronizer.c 
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   TNETWIF.h                                                  */
+/*    PURPOSE:  TNETWIF api file                                            */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef TNETWIF_H
+#define TNETWIF_H
+
+#include "commonTypes.h"
+#include "TNETW_Driver_types.h"
+
+
+/* Modules ID's */
+enum 
+{
+    DEFAULT_MODULE_ID = 0,
+    TX_XFER_MODULE_ID, 
+    HAL_RX_MODULE_ID,  
+    HAL_INT_MODULE_ID,  
+    HAL_CMD_MODULE_ID,  
+    FW_EVENT_MODULE_ID,
+    HAL_INIT_MODULE_ID,
+
+    NUM_OF_TNETWIF_MODULES,
+    TNETWIF_LAST_MODULE_ID = NUM_OF_TNETWIF_MODULES - 1
+};
+
+
+typedef enum
+{
+    HW_ACCESS_DOWNLOAD,
+    HW_ACCESS_WORKING,
+
+} TNETIF_HwAccess_SetPartition_mode_e;
+
+
+/* 
+ * Defines a TNETWIF read/write field with padding.
+ * A low level driver may use this padding internally
+ */
+#if defined(HW_ACCESS_WSPI)
+#define PADDING(field) \
+    UINT8 padding [TNETWIF_READ_OFFSET_BYTES]; \
+    field;
+#else
+#define PADDING(field) field;
+#endif
+/*
+ * A pointer to the read offset of the padded field
+ */
+#define PADREAD(field_ptr) \
+   (((UINT8*)field_ptr) - TNETWIF_READ_OFFSET_BYTES)
+
+/*
+ * A pointer to the write offset of the padded field
+ */
+#define PADWRITE(field_ptr) \
+   (((UINT8*)field_ptr) - TNETWIF_WRITE_OFFSET_BYTES)
+
+
+typedef void (*TNETWIF_callback_t)(TI_HANDLE CB_Handle, UINT8 module_id, TI_STATUS status);
+
+/**************************** TNETWIF_CB ********************************/
+/****************************************************************************/
+typedef struct T_TNETWIF_CB
+{
+    TI_HANDLE           hOs;
+    TI_HANDLE           hReport;
+    TI_HANDLE           hTNETWArb;
+    TI_HANDLE           hHwAccess;
+    TI_HANDLE           hELPCtrl;
+    UINT32              uInitStage;
+    UINT32              uRegBaseAddr;
+    UINT32              uMemBaseAddr;
+    TNETWIF_callback_t  fCb;
+    TI_HANDLE           hCb;
+    TI_STATUS           status;
+} TNETWIF_t;
+
+
+/* API for external module in charge of creating the gwsi_synchronizer initialization */
+TI_HANDLE TNETWIF_Create              (TI_HANDLE hOs);
+TI_STATUS TNETWIF_Config              (TI_HANDLE hTNETWIF, TI_HANDLE hReport, UINT32 uRegBaseAddr, UINT32 uMemBaseAddr, TNETWIF_callback_t fCb, TI_HANDLE hCb);
+TI_STATUS TNETWIF_Destroy             (TI_HANDLE hTNETWIF);
+
+/************************************************************************
+ API for the recovery 
+************************************************************************/
+TI_STATUS TNETWIF_ReConfig            (TI_HANDLE hTNETWIF);
+
+/************************************************************************
+ API for the OS (PALAU) to handle the running module's Callbacks.
+************************************************************************/
+void      TNETWIF_BusTxn_Complete     (TI_HANDLE hTNETWIF);
+
+/************************************************************************
+ API for the Client to send an event to the Synchronizer : It can be :
+            EV_REG_ID (PERFORM_IMMEDIATE or start time for future use)
+            EV_FINISH_ID (To be called by the client when if finishes its State Machine
+************************************************************************/
+TI_STATUS TNETWIF_Start               (TI_HANDLE hTNETWIF, UINT8 module_id, TI_HANDLE CB_Handle,TNETWIF_callback_t CallBack_Func);
+TI_STATUS TNETWIF_Restart             (TI_HANDLE hTNETWIF, UINT8 module_id, TI_HANDLE CB_Handle,TNETWIF_callback_t CallBack_Func);
+TI_STATUS TNETWIF_Finish              (TI_HANDLE hTNETWIF, UINT8 module_id, TI_HANDLE CB_Handle,TNETWIF_callback_t CallBack_Func);
+
+/************************************************************************
+ API for the Client to use the ElpCtrl
+************************************************************************/
+int TNETWIF_ElpCtrl_Mode              (TI_HANDLE hTNETWIF, elpCtrl_Mode_e mode);
+int TNETWIF_ElpCtrl_HostIF_required   (TI_HANDLE hTNETWIF, int flag);
+TI_STATUS TNETWIF_UnMux (TI_HANDLE hTNETWIF);
+
+/************************************************************************
+ API for the Client to do I/O operations write/read Memory/Register 
+************************************************************************/
+TI_STATUS   TNETWIF_SetPartitionsOpt  (TI_HANDLE hTNETWIF, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start, UINT8 module_id, TNETWIF_callback_t CBFunc, TI_HANDLE CB_Handle);
+void TNETWIF_RegisterFailureEventCB   (TI_HANDLE hTNETWIF, void *failureEventCB, TI_HANDLE hFailureEventObj );
+void TNETWIF_RegisterBusFailureEventCB(TI_HANDLE hTNETWIF, void *failureEventCB, TI_HANDLE hFailureEventObj );
+void TNETWIF_RegisterFailureEventCB   (TI_HANDLE hTNETWIF, void *failureEventCB, TI_HANDLE hFailureEventObj);
+
+/************************************************************************
+ Optimized IO mode : In this mode the SDIO/SPI Driver will decide with its inner thresholds if to make a DMA or not
+************************************************************************/
+TI_STATUS   TNETWIF_ReadMemOpt        (TI_HANDLE hTNETWIF, UINT32 addr, UINT8* data, UINT32 len, UINT8 module_id, TNETWIF_callback_t CBFunc, TI_HANDLE CB_Handle);
+TI_STATUS   TNETWIF_WriteMemOpt       (TI_HANDLE hTNETWIF, UINT32 addr, UINT8* data, UINT32 len, UINT8 module_id, TNETWIF_callback_t CBFunc, TI_HANDLE CB_Handle);
+TI_STATUS   TNETWIF_ReadRegOpt        (TI_HANDLE hTNETWIF, UINT32 addr, UINT32* data,            UINT8 module_id, TNETWIF_callback_t CBFunc, TI_HANDLE CB_Handle);
+TI_STATUS   TNETWIF_WriteRegOpt       (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 data,             UINT8 module_id, TNETWIF_callback_t CBFunc, TI_HANDLE CB_Handle);
+TI_STATUS   TNETWIF_WriteELPOpt       (TI_HANDLE hTNETWIF,              UINT32 data,             UINT8 module_id, TNETWIF_callback_t CBFunc, TI_HANDLE CB_Handle, BOOL bMore);
+TI_STATUS   TNETWIF_ReadELPOpt        (TI_HANDLE hTNETWIF,              UINT8 *data, UINT8 module_id, TNETWIF_callback_t fCb, TI_HANDLE hCb, BOOL bMore);
+
+#ifdef USE_SYNC_API
+
+TI_STATUS   TNETWIF_SetPartitions     (TI_HANDLE hTNETWIF, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start);
+
+/************************************************************************
+ Synchronous IO mode 
+************************************************************************/
+TI_STATUS   TNETWIF_ReadMemSync       (TI_HANDLE hTNETWIF, UINT32 addr, UINT8* data, UINT32 len);
+TI_STATUS   TNETWIF_WriteMemSync      (TI_HANDLE hTNETWIF, UINT32 addr, UINT8* data, UINT32 len);
+TI_STATUS   TNETWIF_ReadRegSync       (TI_HANDLE hTNETWIF, UINT32 addr, UINT32* data);
+TI_STATUS   TNETWIF_WriteRegSync      (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 data);
+TI_STATUS   TNETWIF_WriteELPSync      (TI_HANDLE hTNETWIF,              UINT32 data);
+
+/*
+ * Hardware memory API
+ */
+UINT8       TNETWIF_GetU08            (TI_HANDLE hTNETWIF, UINT32 addr);
+void        TNETWIF_SetU08            (TI_HANDLE hTNETWIF, UINT32 addr, UINT8  Val);
+void        TNETWIF_SetU08_Bits       (TI_HANDLE hTNETWIF, UINT32 addr, UINT8  BitsVal);
+void        TNETWIF_ResetU08_Bits     (TI_HANDLE hTNETWIF, UINT32 addr, UINT8  BitsVal);
+UINT16      TNETWIF_GetU16            (TI_HANDLE hTNETWIF, UINT32 addr);
+void        TNETWIF_SetU16            (TI_HANDLE hTNETWIF, UINT32 addr, UINT16 Val);
+void        TNETWIF_SetU16_Bits       (TI_HANDLE hTNETWIF, UINT32 addr, UINT16 BitsVal);
+void        TNETWIF_ResetU16_Bits     (TI_HANDLE hTNETWIF, UINT32 addr, UINT16 BitsVal);
+UINT32      TNETWIF_GetU32            (TI_HANDLE hTNETWIF, UINT32 addr);
+void        TNETWIF_SetU32            (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 Val);
+void        TNETWIF_SetU32_Bits       (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 BitsVal);
+void        TNETWIF_ResetU32_Bits     (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 BitsVal);
+
+/*
+ * Hardware Registers API
+ */
+void        TNETWIF_RegSetBitVal      (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 BitVal);
+void        TNETWIF_RegResetBitVal    (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 BitVal);
+int         TNETWIF_RegIsBitSet       (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 BitVal);
+
+#endif /* USE_SYNC_API */
+
+char* TNETWIF_ModuleIdToString(UINT32 module_id);
+void  TNETWIF_printErrorLog(void);
+
+#endif /* TNETWIF_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/ElpCtrl.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/ElpCtrl.h
new file mode 100644 (file)
index 0000000..4b26b63
--- /dev/null
@@ -0,0 +1,105 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/**********************************************************************************/
+/*                                                                                */
+/*   MODULE:  ElpCtrl.h                                                                                                                          */
+/*   PURPOSE: ElpCtrl api file                                                                                                   */
+/*                                                                                */
+/**********************************************************************************/
+#ifndef _ELP_CONTROLLER_H_
+#define _ELP_CONTROLLER_H_
+
+/*****************************************************************************
+ **         MACRO                                                             **
+ *****************************************************************************/
+
+/* ELP register commands */
+#define ELPCTRL_WAKE_UP             0x1
+#define ELPCTRL_WAKE_UP_WLAN_READY  0x5
+#define ELPCTRL_SLEEP               0x0
+/* ELP WLAN_READY bit */
+#define ELPCTRL_WLAN_READY          0x2
+
+
+/*****************************************************************************
+ **         Enums                                                    **
+ *****************************************************************************/
+
+/* ELP Control API return values */
+typedef enum 
+{
+    ELPCTRL_COMPLETE,
+    ELPCTRL_PENDING,
+    ELPCTRL_ERROR,
+    ELPCTRL_AWAKE,
+    ELPCTRL_ASLEEP,
+    ELPCTRL_WLAN_RDY,
+    ELPCTRL_WLAN_RDY_COMPLETE
+
+} elpCtrl_e;
+
+ /*****************************************************************************
+ **         Types                                                             **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         External functions definitions                                  **
+ *****************************************************************************/
+TI_HANDLE elpCtrl_Create    (TI_HANDLE hOs);
+int       elpCtrl_Destroy   (TI_HANDLE hElpCtrl);
+int       elpCtrl_Configure (TI_HANDLE hElpCtrl, TI_HANDLE hTNETWIF, TNETWIF_callback_t fCb);
+int       elpCtrl_Wake      (TI_HANDLE hElpCtrl, BOOL bHwAvail);
+int       elpCtrl_Sleep     (TI_HANDLE hElpCtrl);
+int       elpCtrl_UnMux       (TI_HANDLE hElpCtrl);
+int       elpCtrl_Mode      (TI_HANDLE hElpCtrl, elpCtrl_Mode_e aMode);
+int       elpCtrl_Stop      (TI_HANDLE hElpCtrl);
+int       elpCtrl_Start     (TI_HANDLE hElpCtrl);
+BOOL      elpCtrl_isIRQComing (TI_HANDLE hElpCtrl);
+elpCtrl_e elpCtrl_exitWakeUpSeq (TI_HANDLE hElpCtrl);
+void      elpCtrl_ReceivedIRQ (TI_HANDLE hElpCtrl);
+
+void     elpCtrl_RegisterFailureEventCB 
+                            (TI_HANDLE hElpCtrl, void *fFail, TI_HANDLE hFail);
+
+
+#endif /* _ELP_CONTROLLER_H_ */
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArb.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArb.h
new file mode 100644 (file)
index 0000000..771bd2e
--- /dev/null
@@ -0,0 +1,153 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 GWSI_Synchronizer.h
+ *  \brief GWSI Synchronizer include file
+ *
+ *  \see GWSI_Synchronizer.c
+ */
+
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   GWSI_Synchronizer.h                                         */
+/*    PURPOSE:  GWSI  Synchronizer include file                         */
+/*                                                                          */
+/***************************************************************************/
+
+
+#ifndef SYNCHRONIZER_H
+#define SYNCHRONIZER_H
+
+#include "TNETWIF.h"
+#include "TNETWArbSM.h"
+#include "TNETWArb_buffer.h"
+#include "osTIType.h"  
+
+
+#define TODO_LIST_INDEX                     0
+#define RUNNING_LIST_INDEX                  1
+#define NUM_OF_TNETWARB_QUEUES              2
+
+
+#define TNETWARB_IS_EVENT_PENDING       0x100
+
+/* These defines should be closed by default. They may be open for debug purposes */
+
+typedef struct TNETWARB_INSTANCE_struct
+{
+    TI_HANDLE   instance_handle;    /* The handle of the module to be used when calling back the client */
+    TNETWIF_callback_t  instance_callback;  /* The handler of the module to be used when calling back the client */
+    UINT8       module_id;          /* The module_id of the Client */
+    UINT8       priority;           /* The priority of the client instance */
+} TNETWARB_INSTANCE_T;
+
+#define TNETWARB_INSTANCE_SIZE sizeof(TNETWARB_INSTANCE_T)
+
+typedef struct TNETWArbStat_t_
+{
+    UINT32             uStart;
+    UINT32             uRestart;
+    UINT32             uFinish; 
+} TNETWArbStat_t;
+
+
+/**************************** TNETWARB_CB ********************************/
+/****************************************************************************/
+typedef struct T_TNETWARB_CB
+{
+    TI_HANDLE           hOs;
+    TI_HANDLE           hReport;
+    TI_HANDLE           hTNETWArbSM;
+    UINT8               TNETWArb_Client_Instance_Array[NUM_OF_TNETWIF_MODULES] [BUFFER_HDR_SIZE+TNETWARB_INSTANCE_SIZE];
+    TNETWARB_INSTANCE_T *TNETWArb_Running_instance;
+    TNETWARB_INSTANCE_T *pDefInst;
+    BUFFER_Q            TNETWArbiter_Queues[NUM_OF_TNETWARB_QUEUES];
+    TnetwArbSMEvents_e  event_to_dispatch; /* This is used after the client callback has potentially called itself a FOINISH or RESTART API 
+                                              Then we remmember the Event to be sent to the TNETW Arbiter State Machine so we prevent nested entrance in the TNETW ARBITER MODULE */
+
+  #ifdef TI_DBG
+    TNETWArbStat_t      stat;
+  #endif
+} TNETWArb_t;
+
+
+
+
+#define TNETWArb_is_idle(pTnetwArb_cb)              (!pTnetwArb_cb->TNETWArbiter_Queues[RUNNING_LIST_INDEX].count)
+#define TNETWArb_is_running(pTnetwArb_cb)           (pTnetwArb_cb->TNETWArbiter_Queues[RUNNING_LIST_INDEX].count)
+
+
+
+/*******************************************************************************/
+/*    Each new client shall register itself to the synchronizer by inserting here 
+      its start instance                                                        */
+/*    The "extern" here is anyway to explicite to the user that this fucntion is not
+      implemented in the synchronizer but in the client                         */
+/*******************************************************************************/
+
+
+/************************************************************************
+ API for the TNETWIF to handle the running module's Callbacks.
+************************************************************************/
+TI_STATUS TNETWArb_CallClientCallback (TI_HANDLE hTNETWArb);
+TI_STATUS TNETWArb_CallTxnCb (TI_HANDLE hTNETWArb);
+void TNETWArb_TxnCb (TI_HANDLE hTNETWArb, UINT8 module_id, TI_STATUS status);
+void TNETWArb_PrintStat (TI_HANDLE hTNETWArb);
+
+
+/* API for external module in charge of creating the gwsi_synchronizer initialization */
+TI_HANDLE TNETWArb_Init (TI_HANDLE hOs);
+void TNETWArb_Config (TI_HANDLE hTNETWArb,TI_HANDLE hReport,TI_HANDLE hELPCtrl);
+TI_STATUS TNETWArb_Destroy (TI_HANDLE hTNETWArb);
+TI_STATUS TNETWArb_Recovery(TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl);
+
+
+/************************************************************************
+ API for the Client to send an event to the Synchronizer : It can be :
+            EV_REG_ID (PERFORM_IMMEDIATE or start time for future use)
+            EV_FINISH_ID (To be called by the client when if finishes its State Machine
+************************************************************************/
+TI_STATUS TNETWArb_Start (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func);
+TI_STATUS TNETWArb_Restart (TI_HANDLE hTNETWArb, UINT8 module_id,TI_HANDLE CallBAck_Handle,TNETWIF_callback_t CallBack_Func);
+TI_STATUS TNETWArb_Finish (TI_HANDLE hTNETWArb, UINT8 module_id,TI_HANDLE CallBAck_Handle,TNETWIF_callback_t CallBack_Func);
+
+/************************************************************************
+ API for the Client to register its handle 
+************************************************************************/
+void TNETWArb_register_handler(TI_HANDLE hTNETWArb,UINT8 module_id,TNETWIF_callback_t module_CB_Func,TI_HANDLE module_handle);
+
+
+#endif /* SYNCHRONIZER_H */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArbSM.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArbSM.h
new file mode 100644 (file)
index 0000000..03c2968
--- /dev/null
@@ -0,0 +1,226 @@
+/** \file TNETWArbvSM.h
+ *  \brief This is the PowerSrv module API.
+ *  \author Ruthy Zaphir
+ *  \date 15-May-2005
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  TNETWArbvSM                                               *
+ *   PURPOSE: TNETWArbvSM Module API                                    *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _TNETWARBSM_H_
+#define _TNETWARBSM_H_
+
+#include "commonTypes.h"
+#include "whalCommon.h"
+
+/*****************************************************************************
+ **         Constants                                                       **
+ *****************************************************************************/
+
+#define TNETWARB_SM_MODULE_LOG /*POWER_MANAGER_SM_MODULE_LOG*/
+
+
+/*****************************************************************************
+ **         Enumerations                                                    **
+ *****************************************************************************/
+
+
+/** \enum TnetwArbSMEvents_e */
+enum TnetwArbSMEvents_e
+{
+    TNETWARBSM_EV_START,             /**< move to active command */
+    TNETWARBSM_EV_BUS_AVAIL,
+    TNETWARBSM_EV_HW_AVAIL,
+    TNETWARBSM_EV_RESTART,
+    TNETWARBSM_EV_FINISH,
+    TNETWARBSM_EV_TXN_CMPLT,
+
+    TNETWARBSM_EVENT_NUM
+};
+
+/** \enum TnetwArbSMStates_e */
+enum TnetwArbSMStates_e
+{
+    TNETWARBSM_STATE_IDLE,              /**< TNETW ARBITER is not running any process */
+    TNETWARBSM_STATE_WAIT_BUS,          /**< TNETW ARBITER is waiting to receive the Bus Semaphore */
+    TNETWARBSM_STATE_WAIT_HW,           /**< TNETW ARBITER is waiting for HW to awake */
+    TNETWARBSM_STATE_WAIT_BUS_AFTER_HW, /**< TNETW ARBITER is waiting for bus */
+    TNETWARBSM_STATE_WAIT_TXN1,         /**< TNETW ARBITER is waiting for end of bus transaction [1] */
+    TNETWARBSM_STATE_RUNNING,           /**< TNETW ARBITER is running at least a process */
+    TNETWARBSM_STATE_WAIT_TXN2,         /**< TNETW ARBITER is waiting for end of bus transaction [2] */
+    TNETWARB_SM_STATE_NUM
+};
+
+/*****************************************************************************
+ **         Typedefs                                                        **
+ *****************************************************************************/
+
+typedef enum TnetwArbSMEvents_e TnetwArbSMEvents_e;
+
+typedef enum TnetwArbSMStates_e TnetwArbSMStates_e;
+
+
+/*****************************************************************************
+ **         Structures                                                      **
+ *****************************************************************************/
+
+/** \struct TNETWArbSM_Config_t */
+/*
+typedef struct
+{
+
+} TNETWArbSM_Config_t;
+*/
+
+/** \struct TNETWArbSM_t */
+typedef struct
+{
+    TI_HANDLE           hOS;                    /**<
+                                                 * Handle to the OS object.
+                                                 */
+
+    TI_HANDLE           hFSM;                   /**< Handle to the FSM object.
+                                                 */
+
+    TI_HANDLE           hTNETWArb;              /* Handle to the TNET Arbiter to call it when doing actions with the TODO Queue */
+
+    TI_HANDLE           hReport;                /**<
+                                                 * Handle to the Report module.
+                                                 */
+    
+
+    TI_HANDLE           hELPCtrl;               /**< Handle to the power controller object via the WhalCtrl.
+                                                 * Need for configure the desired power mode policy in the system.
+                                                 */
+
+    TI_HANDLE           hBusArbiter;            /**< Handle to the power controller object via the WhalCtrl.
+                                                 * Need for configure the desired power mode policy in the system.
+                                                 */
+
+    UINT32              event;                  /**< Last event sent */
+
+    BOOL                bHwAvail;               /**< Is set to TRUE is received HW_AVAIL event */
+
+       TI_STATUS                       SMlastOperationStatus;  /**< Used to store the status of the last SM operation,
+                                                                                                 *      to allow the use of non-recursive state mahcine */
+
+} TNETWArbSM_t;
+
+
+/*****************************************************************************
+ **         External data definitions                                       **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         External functions definitions                                  **
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ **         Public Function prototypes                                      **
+ *****************************************************************************/
+
+/**
+ * \author Yossi Peery
+ * \date 15-May-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 TNETWArbSM_Create (TI_HANDLE hOs);
+
+/**
+ * \author Yossi Peery
+ * \date 15-May-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 - OK on success else NOK.\n
+ */
+TI_STATUS TNETWArbSM_Destroy (TI_HANDLE hTNETWArbSM);
+
+/**
+ * \author Yossi Peery
+ * \date 15-May-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 whalCtrl object.
+ * 4) TI_HANDLE - handle to the QosMgr object.
+ * 5) TI_HANDLE - handle to the Mlme object.
+ * 6) TI_HANDLE - handle to the SiteMgr object.
+ * 7) PowerSrvInitParams_t - the Power Server initialize parameters.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ */
+TI_STATUS TNETWArbSM_Init (TI_HANDLE hTNETWArbSM, TI_HANDLE hReport, TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl, TI_HANDLE hBusArbiter);
+
+/**
+ * \author Yossi Peery
+ * \date 15-May-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the manager of the state macine (PowerSrvSM_SMEvent()).
+ */
+TI_STATUS TNETWArbSM_SMEvent(TI_HANDLE hTNETWArbSM,
+                           TnetwArbSMEvents_e theSMEvent);
+
+
+void TNETWArbSM_HwAvailCB(TI_HANDLE hTNETWArbSM);
+void TNETWArbSM_TxnCb(TI_HANDLE hTNETWArbSM);
+
+
+#endif /*  _GWSI_POWER_SRV_SM_H_  */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArb_buffer.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/TNETWArb_buffer.h
new file mode 100644 (file)
index 0000000..851d2f1
--- /dev/null
@@ -0,0 +1,150 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef TNETWARB_H
+#define TNETWARB_H
+
+#include "osTIType.h"
+
+
+
+/*----------------------------------------------------------------------*/
+/*                      GKI Definitions                                 */
+/*----------------------------------------------------------------------*/
+
+
+/* Define the total number of buffer pools supported, fixed and dynamic.
+*/
+#define NUM_TNETWARB_TOTAL_BUF_POOLS                   3
+
+
+/* Set this flag to non zero if you want to do buffer ownership checks.
+** Note that to do these checks, you should have all tasks that free
+** buffers as GKI tasks.
+*/
+#define TNETWARB_ENABLE_OWNER_CHECK                    0
+
+
+/* Set this flag to non zero if you want to do buffer corruption checks.
+** If set, GKI will check buffer tail corruption every time it processes
+** a buffer. This is very useful for debug, and is minimal overhead in
+** a running system.
+*/
+#define TNETWARB_ENABLE_BUF_CORRUPTION_CHECK  0
+
+
+/* Set this flag to non zero if you want to do pool id checks.
+** If set, GKI will check if pool id exceeds the number of pools.
+** This is useful for debug, but not for release version.
+*/
+#define TNETWARB_ENABLE_POOL_ID_CHECK           0
+
+
+/***********************************************************************
+** This queue is a general purpose buffer queue, for application use.
+*************************************************************************/
+typedef struct 
+{
+    void    *p_first;
+    void    *p_last;
+    UINT16  count;
+} BUFFER_Q;
+
+#define TNETWARB_IS_QUEUE_EMPTY(p_q) (p_q.count == 0)
+
+/* Define the value that create pool will return if it fails
+*/
+#define TNETWARB_INVALID_POOL 0xFF
+
+
+/********************************************************************/
+/**  Buffer Management Data Structures                             **/
+/********************************************************************/
+
+typedef struct _buffer_hdr
+{
+       struct _buffer_hdr *p_next;   
+       UINT8   q_id;
+    UINT8   status;                            
+       
+} BUFFER_HDR_T;
+
+
+/* Buffer related defines
+*/
+#define BUFFER_HDR_SIZE                 (sizeof(BUFFER_HDR_T))
+#define MAGIC_NO                        0xAA55AA55
+
+
+#define BUF_STATUS_UNLINKED                            0  
+#define BUF_STATUS_FREE                                    1  
+#define BUF_STATUS_QUEUED                              2  
+
+
+
+/***********************************************************************
+** Function prototypes
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* To get and release buffers, change owner and get size
+*/
+
+void   TNETWArb_buffer_init(UINT8 *pTNETWArb_Client_Array);
+void   *TNETWArb_getpoolbuf (TI_HANDLE hTNETWArb,UINT8 module_id);
+void   TNETWArb_freebuf(void *bptr);
+
+/* User buffer queue management
+*/
+ void    TNETWArb_init_q (BUFFER_Q *p_q);
+ void    TNETWArb_Enqueue (BUFFER_Q *p_q, void *p_buf);
+ void    TNETWArb_Enqueue_head (BUFFER_Q *p_q, void *p_buf);
+ void   *TNETWArb_Dequeue  (BUFFER_Q *p_q);
+ void   *TNETWArb_remove_from_queue (BUFFER_Q *p_q, void *p_buf);
+ void   *TNETWArb_getfirst (BUFFER_Q *p_q);
+ void   *TNETWArb_getnext (void *p_buf);
+
+#ifdef __cplusplus
+}
+#endif /* of __cplusplus */
+
+
+#endif /* of GKI_H */
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/whalHwAccess.h b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/Inc/whalHwAccess.h
new file mode 100644 (file)
index 0000000..881cdbf
--- /dev/null
@@ -0,0 +1,178 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  hwAccess.c
+ *   PURPOSE: Support access to the wlan hardware registers and memory
+ *
+ ****************************************************************************/
+
+#ifndef __WHAL_HW_ACCESS_H__
+#define __WHAL_HW_ACCESS_H__
+
+/************************************************************************
+ * partition addresses
+ * 
+ * each access region will have its base address and the HAL will use only the logical offset
+ * there isnt an access region for the registers. 
+ * for the mem the access regions are defined for their functionality : double-buffer,tx registers, rx registers etc...
+ *
+ * EXAMPLE : 
+ *     if the HAL wants to read register at offset 0xA the the call will be :
+ *  whal_hwAccess_ReadReg(hHwAccess, 0xA, &RegVal);
+ *     if the HAL wants to read 4bytes from mem at offset 0x10 in the double-buffer region the the call will be:
+ *  whal_hwAccess_ReadMem(hHwAccess, HW_ACCESS_BASE_DOUBLE_BUFFER + 0x10, &RegVal , 4);
+ ************************************************************************/
+
+#define HW_ACCESS_BASE_DOUBLE_BUFFER   0
+#define HW_ACCESS_BASE_CMD_MBX                 0
+
+#define HEALTH_REPORT_BUS_ERROR BIT_2
+
+/************************************************************************
+ * Return codes
+ ************************************************************************/
+#define ERROR_HW_ACCEESS_ADDR  10
+#define ERROR_HW_ACCEESS_LEN   11
+
+/************************************************************************
+ * Types
+ ************************************************************************/
+typedef void (*HwAccess_callback_t)(void *data,int status);
+
+/************************************************************************
+ * partition addresses
+ ************************************************************************/
+  
+/* Download phase */
+#define HW_ACCESS_DOWN_PART0_SIZE              0x16800
+#define HW_ACCESS_DOWN_PART0_ADDR              0x0
+#define HW_ACCESS_DOWN_PART1_SIZE              0x8800
+#define HW_ACCESS_DOWN_PART1_ADDR              0x300000
+
+/* Working phase */
+#ifdef TNETW1251
+#define HW_ACCESS_WORK_PART0_SIZE              0x14000
+#define HW_ACCESS_WORK_PART0_ADDR              0x28000
+#define HW_ACCESS_WORK_PART1_SIZE              0xB000
+#else
+#define HW_ACCESS_WORK_PART0_SIZE              0x16800
+#define HW_ACCESS_WORK_PART0_ADDR              0xF000
+#define HW_ACCESS_WORK_PART1_SIZE              0x8800
+#endif
+#define HW_ACCESS_WORK_PART1_ADDR              0x300000
+
+#define HW_ACCESS_MAX_PARTITIONS               2
+
+#ifndef HW_ACCESS_MEMORY_MAX_RANGE  /* this macro is already defined in SDIO client driver */
+  #define HW_ACCESS_MEMORY_MAX_RANGE           0x1FFC0
+#endif /* ifndef HW_ACCESS_MEMORY_MAX_RANGE */
+
+#define HW_ACCESS_PRAM_MAX_RANGE               0x3c000
+
+/************************************************************************
+ * Functions
+ ************************************************************************/
+
+extern int whal_hwAccess_ReConfig(TI_HANDLE hHwAccess);
+extern int whal_hwAccess_Stop(TI_HANDLE hHwAccess);
+
+#if (defined (HW_ACCESS_SDIO) || defined (HW_ACCESS_WSPI))
+  TI_STATUS whal_hwAccess_RecreateInterface(TI_HANDLE hHwAccess);
+#endif
+
+/* new API */
+/***********/
+
+TI_HANDLE      whal_hwAccess_Create(TI_HANDLE hOs);
+int                    whal_hwAccess_Destroy(TI_HANDLE hHwAccess);
+int                    whal_hwAccess_Config(TI_HANDLE hHwAccess, TI_HANDLE hReport,UINT32 RegBaseAddr, UINT32 MemBaseAddr, HwAccess_callback_t CBFunc,void* CBArg);
+
+int                    whal_hwAccess_SetPartitions(TI_HANDLE hHwAccess, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start);
+int                    whal_hwAccess_SetPartitionsAsync(TI_HANDLE hHwAccess, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start);
+UINT8          whal_hwAccess_Get_Async_Mode(TI_HANDLE hHwAccess);
+int                    whal_hwAccess_WriteELP(TI_HANDLE hHwAccess, UINT32 data);
+int                    whal_hwAccess_WriteELPAsync(TI_HANDLE hHwAccess, UINT32 data, BOOL bCb, BOOL bMore);
+int                    whal_hwAccess_ReadELPAsync (TI_HANDLE hHwAccess, UINT8 *data, BOOL bCb, BOOL bMore);
+
+int                    whal_hwAccess_ReadMem_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+int                    whal_hwAccess_WriteMem_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+int                    whal_hwAccess_ReadMemAsync_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+int                    whal_hwAccess_WriteMemAsync_Align(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+
+int                    whal_hwAccess_ReadMem(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+int                    whal_hwAccess_WriteMem(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+int                    whal_hwAccess_ReadMemAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+TI_STATUS      whal_hwAccess_WriteMemAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT8* data, UINT16 len);
+
+int                    whal_hwAccess_ReadReg(TI_HANDLE hHwAccess, UINT32 addr, UINT32* data);
+int                    whal_hwAccess_WriteReg(TI_HANDLE hHwAccess, UINT32 addr, UINT32 data);
+int                    whal_hwAccess_ReadRegAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT32* data);
+int                    whal_hwAccess_WriteRegAsync(TI_HANDLE hHwAccess, UINT32 addr, UINT32 data);
+
+void                   whal_hwAccess_Print(TI_HANDLE hHwAccess);
+
+/*old - new*/
+/*
+ * Hardware memory Api
+ */
+UINT8                  whal_hwAccess_GetU08       (TI_HANDLE hHwAccess, UINT32 Addr);
+void                   whal_hwAccess_SetU08       (TI_HANDLE hHwAccess, UINT32 Addr, UINT8  Val);
+void                   whal_hwAccess_SetU08_Bits  (TI_HANDLE hHwAccess, UINT32 Addr, UINT8  BitsVal);
+void                   whal_hwAccess_ResetU08_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT8  BitsVal);
+UINT16                 whal_hwAccess_GetU16       (TI_HANDLE hHwAccess, UINT32 Addr);
+void                   whal_hwAccess_SetU16       (TI_HANDLE hHwAccess, UINT32 Addr, UINT16 Val);
+void                   whal_hwAccess_SetU16_Bits  (TI_HANDLE hHwAccess, UINT32 Addr, UINT16 BitsVal);
+void                   whal_hwAccess_ResetU16_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT16 BitsVal);
+UINT32                 whal_hwAccess_GetU32       (TI_HANDLE hHwAccess, UINT32 Addr);
+void                   whal_hwAccess_SetU32       (TI_HANDLE hHwAccess, UINT32 Addr, UINT32 Val);
+void                   whal_hwAccess_SetU32_Bits  (TI_HANDLE hHwAccess, UINT32 Addr, UINT32 BitsVal);
+void                   whal_hwAccess_ResetU32_Bits(TI_HANDLE hHwAccess, UINT32 Addr, UINT32 BitsVal);
+
+/*
+ * Hardware Registers Api
+ */
+void                   whal_hwAccess_RegSetBitVal  (TI_HANDLE hHwAccess, UINT32 RegAddr, UINT32 BitVal);
+void                   whal_hwAccess_RegResetBitVal(TI_HANDLE hHwAccess, UINT32 RegAddr, UINT32 BitVal);
+int                    whal_hwAccess_RegIsBitSet   (TI_HANDLE hHwAccess, UINT32 RegAddr, UINT32 BitVal);
+
+
+
+
+TI_STATUS whal_hwAccess_RegisterForErrorCB(TI_HANDLE hHwAccess,void* CbFunc,TI_HANDLE CbObj);
+
+
+#endif /*__WHAL_HW_ACCESS_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb.c
new file mode 100644 (file)
index 0000000..8081cbb
--- /dev/null
@@ -0,0 +1,616 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  GWSI_Synchronizer.c
+ *   PURPOSE: GWSI Synchronizer used to synchronize between the CMD,INT,TX 
+ *
+ ****************************************************************************/
+
+#include "commonTypes.h"
+#include "memMngrEx.h" /* MSDU */
+#include "report.h"
+
+
+/* First the TNETW Arbiter interface needs the HAL definitions to use them in its API */
+#include "TNETWArb.h"
+#include "TNETWIF.h"
+
+/* Those are functions that he client can send to the GWSI Synchronizer */
+/* The client wants to start its process */
+
+/***********************************************************************************
+ Internal Synchronizer function use
+**************************************************************************************/
+
+/****************************************************************************
+ *                      TNETWArb_Init()
+ ****************************************************************************
+ * DESCRIPTION: Initialize the synchronizer database.
+ *
+ * INPUTS:  TI_HANDLE hOs
+ *
+ * OUTPUT:  
+ *
+ * RETURNS:  TI_HANDLE hTNETWArb - Handle of the TNETW Arbiter module
+ ****************************************************************************/
+TI_HANDLE TNETWArb_Init (TI_HANDLE hOs)
+{
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t  *pTNETWArb;
+
+    pTNETWArb = (TNETWArb_t *)os_memoryAlloc (hOs, sizeof(TNETWArb_t));
+    if (pTNETWArb == NULL)
+        return NULL;
+
+    os_memoryZero (hOs, pTNETWArb, sizeof(TNETWArb_t));
+
+    pTNETWArb->hOs = hOs;
+
+
+
+    /* Get the TNETW Arbiter SM handle */
+    pTNETWArb->hTNETWArbSM = TNETWArbSM_Create(hOs);
+
+    return (TI_HANDLE)pTNETWArb;
+}
+
+
+/****************************************************************************
+ *                      TNETWArb_Config()
+ ****************************************************************************
+ * DESCRIPTION: Configure the TNETWIF module
+ *
+ * INPUTS:  TI_HANDLE hTNETWArb
+ *          TI_HANDLE hReport
+ *          TI_HANDLE hELPCtrl
+ *
+ * OUTPUT:  void
+ *
+ * RETURNS: void
+ ****************************************************************************/
+
+void TNETWArb_Config (TI_HANDLE hTNETWArb,TI_HANDLE hReport,TI_HANDLE hELPCtrl)
+{
+
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t  *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    UINT8       index;
+
+    pTNETWArb->hReport = hReport;
+
+    /* Init buffer Q lists */
+    for(index = 0 ; index < NUM_OF_TNETWARB_QUEUES ; index++)
+    {
+        TNETWArb_init_q (&(pTNETWArb->TNETWArbiter_Queues[index]));
+    }
+
+    /* CAll the TNETW Arbiter Initializeto set the buffer free and their next buffer to NULL */
+    TNETWArb_buffer_init(&(pTNETWArb->TNETWArb_Client_Instance_Array[0][0]));
+
+
+    /* Clear the Event to dispatch bit */
+    pTNETWArb->event_to_dispatch&=~TNETWARB_IS_EVENT_PENDING;
+
+    /* For now the Handle to theBus Arbiter is NULL */
+    TNETWArbSM_Init(pTNETWArb->hTNETWArbSM,pTNETWArb->hReport,hTNETWArb,hELPCtrl,NULL);
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy The TNETWIF Module
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  String the name of the Queue
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWArb_Destroy (TI_HANDLE hTNETWArb)
+{
+
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t  *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+
+
+    /* Call the TNETWArb SM Destruction function */
+    if (pTNETWArb->hTNETWArbSM)
+        TNETWArbSM_Destroy (pTNETWArb->hTNETWArbSM);
+
+    /* Free the TNETW Arbiter memory */
+    if (pTNETWArb)
+        os_memoryFree(pTNETWArb->hOs, pTNETWArb, sizeof(TNETWArb_t));
+
+    return OK;
+
+}
+
+/****************************************************************************
+ *                      TNETWArb_register_handler()
+ ****************************************************************************
+ * DESCRIPTION: Register the Client Callback function to the TNETW Arbiter 
+ *              This function will be called in case of DMA Done i.e BusTXn Complete
+ *
+ * INPUTS:  TI_HANDLE hTNETWArb
+ *          UINT8 module_id
+ *          TNETWIF_callback_t module_CB_Func
+ *          TI_HANDLE module_handle
+ *
+ * OUTPUT:  void
+ *
+ * RETURNS: void
+ ****************************************************************************/
+void TNETWArb_register_handler(TI_HANDLE hTNETWArb,UINT8 module_id,TNETWIF_callback_t module_CB_Func,TI_HANDLE module_handle)
+{   
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t              *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    TNETWARB_INSTANCE_T     *pTNETWARB_Inst;
+
+     /* Get the pointer to the TNETWARB_INSTANCE struct */
+    pTNETWARB_Inst = (TNETWARB_INSTANCE_T *) (&(pTNETWArb->TNETWArb_Client_Instance_Array[module_id][BUFFER_HDR_SIZE]));
+
+    pTNETWARB_Inst->module_id = module_id;
+    pTNETWARB_Inst->instance_callback = module_CB_Func;
+    pTNETWARB_Inst->instance_handle = module_handle;
+
+    if (module_id == DEFAULT_MODULE_ID)
+        pTNETWArb->pDefInst = pTNETWARB_Inst;
+}
+
+
+/****************************************************************************
+ *                      TNETWArb_Start()
+ ****************************************************************************
+ * DESCRIPTION: Client registration to the TNETW Arbiter whishing to have   **
+**              access to the Bus
+ *
+ * INPUTS:  TI_HANDLE hTNETWArb
+ *          UINT8 module_id
+ *          TI_HANDLE ClientCallBack_Handle
+ *          TNETWIF_callback_t module_CB_Func
+ *
+ * OUTPUT:  void
+ *
+ * RETURNS: TI_STATUS - TNETWIF_ERROR - In case that the Client is already registered to the TNETWIF
+ *                      TNETWIF_COMPLETE - In case that the Client callback has been immediately called
+ *                      TNETWIF_PENDING - In case that the Client will be called later 
+ ****************************************************************************/
+TI_STATUS TNETWArb_Start (TI_HANDLE hTNETWArb, UINT8 module_id, TI_HANDLE ClientCallBack_Handle, TNETWIF_callback_t ClientCallBack_Func)
+{   
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t              *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    TNETWARB_INSTANCE_T     *pTNETWARB_Inst;
+    TI_STATUS                ret;
+
+       WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
+                             ("\n TNETWArb_Start: Register START to Synchronizer from module_id %x  \n",module_id));
+
+  #ifdef TI_DBG
+    pTNETWArb->stat.uStart ++;
+  #endif
+
+    /*  Get the instance buffer matching to the module_id */
+    pTNETWARB_Inst = (TNETWARB_INSTANCE_T *) TNETWArb_getpoolbuf(hTNETWArb,module_id);
+
+    /* If the instance is already allocated then return error to Client caller */
+    if(pTNETWARB_Inst == NULL)
+    {
+        WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("\n TNETWArb_Start  Module %s Already requested TNETWIF!!!! \n", TNETWIF_ModuleIdToString(module_id)));
+               TNETWIF_printErrorLog();
+        return TNETWIF_ERROR;
+    }
+
+    TNETWArb_Enqueue (&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]), (void*)pTNETWARB_Inst);
+
+    WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_Start: Enqueue in TODO: module %s, pTNETWARB_Inst %x  instance_handle: %X\n", TNETWIF_ModuleIdToString(module_id), pTNETWARB_Inst,ClientCallBack_Handle));
+
+    /* Fill the Client instance with the callback handle and function passed in the  call */
+    pTNETWARB_Inst->module_id = module_id;
+    pTNETWARB_Inst->instance_callback = ClientCallBack_Func;
+    pTNETWARB_Inst->instance_handle = ClientCallBack_Handle;   
+
+    WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
+                            ("\n TNETWArb_Start: Call TNETWArbSM_SMEvent with TNETWARBSM_EV_START for module %s  \n",TNETWIF_ModuleIdToString(module_id)));
+
+    /* Send the  event EV_REG to the TNETW Arbiter for handling and take appropriate actions */
+    ret = TNETWArbSM_SMEvent (pTNETWArb->hTNETWArbSM,
+                              (module_id == FW_EVENT_MODULE_ID) ? TNETWARBSM_EV_HW_AVAIL : TNETWARBSM_EV_START);
+
+    return ret;
+}
+
+
+
+/*********************************************************************************************************
+**                                                                                                      **
+**  Function Name: TNETWArb_Restart                                                                     **
+**                                                                                                      **
+**  Description: Client Re-registration to the TNETW Arbiter whishing to                                **
+**              regain access to the Bus                                                                **
+**              This will do the following:                                                             **
+**                  1) Remove the instance from the Running Instance                                    **
+**                  2) Add it to the TODO Queue                                                         **  
+**                  3) Will set the Current event to be dispatched later on                             **
+**                      from where the Restart was called inside the TNETW Arbiter                      **
+**                      This is done to prevent nesting operations from within the Client context       **  
+**                                                                                                      **
+**********************************************************************************************************/
+TI_STATUS TNETWArb_Restart (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)
+{   
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t              *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    TNETWARB_INSTANCE_T     *pTNETWARB_Inst;
+
+#ifdef TNETWARB_DEBUG
+    /* For debug, verify that the running instance is not NULL. */
+    if(pTNETWArb->TNETWArb_Running_instance ==  NULL )
+    {
+        WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
+            ("TNETWArb_Restart: There is no module running, requested by module %d\n", module_id));
+        return TNETWIF_ERROR;
+    }
+
+    /* For debug check that the instance requesting restart is really the running instance */
+    if(pTNETWArb->TNETWArb_Running_instance->module_id !=  module_id )
+    {
+        /* In this case return to caller ERROR */
+        return TNETWIF_ERROR;
+    }
+#endif
+
+  #ifdef TI_DBG
+    pTNETWArb->stat.uRestart ++;
+  #endif
+
+    /* Take the Running instance control block */
+    pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance ;
+
+    /* First indicate that there is not any handle in the Running instance */
+    pTNETWArb->TNETWArb_Running_instance = NULL;
+
+    /* Enqueue the client request or i.e its instance in the TODO List */
+    TNETWArb_Enqueue(&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]), (void*)pTNETWARB_Inst);
+    
+    WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_Restart: Enqueue in TODO: module %s, instance_handle: %X\n", TNETWIF_ModuleIdToString(module_id), ClientCallBack_Handle));
+
+    /* Fill the Client instance with the callback handle and function given by the  call */
+    pTNETWARB_Inst->module_id = module_id;
+    pTNETWARB_Inst->instance_callback = ClientCallBack_Func;
+    pTNETWARB_Inst->instance_handle = ClientCallBack_Handle;
+    
+
+     /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
+    /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context 
+    to prevent nesting of many calls and prevent to increse the stack */
+    pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
+    pTNETWArb->event_to_dispatch|=TNETWARB_IS_EVENT_PENDING;
+
+    /* Return Pending since the Restart will be handled in a later context */
+    return TNETWIF_PENDING;
+
+}
+
+/*********************************************************************************************************
+**                                                                                                      **
+**  Function Name: TNETWArb_Finish                                                                      **
+**                                                                                                      **
+**  Description: Client De-registration to the TNETW Arbiter whishing to                                **
+**              release access to the Bus                                                               **
+**              This will do the following:                                                             **
+**                  1) Remove the instance from the Running Instance                                    **
+**                  3) Will set the Current event to be dispatched later on                             **
+**                      from where the Finish was called inside the TNETW Arbiter                       **
+**                      This is done to prevent nesting operations from within the Client context       **  
+**                                                                                                      **
+**********************************************************************************************************/
+TI_STATUS TNETWArb_Finish (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)
+{   
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t              *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    TNETWARB_INSTANCE_T     *pTNETWARB_Inst;
+    
+#ifdef TNETWARB_DEBUG
+    /* For debug, verify that the running instance is not NULL. */
+    if(pTNETWArb->TNETWArb_Running_instance ==  NULL )
+    {
+        WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
+            ("TNETWArb_Finish: There is no module running, requested by module %d\n", module_id));
+        return TNETWIF_ERROR;
+    }
+
+    /* For debug check that the instance requesting restart is really the running instance */
+    if(pTNETWArb->TNETWArb_Running_instance->module_id !=  module_id )
+    {
+        WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
+                          ("TNETWArb_Finish: Module %s is not Running module %s is Running \n",
+                          TNETWIF_ModuleIdToString(module_id), 
+                          TNETWIF_ModuleIdToString(pTNETWArb->TNETWArb_Running_instance->module_id)));
+        /* In this case return to caller ERROR */
+        return TNETWIF_ERROR;
+    }
+
+#endif
+
+  #ifdef TI_DBG
+    pTNETWArb->stat.uFinish ++;
+  #endif
+
+    /* Take the Running instance control block */
+    pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance ;
+
+    WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
+                            ("TNETWArb_Finish: module %s, instance_handle: %X\n",
+                            TNETWIF_ModuleIdToString(module_id), 
+                            pTNETWARB_Inst->instance_handle));
+
+    /* Free the buffer instance */
+    TNETWArb_freebuf((void *)pTNETWARB_Inst);
+
+    /* Indicate that there is not any handle in the Running instance */
+    pTNETWArb->TNETWArb_Running_instance = NULL;
+
+    /* Fill the Client instance with NULL callback to ease debugging */
+    pTNETWARB_Inst->module_id = module_id;
+    pTNETWARB_Inst->instance_callback = NULL;
+    pTNETWARB_Inst->instance_handle = NULL;
+    
+
+    /* Now check the Event to send to the TNETW Arbiter State Machine */
+    /* If there are more reequest in the TODO Queue then Send PROCESS_NEXT_EV else send FINISH event to TNETW Arbiter */
+    if(TNETWArb_getfirst(&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX])))
+    {
+        /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
+        /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context 
+        to prevent nesting of many calls and prevent to increse the stack */
+        pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
+        WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG ,
+                                  ("TNETWArb_Finish: module %s, instance_handle: %x Send TNETWARBSM_EV_RESTART \n",
+                                  TNETWIF_ModuleIdToString(module_id),
+                                  pTNETWARB_Inst->instance_handle));
+
+    }
+    else
+    {
+        /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
+        /*  Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context 
+        to prevent nesting of many calls and prevent to increse the stack */
+        pTNETWArb->event_to_dispatch = TNETWARBSM_EV_FINISH;
+        WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
+                                ("TNETWArb_Finish: module %s, TNETWARBSM_EV_FINISH \n", 
+                                TNETWIF_ModuleIdToString(module_id), 
+                                pTNETWARB_Inst->instance_handle));
+
+    }
+
+
+    pTNETWArb->event_to_dispatch|=TNETWARB_IS_EVENT_PENDING;
+
+    /* Return Pending since the Process_Next/Finish Event will be handled in a later context */
+    return TNETWIF_COMPLETE;
+
+}
+
+
+/****************************************************************************
+ *                      TNETWArb_CallTxnCb()
+ ****************************************************************************
+ * DESCRIPTION: This function is used to call the client callback function that was previously
+ *              supplied to the TNETWIF via 2 ways:
+ *                  1) When the Client requested with TNETWIF_Start to access the Bus
+ *                  2) When the Client call the TNETWIF with Async or Optimzed mode.
+ *                      In this case the callback will be called when the DMA will finish.
+ *
+ *              Note :The Client can request FINISHor RESTART bu the TNETW Arbiter state machine will
+ *                     be sent the event only after that the client function callback returns.
+ *                      This is done to prevent a deep nesting in case of RESTART.
+ *
+ * INPUTS:  TI_HANDLE hTNETWArb
+ *
+ * OUTPUT:  void
+ *
+ * RETURNS: void
+ ****************************************************************************/
+TI_STATUS TNETWArb_CallTxnCb (TI_HANDLE hTNETWArb)
+{
+    TNETWArb_t              *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    TNETWARB_INSTANCE_T     *pTNETWArbInst;
+
+    /* 
+     * If the pDefInst is not NULL it is a special arbiter client (ELP control).
+     * Call the ELP control callback.
+     */
+    if (pTNETWArb->pDefInst != NULL)
+    {
+        pTNETWArbInst = pTNETWArb->pDefInst;
+        pTNETWArb->pDefInst = NULL;
+
+        if (pTNETWArbInst->instance_callback != NULL)
+            ((TNETWIF_callback_t)(pTNETWArbInst->instance_callback))
+                (pTNETWArbInst->instance_handle, pTNETWArbInst->module_id, OK);
+
+        return TNETWIF_COMPLETE;
+    }
+
+    /* Otherwise, call a regular arbiter client callback */
+    else
+    {
+        return TNETWArb_CallClientCallback (hTNETWArb);
+    }
+} 
+
+
+
+/****************************************************************************
+ *                      TNETWArb_CallClientCallback()
+ ****************************************************************************
+ * DESCRIPTION: This function is used to call the client callback function that was previously
+ *              supplied to the TNETWIF via 2 ways:
+ *                  1) When the Client requested with TNETWIF_Start to access the Bus
+ *                  2) When the Client call the TNETWIF with Async or Optimzed mode.
+ *                      In this case the callback will be called when the DMA will finish.
+ *
+ *              Note :The Client can request FINISHor RESTART bu the TNETW Arbiter state machine will
+ *                     be sent the event only after that the client function callback returns.
+ *                      This is done to prevent a deep nesting in case of RESTART.
+ *
+ * INPUTS:  TI_HANDLE hTNETWArb
+ *
+ * OUTPUT:  void
+ *
+ * RETURNS: void
+ ****************************************************************************/
+TI_STATUS TNETWArb_CallClientCallback (TI_HANDLE hTNETWArb)
+{
+    /* Handle to TNETW Arbiter struct */
+    TNETWArb_t              *pTNETWArb = (TNETWArb_t *)hTNETWArb;   
+    TNETWARB_INSTANCE_T     *pTNETWARB_Inst;
+
+    /* Take the Running instance control block */
+    if (pTNETWArb->TNETWArb_Running_instance != NULL)
+    {
+        pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
+                           ("TNETWArb_CallClientCallback: no running instance\n"));
+               TNETWIF_printErrorLog();
+
+        return TNETWIF_ERROR;
+    }
+  
+    /* Call the client callback */
+    if (pTNETWARB_Inst->instance_callback != NULL)
+        ((TNETWIF_callback_t)(pTNETWARB_Inst->instance_callback))
+            (pTNETWARB_Inst->instance_handle, pTNETWARB_Inst->module_id, OK);
+
+    /* Check if there is an event to be dispatch */
+    if (pTNETWArb->event_to_dispatch & TNETWARB_IS_EVENT_PENDING)
+    {
+        TI_STATUS  status;
+
+        pTNETWArb->event_to_dispatch &= ~TNETWARB_IS_EVENT_PENDING;
+
+
+        /* Now check the Event to send to the TNETW Arbiter State Machine */
+        /* If there are more request in the TODO Queue then Send PROCESS_NEXT_EV else send FINISH event to TNETW Arbiter */
+        if (TNETWArb_getfirst (&pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]))
+        {
+            /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
+            /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context 
+            to prevent nesting of many calls and prevent to increase the stack */
+            pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
+            status = TNETWIF_PENDING;
+            WLAN_REPORT_INFORMATION (pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG ,("TNETWArb_CallClientCallback: module %s, instance_handle: %x Send TNETWARBSM_EV_RESTART \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle));
+        }
+        else
+        {
+            /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
+            /*  Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context 
+            to prevent nesting of many calls and prevent to increase the stack */
+            pTNETWArb->event_to_dispatch = TNETWARBSM_EV_FINISH;
+            status = TNETWIF_COMPLETE;
+            WLAN_REPORT_INFORMATION (pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_CallClientCallback: module %s, TNETWARBSM_EV_FINISH \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle));
+        }
+
+        WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG, ("TNETWArb_CallClientCallback: module %s, instance_handle: %x Send pTNETWArb->event_to_dispatch %d \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle, pTNETWArb->event_to_dispatch));
+
+        TNETWArbSM_SMEvent (pTNETWArb->hTNETWArbSM, pTNETWArb->event_to_dispatch);
+
+        return status;
+    }
+
+    return TNETWIF_PENDING;
+}
+
+
+/****************************************************************************
+ *                      TNETWArb_TxnCb()
+ ****************************************************************************
+ * DESCRIPTION: ELP Controller Callabck - Indicate to the TNETWArb that the HW is now Available 
+ *              The FW has waken up. 
+ * 
+ * INPUTS:  hTNETWArb - the handle to the TNETW Arbiter
+ *       
+ * OUTPUT:  
+ * 
+ * RETURNS: OK
+ ****************************************************************************/
+void TNETWArb_TxnCb (TI_HANDLE hTNETWArb, UINT8 module_id, TI_STATUS status)
+{
+    TNETWArb_t  *pTNETWArb = (TNETWArb_t *)hTNETWArb;
+
+    TNETWArbSM_TxnCb (pTNETWArb->hTNETWArbSM);
+}
+
+
+#ifdef TI_DBG
+void TNETWArb_PrintStat (TI_HANDLE hTNETWArb)
+{
+    TNETWArb_t  *pTNETWArb = (TNETWArb_t *)hTNETWArb;
+
+    WLAN_OS_REPORT (("Num of start   = %u\n", pTNETWArb->stat.uStart));
+    WLAN_OS_REPORT (("Num of restart = %u\n", pTNETWArb->stat.uRestart));
+    WLAN_OS_REPORT (("Num of finish  = %u\n", pTNETWArb->stat.uFinish));
+
+       TNETWIF_printErrorLog();
+}
+#endif
+
+
+/****************************************************************************
+ *                      BusArbiter_Recovery()
+ ****************************************************************************
+ * DESCRIPTION: handles the recovery 
+ *
+ * INPUTS:  TI_HANDLE hBusArbiter
+ *
+ * OUTPUT:  void
+ *
+ * RETURNS: void
+ ****************************************************************************/
+TI_STATUS TNETWArb_Recovery(TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl)
+{
+       TNETWArb_t  *pTNETWArb = (TNETWArb_t *)hTNETWArb;
+
+       /* should be updated - see CE20 */
+       TNETWArb_Config (hTNETWArb, pTNETWArb->hReport, hELPCtrl);
+       return OK;
+       
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArbSM.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArbSM.c
new file mode 100644 (file)
index 0000000..c9be9ff
--- /dev/null
@@ -0,0 +1,783 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  GWSI_Synchronizer.c
+ *   PURPOSE: GWSI Synchronizer used to synchronize between the CMD,INT,TX 
+ *
+ ****************************************************************************/
+
+#include "commonTypes.h"
+#include "memMngrEx.h" /* MSDU */
+#include "report.h"
+#include "nrfsm.h"
+
+
+/* First the GWSI interface needs the HAL definitions to use them in its API */
+#include "TNETWIF.h"
+#include "TNETWArb.h"
+#include "ElpCtrl.h"
+#include "whalHwAccess.h"
+
+#undef BUS_GUARD_SUPPORT
+
+
+/***********************************************************************************
+ Internal TNWTW Arbiter SM Module Internal function use
+**************************************************************************************/
+static TI_STATUS TNETWArbSM_SeizeBusOnStart        (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_SeizeBusOnHwAvail      (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_SeizeBus               (TI_HANDLE hTNETWArbSM, BOOL bHwAvail);
+static TI_STATUS TNETWArbSM_ReturnPendingOnStart   (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_ReturnPendingOnHwAvail (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_WakeHw                 (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_RunClientCb            (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_ReseizeBus             (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_PutSleepHw             (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_WaitIRQHw              (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_ExitWakeUp             (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_ReleaseBus             (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_DoNothing              (TI_HANDLE hTNETWArbSM);
+static TI_STATUS TNETWArbSM_ActionUnexpected       (TI_HANDLE hTNETWArbSM);
+
+#if defined(BUS_GUARD_SUPPORT)
+static void TNETWArbSM_BusAvailCB                  (TI_HANDLE hTNETWArbSM);
+#endif
+
+
+/*****************************************************************************
+ **         Public Function prototypes                                      **
+ *****************************************************************************/
+
+/**
+ * \author Yossi Peery
+ * \date 15-May-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 TNETWArbSM_Create (TI_HANDLE hOs)
+{
+    TNETWArbSM_t *pTNETWArbSM = NULL;
+    TI_STATUS status;
+
+    pTNETWArbSM = (TNETWArbSM_t*) os_memoryAlloc (hOs, sizeof(TNETWArbSM_t));
+    if (pTNETWArbSM == NULL)
+    {
+        WLAN_OS_REPORT(("%s(%d) - Memory Allocation Error!\n",__FILE__,__LINE__));
+        return NULL;
+    }
+
+    os_memoryZero (hOs, pTNETWArbSM, sizeof(TNETWArbSM_t));
+
+    pTNETWArbSM->hOS = hOs;
+
+    status = nrfsm_Create (hOs, &pTNETWArbSM->hFSM, TNETWARB_SM_STATE_NUM, TNETWARBSM_EVENT_NUM); 
+    if (status != OK)
+    {
+        WLAN_OS_REPORT(("%s(%d) - Error in create FSM!\n",__FILE__,__LINE__));
+        TNETWArbSM_Destroy(pTNETWArbSM);
+        return NULL;
+    }
+
+    return pTNETWArbSM;
+}
+
+
+/**
+ * \author Yossi Peery
+ * \date 15-May-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 - OK on success else NOK.\n
+ */
+TI_STATUS TNETWArbSM_Destroy (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+    TI_HANDLE hOs = pTNETWArbSM->hOS;
+
+    if (pTNETWArbSM->hFSM != NULL)
+    {
+        nrfsm_Unload (pTNETWArbSM->hFSM);                  
+    }
+
+    os_memoryFree (hOs, pTNETWArbSM, sizeof(TNETWArbSM_t));
+
+    WLAN_OS_REPORT (("%s(%d) -  TNETWArbSM destroyed\n", __FILE__, __LINE__));
+
+    return OK;
+}
+
+
+/**
+ * \date 15-May-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 whalCtrl object.
+ * 4) TI_HANDLE - handle to the QosMgr object.
+ * 5) TI_HANDLE - handle to the Mlme object.
+ * 6) TI_HANDLE - handle to the SiteMgr object.
+ * 7) PowerSrvInitParams_t - the Power Server initialize parameters.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ */
+TI_STATUS TNETWArbSM_Init (TI_HANDLE hTNETWArbSM, TI_HANDLE hReport, TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl, TI_HANDLE hBusArbiter)
+{
+    TNETWArbSM_t    *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    nrfsm_action_cell_t smMatrix[TNETWARB_SM_STATE_NUM][TNETWARBSM_EVENT_NUM] =
+    {
+        /*
+         * State [TNETWARBSM_STATE_IDLE]
+        */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_SeizeBusOnStart},                 
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_IDLE               , TNETWArbSM_ActionUnexpected},                 
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_SeizeBusOnHwAvail},                 
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ReseizeBus},                             
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_IDLE               , TNETWArbSM_ActionUnexpected},                              
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_IDLE               , TNETWArbSM_ActionUnexpected}                              
+        },
+
+        /*
+         * State [TNETWARBSM_STATE_WAIT_BUS]
+         */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ReturnPendingOnStart},                   
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_HW            , TNETWArbSM_WakeHw}, 
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ReturnPendingOnHwAvail}, 
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ActionUnexpected}, 
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ActionUnexpected},  
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ActionUnexpected}                              
+        },
+
+        /*
+         * State [TNETWARBSM_STATE_WAIT_HW]
+         */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_HW            , TNETWArbSM_ReturnPendingOnStart},
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_HW            , TNETWArbSM_DoNothing},
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1          , TNETWArbSM_ExitWakeUp}, 
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_HW            , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_HW            , TNETWArbSM_ActionUnexpected}, 
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1            , TNETWArbSM_WaitIRQHw}                              
+        },
+
+        /*
+         * State [TNETWARBSM_STATE_WAIT_BUS_AFTER_HW]
+         */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_BUS_AFTER_HW  , TNETWArbSM_ReturnPendingOnStart},
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1          , TNETWArbSM_WaitIRQHw},
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_WAIT_BUS_AFTER_HW  , TNETWArbSM_ReturnPendingOnHwAvail}, 
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_BUS_AFTER_HW  , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_WAIT_HW */
+            {TNETWARBSM_STATE_WAIT_BUS_AFTER_HW  , TNETWArbSM_ActionUnexpected}, 
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_WAIT_BUS_AFTER_HW */
+            {TNETWARBSM_STATE_WAIT_BUS_AFTER_HW  , TNETWArbSM_ActionUnexpected}                              
+        },
+
+        /*
+         * State [TNETWARBSM_STATE_WAIT_TXN1]
+         */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1          , TNETWArbSM_ReturnPendingOnStart},
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1          , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_RUNNING          , TNETWArbSM_RunClientCb}, 
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1          , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_WAIT_TXN1 */
+            {TNETWARBSM_STATE_WAIT_TXN1          , TNETWArbSM_ActionUnexpected}, 
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_RUNNING            , TNETWArbSM_RunClientCb} 
+        },
+
+        /*
+         * State [TNETWARBSM_STATE_RUNNING]
+         */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_RUNNING            , TNETWArbSM_ReturnPendingOnStart},
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_RUNNING            , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_RUNNING            , TNETWArbSM_ReturnPendingOnHwAvail},
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_WAIT_BUS */
+            {TNETWARBSM_STATE_WAIT_BUS           , TNETWArbSM_ReseizeBus},
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_WAIT_TXN2          , TNETWArbSM_PutSleepHw}, 
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_RUNNING */
+            {TNETWARBSM_STATE_RUNNING            , TNETWArbSM_ActionUnexpected} 
+        },
+
+        /*
+         * State [TNETWARBSM_STATE_WAIT_TXN2]
+         */
+        {
+            /* {TNETWARBSM_EV_START} -> TNETWARBSM_STATE_WAIT_TXN2 */
+            {TNETWARBSM_STATE_WAIT_TXN2          , TNETWArbSM_ReturnPendingOnStart},
+
+            /* {TNETWARBSM_EV_BUS_AVAIL} -> TNETWARBSM_STATE_WAIT_TXN2 */
+            {TNETWARBSM_STATE_WAIT_TXN2          , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_HW_AVAIL} -> TNETWARBSM_STATE_WAIT_TXN2 */
+            {TNETWARBSM_STATE_WAIT_TXN2          , TNETWArbSM_ReturnPendingOnHwAvail},
+
+            /* {TNETWARBSM_EV_RESTART} -> TNETWARBSM_STATE_WAIT_TXN2 */
+            {TNETWARBSM_STATE_WAIT_TXN2          , TNETWArbSM_ActionUnexpected},
+
+            /* {TNETWARBSM_EV_FINISH} -> TNETWARBSM_STATE_WAIT_TXN2 */
+            {TNETWARBSM_STATE_WAIT_TXN2          , TNETWArbSM_ActionUnexpected}, 
+
+            /* {TNETWARBSM_EV_TXN_CMPLT} -> TNETWARBSM_STATE_IDLE */
+            {TNETWARBSM_STATE_IDLE               , TNETWArbSM_ReleaseBus} 
+        },
+    };
+
+    nrfsm_Config (pTNETWArbSM->hFSM,
+                  (nrfsm_matrix_t)smMatrix,
+                  TNETWARB_SM_STATE_NUM,
+                  TNETWARBSM_EVENT_NUM);
+
+    pTNETWArbSM->hReport = hReport;
+    pTNETWArbSM->hELPCtrl = hELPCtrl;
+    pTNETWArbSM->hBusArbiter = hBusArbiter;
+    pTNETWArbSM->hTNETWArb =  hTNETWArb;
+
+    /* TNETWArbSM start in IDLE State (No one is running in the TNETW Arbiter) */    
+    nrfsm_SetState (pTNETWArbSM->hFSM, TNETWARBSM_STATE_IDLE);
+
+    WLAN_REPORT_INIT (pTNETWArbSM->hReport, TNETW_ARBITER_MODULE_LOG, ("TNETWArbSM Initialized\n"));
+
+    return OK;
+}
+
+#define TNETWArbSM_SMEvent__(hSm,ev) \
+    (nrfsm_Event (((TNETWArbSM_t*)hSm)->hFSM, ((TNETWArbSM_t*)hSm)->event = ev, hSm) == OK) \
+        ? ((TNETWArbSM_t*)hSm)->SMlastOperationStatus \
+        : TNETWIF_PENDING
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+TI_STATUS TNETWArbSM_SMEvent (TI_HANDLE hTNETWArbSM, TnetwArbSMEvents_e event)                          
+{
+    return TNETWArbSM_SMEvent__ (hTNETWArbSM, event);
+}
+
+
+static TI_STATUS TNETWArbSM_SeizeBusOnStart (TI_HANDLE hTNETWArbSM)
+{
+    return TNETWArbSM_SeizeBus (hTNETWArbSM, FALSE);
+}
+
+
+static TI_STATUS TNETWArbSM_SeizeBusOnHwAvail (TI_HANDLE hTNETWArbSM)
+{
+    return TNETWArbSM_SeizeBus (hTNETWArbSM, TRUE);
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+static TI_STATUS TNETWArbSM_SeizeBus (TI_HANDLE hTNETWArbSM, BOOL bHwAvail)
+{
+    TNETWArbSM_t *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+    TI_STATUS     status;
+
+    pTNETWArbSM->bHwAvail = bHwAvail;
+
+  #if defined(BUS_GUARD_SUPPORT)
+    status = BusArb_SeizeReq (pTNETWArbSM->hBusArbiter,
+                              TNETWArbSM_BusAvailCB,
+                              hTNETWArbSM);
+#else
+    /* For now assume that we always have the bus */
+    status = TNETWIF_COMPLETE;
+#endif
+
+    /* In case we took the Bus then generate the BUS_AVAIL Event to the State Machine */
+    if (status == TNETWIF_COMPLETE)
+    {
+        /* Then the status could be TNETWIF_COMPLETE at this end or also can be TNETWIF_PENDING if the HW is not Awake */
+        TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_BUS_AVAIL);
+    }
+    /* Return ERROR or PENDING to Client */
+    else
+    {
+        pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+    }
+
+    return OK;
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+#if defined(BUS_GUARD_SUPPORT)
+static void TNETWArbSM_BusAvailCB (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_BUS_AVAIL);
+}
+#endif
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+static TI_STATUS TNETWArbSM_WakeHw (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t  *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    /* Call the ELP Controller module to wake the FW */
+        switch (elpCtrl_Wake (pTNETWArbSM->hELPCtrl,pTNETWArbSM->bHwAvail))
+    {
+        case ELPCTRL_AWAKE:
+        case ELPCTRL_WLAN_RDY_COMPLETE:
+
+            TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_TXN_CMPLT);
+            break;
+
+        case ELPCTRL_WLAN_RDY:
+
+            TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_BUS_AVAIL);
+            break;
+
+        case ELPCTRL_ASLEEP:
+       case ELPCTRL_COMPLETE:
+            pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+            break;
+        default:
+            pTNETWArbSM->SMlastOperationStatus = TNETWIF_ERROR;
+            break;
+    }
+
+    return OK;
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+void TNETWArbSM_TxnCb (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_TXN_CMPLT);
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will do the following:
+ *          1) Dequeue from the TODO Queue the first item or process request to start
+ *          2) Set the Dequeued instance to be the Running instance
+ *          3) Call the Client callback (must be the module start_instance )
+ */
+static TI_STATUS TNETWArbSM_RunClientCb (TI_HANDLE TNETWArbSM)
+{
+    TNETWArbSM_t         *pTNETWArbSM = (TNETWArbSM_t *)TNETWArbSM;
+    TNETWArb_t           *pTNETWArb = (TNETWArb_t *)pTNETWArbSM->hTNETWArb;
+    TNETWARB_INSTANCE_T  *pTNETWARB_Inst;
+
+    /* Mark to ElpCtrl that the IRQ was received and it should get back to AWAKE */
+    elpCtrl_ReceivedIRQ (pTNETWArbSM->hELPCtrl);
+    
+    /* First Dequeue the instance from the TODO Queue */
+    pTNETWARB_Inst = (TNETWARB_INSTANCE_T *)TNETWArb_Dequeue 
+        (&pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]);
+
+    WLAN_REPORT_INFORMATION (pTNETWArbSM->hReport,
+                             TNETW_ARBITER_MODULE_LOG,
+                             ("\n TNETWArbSM_ProcessToDoList: DeQueued pTNETWARB_Inst %x\n", 
+                             pTNETWARB_Inst));
+
+     /* If the instance is already allocated then return error to Client caller */
+    if (pTNETWARB_Inst == NULL)
+    {
+        WLAN_REPORT_ERROR (pTNETWArbSM->hReport, 
+                           TNETW_ARBITER_MODULE_LOG,
+                           ("\nTNETWArbSM_RunClientCb: NULL instance\n")); 
+
+         pTNETWArbSM->SMlastOperationStatus = TNETWIF_ERROR;
+
+         return OK;
+    }
+
+    /* Set it to be the Running instance right now */
+    pTNETWArb->TNETWArb_Running_instance = pTNETWARB_Inst;
+
+    /* Call the Client Callback that must here be the start function of the module */
+    pTNETWArbSM->SMlastOperationStatus = TNETWArb_CallClientCallback (pTNETWArbSM->hTNETWArb);
+
+    return OK;
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+static TI_STATUS TNETWArbSM_ReseizeBus (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t    *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+    TI_STATUS        status;
+
+  #if defined(BUS_GUARD_SUPPORT)
+    status = BusArb_ReseizeReq (pTNETWArbSM->hBusArbiter,
+                                TNETWArbSM_BusAvailCB,
+                                hTNETWArbSM);
+
+  #else
+    /* For now assume that we always have the bus */
+    status = TNETWIF_COMPLETE;
+  #endif
+
+    /* In the case we did not get the Bus now for second time then release the HW till we will get the Callback from the Bus ARbiter */
+    if (status == TNETWIF_PENDING)
+    {
+        pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+    }
+    /* If we got TNETWIF_COMPLETE then we could get the Bus Semaphore again then send the BUS_AVAIL Event */
+    else if (status == TNETWIF_COMPLETE)
+    {
+        /* Get the status again through sending the BUS_AVAIL Event to the TNETW ARbiter SM */
+        /* Then the status could be TNETWIF_COMPLETE at this end or also can be TNETWIF_PENDING if the HW is not Awake */
+        TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_BUS_AVAIL);
+    }
+    else 
+    {
+        pTNETWArbSM->SMlastOperationStatus = TNETWIF_ERROR;
+    }
+
+    return OK;
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * 2) TnetwArbSMEvents_e - the input events to the state machine.
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+static TI_STATUS TNETWArbSM_PutSleepHw (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t    *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    pTNETWArbSM->bHwAvail = FALSE;
+
+    /* The HW is not needed anymore then the FW can go to sleep */
+    if (elpCtrl_Sleep (pTNETWArbSM->hELPCtrl) == TNETWIF_COMPLETE)
+    {
+         return TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_TXN_CMPLT);
+
+    }
+  
+    pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+
+    return OK;
+}
+
+
+static TI_STATUS TNETWArbSM_WaitIRQHw (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t    *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    /* check whether IRQ is about to happen or not, depending on the ElpCtrl Mux state */
+    if ( elpCtrl_isIRQComing (pTNETWArbSM->hELPCtrl) )
+{
+        /* Please be patient - IRQ is about to come any minute */
+        pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+    } 
+    else /* No IRQ is supposed to arrive - roll SM to next position */
+    {
+        TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_HW_AVAIL);
+    }
+
+    return OK;
+}
+
+static TI_STATUS TNETWArbSM_ExitWakeUp (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t    *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    /* Inform ElpCtrl that it should exit the wake up sequence */
+    if ( elpCtrl_exitWakeUpSeq (pTNETWArbSM->hELPCtrl) == ELPCTRL_AWAKE)
+    {   
+        /* We are already awake - send TXN_COMPLETE to roll SM forward */
+        TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_TXN_CMPLT);
+    } 
+    else /* Wait till we get TXN_COMPLETE event */
+    {
+        pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+}
+
+    return OK;
+}
+
+static TI_STATUS TNETWArbSM_ReleaseBus (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t  *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+    TNETWArb_t    *pTNETWArb   = (TNETWArb_t *)pTNETWArbSM->hTNETWArb;
+
+    if (TNETWArb_getfirst (&pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]))
+    {
+        TNETWArbSM_SMEvent__ (hTNETWArbSM, TNETWARBSM_EV_RESTART);
+    }
+
+    else
+    {
+        /* The Bus is not needed anymore */
+      #if defined(BUS_GUARD_SUPPORT)
+        return BusArb_ReleaseReq (pTNETWArbSM->hBusArbiter, hTNETWArbSM);
+      #else 
+        pTNETWArbSM->SMlastOperationStatus = TNETWIF_COMPLETE;
+      #endif
+    }
+
+    return OK;
+}
+
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief trigger events from the outside of the module into the state machine.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * Return Value: TI_STATUS - OK on success else NOK.\n
+ * \b Description:\n
+ * this function will trigger the fsm generic state machine function.
+ */
+static TI_STATUS TNETWArbSM_ReturnPendingOnStart (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t  *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    /* 
+     * In this case return PENDING to the client
+     * meaning that the client will not run immediately.
+     * (Bus Busy/Hw not awake or other client running )
+     */
+    pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+
+    return OK;
+}
+
+
+static TI_STATUS TNETWArbSM_ReturnPendingOnHwAvail (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t  *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    pTNETWArbSM->bHwAvail = TRUE;   
+
+    pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+
+    return OK;
+}
+
+
+static TI_STATUS TNETWArbSM_DoNothing (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t  *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+
+    pTNETWArbSM->SMlastOperationStatus = TNETWIF_PENDING;
+
+    return OK;
+}
+
+
+/**
+ * \date 26-Oct-2005\n
+ * \brief The Event received by the TNETW Arbiter Sm at this specific state is not expected.
+ *
+ * Function Scope \e Public.\n
+ * Parameters:\n
+ * 1) TI_HANDLE - handle to the TNETWArbSMf object.\n
+ * Return Value: TI_STATUS - TNETWIF_ERROR
+ * \b Description:\n
+ * This function will only set a Log to indicate that this event is not expected in the SM
+ */
+TI_STATUS TNETWArbSM_ActionUnexpected (TI_HANDLE hTNETWArbSM)
+{
+    TNETWArbSM_t    *pTNETWArbSM = (TNETWArbSM_t *)hTNETWArbSM;
+    UINT32           state;
+
+    if (nrfsm_GetState (pTNETWArbSM->hFSM, &state) == OK) 
+    {
+        WLAN_REPORT_ERROR (pTNETWArbSM->hReport, 
+                           TNETW_ARBITER_MODULE_LOG,
+                           ("\nTNETWArbSM_ActionUnexpected: state=%u, event=%u\n", 
+                           state,
+                           pTNETWArbSM->event));
+    }
+
+    pTNETWArbSM->SMlastOperationStatus = TNETWIF_ERROR;
+
+    return OK;
+}
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb_buffer.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb_buffer.c
new file mode 100644 (file)
index 0000000..62d08ae
--- /dev/null
@@ -0,0 +1,400 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include "commonTypes.h"
+#include "memMngrEx.h" /* MSDU */
+#include "report.h"
+
+#include "TNETWArb_buffer.h"
+#include "TNETWArb.h"
+#include "TNETWIF.h"
+
+
+/* Each module has its own buffer in the TNETW Arbiter synchronizer */
+
+/*******************************************************************************
+**
+** Function         TNETWArb_init_q
+**
+** Description      Called by an application to initialize a buffer queue.
+**
+** Returns          void
+**
+*******************************************************************************/
+void TNETWArb_init_q (BUFFER_Q *p_q)
+{
+    p_q->p_first = p_q->p_last = NULL;
+    p_q->count = 0;
+}
+
+
+
+/*******************************************************************************
+**
+** Function         TNETWArb_getfirst
+**
+** Description      Return a pointer to the first buffer in a queue
+**
+** Returns          NULL if queue is empty, else buffer address
+**
+*******************************************************************************/
+void *TNETWArb_getfirst (BUFFER_Q *p_q)
+{
+    return (p_q->p_first);
+}
+
+/*******************************************************************************
+**
+** Function         TNETWArb_getnext
+**
+** Description      Return a pointer to the next buffer in a queue
+**
+** Returns          NULL if no more buffers in the queue, else next buffer address
+**
+*******************************************************************************/
+void *TNETWArb_getnext (void *p_buf)
+{
+    BUFFER_HDR_T    *p_hdr;
+
+    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
+
+        if (p_hdr->p_next)
+       {
+        return ((UINT8 *)p_hdr->p_next + BUFFER_HDR_SIZE);
+       }
+    else
+       {
+               return (NULL);
+       }
+}
+
+
+/*******************************************************************************
+**
+** Function         TNETWArb_remove_from_queue
+**
+** Description      Dequeue a buffer from the middle of the queue
+**
+** Returns          NULL if queue is empty, else buffer
+**
+*******************************************************************************/
+void *TNETWArb_remove_from_queue (BUFFER_Q *p_q, void *p_buf)
+{
+    BUFFER_HDR_T *p_hdr;
+
+    if (!p_q->count)
+        return (NULL);
+
+    p_hdr = (BUFFER_HDR_T *)(p_q->p_first) - 1;
+
+    if ((void *)(p_hdr + 1) == p_buf)
+        return (TNETWArb_Dequeue (p_q));
+
+       for ( ; p_hdr; p_hdr = p_hdr->p_next)
+    {
+        if ((void *)(p_hdr->p_next + 1) == p_buf)
+        {
+            p_hdr->p_next = ((BUFFER_HDR_T *)p_buf - 1)->p_next;
+            p_q->count--;
+
+            /* Unlink the buffer since it has been removed from the queue */
+            ((BUFFER_HDR_T *)p_buf - 1)->status = BUF_STATUS_UNLINKED; 
+               
+            return (p_buf);
+        }
+    }
+
+    return (NULL);
+}
+
+
+
+/*******************************************************************************
+**
+** Function         TNETWArb_Dequeue
+**
+** Description      Dequeue a buffer from the head of a queue
+**                  CAUTION This function Is not protected againt reentrance : see GKI_dequeue
+**
+** Returns          NULL if queue is empty, else buffer that is dequeued
+**
+*******************************************************************************/
+void *TNETWArb_Dequeue (BUFFER_Q *p_q)
+{
+    BUFFER_HDR_T    *p_hdr;
+
+       /*WLAN_OS_REPORT(("\n TNETWArb_Dequeue  p_q %x  !!!!  \n", p_q));*/
+
+    if (!p_q->count)
+        return (NULL);
+
+    p_hdr = (BUFFER_HDR_T *)((UINT8 *)p_q->p_first - BUFFER_HDR_SIZE);
+
+
+       if (p_hdr->status != BUF_STATUS_QUEUED)
+    {
+               WLAN_OS_REPORT(("\n GKI_Dequeue ==>  ERROR  p_q->p_first %x BUF_STATUS_QUEUED NOT QUEUED!!!!  %x\n", p_q->p_first));
+        return NULL;
+    }
+
+
+    /* Keep buffers such that GKI header is invisible
+    */
+       if (p_hdr->p_next)
+       {
+        p_q->p_first = ((UINT8 *)p_hdr->p_next + BUFFER_HDR_SIZE);
+       }
+    else
+    {
+        p_q->p_first = NULL;
+        p_q->p_last  = NULL;
+    }
+
+    p_q->count--;
+
+    p_hdr->p_next = NULL;
+       p_hdr->status = BUF_STATUS_UNLINKED;
+
+    return ((UINT8 *)p_hdr + BUFFER_HDR_SIZE);
+}
+
+
+/*******************************************************************************
+**
+** Function         TNETWArb_Enqueue
+**
+** Description      Enqueue a buffer at the tail of the queue.
+**                  CAUTION This function Is not protected againt reentrance 
+**
+** Returns          void
+**
+*******************************************************************************/
+void TNETWArb_Enqueue (BUFFER_Q *p_q, void *p_buf)
+{
+    BUFFER_HDR_T    *p_hdr;
+
+    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
+
+
+       if (p_hdr->status != BUF_STATUS_UNLINKED)
+    {
+               WLAN_OS_REPORT(("\n GKI_Enqueue ==>  ERROR  p_buf %x BUF_STATUS_UNLINKED!!!!  %x\n", p_buf));
+        return;
+    }
+
+    /* Since the queue is exposed (C vs C++), keep the pointers in exposed format */
+    if (p_q->p_first)
+    {
+               BUFFER_HDR_T *p_last_hdr = (BUFFER_HDR_T *)((UINT8 *)p_q->p_last - BUFFER_HDR_SIZE);
+        
+               p_last_hdr->p_next = p_hdr;
+
+    }
+    else
+       {
+        p_q->p_first = p_buf;
+       }
+
+    p_q->p_last = p_buf;
+    p_q->count++;
+    
+       p_hdr->p_next = NULL;
+       p_hdr->status = BUF_STATUS_QUEUED;
+
+
+}
+
+
+/*******************************************************************************
+**
+** Function         TNETWArb_Enqueue_head
+**
+** Description      Enqueue a buffer at the head of the queue
+**
+** Returns          void
+**
+*******************************************************************************/
+void TNETWArb_Enqueue_head (BUFFER_Q *p_q, void *p_buf)
+{
+    BUFFER_HDR_T    *p_hdr;
+
+
+    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
+
+       if (p_hdr->status != BUF_STATUS_UNLINKED)       
+    {
+               WLAN_OS_REPORT(("\n GKI_Enqueue ==>  ERROR  p_buf %x BUF_STATUS_UNLINKED!!!!  %x\n", p_buf));
+        return;
+    }
+
+    if (p_q->p_first)
+    {
+
+        p_hdr->p_next = (BUFFER_HDR_T *)((UINT8 *)p_q->p_first - BUFFER_HDR_SIZE);
+        p_q->p_first = p_buf;
+    }
+    else
+    {
+        p_q->p_first = p_buf;
+        p_q->p_last  = p_buf;
+        p_hdr->p_next = NULL;
+
+
+    }
+
+    p_q->count++;
+
+       p_hdr->status = BUF_STATUS_QUEUED;
+
+}
+
+
+
+
+
+
+
+
+
+/************************* NEW GKI FOR WLAN ***********************************/
+
+/*******************************************************************************
+**
+** Function         TNETWArb_buffer_init
+**
+** Description      Called once internally by GKI at startup to initialize all
+**                  buffers and free buffer pools.
+**
+** Returns          void
+**
+*******************************************************************************/
+void TNETWArb_buffer_init(UINT8 *pTNETWArb_Client_Array)
+{
+    BUFFER_HDR_T  *p_hdr;
+       void              *p_buf;
+       UINT8                   module_id;
+
+
+       /*
+       ** Resetting the buffer to STATUS_FREE
+       */
+    for (module_id = 0; module_id < NUM_OF_TNETWIF_MODULES; module_id++)
+    {
+               /* Pick up corresponding buffer */
+               p_buf = (void *)(&(pTNETWArb_Client_Array[module_id*(BUFFER_HDR_SIZE+TNETWARB_INSTANCE_SIZE)]) + BUFFER_HDR_SIZE);
+               p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
+
+               p_hdr->p_next  = NULL;   /* There is no next buffer of the last one*/
+               p_hdr->status  = BUF_STATUS_FREE; /* Update the status of the released buffer*/
+       }
+
+}
+
+
+
+
+/*******************BUFFER ALLOCATION******************************************/
+
+/*******************************************************************************
+**
+** Function         TNETWArb_getpoolbuf
+**
+** Description      Called by an application to get a free buffer from
+**                  a specific buffer pool should be used in sections which no interrupts 
+**                                     protection is needed.
+**
+** Returns          A pointer to the buffer, or NULL if none available
+**
+*******************************************************************************/
+void *TNETWArb_getpoolbuf (TI_HANDLE hTNETWArb,UINT8 module_id)
+{
+       /* Handle to TNETW Arbiter struct */
+       TNETWArb_t        *pTNETWArb = (TNETWArb_t *)hTNETWArb; 
+    BUFFER_HDR_T  *p_hdr;
+       void              *p_buf;
+
+       p_buf = (void *)((&(pTNETWArb->TNETWArb_Client_Instance_Array[module_id][0])) + BUFFER_HDR_SIZE);
+
+    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
+
+       if (p_hdr->status != BUF_STATUS_FREE)   
+       {       
+               /*WLAN_OS_REPORT(("\n GKI_getpoolbuf ==>  ERROR  p_hdr %x NOT FREE Status %d module_id %d !!!\n", p_hdr,p_hdr->status,module_id));*/
+               return NULL;
+       }
+
+    p_hdr->status  = BUF_STATUS_UNLINKED;
+    p_hdr->p_next  = NULL;
+               
+       return ((void *) ((UINT8 *)p_hdr + BUFFER_HDR_SIZE));
+
+}
+
+
+/*******************************************************************************
+**
+** Function         TNETWArb_freebuf
+**
+** Description      Called by an application to return a buffer to the free pool.
+**                                     To be used in sections which no interrupts protection is needed. 
+**
+** Returns          void
+**
+*******************************************************************************/
+void TNETWArb_freebuf(void *bptr)
+{
+       BUFFER_HDR_T    *p_hdr;
+
+
+       p_hdr = (BUFFER_HDR_T *) ((UINT8 *)bptr - BUFFER_HDR_SIZE);
+
+       if (p_hdr->status != BUF_STATUS_UNLINKED)       
+       {       
+               WLAN_OS_REPORT(("\n GKI_freebuf ==>  ERROR  bptr %x BUF_STATUS_UNLINKED!!!!  %x\n", bptr));
+               return;
+       }
+
+       /*
+       ** Resetting the buffer to STATUS_FREE
+       */
+       p_hdr->p_next  = NULL;   /* There is no next buffer of the last one*/
+       p_hdr->status  = BUF_STATUS_FREE; /* Update the status of the released buffer*/
+               
+}
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWIF.c b/sta_dk_4_0_4_32/common/src/TNETW_Driver/TNETWIF/TNETWIF.c
new file mode 100644 (file)
index 0000000..9a25047
--- /dev/null
@@ -0,0 +1,1123 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  GWSI_Synchronizer.c
+ *   PURPOSE: GWSI Synchronizer used to synchronize between the CMD,INT,TX 
+ *
+ ****************************************************************************/
+
+#include "commonTypes.h"
+#include "report.h"
+#include "osApi.h"
+/* Need tthe TNETWARB API Function to create and confit it */
+#include "TNETWArb.h"
+#include "TNETWIF.h"
+/* Need the HwAcess API Function to create and confit it */
+#include "whalHwAccess.h"
+/* Need the ELP Control API Function to create and confit it */
+#include "ElpCtrl.h"
+
+/*
+ * Special debug mode to trace all calls to TNETWIF_XXX
+ */
+#ifdef TNETWIF_DEBUG
+
+typedef enum
+{
+       No_FUNC,
+       Start_FUNC,
+       Restart_FUNC,
+       Finish_FUNC,
+       WriteMem_FUNC,
+       ReadMem_FUNC,
+       WriteReg_FUNC,
+       ReadReg_FUNC,
+       WriteElp_FUNC,
+       ReadElp_FUNC,
+       BusComplete_FUNC,
+       UnMux_FUNC
+} ETNETIF_Functions;
+
+typedef struct
+{
+       UINT32                          uData;
+       UINT32                          uModule;
+       UINT32                          uTS;
+       ETNETIF_Functions       eFunc;
+
+} TTNETWIF_DEBUG;
+
+/* Should be the max value of uDebugCounter */
+#define TNETWIF_SIZE_OF_DEBUG_ARRAY 256
+
+/* Global variables for debug */
+UINT8                          uDebugCounter ;
+TTNETWIF_DEBUG         tDebug[TNETWIF_SIZE_OF_DEBUG_ARRAY];
+
+#define TNETWIF_TRACE(hOs,func,module,data) \
+               tDebug[uDebugCounter].uData   = (UINT32)(data); \
+               tDebug[uDebugCounter].uModule = module; \
+               tDebug[uDebugCounter].uTS     = os_timeStampUs(hOs); \
+               tDebug[uDebugCounter].eFunc   = func; \
+               uDebugCounter++;
+
+/****************************************************************************
+*                      TNETWIF_FuncEnumdToString()
+*****************************************************************************/
+char* TNETWIF_FuncEnumToString(ETNETIF_Functions eFunc)
+{
+       switch (eFunc)
+       {
+       case No_FUNC:                   return "(No_FUNC)           ";
+       case Start_FUNC:                return "(Start_FUNC)        ";
+       case Restart_FUNC:              return "(Restart_FUNC)      ";
+       case Finish_FUNC:               return "(Finish_FUNC)       ";
+       case WriteMem_FUNC:             return "(WriteMem_FUNC)     ";
+       case ReadMem_FUNC:              return "(ReadMem_FUNC)      ";
+       case WriteReg_FUNC:             return "(WriteReg_FUNC)     ";
+       case ReadReg_FUNC:              return "(ReadReg_FUNC)      ";
+       case WriteElp_FUNC:             return "(WriteElp_FUNC)     ";
+       case ReadElp_FUNC:              return "(ReadElp_FUNC)      ";
+       case BusComplete_FUNC:  return "(BusComplete_FUNC)  ";
+       case UnMux_FUNC:                return "(UnMux_FUNC)        ";
+       default :
+               return " No_FUNC???)";
+       }
+}
+/****************************************************************************
+*                      TNETWIF_printErrorLog()
+*****************************************************************************/
+void TNETWIF_printErrorLog(void)
+{
+       int i;
+       WLAN_OS_REPORT(("\n%s\n",__FUNCTION__));
+       WLAN_OS_REPORT(("Counter at %d (i.e. last operation is %d)\n",uDebugCounter,uDebugCounter-1));
+       for ( i = 0  ; i < TNETWIF_SIZE_OF_DEBUG_ARRAY ; i++)
+       {
+               WLAN_OS_REPORT(("%03d %s: %s TS(Diff) = %07d data = 0x%x\n",i,
+                       TNETWIF_FuncEnumToString(tDebug[i].eFunc), 
+                       TNETWIF_ModuleIdToString(tDebug[i].uModule),
+                       tDebug[i].uTS - tDebug[(UINT8)(i-1)].uTS,
+                       tDebug[i].uData));
+       }
+}
+
+#else /* TNETWIF_DEBUG */
+
+#define TNETWIF_TRACE(hOs,func,module_id,data)
+void TNETWIF_printErrorLog(void) { WLAN_OS_REPORT(("%s define TNETWIF_DEBUG to debug error\n",__FUNCTION__)); }
+
+#endif
+
+extern void os_TNETWIF_BusTxn_Complete(TI_HANDLE OsContext,int status);
+
+
+/***********************************************************************************
+ Internal TNETWIF function use
+
+
+
+**************************************************************************************/
+/****************************************************************************/
+/*                      TNETWIF_Create()
+ ****************************************************************************
+ * DESCRIPTION: Request The Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  String the name of the Queue
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_HANDLE TNETWIF_Create (TI_HANDLE hOs)
+{
+    TNETWIF_t *pTNETWIF;
+
+    /* Allocate the TNETWIF module */
+    pTNETWIF = os_memoryAlloc (hOs, sizeof(TNETWIF_t));
+
+    if (pTNETWIF == NULL)
+        return NULL;
+
+    os_memoryZero (hOs, pTNETWIF, sizeof(TNETWIF_t));
+
+    pTNETWIF->hOs = hOs;
+
+    /* Create the TNETW Arbiter module */
+    pTNETWIF->hTNETWArb = TNETWArb_Init (hOs);
+
+    /* Create the Hw Access module */
+    pTNETWIF->hHwAccess = whal_hwAccess_Create (hOs);
+
+    /* Create the ELP Controller module */
+    pTNETWIF->hELPCtrl = elpCtrl_Create (hOs);
+
+    return (TI_HANDLE)pTNETWIF;
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy The TNETWIF Module
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  String the name of the Queue
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWIF_Destroy (TI_HANDLE hTNETWIF)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    /* Destroy the ELP Controller module */ 
+    elpCtrl_Destroy (pTNETWIF->hELPCtrl);
+
+    /* Destroy the HwAccess Module */
+    whal_hwAccess_Destroy (pTNETWIF->hHwAccess);
+
+    /* Destroy the TNETW Arbiter */
+    TNETWArb_Destroy (pTNETWIF->hTNETWArb);
+
+    /* Free the TNETWIF Memory */
+    os_memoryFree (pTNETWIF->hOs, pTNETWIF, sizeof(TNETWIF_t));
+        
+
+    return OK;
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_ConfigCb()
+ ****************************************************************************
+ * DESCRIPTION: TNETWIF module configuration state machine
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+static void TNETWIF_ConfigCb (TI_HANDLE hTNETWIF, UINT8 module_id, TI_STATUS status)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    switch (pTNETWIF->uInitStage)
+    {
+    case 0:
+        pTNETWIF->uInitStage ++;
+
+       #ifdef GWSI_SPI_TEST
+               /*
+               * This is a special build meant only for testing the SPI bus. We don't need anything 
+               * but initiating the TNETWIF. That's why we skip partition and ELP phase
+               */
+               pTNETWIF->uInitStage = 3;
+       #endif /* GWSI_SPI_TEST */
+
+        /* Register the arbiter callback */
+        TNETWArb_register_handler (pTNETWIF->hTNETWArb, 
+                                   HAL_INIT_MODULE_ID, 
+                                   TNETWIF_ConfigCb, 
+                                   hTNETWIF);
+
+        /* Configure the HwAccess with the DMA Done callback */
+        status = (TI_STATUS)whal_hwAccess_Config (pTNETWIF->hHwAccess, 
+                                       pTNETWIF->hReport, 
+                                       pTNETWIF->uRegBaseAddr, 
+                                       pTNETWIF->uMemBaseAddr, 
+                                       os_TNETWIF_BusTxn_Complete, 
+                                       pTNETWIF->hOs);
+     
+        if (status == TNETWIF_PENDING)
+        {
+            pTNETWIF->status = TNETWIF_PENDING;
+            return;
+        }
+               else if (status == TNETWIF_ERROR)
+               {       /* This case is mainly used for the SPI test */
+                       pTNETWIF->status = TNETWIF_ERROR;
+               }
+        else 
+        {
+            pTNETWIF->status = TNETWIF_COMPLETE;
+        }
+
+    case 1:
+        pTNETWIF->uInitStage ++;
+
+      #if defined(HW_ACCESS_SDIO) || defined(HW_ACCESS_WSPI)
+        status = TNETWIF_SetPartitionsOpt (hTNETWIF, 
+                                           HW_ACCESS_DOWNLOAD, 
+                                           HW_ACCESS_DOWN_PART0_ADDR,
+                                           module_id,
+                                           (TNETWIF_callback_t)TNETWIF_ConfigCb, 
+                                           hTNETWIF);
+        if (status == TNETWIF_PENDING)
+        {
+            pTNETWIF->status = TNETWIF_PENDING;
+            return;
+        }
+        else 
+        {
+            pTNETWIF->status = TNETWIF_COMPLETE;
+        }
+      #endif
+
+    case 2:
+        pTNETWIF->uInitStage ++;
+
+        /* Awake firmware */
+        if (TNETWIF_WriteELPOpt (hTNETWIF, 
+                                 ELPCTRL_WAKE_UP,
+                                 HAL_INIT_MODULE_ID,
+                                 TNETWIF_ConfigCb,
+                                 hTNETWIF,
+                                 TRUE) == TNETWIF_PENDING)
+        {
+            pTNETWIF->status = TNETWIF_PENDING;
+            return;
+        }
+        else
+        {
+            pTNETWIF->status = TNETWIF_COMPLETE;
+        }
+
+    case 3:
+        /* Call upper module callback */
+        pTNETWIF->fCb (pTNETWIF->hCb, module_id, pTNETWIF->status);
+        pTNETWIF->uInitStage = 0;
+
+        WLAN_REPORT_INIT (pTNETWIF->hReport, TNETW_IF_MODULE_LOG,
+                          ("%s(%d) - TNETWIF Initialized\n", __FILE__, __LINE__));
+    }
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_Config()
+ ****************************************************************************
+ * DESCRIPTION: Configure the TNETWIF module
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWIF_Config (TI_HANDLE hTNETWIF, TI_HANDLE hReport, UINT32 uRegBaseAddr, UINT32 uMemBaseAddr, TNETWIF_callback_t fCb, TI_HANDLE hCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    pTNETWIF->hReport = hReport;
+    pTNETWIF->uInitStage = 0;
+    pTNETWIF->uRegBaseAddr = uRegBaseAddr;
+    pTNETWIF->uMemBaseAddr = uMemBaseAddr;
+    pTNETWIF->fCb = fCb;
+    pTNETWIF->hCb = hCb;
+    pTNETWIF->status = TNETWIF_PENDING;
+#ifdef TNETWIF_DEBUG
+       uDebugCounter = 0;
+       os_memoryZero(pTNETWIF->hOs, (void*)tDebug, sizeof(tDebug));
+       WLAN_OS_REPORT(("Using Debug Arbiter\n"));
+#endif
+
+    /* Send the ELP Controller handle to the TNETW Arbiter */
+    TNETWArb_Config (pTNETWIF->hTNETWArb, hReport, pTNETWIF->hELPCtrl);
+
+    /* Configure ELP control before the 1st TNETWIF_Start call */
+    elpCtrl_Configure (pTNETWIF->hELPCtrl, hTNETWIF, TNETWArb_TxnCb);
+
+    /* Start TNETWIF config state machine */
+    TNETWIF_Start (hTNETWIF, HAL_INIT_MODULE_ID, hTNETWIF, TNETWIF_ConfigCb);
+
+    return pTNETWIF->status;
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_ReConfig()
+ ****************************************************************************
+ * DESCRIPTION: stop the SDIO in Recovery process
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  status
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWIF_ReConfig (TI_HANDLE hTNETWIF)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS status = OK;
+    #if (defined(_WINDOWS) && defined(HW_ACCESS_SDIO))
+    #else 
+    whal_hwAccess_Stop (pTNETWIF->hHwAccess);
+    #endif 
+
+    return (status);
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_Start()
+ ****************************************************************************
+ * DESCRIPTION: Request The Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  String the name of the Queue
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWIF_Start (TI_HANDLE hTNETWIF, UINT8 module_id, TI_HANDLE hCb, TNETWIF_callback_t fCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS  status;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,Start_FUNC,module_id,fCb)
+
+    /* Call the TNETW Arbiter for the start operation - the client requests access the bus */
+    status = TNETWArb_Start (pTNETWIF->hTNETWArb, module_id, hCb, fCb);
+
+    return status;
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_Restart()
+ ****************************************************************************
+ * DESCRIPTION: Re-Request The Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT: 
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWIF_Restart (TI_HANDLE hTNETWIF, UINT8 module_id, TI_HANDLE hCb, TNETWIF_callback_t fCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS  status;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,Restart_FUNC,module_id,fCb)
+
+    /* Call the TNETW Arbiter for the restart operation - the client requests access to the bus */
+    status = TNETWArb_Restart (pTNETWIF->hTNETWArb, module_id, hCb, fCb);       
+
+    return status;
+}
+
+
+/****************************************************************************/
+/*                      TNETWIF_Finish()
+ ****************************************************************************
+ * DESCRIPTION: Release The Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS TNETWIF_Finish (TI_HANDLE hTNETWIF, UINT8 module_id, TI_HANDLE hCb, TNETWIF_callback_t fCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS  status;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,Finish_FUNC,module_id,fCb)
+
+    /* Call the TNETW Arbiter for the finish operation - the client frees the bus */
+    status = TNETWArb_Finish (pTNETWIF->hTNETWArb, module_id, hCb, fCb);        
+
+    return status;
+}
+
+/******************************************************************************
+**                                                                           **
+**  Function Name: TNETWIF_UnMux                                   **
+**                                                                           **
+**  Description: This should be called FwEvent to switch MUX from WLAN_READY to FwEvent.        **
+**                                                                           **
+******************************************************************************/
+TI_STATUS TNETWIF_UnMux (TI_HANDLE hTNETWIF)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,UnMux_FUNC,0xFF,0)
+
+    return (TI_STATUS)elpCtrl_UnMux(pTNETWIF->hELPCtrl);
+    
+}
+
+
+/******************************************************************************
+**                                                                           **
+**  Function Name: TNETWIF_BusTxn_Complete                                   **
+**                                                                           **
+**  Description: This should be called now from the tasklet  
+                Distribute SPI interrupt to all running modules     .        **
+**                                                                           **
+******************************************************************************/
+void TNETWIF_BusTxn_Complete (TI_HANDLE hTNETWIF)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,BusComplete_FUNC,0xFF,0)
+
+    TNETWArb_CallTxnCb (pTNETWIF->hTNETWArb);
+}
+
+
+/******************************************************************************
+**                                                                           **
+**  Function Name: TNETWIF_ElpCtrl_Mode                                      **
+**                                                                           **
+**  Description:    this function changes the mode of the ElpCtrl            **
+**                                                                           **
+******************************************************************************/
+int TNETWIF_ElpCtrl_Mode (TI_HANDLE hTNETWIF, elpCtrl_Mode_e mode)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    elpCtrl_Mode (pTNETWIF->hELPCtrl, mode);
+
+    return OK;
+
+}
+
+
+/******************************************************************************
+**                                                                           **
+**  Function Name: TNETWIF_ElpCtrl_HostIF_required                                       **
+**                                                                           **
+**  Description:    
+**                                                                           **
+******************************************************************************/
+int TNETWIF_ElpCtrl_HostIF_required (TI_HANDLE hTNETWIF, int flag)
+{
+    /* TODO: what is the purpose of this API? */
+    return OK;
+}
+
+
+/******************************************************************************
+                  IO Operations : There are 3 modes of operation:
+                                1) Synchronous mode : The caller context is blocked till the Transcation has finished
+                                2) Asynchronous mode : The caller context is unblocked and the Transcation will end later by DMA
+******************************************************************************/
+#ifdef USE_SYNC_API
+
+/******* Synchronous IO mode **************************************************/
+/****************************************************************************
+ *                      TNETWIF_WriteMemSync()
+ ****************************************************************************
+ * DESCRIPTION: Request an Synchronous IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_WriteMemSync (TI_HANDLE hTNETWIF, UINT32 addr, UINT8* data, UINT32 len)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    int  status;
+
+    /* Then Call the HwAccess to operate the I/O */
+    status = whal_hwAccess_WriteMem (pTNETWIF->hHwAccess, addr, data, len);
+
+    /* The return status could be TNETWIF_COMPLETE in case of Success 
+                                  TNETWIF_ERROR in case of ERROR */
+    if (status == OK)
+        return TNETWIF_COMPLETE;
+    else
+        return TNETWIF_ERROR;
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_ReadMemSync()
+ ****************************************************************************
+ * DESCRIPTION: Request an Synchronous IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_ReadMemSync (TI_HANDLE hTNETWIF, UINT32 addr, UINT8* data, UINT32 len)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS  status;
+
+    /* Then Call the HwAccess to operate the I/O */
+    status = (TI_STATUS)whal_hwAccess_ReadMem (pTNETWIF->hHwAccess, addr, data, len);
+
+    /* The return status could be TNETWIF_COMPLETE in case of Success 
+                                  TNETWIF_ERROR in case of ERROR */
+    return status;
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_ReadRegSync()
+ ****************************************************************************
+ * DESCRIPTION: Request an Synchronous IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT: 
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_ReadRegSync (TI_HANDLE hTNETWIF, UINT32 addr, UINT32* data)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS  status;
+
+    /* Then Call the HwAccess to operate the I/O */
+    status = (TI_STATUS)whal_hwAccess_ReadReg (pTNETWIF->hHwAccess, addr, data);
+
+    /* The return status could be TNETWIF_COMPLETE in case of Success 
+                                  TNETWIF_ERROR in case of ERROR */
+    return status;
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_WriteRegSync()
+ ****************************************************************************
+ * DESCRIPTION: Request an Synchronous IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_WriteRegSync (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 data)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    TI_STATUS  status;
+
+    /* Then Call the HwAccess to operate the I/O */
+    status = (TI_STATUS)whal_hwAccess_WriteReg (pTNETWIF->hHwAccess, addr, data);
+
+    /* The return status could be TNETWIF_COMPLETE in case of Success 
+                                  TNETWIF_ERROR in case of ERROR */
+    return status;
+}
+#endif /* USE_SYNC_API */
+
+
+/******* Optimized IO mode : In this mode the SDIO/SPI Driver will decide with its inner thresholds if to make a DMA or not  **************************************************/
+
+/****************************************************************************
+ *                      TNETWIF_ReadMemOpt()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Read Memory IO with the Bus
+ *              Note: Currently, only Sync read is implemented!
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_ReadMemOpt 
+(
+    TI_HANDLE          hTNETWIF, 
+    UINT32             addr, 
+    UINT8             *data, 
+    UINT32             len, 
+    UINT8              module_id, 
+    TNETWIF_callback_t fCb, 
+    TI_HANDLE          hCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,ReadMem_FUNC,module_id,data)
+
+    /* First Register the Callback to the TNET Arbiter where the DMA DONE Callback will be received */
+    TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+
+    /* Call the HwAccess to operate the I/O */
+    return (TI_STATUS)whal_hwAccess_ReadMemAsync (pTNETWIF->hHwAccess, addr, data, len);
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_WriteMemOpt()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Write Memory IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_WriteMemOpt 
+(
+    TI_HANDLE          hTNETWIF, 
+    UINT32             addr, 
+    UINT8             *data, 
+    UINT32             len, 
+    UINT8              module_id, 
+    TNETWIF_callback_t fCb, 
+    TI_HANDLE          hCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,WriteMem_FUNC,module_id,*(UINT32*)(data + TNETWIF_WRITE_OFFSET_BYTES))
+
+    /* First Register the Callback to the TNET Arbiter where the DMA DONE Callback will be received */
+    TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+        
+    /* Then Call the HwAccess to operate the I/O */
+    return whal_hwAccess_WriteMemAsync (pTNETWIF->hHwAccess, addr, data, len);
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_ReadRegOpt()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Read Register IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR or TNETWIF_PENDING
+ *
+ * RETURNS:   
+ ****************************************************************************/
+TI_STATUS  TNETWIF_ReadRegOpt (TI_HANDLE hTNETWIF, UINT32 addr, UINT32* data, UINT8 module_id, TNETWIF_callback_t fCb, TI_HANDLE hCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,ReadReg_FUNC,module_id,data)
+
+    /* First Register the Callback to the TNET Arbiter where the DMA DONE Callback will be received */
+    TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+    
+   /* Call the HwAccess to operate the I/O */
+    return (TI_STATUS)whal_hwAccess_ReadRegAsync (pTNETWIF->hHwAccess, addr, data);
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_WriteRegOpt()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Read Register IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR or TNETWIF_PENDING
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS  TNETWIF_WriteRegOpt (TI_HANDLE hTNETWIF, UINT32 addr, UINT32 data, UINT8 module_id, TNETWIF_callback_t fCb, TI_HANDLE hCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,WriteReg_FUNC,module_id,data)
+
+    /* First Register the Callback to the TNET Arbiter where the DMA DONE Callback will be received */
+    TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+
+    /* Then Call the HwAccess to operate the I/O */
+    return (TI_STATUS)whal_hwAccess_WriteRegAsync (pTNETWIF->hHwAccess, addr, data);
+}
+
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      TNETWIF_WriteELPSync()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Read Register IO with the Bus
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR or TNETWIF_PENDING
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_WriteELPSync (TI_HANDLE hTNETWIF, UINT32 data)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    /* Call the HwAccess to operate the I/O */
+    return (TI_STATUS)whal_hwAccess_WriteELP (pTNETWIF->hHwAccess, data);
+}
+#endif /* USE_SYNC_API */
+
+
+/****************************************************************************
+ *                      TNETWIF_WriteELPOpt()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Read Register IO with the Bus
+ *
+ * INPUTS:  bMore - indicate whether more txn on the bus are about to happen
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR or TNETWIF_PENDING
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_WriteELPOpt (TI_HANDLE hTNETWIF, UINT32 data, UINT8 module_id, TNETWIF_callback_t fCb, TI_HANDLE hCb, BOOL bMore)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,WriteElp_FUNC,module_id,data)
+
+    /* Register a callback */
+    if(fCb)
+      TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+
+    /* Call the HwAccess to operate the I/O */
+    return  (TI_STATUS)whal_hwAccess_WriteELPAsync (pTNETWIF->hHwAccess, data, fCb != NULL, bMore);
+}
+
+/****************************************************************************
+ *                      TNETWIF_ReadELPOpt()
+ ****************************************************************************
+ * DESCRIPTION: Request an Unspecified Read Register IO with the Bus
+ *
+ * INPUTS:  bMore - indicate whether more txn on the bus are about to happen
+ *
+ * OUTPUT:  TI_STATUS    TNETWIF_COMPLETE or TNETWIF_ERROR or TNETWIF_PENDING
+ *
+ * RETURNS: 
+ ****************************************************************************/
+TI_STATUS   TNETWIF_ReadELPOpt (TI_HANDLE hTNETWIF, UINT8 *data, UINT8 module_id, TNETWIF_callback_t fCb, TI_HANDLE hCb, BOOL bMore)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+       TNETWIF_TRACE(pTNETWIF->hOs,ReadElp_FUNC,module_id,data)
+
+    /* Register a callback */
+    if(fCb)
+      TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+
+    /* Call the HwAccess to operate the I/O */
+    return  (TI_STATUS)whal_hwAccess_ReadELPAsync (pTNETWIF->hHwAccess, data, fCb != NULL, bMore);
+}
+
+
+/*****************************************************************************************************
+*             Registers API : All the following API are synchronous only and the return value can be:
+                                ** TNEDTWIF_ERROR - In case the action did not succeed
+                                ** TNETWIF_COMPLETE - In case the action succeeded
+
+*******************************************************************************************************/
+#ifdef USE_SYNC_API
+/****************************************************************************
+ *                      TNETWIF_GetU08()
+ ****************************************************************************
+ * DESCRIPTION: Request an U8 Value from the Hw Access
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  String the name of the Queue
+ *
+ * RETURNS: 
+ ****************************************************************************/
+UINT8  TNETWIF_GetU08 (TI_HANDLE hTNETWIF, UINT32 Addr)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    UINT8      Value;
+
+    Value = whal_hwAccess_GetU08 (pTNETWIF->hHwAccess, Addr);
+
+    return Value;
+
+}
+
+
+/****************************************************************************
+ *                      TNETWIF_SetU08()
+ ****************************************************************************
+ * DESCRIPTION: Set an U8 Value from the Hw Access
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  String the name of the Queue
+ *
+ * RETURNS: 
+ ****************************************************************************/
+void  TNETWIF_SetU08 (TI_HANDLE hTNETWIF, UINT32 Addr, UINT8 Val)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_SetU08 (pTNETWIF->hHwAccess, Addr, Val);
+}
+
+
+void  TNETWIF_ResetU08_Bits (TI_HANDLE hTNETWIF, UINT32 Addr, UINT8  BitsVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_ResetU08_Bits (pTNETWIF->hHwAccess, Addr, BitsVal);
+
+}
+
+
+UINT16  TNETWIF_GetU16 (TI_HANDLE hTNETWIF, UINT32 Addr)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    UINT16     U16Value;
+
+    U16Value = whal_hwAccess_GetU16 (pTNETWIF->hHwAccess,Addr);
+
+    return U16Value;
+}
+
+
+void  TNETWIF_SetU16 (TI_HANDLE hTNETWIF, UINT32 Addr, UINT16 Val)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_SetU16 (pTNETWIF->hHwAccess, Addr, Val);
+}
+
+
+void  TNETWIF_SetU16_Bits (TI_HANDLE hTNETWIF, UINT32 Addr, UINT16 BitsVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_SetU16_Bits (pTNETWIF->hHwAccess,Addr,BitsVal);
+}
+
+
+void  TNETWIF_ResetU16_Bits (TI_HANDLE hTNETWIF, UINT32 Addr, UINT16 BitsVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_ResetU16_Bits (pTNETWIF->hHwAccess, Addr, BitsVal);
+}
+
+
+UINT32  TNETWIF_GetU32 (TI_HANDLE hTNETWIF, UINT32 Addr)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    UINT32     U32Value;
+
+    U32Value = whal_hwAccess_GetU32 (pTNETWIF->hHwAccess, Addr);
+
+    return U32Value;
+}
+
+
+void TNETWIF_SetU32 (TI_HANDLE hTNETWIF, UINT32 Addr, UINT32 Val)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_SetU32 (pTNETWIF->hHwAccess ,Addr, Val);
+
+}
+
+
+void  TNETWIF_SetU32_Bits (TI_HANDLE hTNETWIF, UINT32 Addr, UINT32 BitsVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    whal_hwAccess_SetU32_Bits (pTNETWIF->hHwAccess, Addr, BitsVal);
+
+}
+
+
+void  TNETWIF_ResetU32_Bits (TI_HANDLE hTNETWIF, UINT32 Addr, UINT32 BitsVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    
+    whal_hwAccess_ResetU32_Bits (pTNETWIF->hHwAccess, Addr, BitsVal);
+
+}
+
+
+/*
+ * Hardware Registers Api
+ */
+void  TNETWIF_RegSetBitVal (TI_HANDLE hTNETWIF, UINT32 RegAddr, UINT32 BitVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    
+    whal_hwAccess_RegSetBitVal (pTNETWIF->hHwAccess, RegAddr, BitVal);
+
+}
+
+
+void  TNETWIF_RegResetBitVal (TI_HANDLE hTNETWIF, UINT32 RegAddr, UINT32 BitVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    
+    whal_hwAccess_RegResetBitVal (pTNETWIF->hHwAccess, RegAddr, BitVal);
+
+}
+
+
+int  TNETWIF_RegIsBitSet (TI_HANDLE hTNETWIF, UINT32 RegAddr, UINT32 BitVal)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    int        status;
+    
+    status = whal_hwAccess_RegIsBitSet (pTNETWIF->hHwAccess, RegAddr, BitVal);
+    return status;
+}
+
+#endif /* USE_SYNC_API */
+
+
+/***********************************************************************************
+**                           Client implementation 
+***********************************************************************************/
+/******************************************************************************
+**                                                                           **
+**  Function Name: gwsi_rx_start_instance                                    **
+**                                                                           **
+**  Description: GWSI Rx Data Path Start Instance.                           **
+**                                                                           **
+******************************************************************************/
+void TNETWIF_rx_start_instance (TI_HANDLE CB_Handle, TI_HANDLE module_id, TI_STATUS status)
+{
+/*  WLAN_REPORT_ERROR (GWSI_handle->hReport, TNETW_IF_MODULE_LOG,
+                        ("\n gwsi_rx_start_instance() : Not implemented Yet !!! \n\n"));*/
+
+    return;
+}
+
+
+#ifdef USE_SYNC_API
+
+TI_STATUS TNETWIF_SetPartitions (TI_HANDLE hTNETWIF, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    return (TI_STATUS)whal_hwAccess_SetPartitions (pTNETWIF->hHwAccess, partitionMode, partition_start);
+}
+
+#endif /* USE_SYNC_API */
+
+
+TI_STATUS TNETWIF_SetPartitionsOpt (TI_HANDLE hTNETWIF, TNETIF_HwAccess_SetPartition_mode_e partitionMode, UINT32 partition_start, UINT8 module_id, TNETWIF_callback_t fCb, TI_HANDLE hCb)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    /* Register a callback */
+    TNETWArb_register_handler (pTNETWIF->hTNETWArb, module_id, fCb, hCb);
+
+    return (TI_STATUS)whal_hwAccess_SetPartitionsAsync (pTNETWIF->hHwAccess, partitionMode, partition_start);
+}
+
+
+/****************************************************************************************
+ *                       TNETWIF_RegisterFailureEventCB                                                 *
+ ****************************************************************************************
+DESCRIPTION: Registers a failure event callback to the elp controler.
+                
+                                                                                                                   
+INPUT:      - hTNETWIF      - handle to the TNETWIF object.     
+            - failureEventCB    - the failure event callback function.\n
+            - hFailureEventObj - handle to the object passed to the failure event callback function.
+
+OUTPUT: 
+RETURN:    void.
+****************************************************************************************/
+
+void TNETWIF_RegisterFailureEventCB (TI_HANDLE  hTNETWIF, 
+                                     void      *failureEventCB, 
+                                     TI_HANDLE  hFailureEventObj )
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+
+    elpCtrl_RegisterFailureEventCB (pTNETWIF->hELPCtrl, failureEventCB, hFailureEventObj);    
+}
+
+
+/****************************************************************************************
+ *                       TNETWIF_RegisterBusFailureEventCB                                                  *
+ ****************************************************************************************
+DESCRIPTION: Registers a failure event to the hal ctrl for case of SDIO bus fail.
+                
+                                                                                                                   
+INPUT:      - hTNETWIF      - handle to the TNETWIF object.     
+            - failureEventCB    - the failure event callback function.\n
+            - hFailureEventObj - handle to the object passed to the failure event callback function.
+
+OUTPUT: 
+RETURN:    void.
+****************************************************************************************/
+
+void TNETWIF_RegisterBusFailureEventCB (TI_HANDLE  hTNETWIF, 
+                                        void      *failureEventCB, 
+                                        TI_HANDLE  hFailureEventObj)
+{
+    TNETWIF_t *pTNETWIF = (TNETWIF_t *)hTNETWIF;
+    whal_hwAccess_RegisterForErrorCB (pTNETWIF->hHwAccess, failureEventCB, hFailureEventObj);
+    
+}
+
+/****************************************************************************
+*                      TNETWIF_ModuleIdToString()
+****************************************************************************
+* DESCRIPTION: Convert the module ID to the Name of the module in string
+*
+* INPUTS:  UINT32 module_id
+*
+* OUTPUT:  String the name of the module
+*
+* RETURNS: 
+****************************************************************************/
+char* TNETWIF_ModuleIdToString(UINT32 module_id)
+{
+       switch (module_id)
+       {
+       case DEFAULT_MODULE_ID:  return "(DEFAULT_MODULE_ID)  ";
+       case TX_XFER_MODULE_ID:  return "(TX_XFER_MODULE_ID)  ";
+       case HAL_RX_MODULE_ID:   return "(HAL_RX_MODULE_ID )  ";
+       case HAL_INT_MODULE_ID:  return "(HAL_INT_MODULE_ID)  ";
+       case HAL_CMD_MODULE_ID:  return "(HAL_CMD_MODULE_ID ) ";
+       case FW_EVENT_MODULE_ID: return "(FW_EVENT_MODULE_ID) ";
+       case HAL_INIT_MODULE_ID: return "(HAL_INIT_MODULE_ID )";
+
+       default : 
+               return "(NOT_SUPPORTED)      ";
+       }
+
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/Core_Adapt/CORE_Adapt_Defs.h b/sta_dk_4_0_4_32/common/src/core/Core_Adapt/CORE_Adapt_Defs.h
new file mode 100644 (file)
index 0000000..043424b
--- /dev/null
@@ -0,0 +1,161 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  CORE_Adapt_Defs_Defs.h
+ *   PURPOSE: Core Adapt component structures definitions
+ *
+ ****************************************************************************/
+
+#ifndef __CORE_ADAPT_DEFS_H__
+#define __CORE_ADAPT_DEFS_H__
+
+
+#include "paramOut.h"
+
+/*
+ * --------------------------------------------------------------
+ *                                     for Core API
+ * --------------------------------------------------------------
+ */                                     
+
+typedef enum
+{
+  CORE_MANAGEMENT_FRAME = 0,
+  CORE_CONTROL_FRAME    = 1,
+  CORE_DATA_FRAME       = 2,
+  CORE_RESERVED_FRAME   = 3,
+} CoreAdapt_Tx_frameType_e;
+
+#if 0
+typedef struct
+{
+       CoreAdapt_Tx_frameType_e  txFrameType;
+       rate_e                                  txRequestRate;  
+       modulationType_e                txRequestModulation;
+       rate_e                                  txActualRate;   
+       modulationType_e                txActualModulation;
+       int                                     txStatus; /* OK/NOK of frame transmittion*/
+       void                                    *MsduAddr;
+    int                                                txNumWaiting;
+       /* voice synch trigger for scan */
+    /* disassociate packet trigger to ibssCon SM */
+       UINT32                                  txDescFlags ;
+
+} CoreAdapt_TxCmplt_attr_t; 
+
+typedef enum
+{
+       CORE_RX_SUCCESS         = 0,
+       CORE_RX_STATUS_ERROR,
+       CORE_RX_MIC_FAIL
+} CoreAdapt_Rx_status_e;
+
+typedef struct
+{
+       CoreAdapt_Rx_status_e Status;
+       UINT8       Lna;
+       UINT32          TimeStamp;
+       rate_e          Rate;                           
+       modulationType_e Modulation;
+       UINT8           SNR;
+       UINT8           RxLevel;        
+       UINT8           channel;
+} CoreAdapt_Rx_attr_t; 
+
+/* Callback for tx compleate */
+typedef void (*TxCompleteStatusCB_t)(TI_HANDLE hCtrlData, CoreAdapt_TxCmplt_attr_t* CmpltTxAttr);
+/* Callback for tx compleate */
+typedef void (*TxCompleteStatusCB_t)(TI_HANDLE CB_handle, whalTxCmplt_attr_t* CmpltTxAttr);
+/* Callback for tx sendPacketTranfer */
+typedef void (* SendPacketTranferCB_t)(TSendXferStatus_e aStatus,UINT32 aPacketId,void *reserved);
+
+
+/* Callback for rx msdu */
+typedef void (*msduReceiveCB_t)(TI_HANDLE hRx, mem_MSDU_T *pMsdu, CoreAdapt_Rx_attr_t* pRxAttr);
+
+#endif
+
+
+/* Scan complete Callback - This routine is called from the HAL upon TNET scan complete */
+typedef void (*scanCompleteCB_t)(TI_HANDLE hScan);
+
+/* SME scan complete CB - This function is called by the scan service when it wants to indicate scan_complete event (to the sme)*/
+typedef void (*smeScanCompleteCB_t)(TI_HANDLE hSme);
+
+/* Incoming Info Callback */
+typedef void (*InfoCB_t)(TI_HANDLE handle, char* buf, UINT32 bufSize);
+
+/* Mac status Callback */
+typedef void (*MacStatusCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);
+
+/* Health Report Callback */
+typedef void (*HealthReportCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);
+
+/* Aci Indication Callback */
+typedef void (*AciIndicationCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);
+
+/* Failure Event Callback */
+typedef void (*failureEventCB_t)(TI_HANDLE siteMgr, failureEvent_e failureEvent);
+
+/*
+ * --------------------------------------------------------------
+ *                                     Indication definitions
+ * --------------------------------------------------------------
+ */                                     
+
+
+
+/*
+ * --------------------------------------------------------------
+ *                                     Internal Core_Adapt attributes
+ * --------------------------------------------------------------
+ */                                     
+
+typedef struct _InternalCoreAdapt_attr_t
+{
+       UINT8   NumFrags;
+       BOOL    tkipBitEnable;
+       UINT8   Frag;
+       UINT16  FrameControl;
+       UINT32  HwMpduAddr;
+       UINT8   RtsSet;
+       UINT32  MpduSize;
+       UINT8   numRequiredDataBlks;
+       UINT32  RtsThreshold;
+} InternalCoreAdapt_attr_t;
+
+#endif /* __CORE_ADAPT_DEFS_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/Core_Adapt/Core_AdaptTx.c b/sta_dk_4_0_4_32/common/src/core/Core_Adapt/Core_AdaptTx.c
new file mode 100644 (file)
index 0000000..06788e9
--- /dev/null
@@ -0,0 +1,300 @@
+/** \file Core_AdaptTx.c
+ *  \brief CORE Adaptation Ctrl layer implementation
+ *
+ *  \see CORE_AdaptTx.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                          */
+/*    MODULE:  Core_AdaptTx.c                                            */
+/*    PURPOSE:  CORE Adaptation Tx layer implementation                   */
+/*                                                                          */
+/***************************************************************************/
+#include "report.h"
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "siteHash.h"
+#include "configMgr.h"
+#include "whalCtrl_api.h"
+#include "Core_AdaptTx.h"
+#include "utils.h"
+#include "DataCtrl_Api.h"
+#include "TNETW_Driver_api.h"
+
+/* Globals */
+TI_HANDLE              CORE_AdaptTx_handle=NULL;
+
+/* definitions */
+
+
+/* Local Macros */
+
+
+/* Local  functions definitions*/
+
+
+/****************************************************************************************
+ *                        CORE_AdaptTx_Create                                              *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX CREATION
+
+INPUT:          TI_HANDLE hOs
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_HANDLE CORE_AdaptTx_Create(TI_HANDLE hOs)
+{
+       CORE_AdaptTx_t *pCORE_AdaptTx_handle;
+
+    pCORE_AdaptTx_handle = os_memoryAlloc (hOs, sizeof(CORE_AdaptTx_t));
+    if (pCORE_AdaptTx_handle == NULL)
+        return NULL;
+
+       pCORE_AdaptTx_handle->hOs = hOs;
+               
+    return (TI_HANDLE)pCORE_AdaptTx_handle;
+}
+
+
+/****************************************************************************************
+ *                        CORE_AdaptTx_Config                                              *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX CONFIGURATION
+
+INPUT:          TI_HANDLE hOs
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+int CORE_AdaptTx_Config (TI_HANDLE CORE_AdaptTx_handle, Core_AdaptTx_config_t *pCore_AdaptTx_config,txDataInitParams_t *txDataInitParams)
+{
+    CORE_AdaptTx_t *pCore_AdaptTx = (CORE_AdaptTx_t*)CORE_AdaptTx_handle;
+
+       /* 
+        * handles
+        */
+       pCore_AdaptTx->hReport = pCore_AdaptTx_config->hReport;
+       pCore_AdaptTx->hMemMgr = pCore_AdaptTx_config->hMemMgr;
+       pCore_AdaptTx->hTnetwDrv = pCore_AdaptTx_config->hTnetwDrv;
+       pCore_AdaptTx->hTxData = pCore_AdaptTx_config->hTxData;
+       pCore_AdaptTx->hCtrlData = pCore_AdaptTx_config->hCtrlData;
+
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        CORE_AdaptTx_Destroy                                              *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX DESTRUCTION
+
+INPUT:          TI_HANDLE hCore_AdaptTx - Passed even if its is global variable
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+int CORE_AdaptTx_Destroy (TI_HANDLE hCore_AdaptTx)
+{
+       CORE_AdaptTx_t *pCore_AdaptTx=(CORE_AdaptTx_t*)hCore_AdaptTx;
+       int status = OK;
+
+       if(hCore_AdaptTx == NULL)
+       {
+               return OK;
+       }
+
+    /* free the CORE_AdaptCtrl data structure*/
+    os_memoryFree (pCore_AdaptTx->hOs, pCore_AdaptTx, sizeof(CORE_AdaptTx_t));
+
+    return status;
+}
+
+
+/****************************************************************************************
+ *                        CORE_AdaptTx_SendPacket                                              *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX SendPacket
+
+INPUT:          TI_HANDLE hCore_AdaptTx - Passed even if its is global variable
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+
+
+TI_STATUS CORE_AdaptTx_SendPacket (TI_HANDLE hCore_AdaptTx,
+                                                        UINT8 TxQid,
+                                                        mem_MSDU_T* pMsdu,
+                                                        txData_attr_t* pTxAttr,
+                             UINT32 packetId,
+                                                        UINT32 msduTimeToExpiry )
+{
+       void      *aFrame;
+       UINT16     aLength;
+       UINT8      aQueueId;
+       UINT8      aTxRateClassId;
+       CORE_AdaptTx_t *pCore_AdaptTx=(CORE_AdaptTx_t*)hCore_AdaptTx;
+
+       /*
+        *      handling send packet parameters
+        */
+
+    /* Pointer to the frame actual data (right after TNETWIF_WRITE_OFFSET_BYTES and descriptor)  */
+    aFrame = (void *)((UINT8*)memMgr_BufData(pMsdu->firstBDPtr) + TX_TOTAL_OFFSET_BEFORE_DATA);
+
+       /*
+        * MSDU length. Measured from the first byte of the MAC header 
+        * to the last byte of the frame body.
+        */
+       aLength = memMgr_MsduDataSize(pMsdu);
+
+       /*
+        * Transmit queue as defined in ConfigureQueue
+        */
+       aQueueId = TxQid;
+
+       /*
+        * Transmit rate class ID defined in txRatePolicy 
+        */
+       aTxRateClassId = pTxAttr->txRatePolicyId;
+
+    return TnetwDrv_txXfer_sendPacket (pCore_AdaptTx->hTnetwDrv,  
+                                                   aFrame,
+                                                   aLength,
+                                                   aQueueId,
+                                                   aTxRateClassId,
+                                                   pTxAttr->HwRate,
+                                                   FALSE, /* more indication, currently ignored by GWSI */
+                                                   packetId,
+                                                   0,
+                                                   msduTimeToExpiry,
+                                       NULL);
+}
+
+
+/* --------------------------------- Call Back ---------------------------------------------------*/
+
+/****************************************************************************************
+ *                        SendPacketComplete                                              *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX Tx Complete callback
+
+INPUT:          
+
+OUTPUT:
+
+RETURN:         
+
+************************************************************************/
+void SendPacketComplete (TI_HANDLE hUser,
+                         systemStatus_e aStatus,
+                        UINT32 aPacketId,
+                        UINT32 aRate,
+                        UINT8 aAckFailures,
+                        UINT32 actualDurationInAir,
+                        UINT32 fwHandlingTime,
+                                               UINT32 mediumDelay)
+{
+       CORE_AdaptTx_t *pCore_AdaptTx=(CORE_AdaptTx_t*)CORE_AdaptTx_handle;
+       txCompleteAttr_t txCompleteAttr;
+
+       WLAN_REPORT_INFORMATION(pCore_AdaptTx->hReport, CTRL_DATA_MODULE_LOG, 
+                                               ("SendPacketComplete: aStatus = %d\n\n",aStatus));
+
+       /*
+        * Call the core  CB (TI CORE)
+        */
+       txCompleteAttr.status              = aStatus;
+       txCompleteAttr.packetId            = aPacketId;
+       txCompleteAttr.rate                = aRate;
+       txCompleteAttr.ackFailures         = aAckFailures;
+       txCompleteAttr.actualDurationInAir = actualDurationInAir;
+    txCompleteAttr.fwHandlingTime      = fwHandlingTime;
+    txCompleteAttr.mediumDelay         = mediumDelay;
+
+    ctrlData_txCompleteStatus (pCore_AdaptTx->hCtrlData, &txCompleteAttr);
+}
+
+
+/****************************************************************************************
+ *                        SendPacketTransfer                                             *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX SendPacketTransfer callback
+
+INPUT:          
+
+OUTPUT:
+
+RETURN:         
+
+************************************************************************/
+void SendPacketTransfer (TI_HANDLE hUser, UINT32 aPacketId)
+{
+    CORE_AdaptTx_t *pCore_AdaptTx = (CORE_AdaptTx_t*)CORE_AdaptTx_handle;
+
+    txData_sendPacketTransfer (pCore_AdaptTx->hTxData, aPacketId);
+}
+
+
+/****************************************************************************************
+ *                        SendPacketDebug                                               *
+ ****************************************************************************************
+DESCRIPTION:    CORE ADAPTER TX SendPacketDebug callback
+
+INPUT:          
+
+OUTPUT:
+
+RETURN:         
+
+************************************************************************/
+#ifdef TI_DBG
+void SendPacketDebug (TI_HANDLE hUser, UINT32 uPacketId, UINT32 uDebugInfo)
+{
+    CORE_AdaptTx_t *pCore_AdaptTx = (CORE_AdaptTx_t *)CORE_AdaptTx_handle;
+
+    txData_sendPacketDebug (pCore_AdaptTx->hTxData, uPacketId, uDebugInfo);
+}
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/Core_Adapt/Export_Inc/Core_AdaptCB.h b/sta_dk_4_0_4_32/common/src/core/Core_Adapt/Export_Inc/Core_AdaptCB.h
new file mode 100644 (file)
index 0000000..14be093
--- /dev/null
@@ -0,0 +1,85 @@
+/** \file Core_AdaptCB.h
+ *  \brief Core Adapt CB API   (PALAU CB's)
+ *
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:  Core_AdaptCB.h                                             */
+/*    PURPOSE: Core Adapt CB API  (Palau CB's)                            */
+/*                                                                        */
+/***************************************************************************/
+#ifndef __CORE_ADAPT_CB_H__
+#define __CORE_ADAPT_CB_H__
+
+
+#include "paramOut.h"
+
+
+
+/* External data definitions */
+
+/* External functions definitions */
+/* Shall be the definitions of PALAU CB prototypes */
+/* 
+ * GWSI Call-Back functions:
+ */
+
+/* Callback for Join complete */
+
+
+/* Function prototypes */
+void GWSI_WriteMIBComplete(TI_STATUS aStatus);
+
+void GWSI_JoinComplete (TI_STATUS Status);                             /* CB method after WLAN device completes Join operation*/
+void GWSI_ConfigureQueueComplete(TI_STATUS aStatus);
+void GWSI_ConfigureACComplete(TI_STATUS aStatus);
+void GWSI_DisconnectComplete (TI_STATUS Status);       
+void GWSI_SetBSSParametersComplete (TI_STATUS Status); /* CB method after driver delivers the BSS parameters to the WLAN device*/
+void GWSI_ReadMIBComplete (TI_STATUS Status, 
+                                        TMIB aMib,
+                                        TUINT16 aLength, 
+                                        const void *aData);                                    /* CB method deliver MIB read results*/
+void GWSI_AddKeyComplete(TI_STATUS aStatus);                           /* CB method after setting the Key to the WLAN device*/
+
+
+
+
+
+
+
+#endif /* __CORE_ADAPT_CB_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/core/Core_Adapt/Export_Inc/Core_AdaptTx.h b/sta_dk_4_0_4_32/common/src/core/Core_Adapt/Export_Inc/Core_AdaptTx.h
new file mode 100644 (file)
index 0000000..7f04747
--- /dev/null
@@ -0,0 +1,128 @@
+/** \file Core_AdaptTx.h
+ *  \brief CORE Adaptation Ctrl include file
+ *
+ *  \see Core_AdaptTx.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:  Core_AdaptTx.h                                             */
+/*    PURPOSE: CORE Adaptation TX include file                            */
+/*                                                                         */
+/***************************************************************************/
+#ifndef __CORE_ADAPT_TX_H__
+#define __CORE_ADAPT_TX_H__
+
+
+#include "paramOut.h"
+#include "whalBus_Defs.h"
+#include "MsduList.h"
+#include "DataCtrl_Api.h"
+
+extern TI_HANDLE               CORE_AdaptTx_handle;
+
+/* Callback for tx sendPacketTranfer */
+typedef void (* CoreAdapt_SendPacketTranferCB_t)(TI_HANDLE        hTxData,
+                                                                                                UINT32           pPacketIdAttr);
+
+/* Callback for tx compleate */
+typedef void (*CoreAdapt_TxCompleteStatusCB_t)( TI_HANDLE        hCtrlData,           
+                                                                                               txCompleteAttr_t *pTxCompleteAttr);
+
+
+typedef void (*CoreAdapt_QueueFreeEventCB_t)(TI_HANDLE hTxData,UINT32 *pTxDataHwFreeBuffersPerQ);
+
+
+
+typedef struct
+{
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMgr;
+       TI_HANDLE hTxData;
+       TI_HANDLE hTnetwDrv;
+       TI_HANDLE hCtrlData;
+
+
+} Core_AdaptTx_config_t;
+
+
+/* Typedefs */
+typedef struct
+{
+       /* handles handled */
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMgr;
+       TI_HANDLE hTnetwDrv;
+       TI_HANDLE hTxData;
+       TI_HANDLE hCtrlData;
+} CORE_AdaptTx_t;
+
+
+
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+TI_HANDLE CORE_AdaptTx_Create(TI_HANDLE hOs);
+int CORE_AdaptTx_Config(TI_HANDLE CORE_AdaptTx_handle, Core_AdaptTx_config_t *pCore_AdaptTx_config,txDataInitParams_t *txDataInitParams);
+int CORE_AdaptTx_Destroy(TI_HANDLE hCore_AdaptTx);
+TI_STATUS CORE_AdaptTx_SendPacket(TI_HANDLE hCore_AdaptTx,
+                                                        UINT8 TxQid,
+                                                        mem_MSDU_T* pMsdu,
+                                                        txData_attr_t* pTxAttr,
+                             UINT32 packetId,
+                                                        UINT32 msduTimeToExpiry );
+
+/*  callbacks */
+void SendPacketComplete (TI_HANDLE hUser,
+                         systemStatus_e aStatus,
+                        UINT32 aPacketId,
+                        UINT32 aRate,
+                        UINT8 aAckFailures,
+                        UINT32 actualDurationInAir,
+                        UINT32 fwHandlingTime,
+                                               UINT32 mediumDelay);
+
+void SendPacketTransfer (TI_HANDLE hUser, UINT32 aPacketId);
+void SendPacketDebug    (TI_HANDLE hUser, UINT32 aPacketId, UINT32 uDebugInfo);
+
+
+#endif /* __CORE_ADAPT_TX_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/core/EvHandler/EvHandler.c b/sta_dk_4_0_4_32/common/src/core/EvHandler/EvHandler.c
new file mode 100644 (file)
index 0000000..21f2403
--- /dev/null
@@ -0,0 +1,348 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "IPCKernelApi.h"
+#include "EvHandler.h"
+#include "osAdapter.h"
+/*#include "configMgr.h"*/
+
+
+#ifdef EV_HANDLER_DEBUG
+  TI_HANDLE ghEvHandler; /* for debug, remove later*/
+#endif
+
+/* ************************** Upper Interface **********************************/
+
+TI_HANDLE EvHandlerInit(TI_HANDLE hOs)
+{
+
+    EV_HANDLER_STRUCT_T*  pEvHandler;
+    PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hOs;            
+
+    PRINT(DBG_INIT_LOUD, (" EvHandlerInit\n"));
+    pEvHandler = os_memoryAlloc(hOs,sizeof(EV_HANDLER_STRUCT_T));
+    os_memoryZero(hOs,pEvHandler,sizeof(EV_HANDLER_STRUCT_T));
+
+    #ifdef EV_HANDLER_DEBUG
+      ghEvHandler= pEvHandler;
+      PRINTF(DBG_INIT_VERY_LOUD, ("EvHandlerInit: ghEvHandler set to %08X\n", ghEvHandler));
+    #endif
+
+    pEvHandler->hOs = hOs;
+    
+    pAdapter->hEvHandler =  pEvHandler;
+
+    pEvHandler->LastUMEventType = 0xFFFFFFFF;
+
+       return (TI_HANDLE) pEvHandler;
+}
+
+UINT32 EvHandlerUnload (TI_HANDLE hEvHandler){
+
+    EV_HANDLER_STRUCT_T*  pEvHandler;            
+
+    PRINT(DBG_INIT_LOUD, (" ev_handler_unLoad\n"));
+    pEvHandler = (EV_HANDLER_STRUCT_T *)hEvHandler;
+
+    os_memoryFree(pEvHandler->hOs,pEvHandler,sizeof(EV_HANDLER_STRUCT_T));
+
+       return OK;
+}
+
+
+UINT32 EvHandlerRegisterEvent(TI_HANDLE hEvHandler, PUCHAR pData, ULONG Length)
+{
+    EV_HANDLER_STRUCT_T* pEvHandler;
+       IPC_EVENT_PARAMS*    pEvParams;
+    UINT32  ModuleIndex;
+
+    if( (hEvHandler==NULL) || (pData == NULL)){
+        PRINT(DBG_INIT_ERROR, "EvHandler:EvHandlerRegisterEvent Bad Handle passed \n");
+        return NOK;
+    }
+
+    #ifdef EV_HANDLER_DEBUG
+         if (ghEvHandler !=  hEvHandler)
+         {
+              return NOK;
+          }
+    #endif
+
+    pEvHandler  = (EV_HANDLER_STRUCT_T*)hEvHandler;
+
+       pEvParams = (IPC_EVENT_PARAMS*)pData;
+
+    
+    PRINTF(DBG_INIT_LOUD, (" EvHandlerRegisterEvent EventType = %d \n",pEvParams->uEventType));
+
+    /* used to be: if ( sizeof(IPC_EVENT_PARAMS) != Length)     
+       relaxed size checking (okay if output buffer is larger)  */
+    if ( sizeof(IPC_EVENT_PARAMS) > Length) 
+    {
+        PRINTF(DBG_INIT_ERROR, (" EvHandlerRegisterEvent Error sizeof(IPC_EVENT_PARAMS) != Length,"
+                               "%d != %d \n",sizeof(IPC_EVENT_PARAMS), (int)Length));
+        return (UINT32)STATUS_INVALID_PARAMETER;
+    }
+
+    if( pEvParams->uEventType >= IPC_EVENT_MAX){
+        PRINTF(DBG_INIT_ERROR, (" EvHandlerRegisterEvent Error - Invalid Event Type = %d \n",
+              pEvParams->uEventType));
+        return (UINT32)STATUS_INVALID_PARAMETER;
+    }
+
+    ModuleIndex = 0;
+
+
+    while ( (pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID != NULL )
+            && ( ModuleIndex < MAX_REGISTERED_MODULES)    )
+    {
+        ModuleIndex++; 
+    }
+
+    if(ModuleIndex == MAX_REGISTERED_MODULES)
+    {
+        PRINTF(DBG_INIT_WARNING, (" EvHandlerRegisterEvent %d"
+                               "Registration queue full or event already registered! %x address \n",
+                               pEvParams->uEventType,
+                               (int)(pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID)));
+        return (UINT32)STATUS_INVALID_PARAMETER;
+    }
+
+    os_memoryCopy(pEvHandler->hOs,(UINT8*)&pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex],
+                    (UINT8*)pEvParams,Length);
+
+    pEvParams->uEventID = (TI_HANDLE)&pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex];
+
+    pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID = pEvParams->uEventID;
+
+    PRINT(DBG_INIT_LOUD, " EvHandlerRegisterEvent Out \n");
+
+    return STATUS_SUCCESS;
+
+}
+
+
+UINT32 EvHandlerUnRegisterEvent(TI_HANDLE hEvHandler, TI_HANDLE uEventID)
+{
+    EV_HANDLER_STRUCT_T* pEvHandler;
+    IPC_EVENT_PARAMS*    pEvParams;
+    UINT32  ModuleIndex;
+
+    #ifdef EV_HANDLER_DEBUG
+      if (ghEvHandler !=  hEvHandler )
+      {
+          return NOK;
+      }
+    #endif
+
+    if (uEventID == NULL) 
+    {
+        return NOK;
+    }
+
+    pEvHandler  = (EV_HANDLER_STRUCT_T*)hEvHandler;
+    pEvParams = (IPC_EVENT_PARAMS*)uEventID;
+
+
+    PRINTF(DBG_INIT_LOUD, (" EvHandlerUnRegisterEvent EventType = %d \n",pEvParams->uEventType));
+
+    if( pEvParams->uEventType >= IPC_EVENT_MAX){
+        PRINTF(DBG_INIT_ERROR, (" EvHandlerRegisterEvent Error Event Type = %d \n",
+              pEvParams->uEventType));
+        return (UINT32)STATUS_INVALID_PARAMETER;
+    }
+
+    ModuleIndex = 0;
+
+    while ( (pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID != pEvParams->uEventID )
+            && ( ModuleIndex < MAX_REGISTERED_MODULES)    )
+    {
+        ModuleIndex++; 
+    }
+
+    if(ModuleIndex == MAX_REGISTERED_MODULES)
+    {
+        PRINTF(DBG_INIT_ERROR, (" EvHandlerUnRegisterEvent %d"
+                               "Registration queue doesn't hold this event! %x address \n",
+                               pEvParams->uEventType,
+                               (int)(pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID)));
+        return (UINT32)STATUS_INVALID_PARAMETER;
+    }
+
+    pEvHandler->RegistrationArray[pEvParams->uEventType][ModuleIndex].uEventID = NULL;
+
+    return STATUS_SUCCESS;
+}
+
+
+/* Doesn't support pLength less than expected needed size*/
+UINT32 EvHandlerGetEventData(TI_HANDLE hEvHandler, PUCHAR pData, ULONG* pLength)
+{
+    EV_HANDLER_STRUCT_T* pEvHandler;
+    UINT32              HeadIndex;
+    IPC_EV_DATA*        pNewEvent;
+
+    if(pData == NULL){
+        /*PRINT(DBG_INIT_ERROR, "EvHandler:EvHandlerGetEventData Bad Handle passed \n");*/
+        return NOK;
+    }
+       
+#ifdef EV_HANDLER_DEBUG
+    if (ghEvHandler !=  hEvHandler)
+    {
+        return NOK;
+    }
+#endif
+
+    pEvHandler  = (EV_HANDLER_STRUCT_T*)hEvHandler;
+    HeadIndex   = pEvHandler->SendEventArray.HeadIndex;
+    pNewEvent   = &pEvHandler->SendEventArray.Array[HeadIndex];
+    
+    PRINTF(DBG_INIT_LOUD, (" IPCGetEventData Getting Event = %d",
+                            pEvHandler->SendEventArray.Array[HeadIndex].EvParams.uEventType));
+
+    if (pEvHandler->SendEventArray.Counter == 0)
+    {
+        PRINT(DBG_INIT_ERROR, "Attempting to get from empty queue");
+        return NOK;
+    }
+    *pLength = sizeof(IPC_EV_DATA);
+
+    os_memoryCopy(pEvHandler->hOs, pData,pNewEvent, sizeof(IPC_EV_DATA)); 
+
+    pEvHandler->SendEventArray.HeadIndex = (HeadIndex+1) % MAX_SEND_EVENTS;
+    pEvHandler->SendEventArray.Counter--;
+    HeadIndex   = pEvHandler->SendEventArray.HeadIndex;
+
+    /* SEND SIGNAL FOR THE NEXT EVENT*/
+    if (pEvHandler->SendEventArray.Counter != 0)
+    {
+        IPC_EventSend (pEvHandler->hOs,NULL,0);
+    }
+
+    PRINTF(DBG_INIT_LOUD, ("EvHandlerGetEventData: Normal Exit\n"));
+
+    return STATUS_SUCCESS;
+}
+
+/* ************************** Upper Interface End*********************************/
+
+/* ************************** Bottom Interface **********************************/
+
+UINT32 EvHandlerSendEvent(TI_HANDLE hEvHandler, UINT32 EvType, UINT8* pData, UINT32 Length)
+{
+    EV_HANDLER_STRUCT_T* pEvHandler;
+    IPC_EV_DATA*         pNewEvent;
+    UINT32               TailIndex;
+    UINT32               ModuleIndex=0;
+
+    PRINTF(DBG_INIT_LOUD, (" EvHandlerSendEvent %d  \n", EvType));
+
+    if(hEvHandler == NULL){
+        PRINT(DBG_INIT_ERROR, "EvHandlerSendEvent Bad Handle passed \n");
+        return NOK;
+    }
+
+#ifdef EV_HANDLER_DEBUG
+    if (ghEvHandler !=  hEvHandler)
+    {
+        return NOK;
+    }
+#endif
+
+    pEvHandler  = (EV_HANDLER_STRUCT_T*)hEvHandler;
+
+    TailIndex   = pEvHandler->SendEventArray.TailIndex;
+
+    while ((ModuleIndex < MAX_REGISTERED_MODULES) && (EvType <= IPC_EVENT_MAX))
+    {
+
+        if (pEvHandler->RegistrationArray[EvType][ModuleIndex].uEventID != NULL )
+        {
+            if(pEvHandler->SendEventArray.Counter == MAX_SEND_EVENTS){
+                PRINT(DBG_INIT_ERROR, " EvHandlerSendEvent Array Full u Fool! \n");
+                return NOK;
+            }
+
+            pNewEvent = &pEvHandler->SendEventArray.Array[TailIndex];
+            
+            /* copy the event parameters and data to the events queue*/
+            os_memoryCopy(pEvHandler->hOs,(UINT8*)&pNewEvent->EvParams,
+                            (UINT8*)&pEvHandler->RegistrationArray[EvType][ModuleIndex],
+                            sizeof(IPC_EVENT_PARAMS));
+
+            if( Length > MAX_EVENT_DATA_SIZE ) { /* Dm: Security fix */
+                PRINTF(DBG_INIT_ERROR, ("TI: %s Security Error\n", __FUNCTION__));
+                return NOK;
+            }
+            os_memoryCopy(pEvHandler->hOs,(UINT8*)pNewEvent->uBuffer,
+                    (UINT8*)pData,Length);
+    
+            pNewEvent->uBufferSize = Length;
+    
+            if(pNewEvent->EvParams.uDeliveryType == DELIVERY_PUSH)
+            {
+                    PRINTF(DBG_INIT_LOUD, (" EvHandlerSendEvent %d to OS \n", EvType));                
+                    PRINTF(DBG_INIT_LOUD, ("EvHandlerSendEvent Matching OS Registered event found at EvType = %d,"
+                                          "ModuleIndex = %d  \n", EvType, ModuleIndex));
+                IPC_EventSend (pEvHandler->hOs,(UINT8*)pNewEvent,sizeof(IPC_EV_DATA));
+            }
+            else {
+
+                pEvHandler->LastUMEventType = EvType;
+                pEvHandler->SendEventArray.TailIndex = (TailIndex+1) % MAX_SEND_EVENTS;
+                pEvHandler->SendEventArray.Counter++;
+                TailIndex   = pEvHandler->SendEventArray.TailIndex;
+                PRINTF(DBG_INIT_LOUD, (" EvHandlerSendEvent %d to User Mode \n", EvType));
+                PRINTF(DBG_INIT_LOUD, ("EvHandlerSendEvent Matching User Mode Registered event found at EvType = %d,"
+                                       "ModuleIndex = %d  \n", EvType, ModuleIndex));
+                if (pEvHandler->SendEventArray.Counter == 1)
+                {
+                    IPC_EventSend (pEvHandler->hOs,NULL,0);
+                }
+            }   
+
+        } /* end if*/
+
+       ModuleIndex++; 
+
+   } /* end of while*/
+
+    return OK;
+}
+
+/* ************************** Bottom Interface End **********************************/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/EvHandler/EvHandler.h b/sta_dk_4_0_4_32/common/src/core/EvHandler/EvHandler.h
new file mode 100644 (file)
index 0000000..bf2d26d
--- /dev/null
@@ -0,0 +1,80 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _EVHANDLER_H_
+#define _EVHANDLER_H_
+
+
+#include "TI_IPC_Api.h"
+
+
+typedef struct 
+{
+    IPC_EV_DATA Array[MAX_SEND_EVENTS];
+    UINT32       TailIndex; /* Points to the next free node*/
+    UINT32       HeadIndex; /* Points to the first occupied node*/
+    UINT32       Counter;
+}EV_CYCL_ARRAY, *PEV_CYCL_ARRAY;
+
+typedef struct _EV_HANDLER_STRUCT_T {
+       
+    TI_HANDLE             hOs;
+    IPC_EVENT_PARAMS   RegistrationArray[IPC_EVENT_MAX][MAX_REGISTERED_MODULES];
+    EV_CYCL_ARRAY      SendEventArray;
+    UINT32             LastUMEventType;
+
+}EV_HANDLER_STRUCT_T, *PEV_HANDLER_STRUCT_T;
+
+/* Upper Interface*/
+TI_HANDLE EvHandlerInit         (TI_HANDLE hOs);
+
+UINT32 EvHandlerUnload          (TI_HANDLE hEvHandler);
+
+UINT32 EvHandlerRegisterEvent   (TI_HANDLE hEvHandler, PUCHAR pData,   ULONG Length);
+
+UINT32 EvHandlerUnRegisterEvent (TI_HANDLE hEvHandler, TI_HANDLE uEventID);
+
+UINT32 EvHandlerMaskEvent       (TI_HANDLE hEvHandler, UINT32 uEventID);
+
+UINT32 EvHandlerUnMaskEvent     (TI_HANDLE hEvHandler, UINT32 uEventID);
+
+UINT32 EvHandlerGetEventData    (TI_HANDLE hEvHandler, PUCHAR pData, ULONG* pLength);
+
+/* Bottom Interface*/
+
+UINT32 EvHandlerSendEvent       (TI_HANDLE hEvHandler, UINT32 EvType, UINT8* pData, UINT32 Length);
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/ExpInc/apConnApi.h b/sta_dk_4_0_4_32/common/src/core/ExpInc/apConnApi.h
new file mode 100644 (file)
index 0000000..b064aca
--- /dev/null
@@ -0,0 +1,184 @@
+/** \file apConnApi.h
+ *  \brief AP Connection Module API
+ *
+ *  \see apConn.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  AP Connection                                                 *
+ *   PURPOSE: AP Connection Module API                                      *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _AP_CONNECTION_API_H_
+#define _AP_CONNECTION_API_H_
+
+#include "paramOut.h"
+#include "rsnApi.h"
+#include "roamingMngrTypes.h"
+
+/* Constants */
+
+#define AP_CONNECT_TRIGGER_IGNORED  0x0
+
+/* Enumerations */
+
+/** 
+* Requests to connect types 
+*/
+typedef enum
+{
+    AP_CONNECT_RETAIN_CURR_AP = 0,  /**< Give-up on roaming, return to current AP without performing re-connection */
+    AP_CONNECT_RECONNECT_CURR_AP,   /**< Perform roaming - connect to AP, registered as current AP */
+    AP_CONNECT_FAST_TO_AP,          /**< Perform roaming - re-connect to new AP via RE-Assoc, parameters attached */
+    AP_CONNECT_FULL_TO_AP           /**< Perform full connection - connect to new AP via Assoc, parameters attached */
+} apConn_connRequest_e;
+
+/* triggers for Roaming */
+typedef enum
+{
+    ROAMING_TRIGGER_NONE,
+
+    ROAMING_TRIGGER_LOW_QUALITY_FOR_BG_SCAN,
+    ROAMING_TRIGGER_NORMAL_QUALITY_FOR_BG_SCAN,
+
+    ROAMING_TRIGGER_LOW_TX_RATE,
+    ROAMING_TRIGGER_LOW_SNR,
+    ROAMING_TRIGGER_LOW_QUALITY,
+
+    ROAMING_TRIGGER_MAX_TX_RETRIES,
+    ROAMING_TRIGGER_BSS_LOSS,
+    ROAMING_TRIGGER_SWITCH_CHANNEL,
+
+    ROAMING_TRIGGER_AP_DISCONNECT, /* DE_AUTH, DIS_ASSOC*/
+    ROAMING_TRIGGER_SECURITY_ATTACK,
+
+    ROAMING_TRIGGER_LAST
+} apConn_roamingTrigger_e;
+
+typedef enum
+{
+    CONN_STATUS_CONNECTED,
+    CONN_STATUS_NOT_CONNECTED,
+    CONN_STATUS_HANDOVER_FAILURE,
+    CONN_STATUS_HANDOVER_SUCCESS,
+    CONN_STATUS_LAST
+} apConn_connStatus_e;
+
+typedef enum
+{
+    REG_DOMAIN_FIXED,
+    REG_DOMAIN_80211D,
+    REG_DOMAIN_80211H
+} REG_DOMAIN_CAPABILITY;
+/* Typedefs */
+
+/** 
+* Roaming Manager callback type  
+*/
+
+typedef TI_STATUS (*apConn_roamMngrCallb_t) (TI_HANDLE hRoamingMngr, void *pData);
+
+/* Structures */
+
+typedef struct _apConn_staCapabilities_t
+{
+    /* None, Shared, AutoSwitch, WPA, WPAPSK, WPANone, WPA2, WPA2PSK */
+    OS_802_11_AUTHENTICATION_MODE   authMode;  
+    /* None, WEP, TKIP, AES */
+    OS_802_11_ENCRYPTION_TYPES      encryptionType; 
+    /* 2.4G, 5G or Dual */
+    OS_802_11_NETWORK_TYPE          networkType;  
+    /* An array of 16 octets. Each octet contains a preferred data rate in units of 0.5 Mbps */
+    OS_802_11_RATES_EX              rateMask;  
+    /* TRUE - EXC enabled, FALSE - EXC disabled */
+    BOOL                            excEnabled; 
+    /* TRUE - QOS enabled, FALSE - QOS disabled */
+    BOOL                            qosEnabled; 
+    /* Fixed, 802.11D, 802.11H */
+    REG_DOMAIN_CAPABILITY           regDomain;  
+} apConn_staCapabilities_t;
+
+typedef struct _apConn_connStatus_t
+{
+    apConn_connStatus_e     status;         /** Reported status of the connection */
+    UINT32                  dataBufLength;  /** (Optional) length of attached buffer */
+    char                    *dataBuf;       /** (Optional) attached buffer - can be used in case of vendor specific IEs in Assoc resp packet */
+} apConn_connStatus_t;
+
+typedef struct _apConn_connRequest_t
+{
+    apConn_connRequest_e    requestType;    /** Type of request to establish connection */
+    UINT32                  dataBufLength;  /** (Optional) length of attached buffer */
+    char                    *dataBuf;       /** (Optional) attached buffer - can be used in case of vendor specific IEs in Assoc req packet */
+} apConn_connRequest_t;
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+/* Called by Roaming Manager */
+TI_STATUS apConn_setRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam);
+TI_STATUS apConn_getRoamThresholds(TI_HANDLE hAPConnection, roamingMngrThresholdsConfig_t *pParam);
+
+TI_STATUS apConn_registerRoamMngrCallb(TI_HANDLE hAPConnection, 
+                                       apConn_roamMngrCallb_t roamEventCallb,
+                                       apConn_roamMngrCallb_t reportStatusCallb,
+                                       apConn_roamMngrCallb_t returnNeighborApsCallb);
+TI_STATUS apConn_unregisterRoamMngrCallb(TI_HANDLE hAPConnection);
+
+TI_STATUS apConn_disconnect(TI_HANDLE hAPConnection);
+TI_STATUS apConn_getStaCapabilities(TI_HANDLE hAPConnection,
+                                    apConn_staCapabilities_t *ie_list);
+TI_STATUS apConn_connectToAP(TI_HANDLE hAPConnection,
+                             bssEntry_t *newAP,
+                             apConn_connRequest_t *request,
+                             BOOL reNegotiateTspec);
+bssEntry_t *apConn_getBSSParams(TI_HANDLE hAPConnection);
+
+BOOL apConn_isSiteBanned(TI_HANDLE hAPConnection, macAddress_t * bssid);
+
+BOOL apConn_getPreAuthAPStatus(TI_HANDLE hAPConnection,
+                              macAddress_t *givenAp);
+TI_STATUS apConn_preAuthenticate(TI_HANDLE hAPConnection, bssList_t *listAPs);
+TI_STATUS apConn_prepareToRoaming(TI_HANDLE hAPConnection, apConn_roamingTrigger_e reason);
+
+#endif /*  _AP_CONNECTION_API_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.c b/sta_dk_4_0_4_32/common/src/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.c
new file mode 100644 (file)
index 0000000..daec73d
--- /dev/null
@@ -0,0 +1,1550 @@
+/** \file regulatoryDomain.c
+ *  \brief regulatoryDomain module interface
+ *
+ *  \see regulatoryDomain.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**  
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/************************************************************************************************/
+/*                                                                                             */
+/*             MODULE:         regulatoryDomain.c                                              */
+/*             PURPOSE:        regulatoryDomain module interface.                              */
+/*                  This module calculated the channel that should be scanned and that are      */
+/*                   supported. Moreover, he set the transmit power level according to the      */
+/*                   regulatory domain requirements and the supported channel.                  */
+/*                                                                                             */
+/************************************************************************************************/
+#include "report.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "utils.h"
+#include "regulatoryDomain.h"
+#include "regulatoryDomainApi.h"
+#include "whalCtrl_api.h"
+#include "siteMgrApi.h"
+#include "whalHwCtrl.h"
+#include "SwitchChannelApi.h"
+
+/* Mask for retrieving the TxPower from the Scan Control Table */
+#define MASK_TX_POWER                                  (0x1f) /* bits 0-4 indicates MaxTxPower */ 
+#define MASK_ACTIVE_ALLOWED                    (0x40) /* bit 6 indiactes the channel is allowed for Active scan */
+#define MASK_FREQ_ALLOWED                              (0x80) /* bit 7 indicates the cahnnel is allowed*/
+
+#define CHANNEL_VALIDITY_TS_THRESHOLD   10000 /* 10 sec */
+
+#define INVALID_CHANNEL_165 165
+
+/********************************************************************************/
+/*                                             Internal functions prototypes.                                                  */
+/********************************************************************************/
+static TI_STATUS regulatoryDomain_updateCurrTxPower(regulatoryDomain_t *pRegulatoryDomain);
+
+static void regulatoryDomain_setChannelValidity(regulatoryDomain_t *pRegulatoryDomain, 
+                                                                                               UINT16 channelNum, BOOL channelValidity);
+
+static TI_STATUS setSupportedChannelsAccording2CountryIe(regulatoryDomain_t *pRegulatoryDomain, country_t*     pCountry, BOOL band_2_4);
+
+static void setSupportedChannelsAccording2ScanControlTable(regulatoryDomain_t  *pRegulatoryDomain);
+
+static TI_STATUS regulatoryDomain_getChannelCapability(regulatoryDomain_t *pRegulatoryDomain, 
+                                                                                                          channelCapabilityReq_t channelCapabilityReq, 
+                                                                                                          channelCapabilityRet_t *channelCapabilityRet);
+
+static void regulatoryDomain_updateChannelsTs(regulatoryDomain_t *pRegulatoryDomain, UINT8 channel);
+
+static void regulatoryDomain_buildDefaultListOfChannelsPerBand(regulatoryDomain_t *pRegulatoryDomain, radioBand_e band, UINT8 *listSize);
+
+static void regulatoryDomain_checkCountryCodeExpiry(regulatoryDomain_t *pRegulatoryDomain);
+
+static BOOL regulatoryDomain_isChannelSupprted(regulatoryDomain_t *pRegulatoryDomain, UINT8 channel);
+
+static BOOL regulatoryDomain_isCountryFound(regulatoryDomain_t *pRegulatoryDomain, radioBand_e radioBand);
+
+static void regulatoryDomain_getPowerLevelTableCB( TI_HANDLE hRegulatoryDomain, TI_STATUS status, 
+                                                                                                  UINT8* CB_buf );
+
+static UINT8 regulatoryDomain_getMaxPowerAllowed(regulatoryDomain_t    *pRegulatoryDomain,
+                                                                                                UINT8                          uChannel,
+                                                                                                radioBand_e            eBand,
+                                                                                                BOOL                           bServingChannel);
+
+/********************************************************************************/
+/*                                             Interface functions Implementation.                                             */
+/********************************************************************************/
+
+
+/************************************************************************
+ *                        regulatoryDomain_create                                                                      *
+ ************************************************************************
+DESCRIPTION: regulatoryDomain module creation function, called by the config mgr in creation phase 
+                               performs the following:
+                               -       Allocate the regulatoryDomain handle
+                                                                                                                                  
+INPUT:      hOs -                      Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the regulatoryDomain module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE regulatoryDomain_create(TI_HANDLE hOs)
+{
+       regulatoryDomain_t                      *pRegulatoryDomain = NULL;
+       
+       /* allocating the regulatoryDomain object */
+       pRegulatoryDomain = os_memoryAlloc(hOs,sizeof(regulatoryDomain_t));
+
+       if (pRegulatoryDomain == NULL)
+               return NULL;
+
+       return(pRegulatoryDomain);
+}
+
+/************************************************************************
+ *                        regulatoryDomain_config                                              *
+ ************************************************************************
+DESCRIPTION: regulatoryDomain module configuration function, called by the config mgr in configuration phase
+                               performs the following:
+                               -       Reset & initializes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hRegulatoryDomain  -       regulatoryDomain handle
+                       List of handles to be used by the module
+                       pRegulatoryDomainInitParams     -       Init table of the module.               
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS regulatoryDomain_config(TI_HANDLE    hRegulatoryDomain,
+                                                               TI_HANDLE               hSiteMgr,
+                                                               TI_HANDLE               hHalCtrl,
+                                                               TI_HANDLE               hReport,
+                                                               TI_HANDLE               hOs,
+                                TI_HANDLE              hSwitchChannel,
+                                                               regulatoryDomainInitParams_t *pRegulatoryDomainInitParams)
+{
+       regulatoryDomain_t *pRegulatoryDomain = (regulatoryDomain_t *)hRegulatoryDomain;
+       whalParamInfo_t    tWhalParam;
+
+       /* 
+        *init variables - must be the 1st thing that is init!
+        */
+       pRegulatoryDomain->country_2_4_WasFound         = FALSE;
+       pRegulatoryDomain->country_5_WasFound           = FALSE;
+       pRegulatoryDomain->uExternTxPowerPreferred      = MAX_TX_POWER; /* i.e. no restriction */
+       pRegulatoryDomain->uPowerConstraint                     = MIN_TX_POWER; /* i.e. no restriction */
+        
+       /* Init handlers */
+       pRegulatoryDomain->hSiteMgr = hSiteMgr;
+       pRegulatoryDomain->hHalCtrl     = hHalCtrl;
+       pRegulatoryDomain->hReport      = hReport;
+       pRegulatoryDomain->hOs  = hOs;
+    pRegulatoryDomain->hSwitchChannel = hSwitchChannel;
+
+       /* User max Tx power for all channels */
+       pRegulatoryDomain->uUserMaxTxPower        = pRegulatoryDomainInitParams->desiredTxPower; 
+       /* Temporary Tx Power control to be used */
+       pRegulatoryDomain->uDesiredTemporaryTxPower = pRegulatoryDomainInitParams->uTemporaryTxPower;
+    pRegulatoryDomain->uTemporaryTxPower  = pRegulatoryDomainInitParams->uTemporaryTxPower;
+
+    /* 
+        * Indicate the time in which the STA didn't receive any country code and was not connected, and therefore
+     * will delete its current country code 
+        */
+    pRegulatoryDomain->uTimeOutToResetCountryMs = pRegulatoryDomainInitParams->uTimeOutToResetCountryMs;
+       pRegulatoryDomain->uLastCountryReceivedTS = 0;
+
+       /* Get Power Translation Table from NVS. This table is retrieved only once */
+       tWhalParam.paramType = HAL_CTRL_POWER_LEVEL_TABLE_PARAM;
+       tWhalParam.content.interogateCmdCBParams.CB_Func = (void *)regulatoryDomain_getPowerLevelTableCB;
+       tWhalParam.content.interogateCmdCBParams.CB_handle = hRegulatoryDomain;
+       tWhalParam.content.interogateCmdCBParams.CB_buf = (UINT8*)(&(pRegulatoryDomain->tPowerLevelTableInterrogate));
+       whalCtrl_GetParam( pRegulatoryDomain->hHalCtrl, &tWhalParam );
+       
+
+       pRegulatoryDomain->regulatoryDomainEnabled = pRegulatoryDomainInitParams->multiRegulatoryDomainEnabled;
+       pRegulatoryDomain->spectrumManagementEnabled = pRegulatoryDomainInitParams->spectrumManagementEnabled;
+       if (pRegulatoryDomain->spectrumManagementEnabled == TRUE)
+       {
+               pRegulatoryDomain->regulatoryDomainEnabled = TRUE;
+       }
+               
+       /* Getting the desired Control Table contents for 2.4 Ghz*/
+       os_memoryCopy(pRegulatoryDomain->hOs,
+                                 (void *)pRegulatoryDomain->scanControlTable.ScanControlTable24.tableString,
+                                 (void *)pRegulatoryDomainInitParams->desiredScanControlTable.ScanControlTable24.tableString,
+                                       NUM_OF_CHANNELS_24 * sizeof(INT8));
+
+       /* Getting the desired Control Table contents for 5 Ghz*/
+       os_memoryCopy(pRegulatoryDomain->hOs,
+                                 (void *)pRegulatoryDomain->scanControlTable.ScanControlTable5.tableString,
+                                 (void *)pRegulatoryDomainInitParams->desiredScanControlTable.ScanControlTable5.tableString,
+                                       A_5G_BAND_NUM_CHANNELS * sizeof(INT8));
+
+       setSupportedChannelsAccording2ScanControlTable(pRegulatoryDomain);
+
+    pRegulatoryDomain->minDFS_channelNum = A_5G_BAND_MIN_MIDDLE_BAND_DFS_CHANNEL;
+    pRegulatoryDomain->maxDFS_channelNum = A_5G_BAND_MAX_UPPER_BAND_DFS_CHANNEL;
+
+       WLAN_REPORT_INIT(hReport, REGULATORY_DOMAIN_MODULE_LOG,  (".....Regulatory domain configured successfully\n"));
+
+       return OK;
+}
+
+
+/***********************************************************************
+ *                        regulatoryDomain_setParam                                                                    
+ ***********************************************************************
+DESCRIPTION: Regulatory Domain set param function, called by the following:
+                       -       config mgr in order to set a parameter receiving from the OS abstraction layer.
+                       -       From inside the driver  
+                                                                                                   
+INPUT:      hRegulatoryDomain  -       Regulatory Domain handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS regulatoryDomain_setParam(TI_HANDLE          hRegulatoryDomain,
+                                                                                       paramInfo_t     *pParam)
+{
+       regulatoryDomain_t *pRegulatoryDomain = (regulatoryDomain_t *)hRegulatoryDomain;
+    
+                       
+       switch(pParam->paramType)
+       {
+    case REGULATORY_DOMAIN_COUNTRY_PARAM:
+        {
+            BOOL        bBand_2_4;
+
+            /* Sanity check */
+            if (NULL == pParam->content.pCountry)
+            {   
+                WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                  ("regulatoryDomain_setParam, REGULATORY_DOMAIN_COUNTRY_PARAM is set with NULL pointer"));
+
+                return NOK;
+            }
+            else /* Update country code and supported channels */
+            {         
+                bBand_2_4 = siteMgr_isCurrentBand24(pRegulatoryDomain->hSiteMgr);
+
+                           /* Setting the CountryIE for every Band */
+                           setSupportedChannelsAccording2CountryIe(pRegulatoryDomain, pParam->content.pCountry, bBand_2_4);
+            }
+        }
+               break;
+
+    case REGULATORY_DOMAIN_CHECK_COUNTRY_PARAM:
+        
+        /* Check if Country code should be updated */
+        regulatoryDomain_checkCountryCodeExpiry(pRegulatoryDomain);
+
+        break;
+
+       case REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM:
+
+        /* Update only if 11h enabled */
+        if (pRegulatoryDomain->spectrumManagementEnabled)
+               {       
+            /* Convert to RegDomain units */
+            UINT8 uNewPowerConstraint = DBM2DBMDIV10(pParam->content.powerConstraint);
+
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                         ("SET_POWER_CONSTRAINT Old= %d New = %d (Only if bigger...)\n", 
+                                                         pRegulatoryDomain->uPowerConstraint, uNewPowerConstraint));
+
+                       /* Update powerConstraint */
+                       if ( pRegulatoryDomain->uPowerConstraint != uNewPowerConstraint )
+                       {
+                               pRegulatoryDomain->uPowerConstraint = uNewPowerConstraint;
+                               /* Set new Tx power to Hal - only if needed ! */
+                               regulatoryDomain_updateCurrTxPower(pRegulatoryDomain);
+                       }
+        }
+               break;  
+               
+       case REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED:
+               /* ExternTxPowerPreferred is the TX Power Control (TPC) */
+               {
+                       /* Convert to RegDomain units */
+                       UINT8 uNewTPC = DBM2DBMDIV10(pParam->content.ExternTxPowerPreferred);
+
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                               ("REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED Old= %d New = %d\n", 
+                               pRegulatoryDomain->uExternTxPowerPreferred, uNewTPC));
+
+                       if ( uNewTPC != pRegulatoryDomain->uExternTxPowerPreferred )
+                       {
+                               pRegulatoryDomain->uExternTxPowerPreferred = uNewTPC;
+                               /* Set new Tx power to Hal - only if needed ! */
+                               regulatoryDomain_updateCurrTxPower(pRegulatoryDomain);
+                       }
+               }
+               break;  
+       
+       case REGULATORY_DOMAIN_SET_CHANNEL_VALIDITY:
+               /* Set channel as Valid or Invalid for Active SCAN only.
+                       Mainly used by DFS when Switch Channel is active */
+               regulatoryDomain_setChannelValidity(pRegulatoryDomain, pParam->content.channelValidity.channelNum, 
+                                                                                                                          pParam->content.channelValidity.channelValidity);
+               break;
+       
+       case REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM:
+               /* This case is called when the desired Tx Power Level in Dbm is changed by the user */
+        if(pRegulatoryDomain->uUserMaxTxPower != pParam->content.desiredTxPower)
+        {
+            pRegulatoryDomain->uUserMaxTxPower = pParam->content.desiredTxPower;                       
+                       /* Set new Tx power to Hal - only if needed ! */
+                       regulatoryDomain_updateCurrTxPower(pRegulatoryDomain);
+        }
+
+               break;
+
+       case REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM:
+               /* Called after joining BSS, set Tx power to Hal */
+
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_setParam, REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM \n"));
+
+          /* setting the Tx Power according to the selected channel */
+        regulatoryDomain_updateCurrTxPower(pRegulatoryDomain);
+        
+               break;
+
+    case REGULATORY_DOMAIN_DISCONNECT_PARAM:
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_setParam, REGULATORY_DOMAIN_DISCONNECT_PARAM\n"));
+
+        pRegulatoryDomain->uExternTxPowerPreferred = MAX_TX_POWER;     /* i.e. no restriction */
+        pRegulatoryDomain->uPowerConstraint               = MIN_TX_POWER;      /* i.e. no restriction */
+
+        /* Update the last time a country code was used. 
+        After uTimeOutToResetCountryMs the country code will be deleted     */
+        if (pRegulatoryDomain->country_2_4_WasFound || pRegulatoryDomain->country_5_WasFound)
+        {
+            pRegulatoryDomain->uLastCountryReceivedTS = os_timeStampMs(pRegulatoryDomain->hOs);
+        }
+        break;
+
+       case REGULATORY_DOMAIN_UPDATE_CHANNEL_VALIDITY:
+               regulatoryDomain_updateChannelsTs(pRegulatoryDomain, pParam->content.channel);
+               break;
+
+    case REGULATORY_DOMAIN_TEMPORARY_TX_ATTENUATION_PARAM:
+               /* Temporary Tx Power control */
+               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                 (" temporary fix = %d, \n", pParam->content.bActivateTempPowerFix));
+
+               /* Check if Temporary Tx Power control is enabled or disabled */
+               if ( pParam->content.bActivateTempPowerFix )
+        {   /* setting the Temporary Tx Power directly to Hal */
+            whalParamInfo_t     whalParam;
+
+            whalParam.content.halCtrlTxPowerDbm = pRegulatoryDomain->uTemporaryTxPower;
+            whalParam.paramType = HAL_CTRL_TX_POWER_PARAM;
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                         (" Setting actual temporary TX power = %d,Desired =%d \n", 
+                                                          pRegulatoryDomain->uTemporaryTxPower,
+                                                          pRegulatoryDomain->uDesiredTemporaryTxPower));
+            whalCtrl_SetParam(pRegulatoryDomain->hHalCtrl, &whalParam);
+        }    
+               else    
+               {       /* Exit from Temporary Tx Power control- return to normal Tx Power */
+                       regulatoryDomain_updateCurrTxPower(pRegulatoryDomain);
+        }        
+
+        break;
+
+    case REGULATORY_DOMAIN_ENABLE_DISABLE_802_11D:
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_setParam, REGULATORY_DOMAIN_ENABLE_DISABLE_802_11D = %d, \n", pParam->content.enableDisable_802_11d));
+
+        if ((pRegulatoryDomain->regulatoryDomainEnabled != pParam->content.enableDisable_802_11d) &&
+            !pParam->content.enableDisable_802_11d && pRegulatoryDomain->spectrumManagementEnabled)
+        {   /* Disable of 802_11d, is not allowed when 802_11h is enabled */
+            WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                              ("regulatoryDomain_setParam, Disable of 802_11d, is not allowed when 802_11h is enabled  \n"));
+            return NOK;
+            
+        }
+        pRegulatoryDomain->regulatoryDomainEnabled = pParam->content.enableDisable_802_11d;
+
+               /* Mark that no country was found - applies for both enabling and disabling of 11d */
+               pRegulatoryDomain->country_2_4_WasFound = FALSE;
+               pRegulatoryDomain->country_5_WasFound = FALSE;
+
+        if (!pRegulatoryDomain->regulatoryDomainEnabled)
+        {   /* Set regulatory Domain according to scan control table */
+            setSupportedChannelsAccording2ScanControlTable(pRegulatoryDomain);
+        }
+
+               break;
+
+    case REGULATORY_DOMAIN_ENABLE_DISABLE_802_11H:
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_setParam, REGULATORY_DOMAIN_ENABLE_DISABLE_802_11H = %d, \n", pParam->content.enableDisable_802_11h));
+
+        pRegulatoryDomain->spectrumManagementEnabled = pParam->content.enableDisable_802_11h;
+        if (pParam->content.enableDisable_802_11h)
+        {   /* If 802_11h is enabled, enable 802_11d as well */
+            pRegulatoryDomain->regulatoryDomainEnabled = TRUE;
+        }
+        switchChannel_enableDisableSpectrumMngmt(pRegulatoryDomain->hSwitchChannel, pRegulatoryDomain->spectrumManagementEnabled);
+               break;
+
+       case REGULATORY_DOMAIN_COUNTRY_2_4_PARAM:
+        /* NOTE !!! use this feature carefully. */
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_setParam, REGULATORY_DOMAIN_COUNTRY_2_4_PARAM Len = %d, \n", pParam->paramLength));
+
+        WLAN_REPORT_HEX_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, (UINT8*)pParam->content.pCountry, sizeof(country_t));
+
+        return setSupportedChannelsAccording2CountryIe(pRegulatoryDomain, pParam->content.pCountry, TRUE);
+
+       case REGULATORY_DOMAIN_COUNTRY_5_PARAM:
+        /* NOTE !!! use this feature carefully */
+        return setSupportedChannelsAccording2CountryIe(pRegulatoryDomain, pParam->content.pCountry, FALSE);
+
+
+    case REGULATORY_DOMAIN_DFS_CHANNELS_RANGE:
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_setParam, DFS_CHANNELS_RANGE, min = %d, max = %d, \n", 
+                           pParam->content.DFS_ChannelRange.minDFS_channelNum,
+                           pParam->content.DFS_ChannelRange.maxDFS_channelNum));
+        if ((pParam->content.DFS_ChannelRange.minDFS_channelNum<A_5G_BAND_MIN_CHANNEL) ||
+            (pParam->content.DFS_ChannelRange.maxDFS_channelNum>A_5G_BAND_MAX_CHANNEL) ||
+            pParam->content.DFS_ChannelRange.minDFS_channelNum > pParam->content.DFS_ChannelRange.maxDFS_channelNum)
+        {
+            WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                              ("regulatoryDomain_setParam, Bad DFS_CHANNELS_RANGE, min = %d, max = %d, \n", 
+                               pParam->content.DFS_ChannelRange.minDFS_channelNum,
+                               pParam->content.DFS_ChannelRange.maxDFS_channelNum));
+            return NOK;
+        }
+        pRegulatoryDomain->minDFS_channelNum = (UINT8)pParam->content.DFS_ChannelRange.minDFS_channelNum;
+        pRegulatoryDomain->maxDFS_channelNum = (UINT8)pParam->content.DFS_ChannelRange.maxDFS_channelNum;
+
+        break;
+
+       default:
+               WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, ("Set param, Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        regulatoryDomain_getParam                                                                    
+ ***********************************************************************
+DESCRIPTION: Regulatory Domain get param function, called by the following:
+                       -       config mgr in order to get a parameter from the OS abstraction layer.
+                       -       From inside the driver  
+                                                                                                   
+INPUT:      hRegulatoryDomain  -       Regulatory Domain handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS regulatoryDomain_getParam(TI_HANDLE          hRegulatoryDomain,
+                                                                                       paramInfo_t     *pParam)
+{
+       regulatoryDomain_t      *pRegulatoryDomain = (regulatoryDomain_t *)hRegulatoryDomain;
+
+       switch(pParam->paramType)
+       {
+
+       case REGULATORY_DOMAIN_TX_POWER_LEVEL_TABLE_PARAM:
+        /* Copy power translation table */
+               os_memoryCopy(pRegulatoryDomain->hOs, (void*)&pParam->content.powerLevelTable,
+                       (void*)&(pRegulatoryDomain->tPowerLevelTableInterrogate.tTable), sizeof(powerLevelTable_t));
+
+        break;
+
+       case REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM:
+               pParam->content.spectrumManagementEnabled = pRegulatoryDomain->spectrumManagementEnabled;
+               break;
+               
+       case REGULATORY_DOMAIN_ENABLED_PARAM:
+               pParam->content.regulatoryDomainEnabled = pRegulatoryDomain->regulatoryDomainEnabled;
+               break;
+
+       case REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES:
+               {
+                       channelCapabilityReq_t  channelCapabilityReq;
+
+                       channelCapabilityReq.band = pParam->content.channelCapabilityReq.band;
+                       channelCapabilityReq.channelNum = pParam->content.channelCapabilityReq.channelNum;
+                       channelCapabilityReq.scanOption = pParam->content.channelCapabilityReq.scanOption;
+
+                       regulatoryDomain_getChannelCapability(pRegulatoryDomain, channelCapabilityReq, &pParam->content.channelCapabilityRet);
+               }
+               break;
+
+       case REGULATORY_DOMAIN_POWER_CAPABILITY_PARAM:
+               /* power capability is only applicable when spectrum management is active (802.11h) */ 
+               if(pRegulatoryDomain->spectrumManagementEnabled)
+               {
+                       pParam->content.powerCapability.minTxPower = pRegulatoryDomain->uMinPowerDbm;
+                       pParam->content.powerCapability.maxTxPower = pRegulatoryDomain->uMaxPowerDbm;
+               }
+               else
+               {
+                       return NOK;
+               }
+               break;
+
+       case REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED:
+               /* checking if the channel is supported */
+               pParam->content.bIsChannelSupprted  = 
+                       regulatoryDomain_isChannelSupprted(pRegulatoryDomain, pParam->content.channel);
+                       
+               break;
+
+       case REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS:
+               {
+                       radioBand_e     band = pParam->content.siteMgrRadioBand;
+                       regulatoryDomain_buildDefaultListOfChannelsPerBand(pRegulatoryDomain, band, &pParam->content.supportedChannels.sizeOfList);
+                   pParam->content.supportedChannels.listOfChannels = pRegulatoryDomain->pDefaultChannels;
+               }
+               break;
+
+       case REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM:
+
+            {
+                       whalParamInfo_t         tWhalParam;
+                       /* Get last configured Tx power from Hal */
+                       tWhalParam.paramType = HAL_CTRL_TX_POWER_PARAM;
+                       whalCtrl_GetParam(pRegulatoryDomain->hHalCtrl, &tWhalParam);
+
+                       pParam->content.desiredTxPower = tWhalParam.content.halCtrlTxPowerDbm;
+
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                         ("regulatoryDomain_getParam, CURRENT_TX_POWER_IN_DBM  = %d\n", 
+                                                          pParam->content.desiredTxPower));
+            }
+
+        break;
+
+    case REGULATORY_DOMAIN_COUNTRY_PARAM:
+        {   
+            /* This case is used as an inner function of the driver to retrieve the full IE of the country */
+
+            BOOL bBand_2_4 = siteMgr_isCurrentBand24(pRegulatoryDomain->hSiteMgr);
+
+            /* Check if country code is still valid */
+            regulatoryDomain_checkCountryCodeExpiry(pRegulatoryDomain);
+                
+            if (bBand_2_4)
+            {
+                if (pRegulatoryDomain->country_2_4_WasFound)
+                {
+                    pParam->content.pCountry = &pRegulatoryDomain->country24;
+                }
+                else    /* Do not use the Inforamtion */
+                {
+                    pParam->content.pCountry = NULL;
+                }
+            }   /* band 5.0 */
+            else
+            { 
+                if (pRegulatoryDomain->country_5_WasFound)
+                {
+                   pParam->content.pCountry = &pRegulatoryDomain->country5;
+                }
+                else    /* Do not use the Inforamtion */
+                {
+                    pParam->content.pCountry = NULL;
+                }
+            }
+        }
+        break;
+        
+       case REGULATORY_DOMAIN_COUNTRY_2_4_PARAM:
+               /* Getting only country string */
+
+        /* Check if country code is still valid */
+        regulatoryDomain_checkCountryCodeExpiry(pRegulatoryDomain);
+
+        if (pRegulatoryDomain->country_2_4_WasFound)
+        {
+            os_memoryCopy(pRegulatoryDomain->hOs, (void*)pParam->content.pCountryString, (void*)pRegulatoryDomain->country24.countryIE.CountryString, COUNTRY_STRING_LEN);
+        }
+        else
+        {
+            pParam->content.pCountryString[0] = '\0';
+        }
+               break;
+
+       case REGULATORY_DOMAIN_COUNTRY_5_PARAM:
+               /* Getting only country string */
+
+        /* Check if country code is still valid */
+        regulatoryDomain_checkCountryCodeExpiry(pRegulatoryDomain);
+
+        if (pRegulatoryDomain->country_5_WasFound)
+        {
+            os_memoryCopy(pRegulatoryDomain->hOs, (void*)pParam->content.pCountryString, (void*)pRegulatoryDomain->country5.countryIE.CountryString, COUNTRY_STRING_LEN);
+        }
+        else
+        {
+            pParam->content.pCountryString[0] = '\0';
+        }
+               break;
+
+    case REGULATORY_DOMAIN_DFS_CHANNELS_RANGE:
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                          ("regulatoryDomain_getParam, DFS_CHANNELS_RANGE, min = %d, max = %d, \n", 
+                           pRegulatoryDomain->minDFS_channelNum,
+                           pRegulatoryDomain->maxDFS_channelNum));
+        pParam->content.DFS_ChannelRange.minDFS_channelNum = pRegulatoryDomain->minDFS_channelNum;
+        pParam->content.DFS_ChannelRange.maxDFS_channelNum = pRegulatoryDomain->maxDFS_channelNum;
+
+        break;
+
+       case REGULATORY_DOMAIN_IS_COUNTRY_FOUND:
+
+               pParam->content.bIsCountryFound = 
+                        regulatoryDomain_isCountryFound(pRegulatoryDomain, pParam->content.eRadioBand);
+               
+               break;
+
+       default:
+               WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+/************************************************************************
+ *                        regulatoryDomain_destroy                                             *
+ ************************************************************************
+DESCRIPTION: regulatoryDomain module destroy function, called by the config mgr in the destroy phase 
+                               performs the following:
+                               -       Free all memory allocated by the module
+                                                                                                   
+INPUT:      hRegulatoryDomain  -       regulatoryDomain handle.                
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS regulatoryDomain_destroy(TI_HANDLE hRegulatoryDomain)
+{
+       regulatoryDomain_t      *pRegulatoryDomain = (regulatoryDomain_t *)hRegulatoryDomain;
+
+       if (pRegulatoryDomain == NULL)
+               return OK;
+
+    utils_nullMemoryFree(pRegulatoryDomain->hOs, pRegulatoryDomain, sizeof(regulatoryDomain_t));
+
+       return OK;
+}
+
+/************************************************************************
+ *                        regulatoryDomain_isCountryFound                                              *
+ ************************************************************************
+DESCRIPTION: This function returns the validity of Country according to band
+                                                                                                   
+INPUT:      hRegulatoryDomain  -       regulatoryDomain handle.   
+            radioBand           - the desired band     
+
+
+OUTPUT:                
+
+RETURN:     TRUE - if country IE was found according to the band.
+            FALSE - otherwise.
+
+************************************************************************/
+BOOL regulatoryDomain_isCountryFound(regulatoryDomain_t  *pRegulatoryDomain, radioBand_e radioBand)
+{
+
+    if(radioBand == RADIO_BAND_2_4_GHZ)
+    {
+            return pRegulatoryDomain->country_2_4_WasFound;
+    }
+    else
+    {
+        return pRegulatoryDomain->country_5_WasFound;
+    }
+
+}
+
+/***********************************************************************
+ *                       setSupportedChannelsAccording2CountryIe                                                                       
+ ***********************************************************************
+DESCRIPTION:   Called when beacon/Probe Response with Country IE
+                               is found.
+                               The function sets the local countryIE per band with the CountryIE
+                                that was detected in the last passive scan.
+                                It is assumed that only one Country IE per band is allowed.
+                                If Country is changed when the TNET is loaded, it should
+                                be re-loaded in order to re-config the new Country domain.
+                                                                                                   
+INPUT:      hRegulatoryDomain  -       RegulatoryDomain handle.
+                       pCountry        -       pointer to the detected country IE.
+
+OUTPUT:                
+
+RETURN:     OK - New country code was set (or the same one was already configured)
+            NOK - The new country code could not be set
+
+************************************************************************/
+static TI_STATUS setSupportedChannelsAccording2CountryIe(regulatoryDomain_t *pRegulatoryDomain, country_t* pCountry, BOOL band_2_4)
+{
+       channelCapability_t *pSupportedChannels;
+       UINT8                           channelIndex;
+       UINT8                           tripletChannelIndex, tripletChannelCnt;
+       UINT8                           channelStep, numberOfChannels, minChannelNumber, maxChannelNumber;
+
+       
+       if (!pRegulatoryDomain->regulatoryDomainEnabled)
+       {  /* Ignore the Country IE if 802.11d is disabled */
+               return NOK;
+       }
+
+    /* Check if the country code should be reset */
+    regulatoryDomain_checkCountryCodeExpiry(pRegulatoryDomain);
+
+       if( band_2_4 == TRUE )
+       {
+               if (pRegulatoryDomain->country_2_4_WasFound)
+               {       /* Do not update new Country IE */
+                       if (os_memoryCompare(pRegulatoryDomain->hOs, (void *)&pCountry->countryIE, 
+                               (void *)&pRegulatoryDomain->country24.countryIE, sizeof(countryIE_t)))
+                       {
+                               WLAN_REPORT_WARNING(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                                       ("setSupportedChannelsAccording2CountryIe different Country, cur=%s, new=%s\n", 
+                                                                       pRegulatoryDomain->country24.countryIE.CountryString, pCountry->countryIE.CountryString));
+               return NOK;
+            }
+            else    /* Same IE - just mark the TS and return OK */
+            {
+                /* Mark the time of the received country IE */                
+                pRegulatoryDomain->uLastCountryReceivedTS = os_timeStampMs(pRegulatoryDomain->hOs);
+                return OK;
+            }
+               }
+               pRegulatoryDomain->country_2_4_WasFound = TRUE;
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+               channelStep = BG_24G_BAND_CHANNEL_HOPS;
+               maxChannelNumber = NUM_OF_CHANNELS_24;
+               minChannelNumber = BG_24G_BAND_MIN_CHANNEL;
+               numberOfChannels = NUM_OF_CHANNELS_24;
+               /* save the country IE */
+               os_memoryCopy(pRegulatoryDomain->hOs, (void*)&pRegulatoryDomain->country24, (void *)pCountry, sizeof(country_t));
+
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                ("Country 2.4 =%c%c%c\n",pRegulatoryDomain->country24.countryIE.CountryString[0],
+                                 pRegulatoryDomain->country24.countryIE.CountryString[1], 
+                                                                pRegulatoryDomain->country24.countryIE.CountryString[2]));
+
+       }
+       else    /* band 5.0 */
+       {
+               if (pRegulatoryDomain->country_5_WasFound)
+               {       /* Do not update new Country IE if the IE is the same*/
+                       if (os_memoryCompare(pRegulatoryDomain->hOs, (void *)&pCountry->countryIE, 
+                               (void *)&pRegulatoryDomain->country5.countryIE, sizeof(countryIE_t)))
+                       {
+                               WLAN_REPORT_WARNING(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                                       ("setSupportedChannelsAccording2CountryIe different Country, cur=%s, new=%s\n", 
+                                                                       pRegulatoryDomain->country5.countryIE.CountryString, pCountry->countryIE.CountryString));
+               return NOK;
+            }
+            else    /* Same IE - just mark the TS and return OK */
+            {
+                /* Mark the time of the received country IE */                
+                pRegulatoryDomain->uLastCountryReceivedTS = os_timeStampMs(pRegulatoryDomain->hOs);
+                return OK;
+            }
+               }
+               pRegulatoryDomain->country_5_WasFound = TRUE;
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+               channelStep = A_5G_BAND_CHANNEL_HOPS;
+               maxChannelNumber = A_5G_BAND_MAX_CHANNEL;
+               minChannelNumber = A_5G_BAND_MIN_CHANNEL;
+               numberOfChannels = A_5G_BAND_NUM_CHANNELS;
+               /* save the country IE */
+               os_memoryCopy(pRegulatoryDomain->hOs, (void*)&pRegulatoryDomain->country5, (void*)pCountry, sizeof(country_t));
+
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                ("Country 5 =%c%c%c\n",pRegulatoryDomain->country5.countryIE.CountryString[0],
+                                 pRegulatoryDomain->country5.countryIE.CountryString[1], 
+                                                                pRegulatoryDomain->country5.countryIE.CountryString[2]));
+       }
+
+    /*
+     * New Country IE was saved. Now - update the last received TS and ScanControlTable
+     */
+
+    /* Mark the time of the received country IE */                
+    pRegulatoryDomain->uLastCountryReceivedTS = os_timeStampMs(pRegulatoryDomain->hOs);
+
+       /* First clear the validity of all channels 
+               Overwrite the ScanControlTable */
+       for (channelIndex=0; channelIndex<numberOfChannels; channelIndex++)
+       {
+               pSupportedChannels[channelIndex].channelValidityActive = FALSE;
+               pSupportedChannels[channelIndex].channelValidityPassive = FALSE;
+               pSupportedChannels[channelIndex].bChanneInCountryIe = FALSE;
+               pSupportedChannels[channelIndex].uMaxTxPowerDomain = MIN_TX_POWER;      
+       }
+    
+       tripletChannelCnt = (pCountry->len - COUNTRY_STRING_LEN) / 3;
+       /* set validity of the channels according to the band (2.4 or 5) */
+       for( tripletChannelIndex = 0; tripletChannelIndex < tripletChannelCnt ; tripletChannelIndex++)
+       {
+               UINT8   firstChannelNumInTriplet;
+               
+               firstChannelNumInTriplet = pCountry->countryIE.tripletChannels[tripletChannelIndex].firstChannelNumber;
+               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                ("firstChannelNumInTriplet=%d,channelStep=%d\n", firstChannelNumInTriplet, channelStep));
+               for (channelIndex=0; channelIndex<pCountry->countryIE.tripletChannels[tripletChannelIndex].numberOfChannels; channelIndex++)
+               {
+                       UINT16  channelNumber;
+
+                       channelNumber = firstChannelNumInTriplet+(channelIndex*channelStep);
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                       ("setSupportedChannelsAccording2CountryIe of channel=%d\n", channelNumber));
+                       
+                       if ((channelNumber <= maxChannelNumber)&& (channelNumber !=INVALID_CHANNEL_165))
+                       {
+                               UINT8   channelIndex4Band;
+
+                               channelIndex4Band = (channelNumber-minChannelNumber);
+                               pSupportedChannels[channelIndex4Band].bChanneInCountryIe = TRUE;
+                               pSupportedChannels[channelIndex4Band].channelValidityPassive = TRUE;
+                               pSupportedChannels[channelIndex4Band].channelValidityActive = TRUE;
+
+                               /* set the TX power in DBM/10 units */
+                           pSupportedChannels[channelIndex4Band].uMaxTxPowerDomain = 
+                                       DBM2DBMDIV10(pCountry->countryIE.tripletChannels[tripletChannelIndex].maxTxPowerLevel);
+
+                               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                        ("channel = %d uMaxTxPowerDomain=%d\n", 
+                                                                               channelNumber, pSupportedChannels[channelIndex4Band].uMaxTxPowerDomain));
+                       }
+               }
+    }
+
+       return OK;
+}
+
+
+/***********************************************************************
+ *                        regulatoryDomain_isChannelSupprted                                                                   
+ ***********************************************************************
+DESCRIPTION:   The function checks if the input channel is supported.
+                                                                                                   
+INPUT:      pRegulatoryDomain  -       RegulatoryDomain pointer.
+                       channel                         -       Channel number.
+                       
+
+OUTPUT:                
+
+RETURN:     OK if channel is supported, NOK otherwise.
+
+************************************************************************/
+static BOOL regulatoryDomain_isChannelSupprted(regulatoryDomain_t *pRegulatoryDomain, UINT8 channel)
+{
+       UINT8                           channelIndex;
+       channelCapability_t *pSupportedChannels;
+
+       if (pRegulatoryDomain==NULL)
+       {
+               return FALSE;
+       }
+
+       if ((channel<BG_24G_BAND_MIN_CHANNEL) || (channel>A_5G_BAND_MAX_CHANNEL))
+       {
+               return FALSE;
+       }
+       if (channel>=A_5G_BAND_MIN_CHANNEL)
+       {
+               channelIndex = (channel-A_5G_BAND_MIN_CHANNEL);
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+       }
+       else
+       {
+               channelIndex = (channel-BG_24G_BAND_MIN_CHANNEL);
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+       }
+       if (pRegulatoryDomain->spectrumManagementEnabled 
+               && (channel >= pRegulatoryDomain->minDFS_channelNum) 
+        && (channel <= pRegulatoryDomain->maxDFS_channelNum)
+               && ((os_timeStampMs(pRegulatoryDomain->hOs)-pSupportedChannels[channelIndex].timestamp) >=CHANNEL_VALIDITY_TS_THRESHOLD ))
+       {       /* If 802.11h is enabled, a DFS channel is valid only for 10 sec
+                       from the last Beacon/ProbeResponse */
+        pSupportedChannels[channelIndex].channelValidityActive = FALSE;
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                ("regulatoryDomain_isChannelSupprted(): CHANNEL_VALIDITY_TS_THRESHOLD !! Disable channel no %d, DFS channel\n", channel ));
+
+       }
+
+       return (pSupportedChannels[channelIndex].channelValidityActive);
+
+}
+
+/************************************************************************
+ *                        regulatoryDomain_setChannelValidity                  *
+ ************************************************************************/
+/*
+*
+*
+* \b Description: 
+*
+* This function sets a channel as invalid or valid in the internal Regulatory Domain
+ * database. 
+*
+* \b ARGS:
+*
+*  I   - pData - pointer to the regDoamin SM context  \n
+*  I   - channelNum - the invalid/valid channel number
+*  I   - channelValidity - TRUE if channel is valid, FALSE channel is invalid
+*
+* \b RETURNS:
+*
+*  None.
+*
+* 
+*************************************************************************/
+static void regulatoryDomain_setChannelValidity(regulatoryDomain_t *pRegulatoryDomain, 
+                                                                                               UINT16 channelNum, BOOL channelValidity)
+{
+       channelCapability_t             *pSupportedChannels;
+       UINT8                                   channelIndex;
+
+
+       if (pRegulatoryDomain == NULL)
+       {
+               return;
+       }
+       if ((channelNum==0 ) || (channelNum>A_5G_BAND_MAX_CHANNEL))
+       {
+               WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                               ("regulatoryDomain_setChannelValidity, invalid channelNum=%d \n", channelNum));
+               return;
+       }
+       
+       if (channelNum <= NUM_OF_CHANNELS_24)
+       {
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+               channelIndex = (channelNum-BG_24G_BAND_MIN_CHANNEL);
+       }
+       else 
+       {
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+               channelIndex = (channelNum - A_5G_BAND_MIN_CHANNEL);
+       }
+       
+       if(channelValidity == TRUE)
+               if((pSupportedChannels[channelIndex].bChanneInCountryIe == FALSE) && (pRegulatoryDomain->regulatoryDomainEnabled == TRUE))
+               {
+                       WLAN_REPORT_WARNING(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                                       ("regulatoryDomain_setChannelValidity: channelNum = %d isn't supported at the Country. wll not set to active!\n", channelNum));
+                       return;
+               }
+
+    WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                       ("regulatoryDomain_setChannelValidity: channelNum=%d, validity=%d \n", channelNum, channelValidity));
+
+
+       pSupportedChannels[channelIndex].channelValidityActive = channelValidity;
+}
+
+
+/************************************************************************
+ *      setSupportedChannelsAccording2ScanControlTable                                         *
+ ************************************************************************/
+/**
+*
+*
+* \b Description: 
+*
+* This function is called in config and sets the supported channels according to
+* the scan control table read from registry and reg domain read from the chip.
+*
+* \b ARGS:
+*
+*  I   - pRegulatoryDomain - pointer to the regDoamin SM context  \n
+*
+* \b RETURNS:
+*
+*  None.
+*
+* 
+*************************************************************************/
+static void setSupportedChannelsAccording2ScanControlTable(regulatoryDomain_t  *pRegulatoryDomain)
+{
+       UINT8   channelIndex;
+       UINT8   channelMask;
+
+       if (pRegulatoryDomain==NULL)
+       {
+               return;
+       }
+
+       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                       ("setSupportedChannelsAccording2ScanControlTable \n"));
+
+       for (channelIndex=0; channelIndex<NUM_OF_CHANNELS_24; channelIndex++)
+       {
+               channelMask = pRegulatoryDomain->scanControlTable.ScanControlTable24.tableString[channelIndex];
+               pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].bChanneInCountryIe = FALSE;
+
+               /* Calculate Domain Tx Power - channelMask units are in Dbm. */
+               pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].uMaxTxPowerDomain = 
+                                               DBM2DBMDIV10(channelMask & MASK_TX_POWER);
+               if (channelMask & (MASK_ACTIVE_ALLOWED | MASK_FREQ_ALLOWED))
+               {       /* The channel is allowed for Active & Passive scans */
+                       if (pRegulatoryDomain->regulatoryDomainEnabled)
+                       {       /* All channels should be invalid for Active scan */
+                               pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityActive = FALSE;
+                               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                       ("channelIndex=%d is invalid for Active \n", channelIndex+1));
+                       }
+                       else
+                       {
+                               pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityActive = TRUE;
+                               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                       ("channelIndex=%d is Active valid \n", channelIndex+1));
+                       }
+                       
+               }
+               
+               if (channelMask & MASK_FREQ_ALLOWED)
+               {       /* The channel is allowed for Passive scan */
+                       pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityPassive = TRUE;
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                                       ("channelIndex=%d is Passive valid \n", channelIndex+1));
+               }
+               else
+               {       /* The channel is not allowed */
+                       pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityPassive = FALSE;
+                       pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityActive = FALSE;
+               }
+       }
+
+       for (channelIndex=A_5G_BAND_MIN_CHANNEL; channelIndex<=A_5G_BAND_MAX_CHANNEL; channelIndex++)
+       {       
+               UINT8   channelIndexInBand5;
+
+               channelIndexInBand5 = (channelIndex-A_5G_BAND_MIN_CHANNEL);
+               channelMask = pRegulatoryDomain->scanControlTable.ScanControlTable5.tableString[channelIndexInBand5];
+               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                               ("channelIndex=%d, channelIndexInBand5=%d channelMask=%d\n", channelIndex, channelIndexInBand5, channelMask));
+
+               /* Calculate Domain Tx Power - channelMask units are in Dbm. */
+               pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].uMaxTxPowerDomain = 
+                       DBM2DBMDIV10(channelMask & MASK_TX_POWER);
+
+               pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].bChanneInCountryIe = FALSE;
+               if (channelMask & (MASK_ACTIVE_ALLOWED | MASK_FREQ_ALLOWED))
+               {        /* The channel is allowed for Active & Passive scans */
+                       if (pRegulatoryDomain->regulatoryDomainEnabled)
+                       {       /* All channels should be invalid for Active scan */
+                               pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].channelValidityActive = FALSE;
+                               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                       ("channelIndex=%d is invalid for Active \n", channelIndex));
+                       }
+                       else
+                       {
+                               pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].channelValidityActive = TRUE;
+                               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                 ("channelIndex=%d, channelIndexInBand5=%d, is Active valid \n", channelIndex, channelIndexInBand5));
+                       }               
+               }
+               
+               if (channelMask & MASK_FREQ_ALLOWED)
+               {       /* The channel is allowed for Passive scan */
+                       pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].channelValidityPassive = TRUE;
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                          ("channelIndex=%d, channelIndexInBand5=%d, is Passive valid \n", channelIndex, channelIndexInBand5));
+               }
+               else
+               {       /* The channel is not allowed */
+                       pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].channelValidityPassive = FALSE;
+                       pRegulatoryDomain->supportedChannels_band_5[channelIndexInBand5].channelValidityActive = FALSE;
+               }
+
+       }
+}
+
+
+/***********************************************************************
+*                        regulatoryDomain_getChannelCapability                                                                 
+***********************************************************************
+DESCRIPTION:   This function returns the channel capability information
+
+INPUT:      pRegulatoryDomain          -       RegulatoryDomain pointer.
+                       channelCapabilityReq    -       Channels parameters
+
+
+OUTPUT:                channelCapabilityRet    -   Channel capability information
+
+RETURN:     OK if information was retrieved, NOK otherwise.
+
+************************************************************************/
+static TI_STATUS regulatoryDomain_getChannelCapability(regulatoryDomain_t *pRegulatoryDomain, 
+                                                                                                          channelCapabilityReq_t channelCapabilityReq, 
+                                                                                                          channelCapabilityRet_t *channelCapabilityRet)
+{
+       channelCapability_t             *pSupportedChannels;
+       UINT8                                   channelIndex;
+       BOOL                                    bCountryWasFound, bServingChannel;
+       paramInfo_t                             tParamInfo;
+
+       if ((pRegulatoryDomain == NULL) || (channelCapabilityRet == NULL))
+       {
+               return NOK;
+       }
+       
+       channelCapabilityRet->channelValidity = FALSE;
+       channelCapabilityRet->maxTxPowerDbm = 0;
+       if ((channelCapabilityReq.channelNum==0 ) || (channelCapabilityReq.channelNum>A_5G_BAND_MAX_CHANNEL))
+       {
+               WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                               ("regulatoryDomain_getChannelCapability, invalid channelNum=%d \n", channelCapabilityReq.channelNum));
+               return NOK;
+       }
+       
+       if (channelCapabilityReq.band==RADIO_BAND_2_4_GHZ)
+       {
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+               channelIndex = (channelCapabilityReq.channelNum-BG_24G_BAND_MIN_CHANNEL);
+               bCountryWasFound = pRegulatoryDomain->country_2_4_WasFound;
+       }
+       else if (channelCapabilityReq.band==RADIO_BAND_5_0_GHZ)
+       {
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+               channelIndex = (channelCapabilityReq.channelNum - A_5G_BAND_MIN_CHANNEL);
+               bCountryWasFound = pRegulatoryDomain->country_5_WasFound;
+       }
+       else
+       {
+               WLAN_REPORT_ERROR(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                               ("regulatoryDomain_getChannelCapability, invalid band=%d \n", channelCapabilityReq.band));
+               return NOK;
+       }
+
+
+       /* 
+        * Set channelValidity according to ScanTable and whether 11d is enabled 
+        */
+       if (channelCapabilityReq.scanOption == ACTIVE_SCANNING)
+       {
+               if ( ( pRegulatoryDomain->regulatoryDomainEnabled ) && ( !bCountryWasFound ) )
+               {       /* 11d enabled and no country IE was found - set channel to invalid */
+                       channelCapabilityRet->channelValidity = FALSE;
+               }
+               else
+               {
+        channelCapabilityRet->channelValidity = pSupportedChannels[channelIndex].channelValidityActive;
+                       /*
+                        * Set Maximum Tx power for the channel - only for active scanning
+                        */ 
+
+                       /* Get current channel and check if we are using the same one */
+                       tParamInfo.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+                       siteMgr_getParam(pRegulatoryDomain->hSiteMgr, &tParamInfo);
+
+                       bServingChannel = ( tParamInfo.content.siteMgrCurrentChannel == channelCapabilityReq.channelNum ?
+                                                               TRUE : FALSE );
+
+                       channelCapabilityRet->maxTxPowerDbm = regulatoryDomain_getMaxPowerAllowed(pRegulatoryDomain, 
+                               channelCapabilityReq.channelNum, 
+                               channelCapabilityReq.band, 
+                               bServingChannel);
+               }
+       }
+       else    /* Passive scanning */
+       {
+               if ( ( pRegulatoryDomain->regulatoryDomainEnabled ) && ( !bCountryWasFound ) )
+               {       /* 11d enabled and no country IE was found - set channel to valid for passive scan */
+                       channelCapabilityRet->channelValidity = TRUE;
+               }
+       else
+       {
+               channelCapabilityRet->channelValidity = pSupportedChannels[channelIndex].channelValidityPassive;
+       }
+       }
+       
+       if (pRegulatoryDomain->spectrumManagementEnabled 
+               && (channelCapabilityReq.scanOption == ACTIVE_SCANNING)
+        && (channelCapabilityReq.channelNum >= pRegulatoryDomain->minDFS_channelNum) 
+        && (channelCapabilityReq.channelNum <= pRegulatoryDomain->maxDFS_channelNum)
+               && ((os_timeStampMs(pRegulatoryDomain->hOs)-pSupportedChannels[channelIndex].timestamp) >=CHANNEL_VALIDITY_TS_THRESHOLD ))
+       {       /* If 802.11h is enabled, a DFS channel is valid only for 10 sec
+                       from the last Beacon/ProbeResponse */
+        pSupportedChannels[channelIndex].channelValidityActive = FALSE;
+        channelCapabilityRet->channelValidity = FALSE;
+        WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                ("regulatoryDomain_getChannelCapability(): CHANNEL_VALIDITY_TS_THRESHOLD !!! Disable channel no %d, DFS channel\n", channelCapabilityReq.channelNum  ));
+    }
+
+       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                       (" Channel num= %d, scan option=%d validity = %d, TX power = %d \n", 
+                                       channelCapabilityReq.channelNum, 
+                                       channelCapabilityReq.scanOption,
+                                       channelCapabilityRet->channelValidity,
+                                       channelCapabilityRet->maxTxPowerDbm));
+       return OK;
+
+}
+
+
+static void regulatoryDomain_updateChannelsTs(regulatoryDomain_t *pRegulatoryDomain, UINT8 channel)
+{
+       UINT8                           channelIndex;
+       channelCapability_t *pSupportedChannels;
+
+       if (pRegulatoryDomain==NULL)
+       {
+               return;
+       }
+
+       if ((channel<BG_24G_BAND_MIN_CHANNEL) || (channel>A_5G_BAND_MAX_CHANNEL))
+       {
+               return;
+       }
+
+       if (channel>=A_5G_BAND_MIN_CHANNEL)
+       {
+               channelIndex = (channel-A_5G_BAND_MIN_CHANNEL);
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+       }
+       else
+       {
+               channelIndex = (channel-BG_24G_BAND_MIN_CHANNEL);
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+       }
+       
+       if((pSupportedChannels[channelIndex].bChanneInCountryIe == FALSE) && (pRegulatoryDomain->regulatoryDomainEnabled == TRUE))
+       {
+               WLAN_REPORT_WARNING(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                                               ("regulatoryDomain_updateChannelsTs: channelNum = %d isn't supported at the Country. wll not set to active!\n", channel));
+               return;
+       }
+
+       pSupportedChannels[channelIndex].timestamp = os_timeStampMs(pRegulatoryDomain->hOs);
+       pSupportedChannels[channelIndex].channelValidityActive = TRUE;
+
+}
+
+/***********************************************************************
+ *              regulatoryDomain_updateCurrTxPower                                                             
+ ***********************************************************************
+DESCRIPTION: Called when new Tx power should be calculated and configured.
+                        Check if we are already joined to BSS/IBSS, calculate 
+                        new Tx power and configure it to Hal.
+                               
+INPUT:         pRegulatoryDomain       - regulatoryDomain pointer.
+                       
+RETURN:     OK - New value was configured to Hal, NOK - Can't configure value
+                       TX_POWER_SET_SAME_VALUE - Same value was already configured.
+
+************************************************************************/
+static TI_STATUS regulatoryDomain_updateCurrTxPower(regulatoryDomain_t *pRegulatoryDomain)
+{
+       UINT8                           uCurrChannel, uNewTxPower;
+       whalParamInfo_t         whalParam;
+       paramInfo_t                     tParamInfo;
+       TI_STATUS                       eStatus;
+
+       /* Get the current channel, and update HAL with the changed */
+       tParamInfo.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+       eStatus = siteMgr_getParam(pRegulatoryDomain->hSiteMgr, &tParamInfo);
+
+       if ( eStatus != OK )
+       {
+               /* We are not joined yet - no meaning for new Tx power */
+               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                       ("regulatoryDomain_updateCurrTxPower, No site selected yet\n"));
+
+               return NOK;
+       }
+       /* Save current channel */
+       uCurrChannel = tParamInfo.content.siteMgrCurrentChannel;
+
+       /* Get the current channel, and update HAL with the changed */
+       tParamInfo.paramType =  SITE_MGR_RADIO_BAND_PARAM;
+       siteMgr_getParam(pRegulatoryDomain->hSiteMgr, &tParamInfo);
+
+       /* Calculate maximum Tx power for the serving channel */
+       uNewTxPower = regulatoryDomain_getMaxPowerAllowed(pRegulatoryDomain, uCurrChannel, 
+                                                                                                         tParamInfo.content.siteMgrRadioBand, TRUE);
+       /* Verify that the Temporary TX Power Control doesn't violate the TX Power Constraint */
+       pRegulatoryDomain->uTemporaryTxPower = MIN(pRegulatoryDomain->uDesiredTemporaryTxPower, uNewTxPower);
+
+       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG, 
+                                       ("regulatoryDomain_updateCurrTxPower, Write to Hal = %d \n", uNewTxPower));
+
+    whalParam.paramType = HAL_CTRL_TX_POWER_PARAM;
+       whalParam.content.halCtrlTxPowerDbm = uNewTxPower;
+       return whalCtrl_SetParam(pRegulatoryDomain->hHalCtrl, &whalParam);
+}
+
+/***********************************************************************
+ *                        regulatoryDomain_checkCountryCodeExpiry                                                                      
+ ***********************************************************************
+DESCRIPTION: Check & Reset the country code that was detected earlier.
+                Reseting country code will be done when the STA was not connected for 
+                a certain amount of time, and no country code was received in that period (from the same country).
+                This scenario might indicate that the STA has moved to a different country.
+                                                                                                   
+INPUT:      pRegulatoryDomain  -       Regulatory Domain handle.
+
+OUTPUT:                updating country code if necessary.
+
+RETURN:     
+
+************************************************************************/
+void regulatoryDomain_checkCountryCodeExpiry(regulatoryDomain_t *pRegulatoryDomain)
+{
+    paramInfo_t param;
+    TI_STATUS   connStatus;
+    UINT32      uCurrentTS = os_timeStampMs(pRegulatoryDomain->hOs);
+
+    if ((pRegulatoryDomain->country_2_4_WasFound) || (pRegulatoryDomain->country_5_WasFound))
+    {
+        /* Get connection status */
+        param.paramType = SITE_MGR_CURRENT_SSID_PARAM;
+        connStatus      = siteMgr_getParam(pRegulatoryDomain->hSiteMgr, &param);    
+
+         /* If (uTimeOutToResetCountryMs has elapsed && we are not connected)
+                 delete the last country code received */
+        if (((uCurrentTS - pRegulatoryDomain->uLastCountryReceivedTS) > pRegulatoryDomain->uTimeOutToResetCountryMs) &&
+            (connStatus == NO_SITE_SELECTED_YET))
+        {
+            WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                 ("%s, Reset country code after %d Ms\n",
+                 __FUNCTION__,(uCurrentTS - pRegulatoryDomain->uLastCountryReceivedTS)));
+
+            /* Reset country codes */
+            pRegulatoryDomain->country_2_4_WasFound = FALSE;
+            pRegulatoryDomain->country_5_WasFound = FALSE;
+            
+            /* Restore default values of the scan control table */
+            setSupportedChannelsAccording2ScanControlTable(pRegulatoryDomain); 
+        } 
+    }
+}
+
+/***********************************************************************
+*              regulatoryDomain_getMaxPowerAllowed                                                             
+***********************************************************************
+DESCRIPTION: Get the maximum tx power allowed for the given channel.
+                               The final value is constructed by:
+                               1) User max value
+                               2) Domain restriction - 11d country code IE
+                               3) 11h power constraint - only on serving channel
+                               4) EXC TPC - only on serving channel
+
+RETURN:     Max power in Dbm/10 for the given channel
+
+************************************************************************/
+static UINT8 regulatoryDomain_getMaxPowerAllowed(regulatoryDomain_t    *pRegulatoryDomain,
+                                                                                                UINT8                          uChannel,
+                                                                                                radioBand_e            eBand,
+                                                                                                BOOL                           bServingChannel)
+{
+       channelCapability_t     *pSupportedChannels;
+       UINT8                            uChannelIndex, uTxPower;
+
+       if( eBand == RADIO_BAND_2_4_GHZ)
+       {
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+               uChannelIndex = uChannel - BG_24G_BAND_MIN_CHANNEL;
+       }
+       else
+       {
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+               uChannelIndex = uChannel - A_5G_BAND_MIN_CHANNEL;
+       }
+
+       /* We'll start with the "Domain restriction - 11d country code IE" */
+       uTxPower = pSupportedChannels[uChannelIndex].uMaxTxPowerDomain;
+
+       if ( bServingChannel)
+       {
+               if (pRegulatoryDomain->uPowerConstraint < uTxPower)
+               {
+                       /* When 802.11h is disabled, uPowerConstraint is 0 anyway */
+                       uTxPower -= pRegulatoryDomain->uPowerConstraint;
+               }
+        
+        /* Take EXC limitation too */
+        uTxPower = MIN(uTxPower, pRegulatoryDomain->uExternTxPowerPreferred);
+
+       }
+
+       /* Now make sure we are not exceeding the user maximum */
+       uTxPower = MIN(uTxPower, pRegulatoryDomain->uUserMaxTxPower);
+
+       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+               ("%s uChannel = %d bServingChannel = %d uTxPower = %d \n", 
+               __FUNCTION__, uChannel, bServingChannel, uTxPower));
+
+       return uTxPower;
+}
+
+
+static void regulatoryDomain_buildDefaultListOfChannelsPerBand(regulatoryDomain_t *pRegulatoryDomain, radioBand_e band, UINT8 *listSize)
+{
+       UINT8                           channelIndex;
+       UINT8                           numberOfChannels, minChannelNumber;
+       channelCapability_t     *pSupportedChannels;
+       UINT8                           maxSupportedChannels=0;
+
+       if ( (pRegulatoryDomain==NULL) || (listSize==NULL))
+       {
+               return;
+       }
+
+       if( band == RADIO_BAND_2_4_GHZ)
+       {
+               minChannelNumber = BG_24G_BAND_MIN_CHANNEL;
+               numberOfChannels = NUM_OF_CHANNELS_24;
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_2_4;
+       }
+       else
+       {
+               minChannelNumber = A_5G_BAND_MIN_CHANNEL;
+               numberOfChannels = A_5G_BAND_NUM_CHANNELS;
+               pSupportedChannels = pRegulatoryDomain->supportedChannels_band_5;
+       }
+
+
+       for (channelIndex=0; channelIndex<numberOfChannels; channelIndex++)
+       {
+               if (pSupportedChannels[channelIndex].channelValidityPassive)
+               {
+                       pRegulatoryDomain->pDefaultChannels[maxSupportedChannels] = channelIndex+minChannelNumber;
+                       WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                                                                       ("Channel num %d is supported \n", pRegulatoryDomain->pDefaultChannels[maxSupportedChannels]));
+                       maxSupportedChannels++;
+               }
+       }
+       *listSize = maxSupportedChannels;
+    
+}
+
+/***********************************************************************
+*              regulatoryDomain_getPowerLevelTableCB                                                           
+***********************************************************************
+DESCRIPTION: CB for retrieving power level table from FW (NVS).
+                        The table is made of 4 power levels and 5 bands/sub-bands. For
+                        each power level there's a maximum value of Dbm to be used.
+
+RETURN:     void
+
+************************************************************************/
+static void regulatoryDomain_getPowerLevelTableCB( TI_HANDLE hRegulatoryDomain, TI_STATUS status, 
+                                                                                                 UINT8* CB_buf )
+{
+       regulatoryDomain_t  *pRegulatoryDomain = (regulatoryDomain_t *)hRegulatoryDomain;
+       UINT8   i;
+
+       /* Calculate Min and Max values of the table */
+       pRegulatoryDomain->uMinPowerDbm = MAX_TX_POWER;
+       pRegulatoryDomain->uMaxPowerDbm = MIN_TX_POWER; 
+       for ( i = 0 ; i < NUM_SUB_BANDS_FOR_POWER_TABLE ; i++ )
+       {
+               WLAN_REPORT_INFORMATION(pRegulatoryDomain->hReport, REGULATORY_DOMAIN_MODULE_LOG,
+                       ("PowerTable sub-band %i : %d %d %d %d\n", i,  
+                       pRegulatoryDomain->tPowerLevelTableInterrogate.tTable.uDbm[i][0],
+                       pRegulatoryDomain->tPowerLevelTableInterrogate.tTable.uDbm[i][1],
+                       pRegulatoryDomain->tPowerLevelTableInterrogate.tTable.uDbm[i][2],
+                       pRegulatoryDomain->tPowerLevelTableInterrogate.tTable.uDbm[i][3]));
+
+               pRegulatoryDomain->uMinPowerDbm = MIN(pRegulatoryDomain->uMinPowerDbm, 
+                                                                                         pRegulatoryDomain->tPowerLevelTableInterrogate.tTable.uDbm[i][MIN_POWER_LEVEL]);
+               pRegulatoryDomain->uMaxPowerDbm = MAX(pRegulatoryDomain->uMaxPowerDbm, 
+                       pRegulatoryDomain->tPowerLevelTableInterrogate.tTable.uDbm[i][MAX_POWER_LEVEL]);
+
+       }
+}
+
+/* for debug */
+void regDomainPrintValidTables(TI_HANDLE hRegulatoryDomain)
+{
+       regulatoryDomain_t  *pRegulatoryDomain = (regulatoryDomain_t *)hRegulatoryDomain;
+       UINT16 channelIndex;
+
+       for (channelIndex=0; channelIndex<NUM_OF_CHANNELS_24; channelIndex++)
+       {
+               if (pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityPassive)
+                       WLAN_OS_REPORT(("channel num =%d is valid for passive \n", channelIndex+1));
+               if (pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].channelValidityActive)
+               {
+                       WLAN_OS_REPORT(("channel =%d is valid for active TX power=%d\n", 
+                               channelIndex+1, pRegulatoryDomain->supportedChannels_band_2_4[channelIndex].uMaxTxPowerDomain));
+               }
+       }
+
+       for (channelIndex=0; channelIndex<A_5G_BAND_NUM_CHANNELS; channelIndex++)
+       {
+               UINT8   channelNum;
+               channelNum = channelIndex+A_5G_BAND_MIN_CHANNEL;
+               if (pRegulatoryDomain->supportedChannels_band_5[channelIndex].channelValidityPassive)
+                       WLAN_OS_REPORT(("channel =%d is valid for passive \n", channelNum));
+               if (pRegulatoryDomain->supportedChannels_band_5[channelIndex].channelValidityActive)
+               {
+                       WLAN_OS_REPORT(("channel =%d is valid for active TX power=%d\n", 
+                               channelNum,pRegulatoryDomain->supportedChannels_band_5[channelIndex].uMaxTxPowerDomain));
+               }
+               }
+
+       WLAN_OS_REPORT(("11h PowerConstraint = %d, EXC TPC = %d, User  = %d\n", 
+               pRegulatoryDomain->uPowerConstraint, pRegulatoryDomain->uExternTxPowerPreferred,
+               pRegulatoryDomain->uUserMaxTxPower));
+
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.h b/sta_dk_4_0_4_32/common/src/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.h
new file mode 100644 (file)
index 0000000..f2ce2d7
--- /dev/null
@@ -0,0 +1,145 @@
+/** \file regulatoryDomain.h
+ *  \brief regulatoryDomain module internal header file
+ *
+ *  \see regulatoryDomain.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   regulatoryDomain.h                                          */
+/*    PURPOSE:  regulatoryDomain module internal header file                */
+/*                                                                          */
+/***************************************************************************/
+#ifndef __REGULATORY_DOMAIN_H__
+#define __REGULATORY_DOMAIN_H__
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "802_11Defs.h"
+#include "whalCtrl_api.h"
+#include "regulatoryDomainApi.h"
+
+#define BG_24G_BAND_CHANNEL_HOPS    1
+#define BG_24G_BAND_MIN_CHANNEL     1
+
+#define A_5G_BAND_CHANNEL_HOPS      4
+
+#define A_5G_BAND_MIN_MIDDLE_BAND_DFS_CHANNEL   52
+#define A_5G_BAND_MAX_MIDDLE_BAND_DFS_CHANNEL   64
+#define A_5G_BAND_MIN_UPPER_BAND_DFS_CHANNEL    100
+#define A_5G_BAND_MAX_UPPER_BAND_DFS_CHANNEL    140
+
+typedef struct
+{
+    BOOL    channelValidityPassive; /*TRUE-valid, FALSE-invalid */
+    BOOL    channelValidityActive; /*TRUE-valid, FALSE-invalid */
+    BOOL    bChanneInCountryIe;
+                                                                        
+    UINT8   uMaxTxPowerDomain;          /* 
+                                                                         * Holds ONLY the default limitation (Application) 
+                                                                         * or according to 11d country code IE 
+                                                                         * Updated on init phase or upon receiving new country code IE                           
+                                                                         */ 
+    UINT32  timestamp;
+}   channelCapability_t;
+
+
+typedef struct 
+{
+    /* Variables read from registry */
+    /********************************/   
+    /* 802.11h enabled or disabled */
+    BOOL                            spectrumManagementEnabled;
+    /* 802.11d enabled or disabled */
+    BOOL                            regulatoryDomainEnabled;
+    /* scan availability channels from registry */
+    scanControlTable_t              scanControlTable;
+    /* Desired Temp Tx Power */
+    UINT8                           uDesiredTemporaryTxPower; 
+       /* Actual Temp Tx Power */
+    UINT8                           uTemporaryTxPower; 
+
+    /* User configuration for max Tx power */
+    UINT8                           uUserMaxTxPower; 
+    /* The TX power level translation from NVS */
+    powerLevelTableInterrogate_t    tPowerLevelTableInterrogate; 
+
+       /* Min and Max values of Dbm retrieved from power level table and used for 11h assoc request */
+       UINT8                                                   uMinPowerDbm;
+       UINT8                                                   uMaxPowerDbm;
+      /* Internal reg domain variables */
+    /********************************/
+
+    /* Power Constraint IE 32 in DBM/10, valid only when 802.11h is enabled  */
+    UINT8                           uPowerConstraint;    
+    /* External TX Power Control in DBM/10, valid only when 802.11h is disabled */
+    UINT8                           uExternTxPowerPreferred;       
+
+    UINT8                           minDFS_channelNum;
+    UINT8                           maxDFS_channelNum;
+
+    country_t                       country24;   /* Detected County IE for 2.4 Ghz */
+    country_t                       country5;    /* Detected County IE for 5 Ghz */
+    BOOL                            country_2_4_WasFound;
+    BOOL                            country_5_WasFound;
+    UINT32                          uLastCountryReceivedTS;
+    UINT32                          uTimeOutToResetCountryMs;
+    channelCapability_t             supportedChannels_band_5[A_5G_BAND_NUM_CHANNELS];
+    channelCapability_t             supportedChannels_band_2_4[NUM_OF_CHANNELS_24];
+
+    /* set the size of the array to max of B_G & A, so that the array doesnt overflow. +3 for word alignment */
+    UINT8                           pDefaultChannels[A_5G_BAND_NUM_CHANNELS+3];
+    /* merge 4.02/4.03 evaluate the +3 above and adjust or hSiteMgr and below will be 
+       will be unaligned accesses.  Expect it might now be +1 since 2 UINT8 variable 
+       have been added in 4.03 (max and min DFS_channelNum above) */
+
+    
+    /* Handles to other objects */
+    TI_HANDLE                       hSiteMgr;
+    TI_HANDLE                       hHalCtrl;
+    TI_HANDLE                       hSwitchChannel;
+    TI_HANDLE                       hReport;
+    TI_HANDLE                       hOs;
+
+
+} regulatoryDomain_t;
+
+
+
+
+
+#endif /* __REGULATORY_DOMAIN_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/core/NetworkCtrl/inc/regulatoryDomainApi.h b/sta_dk_4_0_4_32/common/src/core/NetworkCtrl/inc/regulatoryDomainApi.h
new file mode 100644 (file)
index 0000000..8203b8c
--- /dev/null
@@ -0,0 +1,74 @@
+/** \file regulatoryDomainApi.h
+ *  \brief regulatoryDomain module interface header file
+ *
+ *  \see regulatoryDomain.c & regulatoryDomain.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       regulatoryDomainApi.h                                                                           */
+/*    PURPOSE: regulatoryDomain module interface header file                           */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __REGULATORY_DOMAIN_API_H__
+#define __REGULATORY_DOMAIN_API_H__
+
+
+#include "802_11Defs.h"
+#include "paramOut.h"
+
+TI_HANDLE regulatoryDomain_create(TI_HANDLE hOs);
+
+TI_STATUS regulatoryDomain_config(TI_HANDLE    hRegulatoryDomain,
+                                                               TI_HANDLE               hSiteMgr,
+                                                               TI_HANDLE               hHalCtrl,
+                                                               TI_HANDLE               hReport,
+                                                               TI_HANDLE               hOs,
+                                                               TI_HANDLE               hSwitchChannel,
+                                                               regulatoryDomainInitParams_t *pRegulatoryDomainInitParams);
+
+TI_STATUS regulatoryDomain_setParam(TI_HANDLE          hRegulatoryDomain, paramInfo_t  *pParam);
+
+TI_STATUS regulatoryDomain_getParam(TI_HANDLE          hRegulatoryDomain, paramInfo_t  *pParam);
+
+TI_STATUS regulatoryDomain_destroy(TI_HANDLE hRegulatoryDomain);
+
+/* Note: do not add more functions to this API */
+
+#endif /* __REGULATORY_DOMAIN_API_H__*/
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/currBss/currBss.c b/sta_dk_4_0_4_32/common/src/core/currBss/currBss.c
new file mode 100644 (file)
index 0000000..09ba523
--- /dev/null
@@ -0,0 +1,1357 @@
+/** \file currBss.c
+ *  \brief Current BSS info
+ *
+ *  \see currBss.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Current BSS                                                   *
+ *   PURPOSE:                                                               *
+ *   Roaming ability of eSTA is implemented by Roaming Manager Component and 
+ *   described in "Roaming Manager module LLD" document, and by 
+ *   AP Connection module. AP Connection module implemented as two sub-modules.
+ *   The major one is AP Connection, that is responsible for: 
+ *   - providing Roaming Manager with access to other parts of WLAN Driver, 
+ *   - implementing low levels of roaming mechanism.
+ *   Current BSS sub-module takes care of:
+ *   - maintaining database of current AP info,
+ *   - providing access to database of current AP info.
+ *   The Current BSS represents the BSS we are currently connected to. 
+ *   Among other parameters, it holds the capabilities of the current AP, 
+ *   its ID and its quality.
+ *   When FW indicates 'Out of Sync' event, Current BSS module is responsible
+ *   for awaking the device, sending unicast Probe request, waiting for
+ *   response and - in case FW comes to the conclusion that there was 
+ *   no response - for triggering "Beacon missed" to AP Connection module. 
+ *   In eSTA5.0 FW updates and checks the quality of the connection with
+ *   current AP. Current BSS module is responsible to handle event of type
+ *   'Low RSSI' from FW. Third type of roaming event reported by FW is
+ *   'Consecutive no ack on TX", and it is handled as well by Current
+ *   BSS module.Upon reception of any roaming event from FW, Current BSS
+ *   module is transferring this event to the AP Connection module in case
+ *   of BSS connection, or to SME module in case of IBSS connection.
+ *   When WLAN driver is working in IBSS mode, Current BSS module is holding
+ *   the parameters of BSS (channel, band, SSID etc.).
+ *                                                                          *
+ ****************************************************************************/
+
+#include "currBss.h"
+#include "osApi.h"
+#include "paramIn.h"
+#include "report.h"
+#include "802_11Defs.h"
+#include "utils.h"
+#include "memMngrEx.h"
+#include "DataCtrl_Api.h"
+#include "qosMngr_API.h"
+#include "regulatoryDomainApi.h"
+#include "apConn.h"
+#include "scanMngrApi.h" 
+#include "MacServices_api.h"
+#include "smeApi.h"
+#include "smeSmApi.h"
+#include "TNETW_Driver_types.h"
+
+/* Constants */
+
+#define NUM_PACKETS_4_CONN_LIVENESS 2
+
+/* Enumerations */
+
+
+/* Typedefs */
+
+typedef UINT8 (*currBSS_beaconRxCallb_t) (TI_HANDLE hModule, UINT64 staTSF, UINT8 dtimCount);
+
+
+/* Structures */
+
+/**
+* Current BSS control block 
+* Following structure defines parameters that can be configured externally,
+* internal variables, and handlers of other modules used by Current BSS module
+*/
+typedef struct _currBSS_t
+{
+    /* Internal variables and configurable parameters */
+    bssType_e   type;                   /**< Set by SME module; EBSS, IBSS or none */
+    radioBand_e band;                   /**< Set by SME module */
+    UINT8       channel;                /**< Set by AP Connection, SME and Switch Channel modules */
+    UINT8       numOfPktsInRevivalTest; /**< Set by AP Connection; nmber of Probe Request Packets sent when 'Out of sync' suspected */
+    BOOLEAN     fwIsOutOfSync;          /**< TRUE if 'Out of Sync' event received */
+    BOOLEAN     isConnected;            /**< Default: not connected */
+    bssEntry_t  currAPInfo;             /**< Set by SME upon request from AP Connection */
+    UINT8       snr;                    /**< Value of SNR of last management packet received form the current AP */
+    UINT8        snrFilterWeight;            /**< The weigh for average SNR value of management packets received form the current AP */
+    BOOLEAN     rssiBelowThrReported;   /**< Set to TRUE whem low RSSI threshold crossed */
+    BOOLEAN     rssiAboveThrReported;   /**< Set to TRUE whem high RSSI threshold crossed */
+    INT8        averageRssi;            /**< Average value of RSSI of management packets received form the current AP */
+    INT8        lowRssiThreshold;       /**< Indicator used to increase the background scan period when quality is low */
+    INT8        highRssiThreshold;      /**< Indicator used to reduce the background scan period when quality is normal */
+    UINT8        rssiFilterWeight;            /**< The weigh for average RSSI value of management packets received form the current AP */
+    BOOLEAN     bUseSGParams;           /**< Whether to use the Soft Gemini compensation on the roaming triggers (currently: BSS Loss) */
+                                        /**< This compensation is needed since BT Activity might over-run beacons                       */
+    UINT8       numExpectedTbttForBSSLoss; /**< last configured value without Soft Gemini compensation                                 */
+    UINT32      SGcompensationPercent;  /*< the percentage of increasing the TbttForBSSLoss value when SG is enabled */
+
+    /* Handlers of other modules used by AP Connection */
+    TI_HANDLE   hOs;
+    TI_HANDLE   hPowerMngr;
+    TI_HANDLE   hAPConn;
+    TI_HANDLE   hSme;
+    TI_HANDLE   hHal;
+    TI_HANDLE   hMlme;
+    TI_HANDLE   hReport;
+    TI_HANDLE   hRegulatoryDomain;
+    TI_HANDLE   hMemMgr;
+    TI_HANDLE   hTxData;
+    TI_HANDLE   hSiteMgr;
+    TI_HANDLE   hScanMngr;
+    TI_HANDLE   hMacServices;
+} currBSS_t;
+
+/* Internal functions prototypes */
+
+static void currBSS_lowRssiThrCrossed(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength);
+static void currBSS_lowSnrThrCrossed(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength);
+static void currBSS_consecTxErrors(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength);
+static void currBSS_outOfSync(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength);
+static void currBSS_reviveConnection(currBSS_t *hCurrBSS);
+static void currBSS_terminateOutOfSyncMode(currBSS_t *pCurrBSS);
+static void currBSS_beaconMissed(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength);
+static void currBSS_sendUnicastProbeRequest(currBSS_t *pCurrBSS);
+static void currBSS_reportRoamingEvent(currBSS_t *hCurrBSS, apConn_roamingTrigger_e roamingEventType, roamingEventData_u *pRoamingEventData);
+static void currBSS_updateBSSLoss(currBSS_t *pCurrBSS);
+
+/* Public functions implementation */
+
+
+/**
+*
+* currBSS_create
+*
+* \b Description: 
+*
+* Create the Current BSS context: allocate memory for internal variables
+*
+* \b ARGS:
+*
+*  I   - hOS - the handle to the OS object
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_HANDLE currBSS_create(TI_HANDLE hOs)
+{
+    currBSS_t   *pCurrBss;
+
+    if ((pCurrBss = os_memoryAlloc(hOs, sizeof(currBSS_t))) != NULL)
+    {
+        pCurrBss->hOs = hOs;
+    
+        return pCurrBss;
+    }
+    else /* Failed to allocate control block */
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: currBSS_create(): Error allocating cb - aborting\n"));
+        return NULL;
+    }
+}
+
+
+/**
+*
+* currBSS_unload
+*
+* \b Description: 
+*
+* Finish Current BSS module work.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_unload(TI_HANDLE hCurrBSS)
+{
+    currBSS_t   *pCurrBSS;
+    
+    if (hCurrBSS != NULL)
+    {
+        pCurrBSS = (currBSS_t *)hCurrBSS;
+
+        /* Free pre-allocated control block */
+        utils_nullMemoryFree(pCurrBSS->hOs, pCurrBSS, sizeof(currBSS_t));
+    }
+    return OK;
+}
+
+/**
+*
+* currBSS_init
+*
+* \b Description: 
+*
+* Prepare Current BSS module to work
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  I   - hMlme  \n
+*  I   - hScanMng  \n
+*  I   - hPowerMgr  \n
+*  I   - hAPConnection  \n
+*  I   - hSME  \n
+*  I   - hHal  \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_init(TI_HANDLE hCurrBSS,
+                       TI_HANDLE hMlme,
+                       TI_HANDLE hPowerMgr,
+                       TI_HANDLE hAPConnection,
+                       TI_HANDLE hSME,
+                       TI_HANDLE hHal,
+                       TI_HANDLE hReport,
+                       TI_HANDLE hMemMgr,
+                       TI_HANDLE hTxData,
+                       TI_HANDLE hSiteMngr,
+                       TI_HANDLE hScanMngr,
+                       TI_HANDLE hMacServices)
+{
+    currBSS_t   *pCurrBSS;
+    whalCtrl_roamingTriggerCmd_t params;
+    
+    if (hCurrBSS != NULL)
+    {
+        pCurrBSS = (currBSS_t *)hCurrBSS;
+        
+        /* Registration succeeded, continue with init procedure */
+        pCurrBSS->band = RADIO_BAND_2_4_GHZ;
+        pCurrBSS->channel = 0;
+        pCurrBSS->isConnected = FALSE;
+        pCurrBSS->fwIsOutOfSync = FALSE;
+        pCurrBSS->rssiAboveThrReported = FALSE;
+        pCurrBSS->rssiBelowThrReported = FALSE;
+        pCurrBSS->type = BSS_ANY;
+        pCurrBSS->numOfPktsInRevivalTest = NUM_PACKETS_4_CONN_LIVENESS;
+        pCurrBSS->snr = 0;
+        pCurrBSS->snrFilterWeight = SNR_DEFAULT_WEIGHT;
+        pCurrBSS->averageRssi = 0;
+        pCurrBSS->rssiFilterWeight = RSSI_DEFAULT_WEIGHT;
+        pCurrBSS->currAPInfo.RSSI = 0;
+        pCurrBSS->highRssiThreshold = RSSI_DEFAULT_THRESHOLD;
+        pCurrBSS->lowRssiThreshold = RSSI_DEFAULT_THRESHOLD;
+        pCurrBSS->bUseSGParams = FALSE;
+        
+        pCurrBSS->hAPConn = hAPConnection;
+        pCurrBSS->hTxData = hTxData;
+        pCurrBSS->hHal = hHal;
+        pCurrBSS->hMlme = hMlme;
+        pCurrBSS->hPowerMngr = hPowerMgr;
+        pCurrBSS->hSme = hSME;
+        pCurrBSS->hMemMgr = hMemMgr;
+        pCurrBSS->hSiteMgr = hSiteMngr;
+        pCurrBSS->hReport = hReport;
+        pCurrBSS->hScanMngr = hScanMngr;
+        pCurrBSS->hMacServices = hMacServices;
+        
+        /* Configure and enable the Low RSSI, the Low SNR and the Missed beacon events */
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_RSSI_LEVEL, (void *)currBSS_lowRssiThrCrossed, pCurrBSS); 
+        whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_RSSI_LEVEL);
+
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_LOW_SNR, (void *)currBSS_lowSnrThrCrossed, pCurrBSS); 
+        whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_LOW_SNR);
+
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_BSS_REGAIN, (void *)currBSS_Bss_Regain_CallB , pCurrBSS); 
+        whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_BSS_REGAIN);
+
+        params.rssiFilterDepth = RSSI_DEFAULT_DEPTH;
+        params.rssiFilterWeight = RSSI_DEFAULT_WEIGHT;
+        params.rssiThreshold =  RSSI_DEFAULT_THRESHOLD;
+        params.lowRSSIEventType = LOW_RSSI_EVENT_LEVEL;
+        whalCtrl_SetRSSIParamsCmd(pCurrBSS->hHal, &params);
+        
+        params.snrFilterDepth = SNR_DEFAULT_DEPTH;
+        params.snrFilterWeight = SNR_DEFAULT_WEIGHT;
+        params.snrThreshold =  SNR_DEFAULT_THRESHOLD;
+        params.lowSNREventType = LOW_SNR_EVENT_LEVEL;
+        whalCtrl_SetSNRParamsCmd(pCurrBSS->hHal, &params);
+        
+        /* Register for 'Out of Sync' and 'No Beacon trigger' events */
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_BSS_LOSE, (void *)currBSS_beaconMissed, pCurrBSS);
+        whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_BSS_LOSE);
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_SYNCHRONIZATION_TIMEOUT, (void *)currBSS_outOfSync, pCurrBSS);
+        whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_SYNCHRONIZATION_TIMEOUT);
+            /* save last configured value for handling Soft Gemini changes */ 
+        pCurrBSS->numExpectedTbttForBSSLoss = OUT_OF_SYNC_DEFAULT_THRESHOLD;
+        params.TsfMissThreshold = OUT_OF_SYNC_DEFAULT_THRESHOLD;
+        params.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
+        whalCtrl_SetBssLossTsfThresholdParamsCmd(pCurrBSS->hHal, &params);
+
+        /* Register for BSS_RESET event' */        
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_BSS_RESET, (void *)currBSS_Bss_Reset_CallB , pCurrBSS);  
+        /* Register for 'Consec. Tx error' */
+        whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_MAX_TX_RETRY, (void *)currBSS_consecTxErrors, pCurrBSS);
+        whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_MAX_TX_RETRY);
+        params.maxTxRetry = NO_ACK_DEFAULT_THRESHOLD;
+        whalCtrl_SetMaxTxRetryParamsCmd(pCurrBSS->hHal, &params);
+        
+        return OK;
+    }
+    else /* Current BSS handle is NULL */
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: Current BSS context is not initiated\n"));
+        return NOK;
+    }
+}
+
+
+/**
+*
+* currBSS_updateRoamingTriggers
+*
+* \b Description: 
+*
+* Configure parameter of Current BSS
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  I   - params - pointer to datablock of roaming threshols \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_updateRoamingTriggers(TI_HANDLE hCurrBSS,
+                                        roamingMngrThresholdsConfig_t *params)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+    whalCtrl_roamingTriggerCmd_t roamingTriggersParams;
+    
+    /* Configure HAL with RSSI parameters */
+    roamingTriggersParams.rssiFilterDepth = RSSI_DEFAULT_DEPTH;
+    roamingTriggersParams.rssiFilterWeight = params->rssiFilterWeight /* RSSI_DEFAULT_WEIGHT */ ;
+    roamingTriggersParams.rssiThreshold = params->lowRssiThreshold;
+    roamingTriggersParams.lowRSSIEventType = LOW_RSSI_EVENT_LEVEL;
+    whalCtrl_SetRSSIParamsCmd(pCurrBSS->hHal, &roamingTriggersParams);
+    
+    /* Configure HAL with SNR parameters */
+    roamingTriggersParams.snrFilterDepth = SNR_DEFAULT_DEPTH;
+    roamingTriggersParams.snrFilterWeight = params->snrFilterWeight /* SNR_DEFAULT_WEIGHT */ ;
+    roamingTriggersParams.snrThreshold = params->lowSnrThreshold;
+    roamingTriggersParams.lowSNREventType = LOW_SNR_EVENT_LEVEL;
+    whalCtrl_SetSNRParamsCmd(pCurrBSS->hHal, &roamingTriggersParams);
+    
+    /* save last configured value for handling Soft Gemini changes */ 
+    pCurrBSS->numExpectedTbttForBSSLoss = params->numExpectedTbttForBSSLoss;
+    /* Configure HAL with 'No BSS' thresholds (Same as the other parameters but in  a special
+        function for the Soft Gemini module consideration) */
+    currBSS_updateBSSLoss(pCurrBSS);
+    
+    /* Configure HAL with 'Consecutive NACK' thresholds */
+    roamingTriggersParams.maxTxRetry = params->dataRetryThreshold;
+    whalCtrl_SetMaxTxRetryParamsCmd(pCurrBSS->hHal, &roamingTriggersParams);
+    
+    pCurrBSS->lowRssiThreshold = params->lowQualityForBackgroungScanCondition;
+    
+    pCurrBSS->highRssiThreshold = params->normalQualityForBackgroungScanCondition;
+    
+    pCurrBSS->rssiFilterWeight = params->rssiFilterWeight;
+
+    pCurrBSS->snrFilterWeight = params->snrFilterWeight;
+
+    
+    return OK;
+}
+
+/**
+*
+* currBSS_getRoamingParams
+*
+* \b Description: 
+*
+* Retrieves the roaming triggers stored in the CurrBSS module.
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  O   - aNumExpectedTbttForBSSLoss - Current BSS handle \n
+*  O   - aLowQualityForBackgroungScanCondition - Current BSS handle \n
+*  O   - aNormalQualityForBackgroungScanCondition - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_getRoamingParams(TI_HANDLE hCurrBSS,
+                                   UINT8 * aNumExpectedTbttForBSSLoss,
+                                   INT8 * aLowQualityForBackgroungScanCondition,
+                                   INT8 * aNormalQualityForBackgroungScanCondition,
+                                   UINT8 * rssiFilterWeight,
+                                   UINT8 * snrFilterWeight)
+{
+    currBSS_t * pCurrBSS = (currBSS_t *) hCurrBSS;
+
+    *aNumExpectedTbttForBSSLoss = pCurrBSS->numExpectedTbttForBSSLoss;
+    *aLowQualityForBackgroungScanCondition = pCurrBSS->lowRssiThreshold;
+    *aNormalQualityForBackgroungScanCondition = pCurrBSS->highRssiThreshold;
+    *rssiFilterWeight = pCurrBSS->rssiFilterWeight;
+    *snrFilterWeight = pCurrBSS->snrFilterWeight;
+    
+    return OK;
+}
+
+/**
+*
+* currBSS_SGconfigureBSSLoss
+*
+* \b Description: 
+*
+*   This function is called by the Soft Gemini module in order to enable/disable the use of
+*   the compensation value for the BSSLoss count , and the percent of increasing that value
+*   It also set the new parameter to the FW (with another generic function)
+*   The compensation is needed since BT activity might over-run recieved beacons
+*    
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*        SGcompensationPercent - percent of increasing the BSSLoss value to the FW \n
+*        bUseSGParams - whether to use the SG compensation
+*
+* \b RETURNS:
+*
+*  -
+*
+* \sa 
+*/
+
+void currBSS_SGconfigureBSSLoss(TI_HANDLE hCurrBSS,
+                                        UINT32 SGcompensationPercent , BOOLEAN bUseSGParams)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+        
+    pCurrBSS->bUseSGParams = bUseSGParams;
+    pCurrBSS->SGcompensationPercent = SGcompensationPercent;
+
+       WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("CurrBSS_SGConf: SG =%d\n",
+                                                                                                                                                  pCurrBSS->bUseSGParams));
+
+    /* update the change of BSSLoss in the FW */
+    currBSS_updateBSSLoss(pCurrBSS);
+}
+
+/**
+*
+* currBSS_updateBSSLoss
+*
+* \b Description: 
+*
+*   This function updates only BSS Loss parameter , we need it to be able to consider the
+*   Soft Gemini status , and change the parameter according to it 
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  -
+*
+* \sa 
+*/
+void currBSS_updateBSSLoss(currBSS_t   *pCurrBSS)
+{
+    whalCtrl_roamingTriggerCmd_t roamingTriggersParams;
+
+    /* In Ad-Hoc we use default parameter */
+    if (pCurrBSS->type == BSS_INDEPENDENT)
+    {
+       roamingTriggersParams.TsfMissThreshold = OUT_OF_SYNC_IBSS_THRESHOLD; 
+    }
+    else /* In Infra we use the saved parameter */
+    {
+        roamingTriggersParams.TsfMissThreshold = pCurrBSS->numExpectedTbttForBSSLoss;
+    }
+    
+    roamingTriggersParams.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
+
+       WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("CurrBSS: SG=%d, Band=%d\n",
+                                                                                                                                                  pCurrBSS->bUseSGParams,
+                                                                                                                                                  pCurrBSS->currAPInfo.band));
+    /* if Soft Gemini is enabled - increase the BSSLoss value (because BT activity might over-run beacons) */
+    if ((pCurrBSS->bUseSGParams) && (pCurrBSS->currAPInfo.band == RADIO_BAND_2_4_GHZ))
+    {
+        roamingTriggersParams.TsfMissThreshold = (roamingTriggersParams.TsfMissThreshold * 
+            (100 + pCurrBSS->SGcompensationPercent)) / 100;
+
+        WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,
+            ("%s: old value = %d, new value (for SG compensation) = %d\n", __FUNCTION__, 
+            pCurrBSS->numExpectedTbttForBSSLoss,roamingTriggersParams.TsfMissThreshold));   
+    }
+    whalCtrl_SetBssLossTsfThresholdParamsCmd(pCurrBSS->hHal, &roamingTriggersParams);
+}
+
+/**
+*
+* currBSS_swChFinished
+*
+* \b Description: 
+*
+* Called when switch channel process is complete in order to reset RSSI calculations
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  -
+*
+* \sa 
+*/
+void currBSS_restartRssiCounting(TI_HANDLE hCurrBSS)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+
+    pCurrBSS->averageRssi = 0;
+    pCurrBSS->currAPInfo.RSSI = 0;
+}
+
+/**
+*
+* currBSS_getBssInfo
+*
+* \b Description: 
+*
+* Get parameter of Current BSS
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  pointer to current BSS info block.
+*
+* \sa 
+*/
+bssEntry_t *currBSS_getBssInfo(TI_HANDLE hCurrBSS)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+
+    /* Return pointer to current AP info */
+    return &(pCurrBSS->currAPInfo);
+}
+
+
+/**
+*
+* currBSS_probRespReceivedCallb
+*
+* \b Description: 
+*
+* Callback function, provided to MLME module. Called each time Probe response received.
+* This function verifies that the Probe response was sent by current AP, and then
+* updates current AP database.
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_probRespReceivedCallb(TI_HANDLE hCurrBSS,
+                                        Rx_attr_t *pRxAttr,
+                                        macAddress_t *bssid,
+                                        mlmeFrameInfo_t *pFrameInfo,
+                                        char *dataBuffer,
+                                        UINT16 bufLength)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+    paramInfo_t param;
+    
+    param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
+    siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+
+    if ((pCurrBSS->isConnected) && (MAC_EQUAL((&(param.content.siteMgrDesiredBSSID)), (bssid))))
+    {
+            /* If this is first probe response since FW reported 'Out of sync' situation, 
+               then we were trying to revive connection, now stop sending probe requests */
+        currBSS_terminateOutOfSyncMode(pCurrBSS);
+
+        siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (radioBand_e)pRxAttr->band, FALSE);
+        /* Save the IE part of the Probe Response buffer in the site table */
+        siteMgr_saveProbeRespBuffer(pCurrBSS->hSiteMgr, bssid, (UINT8 *)dataBuffer, bufLength);
+    }
+    return OK;
+}
+
+
+
+/**
+*
+* currBSS_beaconReceivedCallb
+*
+* \b Description: 
+*
+* Callback function, provided to MLME module. Called each time Beacon received.
+* This function verifies that the Probe response was sent by current AP, and then
+* updates current AP database.
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_beaconReceivedCallb(TI_HANDLE hCurrBSS,
+                                      Rx_attr_t *pRxAttr,
+                                      macAddress_t *bssid,
+                                      mlmeFrameInfo_t *pFrameInfo,
+                                      char *dataBuffer,
+                                      UINT16 bufLength)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+    paramInfo_t param;
+    param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
+    siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+
+    if ((pCurrBSS->isConnected) && (MAC_EQUAL((&(param.content.siteMgrDesiredBSSID)), (bssid))))
+    {
+        /* If this is first beacon since FW reported 'Out of sync' situation, 
+           then we were trying to revive connection, now stop sending probe requests */
+        currBSS_terminateOutOfSyncMode(pCurrBSS);
+
+        siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (radioBand_e)pRxAttr->band, FALSE);
+        /* Save the IE part of the beacon buffer in the site table */
+        siteMgr_saveBeaconBuffer(pCurrBSS->hSiteMgr, bssid, (UINT8 *)dataBuffer, bufLength);
+
+        currBSS_updateRxSignal(hCurrBSS, pRxAttr->SNR, pRxAttr->Rssi, FALSE);
+    }
+
+    return OK;
+}
+
+
+
+/**
+*
+* currBSS_performRecovery
+*
+* \b Description: 
+*
+* This function is called when FW recovery performed.
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS currBSS_performRecovery(TI_HANDLE hCurrBSS)
+{
+    currBSS_terminateOutOfSyncMode(hCurrBSS);
+    return OK;
+}
+
+
+/**
+*
+* currBSS_updateConnectedState
+*
+* \b Description: 
+*
+* This function is called when FW recovery performed.
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  I   - isConnected - TRUE or FALSE \n
+*  I   - type - IBSS or EBSS \n
+*  
+* \b RETURNS:
+*
+*  -
+*
+* \sa 
+*/
+void currBSS_updateConnectedState(TI_HANDLE hCurrBSS, BOOLEAN isConnected, bssType_e type)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+    paramInfo_t param;
+    pCurrBSS->type = type;
+    pCurrBSS->isConnected = isConnected;
+
+    /* If new connection established or roaming started, as well as
+       in case of disconnect, the event 'Out of sync' from FW is 
+       no more relevant, do not proceed with it's handling */
+    currBSS_terminateOutOfSyncMode(pCurrBSS);
+    pCurrBSS->averageRssi = pCurrBSS->currAPInfo.RSSI;
+
+    if (isConnected) 
+    {
+        /*** Store the info of current AP ***/
+
+        /* BSSID */
+        param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+        os_memoryCopy(pCurrBSS->hOs, (void *)pCurrBSS->currAPInfo.BSSID.addr, (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN);
+
+        /* Rx rate */
+        param.paramType = SITE_MGR_LAST_RX_RATE_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);               
+        pCurrBSS->currAPInfo.rxRate = param.content.ctrlDataCurrentBasicRate;
+
+        /* Band */
+        param.paramType = SITE_MGR_RADIO_BAND_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);               
+        pCurrBSS->currAPInfo.band = param.content.siteMgrRadioBand;
+
+        /* Channel */
+        param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);               
+        pCurrBSS->currAPInfo.channel = param.content.siteMgrCurrentChannel;
+
+        /* Last Rx Tsf */
+        param.paramType = SITE_MGR_CURRENT_TSF_TIME_STAMP;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);               
+        os_memoryCopy(pCurrBSS->hOs, &pCurrBSS->currAPInfo.lastRxTSF, 
+                      param.content.siteMgrCurrentTsfTimeStamp, sizeof(pCurrBSS->currAPInfo.lastRxTSF));
+
+        /* Beacon interval */
+        param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);               
+        pCurrBSS->currAPInfo.beaconInterval = param.content.beaconInterval;
+
+        /* Capability */
+        param.paramType = SITE_MGR_SITE_CAPABILITY_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr,&param);
+        pCurrBSS->currAPInfo.capabilities = param.content.siteMgrSiteCapability;
+        param.paramType = SITE_MGR_CURRENT_TSF_TIME_STAMP;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+
+        /* pCurrBSS->currAPInfo.lastRxHostTimestamp = *((UINT64 *)(pIEs->TimeStamp));*/ /* TBD*/
+        os_memoryCopy(pCurrBSS->hOs, &pCurrBSS->currAPInfo.lastRxHostTimestamp, param.content.siteMgrCurrentTsfTimeStamp, sizeof(UINT32));
+
+        param.paramType = SITE_MGR_LAST_BEACON_BUF_PARAM;
+        siteMgr_getParam(pCurrBSS->hSiteMgr, &param);               
+        pCurrBSS->currAPInfo.pBuffer = param.content.siteMgrLastBeacon.buffer;
+        pCurrBSS->currAPInfo.bufferLength = param.content.siteMgrLastBeacon.bufLength;
+        pCurrBSS->currAPInfo.resultType = (param.content.siteMgrLastBeacon.isBeacon) ? SCAN_RFT_BEACON : SCAN_RFT_PROBE_RESPONSE;
+
+        /* Set BSS Loss to Fw - note that it depends on the Connection type - (Infa/IBSS) */
+        currBSS_updateBSSLoss(pCurrBSS);
+
+        /* 
+        this section is for the first beacon. in here we set the flag for waiting for 
+        the first beacon and during all this time we must keep the Hw awake 
+        this things are done only for INFRA connection.
+        */
+        if(type == BSS_INFRASTRUCTURE)
+        {
+                siteMgr_clearFirstBcnFlag(pCurrBSS->hSiteMgr);
+        }        
+    }
+    else
+    {
+        /* 
+        this section is for the first beacon. in here we cancel the setting of the flag 
+        and the Hw available in case that the connection was closed.
+        this things are done only for INFRA connection.
+        */
+        if(type == BSS_INFRASTRUCTURE)
+            siteMgr_setFirstBcnFlag(pCurrBSS->hSiteMgr);
+        
+    }
+}
+
+/* Internal functions implementation */
+
+
+/**
+*
+* currBSS_outOfSync
+*
+* \b Description: 
+*
+* Callback function, provided to HAL module.
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_outOfSync(currBSS_t *hCurrBSS,
+                              UINT8     *data,
+                              UINT8     dataLength)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+    /*while syn with current BSS is lost, we need beacons to resynchronize*/
+        
+    /* If connected, and this kind of event was not received yet, handle it */ 
+    if (pCurrBSS->isConnected && 
+        pCurrBSS->fwIsOutOfSync == FALSE && 
+        pCurrBSS->type != BSS_INDEPENDENT)
+    {
+        
+        /* TBD IBSS configuration; no roaming enabled, report SME */
+        
+        pCurrBSS->fwIsOutOfSync = TRUE;
+
+        /* force TNETW to active */
+        MacServices_powerAutho_AwakeRequiredUpdate(pCurrBSS->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_OUT_OS_SYNC);
+
+        /* try to send Unicast Probe requests */
+        currBSS_reviveConnection(pCurrBSS);
+
+    }
+    else
+    {
+    /*  If no connection, 
+        or in the middle of roaming,
+        or this kind of event was already received, - do nothing */ 
+    }
+}
+
+
+
+/**
+*
+* currBSS_reviveConnection
+*
+* \b Description: 
+*
+* Called when FW indicates "Beacon missed" problem ('Out of sync' event).
+* This function makes sure that FW is not asleep (the radio is awake), and
+* sends Unicast Probe Request packet in order to provoke AP to answer with 
+* Probe response.
+* If HW interface is available (normal case), called immediately upon reception
+* of the event from FW. Otherwise, this function is a function, provided to Power control.
+* Called by Power control module in several cases:
+* - when Power control exits pending and informs registered clients about HW availability; 
+* - when FW recovery occurs - timeout waiting for FW to wakeup
+*
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_reviveConnection(currBSS_t *pCurrBSS)
+{
+    int pktsCount;
+   
+    /* TBD Turn ON LNA if the current state is OFF */
+
+#if 0
+    /* Perform MAC RX module reset. */
+    /* For the moment we don't think the Rx Reset is nessasery */
+    whalCtrl_resetMacRx(pCurrBSS->hHal);
+#endif
+
+    WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("currBSS_reviveConnection: sending %d Probe requests\n", pCurrBSS->numOfPktsInRevivalTest)); 
+
+    /* Test connection with Unicast Probe request */
+    for (pktsCount = pCurrBSS->numOfPktsInRevivalTest; pktsCount > 0; pktsCount--) 
+    {
+        currBSS_sendUnicastProbeRequest(pCurrBSS);
+    }
+}
+
+
+/**
+*
+* currBSS_sendUnicastProbeRequest
+*
+* \b Description: 
+*
+* This function creaes and sends Unicast Probe request packet to current AP
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_sendUnicastProbeRequest(currBSS_t *pCurrBSS)
+{
+    paramInfo_t             param;
+    mem_MSDU_T              *pMsdu;
+    probeReqTemplate_t      *pProbeReqTemplate;
+    whalCtrl_setTemplate_t  templateStruct;
+    TI_STATUS               status;
+       radioBand_e                             eRadioBand;
+    /* 1. Allocate packet */ 
+    status = wlan_memMngrAllocMSDU(pCurrBSS->hMemMgr, &pMsdu, sizeof(probeReqTemplate_t)+TX_TOTAL_OFFSET_BEFORE_DATA, CURRENT_BSS_MODULE);
+    if (status != OK)
+    {
+        return;
+    }
+
+    /* 2. Build a probe request template */
+    pProbeReqTemplate = (probeReqTemplate_t *)((char *)(memMgr_BufData(pMsdu->firstBDPtr))+ TX_TOTAL_OFFSET_BEFORE_DATA);
+    templateStruct.pTemplate = (UINT8 *)pProbeReqTemplate;
+    templateStruct.templateType = PROBE_REQUEST_TEMPLATE;
+
+       param.paramType = SITE_MGR_RADIO_BAND_PARAM;
+       siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+       eRadioBand = param.content.siteMgrRadioBand;
+
+    param.paramType = SITE_MGR_CURRENT_SSID_PARAM;
+    siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+    buildProbeReqTemplate(pCurrBSS->hSiteMgr, &templateStruct, &param.content.siteMgrCurrentSSID, eRadioBand);
+
+    /* 3. Update BSSID to current BSSID */
+    param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
+    siteMgr_getParam(pCurrBSS->hSiteMgr, &param);    
+    os_memoryCopy(pCurrBSS->hOs, &(pProbeReqTemplate->hdr.DA.addr), (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN);
+    os_memoryCopy(pCurrBSS->hOs, &(pProbeReqTemplate->hdr.BSSID.addr), (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN);
+    os_memoryCopy(pCurrBSS->hOs, &(pProbeReqTemplate->hdr.DA.addr), (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN);
+    /* 4. Update MSDU parameters */
+    pMsdu->headerLen = sizeof(dot11_mgmtHeader_t) + TX_TOTAL_OFFSET_BEFORE_DATA;
+    pMsdu->dataLen = templateStruct.templateLen;
+    memMgr_BufOffset(pMsdu->firstBDPtr) = TX_TOTAL_OFFSET_BEFORE_DATA;
+    /*
+     * Fix length according to TX_DESCRIPTOR_SIZE and bus txn reserved place
+     */
+    pMsdu->firstBDPtr->length = pMsdu->dataLen + TX_TOTAL_OFFSET_BEFORE_DATA;
+
+    /* 5. Send the packet to the TX */
+    pMsdu->txFlags |= TX_DATA_MGMT_MSDU;
+    status = txData_txSendMsdu(pCurrBSS->hTxData, pMsdu);
+}
+
+
+/**
+*
+* currBSS_terminateOutOfSyncMode
+*
+* \b Description: 
+*
+* Beacon/probe response received, or connected state is changes - 
+* if was in the middle of handling 'Out os sync' event, give it up
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_terminateOutOfSyncMode(currBSS_t *pCurrBSS)
+{
+    if (pCurrBSS->fwIsOutOfSync) 
+    {
+        pCurrBSS->fwIsOutOfSync = FALSE;
+
+        /* undo forcing TNETW to active */
+        MacServices_powerAutho_AwakeRequiredUpdate(pCurrBSS->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_OUT_OS_SYNC);     
+    }
+}
+
+/**
+*
+* currBSS_beaconMissed
+*
+* \b Description: 
+*
+* Callback function, provided to HAL module.
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_beaconMissed(currBSS_t *hCurrBSS,
+                                      UINT8     *data,
+                                      UINT8     dataLength)
+{
+    currBSS_terminateOutOfSyncMode(hCurrBSS);
+    currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_BSS_LOSS, NULL);
+}
+
+
+/**
+*
+* currBSS_consecTxErrors
+*
+* \b Description: 
+*
+* Callback function, provided to HAL module.
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_consecTxErrors(currBSS_t *hCurrBSS,
+                                   UINT8     *data,
+                                   UINT8     dataLength)
+{
+    currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_MAX_TX_RETRIES, NULL);
+}
+
+
+/**
+*
+* currBSS_lowRssiThrCrossed
+*
+* \b Description: 
+*
+* Callback function, provided to HAL module.
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_lowRssiThrCrossed(currBSS_t *hCurrBSS,
+                                      UINT8     *data,
+                                      UINT8     dataLength)
+{
+    currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_LOW_QUALITY, NULL);
+}
+
+
+/**
+*
+* currBSS_lowSnrThrCrossed
+*
+* \b Description: 
+*
+* Callback function, provided to HAL module.
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_lowSnrThrCrossed(currBSS_t *hCurrBSS,
+                                      UINT8     *data,
+                                      UINT8     dataLength)
+{
+    currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_LOW_SNR, NULL);
+}
+
+/**
+*
+* currBSS_reportRoamingEvent
+*
+* \b Description: 
+*
+* This function checks the mode of Current BSS module. 
+* If connected to EBSS, it reports roaming event to AP Connection.
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  I   - roamingEventType - Roaming trigger to report \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+static void currBSS_reportRoamingEvent(currBSS_t *pCurrBSS, 
+                                       apConn_roamingTrigger_e roamingEventType,
+                                                                          roamingEventData_u *pRoamingEventData)
+{
+    WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("currBSS_reportRoamingEvent: trigger %d\n", roamingEventType));  
+
+    if (pCurrBSS->isConnected)
+    {
+        if (pCurrBSS->type == BSS_INFRASTRUCTURE) 
+        {
+            apConn_reportRoamingEvent(pCurrBSS->hAPConn, roamingEventType, pRoamingEventData);
+        }
+        else /* IBSS */
+        { 
+            if( roamingEventType == ROAMING_TRIGGER_BSS_LOSS )
+            {
+                /* If in IBSS call the SME reselect function, this logic issues a DISCONNECT 
+                 * event and tries to connect to other STA or establish self connection.
+                 */
+                smeSm_reselect(pCurrBSS->hSme);
+            }
+        }
+    }
+}
+
+/***********************************************************************
+ *                        currBSS_updateRxSignal
+ ***********************************************************************
+DESCRIPTION: Called when receiving beacon or Probe response from current AP
+             updates SNR and RSSI in siteMgr and calls apConn in case 
+             roaming trigger for BG scan occurred.
+
+INPUT:      hCurrBSS    -   currBss handle.
+            uSNR        
+            iRSSI
+            bAveragedData - indicate whether the given SNR,RSSI are already averaged.
+                            This is done since this values can be given directly from the 
+                            Fw, which average those values.
+OUTPUT:
+
+RETURN:     
+
+************************************************************************/
+void currBSS_updateRxSignal(TI_HANDLE hCurrBSS, UINT8 uSNR, INT8 iRSSI, BOOL bAveragedData)
+{
+    currBSS_t   *pCurrBSS = (currBSS_t *)hCurrBSS;
+    INT8 tmpRssiAvg;
+    INT8 rssiPrevVal;
+    INT8 rssiLatestVal;
+    paramInfo_t param;
+
+    /* Update SNR */
+    pCurrBSS->snr = uSNR;
+
+    /* Update Rx rate of primary site is done in Site Manager */
+
+    /* Update RSSI: */
+    /* Count average RSSI */
+    rssiPrevVal = pCurrBSS->averageRssi;
+    rssiLatestVal = pCurrBSS->currAPInfo.RSSI = iRSSI;
+
+    /* if the data is already averaged, or this is the first measured RSSI */
+    if ((bAveragedData) || (rssiPrevVal == 0))  
+    {
+        pCurrBSS->averageRssi = rssiLatestVal;
+    }
+    else /* average the RSSI given */
+    {
+        tmpRssiAvg = ((rssiLatestVal*pCurrBSS->rssiFilterWeight) + (rssiPrevVal*(100-pCurrBSS->rssiFilterWeight)))/100;
+    
+        /* for faster convergence on RSSI changes use rounding error calculation with latest sample and not */
+        /* on latest average */
+        if (rssiLatestVal > tmpRssiAvg)
+            tmpRssiAvg++;
+        else
+            if (rssiLatestVal < tmpRssiAvg)
+                tmpRssiAvg--;
+
+        pCurrBSS->averageRssi = tmpRssiAvg;
+    }
+
+    /* Report to AP Connection about reaching RSSI low or normal threshold */
+    if ((pCurrBSS->rssiBelowThrReported == FALSE) && (pCurrBSS->averageRssi < pCurrBSS->lowRssiThreshold))
+    {
+        pCurrBSS->rssiAboveThrReported = FALSE;
+        pCurrBSS->rssiBelowThrReported = TRUE;
+        apConn_reportRoamingEvent(pCurrBSS->hAPConn, ROAMING_TRIGGER_LOW_QUALITY_FOR_BG_SCAN, NULL);
+    }
+    if ((pCurrBSS->rssiAboveThrReported == FALSE) && (pCurrBSS->averageRssi > pCurrBSS->highRssiThreshold))
+    {
+        pCurrBSS->rssiAboveThrReported = TRUE;
+        pCurrBSS->rssiBelowThrReported = FALSE;
+        apConn_reportRoamingEvent(pCurrBSS->hAPConn, ROAMING_TRIGGER_NORMAL_QUALITY_FOR_BG_SCAN, NULL); 
+    }
+
+    /* Update Site Table in order to represent the RSSI of current AP correctly in the utility */
+    param.paramType = SITE_MGR_CURRENT_SIGNAL_PARAM;
+    param.content.siteMgrCurrentSignal.rssi = pCurrBSS->averageRssi;
+    siteMgr_setParam(pCurrBSS->hSiteMgr, &param);
+}
+
+/**
+*
+* currBSS_Bss_Regain_CallB
+*
+* \b Description: 
+*   Used by site manager in case of BSS regain
+* 
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+
+TI_STATUS currBSS_Bss_Regain_CallB(TI_HANDLE hCurrBSS)
+
+{
+    currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
+    paramInfo_t param;
+
+    if ( NULL == hCurrBSS )
+    {
+        WLAN_REPORT_ERROR(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Pointer to Curr BSS NULL, abort regain !")) ;
+        return NOK;
+    }
+    
+    param.paramType = SITE_MGR_CURRENT_BSSID_PARAM;
+    siteMgr_getParam(pCurrBSS->hSiteMgr, &param);           
+
+    if (pCurrBSS->isConnected) 
+    {
+        WLAN_REPORT_INFORMATION(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Regain Current Connected BSS" ));  
+
+        /* If we got the REGAIN_BSS Event from FW since it reported 'Out of sync' situation*/
+        /* then we were trying to revive connection, now stop sending probe requests */
+        currBSS_terminateOutOfSyncMode(pCurrBSS);
+
+    }
+    else
+    {
+        WLAN_REPORT_INFORMATION(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Can't Regain BSS not connected !" ));    
+    }
+    return OK;
+
+}
+
+/**
+*
+* currBSS_Bss_Reset_CallB
+*
+* \b Description: 
+*      Used by site manager in case of BSS Reset - if tsf was changed FW will signal with this event
+* 
+* \b ARGS:
+*
+*  I   - hCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+
+TI_STATUS currBSS_Bss_Reset_CallB(TI_HANDLE hCurrBSS)
+
+{
+       currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
+    
+       if ( NULL == hCurrBSS )
+       {
+               WLAN_REPORT_ERROR(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Pointer to Curr BSS NULL, abort Reset !")) ;
+               return NOK;
+       }
+    
+    
+       if (pCurrBSS->isConnected) 
+               {
+                       WLAN_REPORT_INFORMATION(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Reset Current Connected BSS" ));       
+
+           /* If we got the Reset_BSS Event from FW since TSF was changed may indicate BSS reset in the AP
+           requier to initiate fist beacon mechanism and also test connectivity with the AP (NULL packet)*/
+           siteMgr_clearFirstBcnFlag(pCurrBSS->hSiteMgr);
+
+           
+
+        }
+       else
+       {
+               WLAN_REPORT_ERROR(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Can't Reset BSS not connected !" )); 
+       }
+    return OK;
+
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/currBss/currBss.h b/sta_dk_4_0_4_32/common/src/core/currBss/currBss.h
new file mode 100644 (file)
index 0000000..3d4a01b
--- /dev/null
@@ -0,0 +1,140 @@
+/** \file currBss.h
+ *  \brief Current BSS module API
+ *
+ *  \see currBss.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Current BSS                                               *
+ *   PURPOSE: Current BSS Module API                                    *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _CURR_BSS_H_
+#define _CURR_BSS_H_
+
+#include "whalParams.h"
+#include "siteMgrApi.h"
+#include "roamingMngrTypes.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/** 
+* Current BSS module configurable parameters type  
+*/
+typedef enum
+{
+    CURR_BSS_TYPE = 0,          /**< BSS or IBSS */
+    CURR_BSS_CONNECTED_STATE,   /**< Connected or not connected, roaming enabled or not */
+    CURR_BSS_LOW_RSSI_SCAN_COND,/**< Set by AP Connection when Roaming Manager configures low RSSI threshold for BG scan */
+    CURR_BSS_HI_RSSI_SCAN_COND, /**< Set by AP Connection when Roaming Manager configures normal RSSI threshold for BG scan */
+    CURR_BSS_QUALITY_THRESHOLD, /**< Set by AP Connection when Roaming Manager configures event of type 'Low RSSI' */
+    CURR_BSS_NO_BSS_THRESHOLDS, /**< Set by AP Connection when Roaming Manager configures event of type 'BSS Loss' */
+    CURR_BSS_NUM_OF_TEST_REPEAT,/**< Set by AP Connection when Roaming Manager configures event of type 'BSS Loss' */
+    CURR_BSS_CONSEC_NACK,       /**< Set by AP Connection when Roaming Manager configures event of type 'Consecutive nack' */
+    CURR_BSS_INFO               /**< Requested by AP Connection: includes quality and last beacon info */
+} currBSS_configParam_e;
+
+
+/* Structures */
+
+/* Typedefs */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_HANDLE currBSS_create(TI_HANDLE hOs);
+TI_STATUS currBSS_init(TI_HANDLE hCurrBSS,
+                       TI_HANDLE hMlme,
+                       TI_HANDLE hPowerMgr,
+                       TI_HANDLE hAPConnection,
+                       TI_HANDLE hSME,
+                       TI_HANDLE hHal,
+                       TI_HANDLE hReport,
+                       TI_HANDLE hMemMgr,
+                       TI_HANDLE hTxData,
+                       TI_HANDLE hSiteMngr,
+                       TI_HANDLE hScanMngr,
+                       TI_HANDLE hMacServices);
+TI_STATUS currBSS_unload(TI_HANDLE hCurrBSS);
+
+void currBSS_updateConnectedState(TI_HANDLE hCurrBSS, BOOLEAN isConnected, bssType_e type);
+TI_STATUS currBSS_updateRoamingTriggers(TI_HANDLE hCurrBSS,
+                                        roamingMngrThresholdsConfig_t *params);
+void currBSS_SGconfigureBSSLoss(TI_HANDLE hCurrBSS,
+                                        UINT32 SGcompensationPercent , BOOLEAN bUseSGParams);
+bssEntry_t *currBSS_getBssInfo(TI_HANDLE hCurrBSS);
+
+TI_STATUS currBSS_getRoamingParams(TI_HANDLE hCurrBSS,
+                                   UINT8 * aNumExpectedTbttForBSSLoss,
+                                   INT8 * aLowQualityForBackgroungScanCondition,
+                                   INT8 * aNormalQualityForBackgroungScanCondition,
+                                   UINT8 * rssiFilterWeight,
+                                   UINT8 * snrFilterWeight);
+
+TI_STATUS currBSS_probRespReceivedCallb(TI_HANDLE hCurrBSS,
+                                        Rx_attr_t *pRxAttr,
+                                        macAddress_t *bssid,
+                                        mlmeFrameInfo_t *pFrameInfo,
+                                        char *dataBuffer,
+                                        UINT16 bufLength);
+
+TI_STATUS currBSS_beaconReceivedCallb(TI_HANDLE hCurrBSS,
+                                        Rx_attr_t *pRxAttr,
+                                        macAddress_t *bssid,
+                                        mlmeFrameInfo_t *pFrameInfo,
+                                        char *dataBuffer,
+                                        UINT16 bufLength);
+
+TI_STATUS currBSS_performRecovery(TI_HANDLE hCurrBSS);
+
+void currBSS_restartRssiCounting(TI_HANDLE hCurrBSS);
+TI_STATUS currBSS_Bss_Regain_CallB(TI_HANDLE hCurrBSS);
+
+void currBSS_updateRxSignal(TI_HANDLE hCurrBSS, UINT8 uSNR, INT8 iRSSI, BOOL bAveragedData);
+
+TI_STATUS currBSS_Bss_Reset_CallB(TI_HANDLE hCurrBSS);
+
+
+#endif /*  _CURR_BSS_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/Concatenator.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/Concatenator.c
new file mode 100644 (file)
index 0000000..962bcc1
--- /dev/null
@@ -0,0 +1,350 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE:                                                                                                    */
+/*             PURPOSE:                                                                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+#include "Concatenator.h"
+#include "report.h"
+#include "osApi.h"
+#include "utils.h"
+#include "802_11Defs.h"
+#include "whalBus_Defs.h"
+#include "TNETW_Driver_api.h"
+
+
+static TI_STATUS concat_replaceWlanHeader(concatenator_t* pConcatenator,
+                                                                                 mem_MSDU_T *msduPtr);
+
+
+/*************************************************************************
+*                        concat_create                                 *
+**************************************************************************
+* DESCRIPTION: This function initializes the Ctrl data module.                 
+*                                                      
+* INPUT:               hOs - handle to Os Abstraction Layer
+*                              
+* OUTPUT:              TxCmplt_CB - call back function that return to configMngr
+*                              in order to register in the Hal
+*
+* RETURN:              Handle to the allocated Ctrl data control block
+************************************************************************/
+
+concatenator_t* concat_create(TI_HANDLE hOs)
+{
+       concatenator_t* pConcatenator;
+
+       if( hOs  == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: concat_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       /* alocate concatenator block */
+       pConcatenator = os_memoryAlloc(hOs, (sizeof(concatenator_t)));
+
+
+       if (!pConcatenator)
+       {
+               utils_nullMemoryFree(hOs, pConcatenator, sizeof(concatenator_t));
+           WLAN_OS_REPORT(("FATAL ERROR: concat_create(): Error Creating Concatenator module- Aborting\n"));
+               return(NULL);
+       }
+
+       /* reset control module control block */
+       os_memoryZero(hOs, pConcatenator, (sizeof(concatenator_t)));
+
+       pConcatenator->hOs = hOs;
+
+       return(pConcatenator);
+}
+
+/***************************************************************************
+*                                                      concat_config                                              *
+****************************************************************************
+* DESCRIPTION: This function configures the Ctrl Data module           
+* 
+* INPUTS:              hCtrlData - The object
+*                              hOs - Handle to the Os Abstraction Layer
+*                              hReport - Handle to the Report object
+*                              ctrlDataInitParams - pointer to Ctrl module init parameters
+* OUTPUT:              
+* 
+* RETURNS:             OK - Configuration succesfull
+*                              NOK - Configuration unsuccesfull
+***************************************************************************/
+TI_STATUS concat_config(concatenator_t*                pConcatenator,
+                                               TI_HANDLE                       hOs,
+                                               TI_HANDLE                       hReport,
+                                               TI_HANDLE                       hMemMngr
+                                               /*concatInitParams_t* concatInitParams*/)
+{
+       /* check parameters validity */
+       if( pConcatenator == NULL || hOs == NULL || 
+               hReport == NULL || hMemMngr == NULL /*||  concatInitParams == NULL*/)
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: concat_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+
+       /* set objects handles */
+       pConcatenator->hOs = hOs;
+       pConcatenator->hReport = hReport;
+       pConcatenator->hMemMngr = hMemMngr;
+
+       WLAN_REPORT_INIT(pConcatenator->hReport, CONCATENATOR_MODULE_LOG, 
+               (".....Concatenator configured successfully\n"));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                                      ctrlData_unLoad                                            *
+****************************************************************************
+* DESCRIPTION: This function unload the Ctrl data module. 
+* 
+* INPUTS:              hCtrlData - the object
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK - Unload succesfull
+*                              NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS concat_destroy(concatenator_t* pConcatenator)
+{
+       /* free control module controll block */
+       os_memoryFree(pConcatenator->hOs, pConcatenator, sizeof(concatenator_t));
+
+       return OK;
+}
+
+
+/*************************************************************************
+ *                        wdrv_txConcatMsduList                          *
+ *************************************************************************
+DESCRIPTION: This function get a list of MSDUs (The first MSDU points 
+             on the others) and concatenate them into one MPDU by linking the
+             buffers BDs. In return only the first MSDU struct is in use, 
+             and it contains the entire concatenated MPDU.                
+                                                                                                   
+INPUT:       msduPtr     - Pointer to the first MSDU.
+             concatFlags - Concatenation flags.
+             
+             
+OUTPUT:      By reference to the msduPtr.
+
+RETURN:      OK : Initiation successful.
+             NOK: Initiation unsuccessful.                                                                                                                                             
+************************************************************************/
+TI_STATUS concat_concatMsduList(concatenator_t*        pConcatenator,
+                                                               mem_MSDU_T*             pFirstMsduPtr,
+                                                               mem_MSDU_T**    pReturnMsduPtr,
+                                                               UINT16                  concatFlags)
+{
+       mem_MSDU_T     *currMsduPtr;
+       mem_MSDU_T     *prevMsduPtr;
+       /*mem_MSDU_T     *buildMsduPtr; */
+       UINT8          *srcDataPtr;
+       UINT8          *buildDataPtr;
+    Wdrv4xHeader_t *w4xHeaderPtr;
+       UINT8                   tiSnapDataArray[8] = {0xAA,0xAA,0x03,0x08,0x00,0x28,0x60,0xD0};
+
+       /* Allocate MSDU and a BD for the concatenatetion header. */
+       if(wlan_memMngrAllocMSDU(pConcatenator->hMemMngr, pReturnMsduPtr, 
+                                                         WLAN_HDR_LEN + WLAN_SNAP_HDR_LEN +WLAN_4X_CONCAT_HDR_LEN + sizeof(DbTescriptor),
+                                                         CONCAT_MODULE) == NOK)
+       {
+               WLAN_REPORT_ERROR(pConcatenator->hReport, CONCATENATOR_MODULE_LOG, 
+                       ("concat_concatMsduList: no MemMngre resources, free the MsduList to concat\n"));
+                       
+               wlan_memMngrFreeListOfMSDU(pConcatenator->hMemMngr, memMgr_MsduHandle(pFirstMsduPtr));
+               return NOK;
+       }
+
+       (*pReturnMsduPtr)->txFlags = pFirstMsduPtr->txFlags;
+       
+       /* Create the first BD.(contains 802.11 header, TI wlan SNAP & Concat headr) */
+       srcDataPtr = (UINT8 *)memMgr_MsduHdrAddr(pFirstMsduPtr);
+       buildDataPtr = (UINT8 *)memMgr_MsduHdrAddr(*pReturnMsduPtr);
+
+       /* Copy the 802.11 header. */
+       os_memoryCopy(pConcatenator->hOs, buildDataPtr, srcDataPtr, WLAN_HDR_LEN );
+
+       /* We send the frame from the STA so the AP */
+       os_memoryCopy(pConcatenator->hOs, buildDataPtr+WLAN_DA_FIELD_OFFSET, srcDataPtr+WLAN_BSSID_FIELD_OFFSET, 6 );
+   
+       buildDataPtr += WLAN_HDR_LEN;
+       
+       /* create a TI WLAN SNAP */
+       os_memoryCopy(pConcatenator->hOs, buildDataPtr ,tiSnapDataArray, WLAN_SNAP_HDR_LEN );
+       buildDataPtr += WLAN_SNAP_HDR_LEN;
+       
+       /* create 4X header.   */
+    w4xHeaderPtr = (Wdrv4xHeader_t*)buildDataPtr;
+    w4xHeaderPtr->type = WLAN_HEADER_TYPE_CONCATENATION;
+    w4xHeaderPtr->headerLen = WLAN_CONCAT_HEADER_LEN;
+    w4xHeaderPtr->txFlags = wlan_htons(concatFlags);
+       
+       (*pReturnMsduPtr)->firstBDPtr->length = WLAN_HDR_LEN + WLAN_SNAP_HDR_LEN + 
+                                                                               WLAN_4X_CONCAT_HDR_LEN;
+
+    (*pReturnMsduPtr)->dataLen =  WLAN_HDR_LEN + WLAN_SNAP_HDR_LEN + 
+                                                                               WLAN_4X_CONCAT_HDR_LEN;
+
+
+    (*pReturnMsduPtr)->headerLen = WLAN_HDR_LEN;
+
+
+    /*buildMsduPtr->nextMSDUinList = (*pMsduPtr);*/
+
+       
+       /* Link the new MSDU to the first MSDU to imitate the MSDU list format.     */
+       (*pReturnMsduPtr)->firstBDPtr->nextBDPtr = pFirstMsduPtr->firstBDPtr;
+       
+       /* Start Concatenating the MSDUs, payload is copied from the SNAP to       */
+       /* payload  end.                                                           */        
+       currMsduPtr = pFirstMsduPtr;
+       while( currMsduPtr != NULL )
+       {
+        concat_replaceWlanHeader(pConcatenator, currMsduPtr );
+
+        /* Update the size of the concatenated MSDU. */                
+        (*pReturnMsduPtr)->dataLen += currMsduPtr->dataLen;
+
+               
+        if(  currMsduPtr->nextMSDUinList != NULL )
+        {
+            /* Link last BD of the current MSDU to the first BD of the next MSDU.*/
+             currMsduPtr->lastBDPtr->nextBDPtr = currMsduPtr->nextMSDUinList->firstBDPtr;
+               
+            /* Jump for the next MSDU */
+            prevMsduPtr = currMsduPtr;
+                       currMsduPtr = currMsduPtr->nextMSDUinList;
+                       prevMsduPtr->firstBDPtr = NULL;
+                       prevMsduPtr->nextMSDUinList = NULL;
+                       wlan_memMngrFreeMSDU(pConcatenator->hMemMngr, memMgr_MsduHandle(prevMsduPtr));
+
+               
+        }
+        else 
+               {
+            /* Last MSDU */
+            prevMsduPtr = currMsduPtr;
+                       prevMsduPtr->firstBDPtr = NULL;
+                       prevMsduPtr->nextMSDUinList = NULL;
+                       wlan_memMngrFreeMSDU(pConcatenator->hMemMngr, memMgr_MsduHandle(prevMsduPtr));
+
+            currMsduPtr = NULL;
+
+        }
+
+               
+       } /* While( currMsduPtr != NULL ) */
+
+       
+       return OK;
+}
+
+
+/*************************************************************************
+ *                        wdrv_txReplaceWlanHeader                       *
+ *************************************************************************
+DESCRIPTION: This function replaces the 802.11 header with length + SA as
+             prefix to the concatenated MSDU.                
+                                                                                                   
+INPUT:       msduPtr     - Pointer to the first MSDU.
+             
+             
+
+RETURN:      OK : Initiation succesfull.
+             NOK: Initiation unsuccesfull.                                                                                                                                             
+************************************************************************/
+static TI_STATUS concat_replaceWlanHeader(concatenator_t* pConcatenator,
+                                                                                 mem_MSDU_T *msduPtr)
+{
+    UINT8   *firstDataBuf;
+    UINT8    numOfPadBytes;
+    UINT8   *tmpPtr;
+       UINT8   tmpMacAddr[WLAN_DA_FIELD_LEN];
+    int i;
+       
+       
+       /* Replace the 802.11 header with 2 length bytes and 6 DA . */
+       firstDataBuf = (UINT8 *)(msduPtr->firstBDPtr->data + 
+                                                       msduPtr->firstBDPtr->dataOffset);
+
+       /*
+        * Use temporary buffer to prevent overwrite on the same data
+        */
+       os_memoryCopy(pConcatenator->hOs,
+                                 tmpMacAddr,
+                                 firstDataBuf+WLAN_DA_FIELD_OFFSET, WLAN_DA_FIELD_LEN);
+       os_memoryCopy(pConcatenator->hOs,
+                                 firstDataBuf+ WLAN_HDR_LEN - WLAN_DA_FIELD_LEN,
+                                 tmpMacAddr, WLAN_DA_FIELD_LEN);
+       
+       msduPtr->firstBDPtr->dataOffset += WLAN_CONCAT_HDR_OFFSET;
+       msduPtr->firstBDPtr->length -= WLAN_CONCAT_HDR_OFFSET;
+       msduPtr->dataLen -= WLAN_CONCAT_HDR_OFFSET;
+       
+       /* Fill the length bytes.   */
+       (*(UINT16*)(firstDataBuf+ WLAN_CONCAT_HDR_OFFSET)) = 
+                       wlan_htons((UINT16)(msduPtr->dataLen - WLAN_4X_LEN_FIELD_LEN));
+       
+       /* Padding the last buffer with zeros.*/
+       numOfPadBytes = msduPtr->dataLen % 4;
+       
+       if( numOfPadBytes > 0 )
+       { 
+#if 1
+       /*
+       * fixing the alignment bug. 
+              */
+               numOfPadBytes = 4 - numOfPadBytes;
+#endif       
+               tmpPtr = (UINT8 *) ((UINT32)msduPtr->lastBDPtr->data + msduPtr->lastBDPtr->length +
+                       msduPtr->lastBDPtr->dataOffset);
+               for( i=0; i<numOfPadBytes; i++)
+                       tmpPtr[i] = 0x00;
+               
+               msduPtr->lastBDPtr->length += numOfPadBytes;
+               msduPtr->dataLen += numOfPadBytes;
+       }
+
+       return OK; 
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/Concatenator.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/Concatenator.h
new file mode 100644 (file)
index 0000000..1fc1012
--- /dev/null
@@ -0,0 +1,81 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:                                                                                                              */
+/*    PURPOSE:                                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _CONCATENATOR_H_
+#define _CONCATENATOR_H_
+
+#include "osTIType.h"
+#include "memMngrEx.h" 
+
+#define CONCATENATOR_MODULE_LOG                CTRL_DATA_MODULE_LOG
+
+#define MAX_CONCAT_SIZE                        4096
+
+
+typedef struct
+{
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hMemMngr;
+
+       /*UINT32                                concat_maxConcatSize;*/
+
+} concatenator_t;
+
+concatenator_t* concat_create(TI_HANDLE hOs);
+
+TI_STATUS concat_config(concatenator_t*                pConcatenator,
+                                               TI_HANDLE                       hOs,
+                                               TI_HANDLE                       hReport,
+                                               TI_HANDLE                       hMemMngr
+                                               /*concatInitParams_t* concatInitParams*/);
+
+TI_STATUS concat_destroy(concatenator_t* pConcatenator);
+
+TI_STATUS concat_concatMsduList(concatenator_t*        pConcatenator,
+                                                               mem_MSDU_T*             pFirstMsduPtr,
+                                                               mem_MSDU_T**    pReturnMsduPtr,
+                                                               UINT16                  concatFlags);
+
+
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/DeConcatenator.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/DeConcatenator.c
new file mode 100644 (file)
index 0000000..835cc37
--- /dev/null
@@ -0,0 +1,409 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE:                                                                                                    */
+/*             PURPOSE:                                                                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+#include "DeConcatenator.h"
+#include "report.h"
+#include "osApi.h"
+#include "utils.h"
+#include "802_11Defs.h"
+
+#define MAX_DECONACT_LEN  1600 /* Maximum length of real ip packet inside concatination packet */   
+
+/*************************************************************************
+*                        concat_create                                 *
+**************************************************************************
+* DESCRIPTION: This function initializes the Ctrl data module.                 
+*                                                      
+* INPUT:               hOs - handle to Os Abstraction Layer
+*                              
+* OUTPUT:              TxCmplt_CB - call back function that return to configMngr
+*                              in order to register in the Hal
+*
+* RETURN:              Handle to the allocated Ctrl data control block
+************************************************************************/
+
+deConcatenator_t* deConcat_create(TI_HANDLE hOs)
+{
+       deConcatenator_t* pDeConcatenator;
+
+       if( hOs  == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: deConcat_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       /* alocate concatenator block */
+       pDeConcatenator = os_memoryAlloc(hOs, (sizeof(deConcatenator_t)));
+
+
+       if (!pDeConcatenator)
+       {
+               utils_nullMemoryFree(hOs, pDeConcatenator, sizeof(deConcatenator_t));
+           WLAN_OS_REPORT(("FATAL ERROR: deConcat_create(): Error Creating DeConcatenator module- Aborting\n"));
+               return(NULL);
+       }
+
+       /* reset control module control block */
+       os_memoryZero(hOs, pDeConcatenator, (sizeof(deConcatenator_t)));
+
+       pDeConcatenator->hOs = hOs;
+
+       return(pDeConcatenator);
+}
+
+/***************************************************************************
+*                                                      ctrlData_config                                            *
+****************************************************************************
+* DESCRIPTION: This function configures the Ctrl Data module           
+* 
+* INPUTS:              hCtrlData - The object
+*                              hOs - Handle to the Os Abstraction Layer
+*                              hReport - Handle to the Report object
+*                              ctrlDataInitParams - pointer to Ctrl module init parameters
+* OUTPUT:              
+* 
+* RETURNS:             OK - Configuration succesfull
+*                              NOK - Configuration unsuccesfull
+***************************************************************************/
+TI_STATUS deConcat_config(deConcatenator_t*    pDeConcatenator,
+                                                 TI_HANDLE                     hOs,
+                                                 TI_HANDLE                     hReport,
+                                                 TI_HANDLE                     hMemMngr)
+{
+       /* check parameters validity */
+       if( pDeConcatenator == NULL || hOs == NULL || 
+               hReport == NULL || hMemMngr == NULL)
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: deConcat_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+
+       /* set objects handles */
+       pDeConcatenator->hOs = hOs;
+       pDeConcatenator->hReport = hReport;
+       pDeConcatenator->hMemMngr = hMemMngr;
+
+       WLAN_REPORT_INIT(pDeConcatenator->hReport, DE_CONCATENATOR_MODULE_LOG, 
+               (".....DeConcatenator configured successfully\n"));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                                      ctrlData_unLoad                                            *
+****************************************************************************
+* DESCRIPTION: This function unload the Ctrl data module. 
+* 
+* INPUTS:              hCtrlData - the object
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK - Unload succesfull
+*                              NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS deConcat_destroy(deConcatenator_t*   pDeConcatenator)
+{
+       /* free control module controll block */
+       os_memoryFree(pDeConcatenator->hOs, pDeConcatenator, sizeof(deConcatenator_t));
+
+       return OK;
+}
+
+
+/*************************************************************************
+ *                        wdrv_rxDeConcatMsdu                            *
+ *************************************************************************
+DESCRIPTION: This function de concatenates number of MSDUs froma single 
+             MPDU.                
+                                                                                                   
+INPUT:       msduPtr     - Pointer to the first MSDU.
+             
+             
+OUTPUT:     
+
+RETURN:      OK : Deconcatenation OK.
+             NOK: Deconcatenation Faild.                                                                                                                                             
+************************************************************************/
+TI_STATUS deConcat_deConcatMsdu(deConcatenator_t*      pDeConcatenator,
+                                                               mem_MSDU_T**            MsduPtr)
+{
+       
+    Wdrv4xConcatHeader_t       *concatHdrPtr;
+    dot114xMsdu_t                      *pdot11fourXHeader;
+       mem_MSDU_T                              *firstMsduPtr = NULL;
+    UINT8                                      *currPtr;
+    UINT8                                      *newDot11HeaderPtr;
+       UINT16                                  currentLength;
+    UINT32                                     concatLength;
+    UINT32                                     rc = OK;
+    UINT32                                     parsedLen;
+       UINT32                                  msduNum = 0;
+       BOOL                                    firsdMsduInList = TRUE;
+       mem_MSDU_T                              *NextMsduPtr;
+    mem_MSDU_T                         *PrevMsduPtr = NULL;
+
+       /*print_MsduDataHeader(pDeConcatenator->hMemMngr, *MsduPtr);*/
+
+       
+   /*
+       * The 802.11 header is located in the beggining of the concat frame.
+       */
+    pdot11fourXHeader = (dot114xMsdu_t*)memMgr_BufData((*MsduPtr)->firstBDPtr);
+       
+    concatLength =  (*MsduPtr)->dataLen;
+       
+   /*
+       * The parsed size is currently the wlan snap and 4x headers.
+       */ 
+    parsedLen =  sizeof( dot114xMsdu_t );
+    currPtr =  (UINT8*) pdot11fourXHeader + sizeof(dot114xMsdu_t);
+       
+    /*
+       * Start parsing the concatenated MPDU and create an MSDUs.
+       */
+
+       if(parsedLen + sizeof(Wdrv4xConcatHeader_t) >= concatLength)
+       {
+               WLAN_REPORT_ERROR(pDeConcatenator->hReport, DE_CONCATENATOR_MODULE_LOG, 
+                               ("deConcat_deConcatMsdu: Error Parsing Deconcat Packet: concatLength = %d ",concatLength));
+               firstMsduPtr = NULL;
+               rc = NOK;
+       }
+
+    while ( parsedLen + sizeof(Wdrv4xConcatHeader_t) < concatLength ) 
+       {
+               
+               UINT8           numOfPadBytes;
+               mem_MSDU_T* CurrentMsduPtr;
+               
+               msduNum++;
+               
+               concatHdrPtr = (Wdrv4xConcatHeader_t*)currPtr;
+               
+               currentLength = wlan_htons(concatHdrPtr->len);
+
+               if( currentLength > MAX_DECONACT_LEN)
+               {
+                       WLAN_REPORT_ERROR(pDeConcatenator->hReport, DE_CONCATENATOR_MODULE_LOG, 
+                               ("deConcat_deConcatMsdu: Error Parsing Deconcat Packet Len  %d ",currentLength));
+            rc = NOK;
+                       break;
+               }
+               
+               currPtr += sizeof(Wdrv4xConcatHeader_t);
+               
+       /*
+               *  Zero Padding checking.
+               */
+               numOfPadBytes = (currentLength+ 2) % 4;
+               
+               if( numOfPadBytes ) 
+                       numOfPadBytes = 4 - numOfPadBytes;
+               
+          /*
+               * Create MSDU with one buffer for the wlan header.
+               * and copy the 802.11 header from the MSDU to it. 
+               */
+#if 1
+               /*******************************************************************/
+               /*     Deconcatenation with COPY Solution                          */
+               /*******************************************************************/         
+               
+               if( wlan_memMngrAllocMSDU(pDeConcatenator->hMemMngr, 
+                                                                 &CurrentMsduPtr, 
+                                                                 WLAN_HDR_LEN + currentLength - sizeof(macAddress_t),
+                                                                 DE_CONCAT_MODULE ) != OK)
+               {
+                       WLAN_REPORT_ERROR(pDeConcatenator->hReport, DE_CONCATENATOR_MODULE_LOG,
+                               ("fail to allocate msdu \n"));
+                       rc = NOK;
+                       break; /* fail to allocate - abort deconcatenation */
+               }
+               
+               if(firsdMsduInList == TRUE)
+               {
+                       firstMsduPtr = CurrentMsduPtr;
+                       firstMsduPtr->prevMSDUinList = NULL;
+                       firsdMsduInList = FALSE;
+               }
+               else
+               {
+                       CurrentMsduPtr->prevMSDUinList = PrevMsduPtr;
+                       PrevMsduPtr->nextMSDUinList = CurrentMsduPtr;
+               }
+
+               
+               CurrentMsduPtr->headerLen = WLAN_HDR_LEN;
+               newDot11HeaderPtr =  (UINT8 *)memMgr_BufData(CurrentMsduPtr->firstBDPtr);
+               
+               os_memoryCopy(NULL, newDot11HeaderPtr, (char*)pdot11fourXHeader, WLAN_HDR_LEN );
+               
+          /*
+               *  Copy the SA from the concatenated MSDU to the header.
+               */ 
+               os_memoryCopy(NULL, (void*)&(((dot11_header_t*)newDot11HeaderPtr)->address3), 
+                       (void*)&(concatHdrPtr->SaDa),sizeof(macAddress_t) );
+               
+          /*
+               * Reading the concatenation More bit, if it is exists, set it in each MSDU's
+               * order bit. (Used by the Ack emulation)
+               */
+               if( pdot11fourXHeader->header4x.txFlags == wlan_htons(WLAN_4X_CONCAT_MORE_BIT) )
+                       ((dot11_header_t*)newDot11HeaderPtr)->fc |= DOT11_FC_ORDER; 
+               else
+            ((dot11_header_t*)newDot11HeaderPtr)->fc &= ~DOT11_FC_ORDER;       
+
+          /*
+        *  Copy the SNAP + Payload length to the new data buffer.
+        *  ( 2 copies solution ). 
+               */
+               
+               os_memoryCopy(NULL, (void*)((UINT32)(newDot11HeaderPtr)+WLAN_HDR_LEN ), 
+                       currPtr, currentLength - sizeof(macAddress_t)  );
+               
+               
+               currPtr+= currentLength - sizeof(macAddress_t) + numOfPadBytes;
+               
+        CurrentMsduPtr->firstBDPtr->length = currentLength - sizeof(macAddress_t) + WLAN_HDR_LEN ;
+               CurrentMsduPtr->dataLen =  CurrentMsduPtr->firstBDPtr->length;
+               CurrentMsduPtr->firstBDPtr->dataOffset = 0;
+               CurrentMsduPtr->firstBDPtr->nextBDPtr = NULL;
+               
+               
+#else
+               /*******************************************************************/
+               /*     Deconcatenation with NO COPY Solution                       */
+               /*******************************************************************/ 
+               if( wlan_memMngrAllocMSDU(pDeConcatenator->hMemMngr, &buildMsduPtr,
+                       sizeof(dot11_header_t),DE_CONCAT_MODULE )==NOK)
+               {
+                       WLAN_REPORT_ERROR(pDeConcatenator->hReport, DE_CONCATENATOR_MODULE_LOG,
+                               ("fail to allocate msdu \n"));
+                       return NOK;
+               }
+               
+          /*
+               *  Copy the 802.11 header to the first buffer. (BssBridge needs the 802.11
+               *  and the SNAP in the same buffer for Ethernet header translation. 
+               */
+               newDot11HeaderPtr =  memMgr_BufData(buildMsduPtr->firstBDPtr);
+               os_memoryCopy(NULL, newDot11HeaderPtr, (char*)pdot11Header, sizeof(dot11_header_t));
+               
+          /*
+               *  Copy the SA from the concatenated MSDU to the header.
+               */ 
+               os_memoryCopy(NULL, (void*)&(((dot11_header_t*)newDot11HeaderPtr)->address3), 
+                       (void*)&(concatHdrPtr->SaDa),sizeof(macAddress_t) );
+               
+                       /*
+                       * Reading the concatenation More bit, if it is exists, set it in each MSDU's
+                       * order bit. (Used by the Ack emulation)
+               */
+               if( pdot11Header->header4x.txFlags == WLAN_4X_CONCAT_MORE_BIT )
+                       ((dot11_header_t*)newDot11HeaderPtr)->fc |= DOT11_FC_ORDER;        
+               else
+            ((dot11_header_t*)newDot11HeaderPtr)->fc &= ~DOT11_FC_ORDER;  
+               
+          /*
+               *  Copy the SNAP header to the first buffer. (BssBridge needs the 802.11
+               *  and the SNAP in the same buffer for Ethernet header translation. 
+               */
+               os_memoryCopy(NULL, (void*)((UINT32)(newDot11HeaderPtr)+sizeof(dot11_header_t)), 
+                       currPtr, sizeof(Wlan_LlcHeader_T) );
+               
+               currPtr+= sizeof(Wlan_LlcHeader_T);
+               
+               buildMsduPtr->firstBDPtr->length = sizeof( dot11_header_t ) + sizeof(Wlan_LlcHeader_T);
+               
+               /*
+               * Create a new BD, link it concatenated to the data buffer's SNAP header.
+               */
+               if( wlan_memMngrAllocBDs(pDeConcatenator->hMemMngr, 1, &payloadBdPtr) == NOK)
+               {
+                       WLAN_REPORT_ERROR(pDeConcatenator->hReport, DE_CONCATENATOR_MODULE_LOG,
+                               ("fail to allocate BD \n"));
+                       return NOK;
+               }
+               payloadBdPtr->dataBuf = MsduPtr->firstBDPtr->dataBuf;
+               payloadBdPtr->data = currPtr;
+               payloadBdPtr->length = currentLength - sizeof(macAddress_t) - sizeof(Wlan_LlcHeader_T);
+               payloadBdPtr->dataOffset = 0;
+               payloadBdPtr->nextBDPtr = NULL;
+               
+               /*
+               *  Link the MSDU first BD (wlan header) to the second one (snap+payload)
+               *  creating a complete MSDU.
+               */
+               buildMsduPtr->firstBDPtr->nextBDPtr =  payloadBdPtr;
+               payloadBdPtr->dataBuf->refCount++;
+               buildMsduPtr->dataLen =  buildMsduPtr->firstBDPtr->length + payloadBdPtr->length;
+               
+               currPtr += currentLength - sizeof(macAddress_t) - sizeof(Wlan_LlcHeader_T) + numOfPadBytes;;          
+#endif
+               
+               PrevMsduPtr = CurrentMsduPtr;
+               parsedLen += currentLength + 2 + numOfPadBytes;
+               
+    } /* while ( parsedLen < concatLength ) */
+       
+         /*
+         *  Free the c MSDU.
+         */
+       if(rc == OK)
+       {
+               wlan_memMngrFreeMSDU(pDeConcatenator->hMemMngr, (*MsduPtr)->handle);
+               /* update the return msdu */
+               *MsduPtr = firstMsduPtr;
+       }
+       else /* free all allocated MSDUs in case of failure */
+       {
+               while(firstMsduPtr)
+               {
+                       /* Save the next msdu in the list before free the current msdu */
+                       NextMsduPtr = firstMsduPtr->nextMSDUinList;
+                       wlan_memMngrFreeMSDU(pDeConcatenator->hMemMngr, firstMsduPtr->handle);
+                       firstMsduPtr = NextMsduPtr;
+               }
+       }
+  
+       return (TI_STATUS)rc;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/DeConcatenator.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/DeConcatenator.h
new file mode 100644 (file)
index 0000000..04889fb
--- /dev/null
@@ -0,0 +1,72 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:                                                                                                              */
+/*    PURPOSE:                                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _DE_CONCATENATOR_H_
+#define _DE_CONCATENATOR_H_
+
+#include "osTIType.h"
+#include "memMngrEx.h" 
+
+#define DE_CONCATENATOR_MODULE_LOG             CTRL_DATA_MODULE_LOG
+
+typedef struct
+{
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hMemMngr;
+
+} deConcatenator_t;
+
+deConcatenator_t* deConcat_create(TI_HANDLE hOs);
+
+TI_STATUS deConcat_config(deConcatenator_t*    pDeConcatenator,
+                                                 TI_HANDLE                     hOs,
+                                                 TI_HANDLE                     hReport,
+                                                 TI_HANDLE                     hMemMngr);
+
+TI_STATUS deConcat_destroy(deConcatenator_t*   pDeConcatenator);
+
+TI_STATUS deConcat_deConcatMsdu(deConcatenator_t*      pDeConcatenator,
+                                                               mem_MSDU_T**            msduPtr);
+
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.c
new file mode 100644 (file)
index 0000000..b9512db
--- /dev/null
@@ -0,0 +1,1348 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*   MODULE:   ackEmulDb.c                                                */
+/*   PURPOSE:  Ack emulation database                                     */
+/*                                                                         */
+/***************************************************************************/
+#include "osApi.h"
+#include "802_11Defs.h"
+#include "ackEmulDb.h"
+#include "report.h"
+#include "utils.h"
+
+
+static void wdrv_aeFindFreeActiveIndex(ackEmulDB_t*    ackEmulDB,UINT8 *freeIndex);
+
+static void wdrv_aeWTargetDbInit(ackEmulDB_t*  ackEmulDB);
+static void wdrv_aeWSourceDbInit(ackEmulDB_t*  ackEmulDB);
+static void wdrv_aeWSourceDbResetstation(ackEmulDB_t*  ackEmulDB,int stationIndex);
+
+/*
+ULONG rt_osTimerGetTick(void)
+{
+       ULONG sysuptime;
+       
+#if (TIWLN_MAJOR_VERSION >= 5)  
+       NdisGetSystemUpTime(&sysuptime);
+#else
+       LARGE_INTEGER systime;
+
+       NdisGetCurrentSystemTime(&systime);
+       sysuptime = (((UINT32)systime.LowPart >> 10) | ((UINT32)systime.HighPart << 22))/10;
+#endif
+       
+       return sysuptime;
+}
+
+*/
+ackEmulDB_t* ackEmulDb_create(TI_HANDLE hOs)
+{
+       ackEmulDB_t*    ackEmulDB;
+
+       if( hOs  == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: ackEmulDb_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       /* alocate concatenator block */
+       ackEmulDB = os_memoryAlloc(hOs, (sizeof(ackEmulDB_t)));
+
+       if ( (!ackEmulDB) )
+       {
+               utils_nullMemoryFree(hOs, ackEmulDB, sizeof(ackEmulDB_t));
+           WLAN_OS_REPORT(("FATAL ERROR: ackEmulDb_create(): Error Creating ackEmulDB module- Aborting\n"));
+               return(NULL);
+       }
+
+       /* reset control module control block */
+       os_memoryZero(hOs, ackEmulDB, (sizeof(ackEmulDB_t)));
+
+       ackEmulDB->hOs = hOs;
+
+       return(ackEmulDB);
+
+
+}
+
+TI_STATUS ackEmulDb_config(ackEmulDB_t*        ackEmulDB,
+                                                  TI_HANDLE    hOs,
+                                                  TI_HANDLE    hReport)
+{
+       /* check parameters validity */
+       if( (ackEmulDB == NULL) || (hOs == NULL) || (hReport == NULL) )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: ackEmulDb_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+
+       /* set objects handles */
+       ackEmulDB->hOs = hOs;
+       ackEmulDB->hReport = hReport;
+
+       wdrv_aeDbInit(ackEmulDB);
+
+       WLAN_REPORT_INIT(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG, 
+               (".....ackEmulDB configured successfully\n"));
+
+       return OK;
+
+}
+
+TI_STATUS ackEmulDb_destroy(ackEmulDB_t*       ackEmulDB)
+{
+       /* free control module controll block */
+       os_memoryFree(ackEmulDB->hOs, ackEmulDB, sizeof(ackEmulDB_t));
+
+       return OK;
+
+
+}
+
+/****************************************************************************
+ *                      wdrv_aeDbInit()
+ ****************************************************************************
+ * DESCRIPTION:        Initialize the WTarget and WSource database
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+
+void wdrv_aeDbInit(ackEmulDB_t*        ackEmulDB)
+{
+   wdrv_aeWTargetDbInit(ackEmulDB);
+   wdrv_aeWSourceDbInit(ackEmulDB);     
+}      
+
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbInit()
+ ****************************************************************************
+ * DESCRIPTION:        Initialize the WTarget database
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+
+static void wdrv_aeWTargetDbInit(ackEmulDB_t*  ackEmulDB)
+{
+       int index;
+       for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
+               wdrv_aeWTargetDbResetTuple(ackEmulDB,index); 
+       for(index=0 ; index< MAX_ACIVE_SESSION; index++)
+       {
+               ackEmulDB->activeIndexTable[index].status = INDEX_FREE;
+               ackEmulDB->activeIndexTable[index].monitorIndex = 0xff;
+       }
+       ackEmulDB->sessionsTableManager.currentActiveState =0;
+       ackEmulDB->sessionsTableManager.currentStandbyState =0;
+}
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbAddSession()
+ ****************************************************************************
+ * DESCRIPTION:        ADD new session to WTarget database
+ * 
+ * INPUTS:     pktBuf - Pointer to packet IP header
+ *          stationIndex - The station index of the packet source 
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    Session index if added, otherwise 0xff  
+ ****************************************************************************/
+
+
+int wdrv_aeWTargetDbAddSession(ackEmulDB_t*    ackEmulDB,UINT8 *pktBuf)
+{
+   int index;
+   int freeIndex = 0xff;
+   UINT32 currentTimeTick;
+   UINT32 oldestTimeTick;
+   UINT8  oldestTimeIndex;
+   
+   /* find free index */
+   for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
+   {
+      if(ackEmulDB->wdrv_aeWTargetTable[index].sPorts  == 0)
+      {
+         freeIndex = index;
+         break;
+      }
+   }
+   if (freeIndex == 0xff)
+   {
+      /* find old session to delete */
+      currentTimeTick = oldestTimeTick = os_timeStampUs(ackEmulDB->hOs);
+      oldestTimeIndex = 0xff;
+      for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
+      {
+         if(ackEmulDB->wdrv_aeWTargetTable[index].timeStamp    < oldestTimeTick)
+         {
+            oldestTimeTick = ackEmulDB->wdrv_aeWTargetTable[index].timeStamp;
+            oldestTimeIndex = index;
+         }
+      }
+      
+      if((WTARGET_TERMINATE_TIME_OUT) < (currentTimeTick - oldestTimeTick))
+      {
+         wdrv_aeWTargetDbResetTuple(ackEmulDB, oldestTimeIndex);
+         freeIndex = oldestTimeIndex;
+      }
+      
+   }
+   
+   if (freeIndex != 0xff)
+   {
+      /* Add new session */
+
+      int ipHeaderLen = ((*(unsigned char*)pktBuf  & 0x0f) * 4);
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].sPorts = wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen));                          
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].dPorts = wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen+DEST_PORT_FIELD));                          
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].srcIPAddr = wlan_ntohl(*(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD));                      
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].destIPAddr = wlan_ntohl(*(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD));                     
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].segmentSize                            =0;                    
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].sequenceNumber = wlan_ntohl(*(unsigned long*)(pktBuf+ipHeaderLen+TCP_SEQUENCE_NUMBER_FIELD));                      
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackNumber                                      =0;                         
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].timeStamp                                      =os_timeStampUs(ackEmulDB->hOs);                      
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackCounter                                =0;                      
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackTemplate.ipHeaderLen                        =0;                     
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackTemplate.tcpHeaderLen                       =0;                     
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].monitorState                           = AE_STANDBY;                     
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].equalSegmentSizeCounter        =0;          
+      ackEmulDB->wdrv_aeWTargetTable[freeIndex].yTagFlag                                       =FALSE;  
+               ackEmulDB->wdrv_aeWTargetTable[freeIndex].activeIndex                           = 0xff;
+        ackEmulDB->sessionsTableManager.currentStandbyState ++;
+   }
+   return freeIndex;
+}
+
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbFindDataSession()
+ ****************************************************************************
+ * DESCRIPTION:        Find existing session index for data packet at 
+ *                WTarget database.
+ * 
+ * INPUTS:     pktBuf - Pointer to packet IP header
+ *          stationIndex - The station index of the packet source 
+ * 
+ * OUTPUT:     monitorState - The monitor state 
+ * 
+ * RETURNS:    Ok if exist  otherwise  NOK
+ ****************************************************************************/
+
+
+int wdrv_aeWTargetDbFindDataSession(ackEmulDB_t*       ackEmulDB, UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState)
+{
+   int index;
+   int ipHeaderLen;
+
+   ipHeaderLen = ((*(unsigned char*)pktBuf  & 0x0f) * 4);
+   *monitorState = AE_INACTIVE;
+
+       for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
+       {
+               if (ackEmulDB->wdrv_aeWTargetTable[index].sPorts                == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen)) && 
+          ackEmulDB->wdrv_aeWTargetTable[index].dPorts         == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen + DEST_PORT_FIELD)) && 
+               ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr == wlan_ntohl(*(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD)) &&
+               ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr        == wlan_ntohl(*(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD)))
+               {
+                       *sessionIndex = index;
+         *monitorState = ackEmulDB->wdrv_aeWTargetTable[index].monitorState;
+
+         return OK;
+      }
+   }
+   return NOK;
+   
+}
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbFindDataSession()
+ ****************************************************************************
+ * DESCRIPTION:        Find existing session index for Ack packet at 
+ *                WTarget database.
+ * 
+ * INPUTS:     pktBuf - Pointer to packet IP header
+ *          stationIndex - The station index of the packet source 
+ * 
+ * OUTPUT:     monitorState - The monitor state 
+ * 
+ * RETURNS:            Ok if exist  otherwise  NOK  
+ ****************************************************************************/
+int wdrv_aeWTargetDbFindAckSession(ackEmulDB_t*        ackEmulDB, UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState)
+{
+   int index;
+   int ipHeaderLen;
+
+   ipHeaderLen = ((*(unsigned char*)pktBuf  & 0x0f) * 4);
+   *monitorState = AE_INACTIVE;
+
+       for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
+       {
+
+      if (ackEmulDB->wdrv_aeWTargetTable[index].sPorts         == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen + DEST_PORT_FIELD)) && 
+          ackEmulDB->wdrv_aeWTargetTable[index].dPorts         == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen )) && 
+               ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr == wlan_ntohl(*(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD)) &&
+               ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr        == wlan_ntohl(*(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD)))
+               {
+                       *sessionIndex = index;
+         *monitorState = ackEmulDB->wdrv_aeWTargetTable[index].monitorState;
+
+         return OK;
+      }
+   }
+   return NOK;
+   
+}
+
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbResetTuple()
+ ****************************************************************************
+ * DESCRIPTION:        reset tuple at WTarget database 
+ * 
+ * INPUTS:     index - the tuple index
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+
+void wdrv_aeWTargetDbResetTuple(ackEmulDB_t*   ackEmulDB, int index)
+{
+   UINT8 freeActiveIndex = ackEmulDB->wdrv_aeWTargetTable[index].activeIndex;
+       if (ackEmulDB->wdrv_aeWTargetTable[index].monitorState == AE_ACTIVE)
+       {
+               ackEmulDB->sessionsTableManager.currentActiveState --;
+       }
+       else
+       {
+               ackEmulDB->sessionsTableManager.currentStandbyState --;
+       }
+       
+   ackEmulDB->wdrv_aeWTargetTable[index].sPorts                                                =0;                          
+   ackEmulDB->wdrv_aeWTargetTable[index].dPorts                                                =0;                          
+   ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr                                     =0;                      
+   ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr                            =0;                     
+   ackEmulDB->wdrv_aeWTargetTable[index].segmentSize                           =0;                    
+   ackEmulDB->wdrv_aeWTargetTable[index].sequenceNumber                        =0;                         
+   ackEmulDB->wdrv_aeWTargetTable[index].ackNumber                                     =0;                         
+   ackEmulDB->wdrv_aeWTargetTable[index].timeStamp                                     =0;                      
+   ackEmulDB->wdrv_aeWTargetTable[index].ackCounter                            =0;                         
+   ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.ipHeaderLen                       =0;                     
+   ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.tcpHeaderLen                      =0;                     
+   ackEmulDB->wdrv_aeWTargetTable[index].monitorState                          =AE_INACTIVE;                     
+   ackEmulDB->wdrv_aeWTargetTable[index].equalSegmentSizeCounter       =0;          
+   ackEmulDB->wdrv_aeWTargetTable[index].yTagFlag                                      =FALSE; 
+       ackEmulDB->wdrv_aeWTargetTable[index].activeIndex               = 0xff;
+   if(freeActiveIndex != 0xff)
+
+   {
+      ackEmulDB->activeIndexTable[freeActiveIndex].status = INDEX_FREE;
+      ackEmulDB->activeIndexTable[freeActiveIndex].monitorIndex = 0xff;
+                       
+      
+   }
+}
+
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbPrint()
+ ****************************************************************************
+ * DESCRIPTION:        Print the WTarget database 
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWTargetDbPrint(ackEmulDB_t*        ackEmulDB)
+{
+       int index;
+   unsigned char* sipByte;
+        unsigned char*         dipByte;
+
+   WLAN_OS_REPORT(("\n current Active State = %d\n", ackEmulDB->sessionsTableManager.currentActiveState));
+   WLAN_OS_REPORT((" current Standby State = %d\n", ackEmulDB->sessionsTableManager.currentStandbyState));
+   WLAN_OS_REPORT((" --------------------------\n"));
+   
+   WLAN_OS_REPORT(("|  |   SOURCE IP   |   DEST  IP    |SPORT|DPORT|St|Seg Size |AI|AC\n"));
+   WLAN_OS_REPORT(("|------------------------------------------------------------------------| \n"));
+   for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
+   {
+          sipByte = (unsigned char*) &ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr;
+          dipByte = (unsigned char*) &ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr;
+          
+          WLAN_OS_REPORT(("|%02.2u|%03.3u.%03.3u.%03.3u.%03.3u|%03.3u.%03.3u.%03.3u.%03.3u|%05u|%05u|%02x|%09lu|%02x|%x|\n",
+                  index,
+                  sipByte[3],sipByte[2],sipByte[1],sipByte[0], 
+                  dipByte[3],dipByte[2],dipByte[1],dipByte[0],
+                  ackEmulDB->wdrv_aeWTargetTable[index].sPorts,
+                  ackEmulDB->wdrv_aeWTargetTable[index].dPorts,
+                  (UINT8)ackEmulDB->wdrv_aeWTargetTable[index].monitorState,
+                  ackEmulDB->wdrv_aeWTargetTable[index].segmentSize,
+         (UINT8)ackEmulDB->wdrv_aeWTargetTable[index].activeIndex,
+         (UINT8)ackEmulDB->wdrv_aeWTargetTable[index].ackCounter));
+                  
+   }
+}
+
+
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbSetSessionSequenceNumber()
+ ****************************************************************************
+ * DESCRIPTION:        Set the Sequence Number fild at WTarget data base
+ * 
+ * INPUTS:     index          - session index
+ *          sequenceNumber - Tcp sequence number
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+
+void wdrv_aeWTargetDbSetSessionSequenceNumber(ackEmulDB_t*     ackEmulDB, UINT8 index, UINT32 sequenceNumber)
+{
+   ackEmulDB->wdrv_aeWTargetTable[index].sequenceNumber = sequenceNumber;
+}
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbGetSessionSequenceNumber()
+ ****************************************************************************
+ * DESCRIPTION:        Get the Sequence Number fild from WTarget data base
+ * 
+ * INPUTS:     index          - session index
+ * 
+ * OUTPUT:     *sequenceNumber - Tcp sequence number
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetSessionSequenceNumber(ackEmulDB_t*     ackEmulDB, UINT8 index, UINT32 *sequenceNumber)
+{
+      *sequenceNumber = ackEmulDB->wdrv_aeWTargetTable[index].sequenceNumber;
+
+}
+
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbSetSessionSegmentSize()
+ ****************************************************************************
+ * DESCRIPTION:        Set the Segmen tSize fild at WTarget data base
+ * 
+ * INPUTS:     index          - session index
+ *          segmentSize - Tcp segment size
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWTargetDbSetSessionSegmentSize(ackEmulDB_t*        ackEmulDB, UINT8 index, UINT32 segmentSize)
+{
+   ackEmulDB->wdrv_aeWTargetTable[index].segmentSize = segmentSize;
+
+}
+
+/****************************************************************************
+ *                      wdrv_aeWTargetDbGetSessionSegmentSize()
+ ****************************************************************************
+ * DESCRIPTION:        Get the SegmentSize fild from WTarget data base
+ * 
+ * INPUTS:     index          - session index
+ * 
+ * OUTPUT:     *segmentSize - Tcp sequence number
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetSessionSegmentSize(ackEmulDB_t*        ackEmulDB, UINT8 index, UINT32 *segmentSize)
+{
+      *segmentSize = ackEmulDB->wdrv_aeWTargetTable[index].segmentSize;
+
+}
+/****************************************************************************
+ *               wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter()
+ ****************************************************************************
+ * DESCRIPTION:        Set the number of sequential packet 
+ *                with the same Segment Size.
+ * INPUTS:     index                    - session index
+ *          equalSegmentSizeCounter - the number of sequential packet
+ *                                    with the same Segment Size
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter(ackEmulDB_t*    ackEmulDB, UINT8 index, UINT8 equalSegmentSizeCounter)
+{
+       ackEmulDB->wdrv_aeWTargetTable[index].equalSegmentSizeCounter = equalSegmentSizeCounter; 
+}
+
+/****************************************************************************
+ *              wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter()
+ ****************************************************************************
+ * DESCRIPTION:        Increase and return  the number of sequential packet 
+ *                with the same Segment Size.
+ * 
+ * INPUTS:     index          - session index
+ * 
+ * OUTPUT:     *equalSegmentSizeCounter - the number of sequential packet
+ *          with the same Segment Size
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter(ackEmulDB_t*        ackEmulDB, UINT8 index, UINT8 *equalSegmentSizeCounter)
+{
+       *equalSegmentSizeCounter = (ackEmulDB->wdrv_aeWTargetTable[index].equalSegmentSizeCounter ++);
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbSetActiveState()
+ ****************************************************************************
+ * DESCRIPTION:        Find free active index and update the WTarget DB with 
+ *                this index
+ * 
+ * INPUTS:     index          - monitor session index
+ * 
+ * OUTPUT:     *activeIndex - the active index
+ * 
+ * RETURNS:    Ok if change state to active, otherwise NOK
+ ****************************************************************************/
+int wdrv_aeWTargetDbSetActiveState(ackEmulDB_t*        ackEmulDB, UINT8 index , UINT8 *activeIndex)
+{
+   UINT8 monitorState = AE_ACTIVE ;
+   UINT8 freeIndex ,aIndex;
+   
+   wdrv_aeFindFreeActiveIndex(ackEmulDB, &freeIndex);
+   
+   if(freeIndex == 0xff)
+   {
+      /* We don't have free active index we try find old active session to delete */
+      UINT32 currentTimeTick;
+      UINT32 oldestTimeTick;
+      UINT8  oldestTimeIndex;
+      currentTimeTick = oldestTimeTick = os_timeStampUs(ackEmulDB->hOs);
+      oldestTimeIndex = 0xff;
+      for(aIndex=0 ; aIndex< MAX_ACIVE_SESSION; aIndex++)
+      {
+         if(ackEmulDB->wdrv_aeWTargetTable[ackEmulDB->activeIndexTable[aIndex].monitorIndex].timeStamp < 
+            oldestTimeTick)
+         {
+            oldestTimeTick = ackEmulDB->wdrv_aeWTargetTable[ackEmulDB->activeIndexTable[aIndex].monitorIndex].timeStamp;
+            oldestTimeIndex = aIndex;
+         }
+      }
+      
+      if((WTARGET_TERMINATE_TIME_OUT) < (currentTimeTick - oldestTimeTick))
+      {
+         wdrv_aeWTargetDbResetTuple(ackEmulDB, ackEmulDB->activeIndexTable[oldestTimeIndex].monitorIndex);
+         freeIndex = oldestTimeIndex;
+      }
+      
+   }
+
+
+   if (freeIndex == 0xff)
+   {
+      *activeIndex = 0xff;
+      return NOK;
+   }
+
+   /* we have new active index */
+   ackEmulDB->activeIndexTable[freeIndex].status = INDEX_BUSY;
+   ackEmulDB->activeIndexTable[freeIndex].monitorIndex = index;
+   ackEmulDB->wdrv_aeWTargetTable[index].activeIndex = freeIndex;
+   *activeIndex = freeIndex;
+
+   ackEmulDB->sessionsTableManager.currentActiveState ++;
+   ackEmulDB->sessionsTableManager.currentStandbyState --;
+   
+   /* set the monitor session state to ACTIVE */
+   wdrv_aeWTargetDbSetSessionMonitorState(ackEmulDB, index, monitorState);   
+   return OK;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbSetSessionMonitorState()
+ ****************************************************************************
+ * DESCRIPTION:        Set the state of monitor session.
+ * 
+ * INPUTS:     index       - session index
+ *          
+ * 
+ * OUTPUT:     monitorState - the new monitor state
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+
+void wdrv_aeWTargetDbSetSessionMonitorState(ackEmulDB_t*       ackEmulDB, UINT8 index, UINT8 monitorState)
+{
+      ackEmulDB->wdrv_aeWTargetTable[index].monitorState = monitorState;
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbGetSessionAckNumber()
+ ****************************************************************************
+ * DESCRIPTION:        Get the monitor session ack number
+ * 
+ * INPUTS:     index          - monitor session index
+ * 
+ * OUTPUT:     *ackNumber - The ack number
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetSessionAckNumber(ackEmulDB_t*  ackEmulDB, UINT8 index, UINT32 *ackNumber)
+{
+      *ackNumber = ackEmulDB->wdrv_aeWTargetTable[index].ackNumber;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbSetSessionAckNumber()
+ ****************************************************************************
+ * DESCRIPTION:        Set the monitor session ack number
+ * 
+ * INPUTS:     index          - monitor session index
+ *             ackNumber - The ack number
+ * 
+ * OUTPUT:     ackNumber - The ack number
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbSetSessionAckNumber(ackEmulDB_t*  ackEmulDB, UINT8 index, UINT32 ackNumber)
+{
+      ackEmulDB->wdrv_aeWTargetTable[index].ackNumber = ackNumber;
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbGetSessionAckCounter()
+ ****************************************************************************
+ * DESCRIPTION:        Get the monitor session ack counter
+ * 
+ * INPUTS:     index          - monitor session index
+ * 
+ * OUTPUT:     *ackCounter - The ack counter
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 *ackCounter)
+{
+      *ackCounter = ackEmulDB->wdrv_aeWTargetTable[index].ackCounter;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbSetSessionAckCounter()
+ ****************************************************************************
+ * DESCRIPTION:        Set the monitor session ack counter
+ * 
+ * INPUTS:     index          - monitor session index
+ *          ackCounter     - The ack counter
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 ackCounter)
+{
+      ackEmulDB->wdrv_aeWTargetTable[index].ackCounter = ackCounter;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbGetSessionActiveIndex()
+ ****************************************************************************
+ * DESCRIPTION:        Get the monitor session active index
+ * 
+ * INPUTS:     index          - monitor session index
+ * 
+ * OUTPUT:     *activeIndex - The session active index
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetSessionActiveIndex(ackEmulDB_t*        ackEmulDB, UINT8 index, UINT8 *activeIndex)
+{
+      *activeIndex = ackEmulDB->wdrv_aeWTargetTable[index].activeIndex;
+
+}
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbGetLastWackInfo()
+ ****************************************************************************
+ * DESCRIPTION:        Get the last wack info for this monitor session.
+ * 
+ * INPUTS:     index          - monitor session index
+ * 
+ * OUTPUT:     *lastWackInfo -  the last wack info
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbGetSessionTimeStamp(ackEmulDB_t*  ackEmulDB, UINT8 index, UINT32 *timeStamp)
+{
+      *timeStamp = ackEmulDB->wdrv_aeWTargetTable[index].timeStamp;
+
+}
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbSetSessionTimeStamp()
+ ****************************************************************************
+ * DESCRIPTION:        Set the time stamp for this monitor session.
+ * 
+ * INPUTS:     index          - monitor session index
+ *          timeStamp -  the time stamp info
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbSetSessionTimeStamp(ackEmulDB_t*  ackEmulDB, UINT8 index, UINT32 timeStamp)
+{
+      ackEmulDB->wdrv_aeWTargetTable[index].timeStamp= timeStamp;
+}
+
+/****************************************************************************
+ *                   wdrv_aeFindFreeActiveIndex()
+ ****************************************************************************
+ * DESCRIPTION:        find if there is free index for active session.
+ * 
+ * INPUTS:     None.
+ * 
+ * OUTPUT:     *freeIndex -  index of free tuple in table activeIndexTable
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+static void wdrv_aeFindFreeActiveIndex(ackEmulDB_t*    ackEmulDB, UINT8 *freeIndex)
+{
+       UINT8 index;
+       *freeIndex = 0xff;
+       for(index=0 ; index< MAX_ACIVE_SESSION; index++)
+       {
+               if(ackEmulDB->activeIndexTable[index].status == INDEX_FREE)
+               {
+                       *freeIndex = index;
+                       return;
+               }
+       }       
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbSaveAckTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        save the Tcp ack template for the WTarget side.
+ * 
+ * INPUTS:     index          - monitor session index.
+ *          *pIpHeader     - Pointer to packet IP header
+ * 
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbSaveAckTemplate(ackEmulDB_t*      ackEmulDB, UINT8 index, UINT8 *pIpHeader)
+{
+
+   UINT8 ipHeaderLen;
+   UINT8 tcpHeaderLen;
+   
+   ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+   tcpHeaderLen = ((((*(unsigned char*)(pIpHeader + ipHeaderLen+TCP_OFFSET_FIELD))& 0xf0)>>4) * 4);
+   os_memoryCopy(NULL, ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.data, pIpHeader, ipHeaderLen+tcpHeaderLen);
+   ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.ipHeaderLen = ipHeaderLen;
+   ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.tcpHeaderLen = tcpHeaderLen;
+}
+
+
+
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbUpdateAckTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        Update the Tcp ack template for the WTarget side.
+ * 
+ * INPUTS:     index          - monitor session index.
+ *          sequenceNumber - New sequence number
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWTargetDbUpdateAckTemplate(ackEmulDB_t*    ackEmulDB, UINT8 index, UINT32 sequenceNumber)
+{
+   UINT8 *pSequenceNumber;
+   /* Update Template Sequence Number */
+   pSequenceNumber = ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.data + 
+        ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.tcpHeaderLen +TCP_SEQUENCE_NUMBER_FIELD;
+   *(unsigned long*)(pSequenceNumber) = wlan_ntohl(sequenceNumber);
+}
+
+
+
+/****************************************************************************
+ *                   wdrv_aeWTargetDbCmpAckTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        comper the current tcp ack with ack template.
+ * 
+ * INPUTS:     index          - monitor session index.
+ *          *pIpHeader     - Pointer to packet IP header
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+int wdrv_aeWTargetDbCmpAckTemplate(ackEmulDB_t*        ackEmulDB, UINT8 index, UINT8 *pIpHeader)
+{
+   UINT8 ipHeaderLen;
+   UINT8 *pTcpHeader;
+   UINT8 *pIpHeaderTemplate;
+   UINT8 *pTcpHeaderTemplate;
+   UINT8 ipHeaderTemplateLen;
+   
+   ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+   pIpHeaderTemplate = ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.data;
+   ipHeaderTemplateLen = ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.ipHeaderLen;
+   
+   /* Comprer IP field: Version ,Header Length, Precedence, TOS , Unused, Total Length */
+   if((*(UINT32*)(pIpHeaderTemplate))!=(*(UINT32*)pIpHeader))
+   {
+      WLAN_OS_REPORT(("\nCompare field: Version,Header Length, Precedence, TOS, Total Length fail \n"));
+      return NOK;
+   }
+
+   /* Comprer IP field:Fragmentation Flags, Fragment Offset, TTL */
+   if((*(UINT32*)(pIpHeaderTemplate+IP_IDENTIFIER_FIELD+2))!= 
+      (*(UINT32*)(pIpHeader+IP_IDENTIFIER_FIELD+2)))
+   {
+               WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG, 
+                       ("Compare IP field:Fragmentation Flags, Fragment Offset, TTL fail \n"));
+      return NOK;
+   }
+   
+   pTcpHeader = pIpHeader + ipHeaderLen;
+   pTcpHeaderTemplate = pIpHeaderTemplate + ipHeaderTemplateLen;
+   
+   
+      /* Comprer TCP field: Offset, Reserved, Code, Window */
+      if((*(UINT32*)(pTcpHeaderTemplate+TCP_ACK_NUMBER_FIELD+4))!= 
+      (*(UINT32*)(pTcpHeader+TCP_ACK_NUMBER_FIELD+4)))
+   {
+               WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG, 
+                       ("Compare TCP field: Offset, Reserved, Code, Window fail\n"));
+      return NOK;
+   }
+      /* Comprer TCP field: Urgent */
+   
+   if((*(UINT16*)(pTcpHeaderTemplate+TCP_CHECKSUM_FIELD+2))!= 
+      (*(UINT16*)(pTcpHeader+TCP_CHECKSUM_FIELD+2)))
+   {
+               WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG, 
+                       ("Compare TCP field: Urgent fail\n\n"));
+      return NOK;
+   }
+   
+      
+      /* Comprer TCP field: Sequence Number */
+   if((*(UINT32*)(pTcpHeaderTemplate+TCP_SEQUENCE_NUMBER_FIELD))!= 
+      (*(UINT32*)(pTcpHeader+TCP_SEQUENCE_NUMBER_FIELD)))
+   {
+       WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG, 
+                       ("Comprare TCP field: Sequence Number fail\n\n"));
+       /* add Ytag */
+      return NOK;
+   }
+   
+
+   return OK;
+   
+}
+
+
+/****************************************************************************
+ *                         wdrv_aeDbGetXTagStatus()
+ ****************************************************************************
+ * DESCRIPTION:        Get the Xtag status of the source station for this 
+ *                session index.
+ * 
+ * INPUTS:     sessionIndex  - monitor session index
+ * 
+ * OUTPUT:     *status -  Xtag status
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeDbGetXTagStatus(ackEmulDB_t*       ackEmulDB, UINT8 sessionIndex, UINT8 *status)
+{
+      UINT16 stationIndex = ackEmulDB->wdrv_aeWTargetTable[sessionIndex].sourceStationIndex;
+      if(stationIndex != 0xff)
+         *status = ackEmulDB->ackEmulationXTagTable[stationIndex];
+}
+
+/****************************************************************************
+ *                         wdrv_aeDbSetXTagStatus()
+ ****************************************************************************
+ * DESCRIPTION:        Set the Xtag status of the source station for this 
+ *                session index.
+ * 
+ * INPUTS:     sessionIndex  - monitor session index
+ * 
+ * OUTPUT:     status -  Xtag status
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeDbSetXTagStatus(ackEmulDB_t*       ackEmulDB, UINT8 sessionIndex, UINT8 status)
+{
+      UINT16 stationIndex = ackEmulDB->wdrv_aeWTargetTable[sessionIndex].sourceStationIndex;
+      if(stationIndex != 0xff)
+         ackEmulDB->ackEmulationXTagTable[stationIndex] = status;
+}
+
+
+
+
+
+
+
+/******************************* WSource Data base *************************************/
+
+/****************************************************************************
+ *                      wdrv_aeWSourceDbInit()
+ ****************************************************************************
+ * DESCRIPTION:        Initialize the WSource database
+ * 
+ * INPUTS:     None
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+static void wdrv_aeWSourceDbInit(ackEmulDB_t*  ackEmulDB)
+{
+       int stationIndex;
+       for (stationIndex =0;stationIndex < MAX_AE_STATIONS;stationIndex++)
+               wdrv_aeWSourceDbResetstation(ackEmulDB, stationIndex);
+}
+
+/****************************************************************************
+ *                      wdrv_aeWSourceDbResetstation()
+ ****************************************************************************
+ * DESCRIPTION:        Reset all the WSource tuple for specific station.
+ * 
+ * INPUTS:     stationIndex - index of station to reset
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+static void wdrv_aeWSourceDbResetstation(ackEmulDB_t*  ackEmulDB, int stationIndex)
+{
+       int activeIndex;
+       for (activeIndex =0;activeIndex < MAX_ACIVE_SESSION;activeIndex++)
+       {
+               ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize=0;              
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber =0;                          
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter =0;                         
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp =0;                          
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem = REORDER_PROBLEM_OFF;
+               ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen =0;   
+               ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen =0;  
+       }                       
+}
+
+/****************************************************************************
+ *                      wdrv_aeWSourceDbResetSession()
+ ****************************************************************************
+ * DESCRIPTION:        Reset specific WSource session tuple for specific station.
+ * 
+ * INPUTS:     stationIndex - index of station to reset
+ *          activeIndex  - the index of the WSource tcp session
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    None
+ ****************************************************************************/
+void wdrv_aeWSourceDbResetSession(ackEmulDB_t* ackEmulDB, int stationIndex,int activeIndex)
+{
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize=0;              
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber =0;                             
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter =0;                            
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp =0;                             
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem = REORDER_PROBLEM_OFF;
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen =0;       
+   ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen =0;      
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceSaveAckTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        save the Tcp ack template for the WSource side.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          *dataBuf              -  Packet data
+ *          dataLen               -  data len
+ *          segmentSize           - segment Size
+ * 
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceSaveAckTemplate(ackEmulDB_t*        ackEmulDB, UINT8 stationIndex,UINT8 activeIndex,
+                                                                  UINT8* pDot11Header, UINT8 *pWlanSnapHeader, UINT8 *pIpHeader 
+                                                                  ,UINT16 dataLen,UINT16 segmentSize)
+{
+       UINT8 *pTcpHeader;
+       UINT8 *pTemplateData;
+       UINT8 ipHeaderLen;
+       UINT8 tcpHeaderLen;
+       UINT32 ackNumber;
+       
+       
+       WLAN_OS_REPORT(("wdrv_aeWSourceSaveAckTemplate datalen = %d\n",dataLen));
+       
+    wdrv_aeWSourceDbSetSessionTimeStamp(ackEmulDB, stationIndex,activeIndex,os_timeStampUs(ackEmulDB->hOs));   
+       
+       
+       ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+       pTcpHeader = pIpHeader + ipHeaderLen;
+       tcpHeaderLen = ((((*(unsigned char*)(pTcpHeader+TCP_OFFSET_FIELD))& 0xf0)>>4) * 4);
+       pTemplateData = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.data;
+       
+       os_memoryCopy(ackEmulDB->hOs, pTemplateData,pDot11Header, WLAN_HDR_LEN);
+       os_memoryCopy(ackEmulDB->hOs, pTemplateData+WLAN_HDR_LEN,pWlanSnapHeader, WLAN_SNAP_HDR_LEN);
+       WLAN_OS_REPORT((" osMoveMemory 2 \n"));   
+       
+       /* osMoveMemory(pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN,pIpHeader, dataLen-WLAN_HDR_LEN-WLAN_SNAP_HDR_LEN);*/
+       os_memoryCopy(ackEmulDB->hOs, pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN,pIpHeader, dataLen);
+       ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen = ipHeaderLen;
+       ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen = tcpHeaderLen;
+       
+       ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize = segmentSize;    
+       
+       ackNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_ACK_NUMBER_FIELD));
+       ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber = ackNumber;
+       ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter =  ackNumber/(segmentSize*2);      
+       ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem = REORDER_PROBLEM_OFF;
+       
+       /* reset the Ip & TCP Checksum */
+       *(UINT16*)(pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN+IP_CHECKSUM_FIELD) = 0x0000;
+       *(UINT16*)(pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN+ipHeaderLen+TCP_CHECKSUM_FIELD) = 0x0000;
+       
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetSessionAckCounter()
+ ****************************************************************************
+ * DESCRIPTION:        Get the ackCounter fild from WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ * 
+ * OUTPUT:     *ackCounter -         -  the Ack Counter
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackCounter)
+{
+      *ackCounter = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetSessionAckCounter()
+ ****************************************************************************
+ * DESCRIPTION:        Set the ackCounter fild at WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          ackCounter -         -  the Ack Counter
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 ackCounter)
+{
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter= ackCounter;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetSessionAckNumber()
+ ****************************************************************************
+ * DESCRIPTION:        Get the AckNumber fild from WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ * 
+ * OUTPUT:     *ackNumber -         -  the ack number
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbGetSessionAckNumber(ackEmulDB_t*  ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackNumber)
+{
+      *ackNumber = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbSetSessionAckNumber()
+ ****************************************************************************
+ * DESCRIPTION:        Set the ackNumber fild at WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          ackNumber -           -  the ack number
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbSetSessionAckNumber(ackEmulDB_t*  ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 ackNumber)
+{
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber= ackNumber;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetSessionSegmentSize()
+ ****************************************************************************
+ * DESCRIPTION:        Get the SegmentSize fild from WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ * 
+ * OUTPUT:     *segmentSize -         -  the ack segment size
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbGetSessionSegmentSize(ackEmulDB_t*        ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *segmentSize)
+{
+      *segmentSize = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbSetSessionSegmentSize()
+ ****************************************************************************
+ * DESCRIPTION:        Set the segmentSize fild at WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          segmentSize -         -  the segment size
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbSetSessionSegmentSize(ackEmulDB_t*        ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 segmentSize)
+{
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize= segmentSize;
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetSessionTimeStamp()
+ ****************************************************************************
+ * DESCRIPTION:        Get the timeStamp fild from WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ * 
+ * OUTPUT:     *timeStamp -         -  the time stamp
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbGetSessionTimeStamp(ackEmulDB_t*  ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *timeStamp)
+{
+      *timeStamp = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbSetSessionTimeStamp()
+ ****************************************************************************
+ * DESCRIPTION:        Set the timeStamp fild at WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          timeStamp -         -  the time stamp
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbSetSessionTimeStamp(ackEmulDB_t*  ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 timeStamp)
+{
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp= timeStamp;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetSessionAckReorderProblem()
+ ****************************************************************************
+ * DESCRIPTION:        Get the ack reorder problem fild from WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ * 
+ * OUTPUT:     *ackReorderProblem    -  the ack reorder problem
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbGetSessionAckReorderProblem(ackEmulDB_t*  ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackReorderProblem)
+{
+      *ackReorderProblem = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbSetSessionAckReorderProblem()
+ ****************************************************************************
+ * DESCRIPTION:        Set the timeStamp fild at WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          ackReorderProblem     -  the ack reorder problem
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbSetSessionAckReorderProblem(ackEmulDB_t*  ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 ackReorderProblem)
+{
+      ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem= ackReorderProblem;
+}
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbGetAckTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        Get the ack reorder problem fild from WSource data base.
+ * 
+ * INPUTS:     stationIndex          -  station index.
+ *          activeIndex           -  session index
+ *          
+ * OUTPUT:     **pTeplate            -  pointer to the ack template buffer.
+ *          *ipHeaderLen          -  IP header length of Ack template.
+ *          tcpHeaderLen          -  TCP header length of Ack template.
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbGetAckTemplate(ackEmulDB_t*       ackEmulDB, UINT16 stationIndex, UINT8 activeIndex,UINT8 **pTeplate,
+                                                                                                        UINT8 *ipHeaderLen, UINT8 *tcpHeaderLen)
+{                                                                                                                                                                      
+      *ipHeaderLen   = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen;
+      *tcpHeaderLen  = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen;
+      *pTeplate      = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.data;
+}
+
+
+/****************************************************************************
+ *                   wdrv_aeWSourceDbUpdateTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        .Fide  and updte the WSource monitor session 
+ * 
+ * INPUTS:     *pktBuf               -  receive tcp Ack buffer.
+ *          stationIndex          -  station index
+ *          
+ * OUTPUT:     *sessionIndex         -  The session index of the received ack
+ * 
+ * RETURNS:None
+ ****************************************************************************/
+void wdrv_aeWSourceDbUpdateTemplate(ackEmulDB_t*       ackEmulDB, UINT8 *pktBuf,UINT8 stationIndex,UINT8 *sessionIndex)
+{
+   int index;
+   int ipHeaderLen;
+   UINT8 *pTmpIpHeader;
+   int tmpIpHeaderLen;
+   UINT32 ackNumber;
+   UINT32 prevAckNumber;
+   UINT32 segmentSize;
+   UINT32 reorderProblemStatus;
+   *sessionIndex =0xff;
+
+   ipHeaderLen = ((*(unsigned char*)pktBuf  & 0x0f) * 4);
+   /* Find WSource session */
+   for(index=0 ; index< MAX_ACIVE_SESSION; index++)
+       {
+      pTmpIpHeader = (ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackTemplate.data)+ WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN;
+      tmpIpHeaderLen = ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackTemplate.ipHeaderLen;
+      if (     *(UINT16*)(pTmpIpHeader +tmpIpHeaderLen + DEST_PORT_FIELD)== *(UINT16*)(pktBuf +ipHeaderLen + DEST_PORT_FIELD) && 
+            *(UINT16*)(pTmpIpHeader +tmpIpHeaderLen )  == *(UINT16*)(pktBuf +ipHeaderLen ) && 
+                *(unsigned long*)(pTmpIpHeader+IP_DEST_ADDRESS_FIELD)  == *(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD) &&
+            *(unsigned long*)(pTmpIpHeader+IP_SRC_ADDRESS_FIELD)       == *(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD))
+      {
+         /* Update ackNumber , ackCounter and reorder problem flag */
+         ackNumber = wlan_ntohl(*(unsigned long*)(pktBuf+ipHeaderLen+TCP_ACK_NUMBER_FIELD));
+         segmentSize = ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].segmentSize;
+                       prevAckNumber = ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackNumber;
+         
+         
+         if((prevAckNumber % (segmentSize*2))>(ackNumber % (segmentSize*2)))
+         {
+            reorderProblemStatus = ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackReorderProblem;
+
+            switch(reorderProblemStatus)
+            {
+            case REORDER_PROBLEM_OFF:
+               ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackReorderProblem = REORDER_PROBLEM_ON;
+               break;
+            case REORDER_PROBLEM_ON:
+               ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackReorderProblem = REORDER_PROBLEM_PRE;
+               break;
+            case REORDER_PROBLEM_PRE:
+            default:
+               break;
+            }
+         }
+                       
+         ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackNumber = ackNumber;
+         ackEmulDB->wdrv_aeWSourceTable[stationIndex][index].ackCounter =      ackNumber/(segmentSize*2);      
+          *(unsigned long*)(pTmpIpHeader+tmpIpHeaderLen+TCP_SEQUENCE_NUMBER_FIELD) =
+          *(unsigned long*)(pktBuf+ipHeaderLen+TCP_SEQUENCE_NUMBER_FIELD);
+         
+         *sessionIndex = index;
+         WLAN_OS_REPORT(("\nindex =  = %d ackNumber %X , indentifier %d\n", *sessionIndex,ackNumber,
+            *(UINT16*)(pktBuf+IP_IDENTIFIER_FIELD)));
+       
+         
+         return ;
+      }
+   }
+   return ;
+   
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.h
new file mode 100644 (file)
index 0000000..d0a5296
--- /dev/null
@@ -0,0 +1,240 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*   MODULE:   ackEmulDb.h                                                */
+/*   PURPOSE:  Ack emulation database                                     */
+/*                                                                         */
+/***************************************************************************/
+#ifndef _ACK_EMULATION_DB_H_
+#define _ACK_EMULATION_DB_H_
+
+#include "osTIType.h"
+
+#define ACK_EMUL_MODULE_LOG            CTRL_DATA_MODULE_LOG
+void ackEGetPktType(unsigned char* pPacket , UINT16 *packetInclude, UINT16 *tcpDataSize);
+
+#define TCP_LOOKAHEAD_SIZE 64
+#define MAX_ACK_TEMPLATE_SIZE 100
+#define MAX_AE_STATIONS 1
+
+
+#define IP_PROTOCOL_NUMBER          0x0800
+#define TCP_PROTOCOL                0x06
+#define IP_TOTAL_LEN_FIELD          2
+#define IP_IDENTIFIER_FIELD         4
+
+#define IP_PROTOCOL_FIELD           9
+#define IP_CHECKSUM_FIELD           10
+#define DEST_PORT_FIELD             2
+#define IP_SRC_ADDRESS_FIELD              12
+#define IP_DEST_ADDRESS_FIELD             16
+
+
+#define TCP_SEQUENCE_NUMBER_FIELD      4
+#define TCP_ACK_NUMBER_FIELD        8
+#define TCP_OFFSET_FIELD                12
+#define TCP_CHECKSUM_FIELD              16
+
+#define WTARGET_ACTIVE_TIME_OUT 500000 /* was 500 */
+#define WTARGET_TERMINATE_TIME_OUT 1000
+#define WSOURCE_SESSION_TIME_OUT 700
+
+#define MAX_ACIVE_SESSION      2
+#define MAX_STANDBY_SESSION 8
+
+#define INDEX_FREE 0
+#define INDEX_BUSY 1
+
+
+typedef struct {
+  int  lastUsedIndex;
+  int  currentActiveState;
+  int  currentStandbyState;
+} sessionsTableManager_T;
+
+typedef struct {
+       int status;                     /* INDEX_FREE or INDEX_BUSY */
+       int monitorIndex ; /* Index in wdrv_aeWTargetTable */
+}activeIndexTable_T;
+
+
+
+typedef struct {  
+   UINT8 data[MAX_ACK_TEMPLATE_SIZE];
+   UINT8 ipHeaderLen;
+   UINT8 tcpHeaderLen;
+} ackTemplate_T;
+
+typedef struct {  
+   UINT16      sPorts;                              /* Include source port  */
+   UINT16      dPorts;                              /* Include destination port */
+   UINT32      srcIPAddr;                          /* source ip address */
+   UINT32      destIPAddr;                         /* destination ip address */
+   UINT32   segmentSize;                        /* Stable segment size */
+   UINT32   sequenceNumber;                      /* The data sequence number */
+   UINT32   ackNumber;                         /* Specifies the next byte expected.*/
+   UINT32   timeStamp;                          /*  */
+   UINT32   ackCounter;                                /* The number of 2 * Segement_size in ACK number  */
+   ackTemplate_T    ackTemplate;                               /* Ack template block */ 
+   UINT8    monitorState;                       /* current monitor state */
+   UINT8    equalSegmentSizeCounter;            /* count the number of equal segment size. */
+   UINT8    yTagFlag;                           /* True if send Y tag */
+   UINT8    activeIndex;                        /* Active session index */
+   UINT16    sourceStationIndex;                 /* Source station index */
+} ackEmulationWTargetDbTyple_T;
+
+
+typedef struct {  
+   UINT32   segmentSize;                        /* Stable segment size */
+   UINT32   ackNumber;                         /* Specifies the next byte expected.*/
+   UINT32   ackCounter;                                /* The number of 2 * Segement_size in ACK number  */
+   UINT32   timeStamp;                         /* The number of 2 * Segement_size in ACK number  */
+   UINT32   ackReorderProblem;                
+   ackTemplate_T    ackTemplate;                               /* Ack template block */ 
+}ackEmulationWSourceDbTyple_T;
+
+
+/* Ack emulation monitor states */
+typedef enum {
+       REORDER_PROBLEM_OFF =0,
+       REORDER_PROBLEM_ON,
+       REORDER_PROBLEM_PRE,
+} wdrv_eaAckReorderProblem_T;
+
+
+typedef enum {
+       AE_INACTIVE =0,
+       AE_STANDBY,
+       AE_CANDIDATE_ACTIVE,
+       AE_ACTIVE,
+       AE_TERMINATE,
+} wdrv_eaMonitorStatus_T;
+
+
+typedef struct 
+{
+       TI_HANDLE       hOs;
+       TI_HANDLE       hReport;
+
+
+       /* This table store the WTarget monitor session */ 
+       ackEmulationWTargetDbTyple_T wdrv_aeWTargetTable[MAX_ACIVE_SESSION+MAX_STANDBY_SESSION];
+       sessionsTableManager_T sessionsTableManager;
+
+       /* This table store the WSource monitor session */ 
+       ackEmulationWSourceDbTyple_T wdrv_aeWSourceTable[MAX_AE_STATIONS][MAX_ACIVE_SESSION];
+
+       /* This table store the Xtag status */ 
+       UINT8 ackEmulationXTagTable[MAX_AE_STATIONS];
+
+       /* This table store the active monitor session index */ 
+       activeIndexTable_T activeIndexTable[MAX_ACIVE_SESSION];
+                       
+}ackEmulDB_t;
+
+
+ackEmulDB_t* ackEmulDb_create(TI_HANDLE hOs);
+
+TI_STATUS ackEmulDb_config(ackEmulDB_t*        ackEmulDB,
+                                                  TI_HANDLE    hOs,
+                                                  TI_HANDLE    hReport);
+
+TI_STATUS ackEmulDb_destroy(ackEmulDB_t*       ackEmulDB);
+
+void wdrv_aeDbInit(ackEmulDB_t*        ackEmulDB);
+void wdrv_aeWTargetDbPrint(ackEmulDB_t*        ackEmulDB);
+int wdrv_aeWTargetDbFindDataSession(ackEmulDB_t*       ackEmulDB,UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState);
+int wdrv_aeWTargetDbFindAckSession(ackEmulDB_t*        ackEmulDB,UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState);
+int wdrv_aeWTargetDbAddSession(ackEmulDB_t*    ackEmulDB,UINT8 *pktBuf);
+
+int wdrv_aeWTargetDbDelSession(ackEmulDB_t*    ackEmulDB,UINT8 SessionIndex);
+int wdrv_aeWTargetDbSetActiveState(ackEmulDB_t*        ackEmulDB,UINT8 index , UINT8 *activeIndex);
+void wdrv_aeWTargetDbSaveAckTemplate(ackEmulDB_t*      ackEmulDB,UINT8 index, UINT8 *pIpHeader);
+void wdrv_aeWTargetDbUpdateAckTemplate(ackEmulDB_t*    ackEmulDB,UINT8 index, UINT32 sequenceNumber);
+int wdrv_aeWTargetDbCmpAckTemplate(ackEmulDB_t*        ackEmulDB,UINT8 index, UINT8 *pIpHeader);
+void wdrv_aeWTargetDbResetTuple(ackEmulDB_t*   ackEmulDB,int index);
+
+void wdrv_aeWTargetDbGetSessionSequenceNumber(ackEmulDB_t*     ackEmulDB,UINT8 index, UINT32 *sequenceNumber);
+void wdrv_aeWTargetDbGetSessionAckNumber(ackEmulDB_t*  ackEmulDB,UINT8 index, UINT32 *ackNumber);
+void wdrv_aeWTargetDbGetSessionSegmentSize(ackEmulDB_t*        ackEmulDB,UINT8 index, UINT32 *segmentSize);
+void wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter(ackEmulDB_t*        ackEmulDB,UINT8 index, UINT8 *equalSegmentSizeCounter);
+void wdrv_aeWTargetDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 *ackCounter);
+void wdrv_aeWTargetDbGetSessionMmonitorState(ackEmulDB_t*      ackEmulDB,UINT8 index, UINT8 *monitorState);
+void wdrv_aeWTargetDbGetSessionActiveIndex(ackEmulDB_t*        ackEmulDB,UINT8 index, UINT8 *activeIndex);
+
+void wdrv_aeWTargetDbSetSessionSequenceNumber(ackEmulDB_t*     ackEmulDB,UINT8 index, UINT32 sequenceNumber);
+void wdrv_aeWTargetDbSetSessionAckNumber(ackEmulDB_t*  ackEmulDB,UINT8 index, UINT32 ackNumber);
+void wdrv_aeWTargetDbSetSessionSegmentSize(ackEmulDB_t*        ackEmulDB,UINT8 index, UINT32 segmentSize);
+void wdrv_aeWTargetDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 ackCounter);
+void wdrv_aeWTargetDbSetSessionMonitorState(ackEmulDB_t*       ackEmulDB,UINT8 index, UINT8 monitorState);
+void wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter(ackEmulDB_t*    ackEmulDB,UINT8 index, UINT8 equalSegmentSizeCounter);
+void wdrv_aeWTargetDbGetSessionTimeStamp(ackEmulDB_t*  ackEmulDB,UINT8 index, UINT32 *timeStamp);
+void wdrv_aeWTargetDbSetSessionTimeStamp(ackEmulDB_t*  ackEmulDB,UINT8 index, UINT32 timeStamp);
+
+void wdrv_aeWSourceDbUpdateTemplate(ackEmulDB_t*       ackEmulDB,UINT8 *pktBuf,UINT8 stationIndex,UINT8 *sessionIndex);
+void wdrv_aeWSourceDbResetSession(ackEmulDB_t* ackEmulDB,int stationIndex,int activeIndex);
+
+void wdrv_aeWSourceSaveAckTemplate(ackEmulDB_t*        ackEmulDB,UINT8 stationIndex,UINT8 activeIndex,
+                                                                                         UINT8* pDot11Header, UINT8 *pWlanSnapHeader, UINT8 *pIpHeader 
+                                                                                               ,UINT16 dataLen,UINT16 segmentSize);
+
+void wdrv_aeWSourceDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackCounter);
+
+void wdrv_aeWSourceDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 ackCounter);
+
+void wdrv_aeWSourceDbGetSessionAckNumber(ackEmulDB_t*  ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackNumber);
+void wdrv_aeWSourceDbSetSessionAckNumber(ackEmulDB_t*  ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 ackNumber);
+
+void wdrv_aeWSourceDbGetSessionSegmentSize(ackEmulDB_t*        ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *segmentSize);
+void wdrv_aeWSourceDbSetSessionSegmentSize(ackEmulDB_t*        ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 segmentSize);
+
+void wdrv_aeWSourceDbGetSessionTimeStamp(ackEmulDB_t*  ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *timeStamp);
+void wdrv_aeWSourceDbSetSessionTimeStamp(ackEmulDB_t*  ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 timeStamp);
+
+void wdrv_aeWSourceDbGetSessionAckReorderProblem(ackEmulDB_t*  ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackReorderProblem);
+void wdrv_aeWSourceDbSetSessionAckReorderProblem(ackEmulDB_t*  ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 ackReorderProblem);
+
+
+void wdrv_aeWSourceDbGetAckTemplate(ackEmulDB_t*       ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT8 **pTeplate,
+                                                                                                        UINT8 *ipHeaderLen, UINT8 *tcpHeaderLen);
+
+
+void wdrv_aeDbGetXTagStatus(ackEmulDB_t*       ackEmulDB,UINT8 sessionIndex, UINT8 *status);
+void wdrv_aeDbSetXTagStatus(ackEmulDB_t*       ackEmulDB,UINT8 sessionIndex, UINT8 status);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulUtil.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulUtil.c
new file mode 100644 (file)
index 0000000..e00790f
--- /dev/null
@@ -0,0 +1,1205 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: ackEmulUtil.c                                                                                      */
+/*   PURPOSE:  Ack emulation utility                                                      */
+/*                                                                                                                                        */
+/***************************************************************************/
+#include "osApi.h"
+#include "802_11Defs.h"
+#include "ackEmulDb.h"
+#include "report.h"
+#include "utils.h"
+#include "memMngrEx.h"
+#include "ackEmulDb.h"
+#include "ackEmulUtil.h"
+#include "whalCtrl_api.h"
+
+
+/* The minimum of segment size in byte to lock the segment size */
+#define MIN_LOCK_SEGMENT_SIZE 500
+
+typedef enum {
+       OTHER    =0,
+      TCP_ACK_ONLY ,
+      TCP_DATA    ,
+} packetInclude_T;
+
+
+
+#define TI_SNAP_HEADER_LEN 8
+#define TI_SNAP_AE_TYPE 0x02
+#define TI_SNAP_AE_LEN  3
+
+#define OFFSET_802_3_HDR       14
+
+#define K_FACTOR 14
+
+/* TI Snap Header */
+/*  -------------------------------------------
+   | dsap | SSAP | Control |    OUI   |  Type  |
+   | 0xAA | 0xAA |   0x00  | 0x080028 | 0x60D0 |
+    -------------------------------------------  */
+
+static UINT8 tiSnapHeader[]={0xAA,0xAA,0x00,0x08,0x00,0x28,0x60,0xD0};
+
+static void wdrv_ackEmulationPktType(ackEmul_t*                ackEmul, UINT8 *pWlanSnapHeader ,UINT8 *pIpHeader , packetInclude_T *packetInclude, UINT16 *tcpDataSize);
+static void wdrv_ackEmulationDataStandbyState(ackEmul_t*               ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader);
+static void wdrv_ackEmulationAckStandbyState(ackEmul_t*                ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader);
+static void wdrv_ackEmulationAckCandidateActivState(ackEmul_t*         ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader,
+                                                                                                                                        UINT8 *addYTag, UINT8 *activeIndex,
+                                                                                                                                        UINT32 *segmentSize);
+static void wdrv_ackEmulationAckActivState(ackEmul_t*          ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader,UINT8 *dropAck);
+static void wdrv_ackEmulationAckTerminateState(ackEmul_t*              ackEmul, UINT8 sessionIndex);
+
+static void wdrv_ackEmulationAddYTag(ackEmul_t*                ackEmul, UINT8 *pDot11Header, UINT16 firstBdLength,
+                                                                                                UINT8 activeIndex, UINT32 segmentSize);
+
+static int wdrv_aeChackSnapWithYtag(ackEmul_t*         ackEmul, UINT8 *pSnapHeader, UINT8 *tiSnapLen,
+                                                                                 UINT8 *activeIndex, UINT16 *segmentSize);
+
+static void wdrv_aeGenerateAck(ackEmul_t*              ackEmul, UINT16 stationIndex, UINT8 activeIndex ,UINT32 ackNumber);
+
+
+static UINT16 wdrv_IpChecksumCalc(ackEmul_t*           ackEmul, UINT16 len_ip_header, UINT8 *buff);
+static UINT16 wdrv_TcpChecksumCalc(ackEmul_t*          ackEmul, UINT16 len_tcp_header,UINT8 *IpSource, UINT8 *IpDest ,UINT8 *buff);
+
+
+
+
+ackEmul_t* ackEmul_create(TI_HANDLE hOs)
+{
+       ackEmul_t*              ackEmul;
+       ackEmulDB_t*    ackEmulDB;
+
+       if( hOs  == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: ackEmul_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       ackEmul = os_memoryAlloc(hOs, (sizeof(ackEmul_t)));
+
+       ackEmulDB = ackEmulDb_create(hOs);
+
+       if ( (!ackEmul) || (!ackEmulDB) )
+       {
+               utils_nullMemoryFree(hOs, ackEmul, sizeof(ackEmul_t));
+               utils_nullMemoryFree(hOs, ackEmulDB, sizeof(ackEmulDB_t));
+           WLAN_OS_REPORT(("FATAL ERROR: ackEmul_create(): Error Creating ackEmulDB module- Aborting\n"));
+               return(NULL);
+       }
+
+       /* reset control module control block */
+       os_memoryZero(hOs, ackEmul, (sizeof(ackEmul_t)));
+
+       ackEmul->pAckEmulDB = ackEmulDB;
+
+       ackEmul->hOs = hOs;
+
+       return(ackEmul);
+
+
+}
+
+TI_STATUS ackEmul_config(ackEmul_t*            ackEmul,
+                                                       TI_HANDLE       hWhalCtrl,
+                                                       TI_HANDLE       hOs,
+                                                       TI_HANDLE       hReport,
+                                                       TI_HANDLE       hMemMngr)
+{
+       /* check parameters validity */
+       if( (ackEmul == NULL) || (hOs == NULL) || (hReport == NULL)|| 
+               (hWhalCtrl == NULL) || (hMemMngr == NULL) )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: ackEmul_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+
+       /* set objects handles */
+       ackEmul->hOs = hOs;
+       ackEmul->hReport = hReport;
+       ackEmul->hMemMngr = hMemMngr;
+       ackEmul->hWhalCtrl = hWhalCtrl;
+
+       ackEmul->ackEmulationActive = TRUE;
+
+       ackEmulDb_config(ackEmul->pAckEmulDB,hOs,hReport);
+
+       /*whalCtrl_setSend4xWackInfo(ackEmul->hWhalCtrl, 0);           */
+
+       WLAN_REPORT_INIT(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+               (".....ackEmul configured successfully\n"));
+
+       return OK;
+
+}
+
+TI_STATUS ackEmul_destroy(ackEmul_t*   ackEmul)
+{
+       ackEmulDb_destroy(ackEmul->pAckEmulDB);
+
+       /* free control module controll block */
+       os_memoryFree(ackEmul->hOs, ackEmul, sizeof(ackEmul_t));
+
+       return OK;
+
+
+}
+
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationRxPacket()
+ **********************************************************************************
+ * DESCRIPTION:        This is the Ack emulation packet receiver main function.
+ * 
+ * INPUTS:   *pMsdu     - Pointer to the packet MSDU.
+ * 
+ * OUTPUT:   None
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+TI_STATUS wdrv_ackEmulationRxPacket(ackEmul_t*         ackEmul, mem_MSDU_T *pMsdu)
+{
+   
+   UINT8 rc;
+   UINT8 *dataBuf;
+   dot11_header_t *pDot11Header;
+   UINT8 *pWlanSnapHeader;
+   UINT8 *pSnapHeader;
+   UINT8 *pIpHeader;
+   UINT16 tcpDataSize;
+   packetInclude_T packetInclude;
+   UINT8 sessionIndex, monitorState;
+   UINT8 activeIndex = 0xff;
+   UINT16 segmentSize = 0;
+   UINT8 tiSnapLen = 0;
+   UINT16 dataLen;
+   UINT8 WTsessionIndex =0xff;
+   UINT8 XTag =0;
+
+
+   if (ackEmul->ackEmulationActive == FALSE)
+      return OK;
+
+
+   dataBuf = (UINT8 *)memMgr_BufData(pMsdu->firstBDPtr)+ memMgr_BufOffset(pMsdu->firstBDPtr);
+   dataLen = memMgr_BufLength(pMsdu->firstBDPtr);
+   pDot11Header = (dot11_header_t*) dataBuf;
+   /* Find the station Index  */
+
+   
+   XTag = ((pDot11Header->fc)&0x8000)>>15;
+   pSnapHeader = dataBuf + WLAN_HDR_LEN;
+   
+   pWlanSnapHeader = dataBuf + WLAN_HDR_LEN;
+   pIpHeader = pWlanSnapHeader + WLAN_SNAP_HDR_LEN;
+
+   /* Chack if SNAP with Y TAG */
+   rc = wdrv_aeChackSnapWithYtag(ackEmul, pSnapHeader, &tiSnapLen, &activeIndex, &segmentSize);
+   if(rc == OK)
+   {
+               WLAN_REPORT_WARNING(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("Packet with Ytag........\n"));
+
+      /* remove the TI SMAP */
+      os_memoryMove(NULL, pSnapHeader,pSnapHeader + tiSnapLen, dataLen - WLAN_HDR_LEN - tiSnapLen);
+      pMsdu->firstBDPtr->length -= tiSnapLen ;
+      pMsdu->dataLen -= tiSnapLen;
+
+         /* Update table and save template */
+         wdrv_aeWSourceSaveAckTemplate(ackEmul->pAckEmulDB, 0,activeIndex,dataBuf,pWlanSnapHeader,pIpHeader,(UINT16)pMsdu->dataLen,segmentSize);
+
+      
+      return OK;
+   }
+       
+   /* Packet without ack emulation TI Snap */
+       
+   /* Find the packet type and length */
+   wdrv_ackEmulationPktType(ackEmul, pWlanSnapHeader,pIpHeader,&packetInclude,&tcpDataSize);
+       
+       switch (packetInclude)
+   {
+   case TCP_DATA:
+               WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("RX packet = TCP_DATA....\n"));
+
+      rc = wdrv_aeWTargetDbFindDataSession(ackEmul->pAckEmulDB, pIpHeader ,&sessionIndex, &monitorState);
+      if(rc == OK)
+      {
+               WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("RX packet XTAG = %d......\n",XTag));
+
+         wdrv_aeDbSetXTagStatus(ackEmul->pAckEmulDB, sessionIndex, XTag);
+      } 
+      switch (monitorState)
+      {
+      case AE_INACTIVE:
+            rc = wdrv_aeWTargetDbAddSession(ackEmul->pAckEmulDB, pIpHeader);
+         
+                       break;
+               case AE_STANDBY:
+         wdrv_ackEmulationDataStandbyState(ackEmul, sessionIndex, pIpHeader);
+                       break;
+               case AE_CANDIDATE_ACTIVE:
+                       break;
+               case AE_ACTIVE:
+      default:
+                       break;
+      }
+      /*         printf("\n rc= %d  sessionIndex = %d monitorState = %d\n",rc, sessionIndex , monitorState);*/
+      break;
+      case TCP_ACK_ONLY:
+               WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("RX packet = TCP_ACK_ONLY....\n"));
+
+       wdrv_aeWSourceDbUpdateTemplate(ackEmul->pAckEmulDB, pIpHeader,0,&WTsessionIndex);
+         break;
+      case OTHER:
+           WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("RX packet = OTHER....\n"));
+
+         default:
+         break;
+   }
+       /*wdrv_aeWTargetDbPrint(ackEmul->pAckEmulDB);*/
+   return OK;
+}
+
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationTxPacket()
+ **********************************************************************************
+ * DESCRIPTION:        This is the Ack emulation packet transmission main function.
+ * 
+ * INPUTS:   *pMsdu     - Pointer to the packet MSDU.
+ * 
+ * OUTPUT:   *discardPacket - If TRUE discard the msdu.
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+TI_STATUS wdrv_ackEmulationTxPacket(ackEmul_t*         ackEmul, mem_MSDU_T *pMsdu,int *discardPacket)
+ {
+    UINT8              *pDot11Header;
+    UINT8    *pWlanSnapHeader;
+    UINT8              *pIpHeader;
+    UINT16     tcpDataSize;
+    packetInclude_T packetInclude;
+    UINT8      sessionIndex = 0xff;
+   UINT8       monitorState = 0xff;
+   UINT8               addYTag =FALSE;
+    UINT8              dropAck =FALSE;
+    UINT16     firstBdLength = 0;
+    UINT32     firstBddataOffset = 0;
+    UINT32     secondBddataOffset = 0;
+    UINT8      activeIndex = 0xff;
+    UINT32     segmentSize = 0;
+    
+    *discardPacket = FALSE;
+    pIpHeader     = NULL;
+
+    
+    if (ackEmul->ackEmulationActive == FALSE)
+       return OK;
+    
+    firstBdLength = memMgr_BufLength(pMsdu->firstBDPtr);
+    firstBddataOffset = memMgr_BufOffset(pMsdu->firstBDPtr) ;
+    pDot11Header = (UINT8 *)memMgr_BufData(pMsdu->firstBDPtr)+firstBddataOffset;
+    
+    if (firstBdLength == WLAN_HDR_LEN + WLAN_SNAP_HDR_LEN)
+    {
+       /* Packet from Ethernet, the IP heder is in the second data buffer */
+       if(pMsdu->firstBDPtr->nextBDPtr != NULL)
+       {
+          secondBddataOffset = memMgr_BufOffset(pMsdu->firstBDPtr->nextBDPtr);
+          pIpHeader = (UINT8 *)memMgr_BufData(pMsdu->firstBDPtr->nextBDPtr)+ secondBddataOffset;
+       }
+    }
+    else
+    {
+       /* Packet from Wlan  */
+       pIpHeader = pDot11Header + WLAN_HDR_LEN + WLAN_SNAP_HDR_LEN;
+    }
+    
+    pWlanSnapHeader = pDot11Header + WLAN_HDR_LEN;
+    
+   /* Find the packet type and length */
+    wdrv_ackEmulationPktType(ackEmul, pWlanSnapHeader,pIpHeader ,&packetInclude,&tcpDataSize);
+    
+    switch (packetInclude)
+    {
+    case TCP_ACK_ONLY:
+               WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("TX packet = TCP_ACK_ONLY....\n"));
+
+       
+       wdrv_aeWTargetDbFindAckSession(ackEmul->pAckEmulDB, pIpHeader ,&sessionIndex, &monitorState);
+       
+       switch (monitorState)
+       {
+       case AE_INACTIVE:
+                  
+                  break;
+       case AE_STANDBY:
+                  
+                  wdrv_ackEmulationAckStandbyState(ackEmul, sessionIndex, pIpHeader);
+                  break;
+       case AE_CANDIDATE_ACTIVE:
+                  wdrv_ackEmulationAckCandidateActivState(ackEmul, sessionIndex,
+                          pIpHeader,
+                          &addYTag,
+                          &activeIndex,
+                          &segmentSize);
+                  if(addYTag == TRUE)
+                  {
+                          wdrv_ackEmulationAddYTag(ackEmul, pDot11Header, firstBdLength, activeIndex, segmentSize);
+                          
+                          /* update the MSDU fields */
+                          pMsdu->firstBDPtr->length += TI_SNAP_HEADER_LEN+2+TI_SNAP_AE_LEN;
+                          pMsdu->dataLen += TI_SNAP_HEADER_LEN+2+TI_SNAP_AE_LEN;
+                  }
+                  
+                  break;
+       case AE_ACTIVE:
+                  /* Comper Template and drop packet */
+                  wdrv_ackEmulationAckActivState(ackEmul, sessionIndex, pIpHeader,&dropAck);
+                  
+                  *discardPacket = dropAck;
+                  break;
+                  
+       case AE_TERMINATE:
+                  wdrv_ackEmulationAckTerminateState(ackEmul, sessionIndex);
+                  
+                  break;
+       default:
+                  
+                  break;
+       }
+       
+          break;
+          case TCP_DATA:
+                  WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                          ("TX packet = TCP_DATA....\n"));
+                  
+                  break;
+       case OTHER:
+                  WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                          ("TX packet = OTHER....\n"));
+       default:
+                  break;
+    }
+    return OK;
+}
+
+
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationPktType()
+ **********************************************************************************
+ * DESCRIPTION:        Find the packet type and length.
+ * 
+ * INPUTS:   pWlanSnapHeader    - Pointer to the 802.11 SNAP header buffer.
+ *           pIpHeader         - Pointer to the ip header header buffer.
+ * 
+ * OUTPUT:   packetInclude     - The packet type, TCP_DATA, TCP_ACK_ONLY or OTHER
+ *           tcpDataSize       - The packet size (only for tcp packet) 
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+static void wdrv_ackEmulationPktType(ackEmul_t*                ackEmul, UINT8 *pWlanSnapHeader ,UINT8 *pIpHeader ,
+                                     packetInclude_T *packetInclude, UINT16 *tcpDataSize)
+{
+   UINT16 pktTotalLen;
+   UINT8 ipHeaderLen, tcpHeaderLen;
+
+   *tcpDataSize =0;
+
+
+
+   /* Check if the packet is TCP/IP */
+   if ((wlan_ntohs(((Wlan_LlcHeader_T*)pWlanSnapHeader)->Type) == IP_PROTOCOL_NUMBER) &&
+      (*(unsigned char*) ((ULONG)pIpHeader+(ULONG)IP_PROTOCOL_FIELD)== TCP_PROTOCOL))
+   {
+      /* Check if the packet include data or Ack only */
+      pktTotalLen = wlan_ntohs((*(UINT16*)(pIpHeader + IP_TOTAL_LEN_FIELD)));
+      ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+      tcpHeaderLen = ((((*(unsigned char*)(pIpHeader + ipHeaderLen+TCP_OFFSET_FIELD))& 0xf0)>>4) * 4);
+      *tcpDataSize = pktTotalLen - (ipHeaderLen + tcpHeaderLen);
+
+      if(*tcpDataSize > 0)
+         *packetInclude = TCP_DATA;
+      else 
+         *packetInclude = TCP_ACK_ONLY;
+
+   }
+   else
+   {
+      *packetInclude = OTHER;
+   }
+   
+}
+
+
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationDataStandbyState()
+ **********************************************************************************
+ * DESCRIPTION:        This function handle the tcp date packet for session in 
+ *                standby state.
+ * 
+ * INPUTS:   sessionIndex       - the session index
+ *           *pIpHeader     - Pointer to the ip header header buffer.
+ * 
+ * OUTPUT:   None.
+ * 
+ * RETURNS:     None 
+ **********************************************************************************/
+static void wdrv_ackEmulationDataStandbyState(ackEmul_t*               ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader)
+{
+       UINT8 ipHeaderLen = 0;
+
+       UINT32 prevSequenceNumber =0;
+       UINT32 currentSequenceNumber =0;
+       
+       UINT32 prevSegmentSize = 0;
+       UINT32 currentSegmentSize =0;
+
+       UINT8 equalSegmentSizeCounter =0;
+
+
+
+       /* Calculate Current Sequence Number */
+       ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+       currentSequenceNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_SEQUENCE_NUMBER_FIELD));
+
+       wdrv_aeWTargetDbGetSessionSequenceNumber(ackEmul->pAckEmulDB, sessionIndex,&prevSequenceNumber);
+       /* Calclate Segment Size */
+       wdrv_aeWTargetDbGetSessionSegmentSize(ackEmul->pAckEmulDB, sessionIndex,&prevSegmentSize);
+       currentSegmentSize = currentSequenceNumber - prevSequenceNumber;
+
+       if (prevSegmentSize == currentSegmentSize)
+       {
+               /* Increase Equal Segment Size Counter */
+               wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter(ackEmul->pAckEmulDB, sessionIndex,&equalSegmentSizeCounter);
+               if(equalSegmentSizeCounter == 2 && currentSegmentSize > MIN_LOCK_SEGMENT_SIZE)
+               {
+                       /* Monitor state -> AE_CANDIDATE_ACTIVE */
+/*         printf("\n Session %d chabge state to AE_CANDIDATE_ACTIVE with segment size %d\n",
+            sessionIndex,
+            currentSegmentSize);*/
+                       wdrv_aeWTargetDbSetSessionMonitorState(ackEmul->pAckEmulDB, sessionIndex,AE_CANDIDATE_ACTIVE);
+               }
+
+       }
+       else
+       {
+               wdrv_aeWTargetDbSetSessionSegmentSize(ackEmul->pAckEmulDB, sessionIndex,currentSegmentSize);
+               wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter(ackEmul->pAckEmulDB, sessionIndex,0);
+       }
+       
+       wdrv_aeWTargetDbSetSessionSequenceNumber(ackEmul->pAckEmulDB, sessionIndex,currentSequenceNumber);      
+}
+
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationAckStandbyState()
+ **********************************************************************************
+ * DESCRIPTION:        This function handle the tcp ack packet for session in 
+ *                standby state.
+ * 
+ * INPUTS:   sessionIndex       - the session index
+ *           *pIpHeader     - Pointer to the ip header header buffer.
+ * 
+ * OUTPUT:   None.
+ * 
+ * RETURNS:     None 
+ **********************************************************************************/
+static void wdrv_ackEmulationAckStandbyState(ackEmul_t*                ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader)
+{
+
+   UINT8 ipHeaderLen = 0;
+       UINT32 currentAckNumber =0;
+
+       /* Calculate Current Ack Number */
+       ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+       currentAckNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_ACK_NUMBER_FIELD));
+
+       /* Set Current Ack Number */
+       wdrv_aeWTargetDbSetSessionAckNumber(ackEmul->pAckEmulDB, sessionIndex,currentAckNumber);
+
+
+
+}
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationAckCandidateActivState()
+ **********************************************************************************
+ * DESCRIPTION:        This function handle the tcp ack packet for session in 
+ *                candidate activ state.
+ * 
+ * INPUTS:   sessionIndex       - the session index
+ *           *pIpHeader     - Pointer to the ip header header buffer.
+ * 
+ * OUTPUT:   *addYTag       - If true, add Ytag to the tcp acp packet
+ *           *activeIndex   - The activeIndex that assign for this session
+ *           *segmentSize   - The segment size of this tcp session.
+ * 
+ * RETURNS:     None 
+ **********************************************************************************/
+static void wdrv_ackEmulationAckCandidateActivState(ackEmul_t*         ackEmul, UINT8 sessionIndex,
+                                                                                                                                        UINT8 *pIpHeader,
+                                                                                                                                        UINT8 *addYTag,
+                                                                                                                                        UINT8 *activeIndex,
+                                                                                                                                        UINT32 *segmentSize)
+{
+
+   UINT8 ipHeaderLen = 0;
+       UINT32 prevAckNumber =0;
+       UINT32 currentAckNumber =0;
+   UINT32 ackCounter =0;
+
+       /* Calculate Current Ack Number */
+       ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+       currentAckNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_ACK_NUMBER_FIELD));
+
+       wdrv_aeWTargetDbGetSessionSegmentSize(ackEmul->pAckEmulDB, sessionIndex,segmentSize);
+       wdrv_aeWTargetDbGetSessionAckNumber(ackEmul->pAckEmulDB, sessionIndex,&prevAckNumber);
+
+   if((currentAckNumber - prevAckNumber) == *segmentSize *2)
+   {
+       WLAN_REPORT_FATAL_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("Change State to active............\n"));
+      /* Change state to Active and update Active index */
+      if(wdrv_aeWTargetDbSetActiveState(ackEmul->pAckEmulDB, sessionIndex, activeIndex) == OK)
+      {
+         
+         /* Calculate Ack Counter */
+         ackCounter = currentAckNumber / (*segmentSize *2);
+         wdrv_aeWTargetDbSetSessionAckCounter(ackEmul->pAckEmulDB, sessionIndex,ackCounter) ;
+         /* Save template update Active index */
+         wdrv_aeWTargetDbSaveAckTemplate(ackEmul->pAckEmulDB, sessionIndex,pIpHeader);
+         /* add addYTag */
+
+                WLAN_REPORT_FATAL_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("ADD Y TAG.........!!!!!!!!!!!!\n"));
+
+                       *addYTag = TRUE;
+
+      }
+   }
+   wdrv_aeWTargetDbSetSessionAckNumber(ackEmul->pAckEmulDB, sessionIndex,currentAckNumber);
+
+}
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationAckActivState()
+ **********************************************************************************
+ * DESCRIPTION:        This function handle the tcp ack packet for session in 
+ *                active state.
+ * 
+ * INPUTS:   sessionIndex       - the session index
+ *           *pIpHeader     - Pointer to the ip header header buffer.
+ * 
+ * OUTPUT:   *dropAck       - If TRUE discard the packet.
+ * 
+ * RETURNS:     None 
+ **********************************************************************************/
+static void wdrv_ackEmulationAckActivState(ackEmul_t*          ackEmul, UINT8 sessionIndex, UINT8 *pIpHeader,UINT8 *dropAck)
+{
+   int rc =NOK;
+
+   UINT8 ipHeaderLen = 0;
+   UINT32 currentAckNumber   =0;
+   UINT32 prevAckNumber   =0;
+   UINT32 segmentSize =0;
+   UINT32 currentAckCounter =0;
+   UINT32 prevAckCounter =0;
+   UINT8  activeIndex = 0xff;
+   UINT32 segmentNumber = 0;
+   UINT32 prevTimeStamp;
+   UINT32 currentTimeStamp;
+   UINT8 newWackInfo = 0;
+   UINT8 prevWackInfo;
+   UINT8 prevOwnershipBit;
+   UINT8 prevActvIndxBits;
+       UINT8 prevAckCounterBits;
+
+   
+   currentTimeStamp =os_timeStampUs(ackEmul->hOs); 
+   wdrv_aeWTargetDbGetSessionTimeStamp(ackEmul->pAckEmulDB, sessionIndex, &prevTimeStamp);
+   if(prevTimeStamp != 0)
+   {
+      if((WTARGET_ACTIVE_TIME_OUT) < (currentTimeStamp - prevTimeStamp))
+      {  /* If the delay between two ack packet for the same session grater */
+         /* than  WTARGET_ACTIVE_TIME_OUT change session state to terminate */
+         wdrv_aeWTargetDbSetSessionMonitorState(ackEmul->pAckEmulDB, sessionIndex,AE_TERMINATE);
+                /*WLAN_OS_REPORT(("1\n"));*/
+                 return;
+      }
+   }
+
+   
+   /* extract the information from prevWackInfo */
+
+   whalCtrl_getSend4xWackInfo(ackEmul->hWhalCtrl, &prevWackInfo);           
+   prevAckCounterBits = (prevWackInfo&0x0f);
+   prevActvIndxBits = (prevWackInfo&0x10)>>4;
+   prevOwnershipBit = (prevWackInfo&0x80)>>7;
+   
+   /* Calculate Current Ack Number */
+   ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+   currentAckNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_ACK_NUMBER_FIELD));
+   
+   wdrv_aeWTargetDbGetSessionSegmentSize(ackEmul->pAckEmulDB, sessionIndex,&segmentSize);
+   wdrv_aeWTargetDbGetSessionAckNumber(ackEmul->pAckEmulDB, sessionIndex,&prevAckNumber);
+   
+   wdrv_aeWTargetDbGetSessionAckCounter(ackEmul->pAckEmulDB, sessionIndex, &prevAckCounter) ;
+   wdrv_aeWTargetDbGetSessionActiveIndex(ackEmul->pAckEmulDB, sessionIndex, &activeIndex);
+
+   /* Calculate Ack Counter */
+   currentAckCounter = currentAckNumber / (segmentSize*2);
+   if((currentAckNumber - prevAckNumber) == segmentSize *2)
+   {
+                /*WLAN_OS_REPORT(("--2\n"));*/
+
+          if ((currentAckCounter > prevAckCounter) && (currentAckCounter < prevAckCounter + 5))
+          {                            
+                /*WLAN_OS_REPORT(("----3\n"));*/
+                  rc = wdrv_aeWTargetDbCmpAckTemplate(ackEmul->pAckEmulDB, sessionIndex, pIpHeader);
+                  if (rc == OK)
+                  {  
+                          /* drop this Ack */
+                          
+                          UINT8 Xtag;
+
+                          wdrv_aeDbGetXTagStatus(ackEmul->pAckEmulDB, sessionIndex,&Xtag);
+                        /*WLAN_OS_REPORT(("------4 Xtag=%d prevOwnershipBit=%d activeIndex=%d prevActvIndxBits=%d\n",Xtag,prevOwnershipBit,activeIndex,prevActvIndxBits));*/
+                          if (((prevOwnershipBit == 1)|| (activeIndex == prevActvIndxBits)) && Xtag)
+                          {
+                                  *dropAck = TRUE;
+                                  
+                          }
+                  }
+          }
+   }
+   else
+   {
+               /*WLAN_OS_REPORT(("------99 prevAckNumber=%d,currentAckCounter=%d currentAckNumber=%d segmentSize=%d \n",*/
+               /*                                                prevAckNumber,   currentAckCounter,   currentAckNumber,   segmentSize));*/
+   }
+
+  WLAN_REPORT_FATAL_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                  ("dropAck = %d\n",*dropAck));
+   
+   if(*dropAck == TRUE)
+   {
+          newWackInfo = (((currentAckCounter % K_FACTOR)+1)&0xf); /* Add currentAckCounter MOD K_FACTOR to bit 0-3 */   
+          newWackInfo = newWackInfo | (activeIndex << 4);  /* Add activeIndex to bit 4 */
+          whalCtrl_setSend4xWackInfo(ackEmul->hWhalCtrl, newWackInfo);           
+          wdrv_aeWTargetDbSetSessionTimeStamp(ackEmul->pAckEmulDB, sessionIndex, currentTimeStamp);
+   }
+   else
+   {
+          
+          if((prevAckNumber % (segmentSize*2))>(currentAckNumber % (segmentSize*2)))
+          {
+                  /* Ack Reorder Problem */
+                  newWackInfo = 0xF; 
+          }
+          else
+          {
+                  if(prevAckCounterBits == 0xF)
+                  {
+                          /* chack if this wack info send */
+                          if(prevOwnershipBit == 1)
+                                  newWackInfo = 0;
+                  }
+                  else
+                  {
+               newWackInfo = 0;
+                  }
+          }
+          newWackInfo = newWackInfo | (activeIndex << 4);  /* Add activeIndex to bit 4 */
+          whalCtrl_setSend4xWackInfo(ackEmul->hWhalCtrl, newWackInfo);           
+          
+          wdrv_aeWTargetDbSetSessionAckCounter(ackEmul->pAckEmulDB, sessionIndex,currentAckCounter) ;
+          
+   }
+   wdrv_aeWTargetDbSetSessionAckNumber(ackEmul->pAckEmulDB, sessionIndex,currentAckNumber);
+   segmentNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_SEQUENCE_NUMBER_FIELD));
+   wdrv_aeWTargetDbUpdateAckTemplate(ackEmul->pAckEmulDB, sessionIndex,segmentNumber);
+   
+}
+
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationAckTerminateState()
+ **********************************************************************************
+ * DESCRIPTION:        This function handle the tcp ack packet for session in 
+ *                terminate state.
+ * 
+ * INPUTS:   sessionIndex       - 
+ * 
+ * OUTPUT:   None
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+static void wdrv_ackEmulationAckTerminateState(ackEmul_t*              ackEmul, UINT8 sessionIndex)
+{
+   UINT32 prevTimeStamp;
+   UINT32 currentTimeStamp = os_timeStampUs(ackEmul->hOs);
+
+   wdrv_aeWTargetDbGetSessionTimeStamp(ackEmul->pAckEmulDB, sessionIndex, &prevTimeStamp);
+   if(prevTimeStamp != 0)
+   {
+      if((WTARGET_TERMINATE_TIME_OUT) < (currentTimeStamp - prevTimeStamp))
+      {
+         /* Reset Session */
+         wdrv_aeWTargetDbResetTuple(ackEmul->pAckEmulDB, sessionIndex); 
+      }
+   }
+   return;
+}
+
+/**********************************************************************************
+ *                      wdrv_ackEmulationAddYTag()
+ **********************************************************************************
+ * DESCRIPTION: Add Ytag to the Tcp Ack PAcket
+ * 
+ * INPUTS:   *pDot11Header      - Pointer to the 802.11 heder
+ *           firstBdLength  - The length of the first BD
+ *           activeIndex    - The active index of the monitor session. 
+ *           segmentSize    - The segmentSize of the monitor session. 
+ * 
+ * OUTPUT:     None 
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+
+/* Tcp Ack without Ytag */
+/*  -------------------------------------------
+   | 802.11 | SSAP |   IP   |  TCP   | Payload |
+   | header |      | header | header |         |
+    -------------------------------------------  */
+/* Tcp Ack with Ytag */
+/*  ---------------------------------------------------------
+   | 802.11 |  TI  | 802.11 SNAP |   IP   |  TCP   | Payload |
+   | header | SNAP | header      | header | header |         |
+    ---------------------------------------------------------  */
+
+
+/* TI Snap */
+/*  -------------------------------------------------------------------------
+   | dsap | SSAP | Control |    OUI   |  Type  |  AE  | AE  |Active |Segment |
+   | 0xAA | 0xAA |   0x00  | 0x080028 | 0x60D0 | Type | Len | Index |  Size  |
+    ------------------------------------------------------------------------- */
+
+
+static void wdrv_ackEmulationAddYTag(ackEmul_t*                ackEmul, UINT8 *pDot11Header, UINT16 firstBdLength,
+                                                                                                UINT8 activeIndex, UINT32 segmentSize)
+{
+       UINT8 *tempPtr;
+       UINT32 moveLen;
+       
+       tempPtr = pDot11Header + WLAN_HDR_LEN;
+       moveLen = firstBdLength - WLAN_HDR_LEN;
+       os_memoryMove(NULL, tempPtr+TI_SNAP_HEADER_LEN+2+TI_SNAP_AE_LEN ,tempPtr,moveLen);
+       os_memoryCopy(NULL, tempPtr,tiSnapHeader,TI_SNAP_HEADER_LEN);
+       tempPtr += TI_SNAP_HEADER_LEN;
+   *(UINT8*)tempPtr = TI_SNAP_AE_TYPE; 
+       tempPtr ++;
+       *(UINT8*)tempPtr = TI_SNAP_AE_LEN; /* Length */
+       tempPtr ++;
+       *(UINT8*)tempPtr = activeIndex; /* Active Index */
+       tempPtr ++;
+       *(UINT16*)tempPtr = wlan_ntohs((UINT16)segmentSize); /* Segment Size */
+}
+
+/**********************************************************************************
+ *                      wdrv_aeChackSnapWithYtag()
+ **********************************************************************************
+ * DESCRIPTION: Check if the packet include Ytag 
+ * 
+ * INPUTS:   *pSnapHeader - Pointer to the SNAP heder
+ * 
+ * OUTPUT:   *tiSnapLen      - The length of the first BD
+ *           *activeIndex    - The active index. 
+ *           *segmentSize    - The segmentSize.       
+ * 
+ * RETURNS:            Ok if include Ytag, otherwise NOK
+ **********************************************************************************/
+static int wdrv_aeChackSnapWithYtag(ackEmul_t*         ackEmul, UINT8 *pSnapHeader, UINT8 *tiSnapLen,
+                                    UINT8 *activeIndex, UINT16 *segmentSize)
+{
+   
+       /* Chack if SNAP with Y TAG */
+   if ((os_memoryCompare(ackEmul->hOs, pSnapHeader,tiSnapHeader,TI_SNAP_HEADER_LEN)== 0)&&
+      (*(UINT8*)(pSnapHeader + TI_SNAP_HEADER_LEN) == TI_SNAP_AE_TYPE))
+   {
+      
+      /* This packet include Ack with Y TAG */
+               UINT8* tempPtr;
+               UINT8 templen;
+               tempPtr = pSnapHeader + TI_SNAP_HEADER_LEN+1;
+               templen = *(UINT8*)tempPtr;
+               *tiSnapLen = TI_SNAP_HEADER_LEN + 2 + templen;     
+               tempPtr ++;
+               *activeIndex = (UINT8)(wlan_ntohs(*(UINT16*)tempPtr));
+               tempPtr +=2;
+               *segmentSize = (UINT16)(wlan_ntohl(*(UINT32*)tempPtr));
+               return OK;
+       }
+       else
+       {
+               return NOK;
+       }
+}
+
+int genera = 0;
+int modulo_off = 0;
+int mod_off = 0;
+int mod_on = 0;
+
+/**********************************************************************************
+ *                      wdrv_aeWackReceive()
+ **********************************************************************************
+ * DESCRIPTION:        Parse the wack info and generate emulated tcp ack
+ * 
+ * INPUTS:   station    - The wack source station index.
+ *           wackInfo - The wackInfo  
+ * 
+ * OUTPUT:   None    
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+void wdrv_aeWackReceive(ackEmul_t*             ackEmul, UINT16 station, UINT8 wackInfo)
+{
+       UINT8 ackCounterlowBits;
+       UINT8 activeIndex;
+       UINT32 oldAckNumber;
+       UINT32 newAckNumber;
+       UINT32 oldAckCounter;
+       UINT32 newAckCounter;
+       UINT32 segmentSize;
+       UINT32 prevWackTimeStamp;
+       UINT32 currentWackTimeStamp;
+       UINT32  reorderProblemStatus;
+       
+       static UINT8 prev_wackInfo = 0xff;
+       
+       if(prev_wackInfo != wackInfo)
+       {
+               prev_wackInfo = wackInfo;
+               
+               
+               /* extract the information from wackInfo */
+               ackCounterlowBits = (wackInfo & 0xf);
+               activeIndex      = (wackInfo & 0x10) >> 4;
+               
+               
+               if (ackCounterlowBits == 0)
+                       ackCounterlowBits = 0xF;
+               else
+                       ackCounterlowBits --;
+               
+               
+               if(ackCounterlowBits == 0xF)
+                       return;
+               
+               if(ackCounterlowBits == 0xE)
+               {
+                       /* Reorder problem is possible */
+                       wdrv_aeWSourceDbSetSessionAckReorderProblem(ackEmul->pAckEmulDB, station,activeIndex,REORDER_PROBLEM_ON);
+                       return;
+               }
+               wdrv_aeWSourceDbGetSessionTimeStamp(ackEmul->pAckEmulDB, station,activeIndex,&prevWackTimeStamp);
+               if(prevWackTimeStamp != 0)
+               {
+                       currentWackTimeStamp = os_timeStampUs(ackEmul->hOs);
+                       
+                       if((WSOURCE_SESSION_TIME_OUT) < (currentWackTimeStamp - prevWackTimeStamp))
+                       {
+                               /* reset Wsource session */
+                               /*WLAN_OS_REPORT((" Reset Wsource session  activeIndex %\n",activeIndex));*/
+                               
+                               wdrv_aeWSourceDbResetSession(ackEmul->pAckEmulDB, station, activeIndex);
+                               
+                               return;
+                       }
+                       
+                       wdrv_aeWSourceDbSetSessionTimeStamp(ackEmul->pAckEmulDB, station,activeIndex,currentWackTimeStamp);
+                       
+                       wdrv_aeWSourceDbGetSessionSegmentSize(ackEmul->pAckEmulDB, station,activeIndex,&segmentSize); 
+                       
+                       if(segmentSize != 0)
+                       {
+                               wdrv_aeWSourceDbGetSessionAckNumber(ackEmul->pAckEmulDB, station,activeIndex,&oldAckNumber); 
+                               wdrv_aeWSourceDbGetSessionAckCounter(ackEmul->pAckEmulDB, station,activeIndex,&oldAckCounter); 
+                               
+                               /* newACK_counter = (Low_counter - (oldACK_counter mod 2^k) + 2^k + 3) mod 2^k - 3 + oldACK_counter*/
+                               newAckCounter = ((ackCounterlowBits - (oldAckCounter % K_FACTOR) + K_FACTOR + 3) % K_FACTOR) -3 + oldAckCounter;
+                               
+                               if(newAckCounter <= oldAckCounter)
+                                       return;
+                               
+                               wdrv_aeWSourceDbGetSessionAckReorderProblem(ackEmul->pAckEmulDB, station,activeIndex,&reorderProblemStatus);
+                               
+                               if(reorderProblemStatus == REORDER_PROBLEM_ON)     
+                               {
+                                       newAckNumber = (newAckCounter * (segmentSize*2));
+                               }
+                               else
+                               {
+                                       /* newACK_number = oldACK_number mod (Segment_Size*2) + Rx_Ack_count * (Segment_Size*2)*/      
+                                       newAckNumber = (oldAckNumber % (segmentSize*2)) + (newAckCounter * (segmentSize*2));
+                               }
+                               /* Generate ack */
+                               genera++;
+                               wdrv_aeGenerateAck(ackEmul, station,activeIndex,newAckNumber);
+                               
+                               wdrv_aeWSourceDbSetSessionAckNumber(ackEmul->pAckEmulDB, station,activeIndex,newAckNumber); 
+                               wdrv_aeWSourceDbSetSessionAckCounter(ackEmul->pAckEmulDB, station,activeIndex,newAckCounter); 
+                       }
+                       return;
+                       
+               }
+
+       }
+}
+/**********************************************************************************
+ *                      wdrv_aeGenerateAck()
+ **********************************************************************************
+ * DESCRIPTION: Generate emulated TCP Ack
+ * 
+ * INPUTS:   sessionIndex       - 
+ *           activeIndex
+ *           ackNumber
+ * 
+ * OUTPUT:   None     
+ * 
+ * RETURNS:            None 
+ **********************************************************************************/
+ static void wdrv_aeGenerateAck(ackEmul_t*             ackEmul, UINT16 stationIndex, UINT8 activeIndex ,UINT32 ackNumber)
+ {
+        mem_MSDU_T *pMsdu;
+        UINT8 ipHeaderLen;
+        UINT8 tcpHeaderLen;
+        UINT8 *pTeplate;
+        UINT8 *pNewPkt;
+        UINT16  newPktLen;
+        UINT8 *ipSource, *ipDest;
+        UINT8 *pIpHeader, *pTcpHeader;
+        UINT16 ipChecksum =0;
+        UINT16 tcpChecksum =0;
+        
+        dot11_header_t *pDot11Header;
+        UINT8 *pDAddr,*pSAddr;
+
+       WLAN_REPORT_ERROR(ackEmul->hReport, ACK_EMUL_MODULE_LOG, 
+                               ("wdrv_aeGenerateAck....==============================================\n"));
+
+        wdrv_aeWSourceDbGetAckTemplate(ackEmul->pAckEmulDB, stationIndex, activeIndex, &pTeplate,&ipHeaderLen, &tcpHeaderLen);
+        if(ipHeaderLen > 0)
+        {
+                newPktLen = ipHeaderLen+tcpHeaderLen;
+                if(wlan_memMngrAllocMSDU(ackEmul->hMemMngr, &pMsdu,newPktLen+OFFSET_802_3_HDR,(allocatingModule_e)(ACK_EMUL_MODULE+ sizeof(DbTescriptor)))==NOK)
+                {
+                        WLAN_OS_REPORT(( "WDRV_4X: GenerateAck - fail to allocate buildMsduPtr\n"));
+                        return;
+                }
+                pNewPkt = (UINT8*)memMgr_BufData(pMsdu->firstBDPtr)+ sizeof(DbTescriptor);
+
+                os_memoryCopy(ackEmul->hOs, pNewPkt + OFFSET_802_3_HDR -2,pTeplate + WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN -2,newPktLen+2);
+                
+                /* Extract Info from frame header */
+                pDot11Header = (dot11_header_t *)pTeplate;
+                
+                pDAddr = (UINT8 *)&pDot11Header->address1;
+                pSAddr = (UINT8 *)((pDot11Header->fc & DOT11_FC_FROM_DS)? &pDot11Header->address3 : &pDot11Header->address2);
+                
+                pMsdu->firstBDPtr->dataOffset =  sizeof(DbTescriptor);
+                pMsdu->firstBDPtr->length = newPktLen;
+                pMsdu->dataLen = newPktLen+OFFSET_802_3_HDR;
+                
+                /* Calclate IP Checksum */
+                pIpHeader = pNewPkt+OFFSET_802_3_HDR;
+                ipChecksum = wdrv_IpChecksumCalc(ackEmul, ipHeaderLen,pIpHeader);
+                
+                /* Calclate TCP Checksum */
+                pTcpHeader = pIpHeader + ipHeaderLen;
+                *(UINT32*)(pTcpHeader+TCP_ACK_NUMBER_FIELD) = wlan_ntohl(ackNumber);
+                ipSource = pIpHeader+IP_SRC_ADDRESS_FIELD;
+                ipDest   = pIpHeader+IP_DEST_ADDRESS_FIELD;
+                tcpChecksum = wdrv_TcpChecksumCalc(ackEmul, tcpHeaderLen, ipSource, ipDest, pTcpHeader);
+                /* Add the Checksum to the new packet */
+                *(UINT16*)(pIpHeader+IP_CHECKSUM_FIELD) = wlan_ntohs(ipChecksum);
+                *(UINT16*)(pTcpHeader+TCP_CHECKSUM_FIELD) = wlan_ntohs(tcpChecksum);
+                
+                /* Generate 802.3 Header */
+                os_memoryCopy (ackEmul->hOs, pNewPkt, pDAddr, MAC_ADDR_LEN);
+                os_memoryCopy (ackEmul->hOs, pNewPkt+MAC_ADDR_LEN, pSAddr, MAC_ADDR_LEN);
+                
+                /* Send the emulated ack to the bss Bridge*/
+                os_receivePacket(ackEmul->hOs, pMsdu, (UINT16)pMsdu->dataLen);
+        }
+ }
+ /****************************************************************************
+ *                      wdrv_aeSetActive()
+ ****************************************************************************
+ * DESCRIPTION:        Enable/ Desable Ack Emulation
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+
+void wdrv_aeSetActive(ackEmul_t*               ackEmul, int status)
+{
+   
+/*   if (status == TRUE)
+   {
+      (void)whal_apiSetSend4xWackInfo(ackEmul->hWhalCtrl, 0);
+      (void)whal_apiEnable4xWackFeature(ackEmul->hWhalCtrl);
+   }
+   if (status == FALSE)
+   {
+      (void)whal_apiSetSend4xWackInfo(ackEmul->hWhalCtrl, 0);
+      (void)whal_apiDisable4xWackFeature(ackEmul->hWhalCtrl);
+   }
+*/   
+      ackEmul->ackEmulationActive = status;
+}
+
+
+
+int wdrv_aeGetActive(ackEmul_t*                ackEmul )
+{
+   return(ackEmul->ackEmulationActive);
+}
+
+
+
+/*
+**************************************************************************
+Function: wdrv_IpChecksumCalc
+Description: Calculate the 16 bit IP Checksum.
+***************************************************************************
+*/
+
+
+static UINT16 wdrv_IpChecksumCalc(ackEmul_t*           ackEmul, UINT16 len_ip_header, UINT8 *buff)
+{
+UINT16 word16;
+UINT32 sum=0;
+
+UINT16 i;
+       /* make 16 bit words out of every two adjacent 8 bit words in the packet*/
+       /* and add them up*/
+       for (i=0;i<len_ip_header;i=i+2){
+               word16 = wlan_ntohs(*(UINT16*)(buff+i));
+               sum = sum + (UINT32) word16;    
+       }
+       
+       /* take only 16 bits out of the 32 bit sum*/
+/*temp = (sum & 0xffff0000)>>16;*/
+sum = (sum & 0x0000ffff)+((sum & 0xffff0000)>>16);
+       /* one's complement the result*/
+       sum = ~sum;
+       
+return ((UINT16) sum);
+}
+
+/*
+**************************************************************************
+Function: wdrv_TcpChecksumCalc
+Description: Calculate the 16 bit TCP Checksum.
+***************************************************************************
+*/
+
+static UINT16 wdrv_TcpChecksumCalc(ackEmul_t*          ackEmul, UINT16 len_tcp_header,UINT8 *IpSource, UINT8 *IpDest ,UINT8 *buff)
+{
+UINT16 word16;
+UINT32 sum=0;
+UINT16 i;
+
+
+       
+       /* add a padding byte = 0 at the end of packet */
+
+               buff[len_tcp_header]=0;
+       
+
+       /* make 16 bit words out of every two adjacent 8 bit words in the packet
+          and add them up */
+       for (i=0;i<len_tcp_header;i=i+2){
+               word16 = wlan_ntohs(*(UINT16*)(buff+i));
+               sum = sum + (UINT32) word16;    
+       }
+
+       
+   /* add the TCP pseudo header which contains:
+      the IP source and destinationn addresses, TCP protocol & TCP length */
+
+   
+   word16 = wlan_ntohs(*(UINT16*)IpSource);
+   sum = sum + (UINT32) word16;        
+   word16 = wlan_ntohs(*(UINT16*)(IpSource+2));
+   sum = sum + (UINT32) word16;        
+   word16 = wlan_ntohs(*(UINT16*)IpDest);
+   sum = sum + (UINT32) word16;        
+   word16 = wlan_ntohs(*(UINT16*)(IpDest+2));
+   sum = sum + (UINT32) word16;        
+   sum = sum + (UINT32)len_tcp_header + 0x06;
+   
+      
+      
+      
+      /* take only 16 bits out of the 32 bit sum */
+sum = (sum & 0x0000ffff)+((sum & 0xffff0000)>>16);
+       /* one's complement the result */
+       sum = ~sum;
+       
+return ((UINT16) sum);
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulUtil.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/ackEmulUtil.h
new file mode 100644 (file)
index 0000000..683452b
--- /dev/null
@@ -0,0 +1,87 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: ackEmulUtil.h                                                                                      */
+/*   PURPOSE:  Ack emulation Utility                                                      */
+/*                                                                                                                                        */
+/***************************************************************************/
+#ifndef _ACK_EMULATION_UTIL_H_
+#define _ACK_EMULATION_UTIL_H_
+
+#include "osTIType.h"
+#include "ackEmulDb.h"
+
+
+typedef struct
+{
+       TI_HANDLE                       hWhalCtrl;
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hMemMngr;
+
+       ackEmulDB_t*            pAckEmulDB;
+
+       int ackEmulationActive;
+
+}ackEmul_t;
+
+ackEmul_t* ackEmul_create(TI_HANDLE hOs);
+
+TI_STATUS ackEmul_config(ackEmul_t*            ackEmul,
+                                                       TI_HANDLE       hWhalCtrl,
+                                                       TI_HANDLE       hOs,
+                                                       TI_HANDLE       hReport,
+                                                       TI_HANDLE       hMemMngr);
+
+TI_STATUS ackEmul_destroy(ackEmul_t*   ackEmul);
+
+
+
+
+TI_STATUS wdrv_ackEmulationRxPacket(ackEmul_t*         ackEmul, mem_MSDU_T *pMsdu);
+
+TI_STATUS wdrv_ackEmulationTxPacket(ackEmul_t*         ackEmul, mem_MSDU_T *pMsdu,int *discardPacket);
+
+void wdrv_aeWackReceive(ackEmul_t*             ackEmul, UINT16 station, UINT8 wackInfo);
+void gener(ackEmul_t*          ackEmul, UINT16 stationIndex, UINT8 activeIndex ,UINT32 ackNumber);
+
+void wdrv_aeSetActive(ackEmul_t*               ackEmul, int status);
+int wdrv_aeGetActive(ackEmul_t*                ackEmul);
+
+void gener(ackEmul_t*          ackEmul, UINT16 stationIndex, UINT8 activeIndex ,UINT32 ackNumber);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourX.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourX.c
new file mode 100644 (file)
index 0000000..4fa0628
--- /dev/null
@@ -0,0 +1,845 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE:                                                                                                    */
+/*             PURPOSE:                                                                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+#include "fourX.h"
+#include "report.h"
+#include "osApi.h"
+#include "utils.h"
+#include "802_11Defs.h"
+
+
+static Wlan4XType_t fourX_parseRxFrame(fourX_t* pFourX, mem_MSDU_T* msduPtr);
+
+static TI_STATUS fourX_MakeConcatDecision(fourX_t*                             pFourX,
+                                                                                  MsduList_t*                  pMsduList,
+                                                                                  hwTxInformation_t*   pHwTxInformation,
+                                                                                  UINT32                                       numOfReadyMsdu,
+                                                                                  UINT16*                              concatFlags,
+                                           UINT32*              numOfMsduToConcat);
+
+static TI_STATUS fourX_prepareMsduListToConcat(fourX_t*                pFourX,
+                                                                                          mem_MSDU_T** returnMsduPtr,
+                                                                                          MsduList_t*  pMsduList,
+                                               UINT32       maxNumMsduToConcat);
+
+
+/*************************************************************************
+*                        concat_create                                 *
+**************************************************************************
+* DESCRIPTION: This function initializes the Ctrl data module.                 
+*                                                      
+* INPUT:               hOs - handle to Os Abstraction Layer
+*                              
+* OUTPUT:              TxCmplt_CB - call back function that return to configMngr
+*                              in order to register in the Hal
+*
+* RETURN:              Handle to the allocated Ctrl data control block
+************************************************************************/
+
+fourX_t* fourX_create(TI_HANDLE hOs)
+{
+       fourX_t*                        pFourX;
+       deConcatenator_t*       pDeConcatenator;
+       concatenator_t*         pConcatenator;
+       ackEmul_t*                      pAckEmul;
+
+
+       if( hOs  == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: fourX_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       /* alocate concatenator block */
+       pFourX = os_memoryAlloc(hOs, (sizeof(fourX_t)));
+
+       /* create 4x sub moduls */
+       pConcatenator = concat_create(hOs);
+       pDeConcatenator = deConcat_create(hOs);
+       pAckEmul = ackEmul_create(hOs);
+
+
+       if ( (!pFourX) || (!pConcatenator) || (!pDeConcatenator) || (!pAckEmul))
+       {
+               utils_nullMemoryFree(hOs, pDeConcatenator, sizeof(deConcatenator_t));
+               utils_nullMemoryFree(hOs, pConcatenator, sizeof(concatenator_t));
+               utils_nullMemoryFree(hOs, pAckEmul, sizeof(ackEmul_t));
+               utils_nullMemoryFree(hOs, pFourX, sizeof(fourX_t));
+           WLAN_OS_REPORT(("FATAL ERROR: fourX_create(): Error Creating fourX module- Aborting\n"));
+               return(NULL);
+       }
+
+       /* reset control module control block */
+       os_memoryZero(hOs, pFourX, (sizeof(fourX_t)));
+
+       pFourX->pConcatenator = pConcatenator;
+       pFourX->pDeConcatenator = pDeConcatenator;
+       pFourX->pAckEmul = pAckEmul;
+
+       pFourX->hOs = hOs;
+
+       return(pFourX);
+}
+
+/***************************************************************************
+*                                                      ctrlData_config                                            *
+****************************************************************************
+* DESCRIPTION: This function configures the Ctrl Data module           
+* 
+* INPUTS:              hCtrlData - The object
+*                              hOs - Handle to the Os Abstraction Layer
+*                              hReport - Handle to the Report object
+*                              ctrlDataInitParams - pointer to Ctrl module init parameters
+* OUTPUT:              
+* 
+* RETURNS:             OK - Configuration succesfull
+*                              NOK - Configuration unsuccesfull
+***************************************************************************/
+TI_STATUS fourX_config(fourX_t*                                pFourX,
+                                          TI_HANDLE                    hOs,
+                                          TI_HANDLE                    hReport,
+                                          TI_HANDLE                    hMemMngr,
+                                          TI_HANDLE                    hWhalCtrl,
+                                          TI_HANDLE                    hTxData,
+                                          fourXInitParams_t*   fourXInitParams)
+{
+       /* check parameters validity */
+       if( (pFourX == NULL) || (hOs == NULL) || (hReport == NULL) || 
+               (hMemMngr == NULL) || (hWhalCtrl == NULL) || (hTxData == NULL))
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: fourX_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+
+       /* set objects handles */
+       pFourX->hOs = hOs;
+       pFourX->hReport = hReport;
+       pFourX->hMemMngr = hMemMngr;
+       pFourX->hWhalCtrl = hWhalCtrl;
+       pFourX->hTxData = hTxData;
+
+       /* configure 4x parameters - TODO USE fourXInitParams */
+       pFourX->desiredConcatenationEnable = DESIRED_CONCATENATION_ENABLE_DEF;
+       pFourX->desiredCWMinEnable = DESIRED_CWMIN_ENABLE_DEF;
+       pFourX->desiredCWComboEnable = DESIRED_CWCOMBO_ENABLE_DEF;
+       pFourX->desiredAckEmulationEnable = DESIRED_ACKEMULATION_ENABLE_DEF;
+       pFourX->desiredERP_ProtectionEnable = DESIRED_ERP_PROTECTION_ENABLE_DEF;
+       pFourX->desiredMaxConcatSize = MAX_CONCAT_SIZE_DEF;
+       pFourX->desiredCWMin = CW_MIN_DEF;
+       pFourX->desiredCWMax = CW_MAX_DEF;
+
+
+       /* configure 4x sub modules */
+       concat_config(pFourX->pConcatenator, hOs, hReport, hMemMngr);
+       deConcat_config(pFourX->pDeConcatenator, hOs, hReport, hMemMngr);
+       ackEmul_config(pFourX->pAckEmul,hWhalCtrl,hOs,hReport,hMemMngr);
+
+
+       WLAN_REPORT_INIT(pFourX->hReport, FOUR_X_MODULE_LOG, 
+               (".....fouorX configured successfully\n"));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                                      ctrlData_unLoad                                            *
+****************************************************************************
+* DESCRIPTION: This function unload the Ctrl data module. 
+* 
+* INPUTS:              hCtrlData - the object
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK - Unload succesfull
+*                              NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS fourX_destroy(fourX_t* pFourX)
+{
+       concat_destroy(pFourX->pConcatenator);
+       deConcat_destroy(pFourX->pDeConcatenator);
+       ackEmul_destroy(pFourX->pAckEmul);
+
+       /* free control module controll block */
+       os_memoryFree(pFourX->hOs, pFourX, sizeof(fourX_t));
+
+       return OK;
+}
+
+
+static Wlan4XType_t fourX_parseRxFrame(fourX_t* pFourX, mem_MSDU_T* msduPtr)
+{
+    dot114xMsdu_t*     pdot114xHeader;
+       UINT8                   tiSnapDataArray[8] = {0xAA,0xAA,0x03,0x08,0x00,0x28,0x60,0xD0};
+
+       /* Check frame len validity */
+       if(msduPtr->dataLen < sizeof(dot114xMsdu_t))
+               return NOT_4X_MSDU;
+
+    pdot114xHeader = (dot114xMsdu_t*)memMgr_BufData(msduPtr->firstBDPtr);
+
+    /* 
+       Verify a TI SNAP header. 
+    */
+    if( os_memoryCompare(pFourX->hOs,
+                                                (void*)&(pdot114xHeader->msduHeader.snapHeader), 
+                                                tiSnapDataArray, 
+                                                sizeof(Wlan_LlcHeader_T)) != 0)
+       {
+               return NOT_4X_MSDU;
+       }
+
+    switch (pdot114xHeader->header4x.type) 
+       {
+               
+    case CONCATENATION : 
+        return CONCATENATION;
+/*             break; - unreachable*/
+               
+    case MANAGMENT_4X :
+        return MANAGMENT_4X;
+/*             break; - unreachable*/
+               
+    default: 
+               return NOT_4X_MSDU;
+/*             break; - unreachable*/
+               
+    }
+}
+
+TI_STATUS fourX_rxMsdu(fourX_t*        pFourX, mem_MSDU_T**    rxMsduPtr)
+{
+    Wlan4XType_t       type4xMsdu; 
+       mem_MSDU_T*             currMsduPtr;
+
+       type4xMsdu = fourX_parseRxFrame(pFourX, *rxMsduPtr);
+
+       switch (type4xMsdu) 
+       {
+               case CONCATENATION :
+                  /*
+                       * Deconcatenate Msdu
+                       */
+            WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG, 
+                               (" Received Concat msdu \n"));
+                       if(deConcat_deConcatMsdu(pFourX->pDeConcatenator, rxMsduPtr) != OK)
+                       {
+                       WLAN_REPORT_ERROR(pFourX->hReport, FOUR_X_MODULE_LOG, 
+                               (" Failed to deconcat packet \n"));
+                       
+                               return NOK;
+                       }
+                       break;
+                       
+               case MANAGMENT_4X :
+                       break;
+                       
+               default: 
+                       break;
+                       
+    }
+
+       if(pFourX->ackEmulationEnable)
+       {
+               /* call ack emulation for each packet */
+               currMsduPtr = *rxMsduPtr;
+               while(currMsduPtr)
+               {
+                       wdrv_ackEmulationRxPacket(pFourX->pAckEmul, currMsduPtr);
+                       currMsduPtr = currMsduPtr->nextMSDUinList;
+               }
+       }
+       return OK;
+
+}
+
+#define NUM_MSDU_TO_COPY 8
+
+/***************************************************************************
+*                                                      fourX_CopyReplace
+****************************************************************************
+* DESCRIPTION: This function copy OS data blocks to local data blocks 
+*                              in the MSDU in order to release OS resources and to enable
+*                              high stream of data from the OS
+* 
+* INPUTS:              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+TI_STATUS fourX_CopyReplace(fourX_t* pFourX, mem_MSDU_T **pMsdu, MsduList_t *pMsduList, mem_MSDU_T **pNewMsdu)
+{
+       mem_MSDU_T              *pOrigMsdu;
+
+       pOrigMsdu = (*pMsdu);
+
+       /* 
+        * The copy is to new msdu pointed by pMsdu 
+        */
+       if(txData_copyPacketToMsdu(pFourX->hTxData, pMsdu, 0 /* dont FreeOldMsdu */) != OK)
+       {
+               /* no msdu to transmit */
+               WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                       (" fourX_CopyReplace() : txData_copyPacketToMsdu FAILED  \n"));
+
+               return NOK;
+       }
+
+       /* 
+        * Still use the old Msdu with its pointers, so swap the BDs of the new and the orig Msdu 
+        */
+       wlan_memMngrSwapMsdu(pFourX->hMemMngr, pOrigMsdu, (*pMsdu));
+
+       /* return the new msdu to free later */
+       (*pNewMsdu) = (*pMsdu);
+       /* use the orig Msdu */
+       (*pMsdu) = pOrigMsdu;
+
+       return OK;
+}
+
+
+/***************************************************************************
+*                                                      fourX_CopyOsData
+****************************************************************************
+* DESCRIPTION: This function scan the Msdu list and copy OS data blocks to 
+*                              local data blocks .
+*                              in the MSDU in order to release OS resources and to enable
+*                              high stream of data from the OS
+* 
+* INPUTS:              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+UINT32 fourX_CopyOsData(fourX_t* pFourX, MsduList_t *pMsduList)
+{
+       int NumMsduToCopy = 0;
+       mem_MSDU_T *pMsdu;
+       mem_MSDU_T *pNewMsdu=NULL;
+       mem_MSDU_T *pMsduFreeList=NULL;
+       mem_MSDU_T *pMsduFreeCurr=NULL;
+       mem_MSDU_T *pKeepNext=NULL;
+       int i;
+       int NumOfCopiedPackets=0;
+
+       os_protectLock(pMsduList->hOs, pMsduList->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+
+       if (pMsduList->CurrNumOfMsdu == 0)
+       {
+               pFourX->counters.count6 = 0;
+               pFourX->counters.count7 = 0;
+               os_protectUnlock(pMsduList->hOs, pMsduList->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+               return 0;
+       }
+
+       /* 
+        * Find how many msdu to copy 
+        */
+       if (pMsduList->CurrNumOfMsdu <= NUM_MSDU_TO_COPY)
+               NumMsduToCopy = pMsduList->CurrNumOfMsdu;
+       else
+               NumMsduToCopy = NUM_MSDU_TO_COPY;
+
+       pMsdu=pMsduList->first;
+               
+       /* 
+        * Start the copy 
+        */
+       for (i=0; (i<NumMsduToCopy) ; i++)
+       {
+               if (pMsdu == NULL)
+               {
+                       WLAN_REPORT_ERROR(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                               (" fourX_CopyMsdu() : fourX_CopyReplace FAILED, pMsdu is NULL i=%d, Num=%d (Actual=%d) \n", i, NumMsduToCopy, pMsduList->CurrNumOfMsdu));
+
+                       break;
+               }
+               /* 
+                * Already copied - skip it 
+                */
+               if (pMsdu->freeFunc == NULL)
+               {
+                       pMsdu=pMsdu->nextMSDUinList;
+                       NumOfCopiedPackets++;
+                       continue;
+               }
+
+               WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                       (" fourX_CopyMsdu() : i=%d, CopyReplace 0x%x\n", i , pMsdu));
+               
+               /* 
+                * Copy and replace in the list 
+                */
+               if(fourX_CopyReplace(pFourX, &pMsdu, pMsduList, &pNewMsdu) != OK)
+               {
+                       /* no msdu to transmit */
+                       WLAN_REPORT_ERROR(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                               (" fourX_CopyMsdu() : fourX_CopyReplace FAILED  \n"));
+
+                       break;
+               }
+
+               /*
+                * Enter the new Msdu to the free list 
+                */
+               if (pMsduFreeList == NULL)
+               {
+                       pMsduFreeList = pNewMsdu;
+               }
+               else
+               {
+                       pMsduFreeCurr = pMsduFreeList;
+                       while (pMsduFreeCurr->nextMSDUinList != NULL)
+                               pMsduFreeCurr = pMsduFreeCurr->nextMSDUinList;
+                       pMsduFreeCurr->nextMSDUinList = pNewMsdu;
+               }
+               pNewMsdu->nextMSDUinList = NULL;
+
+               /* copy the next msdu */
+               pMsdu=pMsdu->nextMSDUinList;
+               NumOfCopiedPackets++;
+       }
+
+       pFourX->counters.count6 = pMsduList->CurrNumOfMsdu;
+       pFourX->counters.count7 = i;
+
+       /* !!!! This is the right place for the unlock */
+       os_protectUnlock(pMsduList->hOs, pMsduList->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+
+       /* 
+        * free loop, do not call the free inside lock !!!
+        */
+       pMsduFreeCurr = pMsduFreeList;
+       while (pMsduFreeCurr != NULL)
+       {
+               pKeepNext = pMsduFreeCurr->nextMSDUinList;
+
+               wlan_memMngrFreeMSDU(pFourX->hMemMngr, memMgr_MsduHandle(pMsduFreeCurr));
+
+               pMsduFreeCurr=pKeepNext;
+       }
+
+       return NumOfCopiedPackets;
+}
+       
+
+
+TI_STATUS fourX_txMsduDeQueue(fourX_t*                         pFourX,
+                                                         mem_MSDU_T**                  returnMsduPtr,
+                                                         MsduList_t*                   pMsduList,
+                                                         hwTxInformation_t*    pHwTxInformation)
+{
+       TI_STATUS               status;
+       mem_MSDU_T*             firstMsduPtr;
+       UINT16                  concatFlags = 0;
+    UINT32          numOfMsduToConcat;
+       UINT32                  numMsdu = 0;
+
+       *returnMsduPtr = NULL;
+
+
+#ifdef NO_COPY_NDIS_BUFFERS    
+       /*
+        * Scan the Msdu list and copy OS data blocks to local data blocks .
+        * in the MSDU in order to release OS resources and to enable
+        * high stream of data from the OS.
+        */
+       numMsdu = fourX_CopyOsData(pFourX, pMsduList);
+       /* This function copied up to 8 or numOfMsdu in list packets from OS to Shared memory
+        * As there is NDISfreeFunc after the copy, New un-copied packets can enter the msduList, 
+        * but the scheduler was blocked from entering the send again.
+        */
+#else
+
+       if (pMsduList->CurrNumOfMsdu < NUM_MSDU_TO_COPY )
+               numMsdu = pMsduList->CurrNumOfMsdu;     
+       else 
+               numMsdu = NUM_MSDU_TO_COPY;
+#endif
+       
+       /*if(pFourX->concatenationEnable != TRUE)*/
+       status = fourX_MakeConcatDecision(pFourX,pMsduList,pHwTxInformation,numMsdu, 
+                                       &concatFlags,&numOfMsduToConcat);
+
+
+       switch(status)
+       {
+       case MAKE_CONCATENATION:
+          
+          /*
+               * Make Concatenation
+               */
+       
+               fourX_prepareMsduListToConcat(pFourX, 
+                                                                         &firstMsduPtr, 
+                                                                         pMsduList,
+                                      numOfMsduToConcat);
+
+               if(firstMsduPtr == NULL)
+                       return NOK;
+
+               
+               return concat_concatMsduList(pFourX->pConcatenator, 
+                                                         firstMsduPtr,
+                                                         returnMsduPtr,
+                                                         concatFlags);
+
+
+       case SEND_ONE_MSDU:
+
+          /*
+               * Send Only One Msdu
+               */
+
+               if((msduList_GetFirst( pMsduList, returnMsduPtr )) != OK)
+               {
+                       /* msdu list is empty - should never reach here */
+                       WLAN_REPORT_ERROR(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                               (" fourX_txMsduDeQueue:msduList_GetFirst() : No Msdu to get in list \n"));
+                       
+                       return NOK;
+               }
+
+               return OK;
+
+       case DO_NOT_SEND_MSDU:
+
+          /*
+               * Don't Send any Msdu
+               */
+
+               return NOK;
+
+       default:
+               break;
+
+       }
+       return OK;
+}
+
+TI_STATUS fourX_txMsduBeforInsertToQueue(fourX_t* pFourX, 
+                                                                                mem_MSDU_T** msduPtr)
+{
+/* no ACK emulation !!!!!!!!!!!!!!!!!! */
+#if 0
+       UINT32 discardPacket;
+       if(pFourX->ackEmulationEnable)
+       {
+               wdrv_ackEmulationTxPacket(pFourX->pAckEmul, *msduPtr, &discardPacket);
+               if (discardPacket == TRUE)
+               {
+                       wlan_memMngrFreeMSDU(pFourX->hMemMngr, (*msduPtr)->handle);
+                       (*msduPtr) = NULL;
+                       return OK;
+               }
+       }
+#endif
+       return OK;
+}
+
+static TI_STATUS fourX_prepareMsduListToConcat(fourX_t*                pFourX,
+                                                                                          mem_MSDU_T** returnMsduPtr,
+                                                                                          MsduList_t*  pMsduList,
+                                               UINT32       maxNumMsduToConcat)
+{
+       mem_MSDU_T*             currentMsduPtr;
+       mem_MSDU_T*             PrevMsduPtr=NULL;
+       UINT32                  totalLen = 0;
+       BOOL                    firsdMsduInList = TRUE;
+       UINT32                  numOfMsdu = 0;
+
+       
+       *returnMsduPtr = NULL;
+
+       while(maxNumMsduToConcat--)
+       {
+               /* prepare a link list of msdu in the concatenator format */
+               if((msduList_WatchFirst( pMsduList, &currentMsduPtr )) != OK)
+               {
+                       /* msdu list is empty - can return now */
+                       WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                               (" fourX_txMsduDeQueue: msduList_WatchFirst() : No Msdu to watch \n"));
+                       break;
+               }
+               totalLen += currentMsduPtr->dataLen;
+               
+               if(totalLen > 4032/*pFourX->currentMaxConcatSize*/)
+                       break;
+               
+               if((msduList_GetFirst( pMsduList, &currentMsduPtr )) != OK)
+               {
+                       /* msdu list is empty - should never reach here */
+                       WLAN_REPORT_ERROR(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                               (" fourX_txMsduDeQueue:msduList_GetFirst() : No Msdu to get in list \n"));
+                       break;
+               }
+
+               /* In this phase, the free func should be NULL !!!!!!!!!!! */
+               if (currentMsduPtr->freeFunc)
+               {
+                       WLAN_REPORT_ERROR(pFourX->hReport, FOUR_X_MODULE_LOG,  
+                               (" fourX_txMsduDeQueue:msduList_GetFirst() : fourX_prepareMsduListToConcat, free funct is not NULL !!!!!!!\n"));
+               }
+
+               numOfMsdu++;
+
+               if(firsdMsduInList == TRUE)
+               {
+                       *returnMsduPtr = currentMsduPtr;
+                       firsdMsduInList = FALSE;
+               }
+               else
+               {
+                       PrevMsduPtr->nextMSDUinList = currentMsduPtr;
+               }
+               
+               PrevMsduPtr = currentMsduPtr;
+       }
+
+       return OK;
+}
+
+static TI_STATUS fourX_MakeConcatDecision(fourX_t*                             pFourX,
+                                                                                  MsduList_t*                  pMsduList,
+                                                                                  hwTxInformation_t*   pHwTxInformation,
+                                                                                  UINT32                                       numOfReadyMsdu,
+                                                                                  UINT16*                              concatFlags,
+                                           UINT32*              numOfMsduToConcat)
+{
+       memMgrResources_t memMgrResources;
+
+#ifdef TNETW_MASTER_MODE
+       UINT32 limitResourcees;
+#endif
+
+       *numOfMsduToConcat = 0;
+       
+       /* get MemoryMgr resources for concatenation */
+       wlan_memMngrGetMemMgrResources(pFourX->hMemMngr, &memMgrResources);
+
+#ifdef TNETW_MASTER_MODE
+       limitResourcees = MIN(memMgrResources.numOfFreeBufPool2 ,(MIN(memMgrResources.numOfFreeBufPool1-1 , pHwTxInformation->hwNumOfFreeBDs)));
+
+
+
+       /* No free space in HW to send */
+    if( (pHwTxInformation->hwNumOfFreeMsdu == 0) || (limitResourcees < 2) )
+    {
+        pFourX->counters.count1++;
+        return DO_NOT_SEND_MSDU;
+       }
+
+    /*
+        * Phase 1: At least 3 waiting msdu for concat (and enough space in HW)
+        * --------------------------------------------------------------------
+        * In case there are 2 msdu the decision will be later
+     * We have resources to send, decide if to concat, send single or wait.
+     */ 
+    if(  numOfReadyMsdu >= 3 )
+    {
+        pFourX->counters.count2++;
+        /* We have enough msdus to concat. */
+               *concatFlags = *concatFlags | WLAN_4X_CONCAT_MORE_BIT;
+
+               /* not enough free bd to send or concat - need at least 2 msdu and 2 bd for each + concat header bd */
+               if (limitResourcees < 5)
+                       return DO_NOT_SEND_MSDU;
+
+               /* minimum 2 bd for each msdu and one for cocat header */        
+               *numOfMsduToConcat = MIN( (limitResourcees - 1)>>1, numOfReadyMsdu);
+
+               /* minimum 2 msdu to concat */        
+               if (*numOfMsduToConcat < 2)
+                       return SEND_ONE_MSDU;
+
+               return MAKE_CONCATENATION;
+    }
+
+
+       /*
+        * Phase 2: Less than 3 waiting msdu, and the HW already has Msdu to send
+        * ----------------------------------------------------------------------
+        * It is allowed to delay the msdu and continue queueing more MSDU 
+        */
+       if(pHwTxInformation->hwNumOfBusyMsdu > 1)
+       {
+        pFourX->counters.count3++;
+          /*
+               * ACX has enough packets to send, delay the current sending.
+               */
+               return DO_NOT_SEND_MSDU;
+       }
+       /*
+        * Phase 3: Less than 3 waiting msdu, and the HW is free to send
+        * -------------------------------------------------------------
+        * It is NOT allowed to delay the msdu, so send it 
+        */
+    else 
+    {
+          /*
+               * Phase 4: There are 2 msdu to concat and the HW is free to send
+               * --------------------------------------------------------------
+        */
+        if(  numOfReadyMsdu > 1 ) 
+               {
+            pFourX->counters.count4++;
+            /* We have enough msdus to concat. */
+            *concatFlags = *concatFlags | WLAN_4X_CONCAT_MORE_BIT;
+
+                       /* not enough free bd to send or concat - need at least 2 msdu and 2 bd for each + concat header bd */
+                       if (limitResourcees < 5)
+                               return DO_NOT_SEND_MSDU;
+
+                       /* minimum 2 bd for each msdu and one for cocat header */        
+                       *numOfMsduToConcat = MIN( (limitResourcees - 1)>>1, numOfReadyMsdu);
+
+                       /* minimum 2 msdu to concat */        
+                       if (*numOfMsduToConcat < 2)
+                               return SEND_ONE_MSDU;
+
+                return MAKE_CONCATENATION;
+        }
+          /*
+               * Phase 5: There are only one msdu to send, send it (no concatination)
+               * --------------------------------------------------------------------
+               */
+        else 
+        {
+            pFourX->counters.count5++;
+                       /* 
+                        * There space in HW and only one MSDU to send, send it as single.
+                        */
+            return SEND_ONE_MSDU;
+        }
+    }
+
+
+#else /* SLAVE_MODE */
+               if((pHwTxInformation->hwTotalAvailMem > 4095) && (numOfReadyMsdu > 1))
+                       {
+                               *concatFlags = *concatFlags | WLAN_4X_CONCAT_MORE_BIT;
+                               return MAKE_CONCATENATION;
+                       }
+               else
+        {
+                       if(pHwTxInformation->hwTotalAvailMem > pMsduList->first->dataLen)
+                               return SEND_ONE_MSDU;
+                       else
+                               return DO_NOT_SEND_MSDU;
+        }
+
+#endif /* MASTER/SALVE modes */
+
+
+
+}
+
+       
+/* debug functions */
+void fourX_printParams(fourX_t* pFourX)
+{
+       
+       WLAN_OS_REPORT(("          FOUR X Parameters          \n"));
+       WLAN_OS_REPORT(("-------------------------------------\n"));
+
+       WLAN_OS_REPORT(("hOs                           = 0x%X\n",pFourX->hOs  ));
+       WLAN_OS_REPORT(("hReport                       = 0x%X\n",pFourX->hReport  ));
+       WLAN_OS_REPORT(("hMemMngr                      = 0x%X\n\n",pFourX->hMemMngr  ));
+
+       WLAN_OS_REPORT(("concatenationEnable           = %d\n",pFourX->concatenationEnable  ));
+       WLAN_OS_REPORT(("CWMinEnable                   = %d\n",pFourX->CWMinEnable  ));
+       WLAN_OS_REPORT(("CWComboEnable                 = %d\n",pFourX->CWComboEnable  ));
+       WLAN_OS_REPORT(("ackEmulationEnable            = %d\n",pFourX->ackEmulationEnable  ));
+       WLAN_OS_REPORT(("ERP_ProtectionEnable          = %d\n\n",pFourX->ERP_ProtectionEnable  ));
+
+       WLAN_OS_REPORT(("desiredConcatenationEnable    = %d\n",pFourX->desiredConcatenationEnable  ));
+       WLAN_OS_REPORT(("desiredCWMinEnable            = %d\n",pFourX->desiredCWMinEnable  ));
+       WLAN_OS_REPORT(("desiredCWComboEnable          = %d\n",pFourX->desiredCWComboEnable  ));
+       WLAN_OS_REPORT(("desiredAckEmulationEnable     = %d\n",pFourX->desiredAckEmulationEnable  ));
+       WLAN_OS_REPORT(("desiredERP_ProtectionEnable   = %d\n\n",pFourX->desiredERP_ProtectionEnable  ));
+
+       WLAN_OS_REPORT(("desiredMaxConcatSize          = %d\n",pFourX->desiredMaxConcatSize  ));
+       WLAN_OS_REPORT(("desiredCWMin                  = %d\n",pFourX->desiredCWMin  ));
+       WLAN_OS_REPORT(("desiredCWMax                  = %d\n\n",pFourX->desiredCWMax  ));
+
+
+       /* AP supported features */
+
+
+       /* 4x parameters */
+       WLAN_OS_REPORT(("currentMaxConcatSize          = %d\n",pFourX->currentMaxConcatSize  ));
+       WLAN_OS_REPORT(("currentCWMin                  = %d\n",pFourX->currentCWMin  ));
+       WLAN_OS_REPORT(("currentCWMax                  = %d\n\n",pFourX->currentCWMax  ));
+
+
+       WLAN_OS_REPORT(("ApFourX_Capabilities.fourXProtocolVersion        = %d\n", pFourX->ApFourX_Capabilities.fourXProtocolVersion));
+       WLAN_OS_REPORT(("-------------------------------------------------\n"));
+
+       WLAN_OS_REPORT(("AP_Cap.concatenationParams.enableDisable          = %d\n", pFourX->ApFourX_Capabilities.concatenationParams.enableDisable));
+       WLAN_OS_REPORT(("AP_Cap.concatenationParams.concatenationSize      = %d\n", pFourX->ApFourX_Capabilities.concatenationParams.concatenationSize));
+
+       WLAN_OS_REPORT(("AP_Cap.contentionWindowParams.enableDisable       = %d\n", pFourX->ApFourX_Capabilities.contentionWindowParams.enableDisable));
+       WLAN_OS_REPORT(("AP_Cap.contentionWindowParams.CWMin               = %d\n", pFourX->ApFourX_Capabilities.contentionWindowParams.CWMin));
+       WLAN_OS_REPORT(("AP_Cap.contentionWindowParams.CWMax               = %d\n", pFourX->ApFourX_Capabilities.contentionWindowParams.CWMax));
+
+       WLAN_OS_REPORT(("AP_Cap.CWCombParams.enableDisable                 = %d\n", pFourX->ApFourX_Capabilities.CWCombParams.enableDisable));
+       WLAN_OS_REPORT(("AP_Cap.CWCombParams.DIFS                          = %d\n", pFourX->ApFourX_Capabilities.CWCombParams.DIFS));
+       WLAN_OS_REPORT(("AP_Cap.CWCombParams.SLOT                          = %d\n", pFourX->ApFourX_Capabilities.CWCombParams.SLOT));
+       WLAN_OS_REPORT(("AP_Cap.CWCombParams.CWMin                         = %d\n", pFourX->ApFourX_Capabilities.CWCombParams.CWMin));
+       
+       WLAN_OS_REPORT(("AP_Cap.ackEmulationParams.enableDisable           = %d\n", pFourX->ApFourX_Capabilities.ackEmulationParams.enableDisable));
+       
+       WLAN_OS_REPORT(("AP_Cap.ERP_ProtectionParams.enableDisable         = %d\n", pFourX->ApFourX_Capabilities.ERP_ProtectionParams.enableDisable));
+
+       WLAN_OS_REPORT(("No Free Msdu in ACX   = %d\n", pFourX->counters.count1));
+       WLAN_OS_REPORT(("Concat more than 2    = %d\n", pFourX->counters.count2));
+       WLAN_OS_REPORT(("Delay sending         = %d\n", pFourX->counters.count3));
+       WLAN_OS_REPORT(("Concat less than 3    = %d\n", pFourX->counters.count4));
+       WLAN_OS_REPORT(("send one msdu         = %d\n", pFourX->counters.count5));
+
+       WLAN_OS_REPORT(("Msdu in Queue Total   = %d\n", pFourX->counters.count6));
+       WLAN_OS_REPORT(("Msdu in Queue Copied  = %d\n", pFourX->counters.count7));
+
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourX.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourX.h
new file mode 100644 (file)
index 0000000..1696c35
--- /dev/null
@@ -0,0 +1,218 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:                                                                                                              */
+/*    PURPOSE:                                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _FOUR_X_H
+#define _FOUR_X_H
+
+#include "osTIType.h"
+#include "paramIn.h"
+#include "paramOut.h"
+#include "Concatenator.h"
+#include "DeConcatenator.h"
+#include "ackEmulUtil.h"
+#include "memMngrEx.h"
+#include "802_11Defs.h"
+#include "MsduList.h"
+#include "DataCtrl_Api.h"
+
+
+#define FOUR_X_MODULE_LOG                                              CTRL_DATA_MODULE_LOG
+
+#define DEF_CW_MAX                                                             1023
+#define DEF_CW_MIN                                                             15
+#define DEF_CW_COMBO_CW_MIN                                            3
+#define DEF_CW_COMBO_DIFS                                              64
+#define DEF_CW_COMBO_SLOT                                              15
+
+#define CONCATENATION_CAPABILITY_ID                            0x0001
+#define CONTENTION_WINDOW_CAPABILITY_ID                        0x0002
+#define CW_COMB_CAPABILITY_ID                                  0x0003
+#define ACK ELIMINATION_CAPABILITY_ID                  0x0004
+#define ERP_PROTECTION_CAPABILITY_ID                   0x0005
+
+#define FOUR_X_PROTOCOL_VERSION_0                      0x00
+#define FOUR_X_INFO_ELEMENT_VERSION_0_LEN      4
+
+#define FOUR_X_PROTOCOL_VERSION_1                      0x01
+#define FOUR_X_CONCAT_CAP_ID                           0x0001
+#define FOUR_X_CONCAT_CAP_LEN                          0x0002
+
+
+typedef struct 
+{
+       BOOL    enableDisable;
+       UINT16  concatenationSize;
+} concatenationParams_t;
+
+typedef struct 
+{
+       UINT32  count1;
+       UINT32  count2;
+       UINT32  count3;
+       UINT32  count4;
+       UINT32  count5;
+       UINT32  count6;
+       UINT32  count7;
+} concatenationDecisionCounter_t;
+
+typedef struct 
+{
+       BOOL    enableDisable;
+       UINT16  CWMin;
+       UINT16  CWMax;
+}contentionWindowParams_t;
+
+typedef struct 
+{
+       BOOL    enableDisable;
+       UINT16  DIFS;
+       UINT16  SLOT;
+       UINT16  CWMin;
+}CWCombParams_t;
+
+typedef struct 
+{
+       BOOL    enableDisable;
+}ackEmulationParams_t;
+
+typedef struct 
+{
+       BOOL    enableDisable;
+}ERP_ProtectionParams_t;
+
+typedef struct 
+{
+       UINT8                                           fourXProtocolVersion;
+       concatenationParams_t           concatenationParams;
+       contentionWindowParams_t        contentionWindowParams;
+       CWCombParams_t                          CWCombParams;
+       ackEmulationParams_t            ackEmulationParams;
+       ERP_ProtectionParams_t          ERP_ProtectionParams;
+} fourX_Capabilities_t;
+
+
+typedef struct
+{
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hMemMngr;
+       TI_HANDLE                       hWhalCtrl;
+       TI_HANDLE                       hTxData;
+
+       /* current enable/disable status */
+       BOOL                            concatenationEnable;
+       BOOL                            CWMinEnable;
+       BOOL                            CWComboEnable;
+       BOOL                            ackEmulationEnable;
+       BOOL                            ERP_ProtectionEnable;
+
+       /* desired enable/disable features  */
+       BOOL                            desiredConcatenationEnable;
+       BOOL                            desiredCWMinEnable;
+       BOOL                            desiredCWComboEnable;
+       BOOL                            desiredAckEmulationEnable;
+       BOOL                            desiredERP_ProtectionEnable;
+
+       /* desired parameters */
+       UINT32                          desiredMaxConcatSize;
+       UINT16                          desiredCWMin;
+       UINT16                          desiredCWMax;
+
+       /* AP supported features */
+       fourX_Capabilities_t    ApFourX_Capabilities;
+
+       /* 4x parameters */
+       UINT32                          currentMaxConcatSize;
+       UINT16                          currentCWMin;
+       UINT16                          currentCWMax;
+
+       /* 4x sub modules */
+       deConcatenator_t*       pDeConcatenator;
+       concatenator_t*         pConcatenator;
+       ackEmul_t*                      pAckEmul;
+
+    /* for debug */
+    concatenationDecisionCounter_t counters;
+
+} fourX_t;
+
+fourX_t* fourX_create(TI_HANDLE hOs);
+
+TI_STATUS fourX_config(fourX_t*                                pFourX,
+                                          TI_HANDLE                    hOs,
+                                          TI_HANDLE                    hReport,
+                                          TI_HANDLE                    hMemMngr,
+                                          TI_HANDLE                    hWhalCtrl,
+                                          TI_HANDLE                    hTxData,
+                                          fourXInitParams_t*   fourXInitParams);
+
+TI_STATUS fourX_destroy(fourX_t* pFourX);
+
+TI_STATUS fourX_rxMsdu(fourX_t*        pFourX, 
+                                          mem_MSDU_T** rxMsduPtr);
+
+TI_STATUS fourX_txMsduBeforInsertToQueue(fourX_t* pFourX, 
+                                                                                mem_MSDU_T** msduPtr);
+
+TI_STATUS fourX_txMsduDeQueue(fourX_t*                         pFourX,
+                                                         mem_MSDU_T**                  returnMsduPtr,
+                                                         MsduList_t*                   pMsduList,
+                                                         hwTxInformation_t*    pHwTxInformation);
+
+
+/* 4X manager */
+TI_STATUS fourXManager_evalSite(fourX_t* pFourX, 
+                                                               dot11_4X_t* site4xParams,
+                                                               UINT32 *matchingLevel);
+
+TI_STATUS fourXManager_setSite(fourX_t* pFourX, 
+                                                          dot11_4X_t* site4xParams);
+
+TI_STATUS fourXManager_get4xInfoElemnt(fourX_t* pFourX, 
+                                                                          dot11_4X_t* fourXInfoElemnt);
+
+
+
+/* debug functions */
+void fourX_printParams(fourX_t* pFourX);
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourXManager.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/4X/fourXManager.c
new file mode 100644 (file)
index 0000000..58b81d6
--- /dev/null
@@ -0,0 +1,430 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE:                                                                                                    */
+/*             PURPOSE:                                                                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+#include "fourX.h"
+#include "report.h"
+#include "osApi.h"
+#include "utils.h"
+
+
+static void fourXManager_resetAll4xCapabilities(fourX_t* pFourX);
+static void fourXManager_resetAll_AP_4xCapabilities(fourX_t* pFourX);
+
+static TI_STATUS fourXManager_InfoElementParsing(fourX_t* pFourX, 
+                                                                                                dot11_4X_t* site4xParams,
+                                                                                                fourX_Capabilities_t* pFourX_Capabilities);
+
+static void setDefault4xCapabilities(fourX_Capabilities_t* pFourX_Capabilities);
+static TI_STATUS build4XInfoElementVersion0(fourX_t* pFourX, 
+                                                                          dot11_4X_t* fourXInfoElemnt);
+
+static TI_STATUS build4XInfoElementVersion1(fourX_t* pFourX, 
+                                                                          dot11_4X_t* fourXInfoElemnt);
+
+
+
+
+/* 4X manager */
+TI_STATUS fourXManager_evalSite(fourX_t* pFourX, 
+                                                               dot11_4X_t* site4xParams,
+                                                               UINT32 *matchingLevel)
+{
+       /* TODO - define 4x matching level */
+       return OK;
+}
+
+TI_STATUS fourXManager_setSite(fourX_t* pFourX, 
+                                                          dot11_4X_t* site4xParams)
+{
+       TI_STATUS       status;
+       whalParamInfo_t param;
+
+
+       status = fourXManager_InfoElementParsing(pFourX, 
+                                                                                        site4xParams, 
+                                                                                        &pFourX->ApFourX_Capabilities);
+       if(status != OK)
+       {
+               /* set all 4x capabilities to 0 */
+               fourXManager_resetAll4xCapabilities(pFourX);
+               return NOK;
+       }
+
+   /*
+       * configure fourX module and driver 4x Parameters
+       */
+
+       /* configure concatenation parameters */
+       if( (pFourX->desiredConcatenationEnable == TRUE) &&
+               (pFourX->ApFourX_Capabilities.concatenationParams.enableDisable == TRUE) )
+       {
+               pFourX->concatenationEnable = TRUE;
+       }
+       else
+       {
+               pFourX->concatenationEnable = FALSE;
+       }
+       pFourX->currentMaxConcatSize = MIN(pFourX->desiredMaxConcatSize,pFourX->ApFourX_Capabilities.concatenationParams.concatenationSize);
+
+   /*
+       * set Hal Parameters
+       */
+       param.paramType = HAL_CTRL_RTS_THRESHOLD_PARAM;
+       param.content.halCtrlRtsThreshold = HAL_CTRL_RTS_THRESHOLD_MAX;
+
+       whalCtrl_SetParam(pFourX->hWhalCtrl, &param);
+       
+       
+       /* configure contentionWindow parameters */
+       if( (pFourX->desiredCWMinEnable == TRUE) &&
+               (pFourX->ApFourX_Capabilities.contentionWindowParams.enableDisable == TRUE) )
+       {
+               pFourX->CWMinEnable = TRUE;
+       }
+       else
+       {
+               pFourX->CWMinEnable = FALSE;
+
+       }
+       pFourX->currentCWMax = MIN(pFourX->desiredCWMax,pFourX->ApFourX_Capabilities.contentionWindowParams.CWMax);
+       pFourX->currentCWMax = MAX(pFourX->desiredCWMin,pFourX->ApFourX_Capabilities.contentionWindowParams.CWMin);
+
+       /* configure CWCombo parameters - DO NOT Supported */
+       if( (pFourX->desiredCWComboEnable == TRUE) &&
+               (pFourX->ApFourX_Capabilities.CWCombParams.enableDisable == TRUE) )
+       {
+               pFourX->CWComboEnable = TRUE;
+       }
+       else
+       {
+               pFourX->CWComboEnable = FALSE;
+
+       }
+
+       /* configure CWCombo parameters */
+       if( (pFourX->desiredAckEmulationEnable == TRUE) &&
+               (pFourX->ApFourX_Capabilities.ackEmulationParams.enableDisable == TRUE) )
+       {
+#ifdef ACK_EMUL
+               pFourX->ackEmulationEnable = TRUE;
+#else
+               pFourX->ackEmulationEnable = FALSE;
+#endif
+       }
+       else
+       {
+               pFourX->ackEmulationEnable = FALSE;
+
+       }
+       
+       /* configure CWCombo parameters - DO NOT Supported */
+       if( (pFourX->desiredERP_ProtectionEnable == TRUE) &&
+               (pFourX->ApFourX_Capabilities.ERP_ProtectionParams.enableDisable == TRUE) )
+       {
+               pFourX->ERP_ProtectionEnable = TRUE;
+       }
+       else
+       {
+               pFourX->ERP_ProtectionEnable = FALSE;
+
+       }
+
+       return OK;
+}
+
+
+static TI_STATUS fourXManager_InfoElementParsing(fourX_t* pFourX, 
+                                                                                                dot11_4X_t* site4xParams,
+                                                                                                fourX_Capabilities_t* pFourX_Capabilities)
+{
+       char *capPtr;
+       UINT32 len;
+    UINT16 capLen;
+       WlanTIcap_t cap_type;
+       UINT8 ti_oui[] = TI_OUI;
+
+       if(site4xParams == NULL)
+       {
+               fourXManager_resetAll_AP_4xCapabilities(pFourX);
+               return NOK;
+       }
+
+   /*
+       * IE parsing 
+       */
+       if( (site4xParams->hdr.eleId != DOT11_4X_ELE_ID) ||
+               (site4xParams->hdr.eleLen > DOT11_4X_MAX_LEN) ||
+               (os_memoryCompare(pFourX->hOs ,ti_oui, (PUINT8)site4xParams->fourXCapabilities, DOT11_OUI_LEN) != 0) )
+       {
+               fourXManager_resetAll_AP_4xCapabilities(pFourX);
+               return NOK;
+       }
+
+   /* 
+       * check protocol version 
+       */
+       if( ((site4xParams->fourXCapabilities[DOT11_OUI_LEN]) & 0xF) == FOUR_X_PROTOCOL_VERSION_0)
+       {
+          /* 
+               * version 0 
+               */
+               pFourX_Capabilities->fourXProtocolVersion = FOUR_X_PROTOCOL_VERSION_0;
+               setDefault4xCapabilities(pFourX_Capabilities);
+               return OK;
+       }
+       else
+       if( ((site4xParams->fourXCapabilities[DOT11_OUI_LEN]) & 0xF) == FOUR_X_PROTOCOL_VERSION_1)
+       {
+          /* 
+               * version 1
+               */
+               pFourX_Capabilities->fourXProtocolVersion = FOUR_X_PROTOCOL_VERSION_1;
+
+               capPtr = (char *)site4xParams;
+               capPtr += (sizeof(dot11_eleHdr_t) + DOT11_OUI_LEN + 1); /*IE header + TI_OUI + version field */; 
+
+               len = DOT11_OUI_LEN+1; /* TI_OUI + version field */
+                                               
+               while(len < (UINT32)(site4xParams->hdr.eleLen)) /* Dm: Security fix */
+               {
+                       cap_type = (WlanTIcap_t)(*((UINT16*)(capPtr)));
+                       
+                       switch(cap_type)
+                       {
+                       case TI_CAP_4X_CONCATENATION:                                                   
+                               pFourX_Capabilities->concatenationParams.enableDisable = TRUE;
+                               capPtr += 2;
+                               capLen = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               pFourX_Capabilities->concatenationParams.concatenationSize = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val fields */;
+                               break;
+
+                       case TI_CAP_4X_CONT_WINDOW:
+                               pFourX_Capabilities->contentionWindowParams.enableDisable = TRUE;
+                               capPtr += 2;
+                               capLen = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               pFourX_Capabilities->contentionWindowParams.CWMin = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               pFourX_Capabilities->contentionWindowParams.CWMax = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
+                               break;
+
+                       case TI_CAP_4X_CONT_WINDOW_COMBO:
+                               pFourX_Capabilities->CWCombParams.enableDisable = TRUE;
+                               capPtr += 2;
+                               capLen = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               pFourX_Capabilities->CWCombParams.DIFS = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               pFourX_Capabilities->CWCombParams.SLOT = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               pFourX_Capabilities->CWCombParams.CWMin = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
+                               break;
+
+                       case TI_CAP_4X_TCP_ACK_EMUL:
+                               pFourX_Capabilities->ackEmulationParams.enableDisable = TRUE;
+                               capPtr += 2;
+                               capLen = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
+                               break;
+
+                       case TI_CAP_TRICK_PACKET_ERP:
+                               pFourX_Capabilities->ERP_ProtectionParams.enableDisable = TRUE;
+                               capPtr += 2;
+                               capLen = *((UINT16*)(capPtr));
+                               capPtr += 2;
+                               len += sizeof(UINT16) /* type field */ + sizeof(UINT16) /* len field */ + (UINT32)capLen /* val field */;
+                               break;
+                       
+                       default:
+                               WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG, 
+                                               ("unrecognized capability in TI IE: %d\n",cap_type));
+                               return NOK;
+                       }
+               }
+       }
+       else
+       {
+          /* 
+               * unknown version
+               */
+               fourXManager_resetAll_AP_4xCapabilities(pFourX);
+               return NOK;
+       }
+
+       return OK;
+}
+
+TI_STATUS fourXManager_get4xInfoElemnt(fourX_t* pFourX, 
+                                                                          dot11_4X_t* fourXInfoElemnt)
+{
+    TI_STATUS Status;
+       if(pFourX->ApFourX_Capabilities.fourXProtocolVersion == FOUR_X_PROTOCOL_VERSION_0)
+       {
+               Status = build4XInfoElementVersion0(pFourX, fourXInfoElemnt);
+       }
+       else
+       if(pFourX->ApFourX_Capabilities.fourXProtocolVersion == FOUR_X_PROTOCOL_VERSION_1)
+       {
+               Status = build4XInfoElementVersion1(pFourX, fourXInfoElemnt);
+       }
+       else
+       {
+               WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG, 
+                               ("fourXManager_get4xInfoElemnt: Versionm unknown\n"));
+               return NOK;
+       }
+       
+       return Status;
+}
+
+static TI_STATUS build4XInfoElementVersion0(fourX_t* pFourX, 
+                                                                          dot11_4X_t* fourXInfoElemnt)
+{
+       UINT8 ti_oui[] = TI_OUI;
+
+       WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG, 
+                               ("build4XInfoElementVersion0: build IE version 0\n"));
+
+       /* 4x Protocol version should support ALL  version 0 features */
+       if( (pFourX->desiredConcatenationEnable == FALSE) ||
+               (pFourX->desiredCWMinEnable == FALSE) )
+       {
+               return NOK;
+       }
+
+       fourXInfoElemnt->hdr.eleId = TI_4X_IE_ID;
+       fourXInfoElemnt->hdr.eleLen = FOUR_X_INFO_ELEMENT_VERSION_0_LEN;
+
+       os_memoryCopy(pFourX->hOs, (PUINT8)fourXInfoElemnt->fourXCapabilities, ti_oui, DOT11_OUI_LEN);
+       fourXInfoElemnt->fourXCapabilities[DOT11_OUI_LEN] = FOUR_X_PROTOCOL_VERSION_0;
+    return OK;
+}
+
+static TI_STATUS build4XInfoElementVersion1(fourX_t* pFourX, 
+                                                                          dot11_4X_t* fourXInfoElemnt)
+{
+       UINT8 len = 0;
+       UINT8 *capPtr; 
+       UINT8 ti_oui[] = TI_OUI;
+
+       WLAN_REPORT_INFORMATION(pFourX->hReport, FOUR_X_MODULE_LOG, 
+                               ("build4XInfoElementVersion0: build IE version 1\n"));
+
+       fourXInfoElemnt->hdr.eleId = TI_4X_IE_ID;
+
+       capPtr = (UINT8 *)fourXInfoElemnt->fourXCapabilities;
+
+       os_memoryCopy(pFourX->hOs, capPtr, ti_oui, DOT11_OUI_LEN);
+       capPtr += DOT11_OUI_LEN ;
+       len += DOT11_OUI_LEN ;
+
+       *capPtr = FOUR_X_PROTOCOL_VERSION_1;
+       capPtr += 1;
+       len += 1;
+
+
+       if(pFourX->desiredConcatenationEnable == TRUE)
+       {
+               *((UINT16*)capPtr) = FOUR_X_CONCAT_CAP_ID;
+               capPtr += 2;
+               len += 2;
+               *((UINT16*)capPtr) = FOUR_X_CONCAT_CAP_LEN;
+               capPtr += 2;
+               len += 2;
+               *((UINT16*)capPtr) = 4095;
+               capPtr += 2;
+               len += 2;
+       }
+               
+       
+       fourXInfoElemnt->hdr.eleLen = len;
+    return OK;
+
+}
+
+static void fourXManager_resetAll4xCapabilities(fourX_t* pFourX)
+{
+               pFourX->concatenationEnable = FALSE;
+               pFourX->CWMinEnable = FALSE;
+               pFourX->CWComboEnable = FALSE;
+               pFourX->ackEmulationEnable = FALSE;
+               pFourX->ERP_ProtectionEnable = FALSE;
+}
+
+static void fourXManager_resetAll_AP_4xCapabilities(fourX_t* pFourX)
+{
+       os_memoryZero(pFourX->hOs, &pFourX->ApFourX_Capabilities, (sizeof(fourX_Capabilities_t)));
+}
+
+static void setDefault4xCapabilities(fourX_Capabilities_t* pFourX_Capabilities)
+{
+       /* Concatenation */
+       pFourX_Capabilities->concatenationParams.enableDisable = TRUE;
+       pFourX_Capabilities->concatenationParams.concatenationSize = MAX_CONCAT_SIZE_DEF;
+       
+       /* CW min */
+       pFourX_Capabilities->contentionWindowParams.enableDisable = TRUE;
+       pFourX_Capabilities->contentionWindowParams.CWMax = DEF_CW_MAX;
+       pFourX_Capabilities->contentionWindowParams.CWMin = DEF_CW_MIN;
+
+       /* CW combo */
+       pFourX_Capabilities->CWCombParams.enableDisable = FALSE;
+       pFourX_Capabilities->CWCombParams.CWMin = DEF_CW_COMBO_CW_MIN;
+       pFourX_Capabilities->CWCombParams.DIFS = DEF_CW_COMBO_DIFS;
+       pFourX_Capabilities->CWCombParams.SLOT = DEF_CW_COMBO_SLOT;
+
+       /* Ack Emulation */
+       pFourX_Capabilities->ackEmulationParams.enableDisable = TRUE;
+
+       /* ERP protection */
+       pFourX_Capabilities->ERP_ProtectionParams.enableDisable = FALSE;
+
+
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/Clsfr.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/Clsfr.c
new file mode 100644 (file)
index 0000000..c3ad75d
--- /dev/null
@@ -0,0 +1,1043 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 Clsfr.c
+ */
+
+#include "paramOut.h"
+#include "Clsfr.h"
+#include "utils.h"
+#include "report.h"
+
+
+#define ETHERNET_HEADER_SIZE    14
+
+static TI_STATUS classifier_getIpAndUdpHeader(classifier_t* pClsfr, mem_MSDU_T *pMsdu, UINT8 **pIpHeader, UINT8 **pUdpHeader);
+
+
+
+/*************************************************************************
+*                        Classifier_create                               *
+**************************************************************************
+* DESCRIPTION:  This function creates the Classifier module.                 
+*                                                      
+* INPUT:        hOs - handle to Os Abstraction Layer
+*               
+* OUTPUT:       Pointer to the Classifier module
+************************************************************************/
+
+classifier_t* Classifier_create(TI_HANDLE hOs)
+{
+    classifier_t*   pClsfr;
+    
+    if( hOs  == NULL )
+               return NULL;
+   
+
+    /* alocate classifier block */
+    pClsfr = os_memoryAlloc(hOs, (sizeof(classifier_t)));
+
+    if (!pClsfr) 
+    {
+        utils_nullMemoryFree(hOs, pClsfr, sizeof(classifier_t));
+        return NULL;
+    }
+
+    /* clear the block */
+    os_memoryZero(hOs, pClsfr, (sizeof(classifier_t)));
+
+    pClsfr->hOs = hOs;
+
+    return(pClsfr);
+}
+
+
+
+/******************************************************************************
+*                        Classifier_config                                    *
+*******************************************************************************
+* DESCRIPTION:  This function configures the Classifier module.                 
+*                                                      
+* INPUT:        hOs, hReport - handle to Os Abstraction Layer and to the Report
+*               
+* OUTPUT:       PARAM_VALUE_NOT_VALID in case of problems with input parameters
+*               and OK otherwise
+********************************************************************************/
+
+
+TI_STATUS Classifier_config(classifier_t* pClsfr, TI_HANDLE hOs, TI_HANDLE hReport, clsfr_Params_t* ClsfrInitParams)
+{
+    int i,j,actualEntryCount;
+    BOOL conflictFound;
+    
+    /* check parameters validity */
+    if (pClsfr == NULL) 
+               return NOK;
+    
+       if ( (hOs == NULL) || (hReport == NULL) )
+               return NOK;
+
+    /* set objects handles */
+    pClsfr->hOs = hOs;
+    pClsfr->hReport = hReport;
+    
+    /* Active classification algorithm */
+    pClsfr->clsfrParameters.clsfrType = ClsfrInitParams->clsfrType;
+
+    /* the number of active entries */
+    if (ClsfrInitParams->NumOfActiveEntries <= NUM_OF_CLSFR_TABLE_ENTRIES)
+        pClsfr->clsfrParameters.NumOfActiveEntries = ClsfrInitParams->NumOfActiveEntries;
+    else 
+        pClsfr->clsfrParameters.NumOfActiveEntries = NUM_OF_CLSFR_TABLE_ENTRIES;
+
+    /* Initialization of the classification table */
+    switch (pClsfr->clsfrParameters.clsfrType)
+    {
+        case D_TAG_CLSFR:
+                       pClsfr->clsfrParameters.NumOfActiveEntries = 0;
+        break;
+        
+        case DSCP_CLSFR:
+            actualEntryCount=0;
+            for (i=0; (i < pClsfr->clsfrParameters.NumOfActiveEntries ) ; i++)
+            {
+               conflictFound = FALSE;
+                /* check conflict */
+                for (j=0;j<i;j++)
+                {
+                   /* Detect both duplicate and conflicting entries */
+                    if (pClsfr->clsfrParameters.ClsfrTable[j].Dscp.CodePoint == ClsfrInitParams->ClsfrTable[i].Dscp.CodePoint)
+                    {
+                        WLAN_REPORT_WARNING (pClsfr->hReport, CLSFR_MODULE_LOG,("ERROR: Classifier_config(): duplicate/conflicting classifier entries\n"));
+                        conflictFound = TRUE;
+                    }
+                }
+                if (conflictFound == FALSE)
+                {
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].Dscp.CodePoint = ClsfrInitParams->ClsfrTable[i].Dscp.CodePoint;
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].DTag = ClsfrInitParams->ClsfrTable[i].DTag;
+                  actualEntryCount++;
+                }
+            }
+            pClsfr->clsfrParameters.NumOfActiveEntries = actualEntryCount;
+        break;
+        case PORT_CLSFR:
+           actualEntryCount=0;
+            for (i=0; (i < pClsfr->clsfrParameters.NumOfActiveEntries ) ; i++)
+            {
+                               conflictFound = FALSE;
+                /* check conflict */
+                for (j=0;j<i;j++)
+                {
+                    /* Detect both duplicate and conflicting entries */
+                    if (pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstPortNum == ClsfrInitParams->ClsfrTable[i].Dscp.DstPortNum)
+                    {
+                        WLAN_REPORT_WARNING (pClsfr->hReport, CLSFR_MODULE_LOG,("ERROR: Classifier_config(): classifier entries conflict\n"));
+                        conflictFound = TRUE;
+                    }
+                }
+                if (conflictFound == FALSE)
+                {
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].Dscp.DstPortNum = ClsfrInitParams->ClsfrTable[i].Dscp.DstPortNum;
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].DTag = ClsfrInitParams->ClsfrTable[i].DTag;
+                  actualEntryCount++;
+                }
+            }
+            pClsfr->clsfrParameters.NumOfActiveEntries = actualEntryCount;
+        break;    
+        case IPPORT_CLSFR:
+           actualEntryCount=0;
+            for (i=0; (i < pClsfr->clsfrParameters.NumOfActiveEntries ) ; i++)
+            {
+                               conflictFound = FALSE;
+                /* check conflict */
+                for (j=0;j<i;j++)
+                {
+                   /* Detect both duplicate and conflicting entries */
+                    if ((pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstIPPort.DstIPAddress == ClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress)&& 
+                    (pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstIPPort.DstPortNum == ClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum))
+                    {
+                        WLAN_REPORT_WARNING (pClsfr->hReport, CLSFR_MODULE_LOG,("ERROR: Classifier_config(): classifier entries conflict\n"));
+                        conflictFound = TRUE;
+                    }
+                }
+                if (conflictFound == FALSE)
+                {
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].Dscp.DstIPPort.DstIPAddress = ClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstIPAddress;
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].Dscp.DstIPPort.DstPortNum = ClsfrInitParams->ClsfrTable[i].Dscp.DstIPPort.DstPortNum;
+                  pClsfr->clsfrParameters.ClsfrTable[actualEntryCount].DTag = ClsfrInitParams->ClsfrTable[i].DTag;
+                  actualEntryCount++;
+                }
+            }
+            pClsfr->clsfrParameters.NumOfActiveEntries = actualEntryCount;
+        break;    
+        default:
+            WLAN_REPORT_WARNING (pClsfr->hReport, CLSFR_MODULE_LOG,("ERROR: Classifier_config(): Classifier type -- unknown --> set to D-Tag\n"));
+            pClsfr->clsfrParameters.clsfrType = D_TAG_CLSFR;
+                       pClsfr->clsfrParameters.NumOfActiveEntries = 0;
+    }
+    
+    return OK;
+
+}
+
+
+/******************************************************************************
+*                        Classifier_destroy                                    *
+*******************************************************************************
+* DESCRIPTION:  This function destroys the Classifier module.                 
+*                                                      
+* INPUT:        the object
+*               
+* OUTPUT:       NOK in case of problems with the input parameter
+*               and OK otherwise
+********************************************************************************/
+
+TI_STATUS Classifier_destroy(classifier_t* pClsfr) 
+{
+
+    /* check parameters validity */
+    if( pClsfr == NULL )
+        return NOK;
+
+    /* free the classifier memory block */
+    os_memoryFree(pClsfr->hOs, pClsfr, sizeof(classifier_t));
+    return OK;
+}
+
+
+
+/************************************************************************
+ *                        Classifier_classifyTxMSDU
+ ************************************************************************
+      
+Input:  
+
+* pClsfr: pointer to the classifier 
+* pMsdu: pointer to the MSDU
+* packet_DTag: NDIS Packet 802.1 user priority (UP)
+
+Output:  
+
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+If the value PARAM_VALUE_NOT_VALID is returned, the MSDU qosTag field is zero. 
+
+Description:  
+
+This function performs the classification algorithm for the MSDU pointed 
+by pMsdu, according to the classifier parameters. 
+It initializes the qosTag field of the MSDU with the classification algorithm 
+returned value. Note that if the value in the field clsfrType of Clsfr_Params is 
+D_TAG_CLSFR then it performs the trivial classification algorithm from 
+D-tag to D-tag. That is, Msdu->qosTag is set to packet_DTag. 
+For all other classification algorithms, the classification is performed 
+according to the corresponding classifier table.
+  
+************************************************************************/
+
+
+TI_STATUS Classifier_classifyTxMSDU(classifier_t* pClsfr, mem_MSDU_T *pMsdu, UINT8 packet_DTag)
+{
+   
+    UINT8               i;
+    UINT8               *pUdpHeader = NULL;
+    UINT8               *pIpHeader = NULL;
+    UINT8               DSCP;
+    UINT16              dstPortNum;
+    UINT32              dstIPAdd;
+
+    /* Parameters validation */
+
+       if (pClsfr == NULL)
+               return NOK; 
+
+    if (pMsdu == NULL) 
+    {
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       (" Classifier_classifyTxMSDU() : NULL MSDU error  \n"));
+        return PARAM_VALUE_NOT_VALID; 
+    }
+
+    if ((packet_DTag > MAX_NUM_OF_802_1d_TAGS) && (pClsfr->clsfrParameters.clsfrType == D_TAG_CLSFR))
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       (" Classifier_classifyTxMSDU() : packet_DTag error  \n"));
+               pMsdu->qosTag = 0;
+               return PARAM_VALUE_NOT_VALID;
+    }
+    
+    /* Initialization */
+    pMsdu->qosTag = 0;
+
+    switch(pClsfr->clsfrParameters.clsfrType)
+    {
+        case D_TAG_CLSFR:
+            /* Trivial mapping D-tag to D-tag */
+            pMsdu->qosTag = packet_DTag;
+            WLAN_REPORT_INFORMATION (pClsfr->hReport, CLSFR_MODULE_LOG, ("Classifier D_TAG_CLSFR. pMsdu->qosTag = %d\n",pMsdu->qosTag));
+            
+        break;
+
+        case DSCP_CLSFR:
+        
+            if( (classifier_getIpAndUdpHeader(pClsfr, pMsdu, &pIpHeader, &pUdpHeader) != OK) || 
+                (pIpHeader == NULL) )
+            {
+                WLAN_REPORT_INFORMATION(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                       (" Classifier_classifyTxMSDU() : DSCP clsfr, getIpAndUdpHeader error\n"));
+                               return PARAM_VALUE_NOT_VALID; 
+            }
+
+            /* DSCP to D-tag mapping */
+            DSCP =  *((UINT8 *)(pIpHeader + 1)); /* Fetching the DSCP from the header */
+            DSCP = (DSCP >> 2);
+            
+            /* looking for the specific DSCP, if the DSCP is found, its corresponding 
+               D-tag is set to the qosTag                                           */
+            for(i = 0; i<pClsfr->clsfrParameters.NumOfActiveEntries; i++ )
+            {
+                if (pClsfr->clsfrParameters.ClsfrTable[i].Dscp.CodePoint == DSCP)
+                               {
+                    pMsdu->qosTag = pClsfr->clsfrParameters.ClsfrTable[i].DTag;
+                    WLAN_REPORT_INFORMATION (pClsfr->hReport, CLSFR_MODULE_LOG,("Classifier DSCP_CLSFR found match - entry %d - qosTag = %d\n",i,pMsdu->qosTag));
+                                       break;
+                               }
+            }
+
+        break;
+
+
+        case PORT_CLSFR:
+            if( (classifier_getIpAndUdpHeader(pClsfr, pMsdu, &pIpHeader, &pUdpHeader) != OK) ||
+                (pUdpHeader == NULL) )
+            {
+                WLAN_REPORT_INFORMATION(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                       (" Classifier_classifyTxMSDU() : DstPort clsfr, getIpAndUdpHeader error\n"));
+                return PARAM_VALUE_NOT_VALID; 
+            }
+
+            /* Port to D-tag mapping */
+            dstPortNum = *((UINT16 *)(pUdpHeader + 2)); /* Fetching the port number from the header */
+            dstPortNum = ((dstPortNum >> 8) | (dstPortNum << 8));
+            
+            /* looking for the specific port number, if the port number is found, its corresponding 
+               D-tag is set to the qosTag                                                           */
+            for(i = 0; i<pClsfr->clsfrParameters.NumOfActiveEntries; i++ )
+            {
+                if (pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstPortNum == dstPortNum)
+                               {
+                    pMsdu->qosTag = pClsfr->clsfrParameters.ClsfrTable[i].DTag;
+                    WLAN_REPORT_INFORMATION (pClsfr->hReport, CLSFR_MODULE_LOG,("Classifier PORT_CLSFR found match - entry %d - qosTag = %d\n",i,pMsdu->qosTag));
+                                       break;
+                               }
+            }
+        break;
+
+        case IPPORT_CLSFR: 
+            if( (classifier_getIpAndUdpHeader(pClsfr, pMsdu, &pIpHeader, &pUdpHeader) != OK) ||
+                (pIpHeader == NULL) || (pUdpHeader == NULL) )
+            {
+                WLAN_REPORT_INFORMATION(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                       (" Classifier_classifyTxMSDU() : Dst IP&Port clsfr, getIpAndUdpHeader error\n"));
+                return PARAM_VALUE_NOT_VALID; 
+            }
+
+            /* IP&Port to D-tag mapping */
+            dstPortNum = *((UINT16 *)(pUdpHeader + 2)); /* Fetching the port number from the header */
+            dstPortNum = ((dstPortNum >> 8) | (dstPortNum << 8));
+            {
+                /* Since IP header is 2 bytes aligned we will copy IP as two 16 bits */
+                /* dstIPAdd = *((UINT32 *)(pIpHeader + 16));*/
+                UINT16 hiPart, loPart;
+                hiPart = *((UINT16 *) pIpHeader + 8);
+                loPart = *((UINT16 *) pIpHeader + 9);
+                dstIPAdd = (loPart << 16) | hiPart;     // account for little endian host and network order
+
+            }
+            
+            /* looking for the specific pair of dst IP address and dst port number, if it is found, its corresponding 
+               D-tag is set to the qosTag                                                           */
+            for(i = 0; i<pClsfr->clsfrParameters.NumOfActiveEntries; i++ )
+            {
+                if ((pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstIPAddress == dstIPAdd)&&
+                    ( pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstPortNum == dstPortNum))
+                               {
+                    pMsdu->qosTag = pClsfr->clsfrParameters.ClsfrTable[i].DTag;
+                    WLAN_REPORT_INFORMATION (pClsfr->hReport, CLSFR_MODULE_LOG,("Classifier IPPORT_CLSFR found match - entry %d - qosTag = %d\n",i,pMsdu->qosTag));
+                                       break;
+                               }
+            }
+
+        break;
+        
+        default:
+
+            WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                       (" Classifier_classifyTxMSDU(): clsfrType error\n"));
+    }
+
+    return OK;
+}
+
+
+
+/************************************************************************
+ *                        classifier_getIpAndUdpHeader
+ ************************************************************************
+      
+Input:  
+
+* pClsfr: pointer to the classifier 
+* pMsdu: pointer to the MSDU
+
+Output:  
+
+* pIpHeader: pointer to the IP header
+* pUdpHeader: pointer to the UDP header 
+
+Description:  
+
+This function fetch the addresses of the IP and UDP headers
+  
+************************************************************************/
+static TI_STATUS classifier_getIpAndUdpHeader(classifier_t* pClsfr, mem_MSDU_T *pMsdu, UINT8 **pIpHeader, UINT8 **pUdpHeader)
+{
+    UINT8              ipHeaderLen=0;
+    mem_BD_T*           currBD = NULL;
+    UINT16              swapedTypeLength=0;
+
+    
+       /* Parameters validation */
+       
+       
+       if (pMsdu == NULL)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       (" classifier_getIpAndUdpHeader: NULL MSDU error \n"));
+               return NOK; 
+    }
+
+    currBD = pMsdu->firstBDPtr;
+    if( currBD == NULL)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       (" classifier_getIpAndUdpHeader: first BD is NULL \n"));
+               return NOK;
+    }
+       
+    swapedTypeLength = wlan_htons(*((UINT16*)(currBD->data+currBD->dataOffset+12)) );
+    
+           /* check if frame is IP according to ether type */
+    if( swapedTypeLength != 0x0800)
+    {
+        WLAN_REPORT_INFORMATION(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                       (" classifier_getIpAndUdpHeader: swapedTypeLength is not 0x0800 \n"));
+        return NOK;
+    }
+
+/*Ronnie: we could have skipped the NO_COPY_NDIS_BUFFERS ifdef (both cases are the same)*/
+#ifdef NO_COPY_NDIS_BUFFERS 
+    /* 
+        in windows - protocols headears are in the same buffer. 
+        Headears can not bu split between 2 buffers 
+    */
+
+    /* IP is in first buffer */
+    *pIpHeader = (UINT8 *)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr)) + ETHERNET_HEADER_SIZE;
+    ipHeaderLen = ((*(unsigned char*)(*pIpHeader)  & 0x0f) * 4);
+
+
+    /* UDP/TCP is in first buffer */
+    *pUdpHeader = *pIpHeader + ipHeaderLen;  /* Set the pointer to the begining of the TCP/UDP header */
+
+
+#else
+    /* set the pointer to the beginning of the IP header  and calculate it's size*/
+    *pIpHeader = (UINT8 *)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr)) + ETHERNET_HEADER_SIZE;
+    ipHeaderLen = ((*(unsigned char*)(*pIpHeader)  & 0x0f) * 4);
+    *pUdpHeader = *pIpHeader + ipHeaderLen;  /* Set the pointer to the beggining of the TCP/UDP header */
+#endif
+    return OK;
+}
+
+
+
+/************************************************************************
+ *                        classifier_InsertClsfrEntry                 *
+ ************************************************************************
+ The following API is used to configure the classifier table. Note that 
+ this API provides only insert to table service (and not delete).      
+
+Input:  
+
+*   pClsfr: pointer to the classifier 
+*   NumberOfEntries: number of entries to insert.
+*   ConfigBufferPtr: pointer to the data to insert.
+
+Output:  
+
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+If the value PARAM_VALUE_NOT_VALID is returned, the entries insert operation 
+on the classifier table is canceled. 
+
+The value PARAM_VALUE_NOT_VALID is returned upon the following errors:
+--   NumberOfEntries parameter:
+    a) If it is larger than the available entries in the table.
+    b) If it is smaller than 1.
+    c) If an entry creates conflict with another entry. 
+--   ConfigBufferPtr is pointing on NULL. 
+
+************************************************************************/
+TI_STATUS Classifier_InsertClsfrEntry(classifier_t* pClsfr, UINT8 NumberOfEntries, clsfr_tableEntry_t *ConfigBufferPtr)
+{
+
+    UINT8 avlEntries;
+    clsfr_tableEntry_t *pSrc;
+    int i,j;
+
+    if(pClsfr == NULL)
+               return NOK;
+    
+       if(ConfigBufferPtr == NULL)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("Classifier_InsertClsfrEntry(): NULL ConfigBuffer pointer Error - Aborting\n"));
+               return PARAM_VALUE_NOT_VALID;
+    }
+    
+    avlEntries = (NUM_OF_CLSFR_TABLE_ENTRIES - (pClsfr->clsfrParameters.NumOfActiveEntries));
+    if ((NumberOfEntries < 1) || (NumberOfEntries > avlEntries))
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("Classifier_InsertClsfrEntry(): Bad Number Of Entries - Aborting\n"));
+        return PARAM_VALUE_NOT_VALID;
+    }
+    
+    if (pClsfr->clsfrParameters.clsfrType == D_TAG_CLSFR)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("Classifier_InsertClsfrEntry(): D-Tag classifier - Aborting\n"));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    /* Check conflicts with classifier table entries */
+    /* check all conflicts, if all entries are OK --> insert to classifier table*/
+    pSrc = ConfigBufferPtr;
+    
+    switch (pClsfr->clsfrParameters.clsfrType)
+    {
+        case DSCP_CLSFR:
+            for  (i=0; i< NumberOfEntries ; i++)  
+            {   
+                /* Check entry */
+                               if ((pSrc[i].Dscp.CodePoint > CLASSIFIER_CODE_POINT_MAX) || (pSrc[i].DTag > CLASSIFIER_DTAG_MAX)) 
+                {
+                               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                                       ("Classifier_InsertClsfrEntry(): bad parameter - Aborting\n"));
+                    return PARAM_VALUE_NOT_VALID;
+                }
+                               
+                               /* Check conflict*/
+                               for (j=0;j<pClsfr->clsfrParameters.NumOfActiveEntries;j++)
+                {
+                   /* Detect both duplicate and conflicting entries */
+                    if (pClsfr->clsfrParameters.ClsfrTable[j].Dscp.CodePoint == pSrc[i].Dscp.CodePoint)
+                        {
+                                               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                                               ("Classifier_InsertClsfrEntry(): classifier entries conflict - Aborting\n"));
+                            return PARAM_VALUE_NOT_VALID;
+                        }
+                } 
+               
+            }
+
+            /* All new entries are valid --> insert to classifier table */            
+            for  (i=0; i< NumberOfEntries ; i++)  
+            { 
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].Dscp.CodePoint = pSrc[i].Dscp.CodePoint;
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].DTag = pSrc[i].DTag;
+            }
+            
+        break;
+        
+        case PORT_CLSFR:
+            for  (i=0; i< NumberOfEntries ; i++)  
+            {
+                               /* Check entry */
+                               if ((pSrc[i].DTag > CLASSIFIER_DTAG_MAX) || (pSrc[i].Dscp.DstPortNum > CLASSIFIER_PORT_MAX-1) || (pSrc[i].Dscp.DstPortNum < CLASSIFIER_PORT_MIN) )
+                {
+                               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                                       ("Classifier_InsertClsfrEntry(): bad parameter - Aborting\n"));
+                    return PARAM_VALUE_NOT_VALID;
+                }
+                               
+                               /* Check conflict*/
+                for (j=0;j<pClsfr->clsfrParameters.NumOfActiveEntries;j++)
+                {
+                   /* Detect both duplicate and conflicting entries */
+                    if ((pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstPortNum == pSrc[i].Dscp.DstPortNum))
+                        {
+                                               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                                               ("Classifier_InsertClsfrEntry(): classifier entries conflict - Aborting\n"));
+                             return PARAM_VALUE_NOT_VALID;
+                        }
+                }     
+                                
+            }    
+
+            /* All new entries are valid --> insert to classifier table */            
+            for  (i=0; i< NumberOfEntries ; i++)  
+            { 
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].Dscp.DstPortNum = pSrc[i].Dscp.DstPortNum;
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].DTag = pSrc[i].DTag;
+            }
+                                
+        break;
+        
+        case IPPORT_CLSFR:
+            for  (i=0; i< NumberOfEntries ; i++)  
+            {   
+                               /* Check entry */
+                               if ( (pSrc[i].DTag > CLASSIFIER_DTAG_MAX) || (pSrc[i].Dscp.DstIPPort.DstPortNum > CLASSIFIER_PORT_MAX-1) || 
+                                       (pSrc[i].Dscp.DstIPPort.DstPortNum < CLASSIFIER_PORT_MIN) || (pSrc[i].Dscp.DstIPPort.DstIPAddress > CLASSIFIER_IPADDRESS_MAX-1) || 
+                                       (pSrc[i].Dscp.DstIPPort.DstIPAddress < CLASSIFIER_IPADDRESS_MIN+1) )
+                {
+                               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                                       ("Classifier_InsertClsfrEntry(): bad parameter - Aborting\n"));
+                    return PARAM_VALUE_NOT_VALID;
+                }
+
+                               /* Check conflict*/
+                for (j=0;j<pClsfr->clsfrParameters.NumOfActiveEntries;j++)
+                {
+                   /* Detect both duplicate and conflicting entries */
+                    if ( (pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstIPPort.DstIPAddress == pSrc[i].Dscp.DstIPPort.DstIPAddress) && 
+                         (pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstIPPort.DstPortNum == pSrc[i].Dscp.DstIPPort.DstPortNum))
+                        {
+                                               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                                               ("Classifier_InsertClsfrEntry(): classifier entries conflict - Aborting\n"));
+                             return PARAM_VALUE_NOT_VALID;
+                        }
+                }  
+                
+            }            
+
+            /* All new entries are valid --> insert to classifier table */            
+            for  (i=0; i< NumberOfEntries ; i++)  
+            { 
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].Dscp.DstIPPort.DstIPAddress = pSrc[i].Dscp.DstIPPort.DstIPAddress;
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].Dscp.DstIPPort.DstPortNum = pSrc[i].Dscp.DstIPPort.DstPortNum;
+                pClsfr->clsfrParameters.ClsfrTable[pClsfr->clsfrParameters.NumOfActiveEntries+i].DTag = pSrc[i].DTag;
+            }
+
+        break;
+
+        default:
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                               ("Classifier_InsertClsfrEntry(): Classifier type -- unknown - Aborting\n"));
+            
+    } 
+    
+    /* update the number of classifier active entries */
+    pClsfr->clsfrParameters.NumOfActiveEntries = pClsfr->clsfrParameters.NumOfActiveEntries + NumberOfEntries; 
+
+    return OK;
+}
+
+
+/************************************************************************
+ *                        classifier_RemoveClsfrEntry                   *
+ ************************************************************************
+ The following API is used to remove an entry from the classifier table
+
+Input:  
+
+*   pClsfr: pointer to the classifier 
+*   ConfigBufferPtr: pointer to the data to remove.
+
+Output:  
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+************************************************************************/
+TI_STATUS classifier_RemoveClsfrEntry(classifier_t* pClsfr, clsfr_tableEntry_t *ConfigBufferPtr)
+{
+    int i,j;
+
+    if(pClsfr == NULL)
+               return NOK;
+    
+       if(ConfigBufferPtr == NULL)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("classifier_RemoveClsfrEntry(): NULL ConfigBuffer pointer Error - Aborting\n"));
+               return PARAM_VALUE_NOT_VALID;
+    }
+    
+    if (pClsfr->clsfrParameters.NumOfActiveEntries == 0)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("classifier_RemoveClsfrEntry(): Classifier table is empty - Aborting\n"));
+               return PARAM_VALUE_NOT_VALID;
+    }
+   
+    if (pClsfr->clsfrParameters.clsfrType == D_TAG_CLSFR)
+    {
+        WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("classifier_RemoveClsfrEntry(): D-Tag classifier - Aborting\n"));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    /* Check conflicts with classifier table entries */
+    /* check all conflicts, if all entries are OK --> insert to classifier table*/
+    switch (pClsfr->clsfrParameters.clsfrType)
+    {
+        case DSCP_CLSFR:
+
+           /* Find the classifier entry */
+           i = 0;
+           while ((i < pClsfr->clsfrParameters.NumOfActiveEntries) &&
+                  ((pClsfr->clsfrParameters.ClsfrTable[i].Dscp.CodePoint != ConfigBufferPtr->Dscp.CodePoint) ||
+                  (pClsfr->clsfrParameters.ClsfrTable[i].DTag != ConfigBufferPtr->DTag)))
+            {   
+              i++;
+            }
+
+           /* If we have reached the number of active entries, it means we couldn't find the requested entry */
+           if (i == pClsfr->clsfrParameters.NumOfActiveEntries)
+           {
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                             ("classifier_RemoveClsfrEntry(): Entry not found - Aborting\n"));
+               return PARAM_VALUE_NOT_VALID;
+           }
+
+           /* If there is more than 1 entry, we need to shift all the entries in the table in order to delete the requested entry */
+           if (pClsfr->clsfrParameters.NumOfActiveEntries > 1)
+           {
+                       for (j = i; j < pClsfr->clsfrParameters.NumOfActiveEntries-1; j++)
+                {
+                   /* Move entries */
+                   pClsfr->clsfrParameters.ClsfrTable[j].Dscp.CodePoint = pClsfr->clsfrParameters.ClsfrTable[j+1].Dscp.CodePoint;
+                   pClsfr->clsfrParameters.ClsfrTable[j].DTag = pClsfr->clsfrParameters.ClsfrTable[j+1].DTag;
+                } 
+           }
+          
+        break;
+        
+        case PORT_CLSFR:
+
+           /* Find the classifier entry */
+           i = 0;
+           while ((i < pClsfr->clsfrParameters.NumOfActiveEntries) &&
+                  ((pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstPortNum != ConfigBufferPtr->Dscp.DstPortNum) ||
+                  (pClsfr->clsfrParameters.ClsfrTable[i].DTag != ConfigBufferPtr->DTag)))
+            {   
+              i++;
+            }
+
+           /* If we have reached the number of active entries, it means we couldn't find the requested entry */
+           if (i == pClsfr->clsfrParameters.NumOfActiveEntries)
+           {
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                             ("classifier_RemoveClsfrEntry(): Entry not found - Aborting\n"));
+               return PARAM_VALUE_NOT_VALID;
+           }
+
+           /* If there is more than 1 entry, we need to shift all the entries in the table in order to delete the requested entry */
+           if (pClsfr->clsfrParameters.NumOfActiveEntries > 1)
+           {
+                       for (j = i; j < pClsfr->clsfrParameters.NumOfActiveEntries-1; j++)
+                {
+                   pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstPortNum = pClsfr->clsfrParameters.ClsfrTable[j+1].Dscp.DstPortNum;
+                   pClsfr->clsfrParameters.ClsfrTable[j].DTag = pClsfr->clsfrParameters.ClsfrTable[j+1].DTag;
+                } 
+           }
+                                
+        break;
+        
+        case IPPORT_CLSFR:
+
+           /* Find the classifier entry */
+           i = 0;
+           while ((i < pClsfr->clsfrParameters.NumOfActiveEntries) &&
+                  ((pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstIPAddress != ConfigBufferPtr->Dscp.DstIPPort.DstIPAddress) ||
+                  (pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstPortNum != ConfigBufferPtr->Dscp.DstIPPort.DstPortNum) ||
+                  (pClsfr->clsfrParameters.ClsfrTable[i].DTag != ConfigBufferPtr->DTag)))
+            {   
+              i++;
+            }
+
+           /* If we have reached the number of active entries, it means we couldn't find the requested entry */
+           if (i == pClsfr->clsfrParameters.NumOfActiveEntries)
+           {
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                             ("classifier_RemoveClsfrEntry(): Entry not found - Aborting\n"));
+               return PARAM_VALUE_NOT_VALID;
+           }
+
+           /* If there is more than 1 entry, we need to shift all the entries in the table in order to delete the requested entry */
+           if (pClsfr->clsfrParameters.NumOfActiveEntries > 1)
+           {
+                       for (j = i; j < pClsfr->clsfrParameters.NumOfActiveEntries-1; j++)
+                {
+                   pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstIPPort.DstIPAddress = pClsfr->clsfrParameters.ClsfrTable[j+1].Dscp.DstIPPort.DstIPAddress;
+                   pClsfr->clsfrParameters.ClsfrTable[j].Dscp.DstIPPort.DstPortNum = pClsfr->clsfrParameters.ClsfrTable[j+1].Dscp.DstIPPort.DstPortNum;
+                   pClsfr->clsfrParameters.ClsfrTable[j].DTag = pClsfr->clsfrParameters.ClsfrTable[j+1].DTag;
+                } 
+           }
+
+        break;
+
+        default:
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                               ("classifier_RemoveClsfrEntry(): Classifier type -- unknown - Aborting\n"));
+            
+    } 
+    
+    /* update the number of classifier active entries */
+    pClsfr->clsfrParameters.NumOfActiveEntries--;
+
+    return OK;
+}
+
+
+/************************************************************************
+ *                        classifier_setClsfrType                 *
+ ************************************************************************
+ The following API is used to change the active classifier type. 
+ In addition it empties the classifier table.
+
+Input:  
+
+*  pClsfr: pointer to the classifier 
+*   newClsfrType: the new classifier type.
+
+Output:  
+
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+If the value PARAM_VALUE_NOT_VALID is returned, the classifier type and table are not updated.
+
+************************************************************************/
+
+TI_STATUS Classifier_setClsfrType(classifier_t* pClsfr, clsfr_type_e newClsfrType)
+{
+    if( pClsfr  == NULL )
+        return PARAM_VALUE_NOT_VALID;
+
+       if (newClsfrType > CLSFR_TYPE_MAX)
+       {
+               WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("Classifier_setClsfrType(): classifier type exceed its MAX \n"));
+               return PARAM_VALUE_NOT_VALID;
+    }
+       
+
+       if ( pClsfr->clsfrParameters.clsfrType == newClsfrType)
+       {
+               WLAN_REPORT_WARNING(pClsfr->hReport, CLSFR_MODULE_LOG,
+                       ("Classifier_setClsfrType(): equal classifier type --> will empty classifier table \n"));
+    }
+       
+       /* Update type */
+    pClsfr->clsfrParameters.clsfrType = newClsfrType;
+       /* Empty table */
+       pClsfr->clsfrParameters.NumOfActiveEntries = 0;
+
+    return OK;
+}
+
+TI_STATUS Classifier_getClsfrType (classifier_t* pClsfr, clsfrTypeAndSupport *newClsfrType)
+{
+       if (pClsfr == NULL)
+               return NOK;
+
+       newClsfrType->ClsfrType = (ULONG)pClsfr->clsfrParameters.clsfrType;
+       return OK;
+}
+
+
+/************************************************************************
+ *                        Classifier_deriveUserPriorityFromStream
+ ************************************************************************
+      
+Input:  
+
+* pClsfr: pointer to the classifier 
+* pStream: pointer to stream properties structure
+
+Output:  
+
+userPriority contains the appropriate qosTag that matches the stream properties.
+
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+If the value PARAM_VALUE_NOT_VALID is returned, the MSDU qosTag field is zero. 
+
+Description:  
+  
+************************************************************************/
+
+TI_STATUS Classifier_deriveUserPriorityFromStream (classifier_t* pClsfr, STREAM_TRAFFIC_PROPERTIES *pStream)
+{
+   
+    UINT8               i;
+
+       if (pClsfr == NULL)
+               return NOK; 
+
+    /* Initialization */
+    pStream->userPriority = 0;
+
+    switch(pClsfr->clsfrParameters.clsfrType)
+    {
+        case DSCP_CLSFR:
+            /* looking for the specific DSCP, if the DSCP is found, its corresponding D-tag is set to the qosTag */
+            for(i = 0; i<pClsfr->clsfrParameters.NumOfActiveEntries; i++ )
+            {
+                if (pClsfr->clsfrParameters.ClsfrTable[i].Dscp.CodePoint == pStream->PktTag)
+                               {
+                   pStream->userPriority = pClsfr->clsfrParameters.ClsfrTable[i].DTag;
+                                       return OK;
+                               }
+            }
+        break;
+        case PORT_CLSFR:
+            /* looking for the specific port number, if the port number is found, its corresponding D-tag is returned */
+            for(i = 0; i<pClsfr->clsfrParameters.NumOfActiveEntries; i++ )
+            {
+                if (pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstPortNum == pStream->dstPort)
+                               {
+                   pStream->userPriority = pClsfr->clsfrParameters.ClsfrTable[i].DTag;
+                                       return OK;
+                               }
+            }
+        break;
+        case IPPORT_CLSFR: 
+            /* looking for the specific pair of dst IP address and dst port number, if it is found, its corresponding 
+               D-tag is set to the qosTag                                                           */
+            for(i = 0; i<pClsfr->clsfrParameters.NumOfActiveEntries; i++ )
+            {
+                if ((pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstIPAddress == pStream->dstIpAddress)&&
+                    ( pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstPortNum == pStream->dstPort))
+                               {
+                    pStream->userPriority = pClsfr->clsfrParameters.ClsfrTable[i].DTag;
+                                       return OK;
+                               }
+            }
+        break;
+        default:
+            WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                                       (" Classifier_deriveUserPriorityFromStream(): clsfrType error\n"));
+    }
+
+#if 0
+      WLAN_OS_REPORT (("UserPriority is %d\n",pStream->userPriority));
+#endif
+
+    return OK;
+}
+
+
+#ifdef TI_DBG
+TI_STATUS Classifier_dbgPrintClsfrTable (classifier_t* pClsfr)
+{
+       int i;
+       UINT32 tmpIpAddr;
+
+    if(pClsfr == NULL)
+               return NOK;
+    
+       if (pClsfr->clsfrParameters.clsfrType == D_TAG_CLSFR)
+       {
+               WLAN_OS_REPORT (("D_TAG classifier type selected...Nothing to print...\n"));
+               return OK;
+       }
+
+       WLAN_OS_REPORT (("Number of active entries in classifier table : %d\n",pClsfr->clsfrParameters.NumOfActiveEntries));
+
+       switch (pClsfr->clsfrParameters.clsfrType)
+       {
+               case DSCP_CLSFR:
+                       WLAN_OS_REPORT (("+------+-------+\n"));
+                       WLAN_OS_REPORT (("| Code | D-Tag |\n"));
+                       WLAN_OS_REPORT (("+------+-------+\n"));
+
+                       for  (i=0; i< pClsfr->clsfrParameters.NumOfActiveEntries ; i++)  
+            {
+                               WLAN_OS_REPORT (("| %5d | %5d |\n",pClsfr->clsfrParameters.ClsfrTable[i].Dscp.CodePoint,pClsfr->clsfrParameters.ClsfrTable[i].DTag));
+                       }
+
+                       WLAN_OS_REPORT (("+-------+-------+\n"));
+                       break;
+               case PORT_CLSFR:
+                       WLAN_OS_REPORT (("+-------+-------+\n"));
+                       WLAN_OS_REPORT (("| Port  | D-Tag |\n"));
+                       WLAN_OS_REPORT (("+-------+-------+\n"));
+
+                       for  (i=0; i< pClsfr->clsfrParameters.NumOfActiveEntries ; i++)  
+            {
+                               WLAN_OS_REPORT (("| %5d | %5d |\n",pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstPortNum,pClsfr->clsfrParameters.ClsfrTable[i].DTag));
+                       }
+
+                       WLAN_OS_REPORT (("+-------+-------+\n"));
+                       break;
+               case IPPORT_CLSFR:
+
+                       WLAN_OS_REPORT (("+-------------+-------+-------+\n"));
+                       WLAN_OS_REPORT (("| IP Address  | Port  | D-Tag |\n"));
+                       WLAN_OS_REPORT (("+-------------+-------+-------+\n"));
+
+                       for  (i=0; i< pClsfr->clsfrParameters.NumOfActiveEntries ; i++)  
+            {
+                               tmpIpAddr = pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstIPAddress;
+                               WLAN_OS_REPORT (("| %02x.%02x.%02x.%02x | %5d | %5d |\n",(tmpIpAddr & 0xFF),((tmpIpAddr >> 8) & (0xFF)),((tmpIpAddr >> 16) & (0xFF)),((tmpIpAddr >> 24) & (0xFF)),pClsfr->clsfrParameters.ClsfrTable[i].Dscp.DstIPPort.DstPortNum,pClsfr->clsfrParameters.ClsfrTable[i].DTag));
+                       }
+
+                       WLAN_OS_REPORT (("+-------------+-------+-------+\n"));
+                       break;
+               default:
+                       WLAN_REPORT_ERROR(pClsfr->hReport, CLSFR_MODULE_LOG,
+                               ("Classifier_InsertClsfrEntry(): Classifier type -- unknown - Aborting\n"));
+                       break;
+       }
+
+       return OK;
+    
+
+}
+#endif
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/Ctrl.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/Ctrl.c
new file mode 100644 (file)
index 0000000..ac72e51
--- /dev/null
@@ -0,0 +1,2218 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE:     Ctrl.c                                                 */
+/*      PURPOSE:    Control module functions                               */
+/*                                                                         */
+/***************************************************************************/
+#include "Ctrl.h"
+#include "802_11Defs.h"
+#include "DataCtrl_Api.h"
+#include "osApi.h"
+#include "report.h" 
+#include "utils.h"
+#include "smeApi.h"
+#include "siteMgrApi.h"
+#include "Ethernet.h"
+#include "tx.h"
+#include "TrafficMonitorAPI.h"
+#include "TI_IPC_Api.h"
+#include "EvHandler.h"
+#include "apConn.h"
+#include "TNETW_Driver_api.h"
+#include "Core_AdaptTx.h"
+#include "whalCtrl_api.h"
+
+static void selectRateTable(TI_HANDLE hCtrlData, UINT32 rateMask);
+static void ctrlData_setTxRatePolicies(ctrlData_t *pCtrlData);
+static void ctrlData_resetCounters(TI_HANDLE hCtrlData);
+
+static void ctrlData_resetCounters(TI_HANDLE hCtrlData);
+
+static void ctrlData_UnregisterTrafficIntensityEvents (TI_HANDLE hCtrlData);
+static void ctrlData_RegisterTrafficIntensityEvents (TI_HANDLE hCtrlData);
+
+static UINT32 ctrlData_buildHwBitMapFromArray(policyClassRatesArray_t *pArray);
+static void ctrlData_storeTSRateSet(ctrlData_t *pCtrlData, txDataQosParams_t *tsrsParams);
+static rate_e ctrlData_getClosestTSRate(ctrlData_t *pCtrlData, UINT32 ac, rate_e givenRate);
+
+void ctrlData_TrafficThresholdCrossed(TI_HANDLE Context,UINT32 Cookie);
+
+
+/* definitions for medium usage calculations - in uSec units*/
+#define AVERAGE_ACK_TIME   10
+#define AVERAGE_CTS_TIME   20
+#define B_SIFS             10
+
+#define SHORT_PREAMBLE_TIME   96
+#define LONG_PREAMBLE_TIME    192
+
+#define OFDM_PREAMBLE      12
+#define OFDM_SIGNAL_EXT    6
+#define OFDM_PLCP_HDR      24
+
+#define OFDM_DURATION           (B_SIFS + OFDM_PLCP_HDR + OFDM_SIGNAL_EXT)
+#define NONOFDM_SHORT_DURATION  (B_SIFS + SHORT_PREAMBLE_TIME)
+#define NONOFDM_LONG_DURATION   (B_SIFS + LONG_PREAMBLE_TIME)
+
+/*************************************************************************
+*                        ctrlData_create                                 *
+**************************************************************************
+* DESCRIPTION:  This function initializes the Ctrl data module.                 
+*                                                      
+* INPUT:        hOs - handle to Os Abstraction Layer
+*               
+* OUTPUT:       TxCmplt_CB - call back function that return to configMngr
+*               in order to register in the Hal
+*
+* RETURN:       Handle to the allocated Ctrl data control block
+************************************************************************/
+TI_HANDLE ctrlData_create(TI_HANDLE hOs)
+{
+    ctrlData_t*         hCtrlData;
+    rateAdaptation_t*   pRateAdaptation;
+#ifdef SUPPORT_4X
+    fourX_t*            pFourX;
+#endif
+    classifier_t*       pClsfr;
+
+    if( hOs  == NULL )
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: ctrlData_create(): OS handle Error - Aborting\n"));
+        return NULL;
+    }
+
+    /* alocate Control module control block */
+    hCtrlData = os_memoryAlloc(hOs, (sizeof(ctrlData_t)));
+    if(!hCtrlData)
+        return NULL;
+
+    /* create rate adaptation module */
+    pRateAdaptation = rateAdaptation_create(hOs);
+#ifdef SUPPORT_4X
+    /* create 4X module */
+    pFourX = fourX_create(hOs);
+#endif
+    /* create the classifier module */
+    pClsfr = Classifier_create(hOs);
+    
+    if ( (!pRateAdaptation) 
+#ifdef SUPPORT_4X
+         || (!pFourX)
+#endif
+       )
+    {
+        utils_nullMemoryFree(hOs, pRateAdaptation, sizeof(rateAdaptation_t));
+#ifdef SUPPORT_4X
+        utils_nullMemoryFree(hOs, pFourX, sizeof(fourX_t));
+#endif
+        utils_nullMemoryFree(hOs, hCtrlData, sizeof(ctrlData_t));
+
+        WLAN_OS_REPORT(("FATAL ERROR: ctrlData_create(): Error Creating Ctrl Module - Aborting\n"));
+        return(NULL);
+    }
+
+    /* reset control module control block */
+    os_memoryZero(hOs, hCtrlData, (sizeof(ctrlData_t)));
+
+    hCtrlData->pRateAdaptation = pRateAdaptation;
+#ifdef SUPPORT_4X
+    hCtrlData->pFourX = pFourX;
+#endif
+    hCtrlData->pClsfr = pClsfr;
+
+    hCtrlData->hOs = hOs;
+
+    return(hCtrlData);
+}
+
+/***************************************************************************
+*                           ctrlData_config                                *
+****************************************************************************
+* DESCRIPTION:  This function configures the Ctrl Data module       
+* 
+* INPUTS:       hCtrlData - The object
+*               hWhalCtrl - Handle to the Whal Ctrl object
+*               hSiteMgrHandle - Handle to the Site Mngr object
+*               hTxData - Handle to the Tx Data object
+*               hRxData - Handle to the Rx Data object
+*               hOs - Handle to the Os Abstraction Layer
+*               hReport - Handle to the Report object
+*               ctrlDataInitParams - pointer to Ctrl module init parameters
+* OUTPUT:       
+* 
+* RETURNS:      OK - Configuration succesfull
+*               NOK - Configuration unsuccesfull
+***************************************************************************/
+TI_STATUS ctrlData_config(TI_HANDLE         hCtrlData,
+                       TI_HANDLE            hWhalCtrl, 
+                       TI_HANDLE            hSiteMgrHandle, 
+                       TI_HANDLE            hTxData, 
+                       TI_HANDLE            hRxData, 
+                       TI_HANDLE            hOs, 
+                       TI_HANDLE            hReport, 
+                       TI_HANDLE            hMemMngr, 
+                       TI_HANDLE            hEvHandler,
+                       TI_HANDLE            hAPConnection,
+                       TI_HANDLE            hTrafficMonitor,                       
+                       disassocSentCB_t     disassocSentCBFunc,
+                       TI_HANDLE            disassocSentCBObj,  
+                       ctrlDataInitParams_t *ctrlDataInitParams)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    TI_STATUS Status = OK;
+    rateClassClients_e clientIDindex;
+    txRateClassId_e  TxRateIndex;
+    UINT32 ac;
+
+    /* check parameters validity */
+    if( hCtrlData == NULL || hWhalCtrl == NULL || hSiteMgrHandle == NULL || hRxData == NULL ||
+        hTxData == NULL || hOs == NULL || hReport == NULL || hMemMngr == NULL || ctrlDataInitParams == NULL)
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: ctrlData_config(): Parameters Error - Aborting\n"));
+        return NOK;
+    }
+
+    /* set objects handles */
+    pCtrlData->hWhalCtrl =  hWhalCtrl;  
+    pCtrlData->hSiteMgr =   hSiteMgrHandle;
+    pCtrlData->hTxData =    hTxData;
+    pCtrlData->hRxData =    hRxData;
+    pCtrlData->hOs =        hOs;
+    pCtrlData->hReport =    hReport;
+    pCtrlData->hAPConn = hAPConnection;
+    pCtrlData->hEvHandler = hEvHandler;
+    pCtrlData->hTrafficMonitor  = hTrafficMonitor;
+
+    pCtrlData->disassocSentCBObj = disassocSentCBObj;
+    pCtrlData->disassocSentCBFunc = disassocSentCBFunc;
+
+
+    /*  set Control module parameters */
+    pCtrlData->ctrlDataRateControlEnable = ctrlDataInitParams->ctrlDataRateControlEnable;
+    pCtrlData->ctrlDataIbssProtectionType = ctrlDataInitParams->ctrlDataDesiredIbssProtection;
+    pCtrlData->ctrlDataRtsCtsStatus = ctrlDataInitParams->ctrlDataDesiredCtsRtsStatus;
+
+#ifdef SUPPORT_4X
+    pCtrlData->ctrlDataFourXEnable = ctrlDataInitParams->ctrlDataFourXEnable;
+    pCtrlData->ctrlDataCerruentFourXstate = ctrlDataInitParams->ctrlDataFourXEnable;
+#else
+    pCtrlData->ctrlDataFourXEnable = FALSE;
+    pCtrlData->ctrlDataCerruentFourXstate = FALSE;
+#endif
+    
+    MAC_COPY(pCtrlData->hOs, (&pCtrlData->ctrlDataDeviceMacAddress), 
+            (&ctrlDataInitParams->ctrlDataDeviceMacAddress));
+
+    pCtrlData->ctrlDataStartStoplinkControlAlg = DEF_START_STOP_LINK_CTRL_ALG;
+    pCtrlData->ctrlDataCurrentBasicRate = DEF_BASIC_RATE;
+    pCtrlData->ctrlDataBasicRateBitMask = DEF_BASIC_RATE_MASK;
+    pCtrlData->ctrlDataCurrentBasicModulationType = DRV_MODULATION_QPSK;
+    pCtrlData->ctrlDataCurrentModulationType = DEF_CURRENT_MUDULATION_TYPE;
+    pCtrlData->ctrlDataCurrentBssType = BSS_INFRASTRUCTURE;
+    os_memoryCopy(pCtrlData->hOs, &pCtrlData->ctrlDataRateTables,
+                                  &ctrlDataInitParams->rateTable,
+                                  sizeof(rateTables_t) );
+
+    for (clientIDindex = (rateClassClients_e)0 ; clientIDindex < NUM_OF_RATE_CLASS_CLIENTS ; clientIDindex++) 
+    {
+        pCtrlData->bIsClassAvailable[clientIDindex] = TRUE;
+        /* by default all clients use all available rates */ 
+        pCtrlData->currClientRateMask[clientIDindex] = ALL_RATES_AVAILABLE;
+        pCtrlData->nextClientRateMask[clientIDindex] = ALL_RATES_AVAILABLE;
+
+        /* Init Params are initialized for USER & SG policies only */
+        /* Set short/long retry for all ACs */
+        for (ac=0; ac < MAX_NUM_OF_AC; ac++) 
+        {
+            pCtrlData->ctrlDataTxRatePolicy.rateClass[clientIDindex*MAX_NUM_OF_AC+ac].longRetryLimit  = ctrlDataInitParams->ctrlDataTxRatePolicy[clientIDindex].longRetryLimit;
+            pCtrlData->ctrlDataTxRatePolicy.rateClass[clientIDindex*MAX_NUM_OF_AC+ac].shortRetryLimit = ctrlDataInitParams->ctrlDataTxRatePolicy[clientIDindex].shortRetryLimit;
+        }
+
+        for (TxRateIndex = txPolicy54; TxRateIndex < MAX_NUM_OF_TX_RATES_IN_CLASS; TxRateIndex++)
+        {
+            pCtrlData->policyClassRatesArrayCck[clientIDindex].txRate[TxRateIndex] = ctrlDataInitParams->policyClassRatesArrayCck[clientIDindex].txRate[TxRateIndex];
+            pCtrlData->policyClassRatesArrayPbcc[clientIDindex].txRate[TxRateIndex] = ctrlDataInitParams->policyClassRatesArrayPbcc[clientIDindex].txRate[TxRateIndex]; 
+            pCtrlData->policyClassRatesArrayOfdm[clientIDindex].txRate[TxRateIndex] = ctrlDataInitParams->policyClassRatesArrayOfdm[clientIDindex].txRate[TxRateIndex]; 
+            pCtrlData->policyClassRatesArrayOfdmA[clientIDindex].txRate[TxRateIndex] = ctrlDataInitParams->policyClassRatesArrayOfdmA[clientIDindex].txRate[TxRateIndex]; 
+        }
+    }
+    /* By default use USER_RATE_CLASS */
+    pCtrlData->currClientRateID = USER_RATE_CLASS;
+    pCtrlData->configuredClientRateID = USER_RATE_CLASS;
+
+    pCtrlData->ctrlDataCurrentRateTable = &pCtrlData->ctrlDataRateTables.ctrlDataCckRateTable;
+
+    /* reset Counters */
+    ctrlData_resetCounters(pCtrlData);
+    
+    /* Configure Rate Adaptation Module */
+    rateAdaptation_config(pCtrlData->pRateAdaptation, hOs, hReport, pCtrlData, hEvHandler,
+                          hAPConnection, &ctrlDataInitParams->rateAdaptationInitParam); 
+
+#ifdef SUPPORT_4X
+    /* configure fourX Module */
+    fourX_config(pCtrlData->pFourX, hOs, hReport, hMemMngr, hWhalCtrl, hTxData,
+                            &ctrlDataInitParams->fourXInitParams);
+#endif
+
+    /* configure the classifier Module */
+    Status = Classifier_config(pCtrlData->pClsfr, hOs, hReport, &ctrlDataInitParams->ClsfrInitParam);
+    if (Status != OK)
+    {
+        WLAN_OS_REPORT(("FATAL ERROR: ctrlData_config(): Classifier_config() failed - Aborting\n"));
+        return Status;
+    }
+
+    /* Initialize traffic intensity threshold parameters */
+    pCtrlData->ctrlDataTrafficIntensityEventsEnabled = ctrlDataInitParams->ctrlDataTrafficThresholdEnabled;
+    pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold = ctrlDataInitParams->ctrlDataTrafficThreshold.uHighThreshold;
+    pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold = ctrlDataInitParams->ctrlDataTrafficThreshold.uLowThreshold;
+    pCtrlData->ctrlDataTrafficIntensityThresholds.TestInterval = ctrlDataInitParams->ctrlDataTrafficThreshold.TestInterval;
+
+    WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+       ("\nTraffic Intensity parameters:\nEvents enabled = %d\nuHighThreshold = %d\nuLowThreshold = %d\nTestInterval = %d\n\n",
+       pCtrlData->ctrlDataTrafficIntensityEventsEnabled,
+       pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold,
+       pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold,
+       pCtrlData->ctrlDataTrafficIntensityThresholds.TestInterval));
+
+    /* Register the traffic intensity events with the traffic monitor */
+    ctrlData_RegisterTrafficIntensityEvents (pCtrlData);
+
+    /* If the events are enabled, start notification, if disabled - then do nothing */
+    ctrlData_ToggleTrafficIntensityNotification (pCtrlData, pCtrlData->ctrlDataTrafficIntensityEventsEnabled);
+
+    WLAN_REPORT_INIT(pCtrlData->hReport, CTRL_DATA_MODULE_LOG, 
+        (".....Ctrl Data configured successfully ...\n"));
+
+    return OK;
+}
+
+/***************************************************************************
+*                           ctrlData_unLoad                                *
+****************************************************************************
+* DESCRIPTION:  This function unload the Ctrl data module. 
+* 
+* INPUTS:       hCtrlData - the object
+*       
+* OUTPUT:       
+* 
+* RETURNS:      OK - Unload succesfull
+*               NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS ctrlData_unLoad(TI_HANDLE hCtrlData)  
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    /* check parameters validity */
+    if( pCtrlData == NULL )
+    {
+        WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            (" ctrlData_unLoad() : parametrs value error \n"));
+        return NOK;
+    }
+
+
+    rateAdaptation_destroy(pCtrlData->pRateAdaptation);
+#ifdef SUPPORT_4X
+    fourX_destroy(pCtrlData->pFourX);
+#endif
+    Classifier_destroy(pCtrlData->pClsfr);
+
+    /* free timer */
+    /* free control module controll block */
+    os_memoryFree(pCtrlData->hOs, hCtrlData, sizeof(ctrlData_t));
+
+    return OK;
+}
+/***************************************************************************
+*                           ctrlData_getParam                              *
+****************************************************************************
+* DESCRIPTION:  get a specific parameter
+* 
+* INPUTS:       hCtrlData - the object
+*               
+*       
+* OUTPUT:       pParamInfo - structure which include the value of 
+*               the requested parameter
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+
+TI_STATUS ctrlData_getParam(TI_HANDLE hCtrlData, paramInfo_t *pParamInfo)   
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    
+    /* WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG, 
+        ("ctrlData_getParam() : param=0x%x \n", pParamInfo->paramType)); */
+
+    switch (pParamInfo->paramType)
+    {
+    case CTRL_DATA_RATE_CONTROL_ENABLE_PARAM: 
+        pParamInfo->content.ctrlDataRateControlEnable = pCtrlData->ctrlDataRateControlEnable;
+        break; 
+        
+    case CTRL_DATA_FOUR_X_ENABLE_PARAM: 
+        pParamInfo->content.ctrlDataFourXEnable = pCtrlData->ctrlDataFourXEnable;
+        break; 
+
+    case CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM:
+        if (pCtrlData->ctrlDataCurrentBssType == BSS_INFRASTRUCTURE)
+        {
+            pParamInfo->content.ctrlDataCerruentFourXstate = pCtrlData->ctrlDataCerruentFourXstate;
+        } else {
+            pParamInfo->content.ctrlDataCerruentFourXstate = pCtrlData->ctrlDataFourXEnable;
+        }
+
+        break; 
+
+    case CTRL_DATA_CURRENT_BSSID_PARAM:          
+        MAC_COPY(pCtrlData->hOs, (&pParamInfo->content.ctrlDataCurrentBSSID), 
+                (&pCtrlData->ctrlDataCurrentBSSID));
+        break; 
+
+    case CTRL_DATA_CURRENT_BSS_TYPE_PARAM:  
+        pParamInfo->content.ctrlDataCurrentBssType = pCtrlData->ctrlDataCurrentBssType;        
+        break; 
+
+    case CTRL_DATA_CURRENT_MODULATION_TYPE_PARAM: 
+        pParamInfo->content.ctrlDataCurrentModulationType = pCtrlData->ctrlDataCurrentModulationType;      
+        break; 
+
+    case CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM: 
+        pParamInfo->content.ctrlDataCurrentPreambleType = pCtrlData->ctrlDataCurrentPreambleType;        
+        break; 
+
+    case CTRL_DATA_MAC_ADDRESS:    
+        MAC_COPY(pCtrlData->hOs, (&pParamInfo->content.ctrlDataDeviceMacAddress), (&pCtrlData->ctrlDataDeviceMacAddress)); 
+        break;
+
+    case CTRL_DATA_CURRENT_BASIC_RATE_PARAM:             
+        pParamInfo->content.ctrlDataCurrentBasicRate = pCtrlData->ctrlDataCurrentBasicRate;               
+        break;
+
+    case CTRL_DATA_CURRENT_BASIC_RATE_MASK_PARAM: 
+        pParamInfo->content.ctrlDataBasicRateBitMask = pCtrlData->ctrlDataBasicRateBitMask;      
+        break; 
+
+    case CTRL_DATA_CURRENT_BASIC_MODULATION_PARAM: 
+        pParamInfo->content.ctrlDataCurrentBasicModulationType = pCtrlData->ctrlDataCurrentBasicModulationType;      
+        break; 
+
+    case CTRL_DATA_COUNTERS_PARAM:
+        os_memoryCopy(pCtrlData->hOs,&pParamInfo->content.ctrlDataCounters,
+            &pCtrlData->ctrlDataCounters, sizeof(ctrlDataCounters_t));
+        break; 
+
+    case CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM: 
+        pParamInfo->content.ctrlDataCurrentRateMask = pCtrlData->ctrlDataCurrentRateMask;
+        break; 
+
+    case CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM:
+        pParamInfo->content.ctrlDataProtectionEnabled = pCtrlData->ctrlDataProtectionEnabled;
+        break;
+
+    case CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM:
+        pParamInfo->content.ctrlDataIbssProtecionType = pCtrlData->ctrlDataIbssProtectionType;
+        break;
+
+    case CTRL_DATA_CURRENT_RTS_CTS_STATUS_PARAM:
+        pParamInfo->content.ctrlDataRtsCtsStatus = pCtrlData->ctrlDataRtsCtsStatus;
+        break;
+
+    case CTRL_DATA_CLSFR_TYPE:
+        Classifier_getClsfrType (pCtrlData->pClsfr,&pParamInfo->content.ctrlDataClsfrType);
+        break;
+        /*
+         * NOTE: currently supporting only USER_RATE_CLASS!!!!!!!!!
+         */
+    case CTRL_DATA_SHORT_RETRY_LIMIT_PARAM:
+        pParamInfo->content.TxRatePolicy.rateClass[USER_RATE_CLASS].shortRetryLimit = pCtrlData->ctrlDataTxRatePolicy.rateClass[USER_RATE_CLASS].shortRetryLimit;
+        break;
+
+        /*
+         * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+         */
+    case CTRL_DATA_LONG_RETRY_LIMIT_PARAM:
+        pParamInfo->content.TxRatePolicy.rateClass[USER_RATE_CLASS].longRetryLimit = pCtrlData->ctrlDataTxRatePolicy.rateClass[USER_RATE_CLASS].longRetryLimit;
+        break;
+
+
+    case CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD:
+        pParamInfo->content.ctrlDataTrafficIntensityThresholds.uHighThreshold = pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold;
+        pParamInfo->content.ctrlDataTrafficIntensityThresholds.uLowThreshold = pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold;
+        pParamInfo->content.ctrlDataTrafficIntensityThresholds.TestInterval = pCtrlData->ctrlDataTrafficIntensityThresholds.TestInterval;
+        break;
+
+    default:
+        return (PARAM_NOT_SUPPORTED);
+/*        WLAN_REPORT_ERROR(pCtrlData->hReport, TX_DATA_MODULE_LOG, 
+            (" ctrlData_getParam() : PARAMETER NOT SUPPORTED \n"));
+        return NOK;
+        break; - unreachable */
+    }
+
+    return (OK);
+}
+
+/***************************************************************************
+*                           ctrlData_buildSupportedHwRates                 *
+****************************************************************************
+* DESCRIPTION:  builds HwRatesBitMap (supported rates) for txRatePolicy using 4 elements :
+*               1) AP support
+*               2) Driver support
+*               3) Client support (using currClientRateMask[clientIDindex] )
+*               4) Policy rates   (retries per client)
+* 
+* OUTPUT:       
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+static UINT32 ctrlData_buildSupportedHwRates(ctrlData_rateAdapt_t *pDriverTable,
+                                             UINT32             APsupport,
+                                             UINT32             clientSupport,
+                                             UINT32             policySupport)
+{
+    UINT16  AppRateBitMap = 0;
+    UINT32  HwRatesBitMap, DriverTableBitMap = 0;
+    UINT32 i = 0;
+
+    /* 1. Convert Rates table into bit mask */
+    while (i <= pDriverTable->len)
+    {
+        DriverTableBitMap |= (1 << (pDriverTable->rateAdaptRatesTable[i++] - 1));
+    }
+
+    /* 2. AND with other masks */
+    AppRateBitMap = (UINT16)(DriverTableBitMap & APsupport & clientSupport & policySupport);
+
+    /* In case there are no mutual rates, try to ignore policy settings */
+    if (AppRateBitMap == 0)
+    {
+        AppRateBitMap = (UINT16)(DriverTableBitMap & APsupport);
+    }
+
+    /* 3. Set total supported rates bit map for txRatePolicy */
+    ConvertAppRatesToBitmap(AppRateBitMap, &HwRatesBitMap);
+
+    return HwRatesBitMap;
+}
+
+
+/***************************************************************************
+*                           ctrlData_setTxRatePolicies                     *
+****************************************************************************
+* DESCRIPTION:  This function sets rate fallback policies to be configured to FW
+*               If TSRS is defined to specific AC, the policy is derived from it,
+*               otherwise it is derived from pre-defined map
+* 
+* INPUTS:       pCtrlData - the object
+*       
+* RETURNS:      -
+*               
+***************************************************************************/
+static void ctrlData_setTxRatePolicies(ctrlData_t *pCtrlData)
+{
+    UINT32 ac, policyClassRateMask, supportedHwRatesBitMap, clientIDindex, hwRateIndex;
+    UINT32 fwPolicyID;
+    UINT8 shortRetryLimit, longRetryLimit;
+    txRateClassId_e  txRateIndex;
+    whalParamInfo_t param;
+
+    pCtrlData->currClientRateID = pCtrlData->configuredClientRateID;
+
+    for (clientIDindex = 0, fwPolicyID = 0; clientIDindex < NUM_OF_RATE_CLASS_CLIENTS; clientIDindex++) 
+    {
+        /* Retrieve retry limits stored in first AC of current class */ 
+        shortRetryLimit = pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].shortRetryLimit;
+        longRetryLimit = pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].longRetryLimit;
+
+        /* By default assume that this class can be enabled */
+        pCtrlData->bIsClassAvailable[clientIDindex] = TRUE;
+
+        /* Update the rate mask from nextClientRateMask, where it was stored untill now */
+        pCtrlData->currClientRateMask[clientIDindex] = pCtrlData->nextClientRateMask[clientIDindex];
+
+        for (ac = 0; ac < MAX_NUM_OF_AC; ac++)
+        {
+            /* 1. Check if there is special rate set defined for this access category, */
+            /*    then verify that at least one rate is mutual between TSRS and class policy, */
+            /*    otherwise use default settings for this class */
+            if (pCtrlData->tsrsParameters[ac].supportedRatesMask[clientIDindex] != 0)
+            {
+                /* Check if at least one rate is mutual between TSRS and current class policy, */
+                /* otherwise use default for this class */
+                policyClassRateMask = pCtrlData->tsrsParameters[ac].policyClassRateMask[clientIDindex];
+            }
+            else
+            {
+                policyClassRateMask = ctrlData_buildHwBitMapFromArray(&(pCtrlData->pCurrPolicyClassRatesArray[clientIDindex]));
+            }
+
+            /* 2. Build a bitMap for the supported rates */
+            supportedHwRatesBitMap = ctrlData_buildSupportedHwRates(
+                                pCtrlData->ctrlDataCurrentRateTable,            /* according to radio mode */
+                                pCtrlData->ctrlDataCurrentRateMask,             /* AP supported rates */
+                                pCtrlData->currClientRateMask[clientIDindex],   /* STA supported rates */
+                                policyClassRateMask);                           /* requested by class policy rates */
+
+            if (supportedHwRatesBitMap == 0)
+            {
+                WLAN_REPORT_ERROR(pCtrlData->hReport,CTRL_DATA_MODULE_LOG,
+                                  ("%s No supported rates for client %d, ac %d \n", __FUNCTION__, clientIDindex, ac));
+                pCtrlData->bIsClassAvailable[clientIDindex] = FALSE;
+                pCtrlData->currClientRateID = USER_RATE_CLASS;
+            }
+
+            /* 3. Configure retransmission for the rates */
+            for (hwRateIndex = HW_BIT_RATE_54MBPS, txRateIndex = txPolicy54; 
+                 txRateIndex < MAX_NUM_OF_TX_RATES_IN_CLASS; 
+                 hwRateIndex >>= 1, txRateIndex++)
+            {
+                /* if supported rate */
+                if (supportedHwRatesBitMap & hwRateIndex)
+                {
+                    /* if rate fall back is enabled */
+                    if (pCtrlData->ctrlDataRateControlEnable)
+                    {
+                        /* Set retries as they were configured in ini file for this class; */
+                        /* make sure at least one retransmission is defined, */
+                        /* to take care of cases in which we ignored pre-defined policy */ 
+                        pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].txRate[txRateIndex] = 
+                            (pCtrlData->pCurrPolicyClassRatesArray[clientIDindex].txRate[txRateIndex] > 1) ? 
+                            pCtrlData->pCurrPolicyClassRatesArray[clientIDindex].txRate[txRateIndex] : 1;
+                    }
+                    else /* no rate fallback */
+                    {
+                        /* set max reties because no fall back is implemented */
+                        pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].txRate[txRateIndex] = 
+                            (shortRetryLimit > longRetryLimit) ? shortRetryLimit : longRetryLimit;
+                        pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].flags |= TX_POLICY_FLAGS_TRUNCATE;
+                    }
+                }
+                else
+                {
+                    pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].txRate[txRateIndex] = 0;
+                }
+
+                WLAN_REPORT_INFORMATION(pCtrlData->hReport,CTRL_DATA_MODULE_LOG,
+                    ("%s: AC %d, class %d, rate 0x%x[%d]\n", __FUNCTION__, ac, clientIDindex, hwRateIndex, pCtrlData->ctrlDataTxRatePolicy.rateClass[fwPolicyID].txRate[txRateIndex]));
+            }
+
+            /* Note that Long/Short retries are pre-set during configuration stage */
+
+            /* 4. Finally, increase total number of policies */
+            pCtrlData->tsrsParameters[ac].fwPolicyID[clientIDindex] = fwPolicyID++;
+        }
+    }
+
+    /* Download policies to the FW. Num of policies is 8 - one for each AC for every class */
+    WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+        ("%s: num of Rate policies: %d\n", __FUNCTION__, fwPolicyID));
+
+    pCtrlData->ctrlDataTxRatePolicy.numOfRateClasses = fwPolicyID;
+    param.paramType = HAL_CTRL_TX_RATE_CLASS_PARAMS;
+    param.content.pTxRatePlicy = &pCtrlData->ctrlDataTxRatePolicy;
+
+    whalCtrl_SetParam(pCtrlData->hWhalCtrl, &param);
+}
+
+
+/***************************************************************************
+*                           ctrlData_setParam                              *
+****************************************************************************
+* DESCRIPTION:  set a specific parameter
+* 
+* INPUTS:       hCtrlData - the object
+*               pParamInfo - structure which include the value to set for 
+*               the requested parameter
+*       
+* OUTPUT:       
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+
+TI_STATUS ctrlData_setParam(TI_HANDLE hCtrlData, paramInfo_t *pParamInfo)   
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    whalParamInfo_t param;
+    rateClassClients_e clientID;
+
+    /* WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG, 
+        ("ctrlData_setParam() : param=0x%x \n", pParamInfo->paramType)); */
+
+    switch (pParamInfo->paramType)
+    {
+    case CTRL_DATA_RATE_CONTROL_ENABLE_PARAM:
+        pCtrlData->ctrlDataRateControlEnable = pParamInfo->content.ctrlDataRateControlEnable;
+        selectRateTable(pCtrlData, pCtrlData->ctrlDataCurrentRateMask);
+
+        ctrlData_setTxRatePolicies(pCtrlData);
+
+        rateAdaptation_buildRateMapTable(pCtrlData->pRateAdaptation,
+                                                 pCtrlData->ctrlDataCurrentRateTable,
+                                                 pCtrlData->ctrlDataCurrentRateMask,
+                                                 pCtrlData->currClientRateMask[pCtrlData->currClientRateID],
+                                                 pCtrlData->ctrlDataCurrentModulationType,
+                                                 pCtrlData->ctrlDataCerruentFourXstate,
+                                          pCtrlData->ctrlDataCurrentBssType);
+    
+
+
+    
+
+             if(pCtrlData->ctrlDataRateControlEnable == TRUE )
+             {
+                 /* start rate adaptation algorithm */
+
+                if( pCtrlData->ctrlDataStartStoplinkControlAlg == TRUE)
+                {   
+
+                rateAdaptation_start(pCtrlData->pRateAdaptation);
+            }
+            else 
+            {    
+                /* stop rate adaptation algorithm */
+                rateAdaptation_stop(pCtrlData->pRateAdaptation);
+            }
+        }
+        else 
+        {
+            rateAdaptation_stopTimer(pCtrlData->pRateAdaptation);
+        }
+        break; 
+        
+    case CTRL_DATA_FOUR_X_ENABLE_PARAM: 
+#ifdef SUPPORT_4X
+        pCtrlData->ctrlDataFourXEnable = pParamInfo->content.ctrlDataFourXEnable;
+        if(pCtrlData->ctrlDataStartStoplinkControlAlg == TRUE)
+        {
+            if(pCtrlData->ctrlDataFourXEnable == TRUE)
+            {   
+                pCtrlData->ctrlDataCerruentFourXstate = TRUE;
+            }
+            else 
+            {   
+                pCtrlData->ctrlDataCerruentFourXstate = FALSE;
+            }
+        }
+        rateAdaptation_update4xEnable(pCtrlData->pRateAdaptation,
+                                      pCtrlData->ctrlDataCerruentFourXstate,
+                                      pCtrlData->ctrlDataCurrentBssType );
+
+#else 
+        pCtrlData->ctrlDataFourXEnable = FALSE;
+        pCtrlData->ctrlDataCerruentFourXstate = FALSE;
+#endif
+        break; 
+
+    case CTRL_DATA_CURRENT_RATE_CLASS_CLIENT:
+        /* set a new rate class client to be used on data packets */
+        clientID = pParamInfo->content.ctrlDataRateClassID;
+        /* always save the wanted configuration , even when not enabled */
+        pCtrlData->configuredClientRateID = clientID;
+        
+        if (clientID == pCtrlData->currClientRateID)
+        {       
+            /* Do nothing - already configured */
+            break;
+        }
+        else 
+        {
+            if (TRUE == pCtrlData->bIsClassAvailable[clientID])
+            {       
+                /* use the new clientID + reset rateAdaptation tables */
+                pCtrlData->currClientRateID = clientID;
+                selectRateTable(pCtrlData, pCtrlData->ctrlDataCurrentRateMask);
+                rateAdaptation_buildRateMapTable(pCtrlData->pRateAdaptation,
+                                                     pCtrlData->ctrlDataCurrentRateTable,
+                                                     pCtrlData->ctrlDataCurrentRateMask,
+                                                     pCtrlData->currClientRateMask[pCtrlData->currClientRateID],
+                                                     pCtrlData->ctrlDataCurrentModulationType,
+                                                     pCtrlData->ctrlDataCerruentFourXstate,
+                                                     pCtrlData->ctrlDataCurrentBssType);
+                break;
+
+            }
+            else
+            {   
+                /* The class could not be configured due to no rate support - don't use it */
+                WLAN_REPORT_ERROR(pCtrlData->hReport,CTRL_DATA_MODULE_LOG,
+                    ("%s: Can't enable rate class ID %d\n",__FUNCTION__,clientID));
+                break;
+            } 
+        }
+
+    case CTRL_DATA_NEXT_RATE_MASK_FOR_CLIENT:
+        /* configure the next rate mask to be used for a specific client on the next connection */
+        /* NOTE : changing USER_RATE_CLASS configuration is not advisable */
+        pCtrlData->nextClientRateMask[pParamInfo->content.ctrlDataRateClassMask.clientID] = 
+            pParamInfo->content.ctrlDataRateClassMask.clientRateMask;
+        break;
+        
+    case CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM: 
+#ifdef SUPPORT_4X
+        if((pCtrlData->ctrlDataFourXEnable == TRUE) &&
+           (pCtrlData->ctrlDataCurrentBssType == BSS_INFRASTRUCTURE))
+            pCtrlData->ctrlDataCerruentFourXstate = pParamInfo->content.ctrlDataCerruentFourXstate;
+        else
+            pCtrlData->ctrlDataCerruentFourXstate = FALSE;
+#else 
+        pCtrlData->ctrlDataCerruentFourXstate = FALSE;
+#endif
+        break; 
+
+    case CTRL_DATA_CURRENT_BSSID_PARAM:          
+        MAC_COPY(pCtrlData->hOs, (&pCtrlData->ctrlDataCurrentBSSID),
+            (&pParamInfo->content.ctrlDataCurrentBSSID));
+        break; 
+
+    case CTRL_DATA_CURRENT_BSS_TYPE_PARAM:
+        if( pParamInfo->content.ctrlDataCurrentBssType != BSS_INFRASTRUCTURE &&
+            pParamInfo->content.ctrlDataCurrentBssType != BSS_INDEPENDENT )
+            return(PARAM_VALUE_NOT_VALID);
+
+        pCtrlData->ctrlDataCurrentBssType = pParamInfo->content.ctrlDataCurrentBssType;        
+        break; 
+
+    case CTRL_DATA_CURRENT_MODULATION_TYPE_PARAM: 
+        pCtrlData->ctrlDataCurrentModulationType = pParamInfo->content.ctrlDataCurrentModulationType;   
+        /* update rate modulatin table for Rate adaptation algorithm */
+
+        rateAdaptation_updateModulation(pCtrlData->pRateAdaptation,
+                                        pCtrlData->ctrlDataCurrentModulationType,
+                                        pCtrlData->ctrlDataCurrentBssType);
+
+        break; 
+
+    case CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM: 
+        if( pParamInfo->content.ctrlDataCurrentPreambleType != PREAMBLE_LONG &&
+            pParamInfo->content.ctrlDataCurrentPreambleType != PREAMBLE_SHORT )
+            return(PARAM_VALUE_NOT_VALID);
+        pCtrlData->ctrlDataCurrentPreambleType = pParamInfo->content.ctrlDataCurrentPreambleType;        
+
+        break; 
+
+    case CTRL_DATA_MAC_ADDRESS: 
+        {
+            int status;
+                       status = whalCtrl_SetMacAddress(pCtrlData->hWhalCtrl, &pParamInfo->content.ctrlDataDeviceMacAddress);
+                       WLAN_REPORT_ERROR(pCtrlData->hReport, TX_DATA_MODULE_LOG,  
+                                                         (" ctrlData_setParam() : MAC ADDRESS SET STATUS: %d \n",status));
+                       if(status == OK)
+                               MAC_COPY(pCtrlData->hOs, (&pCtrlData->ctrlDataDeviceMacAddress),
+                                                (&pParamInfo->content.ctrlDataDeviceMacAddress)); 
+
+        }
+        break;
+
+    case CTRL_DATA_CURRENT_BASIC_RATE_PARAM:             
+
+        pCtrlData->ctrlDataCurrentBasicRate = pParamInfo->content.ctrlDataCurrentBasicRate;  
+        /* for Basic Rate Set use the USER_RATE_CLASS (otherwise we could get 0 rates) */
+        pCtrlData->ctrlDataBasicRateBitMask = rateAdaptation_Utils_buildRateBitMap(pCtrlData->pRateAdaptation,
+                                                                                   pCtrlData->ctrlDataCurrentRateTable,
+                                                                                   pCtrlData->ctrlDataCurrentBasicRate,         
+                                                                                   pCtrlData->ctrlDataCurrentRateMask,
+                                                                                   pCtrlData->currClientRateMask[USER_RATE_CLASS]);
+        break;
+    case CTRL_DATA_CURRENT_BASIC_RATE_MASK_PARAM: 
+        pCtrlData->ctrlDataBasicRateBitMask = pParamInfo->content.ctrlDataBasicRateBitMask;
+        break; 
+
+    case CTRL_DATA_CURRENT_BASIC_MODULATION_PARAM: 
+        pCtrlData->ctrlDataCurrentBasicModulationType = pParamInfo->content.ctrlDataCurrentBasicModulationType;
+        break; 
+
+
+    case CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM:
+        pCtrlData->ctrlDataCurrentRateMask = pParamInfo->content.ctrlDataCurrentRateMask;
+        selectRateTable(pCtrlData, pCtrlData->ctrlDataCurrentRateMask);
+        rateAdaptation_buildRateMapTable(pCtrlData->pRateAdaptation,
+                                         pCtrlData->ctrlDataCurrentRateTable,
+                                         pCtrlData->ctrlDataCurrentRateMask,
+                                         pCtrlData->currClientRateMask[pCtrlData->currClientRateID],
+                                         (modulationType_e)pCtrlData->ctrlDataCerruentFourXstate,
+                                         pCtrlData->ctrlDataCurrentModulationType,
+                                         pCtrlData->ctrlDataCurrentBssType);
+
+
+        break; 
+
+    case CTRL_DATA_CURRENT_ACTIVE_RATE_PARAM:
+        rateAdaptation_setCurrentRate(pCtrlData->pRateAdaptation, pParamInfo->content.ctrlDataCurrentActiveRate);
+
+        break;
+
+    case CTRL_DATA_TSRS_PARAM:
+        ctrlData_storeTSRateSet(pCtrlData, &pParamInfo->content.txDataQosParams);
+
+        break;
+
+    case CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM:
+        if (pCtrlData->ctrlDataProtectionEnabled != pParamInfo->content.ctrlDataProtectionEnabled)
+        {
+            pCtrlData->ctrlDataProtectionEnabled = pParamInfo->content.ctrlDataProtectionEnabled;
+
+            /* set indication also to TNET */
+            param.paramType = HAL_CTRL_CTS_TO_SELF_PARAM;
+            if(pCtrlData->ctrlDataProtectionEnabled == TRUE)
+                param.content.halCtrlCtsToSelf = CTS_TO_SELF_ENABLE;
+            else
+                param.content.halCtrlCtsToSelf = CTS_TO_SELF_DISABLE;
+
+            whalCtrl_SetParam(pCtrlData->hWhalCtrl,&param);
+
+
+            /* In case of using protection fragmentation should be disabled */
+            param.paramType = HAL_CTRL_FRAG_THRESHOLD_PARAM;
+            if(pCtrlData->ctrlDataProtectionEnabled == TRUE)
+            {
+                /* save last non-protection mode fragmentation threshold */
+                whalCtrl_GetParam(pCtrlData->hWhalCtrl,&param);
+                pCtrlData->lastFragmentThreshold = param.content.halCtrlFragThreshold;
+                /* set fragmentation threshold to max (disable) */
+                param.content.halCtrlFragThreshold = HAL_CTRL_FRAG_THRESHOLD_MAX;
+            }
+            else
+                param.content.halCtrlFragThreshold = pCtrlData->lastFragmentThreshold;
+            
+            whalCtrl_SetParam(pCtrlData->hWhalCtrl,&param);
+        }
+
+        break;
+
+    case CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM:
+        pCtrlData->ctrlDataIbssProtectionType = pParamInfo->content.ctrlDataIbssProtecionType;
+
+        /* set indication also to TNET */
+        param.paramType = HAL_CTRL_CTS_TO_SELF_PARAM;
+        if(pCtrlData->ctrlDataIbssProtectionType != ERP_PROTECTION_NONE)
+            param.content.halCtrlCtsToSelf = CTS_TO_SELF_ENABLE;
+        else
+            param.content.halCtrlCtsToSelf = CTS_TO_SELF_DISABLE;
+                
+        whalCtrl_SetParam(pCtrlData->hWhalCtrl,&param);
+
+        break;
+
+    case CTRL_DATA_CURRENT_RTS_CTS_STATUS_PARAM:
+        pCtrlData->ctrlDataRtsCtsStatus = pParamInfo->content.ctrlDataRtsCtsStatus;
+        break;
+    case CTRL_DATA_CLSFR_TYPE:
+        ctrlData_clsfrSetClsfrType (pCtrlData->pClsfr,pParamInfo->content.ctrlDataClsfrType);
+        break;
+
+    case CTRL_DATA_CLSFR_CONFIG:
+            Classifier_InsertClsfrEntry(pCtrlData->pClsfr, 1, &pParamInfo->content.ctrlDataClsfrInsertTable);
+        break;
+
+    case CTRL_DATA_CLSFR_REMOVE_ENTRY:
+         classifier_RemoveClsfrEntry(pCtrlData->pClsfr, &pParamInfo->content.ctrlDataClsfrInsertTable);
+       break;
+       
+    case CTRL_DATA_GET_USER_PRIORITY_OF_STREAM:
+       Classifier_deriveUserPriorityFromStream (pCtrlData->pClsfr,&pParamInfo->content.ctrlDataUpOfStream);
+       break;
+            /*
+         * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+         */
+    case CTRL_DATA_SHORT_RETRY_LIMIT_PARAM:
+        pCtrlData->ctrlDataTxRatePolicy.rateClass[USER_RATE_CLASS].shortRetryLimit = pParamInfo->content.TxRatePolicy.rateClass[USER_RATE_CLASS].shortRetryLimit;
+        break;
+
+        /*
+         * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+         */
+    case CTRL_DATA_LONG_RETRY_LIMIT_PARAM:
+        pCtrlData->ctrlDataTxRatePolicy.rateClass[USER_RATE_CLASS].longRetryLimit = pParamInfo->content.TxRatePolicy.rateClass[USER_RATE_CLASS].longRetryLimit;
+        break;
+
+    case CTRL_DATA_TOGGLE_TRAFFIC_INTENSITY_EVENTS:
+
+            /* Enable or disable events according to flag */
+            ctrlData_ToggleTrafficIntensityNotification (pCtrlData, (BOOL)pParamInfo->content.ctrlDataTrafficIntensityEventsFlag);
+        
+        break;
+
+    case CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD:
+        {
+            OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS *localParams = &pParamInfo->content.ctrlDataTrafficIntensityThresholds;
+            BOOL savedEnableFlag;   /* Used to save previous enable/disable flag - before stopping/starting events for change in params */
+        
+            /* If any of the parameters has changed, we need to re-register with the Traffic Monitor */
+            if ((localParams->uHighThreshold != pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold) ||
+                (localParams->uLowThreshold != pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold) ||
+                (localParams->TestInterval != pCtrlData->ctrlDataTrafficIntensityThresholds.TestInterval))
+            {
+
+                os_memoryCopy(pCtrlData->hOs, &pCtrlData->ctrlDataTrafficIntensityThresholds,
+                                localParams,
+                                sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS));
+
+                savedEnableFlag = pCtrlData->ctrlDataTrafficIntensityEventsEnabled;
+
+                /* Turn off traffic events */
+                ctrlData_ToggleTrafficIntensityNotification (pCtrlData, FALSE);
+
+                /* Unregister current events */
+                ctrlData_UnregisterTrafficIntensityEvents (pCtrlData);
+                
+                /* And re-register with new thresholds */
+                ctrlData_RegisterTrafficIntensityEvents (pCtrlData);
+
+                /* Enable events if they were enabled  */
+                ctrlData_ToggleTrafficIntensityNotification (pCtrlData, savedEnableFlag);
+
+            }
+        }
+        
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pCtrlData->hReport, TX_DATA_MODULE_LOG,  
+            (" ctrlData_setParam() : PARAMETER NOT SUPPORTED \n"));
+        return (PARAM_NOT_SUPPORTED);
+/*        break; - unrechable */
+    }
+
+    return (OK);
+}
+
+/***************************************************************************
+*                           ctrlData_getTspecsRateThresholds                                   *
+****************************************************************************
+* DESCRIPTION:  The function retrieves the current low/high phy rate thresholds.
+*
+* INPUTS:       hCtrlData - the object
+*               uAC       - The AC number.
+*               
+* OUTPUT:       pHighThreshold - The current phy rate high threshold
+*               pHighThreshold - The current phy rate low threshold
+*
+* RETURNS:      
+***************************************************************************/
+void ctrlData_getTspecsRateThresholds(TI_HANDLE hCtrlData, UINT8 uAC, UINT32* pHighThreshold, UINT32* pLowThreshold)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    rateAdaptation_t* pRateAdaptation = (rateAdaptation_t*)pCtrlData->pRateAdaptation;
+    
+    *pHighThreshold = hostToUtilityRate(RateNumberToHost(pRateAdaptation->tspecsRateParameters[uAC].highRateThreshold));
+    *pLowThreshold = hostToUtilityRate(RateNumberToHost(pRateAdaptation->tspecsRateParameters[uAC].lowRateThreshold));
+}
+
+/***************************************************************************
+*                           selectRateTable                                *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*
+* RETURNS:      
+***************************************************************************/
+
+static void selectRateTable(TI_HANDLE hCtrlData, UINT32 rateMask)
+{
+    paramInfo_t param;
+    rate_e      rate;
+    
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    rate = getMaxRatefromBitmap(rateMask);
+
+    param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
+    siteMgr_getParam(pCtrlData->hSiteMgr, &param);
+
+    switch(param.content.siteMgrDot11OperationalMode)
+    {
+        case DOT11_B_MODE:
+        {
+            if(rate == DRV_RATE_22M)
+            {
+                pCtrlData->ctrlDataCurrentRateTable = &pCtrlData->ctrlDataRateTables.ctrlDataPbccRateTable;
+                pCtrlData->pCurrPolicyClassRatesArray = pCtrlData->policyClassRatesArrayPbcc;
+            }
+            else
+            {
+                pCtrlData->ctrlDataCurrentRateTable = &pCtrlData->ctrlDataRateTables.ctrlDataCckRateTable;
+                pCtrlData->pCurrPolicyClassRatesArray = pCtrlData->policyClassRatesArrayCck;
+
+            }
+        }
+        break;
+
+        case DOT11_G_MODE:
+            if( (rate == DRV_RATE_22M) ||
+                (rate == DRV_RATE_11M) || 
+                (rate == DRV_RATE_5_5M)|| 
+                (rate == DRV_RATE_2M)  || 
+                (rate == DRV_RATE_1M)    )
+            {
+                pCtrlData->ctrlDataCurrentRateTable = &pCtrlData->ctrlDataRateTables.ctrlDataPbccRateTable;
+                pCtrlData->pCurrPolicyClassRatesArray = pCtrlData->policyClassRatesArrayPbcc;
+            }
+            else
+            {
+                pCtrlData->ctrlDataCurrentRateTable = &pCtrlData->ctrlDataRateTables.ctrlDataOfdmRateTable ;
+                pCtrlData->pCurrPolicyClassRatesArray = pCtrlData->policyClassRatesArrayOfdm;
+            }
+        break;
+
+        case DOT11_A_MODE:
+            pCtrlData->ctrlDataCurrentRateTable = &pCtrlData->ctrlDataRateTables.ctrlDataOfdmARateTable;
+            pCtrlData->pCurrPolicyClassRatesArray = pCtrlData->policyClassRatesArrayOfdmA;
+
+        break;
+        case DOT11_DUAL_MODE:
+        case DOT11_MAX_MODE:
+            WLAN_REPORT_ERROR(pCtrlData->hReport,CTRL_DATA_MODULE_LOG,
+                ("%s ctrlDataCurrentRateTable not configured !!!",__FUNCTION__));
+            break;
+
+    }
+            
+
+
+}
+
+/***************************************************************************
+*                           ctrlData_start                                 *
+****************************************************************************
+* DESCRIPTION:  This function start the link control algorithms. It start
+*               each algorithm (Rate Adaptation) if needed.
+* 
+* INPUTS:       hCtrlData - the object
+*       
+* OUTPUT:       
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+
+TI_STATUS ctrlData_start(TI_HANDLE hCtrlData)   
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    pCtrlData->ctrlDataStartStoplinkControlAlg = TRUE;
+
+
+    /* start Rate Adaptation if needed */
+    if(pCtrlData->ctrlDataRateControlEnable == TRUE)
+    {
+        rateAdaptation_start(pCtrlData->pRateAdaptation);
+    }
+
+
+    WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG, 
+        (" ctrlData_start() : Link control algorithms started successfully \n"));
+
+    return OK;
+}
+
+/***************************************************************************
+*                           ctrlData_stop                                  *
+****************************************************************************
+* DESCRIPTION:  This function stop the link control algorithms. 
+*
+* INPUTS:       hCtrlData - the object
+*       
+* OUTPUT:       
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+
+TI_STATUS ctrlData_stop(TI_HANDLE hCtrlData)    
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    /* stop link control algorithm */
+    pCtrlData->ctrlDataStartStoplinkControlAlg = FALSE;
+
+    /* set modulation option to default value*/
+    pCtrlData->ctrlDataCurrentModulationType = DEF_CURRENT_MUDULATION_TYPE;
+
+    /* set Preamble length option to default value*/
+    pCtrlData->ctrlDataCurrentPreambleType = DEF_CURRENT_PREAMBLE;
+
+    /* set mgmt rate to default value */
+    pCtrlData->ctrlDataCurrentBasicRate = DEF_BASIC_RATE;
+    pCtrlData->ctrlDataBasicRateBitMask = DEF_BASIC_RATE_MASK;
+    pCtrlData->ctrlDataCurrentBasicModulationType = DRV_MODULATION_QPSK;
+
+    os_memoryZero(pCtrlData->hOs, 
+                  &pCtrlData->tsrsParameters, 
+                  sizeof(pCtrlData->tsrsParameters));
+
+    WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+        (" ctrlData_stop() : Link control algorithms stoped \n"));
+
+    rateAdaptation_stop(pCtrlData->pRateAdaptation);
+
+    return OK;
+}
+
+/***************************************************************************
+*                       ctrlData_receiveParamFromRx                        *
+****************************************************************************
+* DESCRIPTION:  This function receive Msdu Rx parameters from the Rx data
+*               module, update counters.
+*
+* INPUTS:       hCtrlData - the object
+*               pRxMsduInfo - Information about the receive msdu
+* OUTPUT:       
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+#ifdef SUPPORT_4X
+TI_STATUS ctrlData_rxMsdu(TI_HANDLE         hCtrlData, 
+                          mem_MSDU_T        **pRxMsdu)  
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    
+    if(pCtrlData->ctrlDataStartStoplinkControlAlg == FALSE)
+        return OK;
+
+    if((pCtrlData->ctrlDataFourXEnable == TRUE) &&
+       (pCtrlData->ctrlDataCurrentBssType == BSS_INFRASTRUCTURE))
+    {
+        /* Call fourX function */
+        if(fourX_rxMsdu(pCtrlData->pFourX, pRxMsdu) != OK)
+        {
+            WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+                (" failed in fourX_rxMsdu\n"));
+            return NOK;
+        }
+    }
+
+    return OK;
+}
+#endif
+/***************************************************************************
+*                       ctrlData_getTxAttributes                           *
+****************************************************************************
+* DESCRIPTION:  This function set the transmited parameters for a 
+*               specific msdu
+*
+* INPUTS:       hCtrlData - the object
+*               txFlags - Information about the msdu
+*               
+* OUTPUT:       pTxAttr - pointer to the tx parameters structure
+* 
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+
+TI_STATUS ctrlData_getTxAttributes(TI_HANDLE hCtrlData, UINT32 txFlags, 
+                                txData_attr_t *pTxAttr, UINT32 ac)  
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    rateModulation4x_table_t* pRateModulation;
+
+    os_memoryZero(pCtrlData->hOs, pTxAttr, sizeof(txData_attr_t));
+
+
+    if( ((txFlags & TX_DATA_MULTICAST_FRAME) && (pCtrlData->ctrlDataCurrentBssType == BSS_INDEPENDENT)) || 
+            (txFlags & TX_DATA_MGMT_MSDU) )
+    {
+        /* BCAST packets in IBSS should be sent at 2M and not in the highest basic rate. */
+        if (pCtrlData->ctrlDataCurrentRateMask & DRV_RATE_MASK_2_BARKER)
+        {
+            pTxAttr->Rate = DRV_RATE_2M;        
+        } 
+        else 
+        {
+            pTxAttr->Rate = ctrlData_getClosestTSRate(pCtrlData, ac, pCtrlData->ctrlDataCurrentBasicRate);
+        }
+        /* by default use USER_RATE_CLASS for this kind of packets */
+        pTxAttr->txRatePolicyId = pCtrlData->tsrsParameters[ac].fwPolicyID[USER_RATE_CLASS];
+    }
+    /* For regular data packets use the rate-adaptation rates. */
+    else
+    {
+        pRateModulation = rateAdaptation_getCurrent(pCtrlData->pRateAdaptation);
+        pTxAttr->Rate = ctrlData_getClosestTSRate(pCtrlData, ac, pRateModulation->rate);
+
+        /* rate class Id ( retries profile per rate) */
+        pTxAttr->txRatePolicyId = pCtrlData->tsrsParameters[ac].fwPolicyID[pCtrlData->currClientRateID];
+
+        /* For voice delivery PSPoll, use only basic rates */
+        if (txFlags & TX_DATA_PS_POLL)
+        {
+            paramInfo_t param;
+            modulationType_e tempModulation;
+
+            param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
+            siteMgr_getParam(pCtrlData->hSiteMgr, &param);
+            
+            /* Get the max rate and modulation from the BasicRateBitMask. */
+            getMaxRate(pCtrlData->ctrlDataBasicRateBitMask, 
+                       &pTxAttr->Rate, 
+                       &tempModulation, 
+                       param.content.siteMgrDot11OperationalMode);
+        }
+
+
+    }
+
+    /* convert Application rate to HW rate */
+    ConvertAppRateToHwBitMapRate(pTxAttr->Rate, &(pTxAttr->HwRate));
+
+    WLAN_REPORT_DEBUG_TX(pCtrlData->hReport, 
+            ("%s: Rate = %d, HwRate = 0x%x\n",
+                __FUNCTION__,
+                pTxAttr->Rate,
+                pTxAttr->HwRate));
+
+    return OK;
+}
+
+/***************************************************************************
+*                        ctrlData_txCompleteStatus                         *
+****************************************************************************
+* DESCRIPTION:  This function is called by the Hal for every Tx supportedBitMap 
+*               Interrupt - it update the rate adaptation algorithm about
+*               the status of the last transmission and used as a trigger
+*               for the Tx scheduler.
+*
+* INPUTS:       hCtrlData - the object
+*               CmpltTxAttr - Information structure about the last 
+*               transmission
+*
+* OUTPUT:       
+* 
+* RETURNS:      void
+***************************************************************************/
+void ctrlData_txCompleteStatus( TI_HANDLE hCtrlData,
+                                       txCompleteAttr_t *pTxCompleteAttr )
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    UINT8       txCompleteFlags;
+    BOOL        frameDataType = 0;
+    rate_e      txActualRate;
+    rate_e      txRequestRate;
+    UINT8       qId;
+    txPacketIdAttr_t    *pPacketId = (txPacketIdAttr_t*)pTxCompleteAttr->packetId; 
+
+
+    /* 
+     * perform rate adaptation algorithm if host processes packets 
+     * and  not TNET.
+     * NOTE: MSDU was already freed in sendPacketTransfer
+     */
+    frameDataType = pPacketId->bDataMsdu;
+    qId = pPacketId->txQid; 
+
+    ConvertHwBitRateToAppRate(pTxCompleteAttr->rate, &txActualRate);
+    ConvertHwBitRateToAppRate(pPacketId->maxTransmitRate, &txRequestRate);
+
+    /* perform rate adaptation algorithm if needed */
+    if((pCtrlData->ctrlDataRateControlEnable == TRUE ) && 
+       (pCtrlData->ctrlDataStartStoplinkControlAlg == TRUE) &&
+           (frameDataType))
+        
+    {
+        rateAdaptation_updateRateAdaptation(pCtrlData->pRateAdaptation, txActualRate,
+                                            txRequestRate,pTxCompleteAttr->status, 0);
+    }
+    txCompleteFlags = pPacketId->txCompleteFlags;
+
+    if(txCompleteFlags & TX_DATA_DISASSOC_SYNC_TRIG)
+    {
+        WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,("Call disconnect test upon NULL data"));
+            pCtrlData->disassocSentCBFunc( pCtrlData->disassocSentCBObj );
+    }
+
+
+    if(txCompleteFlags & TX_DATA_DEAUTH_SYNC_TRIG)
+    {
+            WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            ("De Auth TxCmplt: txStatus = %d, txActualRate = %d  \n",pTxCompleteAttr->status,pTxCompleteAttr->rate));
+            pCtrlData->disassocSentCBFunc( pCtrlData->disassocSentCBObj );
+    }
+    if(txData_isQueueUseMediumTime(pCtrlData->hTxData , qId) == TRUE )
+    {
+        WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG, 
+            (" ctrlData_txCompleteStatus() :usedTime = %d  qNum = %d\n", 
+            pTxCompleteAttr->actualDurationInAir, qId));
+        
+        txData_updateUsedTime(pCtrlData->hTxData, 
+                              qId, 
+                              pTxCompleteAttr->actualDurationInAir);
+    }   
+    /*
+     * update tx complete status to txData (which schedule another packet also );
+     */
+    txData_txCompleteUpdate( pCtrlData->hTxData, pTxCompleteAttr );
+
+}
+
+/***************************************************************************
+*                        ctrlData_resetCounters                            *
+****************************************************************************
+* DESCRIPTION:  This function reset the Ctrl Data module counters
+*
+* INPUTS:       hCtrlData - the object
+*
+* OUTPUT:       
+* 
+* RETURNS:      void
+***************************************************************************/
+static void ctrlData_resetCounters(TI_HANDLE hCtrlData)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    os_memoryZero(pCtrlData->hOs,&pCtrlData->ctrlDataCounters, 
+                                sizeof(ctrlDataCounters_t));
+}
+
+/***************************************************************************
+*                   ctrlData_getCurrBssTypeAndCurrBssId                    *
+****************************************************************************
+* DESCRIPTION:  This function return the current BSSID and the 
+*               current BSS Type
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       pCurrBssid - pointer to return the current bssid    
+*               pCurrBssType - pointer to return the current bss type 
+*
+* RETURNS:      void
+***************************************************************************/
+void ctrlData_getCurrBssTypeAndCurrBssId(TI_HANDLE hCtrlData, macAddress_t *pCurrBssid, 
+                                           bssType_e *pCurrBssType)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    
+    MAC_COPY(pCtrlData->hOs, (pCurrBssid), (&pCtrlData->ctrlDataCurrentBSSID));
+    *pCurrBssType = pCtrlData->ctrlDataCurrentBssType;
+
+}
+
+#ifdef SUPPORT_4X
+/***************************************************************************
+*                   ctrlData_get4xInfoElemnt                               *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+TI_STATUS ctrlData_get4xInfoElemnt(TI_HANDLE hCtrlData, 
+                                   dot11_4X_t* fourXInfoElemnt)
+{
+    TI_STATUS Status = NOK;
+
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    
+    if((pCtrlData->ctrlDataFourXEnable == TRUE) &&
+       (pCtrlData->ctrlDataCurrentBssType == BSS_INFRASTRUCTURE))
+    {
+        Status = fourXManager_get4xInfoElemnt(pCtrlData->pFourX, fourXInfoElemnt);
+    }
+    
+    return Status;
+}
+#endif
+/***************************************************************************
+*                           ctrlData_get4xStatus                           *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+TI_STATUS ctrlData_get4xStatus(TI_HANDLE hCtrlData,BOOL* fourXEnable)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    *fourXEnable = pCtrlData->ctrlDataCerruentFourXstate;
+    return OK;
+}
+#ifdef SUPPORT_4X
+/***************************************************************************
+*                           ctrlData_evalSite                              *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+TI_STATUS ctrlData_evalSite(TI_HANDLE hCtrlData, 
+                            dot11_4X_t* site4xParams, 
+                            UINT32 *matchingLevel)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    if((pCtrlData->ctrlDataFourXEnable == TRUE) &&
+       (pCtrlData->ctrlDataCurrentBssType == BSS_INFRASTRUCTURE))
+    {
+        return (fourXManager_evalSite(pCtrlData->pFourX, site4xParams, matchingLevel));
+    }
+
+    return OK;
+}
+#endif
+/***************************************************************************
+*                           ctrlData_setSite                               *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+
+TI_STATUS ctrlData_setSite(TI_HANDLE hCtrlData,
+                           dot11_4X_t* site4xParams)
+{
+    TI_STATUS   status = NOK;
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+#ifdef SUPPORT_4X
+    if((pCtrlData->ctrlDataFourXEnable == TRUE) &&
+       (pCtrlData->ctrlDataCurrentBssType == BSS_INFRASTRUCTURE))
+    {
+        status = fourXManager_setSite(pCtrlData->pFourX, site4xParams);
+    }
+#endif
+    if(status != OK)
+        pCtrlData->ctrlDataCerruentFourXstate = FALSE;
+    else
+        pCtrlData->ctrlDataCerruentFourXstate = TRUE;
+
+    return status;
+}
+
+#ifdef SUPPORT_4X
+/***************************************************************************
+*                       ctrlData_txDequeueMsdu                            *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+TI_STATUS ctrlData_txDequeueMsdu(TI_HANDLE          hCtrlData, 
+                                 mem_MSDU_T**       buildMsduPtr,
+                                 MsduList_t*        pMsduList, 
+                                 whalTx_attr_t*     pWhalTx_attr,
+                                 hwTxInformation_t* pHwTxInformation)
+{
+    TI_STATUS   status;
+    UINT32      currNumOfMsdu;
+
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    *buildMsduPtr = NULL;
+
+    currNumOfMsdu = msduList_getCurrNumOfMsdu(pMsduList);
+    if(currNumOfMsdu == 0)
+        return DO_NOT_SEND_MSDU;
+
+    if(pCtrlData->ctrlDataCerruentFourXstate == TRUE)
+    {
+        /* call 4x */ 
+        status = fourX_txMsduDeQueue(pCtrlData->pFourX, buildMsduPtr, pMsduList, pHwTxInformation);
+        if(status != OK)
+        {
+            return DO_NOT_SEND_MSDU;
+        }
+
+        ctrlData_getTxAttributes(pCtrlData, (*buildMsduPtr)->txFlags, pWhalTx_attr, QOS_AC_BE); /* stub */
+        return SEND_ONE_MSDU;
+
+    }
+    return FOUR_X_DISABLE;
+
+}
+
+/***************************************************************************
+*                       ctrlData_txMsdu                                    *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+TI_STATUS ctrlData_txMsdu(TI_HANDLE         hCtrlData, 
+                          mem_MSDU_T**      msduPtr)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    if(pCtrlData->ctrlDataCerruentFourXstate == TRUE)
+    {
+        fourX_txMsduBeforInsertToQueue(pCtrlData->pFourX, msduPtr);
+    }
+
+    return OK;
+}
+#endif /* SUPPORT_4X */
+
+/***************************************************************************
+*                       ctrlData_setTspecsRateEvent                       *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+
+void ctrlData_setTspecsRateEvent(TI_HANDLE          hCtrlData,
+                                    UINT8           acID,
+                                    BOOL            enableEvent)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+     rateAdaptation_setTspecsRateEvent(pCtrlData->pRateAdaptation, acID, enableEvent);
+
+}
+
+/***************************************************************************
+*                   ctrlData_setTspecsRateThresholds                      *
+****************************************************************************
+* DESCRIPTION:  
+*
+* INPUTS:       hCtrlData - the object
+*               
+* OUTPUT:       
+*               
+* RETURNS:      
+***************************************************************************/
+
+void ctrlData_setTspecsRateThresholds(TI_HANDLE     hCtrlData,
+                                      UINT8         acID,
+                                      UINT8     highRateThreshold,
+                                      UINT8     lowRateThreshold)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    
+    rateAdaptation_setTspecsRateThresholds(pCtrlData->pRateAdaptation, acID, highRateThreshold, lowRateThreshold);
+}
+
+/************************************************************************
+ *                        Classifier functions
+ ************************************************************************ */
+
+/************************************************************************
+ *                        ctrlData_clsfrClassifyTxMSDU
+ ************************************************************************
+      
+Input:  
+
+* hCtrlData: hCtrlData - the object
+* pMsdu: pointer to the MSDU
+* packet_DTag: NDIS Packet 802.1 user priority (UP)
+
+Output:  
+
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+If the value PARAM_VALUE_NOT_VALID is returned, the MSDU qosTag field is zero. 
+
+Description:  
+
+This function performs the classification algorithm on the MSDU by calling the 
+Classifier_classifyTxMSDU API.
+
+************************************************************************/
+
+TI_STATUS ctrlData_ClsfrClassifyTxMSDU(TI_HANDLE    hCtrlData, 
+                                       mem_MSDU_T   *pMsdu, 
+                                       UINT8        packet_DTag)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    /* check parameters validity */
+    if(!hCtrlData)
+        return NOK;
+
+    if (pMsdu == NULL) 
+    {
+        WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            (" ctrlData_ClsfrClassifyTxMSDU() : parametrs value error (the MSDU's qosTag is not updated) \n"));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    return (Classifier_classifyTxMSDU(pCtrlData->pClsfr, pMsdu, packet_DTag));
+
+}
+
+
+
+/************************************************************************
+ *                        ctrlData_clsfrSetClsfrType
+ ************************************************************************
+      
+Input:  
+
+* hCtrlData: hCtrlData - the object
+* newClsfrType: the new classifier type
+
+Output:  
+
+OK on success and PARAM_VALUE_NOT_VALID in case of input parameters problems.
+If the value PARAM_VALUE_NOT_VALID is returned, the classifier type is not updated.
+
+Description:  
+
+This function changes the active classifier type by calling the 
+Classifier_setClsfrType API.
+
+************************************************************************/
+
+
+TI_STATUS ctrlData_clsfrSetClsfrType(TI_HANDLE          hCtrlData,
+                                    clsfrTypeAndSupport     newClsfrType)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    /* check parameters validity */
+    if(!hCtrlData)
+        return PARAM_VALUE_NOT_VALID;
+        
+    return (Classifier_setClsfrType(pCtrlData->pClsfr, (clsfr_type_e)newClsfrType.ClsfrType));
+    
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: ctrlData_ToggleTrafficIntensityNotification
+Routine Description: turns ON/OFF traffic intensity notification events
+                     from Traffic Monitor module
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+void ctrlData_ToggleTrafficIntensityNotification (TI_HANDLE hCtrlData, BOOL enabledFlag)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    UINT8 idx;
+
+   if (enabledFlag)
+   {
+      for (idx=0; idx < CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS; idx++)
+      {
+         TrafficMonitor_StartEventNotif (pCtrlData->hTrafficMonitor,pCtrlData->ctrlDataTrafficThresholdEvents[idx]);
+      }
+      WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+         ("ctrlData_ToggleTrafficIntensityNotification (TRUE)\n"));
+   }
+   else
+   {
+      for (idx=0; idx < CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS; idx++)
+      {
+         TrafficMonitor_StopEventNotif (pCtrlData->hTrafficMonitor,pCtrlData->ctrlDataTrafficThresholdEvents[idx]);
+      }
+      WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+         ("ctrlData_ToggleTrafficIntensityNotification (FALSE)\n"));
+   }
+   pCtrlData->ctrlDataTrafficIntensityEventsEnabled = enabledFlag;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: ctrlData_UnregisterTrafficIntensityEvents
+Routine Description: unregisters existing events from traffic monitor
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+static void ctrlData_UnregisterTrafficIntensityEvents (TI_HANDLE hCtrlData)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    UINT8 idx;
+
+    /* Loop through events and unregister them */
+    for (idx=0; idx < CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS; idx++)
+    {
+       TrafficMonitor_UnregEvent (pCtrlData->hTrafficMonitor,pCtrlData->ctrlDataTrafficThresholdEvents[idx]);
+    }
+
+    WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+       ("ctrlData_UnregisterTrafficIntensityEvents: Unregistered all events\n"));
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: ctrlData_RegisterTrafficIntensityEvents
+Routine Description: Registers traffic intensity threshold events through traffic monitor
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+static void ctrlData_RegisterTrafficIntensityEvents (TI_HANDLE hCtrlData)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+    TrafficAlertRegParm_t TrafficAlertRegParm;
+    TI_STATUS status;
+
+    /* Register high threshold "direction up" event */
+    TrafficAlertRegParm.CallBack = ctrlData_TrafficThresholdCrossed;
+    TrafficAlertRegParm.Context = hCtrlData; 
+    TrafficAlertRegParm.Cookie =  CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_ABOVE;    
+    TrafficAlertRegParm.Direction = TRAFF_UP;
+    TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+    TrafficAlertRegParm.TimeIntervalMs = pCtrlData->ctrlDataTrafficIntensityThresholds.TestInterval;
+    TrafficAlertRegParm.Threshold = pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold;
+    TrafficAlertRegParm.MonitorType = TX_RX_DIRECTED_FRAMES;
+    pCtrlData->ctrlDataTrafficThresholdEvents[0] = TrafficMonitor_RegEvent(pCtrlData->hTrafficMonitor,&TrafficAlertRegParm,FALSE); 
+
+    if (pCtrlData->ctrlDataTrafficThresholdEvents[0] == NULL)
+    {
+         WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            (" ctrlData_RegisterTrafficIntensityEvents() : Failed to register high treshold event (TRAFF_UP) \n"));
+         return;
+    }
+
+    /* Register high threshold "direction down" event*/
+    TrafficAlertRegParm.Cookie =  CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_BELOW;    
+    TrafficAlertRegParm.Direction = TRAFF_DOWN;
+    TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+    TrafficAlertRegParm.Threshold = pCtrlData->ctrlDataTrafficIntensityThresholds.uHighThreshold;
+    pCtrlData->ctrlDataTrafficThresholdEvents[1] = TrafficMonitor_RegEvent(pCtrlData->hTrafficMonitor,&TrafficAlertRegParm,FALSE); 
+
+    if (pCtrlData->ctrlDataTrafficThresholdEvents[1] == NULL)
+    {
+         WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            (" ctrlData_RegisterTrafficIntensityEvents() : Failed to register high treshold event (TRAFF_DOWN) \n"));
+         return;
+    }
+
+    /* Define the "direction below" and "direction above" events as opposites (events that reset eachother)*/
+    status = TrafficMonitor_SetRstCondition(pCtrlData->hTrafficMonitor,
+                                            pCtrlData->ctrlDataTrafficThresholdEvents[0],
+                                            pCtrlData->ctrlDataTrafficThresholdEvents[1],
+                                            TRUE);
+
+    if (status != OK)
+    {
+      WLAN_REPORT_ERROR (pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+         ("ctrlData_RegisterTrafficIntensityEvents: TrafficMonitor_SetRstCondition returned status = %d\n",status));
+    }
+
+    /* Register low threshold "direction up" event */
+    TrafficAlertRegParm.Cookie =  CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_ABOVE;    
+    TrafficAlertRegParm.Direction = TRAFF_UP;
+    TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+    TrafficAlertRegParm.Threshold = pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold;
+    pCtrlData->ctrlDataTrafficThresholdEvents[2] = TrafficMonitor_RegEvent(pCtrlData->hTrafficMonitor,&TrafficAlertRegParm,FALSE); 
+
+    if (pCtrlData->ctrlDataTrafficThresholdEvents[2] == NULL)
+    {
+         WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            (" ctrlData_RegisterTrafficIntensityEvents() : Failed to register low treshold event (TRAFF_UP) \n"));
+         return;
+    }
+
+    /* Register low threshold "direction below" event */
+    TrafficAlertRegParm.Cookie =  CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_BELOW;
+    TrafficAlertRegParm.Direction = TRAFF_DOWN;
+    TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+    TrafficAlertRegParm.Threshold = pCtrlData->ctrlDataTrafficIntensityThresholds.uLowThreshold;
+    pCtrlData->ctrlDataTrafficThresholdEvents[3] = TrafficMonitor_RegEvent(pCtrlData->hTrafficMonitor,&TrafficAlertRegParm,FALSE); 
+
+    if (pCtrlData->ctrlDataTrafficThresholdEvents[3] == NULL)
+    {
+         WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+            (" ctrlData_RegisterTrafficIntensityEvents() : Failed to register low treshold event (TRAFF_DOWN) \n"));
+         return;
+    }
+
+    /* Define the "direction below" and "direction above" events as opposites (events that reset eachother)*/
+    status = TrafficMonitor_SetRstCondition(pCtrlData->hTrafficMonitor,
+                                            pCtrlData->ctrlDataTrafficThresholdEvents[2],
+                                            pCtrlData->ctrlDataTrafficThresholdEvents[3],
+                                            TRUE);
+
+    if (status != OK)
+    {
+      WLAN_REPORT_ERROR (pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+         ("ctrlData_RegisterTrafficIntensityEvents: TrafficMonitor_SetRstCondition returned status = %d\n",status));
+    }
+  
+    WLAN_REPORT_INFORMATION(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+       (" ctrlData_RegisterTrafficIntensityEvents() : finished registering all events \n"));
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: ctrlData_TrafficThresholdCrossed
+Routine Description: called whenever traffic intensity threshold is crossed. 
+                     notifies event handler to send appropriate event with threshold parameters.
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+void ctrlData_TrafficThresholdCrossed(TI_HANDLE Context,UINT32 Cookie)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)Context;
+    trafficIntensityThresholdCross_t crossInfo;
+
+    switch(Cookie) 
+    {
+    case CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_ABOVE:
+            crossInfo.thresholdCross = (UINT32)HIGH_THRESHOLD_CROSS;
+            crossInfo.thresholdCrossDirection = (UINT32)CROSS_ABOVE;
+            EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t));
+       break;
+
+    case CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_BELOW:
+            crossInfo.thresholdCross = (UINT32)HIGH_THRESHOLD_CROSS;
+            crossInfo.thresholdCrossDirection = (UINT32)CROSS_BELOW;
+            EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t));
+       break;
+
+    case CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_ABOVE:
+            crossInfo.thresholdCross = (UINT32)LOW_THRESHOLD_CROSS;
+            crossInfo.thresholdCrossDirection = (UINT32)CROSS_ABOVE;
+            EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t));
+       break;
+
+    case CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_BELOW:
+            crossInfo.thresholdCross = (UINT32)LOW_THRESHOLD_CROSS;
+            crossInfo.thresholdCrossDirection = (UINT32)CROSS_BELOW;
+            EvHandlerSendEvent(pCtrlData->hEvHandler, IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (UINT8 *)&crossInfo,sizeof(trafficIntensityThresholdCross_t));
+       break;
+    default:
+         WLAN_REPORT_ERROR(pCtrlData->hReport, CTRL_DATA_MODULE_LOG,
+                (" ctrlData_TrafficThresholdCrossed() : Unknown cookie received from traffic monitor !!! \n"));
+       break;
+   }
+    
+}
+
+/***************************************************************************
+*                           ctrlData_buildHwBitMapFromArray                 *
+****************************************************************************
+* DESCRIPTION:  builds HwRatesBitMap (supported rates) for txRatePolicy  
+*               using an array that consist number of retries for each rate
+*               all ew do is : if retry > 0 than the HwBit is ON.
+* 
+* INPUTS:       Array of retries
+*       
+* OUTPUT:       Bit Map of Hw rates.
+* 
+* RETURNS:      Bit Map of Hw rates.
+*           
+***************************************************************************/
+static UINT32 ctrlData_buildHwBitMapFromArray(policyClassRatesArray_t *pArray)
+{
+    txRateClassId_e  TxRateIndex;
+    UINT32 policyRateMask = 0;
+    rateMask_e tempArray[MAX_NUM_OF_TX_RATES_IN_CLASS] = 
+    {
+    DRV_RATE_MASK_54_OFDM,DRV_RATE_MASK_48_OFDM,DRV_RATE_MASK_36_OFDM,
+    DRV_RATE_MASK_24_OFDM,DRV_RATE_MASK_22_PBCC,DRV_RATE_MASK_18_OFDM,
+    DRV_RATE_MASK_12_OFDM,DRV_RATE_MASK_11_CCK,DRV_RATE_MASK_9_OFDM,
+    DRV_RATE_MASK_6_OFDM,DRV_RATE_MASK_5_5_CCK,DRV_RATE_MASK_2_BARKER,
+    DRV_RATE_MASK_1_BARKER};
+
+
+
+    for (TxRateIndex = txPolicy54; TxRateIndex < MAX_NUM_OF_TX_RATES_IN_CLASS; TxRateIndex++)
+    {
+        if (pArray->txRate[TxRateIndex] > 0 )
+        {
+            policyRateMask |= tempArray[TxRateIndex]; 
+        }
+    }
+
+    return policyRateMask;
+}
+
+
+/*************************************************************************
+ *                                                                       *
+ *                          DEBUG FUNCTIONS                              *
+ *                                                                       *
+ *************************************************************************/
+
+void ctrlData_printTxParameters(TI_HANDLE hCtrlData)
+{
+    WLAN_OS_REPORT(("            Tx Parameters            \n"));
+    WLAN_OS_REPORT(("-------------------------------------\n"));
+    WLAN_OS_REPORT(("currentPreamble                     = %d\n\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentPreambleType));
+    WLAN_OS_REPORT(("currentModulation                   = %d\n",  ((ctrlData_t *)hCtrlData)->ctrlDataCurrentModulationType));
+    WLAN_OS_REPORT(("ctrlDataCurrentBasicModulationType  = %d\n",  ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBasicModulationType));
+    WLAN_OS_REPORT(("ctrlDataCurrentBasicRate            = %d\n",  ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBasicRate));
+    WLAN_OS_REPORT(("ctrlDataBasicRateBitMask            = 0x%X\n",((ctrlData_t *)hCtrlData)->ctrlDataBasicRateBitMask));
+    WLAN_OS_REPORT(("ctrlDataCurrentRateMask             = 0x%X\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentRateMask));
+}  
+
+void ctrlData_printRateAdaptation(TI_HANDLE hCtrlData)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    rateAdaptation_print(pCtrlData->pRateAdaptation);
+}
+#ifdef SUPPORT_4X
+void ctrlData_printFourX(TI_HANDLE hCtrlData)
+{
+    ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+    fourX_printParams(pCtrlData->pFourX);
+}
+#endif
+
+void ctrlData_printCtrlBlock(TI_HANDLE hCtrlData)
+{
+    rateClassClients_e  clientID;
+    txRateClassId_e  TxRateIndex;
+
+    WLAN_OS_REPORT(("    CtrlData BLock    \n"));
+    WLAN_OS_REPORT(("----------------------\n"));
+
+    WLAN_OS_REPORT(("hSiteMgr = 0x%X\n",((ctrlData_t *)hCtrlData)->hSiteMgr));
+    WLAN_OS_REPORT(("hTxData = 0x%X\n",((ctrlData_t *)hCtrlData)->hTxData));
+    WLAN_OS_REPORT(("hWhalCtrl = 0x%X\n",((ctrlData_t *)hCtrlData)->hWhalCtrl));
+    WLAN_OS_REPORT(("hOs = 0x%X\n",((ctrlData_t *)hCtrlData)->hOs));
+    WLAN_OS_REPORT(("hReport = 0x%X\n",((ctrlData_t *)hCtrlData)->hReport));
+
+    WLAN_OS_REPORT(("ctrlDataDeviceMacAddress = 0x%X.0x%X.0x%X.0x%X.0x%X.0x%X. \n", ((ctrlData_t *)hCtrlData)->ctrlDataDeviceMacAddress.addr[0],
+                                                                                    ((ctrlData_t *)hCtrlData)->ctrlDataDeviceMacAddress.addr[1],
+                                                                                    ((ctrlData_t *)hCtrlData)->ctrlDataDeviceMacAddress.addr[2],
+                                                                                    ((ctrlData_t *)hCtrlData)->ctrlDataDeviceMacAddress.addr[3],
+                                                                                    ((ctrlData_t *)hCtrlData)->ctrlDataDeviceMacAddress.addr[4],
+                                                                                    ((ctrlData_t *)hCtrlData)->ctrlDataDeviceMacAddress.addr[5]));
+
+    WLAN_OS_REPORT(("ctrlDataCurrentBSSID = 0x%X.0x%X.0x%X.0x%X.0x%X.0x%X. \n", ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBSSID.addr[0],
+                                                                                ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBSSID.addr[1],
+                                                                                ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBSSID.addr[2],
+                                                                                ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBSSID.addr[3],
+                                                                                ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBSSID.addr[4],
+                                                                                ((ctrlData_t *)hCtrlData)->ctrlDataCurrentBSSID.addr[5]));
+
+    WLAN_OS_REPORT(("ctrlDataRateControlEnable = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataRateControlEnable));
+    WLAN_OS_REPORT(("ctrlDataFourXEnable = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataFourXEnable));
+    WLAN_OS_REPORT(("ctrlDataFourCurrState = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCerruentFourXstate));
+    WLAN_OS_REPORT(("ctrlDataStartStoplinkControlAlg = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataStartStoplinkControlAlg));
+
+    WLAN_OS_REPORT(("ctrlDataCurrentBssType = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentBssType));
+    WLAN_OS_REPORT(("ctrlDataCurrentModulationType = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentModulationType));
+    WLAN_OS_REPORT(("ctrlDataCurrentBasicRate = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentBasicRate));
+
+    WLAN_OS_REPORT(("ctrlDataBasicRateBitMask = 0x%X\n",((ctrlData_t *)hCtrlData)->ctrlDataBasicRateBitMask));
+    WLAN_OS_REPORT(("ctrlDataCurrentRateMask = 0x%X\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentRateMask));
+    
+    WLAN_OS_REPORT(("ctrlDataCurrentBasicModulationType = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentBasicModulationType));
+    WLAN_OS_REPORT(("ctrlDataCurrentPreambleType = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCurrentPreambleType));
+
+    WLAN_OS_REPORT(("Traffic Intensity threshold events status: %s\n", (((ctrlData_t *)hCtrlData)->ctrlDataTrafficIntensityEventsEnabled ? "Enabled" : "Disabled")));
+    WLAN_OS_REPORT(("Traffic Intensity high threshold: %d packets/sec \n", ((ctrlData_t *)hCtrlData)->ctrlDataTrafficIntensityThresholds.uHighThreshold));
+    WLAN_OS_REPORT(("Traffic Intensity low threshold: %d packets/sec \n", ((ctrlData_t *)hCtrlData)->ctrlDataTrafficIntensityThresholds.uLowThreshold));
+    WLAN_OS_REPORT(("Traffic Intensity test interval: %d ms\n", ((ctrlData_t *)hCtrlData)->ctrlDataTrafficIntensityThresholds.TestInterval));
+
+    for (clientID = (rateClassClients_e)0 ; clientID < NUM_OF_RATE_CLASS_CLIENTS ; clientID++)
+    {
+        WLAN_OS_REPORT((" client = %d : bIsClassAvailable = %s currMask = 0x%x nextMask = 0x%x \n",
+             clientID,(TRUE == ((ctrlData_t *)hCtrlData)->bIsClassAvailable[clientID] ? "TRUE" : "FALSE"),
+             ((ctrlData_t *)hCtrlData)->currClientRateMask[clientID],((ctrlData_t *)hCtrlData)->nextClientRateMask[clientID]));
+        WLAN_OS_REPORT(("Policy for client %d (starting from 54): \n",clientID));
+        for (TxRateIndex = txPolicy54; TxRateIndex < MAX_NUM_OF_TX_RATES_IN_CLASS; TxRateIndex++)
+        {
+            WLAN_OS_REPORT(("retries for rate %d = %d\n",TxRateIndex,((ctrlData_t *)hCtrlData)->ctrlDataTxRatePolicy.rateClass[clientID*MAX_NUM_OF_AC].txRate[TxRateIndex]));   
+        }
+        WLAN_OS_REPORT(("Long retry = %d  ,  Short retry = %d\n",
+            ((ctrlData_t *)hCtrlData)->ctrlDataTxRatePolicy.rateClass[clientID].longRetryLimit,((ctrlData_t *)hCtrlData)->ctrlDataTxRatePolicy.rateClass[clientID*MAX_NUM_OF_AC].shortRetryLimit));
+    }
+    WLAN_OS_REPORT(("current used client %d\n",((ctrlData_t *)hCtrlData)->currClientRateID));
+}
+
+void ctrlData_printCtrlCounters(TI_HANDLE hCtrlData)
+{
+    WLAN_OS_REPORT(("    CtrlData Counters    \n"));
+    WLAN_OS_REPORT(("-------------------------\n"));
+    
+    WLAN_OS_REPORT(("icvFailCounter        = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCounters.icvFailCounter));
+    WLAN_OS_REPORT(("keyNotFoundCounter    = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCounters.keyNotFoundCounter));
+    WLAN_OS_REPORT(("MicFailureCounter     = %d\n",((ctrlData_t *)hCtrlData)->ctrlDataCounters.MicFailureCounter));
+}
+
+
+#ifdef TI_DBG
+
+void ctrlData_printClsfrTable ( TI_HANDLE hCtrlData )
+{
+   ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+   Classifier_dbgPrintClsfrTable (pCtrlData->pClsfr);
+}
+
+void ctrlData_clearClsfrTable ( TI_HANDLE hCtrlData )
+{
+   clsfrTypeAndSupport myLocalType;
+   ctrlData_t *pCtrlData = (ctrlData_t *)hCtrlData;
+
+   Classifier_getClsfrType (pCtrlData->pClsfr,&myLocalType);
+   ctrlData_clsfrSetClsfrType (pCtrlData,myLocalType);
+}
+
+#endif
+
+
+/***************************************************************************
+*                           ctrlData_storeTSRateSet                        
+****************************************************************************
+* DESCRIPTION:  This function translates TSRS rates into map of retransmissions
+*               similar to predefined clients rates retransmissions, and stores
+*               in the Ctrl database
+*
+* INPUTS:       pCtrlData - the object
+*               acID
+*               rates array
+*
+* RETURNS:      -
+****************************************************************************/
+static void ctrlData_storeTSRateSet(ctrlData_t *pCtrlData, txDataQosParams_t *tsrsParams)
+{
+    UINT32 rateCount;
+    UINT32 acID, rateID;
+    UINT32 tsrsRequestedMap;
+    rate_e rateNumber;
+    rateClassClients_e clientNumber;
+    txRateClassId_e rate_e_to_txRateClassId_e[DRV_RATE_MAX+1] = 
+    {
+        txPolicy1,  txPolicy1, txPolicy2, txPolicy5_5, txPolicy11,
+        txPolicy22, txPolicy6, txPolicy9, txPolicy12,  txPolicy18,
+        txPolicy24, txPolicy36, txPolicy48, txPolicy54
+    };
+
+    acID = tsrsParams->acID;
+    os_memoryZero(pCtrlData->hOs, 
+                  &(pCtrlData->tsrsParameters[acID]), 
+                  sizeof(pCtrlData->tsrsParameters[acID]));
+
+
+    for (clientNumber = (rateClassClients_e)0; clientNumber < NUM_OF_RATE_CLASS_CLIENTS; clientNumber++) 
+    {
+        tsrsRequestedMap = 0;
+
+        for (rateCount = 0; rateCount < tsrsParams->tsrsArrLen; rateCount++) 
+        {
+            /* Erase Most significant bit in case it was raised to mark nominal PHY rates (& 0x7F) */
+            /* Convert multiplication of 500kb/sec to rate_e and then to txRateClassId_e */
+            /* and update retransmission map in accordance to USER_RATE client definitions */
+            rateNumber = RateNumberToHost((tsrsParams->tsrsArr[rateCount] & 0x7F) >> 1);
+            rateID = rate_e_to_txRateClassId_e[rateNumber];
+
+            /* Update Rate Fallback policy map according to the class predefined policy map */
+            if (pCtrlData->pCurrPolicyClassRatesArray[clientNumber].txRate[rateID] > 0)
+            {
+                pCtrlData->tsrsParameters[acID].policyClassRateMask[clientNumber] |= (1<<(rateNumber-1));
+            }
+            tsrsRequestedMap |= (1<<(rateNumber-1));
+        }
+        /* Update supportedRatesMask according to TSRS rates and rates supported for this class */
+        pCtrlData->tsrsParameters[acID].supportedRatesMask[clientNumber] = 
+            pCtrlData->nextClientRateMask[clientNumber] & tsrsRequestedMap;
+
+        /* Check that Rate Fallback policy map is not empty; if this is a case, ignore pre-defined policy */
+        if (pCtrlData->tsrsParameters[acID].policyClassRateMask[clientNumber] == 0)
+        {
+            pCtrlData->tsrsParameters[acID].policyClassRateMask[clientNumber] = 
+                pCtrlData->tsrsParameters[acID].supportedRatesMask[clientNumber];
+        }
+    }
+}
+
+/***************************************************************************
+*                           ctrlData_getClosestTSRate                          
+****************************************************************************
+* DESCRIPTION:  This function checks if the TSRS is defined for the requested
+*               access category or not; if requested, it chooses from the TSRS
+*               a rate that is as close as possible to the requestede one.
+*
+* INPUTS:       pCtrlData - the object
+*               acID
+*
+* RETURNS:      -
+****************************************************************************/
+static rate_e ctrlData_getClosestTSRate(ctrlData_t *pCtrlData, UINT32 ac, rate_e givenRate)
+{
+    UINT32 tsRate;
+    rate_e resultRate;
+
+    if (pCtrlData->tsrsParameters[ac].supportedRatesMask[pCtrlData->currClientRateID] != 0)
+    {
+        /* From TSRS rates, choose the closest to the basic rate */
+        /* ((1 << givenRate) - 1) gives a map of all rates <= givenRate */
+        /* Logical AND with TSRS supported rates gives a map of supported rates <= givenRate */
+        /* Now just pick the maximal */
+        tsRate = pCtrlData->tsrsParameters[ac].supportedRatesMask[pCtrlData->currClientRateID]
+                    & ((1 << givenRate) - 1);
+        resultRate = calculateMaxSupportedRate(&tsRate);
+
+        if (resultRate == DRV_RATE_INVALID)
+        {
+            return givenRate;
+        }
+        else
+        {
+            return resultRate;
+        }
+    }
+    else
+    {
+        return givenRate;
+    }
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/RateAdaptation.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/RateAdaptation.c
new file mode 100644 (file)
index 0000000..9ca2ce4
--- /dev/null
@@ -0,0 +1,1231 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*   MODULE:  Rate Adaptation.c                                           */
+/*                                                                        */
+/**************************************************************************/
+#include "RateAdaptation.h"
+#include "DataCtrl_Api.h"
+#include "802_11Defs.h"
+#include "osApi.h"
+#include "report.h"
+#include "utils.h"
+#include "EvHandler.h"
+#include "apConn.h"
+
+
+static TI_STATUS rateAdaptationa_rateToIndexInRateMapTable(rateAdaptation_t* pRateAdaptation, 
+                                                                                                                  rate_e rate, UINT8* Index);
+
+static modulationType_e setModulationForRate(rateAdaptation_t  *pRateAdaptation,
+                                                                                        rate_e                         rate,
+                                                                                        modulationType_e       modulation,
+                                                                                        bssType_e                      bssType);
+
+BOOL rateAdaptation_isRateInTable(ctrlData_rateAdapt_t *currTable,
+                                                               rate_e                  rate);
+
+void rateAdaptation_getFallBackStepUp(ctrlData_rateAdapt_t *currTable,
+                                                                               rate_e                  rate,UINT8* FB,UINT8* SU);
+
+static void rateAdaptation_rxTimeOut(TI_HANDLE hRateAdaptation);
+
+static BOOL set4xEnableForRate(rateAdaptation_t*       pRateAdaptation, 
+                                                          rate_e                               rate,
+                                                          BOOL                                 enable4x, 
+                                                          bssType_e                    bssType);
+
+/*************************************************************************
+*                        ctrlData_create                                 
+**************************************************************************
+* DESCRIPTION: This function create the rateAdaptation module.                 
+*                                                      
+* INPUT:               hOs - handle to Os Abstraction Layer
+*                              
+* OUTPUT:      
+*
+* RETURN:              Handle to the allocated rateAdaptation block
+************************************************************************/
+
+rateAdaptation_t* rateAdaptation_create(TI_HANDLE hOs)
+{
+       rateAdaptation_t* pRateAdaptation;
+       void                    *pTimer;
+
+       if( hOs == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: rateAdaptation_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       /* alocate RateAdaptation block */
+       pRateAdaptation = os_memoryAlloc(hOs, (sizeof(rateAdaptation_t)));
+       if(!pRateAdaptation)
+               return NULL;
+
+       /* alocate Timer to use in PowerSave algorithm */
+       pTimer = os_timerCreate(hOs, rateAdaptation_rxTimeOut, pRateAdaptation);
+
+       if (!pTimer)
+       {
+               utils_nullMemoryFree(hOs, pRateAdaptation, sizeof(rateAdaptation_t));
+           WLAN_OS_REPORT(("FATAL ERROR: rateAdaptation_create(): Error Creating rateAdaptation Module - Aborting\n"));
+               return NULL;
+       }
+
+
+       /* reset RateAdaptation module block */
+       os_memoryZero(hOs, pRateAdaptation, (sizeof(rateAdaptation_t)));
+
+       pRateAdaptation->pTimer = pTimer;
+
+       pRateAdaptation->hOs = hOs;
+
+       return(pRateAdaptation);
+
+}
+
+/***************************************************************************
+*                                              rateAdaptation_config                                          
+****************************************************************************
+* DESCRIPTION: This function initialize the Rate Adaptation algorithm
+*
+* INPUTS:              pRateAdaptation - the object
+*                              hOs - Handle to the Os Abstraction Layer
+*                              hReport - Handle to the Report object
+*                              rateAdaptationInitParam - pointer to Rate Adaptation
+*                                                                                module init parameters
+*
+* OUTPUT:                      
+* 
+* RETURNS:             void
+***************************************************************************/
+TI_STATUS rateAdaptation_config(rateAdaptation_t*                      pRateAdaptation, 
+                                                               TI_HANDLE                                       hOs, 
+                                                               TI_HANDLE                                       hReport, 
+                                                               TI_HANDLE                                       hCtrlData, 
+                                TI_HANDLE                                      hEvHandler,
+                                                               TI_HANDLE                                       hAPConnection,
+                                                               rateAdaptationInitParam_t*      rateAdaptationInitParam)
+{
+
+       UINT32 i;
+
+       if( (pRateAdaptation == NULL)  || (hOs == NULL) || 
+               (hReport == NULL) ||  (rateAdaptationInitParam == NULL) )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: rateAdaptation_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+
+       pRateAdaptation->hOs = hOs;
+       pRateAdaptation->hReport = hReport;
+       pRateAdaptation->hCtrlData = hCtrlData;
+    pRateAdaptation->hEvHandler = hEvHandler;
+       pRateAdaptation->hAPConnection = hAPConnection;
+
+       pRateAdaptation->contTxPacketsThreshold = rateAdaptationInitParam->contTxPacketsThreshold; 
+       pRateAdaptation->stepUpTxPacketsThreshold = rateAdaptationInitParam->stepUpTxPacketsThreshold; 
+       pRateAdaptation->ctrlDataFBShortInterval = rateAdaptationInitParam->ctrlDataFBShortInterval;
+       pRateAdaptation->ctrlDataFBLongInterval = rateAdaptationInitParam->ctrlDataFBLongInterval;
+       pRateAdaptation->lowRateThreshold = DEF_LOW_RATE_THRESHOLD;
+
+       pRateAdaptation->rateAdapt_timeout = 1000*rateAdaptationInitParam->rateAdapt_timeout;
+
+       pRateAdaptation->txCount = 0;
+       pRateAdaptation->txSkipCount = 0;
+       pRateAdaptation->txFailCount = 0;
+    pRateAdaptation->txRateFallBackCount = 0;
+
+       pRateAdaptation->stepUpFlag = FALSE;
+
+       /* resset Tspecs Rate Parameters */
+       for(i = 0 ; i < MAX_NUM_OF_AC ; i++)
+       {
+               pRateAdaptation->tspecsRateParameters[i].enableEvent = FALSE;
+               if(rateAdaptationInitParam->tspecsRateParameters[i].highRateThreshold < rateAdaptationInitParam->tspecsRateParameters[i].lowRateThreshold)
+               {
+                       WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                                       (" rateAdaptation_config() ERROR: highRateThreshold < lowRateThreshold,  ac = %d\n",i));
+
+                       pRateAdaptation->tspecsRateParameters[i].highRateThreshold = 0;
+                       pRateAdaptation->tspecsRateParameters[i].lowRateThreshold = 0;
+               
+               }
+               /* if either one of the threshold is zero all threshold should be with zero default value */
+               else if( (rateAdaptationInitParam->tspecsRateParameters[i].highRateThreshold == 0) ||
+                                (rateAdaptationInitParam->tspecsRateParameters[i].lowRateThreshold == 0))
+               {
+                       pRateAdaptation->tspecsRateParameters[i].highRateThreshold = 0;
+                       pRateAdaptation->tspecsRateParameters[i].lowRateThreshold = 0;
+               }
+               else
+               {
+                       pRateAdaptation->tspecsRateParameters[i].highRateThreshold = rateAdaptationInitParam->tspecsRateParameters[i].highRateThreshold;
+                       pRateAdaptation->tspecsRateParameters[i].lowRateThreshold = rateAdaptationInitParam->tspecsRateParameters[i].lowRateThreshold;
+               }
+       }
+
+       WLAN_REPORT_INFORMATION(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,  
+                       (" Rate Adaptation initialize success\n"));
+
+       return OK;
+
+}
+
+/***************************************************************************
+*                                                      rateAdaptation_destroy                                     
+****************************************************************************
+* DESCRIPTION: This function destroy the rateAdaptation object. 
+* 
+* INPUTS:              rateAdaptation - the object
+* 
+* RETURNS:             OK - Unload succesfull
+*                              NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS rateAdaptation_destroy(rateAdaptation_t* pRateAdaptation)    
+{
+
+       /* check parameters validity */
+       if( pRateAdaptation == NULL )
+       {
+               WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                       (" rateAdaptation_destroy() : parametrs value error \n"));
+               return NOK;
+       }
+
+       /* free timer */
+       os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
+       utils_nullTimerDestroy(pRateAdaptation->hOs, pRateAdaptation->pTimer);
+
+
+       /* free rateAdaptation block */
+       os_memoryFree(pRateAdaptation->hOs, pRateAdaptation, sizeof(rateAdaptation_t));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                                      rateAdaptation_rxTimeOut                                   
+****************************************************************************
+* DESCRIPTION: 
+****************************************************************************/
+
+static void rateAdaptation_rxTimeOut(TI_HANDLE hRateAdaptation)
+{
+   rateAdaptation_t* pRateAdaptation = (rateAdaptation_t *) hRateAdaptation;
+       UINT8           prevIndex = pRateAdaptation->currRateIndex,i;
+       OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS     tspecRateCross;
+
+       os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
+       os_timerStart(pRateAdaptation->hOs, pRateAdaptation->pTimer,pRateAdaptation->rateAdapt_timeout,FALSE);
+
+       pRateAdaptation->txCount = 0;
+       pRateAdaptation->txSkipCount = 0;
+       pRateAdaptation->txFailCount = 0;
+    pRateAdaptation->txRateFallBackCount = 0;
+       pRateAdaptation->currRateIndex = pRateAdaptation->maxRateIndex;
+
+       
+       /* update OS with the current rate */
+       if(prevIndex != pRateAdaptation->currRateIndex)
+       {
+               UINT32                                  statusData;
+               paramInfo_t                             param;
+
+           pRateAdaptation->expirTimeTick = os_timeStampMs(pRateAdaptation->hOs) + pRateAdaptation->ctrlDataFBShortInterval;
+           pRateAdaptation->stepUpFlag = TRUE;
+
+        WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                       (" RateAdapt() : Time: %d, (60sec) OldRate(Index,Rate): %d,%d, NewRate(Index,Rate): %d,%d\n",
+            os_timeStampMs(pRateAdaptation->hOs),
+                       prevIndex,pRateAdaptation->RatesMap[prevIndex].rateNumber,
+                       pRateAdaptation->currRateIndex, pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber ));
+
+        /* update OS with the current rate */
+               param.paramType = CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM;
+               param.content.ctrlDataCerruentFourXstate = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].fourXEnable;
+               ctrlData_setParam(pRateAdaptation->hCtrlData, &param);
+
+       /* update OS with the current rate */
+
+               statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
+
+        EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
+               
+               /* send Tspecs Rate Event */
+               for(i = 0 ; i < MAX_NUM_OF_AC ; i++)
+               {
+                       if(pRateAdaptation->tspecsRateParameters[i].enableEvent == FALSE)
+                       {
+                               continue;
+                       }
+                       else
+                       {
+                               if( ((pRateAdaptation->RatesMap[prevIndex].rateNumber) < (pRateAdaptation->tspecsRateParameters[i].highRateThreshold)) &&
+                                       (pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber >= (pRateAdaptation->tspecsRateParameters[i].highRateThreshold)) )
+                               {
+                                       tspecRateCross.uAC = i;
+                                       tspecRateCross.uHighOrLowThresholdFlag = HIGH_THRESHOLD_CROSS;
+                    tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
+                                       EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(tspecRateCross));
+                               }
+                else
+                if( ((pRateAdaptation->RatesMap[prevIndex].rateNumber) < (pRateAdaptation->tspecsRateParameters[i].lowRateThreshold)) &&
+                                               (hostRateToNumber((rate_e)pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber) >= (pRateAdaptation->tspecsRateParameters[i].lowRateThreshold)) )
+                                       {
+                                               tspecRateCross.uAC = i;
+                                               tspecRateCross.uHighOrLowThresholdFlag = LOW_THRESHOLD_CROSS;
+                        tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
+                                               EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+                                       }
+
+                       }
+               }
+       }
+    else {
+        /* no change */
+        pRateAdaptation->expirTimeTick = os_timeStampMs(pRateAdaptation->hOs) + pRateAdaptation->ctrlDataFBLongInterval;
+           pRateAdaptation->stepUpFlag = FALSE;
+    }
+
+}
+/***************************************************************************
+*                                                      rateAdaptation_getCurrent                                  
+****************************************************************************
+* DESCRIPTION: get current state - Rate and Modulation
+*               Note: since a pointer to the rates map is returned,
+*               Its content should be treated as READ ONLY!!!                
+****************************************************************************/
+rateModulation4x_table_t* rateAdaptation_getCurrent(rateAdaptation_t* pRateAdaptation) 
+{
+    return &(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex]);
+}
+               
+/***************************************************************************
+*                                              rateAdaptation_getCurrentRate                          
+****************************************************************************
+* DESCRIPTION: get current Rate 
+****************************************************************************/
+rate_e rateAdaptation_getCurrentRate(rateAdaptation_t* pRateAdaptation)        
+{
+       return pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate;
+}      
+       
+/***************************************************************************
+*                                      rateAdaptation_getCurrentModulation                            *
+****************************************************************************
+* DESCRIPTION: get current Modulation
+****************************************************************************/
+modulationType_e rateAdaptation_getCurrentModulation(rateAdaptation_t* pRateAdaptation)        
+{
+       return pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].modulation;
+}              
+
+/***************************************************************************
+*                                      rateAdaptation_getCurrentFourXEnable                   *
+****************************************************************************
+* DESCRIPTION: get current fourx status
+****************************************************************************/
+BOOL rateAdaptation_getCurrentFourXEnable(rateAdaptation_t* pRateAdaptation)   
+{
+       return pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].fourXEnable;
+}
+
+/***************************************************************************
+*                                      rateAdaptation_buildRateMapTable                               *
+****************************************************************************
+* DESCRIPTION: build the rate map table
+****************************************************************************/
+TI_STATUS rateAdaptation_buildRateMapTable(rateAdaptation_t            *pRateAdaptation,
+                                                                                                  ctrlData_rateAdapt_t *currTable,
+                                                                                                  UINT32                               supportedBitMap,
+                                                                                                  UINT32                               clientBitMap,
+                                                                                                  modulationType_e             modulation,
+                                                                                                  BOOL                                 enable4x,
+                                                                                                  bssType_e                    bssType)
+{
+       UINT8 i = 0;
+       UINT8 index = 0;
+       UINT32                                  statusData;
+       UINT8 fallBack,stepUp;
+
+       /* 
+       Note : allRates[] is changed due to the fact that rate_e was set in the 
+       wrong order : 6,9 were in higher numeric value then 5.5 and 11 !!!
+        */
+       rate_e  allRates[] =   {DRV_RATE_1M,
+                                                       DRV_RATE_2M,
+                                                       DRV_RATE_5_5M,
+                                                       DRV_RATE_6M,
+                                                       DRV_RATE_9M,
+                                                       DRV_RATE_11M,
+                                                       DRV_RATE_12M,
+                                                       DRV_RATE_18M,
+                                                       DRV_RATE_22M,
+                                                       DRV_RATE_24M,
+                                                       DRV_RATE_36M,
+                                                       DRV_RATE_48M,
+                                                       DRV_RATE_54M
+       };
+
+       while(i < DRV_RATE_MAX)
+       {
+               if(rateAdaptation_Utils_IsRateInBitmap(pRateAdaptation,
+                                                                                         supportedBitMap,
+                                                                                         allRates[i]) == OK)
+               {
+                       /* update rates parameters */
+                       pRateAdaptation->RatesMap[index].rate = allRates[i];
+                       pRateAdaptation->RatesMap[index].rateNumber = hostRateToNumber(allRates[i]);
+
+                       if((rateAdaptation_isRateInTable(currTable,pRateAdaptation->RatesMap[index].rate)) &&
+                               (rateAdaptation_Utils_IsRateInBitmap(pRateAdaptation,
+                                                                                                       clientBitMap,
+                                                                                                       allRates[i]) == OK))
+                       {
+                               pRateAdaptation->RatesMap[index].valid = TRUE;
+                               rateAdaptation_getFallBackStepUp(currTable,pRateAdaptation->RatesMap[index].rate,&fallBack,&stepUp);
+                               pRateAdaptation->RatesMap[index].rateAdaptFallBack = fallBack;
+                               pRateAdaptation->RatesMap[index].rateAdaptStepUp = stepUp;
+                               
+                               /* update modulation parameter */
+                               pRateAdaptation->RatesMap[index].modulation = setModulationForRate(pRateAdaptation,
+                                                                                                                                                                  pRateAdaptation->RatesMap[index].rate,
+                                                                                                                                                                  modulation,bssType);
+
+                               /* update 4x enable parameter */
+                               pRateAdaptation->RatesMap[index].fourXEnable = set4xEnableForRate(pRateAdaptation,
+                                                                                                                                                                 pRateAdaptation->RatesMap[index].rate,
+                                                                                                                                                                 enable4x, bssType);
+
+                               pRateAdaptation->maxRateIndex = index;
+                               pRateAdaptation->currRateIndex = index;
+                       }
+                       else
+                       {
+                               pRateAdaptation->RatesMap[index].valid = FALSE;
+                               pRateAdaptation->RatesMap[index].modulation = setModulationForRate(pRateAdaptation,
+                                                                                                                                                                  pRateAdaptation->RatesMap[index].rate,
+                                                                                                                                                                  modulation,bssType);
+                       }
+
+                       index++;
+               }
+
+               i++;
+       }
+
+       /* report the current rate to OS */
+       statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
+
+    EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
+
+       return OK;
+}              
+
+/***************************************************************************
+*                                                      buildRateBitMap                                                *
+****************************************************************************
+* DESCRIPTION: 
+****************************************************************************/
+
+UINT32 rateAdaptation_Utils_buildRateBitMap(rateAdaptation_t   *pRateAdaptation,
+                                                                                       ctrlData_rateAdapt_t *currTable,
+                                                                                       rate_e                  rate,
+                                                                                       UINT32                  supportedBitMap,
+                                                                                       UINT32                  clientBitMap)
+{
+       UINT32 buildRateBitMap = 0;
+       UINT8 rateNumber = hostRateToNumber(rate);
+
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_1M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_1M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_1_BARKER);
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_2M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_2M) ) )  buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_2_BARKER);
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_5_5M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_5_5M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_5_5_CCK); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_11M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_11M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_11_CCK); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_22M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_22M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_22_PBCC); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_6M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_6M) ) )  buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_6_OFDM); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_9M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_9M) ) )  buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_9_OFDM); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_12M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_12M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_12_OFDM); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_18M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_18M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_18_OFDM); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_24M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_24M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_24_OFDM); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_36M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_36M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_36_OFDM);
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_48M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_48M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_48_OFDM); 
+       if( (rateNumber >= hostRateToNumber(DRV_RATE_54M)) && (rateAdaptation_isRateInTable(currTable, DRV_RATE_54M) ) ) buildRateBitMap |= (clientBitMap & supportedBitMap & DRV_RATE_MASK_54_OFDM);
+       
+       return buildRateBitMap;
+}
+
+/***************************************************************************
+*                                                      rateAdaptation_isRateInTable                                                   *
+****************************************************************************
+* DESCRIPTION: check if a specific rate is in a rates table 
+****************************************************************************/
+
+BOOL rateAdaptation_isRateInTable(ctrlData_rateAdapt_t *currTable,
+                                                                               rate_e                  rate)
+{
+       UINT8 i = 0;
+
+       while(i <= currTable->len)
+       {
+               if(currTable->rateAdaptRatesTable[i++] == rate)
+                       return TRUE;
+       }
+       return FALSE;
+}
+
+/***************************************************************************
+*                                                      rateAdaptation_getFallBackStepUp                                                       *
+****************************************************************************
+* DESCRIPTION: return Fall Back & Step UP values of a certain rate 
+****************************************************************************/
+
+void rateAdaptation_getFallBackStepUp(ctrlData_rateAdapt_t *currTable,
+                                                                               rate_e                  rate,UINT8* FB,UINT8* SU)
+{
+       UINT8 i = 0;
+
+       while(i <= currTable->len)
+       {
+               if(currTable->rateAdaptRatesTable[i++] == rate)
+               {
+                       *FB = currTable->rateAdaptFBTable[--i];
+                       *SU = currTable->rateAdaptSUTable[i];
+                       return;
+               }
+       }
+
+       *FB = 0;
+       *SU = 0;
+}
+
+
+/***************************************************************************
+*                                                      IsRateInBitmap                                                 *
+****************************************************************************
+* DESCRIPTION: check if a specific rate is in a rates bitmap 
+****************************************************************************/
+TI_STATUS rateAdaptation_Utils_IsRateInBitmap(rateAdaptation_t *pRateAdaptation,
+                                                                                       UINT32                          ratesBitMap,
+                                                                                       rate_e                          rate)
+{
+       if( ( (rate == DRV_RATE_1M) && (ratesBitMap & DRV_RATE_MASK_1_BARKER) )||
+               ( (rate == DRV_RATE_2M) && (ratesBitMap & DRV_RATE_MASK_2_BARKER) ) ||
+               ( (rate == DRV_RATE_5_5M) && (ratesBitMap & DRV_RATE_MASK_5_5_CCK) ) ||
+               ( (rate == DRV_RATE_11M) && (ratesBitMap & DRV_RATE_MASK_11_CCK) ) ||
+               ( (rate == DRV_RATE_22M) && (ratesBitMap & DRV_RATE_MASK_22_PBCC) ) ||
+               ( (rate == DRV_RATE_6M) && (ratesBitMap & DRV_RATE_MASK_6_OFDM) ) ||
+               ( (rate == DRV_RATE_9M) && (ratesBitMap & DRV_RATE_MASK_9_OFDM) ) ||
+               ( (rate == DRV_RATE_12M) && (ratesBitMap & DRV_RATE_MASK_12_OFDM) ) ||
+               ( (rate == DRV_RATE_18M) && (ratesBitMap & DRV_RATE_MASK_18_OFDM) ) ||
+               ( (rate == DRV_RATE_24M) && (ratesBitMap & DRV_RATE_MASK_24_OFDM) ) ||
+               ( (rate == DRV_RATE_36M) && (ratesBitMap & DRV_RATE_MASK_36_OFDM) ) ||
+               ( (rate == DRV_RATE_48M) && (ratesBitMap & DRV_RATE_MASK_48_OFDM) ) ||
+               ( (rate == DRV_RATE_54M) && (ratesBitMap & DRV_RATE_MASK_54_OFDM) ) )
+       {
+               return OK;
+       }
+
+       return NOK;
+}
+/***************************************************************************
+*                                                      setModulationForRate                                   *
+****************************************************************************
+* DESCRIPTION: set modulation for the rate map table
+****************************************************************************/
+
+static modulationType_e setModulationForRate(rateAdaptation_t  *pRateAdaptation,
+                                                                                        rate_e                         rate,
+                                                                                        modulationType_e       modulation,
+                                                                                        bssType_e                      bssType)
+{
+       switch(rate)
+       {
+               case DRV_RATE_1M:
+                       return DRV_MODULATION_QPSK;
+
+               case DRV_RATE_2M:
+                       return DRV_MODULATION_QPSK;
+
+               case DRV_RATE_5_5M:
+                       if( (modulation == DRV_MODULATION_PBCC) && 
+                               (bssType == BSS_INFRASTRUCTURE) )
+                               return DRV_MODULATION_PBCC;
+                       else
+                               return DRV_MODULATION_CCK;
+
+               case DRV_RATE_11M:
+                       if( (modulation == DRV_MODULATION_PBCC) && 
+                               (bssType == BSS_INFRASTRUCTURE) )
+                               return DRV_MODULATION_PBCC;
+                       else
+                               return DRV_MODULATION_CCK;
+
+               case DRV_RATE_22M:
+                       return DRV_MODULATION_PBCC;
+
+               case DRV_RATE_6M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_9M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_18M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_12M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_24M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_36M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_48M:
+                       return DRV_MODULATION_OFDM;
+
+               case DRV_RATE_54M:
+                       return DRV_MODULATION_OFDM;
+
+               default:
+                       WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,  
+                                               (" setModulationForRate(): unKnown rate !!! \n"));
+                       return DRV_MODULATION_NONE;
+
+       }
+}
+
+static BOOL set4xEnableForRate(rateAdaptation_t*       pRateAdaptation, 
+                                                          rate_e                               rate,
+                                                          BOOL                                 enable4x, 
+                                                          bssType_e                    bssType)
+{
+       if(bssType == BSS_INDEPENDENT)
+               return FALSE;
+
+       switch(rate)
+       {
+               case DRV_RATE_1M:
+                       return FALSE;
+
+               case DRV_RATE_2M:
+                       return FALSE;
+
+               case DRV_RATE_5_5M:
+                       return FALSE;
+
+               case DRV_RATE_11M:
+                       return enable4x;
+
+               case DRV_RATE_22M:
+                       return enable4x;
+
+               case DRV_RATE_6M:
+                       return FALSE;
+
+               case DRV_RATE_9M:
+                       return FALSE;
+
+               case DRV_RATE_18M:
+                       return enable4x;
+
+               case DRV_RATE_12M:
+                       return enable4x;
+
+               case DRV_RATE_24M:
+                       return enable4x;
+
+               case DRV_RATE_36M:
+                       return enable4x;
+
+               case DRV_RATE_48M:
+                       return enable4x;
+
+               case DRV_RATE_54M:
+                       return enable4x;
+
+               default:
+                       WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,  
+                                               (" set4xEnableForRate(): unKnown rate !!! \n"));
+                       return DRV_MODULATION_NONE;
+
+       }
+
+
+}
+/***************************************************************************
+*                                      rateAdaptation_setMaxActivRate                         
+****************************************************************************
+* DESCRIPTION: set current rate
+****************************************************************************/
+TI_STATUS rateAdaptation_setMaxActivRate(rateAdaptation_t* pRateAdaptation, rate_e rate)       
+{
+       UINT8  index;
+       UINT32 status;
+
+       status = rateAdaptationa_rateToIndexInRateMapTable(pRateAdaptation, rate, &index);
+       
+       if(status != OK)
+               return NOK;
+
+       pRateAdaptation->maxRateIndex = index;
+
+       return OK;
+}
+
+/***************************************************************************
+*                                      rateAdaptation_configLowRateThrsh                              
+****************************************************************************
+* DESCRIPTION: set low rate threshold
+****************************************************************************/
+TI_STATUS rateAdaptation_configLowRateThrsh(rateAdaptation_t *pRateAdaptation, UINT8 rate)     
+{
+       pRateAdaptation->lowRateThreshold = rate;
+
+       WLAN_REPORT_INFORMATION(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,  
+                       (" \nrateAdaptation_configLowRateThrsh:rate  %d, translated to %d \n", rate, pRateAdaptation->lowRateThreshold));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                      rateAdaptation_updateModulation                        
+****************************************************************************
+* DESCRIPTION: set current rate
+****************************************************************************/
+void rateAdaptation_updateModulation(rateAdaptation_t* pRateAdaptation,
+                                                                        modulationType_e modulation,
+                                                                        bssType_e bssType)
+{
+       UINT8 index = 0;
+
+       for(index = 0 ; index < pRateAdaptation->maxRateIndex ; index++)
+       {
+               pRateAdaptation->RatesMap[index].modulation = setModulationForRate(pRateAdaptation,
+                                                                                                                                                       pRateAdaptation->RatesMap[index].rate,
+                                                                                                                                                       modulation,
+                                                                                                                                                       bssType);
+       }
+}
+/***************************************************************************
+*                                      rateAdaptation_updateModulation                        
+****************************************************************************
+* DESCRIPTION: set current rate
+****************************************************************************/
+void rateAdaptation_update4xEnable(rateAdaptation_t* pRateAdaptation,
+                                                                  BOOL                          enable4x,
+                                                                  bssType_e             bssType)
+{
+       UINT8 index = 0;
+
+       for(index = 0 ; index < pRateAdaptation->maxRateIndex ; index++)
+       {
+               pRateAdaptation->RatesMap[index].fourXEnable = set4xEnableForRate(pRateAdaptation,
+                                                                                                                                                 pRateAdaptation->RatesMap[index].rate,
+                                                                                                                                                 enable4x, bssType);
+       }
+}
+/***************************************************************************
+*                                              ctrlData_rateAdaptationStart                                   
+****************************************************************************
+* DESCRIPTION: This function start the Rate Adaptation algorithm
+***************************************************************************/
+TI_STATUS rateAdaptation_start(rateAdaptation_t* pRateAdaptation)
+{
+       UINT32                                  statusData;
+
+       pRateAdaptation->txCount = 0;
+       pRateAdaptation->txSkipCount = 0;
+       pRateAdaptation->txFailCount = 0;
+    pRateAdaptation->txRateFallBackCount = 0;
+
+       pRateAdaptation->stepUpFlag = FALSE;
+
+       os_timerStart(pRateAdaptation->hOs, pRateAdaptation->pTimer,pRateAdaptation->rateAdapt_timeout,FALSE);
+
+       pRateAdaptation->expirTimeTick = os_timeStampMs(pRateAdaptation->hOs) + pRateAdaptation->ctrlDataFBLongInterval;
+
+       /* update OS with the current rate */
+       statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
+
+    EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                              ctrlData_rateAdaptationStop                                            
+****************************************************************************
+* DESCRIPTION: This function stop the rate adaptation algorithm
+***************************************************************************/
+TI_STATUS rateAdaptation_stop(rateAdaptation_t* pRateAdaptation)
+{
+       os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
+
+       pRateAdaptation->txCount = 0;
+       pRateAdaptation->txSkipCount = 0;
+       pRateAdaptation->txFailCount = 0;
+    pRateAdaptation->txRateFallBackCount = 0;
+       pRateAdaptation->stepUpFlag = FALSE;
+       pRateAdaptation->expirTimeTick = 0;
+
+       pRateAdaptation->currRateIndex = pRateAdaptation->maxRateIndex;
+
+
+       return OK;
+}
+
+/***************************************************************************
+*                                              rateAdaptation_stopTimer                                               
+****************************************************************************
+* DESCRIPTION: This function stop the rate adaptation timer
+***************************************************************************/
+TI_STATUS rateAdaptation_stopTimer(rateAdaptation_t* pRateAdaptation)
+{
+       os_timerStop(pRateAdaptation->hOs, pRateAdaptation->pTimer);
+
+       return OK;
+}
+
+
+/***************************************************************************
+*                                      rateAdaptation_setCurrentRate                          
+****************************************************************************
+* DESCRIPTION: set current rate
+****************************************************************************/
+TI_STATUS rateAdaptation_setCurrentRate(rateAdaptation_t* pRateAdaptation,rate_e rate)
+{
+       UINT8                                   index;
+       UINT32                                  statusData;
+
+       if(rateAdaptationa_rateToIndexInRateMapTable(pRateAdaptation, rate, &index) == OK)
+               pRateAdaptation->currRateIndex = index;
+       else
+               pRateAdaptation->currRateIndex = pRateAdaptation->maxRateIndex;
+
+       /* report the current rate to OS */
+
+       statusData = hostToUtilityRate(pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate);
+
+    EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
+
+       return OK;
+}
+
+/***************************************************************************
+*                                      ctrlData_rateToIndexInRateMapTable                                     
+****************************************************************************
+* DESCRIPTION: This function convert a specific rate to index in the 
+*                              Rate Adaptation algorithm ratemap table
+*
+* INPUTS:              pRateAdaptation - the object
+*                              rate - the rate to convert
+*
+* OUTPUT:              Index - the index of the rate in the table.     
+* 
+* RETURNS:             If the rate is not in the table - return NOK otherwise OK
+***************************************************************************/
+static TI_STATUS rateAdaptationa_rateToIndexInRateMapTable(rateAdaptation_t* pRateAdaptation, 
+                                                                                                                  rate_e rate, UINT8* Index)
+{
+       UINT8 i;
+
+       for(i = 0 ; i <= pRateAdaptation->maxRateIndex ; i++)
+       {
+               if(pRateAdaptation->RatesMap[i].rate == rate)
+               {
+                       *Index = i;
+                       return OK;
+               }
+       }
+
+       return NOK;
+}
+
+/***************************************************************************
+*                                      getPrevRate                                            
+****************************************************************************
+* DESCRIPTION: 
+*
+* INPUTS:              pRateAdaptation - the object
+*
+* RETURNS:             new rate
+****************************************************************************/
+UINT8 getPrevRate(rateAdaptation_t *pRateAdaptation)
+{
+    INT16 i;
+    if(pRateAdaptation->currRateIndex != 0)
+    {
+        for(i = pRateAdaptation->currRateIndex - 1; i > 0; i--)
+        {
+            if(pRateAdaptation->RatesMap[i].valid)
+                return (UINT8)i;
+        }
+    }
+    return pRateAdaptation->currRateIndex;
+}
+
+
+/***************************************************************************
+*                                      getNextRate                                            
+****************************************************************************
+* DESCRIPTION: 
+*
+* INPUTS:              pRateAdaptation - the object
+*
+* RETURNS:             new rate
+****************************************************************************/
+UINT8 getNextRate(rateAdaptation_t *pRateAdaptation)
+{
+       UINT32 i;
+
+       for(i = pRateAdaptation->currRateIndex + 1; i <= pRateAdaptation->maxRateIndex; i++)
+       {
+               if(pRateAdaptation->RatesMap[i].valid)
+                       return i;
+       }
+
+       return pRateAdaptation->currRateIndex;
+}
+
+/***************************************************************************
+*                                      rateAdaptation_updateRateAdaptation                                            
+****************************************************************************
+* DESCRIPTION: This function perform the Rate Adaptation algorithm. It
+*                              called for every tx complete.
+*
+* INPUTS:              pRateAdaptation - the object
+*                              actualTxRate - the actual tx rate
+*                              requestTxRate - the request tx rate
+*                              TxStatus - the tx status
+*               txNumWaiting - the number of descriptors in the HW with previous rate
+*
+* RETURNS:             OK/NOK
+****************************************************************************/
+TI_STATUS rateAdaptation_updateRateAdaptation(rateAdaptation_t* pRateAdaptation,
+                                                                                         rate_e                        actualTxRate, 
+                                                                                         rate_e                        requestTxRate, 
+                                                                                         UINT32                        TxStatus,
+                                              int               txNumWaiting)
+{
+       
+       UINT32          txFailPercent;
+       UINT32          timeStamp;
+       UINT8           actualTxRateNumber = hostRateToNumber(actualTxRate);
+       UINT8           requestTxRateNumber = hostRateToNumber(requestTxRate);
+       OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS     tspecRateCross;
+       UINT8           i,prevIndex = pRateAdaptation->currRateIndex;
+
+    /* Check if need to skip some packets due to rate update */
+    if (pRateAdaptation->txSkipCount > 0) {
+        pRateAdaptation->txSkipCount--;
+        return OK;
+    }
+
+    timeStamp = os_timeStampMs(pRateAdaptation->hOs);
+       
+       pRateAdaptation->txCount++;
+
+    /* if the TxStatus wasn't SUCCESS or the rate was falling back - we will update the mechanism, unless */
+       /* the TxStatus is LIFETIME_EXCEEDED and there were no retries - we won't update the mechanism        */
+       if(((TxStatus != SEND_COMPLETE_SUCCESS) && (TxStatus != SEND_COMPLETE_LIFETIME_EXCEEDED)) 
+        || (actualTxRateNumber < requestTxRateNumber)) 
+       {
+               pRateAdaptation->txFailCount++;
+        if (actualTxRateNumber < requestTxRateNumber)
+           pRateAdaptation->txRateFallBackCount++;
+       }
+
+       /* Verify if the checking time has come. */
+       if( TS_EXCEEDS(timeStamp, pRateAdaptation->expirTimeTick) )
+       {
+               /* If step up has just done wait for 10 packets only. */ 
+               if((pRateAdaptation->stepUpFlag == TRUE) && 
+                       (pRateAdaptation->txCount > pRateAdaptation->stepUpTxPacketsThreshold ))
+               {
+                       /* Calculate the packet fail percent. */
+                       txFailPercent = (pRateAdaptation->txFailCount * 100) / pRateAdaptation->txCount;
+                       
+                       pRateAdaptation->stepUpFlag = FALSE; /* Flag is off for next time. */
+                       
+                       if( (txFailPercent > pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateAdaptFallBack) && 
+                               (pRateAdaptation->currRateIndex > 0) )
+                       {
+                               pRateAdaptation->currRateIndex = getPrevRate(pRateAdaptation);
+                       }
+               }
+               else if (pRateAdaptation->txCount > pRateAdaptation->contTxPacketsThreshold )
+               { 
+                       /* Calculate the packet fail percents. */
+                       txFailPercent = (pRateAdaptation->txFailCount * 100) / pRateAdaptation->txCount;
+                       
+                       if ( (txFailPercent > pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateAdaptFallBack) && 
+                               (pRateAdaptation->currRateIndex > 0) )
+                       {
+                pRateAdaptation->currRateIndex = getPrevRate(pRateAdaptation);
+                       }
+                       else if ((txFailPercent < pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateAdaptStepUp) && 
+                               (pRateAdaptation->currRateIndex < pRateAdaptation->maxRateIndex))
+                       {
+                               pRateAdaptation->currRateIndex = getNextRate(pRateAdaptation);
+                               pRateAdaptation->stepUpFlag = TRUE; /* Flag is on for next time. */
+                       }
+               } 
+               else
+               {
+                       return OK;
+               }
+               
+               /* update OS with the current rate */
+               if(prevIndex != pRateAdaptation->currRateIndex)
+               {
+                       UINT32                  statusData;
+                       paramInfo_t             param;
+                       rate_e                  currentRate = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rate;
+                       UINT8                   currentRateNumber = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber;
+
+                   WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                           (" RateAdapt() : Time: %d, Fail: %d, Count: %d,Skip: %d\n",
+                timeStamp,pRateAdaptation->txFailCount,pRateAdaptation->txCount,txNumWaiting));
+                       
+                       WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                           (" OldRate(Index,Rate): %d,%d\n ",prevIndex,pRateAdaptation->RatesMap[prevIndex].rateNumber));
+                       WLAN_REPORT_WARNING(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                               (" NewRate(Index,Rate): %d,%d\n ",pRateAdaptation->currRateIndex,currentRateNumber));
+
+                       /* If the current rate is lower or equal to the roaming threshold, issue roaming trigger. */
+                       if (currentRateNumber <= pRateAdaptation->lowRateThreshold)
+                       {
+                               roamingEventData_u RoamingEventData;
+
+                               RoamingEventData.rate = currentRate;
+                               apConn_reportRoamingEvent(pRateAdaptation->hAPConnection, ROAMING_TRIGGER_LOW_TX_RATE, &RoamingEventData);
+                       }
+            
+                       /* Rate update - initialize the skip counter for packets that are already in the queue with old rates */
+            if ((txNumWaiting >= 0) && (txNumWaiting <= 100)) {
+                /* In reasonable range */
+                pRateAdaptation->txSkipCount = (UINT32)txNumWaiting;
+            } else {
+                pRateAdaptation->txSkipCount = 30; /* something happened, at least skip 30 packets */
+            }
+
+               /* update OS with the current rate */
+                       param.paramType = CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM;
+                       param.content.ctrlDataCerruentFourXstate = pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].fourXEnable;
+                       ctrlData_setParam(pRateAdaptation->hCtrlData, &param);
+
+               /* update OS with the current rate */
+
+                       statusData = hostToUtilityRate(currentRate);
+
+            EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
+
+                       /* send Tspecs Rate Event */
+                       for(i = 0 ; i < MAX_NUM_OF_AC ; i++)
+                       {
+                               if(pRateAdaptation->tspecsRateParameters[i].enableEvent == FALSE)
+                               {
+                                       continue;
+                               }
+                               else
+                               {
+                                       if ( (pRateAdaptation->RatesMap[prevIndex].rateNumber < pRateAdaptation->tspecsRateParameters[i].highRateThreshold) &&
+                                               (currentRateNumber >= pRateAdaptation->tspecsRateParameters[i].highRateThreshold) )
+                                       {
+                                               tspecRateCross.uAC = i;
+                                               tspecRateCross.uHighOrLowThresholdFlag = HIGH_THRESHOLD_CROSS;
+                        tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
+                                               EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+                                       }
+                                       else
+                                       if( (pRateAdaptation->RatesMap[prevIndex].rateNumber >= pRateAdaptation->tspecsRateParameters[i].highRateThreshold) &&
+                                               (currentRateNumber < pRateAdaptation->tspecsRateParameters[i].highRateThreshold) )
+                                       {
+                                               tspecRateCross.uAC = i;
+                                               tspecRateCross.uHighOrLowThresholdFlag = HIGH_THRESHOLD_CROSS;
+                        tspecRateCross.uAboveOrBelowFlag = CROSS_BELOW;
+                                               EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+                                       }
+                    else
+                                       if( (pRateAdaptation->RatesMap[prevIndex].rateNumber >= pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) &&
+                                               (currentRateNumber < pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) )
+                                       {
+                                               tspecRateCross.uAC = i;
+                                               tspecRateCross.uHighOrLowThresholdFlag = LOW_THRESHOLD_CROSS;
+                        tspecRateCross.uAboveOrBelowFlag = CROSS_BELOW;
+                                               EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+                                       }
+                    else
+                                       if( (pRateAdaptation->RatesMap[prevIndex].rateNumber < pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) &&
+                                               (currentRateNumber >= pRateAdaptation->tspecsRateParameters[i].lowRateThreshold) )
+                                       {
+                                               tspecRateCross.uAC = i;
+                                               tspecRateCross.uHighOrLowThresholdFlag = LOW_THRESHOLD_CROSS;
+                        tspecRateCross.uAboveOrBelowFlag = CROSS_ABOVE;
+                                               EvHandlerSendEvent(pRateAdaptation->hEvHandler, IPC_EVENT_TSPEC_RATE_STATUS, (UINT8 *)&tspecRateCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+                                       }
+
+                               }
+                       }
+
+               }
+               
+               pRateAdaptation->txCount = 0;
+               pRateAdaptation->txFailCount = 0;
+        pRateAdaptation->txRateFallBackCount = 0;
+               TS_ADVANCE( timeStamp, pRateAdaptation->expirTimeTick,
+                       (pRateAdaptation->stepUpFlag ? pRateAdaptation->ctrlDataFBShortInterval : pRateAdaptation->ctrlDataFBLongInterval)); 
+
+       }
+       
+       return OK;      
+} 
+
+/***************************************************************************
+*                                      rateAdaptation_setTspecsRateParams                                             
+****************************************************************************
+* DESCRIPTION: 
+*
+* INPUTS:              pRateAdaptation - the object
+**
+* RETURNS:             OK/NOK
+****************************************************************************/
+
+void rateAdaptation_setTspecsRateEvent(rateAdaptation_t* pRateAdaptation,
+                                                                                        UINT8                  acID,
+                                                                                       BOOL                    enableEvent)
+{
+
+   /* Prevent ENABLE_EVENTS if one of the threshold of that AC is ZERO */
+  if (((pRateAdaptation->tspecsRateParameters[acID].highRateThreshold == 0) ||
+        (pRateAdaptation->tspecsRateParameters[acID].lowRateThreshold == 0)) && (enableEvent == TRUE))
+   return;
+
+       pRateAdaptation->tspecsRateParameters[acID].enableEvent = enableEvent;
+}
+
+/***************************************************************************
+*                                      rateAdaptation_setTspecsRateThresholds                                         
+****************************************************************************
+* DESCRIPTION: 
+*
+* INPUTS:              pRateAdaptation - the object
+**
+* RETURNS:             OK/NOK
+****************************************************************************/
+
+void rateAdaptation_setTspecsRateThresholds(rateAdaptation_t* pRateAdaptation,
+                                                                                        UINT8                  acID,
+                                                                                        UINT8                  highRateThreshold,
+                                                                                        UINT8                  lowRateThreshold)
+{      
+               if(highRateThreshold < lowRateThreshold)
+               {
+                       WLAN_REPORT_ERROR(pRateAdaptation->hReport, RATE_ADAPTATION_MODULE_LOG,
+                                       (" rateAdaptation_setTspecsRateThresholds() ERROR: highRateThreshold < lowRateThreshold,  ac = %d\n",acID));
+
+                       pRateAdaptation->tspecsRateParameters[acID].highRateThreshold = 0;
+                       pRateAdaptation->tspecsRateParameters[acID].lowRateThreshold = 0;
+               
+               }
+               else
+               {
+                       pRateAdaptation->tspecsRateParameters[acID].highRateThreshold = highRateThreshold;
+                       pRateAdaptation->tspecsRateParameters[acID].lowRateThreshold = lowRateThreshold;
+               }
+}
+
+
+/*************************************************************************
+ *                                                                                                                                              *
+ *                                                     DEBUG FUNCTIONS                                                          *
+ *                                                                                                                                              *
+ *************************************************************************/
+void rateAdaptation_print(rateAdaptation_t *pRateAdaptation)
+{
+       UINT32 count;
+
+       WLAN_OS_REPORT(("     Rate Adaptation Parameters    \n"));
+       WLAN_OS_REPORT(("-----------------------------------\n"));
+       WLAN_OS_REPORT(("txCount                   = %d\n",pRateAdaptation->txCount));
+       WLAN_OS_REPORT(("txFailCount               = %d\n",pRateAdaptation->txFailCount));
+    WLAN_OS_REPORT(("txRateFallBackCount       = %d\n",pRateAdaptation->txRateFallBackCount));
+       WLAN_OS_REPORT(("txSkipCount               = %d\n",pRateAdaptation->txSkipCount));
+       WLAN_OS_REPORT(("currRateIndex             = %d\n",pRateAdaptation->currRateIndex));
+       WLAN_OS_REPORT(("currRate Number           = %d\n",pRateAdaptation->RatesMap[pRateAdaptation->currRateIndex].rateNumber));
+       WLAN_OS_REPORT(("maxRateIndex              = %d\n",pRateAdaptation->maxRateIndex));
+       WLAN_OS_REPORT(("maxRate Number            = %d\n",pRateAdaptation->RatesMap[pRateAdaptation->maxRateIndex].rateNumber));
+       WLAN_OS_REPORT(("stepUpFlag                = %d\n",pRateAdaptation->stepUpFlag));
+       WLAN_OS_REPORT(("expirTimeTick             = %d\n",pRateAdaptation->expirTimeTick));
+       WLAN_OS_REPORT(("stepUpTxPacketsThreshold  = %d\n",pRateAdaptation->stepUpTxPacketsThreshold));
+       WLAN_OS_REPORT(("contTxPacketsThreshold    = %d\n",pRateAdaptation->contTxPacketsThreshold)); 
+       WLAN_OS_REPORT(("ctrlDataFBShortInterval   = %d\n",pRateAdaptation->ctrlDataFBShortInterval));
+       WLAN_OS_REPORT(("ctrlDataFBLongInterval    = %d\n",pRateAdaptation->ctrlDataFBLongInterval));
+
+       WLAN_OS_REPORT(("    Rate Adaptation Table    \n"));
+       WLAN_OS_REPORT(("-----------------------------\n"));
+       for(count = 0 ; count <  MAX_SUPPORTED_RATES ; count++)
+       {
+               WLAN_OS_REPORT(("Index = %d ,RateNumber = %d,StepUp = %d ,FallBack = %d , Modulation = %d 4X = %d valid = %d,\n",
+                                                                       count, 
+                                                                                 pRateAdaptation->RatesMap[count].rateNumber,
+                                                                                 pRateAdaptation->RatesMap[count].rateAdaptStepUp,
+                                                                                 pRateAdaptation->RatesMap[count].rateAdaptFallBack,
+                                                                                 pRateAdaptation->RatesMap[count].modulation,
+                                                                                 pRateAdaptation->RatesMap[count].fourXEnable,
+                                                                                 pRateAdaptation->RatesMap[count].valid));
+       }
+
+       WLAN_OS_REPORT(("Tspecs Rate Parameters AC = %d  \n",count));
+       WLAN_OS_REPORT(("-----------------------------\n"));
+       for(count = 0 ; count < MAX_NUM_OF_AC ; count++)
+       {
+               WLAN_OS_REPORT(("AC = %d  \n",count));
+               WLAN_OS_REPORT(("---------\n"));
+               WLAN_OS_REPORT(("enableEvent = %d  \n",pRateAdaptation->tspecsRateParameters[count].enableEvent));
+               WLAN_OS_REPORT(("highRateThreshold = %d  \n",pRateAdaptation->tspecsRateParameters[count].highRateThreshold));
+               WLAN_OS_REPORT(("lowRateThreshold = %d  \n",pRateAdaptation->tspecsRateParameters[count].lowRateThreshold));
+       }
+
+
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/Clsfr.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/Clsfr.h
new file mode 100644 (file)
index 0000000..5c3f9b3
--- /dev/null
@@ -0,0 +1,81 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             CLSFRI.H*/
+/**/
+/* Purpose:            This module performs the classification of the MSDU.*/
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef __CLSFR_H__
+#define __CLSFR_H__
+
+#include "paramOut.h"
+#include "memMngrEx.h"
+
+#define CLSFR_MODULE_LOG                               CTRL_DATA_MODULE_LOG
+
+typedef struct
+{
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       clsfr_Params_t          clsfrParameters;
+} classifier_t;
+
+
+classifier_t* Classifier_create(TI_HANDLE hOs);
+
+TI_STATUS Classifier_config(classifier_t* pClsfr, TI_HANDLE hOs, TI_HANDLE hReport, clsfr_Params_t *ClsfrInitParams);
+
+TI_STATUS Classifier_destroy(classifier_t* pClsfr);
+
+TI_STATUS Classifier_classifyTxMSDU(classifier_t* pClsfr, mem_MSDU_T *pMsdu, UINT8 packet_DTag);
+
+TI_STATUS Classifier_InsertClsfrEntry(classifier_t* pClsfr, UINT8 NumberOfEntries, clsfr_tableEntry_t *ConfigBufferPtr);
+
+TI_STATUS classifier_RemoveClsfrEntry(classifier_t* pClsfr, clsfr_tableEntry_t *ConfigBufferPtr);
+
+TI_STATUS Classifier_setClsfrType(classifier_t* pClsfr, clsfr_type_e newClsfrType);  
+
+TI_STATUS Classifier_getClsfrType (classifier_t* pClsfr, clsfrTypeAndSupport *newClsfrType);
+
+TI_STATUS Classifier_deriveUserPriorityFromStream (classifier_t* pClsfr, STREAM_TRAFFIC_PROPERTIES *pStream);
+
+#ifdef TI_DBG
+TI_STATUS Classifier_dbgPrintClsfrTable (classifier_t* pClsfr);
+#endif
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/Ctrl.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/Ctrl.h
new file mode 100644 (file)
index 0000000..514b3bb
--- /dev/null
@@ -0,0 +1,182 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   tx.h                                                       */
+/*    PURPOSE:  Tx module Header file                                      */
+/*                                                                         */
+/***************************************************************************/
+#ifndef _CTRL_H_
+#define _CTRL_H_
+
+#include "osTIType.h"
+#include "paramIn.h"
+#include "paramOut.h"
+#include "rxXfer_api.h"
+#include "RateAdaptation.h"
+#include "Clsfr.h"
+#include "fourX.h"
+
+#define     DEF_CURRENT_PREAMBLE                        PREAMBLE_LONG
+#define     DEF_CURRENT_MUDULATION_TYPE                 DRV_MODULATION_CCK
+#define     DEF_BASIC_RATE                              DRV_RATE_2M
+#define     DEF_BASIC_RATE_MASK                         0x0003
+#define     ALL_RATES_AVAILABLE                         0xFFFFFFFF                      
+
+#define     DEF_RATE_CONTROL_ENABLE                     FALSE
+#define     DEF_START_STOP_LINK_CTRL_ALG                FALSE
+
+typedef enum
+{
+CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_ABOVE,
+CTRL_DATA_TRAFFIC_INTENSITY_HIGH_CROSSED_BELOW,
+CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_ABOVE,
+CTRL_DATA_TRAFFIC_INTENSITY_LOW_CROSSED_BELOW,
+CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS,
+} ctrlData_trafficIntensityEvents_e;
+
+
+#define TS_EXCEEDS(currTime,expTime) (currTime > expTime)
+#define TS_ADVANCE(currTime,expTime,delta) (expTime = currTime + (delta))
+
+typedef struct 
+{
+    UINT32 dbgNumOfMsduFreeInTxComplete[MAX_NUM_OF_TX_QUEUES];
+}ctrlDataDbgCounters_t;
+
+typedef struct 
+{
+    UINT32 supportedRatesMask[NUM_OF_RATE_CLASS_CLIENTS];
+    UINT32 policyClassRateMask[NUM_OF_RATE_CLASS_CLIENTS];
+    UINT32 fwPolicyID[NUM_OF_RATE_CLASS_CLIENTS];
+}tsrsParameters_t;
+
+typedef struct
+{
+    TI_HANDLE           hSiteMgr;
+    TI_HANDLE           hTxData;
+    TI_HANDLE           hRxData;
+    TI_HANDLE           hWhalCtrl;  
+    TI_HANDLE           hOs;
+    TI_HANDLE           hReport;
+    TI_HANDLE           hAPConn;
+    TI_HANDLE           hEvHandler;
+    TI_HANDLE           hTrafficMonitor;
+    TI_HANDLE           hMemMngr;
+    
+
+    rateAdaptation_t*   pRateAdaptation;
+#ifdef SUPPORT_4X
+    fourX_t*            pFourX;
+#endif
+    classifier_t*       pClsfr;
+
+    BOOL                ctrlDataRateControlEnable;
+    BOOL                ctrlDataFourXEnable;    
+    BOOL                ctrlDataCerruentFourXstate; 
+    BOOL                ctrlDataStartStoplinkControlAlg;
+
+    macAddress_t        ctrlDataCurrentBSSID; 
+    bssType_e           ctrlDataCurrentBssType; 
+    UINT32              ctrlDataBasicRateBitMask;
+    UINT32              ctrlDataCurrentRateMask;
+    modulationType_e    ctrlDataCurrentModulationType;
+    rate_e              ctrlDataCurrentBasicRate;
+    modulationType_e    ctrlDataCurrentBasicModulationType; 
+    preamble_e          ctrlDataCurrentPreambleType; 
+    macAddress_t        ctrlDataDeviceMacAddress; 
+
+    BOOL                ctrlDataProtectionEnabled;
+    RtsCtsStatus_e      ctrlDataRtsCtsStatus;
+    erpProtectionType_e ctrlDataIbssProtectionType;
+
+    /* rate adaptation tables */
+    rateTables_t        ctrlDataRateTables;
+    ctrlData_rateAdapt_t* ctrlDataCurrentRateTable;
+
+    /* Control module counters */
+    ctrlDataCounters_t  ctrlDataCounters;
+    /*
+     * txRatePolicy section
+     */
+
+    /* txRatePolicies - here we store the policy and set it to the FW */
+    txRatePolicy_t      ctrlDataTxRatePolicy;
+
+    /* Client supported rates - currently User (all supported) or SG (configured) */
+    UINT32              currClientRateMask[NUM_OF_RATE_CLASS_CLIENTS];
+
+    /* changing supported rates is done in the next array. We use the change only
+        on connection - we copy currClientRateMask = nextClientRateMask */
+    UINT32              nextClientRateMask[NUM_OF_RATE_CLASS_CLIENTS];
+
+    BOOL                bIsClassAvailable[NUM_OF_RATE_CLASS_CLIENTS];
+
+    /* the class ID to use for Tx Data Packets */
+    rateClassClients_e  currClientRateID;
+    /* Saves the last wanted configuration of the Client ID, used when in a connection we get
+        0 supported rates , but in the next connection we get supported rates, thus we use the last one configured */
+    rateClassClients_e  configuredClientRateID;
+    
+    /* number of retries for each rate in each class in the policy that we set to the FW */ 
+    policyClassRatesArray_t policyClassRatesArrayCck  [NUM_OF_RATE_CLASS_CLIENTS];
+    policyClassRatesArray_t policyClassRatesArrayPbcc [NUM_OF_RATE_CLASS_CLIENTS];
+    policyClassRatesArray_t policyClassRatesArrayOfdm [NUM_OF_RATE_CLASS_CLIENTS];
+    policyClassRatesArray_t policyClassRatesArrayOfdmA[NUM_OF_RATE_CLASS_CLIENTS];
+
+    /* holds the current used array */
+    policyClassRatesArray_t *pCurrPolicyClassRatesArray;
+    /* debug counter */
+    ctrlDataDbgCounters_t ctrlDataDbgCounters;
+
+    /* Callback for disassociation notification */
+    disassocSentCB_t    disassocSentCBFunc;
+    TI_HANDLE           disassocSentCBObj;
+
+    /* Flag to indicate whether traffic intensity events should be sent or not */
+    BOOL                ctrlDataTrafficIntensityEventsEnabled;
+    OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS ctrlDataTrafficIntensityThresholds;
+    TI_HANDLE ctrlDataTrafficThresholdEvents[CTRL_DATA_TRAFFIC_INTENSITY_MAX_EVENTS];
+
+    tsrsParameters_t    tsrsParameters[MAX_NUM_OF_AC];
+
+    /* holds last fragmentation threshold */
+    UINT16              lastFragmentThreshold;
+
+} ctrlData_t;
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.c
new file mode 100644 (file)
index 0000000..a70b35c
--- /dev/null
@@ -0,0 +1,511 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+#include "GeneralUtilApi.h"
+#include "GeneralUtil.h"
+#include "report.h"
+#include "osApi.h"
+
+/*************************************************************************
+*                        LIST OBJ                                        *
+**************************************************************************
+**************************************************************************
+*
+ *     The list object mange the allocation and deallocation of generic element.
+ *  The obj create a list of N generic elements and fined a free entry for the Alloc process.
+ *  And free the entry for dealloc.
+ *
+ *
+***************************************************************************/
+
+
+
+/*************************************************************************
+*                        List_create                                     *
+**************************************************************************
+* DESCRIPTION: This function initializes the List data module.                 
+*                                                      
+* INPUT:               hOs - handle to Os Abstraction Layer
+*                              MaxNumOfElements - the number of elemnts that will be Managed by the list
+                ContainerSize - The size of the basic data type managed by the list
+* OUTPUT:              
+*                              
+*
+* RETURN:              Handle to the allocated List data control block
+************************************************************************/
+TI_HANDLE List_create(TI_HANDLE hOs,int MaxNumOfElements,int ContainerSize)
+{
+    int index;
+    List_t *List;
+
+       if( hOs  == NULL )
+       {
+           WLAN_OS_REPORT(("FATAL ERROR:List_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+
+       /* alocate List block */
+       List = (List_t*)os_memoryAlloc(hOs, sizeof(List_t));
+       if(List == NULL)
+           return NULL;
+
+    
+    /* alocate the List of Elements */
+    List->ElementList =(ListElement_t*)os_memoryAlloc(hOs, (sizeof(ListElement_t)*MaxNumOfElements));
+       if(List->ElementList == NULL)
+    {
+        os_memoryFree(List->hOs, List, sizeof(List_t));
+        return NULL;
+    }
+    
+    /*Allocate the Data containers*/
+    for(index=0;index<MaxNumOfElements;index++)
+    {
+        List->ElementList[index].Container = os_memoryAlloc(hOs,ContainerSize);
+        if(List->ElementList[index].Container == NULL)
+            break;
+        List->ElementList[index].Inuse = FALSE;
+    }
+    if (index != MaxNumOfElements)  /*Not all the list element was allocated and*/
+    {                                /*therefore we free the entire list and rap it up*/
+       index--;
+       for(;index>=0;index--)
+            os_memoryFree(hOs,List->ElementList[index].Container,ContainerSize);
+       os_memoryFree(List->hOs, List->ElementList, (sizeof(ListElement_t)*MaxNumOfElements));
+       os_memoryFree(List->hOs,List,(sizeof(List_t)));
+       return NULL;
+   
+    }
+   
+    List->MaxNumOfElements = MaxNumOfElements;
+    List->ContainerSize = ContainerSize;
+       return((TI_HANDLE)List);
+}
+
+
+/***************************************************************************
+*                                                      List_Destroy                                               *
+****************************************************************************
+* DESCRIPTION: This function unload the List data module. 
+* 
+* INPUTS:              hCtrlData - the object
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK - Unload succesfull
+*                              NOK - Unload unsuccesfull
+***************************************************************************/
+TI_STATUS List_Destroy(TI_HANDLE hList)        
+{
+    List_t* List = (List_t*)hList;
+    int index;
+    
+    if(List!=NULL)
+    {
+           if(List->ElementList != NULL)
+        {
+           for(index=0;index<List->MaxNumOfElements;index++)
+             os_memoryFree(List->hOs,List->ElementList[index].Container,List->ContainerSize);
+
+           os_memoryFree(List->hOs,List->ElementList,(sizeof(ListElement_t)*List->MaxNumOfElements));
+        }
+        os_memoryFree(List->hOs, List, sizeof(List_t));
+    }
+    return OK;
+}
+
+/***************************************************************************
+*                                                      List_AllocElement                                  *
+****************************************************************************
+*   
+* 
+*    Fined an empty entry in the list and returns 
+*    a pointer to a memory that contains an element that not in use.
+*
+*    Note in multi Task environment we need to add semaphore to protect the
+*    Function.   
+* 
+***************************************************************************/
+TI_HANDLE List_AllocElement(TI_HANDLE hList)
+{
+    List_t* List = (List_t*)hList;
+    int index;
+    
+    if (List == NULL)
+        return NULL;
+
+    for(index=0;index<List->MaxNumOfElements;index++)
+    {
+        if(!(List->ElementList[index].Inuse))
+        {
+           List->ElementList[index].Inuse = TRUE;
+           os_memoryZero(List->hOs,List->ElementList[index].Container,List->ContainerSize);
+           return((TI_HANDLE)List->ElementList[index].Container);
+        }
+    }
+    return NULL;  
+}
+
+
+/***************************************************************************
+*                                                      List_FreeElement                                               *
+****************************************************************************
+*   
+*   Marks the entry that was allocated as free.
+*   An alloc process can use this space.
+*
+* 
+*
+***************************************************************************/
+TI_STATUS List_FreeElement(TI_HANDLE hList,TI_HANDLE Container)
+{
+    List_t* List = (List_t*)hList;
+    int index;
+
+    if (List == NULL)
+        return NOK;
+
+    for(index=0;index<List->MaxNumOfElements;index++)
+    {
+        if(List->ElementList[index].Container == Container) 
+        {
+            if(!List->ElementList[index].Inuse)
+                return NOK;  /*double free not legal*/
+            List->ElementList[index].Inuse = FALSE; 
+            return OK;
+        }
+    }
+    return NOK;
+}
+
+
+/***************************************************************************
+*                                                      List_GetFirst                                              *
+****************************************************************************
+*   
+*  For purposes of searching the element list (going over all the element in the list)
+*  Get first is used to reset an index for the search.
+*  This function is work combined with GetNext. 
+* 
+*   Note this function can't be used in multi Task environment.
+*
+***************************************************************************/
+TI_HANDLE List_GetFirst(TI_HANDLE hList)
+{
+    List_t* List = (List_t*)hList;
+    int index;
+
+    if (List == NULL)
+        return NULL;
+
+    for(index=0;index<List->MaxNumOfElements;index++)
+    {
+        if(List->ElementList[index].Inuse) 
+        {
+           List->CurrentIndex = index;
+           return (List->ElementList[index].Container); 
+        }
+    }
+    return NULL;
+}
+
+
+/***************************************************************************
+*                                                      List_GetNext                                               *
+****************************************************************************
+*   
+*  This function returns the next element in the list till null
+*  that indicate that there no more element or we have reached the end of the list.
+*  This function is work combined with GetFirst. 
+* 
+*  Note this function can't be used in multi Task environment.
+*
+***************************************************************************/
+TI_HANDLE List_GetNext(TI_HANDLE hList)
+{
+    List_t* List = (List_t*)hList;
+    int index;
+
+    if (List == NULL)
+        return NULL;
+    
+    /* the code works fine even if the elment is the last*/
+    for(index=List->CurrentIndex+1;index<List->MaxNumOfElements;index++)
+    {
+        if(List->ElementList[index].Inuse) 
+        {
+           List->CurrentIndex = index;
+           return (List->ElementList[index].Container); 
+
+        }
+    }
+    return NULL;
+}
+
+
+
+
+/***************************************************************************
+*                                                      DISTRIBUTOR MANAGER                                            *
+****************************************************************************
+***************************************************************************
+*
+ *     PURPOSE:The distributor manger supplies
+ *       1. Register mechanism that has a callback function and the condition 
+ *       (bit mask format) that will be used to distinguish if to call this callback. 
+ *       2. Event occurrence function that go over all the registered function and compare 
+ *       the input mask to the callback mask condition. 
+ *
+ *     
+ *
+***************************************************************************/
+
+
+
+/***************************************************************************
+*                                                      DistributorMgr_Create                              *
+****************************************************************************
+*
+***************************************************************************/
+TI_HANDLE DistributorMgr_Create(TI_HANDLE hOs , int MaxNotifReqElment)
+{
+    DistributorMgr_t *DistributorMgr;
+    
+       DistributorMgr = (DistributorMgr_t*)os_memoryAlloc(hOs, sizeof(DistributorMgr_t));
+       if(DistributorMgr == NULL)
+        return NULL;
+    DistributorMgr->hOs = hOs;
+    DistributorMgr->DistributionList = (List_t*)List_create(hOs,MaxNotifReqElment,sizeof(NotifReqElment_t));
+    if (DistributorMgr->DistributionList == NULL)
+    {
+        os_memoryFree(hOs, DistributorMgr, sizeof(DistributorMgr_t));
+        return NULL;
+    } 
+    return (TI_HANDLE)DistributorMgr;
+}
+
+
+
+/************************************************************************/
+/*               DistributorMgr_Destroy                                 */
+/************************************************************************/
+TI_STATUS DistributorMgr_Destroy(TI_HANDLE hDistributorMgr)
+{
+    DistributorMgr_t *DistributorMgr =(DistributorMgr_t*)hDistributorMgr;
+    
+     if(DistributorMgr == NULL)
+        return NOK;
+
+    List_Destroy(DistributorMgr->DistributionList);
+    
+    os_memoryFree(DistributorMgr->hOs, hDistributorMgr, sizeof(DistributorMgr_t));
+    
+    return OK;
+
+}
+
+/***************************************************************************
+*                                              DistributorMgr_Reg                                                 *
+****************************************************************************
+*   
+*  Use by the client to register a callback function 
+*  with the mask condition that will trigger the call.
+* 
+* input
+*    UINT16 Mask 
+*    TI_HANDLE CallBack
+*    HANDLE Context 
+*    UINT32 Cookie
+* 
+*
+***************************************************************************/
+TI_HANDLE DistributorMgr_Reg(TI_HANDLE hDistributorMgr,UINT16 Mask,TI_HANDLE CallBack,
+                             TI_HANDLE Context,UINT32 Cookie)
+{
+    DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr;
+    NotifReqElment_t *NotifReqElment;
+        
+       if(DistributorMgr == NULL)
+        return NULL;
+
+    NotifReqElment = (NotifReqElment_t*)List_AllocElement(DistributorMgr->DistributionList);
+    if (NotifReqElment == NULL) 
+               return NULL  ;
+
+    NotifReqElment->CallBack = (GeneralEventCall_t)CallBack;
+    NotifReqElment->Mask = Mask;
+    NotifReqElment->Context = Context;
+    NotifReqElment->Cookie = Cookie;
+    NotifReqElment->HaltReq = FALSE;
+    return (TI_HANDLE)NotifReqElment;
+}
+
+
+/***************************************************************************
+*                                              DistributorMgr_ReReg                                           *
+****************************************************************************
+*
+***************************************************************************/
+TI_STATUS DistributorMgr_ReReg(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth ,UINT16 Mask,TI_HANDLE CallBack,TI_HANDLE Context,UINT32 Cookie)
+{
+    DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr;
+    NotifReqElment_t *NotifReqElment = (NotifReqElment_t*)ReqElmenth;
+    
+       if(DistributorMgr == NULL)
+        return NOK;
+
+    if (NotifReqElment == NULL) 
+               return NOK;
+
+    NotifReqElment->CallBack = (GeneralEventCall_t)CallBack;
+    NotifReqElment->Mask = Mask;
+    NotifReqElment->Context = Context;
+    NotifReqElment->Cookie = Cookie;
+    return OK;
+}
+
+
+/***************************************************************************
+*                                              DistributorMgr_AddToMask                                       *
+****************************************************************************
+*   
+* Use this function to add mask bit to the bit mask condition that triggers the Callback 
+*
+*
+***************************************************************************/
+TI_STATUS DistributorMgr_AddToMask(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth,UINT16 Mask)
+{
+    DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr;
+    NotifReqElment_t *NotifReqElment = (NotifReqElment_t*)ReqElmenth;
+     
+    if(DistributorMgr == NULL)
+        return NOK;
+
+    if (NotifReqElment == NULL) 
+               return NOK;
+
+    NotifReqElment->Mask |= Mask;
+    return OK;
+}
+
+
+/***************************************************************************
+*                                              DistributorMgr_HaltNotif                                       *
+****************************************************************************
+*   
+* Use this function to add mask bit to the bit mask condition that triggers the Callback 
+*
+*
+***************************************************************************/
+VOID DistributorMgr_HaltNotif(TI_HANDLE ReqElmenth)
+{
+    NotifReqElment_t *NotifReqElment = (NotifReqElment_t*)ReqElmenth;
+       
+    if (NotifReqElment == NULL) 
+           return;
+
+    NotifReqElment->HaltReq = TRUE;
+   
+}
+
+
+/***************************************************************************
+*                                              DistributorMgr_RestartNotif                                    *
+****************************************************************************
+*   
+* Use this function to add mask bit to the bit mask condition that triggers the Callback 
+*
+*
+***************************************************************************/
+VOID DistributorMgr_RestartNotif(TI_HANDLE ReqElmenth)
+{
+    NotifReqElment_t *NotifReqElment = (NotifReqElment_t*)ReqElmenth;
+       
+    if (NotifReqElment == NULL) 
+           return;
+
+    NotifReqElment->HaltReq = FALSE;
+   
+}
+/***************************************************************************
+*                                              DistributorMgr_UnReg                                           *
+****************************************************************************
+* 
+*
+***************************************************************************/
+TI_STATUS DistributorMgr_UnReg(TI_HANDLE hDistributorMgr,TI_HANDLE RegEventHandle)
+{
+    DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr;
+
+       if(DistributorMgr == NULL)
+        return NOK;
+
+    return List_FreeElement(DistributorMgr->DistributionList, RegEventHandle);
+}
+
+
+/***************************************************************************
+*                                              DistributorMgr_EventCall                                   *
+****************************************************************************
+*   
+* When the client needs to invoke the callback calls function that corresponds 
+* to a specific event mask it will call this function with the desired mask. 
+* And event count that can be used to aggregate the events. 
+* that way calling this function not for every event
+*
+***************************************************************************/
+VOID DistributorMgr_EventCall(TI_HANDLE hDistributorMgr,UINT16 Mask,int EventCount)
+{
+    DistributorMgr_t *DistributorMgr = (DistributorMgr_t*)hDistributorMgr;
+    NotifReqElment_t *NotifReqElment;
+
+    if(DistributorMgr == NULL)
+        return;
+    NotifReqElment = (NotifReqElment_t*)List_GetFirst(DistributorMgr->DistributionList);
+    
+    while(NotifReqElment)
+    {
+        if((NotifReqElment->Mask & Mask) && !(NotifReqElment->HaltReq))
+        {
+            NotifReqElment->CallBack(NotifReqElment->Context,EventCount,Mask,
+                                     NotifReqElment->Cookie);
+        }
+        NotifReqElment = (NotifReqElment_t*)List_GetNext(DistributorMgr->DistributionList);
+    }
+}
+
+
+
+/*******************************************************/
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.h
new file mode 100644 (file)
index 0000000..a020b40
--- /dev/null
@@ -0,0 +1,91 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       TrafficMonitor.h                                                                                                       */
+/*    PURPOSE: TrafficMonitor module Header file                                                                          */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _GENERALUTIL_H_
+#define _GENERALUTIL_H_
+
+
+#include "osTIType.h"
+#include "GeneralUtilApi.h"
+
+
+
+
+/*******************************************************************************************/
+typedef struct
+{
+       TI_HANDLE                       Container;
+    BOOL                Inuse; 
+}ListElement_t;
+
+
+typedef struct
+{
+    int                 CurrentIndex; 
+    int                 MaxNumOfElements;      
+    int                 ContainerSize;    
+    ListElement_t          *ElementList;
+    TI_HANDLE           hOs; 
+}List_t;
+
+
+/*******************************************************************************************/
+
+
+/*******************************************************************************************/
+typedef struct{
+    List_t *DistributionList;
+    TI_HANDLE hOs; 
+}DistributorMgr_t;   
+
+
+typedef struct{
+    UINT16              Mask;
+    BOOL                HaltReq;
+    GeneralEventCall_t  CallBack;
+    TI_HANDLE           Context;
+    UINT32              Cookie;
+}NotifReqElment_t;
+
+/*******************************************************************************************/
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtilApi.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtilApi.h
new file mode 100644 (file)
index 0000000..23143ae
--- /dev/null
@@ -0,0 +1,72 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       TrafficMonitor.h                                                                                                       */
+/*    PURPOSE: TrafficMonitor module Header file                                                                          */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _GENERALUTIL_API_H_
+#define _GENERALUTIL_API_H_
+
+#include "osTIType.h"
+#include "paramOut.h" /* check tis include*/
+/**/
+/* call back functions prototype.*/
+/**/
+typedef void (*GeneralEventCall_t)(TI_HANDLE Context,int EventCount,UINT16 Mask,UINT32 Cookie);
+               
+
+TI_HANDLE DistributorMgr_Create(TI_HANDLE hOs , int MaxNotifReqElment); 
+TI_STATUS DistributorMgr_Destroy(TI_HANDLE hDistributorMgr);
+TI_HANDLE DistributorMgr_Reg(TI_HANDLE hDistributorMgr,UINT16 Mask,TI_HANDLE CallBack,TI_HANDLE Context,UINT32 Cookie);
+TI_STATUS DistributorMgr_ReReg(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth ,UINT16 Mask,TI_HANDLE CallBack,TI_HANDLE Context,UINT32 Cookie);
+TI_STATUS DistributorMgr_AddToMask(TI_HANDLE hDistributorMgr,TI_HANDLE ReqElmenth,UINT16 Mask);
+TI_STATUS DistributorMgr_UnReg(TI_HANDLE hDistributorMgr,TI_HANDLE RegEventHandle);
+VOID DistributorMgr_HaltNotif(TI_HANDLE ReqElmenth);
+VOID DistributorMgr_RestartNotif(TI_HANDLE ReqElmenth);
+VOID DistributorMgr_EventCall(TI_HANDLE hDistributorMgr,UINT16 Mask,int EventCount); 
+
+
+TI_HANDLE List_create(TI_HANDLE hOs,int MaxNumOfElements,int ContainerSize);
+TI_STATUS List_Destroy(TI_HANDLE hList)        ;
+TI_HANDLE List_AllocElement(TI_HANDLE hList);
+TI_STATUS List_FreeElement(TI_HANDLE hList,TI_HANDLE Container);
+TI_HANDLE List_GetFirst(TI_HANDLE List);
+TI_HANDLE List_GetNext(TI_HANDLE List);
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/RateAdaptation.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/RateAdaptation.h
new file mode 100644 (file)
index 0000000..7df0692
--- /dev/null
@@ -0,0 +1,182 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       tx.h                                                                                                   */
+/*    PURPOSE: Tx module Header file                                                                      */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _RATE_ADAPTATION_H_
+#define _RATE_ADAPTATION_H_
+
+#include "osTIType.h"
+#include "paramIn.h"
+#include "paramOut.h"
+
+#define        DEF_LOW_RATE_THRESHOLD                          DRV_RATE_AUTO  /* TBD Below this rate generate roaming event */
+
+#define RATE_ADAPTATION_MODULE_LOG                             CTRL_DATA_MODULE_LOG
+
+
+#define TS_EXCEEDS(currTime,expTime) (currTime > expTime)
+#define TS_ADVANCE(currTime,expTime,delta) (expTime = currTime + (delta))
+
+
+/*#define NUM_OF_RATES_ENTRIES                 5*/
+
+typedef struct
+{
+       rate_e                          rate;
+       UINT8                           rateNumber; /* Rate as actual number - used to compare 2 rates */
+       modulationType_e        modulation;
+       BOOL                            fourXEnable;
+       UINT8                           rateAdaptFallBack;
+       UINT8                           rateAdaptStepUp; 
+       BOOL                            valid;
+
+}rateModulation4x_table_t;
+
+typedef struct
+{
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hCtrlData;
+    TI_HANDLE           hEvHandler;
+
+
+       /* Rate Adaptation Algorithm Parameters */
+       UINT32                          expirTimeTick;
+       UINT32                          txCount;
+       UINT32                          txFailCount;
+    UINT32              txRateFallBackCount;
+       UINT32                          txSkipCount;
+       UINT8                           currRateIndex;
+       UINT8                           maxRateIndex;
+       UINT8                           stepUpFlag;
+       UINT8                           stepUpTxPacketsThreshold;               /* RATE_NUM_SETPUP_PKTS 10  The amount of packets to commite the alghorithem after step up.*/ 
+       UINT8                           contTxPacketsThreshold;      /*#define WDRV_TX_RATE_NUM_CONT_PKTS               30  The amount of packets to commite the alghorithem in contiuse.  */ 
+       UINT8                           lowRateThreshold;
+       UINT32                          ctrlDataFBShortInterval;
+       UINT32                          ctrlDataFBLongInterval;
+
+       TI_HANDLE                       pTimer;
+       TI_HANDLE                       hAPConnection;
+       UINT32                          rateAdapt_timeout;
+
+       
+       rateModulation4x_table_t        RatesMap[MAX_SUPPORTED_RATES];
+
+       tspecsRateParameters_t          tspecsRateParameters[MAX_NUM_OF_AC];
+
+} rateAdaptation_t;
+
+rateAdaptation_t* rateAdaptation_create(TI_HANDLE hOs);
+
+TI_STATUS rateAdaptation_config(rateAdaptation_t*                      pRateAdaptation, 
+                                                               TI_HANDLE                                       hOs, 
+                                                               TI_HANDLE                                       hReport, 
+                                                               TI_HANDLE                                       hCtrlData, 
+                                TI_HANDLE                                      hEvHandler,
+                                                               TI_HANDLE                                       hAPConnection,
+                                                               rateAdaptationInitParam_t*      rateAdaptationInitParam);
+
+TI_STATUS rateAdaptation_destroy(rateAdaptation_t* pRateAdaptation);
+
+TI_STATUS rateAdaptation_start(rateAdaptation_t* pRateAdaptation);
+
+TI_STATUS rateAdaptation_stop(rateAdaptation_t* pRateAdaptation);
+
+TI_STATUS rateAdaptation_stopTimer(rateAdaptation_t* pRateAdaptation);
+
+TI_STATUS rateAdaptation_updateRateAdaptation(rateAdaptation_t* pRateAdaptation,
+                                                                                         rate_e                        actualTxRate,
+                                                                                         rate_e                        requestTxRate, 
+                                                                                         UINT32                        TxStatus,
+                                              int               txNumWaiting);
+
+TI_STATUS rateAdaptation_configLowRateThrsh(rateAdaptation_t* pRateAdaptation, UINT8 rate);
+
+/* Get functions */
+rateModulation4x_table_t* rateAdaptation_getCurrent(rateAdaptation_t* pRateAdaptation);        
+rate_e rateAdaptation_getCurrentRate(rateAdaptation_t* pRateAdaptation);       
+modulationType_e rateAdaptation_getCurrentModulation(rateAdaptation_t* pRateAdaptation);       
+BOOL rateAdaptation_getCurrentFourXEnable(rateAdaptation_t* pRateAdaptation);  
+
+/* Set functions */
+TI_STATUS rateAdaptation_setCurrentRate(rateAdaptation_t* pRateAdaptation, rate_e rate);
+TI_STATUS rateAdaptation_setMaxActivRate(rateAdaptation_t* pRateAdaptation, rate_e rate);      
+void rateAdaptation_updateModulation(rateAdaptation_t* pRateAdaptation,
+                                                                        modulationType_e modulation,
+                                                                        bssType_e bssType);
+
+void rateAdaptation_update4xEnable(rateAdaptation_t* pRateAdaptation,
+                                                                  BOOL                          enable4x,
+                                                                  bssType_e             bssType);
+
+TI_STATUS rateAdaptation_buildRateMapTable(rateAdaptation_t            *pRateAdaptation,
+                                                                                  ctrlData_rateAdapt_t *currTable,
+                                                                                  UINT32                               supportedBitMap,
+                                                                                  UINT32                               clientBitMap,
+                                                                                  modulationType_e             modulation,
+                                                                                  BOOL                                 enable4x,
+                                                                                  bssType_e                    bssType);
+
+/* utils functions */
+TI_STATUS rateAdaptation_Utils_IsRateInBitmap(rateAdaptation_t *pRateAdaptation,
+                                                               UINT32                  ratesBitMap,
+                                                               rate_e                  rate);
+
+UINT32 rateAdaptation_Utils_buildRateBitMap(rateAdaptation_t   *pRateAdaptation,
+                                                                                       ctrlData_rateAdapt_t *currTable,
+                                                                                       rate_e                  rate,
+                                                                                       UINT32                  supportedBitMap,
+                                                                                       UINT32                  clientBitMap);
+
+BOOL rateAdaptation_isRateInTable(ctrlData_rateAdapt_t *currTable,
+                                                               rate_e                  rate);
+
+void rateAdaptation_setTspecsRateEvent(rateAdaptation_t* pRateAdaptation,
+                                                                                        UINT8                  acID,
+                                                                                       BOOL                    enableEvent);
+
+void rateAdaptation_setTspecsRateThresholds(rateAdaptation_t* pRateAdaptation,
+                                                                                        UINT8                  acID,
+                                                                                        UINT8                  highRateThreshold,
+                                                                                        UINT8                  lowRateThreshold);
+
+void rateAdaptation_print(rateAdaptation_t* pRateAdaptation);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.c
new file mode 100644 (file)
index 0000000..da7a857
--- /dev/null
@@ -0,0 +1,1325 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                         */
+/*              MODULE:         TrafficMonitor.c                           */
+/*              PURPOSE:        Traffic Monitor                            */
+/*                                                                         */
+/***************************************************************************/
+#include "TrafficMonitorAPI.h"
+#include "TrafficMonitor.h"
+#include "DataCtrl_Api.h"
+#include "osApi.h"
+#include "report.h"
+
+
+/* Percentage of max down events test interval to use in our "traffic down" timer */ 
+#define MIN_INTERVAL_PERCENT 50
+
+/*#define TRAFF_TEST*/
+#ifdef TRAFF_TEST
+/*for TEST Function*/
+TI_HANDLE TestTrafficMonitor;
+TI_HANDLE TestEventTimer;
+TI_HANDLE Alert1;
+TI_HANDLE Alert2;
+TI_HANDLE Alert3;
+TI_HANDLE Alert4;
+VOID PrintElertStus();
+VOID TestEventFunc(TI_HANDLE hTrafficMonitor);
+#endif
+
+
+/************************************************************************/
+/*           Function prototype                                         */
+/************************************************************************/
+static VOID TimerMonitor_TimeOut(TI_HANDLE hTrafficMonitor);
+static void TrafficMonitor_updateBW(BandWidth_t *pBandWidth, UINT32 uCurrentTS);
+static UINT32 TrafficMonitor_calcBW(BandWidth_t *pBandWidth, UINT32 uCurrentTS);
+static BOOL isThresholdDown(TrafficAlertElement_t *AlertElement,UINT32 CurrentTime);
+static BOOL isThresholdUp(TrafficAlertElement_t *AlertElement , UINT32 CurrentTime);
+static VOID SimpleByteAggregation(TI_HANDLE TraffElem,int Count);
+static VOID SimpleFrameAggregation(TI_HANDLE TraffElem,int Count);
+static TI_HANDLE TrafficMonitor_ExitFunc(TrafficMonitor_t *TrafficMonitor,TI_HANDLE hOs);
+static TI_STATUS FindRstElemEntryIndex (TrafficMonitor_t *TrafficMonitor,TrafficAlertElement_t  *TrafficAlertElement,int *Index);
+static TI_STATUS TrafficMonitor_SetMask(TrafficMonitor_t *TrafficMonitor,TrafficAlertElement_t *TrafficAlertElement,TraffEvntOptNum_t MaskType);
+
+static void TrafficMonitor_UpdateDownTrafficTimerState (TI_HANDLE hTrafficMonitor);
+static void TrafficMonitor_ChangeDownTimerStatus (TI_HANDLE hTrafficMonitor, UINT32 downEventsFound, UINT32 minIntervalTime);
+
+/************************************************************************/
+/*                      TrafficMonitor_create                           */
+/************************************************************************/
+TI_HANDLE TrafficMonitor_create(TI_HANDLE hOs)
+{
+    TrafficMonitor_t *TrafficMonitor;
+    
+    /* Allocate the data structure TrafficMonitor*/     
+        TrafficMonitor = (TrafficMonitor_t*)os_memoryAlloc(hOs, sizeof(TrafficMonitor_t));
+        if (TrafficMonitor == NULL)
+        return NULL;
+
+    os_memoryZero(hOs,TrafficMonitor,sizeof(TrafficMonitor_t));
+
+    TrafficMonitor->hOs = hOs;
+
+    /*Create the base threshold timer that will serve all the down thresholds*/
+        TrafficMonitor->TrafficMonTimer = os_timerCreate(hOs, TimerMonitor_TimeOut, TrafficMonitor);
+        if (TrafficMonitor->TrafficMonTimer == NULL)
+        return TrafficMonitor_ExitFunc(TrafficMonitor,hOs);
+    
+    /*Creates the list that will hold all the registered alert requests*/
+    TrafficMonitor->NotificationRegList = List_create(hOs,MAX_MONITORED_REQ,sizeof(TrafficAlertElement_t));
+    if (TrafficMonitor->NotificationRegList == NULL)
+        return TrafficMonitor_ExitFunc(TrafficMonitor,hOs);
+    return (TI_HANDLE)TrafficMonitor;
+}
+
+
+/************************************************************************/
+/*                    TrafficMonitor_ExitFunc                           */
+/************************************************************************/
+static TI_HANDLE TrafficMonitor_ExitFunc(TrafficMonitor_t *TrafficMonitor,TI_HANDLE hOs)
+{
+    if (TrafficMonitor)
+    {
+        if(TrafficMonitor->TrafficMonTimer)
+          os_timerDestroy(hOs,TrafficMonitor->TrafficMonTimer);
+        os_memoryFree(hOs, TrafficMonitor, sizeof(TrafficMonitor_t));            
+    }
+    return NULL;
+}
+
+
+
+/************************************************************************/
+/*                    TrafficMonitor_config                             */
+/************************************************************************/
+TI_STATUS TrafficMonitor_Init(TI_HANDLE hTrafficMonitor,TI_HANDLE hRxData,TI_HANDLE hTxData)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+       UINT32 uCurrTS = os_timeStampMs(TrafficMonitor->hOs);
+        
+    if(TrafficMonitor == NULL)
+        return NOK;
+    
+    TrafficMonitor->Active = FALSE;
+
+    TrafficMonitor->hRxData = hRxData;
+    TrafficMonitor->hTxData = hTxData;
+
+       /*Init All the bandwidth elements in the system */
+       os_memoryZero(TrafficMonitor->hOs,&TrafficMonitor->DirectTxFrameBW,sizeof(BandWidth_t));
+       os_memoryZero(TrafficMonitor->hOs,&TrafficMonitor->DirectRxFrameBW,sizeof(BandWidth_t));
+       TrafficMonitor->DirectRxFrameBW.auFirstEventsTS[0] = uCurrTS;
+       TrafficMonitor->DirectTxFrameBW.auFirstEventsTS[0] = uCurrTS;
+
+    /*Registering to the RX module for notification.*/
+    TrafficMonitor->RxRegReqHandle = rxData_RegNotif(hRxData,DIRECTED_FRAMES_RECV,
+                                            TrafficMonitor_Event,TrafficMonitor,RX_TRAFF_MODULE);
+    if (TrafficMonitor->RxRegReqHandle == NULL)
+        return NOK;
+
+
+    /*Registering to the TX module for notification .*/
+    TrafficMonitor->TxRegReqHandle = txData_RegNotif(hTxData,DIRECTED_FRAMES_XFER,
+                                            TrafficMonitor_Event,TrafficMonitor,TX_TRAFF_MODULE);
+    if (TrafficMonitor->TxRegReqHandle == NULL)
+        return NOK;
+
+    TrafficMonitor->DownTimerEnabled = FALSE;
+    TrafficMonitor->trafficDownTestIntervalPercent = MIN_INTERVAL_PERCENT;
+
+#ifdef TRAFF_TEST
+    TestTrafficMonitor = TrafficMonitor;
+    TestEventTimer = os_timerCreate(TrafficMonitor->hOs, TestEventFunc, TrafficMonitor);
+    os_timerStart(TrafficMonitor->hOs,TestEventTimer,5000,TRUE);
+#endif
+
+    return OK;
+}
+
+/************************************************************************/
+/*                TrafficMonitor_Start                                  */
+/************************************************************************/
+TI_STATUS TrafficMonitor_Start(TI_HANDLE hTrafficMonitor)       
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *AlertElement;
+    UINT32 CurentTime;
+  
+
+    if(TrafficMonitor == NULL)
+        return NOK;
+
+    /*starts the bandwidth TIMER*/
+    if(!TrafficMonitor->Active) /*To prevent double call to timer start*/
+    {
+        TrafficMonitor_UpdateDownTrafficTimerState (TrafficMonitor);   
+    }
+   
+    AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+    CurentTime = os_timeStampMs(TrafficMonitor->hOs);
+   
+    /* go over all the Down elements and reload the timer*/    
+    while(AlertElement)
+    {
+        if(AlertElement->CurrentState != ALERT_WAIT_FOR_RESET) 
+        {
+            AlertElement->EventCounter = 0;
+            AlertElement->TimeOut = AlertElement->TimeIntervalMs + CurentTime;
+        }
+        AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    }
+    TrafficMonitor->Active = TRUE;
+
+    return OK;
+}
+
+
+
+/************************************************************************/
+/*              TrafficMonitor_Stop                                     */
+/************************************************************************/
+TI_STATUS TrafficMonitor_Stop(TI_HANDLE hTrafficMonitor)        
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *AlertElement;
+     
+    if(TrafficMonitor == NULL)
+        return NOK;
+    
+    if(TrafficMonitor->Active) /*To prevent double call to timer stop*/
+    {
+    
+        TrafficMonitor->Active = FALSE;  
+   
+        TrafficMonitor->DownTimerEnabled = FALSE;
+        os_timerStop(TrafficMonitor->hOs,TrafficMonitor->TrafficMonTimer);
+    
+    }  
+
+    /* Set all events state to ALERT_OFF to enable them to "kick" again once after TrafficMonitor is started */
+    AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+
+     while(AlertElement)
+      {
+         AlertElement->CurrentState = ALERT_OFF;
+         AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    }  
+    
+    return OK;
+}
+
+
+
+/************************************************************************/
+/*                  TrafficMonitor_Destroy                              */
+/************************************************************************/
+TI_STATUS TrafficMonitor_Destroy(TI_HANDLE hTrafficMonitor)     
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+
+    if (TrafficMonitor)
+    {
+        /*Unregister from the RX/TX module for the required notification*/
+        txData_UnRegNotif(TrafficMonitor->hTxData,TrafficMonitor->TxRegReqHandle);
+        rxData_UnRegNotif(TrafficMonitor->hRxData,TrafficMonitor->RxRegReqHandle);
+
+        if(TrafficMonitor->NotificationRegList)
+          List_Destroy(TrafficMonitor->NotificationRegList);
+
+        if(TrafficMonitor->TrafficMonTimer)
+          os_timerDestroy(TrafficMonitor->hOs,TrafficMonitor->TrafficMonTimer);
+        
+#ifdef TRAFF_TEST
+        os_timerDestroy(TrafficMonitor->hOs,TestEventTimer);
+#endif        
+        os_memoryFree(TrafficMonitor->hOs, TrafficMonitor, sizeof(TrafficMonitor_t)); 
+
+        return OK;
+    }
+    
+    return NOK;
+}
+
+
+/***********************************************************************
+ *                        TrafficMonitor_RegEvent                               
+ ***********************************************************************
+DESCRIPTION: Reg event processing function, Perform the following:
+
+                                
+INPUT:          hTrafficMonitor -       Traffic Monitor the object.
+                        
+            TrafficAlertRegParm -       structure which include values to set for 
+                                                the requested Alert event
+                        
+            AutoResetCreate - is only relevant to edge alerts. 
+                  If AutoResetCreate flag is set to true then the registration function will create a conjunction reset element automatic
+                 this reset element will be with the same threshold but opposite in direction
+                 If AutoResetCreate flag is set to false then the reset element will be supplied afterward by the user with the function
+                 TrafficMonitor_SetRstCondition() the alert will not be active till the reset function will be set.
+
+OUTPUT:         
+
+RETURN:     TrafficAlertElement pointer on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE TrafficMonitor_RegEvent(TI_HANDLE hTrafficMonitor,TrafficAlertRegParm_t *TrafficAlertRegParm,BOOL AutoResetCreate)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t  *TrafficAlertElement;
+    UINT32 CurentTime ;
+   
+    if(TrafficMonitor == NULL)
+       return NULL;
+
+    CurentTime = os_timeStampMs(TrafficMonitor->hOs);
+
+    /*Gets a TrafficAlertElement_t memory from the list to assign to the registered request*/
+    TrafficAlertElement = (TrafficAlertElement_t*)List_AllocElement(TrafficMonitor->NotificationRegList);
+    if (TrafficAlertElement == NULL) 
+    {   /* add print*/
+                return NULL  ;
+    }
+
+    /*Init the alert element with the registered parameters.*/
+    TrafficAlertElement->CallBack = TrafficAlertRegParm->CallBack;
+    TrafficAlertElement->Context  = TrafficAlertRegParm->Context;
+    TrafficAlertElement->Cookie  = TrafficAlertRegParm->Cookie;
+    TrafficAlertElement->Direction = TrafficAlertRegParm->Direction;
+    TrafficAlertElement->Threshold = TrafficAlertRegParm->Threshold;
+    TrafficAlertElement->Trigger = TrafficAlertRegParm->Trigger;
+    TrafficAlertElement->TimeIntervalMs = TrafficAlertRegParm->TimeIntervalMs;
+    TrafficAlertElement->TimeOut = CurentTime + TrafficAlertRegParm->TimeIntervalMs;
+    TrafficAlertElement->EventCounter = 0;
+    TrafficMonitor_SetMask(TrafficMonitor,TrafficAlertElement,TrafficAlertRegParm->MonitorType);
+    
+    TrafficAlertElement->CurrentState = ALERT_OFF;
+    TrafficAlertElement->AutoCreated = FALSE;
+    TrafficAlertElement->Enabled = FALSE;
+    /*In case that this is an Edge alert there is a need for a reset condition element*/
+    /*corresponding to the Alert request but opposite in the direction.*/
+    /*Note that the reset condition for this (new) reset element, is the Alert Element it self.*/
+    if(TrafficAlertElement->Trigger == TRAFF_EDGE)
+    {
+        if(AutoResetCreate)
+        {
+            /*Gets a TrafficAlertElement_t memory from the list to assign to the reset elemnt*/
+            TrafficAlertElement->ResetElment[0] = (TrafficAlertElement_t*)List_AllocElement(TrafficMonitor->NotificationRegList);
+            if( TrafficAlertElement->ResetElment[0] == NULL)
+            {
+                List_FreeElement(TrafficMonitor->NotificationRegList,TrafficAlertElement);
+                return NULL;
+            }
+
+            /*
+             copy the Traffic Element init params to the reset Elemnt Except for
+             the direction and the call back that is set to null the CurrentState set to disable.   
+             And the reset condition,that points to the muster alert.
+             */
+            os_memoryCopy(TrafficMonitor->hOs,TrafficAlertElement->ResetElment[0],TrafficAlertElement,sizeof(TrafficAlertElement_t));
+            TrafficAlertElement->ResetElment[0]->CallBack = NULL;
+            /*opposite in the direction from the TrafficAlertElement->Direction*/
+            if (TrafficAlertRegParm->Direction == TRAFF_UP)
+                TrafficAlertElement->ResetElment[0]->Direction = TRAFF_DOWN;
+            else
+                TrafficAlertElement->ResetElment[0]->Direction = TRAFF_UP;
+            TrafficAlertElement->ResetElment[0]->CurrentState = ALERT_WAIT_FOR_RESET;
+            TrafficAlertElement->ResetElment[0]->ResetElment[0] = TrafficAlertElement;
+            TrafficAlertElement->ResetElment[0]->AutoCreated = TRUE;
+            TrafficAlertElement->ResetElment[0]->RstWasAssigned = TRUE;
+            TrafficAlertElement->RstWasAssigned = TRUE;
+   
+        }
+        else/* The reset element will be supplied afterward by the user in the meanwhile disable the alert till then*/
+        {
+            TrafficAlertElement->RstWasAssigned = FALSE;
+            TrafficAlertElement->CurrentState = ALERT_WAIT_FOR_RESET;
+        }
+        
+    }
+
+    TrafficMonitor_UpdateDownTrafficTimerState (TrafficMonitor);
+
+    return TrafficAlertElement;
+}
+
+/************************************************************************/
+/*                  FindRstElemEntryIndex                               */
+/************************************************************************/
+/* Gets a TrafficAlertElement_t memory from the list to assign to the reset elemnt
+ * for internal use
+ ************************************************************************/
+static TI_STATUS FindRstElemEntryIndex (TrafficMonitor_t *TrafficMonitor,TrafficAlertElement_t  *TrafficAlertElement,int *Index)
+{
+    int i;
+    /*Find an empty Rst element entry*/
+    for(i=0;(i<MAX_RST_ELMENT_PER_ALERT) && TrafficAlertElement->ResetElment[i];i++);
+    if(i == MAX_RST_ELMENT_PER_ALERT)
+        return NOK;
+    *Index  = i;
+    return OK;
+}
+
+/************************************************************************/
+/*                  TrafficMonitor_SetMask                              */
+/************************************************************************/
+/*
+ *      Convert the Mask from the types that declared in the 
+ *  TrafficMonitorAPI to the types that are used in the Rx Tx modules.
+ *  And update the TX and RX module of the new event req
+ *  Sets the aggregation function that corresponds to the specific mask type
+ ************************************************************************/
+static TI_STATUS TrafficMonitor_SetMask(TrafficMonitor_t *TrafficMonitor,TrafficAlertElement_t *TrafficAlertElement,TraffEvntOptNum_t MaskType)
+{
+    UINT32 TxMask = 0;
+    UINT32 RxMask = 0;
+    
+   switch(MaskType) {
+   case TX_RX_DIRECTED_FRAMES:
+        TxMask = DIRECTED_FRAMES_XFER;
+        RxMask = DIRECTED_FRAMES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleFrameAggregation;
+        break;
+   case TX_ALL_MSDU_FRAMES:
+        TxMask = DIRECTED_FRAMES_XFER|MULTICAST_FRAMES_XFER|BROADCAST_FRAMES_XFER;
+        TrafficAlertElement->ActionFunc = SimpleFrameAggregation;
+    break;
+   case RX_ALL_MSDU_FRAMES:
+        RxMask = DIRECTED_FRAMES_RECV|MULTICAST_FRAMES_RECV|BROADCAST_FRAMES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleFrameAggregation;
+        break;
+   case TX_RX_ALL_MSDU_FRAMES:
+        TxMask = DIRECTED_FRAMES_XFER|MULTICAST_FRAMES_XFER|BROADCAST_FRAMES_XFER;
+        RxMask = DIRECTED_FRAMES_RECV|MULTICAST_FRAMES_RECV|BROADCAST_FRAMES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleFrameAggregation;
+        break;
+    case TX_RX_ALL_MSDU_IN_BYTES:
+        TxMask = DIRECTED_BYTES_XFER|MULTICAST_BYTES_XFER|BROADCAST_BYTES_XFER;
+        RxMask = DIRECTED_BYTES_RECV|MULTICAST_BYTES_RECV|BROADCAST_BYTES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleByteAggregation;
+        break;
+   case TX_RX_DIRECTED_IN_BYTES:
+        TxMask = DIRECTED_BYTES_XFER;
+        RxMask = DIRECTED_BYTES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleByteAggregation;
+    break;
+   case TX_RX_ALL_802_11_DATA_IN_BYTES:
+        TxMask = DIRECTED_BYTES_XFER | MULTICAST_BYTES_XFER;
+        RxMask = DIRECTED_BYTES_RECV | MULTICAST_BYTES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleByteAggregation;
+    break;
+   case TX_RX_ALL_802_11_DATA_FRAMES:
+        TxMask = DIRECTED_FRAMES_XFER | MULTICAST_FRAMES_XFER;
+        RxMask = DIRECTED_FRAMES_RECV | MULTICAST_FRAMES_RECV;
+        TrafficAlertElement->ActionFunc = SimpleFrameAggregation;
+    break;
+   default:
+        WLAN_OS_REPORT(("TrafficMonitor_SetMask - unknown parameter: %d\n", MaskType));
+       return NOK;
+   }
+   
+   if(RxMask)
+   {
+       TrafficAlertElement->MonitorMask[RX_TRAFF_MODULE] = RxMask;
+       if(rxData_AddToNotifMask(TrafficMonitor->hRxData,TrafficMonitor->RxRegReqHandle,RxMask) == NOK)
+           return NOK;
+   }
+   
+   if(TxMask)
+   {
+       TrafficAlertElement->MonitorMask[TX_TRAFF_MODULE] = TxMask;
+       if(txData_AddToNotifMask(TrafficMonitor->hTxData,TrafficMonitor->TxRegReqHandle,TxMask) == NOK)
+           return NOK;
+   }
+
+   return OK;
+}
+
+
+/***********************************************************************
+ *                        TrafficMonitor_SetRstCondition                        
+ ***********************************************************************
+DESCRIPTION: Reg event processing function, Perform the following:
+             Sets the given reset element to the Alert element. 
+             if MutualRst is set, then The operation is done vise versa .  
+                                
+INPUT:          hTrafficMonitor -       Traffic Monitor the object.
+                        
+            EventHandle -         Alert event
+            
+            ResetEventHandle  Alert Event that will be  used to as the rest for above.
+                        
+            MutualRst - if the 2 elements are used to reset One another. 
+
+NOTE        If the reset element event condition is the same as the alert element the user 
+            have to check the that threshold is bigger or smaller according to the direction 
+            else it can create a deadlock
+
+OUTPUT:         
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS TrafficMonitor_SetRstCondition(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle,TI_HANDLE ResetEventHandle,BOOL MutualRst)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle;
+    TrafficAlertElement_t *TrafficResetAlertElement = (TrafficAlertElement_t*)ResetEventHandle;
+    int i,x;
+    UINT32 CurentTime ;
+
+    if((TrafficMonitor == NULL) || (EventHandle == NULL) || (TrafficResetAlertElement == NULL)) 
+        return NOK;
+
+    
+    CurentTime = os_timeStampMs(TrafficMonitor->hOs);
+
+    /*
+    Check that validity of the reset condition 
+    1.The reset condition is edge.
+    2.The direction is opposite from the main alert.
+    3.The threshold is bigger or smaller according to the direction 
+    This condition is not checked but the user have check it else it can create a deadlock..
+    */
+    if((TrafficResetAlertElement->Trigger != TRAFF_EDGE) || (TrafficAlertElement->Trigger != TRAFF_EDGE))
+        return NOK;
+    if(TrafficResetAlertElement->Direction == TrafficAlertElement->Direction)
+        return NOK;
+
+
+    /*Find an empty Rst element entry*/
+    if(FindRstElemEntryIndex(TrafficMonitor,TrafficResetAlertElement,&i) == NOK)
+        return NOK;
+    
+    TrafficResetAlertElement->ResetElment[i] = TrafficAlertElement;
+    
+    /*if we know for sure that No Rst Element was assigned  
+    therefore that element was in disable mode and we have to enable it.*/
+    if (!(TrafficAlertElement->RstWasAssigned))
+    {
+        TrafficAlertElement->RstWasAssigned = TRUE;
+        TrafficAlertElement->CurrentState = ALERT_OFF;
+        TrafficAlertElement->TimeOut = CurentTime + TrafficAlertElement->TimeIntervalMs;
+        TrafficAlertElement->EventCounter =0;
+    }
+    
+
+    if(MutualRst)
+    {
+      /*Find an empty Rst element entry in the TempRstAlertElement*/
+      if(FindRstElemEntryIndex(TrafficMonitor,TrafficAlertElement,&x) == NOK)
+      {
+        /*this clean up is not complete*/
+        TrafficResetAlertElement->ResetElment[i] = NULL;
+        return NOK;
+      }
+
+      TrafficAlertElement->ResetElment[x] = TrafficResetAlertElement;
+      /*if know for sure that No Rst Element was assigned  
+      therefore that element was in disable mode and we have to enable it.*/
+      if (!(TrafficResetAlertElement->RstWasAssigned))
+      {
+        TrafficResetAlertElement->RstWasAssigned = TRUE;
+        TrafficResetAlertElement->CurrentState = ALERT_OFF;
+        TrafficResetAlertElement->TimeOut = CurentTime + TrafficAlertElement->TimeIntervalMs;
+        TrafficResetAlertElement->EventCounter = 0;
+      }
+    }
+    return OK;
+}
+
+
+/************************************************************************/
+/*               TrafficMonitor_CleanRelatedRef                         */
+/************************************************************************/
+VOID TrafficMonitor_CleanRelatedRef(TrafficMonitor_t *TrafficMonitor,TrafficAlertElement_t *TrafficAlertElement)
+{
+    int i;
+    TrafficAlertElement_t *AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+      
+    /* go over all the Down elements and check for alert ResetElment that ref to TrafficAlertElement*/    
+    while(AlertElement)
+    {
+        for(i=0;i<MAX_RST_ELMENT_PER_ALERT;i++)
+        {
+            if(AlertElement->ResetElment[i] == TrafficAlertElement)
+                AlertElement->ResetElment[i] = NULL;
+        }
+        AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    } 
+}
+
+
+/************************************************************************/
+/*          TrafficMonitor_StopNotif                                   */
+/************************************************************************/
+VOID TrafficMonitor_StopEventNotif(TI_HANDLE hTrafficMonitor,TI_HANDLE EventHandle)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle;
+
+    if(TrafficMonitor == NULL)
+        return ;
+
+    if(TrafficAlertElement == NULL)
+        return ;
+
+    TrafficAlertElement->Enabled = FALSE;
+
+       TrafficMonitor_UpdateDownTrafficTimerState (hTrafficMonitor);
+
+}
+
+
+
+/************************************************************************/
+/*          TrafficMonitor_StartNotif                                   */
+/************************************************************************/
+VOID TrafficMonitor_StartEventNotif(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle;
+
+    if(TrafficMonitor == NULL)
+        return ;
+
+    if(TrafficAlertElement == NULL)
+        return ;
+
+    TrafficAlertElement->Enabled = TRUE;
+
+       TrafficMonitor_UpdateDownTrafficTimerState (hTrafficMonitor);
+
+}
+
+
+
+/************************************************************************/
+/*          TrafficMonitor_StartNotif                                   */
+/************************************************************************/
+VOID TrafficMonitor_ResetEvent(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle;
+
+    if(TrafficMonitor == NULL)
+        return ;
+
+    if(TrafficAlertElement == NULL)
+        return ;
+
+    TrafficAlertElement->CurrentState = ALERT_OFF;
+
+    TrafficMonitor_UpdateDownTrafficTimerState (TrafficMonitor);
+}
+
+
+
+/************************************************************************/
+/*          TrafficMonitor_UnregEvent                                   */
+/************************************************************************/
+VOID TrafficMonitor_UnregEvent(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle;
+
+    if(TrafficMonitor == NULL)
+        return ;
+    
+    /*If it was an edge alert then there can be one more alert element to free.*/
+    /*one is the alert, and the second is the reset element that corresponds to this alert*/
+    /*if it was  Auto Created*/
+    if (TrafficAlertElement->ResetElment[0])
+      if (TrafficAlertElement->ResetElment[0]->AutoCreated)
+       List_FreeElement(TrafficMonitor->NotificationRegList,TrafficAlertElement->ResetElment);
+
+    TrafficMonitor_CleanRelatedRef(TrafficMonitor,TrafficAlertElement);
+
+    List_FreeElement(TrafficMonitor->NotificationRegList,EventHandle);
+
+    TrafficMonitor_UpdateDownTrafficTimerState (TrafficMonitor);
+}
+
+
+/***********************************************************************
+ *                        isThresholdUp                 
+ ***********************************************************************
+DESCRIPTION: Evaluate if alert element as crossed his threshold 
+             if yes it operate the callback registered for this alert and take care of the alert state.  
+                         For alert with UP direction the following algorithm is preformed
+             If the threshold is passed in the req time interval or less. then
+             For Level
+                The alert mode is changed to ON & the next timeout is set to the next interval.
+             For Edge
+                The alert mode is changed to wait for reset and the reset element is set to off.
+                And his timeout is set
+
+INPUT:                          
+            EventHandle -         Alert event
+            CurrentTime - the current time Time stamp 
+            
+OUTPUT:         
+
+RETURN:     If  threshold crossed TRUE else False
+
+************************************************************************/
+static BOOL isThresholdUp(TrafficAlertElement_t *AlertElement , UINT32 CurrentTime)
+{  
+    int i;
+    
+    if (AlertElement->TimeOut < CurrentTime)        
+    {
+        AlertElement->EventCounter = AlertElement->LastCounte;
+        AlertElement->TimeOut = CurrentTime + AlertElement->TimeIntervalMs;
+    }
+    
+    if (AlertElement->EventCounter > AlertElement->Threshold)
+    {
+        AlertElement->EventCounter = 0;
+        /*Sets the new due time (time out)*/
+        AlertElement->TimeOut = CurrentTime + AlertElement->TimeIntervalMs;
+        
+        /*For Edge alert change the alert status to wait for reset and 
+        The corresponding reset element from wait for reset To off.
+        That way toggling the two elements*/
+        if(AlertElement->Trigger == TRAFF_EDGE)
+        {
+            AlertElement->CurrentState = ALERT_WAIT_FOR_RESET;
+            for(i=0;i<MAX_RST_ELMENT_PER_ALERT;i++)
+            {
+                TrafficAlertElement_t *rstElmt = AlertElement->ResetElment[i];
+                if(rstElmt != NULL)
+                    if(rstElmt->CurrentState == ALERT_WAIT_FOR_RESET)
+                    {
+                        rstElmt->CurrentState = ALERT_OFF;
+                        rstElmt->EventCounter = 0;
+                        rstElmt->TimeOut = CurrentTime + rstElmt->TimeIntervalMs;
+                    }
+            }
+        }
+        else 
+            AlertElement->CurrentState = ALERT_ON;
+        
+        /*Call the callback function*/
+        if((AlertElement->CallBack != NULL) && AlertElement->Enabled)
+            AlertElement->CallBack(AlertElement->Context,AlertElement->Cookie);
+        return TRUE;
+    }
+    
+    return FALSE;
+}
+
+
+
+/***********************************************************************
+ *                        isThresholdDown               
+ ***********************************************************************
+DESCRIPTION: Evaluate if alert element as crossed his threshold 
+             if yes it operate the callback registered for this alert and take care of the alert state.  
+                         For alert with DOWN direction the following algorithm is preformed
+             If the threshold is passed (EventCounter < Threshold) in the req time only. then
+             For Level
+               The alert mode is changed to ON & the next timeout is set to the next interval.
+               If the alert condition will still be on.then the next alert will be in the next time interval
+            For Edge
+               The alert mode is changed to wait for reset and the reset element is set to off.
+               And his timeout is set.
+
+INPUT:                          
+            EventHandle -         Alert event
+            CurrentTime - the current time Time stamp 
+            
+OUTPUT:         
+
+RETURN:     If threshold crossed TRUE else False
+
+************************************************************************/
+static BOOL isThresholdDown(TrafficAlertElement_t *AlertElement , UINT32 CurrentTime)
+{
+    int i;
+    BOOL returnVal = FALSE;
+
+    /*
+    if its end of window time.
+    */
+    if (AlertElement->TimeOut <= CurrentTime)        
+    {
+        /*
+        if there was a down edge event.
+        */
+        if (AlertElement->EventCounter <= AlertElement->Threshold)
+        {
+            /*For Edge alert change the alert status to wait for reset and 
+            The corresponding reset element from wait for reset To off.
+            That way toggling the two elements*/
+            if(AlertElement->Trigger == TRAFF_EDGE)
+            {
+                AlertElement->CurrentState = ALERT_WAIT_FOR_RESET;
+                for(i=0;i<MAX_RST_ELMENT_PER_ALERT;i++)
+                {
+                    TrafficAlertElement_t *rstElmt = AlertElement->ResetElment[i];
+                    if(rstElmt != NULL)
+                        if(rstElmt->CurrentState == ALERT_WAIT_FOR_RESET)
+                        {
+                            rstElmt->CurrentState = ALERT_OFF;
+                            rstElmt->EventCounter = 0;
+                            rstElmt->TimeOut = CurrentTime + rstElmt->TimeIntervalMs;
+                        }
+                }
+            }
+            else 
+                AlertElement->CurrentState = ALERT_ON;
+            
+            /*Call the callback function*/
+            if((AlertElement->CallBack != NULL) && AlertElement->Enabled)
+                AlertElement->CallBack(AlertElement->Context,AlertElement->Cookie);
+            
+            returnVal = TRUE;
+        }
+
+        /* end of time window - clear the event counter for the new window.*/
+        AlertElement->EventCounter = 0;
+        /*Sets the new due time (time out)*/
+        AlertElement->TimeOut = CurrentTime + AlertElement->TimeIntervalMs;
+    }
+    else
+    {
+        /*
+        In case we find out that the alert condition will not Occur for this frame window,
+        therefor start a new alert examine cycle (the next farme window).
+        (Not wait till the timeout of this current frame window)
+        */
+        if(AlertElement->EventCounter > AlertElement->Threshold)
+        {
+            AlertElement->EventCounter = 0;
+            AlertElement->TimeOut = CurrentTime + AlertElement->TimeIntervalMs;
+        }
+    }
+    return returnVal;
+}
+
+
+
+/************************************************************************/
+/*              TimerMonitor_TimeOut                                    */
+/************************************************************************/
+/*
+ *      Timer function that is called for every x time interval 
+ *   That will invoke a process if any down limit as occurred. 
+ *
+ ************************************************************************/
+static VOID TimerMonitor_TimeOut(TI_HANDLE hTrafficMonitor)
+{
+    
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *AlertElement;
+    UINT32 CurentTime;
+    UINT32 activeTrafDownEventsNum = 0;
+    UINT32 trafficDownMinTimeout = 0xFFFFFFFF;
+  
+    if(TrafficMonitor == NULL)
+        return;
+
+    AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+    CurentTime = os_timeStampMs(TrafficMonitor->hOs);
+    
+    
+    /* go over all the Down elements and check for alert */    
+    while(AlertElement)
+    {
+        if(AlertElement->CurrentState != ALERT_WAIT_FOR_RESET) 
+        {
+            if (AlertElement->Direction == TRAFF_DOWN)
+            {
+               isThresholdDown(AlertElement,CurentTime);
+            }   
+        }
+
+         if ((AlertElement->Direction == TRAFF_DOWN) && (AlertElement->Trigger == TRAFF_EDGE) && (AlertElement->CurrentState == ALERT_OFF) && (AlertElement->Enabled == TRUE))
+         {
+            /* Increase counter of active traffic down events */
+            activeTrafDownEventsNum++;
+
+            /* Search for the alert with the most short Interval time - will be used to start timer */
+            if ((AlertElement->TimeIntervalMs) < (trafficDownMinTimeout))
+               trafficDownMinTimeout = AlertElement->TimeIntervalMs;
+         }
+
+        AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    }   
+    
+   TrafficMonitor_ChangeDownTimerStatus (TrafficMonitor,activeTrafDownEventsNum,trafficDownMinTimeout);
+
+}
+
+/***********************************************************************
+ *                        TrafficMonitor_IsEventOn
+ ***********************************************************************
+DESCRIPTION: Returns the current status of an event element.
+
+INPUT:      TrafficAlertElement_t 
+
+
+OUTPUT:    bool
+
+RETURN:     True = ON  false = OFF
+
+************************************************************************/
+BOOL TrafficMonitor_IsEventOn(TI_HANDLE EventHandle)
+{
+    TrafficAlertElement_t *TrafficAlertElement = (TrafficAlertElement_t*)EventHandle;
+
+    if(TrafficAlertElement == NULL)
+        return FALSE;
+    
+    
+    if (TrafficAlertElement->CurrentState == ALERT_OFF)
+        return FALSE;
+    else
+        return TRUE;
+
+}
+
+
+
+/***********************************************************************
+ *                        TrafficMonitor_GetFrameBandwidth                        
+ ***********************************************************************
+DESCRIPTION: Returns the total direct frames in the Rx and Tx per second. 
+                                
+INPUT:          hTrafficMonitor -       Traffic Monitor the object.
+                        
+            
+OUTPUT:         
+
+RETURN:     Total BW
+************************************************************************/
+int TrafficMonitor_GetFrameBandwidth(TI_HANDLE hTrafficMonitor)
+{
+       TrafficMonitor_t *pTrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+       UINT32 uCurentTS = os_timeStampMs(pTrafficMonitor->hOs);  
+
+       if(pTrafficMonitor == NULL)
+       {
+               return -1;      /* return error code */
+       }
+
+       /* Calculate BW for Rx & Tx */
+       return ( TrafficMonitor_calcBW(&pTrafficMonitor->DirectRxFrameBW, uCurentTS) +
+                        TrafficMonitor_calcBW(&pTrafficMonitor->DirectTxFrameBW, uCurentTS) );
+}
+
+/***********************************************************************
+*                        TrafficMonitor_updateBW                        
+***********************************************************************
+DESCRIPTION: Upon receiving an event of Tx/Rx (a packet was sent or received), This function is 
+                               called and performs BW calculation.
+
+INPUT:          
+                               pBandWidth              - BW of Rx or Tx        
+                               uCurrentTS              - current TS of the recent event
+
+OUTPUT:         pBandWidth             - updated counters and TS
+
+************************************************************************/
+void TrafficMonitor_updateBW(BandWidth_t *pBandWidth, UINT32 uCurrentTS)
+{
+       /* Check if we should move to the next window */
+       if ( (uCurrentTS - pBandWidth->auFirstEventsTS[pBandWidth->uCurrentWindow]) < (SIZE_OF_WINDOW_MS) )
+       {       
+               pBandWidth->auWindowCounter[pBandWidth->uCurrentWindow]++;
+       }
+       else    /* next window */
+       {       
+               /* increment current window and mark the first event received */        
+               pBandWidth->uCurrentWindow = (pBandWidth->uCurrentWindow + 1) & CYCLIC_COUNTER_ELEMENT;
+               pBandWidth->auFirstEventsTS[pBandWidth->uCurrentWindow] = uCurrentTS;
+               pBandWidth->auWindowCounter[pBandWidth->uCurrentWindow] = 1;
+       }
+}
+/***********************************************************************
+*                        TrafficMonitor_calcBW                        
+***********************************************************************
+DESCRIPTION: Returns the total direct frames in Rx or Tx.
+                        It is called when outside module request the BW. 
+                        Calculate band width by summing up the sliding windows.
+
+INPUT:       pBandWidth                - BW of Rx or Tx        
+                        uCurrentTS             - current TS
+
+RETURN:     Total BW
+************************************************************************/
+UINT32 TrafficMonitor_calcBW(BandWidth_t *pBandWidth, UINT32 uCurrentTS)
+{
+       UINT32 uTotalTime = uCurrentTS - pBandWidth->auFirstEventsTS[pBandWidth->uCurrentWindow];
+       UINT32 uTotalBW = 0;
+       INT32  iter = (INT32)pBandWidth->uCurrentWindow;
+       INT32  iNextIter = (iter - 1) & CYCLIC_COUNTER_ELEMENT; /* Always one less than i */
+
+       /* As long as the summed windows are less than BW_WINDOW_MS and we didn't loop the whole array */
+       while ( (uTotalTime < BW_WINDOW_MS) && (iNextIter != pBandWidth->uCurrentWindow))
+       { 
+               uTotalBW        += pBandWidth->auWindowCounter[iter];
+               /* add next window time - next loop will check if we exceeded the BW window */
+               uTotalTime   = uCurrentTS - pBandWidth->auFirstEventsTS[iNextIter];
+
+               iter = iNextIter; 
+               iNextIter = (iter - 1) & CYCLIC_COUNTER_ELEMENT;                                        
+       } ;
+
+       /* 
+        * Note that if (iNextIter == pBandWidth->uCurrentWindow) than the calculated BW could be up to 
+        * SIZE_OF_WINDOW_MS less than BW_WINDOW_MS 
+        */
+       return uTotalBW;
+}
+
+
+/***********************************************************************
+ *                        TrafficMonitor_Event                  
+ ***********************************************************************
+DESCRIPTION: this function is called for every event that was requested from the Tx or Rx
+             The function preformes update of the all the relevant Alert in the system 
+             that corresponds to the event. checks the Alert Status due to this event.
+             
+                                
+INPUT:          hTrafficMonitor -       Traffic Monitor the object.
+                        
+            Count - evnet count.
+            Mask - the event mask that That triggered this function.
+            
+            MonitorModuleType Will hold the module type from where this function was called. 
+            
+OUTPUT:         
+
+RETURN:     
+
+************************************************************************/
+VOID TrafficMonitor_Event(TI_HANDLE hTrafficMonitor,int Count,UINT16 Mask,UINT32 MonitorModuleType)
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *AlertElement;
+    UINT32 activeTrafDownEventsNum = 0;
+    UINT32 trafficDownMinTimeout = 0xFFFFFFFF;
+       UINT32 uCurentTS = os_timeStampMs(TrafficMonitor->hOs);
+
+    if(TrafficMonitor == NULL)
+        return;
+    
+    if(!TrafficMonitor->Active)   
+        return;
+    
+    /* for BW calculation */
+    if(MonitorModuleType == RX_TRAFF_MODULE)
+    {
+        if(Mask & DIRECTED_FRAMES_RECV)
+               {
+            TrafficMonitor_updateBW(&TrafficMonitor->DirectRxFrameBW, uCurentTS); 
+               } 
+    }
+    else if (MonitorModuleType == TX_TRAFF_MODULE)
+    {
+        if(Mask & DIRECTED_FRAMES_XFER)
+               {
+            TrafficMonitor_updateBW(&TrafficMonitor->DirectTxFrameBW, uCurentTS);
+               }
+    }
+    else  
+       {
+        return; /* module type does not exist, error return */
+       }
+
+    AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+    
+    /* go over all the elements and check for alert */    
+    while(AlertElement)
+    {
+        if(AlertElement->CurrentState != ALERT_WAIT_FOR_RESET) 
+        {
+            if(AlertElement->MonitorMask[MonitorModuleType] & Mask)
+            {
+                AlertElement->ActionFunc(AlertElement,Count);
+                if (AlertElement->Direction == TRAFF_UP)
+                {
+                    isThresholdUp(AlertElement, uCurentTS);
+                }
+            }
+
+            if ((AlertElement->Direction == TRAFF_DOWN) && (AlertElement->Trigger == TRAFF_EDGE) && (AlertElement->CurrentState == ALERT_OFF) && (AlertElement->Enabled == TRUE))
+            {
+               /* Increase counter of active traffic down events */
+               activeTrafDownEventsNum++;
+
+               /* Search for the alert with the most short Interval time - will be used to start timer */
+               if ((AlertElement->TimeIntervalMs) < (trafficDownMinTimeout))
+                  trafficDownMinTimeout = AlertElement->TimeIntervalMs;
+            }
+
+        }
+        AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    }
+
+    TrafficMonitor_ChangeDownTimerStatus (TrafficMonitor,activeTrafDownEventsNum,trafficDownMinTimeout);
+
+}
+
+
+/*
+ *      Used as the aggregation function that is used by the alerts for counting the events. 
+ */
+static VOID SimpleByteAggregation(TI_HANDLE TraffElem,int Count)
+{
+    TrafficAlertElement_t *AlertElement = TraffElem;
+    AlertElement->EventCounter += Count;
+    AlertElement->LastCounte = Count; 
+}
+
+
+/*
+ *      Used as the aggregation function for frame. (count is not used)
+ */
+static VOID SimpleFrameAggregation(TI_HANDLE TraffElem,int Count)
+{
+    TrafficAlertElement_t *AlertElement = TraffElem;
+    AlertElement->EventCounter++;
+    AlertElement->LastCounte = 1; 
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: TrafficMonitor_UpdateDownTrafficTimerState
+Routine Description: called whenever a "down" alert is called, or any other change in the alert list.
+                     used to either start or stop the "traffic down" timer.
+                     loops through alert list, searches for active traffic down events.
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+static void TrafficMonitor_UpdateDownTrafficTimerState (TI_HANDLE hTrafficMonitor)
+{
+       TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *AlertElement;
+    UINT32 activeTrafDownEventsNum = 0;
+    UINT32 trafficDownMinTimeout = 0xFFFFFFFF;
+
+    AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+    
+    while(AlertElement)
+    {
+
+      if ((AlertElement->Direction == TRAFF_DOWN) && (AlertElement->Trigger == TRAFF_EDGE) && (AlertElement->CurrentState == ALERT_OFF) && (AlertElement->Enabled == TRUE))
+      {
+         /* Increase counter of active traffic down events */
+         activeTrafDownEventsNum++;
+
+         /* Search for the alert with the most short Interval time - will be used to start timer */
+         if ((AlertElement->TimeIntervalMs) < (trafficDownMinTimeout))
+            trafficDownMinTimeout = AlertElement->TimeIntervalMs;
+      }
+
+      AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+
+    }
+   
+    TrafficMonitor_ChangeDownTimerStatus (TrafficMonitor,activeTrafDownEventsNum,trafficDownMinTimeout);
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: TrafficMonitor_ChangeDownTimerStatus
+Routine Description: Start or stop down traffic timer according to number of down events found and minInterval time.
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+static void TrafficMonitor_ChangeDownTimerStatus (TI_HANDLE hTrafficMonitor, UINT32 downEventsFound, UINT32 minIntervalTime)
+{
+       TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+
+   if ((downEventsFound == 0) && (TrafficMonitor->DownTimerEnabled == TRUE))
+    {
+      TrafficMonitor->DownTimerEnabled = FALSE;
+      os_timerStop(TrafficMonitor->hOs,TrafficMonitor->TrafficMonTimer);
+    }
+    else if ((downEventsFound > 0) && (TrafficMonitor->DownTimerEnabled == FALSE))
+    {
+      TrafficMonitor->DownTimerEnabled = TRUE;
+      /* Start the timer with user defined percentage of the the minimum interval discovered earlier */
+      os_timerStart(TrafficMonitor->hOs,TrafficMonitor->TrafficMonTimer,
+         ((minIntervalTime * TrafficMonitor->trafficDownTestIntervalPercent) / 100),TRUE);
+      
+    }
+}
+
+#ifdef TI_DBG
+
+/*-----------------------------------------------------------------------------
+Routine Name: TrafficMonitor_UpdateActiveEventsCounters
+Routine Description: 
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+void TrafficMonitor_UpdateActiveEventsCounters (TI_HANDLE hTrafficMonitor)
+{
+       TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)hTrafficMonitor;
+    TrafficAlertElement_t *AlertElement;
+    UINT32 activeTrafDownEventsNum = 0;
+
+    AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+    
+    while(AlertElement)
+    {
+      if ((AlertElement->Direction == TRAFF_DOWN) && (AlertElement->Trigger == TRAFF_EDGE) && (AlertElement->CurrentState == ALERT_OFF) && (AlertElement->Enabled == TRUE))
+      {
+         activeTrafDownEventsNum++;
+      }
+      AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    }
+
+}
+
+
+#endif
+
+#ifdef TRAFF_TEST
+/*
+ *      TEST Function 
+ */
+VOID func1(TI_HANDLE Context,UINT32 Cookie)
+{
+    switch(Cookie) {
+    case 1:
+                WLAN_OS_REPORT(("TRAFF - ALERT UP limit - 50 ON"));
+        break;
+    case 2:
+                WLAN_OS_REPORT(("TRAFF - ALERT UP limit - 30 ON"));
+    break;
+    case 3:
+                WLAN_OS_REPORT(("TRAFF - ALERT DOWN limit - 25 ON"));  
+    break;
+    case 4:
+                WLAN_OS_REPORT(("TRAFF - ALERT DOWN limit - 10 ON"));  
+    break;
+   }
+    
+}
+
+
+VOID PrintElertStus()
+{
+    TrafficMonitor_t *TrafficMonitor =(TrafficMonitor_t*)TestTrafficMonitor;
+    TrafficAlertElement_t *AlertElement  = (TrafficAlertElement_t*)List_GetFirst(TrafficMonitor->NotificationRegList);
+      
+    /* go over all the Down elements and check for alert ResetElment that ref to TrafficAlertElement*/    
+    while(AlertElement)
+    {
+        if(AlertElement->CurrentState == ALERT_WAIT_FOR_RESET)
+            WLAN_OS_REPORT(("TRAFF - ALERT ALERT_WAIT_FOR_RESET"));
+        else
+            WLAN_OS_REPORT(("TRAFF - ALERT ENABLED"));
+
+            
+        AlertElement = (TrafficAlertElement_t*)List_GetNext(TrafficMonitor->NotificationRegList);
+    } 
+}
+
+VOID TestEventFunc(TI_HANDLE hTrafficMonitor)
+{
+
+    static flag = TRUE;
+    TrafficAlertRegParm_t TrafficAlertRegParm ;
+    if(flag)
+    {
+
+        TrafficAlertRegParm.CallBack = func1;
+        TrafficAlertRegParm.Context = NULL ; 
+        TrafficAlertRegParm.Cookie =  1 ;    
+        TrafficAlertRegParm.Direction = TRAFF_UP ;
+        TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+        TrafficAlertRegParm.TimeIntervalMs = 1000;
+        TrafficAlertRegParm.Threshold = 50;
+        TrafficAlertRegParm.MonitorType = TX_RX_DIRECTED_FRAMES;
+        Alert1 = TrafficMonitor_RegEvent(TestTrafficMonitor,&TrafficAlertRegParm,FALSE);   
+        
+        TrafficAlertRegParm.CallBack = func1;
+        TrafficAlertRegParm.Context = NULL ; 
+        TrafficAlertRegParm.Cookie =  2 ;    
+        TrafficAlertRegParm.Direction = TRAFF_UP ;
+        TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+        TrafficAlertRegParm.TimeIntervalMs = 1000;
+        TrafficAlertRegParm.Threshold = 30;
+        TrafficAlertRegParm.MonitorType = TX_RX_DIRECTED_FRAMES;
+        Alert2 = TrafficMonitor_RegEvent(TestTrafficMonitor,&TrafficAlertRegParm,FALSE);
+        
+      
+        TrafficAlertRegParm.CallBack = func1;
+        TrafficAlertRegParm.Context = NULL ; 
+        TrafficAlertRegParm.Cookie =  3 ;    
+        TrafficAlertRegParm.Direction = TRAFF_DOWN ;
+        TrafficAlertRegParm.Trigger = TRAFF_EDGE;
+        TrafficAlertRegParm.TimeIntervalMs = 1000;
+        TrafficAlertRegParm.Threshold = 25;
+        TrafficAlertRegParm.MonitorType = TX_RX_DIRECTED_FRAMES;
+        Alert3 = TrafficMonitor_RegEvent(TestTrafficMonitor,&TrafficAlertRegParm,FALSE);   
+        
+        TrafficAlertRegParm.CallBack = func1;
+        TrafficAlertRegParm.Context = NULL ; 
+        TrafficAlertRegParm.Cookie =  4 ;    
+        TrafficAlertRegParm.Direction = TRAFF_DOWN ;
+        TrafficAlertRegParm.Trigger = TRAFF_LEVEL;
+        TrafficAlertRegParm.TimeIntervalMs = 1000;
+        TrafficAlertRegParm.Threshold = 10;
+        TrafficAlertRegParm.MonitorType = TX_RX_DIRECTED_FRAMES;
+        Alert4 = TrafficMonitor_RegEvent(TestTrafficMonitor,&TrafficAlertRegParm,FALSE);
+        
+       TrafficMonitor_SetRstCondition(TestTrafficMonitor, Alert1,Alert3,TRUE);
+       TrafficMonitor_SetRstCondition(TestTrafficMonitor, Alert2,Alert3,FALSE);
+       flag = FALSE;
+    }
+
+    PrintElertStus();
+
+}
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.h
new file mode 100644 (file)
index 0000000..8045a6f
--- /dev/null
@@ -0,0 +1,152 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */                                                                        
+/*    MODULE:       TrafficMonitor.h                                       */
+/*    PURPOSE:  TrafficMonitor module Header file                          */
+/*                                                                         */                                                                        
+/***************************************************************************/
+#ifndef _TRAFFIC_MONITOR_H
+#define _TRAFFIC_MONITOR_H
+
+
+#include "osTIType.h"
+#include "GeneralUtilApi.h"
+#include "TrafficMonitorAPI.h"
+
+/* time interval to load for the down limit alert Timer *
+ *(TrafficMonitor_t->TrafficMonTimer)                   */
+#define MIN_MONITOR_INTERVAL  50 /*mSec*/
+
+/*The max number of Alert Element that the traffic monitor will be able to Manage.*/
+#define MAX_MONITORED_REQ     32
+
+/* The max number of Alert element that can                *
+ * be associated to other alert element for reset condition*/
+#define MAX_RST_ELMENT_PER_ALERT 3
+
+/* BW Window in MS. changing this number must take NUM_OF_SLIDING_WINDOWS into consideration  */ 
+#define BW_WINDOW_MS                   1000
+
+#define NUM_OF_SLIDING_WINDOWS 8                                                       /* Must be power of 2 !!!                                                        */
+#define CYCLIC_COUNTER_ELEMENT (NUM_OF_SLIDING_WINDOWS - 1)    /* Note that it is aligned to NUM_OF_SLIDING_WINDOWS */
+
+#define SIZE_OF_WINDOW_MS         ( BW_WINDOW_MS / NUM_OF_SLIDING_WINDOWS) /* 125 Ms */
+
+/* BandWidth_t 
+       This struct is used for the sliding windows algorithm used to calculate the band width */
+typedef struct
+{
+       UINT32           uCurrentWindow;
+       UINT32                   auFirstEventsTS[NUM_OF_SLIDING_WINDOWS];                       
+    UINT32           auWindowCounter[NUM_OF_SLIDING_WINDOWS];
+}BandWidth_t;
+
+
+/* The traffic manger class structure */
+typedef struct
+{
+    BOOL                Active;
+    TI_HANDLE           NotificationRegList;
+    TI_HANDLE           hOs;
+    TI_HANDLE           TrafficMonTimer;
+    TI_HANDLE           hRxData;
+    TI_HANDLE           hTxData;
+   
+    TI_HANDLE           TxRegReqHandle;
+    TI_HANDLE           RxRegReqHandle;
+    
+    BandWidth_t         DirectTxFrameBW;
+    BandWidth_t         DirectRxFrameBW;
+    
+    UINT8                      trafficDownTestIntervalPercent; /* Percentage of max down events test interval     */
+                                                        /*to use in our "traffic down" timer               */    
+    BOOL                DownTimerEnabled;      /* Indicates whether the "down traffic" timer is active or not */
+    
+}TrafficMonitor_t;
+
+
+/* Function definition that used for event Aggregation/filtering/etc.. */
+typedef VOID (*TraffActionFunc_t)(TI_HANDLE TraffElem,int Count); 
+                
+/* This enum holds the event providers that are optional in the system */
+typedef enum
+{
+        TX_TRAFF_MODULE                                 = 0,
+        RX_TRAFF_MODULE                         = 1,
+    MAX_NUM_MONITORED_MODULES, /* Don't move this enum this index defines the 
+                                  number of module that can be monitored.*/                   
+}MonModuleTypes_t;
+
+
+
+/*
+ *      Alert State option enum 
+ *  0.  disabled
+ *  1.  ON but not active
+ *  2.  ON and active
+ */
+typedef enum {
+    ALERT_WAIT_FOR_RESET = 0,          /* Event has been triggered, awaiting reset event to occur */
+        ALERT_OFF,
+    ALERT_ON
+}TraffAlertState_t;
+
+
+/* Basic Alert element structure */
+typedef struct AlertElement_t
+{
+    /*initial param*/
+    TraffAlertState_t   CurrentState; 
+    int                             EventCounter;
+    int                             Threshold;
+    UINT32                              TimeOut;  
+    TraffDirection_t    Direction;
+    TraffTrigger_t      Trigger;
+    BOOL                Enabled;
+    int                             LastCounte;
+        TraffEevntCall_t        CallBack;
+    TI_HANDLE           Context ;
+    UINT32              Cookie;    
+    UINT32              TimeIntervalMs;               
+    BOOL                AutoCreated;
+    BOOL                RstWasAssigned;
+    TraffActionFunc_t   ActionFunc;
+    UINT32              MonitorMask[MAX_NUM_MONITORED_MODULES];
+    struct AlertElement_t  *ResetElment[MAX_RST_ELMENT_PER_ALERT];     
+}TrafficAlertElement_t;
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitorAPI.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitorAPI.h
new file mode 100644 (file)
index 0000000..ea71e4b
--- /dev/null
@@ -0,0 +1,120 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                 */
+/*        MODULE:       TrafficMonitor.h                                                                           */
+/*    PURPOSE:  TrafficMonitor module Header file                                              */
+/*                                                                                                                                                 */
+/***************************************************************************/
+#ifndef _TRAFFIC_MONITOR_API_H
+#define _TRAFFIC_MONITOR_API_H
+
+#include "DataCtrl_Api.h"
+
+/**/
+/* call back functions prototype.*/
+/**/
+typedef void (*TraffEevntCall_t)(TI_HANDLE Context,UINT32 Cookie);
+
+
+/*
+ *      This enum list all the available traffic monitor event 
+ *  that a client can register to.
+ */
+typedef enum
+{
+    TX_ALL_MSDU_FRAMES =1,                          
+    RX_ALL_MSDU_FRAMES,
+    TX_RX_DIRECTED_FRAMES,
+    TX_RX_ALL_MSDU_FRAMES,
+    TX_RX_ALL_MSDU_IN_BYTES,
+    TX_RX_DIRECTED_IN_BYTES,
+    TX_RX_ALL_802_11_DATA_IN_BYTES,
+    TX_RX_ALL_802_11_DATA_FRAMES,
+} TraffEvntOptNum_t;
+
+
+typedef enum
+{
+    TRAFF_EDGE = 0,
+    TRAFF_LEVEL 
+}TraffTrigger_t;
+
+typedef enum
+{
+    TRAFF_UP = 0,
+    TRAFF_DOWN 
+}TraffDirection_t;
+
+typedef struct
+{
+    /*initial param*/
+        TraffEevntCall_t    CallBack;
+    TI_HANDLE           Context; 
+    UINT32              Cookie;    
+    TraffDirection_t    Direction;
+    TraffTrigger_t      Trigger;
+    int                                 Threshold;
+    UINT32              TimeIntervalMs;
+    TraffEvntOptNum_t   MonitorType;
+}TrafficAlertRegParm_t;
+
+
+/*********************************************************************/
+
+
+TI_HANDLE TrafficMonitor_create(TI_HANDLE hOs);
+TI_STATUS TrafficMonitor_Init(TI_HANDLE hTrafficMonitor,TI_HANDLE hRxData,TI_HANDLE hTxData);
+TI_STATUS TrafficMonitor_Destroy(TI_HANDLE hTrafficMonitor);
+TI_HANDLE TrafficMonitor_RegEvent(TI_HANDLE hTrafficMonitor, TrafficAlertRegParm_t *TrafficAlertRegParm, BOOL AutoResetCreate);
+TI_STATUS TrafficMonitor_SetRstCondition(TI_HANDLE hTrafficMonitor,TI_HANDLE EventHandle,TI_HANDLE ResetEventHandle,BOOL MutualRst);
+int TrafficMonitor_GetFrameBandwidth(TI_HANDLE hTrafficMonitor);
+VOID TrafficMonitor_UnregEvent(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle);
+VOID TrafficMonitor_Event(TI_HANDLE hTrafficMonitor,int Count,UINT16 Mask,UINT32 MonitorModuleType);
+VOID TrafficMonitor_StopEventNotif(TI_HANDLE hTrafficMonitor,TI_HANDLE EventHandle);
+VOID TrafficMonitor_StartEventNotif(TI_HANDLE hTrafficMonitor,TI_HANDLE EventHandle);
+VOID TrafficMonitor_ResetEvent(TI_HANDLE hTrafficMonitor, TI_HANDLE EventHandle);
+TI_STATUS TrafficMonitor_Stop(TI_HANDLE hTrafficMonitor);       
+TI_STATUS TrafficMonitor_Start(TI_HANDLE hTrafficMonitor);      
+BOOL TrafficMonitor_IsEventOn(TI_HANDLE EventHandle);
+
+
+
+
+#endif
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Rx/rx.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Rx/rx.c
new file mode 100644 (file)
index 0000000..3f69157
--- /dev/null
@@ -0,0 +1,1927 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:          Rx.c                                                */
+/*    PURPOSE:  Rx module functions                                        */
+/*                                                                         */
+/***************************************************************************/
+#include "osTIType.h"
+#include "paramIn.h"
+#include "paramMng.h"
+#include "paramOut.h" 
+#include "memMngrEx.h"
+#include "rx.h"
+#include "osApi.h"
+#include "DataCtrl_Api.h"
+#include "802_11Defs.h"
+#include "Ethernet.h"
+#include "report.h"
+#include "utils.h"
+#include "mlmeApi.h"
+#include "rsnApi.h"
+#include "smeApi.h"
+#include "siteMgrApi.h"
+#include "GeneralUtil.h"   
+#include "EvHandler.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#endif
+#include "TNETW_Driver_api.h"
+
+#define EAPOL_PACKET                                   0x8E88
+#define IAPP_PACKET                                            0x0000
+#define PREAUTH_EAPOL_PACKET                   0xC788
+
+/* CallBack for recieving packet from rxXfer */
+static void rxData_ReceivePacket ( TI_HANDLE   hRxData,TI_STATUS   aStatus,const void *aFrame,
+                                   UINT16      aLength,UINT32      aRate,UINT8       aRCPI,
+                                   UINT8       aChannel,void       *Reserved,UINT32      aFlags);
+
+static void *rxData_RequestForBuffer (TI_HANDLE   hRxData,UINT16 aLength, UINT32 uEncryptionFlag);
+
+#if 0
+static TI_STATUS rxData_checkBssIdAndBssType(TI_HANDLE hRxData, dot11_header_t* dot11_header,
+                                                                                 macAddress_t **rxBssid, bssType_e     *currBssType,
+                                                                                 macAddress_t  *currBssId);
+#endif
+static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, mem_MSDU_T *pMsdu, UINT16 * etherType);
+static void rxData_dataMsduDisptcher(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+static void    rxData_discardMsdu(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+static void    rxData_discardMsduVlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+static void rxData_rcvMsduInOpenNotify(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+static void rxData_rcvMsduEapol(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+static void rxData_rcvMsduData(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, BOOL enabled);
+static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request);
+static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request);
+
+#ifdef EXC_MODULE_INCLUDED
+static void rxData_rcvMsduIapp(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+#endif
+#ifdef TI_DBG
+static void rxData_printRxThroughput(TI_HANDLE hRxData);
+#endif
+
+
+
+/*************************************************************************
+*                        rxData_create                                   *
+**************************************************************************
+* DESCRIPTION: This function initializes the Rx data module.                 
+*                                                      
+* INPUT:               hOs - handle to Os Abstraction Layer
+*                              msduReceiveCB - call back function that return to 
+*                              configMngr in order to register in the Hal
+* OUTPUT:      
+*
+* RETURN:              Handle to the allocated Rx data control block
+************************************************************************/
+TI_HANDLE rxData_create ( TI_HANDLE hOs)
+{
+       rxData_t *hRxData;
+
+       /* check parameters validity */
+       if( hOs  == NULL)
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): OS handle Error - Aborting\n"));
+               return NULL;
+       }
+       
+
+       /* alocate Rx module control block */
+       hRxData = os_memoryAlloc(hOs, (sizeof(rxData_t)));
+
+       if( !hRxData )
+       {
+               utils_nullMemoryFree(hOs, hRxData, sizeof(rxData_t));
+           WLAN_OS_REPORT(("FATAL ERROR: rxData_create(): Error Creating Rx Module - Aborting\n"));
+               return(NULL);
+       }
+
+       /* reset Rx control block */
+       os_memoryZero(hOs, hRxData, (sizeof(rxData_t)));
+
+    hRxData->RxEventDistributor = DistributorMgr_Create(hOs,MAX_RX_NOTIF_REQ_ELMENTS);
+
+       hRxData->hOs = hOs;
+
+    /* allocate timer for debug throughput */
+#ifdef TI_DBG
+    hRxData->hThroughputTimer = os_timerCreate (hOs, rxData_printRxThroughput, hRxData);
+    if (!hRxData->hThroughputTimer)
+    {
+        utils_nullMemoryFree (hOs, hRxData, sizeof(rxData_t));
+        return NULL;
+    }
+    hRxData->rxThroughputTimerEnable = FALSE;
+#endif
+
+       return(hRxData);
+}
+
+/***************************************************************************
+*                                                      rxData_config                                              *
+****************************************************************************
+* DESCRIPTION: This function configures the Rx Data module             
+* 
+* INPUTS:              hRxData - The object
+*                              hCtrlData - Handle to the Ctrl Data object
+*                              hMlme - Handle to the Mlme object
+*                              hRsn - Handle to the Rsn object
+*                              hOs - Handle to the Os Abstraction Layer
+*                              hReport - Handle to the Report object
+*                              hMemMngr - Handle to the MemMngr object
+* OUTPUT:              
+* 
+* RETURNS:             OK - Configuration succesfull
+*                              NOK - Configuration unsuccesfull
+***************************************************************************/
+
+TI_STATUS rxData_config(TI_HANDLE              hRxData, 
+                                        TI_HANDLE                      hCtrlData, 
+                                        TI_HANDLE                      hTxData,
+                                        TI_HANDLE                      hTnetwDrv,
+                        TI_HANDLE   hHalCtrl,
+                                        TI_HANDLE                      hMlme, 
+                                        TI_HANDLE                      hRsn, 
+                                        TI_HANDLE                      hSiteMgr, 
+                                        TI_HANDLE                      hExcMngr, 
+                                        TI_HANDLE                      hOs, 
+                                        TI_HANDLE                      hReport,
+                                        TI_HANDLE                      hMemMngr,
+                        TI_HANDLE   hEvHandler,
+                        rxDataInitParams_t * rxDataInitParams)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+    int i;
+
+       /* check parameters validity */
+       if( hRxData == NULL || hCtrlData == NULL || hMlme == NULL || hRsn == NULL || hHalCtrl == NULL ||
+               hSiteMgr == NULL || hOs == NULL || hReport == NULL || hTxData == NULL || hTnetwDrv == NULL)
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: rxData_config(): Parameters Error - Aborting\n"));
+               return NOK;
+       }
+       pRxData->hCtrlData = hCtrlData; 
+       pRxData->hTxData = hTxData;
+       pRxData->hTnetwDrv = hTnetwDrv;
+    pRxData->hHalCtrl = hHalCtrl;
+       pRxData->hMlme = hMlme; 
+       pRxData->hRsn = hRsn;
+       pRxData->hSiteMgr = hSiteMgr;
+       pRxData->hOs = hOs;
+       pRxData->hReport = hReport;
+       pRxData->hMemMngr = hMemMngr;
+       pRxData->hExcMgr = hExcMngr;
+    pRxData->hEvHandler = hEvHandler;
+       
+       pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED; 
+    pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED;
+       pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION;
+       pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS;
+
+       /*
+        * configure rx data dispatcher 
+        */
+
+
+       /* port status close */
+       pRxData->rxData_dispatchMsdu[CLOSE][DATA_DATA_PACKET]  = &rxData_discardMsdu;       /* data  */
+       pRxData->rxData_dispatchMsdu[CLOSE][DATA_EAPOL_PACKET] = &rxData_discardMsdu;       /* eapol */
+       pRxData->rxData_dispatchMsdu[CLOSE][DATA_IAPP_PACKET]  = &rxData_discardMsdu;       /* Iapp  */
+    pRxData->rxData_dispatchMsdu[CLOSE][DATA_VLAN_PACKET]  = &rxData_discardMsduVlan;   /* VLAN  */
+
+       /* port status open notify */
+       pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_DATA_PACKET]  = &rxData_rcvMsduInOpenNotify; /* data  */ 
+       pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_EAPOL_PACKET] = &rxData_rcvMsduInOpenNotify; /* eapol */ 
+       pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_IAPP_PACKET]  = &rxData_rcvMsduInOpenNotify; /* Iapp  */ 
+    pRxData->rxData_dispatchMsdu[OPEN_NOTIFY][DATA_VLAN_PACKET]  = &rxData_discardMsduVlan;     /* VLAN  */
+
+       /* port status open eapol */
+       pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_DATA_PACKET]  = &rxData_discardMsdu;      /* data  */ 
+       pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_EAPOL_PACKET] = &rxData_rcvMsduEapol;     /* eapol */ 
+       pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_IAPP_PACKET]  = &rxData_discardMsdu;      /* Iapp  */ 
+    pRxData->rxData_dispatchMsdu[OPEN_EAPOL][DATA_VLAN_PACKET]  = &rxData_discardMsduVlan;  /* VLAN  */
+
+       /* port status open */
+       pRxData->rxData_dispatchMsdu[OPEN][DATA_DATA_PACKET]  = &rxData_rcvMsduData;    /* data  */ 
+       pRxData->rxData_dispatchMsdu[OPEN][DATA_EAPOL_PACKET] = &rxData_rcvMsduEapol;   /* eapol */ 
+#ifdef EXC_MODULE_INCLUDED
+       pRxData->rxData_dispatchMsdu[OPEN][DATA_IAPP_PACKET]  = &rxData_rcvMsduIapp;    /* Iapp  */ 
+#else
+       pRxData->rxData_dispatchMsdu[OPEN][DATA_IAPP_PACKET]  = &rxData_rcvMsduData;    /* Iapp  */ 
+#endif
+    pRxData->rxData_dispatchMsdu[OPEN][DATA_VLAN_PACKET]  = &rxData_discardMsduVlan;/* VLAN  */
+
+    /* register CB's for request buffer and receive CB to the lower layers */
+       TnetwDrv_Register_CB(pRxData->hTnetwDrv,TNETW_DRIVER_RX_RECEIVE_PACKET,(void *)rxData_ReceivePacket,hRxData);
+       TnetwDrv_Register_CB(pRxData->hTnetwDrv,TNETW_DRIVER_RX_REQUEST_FOR_BUFFER,(void *)rxData_RequestForBuffer,hRxData);
+
+    /* init rx data filters */
+    pRxData->filteringEnabled = rxDataInitParams->rxDataFiltersEnabled;
+    pRxData->filteringDefaultAction = rxDataInitParams->rxDataFiltersDefaultAction;
+
+       whalCtrl_setRxDataFiltersParams(pRxData->hHalCtrl, pRxData->filteringEnabled, pRxData->filteringDefaultAction);
+
+       for (i = 0; i < MAX_DATA_FILTERS; ++i)
+       {
+               if (rxDataInitParams->rxDataFilterRequests[i].maskLength > 0)
+               {
+                       if (rxData_addRxDataFilter(hRxData, &rxDataInitParams->rxDataFilterRequests[i]) != OK)
+                       {
+                               WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                                               ("%s: Invalid Rx Data Filter configured at init stage (at index %d)!\n", __FUNCTION__, i));
+                       }
+               }
+       }
+
+  #ifdef TI_DBG
+       /* reset counters */
+       rxData_resetCounters(pRxData);
+       rxData_resetDbgCounters(pRxData);
+  #endif
+
+       WLAN_REPORT_INIT(pRxData->hReport, RX_DATA_MODULE_LOG, 
+               (".....Rx Data configured successfully\n"));
+
+       return OK;
+
+}
+
+/***************************************************************************
+*                                                      rxData_unLoad                                              *
+****************************************************************************
+* DESCRIPTION: This function unload the Rx data module. 
+* 
+* INPUTS:              hRxData - the object
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK - Unload succesfull
+*                              NOK - Unload unsuccesfull
+***************************************************************************/
+
+
+TI_STATUS rxData_unLoad(TI_HANDLE hRxData)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       /* check parameters validity */
+       if( pRxData == NULL )
+       {
+               WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       (" rxData_unLoad()      : Illegal value for hRxData\n"));
+               return NOK;
+       }
+
+    DistributorMgr_Destroy(pRxData->RxEventDistributor);
+
+    /* destroy periodic rx throughput timer */
+  #ifdef TI_DBG
+    utils_nullTimerDestroy (pRxData->hOs, pRxData->hThroughputTimer);
+  #endif
+
+       /* free Rx Data controll block */
+       os_memoryFree(pRxData->hOs, pRxData, sizeof(rxData_t));
+
+       return OK;
+}
+
+
+/***************************************************************************
+*                                                      rxData_stop                                                        *
+****************************************************************************
+* DESCRIPTION: this function stop the rx data. 
+* 
+* INPUTS:              hRxData - the object
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK - stop succesfull
+*                              NOK - stop unsuccesfull
+***************************************************************************/
+
+TI_STATUS rxData_stop(TI_HANDLE hRxData)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       /* check parameters validity */
+       if( pRxData == NULL )
+       {
+               WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       (" rxData_stop() : Illegal value for hRxData\n"));
+               return NOK;
+       }
+
+       pRxData->rxDataExcludeUnencrypted = DEF_EXCLUDE_UNENCYPTED; 
+    pRxData->rxDataExludeBroadcastUnencrypted = DEF_EXCLUDE_UNENCYPTED;
+       pRxData->rxDataEapolDestination = DEF_EAPOL_DESTINATION;
+       pRxData->rxDataPortStatus = DEF_RX_PORT_STATUS;
+
+#ifdef TI_DBG
+       /* reset counters */
+       /*rxData_resetCounters(pRxData);*/
+       /*rxData_resetDbgCounters(pRxData);*/
+
+    /* stop throughput timer */
+    if (pRxData->rxThroughputTimerEnable)
+    {
+        os_timerStop (pRxData->hOs, pRxData->hThroughputTimer);
+        pRxData->rxThroughputTimerEnable = FALSE;
+    }
+#endif
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+               (" rxData_stop() :  Succeeded.\n"));
+
+       return OK;
+
+}
+
+/***************************************************************************
+*                                                      rxData_getParam                                            *
+****************************************************************************
+* DESCRIPTION: get a specific parameter
+* 
+* INPUTS:              hTxData - the object
+*                              
+* OUTPUT:              pParamInfo - structure which include the value of 
+*                              the requested parameter
+* 
+* RETURNS:             OK
+*                              NOK
+***************************************************************************/
+
+TI_STATUS rxData_getParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       /* check handle validity */
+       if( pRxData == NULL  )
+       {
+               WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+                       (" rxData_getParam() :  Illegal parametrs value \n"));
+               return NOK;
+       }
+
+       switch (pParamInfo->paramType)
+       {
+               case RX_DATA_EXCLUDE_UNENCRYPTED_PARAM:
+                       pParamInfo->content.rxDataExcludeUnencrypted = pRxData->rxDataExcludeUnencrypted;
+                       break;
+
+               case RX_DATA_EAPOL_DESTINATION_PARAM:
+                       pParamInfo->content.rxDataEapolDestination = pRxData->rxDataEapolDestination;
+                       break;
+
+               case RX_DATA_PORT_STATUS_PARAM:
+                       pParamInfo->content.rxDataPortStatus = pRxData->rxDataPortStatus;
+                       break;
+
+               case RX_DATA_COUNTERS_PARAM:
+                       pParamInfo->content.siteMgrTiWlanCounters.RecvOk = pRxData->rxDataCounters.RecvOk;                              
+                       pParamInfo->content.siteMgrTiWlanCounters.DirectedBytesRecv = pRxData->rxDataCounters.DirectedBytesRecv;                
+                       pParamInfo->content.siteMgrTiWlanCounters.DirectedFramesRecv = pRxData->rxDataCounters.DirectedFramesRecv;              
+                       pParamInfo->content.siteMgrTiWlanCounters.MulticastBytesRecv = pRxData->rxDataCounters.MulticastBytesRecv;              
+                       pParamInfo->content.siteMgrTiWlanCounters.MulticastFramesRecv = pRxData->rxDataCounters.MulticastFramesRecv;    
+                       pParamInfo->content.siteMgrTiWlanCounters.BroadcastBytesRecv = pRxData->rxDataCounters.BroadcastBytesRecv;              
+                       pParamInfo->content.siteMgrTiWlanCounters.BroadcastFramesRecv = pRxData->rxDataCounters.BroadcastFramesRecv;    
+                       break;
+
+        case RX_DATA_GET_RX_DATA_FILTERS_STATISTICS:
+            whalCtrl_getRxDataFiltersStatistics(pRxData->hHalCtrl, 
+                    pParamInfo->content.interogateCmdCBParams.CB_Func,
+                    pParamInfo->content.interogateCmdCBParams.CB_handle, 
+                    pParamInfo->content.interogateCmdCBParams.CB_buf);
+
+            break;
+
+
+               default:
+                       return (PARAM_NOT_SUPPORTED);
+/*                     WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_getParam() : PARAMETER NOT SUPPORTED \n"));
+                       return NOK;
+                       break; - unreachable */
+       }
+
+
+       return (OK);
+
+}
+
+/***************************************************************************
+*                                                      txData_setParam                                            *
+****************************************************************************
+* DESCRIPTION: set a specific parameter
+* 
+* INPUTS:              hTxData - the object
+*                              pParamInfo - structure which include the value to set for 
+*                              the requested parameter
+*              
+* OUTPUT:              
+* 
+* RETURNS:             OK
+*                              NOK
+***************************************************************************/
+
+TI_STATUS rxData_setParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       /* check handle validity */
+       if( pRxData == NULL  )
+       {
+               WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+                       (" rxData_setParam(): Illegal parametrs value \n"));
+               return NOK;
+       }
+
+       switch (pParamInfo->paramType)
+       {
+               case RX_DATA_EXCLUDE_UNENCRYPTED_PARAM:
+                       pRxData->rxDataExcludeUnencrypted = pParamInfo->content.rxDataExcludeUnencrypted;
+                       break;
+        case RX_DATA_EXCLUDE_BROADCAST_UNENCRYPTED_PARAM:
+            pRxData->rxDataExludeBroadcastUnencrypted = pParamInfo->content.rxDataExcludeUnencrypted;
+            break;
+               case RX_DATA_EAPOL_DESTINATION_PARAM:
+                       pRxData->rxDataEapolDestination = pParamInfo->content.rxDataEapolDestination;
+                       break;
+
+               case RX_DATA_PORT_STATUS_PARAM:
+                       pRxData->rxDataPortStatus = pParamInfo->content.rxDataPortStatus;
+                       break;
+
+        case RX_DATA_ENABLE_DISABLE_RX_DATA_FILTERS:
+            return rxData_enableDisableRxDataFilters(hRxData, pParamInfo->content.rxDataFilterEnableDisable);
+
+        case RX_DATA_ADD_RX_DATA_FILTER:
+        {
+            TIWLAN_DATA_FILTER_REQUEST * pRequest = &pParamInfo->content.rxDataFilterRequest;
+            rxDataFilterRequest_t filterRequest;
+
+            filterRequest.offset = pRequest->Offset;
+            filterRequest.maskLength = pRequest->MaskLength;
+            filterRequest.patternLength = pRequest->PatternLength;
+
+            os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.mask, (PVOID) pRequest->Mask, sizeof(filterRequest.mask));
+            os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.pattern, (PVOID) pRequest->Pattern, sizeof(filterRequest.pattern));
+
+            return rxData_addRxDataFilter(hRxData, &filterRequest);
+        }
+
+        case RX_DATA_REMOVE_RX_DATA_FILTER:
+        {
+            TIWLAN_DATA_FILTER_REQUEST * pRequest = &pParamInfo->content.rxDataFilterRequest;
+            rxDataFilterRequest_t filterRequest;
+
+            filterRequest.offset = pRequest->Offset;
+            filterRequest.maskLength = pRequest->MaskLength;
+            filterRequest.patternLength = pRequest->PatternLength;
+            
+            os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.mask, (PVOID) pRequest->Mask, sizeof(filterRequest.mask));
+            os_memoryCopy(pRxData->hOs, (PVOID) filterRequest.pattern, (PVOID) pRequest->Pattern, sizeof(filterRequest.pattern));
+
+            return rxData_removeRxDataFilter(hRxData, &filterRequest);
+        }
+
+               default:
+                       return (PARAM_NOT_SUPPORTED);
+/*                     WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_setParam() : PARAMETER NOT SUPPORTED \n"));
+                       return NOK;
+                       break; - unreachable */
+       }
+
+       return (OK);
+}
+
+
+/***************************************************************************
+*                     rxData_enableDisableRxDataFilters                               *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static TI_STATUS rxData_enableDisableRxDataFilters(TI_HANDLE hRxData, BOOL enabled)
+{
+    rxData_t * pRxData = (rxData_t *) hRxData;
+
+    /* assert 0 or 1 */
+    if (enabled != 0)
+        enabled = 1;
+
+    if (enabled == pRxData->filteringEnabled)
+        return OK;
+
+    pRxData->filteringEnabled = enabled;
+
+       
+       return (TI_STATUS) whalCtrl_setRxDataFiltersParams(pRxData->hHalCtrl, pRxData->filteringEnabled, pRxData->filteringDefaultAction);
+}
+
+/***************************************************************************
+*                          findFilterRequest                                      *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static int findFilterRequest(TI_HANDLE hRxData, rxDataFilterRequest_t * request)
+{
+    rxData_t * pRxData = (rxData_t *) hRxData;
+    int i;
+    
+    for (i = 0; i < MAX_DATA_FILTERS; ++i)
+    {
+        if (pRxData->isFilterSet[i])
+        {
+            if ((pRxData->filterRequests[i].offset == request->offset) &&
+                (pRxData->filterRequests[i].maskLength == request->maskLength) &&
+                (pRxData->filterRequests[i].patternLength == request->patternLength))
+            {
+                if ((os_memoryCompare(pRxData->hOs, pRxData->filterRequests[i].mask, request->mask, request->maskLength) == 0) &&
+                    (os_memoryCompare(pRxData->hOs, pRxData->filterRequests[i].pattern, request->pattern, request->patternLength) == 0))
+                    return i;
+            }
+        }
+    }
+
+    return -1;
+}
+
+/***************************************************************************
+*                            closeFieldPattern                             *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static void closeFieldPattern(rxData_t * pRxData, rxDataFilterFieldPattern_t * fieldPattern, UINT8 * fieldPatterns, UINT8 * lenFieldPatterns)
+{
+    fieldPatterns[*lenFieldPatterns] = fieldPattern->offset;
+    *lenFieldPatterns += sizeof(fieldPattern->offset);
+
+    fieldPatterns[*lenFieldPatterns] = fieldPattern->length;
+    *lenFieldPatterns += sizeof(fieldPattern->length);
+
+    fieldPatterns[*lenFieldPatterns] = fieldPattern->flag;
+    *lenFieldPatterns += sizeof(fieldPattern->flag);
+
+    os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, fieldPattern->pattern, fieldPattern->length);
+    *lenFieldPatterns += fieldPattern->length;
+
+    /* if the pattern bit mask is enabled add it to the end of the request */
+    if ((fieldPattern->flag & RX_DATA_FILTER_FLAG_USE_BIT_MASK) == RX_DATA_FILTER_FLAG_USE_BIT_MASK)
+    {
+        os_memoryCopy(pRxData->hOs, fieldPatterns + *lenFieldPatterns, fieldPattern->mask, fieldPattern->length);
+        *lenFieldPatterns += fieldPattern->length;
+    }
+
+    WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, ("%s: Closed field pattern, length = %d, total length = %d, pattern bit mask = %d.\n", __FUNCTION__, fieldPattern->length, *lenFieldPatterns, ((fieldPattern->flag & RX_DATA_FILTER_FLAG_USE_BIT_MASK) == RX_DATA_FILTER_FLAG_USE_BIT_MASK)));
+}
+
+
+/***************************************************************************
+*                         parseRxDataFilterRequest                         *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static int parseRxDataFilterRequest(TI_HANDLE hRxData, rxDataFilterRequest_t * request, UINT8 * numFieldPatterns, UINT8 * lenFieldPatterns, UINT8 * fieldPatterns)
+{
+    rxData_t * pRxData = (rxData_t *) hRxData;
+
+    int maskIter;
+    int patternIter = 0;
+
+    /* used to store field patterns while they are built */
+    BOOL isBuildingFieldPattern = FALSE;
+    rxDataFilterFieldPattern_t fieldPattern;
+
+    for (maskIter = 0; maskIter < request->maskLength * BIT_TO_BYTE_FACTOR; ++maskIter)
+    {
+        /* which byte in the mask and which bit in the byte we're at */
+        int bit = maskIter % BIT_TO_BYTE_FACTOR;
+        int byte = maskIter / BIT_TO_BYTE_FACTOR;
+
+        /* is the bit in the mask set */
+        BOOL isSet = ((request->mask[byte] & (1 << bit)) == (1 << bit));
+
+        WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+                ("%s: MaskIter = %d, Byte = %d, Bit = %d, isSet = %d\n", __FUNCTION__, maskIter, byte, bit, isSet));
+
+        /* if we're in the midst of building a field pattern, we need to close in case */
+        /* the current bit is not set or we've reached the ethernet header boundary */
+        if (isBuildingFieldPattern)
+        {
+            if ((isSet == FALSE) || (request->offset + maskIter == RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY))
+            {
+                closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns);
+
+                isBuildingFieldPattern = FALSE;
+            }
+        }
+
+        /* nothing to do in case the bit is not set */
+        if (isSet)
+        {
+            /* if not already building a field pattern, create a new one */
+            if (isBuildingFieldPattern == FALSE)
+            {
+                WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+                        ("%s: Creating a new field pattern.\n", __FUNCTION__));
+
+                isBuildingFieldPattern = TRUE;
+                ++(*numFieldPatterns);
+
+                if (*numFieldPatterns > RX_DATA_FILTER_MAX_FIELD_PATTERNS)
+                {
+                    WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+                            ("%s: Invalid filter, too many field patterns, maximum of %u is allowed!\n", __FUNCTION__, RX_DATA_FILTER_MAX_FIELD_PATTERNS));
+
+                    return NOK;
+                }
+
+                fieldPattern.offset = request->offset + maskIter;
+                fieldPattern.length = 0;
+
+                /* we don't support the mask per bit feature yet. */
+                fieldPattern.flag = RX_DATA_FILTER_FLAG_NO_BIT_MASK;
+
+                /* first 14 bits are used for the Ethernet header, rest for the IP header */
+                if (fieldPattern.offset < RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY)
+                {
+                    fieldPattern.flag |= RX_DATA_FILTER_FLAG_ETHERNET_HEADER;
+                }
+                else
+                {
+                    fieldPattern.flag |= RX_DATA_FILTER_FLAG_IP_HEADER;
+                    fieldPattern.offset -= RX_DATA_FILTER_ETHERNET_HEADER_BOUNDARY;
+                }
+
+                WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+                        ("%s: offset = %d, flag = %d.\n", __FUNCTION__, fieldPattern.offset, fieldPattern.flag));
+            }
+
+            /* check that the pattern is long enough */
+            if (patternIter > request->patternLength)
+            {
+                WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+                        ("%s: Invalid filter, mask and pattern lengths are not consistent!\n", __FUNCTION__));
+
+                return NOK;
+            }
+
+            /* add the current pattern byte to the field pattern */
+            fieldPattern.pattern[fieldPattern.length++] = request->pattern[patternIter++];
+
+            /* check pattern matching boundary */
+            if (fieldPattern.offset + fieldPattern.length >= RX_DATA_FILTER_FILTER_BOUNDARY)
+            {
+                WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+                        ("%s: Invalid filter, pattern matching cannot exceed first %u characters.\n", __FUNCTION__, RX_DATA_FILTER_FILTER_BOUNDARY));
+
+                return NOK;
+            }
+        }
+    }
+
+    /* check that the pattern is long enough */
+    if (patternIter != request->patternLength)
+    {
+        WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+            ("%s: Invalid filter, mask and pattern lengths are not consistent!\n", __FUNCTION__));
+
+        return NOK;
+    }
+
+    /* close the last field pattern if needed */
+    if (isBuildingFieldPattern)
+    {
+        closeFieldPattern(hRxData, &fieldPattern, fieldPatterns, lenFieldPatterns);
+    }
+
+    return OK;
+}
+
+
+/***************************************************************************
+*                           rxData_setRxDataFilter                                *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static TI_STATUS rxData_addRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request)
+{
+    rxData_t * pRxData = (rxData_t *) hRxData;
+
+    /* firmware request fields */
+    UINT8 index = 0;
+    UINT8 numFieldPatterns = 0;
+    UINT8 lenFieldPatterns = 0;
+    UINT8 fieldPatterns[MAX_DATA_FILTER_SIZE];
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+   ("rxData_addRxDataFilter, offset=0x%x, maskLength=0x%x, patternLength=0x%x\n",
+                                       request->offset,
+                                       request->maskLength,
+                                       request->patternLength));
+
+       WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->mask, request->maskLength);
+       WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->pattern, request->patternLength);
+
+    /* does the filter already exist? */
+    if (findFilterRequest(hRxData, request) >= 0)
+    {
+        WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+                ("%s: Filter already exists.\n", __FUNCTION__));
+
+        return RX_FILTER_ALREADY_EXISTS;
+    }
+
+    /* find place for insertion */
+    for (index = 0; index < MAX_DATA_FILTERS; ++index)
+    {
+        if (pRxData->isFilterSet[index] == FALSE)
+            break;
+    }
+
+    /* are all filter slots taken? */
+    if (index == MAX_DATA_FILTERS)
+    {
+        WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,
+                ("%s: No place to insert filter!\n", __FUNCTION__));
+
+        return RX_NO_AVAILABLE_FILTERS;
+    }
+
+    WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+            ("%s: Inserting filter at index %d.\n", __FUNCTION__, index));
+
+    /* parse the filter request into discrete field patterns */
+    if (parseRxDataFilterRequest(hRxData, request, &numFieldPatterns, &lenFieldPatterns, fieldPatterns) != OK)
+        return NOK;
+
+    if (numFieldPatterns == 0)
+        return NOK;
+
+    /* store configuration for future manipulation */
+    pRxData->isFilterSet[index] = TRUE;
+    os_memoryCopy(pRxData->hOs, &pRxData->filterRequests[index], request, sizeof(pRxData->filterRequests[index]));
+
+    /* send configuration to firmware */
+       return (TI_STATUS) whalCtrl_setRxDataFilter(pRxData->hHalCtrl, index, ADD_FILTER, FILTER_SIGNAL, 
+                       numFieldPatterns, lenFieldPatterns, fieldPatterns);
+
+       return OK;
+       
+}
+
+/***************************************************************************
+*                         rxData_removeRxDataFilter                               *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static TI_STATUS rxData_removeRxDataFilter(TI_HANDLE hRxData, rxDataFilterRequest_t * request)
+{
+    rxData_t * pRxData = (rxData_t *) hRxData;
+
+    int index = findFilterRequest(hRxData, request);
+
+       WLAN_REPORT_INFORMATION(pRxData->hOs, RX_DATA_MODULE_LOG,
+               ("rxData_removeRxDataFilter, offset=0x%x, maskLength=0x%x, patternLength=0x%x\n",
+                                       request->offset,
+                                       request->maskLength,
+                                       request->patternLength));
+
+       WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->mask, request->maskLength);
+       WLAN_REPORT_HEX_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, request->pattern, request->patternLength);
+
+    /* does the filter exist? */
+    if (index < 0)
+    {
+        WLAN_REPORT_WARNING(pRxData->hOs, RX_DATA_MODULE_LOG,
+                ("%s: Remove data filter request received but the specified filter was not found!", __FUNCTION__));
+
+        return RX_FILTER_DOES_NOT_EXIST;
+    }
+
+    WLAN_REPORT_INFORMATION(pRxData->hOs, RX_DATA_MODULE_LOG,
+            ("%s: Removing filter at index %d.", __FUNCTION__, index));
+
+    pRxData->isFilterSet[index] = FALSE;
+
+       return (TI_STATUS) whalCtrl_setRxDataFilter(pRxData->hHalCtrl, index, REMOVE_FILTER, 
+                               FILTER_SIGNAL, 0, 0, NULL);
+
+       return OK;
+
+       
+}
+
+/***************************************************************************
+*                                              rxData_DistributorRxEvent                                  *
+****************************************************************************
+* DESCRIPTION: 
+*                              
+* 
+* INPUTS:              
+*                              
+*                              
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+*                              
+***************************************************************************/
+static VOID rxData_DistributorRxEvent(rxData_t *pRxData,UINT16 Mask,int DataLen)
+{
+    DistributorMgr_EventCall(pRxData->RxEventDistributor,Mask,DataLen);
+}
+
+/***************************************************************************
+*                                              rxData_RegNotif                                            *
+****************************************************************************/
+TI_HANDLE rxData_RegNotif(TI_HANDLE hRxData,UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,UINT32 Cookie)
+{
+    rxData_t *pRxData = (rxData_t *)hRxData;
+    if (!hRxData)
+        return NULL;
+    return DistributorMgr_Reg(pRxData->RxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie);
+}
+
+/***************************************************************************
+*                                              rxData_AddToNotifMask                                      *
+****************************************************************************/
+TI_STATUS rxData_AddToNotifMask(TI_HANDLE hRxData,TI_HANDLE Notifh,UINT16 EventMask)
+{
+    rxData_t *pRxData = (rxData_t *)hRxData;
+    if (!hRxData)
+        return NOK;
+    return DistributorMgr_AddToMask(pRxData->RxEventDistributor,Notifh,EventMask);
+}
+
+
+/***************************************************************************
+*                                              rxData_UnRegNotif                                          *
+****************************************************************************/
+TI_STATUS rxData_UnRegNotif(TI_HANDLE hRxData,TI_HANDLE RegEventHandle)
+{
+    TI_STATUS status;
+    rxData_t *pRxData = (rxData_t *)hRxData;
+    
+    if (!hRxData)
+        return NOK;
+
+    status = DistributorMgr_UnReg(pRxData->RxEventDistributor,RegEventHandle);
+    return (status);
+}
+
+
+/***************************************************************************
+*                                              rxData_receiveMsduFromWlan                                 *
+****************************************************************************
+* DESCRIPTION: this function is called by the GWSI for each received msdu.
+*                              It filter and distribute the received msdu. 
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+void rxData_receiveMsduFromWlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+       macAddress_t            address3;
+       dot11_header_t          *pDot11Hdr;
+       UINT16 tmpFCtrl;
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       (" rxData_receiveMsduFromWlan() : pRxAttr->packetType = %d\n", pRxAttr->packetType));
+
+       switch (pRxAttr->packetType)
+       {
+       case RX_PACKET_TYPE_MANAGEMENT:
+
+               WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_receiveMsduFromWlan() : Received management msdu len = %d\n", pMsdu->dataLen));
+
+               /* update siteMngr 
+                *
+                * the BSSID in mgmt frames is always addr3 in the header 
+                * must copy address3 since msdu is freed in mlmeParser_recv
+                */  
+               pDot11Hdr = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr)
+                                                                        +memMgr_BufOffset(pMsdu->firstBDPtr));
+               os_memoryCopy(pRxData->hOs, &address3, &pDot11Hdr->address3, sizeof(address3));
+
+               tmpFCtrl = ((pDot11Hdr->fc & DOT11_FC_SUB_MASK) >> 4) ;
+               if((tmpFCtrl == BEACON) || (tmpFCtrl == PROBE_RESPONSE)) 
+               {
+                       if (NOK == siteMgr_CheckRxSignalValidity(pRxData->hSiteMgr, pRxAttr->Rssi, pRxAttr->channel,&address3))
+                       {
+                               wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+                               break;
+                       }
+               }
+
+               /* distribute mgmt msdu to mlme */
+               wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,MLME_RX_MODULE,pMsdu);
+
+               if( mlmeParser_recv(pRxData->hMlme, pMsdu, pRxAttr) != OK )
+               {
+                       WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_receiveMsduFromWlan() :       error sending msdu to MLME \n"));
+                       break;
+               }
+
+
+               if((tmpFCtrl == BEACON) || (tmpFCtrl == PROBE_RESPONSE))
+               {
+                       siteMgr_updateRxSignal(pRxData->hSiteMgr, pRxAttr->SNR, 
+                               pRxAttr->Rssi, pRxAttr->Rate, &address3, FALSE); 
+                       /*WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG,
+                                       (" SIGNAL QUALITY :RX_LEVEL = %d :: SNR = %d \n", pRxAttr->RxLevel,pRxAttr->SNR));      */
+               }
+
+               break;
+
+       case RX_PACKET_TYPE_DATA:
+               WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_receiveMsduFromWlan() : Received Data MSDU len = %d\n", pMsdu->dataLen));
+
+               /* send MSDU to data dispatcher */
+               rxData_dataMsduDisptcher(hRxData, pMsdu, pRxAttr);
+
+               break;
+
+       default:
+               WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_receiveMsduFromWlan() : Received unspecified packet type !!! \n"));
+
+               WLAN_REPORT_DEBUG_RX(pRxData->hReport, 
+                                                        (" rxData_receiveMsduFromWlan() : Received unspecified packet type !!! \n"));
+
+
+               wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 
+               break;
+       }
+}
+/***************************************************************************
+*                                              rxData_dataMsduDisptcher                                   *
+****************************************************************************
+* DESCRIPTION: this function is called upon receving data MSDU,
+*                              it dispatches the packet to the approciate function according to 
+*               data packet type and rx port status. 
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+
+static void rxData_dataMsduDisptcher(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+       portStatus_e DataPortStatus;
+       rxDataPacketType_e DataPacketType;
+
+
+       /* get rx port status */
+       DataPortStatus = pRxData->rxDataPortStatus;
+
+       /* discard data packets received while rx data port is closed */
+       if (DataPortStatus == CLOSE)
+       {
+               WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_dataMsduDisptcher() : Received Data msdu while Rx data port is closed \n", pMsdu->dataLen));
+
+               rxData_discardMsdu(hRxData,pMsdu, pRxAttr);
+               return;
+       }
+
+       /* get data packet type */
+
+#ifdef EXC_MODULE_INCLUDED
+       if (excMngr_isIappPacket(pRxData->hExcMgr, pMsdu) == TRUE)
+       {
+               WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_dataMsduDisptcher() : Received Iapp msdu  \n"));
+
+               DataPacketType = DATA_IAPP_PACKET;
+
+       }
+    else
+#endif
+       {
+               UINT16 etherType;
+               EthernetHeader_t * pEthernetHeader;
+
+               /* 
+                * if Host processes received packets, the header translation
+                * from WLAN to ETH is done here. The conversion has been moved
+                * here so that IAPP packets aren't converted.
+                */
+               rxData_convertWlanToEthHeader(hRxData,pMsdu,&etherType);
+
+               pEthernetHeader = (EthernetHeader_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+
+        if (etherType == ETHERTYPE_802_1D)
+        {
+                       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                                       (" rxData_dataMsduDisptcher() : Received VLAN msdu  \n"));
+
+                       DataPacketType = DATA_VLAN_PACKET;
+
+        }
+               else if(pEthernetHeader->TypeLength == EAPOL_PACKET)
+               {
+                       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                                       (" rxData_dataMsduDisptcher() : Received Eapol msdu  \n"));
+
+                       DataPacketType = DATA_EAPOL_PACKET;
+
+               }
+               else
+               {
+                       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                                       (" rxData_dataMsduDisptcher() : Received Data msdu  \n"));
+
+                       DataPacketType = DATA_DATA_PACKET;
+               }
+       }
+
+       /* dispatch Msdu according to packet type and current rx data port status */
+       pRxData->rxData_dispatchMsdu[DataPortStatus][DataPacketType](hRxData,pMsdu,pRxAttr);
+
+}
+/***************************************************************************
+*                                              rxData_discardMsdu                                         *
+****************************************************************************
+* DESCRIPTION: this function is called to discard MSDU
+* 
+* INPUTS:              hRxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+static void    rxData_discardMsdu(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       (" rxData_discardMsdu: rx port status = %d , Msdu status = %d  \n",pRxData->rxDataPortStatus,pRxAttr->status));
+
+       WLAN_REPORT_DEBUG_RX(pRxData->hReport,
+                       (" rxData_discardMsdu: rx port status = %d , Msdu status = %d  \n",pRxData->rxDataPortStatus,pRxAttr->status));
+
+
+       pRxData->rxDataDbgCounters.excludedFrameCounter++;
+
+
+       /* free Msdu */
+       wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 
+
+
+}
+
+/***************************************************************************
+*                                              rxData_discardMsduVlan                                     *
+****************************************************************************
+* DESCRIPTION: this function is called to discard MSDU
+* 
+* INPUTS:              hRxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+static void    rxData_discardMsduVlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+
+    WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       (" rxData_discardMsduVlan : drop packet that contains VLAN tag\n"));
+
+       pRxData->rxDataDbgCounters.rxDroppedDueToVLANIncludedCnt++;
+
+
+       /* free Msdu */
+       wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 
+}
+
+/***************************************************************************
+*                                              rxData_rcvMsduInOpenNotify                         *
+****************************************************************************
+* DESCRIPTION: this function is called upon receving data Eapol packet type 
+*               while rx port status is "open notify"
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+static void rxData_rcvMsduInOpenNotify(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       (" rxData_rcvMsduInOpenNotify: receiving data packet while in rx port status is open notify\n"));
+
+       WLAN_REPORT_DEBUG_RX(pRxData->hReport, 
+                                                (" rxData_rcvMsduInOpenNotify: ERROR !!! receiving data packet while in rx port status is open notify\n"));
+       
+       pRxData->rxDataDbgCounters.rcvUnicastFrameInOpenNotify++;
+
+       /* free msdu */
+       wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+
+}
+/***************************************************************************
+*                                              rxData_rcvMsduEapol                               *
+****************************************************************************
+* DESCRIPTION: this function is called upon receving data Eapol packet type 
+*               while rx port status is "open  eapol"
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+static void rxData_rcvMsduEapol(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+       (" rxData_rcvMsduEapol() : Received an EAPOL frame tranferred to OS\n"));
+
+       WLAN_REPORT_DEBUG_RX(pRxData->hReport,
+                                                (" rxData_rcvMsduEapol() : Received an EAPOL frame tranferred to OS\n"));
+
+       EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_EAPOL,
+                                         (UINT8*)(pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset),
+                                         pMsdu->firstBDPtr->length);
+
+       wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,OS_ABS_RX_MODULE,pMsdu);
+
+       os_receivePacket(pRxData->hOs, pMsdu, (UINT16)pMsdu->dataLen);
+
+}
+/***************************************************************************
+*                                              rxData_rcvMsduData                                 *
+****************************************************************************
+* DESCRIPTION: this function is called upon receving data "data" packet type 
+*               while rx port status is "open"
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+static void rxData_rcvMsduData(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+#ifdef CONFIG_TROUT_PWRSINK
+       extern unsigned long num_rx_pkt_new;
+#endif
+       rxData_t *pRxData = (rxData_t *)hRxData;
+       EthernetHeader_t *pEthernetHeader;
+       UINT16 EventMask = 0;           
+
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+       (" rxData_rcvMsduData() : Received DATA frame tranferred to OS\n"));
+
+       WLAN_REPORT_DEBUG_RX(pRxData->hReport,
+                                                (" rxData_rcvMsduData() : Received DATA frame tranferred to OS\n"));
+
+       /* check encryption status */
+       pEthernetHeader = (EthernetHeader_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+       if (IsMacAddressDirected(&pEthernetHeader->DstAddr))
+       {  /* unicast frame */
+               if((pRxData->rxDataExcludeUnencrypted) && (!(pRxAttr->packetInfo & RX_PACKET_FLAGS_ENCRYPTION)))
+               {
+                       pRxData->rxDataDbgCounters.excludedFrameCounter++;
+                       /* free msdu */
+                       WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_rcvMsduData() : exclude unicast unencrypted is TRUE & packet encryption is OFF\n"));
+
+                       wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+                       return;
+               }
+
+       }
+       else
+       {  /* broadcast frame */
+               if ((pRxData->rxDataExludeBroadcastUnencrypted) && (!(pRxAttr->packetInfo & RX_PACKET_FLAGS_ENCRYPTION)))
+               {
+                       pRxData->rxDataDbgCounters.excludedFrameCounter++;
+                       /* free msdu */
+                       WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                               (" rxData_receiveMsduFromWlan() : exclude broadcast unencrypted is TRUE & packet encryption is OFF\n"));
+
+                       wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+                       return;
+               }
+       }
+
+       /* update traffic monitor parameters */
+       pRxData->rxDataCounters.RecvOk++;
+       EventMask |= RECV_OK;
+       if ( IsMacAddressDirected(&pEthernetHeader->DstAddr)) 
+       {
+               /* Directed frame */
+               pRxData->rxDataCounters.DirectedFramesRecv++;
+               pRxData->rxDataCounters.DirectedBytesRecv += pMsdu->dataLen;
+               EventMask |= DIRECTED_BYTES_RECV;  
+               EventMask |= DIRECTED_FRAMES_RECV;
+#ifdef CONFIG_TROUT_PWRSINK
+               num_rx_pkt_new++;
+#endif
+       }
+       else if ( IsMacAddressBroadcast(&pEthernetHeader->DstAddr)) 
+       {
+               /* Broadcast frame */
+               pRxData->rxDataCounters.BroadcastFramesRecv++;
+               pRxData->rxDataCounters.BroadcastBytesRecv += pMsdu->dataLen;
+               EventMask |= BROADCAST_BYTES_RECV;  
+               EventMask |= BROADCAST_FRAMES_RECV;
+
+       }
+       else 
+       {
+               /* Multicast Address */
+               pRxData->rxDataCounters.MulticastFramesRecv++;
+               pRxData->rxDataCounters.MulticastBytesRecv += pMsdu->dataLen;
+               EventMask |= MULTICAST_BYTES_RECV;  
+               EventMask |= MULTICAST_FRAMES_RECV;
+#ifdef CONFIG_TROUT_PWRSINK
+               num_rx_pkt_new++;
+#endif
+       }
+       pRxData->rxDataCounters.LastSecBytesRecv += pMsdu->dataLen;
+
+       /*Handle PREAUTH_EAPOL_PACKET*/
+       if(pEthernetHeader->TypeLength == PREAUTH_EAPOL_PACKET)
+       {
+               WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+               (" rxData_receiveMsduFromWlan() : Received an Pre-Auth EAPOL frame tranferred to OS\n"));
+               
+               WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                       ("rxData_receiveMsduFromWlan(): Received an Pre-Auth EAPOL frame tranferred to OS\n"));
+               EvHandlerSendEvent(pRxData->hEvHandler, IPC_EVENT_PREAUTH_EAPOL,
+               (UINT8*)(pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset),
+               pMsdu->firstBDPtr->length);
+       }
+
+
+       rxData_DistributorRxEvent(pRxData,EventMask,(int)pMsdu->dataLen);
+
+       /* deliver packet to os */
+       wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,OS_ABS_RX_MODULE,pMsdu);
+       os_receivePacket(pRxData->hOs, pMsdu, (UINT16)pMsdu->dataLen);
+}
+
+
+/***************************************************************************
+*                                              rxData_rcvMsduIapp                                 *
+****************************************************************************
+* DESCRIPTION: this function is called upon receving data IAPP packet type 
+*               while rx port status is "open"
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - the received msdu.
+*                              pRxAttr - Rx attributes
+*              
+* OUTPUT:              
+* 
+* RETURNS:             
+***************************************************************************/
+#ifdef EXC_MODULE_INCLUDED
+
+static void rxData_rcvMsduIapp(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       WLAN_REPORT_INFORMATION(pRxData->hReport, RX_DATA_MODULE_LOG, 
+       (" rxData_rcvMsduIapp() : Received IAPP frame tranferred to excMgr\n"));
+
+       WLAN_REPORT_DEBUG_RX(pRxData->hReport,
+                                                (" rxData_rcvMsduIapp() : Received IAPP frame tranferred to excMgr\n"));
+
+       /* tranfer packet to excMgr */
+       wlan_memMngrChangeMsduOwner(pRxData->hMemMngr,EXC_MANAGER_RX_MODULE,pMsdu);
+       excMngr_recvIAPPPacket(pRxData->hExcMgr, pMsdu);
+
+       /* free msdu */
+       wlan_memMngrFreeMSDU(pRxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+
+}
+
+#endif
+
+
+/****************************************************************************
+*                                              rxData_convertWlanToEthHeader                           *
+*****************************************************************************
+* DESCRIPTION: this function convert the msdu header from 802.11 header 
+*                              format to ethernet format
+* 
+* INPUTS:              hTxData - the object
+*                              pMsdu - msdu in 802.11 format
+*              
+* OUTPUT:              pMsdu - msdu in ethernet format
+* 
+* RETURNS:             OK/NOK
+***************************************************************************/
+static TI_STATUS rxData_convertWlanToEthHeader (TI_HANDLE hRxData, mem_MSDU_T *pMsdu, UINT16 * etherType)
+{
+       
+       EthernetHeader_t        EthHeader;
+       Wlan_LlcHeader_T        *pWlanSnapHeader;   
+       UINT8                           *dataBuf;
+       dot11_header_t          *pDot11Header;
+       UINT32                          lengthDelta;
+       UINT8                           createEtherIIHeader;
+       UINT16                          swapedTypeLength;
+       UINT32              headerLength;
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       *etherType = 0;
+       headerLength = pMsdu->headerLen;
+       
+       dataBuf = (UINT8 *)memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr);
+       pDot11Header = (dot11_header_t*) dataBuf;
+
+       if(pMsdu->firstBDPtr->length == headerLength)
+       {
+               if (memMgr_BufNext(pMsdu->firstBDPtr))
+               {
+                       pWlanSnapHeader = (Wlan_LlcHeader_T*)(memMgr_BufData(pMsdu->firstBDPtr->nextBDPtr)
+                                                                                                 +memMgr_BufOffset(pMsdu->firstBDPtr->nextBDPtr));
+               } 
+               else 
+               {
+                       return OK;
+               }
+       }
+    else
+       pWlanSnapHeader = (Wlan_LlcHeader_T*)((UINT32)dataBuf + (UINT32)headerLength);
+
+
+       swapedTypeLength = wlan_ntohs(pWlanSnapHeader->Type);
+    *etherType = swapedTypeLength;
+
+       /* See if the LLC header in the frame shows the SAP SNAP... */
+       if((SNAP_CHANNEL_ID == pWlanSnapHeader->DSAP) &&
+          (SNAP_CHANNEL_ID == pWlanSnapHeader->SSAP) &&
+          (LLC_CONTROL_UNNUMBERED_INFORMATION == pWlanSnapHeader->Control)) 
+       {
+               /* Check for the Bridge Tunnel OUI in the SNAP Header... */
+               if((SNAP_OUI_802_1H_BYTE0 == pWlanSnapHeader->OUI[ 0 ]) &&
+                  (SNAP_OUI_802_1H_BYTE1 == pWlanSnapHeader->OUI[ 1 ]) &&
+                  (SNAP_OUI_802_1H_BYTE2 == pWlanSnapHeader->OUI[ 2 ])) 
+               {
+                       /* Strip the SNAP header by skipping over it.                  */
+                       /* Start moving data from the Ethertype field in the SNAP      */
+                       /* header.  Move to the TypeLength field in the 802.3 header.  */
+                       createEtherIIHeader = TRUE;        
+               }
+               /* Check for the RFC 1042 OUI in the SNAP Header   */
+               else 
+               {
+                       /* See if the Ethertype is in our selective translation table  */
+                       /* (Appletalk AARP and DIX II IPX are the two protocols in     */
+                       /* our 'table')                                                */
+                       if((ETHERTYPE_APPLE_AARP == swapedTypeLength) ||
+                          (ETHERTYPE_DIX_II_IPX == swapedTypeLength)) 
+                       {
+                               /* Strip the SNAP header by skipping over it. */
+                               createEtherIIHeader = FALSE;
+                       }
+                       /* All the rest SNAP types are transformed to EthernetII format */
+                       else
+                       {
+                               createEtherIIHeader = TRUE;
+                       }
+               }
+       }
+       else 
+       { 
+               /* Non-SNAP packets strip out the WLAN header and create the dst,src,len header. */
+               createEtherIIHeader = FALSE;
+       }
+       
+       
+
+       /* Prepare the Ethernet header. */
+       if(pDot11Header->fc & DOT11_FC_FROM_DS)
+       {       /* Infrastructure  bss */
+               MAC_COPY(pRxData->hOs, (&EthHeader.DstAddr), (&pDot11Header->address1));
+               MAC_COPY(pRxData->hOs, (&EthHeader.SrcAddr), (&pDot11Header->address3));
+       }
+       else
+       {       /* Independent bss */
+               MAC_COPY(pRxData->hOs, (&EthHeader.DstAddr), (&pDot11Header->address1));
+               MAC_COPY(pRxData->hOs, (&EthHeader.SrcAddr), (&pDot11Header->address2));
+       }
+       
+       if( createEtherIIHeader == TRUE )
+       {
+               EthHeader.TypeLength = pWlanSnapHeader->Type;
+
+        if(pMsdu->firstBDPtr->length == headerLength)
+        {
+            /* Replace the 802.11 header and the LLC with Ethernet packet. */
+            lengthDelta = (pMsdu->firstBDPtr->nextBDPtr->data 
+                                                + pMsdu->firstBDPtr->nextBDPtr->dataOffset 
+                                                - pMsdu->firstBDPtr->data)
+                                                       + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN;
+            dataBuf += lengthDelta;
+            os_memoryCopy(pRxData->hOs, dataBuf, (void*)&EthHeader, ETHERNET_HDR_LEN );
+            pMsdu->firstBDPtr->dataOffset = lengthDelta;
+            pMsdu->dataLen -= headerLength + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN;
+                       pMsdu->firstBDPtr->length = pMsdu->dataLen;
+
+                       /* UDI - modify code to release second BD to test NDIS */
+                       wlan_memMngrFreeBD(pRxData->hMemMngr, pMsdu->firstBDPtr->nextBDPtr->handle);
+                       pMsdu->firstBDPtr->nextBDPtr = NULL;
+            return OK;
+
+        }
+               /* The LEN/TYPE bytes are set to TYPE, the entire WLAN+SNAP is removed.*/
+               lengthDelta = headerLength + WLAN_SNAP_HDR_LEN - ETHERNET_HDR_LEN;
+               EthHeader.TypeLength = pWlanSnapHeader->Type;
+       }
+       else 
+       {
+               /* The LEN/TYPE bytes are set to frame LEN, only the WLAN header is removed, */
+               /* the entire 802.3 or 802.2 header is not removed.*/
+               EthHeader.TypeLength = wlan_ntohs((UINT16)(pMsdu->dataLen - headerLength));
+               lengthDelta = headerLength - ETHERNET_HDR_LEN;
+       }
+       
+       /* Replace the 802.11 header and the LLC with Ethernet packet. */
+       dataBuf += lengthDelta;
+       os_memoryCopy(pRxData->hOs, dataBuf, (void*)&EthHeader, ETHERNET_HDR_LEN );
+       memMgr_BufOffset(pMsdu->firstBDPtr) += lengthDelta;
+       pMsdu->dataLen -= lengthDelta;
+       pMsdu->firstBDPtr->length -= lengthDelta;
+       pMsdu->headerLen = ETHERNET_HDR_LEN;
+       return OK;
+                               
+}
+
+
+/****************************************************************************************
+ *                        rxData_ReceivePacket                                              *
+ ****************************************************************************************
+DESCRIPTION:    receive packet CB from RxXfer.
+                parse the status and other parameters and forward the frame to  
+                rxData_receiveMsduFromWlan()
+                
+INPUT:          Rx frame with its parameters    
+
+OUTPUT:
+
+RETURN:         
+
+************************************************************************/
+static void rxData_ReceivePacket ( TI_HANDLE   hRxData,
+                                   TI_STATUS   aStatus,
+                                   const void *aFrame,
+                                   UINT16      aLength,
+                                   UINT32      aRate,
+                                   UINT8       aRCPI,
+                                   UINT8       aChannel,
+                                   void       *Reserved,
+                                   UINT32      aFlags)
+{
+    rxData_t *pRxData = (rxData_t *)hRxData;
+    mem_MSDU_T *pMsdu = pRxData->pReqForBufMsdu;
+
+    if (pMsdu)
+    {
+        rxXfer_Reserved_t *pWhalReserved = (rxXfer_Reserved_t *)Reserved;
+        Rx_attr_t RxAttr; 
+        dot11_header_t *pHdr;
+        
+        /*
+         * First thing we do is getting the dot11_header, and than we check the status, since the header is
+         * needed for RX_MIC_FAILURE_ERROR 
+         */
+
+        /* The next field includes the data only, excluding the TNETWIF_READ_OFFSET_BYTES */
+        pMsdu->dataLen = aLength;
+        /* NOTE !!! the length field in the rx path exclude the TNETWIF_READ_OFFSET_BYTES !!! (while in the tx path its included) */ 
+        pMsdu->firstBDPtr->length = aLength;
+               /* Actual data starts after the TNETWIF_READ_OFFSET_BYTES reserved for the bus txn */
+               pMsdu->firstBDPtr->dataOffset = TNETWIF_READ_OFFSET_BYTES ; 
+               
+        pHdr = (dot11_header_t *)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+
+        /* Check status */
+        switch (aStatus)
+        {
+            case OK:
+                break;
+
+            case RX_MIC_FAILURE_ERROR:
+            {
+                UINT8 uKeyType; 
+                paramInfo_t Param;
+                macAddress_t* pMac = &pHdr->address1; /* hold the first mac address */
+                /* Get BSS type */
+                Param.paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM;
+                siteMgr_getParam (pRxData->hSiteMgr, &Param);
+
+                /* For multicast/broadcast frames or in IBSS the key used is GROUP, else - it's Pairwise */
+                if (MAC_MULTICAST(pMac) || Param.content.siteMgrCurrentBSSType == BSS_INDEPENDENT)
+                {
+                    uKeyType = (UINT8)KEY_TKIP_MIC_GROUP;
+                }
+                /* Unicast on infrastructure */
+                else 
+                {
+                    uKeyType = (UINT8)KEY_TKIP_MIC_PAIRWISE;
+                }
+
+                WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                    ("rxData_ReceivePacket: Received MSDU MIC failure. Type = %s\n",
+                    ((uKeyType == KEY_TKIP_MIC_GROUP) ? "GROUP" : "PAIRWISE")));
+
+                rsn_reportMicFailure (pRxData->hRsn, &uKeyType, sizeof(uKeyType));
+                wlan_memMngrFreeMSDU (pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 
+                return;
+            }
+            
+            case RX_DECRYPT_FAILURE:
+                /* This error is not important before the Connection, so we ignore it when portStatus is not OPEN */
+                if (pRxData->rxDataPortStatus == OPEN) 
+                {
+                    WLAN_REPORT_WARNING(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                        ("rxData_ReceivePacket: Received MSDU with RX_DECRYPT_FAILURE\n"));
+                }
+                
+                wlan_memMngrFreeMSDU (pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 
+                return;
+
+            default:    
+                /* Unknown error - free packet and return */
+                WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG, 
+                    ("rxData_ReceivePacket: Received MSDU with unknown status = %s\n",
+                    convertTI_STATUS_toString (aStatus)));
+
+                wlan_memMngrFreeMSDU (pRxData->hMemMngr, memMgr_MsduHandle(pMsdu)); 
+                return;
+        }
+
+        WLAN_REPORT_INFORMATION (pRxData->hReport, RX_DATA_MODULE_LOG, ("ReceivePacket\n"));
+                                 
+        /*
+         * Set rx attributes 
+         */ 
+        RxAttr.channel    = aChannel;
+        RxAttr.packetInfo = aFlags;
+        RxAttr.packetType = pWhalReserved->packetType;
+        /* Rate is converted in RxXfer module */
+        RxAttr.Rate       = (rate_e)aRate;
+        RxAttr.Rssi       = pWhalReserved->rssi;
+        RxAttr.SNR        = pWhalReserved->SNR;
+        RxAttr.status     = aStatus;
+        RxAttr.band       = pWhalReserved->band;
+        RxAttr.TimeStamp  = pWhalReserved->TimeStamp;
+        
+        /* Setting the mac header len according to the received FrameControl field in the Mac Header */
+        GET_MAX_HEADER_SIZE (pHdr, &pMsdu->headerLen);
+        
+        WLAN_REPORT_DEBUG_RX(pRxData->hReport, 
+                             ("rxData_ReceivePacket: channel=%d, info=0x%x, type=%d, rate=0x%x, RSSI=%d, SNR=%d, status=%d\n",
+                             RxAttr.channel,  
+                             RxAttr.packetInfo,
+                             RxAttr.packetType,
+                             RxAttr.Rate,
+                             RxAttr.Rssi,
+                             RxAttr.SNR,
+                             RxAttr.status));
+
+        rxData_receiveMsduFromWlan (hRxData, pMsdu, &RxAttr);
+
+        /* MSDU MUST be freed until now */
+        if (pMsdu != NULL)
+        {
+            if (pMsdu->module != MODULE_FREE_MSDU &&
+                pMsdu->module != OS_ABS_TX_MODULE && 
+                pMsdu->module != TX_MODULE)
+            {
+                WLAN_REPORT_ERROR(pRxData->hReport, RX_DATA_MODULE_LOG,  
+                   ("rxData_ReceivePacket: ERROR pMsdu->module != MODULE_FREE_MSDU, module = %d\n", pMsdu->module));
+
+                HexDumpData ((UINT8*)(memMgr_MsduHdrAddr(pMsdu)), memMgr_MsduHdrLen(pMsdu));
+            }
+        }
+    }
+
+    else
+    {
+        WLAN_REPORT_ERROR (pRxData->hReport, RX_DATA_MODULE_LOG,  
+            ("rxData_ReceivePacket: null MSDU received"));
+    }
+}
+
+
+/****************************************************************************************
+ *                        RequestForBuffer                                              *
+ ****************************************************************************************
+DESCRIPTION:     RX request for buffer
+
+INPUT:          
+
+OUTPUT:
+
+RETURN:         
+
+************************************************************************/
+static void *rxData_RequestForBuffer (TI_HANDLE   hRxData,
+                                      UINT16 aLength, UINT32 uEncryptionflag)
+{
+    rxData_t *pRxData = (rxData_t *)hRxData;
+
+       WLAN_REPORT_INFORMATION (pRxData->hReport, RX_DATA_MODULE_LOG,
+                                                               (" RequestForBuffer, length = %d \n",aLength));
+
+       if (wlan_memMngrAllocMSDU(pRxData->hMemMngr, &pRxData->pReqForBufMsdu, aLength, HAL_RX_MODULE) != OK)
+       {
+               WLAN_REPORT_ERROR(pRxData->hReport, HAL_CTRL_MODULE_LOG,  
+                       ("RequestForBuffer: wlan_memMngrAllocMSDU error\n"));
+               return NULL;
+       }
+
+       return memMgr_BufData (pRxData->pReqForBufMsdu->firstBDPtr);
+}
+
+/***************************************************************************
+*                                               rxData_resetCounters                                          *
+****************************************************************************
+* DESCRIPTION: This function reset the Rx Data module counters
+*
+* INPUTS:              hRxData - the object
+*
+* OUTPUT:              
+* 
+* RETURNS:             void
+***************************************************************************/
+#ifdef TI_DBG
+void rxData_resetCounters(TI_HANDLE hRxData)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       os_memoryZero(pRxData->hOs,     &pRxData->rxDataCounters, sizeof(rxDataCounters_t));
+}
+
+/***************************************************************************
+*                                               rxData_resetDbgCounters                                       *
+****************************************************************************
+* DESCRIPTION: This function reset the Rx Data module debug counters
+*
+* INPUTS:              hRxData - the object
+*
+* OUTPUT:              
+* 
+* RETURNS:             void
+***************************************************************************/
+
+void rxData_resetDbgCounters(TI_HANDLE hRxData)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       os_memoryZero(pRxData->hOs,     &pRxData->rxDataDbgCounters, sizeof(rxDataDbgCounters_t));
+}
+
+
+/***************************************************************************
+*                                                       test functions                                                *
+***************************************************************************/
+void rxData_printRxCounters(TI_HANDLE hRxData)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+    if(pRxData) 
+    {
+        WLAN_OS_REPORT(("RecvOk = %d\n", pRxData->rxDataCounters.RecvOk));
+       WLAN_OS_REPORT(("DirectedBytesRecv = %d\n", pRxData->rxDataCounters.DirectedBytesRecv));
+       WLAN_OS_REPORT(("DirectedFramesRecv = %d\n", pRxData->rxDataCounters.DirectedFramesRecv));
+       WLAN_OS_REPORT(("MulticastBytesRecv = %d\n", pRxData->rxDataCounters.MulticastBytesRecv));
+       WLAN_OS_REPORT(("MulticastFramesRecv = %d\n", pRxData->rxDataCounters.MulticastFramesRecv));
+       WLAN_OS_REPORT(("BroadcastBytesRecv = %d\n", pRxData->rxDataCounters.BroadcastBytesRecv));
+       WLAN_OS_REPORT(("BroadcastFramesRecv = %d\n", pRxData->rxDataCounters.BroadcastFramesRecv));
+    
+       /* debug counters */
+        WLAN_OS_REPORT(("excludedFrameCounter = %d\n", pRxData->rxDataDbgCounters.excludedFrameCounter));
+           WLAN_OS_REPORT(("rxDroppedDueToVLANIncludedCnt = %d\n", pRxData->rxDataDbgCounters.rxDroppedDueToVLANIncludedCnt));    
+        WLAN_OS_REPORT(("rxWrongBssTypeCounter = %d\n", pRxData->rxDataDbgCounters.rxWrongBssTypeCounter));
+           WLAN_OS_REPORT(("rxWrongBssIdCounter = %d\n", pRxData->rxDataDbgCounters.rxWrongBssIdCounter));
+        WLAN_OS_REPORT(("rcvUnicastFrameInOpenNotify = %d\n", pRxData->rxDataDbgCounters.rcvUnicastFrameInOpenNotify));        
+    }
+}
+
+
+void rxData_printRxBlock(TI_HANDLE hRxData)
+{
+       rxData_t *pRxData = (rxData_t *)hRxData;
+
+       WLAN_OS_REPORT(("hCtrlData = 0x%X\n", pRxData->hCtrlData));
+       WLAN_OS_REPORT(("hMlme = 0x%X\n", pRxData->hMlme));
+       WLAN_OS_REPORT(("hOs = 0x%X\n", pRxData->hOs));
+       WLAN_OS_REPORT(("hReport = 0x%X\n", pRxData->hReport));
+       WLAN_OS_REPORT(("hRsn = 0x%X\n", pRxData->hRsn));
+       WLAN_OS_REPORT(("hSiteMgr = 0x%X\n", pRxData->hSiteMgr));
+       WLAN_OS_REPORT(("hMemMngr = 0x%X\n", pRxData->hMemMngr));
+
+       WLAN_OS_REPORT(("hCtrlData = 0x%X\n", pRxData->hCtrlData));
+       WLAN_OS_REPORT(("hMlme = 0x%X\n", pRxData->hMlme));
+       WLAN_OS_REPORT(("hOs = 0x%X\n", pRxData->hOs));
+       WLAN_OS_REPORT(("hReport = 0x%X\n", pRxData->hReport));
+       WLAN_OS_REPORT(("hRsn = 0x%X\n", pRxData->hRsn));
+       WLAN_OS_REPORT(("hSiteMgr = 0x%X\n", pRxData->hSiteMgr));
+       WLAN_OS_REPORT(("hMemMngr = 0x%X\n", pRxData->hMemMngr));
+
+       WLAN_OS_REPORT(("rxDataPortStatus = %d\n", pRxData->rxDataPortStatus));
+       WLAN_OS_REPORT(("rxDataExcludeUnencrypted = %d\n", pRxData->rxDataExcludeUnencrypted));
+       WLAN_OS_REPORT(("rxDataEapolDestination = %d\n", pRxData->rxDataEapolDestination));
+
+}
+
+
+void rxData_startRxThroughputTimer (TI_HANDLE hRxData)
+{
+    rxData_t *pRxData = (rxData_t *)hRxData;
+
+    if (!pRxData->rxThroughputTimerEnable)
+    {
+        /* reset throughput counter */
+        pRxData->rxDataCounters.LastSecBytesRecv = 0;
+        pRxData->rxThroughputTimerEnable = TRUE;
+
+        /* start 1 sec throughput timer */
+        os_timerStart (pRxData->hOs, pRxData->hThroughputTimer, 1000, TRUE);
+    }
+}
+
+
+void rxData_stopRxThroughputTimer (TI_HANDLE hRxData)
+{
+
+    rxData_t *pRxData = (rxData_t *)hRxData;
+
+    if (pRxData->rxThroughputTimerEnable)
+    {
+        os_timerStop (pRxData->hOs, pRxData->hThroughputTimer);
+        pRxData->rxThroughputTimerEnable = FALSE;
+    } 
+}
+
+
+static void rxData_printRxThroughput (TI_HANDLE hRxData)
+{
+    rxData_t *pRxData = (rxData_t *)hRxData;
+
+    WLAN_OS_REPORT (("\n"));
+    WLAN_OS_REPORT (("-------------- Rx Throughput Statistics ---------------\n"));
+    WLAN_OS_REPORT (("Throughput = %d KBits/sec\n", pRxData->rxDataCounters.LastSecBytesRecv * 8 / 1024));
+
+    /* reset throughput counter */
+    pRxData->rxDataCounters.LastSecBytesRecv = 0;
+}
+
+void rxData_printRxDataFilter (TI_HANDLE hRxData)
+{
+       UINT32 index;
+    rxData_t *pRxData = (rxData_t *)hRxData;
+
+       for (index=0; index<MAX_DATA_FILTERS; index++)
+        {
+               if (pRxData->isFilterSet[index])
+               {
+                       WLAN_OS_REPORT (("index=%d, pattern & mask\n", index));
+                       HexDumpData(pRxData->filterRequests[index].pattern, pRxData->filterRequests[index].patternLength);
+                       HexDumpData(pRxData->filterRequests[index].mask, pRxData->filterRequests[index].maskLength);
+               }
+               else
+               {
+                       WLAN_OS_REPORT (("No Filter defined for index-%d\n", index));
+               }
+        }
+}
+
+#endif /*TI_DBG*/
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Rx/rx.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Rx/rx.h
new file mode 100644 (file)
index 0000000..c72d9c0
--- /dev/null
@@ -0,0 +1,126 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: rx.h                                                                                                       */
+/*     PURPOSE:        Rx module functions header file                                            */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _RX_DATA_H_
+#define _RX_DATA_H_
+
+#include "paramIn.h"
+#include "paramOut.h"
+#include "memMngrEx.h"
+#include "whalBus_Defs.h"
+
+#define DEF_EXCLUDE_UNENCYPTED                         FALSE
+#define DEF_EAPOL_DESTINATION                          OS_ABS_LAYER
+#define DEF_RX_PORT_STATUS                                     CLOSE
+
+typedef struct 
+{
+       UINT32          excludedFrameCounter;   
+       UINT32          rxDroppedDueToVLANIncludedCnt;    
+    UINT32             rxWrongBssTypeCounter;
+       UINT32          rxWrongBssIdCounter;
+    UINT32      rcvUnicastFrameInOpenNotify;
+}rxDataDbgCounters_t;
+
+
+/*                         |                           |                         |
+ 31 30 29 28 | 27 26 25 24 | 23 22 21 20 | 19 18 17 16 | 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0
+                           |                           |                         |
+*/                                           
+
+
+typedef enum
+{
+       DATA_IAPP_PACKET  = 0,
+       DATA_EAPOL_PACKET = 1,
+       DATA_DATA_PACKET  = 2,
+    DATA_VLAN_PACKET  = 3,
+       MAX_NUM_OF_RX_DATA_TYPES,
+}rxDataPacketType_e;
+
+
+
+typedef void (*rxData_MsduDispatchert)(TI_HANDLE hRxData , mem_MSDU_T *pMsdu , Rx_attr_t *pRxAttr);
+
+
+typedef struct 
+{
+       /* Handles */
+       TI_HANDLE                       hCtrlData;
+       TI_HANDLE                       hTxData;
+       TI_HANDLE                       hTnetwDrv;
+    TI_HANDLE           hHalCtrl;
+       TI_HANDLE                       hMlme;
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hRsn;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hMemMngr;
+       TI_HANDLE                       hSiteMgr;
+       TI_HANDLE                       hExcMgr;
+    TI_HANDLE           hEvHandler;
+    TI_HANDLE           RxEventDistributor;
+       TI_HANDLE           hThroughputTimer;
+    BOOL                rxThroughputTimerEnable;
+       BOOL                            rxDataExcludeUnencrypted;
+    BOOL                rxDataExludeBroadcastUnencrypted;
+       eapolDestination_e      rxDataEapolDestination;
+
+       portStatus_e            rxDataPortStatus;
+       
+    mem_MSDU_T *pReqForBufMsdu; /* request for buffer MSDU - (the lower layer gets only the pointer to the data) */
+
+    /* Rx Data Filters */
+    filter_e            filteringDefaultAction;
+    BOOL                filteringEnabled;
+    BOOL                isFilterSet[MAX_DATA_FILTERS];
+    rxDataFilterRequest_t filterRequests[MAX_DATA_FILTERS];
+
+       /* Counters */
+       rxDataCounters_t        rxDataCounters;
+       rxDataDbgCounters_t     rxDataDbgCounters;
+
+       rxData_MsduDispatchert rxData_dispatchMsdu[MAX_NUM_OF_RX_PORT_STATUS][MAX_NUM_OF_RX_DATA_TYPES];
+
+       INT32                           prevSeqNum;
+}rxData_t;
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/MsduList.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/MsduList.c
new file mode 100644 (file)
index 0000000..8c478d3
--- /dev/null
@@ -0,0 +1,487 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: envList.c                                                                                              */
+/*    PURPOSE: Envelope list implementation                                               */
+/*                                                                                                                                                */
+/***************************************************************************/
+#include "MsduList.h"
+#include "osTIType.h"
+#include "paramIn.h"
+#include "osApi.h"
+
+/*************************************************************************
+ *                        msduList_CreateNewMsduList                     *
+ *************************************************************************
+DESCRIPTION: This function creates new Msdu list. 
+                
+INPUT:       maxNumOfElements : The maximum number of elements allowd 
+                        pOs                      : Pointer to os abstraction layer
+
+OUTPUT:      
+
+RETURN:      MsduList_T                                                 
+*************************************************************************/
+MsduList_t* msduList_CreateNewMsduList(  TI_HANDLE hOs )
+{
+       
+       MsduList_t* msduList = (MsduList_t*) os_memoryAlloc(hOs,sizeof(MsduList_t));
+       if( msduList == NULL )
+        return NULL;
+
+       if(( msduList->hCriticalSectionProtect = os_protectCreate(hOs)) == NULL)
+       {
+           WLAN_OS_REPORT(("FATAL ERROR: Could not Create Critical Section Protection for Msdu List - Aborting\n"));
+          
+               /* free Msdu List Control Block */
+               os_memoryFree(hOs, msduList, sizeof(MsduList_t));
+
+               return NULL;
+       }
+
+    msduList->hOs = hOs;
+       
+       msduList->first = NULL;
+       msduList->last = NULL;
+       msduList->maxNumOfMsdu = 0;
+       msduList->CurrNumOfMsdu = 0;
+       msduList->ovFlowPolicy = DROP_NEW_PACKET;
+       msduList->numOfOverFlow = 0;
+       msduList->maxCurrOfMsdu =0;
+
+       return msduList;
+}
+
+/*************************************************************************
+ *                        msduList_ConfigMsduList                        *
+ *************************************************************************
+DESCRIPTION: This function configure the Msdu list. 
+                
+INPUT:       *this     :                       A pointer to the list to configure
+                        msduListConfig :       Pointer to the Msdu list configuration
+                                                               structure.
+
+OUTPUT:      
+
+RETURN:      TI_STATUS: OK/NOK                                                 
+*************************************************************************/
+TI_STATUS msduList_ConfigMsduList( MsduList_t* this,   TI_HANDLE hMemMgr,
+                                                        TI_HANDLE hReport, TI_HANDLE hOs,INT16 maxNumOfElements)
+{
+       if( hOs == NULL || hReport == NULL || 
+               this == NULL || hMemMgr == NULL)
+               return NOK;
+
+       this->hReport = hReport;
+       this->hMemMgr = hMemMgr;
+       this->hOs = hOs;
+       this->maxNumOfMsdu = maxNumOfElements;
+
+       this->useAdmissionAlgo = FALSE;
+       this->credit = 0;
+       this->enableTransmissionTime = 0;
+       this->lastTimeStamp = 0;
+       this->mediumTime = 0;
+       this->totalUsedTime = 0;
+       
+       this->highMediumUsageThreshold = 0;
+       this->lowMediumUsageThreshold = 0;
+
+
+       return OK;
+
+}
+
+/*************************************************************************
+ *                        msduList_SetMsduListNumOfElements              *
+ *************************************************************************
+DESCRIPTION: This function configure the Msdu list max num of elements. 
+                
+INPUT:       *this     :                       A pointer to the list to configure
+                        maxNumOfElements:  max num of elements.
+OUTPUT:      
+
+RETURN:      TI_STATUS: OK/NOK                                                 
+*************************************************************************/
+
+TI_STATUS      msduList_SetMsduListNumOfElements( MsduList_t* this, UINT16 maxNumOfElements)
+{
+       if(this == NULL)
+               return NOK;
+
+       this->maxNumOfMsdu = maxNumOfElements;
+
+       return OK;
+
+}
+
+/*************************************************************************
+ *                        msduList_SetMsduListOverFlowPolicy             *
+ *************************************************************************
+DESCRIPTION: This function configure the Msdu list policy in case of over flow . 
+                
+INPUT:       *this     :                       A pointer to the list to configure
+                        QueueOvFlowPolicy:  over flow polict - new packet drop or old packet drop.
+OUTPUT:      
+
+RETURN:      TI_STATUS: OK/NOK                                                 
+*************************************************************************/
+
+TI_STATUS      msduList_SetMsduListOverFlowPolicy( MsduList_t* this, qOvFlowPolicy_e  QueueOvFlowPolicy)
+{
+       if(this == NULL)
+               return NOK;
+
+       this->ovFlowPolicy = QueueOvFlowPolicy;
+
+       return OK;
+
+}
+
+
+/*************************************************************************
+ *                        msduList_FreeMsduList                          *
+ *************************************************************************
+DESCRIPTION: This function free the Msdu list. 
+                
+INPUT:       *this     :       A pointer to the list to free
+                        pOs    :       Pointer to os abstraction layer
+
+OUTPUT:      
+
+RETURN:      TI_STATUS: OK/NOK
+*************************************************************************/
+TI_STATUS msduList_FreeMsduList( MsduList_t* this)
+{
+       if( this->CurrNumOfMsdu != 0 )
+       {
+               if( msduList_EmptyMsduList( this ) != OK )
+               {
+                       WLAN_REPORT_ERROR(this->hReport, TX_DATA_MODULE_LOG, 
+                               (" msduList_FreeMsduList() : failed \n"));
+                       return NOK;
+               }
+       }
+
+       /* free protection */
+       os_protectDestroy(this->hOs,this->hCriticalSectionProtect);
+
+       /* free msdu control block */
+       os_memoryFree(this->hOs, this, sizeof(MsduList_t));
+       
+       return OK;                      
+
+}
+
+/*************************************************************************
+ *                        msduList_EmptyMsduList                                                *
+ *************************************************************************
+DESCRIPTION: This function free all the MSDUs from the Msdu list.
+                
+INPUT:       *this     :       A pointer to the list to empty
+                        pOs    :       Pointer to os abstraction layer
+
+OUTPUT:      
+
+RETURN:      TI_STATUS: OK/NOK
+*************************************************************************/
+TI_STATUS msduList_EmptyMsduList( MsduList_t* this)
+{
+       UINT32 count;
+       mem_MSDU_T* pTempMsdu;
+
+       os_protectLock(this->hOs, this->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+       if( this->CurrNumOfMsdu == 0 )
+       {
+               WLAN_REPORT_INFORMATION(this->hReport, TX_DATA_MODULE_LOG,
+                       (" msduList_EmptyMsduList() : List is empty \n"));
+               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+               return OK;
+       }
+       
+       /* update Tx status to NOK for all msdu in list */
+       pTempMsdu = this->first;
+       for(count = 0 ; count < this->CurrNumOfMsdu ; count++)
+       {
+               memMgr_MsduFreeArg2Get(pTempMsdu) = NOK;
+               pTempMsdu = pTempMsdu->nextMSDUinList;
+       }
+
+       os_protectUnlock(this->hOs, this->hCriticalSectionProtect);
+       /* free all msdu back to the memMngr */
+       if ((wlan_memMngrFreeListOfMSDU(this->hMemMgr, memMgr_MsduHandle(       this->first))) != OK)
+       {
+               WLAN_REPORT_ERROR(this->hReport, TX_DATA_MODULE_LOG,  
+                       (" msduList_EmptyMsduList() : Msdu free failed \n"));
+       }
+       
+       os_protectLock(this->hOs, this->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+       this->first = NULL;
+       this->last = NULL;
+       this->CurrNumOfMsdu = 0;
+       this->numOfOverFlow = 0;
+       this->maxCurrOfMsdu = 0;
+
+       this->useAdmissionAlgo = FALSE;
+       this->credit = 0;
+       this->enableTransmissionTime = 0;
+       this->lastTimeStamp = 0;
+       this->mediumTime = 0;
+       this->totalUsedTime = 0;
+
+       os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+       
+       return OK;
+}
+
+/*************************************************************************
+ *                        msduList_MsduListIns                           *
+ *************************************************************************
+DESCRIPTION: This function insert MSDU to the list pointed by this.                 
+                                                                                                   
+INPUT:       *this :   A pointer to the list to insert. 
+             *pMsdu :  Pointer to the MSDU to insert, the MSDU
+                        is inserted to be the last in the list. If the 
+                        list is full the first MSDU will be taken 
+                        out and will be returned in this pointer.
+
+OUTPUT:      *pMsdu :  In case the list is full,this poiter will hold 
+                                               the dropt MSDU's. 
+
+RETURN:      OK :              The MSDU has been inserted, there was enough 
+                                               place in the list.
+             NOK:              The list was full, the first MSDU is dropt, and 
+                                               returned by *pMsdu.                                                                                                                                                  
+************************************************************************/
+TI_STATUS msduList_Insert( MsduList_t* this , mem_MSDU_T  **pMsdu )
+{
+       
+       os_protectLock(this->hOs, this->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+       
+       if( this->CurrNumOfMsdu == 0 )
+       {
+               this->last = *pMsdu;
+               this->first = *pMsdu;
+               (*pMsdu)->nextMSDUinList = NULL;
+               (*pMsdu)->prevMSDUinList = NULL;
+               this->CurrNumOfMsdu++;
+               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+               
+               /* for debug */
+               if( this->CurrNumOfMsdu > this->maxCurrOfMsdu )
+                       this->maxCurrOfMsdu = this->CurrNumOfMsdu;
+               
+               return OK;
+       }
+       else
+       {
+               if(  this->CurrNumOfMsdu == this->maxNumOfMsdu ) 
+               { 
+                       this->numOfOverFlow++;
+                       
+                       if(this->ovFlowPolicy == DROP_NEW_PACKET)
+                       {
+                               /* The list is full, remove the new coming msdu*/
+                               WLAN_REPORT_INFORMATION(this->hReport, TX_DATA_MODULE_LOG,  
+                                       (" msduList_MsduListIns() : New Msdu has to be removed \n"));
+                               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+                               
+                               /* for debug */
+                               if( this->CurrNumOfMsdu > this->maxCurrOfMsdu )
+                                       this->maxCurrOfMsdu = this->CurrNumOfMsdu;
+
+                               return NOK;
+                               
+                       }else
+                       {
+                               /* The list is full, insert the new msdu and remove the first msdu*/
+                               this->last->nextMSDUinList = *pMsdu;
+                               (*pMsdu)->prevMSDUinList = this->last;
+                               (*pMsdu)->nextMSDUinList = NULL;
+                               this->last = *pMsdu;
+                               
+                               /* remove the first msdu from list */
+                               (*pMsdu) = this->first;
+                               this->first = this->first->nextMSDUinList;
+                               this->first->prevMSDUinList = NULL;
+                               (*pMsdu)->nextMSDUinList = NULL;
+                               
+                               WLAN_REPORT_INFORMATION(this->hReport, TX_DATA_MODULE_LOG,  
+                                       (" msduList_MsduListIns() : First Msdu was removed \n"));
+                               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+                               /* indicate that the first msdu has removed */
+                               
+                               /* for debug */
+                               if( this->CurrNumOfMsdu > this->maxCurrOfMsdu )
+                                       this->maxCurrOfMsdu = this->CurrNumOfMsdu;
+
+                               return NOK;
+                               
+                       }
+               }
+               else                    
+               { /* insert the MSDU to be the last. */
+                       this->last->nextMSDUinList = *pMsdu;
+                       (*pMsdu)->prevMSDUinList = this->last;
+                       (*pMsdu)->nextMSDUinList = NULL;
+                       this->last = *pMsdu;
+               }   
+               
+               this->CurrNumOfMsdu++;
+               
+               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+       
+               /* for debug */
+               if( this->CurrNumOfMsdu > this->maxCurrOfMsdu )
+                       this->maxCurrOfMsdu = this->CurrNumOfMsdu;
+               
+               return OK;
+       }
+}
+
+
+/*************************************************************************
+ *                        msduList_MsduListGetFirst                        *
+ *************************************************************************
+DESCRIPTION: This function get MSDU to the list pointed by this.                 
+                                                                                                   
+INPUT:       *this : A pointer to the list to get. 
+
+OUTPUT:      *pMsdu : A pointer to the first MSDU in the list. 
+
+RETURN:      OK : There was an MSDU in the list, and it is assigned 
+                  to the *pMsdu.
+             NOK: The list was empty, *pMsdu is trush.     
+************************************************************************/
+TI_STATUS msduList_GetFirst( MsduList_t *this, mem_MSDU_T  **pMsdu)
+{
+       
+       os_protectLock(this->hOs, this->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+       
+       if( this->CurrNumOfMsdu == 0 )
+       {
+               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+               return NOK;
+       }
+       
+       *pMsdu = this->first;
+       this->first = this->first->nextMSDUinList;
+       if (this->first != NULL)
+               this->first->prevMSDUinList = NULL;
+       this->CurrNumOfMsdu--;
+       (*pMsdu)->nextMSDUinList = NULL;
+       
+       os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+       
+       return OK;
+}
+
+/*************************************************************************
+ *                        msduList_MsduListWatchFirst                       *
+ *************************************************************************
+DESCRIPTION: This function watch at the first SDU in the list. The 
+             MSDU is not removed yet from the list.                 
+                                                                                                   
+INPUT:       *this : A pointer to the list to watch. 
+
+OUTPUT:      *pMsdu : A pointer to the first MSDU in the list. 
+
+RETURN:      OK : There was an MSDU in the list, and it is assigned 
+                  to the *pMsdu.
+             NOK: The list was empty, *pMsdu is trush.     
+************************************************************************/
+TI_STATUS msduList_WatchFirst( MsduList_t *this, mem_MSDU_T  **pMsdu)
+{
+       os_protectLock(this->hOs, this->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+       
+       if( this->CurrNumOfMsdu == 0 )
+       {
+               os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+               return NOK;
+       }
+
+       *pMsdu = this->first;
+       
+       os_protectUnlock(this->hOs, this->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+       
+    return OK;
+}
+
+UINT32 msduList_getCurrNumOfMsdu(MsduList_t *this)
+{
+       return this->CurrNumOfMsdu;
+}
+
+
+/* Debug functions */
+/*-----------------*/
+void printMsduList(MsduList_t *this)
+{
+       WLAN_OS_REPORT(("Msdu List : \n"));
+
+       WLAN_OS_REPORT(("first         = %X\n", this->first));
+       WLAN_OS_REPORT(("last          = %X\n", this->last));
+       WLAN_OS_REPORT(("maxNumOfMsdu  = %d\n", this->maxNumOfMsdu));
+       WLAN_OS_REPORT(("CurrNumOfMsdu = %d\n", this->CurrNumOfMsdu));
+       WLAN_OS_REPORT(("numOfOverFlow = %d\n", this->numOfOverFlow));
+       WLAN_OS_REPORT(("maxCurrOfMsdu = %d\n", this->maxCurrOfMsdu));
+
+       WLAN_OS_REPORT(("useAdmissionAlgo = %d\n", this->useAdmissionAlgo));
+       WLAN_OS_REPORT(("credit = %d\n", this->credit));
+       WLAN_OS_REPORT(("enableTransmissionTime  = %d\n", this->enableTransmissionTime));
+       WLAN_OS_REPORT(("lastTimeStamp = %d\n", this->lastTimeStamp));
+       WLAN_OS_REPORT(("mediumTime = %d\n", this->mediumTime));
+       WLAN_OS_REPORT(("totalUsedTime = %d\n", this->totalUsedTime));
+
+}
+
+void printFullMsduList(MsduList_t *this)
+{
+       mem_MSDU_T*     tmpMSDU;
+       UINT32                  i=0;
+
+       printMsduList(this);
+
+    tmpMSDU = this->first;
+    while (++i, tmpMSDU != NULL) 
+       {
+        WLAN_OS_REPORT(("tmpMSDU %d = %X handle=%d tmpMSDU->nextMSDU=%X\n", i, tmpMSDU, tmpMSDU->handle, tmpMSDU->nextMSDUinList));
+        tmpMSDU = tmpMSDU->nextMSDUinList;
+    }
+
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/MsduList.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/MsduList.h
new file mode 100644 (file)
index 0000000..ec48eaa
--- /dev/null
@@ -0,0 +1,120 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+  
+/***************************************************************************/
+/*                                                                                                                                        */
+/*             MODULE: MsduList.c                                                                                         */
+/*    PURPOSE: MSDU list implementation                                                   */
+/*                                                                                                                                    */
+/***************************************************************************/
+
+#ifndef _MSDU_LIST_H_
+#define _MSDU_LIST_H_
+
+#include "memMngrEx.h"
+#include "report.h" 
+
+
+/************************************************************************/
+/* MSDU link list definition.                                                                                  */
+/************************************************************************/
+typedef struct 
+{
+       TI_HANDLE       hMemMgr;                /* handle to memory manger */
+       TI_HANDLE       hReport;                /* handle to Report object */
+       TI_HANDLE       hOs;                    /* handle to Os Abstraction object */
+
+       TI_HANDLE       hCriticalSectionProtect;
+
+       mem_MSDU_T *first;                      /* Points to the first Msdu's in the list. */
+       mem_MSDU_T *last;                       /* Points to the last Msdu's is the list. */
+       UINT16   maxNumOfMsdu;          /* The maximum number of Msdu's allowed to be in the queue. */
+       UINT16   CurrNumOfMsdu;         /* The current number of Msdu's.         */
+       qOvFlowPolicy_e  ovFlowPolicy; /* tx over flow policy */
+
+       UINT16  numOfOverFlow ;
+       UINT16  maxCurrOfMsdu ;
+
+       /* admission ctrl params */
+       UINT8   acId;   /* the AC used for this Tx queue. */
+       BOOL    useAdmissionAlgo;
+       INT32   credit;
+       UINT32  enableTransmissionTime ;
+       UINT32  lastTimeStamp;
+       UINT32  mediumTime;
+       
+       UINT32 totalUsedTime;
+
+       trafficAdmState_e  admissionState;
+       admissionState_e   admissionRequired;
+
+
+       INT32 highMediumUsageThreshold;
+       INT32 lowMediumUsageThreshold;
+       UINT8 selectionHistoryCounter; /* When selected by Tx scheduler this counter is preset, and is decremented
+                                                                         every scheduler activation, so we have some indication on selections history. */
+
+}MsduList_t;
+
+
+MsduList_t* msduList_CreateNewMsduList(TI_HANDLE hOs );
+
+TI_STATUS      msduList_ConfigMsduList( MsduList_t* this,      TI_HANDLE hMemMgr,
+                                                        TI_HANDLE hReport, TI_HANDLE hOs,INT16 maxNumOfElements );
+
+TI_STATUS      msduList_SetMsduListNumOfElements( MsduList_t* this, UINT16 maxNumOfElements);
+
+TI_STATUS      msduList_SetMsduListOverFlowPolicy( MsduList_t* this, qOvFlowPolicy_e  QueueOvFlowPolicy);
+
+TI_STATUS msduList_FreeMsduList( MsduList_t* this);
+
+TI_STATUS msduList_EmptyMsduList( MsduList_t* this );
+
+TI_STATUS msduList_Insert( MsduList_t* this , mem_MSDU_T  **pMsdu );
+
+TI_STATUS msduList_WatchFirst( MsduList_t *this, mem_MSDU_T  **pMsdu );
+
+TI_STATUS msduList_GetFirst( MsduList_t *this, mem_MSDU_T  **pMsdu );
+
+UINT32 msduList_getCurrNumOfMsdu(MsduList_t *this);
+
+
+/* Test Functions */
+/*----------------*/
+void printFullMsduList(MsduList_t *this);
+void printMsduList(MsduList_t *this);
+
+
+#endif /* _MSDU_LIST_H_ */
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/tx.c b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/tx.c
new file mode 100644 (file)
index 0000000..89832ab
--- /dev/null
@@ -0,0 +1,4557 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE: Tx.c                                                       */
+/*    PURPOSE:  Tx module functions                                        */
+/*                                                                         */
+/***************************************************************************/
+#include "osTIType.h"
+#include "paramIn.h"
+#include "paramOut.h"
+#include "osApi.h"
+#include "tx.h"
+#include "DataCtrl_Api.h"
+#include "siteMgrApi.h"
+#include "802_11Defs.h"
+#include "Ethernet.h"
+/* GWSI_LAYER */
+#include "Core_AdaptTx.h"
+
+#include "memMngrEx.h"
+#include "report.h"
+#include "utils.h"
+#include "measurementMgrApi.h"
+#include "TI_IPC_Api.h"
+#include "EvHandler.h"
+#include "qosMngr_API.h"
+#include "PowerMgr_API.h"
+#include "bufferPoolApi.h"
+#include "TNETW_Driver_api.h"
+
+/*
+This is an Ethernet Version 2 frame:
+
+       +--------------+
+       |              | The destination address is a six byte Media Access
+       | Destination  | Control (MAC) address, usually burned into the
+       |   6 bytes    | ROM of the Ethernet card.
+       +--------------+
+       |              | The source address is a six byte MAC address, and
+       |   Source     | can signify a physical station or a broadcast.
+       |   6 bytes    |
+       +--------------+
+       |     Type     | The Type field it must be grater then 1500 dec.
+       |    2 bytes   |
+       +--------------+
+       |              |  Any higher layer information is placed in the
+       |    Data      |  data field, which could contain protocol
+       |              |  information or user data.
+       ~              ~
+       ~              ~
+       |  46 to 1500  |
+       |    bytes     |
+       |              |
+       +--------------+
+       |     FCS      |
+       |   4 bytes    |
+       +--------------+
+
+
+
+*/
+/*
+
+        802.2 SNAP DATA Frame
+       +----------------+
+       |                |
+       |  Destination   |
+       |    6 bytes     |
+       +----------------+
+       |                |
+       |     Source     |
+       |    6 bytes     |
+       +----------------+
+       |  Frame Length  | Must be <= 1500 Dec.
+       |    2 bytes     |
+       +----------------+
+       |  DSAP - 1 byte | = 0xAA ( SNAP )
+       +----------------+
+       |  SSAP - 1 byte | = 0xAA ( SNAP )
+       +----------------+
+       |Control - 1 byte| = 0x03
+       +----------------+
+       | OUI - 3 bytes  | = 0x0
+       |                |
+       +----------------+
+       | Type - 2 bytes |  = Ethernet type (IP=0x0800)
+       +----------------+
+       |                |
+       |      Data      |
+       |                |
+       ~                ~
+       ~                ~
+       |   46 to 1500   |
+       |     bytes      |
+       |                |
+       +----------------+
+       |      FCS       |
+       |    4 bytes     |
+       +----------------+
+
+
+
+
+        802.11 DATA Frame
+       +----------------+
+       |                |
+       |  Frame Control |
+       |    2 bytes     |
+       +----------------+
+       |                |
+       |  Duration ID   |
+       |    2 bytes     |
+       +----------------+
+       |                |
+       |   Address 1    |
+       |    6 bytes     |
+       +----------------+
+       |                |
+       |   Address 2    |
+       |    6 bytes     |
+       +----------------+
+       |                |
+       |   Address 3    |
+       |    6 bytes     |
+       +----------------+
+       |                |
+       | Sequence Cntrl |
+       |    2 bytes     |
+       +----------------+
+       |                |
+       |   Address 4    |
+       |    6 bytes     |
+       +----------------+
+       |  DSAP - 1 byte | = 0xAA ( SNAP )
+       +----------------+
+       |  SSAP - 1 byte | = 0xAA ( SNAP )
+       +----------------+
+       |Control - 1 byte| = 0x03
+       +----------------+
+       | OUI - 3 bytes  | = 0x0
+       |                |
+       +----------------+
+       | Type - 2 bytes |  = Ethernet type (IP=0x0800)
+       +----------------+
+       |                |
+       |      Data      |
+       |                |
+       ~                ~
+       ~                ~
+       |   46 to 1500   |
+       |     bytes      |
+       |                |
+       +----------------+
+       |      FCS       |
+       |    4 bytes     |
+       +----------------+
+
+*/
+
+/* Tx queue selection definitions */    
+#define Q_LEAST_WEIGHT              0xFFFFFFFF /* Use least possible weight as init value (highest value is lowest priority). */
+#define Q_SELECTION_HISTORY_LEVEL   5   /* Count down from this value if queue is selected to Tx. */
+
+
+#define MANAGEMENT_QUEUE_SIZE           16
+
+#define DEFAULT_QUEUE_TO_HAL            1
+
+#define EAPOL_PACKET                    0x8E88
+
+/* defined in QosMngr.c - used to update QosControl (userPriority) of a given packet after it has been "downgraded" due to admission control */
+extern UINT8 wmeAcToUpIndex[MAX_NUM_OF_AC];
+
+/* defined in qosMngr.c - used to identify voice packets in NON QOS APs */
+extern int WMEQosTagToACTable[MAX_NUM_OF_802_1d_TAGS];
+
+/* this macro accesses the WME Tag-to-AC conversion array in order to enable identifying voice packets even on NON QOS APs */
+#define GET_WME_AC_TYPE_FROM_MSDU(pMsdu)  (WMEQosTagToACTable[pMsdu->qosTag])
+
+#define GET_QUEUE_INDEX(pTxData,acIndex)  (pTxData->txDataAcTrfcCtrl[acIndex].QueueIndex)
+
+#define ABS(a)  (((int)(a) >= 0) ? (a) : -((int)(a)))
+
+static void txData_convertEthToWlanHeader (txData_t *pTxData, mem_MSDU_T *pMsdu);
+
+static TI_STATUS txData_schedulerSelectQueueToTransmitFrom( TI_HANDLE hTxData, MsduList_t** pMsduListPtr,UINT8 *selectedQueueIndex );
+
+static void txData_startTxSchedulerFromTimer(TI_HANDLE hTxData);
+
+static void txData_calcCreditFromTimer(TI_HANDLE hTxData);
+
+static void txData_UpdateTxCounters( TI_HANDLE hTxData, txCompleteAttr_t *pTxCompleteAttr );
+
+static void txData_SetTxDelayCounters( TI_HANDLE hTxData, UINT32 txQid, txCompleteAttr_t *pTxCompleteAttr, UINT32 driverDelay );
+
+static int txData_selectQueueAndUpdateUserPriority (txData_t *pTxData, mem_MSDU_T *pMsdu, int *selectedQueue, acTrfcType_e *selectedAc);
+
+static int txData_getHighestAdmittedAc(txData_t *pTxData, int startingAcIndex);
+
+static void txData_startVadTimer(TI_HANDLE hTxData, UINT16 voiceDuration);
+static void txData_stopVadTimer(TI_HANDLE hTxData);
+static void txData_setVadTimer(TI_HANDLE hTxData, BOOL vadEnabled, UINT16 duration);
+static void txData_resetVadTimer(TI_HANDLE hTxData);
+static void txData_vadTimeout(TI_HANDLE hTxData);
+#ifdef TI_DBG
+
+static void txData_printTxThroughputPerQueue(TI_HANDLE hTxData);
+
+static void txData_printTxAirThroughputPerQueue(TI_HANDLE hTxData);
+
+static void txData_printJitter(TI_HANDLE hTxData);
+
+#endif
+
+static BOOL txData_acVoPsPollMode(txData_t *pTxData);
+
+static UINT32 txDataTimeToMsduExpiry( TI_HANDLE htxData, mem_MSDU_T* pMsdu, UINT8 Qid);
+
+static UINT8 txData_GetAcIdFromQid(TI_HANDLE hTxData,UINT8 Qid);
+
+TI_STATUS txData_setMediumUsageThresholds(TI_HANDLE     hTxData,
+                                      UINT8             acID,
+                                      INT32             highMediumUsageThreshold,
+                                      INT32             lowMediumUsageThreshold);
+
+static void txData_SetQidToAcTable(TI_HANDLE hTxData,UINT8 QidStart, UINT8 QidEnd,UINT8 AcId);
+
+/* The TX delay histogram ranges start and end in msec. */
+static UINT32 txDelayRangeStart[TX_DELAY_RANGES_NUM] = { 0,  1, 10, 20, 40, 60,  80, 100, 200 };
+static UINT32 txDelayRangeEnd  [TX_DELAY_RANGES_NUM] = { 1, 10, 20, 40, 60, 80, 100, 200, 0xFFFFFFFF };
+
+/*************************************************************************
+*                        txData_create                                   *
+**************************************************************************
+* DESCRIPTION:  This function initializes the Tx module.
+*
+* INPUT:        hOs - handle to Os Abstraction Layer
+*               txDataInitParams - Tx Data creation parameters
+* OUTPUT:
+*
+* RETURN:       Handle to the allocated Tx data control block
+*************************************************************************/
+TI_HANDLE txData_create(txDataInitParams_t *txDataInitParams,
+                        TI_HANDLE hOs)
+{
+
+    txData_t *hTxData;
+    MsduList_t *mgmtMsduList;
+    MsduList_t *dataMsduListArr[MAX_NUM_OF_TX_QUEUES];
+    void* pTimer;
+  #ifdef TI_DBG
+    void* pThroughputTimer;
+    void* pAirThroughputTimer;
+    void* pJitterTimer;
+  #endif
+    void* pCreditTimer;
+    void* pVadTimer;
+    int queueIndex = 0;
+
+
+    /* check parameters validity */
+    if( txDataInitParams->txDataNumOfDataQueues > MAX_NUM_OF_TX_QUEUES ||
+        txDataInitParams->txDataNumOfDataQueues <= 0 )
+    {
+        WLAN_OS_REPORT(("FATAL ERROR - UNABLE TO CREATE TX MODULE. Number of queues error = %d.",txDataInitParams->txDataNumOfDataQueues));
+        return NULL;
+    }
+
+    /* allocate Tx module control block */
+    hTxData = os_memoryAlloc(hOs, (sizeof(txData_t)));
+
+    if(!hTxData)
+        return NULL;
+
+    /* reset tx control block */
+    os_memoryZero(hOs, hTxData, (sizeof(txData_t)));
+
+    /* allocate the buffer pool */
+    hTxData->hBufferPool = bufferPool_create( hOs, 
+                                              HAL_CTRL_ACX_TX_DESC_DEF * MAX_NUM_OF_TX_QUEUES, 
+                                              sizeof(txPacketIdAttr_t) );
+    if ( NULL == hTxData->hBufferPool )
+    {
+        utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+
+    /* allocate Timer to use for scheduler trigger */
+    pTimer = os_timerCreate(hOs, txData_startTxSchedulerFromTimer, hTxData);
+    if(!pTimer)
+    {
+        bufferPool_destroy( hTxData->hBufferPool );
+        utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+
+    /* allocate Timer for vad operation */
+    pVadTimer = os_timerCreate(hOs, txData_vadTimeout, hTxData);
+    if(!pVadTimer)
+    {
+        bufferPool_destroy( hTxData->hBufferPool );
+        utils_nullTimerDestroy (hOs, pTimer);        
+        utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+  #ifdef TI_DBG
+    /* allocate timer for debug throughput per queue */
+    pThroughputTimer = os_timerCreate(hOs, txData_printTxThroughputPerQueue, hTxData);
+    if(!pThroughputTimer)
+    {
+        bufferPool_destroy( hTxData->hBufferPool );
+        utils_nullTimerDestroy(hOs, pTimer);
+        utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+
+    /* allocate timer for debug throughput per queue */
+    pAirThroughputTimer = os_timerCreate (hOs, txData_printTxAirThroughputPerQueue, hTxData);
+    if (!pAirThroughputTimer)
+    {
+        bufferPool_destroy (hTxData->hBufferPool);
+        utils_nullTimerDestroy (hOs, pTimer);
+        utils_nullTimerDestroy (hOs, pThroughputTimer);
+        utils_nullMemoryFree (hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+
+    /* allocate timer for debug throughput per queue */
+    pJitterTimer = os_timerCreate (hOs, txData_printJitter, hTxData);
+    if (!pJitterTimer)
+    {
+        bufferPool_destroy (hTxData->hBufferPool);
+        utils_nullTimerDestroy (hOs, pTimer);
+        utils_nullTimerDestroy (hOs, pThroughputTimer);
+        utils_nullTimerDestroy (hOs, pAirThroughputTimer);
+        utils_nullMemoryFree (hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+  #endif
+
+    /* allocate timer for credit calculation */
+    pCreditTimer = os_timerCreate(hOs, txData_calcCreditFromTimer, hTxData);
+    if(!pCreditTimer)
+    {
+        bufferPool_destroy( hTxData->hBufferPool );
+        utils_nullTimerDestroy(hOs, pTimer);
+      #ifdef TI_DBG
+        utils_nullTimerDestroy(hOs, pThroughputTimer);
+        utils_nullTimerDestroy(hOs, pAirThroughputTimer);
+        utils_nullTimerDestroy(hOs, pJitterTimer);
+      #endif
+        utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+
+    /* initialize management queue */
+    mgmtMsduList = msduList_CreateNewMsduList( hOs);
+    if(!mgmtMsduList)
+    {
+        bufferPool_destroy( hTxData->hBufferPool );
+        utils_nullTimerDestroy(hOs, pTimer);
+      #ifdef TI_DBG
+        utils_nullTimerDestroy(hOs, pThroughputTimer);
+        utils_nullTimerDestroy(hOs, pAirThroughputTimer);
+        utils_nullTimerDestroy(hOs, pJitterTimer);
+      #endif
+        utils_nullTimerDestroy(hOs, pCreditTimer);
+        utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+        return NULL;
+    }
+
+    /* initialize tx data queues */
+    for(queueIndex = 0 ; queueIndex < MAX_NUM_OF_TX_QUEUES ; queueIndex++)
+    {
+        dataMsduListArr[queueIndex] = msduList_CreateNewMsduList( hOs);
+        if(!dataMsduListArr[queueIndex])
+        {
+            bufferPool_destroy( hTxData->hBufferPool );
+            utils_nullTimerDestroy(hOs, pTimer);
+          #ifdef TI_DBG
+            utils_nullTimerDestroy(hOs, pThroughputTimer);
+            utils_nullTimerDestroy(hOs, pAirThroughputTimer);
+            utils_nullTimerDestroy(hOs, pJitterTimer);
+          #endif
+            utils_nullTimerDestroy(hOs, pCreditTimer);
+            utils_nullMemoryFree(hOs, mgmtMsduList, sizeof(MsduList_t));
+            queueIndex--;
+            for(; queueIndex >= 0 ; queueIndex--)
+            {
+                utils_nullMemoryFree(hOs, dataMsduListArr[queueIndex], sizeof(MsduList_t));
+            }
+            utils_nullMemoryFree(hOs, hTxData, sizeof(txData_t));
+            return NULL;
+        }
+    }
+
+    hTxData->txDataNumOfQueues = txDataInitParams->txDataNumOfDataQueues;
+
+    /* Threshold to decide whether we drop the packet, or sending it to Fw      */
+    /* example: value of 75 will drop any MSDU that stayed it the Driver        */
+    /* Queues for more than 75% of the time that was originally defined for it  */
+    hTxData->uFracOfLifeTimeToDrop = txDataInitParams->uFracOfLifeTimeToDrop;
+
+    hTxData->TxEventDistributor = DistributorMgr_Create(hOs,MAX_TX_NOTIF_REQ_ELMENTS);
+
+    hTxData->mngMsduList = mgmtMsduList;
+    for(queueIndex = 0 ; queueIndex < MAX_NUM_OF_TX_QUEUES ; queueIndex++)
+    {
+        hTxData->dataMsduListArr[queueIndex] = dataMsduListArr[queueIndex];
+    }
+    hTxData->pSchedulerTimer = pTimer;
+    hTxData->pVadTimer = pVadTimer;
+    hTxData->bSchedulerTimerRunning = FALSE;
+  #ifdef TI_DBG
+    hTxData->pThroughputTimer = pThroughputTimer;
+    hTxData->pAirThroughputTimer = pAirThroughputTimer;
+    hTxData->pJitterTimer = pJitterTimer;
+  #endif
+    hTxData->pCreditTimer = pCreditTimer;
+
+    hTxData->hOs = hOs;
+
+       hTxData->bVadTimerEnabled = FALSE;
+       hTxData->vadTimerDuration = 0;
+
+    hTxData->creditCalculationTimeout = txDataInitParams->creditCalculationTimeout;
+    hTxData->bCreditCalcTimerEnabled  = txDataInitParams->bCreditCalcTimerEnabled;
+    hTxData->admCtrlDelayDueToMediumTimeOverUsage = txDataInitParams->admCtrlDelayDueToMediumTimeOverUsage;
+    hTxData->admissionDownGradeEnable = txDataInitParams->admissionDownGradeEnable;
+    
+
+    return(hTxData);
+}
+
+/***************************************************************************
+*                           txData_config                                  *
+****************************************************************************
+* DESCRIPTION:  This function configures the Tx Data module
+*
+* INPUTS:       hTxData - The object
+*               hCtrlData - Handle to the Ctrl Data object
+*               hOs - Handle to the Os Abstraction Layer
+*               hReport - Handle to the Report object
+*               hMemMngr - Handle to the Memory manager object
+
+* OUTPUT:
+*
+* RETURNS:      OK - Configuration unsuccessful
+*               NOK - Configuration unsuccessful
+***************************************************************************/
+
+TI_STATUS txData_config(TI_HANDLE       hTxData,
+                     TI_HANDLE      hCtrlData,
+                     TI_HANDLE      hTnetwDrv,
+                     TI_HANDLE      hWhalCtrl,
+                     TI_HANDLE      hOs,
+                     TI_HANDLE      hReport,
+                     TI_HANDLE      hMemMngr,
+                     TI_HANDLE      hSiteMgr,
+                     TI_HANDLE      hEvHandler,
+                     TI_HANDLE      hQosMngr,
+                     TI_HANDLE      hPowerMgr)
+{
+    int qIndex;
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    /* configure modules handles */
+    pTxData->hCtrlData = hCtrlData;
+    pTxData->hTnetwDrv = hTnetwDrv;
+    pTxData->hWhalCtrl= hWhalCtrl;
+    pTxData->hOs = hOs;
+    pTxData->hReport = hReport;
+    pTxData->hMemMngr = hMemMngr;
+    pTxData->hSiteMgr = hSiteMgr;
+    pTxData->hEvHandler = hEvHandler;
+    pTxData->hQosMngr = hQosMngr;
+    pTxData->hPowerMgr = hPowerMgr;
+
+    /* set Tx parameters */
+    pTxData->txDataPortStatus = DEF_TX_PORT_STATUS;
+    pTxData->savePortStatus = DEF_TX_PORT_STATUS;
+    pTxData->txDataCurrentPrivacyInvokedMode = DEF_CURRENT_PRIVACY_INVOKED_MODE;
+    pTxData->saveTxDataCurrentPrivacyInvokedMode = DEF_CURRENT_PRIVACY_INVOKED_MODE;
+    pTxData->txDataEapolEncryptionStatus = DEF_EAPOL_ENCRYPTION_STATUS;
+    pTxData->saveTxDataEapolEncryptionStatus = DEF_EAPOL_ENCRYPTION_STATUS;
+
+    pTxData->txDataIsSchedulerInWork = DEF_IS_SCHEDULER_IN_WORK;
+    pTxData->txDataHalInterfaceStatus = DEF_HAL_INTERFACE_STATUS;
+
+    /* Initialize the parameters related to GWSI and to Scheduler in Work */
+    pTxData->txDataGwsiInterfaceStatus = GWSI_OPEN;
+    pTxData->txDataIsSchedulerInWork = FALSE;
+
+    pTxData->bCreditCalcTimerRunning = FALSE;
+    
+    /* encryption header size */
+    pTxData->encryptionFieldSize = 0;
+    pTxData->saveEncryptionFieldSize = 0;
+
+    /* configure the packet ID buffer pool */
+    bufferPool_config( pTxData->hBufferPool, hReport );
+
+    /* configure the Tx queues (msdu lists) */
+    /* num of elements is configured by qosMngr */
+    for (qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        if( (msduList_ConfigMsduList( pTxData->dataMsduListArr[qIndex], pTxData->hMemMngr,
+                                    pTxData->hReport,pTxData->hOs,0 )) != OK )
+        {
+            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                    ("Error configure DataMsduList num: %d\n",qIndex));
+        }
+
+        /*
+         * Mark all queues available for TX
+         */
+        pTxData->txDataAvailableQueue[qIndex] = TRUE;
+    }
+
+    if( (msduList_ConfigMsduList( pTxData->mngMsduList, pTxData->hMemMngr,
+                                pTxData->hReport, pTxData->hOs,MANAGEMENT_QUEUE_SIZE )) != OK )
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                ("Error configure MgmtMsduList\n"));
+    }
+
+    /* reset counters */
+    txData_resetCounters (pTxData);
+    txData_resetDbgCounters (pTxData);
+
+    WLAN_REPORT_INIT(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (".....Tx Data configured successfully\n"));
+
+#ifdef NO_COPY_NDIS_BUFFERS 
+   WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                     ("Driver configured to work in NO COPY MSDU BUFFERS."));
+#else
+   WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                     ("Driver is configured to work in COPY MSDU BUFFERS."));
+#endif
+
+
+    return OK;
+
+}
+
+/***************************************************************************
+*                           txData_unLoad                                  *
+****************************************************************************
+* DESCRIPTION:  This function unload the tx data module. It first free the
+*               MsduLists and then free the Tx data control block
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - Unload succesfull
+*               NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS txData_unLoad(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    TI_STATUS   status = OK;
+    int       queueIndex;
+
+    /* check parameters validity */
+    if( pTxData == NULL )
+    {
+        return NOK;
+    }
+
+    /* free Data queue msdu list */
+    for(queueIndex = 0;queueIndex < MAX_NUM_OF_TX_QUEUES; queueIndex++)
+    {
+        if (msduList_FreeMsduList( pTxData->dataMsduListArr[queueIndex]) != OK)
+        {
+            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_unLoad() : fail to free Data MsduList number: %d\n",queueIndex));
+            status = NOK;
+        }
+    }
+
+    /* free Mgmt queue msdu list */
+    if (msduList_FreeMsduList( pTxData->mngMsduList) != OK)
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_unLoad() : fail to free Mgmt MsduList \n"));
+        status = NOK;
+    }
+
+    DistributorMgr_Destroy(pTxData->TxEventDistributor);
+
+    /* free Timer */
+    utils_nullTimerDestroy(pTxData->hOs, pTxData->pSchedulerTimer);
+    utils_nullTimerDestroy(pTxData->hOs, pTxData->pVadTimer);
+  #ifdef TI_DBG
+    utils_nullTimerDestroy(pTxData->hOs, pTxData->pThroughputTimer);
+    utils_nullTimerDestroy(pTxData->hOs, pTxData->pAirThroughputTimer);
+    utils_nullTimerDestroy(pTxData->hOs, pTxData->pJitterTimer);
+  #endif
+    utils_nullTimerDestroy(pTxData->hOs, pTxData->pCreditTimer);
+
+    /* release the packet ID buffer pool */
+    bufferPool_destroy( pTxData->hBufferPool );
+
+    /* free Tx Data control block */
+    os_memoryFree(pTxData->hOs, pTxData, sizeof(txData_t));
+
+    return status;
+}
+
+/****************************************************************************
+*                               txData_stop                                 *
+*****************************************************************************
+* DESCRIPTION:  this function stop the tx data. It empties the tx queues (msdu
+*               lists) from the msdu's and return all tx data parameters to
+*               default values
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - stop successful
+*               NOK - stop unsuccessful
+****************************************************************************/
+
+TI_STATUS txData_stop(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int      queueIndex;
+
+    pTxData->savePortStatus = pTxData->txDataPortStatus;
+
+    /* stop scheduler timer trigger */
+    if ( TRUE == pTxData->bSchedulerTimerRunning )
+    {
+        os_timerStop(pTxData->hOs, pTxData->pSchedulerTimer);
+    }
+
+    /* stop vad timer */
+    if ( TRUE == pTxData->bVadTimerEnabled )
+    {
+        os_timerStop(pTxData->hOs, pTxData->pVadTimer);
+    }
+    /* stop throughput timer */
+    if(pTxData->txThroughputTimerEnable == TRUE)
+    {
+        os_timerStop(pTxData->hOs, pTxData->pThroughputTimer);
+        pTxData->txThroughputTimerEnable = FALSE;
+    }
+
+    /* stop throughput timer */
+    if (pTxData->txAirThroughputTimerEnable)
+    {
+        os_timerStop (pTxData->hOs, pTxData->pAirThroughputTimer);
+        pTxData->txAirThroughputTimerEnable = FALSE;
+    }
+
+    /* stop credit calculation timer */
+    if ( pTxData->bCreditCalcTimerRunning )
+    {
+        os_timerStop(pTxData->hOs, pTxData->pCreditTimer);
+        pTxData->bCreditCalcTimerRunning = FALSE;
+    }
+
+    /* empty Tx data queue from Msdus */
+    for(queueIndex = 0;queueIndex < MAX_NUM_OF_TX_QUEUES; queueIndex++)
+    {
+        if( msduList_EmptyMsduList( pTxData->dataMsduListArr[queueIndex] ) != OK)
+        {
+            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_stop() : fail to empty Data Msdu List number: %d\n",queueIndex));
+            return NOK;
+        }
+    }
+    /* empty Tx Mgmt queue from Msdus */
+    if( msduList_EmptyMsduList( pTxData->mngMsduList ) != OK)
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_stop() : fail to empty Mgmt Msdu List \n"));
+        return NOK;
+    }
+
+    /* set Tx parameters to default values */
+    pTxData->txDataPortStatus = DEF_TX_PORT_STATUS;
+    pTxData->saveTxDataCurrentPrivacyInvokedMode = pTxData->txDataCurrentPrivacyInvokedMode;
+    pTxData->saveTxDataEapolEncryptionStatus = pTxData->txDataEapolEncryptionStatus;
+    pTxData->saveEncryptionFieldSize = pTxData->encryptionFieldSize;
+
+    pTxData->txDataCurrentPrivacyInvokedMode = DEF_CURRENT_PRIVACY_INVOKED_MODE;
+    pTxData->txDataEapolEncryptionStatus = DEF_EAPOL_ENCRYPTION_STATUS;
+    pTxData->encryptionFieldSize = 0;
+
+
+    WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+        (" txData_stop() :  Succeeded.\n"));
+
+    return OK;
+
+}
+
+/****************************************************************************
+*                               txData_start                                *
+*****************************************************************************
+* DESCRIPTION:  this function start the tx data.
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - stop succesfull
+*               NOK - stop unsuccesfull
+****************************************************************************/
+TI_STATUS txData_start(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    /* check parameters validity */
+    if( pTxData == NULL )
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_start() : Illegal value for hTxData\n"));
+        return NOK;
+    }
+
+    pTxData->txDataPortStatus = pTxData->savePortStatus;
+
+    return OK;
+}
+/****************************************************************************
+*                       txData_recoveryIndication                           *
+*****************************************************************************
+* DESCRIPTION:  this function clears information on recovery.
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      
+****************************************************************************/
+void txData_recoveryIndication (TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int queueIndex;
+
+    /* Reinitializes packet ID buffer pool (mark all buffers as available) */
+    bufferPool_reinit (pTxData->hBufferPool);
+
+    /* Empty Tx data queue from Msdus */
+    for (queueIndex = 0; queueIndex < MAX_NUM_OF_TX_QUEUES; queueIndex++)
+    {
+        if (msduList_EmptyMsduList (pTxData->dataMsduListArr[queueIndex]) != OK)
+        {
+            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_stop() : fail to empty data MSDU list number: %d\n", queueIndex));
+        }
+    }
+
+    /* Empty Tx management queue from MSDU's */
+    if (msduList_EmptyMsduList (pTxData->mngMsduList) != OK)
+    {
+        WLAN_REPORT_ERROR (pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_stop() : fail to empty management MSDU list\n"));
+    }
+
+    /* 
+     * Set GWSI interfaces status as 'opened' 
+     * because it can be undefined upon recovery
+     */
+    pTxData->txDataGwsiInterfaceStatus = GWSI_OPEN;
+
+    for (queueIndex = 0; queueIndex < MAX_NUM_OF_TX_QUEUES; queueIndex++)
+    {
+        /*
+         * Mark all queues available for TX
+         */
+        pTxData->txDataAvailableQueue[queueIndex] = TRUE;
+    }
+}
+
+
+/***************************************************************************
+*                           txData_checkQueueSize                          *
+****************************************************************************
+* DESCRIPTION:  Check the Tx Queue size
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK
+*               NOK  - The queue is full
+***************************************************************************/
+TI_STATUS txData_checkQueueSize(TI_HANDLE hTxData,UINT8 qIndex)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    TI_STATUS Status = OK;
+
+    txData_startTxScheduler(pTxData);
+
+    if (pTxData->dataMsduListArr[qIndex]->CurrNumOfMsdu == pTxData->dataMsduListArr[qIndex]->maxNumOfMsdu)
+        Status = NOK;
+
+    return Status;
+}
+
+/***************************************************************************
+*                           txData_copyPacketToMsdu                        *
+****************************************************************************
+* DESCRIPTION:
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK
+*               NOK  - The queue is full
+***************************************************************************/
+TI_STATUS txData_copyPacketToMsdu(TI_HANDLE hTxData,mem_MSDU_T **pMsdu, int FreeOldMsdu)
+{ 
+#ifdef NO_COPY_NDIS_BUFFERS
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    TI_STATUS       Status = OK;
+    mem_BD_T        *pCurrBd;
+    mem_MSDU_T      *tempMsdu;
+    UINT8           *pMsduData;
+    UINT8           *pCurrBufData;
+    dot11_header_t  *pdot11Header;
+
+
+   /*
+    * Allocate MSDU+BD+BUFFER+TX_DESCRIPTOR_SIZE to copy to !!
+    */
+    if(wlan_memMngrAllocMSDU(pTxData->hMemMngr,&tempMsdu,(*pMsdu)->dataLen+TX_TOTAL_OFFSET_BEFORE_DATA,TX_MODULE) != OK)
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_copyPacketToMsdu() : No Memory in MemMgr \n"));
+
+        return NOK;
+    }
+
+    tempMsdu->dataLen = 0;
+    tempMsdu->firstBDPtr->length = 0;
+    tempMsdu->txFlags = (*pMsdu)->txFlags;
+
+    pCurrBd = (*pMsdu)->firstBDPtr;
+    pMsduData = tempMsdu->firstBDPtr->data + TX_TOTAL_OFFSET_BEFORE_DATA;
+    while(pCurrBd)
+    {
+        pCurrBufData = pCurrBd->data + pCurrBd->dataOffset;
+        /* Copy the packet */
+        os_memoryCopy(pTxData->hOs, pMsduData, pCurrBufData, pCurrBd->length);
+        tempMsdu->dataLen += pCurrBd->length - TNETWIF_WRITE_OFFSET_BYTES;
+        tempMsdu->firstBDPtr->length += pCurrBd->length;
+        pMsduData += pCurrBd->length;
+
+        pCurrBd = pCurrBd->nextBDPtr;
+    }
+
+    tempMsdu->headerLen = (*pMsdu)->headerLen;
+
+    txData_convertEthToWlanHeader( pTxData, tempMsdu );
+
+    /* set wep bit if needed */
+    if((tempMsdu->txFlags & TX_DATA_DATA_MSDU) && (pTxData->txDataCurrentPrivacyInvokedMode))
+    {
+        pdot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+        pdot11Header->fc |= DOT11_FC_WEP;
+    }
+    else if ((tempMsdu->txFlags & TX_DATA_EAPOL_MSDU ) && (pTxData->txDataEapolEncryptionStatus))
+    {
+        pdot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+        pdot11Header->fc |= DOT11_FC_WEP;
+    }
+
+    if (FreeOldMsdu)
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle((*pMsdu)));
+
+    (*pMsdu) = tempMsdu;
+
+#endif
+
+    return OK;
+}
+
+/***************************************************************************
+*                           txData_sendPktToWlan                           *
+****************************************************************************
+* DESCRIPTION:  This function is called by the Os Abstraction Layer in order
+*               to send packet to the wireless LAN. It calls the header
+*               conversion function and passes the to sendMsdu function.
+*
+* INPUTS:       hTxData - the object
+*               pMsdu - pointer the packet in 802.3 format
+*
+* OUTPUT:
+*
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+
+TI_STATUS txData_sendPktToWlan(TI_HANDLE hTxData, mem_MSDU_T *pMsdu, UINT8 pkt_DTag)
+{
+    EthernetHeader_t   *pEthHeader;
+    UINT16              TypeLength;
+    TI_STATUS Status;
+    mem_BD_T*           tempBd;
+    BOOL                UseConvertHeader = TRUE;
+
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    /* check parameters validity */
+    if( pTxData == NULL || pMsdu == NULL )
+    {
+        return NOK;
+    }
+
+    pEthHeader = (EthernetHeader_t*)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr));
+
+    /* check if the frame is multicast/broadcast - need for the transmission rate */
+    if(IsMacAddressGroup( &pEthHeader->DstAddr ))
+        pMsdu->txFlags |= TX_DATA_MULTICAST_FRAME;
+
+    TypeLength = pEthHeader->TypeLength;
+
+      /* Call the Classify function in the Control Module to set the qosTag of the MSDU  */
+     if (ctrlData_ClsfrClassifyTxMSDU(pTxData->hCtrlData, pMsdu, pkt_DTag) != OK)
+     {
+        WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+                     (" txData_sendPktToWlan(): No matching classifier found\n"));              
+     }
+
+
+    /* filter MSDU according to Tx Port Status and the Eth Type */
+    if ( pTxData->txDataPortStatus != OPEN )
+    {
+        int queueIndex;
+        int acIndex;
+
+        WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_sendPktToWlan() : try to transmit Msdu while port is not open (txDataPortStatus = 0x%x)\n", pTxData->txDataPortStatus));
+        
+        /* Find AC and Tx-queue in order to update the correct Queue measurements */
+        acIndex = GET_WME_AC_TYPE_FROM_MSDU(pMsdu);
+        queueIndex = GET_QUEUE_INDEX(pTxData,acIndex);
+        
+        
+        /* updating the measurements - dropped packet counter */
+        pTxData->txDataReportedCounters[queueIndex].OtherFailCounter++;
+        pTxData->txDataReportedCounters[queueIndex].NumPackets++;
+                
+        if((pTxData->txDataPortStatus == CLOSE) || (pTxData->txDataPortStatus == OPEN_NOTIFY) )
+        {
+            WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_sendPktToWlan() : try to transmit Msdu while port is not open (txDataPortStatus = 0x%x)\n", pTxData->txDataPortStatus));
+
+            /* In case the function return status is NOK, no need to call Os free function  */
+            /* Set freefunc in the msdu to null. In this case the MemMngr will not call     */
+            /* the Os free function                                                         */
+            memMgr_MsduFreeFuncGet(pMsdu) = NULL;
+
+            /* free MSDU */
+            if( (wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsdu))) != OK )
+            {
+                WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                    (" txData_sendPktToWlan() : free msdu failed \n"));
+            }
+
+            return NOK;
+        }
+
+        /* filter Data frames while port is open only for Eapol's */
+        if( (pTxData->txDataPortStatus == OPEN_EAPOL) && (TypeLength != EAPOL_PACKET) )
+        {
+            WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_sendPktToWlan() : try to transmit Non Eapol packet while port is open for eapols only\n"));
+
+            /* In case the function return status is NOK, no need to call Os free function. */
+            /* Set freefunc in the msdu to null. In this case the MemMngr will not call     */
+            /* the Os free function  - because the return staus to the Os is NOK the buffer */
+            /* free by the Os                                                               */
+            memMgr_MsduFreeFuncGet(pMsdu) = NULL;
+
+            /* frre MSDU */
+            if ((wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsdu))) != OK)
+            {
+                WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                    (" txData_sendPktToWlan() : free msdu failed \n"));
+            }
+
+            return NOK;
+        }
+    }
+
+    /* PORT IS OPEN */
+#ifdef CORE_TX_DBG
+    WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_sendPktToWlan: port is open \n"));
+#endif
+    
+
+    if( TypeLength != EAPOL_PACKET )
+    {
+        pMsdu->txFlags |= TX_DATA_DATA_MSDU;
+    }
+    else
+    {
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_sendPktToWlan() : Tx an EAPOL frame tranferred to HAL\n"));
+
+        /* because EAPOL is sent from Mgmt queue */
+        pMsdu->txFlags |= TX_DATA_EAPOL_MSDU;
+    }
+
+    UseConvertHeader = TRUE; /* a patch for WinCe */
+#ifdef NO_COPY_NDIS_BUFFERS
+    if (pMsdu->txFlags & TX_DATA_FROM_OS)
+        UseConvertHeader = FALSE;   /* don't convert on external (OS) packets */
+#endif
+
+        if (UseConvertHeader == TRUE)
+    {
+        /* Header conversion from Ethernet to 802.11 */
+        txData_convertEthToWlanHeader( pTxData, pMsdu );
+    }
+
+    /* update last BD */
+    tempBd = pMsdu->firstBDPtr;
+    while(tempBd->nextBDPtr)
+    {
+        tempBd = tempBd->nextBDPtr;
+    }
+    pMsdu->lastBDPtr = tempBd;
+
+    Status = txData_txSendMsdu( pTxData, pMsdu );
+    if( Status == NOK )
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_sendPktToWlan() : txData_txSendMsdu failed \n"));
+    }
+
+    if ((OK == Status) && (GET_WME_AC_TYPE_FROM_MSDU(pMsdu) == QOS_AC_VO))
+    {
+       txData_resetVadTimer(pTxData);
+    }
+    return Status;
+}
+
+/***************************************************************************
+*                           txData_txSendMsdu                              *
+****************************************************************************
+* DESCRIPTION:  This function is insert the MSDU to transmit to the proper
+*               tx queue and give a trigger to the scheduler to start
+*               transmission to the wireless LAN.
+*
+* INPUTS:       hTxData - the object
+*               pMsdu - pointer the MSDU in 802.11 format
+*
+* OUTPUT:
+*
+* RETURNS:  OK
+*           NOK
+***************************************************************************/
+
+TI_STATUS txData_txSendMsdu(TI_HANDLE hTxData, mem_MSDU_T *pMsdu )
+{
+    dot11_header_t     *pdot11Header;
+    TI_STATUS Status = OK;
+    int queueIndex;
+    acTrfcType_e acIndex;
+
+
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    /* ctrlData_txMsdu(pTxData->hCtrlData,&pMsdu); 4x related */
+    
+    if(pMsdu == NULL)
+    {
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_txSendMsdu() : DISCARD Packet...... \n"));
+        txData_startTxScheduler(pTxData);
+
+        return NOK;
+    }
+
+
+#ifndef NO_COPY_NDIS_BUFFERS /* buffers are copied by OAL*/
+    /* set wep bit if needed */
+    if((pMsdu->txFlags & TX_DATA_DATA_MSDU) && (pTxData->txDataCurrentPrivacyInvokedMode))
+    {
+        /* update offset of header */
+        pdot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+        pdot11Header->fc |= DOT11_FC_WEP;
+    }
+    else if ((pMsdu->txFlags & TX_DATA_EAPOL_MSDU ) && (pTxData->txDataEapolEncryptionStatus))
+    {
+        /* update offset of header */
+        pdot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+        pdot11Header->fc |= DOT11_FC_WEP;
+    }
+#endif /*NO_COPY_NDIS_BUFFERS*/
+
+#ifdef EXC_MODULE_INCLUDED
+    if ((pMsdu->txFlags & TX_DATA_IAPP_MSDU) && (pTxData->txDataCurrentPrivacyInvokedMode))
+    {
+        /* update offset of header */
+        pdot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+        pdot11Header->fc |= DOT11_FC_WEP;
+    }
+#endif
+
+
+    WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+        (" txData_txSendMsdu() : Sending PAcket pMsdu %x pMsdu->txFlags %x \n",pMsdu,pMsdu->txFlags));
+
+    /* insert the msdu to the the appropriate queue */
+    if( (pMsdu->txFlags & TX_DATA_DATA_MSDU) || (pMsdu->txFlags & TX_DATA_NULL_MSDU) )
+    {
+        /* Find Tx-queue and AC to use for Tx, and if downgraded from original one update the UP. */
+        txData_selectQueueAndUpdateUserPriority (pTxData, pMsdu, &queueIndex, &acIndex);
+        
+        /* set insertion time for further expiry timeout calculation */
+        pMsdu->insertionTime = os_timeStampUs (pTxData->hOs);
+
+        /* see if the frame is tagged VO. */
+        /* Note: Check actual tag even if current not working in WME, to support voice anyway. */
+        if( GET_WME_AC_TYPE_FROM_MSDU(pMsdu) == QOS_AC_VO)
+        {
+            /*
+             * If the frame is tagged VO and power save is on, send psPoll before the VO frame.
+             */
+            if(txData_acVoPsPollMode(pTxData) == TRUE)
+            {
+                mem_MSDU_T *pMsduPsPoll;
+
+                if(txData_getPsPollFrame(pTxData,&pMsduPsPoll) == OK)
+                {
+                    /* increment debug counters */
+                    pTxData->txDataDbgCounters.dbgInsertToMsduListBytes[queueIndex] += pMsduPsPoll->dataLen;
+                    pTxData->txDataDbgCounters.dbgInsertToMsduListPackets[queueIndex]++;
+
+                    /* set insertion time for further expiry timeout calculation */
+                    pMsduPsPoll->insertionTime = os_timeStampUs (pTxData->hOs);
+
+                    /* insert to queueIndex queue */
+                    if( msduList_Insert( pTxData->dataMsduListArr[queueIndex] , &pMsduPsPoll ) != OK )
+                    {
+                        pTxData->txDataDbgCounters.dbgDropedFromMsduListPackets[queueIndex]++;
+                        /* the first msdu in list has removed and the new one has inserted */
+                        WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                                            (" txData_sendPktToWlan() : Msdu List num %d was full \n",queueIndex));
+
+                        /* free the msdu which removed from the list (returned in pMsdu) */
+                        /*---------------------------------------------------------------*/
+                        /* set msdu tx status to Fail (this status is used by OS) */
+                        memMgr_MsduFreeArg2Get(pMsduPsPoll) = NOK;
+
+                        /* free the msdu */
+                        wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsduPsPoll));
+                        pTxData->txDataDbgCounters.dbgDropedPacketsCounter++;
+                    }/*msduList_Insert*/
+                }/*txData_getPsPollFrame*/
+            }/*txData_acVoPsPollMode*/
+        }
+
+        /* insert to data queue */
+        /* if we didn't succeed to insert psPolls exclude VO packet also */
+        if( msduList_Insert( pTxData->dataMsduListArr[queueIndex] , &pMsdu ) != OK )
+        {
+
+            pTxData->txDataDbgCounters.dbgDropedFromMsduListPackets[queueIndex]++;
+            /* the first msdu in list has removed and the new one has inserted */
+            WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_txSendMsdu() : Data Msdu [%d] List was full \n",queueIndex));
+
+            /* free the msdu which removed from the list (returned in pMsdu) */
+            /*---------------------------------------------------------------*/
+            /* set msdu tx status to Fail (this status is used by OS) */
+            memMgr_MsduFreeArg2Get(pMsdu) = NOK;
+
+            /* free the msdu */
+            wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+            pTxData->txDataDbgCounters.dbgDropedPacketsCounter++;
+            
+            pTxData->txDataReportedCounters[queueIndex].NumPackets++; 
+            pTxData->txDataReportedCounters[queueIndex].OtherFailCounter++;
+
+            return OK;
+        }
+
+        /* increament debug counters */
+        pTxData->txDataDbgCounters.dbgInsertToMsduListBytes[queueIndex] += pMsdu->dataLen;
+        pTxData->txDataDbgCounters.dbgInsertToMsduListPackets[queueIndex]++;
+
+        WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+            (" txData_txSendMsdu() : insert data packet to queue # %d \n",queueIndex));
+    }
+    else
+    {
+        /* Management frame, Eapol and null frame (for measuring a non serving channel)
+            are also sent from the mgmt queue */
+
+        /* set insertion time for further expiry timeout calculation */
+        pMsdu->insertionTime = os_timeStampUs (pTxData->hOs);
+
+        WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+            (" txData_txSendMsdu() : insert mngt packet to Management queue pMsdu %x \n",pMsdu));
+
+        if( msduList_Insert( pTxData->mngMsduList , &pMsdu ) != OK )
+        {
+            /* the first msdu in list has removed and the new one has inserted */
+            WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_txSendMsdu() : Mgmt Msdu List was full \n"));
+
+            /* free the msdu which removed from the list (returned in pMsdu) */
+            /*---------------------------------------------------------------*/
+            /* set msdu tx status to Fail (this status is used by OS) */
+            memMgr_MsduFreeArg2Get(pMsdu) = NOK;
+
+            /* free the msdu */
+            wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsdu));
+            pTxData->txDataDbgCounters.dbgDropedPacketsCounter++;
+        }
+    }
+
+    {
+        /* call the scheduler in order to transmit the frame to the Hal */
+    Status = txData_startTxScheduler(pTxData);
+        if ( Status == NOK )
+        {
+            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_txSendMsdu() : txData_startTxScheduler error \n"));
+        }
+    }
+
+    /* this is the status of the current Msdu */
+    return OK;
+}
+
+/***************************************************************************
+*                       txData_startTxScheduler                            *
+****************************************************************************
+* DESCRIPTION:  This function start the transmission process.
+*               It select msdu to transmit from the tx queues and send
+*               it to the Hal
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:  OK
+*           NOK
+***************************************************************************/
+
+TI_STATUS txData_startTxScheduler(TI_HANDLE hTxData)
+{
+    txData_t            *pTxData = (txData_t *)hTxData;
+    mem_MSDU_T          *pMsdu;
+    MsduList_t          *pMsduList = NULL;
+    txData_attr_t       txAttr;
+    UINT8               count, selectedQueueIndex;
+    TI_STATUS           txStatus;
+    txPacketIdAttr_t    *pPacketId;
+    dot11_header_t      *pDot11Header;
+    bssType_e           currBssType;
+    macAddress_t        currBssId;
+    UINT32              msduTimeToExpiry;
+
+#ifdef SUPPORT_4X
+    hwTxInformation_t   hwTxInformation;
+    BOOL                fourXEnable;
+#endif
+
+    /* check if HAL is open now - used for recovery only!!! */
+    if ( pTxData->txDataHalInterfaceStatus == TX_DATA_CLOSED )
+    {
+        return OK; /* TODO ronen: doesn't seem to be used any more, remove */
+    }
+
+    /* Checking if Tx is now disabled */
+    if(pTxData->txDisable == DISABLE_IMMEDIATELY)
+    {
+        WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_startTxScheduler() : Tx Disabled!!! \n"));
+
+        /* start scheduler timer */
+        if ( FALSE == pTxData->bSchedulerTimerRunning )
+        {
+            os_timerStart( pTxData->hOs, pTxData->pSchedulerTimer, SCHEDULER_TIMER, FALSE );
+            pTxData->bSchedulerTimerRunning = TRUE;
+        }
+
+        pTxData->txDataIsSchedulerInWork = FALSE;
+        return OK;
+    }
+
+   /*
+    * in case of non serialized system no need to
+    * run the scheduler if it is already in work
+    */
+    if(pTxData->txDataIsSchedulerInWork == TRUE)
+    {
+        WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_startTxScheduler() : Scheduler already in work...........!!!! \n"));
+        return OK;
+    }
+    else
+    {
+        pTxData->txDataIsSchedulerInWork = TRUE;
+    }
+
+    /* try to transmit DEF_SCHEDULER_THRESHOLD MSDUs */
+    count = DEF_SCHEDULER_THRESHOLD;
+
+    /*
+     * if non of the queues is available non msdu will be selected
+     */
+       
+    while ( (0 < count--) && (GWSI_OPEN == pTxData->txDataGwsiInterfaceStatus) )
+    {
+        /* select queue to transmit from */
+        if( txData_schedulerSelectQueueToTransmitFrom( pTxData, &pMsduList,&selectedQueueIndex ) != TX_QUEUE_SELECTED_OK)
+        {
+            WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+                    (" txData_startTxScheduler() : No Msdu waiting to transmit  \n"));
+
+           pTxData->txDataIsSchedulerInWork = FALSE;
+            return OK;
+        }
+
+        WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+            (" txData_startTxScheduler() : txData_schedulerSelectQueueToTransmitFrom Returned from selectedQueueIndex %d   \n",selectedQueueIndex));
+
+        
+#ifdef SUPPORT_4X
+        
+        ctrlData_get4xStatus(pTxData->hCtrlData,&fourXEnable);
+
+        if(fourXEnable == TRUE  && pMsduList != pTxData->mngMsduList)
+        {
+           /*
+            * receive Acx tx queuue information for transmission decision
+            */
+            whalTx_getTxQueueInfo(pTxData->hWhalTx,
+                                    DEFAULT_QUEUE_TO_HAL,
+                                    &hwTxInformation.hwNumOfFreeMsdu,
+                                    &hwTxInformation.hwNumOfBusyMsdu,
+                                    &hwTxInformation.hwNumOfFreeBDs,
+                                    &hwTxInformation.hwTotalAvailMem );
+
+           /*
+            * call ctrl Data - DequeueMsdu...
+            * pMsdu - the msdu to transmit.
+            * txAttr - the tx attributes for msdu transmission
+            */
+            status = ctrlData_txDequeueMsdu(pTxData->hCtrlData, &pMsdu, pMsduList, &txAttr, &hwTxInformation);
+
+            if(status == DO_NOT_SEND_MSDU)
+            {
+        WLAN_REPORT_ERROR(pTxData->hReport,
+                    (" txData_startTxScheduler() : TX_STATUS_PENDING  \n"));
+
+                pTxData->txDataIsSchedulerInWork = FALSE;
+
+                return TX_STATUS_PENDING;
+            }
+        }
+
+#else  /*  if not SUPPORT_4X  */
+
+        {
+            /* increment debug counter */
+            pTxData->txDataDbgCounters.dbgScheduledOutPackets[selectedQueueIndex]++;
+
+            if( msduList_WatchFirst( pMsduList ,&pMsdu) != OK )
+            {
+                WLAN_REPORT_ERROR( pTxData->hReport, TX_DATA_MODULE_LOG, 
+                                   ("Unable to retrieve first MSDU from queue index:%d\n", selectedQueueIndex) );
+                pTxData->txDataIsSchedulerInWork = FALSE;
+                return OK;
+            }
+
+            WLAN_REPORT_DEBUG_TX(pTxData->hReport,
+                    (" txData_startTxScheduler() : After msduList_WatchFirst pMsdu %d   \n",pMsdu));
+
+#ifdef NO_COPY_NDIS_BUFFERS
+            
+            if(pMsdu->txFlags & TX_DATA_FROM_OS)
+            {
+                if(txData_copyPacketToMsdu(pTxData, &pMsdu, 1 /* do FreeOldMsdu */) != OK)
+                {
+                    WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                        (" txData_startTxScheduler() : txData_copyPacketToMsdu FAILED  \n"));
+
+                    pTxData->txDataIsSchedulerInWork = FALSE;
+                    return NOK;
+                }
+            }
+
+#endif /* NO_COPY_NDIS_BUFFERS */
+
+        }
+
+#endif /* SUPPORT_4X */
+
+        /* check MSDU expiry time, and if it didn't expire send it to GWSI */
+        if ((msduTimeToExpiry = txDataTimeToMsduExpiry (hTxData, pMsdu, selectedQueueIndex)) == 0)
+        {
+            /* MSDU time expired - drop it */
+            WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                ("txData_startTxScheduler drop msdu due to expiry time, queueId = %d \n",selectedQueueIndex));
+
+            /* Get MSDU with dequeuing */
+            if ( (msduList_GetFirst( pMsduList, &pMsdu )) != OK )
+            {
+                /* No MSDU is waiting to transmit */
+                WLAN_REPORT_ERROR (pTxData->hReport, TX_DATA_MODULE_LOG,
+                    ("%s: can't get Msdu from pMsduList[ %d ]  \n", __FUNCTION__, selectedQueueIndex));
+                pTxData->txDataIsSchedulerInWork = FALSE;
+                return NOK;
+            }
+
+
+            pTxData->txDataDbgCounters.dbgDroppedDueExpiryTimePackets[selectedQueueIndex]++;
+            
+            pTxData->txDataReportedCounters[selectedQueueIndex].NumPackets++; 
+            pTxData->txDataReportedCounters[selectedQueueIndex].OtherFailCounter++; 
+            
+            /* free the MSDU */
+            memMgr_MsduFreeArg2Get(pMsdu) = OK;
+    
+                if( (wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsdu))) != OK )
+                {
+                    WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                        (" txData_startTxScheduler() : free msdu failed \n"));
+                }
+    
+            /* continue to next packet */
+            continue;
+        }
+
+        /* Collect txAttr from control */
+        ctrlData_getTxAttributes(pTxData->hCtrlData, pMsdu->txFlags, &txAttr, selectedQueueIndex);
+
+        /* allocate a buffer for packet ID storage */
+        pPacketId = (txPacketIdAttr_t*)bufferPool_allocateBuffer( pTxData->hBufferPool );
+        if ( BUFFER_POOL_NO_BUFFER == pPacketId )
+        {
+            WLAN_REPORT_ERROR (pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" %s : No PacketID Available!!\n", __FUNCTION__));
+
+            /* shouldn't happen, since we have enough packet ID buffers as the FW has TX descriptors! */
+            pTxData->txDataIsSchedulerInWork = FALSE;
+            return NOK;
+        }
+
+        /* store necessary information in packet ID */
+        pPacketId->pMsdu = pMsdu;
+        if (pMsdu->txFlags & TX_DATA_DATA_MSDU)
+        {
+            pPacketId->bDataMsdu = TRUE;
+        }
+        else
+        {
+            pPacketId->bDataMsdu = FALSE;
+        }
+        pPacketId->txQid = selectedQueueIndex;
+        pPacketId->txCompleteFlags = pMsdu->txCompleteFlags; 
+        pPacketId->maxTransmitRate = txAttr.HwRate;
+      #ifdef TI_DBG
+        os_memoryZero (pTxData->hOs, pPacketId->timeStamp, sizeof(pPacketId->timeStamp));
+        pPacketId->timeStamp[0] = os_timeStampUs (pTxData->hOs);
+      #endif
+
+        pPacketId->msduDataLen = pMsdu->dataLen;
+
+        /* destination mac */
+        pDot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr)+ memMgr_BufOffset(pMsdu->firstBDPtr));
+        ctrlData_getCurrBssTypeAndCurrBssId(pTxData->hCtrlData, &currBssId, &currBssType);
+        if(currBssType == BSS_INDEPENDENT)
+             MAC_COPY( pTxData->hOs, &(pPacketId->destinationMac), &(pDot11Header->address1) );
+        else
+             MAC_COPY( pTxData->hOs, &(pPacketId->destinationMac), &(pDot11Header->address3) );
+
+        /* mark in packet ID that XFER done and TX complete were not called yet */
+        pPacketId->bTxCompleteCalled = pPacketId->bXferDoneCalled = FALSE;
+
+
+      #ifdef TI_DBG
+        if ((pMsdu->txFlags & TX_DATA_DATA_MSDU) != 0 && pMsdu->timeStampNum > 0)
+        {
+            UINT32 uCoreDelay;
+
+            /* add time stamp */
+            wlan_memMngrAddTimeStamp (pTxData->hMemMngr, pMsdu);
+
+            uCoreDelay = pMsdu->timeStamp[pMsdu->timeStampNum - 1] - pMsdu->timeStamp[0];
+
+            /* update core delay and jitter */
+            pTxData->txJitter[selectedQueueIndex].jitter.core += 
+                ABS (pTxData->txJitter[selectedQueueIndex].last_delay.core - uCoreDelay);
+            pTxData->txJitter[selectedQueueIndex].last_delay.core = uCoreDelay;
+            pTxData->txJitter[selectedQueueIndex].delay.core += uCoreDelay;
+            pTxData->txJitter[selectedQueueIndex].count.core ++;
+            if (uCoreDelay > pTxData->txJitter[selectedQueueIndex].max_delay.core)
+                pTxData->txJitter[selectedQueueIndex].max_delay.core = uCoreDelay;
+        }
+      #endif
+
+        /* send the packet to the GWSI layer */
+        txStatus = CORE_AdaptTx_SendPacket( CORE_AdaptTx_handle, selectedQueueIndex, pMsdu, &txAttr, (UINT32)pPacketId, msduTimeToExpiry );
+
+        WLAN_REPORT_DEBUG_TX (pTxData->hReport,
+                              ("txData_startTxScheduler(): called CORE_AdaptTx_SendPacket pMsdu=%d, selectedQueueIndex=%d,txStatus=%d\n",
+                              pMsdu,selectedQueueIndex,txStatus));
+
+        switch ( txStatus )
+        {
+        /* 
+         * XFER_DONE is received when the packet has been synchronously transferred to the FW.
+         * in this case, XFER complete will not be called, only TX complete
+         */
+        case SEND_PACKET_XFER_DONE:
+
+            pPacketId->driverHandlingTime = (os_timeStampUs (pTxData->hOs) - pMsdu->insertionTime) / 1000;
+
+            /* Get MSDU with dequeuing */
+            if ( (msduList_GetFirst( pMsduList, &pMsdu )) != OK )
+            {
+                /* No MSDU is waiting to transmit */
+                WLAN_REPORT_ERROR (pTxData->hReport, TX_DATA_MODULE_LOG,
+                    (" %s : can't get Msdu from pMsduList[ %d ]  \n", __FUNCTION__, selectedQueueIndex));
+                pTxData->txDataIsSchedulerInWork = FALSE;
+                return NOK;
+            }
+
+            /* free the MSDU, since XFER complete won't be called */
+            if ( (wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pMsdu))) != OK )
+            {
+               WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                   ("%s: free msdu failed \n", __FUNCTION__));
+               pTxData->txDataIsSchedulerInWork = FALSE;
+               return NOK;
+            }
+            else
+            {
+                pTxData->txDataDbgCounters.dbgNumOfMsduFreeInTxTransfer[ pPacketId->txQid ]++;
+            }
+
+            /* Nullify the MSDU pointer, just in case */
+            pPacketId->pMsdu = NULL;
+
+            /* mark in packet ID that XFER done was called */
+            pPacketId->bXferDoneCalled = TRUE;
+
+            /* increment debug counter */
+            pTxData->txDataDbgCounters.dbgSendToGwsiQosPackets[ selectedQueueIndex ]++;
+            pTxData->txDataDbgCounters.dbgNumOfMsduXferDoneInShceduler[ selectedQueueIndex ]++;
+            break;
+
+        /* 
+         * SUCCESS is received when the packet has not yet been sent to the FW, but another packet
+         * transfer can start immediately
+         */
+        case SEND_PACKET_SUCCESS:
+            /* Get msdu with dequeuing */
+            if ( (msduList_GetFirst( pMsduList, &pMsdu )) != OK )
+            {
+                /* No msdu is waiting to transmit */
+                WLAN_REPORT_ERROR (pTxData->hReport, TX_DATA_MODULE_LOG,
+                    (" %s : can't get Msdu from pMsduList[ %d ]  \n", __FUNCTION__, selectedQueueIndex));
+                pTxData->txDataIsSchedulerInWork = FALSE;
+                return NOK;
+            }
+
+            /* increment debug counter */
+            pTxData->txDataDbgCounters.dbgNumOfMsduSuccessInScheduler[ selectedQueueIndex ]++;
+            pTxData->txDataDbgCounters.dbgSendToGwsiQosPackets[selectedQueueIndex]++;
+            break;
+
+        /*
+         * PENDING is received when the packet has been received by the GWSI layer, and the double buffer
+         * mechanism is busy. It indicates that no more packets (from all queues) are to be sent until a
+         * XFER complete indication is received
+         */
+        case SEND_PACKET_PENDING:
+            /* Get msdu with dequeuing */
+            if ( (msduList_GetFirst( pMsduList, &pMsdu )) != OK )
+            {
+                /* No msdu is waiting to transmit */
+                WLAN_REPORT_ERROR (pTxData->hReport, TX_DATA_MODULE_LOG,
+                    (" %s : can't get Msdu from pMsduList[ %d ]  \n", __FUNCTION__, selectedQueueIndex));
+                pTxData->txDataIsSchedulerInWork = FALSE;
+                return NOK;
+            }
+
+            /* mark the GWSI interface state as pending (no more frames can be sent) */
+            pTxData->txDataGwsiInterfaceStatus = GWSI_PENDING;                
+
+            /* increment debug counter */
+            pTxData->txDataDbgCounters.dbgNumOfMsduPendingInScheduler[ selectedQueueIndex ]++;
+            pTxData->txDataDbgCounters.dbgSendToGwsiQosPackets[selectedQueueIndex]++;
+            break;
+
+        /*
+         * BUSY is received when the packet has NOT been received by the GWSI layer (and needs to be 
+         * retransmitted). It indicates that the specific FW queue is full and no more packets from this
+         * specific queue are to be sent until a TX complete indication for this queue is received (but 
+         * packets from other queues may be sent).
+         */
+        case SEND_PACKET_BUSY:
+            /* don't dequeue the packet! it was not sent! */
+
+            /* in addition, release the packet ID buffer */
+            bufferPool_releaseBuffer( pTxData->hBufferPool, pPacketId );
+
+            /* mark the specific queue as not available */
+            pTxData->txDataAvailableQueue[ selectedQueueIndex ] = FALSE;
+
+            /* update debug counters */
+            pTxData->txDataDbgCounters.dbgNumOfMsduBusyInScheduler[ selectedQueueIndex ]++;
+
+            break;
+
+        /* 
+         * ERROR is received when a frame is sent although a PENDING indication had been previously 
+         * received and no XFER complete had been receive since, or because a BUSY indication had been
+         * received for a specific queue and no TX complete for this queue had been received since (and
+         * a packet from this queue had been sent now).
+         */
+        case SEND_PACKET_ERROR:
+            /* don't dequeue the packet! it was not sent! */
+
+            /* in addition, release the packet ID buffer */
+            bufferPool_releaseBuffer( pTxData->hBufferPool, pPacketId );
+
+            /* start scheduler timer */
+            if ( FALSE == pTxData->bSchedulerTimerRunning )
+            {
+                os_timerStart( pTxData->hOs, pTxData->pSchedulerTimer, SCHEDULER_TIMER, FALSE );
+                pTxData->bSchedulerTimerRunning = TRUE;
+            }
+            pTxData->txDataIsSchedulerInWork = FALSE;
+            WLAN_REPORT_ERROR( pTxData->hReport, TX_DATA_MODULE_LOG, 
+                                (" %s: received status SEND_PACKET_ERROR from CORE_AdaptTx_SendPacket\n", __FUNCTION__) );
+
+            /* update debug counters */
+            pTxData->txDataDbgCounters.dbgNumOfMsduErrorInScheduler[ selectedQueueIndex ]++;
+
+            return NOK;
+
+/*            break; - unreachable*/
+
+        case SEND_PACKET_RECOVERY:
+            break;
+
+        default:
+            WLAN_REPORT_ERROR( pTxData->hReport, TX_DATA_MODULE_LOG, 
+                               (" %s: received status %d from CORE_AdaptTx_SendPacket\n", __FUNCTION__, txStatus) );
+            break;
+            }
+    
+            WLAN_REPORT_INFORMATION (pTxData->hReport, TX_DATA_MODULE_LOG, 
+                ("txData_startTxScheduler() : MSDU sent: TxQ = %d TxStatus = %d\n", selectedQueueIndex, txStatus));
+    }  /* end of while (count) */
+
+    pTxData->txDataIsSchedulerInWork = FALSE;
+
+    return OK;
+}
+/***************************************************************************
+*                           txData_sendPacketTransfer                      *
+****************************************************************************
+* DESCRIPTION:  GWSI sendPacketTransfer CB. called after transferring a packet
+*               to TNET. 
+*               The function free the transfered MSDU and set GWSI port status
+*               to OPEN. This is the only function which synchronized GWSI port
+*               status.
+*               TNET queues buffer status are updated and the scheduler is executed
+*               trying to send another MSDU.
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:  void
+*
+***************************************************************************/
+void txData_sendPacketTransfer(TI_HANDLE          hTxData,
+                               UINT32    aPacketIdAttr)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    txPacketIdAttr_t* pPacketId = (txPacketIdAttr_t*)aPacketIdAttr;
+
+
+    WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            ("%s: XFER complete CB called\n", __FUNCTION__));
+    pTxData->txDataDbgCounters.dbgNumOfMsduTxTransferCB[ pPacketId->txQid ]++;
+
+    WLAN_REPORT_DEBUG_TX(pTxData->hReport, 
+        ("%s: XFER complete CB called\n", __FUNCTION__));
+
+    /* updating GWSI status to open */
+    pTxData->txDataGwsiInterfaceStatus = GWSI_OPEN;
+
+    /* free the MSDU */
+    if ( pPacketId->pMsdu != NULL )
+    {
+        pPacketId->driverHandlingTime = (os_timeStampUs (pTxData->hOs) - pPacketId->pMsdu->insertionTime) / 1000;
+
+        if( (wlan_memMngrFreeMSDU(pTxData->hMemMngr, memMgr_MsduHandle(pPacketId->pMsdu))) != OK )
+        {
+           WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+               ("%s: free msdu failed \n", __FUNCTION__));
+        }
+        else
+        {
+            pTxData->txDataDbgCounters.dbgNumOfMsduFreeInTxTransfer[ pPacketId->txQid ]++;
+        }
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                ("%s: pMsdu = NULL !!!!\n", __FUNCTION__));
+            pTxData->txDataDbgCounters.dbgNumOfNullMsdu++;
+    }
+
+
+    /* nullify the MSDU pointer, just in case */
+    pPacketId->pMsdu = NULL;
+
+    /* mark in packet ID that XFER done was called */
+    pPacketId->bXferDoneCalled = TRUE;
+    
+    /* 
+     * and check if to release packet ID. In rare cases, TX complete can be called before XFER done. In these
+     * cases, the packet ID should be released here.
+     */
+    if ( TRUE == pPacketId->bTxCompleteCalled )
+    {
+        bufferPool_releaseBuffer( pTxData->hBufferPool, (bufferPool_buffer_t)aPacketIdAttr );
+    }
+
+    /* 
+     * check port status - if it is disconnected, it means the STA is disconnected, and thus
+     * the XFER complete is ignored, to avoid race conditions (when, for example, the MSDU was 
+     * already freed on txData_stop)
+     */
+    if ( CLOSE == pTxData->txDataPortStatus )
+    {
+        WLAN_REPORT_WARNING( pTxData->hReport, TX_DATA_MODULE_LOG,
+                             (" %s: XFER complete CB called when port is CLOSED!", __FUNCTION__)); 
+        return;
+    }
+
+    /* try to schedule another MSDU */
+    txData_startTxScheduler(hTxData);
+}
+
+
+/***************************************************************************
+*                           txData_txCompleteUpdate                        *
+****************************************************************************
+* DESCRIPTION:  check if there are more packets in the queue to transmit,
+*               and that the queues in the HW are empty. if so then release
+*               the HW. else call to the scheduler.
+*
+* INPUTS:       hTxData - the object
+*               txStatus - status of Tx (OK = ok, other = failed)
+*               TxQid - The Tx queue index.
+*
+* OUTPUT:
+*
+* RETURNS:  TI_STATUS - is success then OK, else NOK
+*
+***************************************************************************/
+TI_STATUS txData_txCompleteUpdate(TI_HANDLE hTxData, txCompleteAttr_t *pCmpltAttr)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    UINT8 qIndex;
+    txPacketIdAttr_t* pPacketId = (txPacketIdAttr_t*)pCmpltAttr->packetId;    
+
+    /*
+     * when host processes the packets , we not working with Queue free event
+     * so queue status in TNET is updated in tx complete and the scheduler is triggered.
+     */
+    qIndex = pPacketId->txQid;
+
+    WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            ("txData_txCompleteUpdate , queueId: %d  status: %d\n", qIndex, pCmpltAttr->status));
+
+    /*
+     * first update that TNET Queue is available to get another packet 
+     */
+    pTxData->txDataAvailableQueue[qIndex] = TRUE;
+
+    /* update TX counters for txDistributer */
+    txData_UpdateTxCounters( hTxData, pCmpltAttr );
+
+    /* update dbg counters */
+    pTxData->txDataDbgCounters.dbgNumOfsendPacketComplete[qIndex]++;
+    if (pCmpltAttr->status == SEND_COMPLETE_SUCCESS) 
+    {
+        pTxData->txDataDbgCounters.dbgTxCmpltOk[qIndex]++;
+        pTxData->txDataDbgCounters.dbgTxCmpltOkBytes[qIndex] += pPacketId->msduDataLen;
+      #if defined(TI_DBG)
+        pTxData->txJitter[qIndex].jitter.air += 
+            ABS (pTxData->txJitter[qIndex].last_delay.air - pCmpltAttr->actualDurationInAir);
+        pTxData->txJitter[qIndex].jitter.fw += 
+            ABS (pTxData->txJitter[qIndex].last_delay.fw - pCmpltAttr->fwHandlingTime);
+        pTxData->txJitter[qIndex].last_delay.fw = pCmpltAttr->fwHandlingTime;
+        pTxData->txJitter[qIndex].last_delay.air = pCmpltAttr->actualDurationInAir;
+        pTxData->txJitter[qIndex].delay.fw += pCmpltAttr->fwHandlingTime;
+        pTxData->txJitter[qIndex].delay.air += pCmpltAttr->actualDurationInAir;
+        if (pCmpltAttr->fwHandlingTime > pTxData->txJitter[qIndex].max_delay.fw)
+            pTxData->txJitter[qIndex].max_delay.fw = pCmpltAttr->fwHandlingTime; 
+        if (pCmpltAttr->actualDurationInAir > pTxData->txJitter[qIndex].max_delay.air)
+            pTxData->txJitter[qIndex].max_delay.air = pCmpltAttr->actualDurationInAir; 
+      #endif
+    }
+    else
+    {
+        pTxData->txDataDbgCounters.dbgTxCmpltError[qIndex]++;
+        /* on error, update TX counters (xmit error count) */
+    }
+
+
+    /* check asynchronous in packetId */
+    if ( (pTxData->txDataDbgCounters.dbgNumOfMsduTxTransferCB[qIndex] +  pTxData->txDataDbgCounters.dbgNumOfMsduXferDoneInShceduler[qIndex])< 
+         pTxData->txDataDbgCounters.dbgNumOfsendPacketComplete[qIndex])
+    {
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                ("txData_txCompleteUpdate ,  qIndex = %d Num of XFER done CB + XFER done status = %d  dbgNumOfsendPacketComplete = %d!!!!\n",
+                qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduTxTransferCB[qIndex] +  
+                 pTxData->txDataDbgCounters.dbgNumOfMsduXferDoneInShceduler[qIndex],
+                pTxData->txDataDbgCounters.dbgNumOfsendPacketComplete[qIndex]));
+    }
+
+    /* check if XFER done was called for this packet */
+    if ( TRUE == pPacketId->bXferDoneCalled )
+    {
+        /* free the packet ID buffer */
+        bufferPool_releaseBuffer( pTxData->hBufferPool, (bufferPool_buffer_t)pPacketId );
+    }
+    else
+    {
+        /* 
+         * in rare cases, TX complete can be called before XFER done. If this is the case,
+         * simply mark that TX complete was called. The packet ID will be freed on XFER done
+         */
+        pPacketId->bTxCompleteCalled = TRUE;
+    }
+
+    /* run the scheduler */
+    txData_startTxScheduler(hTxData);
+
+    return OK;
+}
+
+/***************************************************************************
+*                           txData_sendPacketDebug                         *
+****************************************************************************
+* DESCRIPTION:  GWSI sendPacketDebug CB, called upon issuing interrupt to TNET.
+*               The function calculates GWSI delay and jitter.
+*
+* INPUTS:       hTxData    - the object
+*               uPacketId  - packet handle
+* OUTPUT:
+*
+* RETURNS:  void
+*
+***************************************************************************/
+#ifdef TI_DBG
+void txData_sendPacketDebug (TI_HANDLE hTxData, UINT32 uPacketId, UINT32 uDebugInfo)
+{
+
+    txData_t *pTxData = (txData_t *)hTxData;
+    txPacketIdAttr_t* pPacketId = (txPacketIdAttr_t *)uPacketId;
+
+    if (pTxData != NULL && pPacketId != NULL)
+    {
+        UINT32 uXferDelay = os_timeStampUs (pTxData->hOs);
+
+        switch (uDebugInfo)
+        {
+        case 0:
+            /* Calculate full XFER delay */
+            if (uXferDelay >= pPacketId->timeStamp[0])
+            {
+                uXferDelay -= pPacketId->timeStamp[0];
+
+                /* Update jitter statistics */
+                pTxData->txJitter[pPacketId->txQid].delay.xfer += uXferDelay;
+                pTxData->txJitter[pPacketId->txQid].jitter.xfer +=
+                ABS (uXferDelay - pTxData->txJitter[pPacketId->txQid].last_delay.xfer);
+                pTxData->txJitter[pPacketId->txQid].last_delay.xfer = uXferDelay;
+                pTxData->txJitter[pPacketId->txQid].count.xfer ++; 
+                if (uXferDelay > pTxData->txJitter[pPacketId->txQid].max_delay.xfer)
+                    pTxData->txJitter[pPacketId->txQid].max_delay.xfer = uXferDelay;
+            }
+            break;
+
+        default:
+            if (uDebugInfo < 5)
+                pPacketId->timeStamp[uDebugInfo] = uXferDelay;
+            break;
+        }
+    }
+}
+#endif
+
+
+/***************************************************************************
+*                           txData_getHighestAdmittedAc                     *
+****************************************************************************
+* DESCRIPTION:  This function calculate the highest admitted AC starting from
+*               a given ac index. if it fails it returns acIndex of Best effort.
+*
+* INPUTS:       hTxData - the object
+*               qosTag - Qos tag
+*
+* OUTPUT:
+*
+* RETURNS:  OK
+*           NOK
+***************************************************************************/
+
+static int txData_getHighestAdmittedAc(txData_t *pTxData, int startingAcIndex)
+{
+    int qIndex;
+
+    if ((startingAcIndex > MAX_NUM_OF_AC - 1) || (startingAcIndex < FIRST_AC_INDEX))
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                          (" txData_getHighestAdmittedAc() :  failed, startingAcIndex = %d \n",startingAcIndex));
+        return QOS_AC_BE;
+    }
+
+    qIndex = GET_QUEUE_INDEX(pTxData, startingAcIndex);
+
+    /* If desired queue is not admitted, find highest Tx queue that doesn't require admission. */
+    if(pTxData->dataMsduListArr[qIndex]->admissionState == AC_NOT_ADMITTED)
+    {
+        while(qIndex >= 0)
+        {
+            if(pTxData->dataMsduListArr[qIndex]->admissionRequired == ADMISSION_NOT_REQUIRED)
+                break;
+            qIndex--;
+        }
+    }
+    
+    if(qIndex < 0)
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_getHighestAdmittedAc() :  failed, qIndex = %d \n",qIndex));
+        return startingAcIndex;
+    }
+
+    return pTxData->dataMsduListArr[qIndex]->acId;
+}
+
+
+
+/***************************************************************************
+*                           txData_selectQueueAndUpdateUserPriority                           *
+****************************************************************************
+* DESCRIPTION:  This function calculate the queue index according to msdu qos tag
+*               if the queue isn't admitted tt returns the highest admitted queue
+*               bellow.
+*               In addition, if the MSDU has been downgraded due to admission control,
+*               we update the QosControl accordingly
+*
+* INPUTS:       hTxData - the object
+*               pMSDU - pointer to packet
+*
+* OUTPUT:       selectedQueue - pointer to result variable which will hold the selected queue index
+*               acIndex - selected admission control
+*
+* RETURNS:  OK
+*           NOK
+***************************************************************************/
+static int txData_selectQueueAndUpdateUserPriority (txData_t *pTxData, mem_MSDU_T *pMsdu, int *selectedQueue, acTrfcType_e *selectedAc)
+{
+    int startingAcIndex;
+    int acIndex;
+    dot11_header_t      *pdot11Header;
+
+    if (pMsdu->qosTag > MAX_NUM_OF_802_1d_TAGS - 1)
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_selectQueueAndUpdateUserPriority() : txData_getQueueIndex failed, pMsdu->qosTag = %d \n",pMsdu->qosTag));
+        *selectedAc = QOS_AC_BE;
+        *selectedQueue = GET_QUEUE_INDEX(pTxData, QOS_AC_BE);
+        return NOK;
+    }
+    /* calc ac according tag to ac table */
+    acIndex = startingAcIndex = pTxData->txDataQosParams.tag_ToAcClsfrTable[pMsdu->qosTag];
+
+    /* get highest admitted AC */
+    if(pTxData->admissionDownGradeEnable == TRUE)
+        acIndex = txData_getHighestAdmittedAc(pTxData,startingAcIndex);
+
+    /* If the highest admitted AC is not the "starting" AC that we originally desired, we were downgraded due to admission control
+       and we should update the QosControl field accordingly 
+       In addition, we do not want to modify the QosControl unless the header actually contains Qos data */
+    if ((acIndex != startingAcIndex) && (pTxData->txDataQosParams.headerConverMode == QOS_CONVERT))
+    {
+      pdot11Header = (dot11_header_t*)(memMgr_BufData(pMsdu->firstBDPtr)+ memMgr_BufOffset(pMsdu->firstBDPtr));      
+
+      pdot11Header->qosControl = wmeAcToUpIndex[acIndex];
+    }
+
+    /* convert acIndex to qIndex */
+    *selectedQueue = pTxData->txDataAcTrfcCtrl[acIndex].QueueIndex;
+    *selectedAc = (acTrfcType_e)acIndex;
+
+    return OK;
+}
+
+
+
+/***************************************************************************
+*                           txData_acVoPsPollMode                          *
+****************************************************************************
+* DESCRIPTION:  This function determines if we are current in power save mode
+*               sending voice packet with SW ps-poll method.
+*
+* INPUTS:       hTxData - the object
+*               qosTag - Qos tag
+*
+* OUTPUT:
+*
+* RETURNS:  TRUE
+*           FALSE
+***************************************************************************/
+
+static BOOL txData_acVoPsPollMode(txData_t *pTxData)
+{
+    BOOL ps_status = FALSE;
+
+    ps_status = PowerMgr_getPsStatus(pTxData->hPowerMgr);
+
+    if (ps_status &&
+        pTxData->txDataAcTrfcCtrl[QOS_AC_VO].PsMode == PS_SCHEME_LEGACY_PSPOLL)
+    {
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+
+
+/***************************************************************************
+*                       txData_disableTransmission                         *
+****************************************************************************
+* DESCRIPTION:  This function sets an internal flag in order to diable
+*                   transmission.
+*
+* INPUTS:       hTxData - the object
+*               reason  - indicates if the reason for transmission disable
+*                           is measuring of non serving channel or Switch Channel command
+*
+* OUTPUT:
+*
+* RETURNS:       OK on success, NOK otherwise
+***************************************************************************/
+TI_STATUS txData_disableTransmission(TI_HANDLE hTxData,txDisableReason_e reason)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    pTxData->txDisable = reason;
+    return OK;
+}
+
+/***************************************************************************
+*                       txData_enableTransmission                          *
+****************************************************************************
+* DESCRIPTION:  This function sets an internal flag in order to enable
+*                   back the transmission.
+*
+* INPUTS:       hTxData - the object
+*
+*
+* OUTPUT:
+*
+* RETURNS:       OK on success, NOK otherwise
+***************************************************************************/
+TI_STATUS txData_enableTransmission(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    pTxData->txDisable = NO_DISABLE;
+    txData_startTxScheduler(pTxData);
+
+    return OK;
+}
+
+
+
+/***************************************************************************
+*               txData_schedulerSelectQueueToTransmitFrom                  *
+****************************************************************************
+* DESCRIPTION:  This function selects the tx queue to transmit MSDU from.
+*               Management MSDUs are selected in first priority.
+*               For data MSDUs, the queue selection is done by the following order:
+*               1) The queue is not empty.
+*               2) It is permitted to transmit (admitted and not blocked by mediumTime).
+*               3) It has minimal number of Hw blocks waiting for Tx.
+*                   Note: this is to fill all queues for efficient EDCA process in FW.
+*               4) It has minimal history-counter (shows it wasn't selected lately).
+*               5) It is the highest priority queue.
+*
+*               Note: Selection between queues is done by step 'n' only if all steps before it
+*                       gave identical results. Also, steps 1 & 2 are mandatory for selection.
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:       pMsduListPtr -       a pointer to the selected queue list-pointer.
+*               selectedQueueIndex - a pointer to the selected queue index.
+*
+* RETURNS:      TX_QUEUE_SELECTED_OK - a queue was selected.
+*               NO_TX_QUEUE_SELECTED - no msdu to transmit.
+***************************************************************************/
+
+static TI_STATUS txData_schedulerSelectQueueToTransmitFrom( TI_HANDLE hTxData, MsduList_t** pMsduListPtr,UINT8 *selectedQueueIndex )
+{
+    txData_t    *pTxData = (txData_t *)hTxData;
+    UINT8       acIndex;
+    int         qIndex;
+    UINT32      currentTimeStamp = os_timeStampMs(pTxData->hOs);
+    UINT32      AllQueuesMinTime = 0;
+    UINT32      currQueuesTime = 0;
+    MsduList_t  *pMsduList;
+    UINT32      currentQueueWeight; 
+    UINT32      bestWeight = Q_LEAST_WEIGHT; /* Weight of preferred queue (lowest value is selected). */
+    int         bestWeightQueueIndex = 0;    /* Index of preferred queue. */
+    MsduList_t  *bestWeightQueueList = NULL; /* Pointer to the preferred queue list. */
+
+    /* If management MSDU is waiting, select it and return. */
+    if( pTxData->mngMsduList->CurrNumOfMsdu > 0 )
+    {
+        *pMsduListPtr = pTxData->mngMsduList;
+
+        /* get highest admitted AC starting from VO */
+        acIndex = txData_getHighestAdmittedAc(pTxData,QOS_AC_VO);
+
+        /* convert acIndex to queue index */
+        *selectedQueueIndex = GET_QUEUE_INDEX(pTxData,acIndex);
+
+
+        if (pTxData->txDataAvailableQueue[*selectedQueueIndex] == TRUE)
+        {
+            WLAN_REPORT_INFORMATION (pTxData->hReport, TX_DATA_MODULE_LOG,
+               (" txData_schedulerSelectQueueToTransmitFrom() : Management MSDU selected to Tx\n"));
+            return TX_QUEUE_SELECTED_OK;
+        }
+        else
+        {
+            WLAN_REPORT_INFORMATION (pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_schedulerSelectQueueToTransmitFrom() : pTxData->txDataAvailableQueue[%d] = FALSE  \n",*selectedQueueIndex));
+        }
+    }
+
+
+    /* 
+     * Loop over all core data Tx queues and look for the preferred one to transmit from:
+     * =================================================================================
+     *   Note:  Starting from the highest priority ensures that if multiple queues have 
+     *            identical status, the highest priority one among them will be selected.  
+     */
+    for (qIndex = MAX_NUM_OF_TX_QUEUES - 1; qIndex >= 0; qIndex--)
+    {
+        pMsduList = pTxData->dataMsduListArr[qIndex];
+
+        if (pMsduList->selectionHistoryCounter)
+            pMsduList->selectionHistoryCounter--;
+        
+        /* If queue is empty or is not admitted to transmit, continue to next queue.  */
+        if ((pMsduList->CurrNumOfMsdu == 0) || (pMsduList->admissionState != AC_ADMITTED))
+            continue;
+
+        /*
+         * see only if Queue is available.
+         * continue to the next Q if not available
+         */
+        if (pTxData->txDataAvailableQueue[qIndex] == FALSE)
+            continue;
+
+            /* If we are configured to enforce excess Tx time limits, handle the algorithm. */
+            if (pMsduList->useAdmissionAlgo) 
+            {
+            /* Handle case of timer wraparound. */
+                if (currentTimeStamp < pMsduList->lastTimeStamp)
+                    pMsduList->lastTimeStamp = 0;
+                
+            /* If we it's not time to enable Tx yet for this queue, update time to try again if needed. */ 
+            if (currentTimeStamp < pMsduList->lastTimeStamp + pMsduList->enableTransmissionTime)
+            {
+                /* currQueuesTime represents the amount of time the tx scheduler has to wait before 
+                    it will be able to transmit from this queue. */
+                    currQueuesTime = (pMsduList->lastTimeStamp + pMsduList->enableTransmissionTime - currentTimeStamp);
+                    
+                /* Update the minimum time left till we can Tx from any of the queues. */
+                if (AllQueuesMinTime == 0)
+                        AllQueuesMinTime = currQueuesTime;
+                    else
+                        AllQueuesMinTime = MIN(AllQueuesMinTime, currQueuesTime);
+            
+                /* We can't Tx from this queue yet so continue to next queue. */
+                continue;
+            }
+        } 
+
+        /****  If we got here, this queue has something to Tx and it is permitted to Tx now. ****/
+
+        /* Now calculate this queue's weight for selection:  
+         *      Higher 16 bits:  Number of used HW blocks by this AC.
+         *      Lower  16 bits:  Count down from last time it was selected. */
+        currentQueueWeight  = (UINT32)TnetwDrv_txHwQueue_GetUsedHwBlks( pTxData->hTnetwDrv, qIndex ) << 16;
+        currentQueueWeight |= (UINT32)pMsduList->selectionHistoryCounter;
+
+        /* If current queue's weight isn't lower (lower is better!) than previous queues, 
+             continue to next queue. */
+        if (currentQueueWeight >= bestWeight)
+            continue;
+
+        /* Save weight, index and list-pointer of best candidate queue so far . */
+        bestWeight = currentQueueWeight;
+        bestWeightQueueIndex = qIndex;
+        bestWeightQueueList = pMsduList;
+    }
+    
+    
+    /* If we have a delayed queue, we need to re-trigger the scheduler later by timer. */
+    if (AllQueuesMinTime != 0)
+    {   
+        /* msdu is waiting to transmit */
+        WLAN_REPORT_INFORMATION (pTxData->hReport, TX_DATA_MODULE_LOG, 
+            (" txData_schedulerSelectQueueToTransmitFrom() : Start mediumTime timer for - %d ms\n", AllQueuesMinTime));
+        
+        if ( pTxData->bSchedulerTimerRunning == TRUE )
+        {
+            os_timerStop(pTxData->hOs, pTxData->pSchedulerTimer);
+        }
+        os_timerStart(pTxData->hOs,pTxData->pSchedulerTimer, AllQueuesMinTime, FALSE);
+        pTxData->bSchedulerTimerRunning = TRUE;
+    }
+
+
+    /* If we have a queue we can transmit from:  */
+    if (bestWeight != Q_LEAST_WEIGHT)
+    {
+        /* Set selected queue history counter to its initial value, indicating it was selected
+            lately and its priority is temporarily reduced. */
+        bestWeightQueueList->selectionHistoryCounter = Q_SELECTION_HISTORY_LEVEL;
+
+        /* Provide the selected queue index and list pointer. */
+        *pMsduListPtr = bestWeightQueueList;
+        *selectedQueueIndex = bestWeightQueueIndex;
+
+        WLAN_REPORT_INFORMATION (pTxData->hReport, TX_DATA_MODULE_LOG, 
+            (" txData_schedulerSelectQueueToTransmitFrom() : Selected-TxQ = %d,  Weight = 0x%x\n",
+                bestWeightQueueIndex, bestWeight));
+        
+        return TX_QUEUE_SELECTED_OK;
+    }
+
+    
+    /* If we got here, no queue is currently suitable for transmition. */
+    WLAN_REPORT_DEBUG_TX(pTxData->hReport, 
+        (" txData_schedulerSelectQueueToTransmitFrom() : No queue selected for Tx\n"));
+
+    return NO_TX_QUEUE_SELECTED;
+}
+
+
+
+/***************************************************************************
+*                           txData_getParam                                *
+****************************************************************************
+* DESCRIPTION:  get a specific parameter
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:       pParamInfo - structure which include the value of
+*               the requested parameter
+*
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+TI_STATUS txData_getParam(TI_HANDLE hTxData, paramInfo_t *pParamInfo)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    UINT32  tID;
+
+    /* check handle validity */
+    if( pTxData == NULL  )
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_getParam() : Illegal parametrs value \n"));
+        return NOK;
+    }
+
+    switch (pParamInfo->paramType)
+    {
+        case TX_DATA_PORT_STATUS_PARAM:
+            pParamInfo->content.txDataPortStatus = pTxData->txDataPortStatus;
+            break;
+
+        case TX_DATA_CURRENT_PRIVACY_INVOKE_MODE_PARAM:
+            pParamInfo->content.txDataCurrentPrivacyInvokedMode = pTxData->txDataCurrentPrivacyInvokedMode;
+            break;
+
+        case TX_DATA_EAPOL_ENCRYPTION_STATUS_PARAM:
+            pParamInfo->content.txDataEapolEncryptionStatus = pTxData->txDataEapolEncryptionStatus;
+            break;
+
+        case TX_DATA_CONVERT_HEADER_MODE:
+            pParamInfo->content.txDataQosParams.qosParams.headerConverMode = pTxData->txDataQosParams.headerConverMode;
+            break;
+
+        case TX_DATA_COUNTERS_PARAM:
+            os_memoryCopy( pTxData->hOs, &(pTxData->tempTxDataCounters[ 0 ]), &(pTxData->txDataCounters[ 0 ]), 
+                           sizeof(txDataCounters_t) * MAX_NUM_OF_TX_QUEUES );
+            pParamInfo->content.pTxDataCounters = &(pTxData->tempTxDataCounters[ 0 ]);
+            break;
+
+        case TX_DATA_REPORT_TS_STATISTICS:
+            tID = GET_QUEUE_INDEX(pTxData, pParamInfo->content.tsMetricsCounters.acID);
+            os_memoryCopy(pTxData->hOs, 
+                          pParamInfo->content.tsMetricsCounters.pTxDataCounters, 
+                          &(pTxData->txDataReportedCounters[tID]), 
+                          sizeof(txDataCounters_t));
+            os_memoryZero(pTxData->hOs, 
+                          &(pTxData->txDataReportedCounters[tID]), 
+                          sizeof(txDataCounters_t));
+            break;
+
+        case TX_DATA_GET_VAD:
+            pParamInfo->content.txDataVadTimerParams.vadTimerEnabled  = pTxData->bVadTimerEnabled;
+            pParamInfo->content.txDataVadTimerParams.vadTimerDuration = pTxData->vadTimerDuration;
+            
+                   WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                   ("txData_setParams: GET_VAD (enable=%d; duration=%d ms)\n", 
+                     pTxData->bVadTimerEnabled, pTxData->vadTimerDuration));
+               break;
+
+        default:
+            return (PARAM_NOT_SUPPORTED);
+/*            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                (" txData_getParam() : PARAMETER NOT SUPPORTED \n"));
+            return NOK;
+            break; - unreachable*/
+    }
+
+    return (OK);
+}
+
+
+
+/***************************************************************************
+*                           txData_setParam                                *
+****************************************************************************
+* DESCRIPTION:  set a specific parameter
+*
+* INPUTS:       hTxData - the object
+*               pParamInfo - structure which include the value to set for
+*               the requested parameter
+*
+* OUTPUT:
+*
+* RETURNS:      OK
+*               NOK
+***************************************************************************/
+TI_STATUS txData_setParam(TI_HANDLE hTxData, paramInfo_t *pParamInfo)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    UINT8 queueIndex;
+    UINT8 acID = pParamInfo->content.txDataQosParams.acID; /* Note: acID is relevant only in  
+                                                                    some of the param-types!! */
+
+    /* check handle validity */
+    if( pTxData == NULL  )
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_setParam() : Illegal parametrs value \n"));
+        return NOK;
+    }
+
+    
+    switch (pParamInfo->paramType)
+    {
+    case TX_DATA_PORT_STATUS_PARAM:
+
+    {
+        /* Set the new TX port status CLOSE/OPEN_NOTIFY/OPEN_EAPOL/OPEN */
+        WLAN_REPORT_DEBUG_TX (pTxData->hReport, 
+                              (("txData_setParam: Set txDataPortStatus from 0x%x to 0x%x\n"),
+                                pTxData->txDataPortStatus , pParamInfo->content.txDataPortStatus));
+
+        pTxData->txDataPortStatus = pParamInfo->content.txDataPortStatus;
+        break;
+    }
+
+    case TX_DATA_CURRENT_PRIVACY_INVOKE_MODE_PARAM:
+        pTxData->txDataCurrentPrivacyInvokedMode = pParamInfo->content.txDataCurrentPrivacyInvokedMode;
+        break;
+
+    case TX_DATA_EAPOL_ENCRYPTION_STATUS_PARAM:
+        pTxData->txDataEapolEncryptionStatus = pParamInfo->content.txDataEapolEncryptionStatus;
+        break;
+
+    case TX_DATA_HAL_INTERFACE_STATUS_PARAM:
+        pTxData->txDataHalInterfaceStatus = pParamInfo->content.txDataHalInterfaceStatus;
+        break;
+
+    case TX_DATA_PS_MODE_PARAM:
+        pTxData->txDataAcTrfcCtrl[acID].PsMode = 
+            pParamInfo->content.txDataQosParams.acTrfcCtrl.PsMode;
+        break;
+
+    case TX_DATA_CONFIG_TX_QUEUE_SIZE:
+        queueIndex = pParamInfo->content.txDataQosParams.acTrfcCtrl.QueueIndex;
+           pTxData->txDataAcTrfcCtrl[acID].TxQueueSize = 
+               pParamInfo->content.txDataQosParams.acTrfcCtrl.TxQueueSize;
+        if(queueIndex >= MAX_NUM_OF_TX_QUEUES)
+           {
+               WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+               ("Error configure Data MsduList , wrong queue index = %d\n", queueIndex));
+            return NOK;
+        }
+        pTxData->dataMsduListArr[queueIndex]->acId = acID;
+        pTxData->txDataAcTrfcCtrl[acID].QueueIndex = queueIndex;
+
+        /* also set the opposute direction conversion table (queue ID -> ac ID) */
+        txData_SetQidToAcTable( hTxData, queueIndex, queueIndex, acID );
+
+        if( (msduList_SetMsduListNumOfElements( pTxData->dataMsduListArr[queueIndex],
+                pTxData->txDataAcTrfcCtrl[acID].TxQueueSize)) != OK )
+           {
+               WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                       ("Error configure MgmtMsduList\n"));
+               return NOK;
+           }
+        break;
+
+    case TX_DATA_CONFIG_TX_QUEUE_OVFLOW_POLICY:
+        queueIndex = pParamInfo->content.txDataQosParams.acTrfcCtrl.QueueIndex;
+        pTxData->txDataAcTrfcCtrl[acID].QueueOvFlowPolicy = pParamInfo->content.txDataQosParams.acTrfcCtrl.QueueOvFlowPolicy;
+        if(queueIndex >= MAX_NUM_OF_TX_QUEUES)
+        {
+            WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+                 ("Error configure MsduList over flow policy , wrong queue index = %d\n",queueIndex));
+            return NOK;
+        }
+        pTxData->txDataAcTrfcCtrl[acID].QueueIndex  = queueIndex;
+        msduList_SetMsduListOverFlowPolicy(pTxData->dataMsduListArr[pTxData->txDataAcTrfcCtrl[acID].QueueIndex],
+                                           pTxData->txDataAcTrfcCtrl[acID].QueueOvFlowPolicy);
+        break;
+
+    case TX_DATA_CONFIG_AC_MSDU_LIFE_TIME:
+        pTxData->txDataAcTrfcCtrl[acID].MsduLifeTime = 1000 * pParamInfo->content.txDataQosParams.acTrfcCtrl.MsduLifeTime;
+        break;
+
+    case TX_DATA_CONFIG_AC_ACK_POLICY:
+        pTxData->txDataAcTrfcCtrl[acID].ackPolicy = pParamInfo->content.txDataQosParams.acTrfcCtrl.ackPolicy;
+        break;
+
+    case TX_DATA_AC_ADMISSION_STATE:
+        pTxData->dataMsduListArr[GET_QUEUE_INDEX(pTxData, acID)]->admissionRequired = 
+            pParamInfo->content.txDataQosParams.qosParams.admissionRequired;
+
+        pTxData->dataMsduListArr[GET_QUEUE_INDEX(pTxData, acID)]->admissionState = 
+            pParamInfo->content.txDataQosParams.qosParams.admissionState;
+        break;
+
+    case TX_DATA_CONVERT_HEADER_MODE:
+        pTxData->txDataQosParams.headerConverMode = pParamInfo->content.txDataQosParams.qosParams.headerConverMode;
+        break;
+
+    case TX_DATA_TAG_TO_AC_CLASSIFIER_TABLE:
+        os_memoryCopy(pTxData->hOs,(pTxData->txDataQosParams.tag_ToAcClsfrTable),
+            pParamInfo->content.txDataQosParams.qosParams.tag_ToAcClsfrTable,sizeof(acTrfcType_e) * MAX_NUM_OF_802_1d_TAGS);
+        break;
+
+    case TX_DATA_SET_AC_QUEUE_INDEX:
+        queueIndex = pParamInfo->content.txDataQosParams.acTrfcCtrl.QueueIndex;
+
+        pTxData->txDataAcTrfcCtrl[pParamInfo->content.txDataQosParams.acID].QueueIndex = queueIndex;
+        /* also set the opposute direction conversion table (queue ID -> ac ID) */
+        txData_SetQidToAcTable( hTxData, queueIndex, queueIndex, acID );
+        break;
+
+    case TX_DATA_SET_MEDIUM_USAGE_THRESHOLD:
+       txData_setMediumUsageThresholds (hTxData,
+            (UINT8)pParamInfo->content.txDataMediumUsageThreshold.uAC,
+            pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold,
+            pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold);
+       break;
+
+    case TX_DATA_GET_MEDIUM_USAGE_THRESHOLD:
+        /* SET operation is performed, but actually this is only for AC parameter transfer from Utility Adapter to driver, since copy
+          of user supplied block of data (and vice versa) is only performed in SetParam calls, the driver can also modify the supplied
+          structure and thus return it to user mode */
+        queueIndex = pTxData->txDataAcTrfcCtrl[pParamInfo->content.txDataMediumUsageThreshold.uAC].QueueIndex;
+
+        /* get threshold */
+        pParamInfo->content.txDataMediumUsageThreshold.uHighThreshold = pTxData->dataMsduListArr[queueIndex]->highMediumUsageThreshold;
+        pParamInfo->content.txDataMediumUsageThreshold.uLowThreshold = pTxData->dataMsduListArr[queueIndex]->lowMediumUsageThreshold;
+        
+        break;
+
+    case TX_DATA_POLL_AP_PACKETS_FROM_AC:
+
+         queueIndex = pTxData->txDataAcTrfcCtrl[pParamInfo->content.txDataPollApPacketsFromACid].QueueIndex;
+
+         if (queueIndex <= QOS_AC_MAX)
+            return (txData_sendVadFrame (pTxData, queueIndex));
+         else
+            return PARAM_VALUE_NOT_VALID;
+       
+/*       break; - unreachable */
+
+    case TX_DATA_ENCRYPTION_FIELD_SIZE:
+        /* set the space to reserve for encrypted frames */
+        pTxData->encryptionFieldSize = pParamInfo->content.txDataEncryptionFieldSize;
+        break;
+
+    case TX_DATA_RESET_COUNTERS_PARAM:
+        txData_resetCounters( hTxData );
+        break;
+
+    case TX_DATA_SET_VAD:
+       {
+           BOOL bVadTimerEnabled;
+           UINT16 vadTimerDuration;
+
+                   bVadTimerEnabled = pParamInfo->content.txDataVadTimerParams.vadTimerEnabled;
+            vadTimerDuration = pParamInfo->content.txDataVadTimerParams.vadTimerDuration;    
+           WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+               ("txData_setParams: SET_VAD (enable=%d; duration=%d ms)\n", 
+                 bVadTimerEnabled, vadTimerDuration));
+
+           txData_setVadTimer(hTxData, bVadTimerEnabled, vadTimerDuration);
+       }
+
+       break;
+
+    default:
+        return (PARAM_NOT_SUPPORTED);
+/*        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_setParam() : PARAMETER NOT SUPPORTED \n"));
+        return NOK;
+        break; - unreachable */
+    }
+
+    return (OK);
+}
+
+
+/***************************************************************************
+*                   txData_convertEthToWlanHeader                          *
+****************************************************************************
+* DESCRIPTION:  this function convert the msdu header from ethernet format
+*               to the 802.11 header format
+*
+* INPUTS:       hTxData - the object
+*               pMsdu - msdu in ethernet format
+*
+* OUTPUT:       pMsdu - msdu in 802.11 format
+*
+* RETURNS:      
+***************************************************************************/
+static void txData_convertEthToWlanHeader (txData_t *pTxData, mem_MSDU_T *pMsdu)
+{
+    EthernetHeader_t    *pEthHeader;
+    dot11_header_t      dot11Header;
+    Wlan_LlcHeader_T    WlanSnapHeader;
+    UINT16              swapedTypeLength;
+    bssType_e           currBssType;
+    macAddress_t        currBssId;
+    UINT8               SNAP_OUI_802_1H[] = SNAP_OUI_802_1H_BYTES;
+    UINT8               SNAP_OUI_RFC1042[] = SNAP_OUI_RFC1042_BYTES;
+    acTrfcType_e        acIndex;
+    char*               pData;
+
+    /* initialize the frame header length */
+    pMsdu->headerLen = txData_GetWlanHeaderLength( pTxData,
+                                                   memMgr_BufData(pMsdu->firstBDPtr) + 
+                                                   memMgr_BufOffset(pMsdu->firstBDPtr),
+                                                   pMsdu->txFlags );
+
+    /*
+     * Set the Eth pointer to the beginning of the first Bd
+        */  
+       pEthHeader = (EthernetHeader_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr));
+
+       /*
+     * Initialize working copy of the dot11header to zero
+        */
+    os_memoryZero(pTxData->hOs,&dot11Header,sizeof(dot11_header_t));
+        
+        /* 
+         * Convert the header 802.3 ---> 802.11 onto the dot11Header working copy
+         */
+    /* set Qos control */
+    if( pTxData->txDataQosParams.headerConverMode == QOS_CONVERT )
+    {
+        /* set qos Tag */
+        dot11Header.qosControl = ((UINT16)pMsdu->qosTag & QOS_CONTROL_TAG_MASK);
+
+        /* 
+                 * set ac ack policy according to the 
+                 * Ack policy defined for the particular AC
+                 */
+        acIndex = (acTrfcType_e)GET_WME_AC_TYPE_FROM_MSDU(pMsdu);
+        if(pTxData->txDataAcTrfcCtrl[acIndex].ackPolicy == ACK_POLICY_LEGACY)
+        {
+            dot11Header.qosControl &= ~DOT11_QOS_CONTROL_DONT_ACK;
+        }
+        else
+        {
+            dot11Header.qosControl |= DOT11_QOS_CONTROL_DONT_ACK;
+        }
+    }
+
+    /* receive BssId and Bss Type from control module */
+    ctrlData_getCurrBssTypeAndCurrBssId(pTxData->hCtrlData, &currBssId, &currBssType);
+
+    if (currBssType == BSS_INDEPENDENT)
+    {
+        MAC_COPY(pTxData->hOs,(&dot11Header.address1),(&pEthHeader->DstAddr));
+        MAC_COPY(pTxData->hOs,(&dot11Header.address2),(&pEthHeader->SrcAddr));
+        MAC_COPY(pTxData->hOs,(&dot11Header.address3),(&currBssId));
+
+        if( pTxData->txDataQosParams.headerConverMode == QOS_CONVERT )
+            dot11Header.fc = DOT11_FC_DATA_QOS;
+        else
+            dot11Header.fc = DOT11_FC_DATA;
+    }
+    else /* infrastructure BSS */
+    {
+        MAC_COPY(pTxData->hOs,(&dot11Header.address1),(&currBssId));
+        MAC_COPY(pTxData->hOs,(&dot11Header.address2),(&pEthHeader->SrcAddr));
+        MAC_COPY(pTxData->hOs,(&dot11Header.address3),(&pEthHeader->DstAddr));
+
+        if( pTxData->txDataQosParams.headerConverMode == QOS_CONVERT )
+            dot11Header.fc = DOT11_FC_DATA_QOS | DOT11_FC_TO_DS;
+        else
+            dot11Header.fc = DOT11_FC_DATA | DOT11_FC_TO_DS;
+    }
+
+    swapedTypeLength = wlan_htons(pEthHeader->TypeLength);
+
+    /* Detect the packet type and decide if to create a     */
+    /*          new SNAP or leave the original LLC.         */
+    /*------------------------------------------------------*/
+    if( swapedTypeLength > ETHERNET_MAX_PAYLOAD_SIZE )
+    {
+        /* Create the SNAP Header:     */
+        /*-----------------------------*/
+        /*
+         * Make a working copy of the SNAP header 
+         * initialised to zero
+         */
+        os_memoryZero(pTxData->hOs,&WlanSnapHeader,sizeof(Wlan_LlcHeader_T));
+        WlanSnapHeader.DSAP = SNAP_CHANNEL_ID;
+        WlanSnapHeader.SSAP = SNAP_CHANNEL_ID;
+        WlanSnapHeader.Control = LLC_CONTROL_UNNUMBERED_INFORMATION;
+
+        /* Check to see if the Ethertype matches anything in the translation     */
+        /* table (Appletalk AARP or DixII/IPX).  If so, add the 802.1h           */
+        /* SNAP.                                                                 */
+
+        if(( ETHERTYPE_APPLE_AARP == swapedTypeLength ) ||
+           ( ETHERTYPE_DIX_II_IPX == swapedTypeLength ))
+        {
+            /* Fill out the SNAP Header with 802.1H extention   */
+            os_memoryCopy(pTxData->hOs, &WlanSnapHeader.OUI, SNAP_OUI_802_1H,
+                            sizeof( WlanSnapHeader.OUI ) );
+        }
+        else
+        {
+            /* otherwise, add the RFC1042 SNAP   */
+            os_memoryCopy(pTxData->hOs, &WlanSnapHeader.OUI, SNAP_OUI_RFC1042,
+                            sizeof( WlanSnapHeader.OUI) );
+        }
+        /* set type length */
+        WlanSnapHeader.Type = pEthHeader->TypeLength;
+    }
+
+    /*
+     * Now - copy wlan header and snap overriding Ethernet header.
+     */
+
+    /*
+       first the wlan header
+       the header might not include the qosControl which will be erase 
+       later by the snap header
+     */
+    /* pData starts after the reserved place for bus txn and the TxDescriptor */
+    
+    /* update data offset - bus txn extra space + TxDescriptor */
+    memMgr_BufOffset(pMsdu->firstBDPtr) = TX_TOTAL_OFFSET_BEFORE_DATA;
+
+    pData = memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr);
+    os_memoryCopy(pTxData->hOs,pData,&dot11Header,pMsdu->headerLen);
+
+    /* update data length */
+    pMsdu->dataLen = pMsdu->dataLen - ETHERNET_HDR_LEN + pMsdu->headerLen;
+
+    /* now the snap */
+    if( swapedTypeLength > ETHERNET_MAX_PAYLOAD_SIZE )
+    {
+        pData += (pMsdu->headerLen - sizeof(Wlan_LlcHeader_T));
+        os_memoryCopy(pTxData->hOs,pData,&WlanSnapHeader,sizeof(Wlan_LlcHeader_T));
+    }
+
+    return;
+}
+
+/***************************************************************************
+*                       txData_resetCounters                               *
+****************************************************************************
+* DESCRIPTION:  Reset the tx data module counters
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:
+***************************************************************************/
+void txData_resetCounters(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    os_memoryZero(pTxData->hOs, &pTxData->txDataCounters, sizeof(txDataCounters_t) * MAX_NUM_OF_TX_QUEUES);
+    pTxData->currentConsecutiveRetryFail = 0;
+}
+
+/***************************************************************************
+*                       txData_resetDbgCounters                            *
+****************************************************************************
+* DESCRIPTION:  Reset the tx data module debug counters
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:
+***************************************************************************/
+void txData_resetDbgCounters(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    os_memoryZero(pTxData->hOs, &pTxData->txDataDbgCounters, sizeof(txDataDbgCounters_t));
+}
+
+/***************************************************************************
+*                       txData_DistributorTxEvent                          *
+****************************************************************************
+* DESCRIPTION:
+*
+*
+* INPUTS:
+*
+*
+*
+* OUTPUT:
+*
+* RETURNS:
+*
+***************************************************************************/
+static VOID txData_DistributorTxEvent(txData_t *pTxData,UINT16 Mask,int DataLen)
+{
+   if(pTxData->TxEventDistributor)
+     DistributorMgr_EventCall(pTxData->TxEventDistributor,Mask,DataLen);
+
+}
+
+/***************************************************************************
+*                       txData_RegNotif                                    *
+****************************************************************************/
+TI_HANDLE txData_RegNotif(TI_HANDLE hTxData,UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,UINT32 Cookie)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    if (!hTxData)
+        return NULL;
+    return DistributorMgr_Reg(pTxData->TxEventDistributor,EventMask,(TI_HANDLE)CallBack,context,Cookie);
+}
+
+
+/***************************************************************************
+*                       txData_AddToNotifMask                              *
+****************************************************************************/
+TI_STATUS txData_AddToNotifMask(TI_HANDLE hTxData,TI_HANDLE Notifh,UINT16 EventMask)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    if (!hTxData)
+        return NOK;
+    return DistributorMgr_AddToMask(pTxData->TxEventDistributor,Notifh,EventMask);
+}
+
+
+/***************************************************************************
+*                       TxData_UnRegNotif                                  *
+****************************************************************************/
+TI_STATUS txData_UnRegNotif(TI_HANDLE hTxData,TI_HANDLE RegEventHandle)
+{
+    TI_STATUS status;
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if (!hTxData)
+        return NOK;
+
+    status = DistributorMgr_UnReg(pTxData->TxEventDistributor,RegEventHandle);
+    return status;
+}
+
+/****************************************************************************
+ *                      txData_SetTxDelayCounters()
+ ****************************************************************************
+ * DESCRIPTION:          Update transmission path delay counters.
+*
+* INPUTS:       hTxData - the object
+*               txQid - the queue to count delay for
+*               pTxCompleteAttr - struct containing the necessary FW delay data
+*               driverDelay - the time consumed in driver for packet transmission
+*
+* OUTPUT:
+*
+* RETURNS:
+ ****************************************************************************/
+static void txData_SetTxDelayCounters( TI_HANDLE hTxData, UINT32 txQid, txCompleteAttr_t *pTxCompleteAttr, UINT32 driverDelay )
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int     rangeIndex;
+    UINT32  totalTxDelayMs;
+
+    /* Add 1 to the total time so that Total time will always be greater than fwHandlingTime */
+    totalTxDelayMs = driverDelay + (pTxCompleteAttr->fwHandlingTime / 1000) + 1;
+
+    /* Increment the delay range counter that the current packet Tx delay falls in. */
+    for (rangeIndex = TX_DELAY_RANGE_MIN; rangeIndex <= TX_DELAY_RANGE_MAX; rangeIndex++)
+    {
+        if ( (totalTxDelayMs >= txDelayRangeStart[rangeIndex]) &&
+             (totalTxDelayMs <= txDelayRangeEnd  [rangeIndex]) )
+        {
+            pTxData->txDataCounters[ txQid ].txDelayHistogram[ rangeIndex ]++;
+            pTxData->txDataReportedCounters[ txQid ].txDelayHistogram[ rangeIndex ]++;
+            break;
+        }
+    }
+    
+    /* Update total delay and MAC delay sums and packets number for average delay calculation. */
+    if (pTxData->txDataCounters[ txQid ].SumTotalDelayMs < 0x7FFFFFFF) /* verify we are not close to the edge. */
+    {
+        pTxData->txDataCounters[ txQid ].NumPackets++; 
+        pTxData->txDataCounters[ txQid ].SumTotalDelayMs += totalTxDelayMs;   
+        pTxData->txDataCounters[ txQid ].SumFWDelayUs += pTxCompleteAttr->fwHandlingTime;
+        pTxData->txDataCounters[ txQid ].SumMacDelayUs += pTxCompleteAttr->mediumDelay;
+    }
+    else  /* If we get close to overflow, restart average accumulation. */
+    {
+        pTxData->txDataCounters[ txQid ].NumPackets = 1; 
+        pTxData->txDataCounters[ txQid ].SumTotalDelayMs = totalTxDelayMs;   
+        pTxData->txDataCounters[ txQid ].SumFWDelayUs = pTxCompleteAttr->fwHandlingTime;
+        pTxData->txDataCounters[ txQid ].SumMacDelayUs = pTxCompleteAttr->mediumDelay;
+    }
+    pTxData->txDataReportedCounters[ txQid ].NumPackets++; 
+    pTxData->txDataReportedCounters[ txQid ].SumTotalDelayMs += totalTxDelayMs;   
+    pTxData->txDataReportedCounters[ txQid ].SumFWDelayUs += pTxCompleteAttr->fwHandlingTime;
+    pTxData->txDataReportedCounters[ txQid ].SumMacDelayUs += pTxCompleteAttr->mediumDelay;
+}
+
+/***************************************************************************
+*                       txData_UpdateTxCounters                            *
+****************************************************************************
+* DESCRIPTION:  free the transmitted msdu
+*
+* INPUTS:       hTxData - the object
+*               pTxCompletAttr - all atributes passed along with the TX 
+*                                complete indication
+*
+* OUTPUT:
+*
+* RETURNS:
+***************************************************************************/
+void txData_UpdateTxCounters( TI_HANDLE hTxData, txCompleteAttr_t *pTxCompleteAttr )
+{
+    txData_t *pTxData = (txData_t*)hTxData;
+    txPacketIdAttr_t *pPacketId = (txPacketIdAttr_t *)(pTxCompleteAttr->packetId);
+    UINT16 EventMask = 0;
+    UINT32 dataLen, TxQid = pPacketId->txQid;
+    UINT32 retryHistogramIndex;
+
+    switch ( pTxCompleteAttr->status )
+    {
+    case SEND_COMPLETE_SUCCESS:
+        /* update the retry histogram */
+        retryHistogramIndex = (pTxCompleteAttr->ackFailures >= TX_RETRY_HISTOGRAM_SIZE ? 
+                               TX_RETRY_HISTOGRAM_SIZE - 1 :
+                               pTxCompleteAttr->ackFailures);
+        pTxData->txDataCounters[ TxQid ].RetryHistogram[ retryHistogramIndex ]++;
+
+        /* update delay histogram */
+        txData_SetTxDelayCounters( hTxData, TxQid, pTxCompleteAttr, pPacketId->driverHandlingTime );
+
+        if ( (TRUE == pPacketId->bDataMsdu) && (pTxData->txDataQosParams.headerConverMode == QOS_CONVERT) )
+        {
+            dataLen = pPacketId->msduDataLen - (WLAN_WITH_SNAP_QOS_HEADER_MAX_SIZE - ETHERNET_HDR_LEN);
+        }
+        else
+        {
+            dataLen = pPacketId->msduDataLen - (WLAN_WITH_SNAP_HEADER_MAX_SIZE - ETHERNET_HDR_LEN);
+        }
+
+        if ( IsMacAddressDirected( &(pPacketId->destinationMac) ) )
+        {
+            /* Directed frame */
+            pTxData->txDataCounters[TxQid].DirectedFramesXmit++;
+            pTxData->txDataCounters[TxQid].DirectedBytesXmit += dataLen;
+            EventMask |= DIRECTED_BYTES_XFER;
+            EventMask |= DIRECTED_FRAMES_XFER;
+        }
+        else if ( IsMacAddressBroadcast( &(pPacketId->destinationMac) ) )
+        {
+            /* Broadcast frame */
+            pTxData->txDataCounters[TxQid].BroadcastFramesXmit++;
+            pTxData->txDataCounters[TxQid].BroadcastBytesXmit += dataLen;
+            EventMask |= BROADCAST_BYTES_XFER;
+            EventMask |= BROADCAST_FRAMES_XFER;
+        }
+        else
+        {
+            /* Multicast Address */
+            pTxData->txDataCounters[TxQid].MulticastFramesXmit++;
+            pTxData->txDataCounters[TxQid].MulticastBytesXmit += dataLen;
+            EventMask |= MULTICAST_BYTES_XFER;
+            EventMask |= MULTICAST_FRAMES_XFER;
+        }
+        pTxData->txDataCounters[TxQid].XmitOk++;
+        EventMask |= XFER_OK;
+
+        /* update the max consecutive retry failures (if needed) */
+        if (pTxData->currentConsecutiveRetryFail > pTxData->txDataCounters[ TxQid ].MaxConsecutiveRetryFail)
+        {
+            pTxData->txDataCounters[TxQid].MaxConsecutiveRetryFail = pTxData->currentConsecutiveRetryFail;
+        }
+        pTxData->currentConsecutiveRetryFail = 0;
+
+        txData_DistributorTxEvent( pTxData, EventMask, dataLen );
+        break;
+
+    case SEND_COMPLETE_RETRY_EXCEEDED:
+
+        pTxData->txDataCounters[ TxQid ].RetryFailCounter++;
+        pTxData->currentConsecutiveRetryFail++;
+        pTxData->txDataReportedCounters[ TxQid ].OtherFailCounter++;
+        break;
+
+    case SEND_COMPLETE_LIFETIME_EXCEEDED:
+        pTxData->txDataCounters[ TxQid ].TxTimeoutCounter++;
+        pTxData->txDataReportedCounters[ TxQid ].OtherFailCounter++;
+        break;
+
+    case SEND_COMPLETE_NO_LINK:
+        pTxData->txDataCounters[ TxQid ].NoLinkCounter++;
+        pTxData->txDataReportedCounters[ TxQid ].OtherFailCounter++;
+        break;
+
+    case SEND_COMPLETE_MAC_CRASHED: /* curently not used */
+    default:
+        pTxData->txDataCounters[ TxQid ].OtherFailCounter++;
+        pTxData->txDataReportedCounters[ TxQid ].OtherFailCounter++;
+        break;
+    }
+}
+
+static void txData_startVadTimer(TI_HANDLE hTxData, UINT16 voiceDuration)
+{
+    txData_t *pTxData = (txData_t*)hTxData;
+
+    if (FALSE == pTxData->bVadTimerEnabled)
+    {
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            ("txData_startVadTimer: (voiceDuration is %d) .....................\n", voiceDuration));
+       pTxData->vadTimerDuration = voiceDuration;
+       pTxData->bVadTimerEnabled = TRUE;
+       os_timerStart(pTxData->hOs, pTxData->pVadTimer, voiceDuration, TRUE);
+               
+    }
+    else
+    {
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+           ("txData_startVadTimer: nothing done. VAD is already started ........\n", voiceDuration));
+    }
+}
+
+static void txData_stopVadTimer(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t*)hTxData;
+
+    if (pTxData->bVadTimerEnabled)
+    {
+       WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG, ("txData_stopVadTimer ...\n"));
+       os_timerStop(pTxData->hOs, pTxData->pVadTimer);
+       pTxData->bVadTimerEnabled = FALSE;
+    }
+}
+
+static void txData_setVadTimer(TI_HANDLE hTxData, BOOL vadEnabled, UINT16 duration)
+{
+    txData_t *pTxData = (txData_t*)hTxData;
+
+    WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG, ("txData_setVadTimer (%d, %d)\n", vadEnabled, duration));
+    if (vadEnabled)
+       txData_startVadTimer(hTxData, duration);
+    else
+       txData_stopVadTimer(hTxData);
+}
+
+static void txData_resetVadTimer(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t*)hTxData;
+//    UINT32 timeStamp;
+
+    if (pTxData->bVadTimerEnabled)
+    {
+/*
+        timeStamp = os_timeStampMs(pTxData->hOs);
+       printk("resetVadTimer: timestamp = %d\n", timeStamp);
+*/
+       os_timerStop(pTxData->hOs, pTxData->pVadTimer);
+       os_timerStart(pTxData->hOs, pTxData->pVadTimer, pTxData->vadTimerDuration, TRUE);
+    }
+}
+
+static void txData_vadTimeout(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t*)hTxData;
+//    UINT32 timeStamp;
+/*
+    timeStamp = os_timeStampMs(pTxData->hOs);
+    printk("vadTimeout: timestamp = %d\n", timeStamp);
+*/
+    txData_sendVadFrame (pTxData, QOS_AC_VO);
+}
+
+/***************************************************************************
+*                       txData_startTxSchedulerFromTimer                   *
+****************************************************************************
+* DESCRIPTION:
+*
+* INPUTS:
+*
+* OUTPUT:
+*
+* RETURNS:
+***************************************************************************/
+static void txData_startTxSchedulerFromTimer(TI_HANDLE hTxData)
+{
+    WLAN_REPORT_DEBUG_TX(((txData_t *)hTxData)->hReport, 
+        ("in txData_startTxSchedulerFromTimer.....................\n"));
+
+    txData_startTxScheduler(hTxData);
+}
+
+/***********************************************************************
+ *                        txData_sendNullFrame
+ ***********************************************************************
+DESCRIPTION:    Send Null frame Function.
+                The function does the following:
+                -   Builds Null Data Frame with PS bit set to On or Off.
+                -   Allocates MSDU frame.
+                -   Sends the frame.
+
+INPUT:      hTxData         -   Tx Data Pointer.
+            powerSaveMode   -   Indicates if to switch the Power Save
+                                mode to On or Off.
+            module          -   The calling module.
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS txData_sendNullFrame(TI_HANDLE hTxData,
+                               BOOL powerSaveOn,
+                               allocatingModule_e module)
+{
+    TI_STATUS       status;
+    mem_MSDU_T      *pMsdu;
+    paramInfo_t     daParam, saParam;
+    dot11_header_t  *pFrame; /* Note : there is no body for null frame */
+    txData_t        *pTxData = (txData_t *)hTxData;
+
+    /* Getting new msdu */
+    status = wlan_memMngrAllocMSDU(pTxData->hMemMngr, &pMsdu, WLAN_HDR_LEN + TX_TOTAL_OFFSET_BEFORE_DATA, module);
+    if (status != OK)
+        return NOK;
+
+    pFrame = (dot11_header_t*)(pMsdu->firstBDPtr->data + TX_TOTAL_OFFSET_BEFORE_DATA);
+
+    /* Setting the Frame Control with Data frame type and Null frame sub type*/
+    pFrame->fc = 0;
+    pFrame->fc |= DOT11_FC_DATA_NULL_FUNCTION;
+    pFrame->fc |= DOT11_FC_TO_DS;
+
+    /* setting the Power Save bit in the Frame control field*/
+    if(powerSaveOn == TRUE)
+        pFrame->fc |= (0x1 << DOT11_FC_PWR_MGMT_SHIFT);
+
+    daParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+    status = ctrlData_getParam(pTxData->hCtrlData, &daParam);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+
+    /* copy destination mac address */
+    MAC_COPY(pTxData->hOs, (&pFrame->address3), (&daParam.content.ctrlDataCurrentBSSID));
+
+    saParam.paramType = CTRL_DATA_MAC_ADDRESS;
+    status = ctrlData_getParam(pTxData->hCtrlData, &saParam);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+
+    /* copy source mac address */
+    MAC_COPY(pTxData->hOs, (&pFrame->address2), (&saParam.content.ctrlDataCurrentBSSID));
+
+    /* copy BSSID (destination mac address) */
+    MAC_COPY(pTxData->hOs, (&pFrame->address1), (&daParam.content.ctrlDataCurrentBSSID));
+
+    /* Update MSDU parameters */
+    pMsdu->headerLen = pMsdu->dataLen =  WLAN_HDR_LEN;
+    pMsdu->firstBDPtr->length = pMsdu->dataLen + TX_TOTAL_OFFSET_BEFORE_DATA;
+
+    /* send the packet to the TX */
+    pMsdu->qosTag = 0;
+    pMsdu->txFlags |= TX_DATA_NULL_MSDU;
+
+    status = txData_txSendMsdu(hTxData, pMsdu);
+
+    return status;
+}
+
+/***********************************************************************
+ *                        txData_sendVadFrame
+ ***********************************************************************
+DESCRIPTION:    Send a polling frame to retrieve downlink traffic from
+                the AP. Activated by the voice application when there is 
+                  no uplink traffic during a voice call.
+                The polling is either PS-Poll (for legacy PS) or QoS-Null
+                (for UPSD).
+                Null frame is currently added after PS-Poll to trigger
+                the triggered-scan which is only triggered by data frames!
+                Note that currently the acID parameter is ignored to insure this
+                function is not activated for other ACs than Voice (to add this
+                flexibility the txData_txSendMsdu() function should be updated.
+
+INPUT:      acID - Currently not used!  Supporting only AC_VO!
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+TI_STATUS txData_sendVadFrame(TI_HANDLE hTxData, UINT8 acID)
+{
+    mem_MSDU_T *pMsdu;
+    TI_STATUS  status;
+    txData_t   *pTxData = (txData_t *)hTxData;
+    paramInfo_t param;
+
+    if (pTxData->txDataPortStatus != OPEN)
+    {
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                                ("txData_sendVadFrame(): While port status is %d\n", pTxData->txDataPortStatus ));
+        return NOK;
+     }
+
+    param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
+    status = qosMngr_getParams(pTxData->hQosMngr, &param);
+
+    /* For WME - send QoS-Null-Data. */
+    if (param.content.qosSiteProtocol ==  WME)  
+    {
+        /* Send QoS-Null frame to retrieve downlink packets and to trigger the triggered-scan. */
+        /* Note: If VO mode is PSPOLL, the txData_txSendMsdu() will add the PS-Poll frame.  */
+        if((status = txData_buildQosNullDataFrame(pTxData,&pMsdu,wmeAcToUpIndex[QOS_AC_VO])) == OK)
+            status = txData_txSendMsdu(hTxData, pMsdu); 
+        
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            ("txData_sendVadFrame(): WME site...Sending QoS-Null frame, Status=%d\n", status));
+    }
+    
+    /* For non-WME - send PS-Poll plus Null-Data. */
+    else    
+    {
+        /* Send PS-Poll to retrieve downlink packets. */
+        if((status = txData_getPsPollFrame(pTxData,&pMsdu)) == OK)
+            status = txData_txSendMsdu(hTxData, pMsdu);
+
+        /* Send also a null frame to trigger the triggered-scan in the FW. */
+        /* Note: Needed because the scan is triggered only by data frames, so PS-Poll is not enough!. */
+        /* Note: The txData_txSendMsdu() won't send another PS-Poll before the null frame since 
+                 pMsdu->qosTag is set to 0 for null (and not voice). */
+        status = txData_sendNullFrame(hTxData, FALSE, TX_MODULE);
+        
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            ("txData_sendVadFrame(): Non-WME site...Sending PS-Poll and Null frame, Status=%d\n", status));
+    }
+    
+    return status;
+}
+
+
+/***********************************************************************
+ *                        txData_getPsPollFrame
+ ***********************************************************************
+DESCRIPTION:    builds PS POLL frame Function.
+                The function does the following:
+                -   Builds PS POLL Control Frame with PS bit set to On .
+                -   Allocates MSDU frame.
+                -   Sends the frame.
+
+----------------------------
+PS Poll - 802.11 Mac Header
+----------------------------
+  Version              0
+  Type                 %01          (Control)
+  Subtype              %1010        (PS Poll)
+  Frame Control Flag   %00010000    (Power Management Bit set -> Power Save mode)
+  Assoc ID             association ID
+  BSSID                MAC addr of BSSID
+  Transmitter          MAC addr of sender
+----------------------------
+
+typedef struct
+{
+  UINT16        fc;
+  UINT16        AID;
+  macAddress_t  BSSID;
+  macAddress_t  TA;
+} dot11_PsPollFrameHeader_t;
+
+
+INPUT:
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS txData_getPsPollFrame(TI_HANDLE hTxData,mem_MSDU_T **pMsduPsPoll)
+{
+    TI_STATUS       status = OK;
+    UINT32          timeStamp ;
+    paramInfo_t     daParam, saParam;
+    whalParamInfo_t whalParam;
+    dot11_PsPollFrameHeader_t   *pFrame; /* Note : there is no body for null frame */
+    txData_t *pTxData = (txData_t *)hTxData;
+    mem_MSDU_T      *pMsdu;
+    /* Getting new msdu */
+    status = wlan_memMngrAllocMSDU(pTxData->hMemMngr, &pMsdu, WLAN_HDR_LEN + TX_TOTAL_OFFSET_BEFORE_DATA, TX_MODULE);
+    if (status != OK)
+    {
+        return NOK;
+    }
+
+
+    pFrame = (dot11_PsPollFrameHeader_t*)(pMsdu->firstBDPtr->data + TX_TOTAL_OFFSET_BEFORE_DATA);
+
+    /*
+    **   Building the Frame Control word (16 bits)
+    ** ---------------------------------------------
+    */
+    pFrame->fc = 0;
+
+    /*
+    ** Type = Control
+    ** SubType = Power Save (PS) POLL,  */
+    pFrame->fc |= DOT11_FC_PS_POLL;
+
+    /*
+    ** setting the Power Management bit in the Frame control field
+    ** to be "Power Save mode"
+    */
+    pFrame->fc |= (0x1 << DOT11_FC_PWR_MGMT_SHIFT);
+
+    /*
+    **   Association ID
+    ** -----------------
+    */
+    whalParam.paramType = HAL_CTRL_AID_PARAM;
+    status = whalCtrl_GetParam (pTxData->hWhalCtrl, &whalParam) ;
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+    /* AID should have its two MSB bit Set to "1"*/
+    pFrame->AID = whalParam.content.halCtrlAid | 0xC000;
+    WLAN_REPORT_WARNING(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" AID 4 = %d  \n", (whalParam.content.halCtrlAid | 0xC000)));
+
+    /*
+    **   BSSID
+    ** ---------
+    */
+    daParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+    status = ctrlData_getParam(pTxData->hCtrlData, &daParam);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+    /* copy destination mac address */
+    MAC_COPY(pTxData->hOs, (&pFrame->BSSID), (&daParam.content.ctrlDataCurrentBSSID));
+
+
+
+
+    /*
+    **  TA - Transmiter (MAC) Address
+    ** -------------------------------
+    */
+    saParam.paramType = CTRL_DATA_MAC_ADDRESS;
+    status = ctrlData_getParam(pTxData->hCtrlData, &saParam);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+   /* copy source mac address */
+    MAC_COPY(pTxData->hOs, (&pFrame->TA), (&saParam.content.ctrlDataCurrentBSSID));
+
+    timeStamp = os_timeStampMs(pTxData->hOs);
+
+    WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_sendPsPollFrame() : time = %d insert PS_POLL frame to Driver queue \n", timeStamp));
+
+    /* Update MSDU parameters */
+    pMsdu->headerLen = pMsdu->dataLen =  sizeof(dot11_PsPollFrameHeader_t);
+    pMsdu->firstBDPtr->length = pMsdu->dataLen + TX_TOTAL_OFFSET_BEFORE_DATA;
+
+    pMsdu->txFlags |= TX_DATA_PS_POLL;
+
+
+    if (status == OK)
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+        ("in txData_sendPsPollFrame: enter PS_POLL to queue\n"));
+    else
+        WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+        ("in txData_sendPsPollFrame: didn't enter PS_POLL to queue\n"));
+
+    *pMsduPsPoll = pMsdu;
+
+    return status;
+}
+
+
+/***********************************************************************
+ *                        txData_updateUsedTime
+ ***********************************************************************
+DESCRIPTION:    This function is called for every txComplete in order
+                to update the transmisssion time.
+
+INPUT:          hTxData - handale to the ts data object
+                qNum    - the queue that the frame transmitted from
+                usedTime - the time of the transmission (in microseconds)
+
+OUTPUT:     None
+
+RETURN:     OK on success
+************************************************************************/
+TI_STATUS txData_updateUsedTime(TI_HANDLE hTxData, UINT32 qNum, UINT16 usedTime)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    /* addd the used time for the specific queue */
+    pTxData->dataMsduListArr[qNum]->totalUsedTime += usedTime;
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        txData_calcCreditFromTimer
+ ***********************************************************************
+DESCRIPTION:    This function is called when credit calculation timer
+                is expired. it calculate the credit for the admission ctrl
+                credit algorithm
+
+
+INPUT:          hTxData - handle to the ts data object
+
+OUTPUT:     None
+
+RETURN:     void
+************************************************************************/
+static void txData_calcCreditFromTimer(TI_HANDLE hTxData)
+{
+    UINT32 qNum;
+    OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS mediumTimeCross;
+    txData_t *pTxData = (txData_t *)hTxData;
+    INT32       prevCredit;
+    INT32       highCreditThreshold;
+    INT32       lowCreditThreshold;
+    MsduList_t  *pMsduList;
+    INT32       usageRatio;
+    INT32       currUsage;
+    INT32       prevUsage;
+
+    /* get current time stamp */
+    UINT32 currentTimeStamp = os_timeStampMs(pTxData->hOs);
+    
+    
+    for(qNum = 0 ; qNum< MAX_NUM_OF_TX_QUEUES ; qNum++)
+    {
+        pMsduList = pTxData->dataMsduListArr[qNum];
+
+        /* check if this queue is under admission ctrl opration */
+        if(pMsduList->mediumTime == 0)
+        {
+            WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG, 
+                (" txData_calcCreditFromTimer() :qNum = %d mediumTime = 0 \n",qNum));
+            
+            continue;
+        }
+
+        /* in case of wraparound */
+        if(currentTimeStamp < pMsduList->lastTimeStamp)
+            pMsduList->lastTimeStamp = 0;
+        
+        /* store prev credit */
+        prevCredit = pMsduList->credit;
+
+        /* Calculate the medium usage ratio:    totalUsedTime / mediumTime * 1000
+           Note that since the totalUsedTime is in usec and not msec we don't multiply by 1000.  */
+        usageRatio = pMsduList->totalUsedTime / pMsduList->mediumTime;
+
+        /* calculate credit */
+        pMsduList->credit = pMsduList->credit + (currentTimeStamp - pMsduList->lastTimeStamp) - usageRatio;
+        
+        /* update last time stamp */
+        pMsduList->lastTimeStamp = currentTimeStamp;
+
+        /* check if credit exceeds above mediumTime or below -mediumTime */
+        if (pMsduList->credit > (INT32)(pMsduList->mediumTime) )
+        {
+            /* in case of credit is big than mediumTime -> set credit to medium time */
+            pMsduList->credit = pMsduList->mediumTime;
+            pMsduList->enableTransmissionTime = 0;
+        }
+        
+        /* If credit is lower than -mediumTime we exceed the admitted time. */
+        else if (pMsduList->credit <= (INT32)(0 - pMsduList->mediumTime))
+        {
+            /* Only delay transmission on this AC if the "delay" registry key is TRUE */
+            if(pTxData->admCtrlDelayDueToMediumTimeOverUsage == TRUE)
+                pMsduList->enableTransmissionTime = (0 - pMsduList->credit) - pMsduList->mediumTime;
+        }
+
+       WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+          ("credit = %d  | TotalUsedTime = %d  | enableTransmissionTime = %d\n",
+          pMsduList->credit, pMsduList->totalUsedTime/1000, pMsduList->enableTransmissionTime));
+
+        /* Check medium-usage threshold cross events */
+        /*********************************************/
+        /*
+         * The medium-usage events are defined as follows:
+         * The high threshold triggers event only when crossed upward (traffic increased above threshold).
+         * The low threshold triggers event only when crossed downward (traffic decreased below threshold).
+         * Thus, the two thresholds provide hysteresis and prevent multiple triggering.
+         * The high threshold should be greater than the low threshold. 
+         */
+
+        highCreditThreshold = (INT32)((pMsduList->mediumTime)*(pMsduList->highMediumUsageThreshold)/100); 
+        lowCreditThreshold  = (INT32)((pMsduList->mediumTime)*(pMsduList->lowMediumUsageThreshold)/100);
+
+        /* The credit is getting more negative as we get closer to the medium usage limit, so we invert
+             it before comparing to the thresholds (lower credit means higher usage). */
+        currUsage = -pMsduList->credit;
+        prevUsage = -prevCredit;
+
+        /* crossing below the low threshold */
+        if ( (currUsage < lowCreditThreshold) && (prevUsage >= lowCreditThreshold) )
+        {
+            /* send event */
+            mediumTimeCross.uAC = txData_GetAcIdFromQid( hTxData, qNum );
+            mediumTimeCross.uHighOrLowThresholdFlag = (UINT32)LOW_THRESHOLD_CROSS;
+            mediumTimeCross.uAboveOrBelowFlag = (UINT32)CROSS_BELOW;
+
+            EvHandlerSendEvent(pTxData->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS, (UINT8 *)&mediumTimeCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+            WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                ("crossed below low threshold !!! prevUsage = %d, currUsage = %d, lowCreditThreshold = %d\n",
+                prevUsage, currUsage, lowCreditThreshold));
+        }
+        
+        /* crossing above the high threshold */
+        else if ( (currUsage > highCreditThreshold) && (prevUsage <= highCreditThreshold) )
+        {
+            /* send event */
+            mediumTimeCross.uAC = txData_GetAcIdFromQid( hTxData, qNum );
+            mediumTimeCross.uHighOrLowThresholdFlag = (UINT32)HIGH_THRESHOLD_CROSS;
+            mediumTimeCross.uAboveOrBelowFlag = (UINT32)CROSS_ABOVE;
+
+            EvHandlerSendEvent(pTxData->hEvHandler, IPC_EVENT_MEDIUM_TIME_CROSS, (UINT8 *)&mediumTimeCross,sizeof(OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS));
+            WLAN_REPORT_INFORMATION(pTxData->hReport, TX_DATA_MODULE_LOG,
+                ("crossed above high threshold !!! prevUsage = %d, currUsage = %d, highCreditThreshold = %d\n",
+                prevUsage, currUsage, highCreditThreshold));
+        }
+
+        /* reset totalUsedTime */
+        pMsduList->totalUsedTime = 0;
+        
+    }
+    
+}
+
+
+/***********************************************************************
+ *                        txData_setAdmisionCtrlParams
+ ***********************************************************************
+DESCRIPTION:    This function is called for add/delete a tspec in order
+                to update parameters.
+
+INPUT:          hTxData - handale to the ts data object
+                acID - the AC of the tspec
+                mediumTime  - tha alocated medium time for this UP 
+                minimumPHYRate - the min phy rate to send a packet of this UP
+                admFlag - indicate if the its addition or deletion of tspec 
+
+OUTPUT:     None
+
+RETURN:     void
+************************************************************************/
+TI_STATUS txData_setAdmisionCtrlParams(TI_HANDLE hTxData, 
+                                       UINT8 acID,
+                                       UINT16 mediumTime, 
+                                       UINT32 minimumPHYRate,
+                                       BOOL admFlag)
+{
+    UINT8   queueIndex;
+    UINT8   i;
+    txData_t *pTxData = (txData_t *)hTxData;
+    MsduList_t  *pMsduList;
+
+    /* find queue from AC */
+    queueIndex = pTxData->txDataAcTrfcCtrl[acID].QueueIndex;
+    
+    pMsduList = pTxData->dataMsduListArr[queueIndex];
+
+    if(admFlag == TRUE) 
+    {
+        /* tspaec added */
+        pMsduList->mediumTime = mediumTime;
+        
+        /* in case of medium time>0 set relevant parameters to the credit algo calculation */
+        pMsduList->admissionState = AC_ADMITTED;
+
+        /* enable admission algo for this queue */
+        pMsduList->useAdmissionAlgo = TRUE;
+
+        pMsduList->lastTimeStamp = os_timeStampMs(pTxData->hOs);
+        pMsduList->enableTransmissionTime = 0;
+        pMsduList->credit = mediumTime;
+    }
+    else
+    {
+        /* tspaec deleted */
+        pMsduList->mediumTime = 0;
+        
+        /* in case of medium time=0 reset relevant parameters */
+        pMsduList->admissionState = AC_NOT_ADMITTED;
+
+        pMsduList->useAdmissionAlgo = FALSE;
+        pMsduList->lastTimeStamp = 0;
+        pMsduList->enableTransmissionTime = 0;
+        pMsduList->credit = 0;
+
+    }
+    
+    /* If the timer was not enabled in registry than we will never set it */
+    if ( pTxData->bCreditCalcTimerEnabled )
+    {
+        /* enable disable credit calculation timer */
+        for(i = 0 ; i < MAX_NUM_OF_TX_QUEUES ; i++)
+        {
+            if(pTxData->dataMsduListArr[i]->useAdmissionAlgo == TRUE)
+            {
+                if(pTxData->bCreditCalcTimerRunning == FALSE)
+                {
+                    pTxData->bCreditCalcTimerRunning = TRUE;
+                    os_timerStart(pTxData->hOs, pTxData->pCreditTimer, pTxData->creditCalculationTimeout, TRUE);
+                }
+                
+                return OK;
+            }
+        }
+        /* in all queues useAdmissionAlgo is not TRUE */
+        if ( pTxData->bCreditCalcTimerRunning )
+        {
+            os_timerStop(pTxData->hOs, pTxData->pCreditTimer);
+            pTxData->bCreditCalcTimerRunning = FALSE;
+        }
+    }
+
+    return OK;
+
+}
+
+
+/***********************************************************************
+ *                        txData_setPsVoiceDeliveryMode
+ ***********************************************************************
+DESCRIPTION:    This function is called for add/delete a tspec in order
+                to set the PS mode for a specific UP
+
+INPUT:          hTxData - handale to the ts data object
+                userPriority - the user priority of the tspec
+                PsMode  - tha PS mode for the specific UP
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS txData_setPsVoiceDeliveryMode(TI_HANDLE hTxData, PSScheme_e   PsMode)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    pTxData->txDataAcTrfcCtrl[QOS_AC_VO].PsMode = PsMode;
+    return OK;
+}
+
+/***********************************************************************
+ *                        txData_setMediumUsageThresholds
+ ***********************************************************************
+DESCRIPTION:    This function is called in order to set the threshold
+                for the medium time usage
+
+INPUT:          hTxData - handale to the ts data object
+                acID - the AC
+                highMediumUsageThreshold - high threshold
+                lowMediumUsageThreshold - lowhreshold
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS txData_setMediumUsageThresholds(TI_HANDLE     hTxData,
+                                      UINT8             acID,
+                                      INT32             highMediumUsageThreshold,
+                                      INT32             lowMediumUsageThreshold)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    UINT8 queueIndex;
+
+    /* validate AC */
+    if(acID >= MAX_NUM_OF_AC)
+        return NOK;
+
+    /* find queu from ac */
+    queueIndex = pTxData->txDataAcTrfcCtrl[acID].QueueIndex;
+
+    /* set threshold */
+    pTxData->dataMsduListArr[queueIndex]->lowMediumUsageThreshold = lowMediumUsageThreshold;
+    pTxData->dataMsduListArr[queueIndex]->highMediumUsageThreshold = highMediumUsageThreshold;
+
+    return OK;
+
+}
+
+/***********************************************************************
+ *                        txData_isQueueUseMediumTime
+ ***********************************************************************
+DESCRIPTION:    
+
+INPUT:          hTxData - handale to the ts data object
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+
+BOOL txData_isQueueUseMediumTime(TI_HANDLE hTxData, UINT8 qNum)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if(pTxData->dataMsduListArr[qNum]->mediumTime == 0)
+        return FALSE;
+    else
+        return TRUE;
+
+}
+
+
+
+void Test_HeaderConvertion(TI_HANDLE hTxData, mem_MSDU_T *pMsdu)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    print_MsduDataHeader(pTxData->hMemMngr, pMsdu);
+
+    txData_convertEthToWlanHeader( pTxData, pMsdu );
+
+    print_MsduDataHeader(pTxData->hMemMngr, pMsdu);
+
+}
+
+
+#ifdef TI_DBG
+void txData_printTxBlock(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int i;
+
+    WLAN_OS_REPORT(("hCtrlData = 0x%X\n", pTxData->hCtrlData));
+    WLAN_OS_REPORT(("hTnetwDrv = 0x%X\n", pTxData->hTnetwDrv));
+    WLAN_OS_REPORT(("hOs = 0x%X\n", pTxData->hOs));
+    WLAN_OS_REPORT(("hReport = 0x%X\n", pTxData->hReport));
+    WLAN_OS_REPORT(("hMemMngr = 0x%X\n", pTxData->hMemMngr));
+    WLAN_OS_REPORT(("pSchedulerTimer = 0x%X\n", pTxData->pSchedulerTimer));
+
+    WLAN_OS_REPORT(("hCriticalSectionProtect = 0x%X\n", pTxData->hCriticalSectionProtect));
+
+    WLAN_OS_REPORT(("txDataPortStatus = %d\n", pTxData->txDataPortStatus));
+    WLAN_OS_REPORT(("txDataCurrentPrivacyInvokedMode = %d\n", pTxData->txDataCurrentPrivacyInvokedMode));
+    WLAN_OS_REPORT(("txDataEapolEncryptionStatus = %d\n", pTxData->txDataEapolEncryptionStatus));
+
+    WLAN_OS_REPORT(("txDataIsSchedulerInWork = %d\n", pTxData->txDataIsSchedulerInWork));
+
+    WLAN_OS_REPORT(("txDataNumOfQueues = %d\n", pTxData->txDataNumOfQueues));
+    WLAN_OS_REPORT(("mngMsduList = 0x%X\n", pTxData->mngMsduList));
+    for(i=0 ; i < MAX_NUM_OF_TX_QUEUES; i++ )
+    {
+        WLAN_OS_REPORT(("dataMsduList %d = 0x%X\n",i, pTxData->dataMsduListArr[i]));
+    }
+
+}
+
+
+/*
+void printFullMsduList(MsduList_t *this);
+void printMsduList(MsduList_t *this);
+*/
+void txData_printDataMsduList(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int i;
+
+    for(i=0 ; i < MAX_NUM_OF_TX_QUEUES; i++ )
+    {
+        WLAN_OS_REPORT(("List : %d \n", i));
+        printMsduList(pTxData->dataMsduListArr[i]);
+    }
+
+
+}
+
+void txData_fullPrintDataMsduList(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int i;
+
+    for(i=0 ; i < MAX_NUM_OF_TX_QUEUES; i++ )
+    {
+        WLAN_OS_REPORT(("List : %d \n", i));
+        printFullMsduList(pTxData->dataMsduListArr[i]);
+    }
+}
+
+void txData_printMgmtMsduList(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    printMsduList(pTxData->mngMsduList);
+
+
+}
+
+void txData_fullPrintMgmtMsduList(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    printFullMsduList(pTxData->mngMsduList);
+}
+
+
+void txData_printTxCounters(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int TxQid;
+
+    for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
+    {
+        WLAN_OS_REPORT(("Tx Queue %d:\n", TxQid));
+        WLAN_OS_REPORT(("===========\n"));
+        WLAN_OS_REPORT(("XmitOk = %d\n", pTxData->txDataCounters[TxQid].XmitOk));
+        WLAN_OS_REPORT(("DirectedBytesXmit = %d\n", pTxData->txDataCounters[TxQid].DirectedBytesXmit));
+        WLAN_OS_REPORT(("DirectedFramesXmit = %d\n", pTxData->txDataCounters[TxQid].DirectedFramesXmit));
+        WLAN_OS_REPORT(("MulticastBytesXmit = %d\n", pTxData->txDataCounters[TxQid].MulticastBytesXmit));
+        WLAN_OS_REPORT(("MulticastFramesXmit = %d\n", pTxData->txDataCounters[TxQid].MulticastFramesXmit));
+        WLAN_OS_REPORT(("BroadcastBytesXmit = %d\n", pTxData->txDataCounters[TxQid].BroadcastBytesXmit));
+        WLAN_OS_REPORT(("BroadcastFramesXmit = %d\n", pTxData->txDataCounters[TxQid].BroadcastFramesXmit));
+    }
+
+    /* dbg functions */
+    WLAN_OS_REPORT(("\nTx Debug info:\n", TxQid));
+    WLAN_OS_REPORT(("==============\n"));
+    WLAN_OS_REPORT(("DropedPacketsCounter = %d\n", pTxData->txDataDbgCounters.dbgDropedPacketsCounter));
+    WLAN_OS_REPORT(("NumOfNullMsdu (in sendPacketTransfer) = %d\n", pTxData->txDataDbgCounters.dbgNumOfNullMsdu));
+}
+
+
+void txData_printTxQosCounters(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    int qIndex;
+
+    WLAN_OS_REPORT(("-------------- Tx Queues Statistics ---------------\n\n"));
+    WLAN_OS_REPORT(("Successed copied = Scheduled - Droped\n"));
+    WLAN_OS_REPORT(("Successed copied = Scheduled out - check size failed\n"));
+
+    WLAN_OS_REPORT(("-------------- Scheduled To Core queues ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgInsertToMsduListPackets[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Droped From Core queues ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgDropedFromMsduListPackets[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Scheduled out from Core queues ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgScheduledOutPackets[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("--Dropped due Expiry Time in Core Queues (dropped after %d %% of total time)--\n",pTxData->uFracOfLifeTimeToDrop));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgDroppedDueExpiryTimePackets[qIndex]));
+    }
+    WLAN_OS_REPORT(("-------------- Free MSDUs in sendPacketTransfer ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduFreeInTxTransfer[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- sendPacketTransfer CB number ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduTxTransferCB[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- XFER done in scheduler ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduXferDoneInShceduler[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Success in scheduler ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduSuccessInScheduler[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Pending in scheduler ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduPendingInScheduler[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Busy in scheduler ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduBusyInScheduler[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Error in scheduler ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfMsduErrorInScheduler[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- sendPacketComplete ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgNumOfsendPacketComplete[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- sendPacketComplete Error---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgTxCmpltError[qIndex]));
+    }
+            
+
+
+    WLAN_OS_REPORT(("-------------- Number of MSDUs successfuly sent to GWSI layer ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d = %d\n",qIndex, pTxData->txDataDbgCounters.dbgSendToGwsiQosPackets[qIndex]));
+    }
+
+    WLAN_OS_REPORT(("-------------- Current GWSI port status: %s --------------\n", 
+                    (GWSI_OPEN == pTxData->txDataGwsiInterfaceStatus ? "OPEN" : "PENDING") ));
+
+    WLAN_OS_REPORT(("-------------- HW queue available status ---------------\n"));
+    for(qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+        WLAN_OS_REPORT(("Queue %d %s\n",qIndex, 
+                        (TRUE == pTxData->txDataAvailableQueue[qIndex] ? "Available" : "Not available") ));
+    }   
+}
+
+
+void txData_printQosParams(TI_HANDLE hTxData)
+{
+    UINT8 acID;
+    UINT8 qIndex;
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    for(acID = FIRST_AC_INDEX;acID < MAX_NUM_OF_AC; acID++)
+    {
+        switch(acID)
+        {
+        case QOS_AC_BE:
+            WLAN_OS_REPORT(("BE Params:\n"));
+            break;
+        case QOS_AC_BK:
+            WLAN_OS_REPORT(("BK params:\n"));
+            break;
+        case QOS_AC_VI:
+            WLAN_OS_REPORT(("VI params:\n"));
+            break;
+        case QOS_AC_VO:
+            WLAN_OS_REPORT(("VO params:\n"));
+            break;
+        default:
+            break;
+        }
+
+        switch(pTxData->txDataAcTrfcCtrl[acID].PsMode)
+        {
+        case PS_SCHEME_UPSD_TRIGGER:
+            WLAN_OS_REPORT(("PsMode = UPSD\n"));
+
+            break;
+        case PS_SCHEME_LEGACY_PSPOLL:
+            WLAN_OS_REPORT(("PsMode = PS_POLL\n"));
+
+            break;
+        case PS_SCHEME_LEGACY:
+            WLAN_OS_REPORT(("PsMode = PS_SCHEME_REGULAR\n"));
+            break;
+
+        case PS_SCHEME_SAPSD:
+            WLAN_OS_REPORT(("PsMode = S-APSD\n"));
+            break;
+    
+        default:
+            WLAN_OS_REPORT(("Error: PsMode = %d\n", pTxData->txDataAcTrfcCtrl[acID].PsMode));
+            break;
+        }
+        WLAN_OS_REPORT(("QueueIndex = %d\n", pTxData->txDataAcTrfcCtrl[acID].QueueIndex));
+        WLAN_OS_REPORT(("TxQueueSize = %d\n", pTxData->txDataAcTrfcCtrl[acID].TxQueueSize));
+
+        qIndex = GET_QUEUE_INDEX(pTxData, acID);
+
+        if(pTxData->dataMsduListArr[qIndex]->admissionState == AC_NOT_ADMITTED)
+            WLAN_OS_REPORT(("admissionState = Not Admitted\n\n" ));
+        else
+            WLAN_OS_REPORT(("admissionState = Admitted\n\n" ));
+
+    }
+
+    switch(pTxData->txDataQosParams.headerConverMode)
+    {
+    case NO_CONVERT:
+        WLAN_OS_REPORT(("headerConverMode = NO_CONVERT\n"));
+        break;
+    case QOS_CONVERT:
+        WLAN_OS_REPORT(("headerConverMode = QOS_CONVERT\n"));
+        break;
+    case LEGACY_CONVERT:
+        WLAN_OS_REPORT(("headerConverMode = LEGACY_CONVERT\n"));
+        break;
+    }
+
+    WLAN_OS_REPORT(("tag_ToQueueClfrTable = %d, %d, %d, %d, %d, %d, %d, %d\n",
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[0],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[1],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[2],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[3],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[4],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[5],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[6],
+                    pTxData->txDataQosParams.tag_ToAcClsfrTable[7]));
+}
+
+void txData_StartTxThroughputTimer(TI_HANDLE hTxData)
+{
+    int counterIndex;
+
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if(pTxData->txThroughputTimerEnable == FALSE)
+    {
+        for(counterIndex = 0 ; counterIndex < MAX_NUM_OF_TX_QUEUES ; counterIndex++)
+        {
+            /* reset throughput counters */
+            pTxData->txDataDbgCounters.dbgInsertToMsduListBytes[counterIndex] = 0;
+
+
+        }
+
+        pTxData->txThroughputTimerEnable = TRUE;
+
+        /* start throughput timer */
+        os_timerStart(pTxData->hOs, pTxData->pThroughputTimer, THROUGHPUT_TIMER, TRUE);
+    }
+}
+
+void txData_StopTxThroughputTimer(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if(pTxData->txThroughputTimerEnable == TRUE)
+    {
+        os_timerStop(pTxData->hOs, pTxData->pThroughputTimer);
+        pTxData->txThroughputTimerEnable = FALSE;
+    }
+}
+
+static void txData_printTxThroughputPerQueue(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    int qIndex;
+
+    WLAN_OS_REPORT(("\n"));
+    WLAN_OS_REPORT(("\n"));
+    WLAN_OS_REPORT(("-------------- Tx Throughput per Queues Statistics ---------------\n"));
+    WLAN_OS_REPORT(("-------------- Send To Wlan Per Queue Throughput---------------\n"));
+
+    for(qIndex = 0 ; qIndex < MAX_NUM_OF_TX_QUEUES ; qIndex++)
+    {
+
+        WLAN_OS_REPORT(("Queue %d = %d KBits/sec\n", qIndex,pTxData->txDataDbgCounters.dbgInsertToMsduListBytes[qIndex]*8/1024));
+        /* reset throughput counters */
+        pTxData->txDataDbgCounters.dbgInsertToMsduListBytes[qIndex] = 0;
+    }
+}
+
+void txData_StartTxAirThroughputTimer (TI_HANDLE hTxData)
+{
+    unsigned counterIndex;
+
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if (!pTxData->txAirThroughputTimerEnable)
+    {
+        for (counterIndex = 0; counterIndex < MAX_NUM_OF_TX_QUEUES; counterIndex++)
+        {
+            /* reset throughput counters */
+            pTxData->txDataDbgCounters.dbgTxCmpltOkBytes[counterIndex] = 0;
+        }
+
+        pTxData->txAirThroughputTimerEnable = TRUE;
+
+        /* start throughput timer */
+        os_timerStart (pTxData->hOs, pTxData->pAirThroughputTimer, THROUGHPUT_TIMER, TRUE);
+    }
+}
+
+void txData_StopTxAirThroughputTimer (TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if (pTxData->txAirThroughputTimerEnable)
+    {
+        os_timerStop (pTxData->hOs, pTxData->pAirThroughputTimer);
+        pTxData->txAirThroughputTimerEnable = FALSE;
+    }
+}
+
+static void txData_printTxAirThroughputPerQueue (TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    int qIndex;
+
+    WLAN_OS_REPORT (("\n"));
+    WLAN_OS_REPORT (("\n"));
+    WLAN_OS_REPORT (("-------------- Tx Air Throughput per Queue Statistics ---------------\n"));
+    WLAN_OS_REPORT (("-------------- Send to WLAN per Queue Throughput---------------\n"));
+    
+    for (qIndex = 0; qIndex < MAX_NUM_OF_TX_QUEUES; qIndex++)
+    {
+
+        WLAN_OS_REPORT (("Queue %d = %d KBits/sec\n", qIndex, pTxData->txDataDbgCounters.dbgTxCmpltOkBytes[qIndex] * 8 / 1024));
+        /* reset throughput counters */
+        pTxData->txDataDbgCounters.dbgTxCmpltOkBytes[qIndex] = 0;
+    }
+}
+
+void txData_StartJitterTimer (TI_HANDLE hTxData)
+{
+    unsigned u_ac;
+
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if (!pTxData->txJitterTimerEnable)
+    {
+        for (u_ac = 0; u_ac < MAX_NUM_OF_TX_QUEUES; u_ac++)
+        {
+            /* reset jitter intervals */
+            pTxData->txJitter[u_ac].jitter.core = 0;
+            pTxData->txJitter[u_ac].jitter.xfer = 0;
+            pTxData->txJitter[u_ac].jitter.air  = 0;
+            pTxData->txJitter[u_ac].jitter.fw   = 0;
+
+            pTxData->txJitter[u_ac].delay.core  = 0;
+            pTxData->txJitter[u_ac].delay.xfer  = 0;
+            pTxData->txJitter[u_ac].delay.wait  = 0;
+            pTxData->txJitter[u_ac].delay.fw    = 0;
+            pTxData->txJitter[u_ac].delay.air   = 0;
+
+            pTxData->txJitter[u_ac].last_delay.core = 0;
+            pTxData->txJitter[u_ac].last_delay.xfer = 0;
+            pTxData->txJitter[u_ac].last_delay.fw   = 0;
+            pTxData->txJitter[u_ac].last_delay.air  = 0;
+
+            pTxData->txJitter[u_ac].max_delay.core  = 0;
+            pTxData->txJitter[u_ac].max_delay.xfer  = 0;
+            pTxData->txJitter[u_ac].max_delay.fw    = 0;
+            pTxData->txJitter[u_ac].max_delay.air   = 0;
+
+            pTxData->txJitter[u_ac].count.core  = 0;
+            pTxData->txJitter[u_ac].count.xfer  = 0;
+            pTxData->txJitter[u_ac].count.wait  = 0;
+            pTxData->txJitter[u_ac].count.fw = 
+                pTxData->txDataDbgCounters.dbgTxCmpltOk[u_ac];
+            pTxData->txJitter[u_ac].count.fw_err = 
+                pTxData->txDataDbgCounters.dbgTxCmpltError[u_ac];
+        }
+
+        pTxData->txJitterTimerEnable = TRUE;
+
+        /* start throughput timer */
+        os_timerStart (pTxData->hOs, pTxData->pJitterTimer, THROUGHPUT_TIMER, TRUE);
+    }
+}
+
+void txData_StopJitterTimer (TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    if (pTxData->txJitterTimerEnable)
+    {
+        os_timerStop (pTxData->hOs, pTxData->pJitterTimer);
+        pTxData->txJitterTimerEnable = FALSE;
+    }
+}    
+
+static void txData_printJitter (TI_HANDLE hTxData)
+{
+    unsigned  u_ac;
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    WLAN_OS_REPORT (("\n"));
+    WLAN_OS_REPORT (("\n"));
+    WLAN_OS_REPORT (("-------------- Tx Jitter per Queue Statistics ---------------\n"));
+    
+    for (u_ac = 0; u_ac < MAX_NUM_OF_TX_QUEUES; u_ac ++)
+    {
+        UINT32 u_ok   = pTxData->txDataDbgCounters.dbgTxCmpltOk[u_ac] -
+                        pTxData->txJitter[u_ac].count.fw;
+        UINT32 u_nok  = pTxData->txDataDbgCounters.dbgTxCmpltError[u_ac] -
+                        pTxData->txJitter[u_ac].count.fw_err;
+
+        if (u_ok + u_nok) 
+        {
+            WLAN_OS_REPORT (("Queue [%d], drop=%d%%\n", u_ac, u_nok * 100 / (u_ok + u_nok)));
+
+            if (pTxData->txJitter[u_ac].count.core)
+            {
+                WLAN_OS_REPORT (("  Core: avg.delay=%6d, max.delay=%6d, jitter=%6d\n",
+                                 pTxData->txJitter[u_ac].delay.core / pTxData->txJitter[u_ac].count.core,
+                                 pTxData->txJitter[u_ac].max_delay.core,
+                                 pTxData->txJitter[u_ac].jitter.core / pTxData->txJitter[u_ac].count.core));
+            }
+            if (pTxData->txJitter[u_ac].count.xfer)
+            {
+                WLAN_OS_REPORT (("  Xfer: avg.delay=%6d, max.delay=%6d, jitter=%6d\n", 
+                                 pTxData->txJitter[u_ac].delay.xfer / pTxData->txJitter[u_ac].count.xfer,
+                                 pTxData->txJitter[u_ac].max_delay.xfer,
+                                 pTxData->txJitter[u_ac].jitter.xfer / pTxData->txJitter[u_ac].count.xfer));
+            }
+            if (pTxData->txJitter[u_ac].count.wait)
+            {
+                WLAN_OS_REPORT (("  Wait: avg.delay=%6d\n", 
+                                 pTxData->txJitter[u_ac].delay.wait / pTxData->txJitter[u_ac].count.wait));
+            }
+            if (u_ok > 0)
+            {
+                WLAN_OS_REPORT (("  Fw:   avg.delay=%6d, max.delay=%6d, jitter=%6d\n", 
+                                 pTxData->txJitter[u_ac].delay.fw / u_ok,
+                                 pTxData->txJitter[u_ac].max_delay.fw,
+                                 pTxData->txJitter[u_ac].jitter.fw / u_ok));
+                WLAN_OS_REPORT (("  Air:  avg.delay=%6d, max.delay=%6d, jitter=%6d\n", 
+                                 pTxData->txJitter[u_ac].delay.air / u_ok,
+                                 pTxData->txJitter[u_ac].max_delay.air,
+                                 pTxData->txJitter[u_ac].jitter.air / u_ok));
+            }
+        }
+
+        /* Update/reset jitter info */
+        pTxData->txJitter[u_ac].jitter.core = 0;
+        pTxData->txJitter[u_ac].jitter.xfer = 0;
+        pTxData->txJitter[u_ac].jitter.fw   = 0;    
+        pTxData->txJitter[u_ac].jitter.air  = 0;
+
+        pTxData->txJitter[u_ac].delay.core  = 0;
+        pTxData->txJitter[u_ac].delay.xfer  = 0;
+        pTxData->txJitter[u_ac].delay.wait  = 0;
+        pTxData->txJitter[u_ac].delay.fw    = 0;
+        pTxData->txJitter[u_ac].delay.air   = 0;
+
+        pTxData->txJitter[u_ac].max_delay.core  = 0;
+        pTxData->txJitter[u_ac].max_delay.xfer  = 0;
+        pTxData->txJitter[u_ac].max_delay.fw    = 0;
+        pTxData->txJitter[u_ac].max_delay.air   = 0;
+
+        pTxData->txJitter[u_ac].count.core  = 0;
+        pTxData->txJitter[u_ac].count.xfer  = 0;
+        pTxData->txJitter[u_ac].count.wait  = 0;
+        pTxData->txJitter[u_ac].count.fw = 
+            pTxData->txDataDbgCounters.dbgTxCmpltOk[u_ac];
+        pTxData->txJitter[u_ac].count.fw_err = 
+            pTxData->txDataDbgCounters.dbgTxCmpltError[u_ac];
+    }
+}
+
+#endif /* TI_BDG */
+
+/***********************************************************************
+ *                     txData_buildQosNullDataFrame
+ ***********************************************************************
+DESCRIPTION:    builds QOS_NULL_DATA frame.
+
+INPUT:
+
+OUTPUT:     None
+
+RETURN:     OK on success, NOK otherwise
+************************************************************************/
+TI_STATUS txData_buildQosNullDataFrame(TI_HANDLE hTxData,mem_MSDU_T **pMsduPsPoll, UINT8 userPriority)
+{
+    TI_STATUS       status = OK;
+    paramInfo_t     daParam, saParam;
+    dot11_header_t   *pFrame; /* Note : there is no body for null frame */
+
+    txData_t *pTxData = (txData_t *)hTxData;
+    mem_MSDU_T      *pMsdu;
+
+    status = wlan_memMngrAllocMSDU(pTxData->hMemMngr, &pMsdu, WLAN_QOS_HDR_LEN + TX_TOTAL_OFFSET_BEFORE_DATA, TX_MODULE);
+
+    if (status != OK)
+    {
+        return NOK;
+    }
+    pFrame = (dot11_header_t*)(pMsdu->firstBDPtr->data+ TX_TOTAL_OFFSET_BEFORE_DATA);
+
+    /* Build frame control */
+    pFrame->fc = DOT11_FC_DATA_NULL_QOS;
+    pFrame->fc |= (0x1 << DOT11_FC_TO_DS_SHIFT);
+
+    pFrame->qosControl = (userPriority << QOS_CONTROL_UP_SHIFT);
+
+    pFrame->fc = ENDIAN_HANDLE_WORD(pFrame->fc);
+
+    /* BSSID */
+    daParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+    status = ctrlData_getParam(pTxData->hCtrlData, &daParam);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+    MAC_COPY(pTxData->hOs, (&pFrame->address3), (&daParam.content.ctrlDataCurrentBSSID));
+    MAC_COPY(pTxData->hOs, (&pFrame->address1), (&daParam.content.ctrlDataCurrentBSSID));
+
+    /* Source MAC address */
+    saParam.paramType = CTRL_DATA_MAC_ADDRESS;
+    status = ctrlData_getParam(pTxData->hCtrlData, &saParam);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pTxData->hMemMngr, pMsdu->handle);
+        return NOK;
+    }
+   /* copy source mac address */
+    MAC_COPY(pTxData->hOs, (&pFrame->address2), (&saParam.content.ctrlDataDeviceMacAddress));
+
+    /* Update MSDU parameters */
+    pMsdu->headerLen = WLAN_QOS_HDR_LEN;
+    pMsdu->dataLen = WLAN_QOS_HDR_LEN;
+    pMsdu->firstBDPtr->length = WLAN_QOS_HDR_LEN;
+    pMsdu->qosTag = userPriority;
+    pMsdu->txFlags |= TX_DATA_NULL_MSDU;
+
+    // all data or mgmt packets built on host must have the correct 
+    // offset set to point to the start of the mac frame
+    memMgr_BufOffset(pMsdu->firstBDPtr) = TX_TOTAL_OFFSET_BEFORE_DATA;
+
+    
+    *pMsduPsPoll = pMsdu;
+
+    return status;
+}
+
+
+/****************************************************************************
+ *                      txData_SetQidToAcTable()
+ ****************************************************************************
+ * DESCRIPTION: set Qid according to Queue ID
+ ****************************************************************************/
+void txData_SetQidToAcTable(TI_HANDLE hTxData,UINT8 QidStart, UINT8 QidEnd,UINT8 AcId)
+{
+    int i;
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    for(i = QidStart ; i <= QidEnd; i++) 
+        pTxData->QidToAcTable[i] = AcId;
+
+}
+
+/****************************************************************************
+ *                      txData_GetAcIdFromQid()
+ ****************************************************************************
+ * DESCRIPTION: Get the Ac Id according to the Queue id 
+ ****************************************************************************/
+UINT8 txData_GetAcIdFromQid(TI_HANDLE hTxData,UINT8 Qid)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+    return (pTxData->QidToAcTable[Qid]);
+}
+
+/****************************************************************************
+ *                      txData_GetWlanHeaderLength()
+ ****************************************************************************
+ * DESCRIPTION: calculates the WLAN header length, according to QoS,
+ * current encryption, and packet type
+ ****************************************************************************/
+UINT32 txData_GetWlanHeaderLength( TI_HANDLE hTxData, void *pData, UINT32 txFlags )
+{
+    txData_t            *pTxData = (txData_t*)hTxData;
+    UINT32              wlanHeaderLength = 0;
+    EthernetHeader_t    *pEthHeader;
+    UINT16              swapedTypeLength;
+
+
+    /* management frames never have QoS or encryption padding */
+    if ( txFlags & TX_DATA_MGMT_MSDU )
+    {
+        return WLAN_HDR_LEN;
+    }
+    
+    /* 
+     * Determine 802.11 header length 
+     * QoS Header is longer (2 Bytes)
+     */
+    if ( pTxData->txDataQosParams.headerConverMode == QOS_CONVERT )
+    {
+        wlanHeaderLength = WLAN_QOS_HDR_LEN;
+    }
+    else
+    {
+        wlanHeaderLength = WLAN_HDR_LEN;
+    }
+
+    if ( txFlags & TX_DATA_EAPOL_MSDU )
+    {
+        /* EAPOLs should always contain SNAP */
+        wlanHeaderLength += WLAN_SNAP_HDR_LEN;
+        /* EAPOL encryption is set by the RSN module */
+        if ( TRUE == pTxData->txDataEapolEncryptionStatus )
+        {
+            wlanHeaderLength += pTxData->encryptionFieldSize; 
+        }
+        return wlanHeaderLength;
+    }
+    
+    /* add encryption overhead - 4 bytes for TKIP, 8 for AES. Actual decision was done at RSN */
+    if (pTxData->txDataCurrentPrivacyInvokedMode == TRUE)
+    {
+        wlanHeaderLength += pTxData->encryptionFieldSize;
+    }
+
+    /* 
+     * IAPP header should always include SNAP, but this is already included in the frame
+     * body itself, so it is not added here
+     */
+    if ( txFlags & TX_DATA_IAPP_MSDU )
+    {
+        return wlanHeaderLength;
+    }
+
+    /* stat frames are checked if they already contain SNAP header or not */
+    if ( txFlags & TX_DATA_DATA_MSDU )
+    {
+        /*
+         * Detect the packet type and decide if to create a    
+         * new SNAP or leave the original LLC.         
+         */
+        pEthHeader = (EthernetHeader_t *)pData;
+        swapedTypeLength = wlan_htons(pEthHeader->TypeLength);
+
+        /* 
+         * if the "type" field is greater than 1500 bytes, it means the frame we received has
+         * Ethernet II header (destination MAC, source MAC, type, 14 bytes total), and therefore
+         * we need to reserve 8 more bytes after the 802.11 header for LLC/SNAP header.
+         * If this field is smaller than or equal to 1500, this is not really a "type" field of 
+         * Ethernet II header, but rather a 802.3 size field. since 802.3 already has 8 bytes
+         * LLC/SNAP header (other than the 802.3 14 bytes of destination MAC, source MAC and size),
+         * there is no need to reserve 8 more bytes.
+         */
+        if ( swapedTypeLength > ETHERNET_MAX_PAYLOAD_SIZE )
+        {
+            return wlanHeaderLength + WLAN_SNAP_HDR_LEN;
+        }
+        else
+        {
+            return wlanHeaderLength;
+        }
+    }
+    else
+    {
+        WLAN_REPORT_ERROR( pTxData->hReport, TX_DATA_MODULE_LOG,
+                           (" %s: trying to get header length for packet with txFlags: 0x%x\n", __FUNCTION__, txFlags) );
+        return 0;
+    }
+}
+
+/****************************************************************************
+ *                      txDataMsduTimeExpired()
+ ****************************************************************************
+ * DESCRIPTION: calculates the time left until MSDU will expire, retunrs the
+ * time in TUs, or 0 if the MSDU has already expired.
+ ****************************************************************************/
+UINT32 txDataTimeToMsduExpiry (TI_HANDLE hTxData, mem_MSDU_T* pMsdu, UINT8 qID)
+{
+    txData_t    *pTxData = (txData_t*)hTxData;
+    UINT32       acID, uPassedTime;
+
+    /* translate queue ID to AC ID */
+    acID = txData_GetAcIdFromQid (hTxData, qID);
+
+    /* get time passed since insertion */
+    uPassedTime = os_timeStampUs (pTxData->hOs) - pMsdu->insertionTime;
+
+    /* if the passed time is smaller than a certain proportion of the MsduLifeTime - it's O.K. */
+    if (uPassedTime < 
+        ((pTxData->uFracOfLifeTimeToDrop * pTxData->txDataAcTrfcCtrl[acID].MsduLifeTime) / 100))
+    {
+        return (pTxData->txDataAcTrfcCtrl[acID].MsduLifeTime - uPassedTime) >> 10;
+    }
+    
+    /* timer expired, or about to expire --> drop it.*/
+    return 0;
+}
+
+
+/****************************************************************************
+*                               txData_startAfterRecovery                                *
+*****************************************************************************
+* DESCRIPTION:  This function start the tx data after recovery.
+*               It uses params that save before recovery.
+*
+* INPUTS:       hTxData - the object
+*
+* OUTPUT:
+*
+* RETURNS:      OK - stop succesfull
+*               NOK - stop unsuccesfull
+****************************************************************************/
+TI_STATUS txData_startAfterRecovery(TI_HANDLE hTxData)
+{
+    txData_t *pTxData = (txData_t *)hTxData;
+
+    /* check parameters validity */
+    if( pTxData == NULL )
+    {
+        WLAN_REPORT_ERROR(pTxData->hReport, TX_DATA_MODULE_LOG,
+            (" txData_start() : Illegal value for hTxData\n"));
+        return NOK;
+    }
+
+    pTxData->txDataPortStatus = pTxData->savePortStatus;
+    pTxData->txDataCurrentPrivacyInvokedMode = pTxData->saveTxDataCurrentPrivacyInvokedMode;
+    pTxData->txDataEapolEncryptionStatus = pTxData->saveTxDataEapolEncryptionStatus;
+    pTxData->encryptionFieldSize = pTxData->saveEncryptionFieldSize;
+
+    /* start scheduler timer */
+    os_timerStart(pTxData->hOs, pTxData->pSchedulerTimer, SCHEDULER_TIMER, TRUE);
+    pTxData->bSchedulerTimerRunning = TRUE;
+
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/tx.h b/sta_dk_4_0_4_32/common/src/core/data_ctrl/Tx/tx.h
new file mode 100644 (file)
index 0000000..3ce0cf2
--- /dev/null
@@ -0,0 +1,257 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       tx.h                                                                                                   */
+/*    PURPOSE: Tx module Header file                                                                      */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _TX_DATA_H_
+#define _TX_DATA_H_
+
+
+#include "MsduList.h"
+#include "paramOut.h"
+#include "DataCtrl_Api.h"
+
+#define DEF_TX_PORT_STATUS                                     CLOSE
+
+#define DEF_CURRENT_PRIVACY_INVOKED_MODE       FALSE
+
+#define DEF_EAPOL_ENCRYPTION_STATUS                    FALSE
+
+#define DEF_SCHEDULER_THRESHOLD                                32
+#define DEF_IS_SCHEDULER_IN_WORK                       FALSE
+#define SCHEDULER_TIMER                                                1000
+#define THROUGHPUT_TIMER                    1000
+
+#define DEF_HAL_INTERFACE_STATUS                       TX_DATA_OPEN
+/*Ronnie: add GWSI IF status and the following defines*/
+#define DEF_GWSI_INTERFACE_STATUS                      GWSI_OPEN
+
+
+#define MAX_NUMBER_OF_PRIORITIES       1
+
+typedef struct 
+{
+       UINT32  dbgDropedPacketsCounter;                                                    /* Pkts that failed to be inserted into Q */
+    UINT32  dbgInsertToMsduListBytes[MAX_NUM_OF_TX_QUEUES];            /* Bytes inserted into Q */
+       UINT32  dbgInsertToMsduListPackets[MAX_NUM_OF_TX_QUEUES];               /* Pkts that inserted into Q */
+       UINT32  dbgDropedFromMsduListPackets[MAX_NUM_OF_TX_QUEUES];     /* Pkts that failed to be inserted into Q */
+       UINT32  dbgScheduledOutPackets[MAX_NUM_OF_TX_QUEUES];                   /* Pkts scheduled for transmission per Q */
+       UINT32  dbgSendToGwsiQosPackets[MAX_NUM_OF_TX_QUEUES];                  /* Pkts sent to GWSI layer */
+       UINT32  dbgDroppedDueExpiryTimePackets[MAX_NUM_OF_TX_QUEUES];   /* Pkts dropped due to expiry time */
+       UINT32  dbgNumOfMsduFreeInTxTransfer[MAX_NUM_OF_TX_QUEUES];             /* Pkts freed on XFER */
+       UINT32  dbgNumOfMsduTxTransferCB[MAX_NUM_OF_TX_QUEUES];                 /* num of XFER done CB calls */
+       UINT32  dbgNumOfMsduXferDoneInShceduler[MAX_NUM_OF_TX_QUEUES];  /* Pkts for which XFER done was received in scheduler */
+       UINT32  dbgNumOfMsduSuccessInScheduler[MAX_NUM_OF_TX_QUEUES];   /* Pkts fof which success was received in scheduler */
+       UINT32  dbgNumOfMsduPendingInScheduler[MAX_NUM_OF_TX_QUEUES];   /* Pkts for which pending was received in scheduler */
+       UINT32  dbgNumOfMsduBusyInScheduler[MAX_NUM_OF_TX_QUEUES];              /* Pkts for which busy was received in scheduler */
+       UINT32  dbgNumOfMsduErrorInScheduler[MAX_NUM_OF_TX_QUEUES];             /* Pkts for which error was received in scheduler */
+       UINT32  dbgNumOfsendPacketComplete[MAX_NUM_OF_TX_QUEUES];               /* Pkts that reached complete CB */
+       UINT32  dbgTxCmpltOk[MAX_NUM_OF_TX_QUEUES];                     /* Pkts that reached complete CB with status OK */
+    UINT32  dbgTxCmpltError[MAX_NUM_OF_TX_QUEUES];                  /* Pkts that reached complete CB with status NOK */
+    UINT32  dbgTxCmpltOkBytes[MAX_NUM_OF_TX_QUEUES];                /* Acknowledged bytes (complete status OK) */
+       UINT32  dbgNumOfNullMsdu;                                                                               /* number of NULL MSDUs altogether */
+} txDataDbgCounters_t;
+
+
+typedef  struct 
+{
+    struct 
+    {
+        UINT32  core;            /* Cumulative core jitter */ 
+        UINT32  xfer;            /* Cumulative XFER jitter */ 
+        UINT32  fw;              /* Cumulative firmware jitter */
+        UINT32  air;             /* Cumulative air jitter */
+    } jitter;
+
+    struct 
+    {
+        UINT32  core;            /* Cumulative core delay */ 
+        UINT32  xfer;            /* Cumulative XFER delay */
+        UINT32  wait;            /* Cumulative XFER wait for firmware to wake-up */
+        UINT32  fw;              /* Cumulative firmware delay */
+        UINT32  air;             /* Cumulative air delay */ 
+    } delay;
+
+    struct 
+    {
+        UINT32  core;            /* Last core delay */
+        UINT32  xfer;            /* Last xfer delay */
+        UINT32  fw;              /* Last firmware duration */
+        UINT32  air;             /* Last TX air duration */
+    } last_delay;
+
+    struct 
+    {
+        UINT32  core;            /* Maximum core delay */
+        UINT32  xfer;            /* Maximum xfer delay */
+        UINT32  fw;              /* Maximum firmware duration */
+        UINT32  air;             /* Maximum TX air duration */
+    } max_delay;
+
+    struct
+    {
+        UINT32  core;            /* Number of packets passed through core */
+        UINT32  xfer;            /* Number of packets transferred via XFER during last second */
+        UINT32  wait;            /* Number of times XFER waited for firmware to wake-up */
+        UINT32  fw;              /* Packets that reached complete CB with status OK */
+        UINT32  fw_err;          /* Packets that reached complete CB with status NOK */
+    } count;
+} txDataJitter_t;
+
+typedef struct
+{
+    headerConvetMode_e  headerConverMode;                           /* header converting mode        */
+    acTrfcType_e        tag_ToAcClsfrTable[MAX_NUM_OF_802_1d_TAGS]; /* tag to AC classification      */
+} txQosParams_t;
+
+typedef struct 
+{
+       /* Handles */
+       TI_HANDLE                       hCtrlData;
+       TI_HANDLE                       hTnetwDrv;
+       TI_HANDLE                       hWhalCtrl;
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hMemMngr;
+       TI_HANDLE                       pSchedulerTimer;
+       TI_HANDLE                       pCreditTimer;
+       TI_HANDLE                       hSiteMgr;
+    TI_HANDLE                  hEvHandler;
+       TI_HANDLE                       hQosMngr;
+       TI_HANDLE                       hPowerMgr;
+       TI_HANDLE           pThroughputTimer;
+       TI_HANDLE           pAirThroughputTimer;
+       TI_HANDLE           pJitterTimer;
+    TI_HANDLE           TxEventDistributor;
+    TI_HANDLE           hBufferPool;                                /* Packet ID buffer pool */
+    TI_HANDLE                  pVadTimer;                      /* VAD timer handle */
+       /* critical section protect */
+       void*                           hCriticalSectionProtect;
+
+    BOOL                bSchedulerTimerRunning;
+
+       /* Tx flow parameters */
+       portStatus_e            txDataPortStatus;
+    portStatus_e               savePortStatus;                     /* save value for recovery */
+       BOOL                            txDataCurrentPrivacyInvokedMode;
+       BOOL                saveTxDataCurrentPrivacyInvokedMode;/* save value for recovery */
+       BOOL                            txDataEapolEncryptionStatus;
+       BOOL                saveTxDataEapolEncryptionStatus;    /* save value for recovery */
+       BOOL                            txDataIsSchedulerInWork;
+
+       /* Tx queues */
+       UINT8                           txDataNumOfQueues;
+       MsduList_t*             mngMsduList; 
+       MsduList_t*             dataMsduListArr[MAX_NUM_OF_TX_QUEUES];  
+    int                 txDataNumOfMsdusToTransmit; 
+
+       UINT8                           QidToAcTable[MAX_NUM_OF_TX_QUEUES];
+
+       UINT32                          creditCalculationTimeout;
+    
+    /* indicate the percentage of the MSDU lifetime under which the driver   *
+     * will send it to the Fw,                                               */
+    UINT8               uFracOfLifeTimeToDrop;
+       /* GWSI state */
+       txDataGwsiInterfaceStatus_e     txDataGwsiInterfaceStatus;
+
+       txDataHalInterfaceStatus_t      txDataHalInterfaceStatus;
+
+
+       /* Counters */
+       txDataCounters_t        txDataCounters[MAX_NUM_OF_TX_QUEUES]; /* Save Tx statistics per Tx-queue. */
+       txDataCounters_t        txDataReportedCounters[MAX_NUM_OF_TX_QUEUES]; /* Tx statistics per Tx-queue, cleared on read */
+    txDataCounters_t   tempTxDataCounters[MAX_NUM_OF_TX_QUEUES]; /* temporary storage for IOCTL retrieval. */
+       UINT32                          currentConsecutiveRetryFail; /* current consecutive number of tx failures due to max retry */
+
+       /* debug counters */
+       txDataDbgCounters_t     txDataDbgCounters;
+
+    /* Jitter debug info */
+  #if defined(TI_DBG)
+    txDataJitter_t      txJitter [MAX_NUM_OF_TX_QUEUES];
+  #endif
+
+       /* Tx Disabling flag */
+       txDisableReason_e       txDisable;
+
+       /*  QOS parameters */
+       acTrfcCtrl_t        txDataAcTrfcCtrl[MAX_NUM_OF_AC];
+    txQosParams_t       txDataQosParams;
+
+       /* timer throughput per tx queue */
+       BOOL                txThroughputTimerEnable;
+
+    /* timer air throughput per tx queue */
+    BOOL                txAirThroughputTimerEnable;
+
+    /* jitter periodic timer flag */
+    BOOL                txJitterTimerEnable;
+
+       /* credit calculation timer is enabled from registry */
+       BOOL                            bCreditCalcTimerEnabled;
+       /* credit calculation timer is running */
+       BOOL                            bCreditCalcTimerRunning;
+
+       /* enable to delay MSDU because of medium usage exeeded */
+       BOOL                            admCtrlDelayDueToMediumTimeOverUsage;
+
+       /* enable/disable adm down grade */
+       BOOL                            admissionDownGradeEnable;
+       
+       /* power control params and flag */
+    BOOL                               hwRequest;             /* HW request flag */
+       UINT32              powerCtrlId;           /* txDta Id  for power control */
+
+       BOOL                txDataAvailableQueue[MAX_NUM_OF_TX_QUEUES];
+
+    /* encryption params */
+    UINT8               encryptionFieldSize;    /* size to reserve in WLAN header fpr encryption */
+       UINT8               saveEncryptionFieldSize;/* save value for recovery */
+
+       BOOL                            bVadTimerEnabled;
+       UINT16                          vadTimerDuration;               /* in milliseconds */
+} txData_t;
+
+/* test functions */
+/*----------------*/
+void Test_HeaderConvertion(TI_HANDLE hTxData, mem_MSDU_T *pMsdu);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/DataCtrl_Api.h b/sta_dk_4_0_4_32/common/src/core/inc/DataCtrl_Api.h
new file mode 100644 (file)
index 0000000..d376a39
--- /dev/null
@@ -0,0 +1,417 @@
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*                                                                         */
+/*      PURPOSE:    DataCtrl module api functions header file              */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef _DATA_CTRL_API_H_
+#define _DATA_CTRL_API_H_
+
+#include "paramOut.h"
+#include "paramIn.h"
+#include "rxXfer_api.h"
+#include "802_11Defs.h"
+#include "MsduList.h"
+#include "GeneralUtilApi.h"
+
+
+typedef struct
+{
+    UINT32 hwNumOfFreeMsdu;
+    UINT32 hwNumOfBusyMsdu;
+    UINT32 hwNumOfFreeBDs;
+    UINT32 hwTotalAvailMem; 
+}hwTxInformation_t;
+
+/*  RX MODULE   */
+/*--------------*/
+
+/* Rx module interface functions */
+
+#define RECV_OK                  0x1
+#define DIRECTED_BYTES_RECV      0x2
+#define DIRECTED_FRAMES_RECV     0x4
+#define MULTICAST_BYTES_RECV     0x8
+#define MULTICAST_FRAMES_RECV    0x10   
+#define BROADCAST_BYTES_RECV     0x20    
+#define BROADCAST_FRAMES_RECV    0x40
+
+#define NO_RX_NOTIFICATION  0x0
+
+#define ALL_RCV_FRAME (DIRECTED_FRAMES_RECV|MULTICAST_FRAMES_RECV|BROADCAST_FRAMES_RECV)
+
+#define  MAX_RX_NOTIF_REQ_ELMENTS 8
+
+
+/*TI_HANDLE rxData_create (msduReceiveCB_t* msduReceiveCB, TI_HANDLE hOs);  */
+TI_HANDLE rxData_create (TI_HANDLE hOs);    
+
+TI_STATUS rxData_config(TI_HANDLE       hRxData, 
+                     TI_HANDLE          hCtrlData, 
+                     TI_HANDLE          hTxData,
+                     TI_HANDLE          hTnetwDrv,
+                        TI_HANDLE   hHalCtrl,
+                     TI_HANDLE          hMlme, 
+                     TI_HANDLE          hRsn, 
+                     TI_HANDLE          hSiteMgr, 
+                     TI_HANDLE          hExcMngr, 
+                     TI_HANDLE          hOs, 
+                     TI_HANDLE          hReport,
+                     TI_HANDLE          hMemMngr,
+                        TI_HANDLE   hEvHandler,
+                        rxDataInitParams_t * rxDataInitParams);
+
+void rxData_receiveMsduFromWlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+
+
+TI_STATUS rxData_stop(TI_HANDLE hRxData);
+
+TI_STATUS rxData_unLoad(TI_HANDLE hRxData); 
+
+TI_STATUS rxData_getParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo);  
+
+TI_STATUS rxData_setParam(TI_HANDLE hRxData, paramInfo_t *pParamInfo);  
+
+TI_STATUS rxData_getTiwlnCounters(TI_HANDLE hRxData, TIWLN_COUNTERS *pTiwlnCounters);
+
+TI_STATUS txData_copyPacketToMsdu(TI_HANDLE hTxData,mem_MSDU_T **pMsdu, int FreeOldMsdu);
+
+void rxData_resetCounters(TI_HANDLE hRxData);
+
+TI_STATUS txData_updateUsedTime(TI_HANDLE hTxData, UINT32 qNum, UINT16 usedTime);
+
+TI_STATUS txData_setAdmisionCtrlParams(TI_HANDLE hTxData, 
+                                       UINT8 acID,
+                                       UINT16 mediumTime, 
+                                       UINT32 minimumPHYRate,
+                                       BOOL admFlag);
+
+TI_STATUS txData_setPsVoiceDeliveryMode(TI_HANDLE hTxData, PSScheme_e   PsMode);
+
+TI_HANDLE rxData_RegNotif(TI_HANDLE hRxData,UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,UINT32 Cookie);
+
+TI_STATUS rxData_UnRegNotif(TI_HANDLE hRxData,TI_HANDLE RegEventHandle);
+
+TI_STATUS rxData_AddToNotifMask(TI_HANDLE hRxData,TI_HANDLE Notifh,UINT16 EventMask);
+
+
+/* debug functions */
+void rxData_resetDbgCounters(TI_HANDLE hRxData);
+void rxData_printRxBlock(TI_HANDLE hRxData);
+void rxData_printRxCounters(TI_HANDLE hRxData);
+void rxData_startRxThroughputTimer(TI_HANDLE hRxData); 
+void rxData_stopRxThroughputTimer(TI_HANDLE hRxData); 
+void rxData_printRxDataFilter(TI_HANDLE hRxData);
+
+
+/*  TX MODULE   */
+/*--------------*/
+
+/* Tx module data types */
+
+typedef enum 
+{
+    NO_DISABLE                  = 0,
+    DISABLE_IMMEDIATELY         = 1,
+} txDisableReason_e;
+
+typedef struct
+{
+    UINT32      HwRate;
+    rate_e      Rate;   
+    UINT8       txRatePolicyId;
+} txData_attr_t; 
+
+typedef struct
+{
+    mem_MSDU_T          *pMsdu;
+    BOOLEAN             bDataMsdu;
+    UINT8               txQid;
+    UINT8               txCompleteFlags;
+    UINT32              maxTransmitRate;
+    BOOLEAN             bXferDoneCalled;
+    BOOLEAN             bTxCompleteCalled;
+    UINT32              msduDataLen;
+    macAddress_t        destinationMac;
+    UINT32              driverHandlingTime;
+    UINT32              timeStamp [6];  
+} txPacketIdAttr_t;
+
+typedef struct
+{
+    TI_STATUS               status;
+    UINT32                  packetId;
+    UINT32                  rate;
+    UINT8                   ackFailures;
+    UINT32                  actualDurationInAir;
+    UINT32                  fwHandlingTime;
+    UINT32                  mediumDelay;
+} txCompleteAttr_t;
+
+#define XFER_OK                 0x1
+#define DIRECTED_BYTES_XFER     0x2
+#define DIRECTED_FRAMES_XFER    0x4
+#define MULTICAST_BYTES_XFER    0x8
+#define MULTICAST_FRAMES_XFER   0x10
+#define BROADCAST_BYTES_XFER    0x20
+#define BROADCAST_FRAMES_XFER   0x40
+
+#define NO_TX_NOTIFICATION      0x0
+
+#define ALL_XMIT_FRAMES (DIRECTED_FRAMES_XMIT|MULTICAST_FRAMES_XMIT|BROADCAST_FRAMES_XMIT)
+
+#define  MAX_TX_NOTIF_REQ_ELMENTS 8
+
+#define POLL_AP_PACKETS_FORCE_PS_POLL  0xFF /* indicates a "force" PS POLL for the PollAPPackets routine (for backwards compatibility) */
+
+
+/* Tx module interface functions */
+TI_HANDLE txData_create(txDataInitParams_t *txDataInitParams, TI_HANDLE hOs);
+
+TI_STATUS txData_config(TI_HANDLE       hTxData, 
+                     TI_HANDLE      hCtrlData, 
+                     TI_HANDLE      hTnetwDrv,
+                     TI_HANDLE      hWhalCtrl,
+                     TI_HANDLE      hOs,
+                     TI_HANDLE      hReport,
+                     TI_HANDLE      hMemMngr,
+                     TI_HANDLE      hSiteMgr,
+                     TI_HANDLE      hEvHandler,
+                       TI_HANDLE      hQosMngr,
+                       TI_HANDLE      hPowerMgr);
+
+TI_STATUS txData_stop(TI_HANDLE hTxData);
+
+TI_STATUS txData_start(TI_HANDLE hTxData);
+TI_STATUS txData_startAfterRecovery(TI_HANDLE hTxData);
+
+
+void txData_recoveryIndication( TI_HANDLE hTxData );
+
+TI_STATUS txData_getParam(TI_HANDLE hTxData, paramInfo_t *pParamInfo);  
+
+TI_STATUS txData_setParam(TI_HANDLE hTxData, paramInfo_t *pParamInfo);  
+
+TI_STATUS txData_unLoad(TI_HANDLE hTxData); 
+
+TI_STATUS txData_getTiwlnCounters(TI_HANDLE hTxData, TIWLN_COUNTERS *pTiwlnCounters);   
+
+TI_STATUS txData_checkQueueSize(TI_HANDLE hTxData,UINT8 qIndex);
+
+TI_STATUS txData_sendPktToWlan(TI_HANDLE hTxData, mem_MSDU_T *pMsdu, UINT8 pkt_DTag);
+
+TI_STATUS txData_txSendMsdu(TI_HANDLE hTxData, mem_MSDU_T *pMsdu);
+
+TI_STATUS txData_startTxScheduler(TI_HANDLE hTxData);
+
+TI_STATUS txData_txCompleteUpdate( TI_HANDLE hTxData, txCompleteAttr_t *pTxCompleteAttr );
+
+void      txData_sendPacketTransfer(TI_HANDLE hTxData, UINT32 pPacketIdAttr);
+void      txData_sendPacketDebug(TI_HANDLE hTxData, UINT32 pPacketIdAttr, UINT32 uDebugInfo);
+
+
+
+TI_STATUS txData_disableTransmission(TI_HANDLE hTxData,txDisableReason_e reason);
+
+TI_STATUS txData_enableTransmission(TI_HANDLE hTxData);
+TI_STATUS txData_sendNullFrame(TI_HANDLE hTxData,
+                               BOOL powerSaveOn,
+                               allocatingModule_e module);
+
+
+TI_STATUS txData_getPsPollFrame(TI_HANDLE hTxData,mem_MSDU_T **pMsduPsPoll);
+
+TI_STATUS txData_buildQosNullDataFrame(TI_HANDLE hTxData,mem_MSDU_T **pMsduPsPoll, UINT8 userPriority);
+
+TI_STATUS txData_sendVadFrame(TI_HANDLE hTxData, UINT8 acID);
+
+void txData_resetCounters(TI_HANDLE hTxData);
+
+TI_HANDLE txData_RegNotif(TI_HANDLE hTxData,UINT16 EventMask,GeneralEventCall_t CallBack,TI_HANDLE context,UINT32 Cookie);
+
+TI_STATUS txData_UnRegNotif(TI_HANDLE hTxData,TI_HANDLE RegEventHandle);
+
+TI_STATUS txData_AddToNotifMask(TI_HANDLE hTxData,TI_HANDLE Notifh,UINT16 EventMask);
+
+BOOL txData_isQueueUseMediumTime(TI_HANDLE hTxData, UINT8 qNum);
+
+UINT32 txData_GetWlanHeaderLength( TI_HANDLE hTxData, void *pData, UINT32 txFlags );
+
+/* debug functions */
+void txData_printTxBlock(TI_HANDLE hTxData);
+void txData_printTxCounters(TI_HANDLE hTxData);
+void txData_printQosParams(TI_HANDLE hTxData);
+void txData_resetDbgCounters(TI_HANDLE hTxData);
+void txData_printDataMsduList(TI_HANDLE hTxData);
+void txData_fullPrintDataMsduList(TI_HANDLE hTxData);
+void txData_printMgmtMsduList(TI_HANDLE hTxData);
+void txData_fullPrintMgmtMsduList(TI_HANDLE hTxData);
+void txData_StartTxThroughputTimer(TI_HANDLE hTxData);
+void txData_StopTxThroughputTimer(TI_HANDLE hTxData);
+void txData_StartTxAirThroughputTimer(TI_HANDLE hTxData);
+void txData_StopTxAirThroughputTimer(TI_HANDLE hTxData);
+void txData_StartJitterTimer(TI_HANDLE hTxData);
+void txData_StopJitterTimer(TI_HANDLE hTxData);
+void txData_printTxQosCounters(TI_HANDLE hTxData);
+
+
+
+/* CONTROL MODULE */
+/*----------------*/
+
+
+typedef struct
+{
+    macAddress_t    ctrlDataDeviceMacAddress; 
+} ctrlDataConfig_t; 
+
+/*******************************/
+/* Control module interface functions */
+/*TI_HANDLE ctrlData_create(TI_HANDLE hOs,*/
+/*                           TxCompleteStatusCB_t* TxCmplt_CB);*/
+TI_HANDLE ctrlData_create(TI_HANDLE hOs);
+
+TI_STATUS ctrlData_config(TI_HANDLE         hCtrlData,
+                       TI_HANDLE            hWhalCtrl, 
+                       TI_HANDLE            hSiteMgrHandle, 
+                       TI_HANDLE            hTxData, 
+                       TI_HANDLE            hRxData, 
+                       TI_HANDLE            hOs, 
+                       TI_HANDLE            hReport, 
+                       TI_HANDLE            hMemMngr, 
+                       TI_HANDLE            hEvHandler,
+                       TI_HANDLE            hAPConnection,
+                       TI_HANDLE            hTrafficMonitor,
+                       disassocSentCB_t     disassocSentCBFunc,
+                       TI_HANDLE            disassocSentCBObj,  
+                       ctrlDataInitParams_t *ctrlDataInitParams);
+
+TI_STATUS ctrlData_unLoad(TI_HANDLE hCtrlData); 
+
+TI_STATUS ctrlData_getParam(TI_HANDLE hCtrlData, paramInfo_t *pParamInfo);  
+
+TI_STATUS ctrlData_setParam(TI_HANDLE hCtrlData, paramInfo_t *pParamInfo);  
+
+TI_STATUS ctrlData_start(TI_HANDLE hCtrlData);  
+
+TI_STATUS ctrlData_stop(TI_HANDLE hCtrlData);
+
+TI_STATUS ctrlData_getTiwlnCounters(TI_HANDLE hCtrlData, TIWLN_COUNTERS *pTiwlnCounters);   
+
+TI_STATUS ctrlData_rxMsdu(TI_HANDLE         hCtrlData, 
+                          mem_MSDU_T        **pRxMsdu);
+#ifdef SUPPORT_4X
+TI_STATUS ctrlData_txDequeueMsdu(TI_HANDLE          hCtrlData, 
+                                 mem_MSDU_T**       buildMsduPtr,
+                                 MsduList_t*        pMsduList, 
+                                 whalTx_attr_t*     pWhalTx_attr,
+                                 hwTxInformation_t* pHwTxInformation);
+
+TI_STATUS ctrlData_txMsdu(TI_HANDLE         hCtrlData, 
+                          mem_MSDU_T**      msduPtr);
+#endif
+
+TI_STATUS ctrlData_getTxAttributes(TI_HANDLE hCtrlData , 
+                                   UINT32 txFlags, 
+                                   txData_attr_t *pTxAttr,
+                                   UINT32 ac);  
+
+TI_STATUS ctrlData_ClsfrClassifyTxMSDU(TI_HANDLE    hCtrlData, 
+                                       mem_MSDU_T   *pMsdu, 
+                                       UINT8        packet_DTag);
+
+TI_STATUS ctrlData_clsfrSetClsfrType(TI_HANDLE          hCtrlData,
+                                    clsfrTypeAndSupport     newClsfrType);
+
+    
+
+void ctrlData_getCurrBssTypeAndCurrBssId(TI_HANDLE hCtrlData, macAddress_t *pCurrBssid, 
+                                         bssType_e *pCurrBssType);  
+
+#ifdef SUPPORT_4X
+TI_STATUS ctrlData_get4xInfoElemnt(TI_HANDLE hCtrlData, 
+                                   dot11_4X_t* fourXInfoElemnt);
+
+TI_STATUS ctrlData_get4xStatus(TI_HANDLE hCtrlData,BOOL* fourXEnable);
+
+TI_STATUS ctrlData_evalSite(TI_HANDLE hCtrlData, 
+                            dot11_4X_t* site4xParams, 
+                            UINT32 *matchingLevel);
+#endif
+
+TI_STATUS ctrlData_setSite(TI_HANDLE hCtrlData,
+                           dot11_4X_t* site4xParams);
+
+void ctrlData_setTspecsRateEvent(TI_HANDLE          hCtrlData,
+                                    UINT8               acID,
+                                    BOOL                enableEvent);
+
+void ctrlData_setTspecsRateThresholds(TI_HANDLE     hCtrlData,
+                                      UINT8         acID,
+                                      UINT8     highRateThreshold,
+                                      UINT8     lowRateThreshold);
+
+void ctrlData_txCompleteStatus( TI_HANDLE hCtrlData,
+                               txCompleteAttr_t *pTxCompleteAttr);
+
+
+void ctrlData_getTspecsRateThresholds(TI_HANDLE hCtrlData, UINT8 uAC, UINT32* pHighThreshold, UINT32* pLowThreshold);
+void ctrlData_ToggleTrafficIntensityNotification (TI_HANDLE hCtrlData, BOOL enabledFlag);
+
+
+/* dbg functions */
+/*---------------*/
+void ctrlData_printRateAdaptation(TI_HANDLE hCtrlData);
+void ctrlData_printTxParameters(TI_HANDLE hCtrlData);
+void ctrlData_printCtrlBlock(TI_HANDLE hCtrlData);
+void ctrlData_printCtrlCounters(TI_HANDLE hCtrlData);
+void ctrlData_printFourX(TI_HANDLE hCtrlData);
+
+#ifdef TI_DBG
+void ctrlData_clearClsfrTable ( TI_HANDLE hCtrlData );
+void ctrlData_printClsfrTable ( TI_HANDLE hCtrlData );
+#endif
+
+/* TEST FUNCTION */
+/*---------------*/
+void Test_OsFreeFunction(TI_HANDLE hOs, TI_HANDLE pAddr);
+TI_HANDLE Test_rxData_receiveMsduFromWlan(TI_HANDLE hRxData, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/conn.h b/sta_dk_4_0_4_32/common/src/core/inc/conn.h
new file mode 100644 (file)
index 0000000..aa53563
--- /dev/null
@@ -0,0 +1,120 @@
+/** \file conn.h
+ *  \brief connection module internal header file
+ *
+ *  \see conn.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       conn.h                                                                                                          */
+/*    PURPOSE: connection module internal header file                                          */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __CONN_H__
+#define __CONN_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "fsm.h"
+#include "802_11Defs.h"
+#include "connApi.h"
+
+typedef struct
+{
+       mgmtStatus_e                    disAssocEventReason;            /* Disassoc reason to be used for upper layer   */
+       UINT32                                  disAssocEventStatusCode;        /* Extra information for disConnEventReason             */
+} connSmContext_t;
+
+
+/*
+ *     ibssRandomSsidGen - in IBSS, that flag indicates if the ibss must be randommaly changed. 
+ *     FALSE - do not generate random ibss.
+ *     TRUE -  generate random ibss.
+ *     1.      at Start up that flag is FALSE
+ *  2. after Connection fail in connIbss or connSelf SM, set the flag to TRUE in order to 
+ *             generate a new random ibss.
+ */
+
+/* Connection handle */
+typedef struct 
+{
+       UINT8                                   state;  
+       connSmContext_t                 smContext;
+       connectionType_e                currentConnType;
+       UINT32                                  timeout;
+       void                                    *pTimer; /* This timer is used both by IBSS and BSS */
+       fsm_stateMachine_t              *ibss_pFsm;
+    fsm_stateMachine_t         *infra_pFsm;
+       connType_e                              connType;
+       disConnType_e                   disConnType;
+       mgmtStatus_e                    disConnReasonToAP;                      /* Status code for Deauth packet to AP */
+       BOOL                                    disConEraseKeys;
+
+       conn_status_callback_t  pConnStatusCB;
+       TI_HANDLE                               connStatCbObj;
+
+       BOOL                                    scrRequested; 
+    UINT32                  ibssDisconnectCount;
+
+       TI_HANDLE                               hSiteMgr;
+       TI_HANDLE                               hSmeSm;
+       TI_HANDLE                               hMlmeSm;
+       TI_HANDLE                               hRsn;
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hOs;
+       TI_HANDLE                               hRxData;
+       TI_HANDLE                               hTxData;
+       TI_HANDLE                               hPwrMngr;
+       TI_HANDLE                               hCtrlData;
+       TI_HANDLE                               hQosMngr;
+       TI_HANDLE                               hHalCtrl;
+       TI_HANDLE                               hMeasurementMgr;
+       TI_HANDLE                               hScr;
+       TI_HANDLE                               hTrafficMonitor;
+       TI_HANDLE                               hExcMngr;
+       TI_HANDLE                               hScanCnc;
+       TI_HANDLE                               hCurrBss;
+       TI_HANDLE                               hSwitchChannel;
+       TI_HANDLE                               hEvHandler;
+       TI_HANDLE                               hHealthMonitor;
+       TI_HANDLE                               hMacServices;
+    TI_HANDLE               hRegulatoryDomain;
+       TI_HANDLE                       hSoftGemini;
+} conn_t;
+
+#endif /* __CONN_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/mlmeApi.h b/sta_dk_4_0_4_32/common/src/core/inc/mlmeApi.h
new file mode 100644 (file)
index 0000000..c15079b
--- /dev/null
@@ -0,0 +1,253 @@
+/** \file mlmeApi.h
+ *  \brief MLME API
+ *
+ *  \see mlmeSm.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       mlmeApi.h                                                                                                       */
+/*    PURPOSE: MLME API                                                                                                        */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __MLME_API_H__
+#define __MLME_API_H__
+
+#include "osTIType.h"
+
+#include "paramOut.h"
+
+#include "802_11Defs.h"
+#include "memMngrEx.h"
+
+#include "whalBus_Defs.h"
+
+/* Constants */
+
+/* Enumerations */
+
+typedef enum
+{
+       MSG_BROADCAST,
+       MSG_MULTICAST,
+       MSG_UNICAST
+} mlmeMsgDestType_t;
+
+/*
+ * Disconnecting type enum
+ */
+typedef enum{
+       DISCONN_TYPE_IMMEDIATE     = 0,  /* Disconnect without disassociation. */
+       DISCONN_TYPE_DISASSOC,           /* Send disassocciation frame upon disconnecting */
+       DISCONN_TYPE_DEAUTH              /* Send disassocciation notification upon disconnecting */
+}disConnType_e;
+
+/* Typedefs */
+
+
+typedef struct 
+{
+       dot11MgmtSubType_e subType;
+
+       union 
+       {
+               beacon_probeRsp_t iePacket;
+               disAssoc_t      disAssoc;
+               assocRsp_t      assocRsp;
+               authMsg_t       auth;
+               deAuth_t        deAuth;
+               action_t        action;
+       } content;
+
+       union
+       {
+               mlmeMsgDestType_t       destType;
+       } extesion;
+
+} mlmeFrameInfo_t;
+
+typedef struct 
+{
+       dot11_SSID_t            ssid;
+       macAddress_t        bssid;
+    dot11_CHALLENGE_t   challenge;
+    dot11_RATES_t              rates;
+    dot11_RATES_t              extRates;
+    dot11_FH_PARAMS_t  fhParams;
+    dot11_CF_PARAMS_t  cfParams;
+       dot11_DS_PARAMS_t       dsParams;
+    dot11_IBSS_PARAMS_t ibssParams;
+    dot11_COUNTRY_t    country;
+    dot11_WME_PARAM_t  WMEParams;
+    dot11_POWER_CONSTRAINT_t powerConstraint;
+    dot11_4X_t                         fourXParams;
+    dot11_CHANNEL_SWITCH_t channelSwitch;
+    dot11_QUIET_t              quiet;
+    dot11_TPC_REPORT_t         TPCReport;
+#ifdef EXC_MODULE_INCLUDED
+       dot11_CELL_TP_t         cellTP;
+#endif
+    dot11_RSN_t                rsnIe[3];
+       dot11_TIM_t             tim;
+       dot11_QOS_CAPABILITY_IE_t       QosCapParams;
+       UINT8                           rxChannel;
+       UINT8                           band;
+       BOOL                            myBssid;
+       BOOL                            myDst;
+       BOOL                            mySa;
+       BOOL                            recvChannelSwitchAnnoncIE;
+       mlmeFrameInfo_t         frame;
+}mlmeIEParsingParams_t;
+
+typedef void (*mlme_resultCB_t)( TI_HANDLE hObj, macAddress_t* bssid, mlmeFrameInfo_t* pFrameInfo,
+                                 Rx_attr_t* pRxAttr, UINT8* frame, UINT16 frameLength );
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+/* MLME SM API */
+
+TI_HANDLE mlme_create(TI_HANDLE hOs);
+
+TI_STATUS mlme_unload(TI_HANDLE hMlme);
+
+TI_STATUS mlme_config(TI_HANDLE hMlme,
+                                  TI_HANDLE hAuth,
+                                  TI_HANDLE hAssoc,
+                                  TI_HANDLE hSiteMgr,
+                                  TI_HANDLE hCtrlData,
+                                  TI_HANDLE hConn,
+                                  TI_HANDLE hTxData,
+                                  TI_HANDLE hHalCtrl,
+                                  TI_HANDLE hMemMgr,
+                                  TI_HANDLE hMeasurementMgr,
+                                  TI_HANDLE hSwitchChannel,
+                                  TI_HANDLE hRegulatoryDomain,
+                                  TI_HANDLE hReport,
+                                  TI_HANDLE hOs,
+                                  TI_HANDLE hCurrBss,
+                                  TI_HANDLE hApConn,
+                                  TI_HANDLE hScanCncn,
+                                  TI_HANDLE hQosMngr,
+                   TI_HANDLE hConfigMgr);
+
+TI_STATUS mlme_setParam(TI_HANDLE                      hMlmeSm,
+                                               paramInfo_t                     *pParam);
+
+TI_STATUS mlme_getParam(TI_HANDLE                      hMlmeSm, 
+                                               paramInfo_t                     *pParam);
+
+TI_STATUS mlme_start(TI_HANDLE hMlme);
+
+TI_STATUS mlme_stop(TI_HANDLE hMlme, disConnType_e disConnType, mgmtStatus_e reason);
+
+TI_STATUS mlme_reportAuthStatus(TI_HANDLE hMlme, UINT16 status);
+
+TI_STATUS mlme_reportAssocStatus(TI_HANDLE hMlme, UINT16 status);
+
+/* MLME parser API */
+
+TI_STATUS mlmeParser_recv(TI_HANDLE hMlme, mem_MSDU_T *pMSDU, Rx_attr_t* pRxAttr);
+
+TI_STATUS mlmeParser_registerForBeaconAndProbeResp( TI_HANDLE hMlme, 
+                                                    mlme_resultCB_t resultCBFunc, 
+                                                    TI_HANDLE resultCBObj );
+
+void mlmeParser_unregisterForBeaconAndProbeResp( TI_HANDLE hMlme );
+
+TI_STATUS mlmeParser_parseIEs(TI_HANDLE *hMlme, 
+                                                         UINT8 *pData,
+                                                         INT32 bodyDataLen,
+                                                         mlmeIEParsingParams_t *params);
+
+#ifdef EXC_MODULE_INCLUDED
+void mlmeParser_readExcOui (UINT8 *pData, 
+                                                       UINT32 dataLen, 
+                                                       UINT32 *pReadLen, 
+                                                       EXCv4IEs_t *excIEs);
+#endif
+
+mlmeIEParsingParams_t *mlmeParser_getParseIEsBuffer(TI_HANDLE *hMlme);
+
+/* Association SM API */
+
+TI_HANDLE assoc_create(TI_HANDLE pOs);
+
+TI_STATUS assoc_unload(TI_HANDLE pAssoc);
+
+TI_STATUS assoc_config(TI_HANDLE hAssoc,
+                                       TI_HANDLE hMlme,
+                                       TI_HANDLE hRegulatoryDomain,
+                                       TI_HANDLE hSiteMgr,
+                                       TI_HANDLE hCtrlData,
+                                       TI_HANDLE hTxData,
+                                       TI_HANDLE hHalCtrl,
+                                       TI_HANDLE hRsn,
+                                       TI_HANDLE hReport,
+                                       TI_HANDLE hOs,
+                                       TI_HANDLE hExcMngr,
+                                       TI_HANDLE hQosMngr,
+                    TI_HANDLE hMeasurementMgr,
+                                       TI_HANDLE hApConn,
+                                       assocInitParams_t       *pAssocInitParams);
+
+TI_STATUS assoc_setParam(TI_HANDLE hCtrlData, paramInfo_t      *pParam);
+
+TI_STATUS assoc_getParam(TI_HANDLE hCtrlData, paramInfo_t      *pParam);
+
+/* Authentication SM API */
+
+TI_HANDLE auth_create(TI_HANDLE hOs);
+
+TI_STATUS auth_unload(TI_HANDLE hAuth);
+
+TI_STATUS auth_config(TI_HANDLE                        hAuth,
+                   TI_HANDLE                   hMlme,
+                                  TI_HANDLE                    hRsn,
+                                  TI_HANDLE                    hReport,
+                                  TI_HANDLE                    hOs,
+                                  authInitParams_t             *pAuthInitParams);
+
+
+TI_STATUS auth_setParam(TI_HANDLE hCtrlData, paramInfo_t       *pParam);
+
+TI_STATUS auth_getParam(TI_HANDLE hCtrlData, paramInfo_t       *pParam);
+
+#endif /* __MLME_API_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/mlmeBuilder.h b/sta_dk_4_0_4_32/common/src/core/inc/mlmeBuilder.h
new file mode 100644 (file)
index 0000000..0940172
--- /dev/null
@@ -0,0 +1,86 @@
+ /** \file mlmeBuilder.h
+ *  \brief 802.11 MLME Builder
+ *
+ *  \see mlmeBuilder.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mlmeBuilder.h                                                                                      */
+/*    PURPOSE: 802.11 MLME Builder                                                                                */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MLME_BUILDER_H
+#define _MLME_BUILDER_H
+
+#include "802_11Defs.h"
+
+#include "paramOut.h"
+
+#include "mlmeSm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* state machine states */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS mlmeBuilder_sendFrame(TI_HANDLE pMlme, 
+                                                        dot11MgmtSubType_e type, 
+                                                        UINT8 *pDataBuff, 
+                                                        UINT32 dataLen, 
+                                                        UINT8 setWepOpt);
+
+TI_STATUS mlmeBuilder_buildFrameCtrl(mlme_t* pMlme, 
+                                                                 dot11MgmtSubType_e type, 
+                                                                 UINT16* pFctrl, 
+                                                                 UINT8 setWepOpt);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/mlmeSm.h b/sta_dk_4_0_4_32/common/src/core/inc/mlmeSm.h
new file mode 100644 (file)
index 0000000..8de9afd
--- /dev/null
@@ -0,0 +1,173 @@
+ /** \file mlmeSm.h
+ *  \brief 802.11 MLME SM
+ *
+ *  \see mlmeSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mlmeSm.h                                                                                                   */
+/*    PURPOSE: 802.11 MLME SM                                                                     */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MLME_SM_H
+#define _MLME_SM_H
+
+#include "fsm.h"
+#include "mlmeApi.h"
+
+/* Constants */
+
+/* changed to fit double buffer size - S.G */
+/*#define MAX_MANAGEMENT_FRAME_BODY_LEN        2312*/
+#define MAX_MANAGEMENT_FRAME_BODY_LEN  1476
+
+/* Enumerations */
+
+/* state machine states */
+typedef enum 
+{
+       MLME_SM_STATE_IDLE                      = 0,
+       MLME_SM_STATE_AUTH_WAIT         = 1,
+       MLME_SM_STATE_ASSOC_WAIT        = 2,
+       MLME_SM_STATE_ASSOC             = 3,
+       MLME_SM_NUM_STATES
+} mlme_smStates_t;
+
+/* State machine inputs */
+typedef enum 
+{
+       MLME_SM_EVENT_START                             = 0,
+       MLME_SM_EVENT_STOP                              = 1,
+       MLME_SM_EVENT_AUTH_SUCCESS      = 2,
+    MLME_SM_EVENT_AUTH_FAIL                    = 3,
+       MLME_SM_EVENT_ASSOC_SUCCESS     = 4,
+    MLME_SM_EVENT_ASSOC_FAIL           = 5,
+       MLME_SM_NUM_EVENTS                      
+} mlme_smEvents_t;
+
+
+
+/* Typedefs */
+
+typedef struct
+{
+       mgmtStatus_e mgmtStatus;
+       UINT16           uStatusCode;
+} mlmeData_t;
+
+
+typedef struct
+{
+       fsm_stateMachine_t      *pMlmeSm;
+       UINT8                           currentState;
+       mlmeData_t          mlmeData;
+       legacyAuthType_e        legacyAuthType;
+       BOOL                            reAssoc;
+       disConnType_e           disConnType;
+       mgmtStatus_e            disConnReason;
+
+    /* beacons and probe response registration information */
+    mlme_resultCB_t     resultCBFunc;
+    TI_HANDLE           resultCBObj;
+
+    /* temporary frame info */
+    mlmeIEParsingParams_t tempFrameInfo;
+    
+    /* debug info - start */
+    UINT32              debug_lastProbeRspTSFTime;
+    UINT32              debug_lastDtimBcnTSFTime;
+    UINT32              debug_lastBeaconTSFTime;
+    BOOL                debug_isFunctionFirstTime;
+    UINT32              totalMissingBeaconsCounter;
+    UINT32              totalRcvdBeaconsCounter;
+    UINT32              maxMissingBeaconSequence;
+    UINT32              BeaconsCounterPS;
+    /* debug info - end */
+
+    TI_HANDLE                  hAuth;
+       TI_HANDLE                       hAssoc;
+       TI_HANDLE                       hSiteMgr;
+       TI_HANDLE                       hCtrlData;
+       TI_HANDLE                       hConn;
+       TI_HANDLE                       hTxData;
+       TI_HANDLE                       hHalCtrl;
+       TI_HANDLE                       hMemMgr;
+       TI_HANDLE                       hMeasurementMgr;
+       TI_HANDLE                       hSwitchChannel;
+       TI_HANDLE                       hRegulatoryDomain;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hCurrBss;
+       TI_HANDLE                       hApConn;
+       TI_HANDLE           hScanCncn;
+       TI_HANDLE                       hQosMngr;
+    TI_HANDLE           hConfigMgr;
+} mlme_t;
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+void mlme_smTimeout(TI_HANDLE hMlme);
+
+/* local functions */
+
+TI_STATUS mlme_smEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hMlme);
+
+/* state machine functions */
+TI_STATUS mlme_smStartIdle(mlme_t *pMlme);
+TI_STATUS mlme_smAuthSuccessAuthWait(mlme_t *pMlme);
+TI_STATUS mlme_smAuthFailAuthWait(mlme_t *pMlme);
+TI_STATUS mlme_smStopAssocWait(mlme_t *pMlme);
+TI_STATUS mlme_smAssocSuccessAssocWait(mlme_t *pMlme);
+TI_STATUS mlme_smAssocFailAssocWait(mlme_t *pMlme);
+TI_STATUS mlme_smStopAssoc(mlme_t *pMlme);
+TI_STATUS mlme_smActionUnexpected(mlme_t *pMlme);
+TI_STATUS mlme_smNOP(mlme_t *pMlme);
+
+TI_STATUS mlme_smReportStatus(mlme_t *pMlme);
+void mlme_beaconReceivedPrint(TI_HANDLE hMlme);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/rsnApi.h b/sta_dk_4_0_4_32/common/src/core/inc/rsnApi.h
new file mode 100644 (file)
index 0000000..eb06c0a
--- /dev/null
@@ -0,0 +1,203 @@
+/** \file utilsReplvl.h
+ *  \brief Report level API
+ *
+ *  \see utilsReplvl.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*       MODULE:       utilsReplvl.h                                                                                                                           */
+/*    PURPOSE: Report level API                                                                                        */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __RSN_API_H__
+#define __RSN_API_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "memMngrEx.h"
+#include "802_11Defs.h"
+
+/* Constants */
+
+#define RSN_MAC_ADDR_LEN                       6
+#define MAX_KEY_RSC_LEN                                8
+#define MAX_SSN_KEY_DATA_LENGTH                32
+#define RSN_AUTH_FAILURE_TIMEOUT    30000
+
+/* Enumerations */
+
+/** RSN key management suites */
+typedef enum 
+{
+       RSN_KEY_MNG_NONE                                = 0,            /**< no key management available */
+       RSN_KEY_MNG_802_1X                              = 1,            /**< "802.1X" key management */
+       RSN_KEY_MNG_WPA                         = 2,            /**< "WPA 4 way handshake" key management */
+       RSN_KEY_MNG_EXC                         = 3,            /**< "EXC" key management */
+       RSN_KEY_MNG_UNKNOWN                             = 255           /**< UNKNOWN key management available */
+} rsn_keyMngSuite_e;
+
+/** Available cipher suites for admission control */
+typedef enum 
+{
+       RSN_IBSS                = 0,            /**< IBSS mode */
+       RSN_INFRASTRUCTURE              = 1             /**< Infrastructure mode */
+} rsn_networkMode_t;
+
+/** Port Access Entity role type */
+typedef enum
+{
+       RSN_PAE_AP              = 0,
+       RSN_PAE_SUPP    = 1
+} rsn_paeRole_t;
+
+/** RSN Events */
+typedef enum {
+       RSN_EVENT_EAPOL_RECV                    = 0x0,          /**< EAPOL frame received in the RX */
+       RSN_EVENT_SEC_ATTACK_DETECT             = 0x1,          /**< Security Attack detection */
+       RSN_EVENT_RAW_KEY_RECV                  = 0x2,          /**< Raw key recive */
+    RSN_EVENT_KEY_REMOVE            = 0x3              /**< Key remove event */
+} rsn_event_e;  
+
+/** Site ben levels */
+typedef enum 
+{
+    RSN_SITE_BAN_LEVEL_HALF = 1,
+    RSN_SITE_BAN_LEVEL_FULL  = 2
+} rsn_siteBanLevel_e;
+
+
+/* Typedefs */
+
+/** Port Access Entity structure */
+typedef struct
+{
+       externalAuthMode_e      authProtocol;
+       rsn_keyMngSuite_e       keyExchangeProtocol;
+       cipherSuite_e           unicastSuite;
+       cipherSuite_e           broadcastSuite;
+} rsn_paeConfig_t;
+
+typedef struct
+{
+       BOOL                privacy;
+       UINT8               *pIe;
+       UINT8               ieLen;
+} rsnData_t;
+
+typedef struct 
+{
+   macAddress_t bssId;
+   dot11_RSN_t  *pRsnIEs;
+   UINT8        rsnIeLen;
+} bssidRsnInfo_t;
+
+#define MAX_NUM_OF_PRE_AUTH_BSSIDS     16
+typedef struct 
+{
+   UINT8          NumOfItems;
+   bssidRsnInfo_t bssidList[MAX_NUM_OF_PRE_AUTH_BSSIDS];
+} bssidList4PreAuth_t;
+
+
+/* Prototypes */
+
+TI_HANDLE rsn_create(TI_HANDLE hOs);
+
+TI_STATUS rsn_unload(TI_HANDLE hRsn);
+
+TI_STATUS rsn_config(TI_HANDLE                 hRsn,
+                                 TI_HANDLE                     hTx,
+                                 TI_HANDLE                     hRx,
+                                 TI_HANDLE                     hConn,
+                                 TI_HANDLE                     hMlme,
+                                 TI_HANDLE                     hCtrlData,
+                                 TI_HANDLE                     hWhalCtrl,
+                                 TI_HANDLE                     hMemMgr,
+                  TI_HANDLE         hSiteMgr,
+                                 TI_HANDLE             hReport,
+                                 TI_HANDLE             hOs,
+                                 TI_HANDLE             hExcMngr,
+                                 TI_HANDLE             hPowerMgr,
+                  TI_HANDLE         hEvHandler,
+                  TI_HANDLE         hSmeSm,
+                  TI_HANDLE         hAPConn,
+                                 rsnInitParams_t       *pInitParam);
+
+TI_STATUS rsn_reconfig(TI_HANDLE hRsn);
+
+TI_STATUS rsn_start(TI_HANDLE hRsn);
+
+TI_STATUS rsn_stop(TI_HANDLE hRsn, BOOL removeKeys);
+
+TI_STATUS rsn_eventRecv(TI_HANDLE hRsn, rsn_event_e event, void* pData);
+
+TI_STATUS rsn_setParam(TI_HANDLE hCtrlData, paramInfo_t        *pParam);
+
+TI_STATUS rsn_getParam(TI_HANDLE hCtrlData, paramInfo_t        *pParam);
+
+TI_STATUS rsn_evalSite(TI_HANDLE hRsn, rsnData_t *pRsnData, bssType_e bssType, macAddress_t bssid, UINT32 *pMetric);
+
+TI_STATUS rsn_setSite(TI_HANDLE hRsn, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+TI_STATUS rsn_recvEapol(TI_HANDLE hRsn, mem_MSDU_T *pMsdu);
+
+TI_STATUS rsn_getInfoElement(TI_HANDLE hRsn, UINT8 *pRsnIe, UINT8 *pRsnIeLen);
+
+#ifdef EXC_MODULE_INCLUDED
+TI_STATUS rsn_getExcExtendedInfoElement(TI_HANDLE hRsn, UINT8 *pRsnIe, UINT8 *pRsnIeLen);
+#endif
+
+TI_STATUS rsn_reportAuthFailure(TI_HANDLE hRsn, authStatus_e authStatus);
+
+TI_STATUS rsn_reportMicFailure(TI_HANDLE hRsn, UINT8 *pType, UINT32 Length);
+
+TI_STATUS rsn_resetPMKIDList(TI_HANDLE hRsn);
+
+TI_STATUS rsn_removedDefKeys(TI_HANDLE hRsn);
+
+TI_STATUS rsn_startPreAuth(TI_HANDLE hRsn, bssidList4PreAuth_t *pBssidList);
+
+rsn_siteBanLevel_e rsn_banSite(TI_HANDLE hRsn, macAddress_t siteBssid, rsn_siteBanLevel_e banLevel, UINT32 durationMs);
+
+BOOL rsn_isSiteBanned(TI_HANDLE hRsn, macAddress_t siteBssid);
+
+void rsn_MboxFlushFinishCb(TI_HANDLE handle, UINT16 MboxStatus, char *InterrogateParamsBuf);
+
+
+#endif /* __RSN_API_H__*/
diff --git a/sta_dk_4_0_4_32/common/src/core/inc/smeApi.h b/sta_dk_4_0_4_32/common/src/core/inc/smeApi.h
new file mode 100644 (file)
index 0000000..d63f86f
--- /dev/null
@@ -0,0 +1,96 @@
+/** \file smeMgr.h
+ *  \brief SME interface
+ *
+ *  
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                                                                                                     */
+/*             MODULE:         smeApi.h                                                                                                */
+/*             PURPOSE:        SME interface to Other core modules                                             */
+/*                                                                                                                                                     */
+/****************************************************************************/
+#ifndef __SME_API_H__
+#define __SME_API_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "mlmeApi.h"
+
+/* Typedefs */
+typedef enum
+{
+       NO_MATCH = 0,
+       MATCH =         1,
+} match_e;
+
+
+/* Prototypes */
+
+TI_STATUS conn_reportMlmeStatus(TI_HANDLE                      hConn, 
+                                                       mgmtStatus_e                    status,
+                                                       UINT16                                  uStatusCode);
+
+TI_STATUS conn_reportRsnStatus(TI_HANDLE                       hConn, 
+                                                       mgmtStatus_e            status);
+
+TI_STATUS siteMgr_updateSite(TI_HANDLE                 hSiteMgr, 
+                                                 macAddress_t          *bssid, 
+                                                 mlmeFrameInfo_t       *pFrameInfo,
+                                                 UINT8                         rxChannel,
+                          radioBand_e       band,
+                                                 BOOL                          measuring);
+
+TI_STATUS siteMgr_CheckRxSignalValidity(TI_HANDLE  hSiteMgr,
+                         INT8                  rxLevel,
+                                                UINT8                          channel,
+                         macAddress_t       *bssid);
+
+TI_STATUS siteMgr_updateRxSignal(TI_HANDLE             hSiteMgr,
+                                                UINT8                          snr, 
+                                                INT8                           rxLevel, 
+                         rate_e             rate,
+                                                macAddress_t           *bssid,
+                                                BOOL                           dataMsdu);
+
+TI_STATUS siteMgr_saveProbeRespBuffer(TI_HANDLE hSiteMgr, macAddress_t *bssid, UINT8 *pProbeRespBuffer, UINT32 length);
+
+TI_STATUS siteMgr_saveBeaconBuffer(TI_HANDLE hSiteMgr, macAddress_t *bssid, UINT8 *pBeaconBuffer, UINT32 length);
+
+
+#endif /* __SME_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Assoc/AssocSM.h b/sta_dk_4_0_4_32/common/src/core/mlme/Assoc/AssocSM.h
new file mode 100644 (file)
index 0000000..b64f4e6
--- /dev/null
@@ -0,0 +1,155 @@
+
+/** \file AssocSM.h
+ *  \brief 802.11 Association SM
+ *
+ *  \see assocSM.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: AssocSM.h                                                                                                  */
+/*    PURPOSE: 802.11 Association SM                                                                      */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _ASSOC_SM_H
+#define _ASSOC_SM_H
+
+#include "fsm.h"
+#include "mlmeApi.h"
+
+/* Constants */
+
+#define MAX_ASSOC_MSG_LENGTH                   512
+
+#define ASSOC_SM_CAP_ESS_MODE                  0x0001
+#define ASSOC_SM_CAP_IBSS_MODE                 0x0002
+#define ASSOC_SM_CAP_CF_POLLABLE               0x0004
+#define ASSOC_SM_CAP_CF_POLL_REQ               0x0008
+#define ASSOC_SM_CAP_PIVACY                            0x0010
+#define ASSOC_SM_CAP_SHORT_PREAMBLE            0x0020
+#define ASSOC_SM_CAP_PBCC                              0x0040
+#define ASSOC_SM_CAP_CH_AGILITY                        0x0080
+
+/* Enumerations */
+
+/* state machine states */
+typedef enum 
+{
+       ASSOC_SM_STATE_IDLE             = 0,
+       ASSOC_SM_STATE_WAIT     = 1,
+       ASSOC_SM_STATE_ASSOC    = 2
+} assoc_smStates_t;
+
+/* State machine inputs */
+typedef enum 
+{
+       ASSOC_SM_EVENT_START            = 0,
+       ASSOC_SM_EVENT_STOP                     = 1,
+       ASSOC_SM_EVENT_SUCCESS          = 2,
+    ASSOC_SM_EVENT_FAIL                        = 3,
+       ASSOC_SM_EVENT_TIMEOUT          = 4,
+       ASSOC_SM_EVENT_MAX_RETRY        = 5
+} assoc_smEvents_t;
+
+
+
+/* Typedefs */
+
+typedef struct
+{
+       fsm_stateMachine_t              *pAssocSm;
+       UINT32                                  timeout;
+       UINT8                                   currentState;
+       UINT32                                  maxCount;
+       UINT8                                   retryCount;
+       UINT32                                  assocRejectCount;
+       UINT32                                  assocTimeoutCount;
+       char                                    *pChalange;
+    UINT8                       assocRespBuffer[MAX_ASSOC_MSG_LENGTH];
+    UINT32                      assocRespLen;
+    UINT8                       assocReqBuffer[MAX_ASSOC_MSG_LENGTH];
+    UINT32                      assocReqLen;
+
+       BOOL                                            reAssoc;
+       BOOL                                            disAssoc; /* When set dissasociation frame will be sent. */
+
+       TI_HANDLE                               timer;
+       TI_HANDLE                               hMlme;
+       TI_HANDLE                               hSiteMgr;
+       TI_HANDLE                               hCtrlData;
+       TI_HANDLE                               hTxData;
+       TI_HANDLE                               hHalCtrl;
+       TI_HANDLE                               hRsn;
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hOs;
+       TI_HANDLE                                       hRegulatoryDomain;
+       TI_HANDLE                               hExcMngr;
+       TI_HANDLE                               hQosMngr;
+    TI_HANDLE                          hMeasurementMgr;
+       TI_HANDLE                               hApConn;
+} assoc_t;
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS assoc_start(TI_HANDLE hAssoc);
+
+TI_STATUS reassoc_start(TI_HANDLE hAssoc);
+
+TI_STATUS assoc_stop(TI_HANDLE hAssoc);
+
+TI_STATUS assoc_recv(TI_HANDLE hAssoc, mlmeFrameInfo_t *pFrame);
+
+TI_STATUS assoc_setDisAssocFlag(TI_HANDLE hAssoc, BOOL disAsoccFlag);
+
+TI_STATUS assoc_smCapBuild(assoc_t *pCtx, UINT16 *cap);
+
+
+/* local functions */
+
+TI_STATUS assoc_saveAssocRespMessage(assoc_t *pAssocSm, UINT8 *pAssocBuffer, UINT32 length);
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Assoc/assocSM.c b/sta_dk_4_0_4_32/common/src/core/mlme/Assoc/assocSM.c
new file mode 100644 (file)
index 0000000..48acd72
--- /dev/null
@@ -0,0 +1,1752 @@
+/** \file assocSM.c
+ *  \brief 802.11 association SM source
+ *
+ *  \see assocSM.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: assocSM.c                                                                                                  */
+/*    PURPOSE: 802.11 association SM source                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+
+#include "DataCtrl_Api.h"
+#include "siteMgrApi.h"
+#include "rsnApi.h"
+#include "regulatoryDomainApi.h"
+
+#include "mlmeBuilder.h"
+
+#include "mlmeApi.h"
+
+#include "AssocSM.h"
+#include "qosMngr_API.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "excRMMngr.h"
+#include "excMngr.h"
+#endif
+#include "apConn.h"
+
+/* Constants */
+
+/** number of states in the state machine */
+#define        ASSOC_SM_NUM_STATES             3
+
+/** number of events in the state machine */
+#define        ASSOC_SM_NUM_EVENTS             6
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+
+/* functions */
+
+
+/* state machine functions */
+
+
+TI_STATUS assoc_smEvent(assoc_t *pAssoc, UINT8 event, void *pData);
+
+void assoc_smTimeout(TI_HANDLE hAssoc);
+
+TI_STATUS assoc_smStartIdle(assoc_t *pAssoc);
+TI_STATUS assoc_smStopWait(assoc_t *pAssoc);
+TI_STATUS assoc_smSuccessWait(assoc_t *pAssoc);
+TI_STATUS assoc_smFailureWait(assoc_t *pAssoc);
+TI_STATUS assoc_smTimeoutWait(assoc_t *pAssoc);
+TI_STATUS assoc_smMaxRetryWait(assoc_t *pAssoc);
+TI_STATUS assoc_smStopAssoc(assoc_t *pAssoc);
+TI_STATUS assoc_smActionUnexpected(assoc_t *pAssoc);
+
+TI_STATUS assoc_smResetRetry(assoc_t *pAssoc);
+TI_STATUS assoc_smIncRetry(assoc_t *pAssoc);
+TI_STATUS assoc_smReportSuccess(assoc_t *pAssoc);
+TI_STATUS assoc_smReportFailure(assoc_t *pAssoc, UINT16 uStatusCode);
+TI_STATUS assoc_smSendAssocReq(assoc_t *pAssoc);
+TI_STATUS assoc_smStartTimer(assoc_t *pAssoc);
+TI_STATUS assoc_smStopTimer(assoc_t *pAssoc);
+
+TI_STATUS assoc_smCapBuild(assoc_t *pCtx, UINT16 *cap);
+TI_STATUS assoc_smSSIDBuild(assoc_t *pCtx, UINT8 *pSSID, UINT32 *ssidLen);
+TI_STATUS assoc_smRatesBuild(assoc_t *pCtx, UINT8 *pRates, UINT32 *ratesLen);
+TI_STATUS assoc_smRequestBuild(assoc_t *pCtx, UINT8* reqBuf, UINT32* reqLen);
+#ifdef SUPPORT_4X
+TI_STATUS assoc_4xBuild(assoc_t *pCtx, UINT8 *fourX, UINT32 *fourXLen);
+#endif
+
+TI_STATUS assoc_saveAssocReqMessage(assoc_t *pAssocSm, UINT8 *pAssocBuffer, UINT32 length);
+TI_STATUS assoc_sendDisAssoc(assoc_t *pAssocSm, mgmtStatus_e reason);
+
+/**
+*
+* assoc_create - allocate memory for association SM
+*
+* \b Description: 
+*
+* Allocate memory for association SM. \n
+*              Allocates memory for Association context. \n
+*              Allocates memory for association timer. \n
+*              Allocates memory for association SM matrix. \n
+*
+* \b ARGS:
+*
+*  I   - hOs - OS context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecSmKeysOnlyStop()
+*/
+TI_HANDLE assoc_create(TI_HANDLE hOs)
+{
+       assoc_t         *pHandle;
+       TI_STATUS               status;
+
+       /* allocate association context memory */
+       pHandle = (assoc_t*)os_memoryAlloc(hOs, sizeof(assoc_t));
+       if (pHandle == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pHandle, sizeof(assoc_t));
+
+       pHandle->hOs = hOs;
+
+       /* allocate memory for association state machine */
+       status = fsm_Create(hOs, &pHandle->pAssocSm, ASSOC_SM_NUM_STATES, ASSOC_SM_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pHandle, sizeof(assoc_t));
+               return NULL;
+       }
+
+       /* allocate OS timer memory */
+       pHandle->timer = os_timerCreate(hOs, assoc_smTimeout, pHandle);
+       if (pHandle->timer == NULL)
+       {
+               fsm_Unload(hOs, pHandle->pAssocSm);
+               os_memoryFree(hOs, pHandle, sizeof(assoc_t));           
+               return NULL;
+       }
+
+       return pHandle;
+}
+
+
+/**
+*
+* assocunload - unload association SM from memory
+*
+* \b Description: 
+*
+* Unload association SM from memory
+*
+* \b ARGS:
+*
+*  I   - hAssoc - association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecSmKeysOnlyStop()
+*/
+TI_STATUS assoc_unload(TI_HANDLE hAssoc)
+{
+    TI_STATUS          status;
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       status = fsm_Unload(pHandle->hOs, pHandle->pAssocSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pHandle->hReport, ASSOC_MODULE_LOG,
+                                 ("ASSOC_SM: Error releasing FSM memory \n"));
+       }
+       
+       os_timerDestroy(pHandle->hOs, pHandle->timer);
+       
+       os_memoryFree(pHandle->hOs, hAssoc, sizeof(assoc_t));
+
+       return OK;
+}
+
+/**
+*
+* assoc_config - configure a new association SM
+*
+* \b Description: 
+*
+* Configure a new association SM.
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*  I   - hMlme - MLME SM context  \n
+*  I   - hSiteMgr - Site manager context  \n
+*  I   - hCtrlData - Control data context  \n
+*  I   - hTxData - TX data context  \n
+*  I   - hHalCtrl - Hal control context  \n
+*  I   - hReport - Report context  \n
+*  I   - hOs - OS context  \n
+*  I   - assocTimeout - Association SM timeout \n
+*  I   - assocMaxCount - Max number of association requests to send  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Create, assoc_Unload
+*/
+TI_STATUS assoc_config(TI_HANDLE hAssoc,
+                                       TI_HANDLE hMlme,
+                                       TI_HANDLE hRegulatoryDomain,
+                                       TI_HANDLE hSiteMgr,
+                                       TI_HANDLE hCtrlData,
+                                       TI_HANDLE hTxData,
+                                       TI_HANDLE hHalCtrl,
+                                       TI_HANDLE hRsn,
+                                       TI_HANDLE hReport,
+                                       TI_HANDLE hOs,
+                                       TI_HANDLE hExcMngr,
+                                       TI_HANDLE hQosMngr,
+                                       TI_HANDLE hMeasurementMgr,
+                                       TI_HANDLE hApConn,
+                                       assocInitParams_t       *pAssocInitParams)
+{
+       assoc_t         *pHandle;
+       TI_STATUS               status;
+       /** Main 802.1X State Machine matrix */
+       fsm_actionCell_t        assoc_smMatrix[ASSOC_SM_NUM_STATES][ASSOC_SM_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {{ASSOC_SM_STATE_WAIT, (fsm_Action_t)assoc_smStartIdle},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smActionUnexpected}
+               },
+               /* next state and actions for WAIT state */
+               {{ASSOC_SM_STATE_WAIT, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smStopWait},
+                {ASSOC_SM_STATE_ASSOC, (fsm_Action_t)assoc_smSuccessWait},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smFailureWait},
+                {ASSOC_SM_STATE_WAIT, (fsm_Action_t)assoc_smTimeoutWait},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smMaxRetryWait}
+               },
+               /* next state and actions for ASSOC state */
+               {{ASSOC_SM_STATE_ASSOC, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_IDLE, (fsm_Action_t)assoc_smStopAssoc},
+                {ASSOC_SM_STATE_ASSOC, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_ASSOC, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_ASSOC, (fsm_Action_t)assoc_smActionUnexpected},
+                {ASSOC_SM_STATE_ASSOC, (fsm_Action_t)assoc_smActionUnexpected}
+               }};
+       
+
+       if (hAssoc == NULL)
+       {
+               return NOK;
+       }
+
+       pHandle = (assoc_t*)hAssoc;
+       
+       /* configure state machine */
+       status = fsm_Config(pHandle->pAssocSm, &assoc_smMatrix[0][0], 
+                                               ASSOC_SM_NUM_STATES, ASSOC_SM_NUM_EVENTS, NULL, hOs);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       pHandle->assocRejectCount = 0;
+       pHandle->assocTimeoutCount = 0;
+
+       pHandle->currentState = ASSOC_SM_STATE_IDLE;
+       
+       pHandle->hMlme = hMlme;
+       pHandle->hRegulatoryDomain = hRegulatoryDomain;
+       pHandle->hSiteMgr = hSiteMgr;
+       pHandle->hCtrlData = hCtrlData;
+       pHandle->hTxData = hTxData;
+       pHandle->hHalCtrl = hHalCtrl;
+       pHandle->hRsn = hRsn;
+       pHandle->hReport = hReport;
+       pHandle->hOs = hOs;
+       pHandle->hExcMngr = hExcMngr;
+       pHandle->hQosMngr = hQosMngr;
+    pHandle->hMeasurementMgr = hMeasurementMgr;
+       pHandle->hApConn = hApConn;
+
+       pHandle->timeout = pAssocInitParams->assocResponseTimeout;
+       pHandle->maxCount = pAssocInitParams->assocMaxRetryCount;
+
+       return OK;
+}
+
+
+/**
+*
+* assoc_start - Start event for the association SM
+*
+* \b Description: 
+*
+* Start event for the association SM
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Stop, assoc_Recv
+*/
+TI_STATUS assoc_start(TI_HANDLE hAssoc)
+{
+       TI_STATUS               status;
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       if (pHandle == NULL)
+       {
+               return NOK;
+       }
+
+       pHandle->reAssoc = FALSE;
+
+       pHandle->disAssoc = FALSE;
+
+       status = assoc_smEvent(pHandle, ASSOC_SM_EVENT_START, hAssoc);
+
+       return status;
+}
+
+
+/**
+*
+* assoc_start - Start event for the association SM
+*
+* \b Description: 
+*
+* Start event for the association SM - for Re-assoc request 
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Stop, assoc_Recv
+*/
+TI_STATUS reassoc_start(TI_HANDLE hAssoc)
+{
+       TI_STATUS               status;
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       if (pHandle == NULL)
+       {
+               return NOK;
+       }
+       pHandle->reAssoc = TRUE;
+
+       status = assoc_smEvent(pHandle, ASSOC_SM_EVENT_START, hAssoc);
+
+       return status;
+}
+
+/**
+*
+* assoc_stop - Stop event for the association SM
+*
+* \b Description: 
+*
+* Stop event for the association SM
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Start, assoc_Recv
+*/
+TI_STATUS assoc_stop(TI_HANDLE hAssoc)
+{
+       TI_STATUS               status;
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       if (pHandle == NULL)
+       {
+               return NOK;
+       }
+       
+       status = assoc_smEvent(pHandle, ASSOC_SM_EVENT_STOP, hAssoc);
+       
+       return status;
+}
+
+
+TI_STATUS assoc_setDisAssocFlag(TI_HANDLE hAssoc, BOOL disAsoccFlag)
+{
+       assoc_t         *pHandle;
+       pHandle = (assoc_t*)hAssoc;     
+
+       pHandle->disAssoc = disAsoccFlag;
+
+       return OK;
+}
+
+
+
+/**
+*
+* assoc_recv - Recive a message from the AP
+*
+* \b Description: 
+*
+* Parse a message form the AP and perform the appropriate event.
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*  I   - pFrame - Frame recieved  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Start, assoc_Stop
+*/
+TI_STATUS assoc_recv(TI_HANDLE hAssoc, mlmeFrameInfo_t *pFrame)
+{
+       TI_STATUS               status;
+       assoc_t                 *pHandle;
+       whalParamInfo_t         whalParam;
+       UINT16                  rspStatus;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       /* ensure that the SM is waiting for assoc response */
+       if(pHandle->currentState != ASSOC_SM_STATE_WAIT)
+               return OK;
+
+       if (pHandle == NULL)
+       {
+               return NOK;
+       }
+       
+       if ((pFrame->subType != ASSOC_RESPONSE) && (pFrame->subType != RE_ASSOC_RESPONSE))
+       {
+               return NOK;
+       }
+
+    /* check response status */
+       rspStatus  = pFrame->content.assocRsp.status;
+       
+       if (rspStatus == 0)
+       {
+               rsnData_t       rsnData;
+        dot11_RSN_t *pRsnIe;
+        UINT8       curRsnData[255];
+        UINT8       rsnAssocIeLen;
+        UINT16      length=0;
+
+
+        WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                 ("ASSOC_SM: DEBUG Success associating to AP \n"));
+               
+               /* set AID to HAL */
+               whalParam.paramType = HAL_CTRL_AID_PARAM;
+               whalParam.content.halCtrlAid  = pFrame->content.assocRsp.aid;
+               whalCtrl_SetParam(pHandle->hHalCtrl, &whalParam);
+        
+
+        /* Get the RSN IE data */
+        pRsnIe = pFrame->content.assocRsp.pRsnIe;
+        while ((length < pFrame->content.assocRsp.rsnIeLen) && (pFrame->content.assocRsp.rsnIeLen < 255))
+        {
+            if ((pRsnIe->hdr.eleLen + length + 2) > 255) { /* Dm: Security fix */
+                WLAN_REPORT_ERROR(pHandle->hReport, ASSOC_MODULE_LOG, 
+                                  ("%s - Security Error: %u > 255\n", __FUNCTION__,(pRsnIe->hdr.eleLen + length + 2)));
+                break;
+            }
+            curRsnData[0+length] = pRsnIe->hdr.eleId;
+            curRsnData[1+length] = pRsnIe->hdr.eleLen;
+            os_memoryCopy(pHandle->hOs, &curRsnData[2+length], (void *)pRsnIe->rsnIeData, pRsnIe->hdr.eleLen); 
+            length += pRsnIe->hdr.eleLen+2;
+            pRsnIe += 1;
+        }
+        
+               if (pFrame->content.assocRsp.rsnIeLen != 0)
+               {
+                       rsnData.pIe = curRsnData;
+                       rsnData.ieLen = pFrame->content.assocRsp.rsnIeLen;
+                       rsnData.privacy =  ((pFrame->content.assocRsp.capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TRUE : FALSE;
+                       rsn_setSite(pHandle->hRsn, &rsnData, NULL, &rsnAssocIeLen);
+               }
+
+               /* update siteMgr with capabilities and whether we are connected to Cisco AP */
+               siteMgr_assocReport(pHandle->hSiteMgr,
+                                                       pFrame->content.assocRsp.capabilities, pFrame->content.assocRsp.ciscoIEPresent);
+
+               /* update 4x info element */
+               ctrlData_setSite(pHandle->hCtrlData, pFrame->content.assocRsp.fourXParams);
+
+        /* update QoS Manager - it the QOS active protocol is NONE, or no WME IE present, it will return OK */
+               /* if configured by AP, update MSDU lifetime */
+        status = qosMngr_setSite(pHandle->hQosMngr, &pFrame->content.assocRsp);
+
+        if(status != OK)
+        {
+                       WLAN_REPORT_ERROR(pHandle->hReport, ASSOC_MODULE_LOG,
+                                         ("ASSOC_SM: DEBUG - Association failed : qosMngr_setSite error \n"));
+                       /* in case we wanted to work with qosAP and failed to connect to qos AP we want to reassociated again 
+                          to another one */  
+                       status = assoc_smEvent(pHandle, ASSOC_SM_EVENT_FAIL, hAssoc);
+        }
+               else
+               {
+                       status = assoc_smEvent(pHandle, ASSOC_SM_EVENT_SUCCESS, hAssoc);
+               }
+       } 
+       else 
+       {
+               pHandle->assocRejectCount++;
+               
+               /* If there was attempt to renegotiate voice settings, update QoS Manager */
+               qosMngr_checkTspecRenegResults(pHandle->hQosMngr, &pFrame->content.assocRsp);
+
+               /* check failure reason */
+               switch (rspStatus)
+               {
+               case 0:
+                       break;
+               case 1:
+                       /* print debug message */
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Unspecified error \n"));
+                       break;
+               case 10:
+                       /* print debug message */
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Cannot support all requested capabilities in the Capability Information field \n"));
+                       break;
+               case 11:
+                       /* print debug message */
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Reassociation denied due to inability to confirm that association exists \n"));
+                       break;
+               case 12:
+                       /* print debug message */
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Association denied due to reason outside the scope of this standard \n"));
+                       rsn_reportAuthFailure(pHandle->hRsn, RSN_AUTH_STATUS_INVALID_TYPE);
+            break;
+        case 13:
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Association denied due to wrong authentication algorithm \n"));
+                       rsn_reportAuthFailure(pHandle->hRsn, RSN_AUTH_STATUS_INVALID_TYPE);
+            break;
+               case 17:
+                       /* print debug message */
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Association denied because AP is unable to handle additional associated stations \n"));
+                       break;
+               case 18:
+                       /* print debug message */
+                       WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: DEBUG - Association denied: Association denied due to requesting station not supporting all of the data rates in the BSSBasicRateSet parameter \n"));
+                       break;
+               default:
+                       /* print error message on wrong error code for association response */
+                       WLAN_REPORT_ERROR(pHandle->hReport, ASSOC_MODULE_LOG,
+                                                         ("ASSOC_SM: ERROR - Association denied: error code (%d) irrelevant \n", rspStatus));
+                       break;
+               }
+
+               status = assoc_smEvent(pHandle, ASSOC_SM_EVENT_FAIL, hAssoc);
+       }
+
+       return status;
+}
+
+/**
+*
+* assoc_getParam - Get a specific parameter from the association SM
+*
+* \b Description: 
+*
+* Get a specific parameter from the association SM.
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Start, assoc_Stop
+*/
+TI_STATUS assoc_getParam(TI_HANDLE hAssoc, paramInfo_t *pParam)
+{
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       if ((pHandle == NULL) || (pParam == NULL))
+       {
+               return NOK;
+       }
+
+       /* serch parameter type */
+       switch (pParam->paramType)
+       {
+       case ASSOC_RESPONSE_TIMEOUT_PARAM:
+               pParam->content.assocResponseTimeout = pHandle->timeout;
+               break;
+
+       case ASSOC_COUNTERS_PARAM:
+               pParam->content.siteMgrTiWlanCounters.AssocRejects = pHandle->assocRejectCount;
+               pParam->content.siteMgrTiWlanCounters.AssocTimeouts = pHandle->assocTimeoutCount;
+               break;
+
+       case ASSOC_ASSOCIATION_RESP_PARAM:
+               pParam->content.applicationConfigBuffer.buffer = pHandle->assocRespBuffer;
+               pParam->content.applicationConfigBuffer.bufferSize = pHandle->assocRespLen;
+               break;
+
+    case ASSOC_ASSOCIATION_INFORMATION_PARAM:
+       {
+           UINT8  reqBuffIEOffset, respBuffIEOffset;
+           UINT32 RequestIELength = 0;
+           UINT32 ResponseIELength = 0;
+                  paramInfo_t  param;
+
+                  WLAN_REPORT_SM(pHandle->hReport, ASSOC_MODULE_LOG,
+                              ("ASSOC_SM: DEBUG - Association Information Get:  \n"));
+
+                  /* Assoc exists only in Infrastructure */
+                  param.paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;
+                  ctrlData_getParam(pHandle->hCtrlData, &param);
+                  if (param.content.ctrlDataCurrentBssType != BSS_INFRASTRUCTURE)
+                  {
+                          WLAN_REPORT_ERROR(pHandle->hReport, ASSOC_MODULE_LOG, 
+                                                                        ("Not in Infrastructure BSS, No ASSOC Info for GET ASSOC_ASSOCIATION_INFORMATION_PARAM\n"));
+                          return NOK;
+                  }
+
+           /* Init the result buffer to 0 */
+           os_memoryZero(pHandle->hOs ,&pParam->content, sizeof(OS_802_11_ASSOCIATION_INFORMATION));
+
+           reqBuffIEOffset  = 4;  /* In Assoc request frame IEs are located from byte 4 */
+           respBuffIEOffset = 6;  /* In Assoc response frame the IEs are located from byte 6 */
+
+            /* If the last associate was re-associciation, the current AP MAC address */
+            /* is placed before the IEs. Copy it to the result parameters.            */
+            if (pHandle->reAssoc)
+           {
+                os_memoryCopy(pHandle->hOs,
+                              (void *)pParam->content.assocAssociationInformation.RequestFixedIEs.CurrentAPAddress,
+                              &pHandle->assocReqBuffer[reqBuffIEOffset], MAC_ADDR_LEN);
+                reqBuffIEOffset += MAC_ADDR_LEN;
+            }
+
+            /* Calculate length of Info elements in assoc request and response frames */
+            if(pHandle->assocReqLen > reqBuffIEOffset)
+                RequestIELength = pHandle->assocReqLen - reqBuffIEOffset;
+
+            if(pHandle->assocRespLen > respBuffIEOffset)
+                ResponseIELength = pHandle->assocRespLen - respBuffIEOffset;
+
+            /* Copy the association request information */
+            pParam->content.assocAssociationInformation.Length = sizeof(OS_802_11_ASSOCIATION_INFORMATION);
+            pParam->content.assocAssociationInformation.AvailableRequestFixedIEs = OS_802_11_AI_REQFI_CAPABILITIES | OS_802_11_AI_REQFI_LISTENINTERVAL;
+            pParam->content.assocAssociationInformation.RequestFixedIEs.Capabilities = *(UINT16*)&(pHandle->assocReqBuffer[0]);
+            pParam->content.assocAssociationInformation.RequestFixedIEs.ListenInterval = *(UINT16*)(&pHandle->assocReqBuffer[2]);
+
+            pParam->content.assocAssociationInformation.RequestIELength = RequestIELength; 
+            pParam->content.assocAssociationInformation.OffsetRequestIEs = 0;
+            if (RequestIELength > 0)
+            {
+                pParam->content.assocAssociationInformation.OffsetRequestIEs = (UINT32)&pHandle->assocReqBuffer[reqBuffIEOffset];
+            }
+            /* Copy the association response information */
+            pParam->content.assocAssociationInformation.AvailableResponseFixedIEs = 
+                OS_802_11_AI_RESFI_CAPABILITIES | OS_802_11_AI_RESFI_STATUSCODE | OS_802_11_AI_RESFI_ASSOCIATIONID;
+            pParam->content.assocAssociationInformation.ResponseFixedIEs.Capabilities = *(UINT16*)&(pHandle->assocRespBuffer[0]);
+            pParam->content.assocAssociationInformation.ResponseFixedIEs.StatusCode = *(UINT16*)&(pHandle->assocRespBuffer[2]);
+            pParam->content.assocAssociationInformation.ResponseFixedIEs.AssociationId = *(UINT16*)&(pHandle->assocRespBuffer[4]);
+            pParam->content.assocAssociationInformation.ResponseIELength = ResponseIELength;
+            pParam->content.assocAssociationInformation.OffsetResponseIEs = 0;
+            if (ResponseIELength > 0)
+            {
+                pParam->content.assocAssociationInformation.OffsetResponseIEs = (UINT32)&pHandle->assocRespBuffer[respBuffIEOffset];
+            }
+
+       }
+        break;
+       default:
+               return NOK;
+       }
+
+       return OK;
+}
+
+/**
+*
+* assoc_setParam - Set a specific parameter to the association SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the association SM.
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Start, assoc_Stop
+*/
+TI_STATUS assoc_setParam(TI_HANDLE hAssoc, paramInfo_t *pParam)
+{
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+       if ((pHandle == NULL) || (pParam == NULL))
+       {
+               return NOK;
+       }
+
+       switch (pParam->paramType)
+       {
+       case ASSOC_RESPONSE_TIMEOUT_PARAM:
+               /* check bounds */
+               if ((pParam->content.assocResponseTimeout >= ASSOC_RESPONSE_TIMEOUT_MIN) &&
+                       (pParam->content.assocResponseTimeout <= ASSOC_RESPONSE_TIMEOUT_MAX))
+               {
+                       pHandle->timeout = pParam->content.assocResponseTimeout;
+               } else {
+                       return NOK;
+               }
+               break;
+       default:
+               return NOK;
+       }
+
+       return OK;
+}
+
+/**
+*
+* assoc_smTimeout - Time out event activation function
+*
+* \b Description: 
+*
+* Time out event activation function.
+*
+* \b ARGS:
+*
+*  I   - hAssoc - Association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa assoc_Start, assoc_Stop
+*/
+void assoc_smTimeout(TI_HANDLE hAssoc)
+{
+       assoc_t         *pHandle;
+
+       pHandle = (assoc_t*)hAssoc;
+
+
+       if (pHandle == NULL)
+       {
+               return;
+       }
+       
+       pHandle->assocTimeoutCount++;
+
+       assoc_smEvent(pHandle, ASSOC_SM_EVENT_TIMEOUT, hAssoc);
+}
+
+/**
+*
+* assoc_smEvent - Perform an event on the association SM
+*
+* \b Description: 
+*
+* Perform an event on the association SM.
+*
+* \b ARGS:
+*
+*  I   - pAssoc - Association SM context  \n
+*  I   - event - Current event \n
+*  I   - pData - event related data
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+
+#ifdef REPORT_LOG
+
+static char *assocSMStateDesc[ASSOC_SM_NUM_STATES] = { 
+               "ASSOC_SM_STATE_IDLE",
+               "ASSOC_SM_STATE_WAIT",
+               "ASSOC_SM_STATE_ASSOC",
+       };
+       
+/* State machine inputs */
+static char *assocSMEventDesc[ASSOC_SM_NUM_EVENTS] = {
+               "ASSOC_SM_EVENT_START",
+               "ASSOC_SM_EVENT_STOP",
+               "ASSOC_SM_EVENT_SUCCESS",
+               "ASSOC_SM_EVENT_FAILURE",
+               "ASSOC_SM_EVENT_TIME_OUT",
+               "ASSOC_SM_EVENT_MAX_RETRY"
+       };
+
+#endif
+
+TI_STATUS assoc_smEvent(assoc_t *pAssoc, UINT8 event, void *pData)
+{
+       TI_STATUS               status;
+       UINT8           nextState;
+
+       status = fsm_GetNextState(pAssoc->pAssocSm, pAssoc->currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pAssoc->hReport, ASSOC_MODULE_LOG,
+                                                 ("ASSOC_SM: ERROR - failed getting next state \n"));
+
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pAssoc->hReport, ASSOC_MODULE_LOG,
+                                        ("ASSOC_SM: <%s, %s> --> %s\n",
+                                         assocSMStateDesc[pAssoc->currentState],
+                                         assocSMEventDesc[event],
+                                         assocSMStateDesc[nextState]));
+
+       status = fsm_Event(pAssoc->pAssocSm, &pAssoc->currentState, event, pData);
+
+       return(status);
+}
+
+/* state machine functions */
+
+TI_STATUS assoc_smStartIdle(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       status = assoc_smResetRetry(pAssoc);
+       status = assoc_smSendAssocReq(pAssoc);
+       status = assoc_smStartTimer(pAssoc);
+       status = assoc_smIncRetry(pAssoc);
+
+       return status;
+}
+
+TI_STATUS assoc_smStopWait(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       status = assoc_smStopTimer(pAssoc);
+
+       return status;
+}
+
+TI_STATUS assoc_smSuccessWait(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       status = assoc_smStopTimer(pAssoc);
+       status = assoc_smReportSuccess(pAssoc);
+
+       return status;
+}
+
+TI_STATUS assoc_smFailureWait(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+       UINT16                  uRspStatus = *(UINT16*)&(pAssoc->assocRespBuffer[2]);
+
+       status = assoc_smStopTimer(pAssoc);
+
+       /* Sanity check. If the Response status is indeed not 0 */
+       if (uRspStatus) 
+       {
+               status = assoc_smReportFailure(pAssoc, uRspStatus);
+       }
+       else    /* (uRspStatus == 0) how did we get here ? */ 
+       {
+               WLAN_REPORT_ERROR(pAssoc->hReport, ASSOC_MODULE_LOG,
+                       ("%s while Response status is OK (0) !!! \n"));
+
+               status = assoc_smReportFailure(pAssoc, (UINT16)NOK);
+       }
+       return status;
+}
+
+TI_STATUS assoc_smTimeoutWait(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       status = assoc_smSendAssocReq(pAssoc);
+       status = assoc_smStartTimer(pAssoc);
+       status = assoc_smIncRetry(pAssoc);
+
+       return status;
+}
+
+TI_STATUS assoc_smMaxRetryWait(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       status = assoc_smStopTimer(pAssoc);
+       status = assoc_smReportFailure(pAssoc, STATUS_PACKET_REJ_TIMEOUT);
+
+       return status;
+}
+
+TI_STATUS assoc_smSendAssocReq(assoc_t *pAssoc)
+{
+       UINT8                           assocMsg[MAX_ASSOC_MSG_LENGTH];
+       UINT32                          msgLen;
+       TI_STATUS                       status;
+       dot11MgmtSubType_e      assocType=ASSOC_REQUEST;
+
+       if (pAssoc->reAssoc)
+       {
+               assocType = RE_ASSOC_REQUEST;
+       }
+       status = assoc_smRequestBuild(pAssoc, assocMsg, &msgLen);
+       if (status != OK)
+               return status;
+
+    /* Save the association request message */
+       assoc_saveAssocReqMessage(pAssoc, assocMsg, msgLen);
+       status = mlmeBuilder_sendFrame(pAssoc->hMlme, assocType, assocMsg, msgLen, 0);
+       
+       return status;
+}
+
+TI_STATUS assoc_smStopAssoc(assoc_t *pAssoc)
+{
+       if (pAssoc->disAssoc) {
+               assoc_sendDisAssoc(pAssoc, STATUS_UNSPECIFIED);
+       }
+       return OK;
+}
+
+TI_STATUS assoc_smActionUnexpected(assoc_t *pAssoc)
+{
+       return OK;
+}
+
+/* local functions */
+
+
+TI_STATUS assoc_smResetRetry(assoc_t *pAssoc)
+{
+       if (pAssoc == NULL)
+       {
+               return NOK;
+       }
+       
+       pAssoc->retryCount = 0;
+       
+       return OK;
+}
+
+TI_STATUS assoc_smIncRetry(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       if (pAssoc == NULL)
+       {
+               return NOK;
+       }
+       
+       pAssoc->retryCount++;
+       
+       if (pAssoc->retryCount > pAssoc->maxCount)
+       {
+               status = assoc_smEvent(pAssoc, ASSOC_SM_EVENT_MAX_RETRY, pAssoc);
+
+               return status;
+       }
+
+       return OK;
+}
+
+TI_STATUS assoc_smReportSuccess(assoc_t *pAssoc)
+{
+       TI_STATUS               status;
+
+       if (pAssoc == NULL)
+       {
+               return NOK;
+       }
+       status = mlme_reportAssocStatus(pAssoc->hMlme, (UINT16)OK);
+
+       return status;
+}
+
+TI_STATUS assoc_smReportFailure(assoc_t *pAssoc, UINT16 uStatusCode)
+{
+       TI_STATUS               status;
+
+       if (pAssoc == NULL)
+       {
+               return NOK;
+       }
+       
+       status = mlme_reportAssocStatus(pAssoc->hMlme, uStatusCode);
+
+       return status;
+}
+
+TI_STATUS assoc_smStartTimer(assoc_t *pAssoc)
+{
+       if (pAssoc == NULL)
+       {
+               return NOK;
+       }
+       
+       os_timerStart(pAssoc->hOs, pAssoc->timer, pAssoc->timeout, FALSE);
+
+       return OK;
+}
+
+TI_STATUS assoc_smStopTimer(assoc_t *pAssoc)
+{
+       if (pAssoc == NULL)
+       {
+               return NOK;
+       }
+       
+       os_timerStop(pAssoc->hOs, pAssoc->timer);
+
+       return OK;
+}
+
+/*****************************************************************************
+**
+** Association messages builder/Parser
+**
+*****************************************************************************/
+
+TI_STATUS assoc_smCapBuild(assoc_t *pCtx, UINT16 *cap)
+{
+       paramInfo_t                     param;
+       TI_STATUS                       status;
+    dot11mode_e         mode;
+       UINT32                          rateSuppMask, rateBasicMask;
+       UINT8                           ratesBuf[MAX_SUPPORTED_RATES];
+       UINT32                          len = 0, ofdmIndex = 0;
+
+       *cap = 0;
+
+       /* Bss type */
+    param.paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;
+       status =  ctrlData_getParam(pCtx->hCtrlData, &param);
+       if (status == OK)
+       {
+               if (param.content.ctrlDataCurrentBssType == BSS_INFRASTRUCTURE)
+               {
+                       *cap |= DOT11_CAPS_ESS;
+               } else {
+                       *cap |= DOT11_CAPS_IBSS;
+               }
+       } else {
+               return NOK;
+       }
+
+       /* Privacy */
+    param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
+       status =  rsn_getParam(pCtx->hRsn, &param);
+       if (status == OK)
+       {
+               if (param.content.rsnEncryptionStatus != RSN_CIPHER_NONE)
+               {
+                       *cap |= DOT11_CAPS_PRIVACY;
+               }
+       } else {
+               return NOK;
+       }
+
+       /* Preamble */
+    param.paramType = SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM;
+       status =  siteMgr_getParam(pCtx->hSiteMgr, &param);
+       if (status == OK)
+       {
+               if (param.content.siteMgrCurrentPreambleType == PREAMBLE_SHORT)
+                       *cap |= DOT11_CAPS_SHORT_PREAMBLE;
+       } else {
+               return NOK;
+       }
+
+       /* Pbcc */
+    param.paramType = SITE_MGR_CURRENT_RATE_PAIR_PARAM;
+       status =  siteMgr_getParam(pCtx->hSiteMgr, &param);
+       if (status == OK)
+       {
+               if(param.content.siteMgrCurrentRateMask.supportedRateMask & DRV_RATE_MASK_22_PBCC)
+                       *cap |= DOT11_CAPS_PBCC;
+       } else {
+               return NOK;
+       }
+
+       
+       /* Checking if the station supports Spectrum Management (802.11h) */
+       param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+       status =  regulatoryDomain_getParam(pCtx->hRegulatoryDomain, &param);
+       if (status == OK )
+       {
+               if( param.content.spectrumManagementEnabled)
+                       *cap |= DOT11_SPECTRUM_MANAGEMENT;
+       } 
+       else
+       {
+               return NOK;
+       }
+       
+       /* slot time */
+    param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
+    status = siteMgr_getParam(pCtx->hSiteMgr, &param);
+    if(status == OK)
+    {
+        mode = param.content.siteMgrDot11OperationalMode;
+    }
+    else
+        return NOK;
+
+    if(mode == DOT11_G_MODE)
+    {
+               /* new requirement: the short slot time should be set only
+                  if the AP's modulation is OFDM (highest rate) */
+               
+               /* get Rates */
+               param.paramType = SITE_MGR_CURRENT_RATE_PAIR_PARAM;
+               status =  siteMgr_getParam(pCtx->hSiteMgr, &param);
+               if (status == OK)
+               {
+                       rateBasicMask = param.content.siteMgrCurrentRateMask.basicRateMask;
+                       rateSuppMask  = param.content.siteMgrCurrentRateMask.supportedRateMask;
+               } else {
+                       return NOK;
+               }
+               
+               /* convert the bit map to the rates array */
+               bitMapToNetworkStringRates(rateSuppMask, rateBasicMask,
+                                                                  ratesBuf, &len, &ofdmIndex);
+
+               if(ofdmIndex < len)
+                       *cap |= DOT11_CAPS_SHORT_SLOT_TIME;
+
+/*             
+               param.paramType = SITE_MGR_CURRENT_MODULATION_TYPE_PARAM;
+               status = siteMgr_getParam(pCtx->hSiteMgr, &param);
+               if(param.content.siteMgrCurrentModulationType == DRV_MODULATION_OFDM)
+                       *cap |= DOT11_CAPS_SHORT_SLOT_TIME;
+*/
+    }
+
+    /* Qos Support - (is WME on?)*/
+    param.paramType = QOS_MNGR_ACTIVE_PROTOCOL;
+    status = qosMngr_getParams(pCtx->hQosMngr, &param);
+    if (status == OK)
+    {
+      if (param.content.qosSiteProtocol !=  NONE_QOS)
+      {
+         // *cap |= DOT11_CAPS_QOS_SUPPORTED;  /* deleted due to MCS00035798 */
+      }
+    }
+    else 
+      {
+            return NOK;
+         }
+
+       return OK;
+}
+
+#ifdef SUPPORT_4X
+TI_STATUS assoc_4xBuild(assoc_t *pCtx, UINT8 *fourX, UINT32 *fourXLen)
+{
+
+       TI_STATUS               status;
+       dot11_4X_t              *pDot11_4X;
+       paramInfo_t             param;
+       BOOL                    sts, fourXen;
+
+       pDot11_4X = (dot11_4X_t*)fourX;
+
+       param.paramType = SITE_MGR_4X_PARAM;
+       sts = siteMgr_getParam(pCtx->hSiteMgr, &param);
+       fourXen = param.content.siteMgrFourxParam;
+       if(sts != OK || fourXen == FALSE)
+       {
+               pDot11_4X->hdr.eleId = 0;
+               pDot11_4X->hdr.eleLen = 0;
+               *fourXLen = 0;
+               return OK;
+       }
+
+       status = ctrlData_get4xInfoElemnt(pCtx->hCtrlData, pDot11_4X);
+       if(status != OK)
+       {
+               pDot11_4X->hdr.eleId = 0;
+               pDot11_4X->hdr.eleLen = 0;
+               *fourXLen = 0;
+               return OK;
+       }
+
+       *fourXLen = pDot11_4X->hdr.eleLen + sizeof(dot11_eleHdr_t);
+       
+       return OK;
+}
+#endif
+TI_STATUS assoc_smSSIDBuild(assoc_t *pCtx, UINT8 *pSSID, UINT32 *ssidLen)
+{
+       paramInfo_t                     param;
+       TI_STATUS                               status;
+       dot11_SSID_t            *pDot11Ssid;
+
+       pDot11Ssid = (dot11_SSID_t*)pSSID;
+       /* set SSID element id */
+       pDot11Ssid->hdr.eleId = SSID_IE_ID;
+
+       /* get SSID */
+    param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+       status =  siteMgr_getParam(pCtx->hSiteMgr, &param);
+       if (status != OK)
+       {
+               return status;
+    }
+    
+    /* check for ANY ssid */
+    if (param.content.siteMgrDesiredSSID.len != 0)
+    {
+        pDot11Ssid->hdr.eleLen = param.content.siteMgrDesiredSSID.len;
+        os_memoryCopy(pCtx->hOs, 
+                      (void *)pDot11Ssid->serviceSetId, 
+                      (void *)param.content.siteMgrDesiredSSID.ssidString, 
+                      param.content.siteMgrDesiredSSID.len);
+
+    } else {
+        /* if ANY ssid is configured, use the current SSID */
+        param.paramType = SITE_MGR_CURRENT_SSID_PARAM;
+        status =  siteMgr_getParam(pCtx->hSiteMgr, &param);
+        if (status != OK)
+        {
+            return status;
+        }
+        pDot11Ssid->hdr.eleLen = param.content.siteMgrCurrentSSID.len;
+        os_memoryCopy(pCtx->hOs, 
+                      (void *)pDot11Ssid->serviceSetId, 
+                      (void *)param.content.siteMgrCurrentSSID.ssidString, 
+                      param.content.siteMgrCurrentSSID.len);
+
+    }
+
+       *ssidLen = pDot11Ssid->hdr.eleLen + sizeof(dot11_eleHdr_t);
+       
+       return OK;
+}
+
+TI_STATUS assoc_smRatesBuild(assoc_t *pCtx, UINT8 *pRates, UINT32 *ratesLen)
+{
+       paramInfo_t                     param;
+       TI_STATUS                       status;
+       UINT32                          rateSuppMask, rateBasicMask;
+       dot11_RATES_t           *pDot11Rates;
+       UINT32                          len = 0, ofdmIndex = 0;
+       UINT8                           ratesBuf[MAX_SUPPORTED_RATES];
+       BOOL                            useESRie;
+       dot11mode_e                     mode;
+       UINT32                          suppRatesLen, extSuppRatesLen, i;
+       pDot11Rates = (dot11_RATES_t*)pRates;
+
+
+       /* get Rates */
+    param.paramType = SITE_MGR_CURRENT_RATE_PAIR_PARAM;
+       status =  siteMgr_getParam(pCtx->hSiteMgr, &param);
+       if (status == OK)
+       {
+               rateBasicMask = param.content.siteMgrCurrentRateMask.basicRateMask;
+               rateSuppMask  = param.content.siteMgrCurrentRateMask.supportedRateMask;
+       } else {
+               return NOK;
+       }
+
+       /* get operational mode */
+       param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
+       status = siteMgr_getParam(pCtx->hSiteMgr, &param);
+       if(status == OK)
+               mode = param.content.siteMgrDot11OperationalMode;
+       else
+               return NOK;
+
+       /* get param indicating whether the ESR IE should be used */
+       param.paramType = SITE_MGR_USE_DRAFT_NUM_PARAM;
+       status = siteMgr_getParam(pCtx->hSiteMgr, &param);
+       if(status == OK)
+       {
+               if(param.content.siteMgrUseDraftNum == DRAFT_6_AND_LATER)
+                       useESRie = TRUE;
+               else
+                       useESRie = FALSE;
+       }
+       else
+               return NOK;
+
+       /* convert the bit map to the rates array */
+       bitMapToNetworkStringRates(rateSuppMask, rateBasicMask,
+                                                          ratesBuf, &len, &ofdmIndex);
+
+       if(mode != DOT11_G_MODE || ofdmIndex == len || useESRie == FALSE)
+       {
+               pDot11Rates->hdr.eleId = SUPPORTED_RATES_IE_ID;
+               pDot11Rates->hdr.eleLen = len;
+               os_memoryCopy(NULL, (void *)pDot11Rates->rates, ratesBuf, len);
+               *ratesLen = pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+       }
+       else 
+       {
+               /* fill in the supported rates */
+               pDot11Rates->hdr.eleId = SUPPORTED_RATES_IE_ID;
+               pDot11Rates->hdr.eleLen = ofdmIndex;
+               os_memoryCopy(NULL, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr.eleLen);
+               suppRatesLen = pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               /* fill in the extended supported rates */
+               pDot11Rates = (dot11_RATES_t*)(pRates + suppRatesLen);
+               pDot11Rates->hdr.eleId = EXT_SUPPORTED_RATES_IE_ID;
+               pDot11Rates->hdr.eleLen = len - ofdmIndex;
+               os_memoryCopy(NULL, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr.eleLen);
+               extSuppRatesLen = pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               *ratesLen = suppRatesLen + extSuppRatesLen;
+       }
+
+       WLAN_REPORT_INFORMATION(pCtx->hReport, ASSOC_MODULE_LOG,
+                                                       ("ASSOC_SM: ASSOC_REQ - bitmapSupp= 0x%X,bitMapBasic = 0x%X, len = %d\n",                                                  
+                                                       rateSuppMask,rateBasicMask,len));
+       for(i=0; i<len; i++)
+       {
+               WLAN_REPORT_INFORMATION(pCtx->hReport, ASSOC_MODULE_LOG,("ASSOC_SM: ASSOC_REQ - ratesBuf[%d] = 0x%X\n",                                                   
+                                                               i, ratesBuf[i]));
+       }
+
+       return OK;
+}
+
+TI_STATUS assoc_powerCapabilityBuild(assoc_t *pCtx, UINT8 *pPowerCapability, UINT32 *powerCapabilityLen)
+{
+       paramInfo_t                     param;
+       TI_STATUS                               status;
+       dot11_CAPABILITY_t              *pDot11PowerCapability;
+
+       pDot11PowerCapability = (dot11_CAPABILITY_t*)pPowerCapability;
+       
+       /* set Power Capability element id */
+       pDot11PowerCapability->hdr.eleId = DOT11_CAPABILITY_ELE_ID;
+       pDot11PowerCapability->hdr.eleLen = DOT11_CAPABILITY_ELE_LEN;
+
+       /* get power capability */
+    param.paramType = REGULATORY_DOMAIN_POWER_CAPABILITY_PARAM;
+       status =  regulatoryDomain_getParam(pCtx->hRegulatoryDomain, &param);
+
+       if (status == OK)
+       {
+               pDot11PowerCapability->minTxPower = param.content.powerCapability.minTxPower;
+               pDot11PowerCapability->maxTxPower = param.content.powerCapability.maxTxPower;
+               *powerCapabilityLen = pDot11PowerCapability->hdr.eleLen + sizeof(dot11_eleHdr_t);
+       }
+       else
+               *powerCapabilityLen = 0;
+
+       return OK;
+}
+#if 0
+       /* Supported Channels IE is not required */
+
+TI_STATUS assoc_supportedChannelBuild(assoc_t *pCtx, UINT8 *pSupportedChannels, UINT32 *supportedChannelsLen)
+{
+       paramInfo_t                                             param;
+       TI_STATUS                                               status;
+       dot11_CHANNEL_SUPPORTED_t               *pDot11SupportedChannels;
+
+       pDot11SupportedChannels = (dot11_CHANNEL_SUPPORTED_t*)pSupportedChannels;
+       
+       /* set Supported Channels element id */
+       pDot11SupportedChannels->hdr.eleId = DOT11_CHANNEL_SUPPORTED_ELE_ID;
+       pDot11SupportedChannels->hdr.eleLen = 0;
+
+    /* get Num of Supported Channels */
+    param.paramType = REGULATORY_DOMAIN_SUPPORTED_CHANNEL_PAIRS_NUM_PARAM;
+       status =  regulatoryDomain_getParam(pCtx->hRegulatoryDomain, &param);
+
+    if(status == OK)
+    {
+        pDot11SupportedChannels->hdr.eleLen = param.content.numOfSupportedChannelPairs * 2;
+
+       /* get Supported Channels */
+    param.paramType = REGULATORY_DOMAIN_SUPPORTED_CHANNEL_PARAM;
+       status =  regulatoryDomain_getParam(pCtx->hRegulatoryDomain, &param);
+
+       if (status == OK)
+       {
+            
+            os_memoryCopy(pCtx->hOs,&(pDot11SupportedChannels->supportedChannel[0]),param.content.pSupportedChannel,pDot11SupportedChannels->hdr.eleLen * sizeof(UINT8));
+               *supportedChannelsLen = pDot11SupportedChannels->hdr.eleLen + sizeof(dot11_eleHdr_t);
+       }
+       else
+               *supportedChannelsLen = 0;
+    }
+    else
+        *supportedChannelsLen = 0;
+
+       return OK;
+}
+#endif
+
+
+TI_STATUS assoc_smRequestBuild(assoc_t *pCtx, UINT8* reqBuf, UINT32* reqLen)
+{
+       TI_STATUS               status;
+       UINT8                   *pRequest;
+       UINT32                  len;
+       paramInfo_t             param;
+    whalParamInfo_t whalParam;
+       UINT16                  capabilities;
+       
+       pRequest = reqBuf;
+       *reqLen = 0;
+
+       /* insert capabilities */
+       status = assoc_smCapBuild(pCtx, &capabilities);
+       if (status == OK)
+       {
+               *(UINT16*)pRequest = ENDIAN_HANDLE_WORD(capabilities);
+       }
+       else
+               return NOK;
+
+       pRequest += 2;
+       *reqLen += 2;
+
+       /* insert listen interval */
+    whalParam.paramType = HAL_CTRL_LISTEN_INTERVAL_PARAM;
+       status =  whalCtrl_GetParam(pCtx->hHalCtrl, &whalParam);
+       if (status == OK)
+       {
+               *(UINT16*)pRequest = ENDIAN_HANDLE_WORD((UINT16)whalParam.content.halCtrlListenInterval);
+       } else {
+               return NOK;
+       }
+       
+       pRequest += 2;
+       *reqLen += 2;
+       if (pCtx->reAssoc)
+       {       /* Insert currentAPAddress element only in reassoc request*/
+               param.paramType = SITE_MGR_PREV_SITE_BSSID_PARAM;
+               status = siteMgr_getParam(pCtx->hSiteMgr, &param);
+               if (status == OK)
+               {
+                       os_memoryCopy(pCtx->hOs, pRequest, (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN);
+                       WLAN_REPORT_INFORMATION(pCtx->hReport, ASSOC_MODULE_LOG,
+                                                                       ("ASSOC_SM: ASSOC_REQ - prev AP = %x-%x-%x-%x-%x-%x\n",                                            
+                                                                       param.content.siteMgrDesiredBSSID.addr[0], param.content.siteMgrDesiredBSSID.addr[1],
+                                                                       param.content.siteMgrDesiredBSSID.addr[2], param.content.siteMgrDesiredBSSID.addr[3],
+                                                                       param.content.siteMgrDesiredBSSID.addr[4], param.content.siteMgrDesiredBSSID.addr[5]));
+
+
+                       pRequest += MAC_ADDR_LEN;
+                       *reqLen += MAC_ADDR_LEN;
+               }
+               else
+               {
+                       WLAN_REPORT_ERROR(pCtx->hReport, ASSOC_MODULE_LOG,
+                                                                       ("ASSOC_SM: ASSOC_REQ - No prev AP \n"));
+                       return status;
+
+               }
+       }
+
+       /* insert SSID element */
+       status = assoc_smSSIDBuild(pCtx, pRequest, &len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       pRequest += len;
+       *reqLen += len;
+
+       /* insert Rates element */
+       status = assoc_smRatesBuild(pCtx, pRequest, &len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+
+       /* Checking if the station supports Spectrum Management (802.11h) */
+       param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+       status = regulatoryDomain_getParam(pCtx->hRegulatoryDomain,&param);
+       if( (status == OK) && param.content.spectrumManagementEnabled)
+       {
+               /* Checking the selected AP capablities */
+               param.paramType = SITE_MGR_SITE_CAPABILITY_PARAM;
+               status =  siteMgr_getParam(pCtx->hSiteMgr,&param);
+               if(status == OK && ((param.content.siteMgrSiteCapability & DOT11_SPECTRUM_MANAGEMENT) != 0)) 
+               {
+                       /* insert Power capability element */
+                       status = assoc_powerCapabilityBuild(pCtx, pRequest, &len);
+                       if (status != OK)
+                       {
+                               return NOK;
+                       }
+                       pRequest += len;
+                       *reqLen += len;
+#if 0
+                       /* insert Supported Channels element */
+                       status = assoc_supportedChannelBuild(pCtx, pRequest, &len);
+                       if (status != OK)
+                       {
+                               return NOK;
+                       }
+                       pRequest += len;
+                       *reqLen += len;
+#endif
+               }
+
+
+       }
+
+       status = qosMngr_getQosCapabiltyInfeElement(pCtx->hQosMngr,pRequest,(UINT8*)&len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+
+
+#ifdef EXC_MODULE_INCLUDED
+       status = rsn_getExcExtendedInfoElement(pCtx->hRsn, pRequest, (UINT8*)&len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+
+       if (pCtx->reAssoc)
+       {       /* insert CCKM information element only in reassoc */
+               status = excMngr_getCckmInfoElement(pCtx->hExcMngr, pRequest, (UINT8*)&len);
+               
+               if (status != OK)
+               {
+                       return NOK;
+               }
+               pRequest += len;
+               *reqLen += len;
+       }
+       status = excMngr_getEXCVersionInfoElement(pCtx->hExcMngr, pRequest, (UINT8*)&len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+
+    /* Insert Radio Mngt Capability IE */
+    status = measurementMgr_radioMngtCapabilityBuild(pCtx->hMeasurementMgr, pRequest, (UINT8*)&len);
+    if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+#endif
+
+#ifdef SUPPORT_4X
+       /* insert 4X element */
+       status = assoc_4xBuild(pCtx, pRequest, &len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+#endif
+
+    /* insert RSN information elements */
+    status = rsn_getInfoElement(pCtx->hRsn, pRequest, (UINT8*)&len);
+       
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+
+       status = qosMngr_assocReqBuild(pCtx->hQosMngr,pRequest,(UINT8*)&len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+
+       status = apConn_getVendorSpecificIE(pCtx->hApConn, pRequest, &len);
+       if (status != OK)
+       {
+               return NOK;
+       }
+       pRequest += len;
+       *reqLen += len;
+       if (*reqLen>=MAX_ASSOC_MSG_LENGTH)
+       {
+               return NOK;
+       }
+
+       return OK;
+}
+
+
+
+TI_STATUS assoc_saveAssocRespMessage(assoc_t *pAssocSm, UINT8 *pAssocBuffer, UINT32 length)
+{
+    if ((pAssocSm==NULL) || (pAssocBuffer==NULL) || (length>=MAX_ASSOC_MSG_LENGTH))
+    {
+        return NOK;
+    }
+    os_memoryCopy(pAssocSm->hOs, pAssocSm->assocRespBuffer, pAssocBuffer, length);  
+    pAssocSm->assocRespLen = length;
+    
+    WLAN_REPORT_INFORMATION(pAssocSm->hReport, ASSOC_MODULE_LOG,
+                      ("assoc_saveAssocRespMessage: length=%ld \n",length));
+    return OK;
+}
+
+TI_STATUS assoc_saveAssocReqMessage(assoc_t *pAssocSm, UINT8 *pAssocBuffer, UINT32 length)
+{
+
+    if ((pAssocSm==NULL) || (pAssocBuffer==NULL) || (length>=MAX_ASSOC_MSG_LENGTH))
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pAssocSm->hOs, pAssocSm->assocReqBuffer, pAssocBuffer, length);  
+    pAssocSm->assocReqLen = length;
+    
+    WLAN_REPORT_INFORMATION(pAssocSm->hReport, ASSOC_MODULE_LOG,
+                      ("assoc_saveAssocReqMessage: length=%ld \n",length));
+    return OK;
+}
+
+
+TI_STATUS assoc_sendDisAssoc(assoc_t *pAssocSm, mgmtStatus_e reason)
+{
+       TI_STATUS               status;
+       disAssoc_t              disAssoc;
+
+       if (reason == STATUS_SUCCESSFUL)
+       {
+               disAssoc.reason = ENDIAN_HANDLE_WORD(STATUS_UNSPECIFIED);
+       } else {
+               disAssoc.reason = ENDIAN_HANDLE_WORD(reason);
+       }
+
+       status = mlmeBuilder_sendFrame(pAssocSm->hMlme, DIS_ASSOC, (UINT8*)&disAssoc, sizeof(disAssoc_t), 0);
+
+       return status;
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Auth/authSm.c b/sta_dk_4_0_4_32/common/src/core/mlme/Auth/authSm.c
new file mode 100644 (file)
index 0000000..dda63e2
--- /dev/null
@@ -0,0 +1,634 @@
+/** \file authSM.c
+ *  \brief 802.11 authentication SM source
+ *
+ *  \see authSM.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: authSM.c                                                                                                   */
+/*    PURPOSE: 802.11 authentication SM source                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "mlmeApi.h"
+
+#include "mlmeBuilder.h"
+#include "authSm.h"
+#include "openAuthSm.h"
+#include "sharedKeyAuthSm.h"
+
+/* Constants */ 
+
+/** number of states in the state machine */
+#define        AUTH_SM_MAX_NUM_STATES          4
+
+/** number of events in the state machine */
+#define        AUTH_SM_MAX_NUM_EVENTS          8
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+
+/* functions */
+
+/**
+*
+* auth_create - allocate memory for authentication SM
+*
+* \b Description: 
+*
+* Allocate memory for authentication SM. \n
+*              Allocates memory for Association context. \n
+*              Allocates memory for authentication timer. \n
+*              Allocates memory for authentication SM matrix. \n
+*
+* \b ARGS:
+*
+*  I   - hOs - OS context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecSmKeysOnlyStop()
+*/
+TI_HANDLE auth_create(TI_HANDLE hOs)
+{
+       auth_t  *pHandle;
+       TI_STATUS               status;
+
+       /* allocate authentication context memory */
+       pHandle = (auth_t*)os_memoryAlloc(hOs, sizeof(auth_t));
+       if (pHandle == NULL)
+       {
+               return NULL;
+       }
+       
+       os_memoryZero(hOs, pHandle, sizeof(auth_t));
+
+       pHandle->hOs = hOs;
+    
+       /* allocate memory for authentication state machine */
+       status = fsm_Create(hOs, &pHandle->pAuthSm, AUTH_SM_MAX_NUM_STATES, AUTH_SM_MAX_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pHandle, sizeof(auth_t));
+               return NULL;
+       }
+
+       /* allocate OS timer memory */
+       pHandle->timer = os_timerCreate(hOs, auth_smTimeout, pHandle);
+       if (pHandle->timer == NULL)
+       {
+               fsm_Unload(hOs, pHandle->pAuthSm);
+               os_memoryFree(hOs, pHandle, sizeof(auth_t));            
+               return NULL;
+       }
+
+       return pHandle;
+}
+
+
+/**
+*
+* auth_unload - unload authentication SM from memory
+*
+* \b Description: 
+*
+* Unload authentication SM from memory
+*
+* \b ARGS:
+*
+*  I   - hAuth - Authentication SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecSmKeysOnlyStop()
+*/
+TI_STATUS auth_unload(TI_HANDLE hAuth)
+{
+    TI_STATUS          status;
+       auth_t          *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       status = fsm_Unload(pHandle->hOs, pHandle->pAuthSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pHandle->hReport, AUTH_MODULE_LOG,
+                                 ("AUTH_SM: Error releasing FSM memory \n"));
+       }
+       
+       os_timerDestroy(pHandle->hOs, pHandle->timer);
+       
+       os_memoryFree(pHandle->hOs, pHandle, sizeof(auth_t));
+
+       return OK;
+}
+
+/**
+*
+* auth_config - configure a new authentication SM
+*
+* \b Description: 
+*
+* Configure a new authentication SM.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Association SM context  \n
+*  I   - hMlme - MLME SM context  \n
+*  I   - hSiteMgr - Site manager context  \n
+*  I   - hCtrlData - Control data context  \n
+*  I   - hTxData - TX data context  \n
+*  I   - hHalCtrl - Hal control context  \n
+*  I   - hReport - Report context  \n
+*  I   - hOs - OS context  \n
+*  I   - authTimeout - Association SM timeout \n
+*  I   - authMaxCount - Max number of authentication requests to send  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Create, auth_Unload
+*/
+TI_STATUS auth_config(TI_HANDLE                hAuth,
+                                  TI_HANDLE            hMlme,
+                                  TI_HANDLE            hRsn,
+                                  TI_HANDLE            hReport,
+                                  TI_HANDLE            hOs,
+                                  authInitParams_t             *pAuthInitParams)
+{
+       auth_t          *pHandle;
+       
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+
+       pHandle = (auth_t*)hAuth;
+       
+       pHandle->hMlme = hMlme;
+       pHandle->hRsn = hRsn;
+       pHandle->hReport = hReport;
+       pHandle->hOs = hOs;
+
+       pHandle->timeout = pAuthInitParams->authResponseTimeout;
+       pHandle->maxCount = pAuthInitParams->authMaxRetryCount;
+       
+       pHandle->retryCount = 0;
+       pHandle->authRejectCount = 0;
+       pHandle->authTimeoutCount = 0;
+
+       pHandle->authType = AUTH_LEGACY_NONE;
+
+       return OK;
+}
+
+
+/**
+*
+* auth_start - Start event for the authentication SM
+*
+* \b Description: 
+*
+* Start event for the authentication SM
+*
+* \b ARGS:
+*
+*  I   - hAuth - Authentication SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Stop, auth_Recv
+*/
+TI_STATUS auth_start(TI_HANDLE hAuth)
+{
+       auth_t          *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       if (pHandle == NULL)
+               return NOK;
+
+       if (pHandle->authType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       switch (pHandle->authType)
+       {
+    case AUTH_LEGACY_RESERVED1: 
+       case AUTH_LEGACY_OPEN_SYSTEM:
+               return auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_START, pHandle);
+
+       case AUTH_LEGACY_SHARED_KEY:
+               return auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_START, pHandle);
+
+       default:
+               return NOK;
+       }
+}
+
+/**
+*
+* auth_stop - Stop event for the authentication SM
+*
+* \b Description: 
+*
+* Stop event for the authentication SM
+*
+* \b ARGS:
+*
+*  I   - hAuth - Authentication SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Start, auth_Recv
+*/
+TI_STATUS auth_stop(TI_HANDLE hAuth, BOOL sendDeAuth, mgmtStatus_e reason )
+{
+       auth_t          *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       if (pHandle == NULL)
+               return NOK;
+       
+       if (pHandle->authType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       if( sendDeAuth == TRUE )
+       {
+               deAuth_t        deAuth;
+               deAuth.reason = ENDIAN_HANDLE_WORD(reason);
+               mlmeBuilder_sendFrame(pHandle->hMlme, DE_AUTH, (UINT8*)&deAuth, sizeof(deAuth_t), 0);
+       }
+
+       switch (pHandle->authType)
+       {
+    case AUTH_LEGACY_RESERVED1:
+       case AUTH_LEGACY_OPEN_SYSTEM:
+               return auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_STOP, pHandle);
+
+       case AUTH_LEGACY_SHARED_KEY:
+               return auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_STOP, pHandle);
+
+       default:
+               return NOK;
+       }
+}
+
+/**
+*
+* auth_recv - Recive a message from the AP
+*
+* \b Description: 
+*
+* Parse a message form the AP and perform the appropriate event.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Authentication SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Start, auth_Stop
+*/
+TI_STATUS auth_recv(TI_HANDLE hAuth, mlmeFrameInfo_t *pFrame)
+{
+       auth_t                  *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       if (pHandle == NULL)
+               return NOK;
+       
+       if (pFrame->subType != AUTH)
+               return NOK;
+
+       if (pHandle->authType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       if (pFrame->content.auth.status != STATUS_SUCCESSFUL)
+               pHandle->authRejectCount++;
+
+       switch (pHandle->authType)
+       {
+       case AUTH_LEGACY_RESERVED1:
+       case AUTH_LEGACY_OPEN_SYSTEM:
+               return openAuth_Recv(hAuth, pFrame);
+
+       case AUTH_LEGACY_SHARED_KEY:
+               return sharedKeyAuth_Recv(hAuth, pFrame);
+
+       default:
+               return OK;
+       }
+}
+
+/**
+*
+* auth_getParam - Get a specific parameter from the authentication SM
+*
+* \b Description: 
+*
+* Get a specific parameter from the authentication SM.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Authentication SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Start, auth_Stop
+*/
+TI_STATUS auth_getParam(TI_HANDLE hAuth, paramInfo_t *pParam)
+{
+       auth_t          *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       if ((pHandle == NULL) || (pParam == NULL))
+       {
+               return NOK;
+       }
+
+       switch (pParam->paramType)
+       {
+       case AUTH_RESPONSE_TIMEOUT_PARAM:
+               pParam->content.authResponseTimeout = pHandle->timeout;
+               break;
+
+       case AUTH_COUNTERS_PARAM:
+               pParam->content.siteMgrTiWlanCounters.AuthRejects = pHandle->authRejectCount;
+               pParam->content.siteMgrTiWlanCounters.AuthTimeouts = pHandle->authTimeoutCount;
+               break;
+
+       case AUTH_LEGACY_TYPE_PARAM:
+               pParam->content.authLegacyAuthType = pHandle->authType;
+               break;
+
+       default:
+               return NOK;
+       }
+
+       return OK;
+}
+
+/**
+*
+* auth_setParam - Set a specific parameter to the authentication SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the authentication SM.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Authentication SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Start, auth_Stop
+*/
+TI_STATUS auth_setParam(TI_HANDLE hAuth, paramInfo_t *pParam)
+{
+       auth_t          *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       if ((pHandle == NULL) || (pParam == NULL))
+       {
+               return NOK;
+       }
+
+       switch (pParam->paramType)
+       {
+       case AUTH_LEGACY_TYPE_PARAM:
+               pHandle->authType = pParam->content.authLegacyAuthType;
+
+               switch (pHandle->authType)
+               {
+        case AUTH_LEGACY_RESERVED1:
+               case AUTH_LEGACY_OPEN_SYSTEM:
+                       openAuth_Config(hAuth, pHandle->hOs);
+                       break;
+
+               case AUTH_LEGACY_SHARED_KEY:
+                       sharedKeyAuth_Config(hAuth, pHandle->hOs);
+                       break;
+
+               default:
+                       return NOK;
+               }
+               break;
+
+       case AUTH_RESPONSE_TIMEOUT_PARAM:
+               if ((pParam->content.authResponseTimeout >= AUTH_RESPONSE_TIMEOUT_MIN) &&
+                       (pParam->content.authResponseTimeout <= AUTH_RESPONSE_TIMEOUT_MAX))
+               {
+                       pHandle->timeout = pParam->content.authResponseTimeout;
+               } 
+               else 
+               {
+                       return NOK;
+               }
+               break;
+
+       default:
+               return NOK;
+       }
+
+       return OK;
+}
+
+/**
+*
+* auth_smTimeout - Set a specific parameter to the authentication SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the authentication SM.
+*
+* \b ARGS:
+*
+*  I   - hAuth - authentication SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Start, auth_Stop
+*/
+void auth_smTimeout(TI_HANDLE hAuth)
+{
+       auth_t          *pHandle;
+
+       pHandle = (auth_t*)hAuth;
+
+       if (pHandle == NULL)
+               return;
+       
+       if (pHandle->authType == AUTH_LEGACY_NONE)
+               return;
+
+       pHandle->authTimeoutCount++;
+
+       switch (pHandle->authType)
+       {
+    case AUTH_LEGACY_RESERVED1:
+       case AUTH_LEGACY_OPEN_SYSTEM:
+               openAuth_Timeout(pHandle);
+               break;
+
+       case AUTH_LEGACY_SHARED_KEY:
+               sharedKey_Timeout(pHandle);
+               break;
+
+       default:
+               break;
+       }
+}
+
+/*****************************************************************************
+**
+** Authentication messages builder/Parser
+**
+*****************************************************************************/
+
+/**
+*
+* auth_smMsgBuild - Build an authentication message and send it to the mlme builder
+*
+* \b Description: 
+*
+* Build an authentication message and send it to the mlme builder.
+*
+* \b ARGS:
+*
+*  I   - pAssoc - Association SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa auth_Start, auth_Stop
+*/
+TI_STATUS auth_smMsgBuild(auth_t *pCtx, UINT16 seq, UINT16 statusCode, UINT8* pChallange, UINT8 challangeLen)
+{
+       TI_STATUS                               status;
+       UINT8                           len;
+       UINT8                           authMsg[MAX_AUTH_MSG_LEN];
+       authMsg_t                       *pAuthMsg;
+       dot11_CHALLENGE_t       *pDot11Challenge;
+       UINT8                           wepOpt;
+
+       wepOpt = 0;
+
+       pAuthMsg = (authMsg_t*)authMsg;
+       
+       /* insert algorithm */
+       pAuthMsg->authAlgo = ENDIAN_HANDLE_WORD((UINT16)pCtx->authType);
+
+       /* insert sequense */
+       pAuthMsg->seqNum = ENDIAN_HANDLE_WORD(seq);
+
+       /* insert status code */
+       pAuthMsg->status = ENDIAN_HANDLE_WORD(statusCode);
+
+       len = sizeof(authMsg_t) - sizeof(pAuthMsg->pChallenge);
+
+       if (pChallange != NULL)
+       {
+               pDot11Challenge = (dot11_CHALLENGE_t*)&authMsg[len];
+
+               pDot11Challenge->hdr.eleId = CHALLANGE_TEXT_IE_ID;
+               pDot11Challenge->hdr.eleLen = challangeLen;
+
+               os_memoryCopy(pCtx->hOs, (void *)pDot11Challenge->text, pChallange, challangeLen);
+               len += challangeLen + 2;
+
+               wepOpt = 1;
+       }
+
+       status =  mlmeBuilder_sendFrame(pCtx->hMlme, AUTH, authMsg, len, wepOpt);
+
+       return status;
+}
+
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Auth/authSm.h b/sta_dk_4_0_4_32/common/src/core/mlme/Auth/authSm.h
new file mode 100644 (file)
index 0000000..2b8d2ad
--- /dev/null
@@ -0,0 +1,115 @@
+/** \file assocSm.h
+ *  \brief 802.11 authentication SM
+ *
+ *  \see assocSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: assocSm.h                                                                                                  */
+/*    PURPOSE: 802.11 authentication SM                                                                           */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _AUTH_SM_H
+#define _AUTH_SM_H
+
+#include "fsm.h"
+#include "mlmeApi.h"
+
+/* Constants */
+
+#define AUTH_MSG_HEADER_LEN            6
+#define MAX_CHALLANGE_LEN              256
+#define MAX_AUTH_MSG_LEN               MAX_CHALLANGE_LEN + AUTH_MSG_HEADER_LEN
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct
+{
+       UINT16                          status;
+       char                            *pChalange;
+       UINT8                           challangeLen;
+} authData_t;
+
+typedef struct
+{
+       legacyAuthType_e        authType;
+       fsm_stateMachine_t      *pAuthSm;
+       UINT8                           currentState;
+       UINT32                          maxCount;
+       UINT8                           retryCount;
+       UINT32                          authRejectCount;
+       UINT32                          authTimeoutCount;
+       UINT32                          timeout;
+    authData_t          authData;
+       TI_HANDLE                       timer;
+       TI_HANDLE                       hMlme;
+       TI_HANDLE                       hRsn;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hOs;
+} auth_t;
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS auth_start(TI_HANDLE hAuth);
+
+TI_STATUS auth_stop(TI_HANDLE hpAuth, BOOL sendDeAuth, mgmtStatus_e reason );
+
+TI_STATUS auth_recv(TI_HANDLE hAuth, mlmeFrameInfo_t *pFrame);
+
+void auth_smTimeout(TI_HANDLE hAssoc);
+
+TI_STATUS auth_smMsgBuild(auth_t *pCtx, 
+                                          UINT16 seq, 
+                                          UINT16 statusCode, 
+                                          UINT8* pChallange, 
+                                          UINT8 challangeLen);
+
+/* local functions */
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Auth/open/openAuthSm.c b/sta_dk_4_0_4_32/common/src/core/mlme/Auth/open/openAuthSm.c
new file mode 100644 (file)
index 0000000..d568263
--- /dev/null
@@ -0,0 +1,447 @@
+/** \file authSM.c
+ *  \brief 802.11 authentication SM source
+ *
+ *  \see authSM.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: authSM.c                                                                                                   */
+/*    PURPOSE: 802.11 authentication SM source                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "mlmeApi.h"
+#include "../authSm.h"
+#include "openAuthSm.h"
+#include "rsnApi.h"
+
+/* Constants */
+
+/** number of states in the state machine */
+#define        OPEN_AUTH_SM_NUM_STATES         3
+
+/** number of events in the state machine */
+#define        OPEN_AUTH_SM_NUM_EVENTS         6
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+
+/* functions */
+
+/**
+*
+* openAuth_smConfig - configure a new authentication SM
+*
+* \b Description: 
+*
+* Configure a new authentication SM.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Association SM context  \n
+*  I   - hMlme - MLME SM context  \n
+*  I   - hSiteMgr - Site manager context  \n
+*  I   - hCtrlData - Control data context  \n
+*  I   - hTxData - TX data context  \n
+*  I   - hHalCtrl - Hal control context  \n
+*  I   - hReport - Report context  \n
+*  I   - hOs - OS context  \n
+*  I   - authTimeout - Association SM timeout \n
+*  I   - authMaxCount - Max number of authentication requests to send  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa openAuth_Create, openAuth_Unload
+*/
+TI_STATUS openAuth_Config(TI_HANDLE hAuth, TI_HANDLE hOs)
+{
+       auth_t          *pHandle;
+       TI_STATUS               status;
+       /** Main 802.1X State Machine matrix */
+       fsm_actionCell_t        openAuth_smMatrix[OPEN_AUTH_SM_NUM_STATES][OPEN_AUTH_SM_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {{OPEN_AUTH_SM_STATE_WAIT, (fsm_Action_t)openAuth_smStartIdle},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smActionUnexpected}
+               },
+               /* next state and actions for WAIT state */
+               {{OPEN_AUTH_SM_STATE_WAIT, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smStopWait},
+                {OPEN_AUTH_SM_STATE_AUTH, (fsm_Action_t)openAuth_smSuccessWait},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smFailureWait},
+                {OPEN_AUTH_SM_STATE_WAIT, (fsm_Action_t)openAuth_smTimeoutWait},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smMaxRetryWait}
+               },
+               /* next state and actions for AUTH state */
+               {{OPEN_AUTH_SM_STATE_AUTH, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_IDLE, (fsm_Action_t)openAuth_smStopAuth},
+                {OPEN_AUTH_SM_STATE_AUTH, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_AUTH, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_AUTH, (fsm_Action_t)openAuth_smActionUnexpected},
+                {OPEN_AUTH_SM_STATE_AUTH, (fsm_Action_t)openAuth_smActionUnexpected}
+               }};
+       
+
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+
+       pHandle = (auth_t*)hAuth;
+       
+       status = fsm_Config(pHandle->pAuthSm, &openAuth_smMatrix[0][0], 
+                                               OPEN_AUTH_SM_NUM_STATES, OPEN_AUTH_SM_NUM_EVENTS, auth_osSMEvent, hOs);
+       if (status != OK)
+       { 
+               return NOK;
+       }
+
+       pHandle->currentState = OPEN_AUTH_SM_STATE_IDLE;
+       
+       return OK;
+}
+
+
+#ifdef REPORT_LOG
+
+static char *stateDesc[OPEN_AUTH_SM_NUM_STATES] = 
+       {
+               "OPEN_AUTH_SM_STATE_IDLE",
+               "OPEN_AUTH_SM_STATE_WAIT",
+               "OPEN_AUTH_SM_STATE_AUTH",
+       };
+
+static char *eventDesc[OPEN_AUTH_SM_NUM_EVENTS] = 
+       {
+               "OPEN_AUTH_SM_EVENT_START",
+               "OPEN_AUTH_SM_EVENT_STOP",
+               "OPEN_AUTH_SM_EVENT_SUCCESS",
+               "OPEN_AUTH_SM_EVENT_FAIL",
+               "OPEN_AUTH_SM_EVENT_TIMEOUT",
+               "OPEN_AUTH_SM_EVENT_MAX_RETRY",
+       };
+
+#endif
+
+
+TI_STATUS auth_osSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hAuth)
+{
+   auth_t *pAuth = (auth_t *)hAuth;
+       TI_STATUS               status;
+       UINT8           nextState;
+
+       status = fsm_GetNextState(pAuth->pAuthSm, *currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_SM(pAuth->hReport, AUTH_MODULE_LOG, ("State machine error, failed getting next state\n"));
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pAuth->hReport, AUTH_MODULE_LOG, 
+                                                         ("<%s, %s> --> %s\n\n",
+                                                          stateDesc[*currentState],
+                                                          eventDesc[event],
+                                                          stateDesc[nextState]));
+
+       status = fsm_Event(pAuth->pAuthSm, currentState, event, (void *)pAuth);
+
+       return status;
+}
+
+/**
+*
+* openAuth_Recv - Recive a message from the AP
+*
+* \b Description: 
+*
+* Parse a message form the AP and perform the appropriate event.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa openAuth_Start, openAuth_Stop
+*/
+TI_STATUS openAuth_Recv(TI_HANDLE hAuth, mlmeFrameInfo_t *pFrame)
+{ 
+       TI_STATUS                       status;
+       auth_t                  *pHandle;
+       UINT16                  authAlgo;
+
+       pHandle = (auth_t*)hAuth;
+
+       if (pHandle == NULL)
+       {
+               return NOK;
+       }
+       
+       /* check response status */
+       authAlgo = pFrame->content.auth.authAlgo;
+       if ((authAlgo != AUTH_LEGACY_OPEN_SYSTEM) &&
+        (authAlgo != AUTH_LEGACY_RESERVED1))
+       {
+               WLAN_REPORT_SM(pHandle->hReport, AUTH_MODULE_LOG,
+                                 ("OPEN_AUTH_SM: DEBUG recieved authentication message with wrong algorithm \n"));
+        rsn_reportAuthFailure(pHandle->hRsn, RSN_AUTH_STATUS_INVALID_TYPE);
+        return NOK;
+       }
+    
+    if ((pHandle->authType==AUTH_LEGACY_RESERVED1) && (authAlgo !=AUTH_LEGACY_RESERVED1))
+    {
+        rsn_reportAuthFailure(pHandle->hRsn, RSN_AUTH_STATUS_INVALID_TYPE);
+    }
+    WLAN_REPORT_SM(pHandle->hReport, AUTH_MODULE_LOG,
+              ("OPEN_AUTH_SM: DEBUG Authentication status is %d \n", pFrame->content.auth.status));
+
+       pHandle->authData.status = pFrame->content.auth.status;
+
+    if (pHandle->authData.status == STATUS_SUCCESSFUL)
+    {
+        status = auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_SUCCESS, pHandle);
+    } else {
+               rsn_reportAuthFailure(pHandle->hRsn, RSN_AUTH_STATUS_INVALID_TYPE);
+               status = auth_osSMEvent(&pHandle->currentState, OPEN_AUTH_SM_EVENT_FAIL, pHandle);
+    }
+
+       return status;
+}
+
+/* state machine functions */
+
+TI_STATUS openAuth_smStartIdle(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = openAuth_smResetRetry(hAuth);
+       status = openAuth_smSendAuthReq(hAuth);
+       status = openAuth_smStartTimer(hAuth);
+       status = openAuth_smIncRetry(hAuth);
+
+       return status;
+}
+
+TI_STATUS openAuth_smStopWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = openAuth_smStopTimer(hAuth);
+
+       return status;
+}
+TI_STATUS openAuth_smSuccessWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = openAuth_smStopTimer(hAuth);
+       status = openAuth_smReportSuccess(hAuth);
+
+       return status;
+}
+TI_STATUS openAuth_smFailureWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = openAuth_smStopTimer(hAuth);
+       status = openAuth_smReportFailure(hAuth);
+
+       return status;
+}
+
+TI_STATUS openAuth_smTimeoutWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = openAuth_smSendAuthReq(hAuth);
+       status = openAuth_smStartTimer(hAuth);
+       status = openAuth_smIncRetry(hAuth);
+
+       return status;
+}
+
+TI_STATUS openAuth_smMaxRetryWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+    rsn_reportAuthFailure(hAuth->hRsn, RSN_AUTH_STATUS_TIMEOUT);
+       status = openAuth_smReportFailure(hAuth);
+
+       return status;
+}
+
+TI_STATUS openAuth_smSendAuthReq(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = auth_smMsgBuild(hAuth, 1, 0, NULL, 0);
+
+       return status;
+}
+
+TI_STATUS openAuth_smStopAuth(auth_t *hAuth)
+{
+       return OK;
+}
+
+TI_STATUS openAuth_smActionUnexpected(auth_t *hAuth)
+{
+       return OK;
+}
+
+/* local functions */
+
+
+TI_STATUS openAuth_smResetRetry(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       hAuth->retryCount = 0;
+       
+       return OK;
+}
+
+TI_STATUS openAuth_smIncRetry(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       hAuth->retryCount++;
+       
+       return OK;
+}
+
+TI_STATUS openAuth_smReportSuccess(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+    status = mlme_reportAuthStatus(hAuth->hMlme, hAuth->authData.status);
+
+       return status;
+}
+
+TI_STATUS openAuth_smReportFailure(auth_t *hAuth)
+{
+       TI_STATUS               status;
+    
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+
+    status = mlme_reportAuthStatus(hAuth->hMlme, hAuth->authData.status);
+
+       return status;
+}
+
+TI_STATUS openAuth_smStartTimer(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       os_timerStart(hAuth->hOs, hAuth->timer, hAuth->timeout, FALSE);
+
+       return OK;
+}                        
+
+TI_STATUS openAuth_smStopTimer(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       os_timerStop(hAuth->hOs, hAuth->timer);
+
+       return OK;
+}
+
+TI_STATUS openAuth_Timeout(auth_t *pAuth)
+{
+       if (pAuth->retryCount >= pAuth->maxCount)
+       {
+               pAuth->authData.status = STATUS_PACKET_REJ_TIMEOUT;
+               return auth_osSMEvent(&pAuth->currentState, OPEN_AUTH_SM_EVENT_MAX_RETRY, pAuth);
+       }
+
+       return auth_osSMEvent(&pAuth->currentState, OPEN_AUTH_SM_EVENT_TIMEOUT, pAuth);
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Auth/open/openAuthSm.h b/sta_dk_4_0_4_32/common/src/core/mlme/Auth/open/openAuthSm.h
new file mode 100644 (file)
index 0000000..1abf375
--- /dev/null
@@ -0,0 +1,118 @@
+/** \file assocSm.h
+ *  \brief 802.11 authentication SM
+ *
+ *  \see assocSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: assocSm.h                                                                                                  */
+/*    PURPOSE: 802.11 authentication SM                                                                           */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _OPEN_AUTH_SM_H
+#define _OPEN_AUTH_SM_H
+
+#include "fsm.h"
+#include "mlmeApi.h"
+#include "../authSm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* state machine states */
+typedef enum 
+{
+       OPEN_AUTH_SM_STATE_IDLE         = 0,
+       OPEN_AUTH_SM_STATE_WAIT         = 1,
+       OPEN_AUTH_SM_STATE_AUTH         = 2
+} openAuth_smStates_t;
+
+/* State machine inputs */
+typedef enum 
+{
+       OPEN_AUTH_SM_EVENT_START                = 0,
+       OPEN_AUTH_SM_EVENT_STOP                 = 1,
+       OPEN_AUTH_SM_EVENT_SUCCESS      = 2,
+       OPEN_AUTH_SM_EVENT_FAIL                 = 3,
+       OPEN_AUTH_SM_EVENT_TIMEOUT              = 4,
+       OPEN_AUTH_SM_EVENT_MAX_RETRY    = 5
+} openAuth_smEvents_t;
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS openAuth_Config(TI_HANDLE    hAuth,
+                                          TI_HANDLE    pOs);
+
+TI_STATUS openAuth_Recv(TI_HANDLE pAssoc, mlmeFrameInfo_t *pFrame);
+
+TI_STATUS openAuth_Timeout(auth_t *pAuth);
+
+TI_STATUS auth_osSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hAuth);
+
+/* state machine functions */
+
+TI_STATUS openAuth_smStartIdle(auth_t *hAuth);
+TI_STATUS openAuth_smStopWait(auth_t *hAuth);
+TI_STATUS openAuth_smSuccessWait(auth_t *hAuth);
+TI_STATUS openAuth_smFailureWait(auth_t *hAuth);
+TI_STATUS openAuth_smTimeoutWait(auth_t *hAuth);
+TI_STATUS openAuth_smMaxRetryWait(auth_t *hAuth);
+TI_STATUS openAuth_smStopAuth(auth_t *hAuth);
+TI_STATUS openAuth_smActionUnexpected(auth_t *hAuth);
+
+TI_STATUS openAuth_smResetRetry(auth_t *hAuth);
+TI_STATUS openAuth_smIncRetry(auth_t *hAuth);
+TI_STATUS openAuth_smReportSuccess(auth_t *hAuth);
+TI_STATUS openAuth_smReportFailure(auth_t *hAuth);
+TI_STATUS openAuth_smSendAuthReq(auth_t *hAuth);
+TI_STATUS openAuth_smStartTimer(auth_t *hAuth);
+TI_STATUS openAuth_smStopTimer(auth_t *hAuth);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Auth/shared/sharedKeyAuthSm.c b/sta_dk_4_0_4_32/common/src/core/mlme/Auth/shared/sharedKeyAuthSm.c
new file mode 100644 (file)
index 0000000..bc33de7
--- /dev/null
@@ -0,0 +1,563 @@
+/** \file sharedKeyAuthSm.c
+ *  \brief shared key 802.11 authentication SM source
+ *
+ *  \see sharedKeyAuthSm.h 
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: sharedKeyAuthSm.c                                                                                  */
+/*    PURPOSE: shared key 802.11 authentication SM source                                 */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "mlmeApi.h"
+#include "../authSm.h"
+#include "sharedKeyAuthSm.h"
+
+/* Constants */
+
+/** number of states in the state machine */
+#define        SHARED_KEY_AUTH_SM_NUM_STATES           4
+
+/** number of events in the state machine */
+#define        SHARED_KEY_AUTH_SM_NUM_EVENTS           8
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+
+/* functions */
+
+/**
+*
+* sharedKeyAuth_smConfig - configure a new authentication SM
+*
+* \b Description: 
+*
+* Configure a new authentication SM.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Association SM context  \n
+*  I   - hMlme - MLME SM context  \n
+*  I   - hSiteMgr - Site manager context  \n
+*  I   - hCtrlData - Control data context  \n
+*  I   - hTxData - TX data context  \n
+*  I   - hHalCtrl - Hal control context  \n
+*  I   - hReport - Report context  \n
+*  I   - hOs - OS context  \n
+*  I   - authTimeout - Association SM timeout \n
+*  I   - authMaxCount - Max number of authentication requests to send  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa sharedKeyAuth_Create, sharedKeyAuth_Unload
+*/
+TI_STATUS sharedKeyAuth_Config(TI_HANDLE hAuth, TI_HANDLE hOs)
+{
+       auth_t          *pHandle;
+       TI_STATUS               status;
+       /** Main 802.1X State Machine matrix */
+       fsm_actionCell_t        sharedKeyAuth_smMatrix[SHARED_KEY_AUTH_SM_NUM_STATES][SHARED_KEY_AUTH_SM_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {{SHARED_KEY_AUTH_SM_STATE_WAIT_1, (fsm_Action_t)sharedKeyAuth_smStartIdle},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smActionUnexpected}
+               },
+               /* next state and actions for WAIT_1 state */
+               {{SHARED_KEY_AUTH_SM_STATE_WAIT_1, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smStopWait},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_2, (fsm_Action_t)sharedKeyAuth_smSuccess1Wait1},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smFailure1Wait1},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_1, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_1, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_1, (fsm_Action_t)sharedKeyAuth_smTimeoutWait1},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smMaxRetryWait}
+               },
+               /* next state and actions for WAIT_2 state */
+               {{SHARED_KEY_AUTH_SM_STATE_WAIT_2, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smStopWait},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_2, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_2, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smSuccess2Wait2},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smFailure2Wait2},
+                {SHARED_KEY_AUTH_SM_STATE_WAIT_2, (fsm_Action_t)sharedKeyAuth_smTimeoutWait2},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smMaxRetryWait}
+               },
+               /* next state and actions for AUTH state */
+               {{SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_IDLE, (fsm_Action_t)sharedKeyAuth_smStopAuth},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected},
+                {SHARED_KEY_AUTH_SM_STATE_AUTH, (fsm_Action_t)sharedKeyAuth_smActionUnexpected}
+               }};
+       
+
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+
+       pHandle = (auth_t*)hAuth;
+       
+       status = fsm_Config(pHandle->pAuthSm, &sharedKeyAuth_smMatrix[0][0], 
+                                               SHARED_KEY_AUTH_SM_NUM_STATES, SHARED_KEY_AUTH_SM_NUM_EVENTS, auth_skSMEvent, hOs);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       pHandle->currentState = SHARED_KEY_AUTH_SM_STATE_IDLE;
+       
+       return OK;
+}
+
+
+#ifdef REPORT_LOG
+
+static char *stateDesc[SHARED_KEY_AUTH_SM_NUM_STATES] = 
+       {
+               "SHARED_KEY_AUTH_SM_STATE_IDLE",
+               "SHARED_KEY_AUTH_SM_STATE_WAIT_1",
+               "SHARED_KEY_AUTH_SM_STATE_WAIT_2",
+               "SHARED_KEY_AUTH_SM_STATE_AUTH",
+       };
+
+static char *eventDesc[SHARED_KEY_AUTH_SM_NUM_EVENTS] = 
+       {
+               "SHARED_KEY_AUTH_SM_EVENT_START",
+               "SHARED_KEY_AUTH_SM_EVENT_STOP",
+               "SHARED_KEY_AUTH_SM_EVENT_SUCCESS_1",
+               "SHARED_KEY_AUTH_SM_EVENT_FAIL_1",
+               "SHARED_KEY_AUTH_SM_EVENT_SUCCESS_2",
+               "SHARED_KEY_AUTH_SM_EVENT_FAIL_2",
+               "SHARED_KEY_AUTH_SM_EVENT_TIMEOUT",
+               "SHARED_KEY_AUTH_SM_EVENT_MAX_RETRY",
+       };
+
+#endif
+
+
+TI_STATUS auth_skSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hAuth)
+{
+   auth_t *pAuth = (auth_t *)hAuth;
+       TI_STATUS               status;
+       UINT8           nextState;
+
+       status = fsm_GetNextState(pAuth->pAuthSm, *currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_SM(pAuth->hReport, AUTH_MODULE_LOG, ("State machine error, failed getting next state\n"));
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pAuth->hReport, AUTH_MODULE_LOG, 
+                                                         ("<%s, %s> --> %s\n\n",
+                                                          stateDesc[*currentState],
+                                                          eventDesc[event],
+                                                          stateDesc[nextState]));
+
+       status = fsm_Event(pAuth->pAuthSm, currentState, event, (void *)pAuth);
+
+       return status;
+}
+
+
+/**
+*
+* sharedKeyAuth_Recv - Recive a message from the AP
+*
+* \b Description: 
+*
+* Parse a message form the AP and perform the appropriate event.
+*
+* \b ARGS:
+*
+*  I   - hAuth - Association SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa sharedKeyAuth_Start, sharedKeyAuth_Stop
+*/
+TI_STATUS sharedKeyAuth_Recv(TI_HANDLE hAuth, mlmeFrameInfo_t *pFrame)
+{
+       TI_STATUS                       status = NOK;
+       auth_t                  *pHandle;
+       UINT16                  authAlgo;
+       UINT16                  rspSeq;
+
+       pHandle = (auth_t*)hAuth;
+
+       if (pHandle == NULL)
+       {
+               return NOK;
+       }
+       
+       /* check response status */
+       authAlgo = pFrame->content.auth.authAlgo;
+       if (authAlgo != AUTH_LEGACY_SHARED_KEY)
+       {
+               WLAN_REPORT_SM(pHandle->hReport, AUTH_MODULE_LOG,
+                                 ("SHARED_KEY_AUTH_SM: DEBUG recieved authentication message with wrong algorithm \n"));
+               return NOK;
+       }
+    
+       /* check response status */
+       rspSeq  = pFrame->content.auth.seqNum;
+       
+    pHandle->authData.status = pFrame->content.auth.status;
+    pHandle->authData.pChalange = (char *)(pFrame->content.auth.pChallenge->text);
+    pHandle->authData.challangeLen = pFrame->content.auth.pChallenge->hdr.eleLen;
+
+       if (pHandle->authData.status == STATUS_SUCCESSFUL)
+       {
+               switch (rspSeq)
+               {
+               case 2:
+                       WLAN_REPORT_SM(pHandle->hReport, AUTH_MODULE_LOG,
+                                         ("SHARED_KEY_AUTH_SM: DEBUG Success authenticating to AP stage 1\n"));
+
+                       if (pFrame->content.auth.pChallenge->hdr.eleId != CHALLANGE_TEXT_IE_ID)
+                       {
+                               WLAN_REPORT_ERROR(pHandle->hReport, AUTH_MODULE_LOG,
+                                                 ("SHARED_KEY_AUTH_SM: Wrong element ID for challange \n"));
+                               status = NOK;
+                               break;
+                       }
+
+                       status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_SUCCESS_1, hAuth);
+                       break;
+
+               case 4:
+                       WLAN_REPORT_SM(pHandle->hReport, AUTH_MODULE_LOG,
+                                         ("SHARED_KEY_AUTH_SM: DEBUG Success authenticating to AP stage 2\n"));
+                       
+                       status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_SUCCESS_2, hAuth);
+                       break;
+
+               default:
+                       WLAN_REPORT_ERROR(pHandle->hReport, AUTH_MODULE_LOG,
+                                         ("SHARED_KEY_AUTH_SM: Wrong sequence number \n"));
+                       status = NOK;
+                       break;
+               }
+       } 
+       
+       else 
+       {
+               switch (rspSeq)
+               {
+               case 2:
+                       status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_FAIL_1, hAuth);
+                       break;
+
+               case 4:
+                       status = auth_skSMEvent(&pHandle->currentState, SHARED_KEY_AUTH_SM_EVENT_FAIL_2, hAuth);
+                       break;
+       
+               default:
+                       status = NOK;
+                       break;
+               }
+       }
+
+       return status;
+}
+
+/* state machine functions */
+
+TI_STATUS sharedKeyAuth_smStartIdle(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smResetRetry(hAuth);
+       status = sharedKeyAuth_smSendAuth1(hAuth);
+       status = sharedKeyAuth_smStartTimer(hAuth);
+       status = sharedKeyAuth_smIncRetry(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smStopWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smStopTimer(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smSuccess1Wait1(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smResetRetry(hAuth);
+       if (status != OK)
+               return status;
+       status = sharedKeyAuth_smStopTimer(hAuth);
+       if (status != OK)
+               return status;
+       status = sharedKeyAuth_smSendAuth2(hAuth);
+       if (status != OK)
+               return status;
+       status = sharedKeyAuth_smStartTimer(hAuth);
+       if (status != OK)
+               return status;
+       status = sharedKeyAuth_smIncRetry(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smFailure1Wait1(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smStopTimer(hAuth);
+       status = sharedKeyAuth_smReportFailure(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smTimeoutWait1(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smSendAuth1(hAuth);
+       status = sharedKeyAuth_smStartTimer(hAuth);
+       status = sharedKeyAuth_smIncRetry(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smMaxRetryWait(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smReportFailure(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smSuccess2Wait2(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smStopTimer(hAuth);
+       status = sharedKeyAuth_smReportSuccess(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smFailure2Wait2(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smStopTimer(hAuth);
+       status = sharedKeyAuth_smReportFailure(hAuth);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smTimeoutWait2(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = sharedKeyAuth_smSendAuth2(hAuth);
+       status = sharedKeyAuth_smStartTimer(hAuth);
+       status = sharedKeyAuth_smIncRetry(hAuth);
+
+       return status;
+}
+
+/* action routines for authentication SM */
+
+TI_STATUS sharedKeyAuth_smSendAuth1(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       status = auth_smMsgBuild(hAuth, 1, 0, NULL, 0);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smSendAuth2(auth_t *hAuth)
+{
+       TI_STATUS               status;
+       
+       /* GET SECRET  */
+
+       /* ENCRYPT CHALLANGE WITH SECRET */
+
+       status = auth_smMsgBuild(hAuth, 3, 0, (UINT8 *)(hAuth->authData.pChalange), hAuth->authData.challangeLen);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smStopAuth(auth_t *hAuth)
+{
+       return OK;
+}
+
+TI_STATUS sharedKeyAuth_smActionUnexpected(auth_t *hAuth)
+{
+       return OK;
+}
+
+/* local functions */
+
+
+TI_STATUS sharedKeyAuth_smResetRetry(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       hAuth->retryCount = 0;
+       
+       return OK;
+}
+
+TI_STATUS sharedKeyAuth_smIncRetry(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       hAuth->retryCount++;
+       
+       return OK;
+} 
+
+TI_STATUS sharedKeyAuth_smReportSuccess(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       status = mlme_reportAuthStatus(hAuth->hMlme, hAuth->authData.status);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smReportFailure(auth_t *hAuth)
+{
+       TI_STATUS               status;
+
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       status = mlme_reportAuthStatus(hAuth->hMlme, hAuth->authData.status);
+
+       return status;
+}
+
+TI_STATUS sharedKeyAuth_smStartTimer(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       os_timerStart(hAuth->hOs, hAuth->timer, hAuth->timeout, FALSE);
+
+       return OK;
+}
+
+TI_STATUS sharedKeyAuth_smStopTimer(auth_t *hAuth)
+{
+       if (hAuth == NULL)
+       {
+               return NOK;
+       }
+       
+       os_timerStop(hAuth->hOs, hAuth->timer);
+
+       return OK;
+}
+
+TI_STATUS sharedKey_Timeout(auth_t *pAuth)
+{
+       if (pAuth->retryCount >= pAuth->maxCount)
+       {
+               pAuth->authData.status = STATUS_PACKET_REJ_TIMEOUT;
+               return auth_skSMEvent(&pAuth->currentState, SHARED_KEY_AUTH_SM_EVENT_MAX_RETRY, pAuth);
+       }
+
+       return auth_skSMEvent(&pAuth->currentState, SHARED_KEY_AUTH_SM_EVENT_TIMEOUT, pAuth);
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/Auth/shared/sharedKeyAuthSm.h b/sta_dk_4_0_4_32/common/src/core/mlme/Auth/shared/sharedKeyAuthSm.h
new file mode 100644 (file)
index 0000000..e7a56ca
--- /dev/null
@@ -0,0 +1,125 @@
+/** \file sharedKeyAuthSm.h
+ *  \brief shared key 802.11 authentication SM
+ *
+ *  \see sharedKeyAuthSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: sharedKeyAuthSm.h                                                                                  */
+/*    PURPOSE: shared key 802.11 authentication SM                                                */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _SHARED_KEY_AUTH_SM_H
+#define _SHARED_KEY_AUTH_SM_H
+
+#include "fsm.h"
+#include "mlmeApi.h"
+#include "../authSm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* state machine states */
+typedef enum 
+{
+       SHARED_KEY_AUTH_SM_STATE_IDLE           = 0,
+       SHARED_KEY_AUTH_SM_STATE_WAIT_1         = 1,
+       SHARED_KEY_AUTH_SM_STATE_WAIT_2         = 2,
+       SHARED_KEY_AUTH_SM_STATE_AUTH           = 3
+} sharedKeyAuth_smStates_t;
+
+/* State machine inputs */
+typedef enum 
+{
+       SHARED_KEY_AUTH_SM_EVENT_START                  = 0,
+       SHARED_KEY_AUTH_SM_EVENT_STOP                   = 1,
+       SHARED_KEY_AUTH_SM_EVENT_SUCCESS_1      = 2,
+       SHARED_KEY_AUTH_SM_EVENT_FAIL_1                 = 3,
+       SHARED_KEY_AUTH_SM_EVENT_SUCCESS_2      = 4,
+       SHARED_KEY_AUTH_SM_EVENT_FAIL_2                 = 5,
+       SHARED_KEY_AUTH_SM_EVENT_TIMEOUT                = 6,
+       SHARED_KEY_AUTH_SM_EVENT_MAX_RETRY              = 7
+} sharedKeyAuth_smEvents_t;
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS sharedKeyAuth_Config(TI_HANDLE       hAuth,
+                                                       TI_HANDLE       pOs);
+
+TI_STATUS sharedKeyAuth_Recv(TI_HANDLE pAssoc, mlmeFrameInfo_t *pFrame);
+
+TI_STATUS sharedKey_Timeout(auth_t *pAuth);
+
+TI_STATUS auth_skSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hAuth);
+
+/* state machine functions */
+
+TI_STATUS sharedKeyAuth_smStartIdle(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smStopWait(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smSuccess1Wait1(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smFailure1Wait1(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smSuccess2Wait2(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smFailure2Wait2(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smTimeoutWait1(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smTimeoutWait2(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smMaxRetryWait(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smStopAuth(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smActionUnexpected(auth_t *hAuth);
+
+TI_STATUS sharedKeyAuth_smResetRetry(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smIncRetry(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smReportSuccess(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smReportFailure(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smSendAuth1(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smSendAuth2(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smStartTimer(auth_t *hAuth);
+TI_STATUS sharedKeyAuth_smStopTimer(auth_t *hAuth);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/mlmeBuilder.c b/sta_dk_4_0_4_32/common/src/core/mlme/mlmeBuilder.c
new file mode 100644 (file)
index 0000000..6d4b282
--- /dev/null
@@ -0,0 +1,225 @@
+ /** \file mlmeBuilder.c
+ *  \brief 802.11 MLME Builder
+ *
+ *  \see mlmeBuilder.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mlmeBuilder.c                                                                                      */
+/*    PURPOSE: 802.11 MLME Builder                                                                                */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+
+#include "report.h"
+
+#include "802_11Defs.h"
+
+#include "DataCtrl_Api.h"
+#include "memMngrEx.h"
+
+#include "mlmeApi.h"
+#include "mlmeSm.h"
+#include "mlmeBuilder.h"
+#include "srcApi.h"
+#include "TNETW_Driver_types.h"
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Local function prototypes */
+
+/* Functions */
+
+TI_STATUS mlmeBuilder_sendFrame(TI_HANDLE hMlme, 
+                                                        dot11MgmtSubType_e type, 
+                                                        UINT8 *pDataBuff, 
+                                                        UINT32 dataLen,
+                                                        UINT8  setWepOpt)
+{
+       TI_STATUS                       status;
+       mlme_t                  *pHandle;
+       mem_MSDU_T              *pMsdu;
+       paramInfo_t             daParam, saParam;
+       dot11_mgmtFrame_t       *pFrame;
+
+
+
+       if (hMlme == NULL)
+       {
+               return NOK;
+       }
+
+       pHandle = (mlme_t*)hMlme;
+
+
+       /* GET NEW MSDU !!! */
+       status = wlan_memMngrAllocMSDU(pHandle->hMemMgr, &pMsdu, 
+        MAX_MANAGEMENT_FRAME_BODY_LEN + 
+            configMgr_getPacketHeaderLength(pHandle->hConfigMgr, NULL, TX_DATA_MGMT_MSDU), 
+        MLME_MODULE);
+       
+    if (status != OK)
+               return NOK;
+       pFrame = (dot11_mgmtFrame_t*)(pMsdu->firstBDPtr->data + TX_TOTAL_OFFSET_BEFORE_DATA);
+
+       status = mlmeBuilder_buildFrameCtrl(pHandle, type, (UINT16 *)&pFrame->hdr.fc, setWepOpt);
+       if (status != OK)
+       {
+               wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+               return NOK;
+       }
+
+       daParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+       status = ctrlData_getParam(pHandle->hCtrlData, &daParam);
+       if (status != OK)
+       {
+               wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+               return NOK;
+       }
+
+       /* copy destination mac address */
+       MAC_COPY(pHandle->hOs, (&pFrame->hdr.DA), (&daParam.content.ctrlDataCurrentBSSID));
+
+       saParam.paramType = CTRL_DATA_MAC_ADDRESS;
+       status = ctrlData_getParam(pHandle->hCtrlData, &saParam);
+       if (status != OK)
+       {
+               wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+               return NOK;
+       }
+
+       /* copy source mac address */
+       MAC_COPY(pHandle->hOs, (&pFrame->hdr.SA), (&saParam.content.ctrlDataCurrentBSSID));
+
+       /* copy BSSID (destination mac address) */
+       MAC_COPY(pHandle->hOs, (&pFrame->hdr.BSSID), (&daParam.content.ctrlDataCurrentBSSID));
+
+       if (pDataBuff != NULL)
+       {
+               os_memoryCopy(pHandle->hOs, (void *)pFrame->body, pDataBuff, dataLen);
+       }
+
+       /* Update MSDU parameters */
+       pMsdu->headerLen = sizeof(dot11_mgmtHeader_t);
+       pMsdu->dataLen = sizeof(dot11_mgmtHeader_t) + dataLen;
+       pMsdu->firstBDPtr->dataOffset = TX_TOTAL_OFFSET_BEFORE_DATA;
+    pMsdu->firstBDPtr->length = pMsdu->dataLen + pMsdu->firstBDPtr->dataOffset;
+       /* send the packet to the TX */
+       pMsdu->qosTag = 0;
+       pMsdu->txFlags |= TX_DATA_MGMT_MSDU;
+       
+       /* 
+     * sign the Disassoc packet 
+     * A disassociate indication (if occurs) will be provided via TxComplete
+     */
+       if (type == DIS_ASSOC)
+               pMsdu->txCompleteFlags |= TX_DATA_DISASSOC_SYNC_TRIG;
+       
+       /* sign the De Auth packet 
+     * A De Auth indication (if occurs) will be provided via TxComplete
+     */
+       if (type == DE_AUTH)
+               pMsdu->txCompleteFlags |= TX_DATA_DEAUTH_SYNC_TRIG;
+
+       status = txData_txSendMsdu(pHandle->hTxData, pMsdu);
+
+       return status;
+}
+
+TI_STATUS mlmeBuilder_buildFrameCtrl(mlme_t* pMlme, dot11MgmtSubType_e type, UINT16* pFctrl, UINT8 setWepOpt)
+{
+       *pFctrl = 0;
+
+       switch (type)
+       {
+       case ASSOC_REQUEST:
+               *pFctrl |= DOT11_FC_ASSOC_REQ;
+               break;
+       case ASSOC_RESPONSE:
+               *pFctrl |= DOT11_FC_ASSOC_RESP;
+               break;
+       case RE_ASSOC_REQUEST:
+               *pFctrl |= DOT11_FC_REASSOC_REQ;
+               break;
+       case RE_ASSOC_RESPONSE:
+               *pFctrl |= DOT11_FC_REASSOC_RESP;
+               break;
+       case DIS_ASSOC:
+               *pFctrl |= DOT11_FC_DISASSOC;
+               break;
+       case AUTH:
+               *pFctrl |= DOT11_FC_AUTH;
+               break;
+       case DE_AUTH:
+               *pFctrl |= DOT11_FC_DEAUTH;
+               break;
+       case ACTION:
+               *pFctrl |= DOT11_FC_ACTION;
+               break;
+       default:
+               return NOK;
+       }
+       
+       if (setWepOpt)
+       {
+               *pFctrl |= DOT11_FC_WEP;
+       }
+
+
+       return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/mlmeParser.c b/sta_dk_4_0_4_32/common/src/core/mlme/mlmeParser.c
new file mode 100644 (file)
index 0000000..8002560
--- /dev/null
@@ -0,0 +1,2060 @@
+ /** \file mlmeBuilder.c
+ *  \brief 802.11 MLME Builder
+ *
+ *  \see mlmeBuilder.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE: mlmeBuilder.c                                              */
+/*    PURPOSE:  802.11 MLME Builder                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+
+#include "802_11Defs.h"
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "memMngrEx.h"
+#include "report.h"
+
+#include "DataCtrl_Api.h"
+#include "smeApi.h"
+
+#include "mlmeApi.h"
+#include "mlmeSm.h"
+#include "Assoc/AssocSM.h"
+#include "Auth/authSm.h"
+
+#include "mlmeParser.h"
+#include "measurementMgrApi.h"
+#include "siteMgrApi.h"
+#include "spectrumMngmntMgr.h"
+#include "currBss.h"
+#include "apConn.h"
+#include "SwitchChannelApi.h"
+#include "regulatoryDomainApi.h"
+#include "qosMngr_API.h"
+
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Local function prototypes */
+
+/* Functions */
+
+#define BcnMissTst 0
+#define BcnMissTstWithScrPad7 0
+#define CHECK_PARSING_ERROR_CONDITION_PRINT 0
+
+#if BcnMissTst
+static void mlmeParser_printBeaconDebugInfo(TI_HANDLE theMlmeHandle,
+                                            mlmeFrameInfo_t theFrame);
+#endif
+
+BOOL MissingBcnInt = FALSE ;
+extern int WMEQosTagToACTable[MAX_NUM_OF_802_1d_TAGS];
+
+TI_STATUS mlmeParser_recv(TI_HANDLE hMlme, mem_MSDU_T *pMsdu, Rx_attr_t* pRxAttr)
+{
+    TI_STATUS               status = NOK;
+    mlme_t                  *pHandle;
+    UINT8                   *pData;
+    INT32                   bodyDataLen;
+    UINT32                  readLen;
+    dot11_eleHdr_t          *pEleHdr;
+    dot11_mgmtFrame_t       *pMgmtFrame;
+    dot11MgmtSubType_e      msgType;
+    paramInfo_t             param;
+    macAddress_t            recvBssid;
+       macAddress_t            recvSa;
+    UINT8                   rsnIeIdx = 0;
+    UINT8                   wpaIeOuiIe[] = WPA_IE_OUI;
+    UINT8                   ti_oui[] = TI_OUI;
+#ifdef EXC_MODULE_INCLUDED
+    UINT8                   exc_oui[] = EXC_OUI;
+    EXCv4IEs_t              *pExcIeParameter;
+#endif
+    BOOL                    ciscoIEPresent = FALSE;
+#if BcnMissTst
+    /* debug info */
+    UINT32                  currProbeRspTSFTime = 0;
+    UINT32                  deltaProbeRspTSFTime = 0;
+#endif
+    
+
+    if (hMlme == NULL)
+    {       
+        return NOK;
+    }
+
+    pHandle = (mlme_t*)hMlme;
+
+    if (pMsdu == NULL)
+    {       
+        return NOK;
+    }
+
+    /* zero frame content */
+    os_memoryZero(pHandle->hOs, &(pHandle->tempFrameInfo), sizeof(mlmeIEParsingParams_t));
+
+    pMgmtFrame = (dot11_mgmtFrame_t*)(memMgr_BufData(pMsdu->firstBDPtr) + memMgr_BufOffset(pMsdu->firstBDPtr)) ;
+
+    /* get frame type */
+    status = mlmeParser_getFrameType(pHandle, (UINT16 *)&pMgmtFrame->hdr.fc, &msgType);
+    if (status != OK)
+    {
+        wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+        return OK;
+    }
+
+    pHandle->tempFrameInfo.frame.subType = msgType;
+
+    /* We have to ignore management frames from other BSSIDs (except beacons & probe responses) */
+    param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+    ctrlData_getParam(pHandle->hCtrlData, &param);
+
+    os_memoryCopy(pHandle->hOs, &(recvBssid.addr), &(pMgmtFrame->hdr.BSSID), MAC_ADDR_LEN);
+
+       os_memoryCopy(pHandle->hOs, &(recvSa.addr), &(pMgmtFrame->hdr.SA), MAC_ADDR_LEN);
+
+       if (MAC_EQUAL((&(param.content.ctrlDataCurrentBSSID)), (&(recvBssid))))
+        pHandle->tempFrameInfo.myBssid = TRUE;
+    else
+        pHandle->tempFrameInfo.myBssid = FALSE;
+
+       if (MAC_EQUAL((&(param.content.ctrlDataCurrentBSSID)), (&(recvSa))))
+               pHandle->tempFrameInfo.mySa = TRUE;
+       else
+               pHandle->tempFrameInfo.mySa = FALSE;
+
+       /* The Default value of the myDst flag is false, only in case of unicast packet with the STA's destination address, the flag is set to True */
+       pHandle->tempFrameInfo.myDst = FALSE;
+
+    /* check destination MAC address for broadcast */
+
+    if (MAC_BROADCAST((&pMgmtFrame->hdr.DA)))
+    {
+        pHandle->tempFrameInfo.frame.extesion.destType = MSG_BROADCAST;
+    }
+        else
+        {
+        if (MAC_MULTICAST((&pMgmtFrame->hdr.DA)))
+        {
+            pHandle->tempFrameInfo.frame.extesion.destType = MSG_MULTICAST;
+        }
+        else
+        {
+            pHandle->tempFrameInfo.frame.extesion.destType = MSG_UNICAST;
+
+                       param.paramType = CTRL_DATA_MAC_ADDRESS;
+                   ctrlData_getParam(pHandle->hCtrlData, &param);
+
+                       /* Verifying whether the received unicast packet is for the STA, if yes we set the flag to True */
+                       if (MAC_EQUAL( (&(param.content.ctrlDataDeviceMacAddress)), (&(pMgmtFrame->hdr.DA)) )  )
+                               pHandle->tempFrameInfo.myDst = TRUE;
+                       
+               
+        }
+    }
+
+    MAC_COPY(pHandle->hOs, (&(pHandle->tempFrameInfo.bssid)), (&pMgmtFrame->hdr.BSSID));
+
+    pData = (UINT8 *)(pMgmtFrame->body);
+
+    /* length of body (msdu without 802.11 header and FCS) */
+    bodyDataLen = pMsdu->dataLen - WLAN_HDR_LEN;
+
+    switch (msgType)
+    {
+    case ASSOC_REQUEST:
+        WLAN_REPORT_SM(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved ASSOC_REQ message \n"));
+        break;
+    case RE_ASSOC_REQUEST:
+        WLAN_REPORT_SM(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved RE_ASSOC_REQ message \n"));
+        break;
+    case RE_ASSOC_RESPONSE:
+        WLAN_REPORT_SM(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved RE_ASSOC_RSP message \n"));
+      /*  break;*/
+    case ASSOC_RESPONSE:
+               /* if the assoc response is not directed to our STA or not from the current AP */
+        if ((!pHandle->tempFrameInfo.myBssid) || (!pHandle->tempFrameInfo.mySa) || (pHandle->tempFrameInfo.myDst == FALSE))
+            break;
+
+               /* Save the association response message */
+        assoc_saveAssocRespMessage(pHandle->hAssoc, (UINT8 *)(pMgmtFrame->body), bodyDataLen);
+
+        /* init frame fields */
+        pHandle->tempFrameInfo.frame.content.assocRsp.barkerPreambleMode = PREAMBLE_UNSPECIFIED;
+
+        /* read capabilities */
+        pHandle->tempFrameInfo.frame.content.assocRsp.capabilities = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+        /* read status */
+        pHandle->tempFrameInfo.frame.content.assocRsp.status = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+        /* read AID */
+        pHandle->tempFrameInfo.frame.content.assocRsp.aid = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+
+        bodyDataLen -= ASSOC_RESP_FIXED_DATA_LEN;
+        /***************************/
+
+        pHandle->tempFrameInfo.frame.content.assocRsp.pRsnIe = NULL;
+        pHandle->tempFrameInfo.frame.content.assocRsp.rsnIeLen = 0;
+        while (bodyDataLen > 2)
+        {
+            pEleHdr = (dot11_eleHdr_t*)pData;
+
+            if (pEleHdr->eleLen > (bodyDataLen - 2))
+            {
+                WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                  ("MLME_PARSER: IE %d with length %d out of bounds %d\n", pEleHdr->eleId, pEleHdr->eleLen, (bodyDataLen - 2)));
+                wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                return NOK;
+            }
+
+            switch (pEleHdr->eleId)
+            {
+                        /* read rates */
+            case SUPPORTED_RATES_IE_ID:
+                pHandle->tempFrameInfo.frame.content.assocRsp.pRates = &(pHandle->tempFrameInfo.rates);
+                status = mlmeParser_readRates(pHandle, pData, bodyDataLen, &readLen, &(pHandle->tempFrameInfo.rates));
+                if (status != OK)
+                {
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                      ("MLME_PARSER: error reading RATES\n"));
+                    wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                    return NOK;
+                }
+                break;
+
+            case EXT_SUPPORTED_RATES_IE_ID:
+                /* read rates */
+                pHandle->tempFrameInfo.frame.content.assocRsp.pExtRates = &(pHandle->tempFrameInfo.extRates);
+                status = mlmeParser_readRates(pHandle, pData, bodyDataLen, &readLen, &(pHandle->tempFrameInfo.extRates));
+                if (status != OK)
+                {
+                    wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,("MLME_PARSER: error reading RATES\n"));
+                    return NOK;
+                }
+                break;
+
+            case ERP_IE_ID:
+                status = mlmeParser_readERP(pHandle, pData, bodyDataLen, &readLen,
+                                            (BOOL *)&(pHandle->tempFrameInfo.frame.content.assocRsp.useProtection),
+                                            (preamble_e *)&(pHandle->tempFrameInfo.frame.content.assocRsp.barkerPreambleMode));
+                if (status != OK)
+                {
+                    wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);                  
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,("MLME_PARSER: error reading ERP\n"));
+                    return NOK;
+                }
+                break;
+
+            case DOT11_4X_ELE_ID:
+                /* Note : WPA, WME, TSRS, MSDU lifetime and 4X use the same Element ID */
+                /*  Its assumes that:
+                        4X - uses OUI = 0x08,0x00,0x28;
+                        TSRS and MSDU lifetime use OUI = 0x00,0x40,0x96 (=Cisco) but
+                        use different OUI Type:
+                            TSRS          uses OUI Type 8
+                            MSDU lifetime uses OUI Type 9;
+                        WPA and WME use the same OUI = 0x00,0x50,0xf2 but
+                        use different OUI Type:
+                            WPA - uses OUI Type with value  - 1
+                            WME - uses OUI Type with value  - 2.
+                */
+
+                /* check if this is 4X IE */
+                if(os_memoryCompare(pHandle->hOs ,ti_oui, pData+2, DOT11_OUI_LEN) == 0)
+                {
+                    pHandle->tempFrameInfo.frame.content.assocRsp.fourXParams = &(pHandle->tempFrameInfo.fourXParams);
+                    status = mlmeParser_read4Xxarams(pHandle, pData, bodyDataLen, &readLen, 
+                                                     &(pHandle->tempFrameInfo.fourXParams));
+                    if (status != OK)
+                    {
+                        WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                          ("MLME_PARSER: error reading 4X parameters\n"));
+                        wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                        return NOK;
+                    }
+                }
+                /* check if this is WME IE */
+                else if((os_memoryCompare(pHandle->hOs, wpaIeOuiIe, pData+2, DOT11_OUI_LEN) == 0) && 
+                        ((*(UINT8*)(pData+5)) == dot11_WME_OUI_TYPE))
+                {
+                    pHandle->tempFrameInfo.frame.content.assocRsp.WMEParams = &(pHandle->tempFrameInfo.WMEParams);
+                    status = mlmeParser_readWMEParams(pHandle, pData, bodyDataLen, &readLen, 
+                                                      &(pHandle->tempFrameInfo.WMEParams),
+                                                      &(pHandle->tempFrameInfo.frame.content.assocRsp));
+                    if (status != OK)
+                    {
+                        WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                          ("MLME_PARSER: error reading WME parameters\n"));
+                        wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                        return NOK;
+                    }
+                }
+#ifdef EXC_MODULE_INCLUDED
+                /* check if this is EXC vendor specific OUI */
+                else if (os_memoryCompare(pHandle->hOs, exc_oui, pData+2, DOT11_OUI_LEN) == 0) 
+                {
+                    pExcIeParameter = &(pHandle->tempFrameInfo.frame.content.assocRsp.excIEs[WMEQosTagToACTable[*(pData+6)]]);
+                    mlmeParser_readExcOui(pData, bodyDataLen, &readLen, pExcIeParameter);
+                }
+#endif
+                else
+                {
+                    /* skip this IE */
+                    readLen = pEleHdr->eleLen + 2;
+                }
+                break;
+            case EXC_EXT_1_IE_ID:
+                ciscoIEPresent = TRUE;
+                pHandle->tempFrameInfo.frame.content.assocRsp.pRsnIe = &(pHandle->tempFrameInfo.rsnIe[0]);
+                status = mlmeParser_readRsnIe(pHandle, pData, bodyDataLen, &readLen, 
+                                              &(pHandle->tempFrameInfo.rsnIe[rsnIeIdx]));
+                if (status != OK)
+                {
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                      ("MLME_PARSER: error reading EXC EXT1 IE\n"));
+                    wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                    return NOK;
+                }
+    
+                pHandle->tempFrameInfo.frame.content.assocRsp.rsnIeLen += readLen;
+                rsnIeIdx ++;
+                break;
+
+            case EXC_EXT_2_IE_ID:
+                ciscoIEPresent = TRUE;
+                pHandle->tempFrameInfo.frame.content.assocRsp.pRsnIe   = &(pHandle->tempFrameInfo.rsnIe[0]);
+                status = mlmeParser_readRsnIe(pHandle, pData, bodyDataLen, &readLen,
+                                              &(pHandle->tempFrameInfo.rsnIe[rsnIeIdx]));
+                if (status != OK)
+                {
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                      ("MLME_PARSER: error reading RSN IP ADDR IE\n"));
+                    wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                    return NOK;
+                }
+    
+                pHandle->tempFrameInfo.frame.content.assocRsp.rsnIeLen += readLen;
+                rsnIeIdx ++;
+                break;
+
+            case DOT11_QOS_CAPABILITY_ELE_ID:
+                pHandle->tempFrameInfo.frame.content.assocRsp.QoSCapParameters = &(pHandle->tempFrameInfo.QosCapParams);
+                status = mlmeParser_readQosCapabilityIE(pHandle, pData, bodyDataLen, &readLen, 
+                                                        &(pHandle->tempFrameInfo.QosCapParams));
+                if (status != OK)
+                {
+                    wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,("MLME_PARSER: error reading QOS\n"));                   
+                    return NOK;
+                }
+                break;
+
+            default:
+                WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                  ("MLME_PARSER: unsupported IE found (%d)\n", pEleHdr->eleId));
+                readLen = pEleHdr->eleLen + 2;
+                status = OK;
+                break;
+            }
+
+            pData += readLen;
+            bodyDataLen -= readLen;
+        }
+        /***************************/
+
+        /* set the appropriate flag in the association response frame */
+        /* to indicate whether or not we encountered a Cisco IE, i.e., */
+        /* if we have any indication as to whether the AP we've associated */
+        /* with is a Cisco AP. */
+        pHandle->tempFrameInfo.frame.content.assocRsp.ciscoIEPresent = ciscoIEPresent;
+
+        WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                ("MLME_PARSER: ciscoIEPresent = %d\n", ciscoIEPresent));
+
+        status = assoc_recv(pHandle->hAssoc, &(pHandle->tempFrameInfo.frame));
+        break;
+
+    case PROBE_REQUEST:
+        WLAN_REPORT_SM(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved PROBE_REQ message \n"));
+        break;
+    case PROBE_RESPONSE:
+
+        WLAN_REPORT_SM(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved PROBE_RESPONSE message \n"));
+
+               if(pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4 > MAX_BEACON_BODY_LENGTH)
+               {
+                       WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("mlmeParser_recv: probe response length out of range. length=%d, band=%d, channel=%d\n", pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4, pRxAttr->band, pRxAttr->channel));
+                       /* Error in parsing probe response packet - exit */
+                       wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                       return NOK;
+
+               }
+
+               /* init frame fields */
+        pHandle->tempFrameInfo.frame.content.iePacket.barkerPreambleMode = PREAMBLE_UNSPECIFIED;
+
+        /* read time stamp */
+        os_memoryCopy(pHandle->hOs, (void *)pHandle->tempFrameInfo.frame.content.iePacket.timestamp, pData, TIME_STAMP_LEN);
+        pData += TIME_STAMP_LEN;
+
+        bodyDataLen -= TIME_STAMP_LEN;
+        /* read beacon interval */
+        pHandle->tempFrameInfo.frame.content.iePacket.beaconInerval = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+        /* read capabilities */
+        pHandle->tempFrameInfo.frame.content.iePacket.capabilities = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+
+        bodyDataLen -= 4;
+        pHandle->tempFrameInfo.frame.content.iePacket.pRsnIe = NULL;
+        pHandle->tempFrameInfo.frame.content.iePacket.rsnIeLen = 0;
+
+        pHandle->tempFrameInfo.band = pRxAttr->band;
+        pHandle->tempFrameInfo.rxChannel = pRxAttr->channel;
+
+       if ((pRxAttr->band == RADIO_BAND_2_4_GHZ) && (pRxAttr->channel > NUM_OF_CHANNELS_24))
+        {
+            WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                ("mlmeParser_recv, band=%d, channel=%d\n", pRxAttr->band, pRxAttr->channel));
+            /* Error in parsing Probe response packet - exit */
+            wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+            return NOK;
+
+        }
+        else if ((pRxAttr->band == RADIO_BAND_5_0_GHZ) && (pRxAttr->channel <= NUM_OF_CHANNELS_24))
+        {
+            WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+            ("mlmeParser_recv, band=%d, channel=%d\n", pRxAttr->band, pRxAttr->channel));
+            /* Error in parsing Probe response packet - exit */
+            wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+            return NOK;
+
+        }
+        if (mlmeParser_parseIEs(hMlme, pData, bodyDataLen, &(pHandle->tempFrameInfo)) != OK)
+        {
+            /* Error in parsing Probe response packet - exit */
+            WLAN_REPORT_WARNING(pHandle->hReport, MLME_SM_MODULE_LOG,("mlmeParser_parseIEs: Error in parsing probe response \n"));          
+            wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+            return NOK;
+        }
+
+        /* Check if there is a scan in progress */
+        if ( NULL != pHandle->resultCBFunc )
+        {
+            /* result CB is registered - results are sent to the registered callback */
+            pHandle->resultCBFunc( pHandle->resultCBObj, &(pHandle->tempFrameInfo.bssid), &(pHandle->tempFrameInfo.frame), pRxAttr,
+                                   (UINT8 *)(pMgmtFrame->body+TIME_STAMP_LEN+4),
+                                   pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4 );
+        }
+        currBSS_probRespReceivedCallb(pHandle->hCurrBss, pRxAttr, &(pHandle->tempFrameInfo.bssid), 
+                                      &(pHandle->tempFrameInfo.frame), 
+                                      (char *)pMgmtFrame->body+TIME_STAMP_LEN+4, 
+                                      pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4);
+
+/* For Debug */
+#if BcnMissTst
+
+        /* Printing all the required parameters of the received ProbeRsp */
+        currProbeRspTSFTime = (UINT32)ENDIAN_HANDLE_LONG(*(INT32*)(pHandle->tempFrameInfo.frame.content.iePacket.timestamp));
+        deltaProbeRspTSFTime = (UINT32)((UINT32)currProbeRspTSFTime - (UINT32)pHandle->debug_lastProbeRspTSFTime);
+
+        if(pHandle->tempFrameInfo.frame.content.iePacket.pSsid != NULL)
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                    MLME_SM_MODULE_LOG,
+                                    ("ProbeRsp ssid=%8s TS=0x%x TSDelta=0x%x beaconInt=%d HostTime = %d\n",
+                        pHandle->tempFrameInfo.frame.content.iePacket.pSsid->serviceSetId,
+                        currProbeRspTSFTime,
+                        deltaProbeRspTSFTime,
+                        pHandle->tempFrameInfo.frame.content.iePacket.beaconInerval,
+                        os_timeStampMs(pHandle)));
+        }
+
+        if(pHandle->tempFrameInfo.frame.content.iePacket.pSsid == NULL)
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                    MLME_SM_MODULE_LOG,
+                                    ("SSID null\n"));
+
+        pHandle->debug_lastProbeRspTSFTime = currProbeRspTSFTime;
+
+#endif /* BcnMissTst */
+        if(pHandle->tempFrameInfo.recvChannelSwitchAnnoncIE == FALSE)
+        {
+            switchChannel_recvCmd(pHandle->hSwitchChannel, NULL, pRxAttr->channel);
+        }
+
+        break;
+    case BEACON:
+
+        WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved BEACON message, TS= %ld\n", os_timeStampMs(pHandle->hOs)));
+        WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG, ("beacon MSDU") );
+
+               if(pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4 > MAX_BEACON_BODY_LENGTH)
+               {
+                       WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("mlmeParser_recv: beacon length out of range. length=%d, band=%d, channel=%d\n", pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4, pRxAttr->band, pRxAttr->channel));
+                       /* Error in parsing beacon packet - exit */
+                       wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+                       return NOK;
+
+               }
+
+               /* init frame fields */
+        pHandle->tempFrameInfo.frame.content.iePacket.barkerPreambleMode = PREAMBLE_UNSPECIFIED;
+
+        /* read time stamp */
+        os_memoryCopy(pHandle->hOs, (void *)pHandle->tempFrameInfo.frame.content.iePacket.timestamp, pData, TIME_STAMP_LEN);
+        pData += TIME_STAMP_LEN;
+
+        bodyDataLen -= TIME_STAMP_LEN;
+        /* read beacon interval */
+        pHandle->tempFrameInfo.frame.content.iePacket.beaconInerval = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+        /* read capabilities */
+        pHandle->tempFrameInfo.frame.content.iePacket.capabilities = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+
+        bodyDataLen -= 4;
+        pHandle->tempFrameInfo.frame.content.iePacket.pRsnIe = NULL;
+        pHandle->tempFrameInfo.frame.content.iePacket.rsnIeLen = 0;
+
+        if ((pRxAttr->band == RADIO_BAND_2_4_GHZ) && (pRxAttr->channel > NUM_OF_CHANNELS_24))
+        {
+            WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+            ("mlmeParser_recv, band=%d, channel=%d\n", pRxAttr->band, pRxAttr->channel));
+            /* Error in parsing Probe response packet - exit */
+            wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+            return NOK;
+
+        }
+        else if ((pRxAttr->band == RADIO_BAND_5_0_GHZ) && (pRxAttr->channel <= NUM_OF_CHANNELS_24))
+        {
+            WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+            ("mlmeParser_recv, band=%d, channel=%d\n", pRxAttr->band, pRxAttr->channel));
+            /* Error in parsing Probe response packet - exit */
+            wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+            return NOK;
+
+        }
+        pHandle->tempFrameInfo.band = pRxAttr->band;
+        pHandle->tempFrameInfo.rxChannel = pRxAttr->channel;
+
+        if (mlmeParser_parseIEs(hMlme, pData, bodyDataLen, &(pHandle->tempFrameInfo)) != OK)
+        {
+            WLAN_REPORT_WARNING(pHandle->hReport, MLME_SM_MODULE_LOG,("mlmeParser_parseIEs - Error in parsing Beacon \n"));                                 
+            /* Error in parsing Beacon packet - exit */
+            wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle);
+            return NOK;
+        }
+
+        /* Check if there is a scan in progress */
+        if ( NULL != pHandle->resultCBFunc )
+        {
+            /* result CB is registered - results are sent to the registered callback */
+            pHandle->resultCBFunc( pHandle->resultCBObj, &(pHandle->tempFrameInfo.bssid), &(pHandle->tempFrameInfo.frame), pRxAttr,
+                                   (UINT8 *)(pMgmtFrame->body+TIME_STAMP_LEN+4),
+                                   pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4 );
+        }
+
+        /* Counting the number of recieved beacons - used for statistics */
+        pHandle->BeaconsCounterPS++;
+
+        currBSS_beaconReceivedCallb(pHandle->hCurrBss, pRxAttr, &(pHandle->tempFrameInfo.bssid), 
+                                    &(pHandle->tempFrameInfo.frame), (char *)pMgmtFrame->body+TIME_STAMP_LEN+4, 
+                                    pMsdu->dataLen-WLAN_HDR_LEN-TIME_STAMP_LEN-4);
+
+#if BcnMissTst
+        if ( pHandle->tempFrameInfo.myBssid ) 
+        {
+            mlmeParser_printBeaconDebugInfo(hMlme,
+                                            pHandle->tempFrameInfo.frame);
+        }
+#endif
+        if (pHandle->tempFrameInfo.recvChannelSwitchAnnoncIE == FALSE)
+        {
+            switchChannel_recvCmd(pHandle->hSwitchChannel, NULL, pRxAttr->channel);
+        }
+
+        break;
+    case ATIM:
+        if (!pHandle->tempFrameInfo.myBssid)
+            break;
+
+        WLAN_REPORT_SM(pHandle->hReport, MLME_SM_MODULE_LOG,
+                       ("MLME_PARSER: recieved ATIM message \n"));
+        break;
+    case DIS_ASSOC:
+        if ((!pHandle->tempFrameInfo.myBssid) || (!pHandle->tempFrameInfo.mySa))
+            break;
+
+        /* consider the DisAssoc frame if it is one of the following:
+                       1) unicast frame and directed to our STA
+                       2) broadcast frame
+               */
+               if((pHandle->tempFrameInfo.frame.extesion.destType == MSG_UNICAST) && 
+                        (pHandle->tempFrameInfo.myDst == FALSE))
+            break;
+
+        /* read Reason interval */
+        pHandle->tempFrameInfo.frame.content.disAssoc.reason = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+
+               {       /* Send roaming trigger */
+                       roamingEventData_u RoamingEventData;
+                       RoamingEventData.APDisconnect.uStatusCode = pHandle->tempFrameInfo.frame.content.disAssoc.reason;
+                       RoamingEventData.APDisconnect.bDeAuthenticate = FALSE; /* i.e. This is not DeAuth packet */
+                       apConn_reportRoamingEvent(pHandle->hApConn, ROAMING_TRIGGER_AP_DISCONNECT, &RoamingEventData);
+               }
+
+               break;
+    case AUTH:
+        /* Auth response frame is should be directed to our STA, and from the current AP */
+               if ((!pHandle->tempFrameInfo.myBssid) || (!pHandle->tempFrameInfo.mySa) || (pHandle->tempFrameInfo.myDst == FALSE))
+            break;
+
+        /* read Algorithm interval */
+        pHandle->tempFrameInfo.frame.content.auth.authAlgo = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+        /* read Sequence number */
+        pHandle->tempFrameInfo.frame.content.auth.seqNum = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+        /* read status */
+        pHandle->tempFrameInfo.frame.content.auth.status = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+        pData += 2;
+
+        WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                ("MLME_PARSER: Read Auth: algo=%d, seq=%d, status=%d\n",
+                                pHandle->tempFrameInfo.frame.content.auth.authAlgo,
+                                pHandle->tempFrameInfo.frame.content.auth.seqNum,
+                                pHandle->tempFrameInfo.frame.content.auth.status));
+        bodyDataLen -= 6;
+        /* read Challenge */
+        pHandle->tempFrameInfo.frame.content.auth.pChallenge = &(pHandle->tempFrameInfo.challenge);
+        status = mlmeParser_readChallange(pHandle, pData, bodyDataLen, &readLen, &(pHandle->tempFrameInfo.challenge));
+        if (status != OK)
+        {
+            pHandle->tempFrameInfo.challenge.hdr.eleLen = 0;
+            readLen = 0;
+        }
+        pData += readLen;
+
+        status = auth_recv(pHandle->hAuth, &(pHandle->tempFrameInfo.frame));
+        break;
+    case DE_AUTH:
+        if ((!pHandle->tempFrameInfo.myBssid) || (!pHandle->tempFrameInfo.mySa))
+            break;
+
+        /* consider the Assoc frame if it is one of the following:
+                       1) unicast frame and directed to our STA
+                       2) broadcast frame
+               */
+               if((pHandle->tempFrameInfo.frame.extesion.destType == MSG_UNICAST) && 
+                       (pHandle->tempFrameInfo.myDst == FALSE))
+            break;
+
+        /* read Reason */
+        pHandle->tempFrameInfo.frame.content.deAuth.reason = ENDIAN_HANDLE_WORD(*(UINT16*)pData);
+
+               {       /* Send roaming trigger */
+                       roamingEventData_u RoamingEventData;
+                       RoamingEventData.APDisconnect.uStatusCode = pHandle->tempFrameInfo.frame.content.disAssoc.reason;
+                       RoamingEventData.APDisconnect.bDeAuthenticate = TRUE; /* i.e. This is DeAuth packet */
+                       apConn_reportRoamingEvent(pHandle->hApConn, ROAMING_TRIGGER_AP_DISCONNECT, &RoamingEventData);
+               }
+        break;
+
+       case ACTION:
+               param.paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;
+               ctrlData_getParam(pHandle->hCtrlData, &param);
+
+        if ((!pHandle->tempFrameInfo.myBssid) || 
+                       ((!pHandle->tempFrameInfo.mySa) && (param.content.ctrlDataCurrentBssType == BSS_INFRASTRUCTURE)))
+            break;
+
+               /* if the action frame is unicast and not directed to our STA, we should ignore it */
+               if((pHandle->tempFrameInfo.frame.extesion.destType == MSG_UNICAST) && 
+                               (pHandle->tempFrameInfo.myDst == FALSE))
+            break;
+               
+
+        /* read Category field */
+        pHandle->tempFrameInfo.frame.content.action.category = *pData;
+        pData ++;
+        bodyDataLen --;
+
+        /* Checking if the category field is valid */
+        if(( pHandle->tempFrameInfo.frame.content.action.category != CATAGORY_SPECTRUM_MANAGEMENT) &&
+            (pHandle->tempFrameInfo.frame.content.action.category != CATAGORY_QOS)  &&
+            (pHandle->tempFrameInfo.frame.content.action.category != WME_CATAGORY_QOS) )   
+        {
+            WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: Error category is invalid for action management frame %d \n",
+                           pHandle->tempFrameInfo.frame.content.action.category ));
+            break;
+        }
+
+        switch(pHandle->tempFrameInfo.frame.content.action.category)
+        {
+            case CATAGORY_QOS:
+            case WME_CATAGORY_QOS:           
+                /* read action field */
+                pHandle->tempFrameInfo.frame.content.action.action = *pData;
+                pData ++;
+                bodyDataLen --;
+
+                QosMngr_receiveActionFrames(pHandle->hQosMngr, pData, pHandle->tempFrameInfo.frame.content.action.action, bodyDataLen); 
+                break;
+                
+            case CATAGORY_SPECTRUM_MANAGEMENT:
+                /* read action field */
+                pHandle->tempFrameInfo.frame.content.action.action = *pData;
+                pData ++;
+                bodyDataLen --;
+                
+                switch(pHandle->tempFrameInfo.frame.content.action.action)
+                {
+                    case MEASUREMENT_REQUEST:
+                        /* Checking the frame type  */
+                        if(pHandle->tempFrameInfo.frame.extesion.destType == MSG_BROADCAST)
+                            pHandle->tempFrameInfo.frame.content.action.frameType = MSR_FRAME_TYPE_BROADCAST;
+                        else
+                            pHandle->tempFrameInfo.frame.content.action.frameType = MSR_FRAME_TYPE_UNICAST;
+                        
+                            /*measurementMgr_receiveFrameRequest(pHandle->hMeasurementMgr,
+                            pHandle->tempFrameInfo.frame.content.action.frameType,
+                            bodyDataLen,pData);*/
+                        break;
+
+                    case TPC_REQUEST:
+                        /*measurementMgr_receiveTPCRequest(pHandle->hMeasurementMgr,(UINT8)bodyDataLen,pData);*/
+                        break;
+                        
+                    case CHANNEL_SWITCH_ANNOUNCEMENT:
+                        if (pHandle->tempFrameInfo.myBssid)
+                        {   /* Ignore Switch Channel commands from non my BSSID */
+                            mlmeParser_readChannelSwitch(pHandle,pData,bodyDataLen,&readLen,&(pHandle->tempFrameInfo.channelSwitch),
+                                pRxAttr->channel);
+                        }
+                        break;
+                        
+                    default:
+                        WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                            ("MLME_PARSER: Error, category is invalid for action management frame %d \n",
+                            pHandle->tempFrameInfo.frame.content.action.category ));
+                        break;
+                }
+                
+                break;
+
+                
+            default:
+                status = NOK;
+                break;
+                    
+        }
+    }
+
+    /* release MSDU */
+    if (wlan_memMngrFreeMSDU(pHandle->hMemMgr, pMsdu->handle) != OK)
+    {
+        WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: Error releasing MSDU handle %d \n", pMsdu->handle));
+    }
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_getFrameType(mlme_t *pMlme, UINT16* pFrameCtrl, dot11MgmtSubType_e *pType)
+{
+    if ((*pFrameCtrl & DOT11_FC_PROT_VERSION_MASK) != DOT11_FC_PROT_VERSION)
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: Error Wrong protocol version (not %d) \n", DOT11_FC_PROT_VERSION));
+        return NOK;
+    }
+
+    if ((*pFrameCtrl & DOT11_FC_TYPE_MASK) != DOT11_FC_TYPE_MGMT)
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: Error not MANAGEMENT frame\n"));
+        return NOK;
+    }
+
+    *pType = (dot11MgmtSubType_e)((*pFrameCtrl & DOT11_FC_SUB_MASK) >> 4);
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_read4Xxarams(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_4X_t *fourXParams)
+{
+    fourXParams->hdr.eleId = *pData;
+    fourXParams->hdr.eleLen = *(pData+1);
+
+    *pReadLen = fourXParams->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(fourXParams->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (fourXParams->hdr.eleLen > DOT11_4X_MAX_LEN)
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs, (void *)fourXParams->fourXCapabilities, pData+2, fourXParams->hdr.eleLen);
+
+    return OK;
+}
+
+
+#ifdef EXC_MODULE_INCLUDED
+void mlmeParser_readExcOui (UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, EXCv4IEs_t *excIEs)
+{
+    UINT8 ieLen;
+    UINT8 ouiType;
+
+    ieLen = *(pData+1) + 2;
+
+    if (dataLen < ieLen)
+    {
+        /* Wrong length of info-element, skip to the end of the packet */
+        *pReadLen = dataLen;
+        return;
+    }
+
+    *pReadLen = ieLen;
+    ouiType = *(pData+5);
+
+    switch (ouiType) 
+    {
+        case TS_METRIX_OUI_TYPE:
+            excIEs->tsMetrixParameter = (dot11_TS_METRICS_IE_t *)pData;
+            break;
+        case TS_RATE_SET_OUI_TYPE:
+            excIEs->trafficStreamParameter = (dot11_TSRS_IE_t *)pData;
+            break;
+        case EDCA_LIFETIME_OUI_TYPE:
+            excIEs->edcaLifetimeParameter = (dot11_MSDU_LIFE_TIME_IE_t *)pData;
+            break;
+    }
+    return;
+}
+#endif
+
+
+TI_STATUS mlmeParser_readERP(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen,
+                             BOOL *useProtection, preamble_e *barkerPreambleMode)
+{
+
+    UINT32 erpIElen;
+    UINT16 ctrl;
+    UINT16 ShortData=0;
+
+    erpIElen = *(pData+1);
+    *pReadLen = erpIElen + 2;
+
+    if (dataLen < (UINT32)(erpIElen + 2))
+    {
+        return NOK;
+    }
+#ifdef FOUR_ALIGNMENT /*fix for un-aligned exception on ARM */
+    ((UINT8 *)&ShortData)[0] = pData[2];
+    ((UINT8 *)&ShortData)[1] = pData[3];
+    ctrl = ENDIAN_HANDLE_WORD(ShortData);
+#else
+    ctrl = ENDIAN_HANDLE_WORD(*(UINT16*)(pData+2));
+#endif
+
+    *useProtection = (ctrl & 0x2) >>1;
+    *barkerPreambleMode = ((ctrl & 0x4) >>2) ? PREAMBLE_LONG : PREAMBLE_SHORT;
+
+    return OK;
+}
+
+
+TI_STATUS mlmeParser_readRates(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_RATES_t *pRates)
+{
+    pRates->hdr.eleId = *pData;
+    pRates->hdr.eleLen = *(pData+1);
+
+    *pReadLen = pRates->hdr.eleLen + 2;
+
+    if (dataLen < (UINT32)(pRates->hdr.eleLen + 2))
+    {
+        return NOK;
+    }
+
+    if (pRates->hdr.eleLen > MAX_SUPPORTED_RATES)
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs, (void *)pRates->rates, pData+2, pRates->hdr.eleLen);
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readSsid(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_SSID_t *pSsid)
+{
+    pSsid->hdr.eleId = *pData;
+    pSsid->hdr.eleLen = *(pData+1);
+
+    *pReadLen = pSsid->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pSsid->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (pSsid->hdr.eleLen > MAX_SSID_LEN)
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs, (void *)pSsid->serviceSetId, pData+2, pSsid->hdr.eleLen);
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readFhParams(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_FH_PARAMS_t *pFhParams)
+{
+    UINT16 ShortData=0;
+    pFhParams->hdr.eleId = *pData;
+    pFhParams->hdr.eleLen = *(pData+1);
+    pData += 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pFhParams->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+#if 1
+    ((UINT8 *)&ShortData)[0] = pData[0];
+    ((UINT8 *)&ShortData)[1] = pData[1];
+#else
+    /* Fix for possible alignment problem */
+    COPY_UNALIGNED_WORD(&ShortData , pData);
+#endif
+
+    pFhParams->dwellTime = ENDIAN_HANDLE_WORD(ShortData);
+    pData += 2;
+
+    pFhParams->hopSet = *pData;
+    pFhParams->hopPattern = *(pData+1);
+    pFhParams->hopIndex = *(pData+2);
+
+    *pReadLen = pFhParams->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readDsParams(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_DS_PARAMS_t *pDsParams)
+{
+    pDsParams->hdr.eleId = *pData;
+    pDsParams->hdr.eleLen = *(pData+1);
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pDsParams->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+       
+    pDsParams->currChannel = *(pData+2);
+
+    *pReadLen = pDsParams->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readCfParams(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_CF_PARAMS_t *pCfParams)
+{
+    UINT16 ShortData=0;
+    pCfParams->hdr.eleId = *pData;
+    pCfParams->hdr.eleLen = *(pData+1);
+    pData += 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pCfParams->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    pCfParams->cfpCount = *pData;
+    pCfParams->cfpPeriod = *(pData+1);
+    pData += 2;
+
+#if 1
+    /* Fix for possible alignment problem */
+    ((UINT8 *)&ShortData)[0] = pData[0];
+    ((UINT8 *)&ShortData)[1] = pData[1];
+#else
+    COPY_UNALIGNED_WORD(&ShortData, pData);
+#endif
+    pCfParams->cfpMaxDuration = ENDIAN_HANDLE_WORD(ShortData);
+
+    pData += 2;
+
+#if 1
+    /* Fix for possible alignment problem */
+    ((UINT8 *)&ShortData)[0] = pData[0];
+    ((UINT8 *)&ShortData)[1] = pData[1];
+#else
+    /* Fix for possible alignment problem */
+    COPY_UNALIGNED_WORD(&ShortData, pData);
+#endif
+    pCfParams->cfpDurRemain = ENDIAN_HANDLE_WORD(ShortData);
+
+    *pReadLen = pCfParams->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readIbssParams(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_IBSS_PARAMS_t *pIbssParams)
+{
+    UINT16 ShortData=0;
+    pIbssParams->hdr.eleId = *pData;
+    pIbssParams->hdr.eleLen = *(pData+1);
+    pData += 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pIbssParams->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+#if 1
+    /* Fix for possible alignment problem */
+    ((UINT8 *)&ShortData)[0] = pData[0];
+    ((UINT8 *)&ShortData)[1] = pData[1];
+#else
+    /* Fix for possible alignment problem */
+    COPY_UNALIGNED_WORD(&ShortData, pData);
+#endif
+    pIbssParams->atimWindow = ENDIAN_HANDLE_WORD(ShortData);
+
+    *pReadLen = pIbssParams->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readTim(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_TIM_t *pTim)
+{
+    pTim->hdr.eleId = *pData;
+    pTim->hdr.eleLen = *(pData+1);
+    pData += 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pTim->hdr.eleLen + 2)) || (pTim->hdr.eleLen < 3))
+    {
+        return NOK;
+    }
+
+    pTim->dtimCount = *pData;
+    pTim->dtimPeriod = *(pData+1);
+    pTim->bmapControl = *(pData+2);
+    pData += 3;
+
+    if ((pTim->hdr.eleLen - 3) > DOT11_PARTIAL_VIRTUAL_BITMAP_MAX) /* Dm: Security fix */
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: Security Error: eleLen=%d, maxLen=%d\n",
+                          pTim->hdr.eleLen, DOT11_PARTIAL_VIRTUAL_BITMAP_MAX));
+        return NOK;
+    }
+    os_memoryCopy(pMlme->hOs, (void *)pTim->partialVirtualBmap, pData, pTim->hdr.eleLen - 3);
+
+    *pReadLen = pTim->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readCountry(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_COUNTRY_t *countryIE)
+{
+    countryIE->hdr.eleId = *pData;
+    countryIE->hdr.eleLen = *(pData+1);
+
+    *pReadLen = countryIE->hdr.eleLen + 2;
+
+    if ((dataLen < 8) || (dataLen < (UINT32)(countryIE->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (countryIE->hdr.eleLen > DOT11_COUNTRY_ELE_LEN_MAX)
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: country IE error: eleLen=%d, maxLen=%d\n",
+                          countryIE->hdr.eleLen, DOT11_COUNTRY_ELE_LEN_MAX));
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs,&(countryIE->countryIE), pData+2, countryIE->hdr.eleLen);
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readWMEParams(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, 
+                                   UINT32 *pReadLen, dot11_WME_PARAM_t *pWMEParamIE, 
+                                   assocRsp_t *assocRsp)
+{
+    UINT8 ieSubtype;
+    UINT8 ac;
+
+    pWMEParamIE->hdr.eleId = *pData;
+    pWMEParamIE->hdr.eleLen = *(pData+1);
+
+    *pReadLen = pWMEParamIE->hdr.eleLen + 2;
+
+    if (dataLen < *pReadLen)
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: WME Parameter: eleLen=%d is too long (%d)\n", *pReadLen, dataLen));
+        *pReadLen = dataLen;
+        return NOK;
+    }
+
+    if ((pWMEParamIE->hdr.eleLen > WME_TSPEC_IE_LEN) || (pWMEParamIE->hdr.eleLen < DOT11_WME_ELE_LEN))
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: WME Parameter IE error: eleLen=%d\n", pWMEParamIE->hdr.eleLen));
+        return NOK;
+    }
+
+    ieSubtype = *((UINT8*)(pData+6));
+    switch (ieSubtype)
+    {
+        case dot11_WME_OUI_SUB_TYPE_IE:
+        case dot11_WME_OUI_SUB_TYPE_PARAMS_IE:
+            /* Checking WME Version validity */
+            if (*((UINT8*)(pData+7)) != dot11_WME_VERSION )
+            {
+                WLAN_REPORT_INFORMATION(pMlme->hReport, MLME_SM_MODULE_LOG,
+                                  ("MLME_PARSER: WME Parameter IE error: Version =%d is unsupported\n",
+                                  *((UINT8*)(pData+7)) ));
+                return NOK;
+            }
+            /* Copy either the WME-Params IE or the WME-Info IE (Info is a subset of Params)! */
+            os_memoryCopy(pMlme->hOs,&(pWMEParamIE->OUI), pData+2, pWMEParamIE->hdr.eleLen);
+            break;
+
+        case WME_TSPEC_IE_OUI_SUB_TYPE:
+            /* Read renegotiated TSPEC parameters */
+            if (assocRsp == NULL) 
+            {
+                WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                                  ("MLME_PARSER: WME Parameter IE error: TSPEC Sub Type in beacon or probe resp\n"));
+                return NOK;
+            }
+            ac = WMEQosTagToACTable[((((dot11_WME_TSPEC_IE_t *)pData)->tHdr.tsInfoField.tsInfoArr[1]) & TS_INFO_1_USER_PRIORITY_MASK) >> USER_PRIORITY_SHIFT];
+
+            if (ac == QOS_AC_VO)
+            {
+                assocRsp->tspecVoiceParameters = (dot11_WME_TSPEC_IE_t *)pData;
+            }
+            else if (ac == QOS_AC_VI)
+            {
+                assocRsp->tspecSignalParameters = (dot11_WME_TSPEC_IE_t *)pData;
+            }
+            break;
+
+        default:
+            /* Checking OUI Sub Type validity */
+            WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                              ("MLME_PARSER: WME Parameter IE error: Sub Type =%d is invalid\n",
+                              ieSubtype));
+            return NOK;
+    }
+    return OK;
+}
+
+
+TI_STATUS mlmeParser_readQosCapabilityIE(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_QOS_CAPABILITY_IE_t *QosCapParams)
+{
+    QosCapParams->hdr.eleId = *pData;
+    QosCapParams->hdr.eleLen = *(pData+1);
+
+    *pReadLen = QosCapParams->hdr.eleLen + 2;
+
+    if (dataLen < (UINT32)(QosCapParams->hdr.eleLen + 2))
+    {
+        return NOK;
+    }
+
+    if (QosCapParams->hdr.eleLen > DOT11_QOS_CAPABILITY_ELE_LEN)
+    {
+        WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                          ("MLME_PARSER: QOS Capability  IE error: eleLen=%d, maxLen=%d\n",
+                          QosCapParams->hdr.eleLen, DOT11_QOS_CAPABILITY_ELE_LEN));
+        return NOK;
+    }
+
+   QosCapParams->QosInfoField = (*(pData+1));
+    return OK;
+}
+
+
+TI_STATUS mlmeParser_readChallange(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_CHALLENGE_t *pChallange)
+{
+    if (dataLen < 2)
+    {
+        return NOK;
+    }
+
+    pChallange->hdr.eleId = *pData;
+    pChallange->hdr.eleLen = *(pData+1);
+    pData += 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pChallange->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (pChallange->hdr.eleLen > DOT11_CHALLENGE_TEXT_MAX)
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs, (void *)pChallange->text, pData, pChallange->hdr.eleLen);
+
+    *pReadLen = pChallange->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readRsnIe(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_RSN_t *pRsnIe)
+{
+    pRsnIe->hdr.eleId = *pData;
+    pRsnIe->hdr.eleLen = *(pData+1);
+    pData += 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(pRsnIe->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs, (void *)pRsnIe->rsnIeData, pData, pRsnIe->hdr.eleLen);
+
+    *pReadLen = pRsnIe->hdr.eleLen + 2;
+
+    return OK;
+}
+
+TI_STATUS mlmeParser_readPowerConstraint(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_POWER_CONSTRAINT_t *powerConstraintIE)
+{
+    powerConstraintIE->hdr.eleId = *pData;
+    powerConstraintIE->hdr.eleLen = *(pData+1);
+
+    *pReadLen = powerConstraintIE->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(powerConstraintIE->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (powerConstraintIE->hdr.eleLen > DOT11_POWER_CONSTRAINT_ELE_LEN)
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs,(void *)&(powerConstraintIE->powerConstraint), pData+2, powerConstraintIE->hdr.eleLen);
+
+    return OK;
+}
+
+
+TI_STATUS mlmeParser_readChannelSwitch(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_CHANNEL_SWITCH_t *channelSwitch, UINT8 channel)
+{
+    channelSwitch->hdr.eleId = *pData++;
+    channelSwitch->hdr.eleLen = *pData++;
+
+    *pReadLen = channelSwitch->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(channelSwitch->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (channelSwitch->hdr.eleLen > DOT11_CHANNEL_SWITCH_ELE_LEN)
+    {
+        return NOK;
+    }
+
+    channelSwitch->channelSwitchMode = *pData++;
+    channelSwitch->channelNumber = *pData++;
+    channelSwitch->channelSwitchCount = *pData;
+
+
+    switchChannel_recvCmd(pMlme->hSwitchChannel, channelSwitch, channel);
+    return OK;
+}
+
+TI_STATUS mlmeParser_readQuiet(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_QUIET_t *quiet)
+{
+    quiet->hdr.eleId = *pData++;
+    quiet->hdr.eleLen = *pData++;
+
+    *pReadLen = quiet->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(quiet->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (quiet->hdr.eleLen > DOT11_QUIET_ELE_LEN)
+    {
+        return NOK;
+    }
+
+    quiet->quietCount = *pData++;
+    quiet->quietPeriod = *pData++;
+    quiet->quietDuration = *((UINT16*)pData); pData+=2; /* Dm: */
+    quiet->quietOffset = *((UINT16*)pData);
+
+    return OK;
+}
+
+
+TI_STATUS mlmeParser_readTPCReport(mlme_t *pMlme,UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_TPC_REPORT_t *TPCReport)
+{
+    TPCReport->hdr.eleId = *pData;
+    TPCReport->hdr.eleLen = *(pData+1);
+
+    *pReadLen = TPCReport->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(TPCReport->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (TPCReport->hdr.eleLen > DOT11_TPC_REPORT_ELE_LEN)
+    {
+        return NOK;
+    }
+
+    TPCReport->transmitPower = *(pData+2);
+
+    return OK;
+}
+
+
+#ifdef EXC_MODULE_INCLUDED
+TI_STATUS mlmeParser_readCellTP(mlme_t *pMlme, UINT8 *pData, UINT32 dataLen, UINT32 *pReadLen, dot11_CELL_TP_t *cellTP)
+{
+    UINT8 exc_OUI[] = EXC_OUI;
+
+    cellTP->hdr.eleId = *pData++;
+    cellTP->hdr.eleLen = *pData++;
+
+    *pReadLen = cellTP->hdr.eleLen + 2;
+
+    if ((dataLen < 2) || (dataLen < (UINT32)(cellTP->hdr.eleLen + 2)))
+    {
+        return NOK;
+    }
+
+    if (cellTP->hdr.eleLen > DOT11_CELL_TP_ELE_LEN)
+    {
+        return NOK;
+    }
+
+    os_memoryCopy(pMlme->hOs, (PVOID)cellTP->oui, pData, cellTP->hdr.eleLen);
+
+    if (os_memoryCompare(pMlme->hOs, (PVOID)cellTP->oui, exc_OUI, 3) != 0)
+    {
+        return NOK;
+    }
+
+    return OK;
+}
+#endif
+
+TI_STATUS mlmeParser_registerForBeaconAndProbeResp( TI_HANDLE hMlme, 
+                                                    mlme_resultCB_t resultCBFunc, 
+                                                    TI_HANDLE resultCBObj )
+{
+    mlme_t* pMlme = (mlme_t*)hMlme;
+
+    if ( NULL != pMlme->resultCBFunc )
+    {
+        WLAN_REPORT_WARNING( pMlme->hReport, MLME_SM_MODULE_LOG,
+                             ("trying to register for beacons and probe responses when someone is already registered!.\n") );
+        return NOK;
+    }
+
+    pMlme->resultCBFunc = resultCBFunc;
+    pMlme->resultCBObj = resultCBObj;
+    return OK;
+}
+
+void mlmeParser_unregisterForBeaconAndProbeResp( TI_HANDLE hMlme )
+{
+    mlme_t* pMlme = (mlme_t*)hMlme;
+
+    pMlme->resultCBFunc = NULL;
+    pMlme->resultCBObj = NULL;
+}
+
+void mlme_beaconReceivedPrint(TI_HANDLE hMlme)
+{
+#if BcnMissTst
+    mlme_t *pMlme = (mlme_t*) hMlme;
+    WLAN_REPORT_INFORMATION(pMlme->hReport,MLME_SM_MODULE_LOG,
+                                ("Beacon Missed - FW interrupt\n"));
+#endif
+}
+#if BcnMissTst
+static void mlmeParser_printBeaconDebugInfo(TI_HANDLE theMlmeHandle,
+                                            mlmeFrameInfo_t theFrame)
+{
+    mlme_t      *pHandle = (mlme_t*)theMlmeHandle;
+    paramInfo_t param;
+    UINT32      CurNumBcnMissed = 0;
+    BOOL        BeaconMissiedFlag = FALSE;
+    UINT32      currBeaconTSFTime = 0;
+    UINT32      deltaBeaconTSFTime = 0;
+    INT32       dtimPeriod;
+    INT32       dtimCount;
+    UINT8       bmapControl = 0;
+    UINT8       partialVirtualBmap = 0;
+    UINT8       aid = 0;
+
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    txData_getParam(pHandle->hTxData,&param);
+    if(param.content.txDataPortStatus == CLOSE)
+    {
+        return;
+    }
+
+    param.paramType = SITE_MGR_CURRENT_SSID_PARAM;
+    siteMgr_getParam(pHandle->hSiteMgr,&param);
+    if(strcmp(theFrame.content.iePacket.pSsid->serviceSetId , param.content.siteMgrCurrentSSID.ssidString) != 0)
+    {
+        /* If the beacon is not from the primary site, ignore it */
+        return;
+    }
+
+
+        if(theFrame.content.iePacket.pTIM != NULL)
+        {
+            whalParamInfo_t whalParam;
+
+            dtimPeriod  = theFrame.content.iePacket.pTIM->dtimPeriod;
+            dtimCount   = theFrame.content.iePacket.pTIM->dtimCount;
+            bmapControl = theFrame.content.iePacket.pTIM->bmapControl;
+
+            whalParam.paramType = HAL_CTRL_AID_PARAM;
+            whalCtrl_GetParam (pHandle->hHalCtrl, &whalParam) ;
+            aid = whalParam.content.halCtrlAid;
+            if (aid < DOT11_PARTIAL_VIRTUAL_BITMAP_MAX)
+            {
+                partialVirtualBmap = theFrame.content.iePacket.pTIM->partialVirtualBmap[aid/8] & (1 << (aid%8) );
+            }
+            else
+            {
+                WLAN_REPORT_ERROR(pHandle->hReport,
+                                  MLME_SM_MODULE_LOG,
+                                  ("%s(%d) - Invalid AID (=%d)\n",
+                                  __FILE__,__LINE__,aid));
+            }
+        }
+        else
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                    MLME_SM_MODULE_LOG,
+                                    ("Beacon without TIM element\n"));
+            dtimPeriod  = 1;
+            dtimCount   = 0;
+        }
+
+    /* Printing all the required parameters of the received beacon only if the station is connected*/
+    currBeaconTSFTime = (UINT32)ENDIAN_HANDLE_LONG(*(INT32*)(theFrame.content.iePacket.timestamp));
+
+
+    /*
+    **  in case Configured to wake up on DTIM
+    **  ---------------------------------------
+    **  in case received beacon is DTIM
+    **  if delta time between the current DTIM and the former DTIM is Bigger then
+    **  DTIM Time -> there is a beacon miss (DTIM)
+    **
+    */
+    if ((theFrame.content.iePacket.pTIM != NULL) && (dtimPeriod > 1))
+    {
+        if(pHandle->debug_isFunctionFirstTime == TRUE)
+        {
+            if( (dtimCount == 0) && (dtimPeriod > 1))
+            {
+                pHandle->debug_isFunctionFirstTime = FALSE;
+                pHandle->debug_lastDtimBcnTSFTime = currBeaconTSFTime ;
+            }
+        }
+
+
+        /* to avoid dummy BeaconMiss, just until first DTIM received */
+        if((pHandle->debug_isFunctionFirstTime == TRUE) && (dtimPeriod > 1))
+        {
+            return;
+        }
+
+        if(dtimCount == 0)
+        {
+            deltaBeaconTSFTime = (UINT32)((UINT32)currBeaconTSFTime - (UINT32)pHandle->debug_lastDtimBcnTSFTime);
+
+            CurNumBcnMissed = (deltaBeaconTSFTime + ((UINT32)theFrame.content.iePacket.beaconInerval * 500) ) /
+                    ((UINT32)theFrame.content.iePacket.beaconInerval * dtimPeriod * 1000);
+
+            if(CurNumBcnMissed >=1)
+            {
+                CurNumBcnMissed -- ;
+            }
+
+            if (CurNumBcnMissed != 0)
+            {
+                WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                        MLME_SM_MODULE_LOG,
+                                        ("BeaconMiss : currBcnTS=0x%x TSDelta=0x%x DtimCnt=%d DtimPriod=%d beaconInt=%d lastDtimBcnTSFTime = 0x%x \n",
+                                        currBeaconTSFTime,
+                                        deltaBeaconTSFTime,
+                                        dtimCount ,
+                                        dtimPeriod ,
+                                        theFrame.content.iePacket.beaconInerval,
+                                        pHandle->debug_lastDtimBcnTSFTime));
+            }
+
+            pHandle->debug_lastDtimBcnTSFTime = currBeaconTSFTime ;
+        }
+
+        else /* (dtimCount != 0) */
+        {
+            deltaBeaconTSFTime = (UINT32)((UINT32)currBeaconTSFTime - (UINT32)pHandle->debug_lastDtimBcnTSFTime);
+
+            if (deltaBeaconTSFTime > ((UINT32)theFrame.content.iePacket.beaconInerval * dtimPeriod * 1000))
+            {
+                CurNumBcnMissed =   (deltaBeaconTSFTime -
+                                    ((UINT32)(dtimPeriod - dtimCount) * (UINT32)theFrame.content.iePacket.beaconInerval * 1000)  +
+                                    ((UINT32)theFrame.content.iePacket.beaconInerval * 500) ) /
+                                    ((UINT32)theFrame.content.iePacket.beaconInerval * dtimPeriod * 1000);
+
+            }
+            else
+            {
+                CurNumBcnMissed =   0 ;
+            }
+
+            if (CurNumBcnMissed != 0)
+            {
+                WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                        MLME_SM_MODULE_LOG,
+                                        ("BeaconMiss : currBcnTS=0x%x TSDelta=0x%x DtimCnt=%d DtimPriod=%d beaconInt=%d lastDtimBcnTSFTime = 0x%x \n",
+                                        currBeaconTSFTime,
+                                        deltaBeaconTSFTime,
+                                        dtimCount ,
+                                        dtimPeriod ,
+                                        theFrame.content.iePacket.beaconInerval,
+                                        pHandle->debug_lastDtimBcnTSFTime));
+            }
+        }
+
+    } /* Configured to wake up on DTIM */
+
+
+    /*
+    **  in case Configured to wake up on Beacon
+    **  ---------------------------------------
+    */
+    else
+    {
+        if(pHandle->debug_isFunctionFirstTime == TRUE)
+        {
+            pHandle->debug_isFunctionFirstTime = FALSE;
+            pHandle->debug_lastBeaconTSFTime = currBeaconTSFTime;
+        }
+
+        deltaBeaconTSFTime = (UINT32)((UINT32)currBeaconTSFTime - (UINT32)pHandle->debug_lastBeaconTSFTime);
+
+        CurNumBcnMissed = (deltaBeaconTSFTime + ((UINT32)theFrame.content.iePacket.beaconInerval * 500) ) /
+                          ((UINT32)theFrame.content.iePacket.beaconInerval * dtimPeriod * 1000);
+
+        if(CurNumBcnMissed >=1)
+        {
+            CurNumBcnMissed -- ;
+        }
+
+        if (CurNumBcnMissed != 0)
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                    ("BeaconMiss : currBcnTS=0x%x TSDelta=0x%x DtimCnt=%d DtimPriod=%d beaconInt=%d lastBcnTSFTime = 0x%x \n",
+                                    currBeaconTSFTime,
+                                    deltaBeaconTSFTime,
+                                    dtimCount ,
+                                    dtimPeriod ,
+                                    theFrame.content.iePacket.beaconInerval,
+                                    pHandle->debug_lastBeaconTSFTime));
+        }
+
+        pHandle->debug_lastBeaconTSFTime = currBeaconTSFTime;
+
+    } /* Configured to wake up on Beacon */
+
+
+
+    if (CurNumBcnMissed != 0)
+    {
+        BeaconMissiedFlag = TRUE;
+    }
+
+    /* in case DTIM beacon miss */
+    if (BeaconMissiedFlag == TRUE)
+    {
+        pHandle->totalMissingBeaconsCounter += CurNumBcnMissed;
+        if(CurNumBcnMissed > pHandle->maxMissingBeaconSequence)
+        {
+            pHandle->maxMissingBeaconSequence = CurNumBcnMissed;
+        }
+
+        WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                MLME_SM_MODULE_LOG,
+                                ("Beacon Missed Total = %d and currently %d beacon missed\n",pHandle->totalMissingBeaconsCounter,CurNumBcnMissed));
+    }
+
+
+#if BcnMissTstWithScrPad7
+    if (BeaconMissiedFlag == TRUE)
+    {
+        if (MissingBcnInt == TRUE)
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                    MLME_SM_MODULE_LOG,
+                                    ("Driver write to SCR_PAD7 0x1\n"));
+
+            whalCtrlWriteMacReg(pHandle->hHalCtrl, SCR_PAD7 ,0x1);
+        }
+        else
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                            MLME_SM_MODULE_LOG,
+                                            ("Driver write to SCR_PAD7 0x3\n"));
+
+            whalCtrlWriteMacReg(pHandle->hHalCtrl, SCR_PAD7 ,0x3);
+        }
+    }
+    else
+    {
+        if (MissingBcnInt == TRUE)
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                    MLME_SM_MODULE_LOG,
+                                    ("Driver write to SCR_PAD7 0x4\n"));
+
+            whalCtrlWriteMacReg(pHandle->hHalCtrl, SCR_PAD7 ,0x4);
+        }
+        else
+        {
+            WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                    MLME_SM_MODULE_LOG,
+                                    ("Driver write to SCR_PAD7 0x2\n"));
+
+            whalCtrlWriteMacReg(pHandle->hHalCtrl, SCR_PAD7 ,0x2);
+        }
+    }
+#endif
+
+    if(theFrame.content.iePacket.pTIM != NULL && theFrame.content.iePacket.pSsid != NULL)
+    {
+        WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                MLME_SM_MODULE_LOG,
+                                ("Beacon ssid=%8s TS=0x%x TSDelta=0x%x DtimCnt=%d DtimPriod=%d bmapControl=0x%02X partialVirtualBmap=0x%02X beaconInt=%d HostTime=%d Total=%d\n",
+                                theFrame.content.iePacket.pSsid->serviceSetId,
+                                currBeaconTSFTime,
+                                deltaBeaconTSFTime,
+                                dtimCount ,
+                                dtimPeriod ,
+                                bmapControl,
+                                partialVirtualBmap,
+                                theFrame.content.iePacket.beaconInerval,
+                                os_timeStampMs(pHandle),
+                                ++(pHandle->totalRcvdBeaconsCounter)));
+
+#if BcnMissTstWithScrPad7
+        if(BeaconMissiedFlag != TRUE)
+        {
+            whalCtrlWriteMacReg(pHandle->hHalCtrl, SCR_PAD7 ,0x2);
+        }
+#endif
+    }
+
+    if(theFrame.content.iePacket.pTIM == NULL)
+    {
+        WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                MLME_SM_MODULE_LOG,
+                                ("Tim null\n"));
+    }
+    if(theFrame.content.iePacket.pSsid == NULL)
+    {
+        WLAN_REPORT_INFORMATION(pHandle->hReport,
+                                MLME_SM_MODULE_LOG,
+                                ("SSID null\n"));
+    }
+}
+
+#endif
+
+#if CHECK_PARSING_ERROR_CONDITION_PRINT
+    #define CHECK_PARSING_ERROR_CONDITION(x, msg, bDump)       \
+            if ((x)) \
+            { \
+                WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG, msg); \
+                if (bDump) {\
+                    WLAN_REPORT_ERROR(pHandle->hReport, MLME_SM_MODULE_LOG, ("Buff len = %d \n", packetLength)); \
+                    HexDumpData(pPacketBody, packetLength); }\
+                return NOK; \
+            }
+#else
+    #define CHECK_PARSING_ERROR_CONDITION(x, msg, bDump) \
+         if ((x)) return NOK;
+#endif
+
+TI_STATUS mlmeParser_parseIEs(TI_HANDLE *hMlme, 
+                             UINT8 *pData,
+                             INT32 bodyDataLen,
+                             mlmeIEParsingParams_t *params)
+{
+    dot11_eleHdr_t      *pEleHdr;
+    BOOL                skipIE = FALSE;
+    UINT32              readLen;
+    TI_STATUS           status = NOK;
+    UINT8               rsnIeIdx = 0;
+    UINT8               wpaIeOuiIe[4] = { 0x00, 0x50, 0xf2, 0x01};
+    UINT8               ti_oui[] = TI_OUI;
+    UINT8               lastIE = 0;
+    beacon_probeRsp_t   *frame = &(params->frame.content.iePacket);
+    mlme_t              *pHandle = (mlme_t *)hMlme;
+#ifdef EXC_MODULE_INCLUDED
+    BOOL                allowCellTP = TRUE;
+#endif
+#if CHECK_PARSING_ERROR_CONDITION_PRINT
+    INT32               packetLength = bodyDataLen;
+    UINT8               *pPacketBody = pData;
+#endif
+
+    params->recvChannelSwitchAnnoncIE = FALSE;
+
+    while (bodyDataLen > 1)
+    {
+        pEleHdr = (dot11_eleHdr_t *)pData;
+    
+        CHECK_PARSING_ERROR_CONDITION((pEleHdr->eleLen > (bodyDataLen - 2)), ("MLME_PARSER: IE %d with length %d out of bounds %d\n", pEleHdr->eleId, pEleHdr->eleLen, (bodyDataLen - 2)),TRUE);
+
+        /* IEs in the packet must be ordered in increased order        */
+        /* exept of WPA and RSN IEs! I.e. if current IE id less than   */
+        /* the last one , we just skip such element.                   */
+        /* If the current IE is more than the last IE id (and it is not*/
+        /* WPA or RSN one), we save its IE id  as the last id.         */
+    
+        skipIE = FALSE;
+        if((pEleHdr->eleId != WPA_IE_ID) && (pEleHdr->eleId != RSN_IE_ID))
+        {
+            if (pEleHdr->eleId < lastIE)
+            {
+                readLen = 2 + pEleHdr->eleLen;
+                skipIE = TRUE;
+            }
+            else 
+            {
+                lastIE = pEleHdr->eleId;
+            }
+        }
+    
+        if(!skipIE)
+        {
+            switch (pEleHdr->eleId)
+            {
+            /* read SSID */
+            case SSID_IE_ID:
+                frame->pSsid = &params->ssid;
+                status = mlmeParser_readSsid(pHandle, pData, bodyDataLen, &readLen, frame->pSsid);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading SSID\n"),TRUE);
+                break;
+            /* read rates */
+            case SUPPORTED_RATES_IE_ID:
+                frame->pRates = &params->rates;
+                status = mlmeParser_readRates(pHandle, pData, bodyDataLen, &readLen, frame->pRates);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading RATES\n"),TRUE);
+                break;
+            case EXT_SUPPORTED_RATES_IE_ID:
+                frame->pExtRates = &params->extRates;
+                status = mlmeParser_readRates(pHandle, pData, bodyDataLen, &readLen, frame->pExtRates);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading EXT RATES\n"),TRUE);
+                break;
+    
+            case ERP_IE_ID:
+                status = mlmeParser_readERP(pHandle, pData, bodyDataLen, &readLen,
+                                            (BOOL *)&frame->useProtection,
+                                            (preamble_e *)&frame->barkerPreambleMode);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading ERP\n"),TRUE);
+                break;
+            /* read FH parameter set */
+            case FH_PARAMETER_SET_IE_ID:
+                frame->pFHParamsSet = &params->fhParams;
+                status = mlmeParser_readFhParams(pHandle, pData, bodyDataLen, &readLen, frame->pFHParamsSet);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading FH parameters\n"),TRUE);
+                break;
+            /* read DS parameter set */
+            case DS_PARAMETER_SET_IE_ID:
+                frame->pDSParamsSet = &params->dsParams;
+                status = mlmeParser_readDsParams(pHandle, pData, bodyDataLen, &readLen, frame->pDSParamsSet);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading DS parameters\n"),TRUE);
+                if (RADIO_BAND_2_4_GHZ == params->band )
+                {
+                    CHECK_PARSING_ERROR_CONDITION((frame->pDSParamsSet->currChannel != params->rxChannel), 
+                            ("Channel ERROR - incompatible channel source information: Frame=%d Vs Radio=%d.\n\
+                            parser ABORTED!!!\n",
+                            frame->pDSParamsSet->currChannel , params->rxChannel),FALSE);
+                }
+                break;
+            /* read CF parameter set */
+            case CF_PARAMETER_SET_IE_ID:
+                frame->pCFParamsSet = &params->cfParams;
+                status = mlmeParser_readCfParams(pHandle, pData, bodyDataLen, &readLen, frame->pCFParamsSet);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading CF parameters\n"),TRUE);
+                break;
+            /* read IBSS parameter set */
+            case IBSS_PARAMETER_SET_IE_ID:
+                frame->pIBSSParamsSet = &params->ibssParams;
+                status = mlmeParser_readIbssParams(pHandle, pData, bodyDataLen, &readLen, frame->pIBSSParamsSet);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading IBSS parameters\n"),TRUE);
+                break;
+
+            /* read TIM */
+            case TIM_IE_ID:
+                frame->pTIM = &params->tim;
+                status = mlmeParser_readTim(pHandle, pData, bodyDataLen, &readLen, frame->pTIM);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading TIM\n"),TRUE);
+                break;
+    
+            /* read Country */
+            case COUNTRY_IE_ID:
+                frame->country = &params->country;
+                status = mlmeParser_readCountry(pHandle, pData, bodyDataLen, &readLen, frame->country);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading country parameters\n"),TRUE);
+                break;
+    
+            /* read Power Constraint */
+            case POWER_CONSTRAINT_IE_ID:
+#ifdef EXC_MODULE_INCLUDED
+                allowCellTP = FALSE;
+#endif
+                frame->powerConstraint = &params->powerConstraint;
+                status = mlmeParser_readPowerConstraint(pHandle, pData, bodyDataLen, &readLen, frame->powerConstraint);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading Power Constraint parameters\n"),TRUE);
+                break;
+    
+            /* read Channel Switch Mode */
+            case CHANNEL_SWITCH_ANNOUNCEMENT_IE_ID:
+                if (params->myBssid)
+                {   /* Ignore Switch Channel commands from non my BSSID */
+                    params->recvChannelSwitchAnnoncIE = TRUE;
+                    frame->channelSwitch = &params->channelSwitch;
+                    status = mlmeParser_readChannelSwitch(pHandle, pData, bodyDataLen, &readLen, frame->channelSwitch, params->rxChannel);
+                    if (status != OK)
+                    {
+                        /*
+                         * PATCH for working with AP-DK 4.0.51 that use IE 37 (with length 20) for RSNE
+                         * Ignore the IE instead of rejecting the whole Msdu (beacon or probe response)
+                         */
+                        WLAN_REPORT_WARNING(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                          ("MLME_PARSER: error reading Channel Switch announcement parameters - ignore IE\n"));
+                    }
+                }
+                break;
+    
+            /* read Quiet IE */
+            case QUIET_IE_ID:
+                frame->quiet = &params->quiet;
+                status = mlmeParser_readQuiet(pHandle, pData, bodyDataLen, &readLen, frame->quiet);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading Quiet parameters\n"),TRUE);
+                break;
+    
+            /* read TPC report IE */
+            case TPC_REPORT_IE_ID:
+                frame->TPCReport = &params->TPCReport;
+                status = mlmeParser_readTPCReport(pHandle, pData, bodyDataLen, &readLen, frame->TPCReport);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading TPC report parameters\n"),TRUE);
+                break;
+    
+            case EXC_EXT_1_IE_ID:
+                frame->pRsnIe   = &params->rsnIe[0];
+                status = mlmeParser_readRsnIe(pHandle, pData, bodyDataLen, &readLen, &params->rsnIe[rsnIeIdx]);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading RSN IE\n"),TRUE);
+    
+                frame->rsnIeLen += readLen;
+                rsnIeIdx ++;
+                break;
+    
+            case RSN_IE_ID:
+                frame->pRsnIe = &params->rsnIe[0];
+                status = mlmeParser_readRsnIe(pHandle, pData, bodyDataLen, &readLen, &params->rsnIe[rsnIeIdx]);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading RSN IE\n"),TRUE);
+    
+                frame->rsnIeLen += readLen;
+                rsnIeIdx ++;
+                break;
+    
+            case DOT11_QOS_CAPABILITY_ELE_ID:
+                frame->QoSCapParameters = &params->QosCapParams;
+                status = mlmeParser_readQosCapabilityIE(pHandle, pData, bodyDataLen, &readLen, &params->QosCapParams);
+                CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading QOS CapabilityIE\n"),TRUE);
+                break;
+
+            case WPA_IE_ID:
+                if (!os_memoryCompare(pHandle->hOs, pData+2, wpaIeOuiIe, 3))
+                {
+                    /* Note : WPA and WME use the same OUI */
+                    /*  Its assumes that:
+                            WPA uses OUI Type with value  - 1
+                            WME uses OUI Type with value  - 2
+                    */
+    
+                    /* Check the OUI sub Type to verify whether this is a WME IE or WPA IE*/
+                    if( (*(UINT8*)(pData+5)) == dot11_WPA_OUI_TYPE)
+                    {
+                        /* If we are here - the following is WPA IE */
+                        frame->pRsnIe = &params->rsnIe[0];
+                        status = mlmeParser_readRsnIe(pHandle, pData, bodyDataLen,
+                                                      &readLen, &params->rsnIe[rsnIeIdx]);
+                        frame->rsnIeLen += readLen;
+                        rsnIeIdx ++;
+    
+                        CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading RSN IE\n"),TRUE);
+                    }
+                    if( ( (*(UINT8*)(pData+5)) == dot11_WME_OUI_TYPE ) && 
+                        ( ( (*(UINT8*)(pData+6)) == dot11_WME_OUI_SUB_TYPE_PARAMS_IE) ||
+                          ( (*(UINT8*)(pData+6)) == dot11_WME_OUI_SUB_TYPE_IE) ) )
+                    {
+                        /* If we are here - the following is WME-Params IE, WME-Info IE or TSPEC IE. */
+                        /* Note that we are using the WMEParams struct also to hold the WME-Info IE
+                             which is a subset of WMEParams, and only one of them is sent in a frame. */
+                        frame->WMEParams = &params->WMEParams;
+                        status = mlmeParser_readWMEParams(pHandle, pData, bodyDataLen, &readLen, frame->WMEParams, NULL);
+                        
+                        CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading WME params\n"),TRUE);
+                    }
+                    else
+                    {
+                        /* Unrecognized OUI type */
+                        readLen = pEleHdr->eleLen + 2;
+                    }
+                }
+                else
+                /* check if this is 4X IE */
+                if(os_memoryCompare(pHandle->hOs, ti_oui, pData+2, DOT11_OUI_LEN) == 0)
+                {
+                    frame->fourXParams = &params->fourXParams;
+                    status = mlmeParser_read4Xxarams(pHandle, pData, bodyDataLen, &readLen, frame->fourXParams);
+                    CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading 4X parameters\n"),TRUE);
+                }
+                else
+                {
+                    /* not 4x IE */
+                    readLen = pEleHdr->eleLen + 2;
+                }
+
+                break;
+
+#ifdef EXC_MODULE_INCLUDED
+            case CELL_POWER_IE:
+                /* We mustn't take the Cell Transmit Power IE into account if */
+                /* there's a Power Constraint IE. Since the IEs must be in increasing */
+                /* order, it's enough to perform the check here, because if the Power */
+                /* Constraint IE is present it must have already been processed. */ 
+                if (allowCellTP)
+                {
+                    frame->cellTP = &params->cellTP;
+                    status = mlmeParser_readCellTP(pHandle, pData, bodyDataLen, &readLen, frame->cellTP);
+                    CHECK_PARSING_ERROR_CONDITION((status != OK), ("MLME_PARSER: error reading Cell Transmit Power params.\n"),TRUE);
+                }
+                break;
+#endif
+
+            default:
+                WLAN_REPORT_INFORMATION(pHandle->hReport, MLME_SM_MODULE_LOG,
+                                      ("MLME_PARSER: unsupported IE found (%d)\n", pEleHdr->eleId));
+                readLen = pEleHdr->eleLen + 2;
+                break;
+            }
+        }
+        pData += readLen;
+        bodyDataLen -= readLen;
+        CHECK_PARSING_ERROR_CONDITION((bodyDataLen < 0), ("MLME_PARSER: negative bodyDataLen %d bytes\n", bodyDataLen),TRUE);
+    }
+    return OK;
+}
+
+mlmeIEParsingParams_t *mlmeParser_getParseIEsBuffer(TI_HANDLE *hMlme)
+{
+    return (&(((mlme_t *)hMlme)->tempFrameInfo));
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/mlmeParser.h b/sta_dk_4_0_4_32/common/src/core/mlme/mlmeParser.h
new file mode 100644 (file)
index 0000000..892641c
--- /dev/null
@@ -0,0 +1,207 @@
+ /** \file mlmeBuilder.h
+ *  \brief 802.11 MLME Builder
+ *
+ *  \see mlmeBuilder.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mlmeBuilder.h                                                                                      */
+/*    PURPOSE: 802.11 MLME Builder                                                                                */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MLME_PARSER_H
+#define _MLME_PARSER_H
+
+#include "802_11Defs.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "mlmeApi.h"
+
+#include "mlmeSm.h"
+
+/* Constants */
+
+#define FRAME_CTRL_PROTOCOL_VERSION_MASK       0x03
+#define FRAME_CTRL_TYPE_MASK                           0x0C
+#define FRAME_CTRL_SUB_TYPE_MASK                       0xF0
+
+/* Enumerations */
+
+/* state machine states */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS mlmeParser_getFrameType(mlme_t *pMlme, 
+                                                          UINT16* pFrameCtrl, 
+                                                          dot11MgmtSubType_e *pType);
+
+TI_STATUS mlmeParser_readRates(mlme_t *pMlme, 
+                                                       UINT8 *pData, 
+                                                       UINT32 dataLen, 
+                                                       UINT32 *pReadLen, 
+                                                       dot11_RATES_t *pRates);
+
+TI_STATUS mlmeParser_readERP(mlme_t *pMlme,
+                             UINT8 *pData,
+                             UINT32 dataLen,
+                             UINT32 *pReadLen,
+                             BOOL *useProtection,
+                             preamble_e *barkerPreambleMode);
+
+TI_STATUS mlmeParser_read4Xxarams(mlme_t *pMlme,
+                                                                 UINT8 *pData, 
+                                                                 UINT32 dataLen, 
+                                                                 UINT32 *pReadLen, 
+                                                                 dot11_4X_t *fourXParams);
+
+TI_STATUS mlmeParser_readSsid(mlme_t *pMlme, 
+                                                  UINT8 *pData, 
+                                                  UINT32 dataLen, 
+                                                  UINT32 *pReadLen, 
+                                                  dot11_SSID_t *pSsid);
+
+TI_STATUS mlmeParser_readFhParams(mlme_t *pMlme, 
+                                                          UINT8 *pData, 
+                                                          UINT32 dataLen, 
+                                                          UINT32 *pReadLen, 
+                                                          dot11_FH_PARAMS_t *pFhParams);
+
+TI_STATUS mlmeParser_readDsParams(mlme_t *pMlme, 
+                                                          UINT8 *pData, 
+                                                          UINT32 dataLen, 
+                                                          UINT32 *pReadLen, 
+                                                          dot11_DS_PARAMS_t *pDsParams);
+
+TI_STATUS mlmeParser_readCfParams(mlme_t *pMlme, 
+                                                          UINT8 *pData, 
+                                                          UINT32 dataLen, 
+                                                          UINT32 *pReadLen, 
+                                                          dot11_CF_PARAMS_t *pCfParams);
+
+TI_STATUS mlmeParser_readIbssParams(mlme_t *pMlme, 
+                                                                UINT8 *pData, 
+                                                                UINT32 dataLen, 
+                                                                UINT32 *pReadLen, 
+                                                                dot11_IBSS_PARAMS_t *pIbssParams);
+
+TI_STATUS mlmeParser_readTim(mlme_t *pMlme, 
+                                                 UINT8 *pData, 
+                                                 UINT32 dataLen, 
+                                                 UINT32 *pReadLen, 
+                                                 dot11_TIM_t *pTim);
+
+TI_STATUS mlmeParser_readCountry(mlme_t *pMlme,
+                                                                UINT8 *pData,
+                                                                UINT32 dataLen,
+                                                                UINT32 *pReadLen,
+                                                                dot11_COUNTRY_t *countryIE);
+
+TI_STATUS mlmeParser_readWMEParams(mlme_t *pMlme,
+                                                                  UINT8 *pData,
+                                                                  UINT32 dataLen,
+                                                                  UINT32 *pReadLen,
+                                                                  dot11_WME_PARAM_t *pWMEParamIE, 
+                                                                  assocRsp_t *assocRsp);
+
+TI_STATUS mlmeParser_readPowerConstraint(mlme_t *pMlme,
+                                                                                UINT8 *pData,
+                                                                                UINT32 dataLen,
+                                                                                UINT32 *pReadLen,
+                                                                                dot11_POWER_CONSTRAINT_t *powerConstraintIE);
+
+TI_STATUS mlmeParser_readChannelSwitch(mlme_t *pMlme,
+                                                                          UINT8 *pData,
+                                                                          UINT32 dataLen,
+                                                                          UINT32 *pReadLen,
+                                                                          dot11_CHANNEL_SWITCH_t *channelSwitch,
+                                       UINT8 channel);
+
+TI_STATUS mlmeParser_readTPCReport(mlme_t *pMlme,
+                                                                  UINT8 *pData,
+                                                                  UINT32 dataLen,
+                                                                  UINT32 *pReadLen,
+                                                                  dot11_TPC_REPORT_t   *TPCReport);
+
+#ifdef EXC_MODULE_INCLUDED
+TI_STATUS mlmeParser_readCellTP(mlme_t *pMlme, 
+                                                               UINT8 *pData, 
+                                                               UINT32 dataLen, 
+                                                               UINT32 *pReadLen, 
+                                                               dot11_CELL_TP_t *cellTP);
+#endif
+
+TI_STATUS mlmeParser_readQuiet(mlme_t *pMlme,
+                                                          UINT8 *pData,
+                                                          UINT32 dataLen,
+                                                          UINT32 *pReadLen,
+                                                          dot11_QUIET_t *quiet);
+
+TI_STATUS mlmeParser_readChallange(mlme_t *pMlme, 
+                                                               UINT8 *pData, 
+                                                               UINT32 dataLen, 
+                                                               UINT32 *pReadLen, 
+                                                               dot11_CHALLENGE_t *pChallange);
+
+
+TI_STATUS mlmeParser_readRsnIe(mlme_t *pMlme, 
+                               UINT8 *pData, 
+                               UINT32 dataLen, 
+                               UINT32 *pReadLen, 
+                               dot11_RSN_t *pRsnIe);
+
+TI_STATUS mlmeParser_readQosCapabilityIE(mlme_t *pMlme,
+                                                                                UINT8 *pData, 
+                                                                                UINT32 dataLen, 
+                                                                                UINT32 *pReadLen, 
+                                                                                dot11_QOS_CAPABILITY_IE_t *QosCapParams);
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/mlme/mlmeSm.c b/sta_dk_4_0_4_32/common/src/core/mlme/mlmeSm.c
new file mode 100644 (file)
index 0000000..6246cf1
--- /dev/null
@@ -0,0 +1,825 @@
+/** \file mlmeSM.c
+ *  \brief 802.11 MLME SM source
+ *
+ *  \see mlmeSM.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mlmeSM.c                                                                                                   */
+/*    PURPOSE: 802.11 MLME SM source                                                                      */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "smeApi.h"
+#include "Assoc/AssocSM.h"
+#include "Auth/authSm.h"
+#include "mlmeBuilder.h"
+#include "mlmeSm.h"
+#include "Auth/open/openAuthSm.h"
+#include "Auth/shared/sharedKeyAuthSm.h"
+#include "whalCtrl_api.h"
+#include "connApi.h"
+
+
+#ifdef TI_DBG
+#include "siteMgrApi.h"
+#endif
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+#ifdef NO_HAL_VOB
+static void mlme_logBeaconReceived(TI_HANDLE hMlme);
+#endif
+
+void mlme_stopAssocAndAuth(mlme_t *pMlme);
+
+/* functions */
+
+/**
+*
+* mlme_Create - allocate memory for MLME SM
+*
+* \b Description: 
+*
+* Allocate memory for MLME SM. \n
+*              Allocates memory for MLME context. \n
+*              Allocates memory for MLME timer. \n
+*              Allocates memory for MLME SM matrix. \n
+*
+* \b ARGS:
+*
+*  I   - pOs - OS context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecSmKeysOnlyStop()
+*/
+TI_HANDLE mlme_create(TI_HANDLE hOs)
+{
+       mlme_t  *pHandle;
+       TI_STATUS               status;
+
+       /* allocate MLME context memory */
+       pHandle = (mlme_t*)os_memoryAlloc(hOs, sizeof(mlme_t));
+       if (pHandle == NULL)
+       {
+               return NULL;
+       }
+
+       /* zero all MLME context */
+       os_memoryZero(hOs, pHandle, sizeof(mlme_t));
+
+       pHandle->hOs = hOs;
+
+       /* allocate memory for MLME state machine */
+       status = fsm_Create(hOs, &pHandle->pMlmeSm, MLME_SM_NUM_STATES, MLME_SM_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pHandle, sizeof(mlme_t));
+               return NULL;
+       }
+
+       return pHandle;
+}
+
+
+/**
+*
+* mlme_Unload - unload MLME SM from memory
+*
+* \b Description: 
+*
+* Unload MLME SM from memory
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecSmKeysOnlyStop()
+*/
+TI_STATUS mlme_unload(TI_HANDLE hMlme)
+{
+    TI_STATUS          status;
+       mlme_t          *pHandle;
+
+       pHandle = (mlme_t*)hMlme;
+
+       status = fsm_Unload(pHandle->hOs, pHandle->pMlmeSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+       }
+       
+       os_memoryFree(pHandle->hOs, hMlme, sizeof(mlme_t));
+
+       return OK;
+}
+
+/**
+*
+* mlme_smConfig - configure a new MLME SM
+*
+* \b Description: 
+*
+* Configure a new MLME SM.
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*  I   - pMlme - MLME SM context  \n
+*  I   - pSiteMgr - Site manager context  \n
+*  I   - pCtrlData - Control data context  \n
+*  I   - pTxData - TX data context  \n
+*  I   - pHalCtrl - Hal control context  \n
+*  I   - pReport - Report context  \n
+*  I   - pOs - OS context  \n
+*  I   - mlmeTimeout - MLME SM timeout \n
+*  I   - mlmeMaxCount - Max number of MLME requests to send  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa mlme_Create, mlme_Unload
+*/
+TI_STATUS mlme_config(TI_HANDLE hMlme,
+                                  TI_HANDLE hAuth,
+                                  TI_HANDLE hAssoc,
+                                  TI_HANDLE hSiteMgr,
+                                  TI_HANDLE hCtrlData,
+                                  TI_HANDLE hConn,
+                                  TI_HANDLE hTxData,
+                                  TI_HANDLE hHalCtrl,
+                                  TI_HANDLE hMemMgr,
+                                  TI_HANDLE hMeasurementMgr,
+                                  TI_HANDLE hSwitchChannel,
+                                  TI_HANDLE hRegulatoryDomain,
+                                  TI_HANDLE hReport, 
+                                  TI_HANDLE hOs,
+                                  TI_HANDLE hCurrBss,
+                                  TI_HANDLE hAPConn,
+                                  TI_HANDLE hScanCncn,
+                                  TI_HANDLE hQosMngr,
+                   TI_HANDLE hConfigMgr)
+{
+       mlme_t          *pHandle;
+       TI_STATUS               status;
+       /** Main 802.1X State Machine matrix */
+       fsm_actionCell_t        mlme_smMatrix[MLME_SM_NUM_STATES][MLME_SM_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {{MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smStartIdle},             /* MLME_SM_EVENT_START */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smNOP},                         /* MLME_SM_EVENT_STOP  */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected},           /* MLME_SM_EVENT_AUTH_SUCCESS */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected},           /* MLME_SM_EVENT_AUTH_FAIL */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected},           /* MLME_SM_EVENT_ASSOC_SUCCESS */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smActionUnexpected}            /* MLME_SM_EVENT_ASSOC_FAIL */
+               },
+               /* next state and actions for AUTH_WAIT state */
+               {{MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smActionUnexpected},      /* MLME_SM_EVENT_START */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smNOP},                                           /* MLME_SM_EVENT_STOP  */
+                {MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smAuthSuccessAuthWait},  /* MLME_SM_EVENT_AUTH_SUCCESS */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smAuthFailAuthWait},                   /* MLME_SM_EVENT_AUTH_FAIL */
+                {MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smActionUnexpected},              /* MLME_SM_EVENT_ASSOC_SUCCESS */
+                {MLME_SM_STATE_AUTH_WAIT, (fsm_Action_t)mlme_smActionUnexpected}               /* MLME_SM_EVENT_ASSOC_FAIL */
+               },
+               /* next state and actions for ASSOC_WAIT state */
+               {{MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smActionUnexpected}, /* MLME_SM_EVENT_START */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smStopAssocWait},                      /* MLME_SM_EVENT_STOP  */
+                {MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smActionUnexpected},     /* MLME_SM_EVENT_AUTH_SUCCESS */
+                {MLME_SM_STATE_ASSOC_WAIT, (fsm_Action_t)mlme_smActionUnexpected},     /* MLME_SM_EVENT_AUTH_FAIL */
+                {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smAssocSuccessAssocWait},     /* MLME_SM_EVENT_ASSOC_SUCCESS */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smAssocFailAssocWait}          /* MLME_SM_EVENT_ASSOC_FAIL */
+               },
+               /* next state and actions for ASSOC state */
+               {{MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_START */
+                {MLME_SM_STATE_IDLE, (fsm_Action_t)mlme_smStopAssoc},                  /* MLME_SM_EVENT_STOP  */
+                {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_AUTH_SUCCESS */
+                {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_AUTH_FAIL */
+                {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected},  /* MLME_SM_EVENT_ASSOC_SUCCESS */
+                {MLME_SM_STATE_ASSOC, (fsm_Action_t)mlme_smActionUnexpected}   /* MLME_SM_EVENT_ASSOC_FAIL */
+               }
+       };
+       
+
+       if (hMlme == NULL)
+       {
+               return NOK;
+       } 
+
+       pHandle = (mlme_t*)hMlme;
+       
+       status = fsm_Config(pHandle->pMlmeSm, &mlme_smMatrix[0][0], MLME_SM_NUM_STATES, MLME_SM_NUM_EVENTS, mlme_smEvent, hOs);
+       if (status != OK)
+       {
+               return NOK; 
+       }
+       
+       pHandle->currentState = MLME_SM_STATE_IDLE;
+       pHandle->legacyAuthType = AUTH_LEGACY_NONE;
+       pHandle->reAssoc = FALSE;
+       pHandle->disConnType = DISCONN_TYPE_IMMEDIATE;
+       pHandle->disConnReason = STATUS_UNSPECIFIED;
+       
+       pHandle->hAssoc = hAssoc;
+       pHandle->hAuth = hAuth;
+       pHandle->hSiteMgr = hSiteMgr;
+       pHandle->hCtrlData = hCtrlData;
+       pHandle->hTxData = hTxData;
+       pHandle->hHalCtrl = hHalCtrl;
+       pHandle->hMemMgr = hMemMgr;
+       pHandle->hMeasurementMgr = hMeasurementMgr;
+       pHandle->hSwitchChannel = hSwitchChannel;
+       pHandle->hRegulatoryDomain = hRegulatoryDomain;
+       pHandle->hReport = hReport;
+       pHandle->hOs = hOs;
+       pHandle->hConn = hConn;
+       pHandle->hCurrBss = hCurrBss;
+       pHandle->hApConn = hAPConn;
+       pHandle->hScanCncn = hScanCncn;
+    pHandle->hConfigMgr = hConfigMgr;
+
+    /* nullify beacon and probe response registration information */
+    pHandle->resultCBFunc = NULL;
+    pHandle->resultCBObj = NULL;
+       pHandle->hQosMngr = hQosMngr;
+    /*
+    debug info
+    */
+    pHandle->debug_lastProbeRspTSFTime = 0;
+    pHandle->debug_lastDtimBcnTSFTime = 0;
+    pHandle->debug_lastBeaconTSFTime = 0;
+    pHandle->debug_isFunctionFirstTime = TRUE;
+       pHandle->BeaconsCounterPS = 0;
+
+#ifdef NO_HAL_VOB
+       /* Register the Beacon interrrput that can be used for debug - 
+               i.e. on each received beacon in the FW, the FW generated  a beacon interrupt. */
+       
+       /*      there is no Beacon Receive in WSP7.1, in 4.1 its for Prints only hence will not 
+               be supported at this time */
+       WLAN_OS_REPORT(("mlme_config : NO_HAL_VOB not supported"));
+#endif
+       return OK;
+}
+
+
+TI_STATUS mlme_setParam(TI_HANDLE                      hMlmeSm,
+                                               paramInfo_t                     *pParam)
+{
+       mlme_t *pMlmeSm = (mlme_t *)hMlmeSm;
+
+       switch(pParam->paramType)
+       {
+       case MLME_LEGACY_TYPE_PARAM:
+
+               switch (pParam->content.mlmeLegacyAuthType)
+               {
+        case AUTH_LEGACY_RESERVED1:
+               case AUTH_LEGACY_OPEN_SYSTEM:
+                       /* First configure the MLME with the new legacy authentication type */
+                       pMlmeSm->legacyAuthType = pParam->content.mlmeLegacyAuthType;
+                       /* Now configure the authentication module. */
+                       pParam->paramType = AUTH_LEGACY_TYPE_PARAM;
+                       return auth_setParam(pMlmeSm->hAuth, pParam);
+
+               case AUTH_LEGACY_SHARED_KEY:
+                       /* First configure the MLME with the new legacy authentication type */
+                       pMlmeSm->legacyAuthType = AUTH_LEGACY_SHARED_KEY;
+                       /* Now configure the authentication module. */
+                       pParam->paramType = AUTH_LEGACY_TYPE_PARAM;
+                       return auth_setParam(pMlmeSm->hAuth, pParam);
+
+               case AUTH_LEGACY_AUTO_SWITCH:
+                       /* First configure the MLME with the new legacy authentication type */
+                       pMlmeSm->legacyAuthType = AUTH_LEGACY_AUTO_SWITCH;
+                       /* Now configure the authentication module, 
+                               Auto switch mode means start always with shared key, if fail move to open system. */
+                       pParam->paramType = AUTH_LEGACY_TYPE_PARAM;
+                       pParam->content.authLegacyAuthType = AUTH_LEGACY_SHARED_KEY;
+                       return auth_setParam(pMlmeSm->hAuth, pParam);
+
+               default:
+                       WLAN_REPORT_ERROR(pMlmeSm->hReport, MLME_SM_MODULE_LOG, ("Set param, Params is not supported, 0x%x\n\n", pParam->content.mlmeLegacyAuthType));
+                       return PARAM_VALUE_NOT_VALID;
+               }
+/*             break;  - unreachable */
+
+       case MLME_RE_ASSOC_PARAM:
+               pMlmeSm->reAssoc = pParam->content.mlmeReAssoc;
+               break;
+
+       default:
+               WLAN_REPORT_ERROR(pMlmeSm->hReport, MLME_SM_MODULE_LOG, ("Set param, Params is not supported, 0x%x\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+TI_STATUS mlme_getParam(TI_HANDLE                      hMlmeSm, 
+                                               paramInfo_t                     *pParam)
+{
+       mlme_t *pMlmeSm = (mlme_t *)hMlmeSm;
+
+       switch(pParam->paramType)
+       {
+       case MLME_LEGACY_TYPE_PARAM:
+               pParam->content.mlmeLegacyAuthType = pMlmeSm->legacyAuthType;                   
+               break;
+
+       case MLME_CAPABILITY_PARAM:
+               pParam->content.mlmeLegacyAuthType = pMlmeSm->legacyAuthType;
+               assoc_smCapBuild(pMlmeSm->hAssoc, &(pParam->content.siteMgrSiteCapability));
+               break;
+
+    case MLME_BEACON_RECV:
+        pParam->content.siteMgrTiWlanCounters.BeaconsRecv = pMlmeSm->BeaconsCounterPS;
+        break;
+
+       default:
+               WLAN_REPORT_ERROR(pMlmeSm->hReport, MLME_SM_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->content.mlmeLegacyAuthType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+/**
+*
+* mlme_Start - Start event for the MLME SM
+*
+* \b Description: 
+*
+* Start event for the MLME SM
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa mlme_Stop, mlme_Recv
+*/
+TI_STATUS mlme_start(TI_HANDLE hMlme)
+{
+       TI_STATUS               status;
+       mlme_t          *pHandle;
+
+       pHandle = (mlme_t*)hMlme;
+
+       if (pHandle == NULL)
+               return NOK;
+
+       if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       status = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_START, pHandle);
+
+       return status;
+}
+
+/**
+*
+* mlme_Stop - Stop event for the MLME SM
+*
+* \b Description: 
+*
+* Stop event for the MLME SM
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa mlme_Start, mlme_Recv
+*/
+TI_STATUS mlme_stop(TI_HANDLE hMlme, disConnType_e disConnType, mgmtStatus_e reason)
+{
+       TI_STATUS               status;
+       mlme_t          *pHandle;
+
+       pHandle = (mlme_t*)hMlme;
+
+       if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       pHandle->disConnType = disConnType;
+       pHandle->disConnReason = reason;
+
+       status = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_STOP, pHandle);
+       
+       return status;
+}
+
+
+/**
+*
+* mlme_reportAuthStatus - Set a specific parameter to the MLME SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the MLME SM.
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa mlme_Start, mlme_Stop
+*/
+TI_STATUS mlme_reportAuthStatus(TI_HANDLE hMlme, UINT16 status)
+{
+       mlme_t                  *pHandle;
+       paramInfo_t             param;
+    TI_STATUS       fStatus;
+
+       pHandle = (mlme_t*)hMlme;
+
+       if (pHandle == NULL)
+               return NOK;
+       if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       pHandle->mlmeData.uStatusCode = status;
+
+       /* If status is successful */
+       if (status == 0)
+       {
+               /* Mark a successful status - used for conn.c */
+               pHandle->mlmeData.mgmtStatus = STATUS_SUCCESSFUL;
+
+               fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_AUTH_SUCCESS, pHandle);
+       } 
+       else 
+       {
+               /* Now, if the MLME legacy auth type is AUTO_SWITCH, and the Auth legacy auth type is shared key, 
+                       we configure the auth SM to open system, otherwise, this is really an authentication failure. */
+               param.paramType = AUTH_LEGACY_TYPE_PARAM;
+               auth_getParam(pHandle->hAuth, &param);
+
+               if ((pHandle->legacyAuthType == AUTH_LEGACY_AUTO_SWITCH) && (param.content.authLegacyAuthType ==  AUTH_LEGACY_SHARED_KEY))
+               {
+                       param.content.authLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+                       fStatus = auth_setParam(pHandle->hAuth, &param);
+                       fStatus = auth_start(pHandle->hAuth);
+               }
+               else
+               {
+                       pHandle->mlmeData.mgmtStatus = STATUS_AUTH_REJECT;
+                       fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_AUTH_FAIL, pHandle);
+               }
+       }
+
+       return fStatus;
+}
+
+/**
+*
+* mlme_reportAssocStatus - Set a specific parameter to the MLME SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the MLME SM.
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa mlme_Start, mlme_Stop
+*/
+TI_STATUS mlme_reportAssocStatus(TI_HANDLE hMlme, UINT16 status)
+{
+       mlme_t          *pHandle;
+    TI_STATUS   fStatus;
+
+       pHandle = (mlme_t*)hMlme;
+
+       if (pHandle == NULL)
+               return NOK;
+
+       if (pHandle->legacyAuthType == AUTH_LEGACY_NONE)
+               return NOK;
+
+       pHandle->mlmeData.uStatusCode = status;
+
+       /* If status is successful */
+       if (status == 0)
+       {
+               pHandle->mlmeData.mgmtStatus = STATUS_SUCCESSFUL;
+               fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_ASSOC_SUCCESS, pHandle);
+       } else 
+       {
+               pHandle->mlmeData.mgmtStatus = STATUS_ASSOC_REJECT;
+               fStatus = mlme_smEvent(&pHandle->currentState, MLME_SM_EVENT_ASSOC_FAIL, pHandle);
+       }
+
+       return fStatus;
+}
+
+
+/**
+*
+* mlme_SetParam - Set a specific parameter to the MLME SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the MLME SM.
+*
+* \b ARGS:
+*
+*  I   - hMlme - MLME SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa mlme_Start, mlme_Stop
+*/
+
+#ifdef REPORT_LOG
+
+static char *mlmeSMStateDesc[MLME_SM_NUM_STATES] = {   
+               "MLME_SM_STATE_IDLE",
+               "MLME_SM_STATE_AUTH_WAIT",
+               "MLME_SM_STATE_ASSOC_WAIT",
+               "MLME_SM_STATE_ASSOC"
+       };
+       
+       /* State machine inputs */
+static char *mlmeSMEventDesc[MLME_SM_NUM_EVENTS] = {
+               "MLME_SM_EVENT_START",
+               "MLME_SM_EVENT_STOP",
+               "MLME_SM_EVENT_AUTH_SUCCESS",
+               "MLME_SM_EVENT_AUTH_FAIL",
+               "MLME_SM_EVENT_ASSOC_SUCCESS",
+               "MLME_SM_EVENT_ASSOC_FAIL"
+       };
+
+#endif
+
+
+TI_STATUS mlme_smEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hMlme)
+{
+   mlme_t *pMlme = (mlme_t *)hMlme;
+       TI_STATUS               status;
+       UINT8           nextState;
+
+       status = fsm_GetNextState(pMlme->pMlmeSm, *currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMlme->hReport, MLME_SM_MODULE_LOG,
+                                                 ("MLME_SM: ERROR - failed getting next state \n"));
+
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pMlme->hReport, MLME_SM_MODULE_LOG,
+                                        ("MLME_SM: <%s, %s> --> %s\n",
+                                         mlmeSMStateDesc[*currentState],
+                                         mlmeSMEventDesc[event],
+                                         mlmeSMStateDesc[nextState]));
+
+       status = fsm_Event(pMlme->pMlmeSm, currentState, event, (void *)pMlme);
+
+       return(status);
+}
+
+/* state machine functions */
+
+TI_STATUS mlme_smStartIdle(mlme_t *pMlme)
+{
+       TI_STATUS               status;
+
+       status = auth_start(pMlme->hAuth);
+
+       return status;
+}
+
+TI_STATUS mlme_smClass3Idle(mlme_t *pMlme)
+{
+       return OK;
+}
+
+
+
+TI_STATUS mlme_smAuthSuccessAuthWait(mlme_t *pMlme)
+{
+       TI_STATUS               status;
+
+       if (pMlme->reAssoc)
+       {
+               status = reassoc_start(pMlme->hAssoc);
+       }
+       else
+       {
+               status = assoc_start(pMlme->hAssoc);
+       }
+
+       return status;
+}
+
+TI_STATUS mlme_smAuthFailAuthWait(mlme_t *pMlme)
+{
+       TI_STATUS               status;
+
+       status = mlme_smReportStatus(pMlme);
+
+       return status;
+}
+
+TI_STATUS mlme_smStopAssocWait(mlme_t *pMlme)
+{
+       mlme_stopAssocAndAuth(pMlme);
+       return OK;
+}
+
+TI_STATUS mlme_smAssocSuccessAssocWait(mlme_t *pMlme)
+{
+       TI_STATUS               status;
+
+       status = mlme_smReportStatus(pMlme);
+
+       return status;
+}
+
+TI_STATUS mlme_smAssocFailAssocWait(mlme_t *pMlme)
+{
+       TI_STATUS               status;
+       status = mlme_smReportStatus(pMlme);
+
+       return status;
+}
+
+
+TI_STATUS mlme_smStopAssoc(mlme_t *pMlme)
+{
+       mlme_stopAssocAndAuth(pMlme);
+       return OK;
+}
+
+
+
+TI_STATUS mlme_smNOP(mlme_t *pMlme)
+{
+       return OK;
+}
+
+TI_STATUS mlme_smActionUnexpected(mlme_t *pMlme)
+{
+       return OK;
+}
+
+/* local functions */
+
+TI_STATUS mlme_smReportStatus(mlme_t *pMlme)
+{
+       TI_STATUS               status;
+
+       if (pMlme == NULL)
+       {
+               return NOK;
+       }
+
+       status = conn_reportMlmeStatus(pMlme->hConn, pMlme->mlmeData.mgmtStatus, pMlme->mlmeData.uStatusCode);
+
+       return status;
+}
+
+
+#ifdef NO_HAL_VOB
+static void mlme_logBeaconReceived(TI_HANDLE hMlme)
+{
+       mlme_beaconReceivedPrint(hMlme);
+}
+#endif
+
+void mlme_stopAssocAndAuth(mlme_t *pMlme)
+{
+
+       BOOL            sendDeAuth;
+       BOOL            sendDisAssoc;
+
+       switch( pMlme->disConnType )
+       {
+       case DISCONN_TYPE_IMMEDIATE:
+               sendDeAuth       = FALSE;
+               sendDisAssoc = FALSE;
+               break;
+
+       case DISCONN_TYPE_DISASSOC:
+               sendDisAssoc = TRUE;
+               sendDeAuth   = FALSE;
+               break;
+
+       case DISCONN_TYPE_DEAUTH:
+               sendDisAssoc = FALSE;
+               sendDeAuth   = TRUE;
+               break;
+
+       default:
+               return;
+       }
+
+       assoc_setDisAssocFlag(pMlme->hAssoc, sendDisAssoc);
+       assoc_stop(pMlme->hAssoc);
+       
+       auth_stop(pMlme->hAuth, sendDeAuth, pMlme->disConnReason );
+
+       /* If the dis association frame is not sent the MLME generate the event
+          by itself */
+       if (( sendDisAssoc == FALSE) && (sendDeAuth==FALSE)) {
+               conn_disConnFrameSentCBFunc(pMlme->hConn);
+       }
+}
+/*****************************************************************************
+**
+** MLME messages builder/Parser
+**
+*****************************************************************************/
+
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/admCtrl.c b/sta_dk_4_0_4_32/common/src/core/rsn/admCtrl.c
new file mode 100644 (file)
index 0000000..1b7730d
--- /dev/null
@@ -0,0 +1,1068 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 admCtrl.c
+ *  \brief Admission control API implimentation
+ *
+ *  \see admCtrl.h
+ */
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "mlmeApi.h"
+#include "DataCtrl_Api.h"
+
+#include "TI_IPC_Api.h"
+
+#include "rsn.h"
+#include "admCtrl.h"
+
+#include "admCtrlWpa.h"
+#include "admCtrlWpa2.h"
+#include "admCtrlNone.h"
+#include "admCtrlWep.h"
+#include "EvHandler.h"
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+
+/* Function prototypes */
+
+TI_STATUS admCtrl_setAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e authSuite);
+
+TI_STATUS admCtrl_getAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e *pSuite);
+
+TI_STATUS admCtrl_setNetworkMode(admCtrl_t *pAdmCtrl, rsn_networkMode_t mode);
+
+TI_STATUS admCtrl_setExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e extAuthMode);
+
+TI_STATUS admCtrl_getExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e *pExtAuthMode);
+
+TI_STATUS admCtrl_setUcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite);
+
+TI_STATUS admCtrl_setBcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite);
+
+TI_STATUS admCtrl_getCipherSuite(admCtrl_t *pAdmCtrl, cipherSuite_e *pSuite);
+
+TI_STATUS admCtrl_setKeyMngSuite(admCtrl_t *pAdmCtrl, rsn_keyMngSuite_e suite);
+
+TI_STATUS admCtrl_getMixedMode(admCtrl_t *pAdmCtrl, BOOL *pMixedMode);
+
+TI_STATUS admCtrl_setMixedMode(admCtrl_t *pAdmCtrl, BOOL mixedMode);
+
+TI_STATUS admCtrl_getAuthEncrCapability(admCtrl_t *pAdmCtrl, 
+                   rsnAuthEncrCapability_t   *authEncrCapability);
+
+TI_STATUS admCtrl_getPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 *WPAPromoteFlags);
+
+TI_STATUS admCtrl_setPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 WPAPromoteFlags);
+
+TI_STATUS admCtrl_getWPAMixedModeSupport(admCtrl_t *pAdmCtrl, UINT32 *support);
+
+TI_STATUS admCtrl_checkSetSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite, BOOL Broadcast);
+
+#ifdef EXC_MODULE_INCLUDED
+TI_STATUS admCtrl_setNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP networkEap);
+
+TI_STATUS admCtrl_getNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP *networkEap);
+#endif
+
+/**
+*
+* admCtrl_create
+*
+* \b Description: 
+*
+* Create the admission control context.
+*
+* \b ARGS:
+*
+*  I   - role - admission cotrol role (AP or Station)  \n
+*  I   - authSuite - authentication suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+admCtrl_t* admCtrl_create(TI_HANDLE hOs)
+{
+       admCtrl_t               *pHandle;
+
+       /* allocate rsniation context memory */
+       pHandle = (admCtrl_t*)os_memoryAlloc(hOs, sizeof(admCtrl_t));
+       if (pHandle == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pHandle, sizeof(admCtrl_t));
+
+    pHandle->preAuthTimerWpa2 = os_timerCreate(hOs, admCtrlWpa2_preAuthTimerExpire, pHandle);
+
+    /* If we failed to create the timer - exit with error */
+    if (pHandle->preAuthTimerWpa2 == NULL)
+    {
+       os_memoryFree(pHandle->hOs, pHandle, sizeof(admCtrl_t));
+       return NULL;
+    }
+       pHandle->hOs = hOs;
+
+       return pHandle;
+}
+
+/**
+*
+* admCtrl_unload
+*
+* \b Description: 
+*
+* Unload admission control module from memory
+*
+* \b ARGS:
+*
+*  I   - hAdmCtrl - Admossion control context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa admCtrl_create
+*/
+TI_STATUS admCtrl_unload(admCtrl_t *pAdmCtrl)
+{
+       if (pAdmCtrl == NULL)
+       {
+               return NOK;
+       }
+       
+    /* Stop and destroy the wpa2 pre-authentication timer */
+   os_timerStop(pAdmCtrl->hOs, pAdmCtrl->preAuthTimerWpa2);
+   utils_nullTimerDestroy(pAdmCtrl->hOs, pAdmCtrl->preAuthTimerWpa2);
+       os_memoryFree(pAdmCtrl->hOs, pAdmCtrl, sizeof(admCtrl_t));
+
+       return OK;
+}
+
+/**
+*
+* admCtrl_config
+*
+* \b Description: 
+*
+* Configure the admission control module.
+*
+* \b ARGS:
+*
+*  I   - role - admission cotrol role (AP or Station)  \n
+*  I   - authSuite - authentication suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_config(TI_HANDLE hAdmCtrl,
+                                         TI_HANDLE hMlme,
+                                         TI_HANDLE hRx,
+                                         TI_HANDLE hReport,
+                                         TI_HANDLE hOs,
+                                         struct _rsn_t *pRsn,
+                                         TI_HANDLE hExcMngr,
+                                         TI_HANDLE hPowerMgr,
+                         TI_HANDLE     hEvHandler,
+                                         rsnInitParams_t *pInitParam)
+{
+       admCtrl_t               *pAdmCtrl;
+       TI_STATUS                       status;
+
+       if (hAdmCtrl == NULL)
+       {
+               return NOK;
+       }
+       
+       pAdmCtrl = (admCtrl_t*)hAdmCtrl;
+
+       pAdmCtrl->pRsn = pRsn;
+       pAdmCtrl->hMlme = hMlme;
+       pAdmCtrl->hRx = hRx;
+       pAdmCtrl->hReport = hReport;
+       pAdmCtrl->hOs = hOs;
+       pAdmCtrl->hExcMngr = hExcMngr;
+       pAdmCtrl->hPowerMgr = hPowerMgr;
+    pAdmCtrl->hEvHandler = hEvHandler;
+
+       /* Initialize admission control parameters */
+       pAdmCtrl->role = RSN_PAE_SUPP;
+       pAdmCtrl->networkMode = RSN_INFRASTRUCTURE;
+       pAdmCtrl->authSuite     = pInitParam->authSuite;
+       pAdmCtrl->externalAuthMode = pInitParam->externalAuthMode;
+    pAdmCtrl->mixedMode = pInitParam->mixedMode;
+       
+    if (pInitParam->privacyOn)
+    {
+        pAdmCtrl->broadcastSuite = RSN_CIPHER_WEP;
+        pAdmCtrl->unicastSuite = RSN_CIPHER_WEP;
+    } else {
+        pAdmCtrl->broadcastSuite = RSN_CIPHER_NONE;
+        pAdmCtrl->unicastSuite = RSN_CIPHER_NONE;
+    }
+
+       pAdmCtrl->preAuthSupport     = pInitParam->preAuthSupport;
+    pAdmCtrl->preAuthTimeout     = pInitParam->preAuthTimeout;
+       pAdmCtrl->WPAMixedModeEnable = pInitParam->WPAMixedModeEnable;
+       /*pAdmCtrl->PMKIDCandListDelay = pInitParam->PMKIDCandListDelay;*/
+       pAdmCtrl->MaxNumOfPMKIDs     = PMKID_MAX_NUMBER;
+
+       /* Initialize admission control member functions */
+       pAdmCtrl->setAuthSuite = admCtrl_setAuthSuite;
+       pAdmCtrl->setNetworkMode = admCtrl_setNetworkMode;
+       pAdmCtrl->getAuthSuite = admCtrl_getAuthSuite;
+       pAdmCtrl->setExtAuthMode = admCtrl_setExtAuthMode;
+       pAdmCtrl->getExtAuthMode = admCtrl_getExtAuthMode;
+       pAdmCtrl->setUcastSuite = admCtrl_setUcastSuite;
+       pAdmCtrl->setBcastSuite = admCtrl_setBcastSuite;
+       pAdmCtrl->getCipherSuite = admCtrl_getCipherSuite;
+       pAdmCtrl->setKeyMngSuite = admCtrl_setKeyMngSuite;
+    pAdmCtrl->getMixedMode = admCtrl_getMixedMode;
+    pAdmCtrl->setMixedMode = admCtrl_setMixedMode;
+    pAdmCtrl->getAuthEncrCap = admCtrl_getAuthEncrCapability;
+    pAdmCtrl->getPmkidList   = admCtrl_nullGetPMKIDlist;
+    pAdmCtrl->setPmkidList   = admCtrl_nullSetPMKIDlist;
+    pAdmCtrl->resetPmkidList = admCtrl_resetPMKIDlist;
+    pAdmCtrl->getPromoteFlags = admCtrl_getPromoteFlags;
+    pAdmCtrl->setPromoteFlags = admCtrl_setPromoteFlags;
+    pAdmCtrl->getWPAMixedModeSupport = admCtrl_getWPAMixedModeSupport;
+#ifdef EXC_MODULE_INCLUDED
+       pAdmCtrl->setNetworkEap = admCtrl_setNetworkEap;
+       pAdmCtrl->getNetworkEap = admCtrl_getNetworkEap;
+    pAdmCtrl->networkEapMode = OS_EXC_NETWORK_EAP_OFF;
+#endif
+
+       pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
+       pAdmCtrl->startPreAuth  = admCtrl_nullStartPreAuth;
+    pAdmCtrl->get802_1x_AkmExists = admCtrl_nullGet802_1x_AkmExists;
+    /* Zero number of sent wpa2 preauthentication candidates */
+    pAdmCtrl->numberOfPreAuthCandidates = 0;
+
+       status = admCtrl_subConfig(pAdmCtrl);
+
+       return status;
+}
+
+/**
+*
+* admCtrl_subConfig
+*
+* \b Description: 
+*
+* Configure the admission control module according to the Privacy Mode.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admission cotrol context  \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_subConfig(TI_HANDLE hAdmCtrl)
+
+{
+    admCtrl_t* pAdmCtrl = (admCtrl_t*)hAdmCtrl;
+       TI_STATUS status;
+
+       switch(pAdmCtrl->externalAuthMode)
+       {
+       case RSN_EXT_AUTH_MODE_WPA:
+       case RSN_EXT_AUTH_MODE_WPAPSK:
+       case RSN_EXT_AUTH_MODE_WPANONE:
+               status = admCtrlWpa_config(pAdmCtrl);
+               break;
+
+       case RSN_EXT_AUTH_MODE_WPA2:
+       case RSN_EXT_AUTH_MODE_WPA2PSK:
+               status = admCtrlWpa2_config(pAdmCtrl);
+               break;
+
+       default:
+               if(pAdmCtrl->unicastSuite==RSN_CIPHER_NONE)
+               {
+                       status = admCtrlNone_config(pAdmCtrl);
+               }
+               else
+               {
+                       status = admCtrlWep_config(pAdmCtrl);
+               }
+               break;
+
+       }
+       
+       return status;
+
+}
+
+/**
+*
+* admCtrl_setNetworkMode - Change current network mode.
+*
+* \b Description: 
+*
+* Change current network mode.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - mode - network association mode (Infustrucure/IBSS) \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setNetworkMode(admCtrl_t *pAdmCtrl, rsn_networkMode_t mode)
+{
+    pAdmCtrl->networkMode = mode;
+
+    return OK;
+}
+
+/**
+*
+* admCtrl_setAuthSuite - Change current authentication suite.
+*
+* \b Description: 
+*
+* Change current authentication suite.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - authSuite - authentication suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e authSuite)
+{
+       TI_STATUS               status = NOK;
+
+       if (pAdmCtrl == NULL)
+       {
+               return NOK;
+       }
+
+       if (pAdmCtrl->authSuite == authSuite)
+       {
+               return OK;
+       }
+
+       if (pAdmCtrl->authSuite > RSN_AUTH_AUTO_SWITCH)
+       {
+               return NOK;
+       }
+       pAdmCtrl->externalAuthMode = (externalAuthMode_e)authSuite;
+       pAdmCtrl->authSuite = authSuite;
+       status = admCtrl_subConfig(pAdmCtrl);
+       return status;
+}
+
+
+/**
+*
+* admCtrl_getAuthSuite  - Get current authentication suite.
+*
+* \b Description: 
+*
+* Get current authentication suite.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  O   - suite - key management suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_getAuthSuite(admCtrl_t *pAdmCtrl, authSuite_e *pSuite)
+{
+       if (pAdmCtrl == NULL)
+       {
+               return NOK;
+       }
+
+       *pSuite = pAdmCtrl->authSuite;
+
+       return OK;
+}
+
+/**
+*
+* admCtrl_setExtAuthMode  - Set current External authentication Mode Status.
+*
+* \b Description: 
+*
+* Set current External authentication Mode Status.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - extAuthMode - External authentication Mode \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e extAuthMode)
+{
+
+       if (extAuthMode >= RSN_EXT_AUTH_MODEMAX)
+       {
+               return NOK;
+       }
+
+
+       if (pAdmCtrl->externalAuthMode == extAuthMode)
+       {
+               return OK;
+       }
+       pAdmCtrl->externalAuthMode = extAuthMode;
+       if (extAuthMode <= RSN_EXT_AUTH_MODE_AUTO_SWITCH)
+       {
+               pAdmCtrl->authSuite = (authSuite_e)extAuthMode;
+       }
+       else
+       {
+               pAdmCtrl->authSuite = RSN_AUTH_OPEN;
+       }
+       
+       return (admCtrl_subConfig(pAdmCtrl));
+}
+
+/**
+*
+* admCtrl_getExtAuthMode  - Get current External authentication Mode Status.
+*
+* \b Description: 
+*
+* Get current External Mode Status.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pExtAuthMode - EXC External Mode Status \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_getExtAuthMode(admCtrl_t *pAdmCtrl, externalAuthMode_e *pExtAuthMode)
+{
+       *pExtAuthMode = pAdmCtrl->externalAuthMode;
+
+       return OK;
+}
+
+
+/**
+*
+* admCtrl_checkSetSuite -
+*
+* \b Description: 
+*
+* Check the validity/support of the cipher suite according to
+* the admission control parameters
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - suite - cipher suite to check \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_checkSetSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite, BOOL Broadcast)
+{
+       if (pAdmCtrl->externalAuthMode<=RSN_EXT_AUTH_MODE_AUTO_SWITCH)
+       {   
+               if ((suite==RSN_CIPHER_NONE) || (suite==RSN_CIPHER_WEP) || (suite==RSN_CIPHER_WEP104))
+               {
+                       return OK;
+               }
+       }
+       else
+       {
+               if ((suite==RSN_CIPHER_TKIP) || (suite==RSN_CIPHER_WEP) || 
+                       (suite==RSN_CIPHER_WEP104) || (suite==RSN_CIPHER_AES_CCMP))
+               {
+                       return OK;
+               }
+               else if (!Broadcast && (suite==RSN_CIPHER_NONE))
+               {
+                       return OK;
+               }
+       }
+       return NOK;
+}
+
+/**
+*
+* admCtrl_setUcastSuite  - Set current unicast cipher suite support.
+*
+* \b Description: 
+*
+* Set current unicast cipher suite support.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - suite - cipher suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setUcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite)
+{
+       TI_STATUS status;
+
+       if (suite == pAdmCtrl->unicastSuite)
+       {
+               return OK;
+       }
+       status = admCtrl_checkSetSuite(pAdmCtrl, suite, FALSE);
+       if (status == OK)
+       {
+               pAdmCtrl->unicastSuite = suite;
+               status = admCtrl_subConfig(pAdmCtrl);
+       }
+
+       return status;
+}
+
+/**
+*
+* admCtrl_setBcastSuite  - Set current broadcast cipher suite support.
+*
+* \b Description: 
+*
+* Set current broadcast cipher suite support.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - suite - cipher suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setBcastSuite(admCtrl_t *pAdmCtrl, cipherSuite_e suite)
+{
+       TI_STATUS status;
+
+       if (suite == pAdmCtrl->broadcastSuite)
+       {
+               return OK;
+       }
+
+       status = admCtrl_checkSetSuite(pAdmCtrl, suite, TRUE);
+       if (status == OK)
+       {
+               pAdmCtrl->broadcastSuite = suite;
+               status = admCtrl_subConfig(pAdmCtrl);
+       }
+       return status;
+
+}
+
+/**
+*
+* admCtrl_getCipherSuite  - Set current broadcast cipher suite support.
+*
+* \b Description: 
+*
+* Set current broadcast cipher suite support.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  O   - suite - cipher suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_getCipherSuite(admCtrl_t *pAdmCtrl, cipherSuite_e *pSuite)
+{
+       if (pAdmCtrl == NULL)
+       {
+               return NOK;
+       }
+
+       *pSuite = (pAdmCtrl->broadcastSuite > pAdmCtrl->unicastSuite) ? pAdmCtrl->broadcastSuite :pAdmCtrl->unicastSuite;
+        
+       return OK;
+}
+       
+/**
+*
+* admCtrl_setKeyMngSuite  - Set current key management suite support.
+*
+* \b Description: 
+*
+* Set current key management suite support.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - suite - key management suite to work with \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setKeyMngSuite(admCtrl_t *pAdmCtrl, rsn_keyMngSuite_e suite)
+{
+    pAdmCtrl->keyMngSuite = suite;
+
+       return OK;
+}
+
+
+/**
+*
+* admCtrl_parseIe  - Parse a required information element.
+*
+* \b Description: 
+*
+* Parse an Aironet information element. 
+* Builds a structure of all the capabilities described in the Aironet IE.
+* We look at Flags field only to determine KP and MIC bits value
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  I   - pAironetIe - pointer to Aironet IE buffer  \n
+*  O   - pAironetData - capabilities structure
+*  
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrl_parseIe(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 **pIe, UINT8 IeId)
+{
+
+       dot11_eleHdr_t   *eleHdr;
+       INT16                    length;
+       UINT8            *pCurIe;
+
+
+       *pIe = NULL;
+
+       if ((pRsnData == NULL) || (pRsnData->ieLen==0))
+       {
+          return OK;   
+       }
+
+       pCurIe = pRsnData->pIe;
+       
+       length = pRsnData->ieLen;
+       while (length>0)
+       {
+               eleHdr = (dot11_eleHdr_t*)pCurIe;
+               
+               if (length<(eleHdr->eleLen+2))
+               {
+                       WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                                               ("admCtrl_parseIe ERROR: pRsnData->ieLen=%d, length=%d\n\n", pRsnData->ieLen,length));
+                       return OK;
+               }
+               
+               if (eleHdr->eleId == IeId)
+               {
+            *pIe = (UINT8*)eleHdr;
+            break;
+               }
+               length -= eleHdr->eleLen+2;
+               pCurIe += eleHdr->eleLen+2;
+       }
+       return OK;
+}
+
+/**
+*
+* admCtrl_setMixedMode  - Set current mixed Mode Status.
+*
+* \b Description: 
+*
+* Set current mixed Mode Status.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - authMode - mixed Mode \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setMixedMode(admCtrl_t *pAdmCtrl, BOOL mixedMode)
+{
+
+       if (pAdmCtrl->mixedMode == mixedMode)
+       {
+               return OK;
+       }
+       pAdmCtrl->mixedMode = mixedMode;
+
+       return OK;
+}
+
+/**
+*
+* admCtrl_getMixedMode  - Get current mixed Mode Status.
+*
+* \b Description: 
+*
+* Get current mixed Mode Status.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pAuthMode - mixed Mode Status \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_getMixedMode(admCtrl_t *pAdmCtrl, BOOL *pMixedMode)
+{
+       *pMixedMode = pAdmCtrl->mixedMode;
+
+       return OK;
+}
+
+
+
+/* This table presents supported pairs of auth.mode/cipher type */
+static         authEncrPairList_t  supportedAuthEncrPairs[MAX_AUTH_ENCR_PAIR] = 
+{
+       {RSN_EXT_AUTH_MODE_OPEN,       RSN_CIPHER_NONE},
+       {RSN_EXT_AUTH_MODE_OPEN,       RSN_CIPHER_WEP},
+       {RSN_EXT_AUTH_MODE_SHARED_KEY, RSN_CIPHER_NONE},
+       {RSN_EXT_AUTH_MODE_SHARED_KEY, RSN_CIPHER_WEP},
+       {RSN_EXT_AUTH_MODE_WPA,        RSN_CIPHER_TKIP},
+       {RSN_EXT_AUTH_MODE_WPA,        RSN_CIPHER_AES_CCMP},
+       {RSN_EXT_AUTH_MODE_WPAPSK,     RSN_CIPHER_TKIP},
+       {RSN_EXT_AUTH_MODE_WPAPSK,     RSN_CIPHER_AES_CCMP},
+       {RSN_EXT_AUTH_MODE_WPANONE,    RSN_CIPHER_NONE},    /* No encryption in IBSS mode */
+       {RSN_EXT_AUTH_MODE_WPA2,       RSN_CIPHER_TKIP},
+       {RSN_EXT_AUTH_MODE_WPA2,       RSN_CIPHER_AES_CCMP},
+       {RSN_EXT_AUTH_MODE_WPA2PSK,    RSN_CIPHER_TKIP},
+       {RSN_EXT_AUTH_MODE_WPA2PSK,    RSN_CIPHER_AES_CCMP}
+};
+
+/**
+*
+* admCtrl_getAuthEncrCapability  - Get all supported pais of
+*                                  authenticationmode/cipher suite
+*
+* \b Description: 
+*
+*    Returns all supported pais of authenticationmode/cipher suite
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - authEncrCapability - ptr to list of auth.mode/cipher pairs \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+
+TI_STATUS admCtrl_getAuthEncrCapability(admCtrl_t *pAdmCtrl, 
+                                        rsnAuthEncrCapability_t   *authEncrCapability)
+{
+    int i = 0;
+
+    if(!authEncrCapability)
+        return NOK;
+
+    /* The current driver code version  uses the above hardcoded list */
+    /* of auth/encr pairs */
+
+    authEncrCapability->NoOfAuthEncrPairSupported = MAX_AUTH_ENCR_PAIR;
+    authEncrCapability->NoOfPMKIDs                = PMKID_MAX_NUMBER;
+
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+    ("admCtrl get AuthEncr capability:  No. of auth/encr pairs = %d, No of PMKIDs = %d \n", 
+        authEncrCapability->NoOfAuthEncrPairSupported,  authEncrCapability->NoOfPMKIDs));
+
+    /* Copy the hardcoded table of the auth.mode/cipher type */
+    for (i = 0; i < MAX_AUTH_ENCR_PAIR; i++)
+    {
+        authEncrCapability->authEncrPairs[i].authenticationMode = 
+            supportedAuthEncrPairs[i].authenticationMode;
+        authEncrCapability->authEncrPairs[i].cipherSuite        = 
+            supportedAuthEncrPairs[i].cipherSuite;
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+            ("admCtrl get AuthEncr pair list: i = %d, auth mode = %d , cipher suite = %d \n", i,
+                       authEncrCapability->authEncrPairs[i].authenticationMode,
+                       authEncrCapability->authEncrPairs[i].cipherSuite));
+    }
+    
+    return OK;
+}
+
+
+TI_STATUS admCtrl_nullSetPMKIDlist(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList)
+{
+
+    return CONFIGURATION_NOT_VALID;
+}
+
+TI_STATUS admCtrl_nullGetPMKIDlist(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList)
+{
+
+    return CONFIGURATION_NOT_VALID;
+}
+
+
+TI_STATUS admCtrl_resetPMKIDlist(admCtrl_t *pAdmCtrl)
+{
+
+    os_memoryZero(pAdmCtrl->hOs, (PVOID)&pAdmCtrl->pmkid_cache, sizeof(pmkid_cache_t));
+    return OK;
+}
+
+TI_STATUS admCtrl_getWPAMixedModeSupport(admCtrl_t *pAdmCtrl, UINT32 *support)
+{
+    
+    if(pAdmCtrl->WPAMixedModeEnable)
+       *support = ADMCTRL_WPA_OPTION_MAXVALUE;
+    else
+       *support = 0;
+
+    return OK;
+}
+
+TI_STATUS admCtrl_getPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 *WPAPromoteFlags)
+{
+    *WPAPromoteFlags = pAdmCtrl->WPAPromoteFlags;
+    return OK;
+}
+
+TI_STATUS admCtrl_setPromoteFlags(admCtrl_t *pAdmCtrl, UINT32 WPAPromoteFlags)
+{
+    if(WPAPromoteFlags > ADMCTRL_WPA_OPTION_MAXVALUE)
+        return NOK;
+
+    if(!pAdmCtrl->WPAMixedModeEnable)
+       return NOK;
+
+    pAdmCtrl->WPAPromoteFlags = WPAPromoteFlags;
+    return OK;
+}
+
+BOOL admCtrl_nullGetPreAuthStatus(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8 *cacheIndex)
+{
+    return FALSE;
+}
+
+
+TI_STATUS admCtrl_nullStartPreAuth(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList)
+{
+       return OK;
+}
+
+TI_STATUS admCtrl_nullGet802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists)
+{
+    *wpa_802_1x_AkmExists = FALSE;
+    return OK;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: admCtrl_notifyPreAuthStatus
+Routine Description: This routine is used to notify higher level application of the pre-authentication status
+Arguments: newStatus - pre authentication status
+Return Value:
+-----------------------------------------------------------------------------*/
+void admCtrl_notifyPreAuthStatus (admCtrl_t *pAdmCtrl, preAuthStatusEvent_e newStatus)
+{
+    UINT32 memBuff;
+
+    memBuff = (UINT32) newStatus;
+
+    EvHandlerSendEvent(pAdmCtrl->hEvHandler, IPC_EVENT_WPA2_PREAUTHENTICATION,
+                            (UINT8*)&memBuff, sizeof(UINT32));
+
+}
+
+#ifdef EXC_MODULE_INCLUDED
+
+/**
+*
+* admCtrl_setNetworkEap  - Set current Network EAP Mode Status.
+*
+* \b Description: 
+*
+* Set current Network EAP Mode Status..
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - networkEap - Network EAP Mode \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_setNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP networkEap)
+{
+       if (pAdmCtrl==NULL)
+               return NOK;
+
+       if (pAdmCtrl->networkEapMode == networkEap)
+       {
+               return OK;
+       }
+       pAdmCtrl->networkEapMode = networkEap;
+       
+       return OK;
+}
+
+/**
+*
+* admCtrl_getNetworkEap  - Get current Network EAP Mode Status.
+*
+* \b Description: 
+*
+* Get current Network EAP Mode Status.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - networkEap - Network EAP Mode \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrl_getNetworkEap(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP *networkEap)
+{
+       
+       if (pAdmCtrl==NULL)
+       {
+               return NOK;
+       }
+
+       switch (pAdmCtrl->networkEapMode)
+       {
+       case OS_EXC_NETWORK_EAP_OFF: 
+               *networkEap = OS_EXC_NETWORK_EAP_OFF;
+               break; 
+       case OS_EXC_NETWORK_EAP_ON:      
+       case OS_EXC_NETWORK_EAP_ALLOWED:
+       case OS_EXC_NETWORK_EAP_PREFERRED:
+               *networkEap = OS_EXC_NETWORK_EAP_ON;
+               break;
+       default:
+               return NOK;
+/*             break; - unreachable */
+       }
+
+       return OK;
+}
+#endif /* EXC_MODULE_INCLUDED*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlNone.c b/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlNone.c
new file mode 100644 (file)
index 0000000..51f0adb
--- /dev/null
@@ -0,0 +1,332 @@
+/** \file admCtrl.c
+ *  \brief Admission control API implimentation
+ *
+ *  \see admCtrl.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "mlmeApi.h"
+#include "DataCtrl_Api.h"
+
+#include "rsn.h"
+#include "admCtrl.h"
+#include "admCtrlNone.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#include "admCtrlWpa.h"
+#include "admCtrlExc.h"
+#endif
+
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+
+/* Function prototypes */
+
+/**
+*
+* admCtrlNone_config  - Configure empty admission control.
+*
+* \b Description: 
+*
+* Configure empty admission control.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrlNone_config(admCtrl_t *pAdmCtrl)
+{
+       TI_STATUS                       status;
+       rsn_paeConfig_t         paeConfig;
+
+#ifdef EXC_MODULE_INCLUDED
+       whalParamInfo_t                 whalParam;
+#endif
+
+       if ((pAdmCtrl->authSuite !=     RSN_AUTH_OPEN ) &&
+               (pAdmCtrl->authSuite != RSN_AUTH_SHARED_KEY) &&
+               (pAdmCtrl->authSuite != RSN_AUTH_AUTO_SWITCH))  {
+               /* The default is OPEN */
+               pAdmCtrl->authSuite =   RSN_AUTH_OPEN;
+       }
+       
+       /* set admission control parameters */
+    pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
+       pAdmCtrl->externalAuthMode = (externalAuthMode_e)pAdmCtrl->authSuite;
+       
+       /* set callback functions (API) */
+       pAdmCtrl->getInfoElement = admCtrlNone_getInfoElement;
+       pAdmCtrl->setSite = admCtrlNone_setSite;
+       pAdmCtrl->evalSite = admCtrlNone_evalSite;
+
+       pAdmCtrl->getPmkidList   = admCtrl_nullGetPMKIDlist;
+       pAdmCtrl->setPmkidList   = admCtrl_nullSetPMKIDlist;
+       pAdmCtrl->resetPmkidList = admCtrl_resetPMKIDlist;
+       pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
+       pAdmCtrl->startPreAuth  = admCtrl_nullStartPreAuth;
+    pAdmCtrl->get802_1x_AkmExists = admCtrl_nullGet802_1x_AkmExists;
+
+
+       
+       /* set cipher suite */
+       pAdmCtrl->broadcastSuite =  RSN_CIPHER_NONE;
+       pAdmCtrl->unicastSuite = RSN_CIPHER_NONE;
+
+
+       /* set PAE parametrs */
+       paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
+       paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
+       paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
+       paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
+       /* set default PAE configuration */
+       status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
+                                               
+#ifdef EXC_MODULE_INCLUDED
+       /* Clean MIC and KP in HAL and re-send WEP-keys  */
+       whalParam.paramType = HAL_CTRL_RSN_EXC_SW_ENC_ENABLE_PARAM; 
+       whalParam.content.rsnExcSwEncFlag = FALSE;
+       status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+
+       whalParam.paramType = HAL_CTRL_RSN_EXC_MIC_FIELD_ENABLE_PARAM; 
+       whalParam.content.rsnExcMicFieldFlag = FALSE;
+       status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+#endif /*EXC_MODULE_INCLUDED*/
+
+       return status;
+}
+
+
+/**
+*
+* admCtrlNone_getInfoElement - Get the current information element.
+*
+* \b Description: 
+*
+* Get the current information element.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pIe - IE buffer \n
+*  I   - pLength - length of IE \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrlNone_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength)
+{
+       *pLength = 0;
+       pIe = NULL;
+
+       UNUSED(pIe);
+       return OK;
+}
+/**
+*
+* admCtrlNone_setSite  - Set current primary site parameters for registration.
+*
+* \b Description: 
+*
+* Set current primary site parameters for registration.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pAssocIe - result IE of evaluation \n
+*  O   - pAssocIeLen - length of result IE of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK on site is aproved, NOK on site is rejected.
+*
+* \sa 
+*/
+TI_STATUS admCtrlNone_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
+{
+       TI_STATUS                       status;
+       paramInfo_t                     param;
+       whalParamInfo_t         whalParam;
+       authSuite_e                     authSuite;
+
+       admCtrlNone_config(pAdmCtrl);
+
+       authSuite = pAdmCtrl->authSuite;
+
+  /* Config the default keys */
+       if ((authSuite == RSN_AUTH_SHARED_KEY) || (authSuite == RSN_AUTH_AUTO_SWITCH))
+       {   /* Configure Security status in HAL */
+               whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
+               whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_WEP;
+               status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+               /* Configure the keys in HAL */
+               rsn_setDefaultKeys(pAdmCtrl->pRsn);
+       }
+
+#ifdef EXC_MODULE_INCLUDED
+       admCtrlExc_setExtendedParams(pAdmCtrl, pRsnData);
+#endif
+
+       /* Now we configure the MLME module with the 802.11 legacy authentication suite, 
+               THe MLME will configure later the authentication module */
+       param.paramType = MLME_LEGACY_TYPE_PARAM;
+       switch (authSuite)
+       {
+       case RSN_AUTH_OPEN:
+               param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+               break;
+
+       case RSN_AUTH_SHARED_KEY: 
+               param.content.mlmeLegacyAuthType = AUTH_LEGACY_SHARED_KEY;
+               break;
+
+       case RSN_AUTH_AUTO_SWITCH:
+               param.content.mlmeLegacyAuthType = AUTH_LEGACY_AUTO_SWITCH;
+               break;
+
+       default:
+               return NOK;
+       }
+       
+       status = mlme_setParam(pAdmCtrl->hMlme, &param);
+       if (status != OK)
+       {
+               return status;
+       }
+
+       param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
+       param.content.rxDataEapolDestination = OS_ABS_LAYER;
+       status = rxData_setParam(pAdmCtrl->hRx, &param);
+       if (status != OK)
+       {
+               return status;
+       }
+
+       /* Configure privacy status in HAL */
+       if (authSuite == RSN_AUTH_OPEN)
+       {
+               whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
+               whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_NONE;
+               status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+       }
+
+       return status;
+}
+
+/**
+*
+* admCtrlNone_evalSite  - Evaluate site for registration.
+*
+* \b Description: 
+*
+* evaluate site RSN capabilities against the station's cap.
+* If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
+* In IBSS, it does not matter
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - Context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pEvaluation - Result of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK 
+*
+* \sa 
+*/
+TI_STATUS admCtrlNone_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation)
+{
+       if ((pAdmCtrl==NULL) || (pEvaluation==NULL)){
+               return NOK;
+       }
+       *pEvaluation = 1;
+       
+       /* Check privacy bit if not in mixed mode */
+       if (!pAdmCtrl->mixedMode)
+       {   /* There's no mixed mode, so make sure that the privacy Bit is off*/
+               if (pRsnData->privacy)
+               {
+                       *pEvaluation = 0;
+                       return NOK;
+               }
+       }
+
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                        ("admCtrlNone_evalSite:  pEvaluation=%d\n\n", *pEvaluation));
+
+       return OK;
+       
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWep.c b/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWep.c
new file mode 100644 (file)
index 0000000..cfcf03f
--- /dev/null
@@ -0,0 +1,357 @@
+/** \file admCtrlWep.c
+ *  \brief Admission control API implimentation
+ *
+ *  \see admCtrl.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+#include "mlmeApi.h"
+#include "DataCtrl_Api.h"
+
+#include "rsnApi.h"
+#include "admCtrl.h"
+
+#include "rsn.h"
+#include "admCtrl.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "admCtrlWpa.h"
+#include "admCtrlExc.h"
+#endif
+
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+
+/* Function prototypes */
+TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
+
+TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
+
+
+/**
+*
+* admCtrlWep_config  - Configure EXC admission control.
+*
+* \b Description: 
+*
+* Configure EXC admission control.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrlWep_config(admCtrl_t *pAdmCtrl)
+{
+       TI_STATUS                       status;
+       rsn_paeConfig_t         paeConfig;
+
+       
+       /* set admission control parameters */
+       pAdmCtrl->externalAuthMode = (externalAuthMode_e)pAdmCtrl->authSuite;      
+       if ((pAdmCtrl->unicastSuite != RSN_CIPHER_WEP) && 
+               (pAdmCtrl->unicastSuite != RSN_CIPHER_CKIP))
+       {
+               pAdmCtrl->unicastSuite = RSN_CIPHER_WEP;
+       }
+       
+       if ((pAdmCtrl->broadcastSuite != RSN_CIPHER_WEP) && 
+               (pAdmCtrl->broadcastSuite != RSN_CIPHER_CKIP))
+       {
+               pAdmCtrl->broadcastSuite = RSN_CIPHER_WEP;
+       }
+
+       /* set callback functions (API) */
+       pAdmCtrl->getInfoElement = admCtrlWep_getInfoElement;
+       pAdmCtrl->setSite = admCtrlWep_setSite;
+       pAdmCtrl->evalSite = admCtrlWep_evalSite;
+       pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
+       pAdmCtrl->startPreAuth  = admCtrl_nullStartPreAuth;
+    pAdmCtrl->get802_1x_AkmExists = admCtrl_nullGet802_1x_AkmExists;
+
+
+               
+       pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
+
+       /* set PAE parametrs */
+       paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
+       paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
+       paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
+       paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
+       /* set default PAE configuration */
+       status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
+
+       return status;
+}
+
+/**
+*
+* admCtrlWep_getInfoElement - Build the current information element.
+*
+* \b Description: 
+*
+* Build the current information element.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pIe - IE buffer \n
+*  I   - pLength - length of IE \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*                                                        
+* \sa 
+*/
+TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength)
+{
+        
+       if ((pAdmCtrl==NULL) || (pLength==NULL)) 
+       {
+               return NOK;
+       }
+       *pLength = 0;
+       return OK;
+
+}
+/**
+*
+* admCtrlWep_setSite  - Set current primary site parameters for registration.
+*
+* \b Description: 
+*
+* Set current primary site parameters for registration.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pAssocIe - result IE of evaluation \n
+*  O   - pAssocIeLen - length of result IE of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK on site is aproved, NOK on site is rejected.
+*
+* \sa 
+*/
+TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
+{
+       TI_STATUS                       status;
+       paramInfo_t                     param;
+    whalParamInfo_t     whalParam;
+       authSuite_e                     authSuite;
+
+#ifdef EXC_MODULE_INCLUDED
+       if (parseIeBuffer(pAdmCtrl->hOs, pRsnData->pIe, pRsnData->ieLen, EXC_EXT_1_IE_ID, NULL, NULL, 0))
+       {
+               pAdmCtrl->excSupport = TRUE;
+               return (admCtrlExc_setSite(pAdmCtrl, pRsnData, pAssocIe, pAssocIeLen));
+       }
+#endif
+
+
+       pAdmCtrl->excSupport = FALSE;
+       pAdmCtrl->unicastSuite = RSN_CIPHER_WEP;
+       pAdmCtrl->broadcastSuite = RSN_CIPHER_WEP;
+
+       admCtrlWep_config(pAdmCtrl);
+
+       authSuite = pAdmCtrl->authSuite;
+
+  /* Config the default keys */
+       if ((authSuite == RSN_AUTH_SHARED_KEY) || (authSuite == RSN_AUTH_AUTO_SWITCH))
+       {       /* Configure Security status in HAL */
+               whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
+               whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_WEP;
+               status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+               /* Configure the keys in HAL */
+               rsn_setDefaultKeys(pAdmCtrl->pRsn);
+       }
+
+
+       /* Now we configure the MLME module with the 802.11 legacy authentication suite, 
+               THe MLME will configure later the authentication module */
+       param.paramType = MLME_LEGACY_TYPE_PARAM;
+#ifdef EXC_MODULE_INCLUDED     
+       if (pAdmCtrl->networkEapMode!=OS_EXC_NETWORK_EAP_OFF)
+    {
+        param.content.mlmeLegacyAuthType = AUTH_LEGACY_RESERVED1;
+    }
+    else
+#endif
+    {
+        switch (authSuite)
+        {
+        case RSN_AUTH_OPEN:
+            param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+            break;
+
+        case RSN_AUTH_SHARED_KEY: 
+            param.content.mlmeLegacyAuthType = AUTH_LEGACY_SHARED_KEY;
+            break;
+
+        case RSN_AUTH_AUTO_SWITCH:
+            param.content.mlmeLegacyAuthType = AUTH_LEGACY_AUTO_SWITCH;
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport , RSN_MODULE_LOG, 
+                          ("WEP admCtrl mlme_setParam, RSN_AUTH_AUTO_SWITCH\n"));
+            break;
+
+        default:
+            return NOK;
+        }
+    }
+       
+       status = mlme_setParam(pAdmCtrl->hMlme, &param);
+       if (status != OK)
+       {
+               return status;
+       }
+
+       param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
+       param.content.rxDataEapolDestination = OS_ABS_LAYER;
+       status = rxData_setParam(pAdmCtrl->hRx, &param);
+       if (status != OK)
+       {
+               return status;
+       }
+
+       /* Configure Security status in HAL */
+    whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
+    whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_WEP;
+    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+
+       return status;
+
+}
+
+/**
+*
+* admCtrlWep_evalSite  - Evaluate site for registration.
+*
+* \b Description: 
+*
+* evaluate site RSN capabilities against the station's cap.
+* If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
+* In IBSS, it does not matter
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - Context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pEvaluation - Result of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation)
+{
+       
+       *pEvaluation = 0;
+       
+       if (pRsnData==NULL)
+       {
+               return NOK;
+       }
+    pAdmCtrl->setSiteFirst = FALSE;
+
+#ifdef EXC_MODULE_INCLUDED
+       if (admCtrlExc_evalSite(pAdmCtrl, pRsnData, bssType, pEvaluation, &pAdmCtrl->excSupport) != OK)
+    {
+        return NOK;
+    }
+#else
+       pAdmCtrl->excSupport = FALSE;
+#endif /*EXC_MODULE_INCLUDED*/
+       if (!pAdmCtrl->excSupport)
+       {       /* WEP only */
+               *pEvaluation = 1;
+       }
+
+       /* Check privacy bit if not in mixed mode */
+       if (!pAdmCtrl->mixedMode)
+       {       /* There's no mixed mode, so make sure that the privacy Bit matches the privacy mode*/
+               if (!pRsnData->privacy)
+                       {
+                               *pEvaluation = 0;
+                return NOK;
+                       }
+       }
+
+       return OK;
+}
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWpa.c b/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWpa.c
new file mode 100644 (file)
index 0000000..c878cf1
--- /dev/null
@@ -0,0 +1,1338 @@
+/** \file admCtrl.c
+ *  \brief Admission control API implimentation
+ *
+ *  \see admCtrl.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+
+#include "utils.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "mlmeApi.h"
+#include "802_11Defs.h"
+#include "DataCtrl_Api.h"
+#include "report.h"
+
+#include "utils.h"
+
+#include "rsn.h"
+#include "admCtrl.h"
+#include "admCtrlWpa.h"
+#include "admCtrlWpa2.h"
+
+
+#ifdef EXC_MODULE_INCLUDED
+#include "admCtrlExc.h"
+#include "excMngr.h"
+#endif
+
+/* Constants */
+#define MAX_NETWORK_MODE 2
+#define MAX_WPA_CIPHER_SUITE 7
+
+
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+
+static UINT8 wpaIeOuiIe[3] = { 0x00, 0x50, 0xf2};
+
+static BOOL broadcastCipherSuiteValidity[MAX_NETWORK_MODE][MAX_WPA_CIPHER_SUITE]=
+{
+    /* RSN_IBSS */  {
+/* NONE                  */    FALSE,
+/* WEP40         */    FALSE,
+/* TKIP                  */    TRUE,
+/* AES_WRAP      */    TRUE,
+/* AES_CCMP      */    TRUE,
+/* WEP104     */    FALSE,
+/* CKIP       */    FALSE},
+
+    /* RSN_INFRASTRUCTURE */  {
+/* NONE                  */    FALSE,
+/* WEP           */    TRUE,
+/* TKIP                  */    TRUE,
+/* AES_WRAP      */    TRUE,
+/* AES_CCMP      */    TRUE,
+/* WEP104     */    TRUE,
+/* CKIP       */    TRUE}
+};
+
+/** WPA admission table. Used to verify admission parameters to an AP */
+/* table parameters:
+    Max unicast cipher in the IE
+    Max broadcast cipher in the IE
+    Encryption status 
+*/
+typedef struct
+{
+    TI_STATUS        status;
+    cipherSuite_e    unicast;
+    cipherSuite_e    broadcast;
+    UINT8            evaluation; 
+} admCtrlWpa_validity_t;
+
+static admCtrlWpa_validity_t    admCtrlWpa_validityTable[MAX_WPA_CIPHER_SUITE][MAX_WPA_CIPHER_SUITE][MAX_WPA_CIPHER_SUITE] =
+{
+/* AP unicast NONE */ {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP40 */ { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP40 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP40 */ { OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP ,1},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP104 ,1}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_TKIP ,2},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_AES_WRAP ,3},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_AES_CCMP ,3},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP40 */ { OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP ,1},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP104 ,1}}},
+/* AP unicast WEP */  {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { OK, RSN_CIPHER_WEP, RSN_CIPHER_WEP ,1},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK, RSN_CIPHER_WEP, RSN_CIPHER_WEP ,1},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast TKIP */  {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_WEP  ,4},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_TKIP ,7},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_WEP104 ,4},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast AES_WRAP */ {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP40 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_WEP ,5},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_TKIP ,6},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_AES_WRAP ,8},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_WEP104 ,5},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast AES_CCMP */ {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_WEP ,5},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_TKIP ,6},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_AES_CCMP ,7},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_WEP104 ,5},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast WEP104 */  {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK, RSN_CIPHER_WEP104, RSN_CIPHER_WEP104 ,1},
+            /* STA WEP104 */{ OK, RSN_CIPHER_WEP104, RSN_CIPHER_WEP104 ,1}}}
+
+
+};
+
+/* Function prototypes */
+TI_STATUS admCtrlWpa_parseIe(admCtrl_t *pAdmCtrl, UINT8 *pWpaIe, wpaIeData_t *pWpaData);
+UINT16 admCtrlWpa_buildCapabilities(UINT16 replayCnt);
+UINT32  admCtrlWpa_parseSuiteVal(admCtrl_t *pAdmCtrl, UINT8* suiteVal,wpaIeData_t *pWpaData,UINT32 maxVal);
+TI_STATUS admCtrlWpa_checkCipherSuiteValidity (cipherSuite_e unicastSuite, cipherSuite_e broadcastSuite, cipherSuite_e encryptionStatus);
+static TI_STATUS admCtrlWpa_get802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists);
+
+
+/**
+*
+* admCtrlWpa_config  - Configure EXC admission control.
+*
+* \b Description: 
+*
+* Configure EXC admission control.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa_config(admCtrl_t *pAdmCtrl)
+{
+    TI_STATUS           status;
+    rsn_paeConfig_t     paeConfig;
+
+    /* check and set admission control default parameters */
+    pAdmCtrl->authSuite =   RSN_AUTH_OPEN;
+    if (pAdmCtrl->unicastSuite == RSN_CIPHER_NONE)
+    {
+        pAdmCtrl->unicastSuite = RSN_CIPHER_TKIP;
+    }
+    if (pAdmCtrl->broadcastSuite == RSN_CIPHER_NONE)
+    {
+        pAdmCtrl->broadcastSuite = RSN_CIPHER_TKIP;
+    }
+
+    /* set callback functions (API) */
+    pAdmCtrl->getInfoElement = admCtrlWpa_getInfoElement;
+    pAdmCtrl->setSite = admCtrlWpa_setSite;
+    pAdmCtrl->evalSite = admCtrlWpa_evalSite;
+
+    pAdmCtrl->getPmkidList      = admCtrl_nullGetPMKIDlist;
+    pAdmCtrl->setPmkidList      = admCtrl_nullSetPMKIDlist;
+    pAdmCtrl->resetPmkidList    = admCtrl_resetPMKIDlist;
+    pAdmCtrl->getPreAuthStatus = admCtrl_nullGetPreAuthStatus;
+       pAdmCtrl->startPreAuth  = admCtrl_nullStartPreAuth;
+    pAdmCtrl->get802_1x_AkmExists = admCtrlWpa_get802_1x_AkmExists;
+
+    /* set cipher suite */                                  
+    switch (pAdmCtrl->externalAuthMode)
+    {
+    case RSN_EXT_AUTH_MODE_WPA:
+    case RSN_EXT_AUTH_MODE_WPAPSK:
+        /* The cipher suite should be set by the External source via 
+        the Encryption field*/
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
+        break;
+    case RSN_EXT_AUTH_MODE_WPANONE:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
+        /* Not supported */
+    default:
+        return NOK;
+    }
+
+
+    paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
+    paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
+    paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
+    paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
+       /* set default PAE configuration */
+    status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
+
+    return status;
+}
+
+
+
+
+TI_STATUS admCtrlWpa_dynamicConfig(admCtrl_t *pAdmCtrl,wpaIeData_t *pWpaData)
+{
+    TI_STATUS           status;
+    rsn_paeConfig_t     paeConfig;
+
+
+    /* set callback functions (API) */
+    pAdmCtrl->getInfoElement = admCtrlWpa_getInfoElement;
+
+    switch (pAdmCtrl->externalAuthMode)
+    {
+    case RSN_EXT_AUTH_MODE_WPA:
+    case RSN_EXT_AUTH_MODE_WPAPSK:
+        /* The cipher suite should be set by the External source via 
+        the Encryption field*/
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
+        break;
+    case RSN_EXT_AUTH_MODE_WPANONE:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
+        /* Not supported */
+    default:
+        return NOK;
+    }
+
+
+    paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
+    paeConfig.unicastSuite = pWpaData->unicastSuite[0];
+    paeConfig.broadcastSuite = pWpaData->broadcastSuite;
+    paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
+       /* set default PAE configuration */
+    status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
+
+    return status;
+}
+
+/**
+*
+* admCtrlWpa_getInfoElement - Get the current information element.
+*
+* \b Description: 
+*
+* Get the current information element.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pIe - IE buffer \n
+*  I   - pLength - length of IE \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+
+TI_STATUS admCtrlWpa_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength)
+{
+    wpaIePacket_t       localWpaPkt;
+    wpaIePacket_t       *pWpaIePacket;
+    UINT8               length;
+#ifdef FOUR_ALIGNMENT
+       UINT16                          tempInt;
+#endif
+
+    if (pIe==NULL)
+    {
+        *pLength = 0;
+        return NOK;
+    }
+
+    
+    /* Check validity of WPA IE */
+    if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][pAdmCtrl->broadcastSuite])
+    {   /* check Group suite validity */                                          
+        *pLength = 0;
+        return NOK;
+    }
+   
+    
+    if (pAdmCtrl->unicastSuite == RSN_CIPHER_WEP)
+    {   /* check pairwise suite validity */                                       
+        *pLength = 0;
+        return NOK;
+    }
+
+    /* Build Wpa IE */
+    pWpaIePacket = &localWpaPkt;
+    os_memoryZero(pAdmCtrl->hOs, pWpaIePacket, sizeof(wpaIePacket_t));
+    pWpaIePacket->elementid= WPA_IE_ID;
+    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpaIePacket->oui, wpaIeOuiIe, 3);
+    pWpaIePacket->ouiType = WPA_OUI_DEF_TYPE;
+#ifndef FOUR_ALIGNMENT
+       pWpaIePacket->version = ENDIAN_HANDLE_WORD(WPA_OUI_MAX_VERSION);
+#else
+    /* required for WinCe, when the pointer is not even */
+       tempInt = ENDIAN_HANDLE_WORD(WPA_OUI_MAX_VERSION);
+       os_memoryCopy(pAdmCtrl->hOs, (UINT8*)&pWpaIePacket->version, &tempInt, sizeof(pWpaIePacket->version));
+#endif
+
+
+    length = sizeof(wpaIePacket_t)-2;
+    /* check defaults */
+    if (pAdmCtrl->replayCnt==1)
+    {
+        length -= 2; /* 2: capabilities + 4: keyMng suite, 2: keyMng count*/
+#if 0 /* The following was removed since there are APs which do no accept
+       the default WPA IE */
+               if (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA)
+               {
+                       length -= 6; /* 2: capabilities + 4: keyMng suite, 2: keyMng count*/
+                       if (pAdmCtrl->unicastSuite == RSN_CIPHER_TKIP)
+                       {
+                               length -= 6; /* 4: unicast suite, 2: unicast count */
+                               if (pAdmCtrl->broadcastSuite == RSN_CIPHER_TKIP)
+                               {
+                                       length -= 4;  /* broadcast suite */
+                               }
+                       }
+               }
+#endif
+       }
+    pWpaIePacket->length = length;
+    *pLength = length+2;
+
+    
+       
+       if (length>=WPA_IE_MIN_DEFAULT_LENGTH)
+    {   /* build Capabilities */
+        pWpaIePacket->capabilities = ENDIAN_HANDLE_WORD(admCtrlWpa_buildCapabilities(pAdmCtrl->replayCnt));
+       }
+
+       if (length>=WPA_IE_MIN_KEY_MNG_SUITE_LENGTH(1))
+       {
+        /* build keyMng suite */
+#ifndef FOUR_ALIGNMENT        
+               pWpaIePacket->authKeyMngSuiteCnt = ENDIAN_HANDLE_WORD(0x0001);
+#else
+        /* required for WinCe, when the pointer is not even */
+        tempInt =  ENDIAN_HANDLE_WORD(0x0001);
+        os_memoryCopy (pAdmCtrl->hOs,(UINT8*)&pWpaIePacket->authKeyMngSuiteCnt, &tempInt, sizeof(pWpaIePacket->authKeyMngSuiteCnt)); 
+#endif
+
+        os_memoryCopy(pAdmCtrl->hOs, (void *)pWpaIePacket->authKeyMngSuite, wpaIeOuiIe, 3);
+        
+        switch (pAdmCtrl->externalAuthMode)
+        {
+        case RSN_EXT_AUTH_MODE_OPEN:
+        case RSN_EXT_AUTH_MODE_SHARED_KEY:
+        case RSN_EXT_AUTH_MODE_AUTO_SWITCH:
+            pWpaIePacket->authKeyMngSuite[3] = WPA_IE_KEY_MNG_NONE;
+            break;
+               case RSN_EXT_AUTH_MODE_WPA:
+                       {
+#ifdef EXC_MODULE_INCLUDED
+                               UINT8   akmSuite[DOT11_OUI_LEN+1];
+
+                               if (admCtrlExc_getCckmAkm(pAdmCtrl, akmSuite))
+                               {
+                                       os_memoryCopy(pAdmCtrl->hOs, (PVOID)pWpaIePacket->authKeyMngSuite, akmSuite, DOT11_OUI_LEN+1);
+                               }
+                               else
+#endif
+                               {
+                                       pWpaIePacket->authKeyMngSuite[3] = WPA_IE_KEY_MNG_801_1X;
+                               }
+                       }
+
+            break;
+
+        case RSN_EXT_AUTH_MODE_WPAPSK:
+            pWpaIePacket->authKeyMngSuite[3] = WPA_IE_KEY_MNG_PSK_801_1X;
+            break;
+        default:
+            pWpaIePacket->authKeyMngSuite[3] = WPA_IE_KEY_MNG_NONE;
+            break;
+        }
+         
+    }
+
+    
+    if (length>=WPA_IE_MIN_PAIRWISE_SUITE_LENGTH)
+    {  
+#ifdef EXC_MODULE_INCLUDED       
+        if ((pAdmCtrl->pRsn->paeConfig.unicastSuite==RSN_CIPHER_CKIP) || (pAdmCtrl->pRsn->paeConfig.broadcastSuite==RSN_CIPHER_CKIP))
+        {
+           admCtrlExc_getWpaCipherInfo(pAdmCtrl,pWpaIePacket);
+        }
+        else
+#endif
+        {
+        
+            /* build pairwise suite */
+    #ifndef FOUR_ALIGNMENT        
+                   pWpaIePacket->pairwiseSuiteCnt = ENDIAN_HANDLE_WORD(0x0001);
+    #else
+            /* required for WinCe, when the pointer is not even */
+            tempInt =  ENDIAN_HANDLE_WORD(0x0001);
+            os_memoryCopy (pAdmCtrl->hOs,(UINT8*)&pWpaIePacket->pairwiseSuiteCnt, &tempInt, sizeof(pWpaIePacket->pairwiseSuiteCnt));
+    #endif
+
+            os_memoryCopy(pAdmCtrl->hOs, (void *)pWpaIePacket->pairwiseSuite, wpaIeOuiIe, 3);
+            pWpaIePacket->pairwiseSuite[3] = (UINT8)pAdmCtrl->pRsn->paeConfig.unicastSuite;
+       
+            if (length>=WPA_IE_GROUP_SUITE_LENGTH)
+            {   /* build group suite */
+                os_memoryCopy(pAdmCtrl->hOs, (void *)pWpaIePacket->groupSuite, wpaIeOuiIe, 3);
+                pWpaIePacket->groupSuite[3] = (UINT8)pAdmCtrl->pRsn->paeConfig.broadcastSuite;
+            }
+        }
+    }
+    os_memoryCopy(pAdmCtrl->hOs, (UINT8*)pIe, (UINT8*)pWpaIePacket, sizeof(wpaIePacket_t));
+    return OK;
+
+}
+/**
+*
+* admCtrlWpa_setSite  - Set current primary site parameters for registration.
+*
+* \b Description: 
+*
+* Set current primary site parameters for registration.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pAssocIe - result IE of evaluation \n
+*  O   - pAssocIeLen - length of result IE of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK on site is aproved, NOK on site is rejected.
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
+{
+    TI_STATUS           status;
+    paramInfo_t         param;
+    whalParamInfo_t     whalParam;
+    wpaIeData_t         wpaData;
+    cipherSuite_e       encryptionStatus;
+    admCtrlWpa_validity_t *pAdmCtrlWpa_validity=NULL;
+    UINT8                 *pWpaIe;
+    UINT8                 index;
+
+    *pAssocIeLen = 0;
+
+    if (pRsnData==NULL)
+    {
+        return NOK;
+    }
+    if (pRsnData->pIe==NULL)
+    {
+               /* configure the MLME module with the 802.11 OPEN authentication suite, 
+                       THe MLME will configure later the authentication module */
+               param.paramType = MLME_LEGACY_TYPE_PARAM;
+               param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+               status = mlme_setParam(pAdmCtrl->hMlme, &param);
+               if (status != OK)
+               {
+                       return status;
+               }
+
+        return OK;
+    }
+
+#ifdef EXC_MODULE_INCLUDED
+       /* Check if Aironet IE exists */
+       admCtrlExc_setExtendedParams(pAdmCtrl, pRsnData);
+#endif /*EXC_MODULE_INCLUDED*/
+
+    /* Check if any-WPA mode is supported and WPA2 info elem is presented */
+    /* If yes - perform WPA2 set site  procedure                          */
+    if(pAdmCtrl->WPAMixedModeEnable && pAdmCtrl->WPAPromoteFlags)
+    {
+        if((admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpaIe, RSN_IE_ID)== OK) &&
+           (pWpaIe != NULL))
+        {
+           status = admCtrlWpa2_setSite(pAdmCtrl, pRsnData,  pAssocIe, pAssocIeLen);
+           if(status == OK)
+               return status;
+        }
+    }
+    
+       status = admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpaIe, WPA_IE_ID);
+       if (status != OK)                                                         
+       {                                                                                    
+               return status;                                                        
+       }
+    status = admCtrlWpa_parseIe(pAdmCtrl, pWpaIe, &wpaData);
+    if (status != OK)
+    {
+        return status;
+    }
+    if ((wpaData.unicastSuite[0]>=MAX_WPA_CIPHER_SUITE) ||
+        (wpaData.broadcastSuite>=MAX_WPA_CIPHER_SUITE) ||
+        (pAdmCtrl->unicastSuite>=MAX_WPA_CIPHER_SUITE))
+    {
+        return NOK;
+    }
+
+    pAdmCtrl->encrInSw = wpaData.excKp;
+    pAdmCtrl->micInSw = wpaData.excMic; 
+
+    /*Because ckip is a proprietary encryption for Cisco then a different validity check is needed */
+    if(wpaData.broadcastSuite == RSN_CIPHER_CKIP || wpaData.unicastSuite[0] ==  RSN_CIPHER_CKIP)
+    {
+        pAdmCtrl->getCipherSuite(pAdmCtrl, &encryptionStatus);
+       /*Funk supplicant can support CCKM only if it configures the driver to TKIP encryption. */
+        if (encryptionStatus != RSN_CIPHER_TKIP) 
+            return NOK;
+        if (pAdmCtrl->encrInSw)
+            pAdmCtrl->excSupport = TRUE;
+    }
+    else
+    {
+        /* Check validity of Group suite */
+        if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][wpaData.broadcastSuite])
+        {   /* check Group suite validity */                                          
+            return NOK;
+        }
+
+        pAdmCtrl->getCipherSuite(pAdmCtrl, &encryptionStatus);
+        for (index=0; index<wpaData.unicastSuiteCnt; index++)
+        {
+            pAdmCtrlWpa_validity = &admCtrlWpa_validityTable[wpaData.unicastSuite[index]][wpaData.broadcastSuite][encryptionStatus];
+            if (pAdmCtrlWpa_validity->status ==OK)
+            {
+                break;
+            }
+        }
+
+        if (pAdmCtrlWpa_validity->status !=OK)
+        {
+            return pAdmCtrlWpa_validity->status;
+        }
+   
+        /* set cipher suites */
+        wpaData.unicastSuite[0] = pAdmCtrlWpa_validity->unicast ;/*wpaData.unicastSuite[0];*/
+        wpaData.broadcastSuite = pAdmCtrlWpa_validity->broadcast; /*wpaData.broadcastSuite;*/
+    }
+    /* set external auth mode according to the key Mng Suite */
+    switch (wpaData.KeyMngSuite[0])
+    {
+    case WPA_IE_KEY_MNG_NONE:
+        pAdmCtrl->externalAuthMode = RSN_EXT_AUTH_MODE_OPEN;
+        break;
+       case WPA_IE_KEY_MNG_801_1X:
+#ifdef EXC_MODULE_INCLUDED
+       case WPA_IE_KEY_MNG_CCKM:
+#endif
+        pAdmCtrl->externalAuthMode = RSN_EXT_AUTH_MODE_WPA;
+        break;
+    case WPA_IE_KEY_MNG_PSK_801_1X:
+        pAdmCtrl->externalAuthMode = RSN_EXT_AUTH_MODE_WPAPSK;
+        break;
+    default:
+        pAdmCtrl->externalAuthMode = RSN_EXT_AUTH_MODE_OPEN;
+        break;
+    }
+
+      
+
+#ifdef EXC_MODULE_INCLUDED
+       param.paramType = EXC_CCKM_EXISTS;
+       param.content.excCckmExists = (wpaData.KeyMngSuite[0]==WPA_IE_KEY_MNG_CCKM) ? TRUE : FALSE;
+       excMngr_setParam(pAdmCtrl->hExcMngr, &param);
+#endif
+    /* set replay counter */
+    pAdmCtrl->replayCnt = wpaData.replayCounters;
+
+    *pAssocIeLen = pRsnData->ieLen;
+    if (pAssocIe != NULL)
+    {
+        os_memoryCopy(pAdmCtrl->hOs, pAssocIe, &wpaData, sizeof(wpaIeData_t));
+    }
+
+
+    /* Now we configure the MLME module with the 802.11 legacy authentication suite, 
+        THe MLME will configure later the authentication module */
+    param.paramType = MLME_LEGACY_TYPE_PARAM;
+#ifdef EXC_MODULE_INCLUDED
+       if (pAdmCtrl->networkEapMode!=OS_EXC_NETWORK_EAP_OFF)
+    {
+        param.content.mlmeLegacyAuthType = AUTH_LEGACY_RESERVED1;
+    }
+       else
+#endif
+       {
+               param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+       }
+    
+    
+    status = mlme_setParam(pAdmCtrl->hMlme, &param);
+    if (status != OK)
+    {
+        return status;
+    }
+
+    param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
+    param.content.rxDataEapolDestination = OS_ABS_LAYER;
+    status = rxData_setParam(pAdmCtrl->hRx, &param);
+    if (status != OK)
+    {
+        return status;
+    }
+
+       /* Configure privacy status in HAL so that HW is prepared to recieve keys */
+       whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;   
+       whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)wpaData.unicastSuite[0];
+       status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+       if (status != OK)
+       {
+               return status;
+       }
+
+#ifdef EXC_MODULE_INCLUDED
+           
+       /* set MIC and KP in HAL  */
+    whalParam.paramType = HAL_CTRL_RSN_EXC_SW_ENC_ENABLE_PARAM; 
+    whalParam.content.rsnExcSwEncFlag = wpaData.excKp;
+    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+    if (status != OK)
+    {
+        return status;
+    }
+    whalParam.paramType = HAL_CTRL_RSN_EXC_MIC_FIELD_ENABLE_PARAM; 
+    whalParam.content.rsnExcMicFieldFlag = wpaData.excMic;
+    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+    
+    if (status != OK)
+    {
+        return status;
+    }
+#endif /*EXC_MODULE_INCLUDED*/
+
+    /* re-config PAE */
+    status = admCtrlWpa_dynamicConfig(pAdmCtrl,&wpaData);
+    if (status != OK)
+    {
+        return status;
+    }
+
+
+    return status;
+}
+
+/**
+*
+* admCtrlWpa_evalSite  - Evaluate site for registration.
+*
+* \b Description: 
+*
+* evaluate site RSN capabilities against the station's cap.
+* If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
+* In IBSS, it does not matter
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - Context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pEvaluation - Result of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation)
+{
+    TI_STATUS               status;
+    wpaIeData_t             wpaData;
+    admCtrlWpa_validity_t   admCtrlWpa_validity;
+    cipherSuite_e           encryptionStatus;
+    UINT8                   *pWpaIe;
+    UINT8                   index;
+
+    *pEvaluation = 0;
+
+    if (pRsnData==NULL)
+    {
+        return NOK;
+    }
+    if (pRsnData->pIe==NULL)
+    {
+        return NOK;
+    }
+    
+    if (bssType != BSS_INFRASTRUCTURE)
+    {
+        return NOK;
+    }
+
+    /* Set initial values for admCtrlWpa_validity as none*/
+    admCtrlWpa_validity = admCtrlWpa_validityTable[RSN_CIPHER_NONE][RSN_CIPHER_NONE][RSN_CIPHER_NONE];
+   
+    /* Check if WPA-any mode is supported and WPA2 info elem is presented */
+    /* If yes - perform WPA2 site evaluation                              */
+    if(pAdmCtrl->WPAMixedModeEnable && pAdmCtrl->WPAPromoteFlags)
+    {
+        if((admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpaIe, RSN_IE_ID)== OK)  &&
+           (pWpaIe != NULL))
+        {
+            status = admCtrlWpa2_evalSite(pAdmCtrl, pRsnData,  bssType, pEvaluation);
+            if(status == OK)
+                return status;
+        }
+    }
+       
+       status = admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpaIe, WPA_IE_ID);
+       if (status != OK)                                                         
+       {                                                                                    
+               return status;                                                        
+       }
+    status = admCtrlWpa_parseIe(pAdmCtrl, pWpaIe, &wpaData);
+    if (status != OK)
+    {
+        return status;
+    }
+
+    /* check keyMngSuite validity */
+    switch (wpaData.KeyMngSuite[0])
+    {
+    case WPA_IE_KEY_MNG_NONE:
+        status = (pAdmCtrl->externalAuthMode <= RSN_EXT_AUTH_MODE_AUTO_SWITCH) ? OK : NOK;
+        break;
+    case WPA_IE_KEY_MNG_801_1X:
+#ifdef EXC_MODULE_INCLUDED
+       case WPA_IE_KEY_MNG_CCKM:
+               /* CCKM is allowed only in 802.1x auth */
+#endif
+        status = (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA) ? OK : NOK;
+        break;
+    case WPA_IE_KEY_MNG_PSK_801_1X:
+        status = (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPAPSK) ? OK : NOK;
+        break;
+    default:
+        status = NOK;
+        break;
+    }
+    if (status != OK)
+    {
+        return status;
+    }
+
+    /*Because ckip is a proprietary encryption for Cisco then a different validity check is needed */
+    if(wpaData.broadcastSuite == RSN_CIPHER_CKIP || wpaData.unicastSuite[0] ==  RSN_CIPHER_CKIP)
+    {
+        pAdmCtrl->getCipherSuite(pAdmCtrl, &encryptionStatus);
+        if (encryptionStatus != RSN_CIPHER_TKIP) 
+            return NOK;
+    }
+    else
+    {
+        /* Check cipher suite validity */
+        pAdmCtrl->getCipherSuite(pAdmCtrl, &encryptionStatus);
+        for (index=0; index<wpaData.unicastSuiteCnt; index++)
+        {
+            admCtrlWpa_validity = admCtrlWpa_validityTable[wpaData.unicastSuite[index]][wpaData.broadcastSuite][encryptionStatus];
+            if (admCtrlWpa_validity.status ==OK)
+            {
+                break;
+            }
+        }
+
+        if (admCtrlWpa_validity.status!=OK)
+        {
+            return admCtrlWpa_validity.status;
+        }
+    
+        wpaData.broadcastSuite  = admCtrlWpa_validity.broadcast;
+        wpaData.unicastSuite[0] = admCtrlWpa_validity.unicast;
+        *pEvaluation = admCtrlWpa_validity.evaluation;
+    }
+
+    /* Check privacy bit if not in mixed mode */
+    if (!pAdmCtrl->mixedMode)
+    {   /* There's no mixed mode, so make sure that the privacy Bit matches the privacy mode*/
+        if (((pRsnData->privacy) && (wpaData.unicastSuite[0]==RSN_CIPHER_NONE)) ||
+            ((!pRsnData->privacy) && (wpaData.unicastSuite[0]>RSN_CIPHER_NONE)))
+        {
+            *pEvaluation = 0;
+        }
+    }
+
+    /* always return OK */
+    return OK;
+}
+
+
+/**
+*
+* admCtrlWpa_parseIe  - Parse an WPA information element.
+*
+* \b Description: 
+*
+* Parse an WPA information element. 
+* Builds a structure of the unicast adn broadcast cihper suites,
+* the key management suite and the capabilities.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  I   - pWpaIe - pointer to WPA IE buffer  \n
+*  O   - pWpaData - capabilities structure
+*  
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa_parseIe(admCtrl_t *pAdmCtrl, UINT8 *pWpaIe, wpaIeData_t *pWpaData)
+{
+
+    wpaIePacket_t   *wpaIePacket = (wpaIePacket_t*)pWpaIe;
+    UINT8           *curWpaIe;
+    UINT8           curLength = WPA_IE_MIN_LENGTH;
+
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                            ("Wpa_IE: DEBUG: admCtrlWpa_parseIe\n\n"));
+
+    if ((pWpaData == NULL) || (pWpaIe == NULL))
+    {
+        return NOK;
+    }
+
+    if ((wpaIePacket->length < WPA_IE_MIN_LENGTH) ||
+        (wpaIePacket->elementid != WPA_IE_ID) ||
+        (wpaIePacket->ouiType > WPA_OUI_MAX_TYPE) || (ENDIAN_HANDLE_WORD(wpaIePacket->version) > WPA_OUI_MAX_VERSION) ||               
+        (os_memoryCompare(pAdmCtrl->hOs, (PUINT8)wpaIePacket->oui, wpaIeOuiIe, 3)))
+    {
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("Wpa_ParseIe Error: length=0x%x, elementid=0x%x, ouiType=0x%x, version=0x%x, oui=0x%x, 0x%x, 0x%x\n", 
+                                 wpaIePacket->length,wpaIePacket->elementid,
+                                 wpaIePacket->ouiType, wpaIePacket->version,
+                                 wpaIePacket->oui[0], wpaIePacket->oui[1],wpaIePacket->oui[2]));
+
+        return NOK; 
+    }
+    /* Set default values */
+    pWpaData->broadcastSuite = RSN_CIPHER_TKIP;
+    pWpaData->unicastSuiteCnt = 1;
+    pWpaData->unicastSuite[0] = RSN_CIPHER_TKIP;
+    pWpaData->KeyMngSuiteCnt = 1;
+    pWpaData->KeyMngSuite[0] = (rsn_keyMngSuite_e)WPA_IE_KEY_MNG_801_1X;
+    pWpaData->bcastForUnicatst = 1;
+    pWpaData->replayCounters = 1;
+
+    pWpaData->excKp = FALSE;
+    pWpaData->excMic = FALSE;
+
+
+    /* Group Suite */
+    if (wpaIePacket->length >= WPA_IE_GROUP_SUITE_LENGTH)
+    {
+        pWpaData->broadcastSuite = (cipherSuite_e)admCtrlWpa_parseSuiteVal(pAdmCtrl, (UINT8 *)wpaIePacket->groupSuite,pWpaData,RSN_CIPHER_WEP104);
+        curLength = WPA_IE_GROUP_SUITE_LENGTH;
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("Wpa_IE: GroupSuite%x, broadcast %x \n",
+                                 wpaIePacket->groupSuite[3], pWpaData->broadcastSuite));
+    } else
+    {
+        return OK;
+    }
+    /* Unicast Suite */ 
+    if (wpaIePacket->length >= WPA_IE_MIN_PAIRWISE_SUITE_LENGTH)
+    {
+        UINT16 pairWiseSuiteCnt = ENDIAN_HANDLE_WORD(wpaIePacket->pairwiseSuiteCnt);
+        BOOL   cipherSuite[MAX_WPA_UNICAST_SUITES]={FALSE, FALSE, FALSE, FALSE, FALSE, FALSE , FALSE};
+        INT32  index, unicastSuiteIndex=0;
+
+        curWpaIe = (UINT8*)&(wpaIePacket->pairwiseSuite);
+        for (index=0; (index<pairWiseSuiteCnt) && (wpaIePacket->length >= (WPA_IE_MIN_PAIRWISE_SUITE_LENGTH+(index+1)*4)); index++)
+        {
+            cipherSuite_e   curCipherSuite;
+
+            curCipherSuite = (cipherSuite_e)admCtrlWpa_parseSuiteVal(pAdmCtrl, curWpaIe,pWpaData,RSN_CIPHER_WEP104);
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                    ("Wpa_IE: pairwiseSuite %x , unicast %x \n",
+                                     curWpaIe[3], curCipherSuite));
+
+            if ((curCipherSuite!=RSN_CIPHER_UNKNOWN) && (curCipherSuite<MAX_WPA_UNICAST_SUITES))
+            {
+                cipherSuite[curCipherSuite] =  TRUE;
+            }
+            curWpaIe +=4; 
+        }
+        for (index=MAX_WPA_UNICAST_SUITES-1; index>=0; index--)
+        {
+            if (cipherSuite[index])
+            {
+                pWpaData->unicastSuite[unicastSuiteIndex] = (cipherSuite_e)index;
+                WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("Wpa_IE: unicast %x \n", pWpaData->unicastSuite[unicastSuiteIndex]));
+                unicastSuiteIndex++;
+            }
+        }
+        pWpaData->unicastSuiteCnt = unicastSuiteIndex;
+        curLength = WPA_IE_MIN_KEY_MNG_SUITE_LENGTH(pairWiseSuiteCnt);
+        
+    } else
+    {
+        return OK;
+    }
+    /* KeyMng Suite */
+    if (wpaIePacket->length >= curLength)
+    {
+        UINT16              keyMngSuiteCnt = ENDIAN_HANDLE_WORD(*curWpaIe);
+        UINT16              index;
+        rsn_keyMngSuite_e   maxKeyMngSuite = (rsn_keyMngSuite_e)WPA_IE_KEY_MNG_NONE;
+
+        curWpaIe +=2;
+        pAdmCtrl->wpaAkmExists = FALSE;
+        for (index=0; (index<keyMngSuiteCnt) && (wpaIePacket->length >= (curLength+index*4)); index++)
+        {
+            rsn_keyMngSuite_e curKeyMngSuite;
+
+#ifdef EXC_MODULE_INCLUDED
+            curKeyMngSuite = (rsn_keyMngSuite_e)admCtrlExc_parseCckmSuiteVal(pAdmCtrl, curWpaIe);
+                       if (curKeyMngSuite == WPA_IE_KEY_MNG_CCKM)
+                       {       /* CCKM is the maximum AKM */
+                               maxKeyMngSuite =  curKeyMngSuite;
+                       }
+                       else
+#endif
+                       {
+                               curKeyMngSuite = (rsn_keyMngSuite_e)admCtrlWpa_parseSuiteVal(pAdmCtrl, curWpaIe,pWpaData,WPA_IE_KEY_MNG_PSK_801_1X);
+                       }
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                    ("Wpa_IE: authKeyMng %x , keyMng %x \n",
+                                     curWpaIe[3], curKeyMngSuite));
+
+            if ((curKeyMngSuite>maxKeyMngSuite) && (curKeyMngSuite!=WPA_IE_KEY_MNG_NA)
+                               && (curKeyMngSuite!=WPA_IE_KEY_MNG_CCKM))
+            {
+                maxKeyMngSuite =  curKeyMngSuite;
+            }
+            if (curKeyMngSuite==WPA_IE_KEY_MNG_801_1X)
+            {   /* If 2 AKM exist, save also the second priority */
+                pAdmCtrl->wpaAkmExists = TRUE;
+            }
+
+            curWpaIe +=4; 
+        }
+        pWpaData->KeyMngSuite[0] = maxKeyMngSuite;
+        curLength += (index-1)*4;
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("Wpa_IE: keyMng %x \n",  pWpaData->KeyMngSuite[0]));
+
+    } else
+    {
+        return OK;
+    }
+    /* Parse capabilities */
+    if (wpaIePacket->length >= (curLength+2))
+    {
+        UINT16 capabilities = ENDIAN_HANDLE_WORD(*((UINT16 *)curWpaIe));
+
+        pWpaData->bcastForUnicatst = (capabilities & WPA_GROUP_4_UNICAST_CAPABILITY_MASK) >> WPA_REPLAY_GROUP4UNI_CAPABILITY_SHIFT;
+        pWpaData->replayCounters =   (capabilities & WPA_REPLAY_COUNTERS_CAPABILITY_MASK) >> WPA_REPLAY_COUNTERS_CAPABILITY_SHIFT;
+        switch (pWpaData->replayCounters)
+        {
+        case 0: pWpaData->replayCounters=1;
+            break;
+        case 1: pWpaData->replayCounters=2;
+            break;
+        case 2: pWpaData->replayCounters=4;
+            break;
+        case 3: pWpaData->replayCounters=16;
+            break;
+        default: pWpaData->replayCounters=0;
+            break;
+        }
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("Wpa_IE: capabilities %x, bcastForUnicatst %x, replayCounters %x\n", 
+                                 capabilities, pWpaData->bcastForUnicatst, pWpaData->replayCounters));
+
+    }
+
+
+    return OK;
+
+}
+
+
+UINT16 admCtrlWpa_buildCapabilities(UINT16 replayCnt)
+{
+    UINT16 capabilities=0;
+    /* Bit1: group key for unicast */
+    capabilities = 0;
+    capabilities = capabilities << WPA_REPLAY_GROUP4UNI_CAPABILITY_SHIFT;
+    /* Bits 2&3: Replay counter */
+    switch (replayCnt)
+    {
+    case 1:  replayCnt=0;
+        break;
+    case 2:  replayCnt=1;
+        break;
+    case 4:  replayCnt=2;
+        break;
+    case 16: replayCnt=3;
+        break;
+    default: replayCnt=0;
+        break;
+    }
+
+    capabilities |= replayCnt << WPA_REPLAY_COUNTERS_CAPABILITY_SHIFT;
+    return     capabilities;
+
+}
+
+
+UINT32  admCtrlWpa_parseSuiteVal(admCtrl_t *pAdmCtrl, UINT8* suiteVal, wpaIeData_t *pWpaData, UINT32 maxVal)
+{
+    UINT32  suite;
+
+    if ((pAdmCtrl==NULL) || (suiteVal==NULL))
+    {
+        return RSN_CIPHER_UNKNOWN;
+    }
+    if (!os_memoryCompare(pAdmCtrl->hOs, suiteVal, wpaIeOuiIe, 3))
+    {
+        suite =  (cipherSuite_e)((suiteVal[3]<=maxVal) ? suiteVal[3] : RSN_CIPHER_UNKNOWN); 
+    } else
+    {
+#ifdef EXC_MODULE_INCLUDED
+        suite = admCtrlExc_WpaParseSuiteVal(pAdmCtrl,suiteVal,pWpaData);
+#else
+        suite = RSN_CIPHER_UNKNOWN;
+#endif
+    }
+    return     suite;
+}
+
+
+TI_STATUS admCtrlWpa_checkCipherSuiteValidity (cipherSuite_e unicastSuite, cipherSuite_e broadcastSuite, cipherSuite_e encryptionStatus)
+{
+    cipherSuite_e maxCipher;
+
+    maxCipher = (unicastSuite>=broadcastSuite) ? unicastSuite : broadcastSuite ;
+    if (maxCipher != encryptionStatus)
+    {
+        return NOK;
+    }
+    if ((unicastSuite != RSN_CIPHER_NONE) && (broadcastSuite>unicastSuite))
+    {
+        return NOK;
+    }
+    return OK;
+}
+
+static TI_STATUS admCtrlWpa_get802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists)
+{
+    *wpa_802_1x_AkmExists = pAdmCtrl->wpaAkmExists;
+    return OK;
+}
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWpa2.c b/sta_dk_4_0_4_32/common/src/core/rsn/admCtrlWpa2.c
new file mode 100644 (file)
index 0000000..f83b762
--- /dev/null
@@ -0,0 +1,2024 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 admCtrlWpa2.c
+ *  \brief WPA2 Admission control methods
+ *
+ *  \see admCtrl.h
+ */
+
+#include "osApi.h"
+
+#include "utils.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "mlmeApi.h"
+#include "802_11Defs.h"
+#include "DataCtrl_Api.h"
+#include "report.h"
+
+/*
+#include "fsm.h"
+#include "utils.h"
+*/
+
+#include "rsn.h"
+#include "admCtrl.h"
+#include "admCtrlWpa2.h"
+#include "osDot11.h"
+#include "siteMgrApi.h"
+#include "EvHandler.h"
+#include "admCtrl.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "admCtrlWpa.h"
+#include "admCtrlExc.h"
+#include "excMngr.h"
+#endif
+
+/* Constants */
+#define MAX_NETWORK_MODE 2
+#define MAX_WPA2_CIPHER_SUITE 6
+
+#define PMKID_CAND_LIST_MEMBUFF_SIZE  (2*sizeof(UINT32) + (sizeof(OS_802_11_PMKID_CANDIDATE) * PMKID_MAX_NUMBER))
+#define PMKID_MIN_BUFFER_SIZE    2*sizeof(UINT32) + MAC_ADDR_LEN + PMKID_VALUE_SIZE
+
+#define TI_WLAN_COPY_UINT16_UNALIGNED(addr, val) {\
+    *((UINT8 *) &(addr))   = (UINT8)(val & 0x00FF); \
+    *((UINT8 *) &(addr) + 1)   = (UINT8)((val & 0xFF00) >> 8);}
+
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* Local functions definitions */
+
+/* Global variables */
+static UINT8 wpa2IeOuiIe[3] = { 0x00, 0x0f, 0xac};
+
+static BOOL broadcastCipherSuiteValidity[MAX_NETWORK_MODE][MAX_WPA2_CIPHER_SUITE]=
+{
+    /* RSN_IBSS */  {
+/* NONE       */    FALSE,
+/* WEP40      */    FALSE,
+/* TKIP       */    TRUE,
+/* AES_WRAP   */    FALSE,
+/* AES_CCMP   */    TRUE,
+/* WEP104     */    FALSE},
+
+    /* RSN_INFRASTRUCTURE */  {
+/* NONE       */    FALSE,
+/* WEP        */    TRUE,
+/* TKIP       */    TRUE,
+/* AES_WRAP   */    FALSE,
+/* AES_CCMP   */    TRUE,
+/* WEP104     */    TRUE}
+};
+
+/** WPA2 admission table. Used to verify admission parameters to an AP */
+/* table parameters:
+    Max unicast cipher in the IE
+    Max broadcast cipher in the IE
+    Encryption status 
+*/
+typedef struct
+{
+    TI_STATUS        status;
+    cipherSuite_e    unicast;
+    cipherSuite_e    broadcast;
+    UINT8            evaluation; 
+} admCtrlWpa2_validity_t;
+
+static admCtrlWpa2_validity_t    admCtrlWpa2_validityTable[MAX_WPA2_CIPHER_SUITE][MAX_WPA2_CIPHER_SUITE][MAX_WPA2_CIPHER_SUITE] =
+{
+/* AP unicast NONE */ {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP40 */ { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP40 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP40 */ { OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP ,1},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP104 ,1}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_TKIP ,2},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_AES_WRAP ,3},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_NONE, RSN_CIPHER_AES_CCMP ,3},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP40 */ { OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP ,1},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ OK,  RSN_CIPHER_NONE, RSN_CIPHER_WEP104 ,1}}},
+/* AP unicast WEP */  {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WRAP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast TKIP */  {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_WEP  ,4},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_TKIP ,7},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK,  RSN_CIPHER_TKIP, RSN_CIPHER_WEP104 ,4},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast AES_WRAP */ {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP40 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_WEP ,5},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_TKIP ,6},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_AES_WRAP ,8},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { OK,  RSN_CIPHER_AES_WRAP, RSN_CIPHER_WEP104 ,5},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast AES_CCMP */ {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_WEP ,5},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_TKIP ,6},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_TKIP ,6},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_AES_CCMP ,6},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK, RSN_CIPHER_AES_CCMP, RSN_CIPHER_AES_CCMP ,8},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { OK,  RSN_CIPHER_AES_CCMP, RSN_CIPHER_WEP104 ,5},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}},
+/* AP unicast WEP104 */  {
+        /* AP multicast NONE */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast TKIP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WRAP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast CCMP */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}},
+        /* AP multicast WEP104 */ {
+            /* STA NONE */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA TKIP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA AES */   { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA CCMP */  { NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0},
+            /* STA WEP104 */{ NOK, RSN_CIPHER_NONE, RSN_CIPHER_NONE ,0}}}
+
+
+};
+
+
+/* PMKID cache */
+/* static wpa2_pmkid_cache_t wpa2_pmkid_cache; */
+
+/* Function prototypes */
+
+TI_STATUS admCtrlWpa2_parseIe(admCtrl_t *pAdmCtrl, UINT8 *pWpa2Ie, wpa2IeData_t *pWpa2Data);
+UINT16 admCtrlWpa2_buildCapabilities(admCtrl_t *pAdmCtrl);
+UINT32  admCtrlWpa2_parseSuiteVal(admCtrl_t *pAdmCtrl, UINT8* suiteVal, UINT32 maxVal, UINT32 unknownVal);
+TI_STATUS admCtrlWpa2_checkCipherSuiteValidity(cipherSuite_e unicastSuite, cipherSuite_e broadcastSuite, cipherSuite_e encryptionStatus);
+TI_STATUS admCtrlWpa2_getCipherSuiteMetric (admCtrl_t *pAdmCtrl, wpa2IeData_t *pWpa2Data, UINT32 *metric, 
+                                            cipherSuite_e *uSuite,  cipherSuite_e  *bSuite);
+TI_STATUS admCtrlWpa2_DynamicConfig(admCtrl_t *pAdmCtrl, rsn_paeConfig_t *pPaeConfig);
+
+TI_STATUS admCtrlWpa2_resetPMKIDCache(admCtrl_t *pAdmCtrl);
+/*TI_STATUS admCtrlWpa2_sendPMKIDCandListAfterDelay(admCtrl_t * pAdmCtrl, UINT32 delay);*/
+TI_STATUS admCtrlWpa2_getPMKIDList(admCtrl_t * pAdmCtrl,OS_802_11_PMKID *pmkidList);
+TI_STATUS admCtrlWpa2_setPMKIDList(admCtrl_t * pAdmCtrl, OS_802_11_PMKID *pmkidList);
+
+TI_STATUS admCtrlWpa2_addPMKID(admCtrl_t * pAdmCtrl, macAddress_t * pBSSID, pmkidValue_t pmkID);
+TI_STATUS admCtrlWpa2_findPMKID(admCtrl_t * pAdmCtrl, macAddress_t *pBSSID, 
+                                pmkidValue_t *pPMKID, UINT8  *cacheIndex);
+
+static BOOL admCtrlWpa2_getPreAuthStatus(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8  *cacheIndex);
+
+static TI_STATUS admCtrlWpa2_startPreAuth(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList);
+
+static void admCtrlWpa2_buildAndSendPMKIDCandList(TI_HANDLE hHandle, bssidList4PreAuth_t *apList);
+
+static TI_STATUS admCtrlWpa2_get802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists);
+
+/**
+*
+* admCtrlWpa_config  - Configure EXC admission control.
+*
+* \b Description: 
+*
+* Configure EXC admission control.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_config(admCtrl_t *pAdmCtrl)
+{
+    TI_STATUS           status;
+    rsn_paeConfig_t     paeConfig;
+
+    /* check and set admission control default parameters */
+    pAdmCtrl->authSuite =   RSN_AUTH_OPEN;
+    if (pAdmCtrl->unicastSuite == RSN_CIPHER_NONE)
+    {
+        pAdmCtrl->unicastSuite = RSN_CIPHER_AES_CCMP;
+    }
+    if (pAdmCtrl->broadcastSuite == RSN_CIPHER_NONE)
+    {
+        pAdmCtrl->broadcastSuite = RSN_CIPHER_AES_CCMP;
+    }
+
+    /* set callback functions (API) */
+    pAdmCtrl->getInfoElement = admCtrlWpa2_getInfoElement;
+    pAdmCtrl->setSite  = admCtrlWpa2_setSite;
+    pAdmCtrl->evalSite = admCtrlWpa2_evalSite;
+
+    pAdmCtrl->getPmkidList      = admCtrlWpa2_getPMKIDList;
+    pAdmCtrl->setPmkidList      = admCtrlWpa2_setPMKIDList;
+    pAdmCtrl->resetPmkidList    = admCtrlWpa2_resetPMKIDCache;
+    pAdmCtrl->getPreAuthStatus = admCtrlWpa2_getPreAuthStatus;
+    pAdmCtrl->startPreAuth = admCtrlWpa2_startPreAuth;
+    pAdmCtrl->get802_1x_AkmExists = admCtrlWpa2_get802_1x_AkmExists;
+
+    /* set key management suite (AKMP) */
+    switch (pAdmCtrl->externalAuthMode)
+    {
+    case RSN_EXT_AUTH_MODE_WPA2:
+    case RSN_EXT_AUTH_MODE_WPA2PSK:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
+        break;
+    case RSN_EXT_AUTH_MODE_WPANONE:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
+        /* Not supported */
+    default:
+        return NOK;
+    }
+
+
+    paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
+    paeConfig.unicastSuite = pAdmCtrl->unicastSuite;
+    paeConfig.broadcastSuite = pAdmCtrl->broadcastSuite;
+    paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
+    /* set default PAE configuration */
+    status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, &paeConfig);
+
+    return status;
+}
+
+
+/**
+*
+* admCtrlWpa2_getInfoElement - Get the current information element.
+*
+* \b Description: 
+*
+* Get the current information element.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pIe - IE buffer \n
+*  I   - pLength - length of IE \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+
+TI_STATUS admCtrlWpa2_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength)
+{
+    wpa2IePacket_t     *pWpa2IePacket;
+    UINT8              length = 0;
+    macAddress_t       assocBssid;
+    paramInfo_t        param;
+    pmkidValue_t       pmkId;
+    TI_STATUS          status;
+    UINT8              index;
+
+    #ifdef FOUR_ALIGNMENT
+         UINT16                                tempInt;
+    #endif
+
+    if (pIe==NULL)
+    {
+        *pLength = 0;
+        return NOK;
+    }
+
+    /* check Group suite validity */
+    if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][pAdmCtrl->broadcastSuite])
+    {
+        *pLength = 0;
+        return NOK;
+    }
+
+    /* Init Wpa2 IE (RSN IE) */
+    pWpa2IePacket = (wpa2IePacket_t*)pIe;
+    os_memoryZero(pAdmCtrl->hOs, pWpa2IePacket, sizeof(wpa2IePacket_t));
+
+
+    /* Fill the element ID */
+    pWpa2IePacket->elementid = RSN_IE_ID;
+
+
+    #ifndef FOUR_ALIGNMENT
+       pWpa2IePacket->version   = ENDIAN_HANDLE_WORD(WPA2_OUI_MAX_VERSION);
+    #else 
+      /* required for WinCe, when the pointer is not even */
+      tempInt = ENDIAN_HANDLE_WORD(WPA2_OUI_MAX_VERSION);
+      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->version, &tempInt, sizeof(pWpa2IePacket->version));
+    #endif
+    length += 2;
+
+    /* build group suite */
+    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpa2IePacket->groupSuite, wpa2IeOuiIe, 3);
+    pWpa2IePacket->groupSuite[3] = (UINT8)pAdmCtrl->pRsn->paeConfig.broadcastSuite;
+    length += 4;
+
+    /* build pairwise suite - we always send only one pairwise suite */
+    #ifndef FOUR_ALIGNMENT
+      pWpa2IePacket->pairwiseSuiteCnt = ENDIAN_HANDLE_WORD(0x0001);
+    #else
+    /* required for WinCe, when the pointer is not even */
+      tempInt = ENDIAN_HANDLE_WORD(0x0001);
+      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->pairwiseSuiteCnt, &tempInt, sizeof(pWpa2IePacket->pairwiseSuiteCnt));
+    #endif
+
+    length += 2;
+
+    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpa2IePacket->pairwiseSuite, wpa2IeOuiIe, 3);
+    pWpa2IePacket->pairwiseSuite[3] = (UINT8)pAdmCtrl->pRsn->paeConfig.unicastSuite;
+    length += 4;
+
+    
+    /* build keyMng suite - we always send only one key mgmt  suite*/
+    #ifndef FOUR_ALIGNMENT
+       pWpa2IePacket->authKeyMngSuiteCnt = ENDIAN_HANDLE_WORD(0x0001);
+    #else
+    /* required for WinCe, when the pointer is not even */
+      tempInt = ENDIAN_HANDLE_WORD(0x0001);
+      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->authKeyMngSuiteCnt, &tempInt, sizeof(pWpa2IePacket->authKeyMngSuiteCnt));
+    #endif
+    
+    length += 2;
+
+    os_memoryCopy(pAdmCtrl->hOs, (void *)pWpa2IePacket->authKeyMngSuite, wpa2IeOuiIe, 3);
+    
+    switch (pAdmCtrl->externalAuthMode)
+    {
+    case RSN_EXT_AUTH_MODE_OPEN:
+    case RSN_EXT_AUTH_MODE_SHARED_KEY:
+    case RSN_EXT_AUTH_MODE_AUTO_SWITCH:
+        pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_NONE;
+        break;
+    case RSN_EXT_AUTH_MODE_WPA2:
+    case RSN_EXT_AUTH_MODE_WPA:   /* for Any-WPA/WPA-Mixed mode */
+        {
+#ifdef EXC_MODULE_INCLUDED
+            UINT8   akmSuite[DOT11_OUI_LEN+1];
+
+            if (admCtrlExc_getCckmAkm(pAdmCtrl, akmSuite))
+            {
+                os_memoryCopy(pAdmCtrl->hOs, (PVOID)pWpa2IePacket->authKeyMngSuite, akmSuite, DOT11_OUI_LEN+1);
+            }
+            else
+#endif
+            {
+                pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_801_1X;
+            }
+        }
+        break;
+    case RSN_EXT_AUTH_MODE_WPA2PSK:
+    case RSN_EXT_AUTH_MODE_WPAPSK:
+        pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_PSK_801_1X;
+        break;
+    default:
+        pWpa2IePacket->authKeyMngSuite[3] = WPA2_IE_KEY_MNG_NONE;
+        break;
+    }
+
+    length += 4;
+    
+    /* build Capabilities */
+    #ifndef FOUR_ALIGNMENT
+       pWpa2IePacket->capabilities = ENDIAN_HANDLE_WORD(admCtrlWpa2_buildCapabilities(pAdmCtrl));
+    #else
+       /* required for WinCe, when the pointer is not even */
+      tempInt = ENDIAN_HANDLE_WORD(admCtrlWpa2_buildCapabilities(pAdmCtrl));
+      os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->capabilities, &tempInt, sizeof(pWpa2IePacket->capabilities));
+    #endif
+    
+    length += 2;
+
+    /* build PMKID list: we support no more than 1 PMKSA per AP, */
+    /* so no more than 1 PMKID can be sent in the RSN IE         */
+    if(pAdmCtrl->preAuthSupport && 
+       (pAdmCtrl->pRsn->paeConfig.authProtocol == RSN_EXT_AUTH_MODE_WPA2))
+    {
+        /* Init value of PMKID count is 0 */
+       #ifndef FOUR_ALIGNMENT
+           pWpa2IePacket->pmkIdCnt = ENDIAN_HANDLE_WORD(0);
+       #else
+          /* required for WinCe, when the pointer is not even */
+          tempInt = ENDIAN_HANDLE_WORD(0);
+         os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->pmkIdCnt, &tempInt, sizeof(pWpa2IePacket->pmkIdCnt));
+       #endif
+        
+        length += 2;
+
+        param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+        status          = ctrlData_getParam(pAdmCtrl->pRsn->hCtrlData, &param);
+
+        assocBssid      = param.content.ctrlDataCurrentBSSID;
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("admCtrlWpa2_getInfoElement - find PMKID \n"));
+
+        status = admCtrlWpa2_findPMKID(pAdmCtrl, &assocBssid, &pmkId, &index);
+        if(status == OK)
+        {
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                    ("admCtrlWpa2_getInfoElement - PMKID was found! \n"));
+
+       #ifndef FOUR_ALIGNMENT
+            pWpa2IePacket->pmkIdCnt = ENDIAN_HANDLE_WORD(1);
+        #else
+           /* required for WinCe, when the pointer is not even */
+           tempInt = ENDIAN_HANDLE_WORD(1);
+           os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)&pWpa2IePacket->pmkIdCnt, &tempInt, sizeof(pWpa2IePacket->pmkIdCnt));
+        #endif
+
+            os_memoryCopy(pAdmCtrl->hOs, (UINT8 *)pWpa2IePacket->pmkId, 
+                      (UINT8 *)pmkId, PMKID_VALUE_SIZE);
+
+            length += PMKID_VALUE_SIZE;
+        }
+    }
+
+    pWpa2IePacket->length = length;    /* RSN IE length without IEid and length field */
+    *pLength              = length+2;  /* The whole length of the RSN IE */
+
+    WLAN_REPORT_HEX_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                    pIe, *pLength);
+    return OK;
+
+}
+/**
+*
+* admCtrlWpa2_setSite  - Set current primary site parameters for registration.
+*
+* \b Description: 
+*
+* Set current primary site parameters for registration.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pAssocIe - result IE of evaluation \n
+*  O   - pAssocIeLen - length of result IE of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK on site is aproved, NOK on site is rejected.
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
+{
+    TI_STATUS               status;
+    paramInfo_t             param;
+    whalParamInfo_t         whalParam;
+    wpa2IeData_t            wpa2Data;
+    rsn_paeConfig_t         paeConfig;
+    UINT8                   *pWpa2Ie;
+    cipherSuite_e           uSuite, bSuite;
+
+
+    *pAssocIeLen = 0;
+
+    if (pRsnData==NULL)
+    {
+        return NOK;
+    }
+    if (pRsnData->pIe==NULL)
+    {
+        /* configure the MLME module with the 802.11 OPEN authentication suite, 
+            THe MLME will configure later the authentication module */
+        param.paramType = MLME_LEGACY_TYPE_PARAM;
+        param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+        status = mlme_setParam(pAdmCtrl->hMlme, &param);
+        if (status != OK)
+        {
+            return status;
+        }
+
+        return OK;
+    }
+
+#ifdef EXC_MODULE_INCLUDED
+    /* Clean MIC and KP flags in the HAL.                */
+    /* It is needed if the previous privacy mode was EXC */
+    whalParam.paramType = HAL_CTRL_RSN_EXC_SW_ENC_ENABLE_PARAM; 
+    whalParam.content.rsnExcSwEncFlag = FALSE;
+    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+
+    whalParam.paramType = HAL_CTRL_RSN_EXC_MIC_FIELD_ENABLE_PARAM; 
+    whalParam.content.rsnExcMicFieldFlag = FALSE;
+    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+
+    /* Check if Aironet IE exists */
+    admCtrlExc_setExtendedParams(pAdmCtrl, pRsnData);
+
+#endif /*EXC_MODULE_INCLUDED*/
+    
+    status = admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpa2Ie, RSN_IE_ID);
+    if (status != OK)                                                         
+    {                                                                                    
+        return status;                                                        
+    }
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                            ("admCtrlWpa2_setSite: RSN_IE=\n"));
+    WLAN_REPORT_HEX_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, pRsnData->pIe, pRsnData->ieLen);
+    status = admCtrlWpa2_parseIe(pAdmCtrl, pWpa2Ie, &wpa2Data);
+    if (status != OK)
+    {
+        return status;
+    }
+    if ((wpa2Data.unicastSuite[0]>=MAX_WPA2_CIPHER_SUITE) ||
+        (wpa2Data.broadcastSuite>=MAX_WPA2_CIPHER_SUITE) ||
+        (pAdmCtrl->unicastSuite>=MAX_WPA2_CIPHER_SUITE))
+    {
+        return NOK;
+    }
+    /* Check validity of Group suite */
+    if (!broadcastCipherSuiteValidity[pAdmCtrl->networkMode][wpa2Data.broadcastSuite])
+    {   /* check Group suite validity */                                          
+        return NOK;
+    }
+
+    
+    if(admCtrlWpa2_getCipherSuiteMetric (pAdmCtrl, &wpa2Data, NULL, &uSuite, &bSuite) != OK)
+        return NOK;
+
+    /* set replay counter */
+    pAdmCtrl->replayCnt = wpa2Data.ptkReplayCounters;
+
+    *pAssocIeLen = pRsnData->ieLen;
+    if (pAssocIe != NULL)
+    {
+        os_memoryCopy(pAdmCtrl->hOs, pAssocIe, &wpa2Data, sizeof(wpa2IeData_t));
+    }
+
+    /* re-config PAE with updated unicast and broadcast suite values            */
+    /* If STA works in WpaMixed mode/AnyWpa mode, set PAE auth. mode to WPA2    */
+    paeConfig.authProtocol = pAdmCtrl->externalAuthMode;
+
+    if(pAdmCtrl->WPAPromoteFlags)
+    {
+       if(pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA)
+          paeConfig.authProtocol   = RSN_EXT_AUTH_MODE_WPA2;
+       if(pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPAPSK)
+          paeConfig.authProtocol   = RSN_EXT_AUTH_MODE_WPA2PSK;
+    }
+
+
+#ifdef EXC_MODULE_INCLUDED
+    param.paramType = EXC_CCKM_EXISTS;
+    param.content.excCckmExists = (wpa2Data.KeyMngSuite[0]==WPA2_IE_KEY_MNG_CCKM) ? TRUE : FALSE;
+    excMngr_setParam(pAdmCtrl->hExcMngr, &param);
+#endif
+
+
+    paeConfig.keyExchangeProtocol = pAdmCtrl->keyMngSuite;
+    paeConfig.unicastSuite        = uSuite;    /* Updated value */
+    paeConfig.broadcastSuite      = bSuite;    /* Updated value */
+    status = admCtrlWpa2_DynamicConfig(pAdmCtrl, &paeConfig);
+
+    if (status != OK)
+    {
+        return status;
+    }
+
+    /* Now we configure the MLME module with the 802.11 legacy authentication suite, 
+        THe MLME will configure later the authentication module */
+    param.paramType = MLME_LEGACY_TYPE_PARAM;
+#ifdef EXC_MODULE_INCLUDED
+    if (pAdmCtrl->networkEapMode!=OS_EXC_NETWORK_EAP_OFF)
+    {
+        param.content.mlmeLegacyAuthType = AUTH_LEGACY_RESERVED1;
+    }
+    else
+#endif
+    {
+        param.content.mlmeLegacyAuthType = AUTH_LEGACY_OPEN_SYSTEM;
+    }
+    status = mlme_setParam(pAdmCtrl->hMlme, &param);
+    if (status != OK)
+    {
+        return status;
+    }
+
+    param.paramType = RX_DATA_EAPOL_DESTINATION_PARAM;
+    param.content.rxDataEapolDestination = OS_ABS_LAYER;
+    status = rxData_setParam(pAdmCtrl->hRx, &param);
+    if (status != OK)
+    {
+        return status;
+    }
+
+    /* Configure privacy status in HAL so that HW is prepared to recieve keys */
+    whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
+    whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)paeConfig.unicastSuite;
+    status = whalCtrl_SetParam(pAdmCtrl->pRsn->hWhalCtrl, &whalParam);
+
+    return status;
+}
+
+/**
+*
+* admCtrlWpa_evalSite  - Evaluate site for registration.
+*
+* \b Description: 
+*
+* evaluate site RSN capabilities against the station's cap.
+* If the BSS type is infrastructure, the station matches the site only if it's WEP status is same as the site
+* In IBSS, it does not matter
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - Context \n
+*  I   - pRsnData - site's RSN data \n
+*  O   - pEvaluation - Result of evaluation \n
+*  
+* \b RETURNS:
+*
+*  OK 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation)
+{
+    TI_STATUS               status;
+    wpa2IeData_t            wpa2Data;
+    UINT8                   *pWpa2Ie;
+    cipherSuite_e           uSuite, bSuite; 
+    UINT8                   i = 0;
+
+
+    *pEvaluation = 0;
+
+    if (pRsnData==NULL)
+    {
+        return NOK;
+    }
+    if (pRsnData->pIe==NULL)
+    {
+        return NOK;
+    }
+    
+    if (bssType != BSS_INFRASTRUCTURE)
+    {
+        return NOK;
+    }
+
+    status = admCtrl_parseIe(pAdmCtrl, pRsnData, &pWpa2Ie, RSN_IE_ID);
+    if (status != OK)                                                         
+    {                                                                                    
+        return status;                                                        
+    }
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                            ("admCtrlWpa2_evalSite, IE=\n"));
+
+    WLAN_REPORT_HEX_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, pRsnData->pIe, pRsnData->ieLen);
+
+    status = admCtrlWpa2_parseIe(pAdmCtrl, pWpa2Ie, &wpa2Data);
+    if (status != OK)
+    {
+        return status;
+    }
+
+    /* check keyMngSuite validity */
+    status = NOK;
+    for(i = 0; 
+       (i < wpa2Data.KeyMngSuiteCnt) &&(i<MAX_WPA2_KEY_MNG_SUITES)&& (status != OK);
+        i++)
+    {
+       switch (wpa2Data.KeyMngSuite[i])
+       {
+          case WPA2_IE_KEY_MNG_NONE:
+              status = (pAdmCtrl->externalAuthMode <= RSN_EXT_AUTH_MODE_AUTO_SWITCH) ? OK : NOK;
+              break;
+          case WPA2_IE_KEY_MNG_801_1X:
+#ifdef EXC_MODULE_INCLUDED
+          case WPA2_IE_KEY_MNG_CCKM:
+                /* CCKM is allowed only in 802.1x auth */
+#endif
+
+              if(!pAdmCtrl->WPAPromoteFlags)
+               status = (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2) ? OK : NOK;
+              else
+                 /* Any-WPA mode is supported */
+                 status = ((pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2) ||
+                        (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA)) ? OK : NOK;
+              break;
+          case WPA2_IE_KEY_MNG_PSK_801_1X:
+             if(!pAdmCtrl->WPAPromoteFlags)
+                 status = (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2PSK) ? OK : NOK;
+             else
+                 /* Any-WPA mode is supported */
+                status = ((pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPA2PSK) ||
+                       (pAdmCtrl->externalAuthMode == RSN_EXT_AUTH_MODE_WPAPSK)) ? OK : NOK;
+             break;
+       default:
+           WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                            ("admCtrlWpa2_evalSite, default, wpa2Data.KeyMngSuite[i]=%d \n",wpa2Data.KeyMngSuite[i]));
+             status = NOK;
+             break;
+       }
+    }
+
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                         ("admCtrlWpa2_evalSite, status=%d, externalAuthMode=%d, WPAPromoteFlags=%d \n", 
+                          status, pAdmCtrl->externalAuthMode,
+                          pAdmCtrl->WPAPromoteFlags));
+        return status;
+    }
+
+    /* Check cipher suite validity */
+    if(admCtrlWpa2_getCipherSuiteMetric(pAdmCtrl, &wpa2Data, pEvaluation, &uSuite, &bSuite) != OK)
+        return NOK;
+
+    /* Check privacy bit if not in mixed mode */
+    if (!pAdmCtrl->mixedMode)
+    {   /* There's no mixed mode, so make sure that the privacy Bit matches the privacy mode*/
+        if (((pRsnData->privacy) && (uSuite == RSN_CIPHER_NONE)) ||
+            ((!pRsnData->privacy) && (uSuite > RSN_CIPHER_NONE)))
+        {
+            *pEvaluation = 0;
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                             ("admCtrlWpa2_evalSite, mixedMode is FALSE, privacy=%d, uSuite=%d\n",
+                              pRsnData->privacy, uSuite));
+            return NOK;
+        }
+    }
+
+    /* always return OK */
+    return OK;
+}
+
+
+/**
+*
+* admCtrlWpa2_parseIe  - Parse an WPA information element.
+*
+* \b Description: 
+*
+* Parse an WPA information element. 
+* Builds a structure of the unicast adn broadcast cihper suites,
+* the key management suite and the capabilities.
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  I   - pWpa2Ie  - pointer to WPA IE (RSN IE) buffer  \n
+*  O   - pWpa2Data - WPA2 IE (RSN IE) structure after parsing
+*  
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_parseIe(admCtrl_t *pAdmCtrl, UINT8 *pWpa2Ie, wpa2IeData_t *pWpa2Data)
+{
+    dot11_RSN_t      *wpa2Ie       =  (dot11_RSN_t *)pWpa2Ie;
+    UINT16            temp2bytes, capabilities;
+    UINT16 KeyMngSuiteCntTemp=0;
+    UINT8             dataOffset = 0, i = 0, j = 0, curKeyMngSuite = 0;
+    cipherSuite_e     curCipherSuite = RSN_CIPHER_NONE;
+
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                            ("Wpa2_IE: DEBUG: admCtrlWpa2_parseIe\n\n"));
+
+    if ((pWpa2Data == NULL) || (pWpa2Ie == NULL))
+    {
+        return NOK;
+    }
+
+    /* get Version value from the info element */
+    temp2bytes = ENDIAN_HANDLE_WORD(*wpa2Ie->rsnIeData);
+    dataOffset += 2;
+
+    /* Check the header fields and the version */
+    if((wpa2Ie->hdr.eleId != RSN_IE_ID) || (wpa2Ie->hdr.eleLen < WPA2_IE_MIN_LENGTH) ||
+       (temp2bytes != WPA2_OUI_MAX_VERSION))
+    {
+        WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+           ("Wpa2_ParseIe Error: length=0x%x, elementid=0x%x, version=0x%x\n", 
+             wpa2Ie->hdr.eleLen,wpa2Ie->hdr.eleId,temp2bytes));
+
+        return NOK; 
+    }
+
+
+    /* Set default values */
+    os_memoryZero(pAdmCtrl->hOs, pWpa2Data, sizeof(wpa2IeData_t));
+
+    pWpa2Data->broadcastSuite = RSN_CIPHER_AES_CCMP;
+    pWpa2Data->unicastSuiteCnt = 1;
+    pWpa2Data->unicastSuite[0] = RSN_CIPHER_AES_CCMP;
+    pWpa2Data->KeyMngSuiteCnt = 1;
+    pWpa2Data->KeyMngSuite[0] = WPA2_IE_KEY_MNG_801_1X;
+
+    /* If we've reached the end of the received RSN IE */
+    if(wpa2Ie->hdr.eleLen < WPA2_IE_GROUP_SUITE_LENGTH)
+        return OK;
+    
+    /* Processing of Group Suite field - 4 bytes*/
+    pWpa2Data->broadcastSuite = (cipherSuite_e)admCtrlWpa2_parseSuiteVal(pAdmCtrl, (UINT8 *)wpa2Ie->rsnIeData + dataOffset,
+                                                          RSN_CIPHER_WEP104, RSN_CIPHER_UNKNOWN);
+    dataOffset +=4;
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+           ("Wpa2_IE: GroupSuite %x \n", pWpa2Data->broadcastSuite));
+
+
+    /* Processing of Pairwise (Unicast) Cipher Suite - 2 bytes counter and list of 4-byte entries */
+    if(wpa2Ie->hdr.eleLen < WPA2_IE_MIN_PAIRWISE_SUITE_LENGTH)
+        return OK;
+
+    pWpa2Data->unicastSuiteCnt = ENDIAN_HANDLE_WORD(*(wpa2Ie->rsnIeData + dataOffset));
+    dataOffset += 2;
+
+    if(pWpa2Data->unicastSuiteCnt > UNICAST_CIPHER_MAXNO_IN_RSNIE)
+    {
+        /* something wrong in the RSN IE */
+        WLAN_REPORT_ERROR(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+           ("Wpa2_ParseIe Error: Pairwise cipher suite count is  %d \n", pWpa2Data->unicastSuiteCnt));
+        return NOK;
+    }
+
+    /* Get unicast cipher suites */
+    for(i = 0; i < pWpa2Data->unicastSuiteCnt; i++)
+    {
+        curCipherSuite = (cipherSuite_e)admCtrlWpa2_parseSuiteVal(pAdmCtrl, (UINT8 *)wpa2Ie->rsnIeData + dataOffset, 
+                                                   RSN_CIPHER_WEP104, RSN_CIPHER_UNKNOWN);
+        if(curCipherSuite == RSN_CIPHER_NONE)
+            curCipherSuite = pWpa2Data->broadcastSuite;
+
+        pWpa2Data->unicastSuite[i] = curCipherSuite;
+        dataOffset +=4;
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                               ("Wpa_IE: unicast suite %x \n", curCipherSuite));
+    }
+
+    /* Sort all the unicast suites supported by the AP in the decreasing order */
+    /* (so the best cipher suite will be the first)                            */
+    if(pWpa2Data->unicastSuiteCnt > 1)
+    {
+       for(i = 0; i < (pWpa2Data->unicastSuiteCnt -1); i ++)
+       {
+           for(j = 0; j < i; j ++)
+           {
+               if(pWpa2Data->unicastSuite[j] > pWpa2Data->unicastSuite[j + 1])
+               {
+                   curCipherSuite               = pWpa2Data->unicastSuite[j];
+                   pWpa2Data->unicastSuite[j]   = pWpa2Data->unicastSuite[j+1];
+                   pWpa2Data->unicastSuite[j+1] = curCipherSuite;
+               }
+           }
+       }
+    }
+
+    /* If we've reached the end of the received RSN IE */
+    if (wpa2Ie->hdr.eleLen == dataOffset)
+        return OK;
+
+     /* KeyMng Suite */
+/*     pWpa2Data->KeyMngSuiteCnt = ENDIAN_HANDLE_WORD(*((UINT16 *)(wpa2Ie->rsnIeData + dataOffset))); */
+
+     /*Fixing unaligned half word access */
+
+     COPY_UNALIGNED_WORD(&KeyMngSuiteCntTemp,((UINT16 *)(wpa2Ie->rsnIeData + dataOffset)));
+     KeyMngSuiteCntTemp = ENDIAN_HANDLE_WORD(KeyMngSuiteCntTemp);
+     TI_WLAN_COPY_UINT16_UNALIGNED(pWpa2Data->KeyMngSuiteCnt, KeyMngSuiteCntTemp);
+
+
+     dataOffset += 2;
+     pAdmCtrl->wpaAkmExists = FALSE;
+     for(i = 0; i < pWpa2Data->KeyMngSuiteCnt; i++)
+     {
+#ifdef EXC_MODULE_INCLUDED
+            curKeyMngSuite = admCtrlExc_parseCckmSuiteVal4Wpa2(pAdmCtrl, (UINT8 *)(wpa2Ie->rsnIeData + dataOffset));
+            if (curKeyMngSuite == WPA2_IE_KEY_MNG_CCKM)
+            {  /* CCKM is the maximum AKM */
+                pWpa2Data->KeyMngSuite[i] = curKeyMngSuite;
+            }
+            else
+#endif
+            {
+                curKeyMngSuite = admCtrlWpa2_parseSuiteVal(pAdmCtrl, (UINT8 *)wpa2Ie->rsnIeData + dataOffset, 
+                            WPA2_IE_KEY_MNG_PSK_801_1X, WPA2_IE_KEY_MNG_NA);
+            }
+
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+           ("Wpa2_IE: authKeyMng %x  \n", curKeyMngSuite));
+
+         if ((curKeyMngSuite != WPA2_IE_KEY_MNG_NA) && 
+             (curKeyMngSuite != WPA2_IE_KEY_MNG_CCKM))
+         {
+             pWpa2Data->KeyMngSuite[i] = curKeyMngSuite;
+         }
+
+         if (curKeyMngSuite==WPA2_IE_KEY_MNG_801_1X)
+         {   /* If 2 AKM exist, save also the second priority */
+             pAdmCtrl->wpaAkmExists = TRUE;
+         }
+
+         dataOffset += 4;
+     }
+
+    /* If we've reached the end of the received RSN IE */
+    if (wpa2Ie->hdr.eleLen == dataOffset)
+        return OK;
+
+    /* Parse capabilities */
+
+/*    capabilities = ENDIAN_HANDLE_WORD(*((UINT16 *)(wpa2Ie->rsnIeData + dataOffset))); */
+
+   /* Fixing unaligned half word access */
+
+    COPY_UNALIGNED_WORD(&capabilities,((UINT16 *)(wpa2Ie->rsnIeData + dataOffset)));
+    capabilities = ENDIAN_HANDLE_WORD(capabilities);
+
+
+    pWpa2Data->bcastForUnicatst  = (UINT8)(capabilities & WPA2_GROUP_4_UNICAST_CAPABILITY_MASK)>> 
+                                           WPA2_GROUP_4_UNICAST_CAPABILITY_SHIFT;
+    pWpa2Data->ptkReplayCounters = (UINT8)(capabilities &  WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_MASK)>> 
+                                           WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;
+
+    switch (pWpa2Data->ptkReplayCounters)
+    {
+    case 0: pWpa2Data->ptkReplayCounters=1;
+            break;
+    case 1: pWpa2Data->ptkReplayCounters=2;
+            break;
+    case 2: pWpa2Data->ptkReplayCounters=4;
+            break;
+    case 3: pWpa2Data->ptkReplayCounters=16;
+            break;
+    default: pWpa2Data->ptkReplayCounters=1;
+            break;
+   }
+   pWpa2Data->gtkReplayCounters = (UINT8)(capabilities & 
+                                        WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_MASK) >> 
+                                        WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;
+   switch (pWpa2Data->gtkReplayCounters)
+   {
+   case 0: pWpa2Data->gtkReplayCounters=1;
+            break;
+   case 1: pWpa2Data->gtkReplayCounters=2;
+            break;
+   case 2: pWpa2Data->gtkReplayCounters=4;
+            break;
+   case 3: pWpa2Data->gtkReplayCounters=16;
+            break;
+   default: pWpa2Data->gtkReplayCounters=1;
+            break;
+   }
+
+   pWpa2Data->preAuthentication = (UINT8)(capabilities & WPA2_PRE_AUTH_CAPABILITY_MASK);
+
+   WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                ("Wpa2_IE: capabilities %x, preAuthentication = %x, bcastForUnicatst %x, ptk = %x, gtk = %x\n", 
+                                 capabilities, pWpa2Data->preAuthentication,
+                                 pWpa2Data->bcastForUnicatst, pWpa2Data->ptkReplayCounters,
+                                 pWpa2Data->gtkReplayCounters));
+
+    return OK;
+
+}
+
+
+UINT16 admCtrlWpa2_buildCapabilities(admCtrl_t *pAdmCtrl)
+{
+   UINT16 capabilities = 0;
+   UINT16 replayCnt;
+
+
+   /* Bit 0 - Pre-authentication is set to 0             */
+   /* when RSN IE is sent from a STA (in assoc request)  */
+
+   /* Bit1: group key for unicast is set to 0*/
+
+   /* Bits 2&3: PTKSA Replay counter; bits 4&5 GTKSA replay Counters */
+   switch (pAdmCtrl->replayCnt)
+   {
+   case 1:  replayCnt=0;
+       break;
+   case 2:  replayCnt=1;
+       break;
+   case 4:  replayCnt=2;
+       break;
+   case 16: replayCnt=3;
+       break;
+   default: replayCnt=0;
+       break;
+   }
+
+   capabilities |= replayCnt << WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;
+   capabilities |= replayCnt << WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_SHIFT;
+
+   return   capabilities;
+
+}
+
+
+UINT32  admCtrlWpa2_parseSuiteVal(admCtrl_t *pAdmCtrl, UINT8* suiteVal, UINT32 maxVal, UINT32 unknownVal)
+{
+    UINT32  suite;
+
+    if ((pAdmCtrl==NULL) || (suiteVal==NULL))
+    {
+        return RSN_CIPHER_UNKNOWN;
+    }
+    if (!os_memoryCompare(pAdmCtrl->hOs, suiteVal, wpa2IeOuiIe, 3))
+    {
+        suite =  (cipherSuite_e)((suiteVal[3]<=maxVal) ? suiteVal[3] : unknownVal); 
+    } else
+    {
+        suite = unknownVal;
+    }
+    return  suite;
+
+}
+
+
+TI_STATUS admCtrlWpa2_checkCipherSuiteValidity (cipherSuite_e unicastSuite, cipherSuite_e broadcastSuite, cipherSuite_e encryptionStatus)
+{
+    cipherSuite_e maxCipher;
+
+    maxCipher = (unicastSuite>=broadcastSuite) ? unicastSuite : broadcastSuite ;
+    if (maxCipher != encryptionStatus)
+    {
+        return NOK;
+    }
+    if ((unicastSuite != RSN_CIPHER_NONE) && (broadcastSuite>unicastSuite))
+    {
+        return NOK;
+    }
+    return OK;
+}
+
+TI_STATUS admCtrlWpa2_getCipherSuiteMetric (admCtrl_t *pAdmCtrl, wpa2IeData_t *pWpa2Data, UINT32 *metric, 
+                                            cipherSuite_e *uSuite, cipherSuite_e  *bSuite)
+{
+   cipherSuite_e   encryption   = RSN_CIPHER_NONE;
+   cipherSuite_e   unicastSuite = RSN_CIPHER_NONE, brdcstSuite = RSN_CIPHER_NONE;
+   admCtrlWpa2_validity_t  admCtrlWpa2_validity;
+   UINT32     maxMetric = 0, index = 0;
+   TI_STATUS  status = NOK;
+
+   /* Set admCtrlWpa2_validity initial values */
+   admCtrlWpa2_validity = admCtrlWpa2_validityTable[RSN_CIPHER_NONE][RSN_CIPHER_NONE][RSN_CIPHER_NONE];
+
+   /* Check validity of configured encryption (cipher) and validity of */
+   /* promoted cipher (in case of AnyWPA (WPAmixed mode))              */
+   pAdmCtrl->getCipherSuite(pAdmCtrl, &encryption);
+   WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                               ("admCtrlWpa2_getCipherSuiteMetric, encryption=%d\n", encryption));
+
+   while(encryption != RSN_CIPHER_NONE) 
+   {
+      for (index=0; index<pWpa2Data->unicastSuiteCnt; index++)
+      {
+          admCtrlWpa2_validity = 
+          admCtrlWpa2_validityTable[pWpa2Data->unicastSuite[index]][pWpa2Data->broadcastSuite][encryption];
+          if (admCtrlWpa2_validity.status == OK)
+          {
+              WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                          ("admCtrlWpa2_getCipherSuiteMetric, break: validity.evaluation=%d\n", 
+                                           admCtrlWpa2_validity.evaluation));
+              break;
+          }
+      }
+
+      if ((admCtrlWpa2_validity.status == OK) && (admCtrlWpa2_validity.evaluation > maxMetric))
+      {
+          WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG, 
+                                      ("admCtrlWpa2_getCipherSuiteMetric, validity.evaluation=%d, maxMetric=%d\n", 
+                                       admCtrlWpa2_validity.evaluation, maxMetric));
+
+          maxMetric       = admCtrlWpa2_validity.evaluation;
+          status          = admCtrlWpa2_validity.status;
+          unicastSuite    = admCtrlWpa2_validity.unicast;
+          brdcstSuite     = admCtrlWpa2_validity.broadcast;
+      }
+
+      if((pAdmCtrl->WPAPromoteFlags & ADMCTRL_WPA_OPTION_ENABLE_PROMOTE_CIPHER) &&
+         (encryption != RSN_CIPHER_AES_CCMP))
+         encryption = RSN_CIPHER_AES_CCMP;
+      else
+         encryption = RSN_CIPHER_NONE;
+
+    }  /* End of "while encryption" stmt */
+
+   if(metric)
+      *metric = maxMetric;
+
+   if(uSuite)
+      *uSuite = unicastSuite;
+
+   if(bSuite)
+      *bSuite = brdcstSuite;
+
+    return status;
+}
+
+
+/**
+*
+* admCtrlWpa2_DynamicConfig  - Dynamic setting of WPA2 config parameters.
+*
+* \b Description: 
+*
+*   Sets  WPA2 callback procedures and PAE configuration parameters.
+*   This procedure is similar to admCtrlWpa2_Config procedure.
+*   The main difference is that admCtrlWpa2_Config sets the DEFAULT VALUES
+*   of the configuration parameters and so it should be called during
+*   initialization of the driver code or when Auth mode or Encryption status
+*   parameters are beeing set.
+*   admCtrlWpa2_DynamicConfig set the updated values of WPA2 configuration  
+*   parameters which gets after negotiation with an AP. So the procedure 
+*   should be called during setSite stage.
+*   
+* \b ARGS:
+*
+*  I   - pAdmCtrl    - pointer to admCtrl context
+*  I   - pPaeConfig  - pointer to PAE structure
+*
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+
+TI_STATUS admCtrlWpa2_DynamicConfig(admCtrl_t *pAdmCtrl, rsn_paeConfig_t *pPaeConfig)
+{
+    TI_STATUS status = OK;
+
+    /* Set those WPA2 params and callback procedures used after setSite stage */
+    pAdmCtrl->getInfoElement = admCtrlWpa2_getInfoElement;
+
+    pAdmCtrl->getPmkidList      = admCtrlWpa2_getPMKIDList;
+    pAdmCtrl->setPmkidList      = admCtrlWpa2_setPMKIDList;
+    pAdmCtrl->resetPmkidList    = admCtrlWpa2_resetPMKIDCache;
+    pAdmCtrl->getPreAuthStatus = admCtrlWpa2_getPreAuthStatus;
+    pAdmCtrl->startPreAuth = admCtrlWpa2_startPreAuth;
+
+    /* set key management suite */
+    switch (pAdmCtrl->externalAuthMode)
+    {
+    case RSN_EXT_AUTH_MODE_WPA2:
+    case RSN_EXT_AUTH_MODE_WPA2PSK:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
+        break;
+    case RSN_EXT_AUTH_MODE_WPA:  /* It is any-WPA (WPA-mixed mode ) */
+    case RSN_EXT_AUTH_MODE_WPAPSK:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_802_1X;
+        break;
+    case RSN_EXT_AUTH_MODE_WPANONE:
+        pAdmCtrl->keyMngSuite = RSN_KEY_MNG_NONE;
+        /* Not supported */
+    default:
+        return NOK;
+    }
+
+    /* Config PAE (if needed) */
+    if(pPaeConfig)
+       status = pAdmCtrl->pRsn->setPaeConfig(pAdmCtrl->pRsn, pPaeConfig);
+
+    return status;
+}
+
+
+
+
+/**
+*
+* admCtrlWpa2_findPMKID 
+*
+* \b Description: 
+*
+* Retrieve an AP's PMKID (if exist)
+
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  I   - pBSSID   - pointer to AP's BSSID address 
+*  O   - pmkID    - pointer to AP's PMKID (if it is NULL ptr, only
+*                   cache index will be returned to the caller)
+*  O   - cacheIndex  - index of the cache table entry containing the 
+                       bssid
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_findPMKID (admCtrl_t * pAdmCtrl, macAddress_t *pBSSID, 
+                                 pmkidValue_t *pPMKID, UINT8  *cacheIndex)
+{
+
+    UINT8           i     = 0;
+    BOOL            found = FALSE;
+    macAddress_t    entryMac;
+    TI_STATUS       status = NOK;
+
+    while(!found && (i < ADMCTRL_PMKID_CACHE_SIZE) && 
+                    (i <= pAdmCtrl->pmkid_cache.entriesNumber))
+    {
+        entryMac = pAdmCtrl->pmkid_cache.pmkidTbl[i].bssId;
+        if(MAC_EQUAL ((&entryMac),pBSSID))
+        {
+            found       = TRUE;
+            *cacheIndex = i;
+            if(pPMKID)
+            {
+               os_memoryCopy(pAdmCtrl->hOs, (PVOID)pPMKID,
+                             pAdmCtrl->pmkid_cache.pmkidTbl[i].pmkId, 
+                             PMKID_VALUE_SIZE);
+            }
+        }
+        i++;
+    }
+
+    if(found)
+        status = OK;
+
+    return status;
+
+}
+
+
+/**
+*
+* admCtrlWpa2_getPMKIDList 
+*
+* \b Description: 
+*
+* Returns content of the PMKID cache 
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl        - pointer to admCtrl context
+*  O   - pmkidList       - memory buffer where the procedure writes the PMKIDs
+*                          Supplied by the caller procedure. .
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_getPMKIDList (admCtrl_t * pAdmCtrl,OS_802_11_PMKID *pmkidList)
+{
+
+    UINT8   neededLength, i = 0;
+    UINT8   NumOfEntries = pAdmCtrl->pmkid_cache.entriesNumber;
+    UINT8   *bssid, *pmkid;
+
+    if(!pAdmCtrl->preAuthSupport)
+        return PARAM_NOT_SUPPORTED;
+
+    /* Check the buffer length */
+    if(NumOfEntries > 1)
+       neededLength = 30 + ((NumOfEntries - 1) * (MAC_ADDR_LEN + PMKID_VALUE_SIZE));
+    else
+       neededLength = 30;
+
+    if(neededLength > pmkidList->Length)
+    {
+        /* The buffer length is not enough */
+        pmkidList->Length = neededLength;
+        return NOK;
+    }
+
+    /* The buffer is big enough. Fill the info */
+    pmkidList->Length         = neededLength;
+    pmkidList->BSSIDInfoCount = NumOfEntries;
+
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+      ("RSN:  Get PMKID cache.  Number of entries  = %d \n", NumOfEntries));
+
+    for (i = 0; i < NumOfEntries; i++ )
+    {
+        bssid = (UINT8 *) pAdmCtrl->pmkid_cache.pmkidTbl[i].bssId.addr;
+        pmkid = (UINT8 *)pAdmCtrl->pmkid_cache.pmkidTbl[i].pmkId;
+
+        os_memoryCopy(pAdmCtrl->hOs, (void *)pmkidList->osBSSIDInfo[i].BSSID,
+                      &bssid, MAC_ADDR_LEN);
+
+        os_memoryCopy(pAdmCtrl->hOs,(void *)pmkidList->osBSSIDInfo[i].PMKID,
+                      &pmkid, PMKID_VALUE_SIZE);
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+        ("RSN:  BSSID:  %.2X-%.2X-%.2X-%.2X-%.2X-%.2X   PMKID: %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X  \n",
+           bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5],
+           pmkid[0], pmkid[1], pmkid[2], pmkid[3],
+           pmkid[4], pmkid[5], pmkid[6], pmkid[7],
+           pmkid[8], pmkid[9], pmkid[10],pmkid[11],
+           pmkid[12],pmkid[13],pmkid[14],pmkid[15]));
+    }
+
+    return OK;
+
+}
+
+/**
+*
+* admCtrlWpa2_addPMKID 
+*
+* \b Description: 
+*
+* Add/Set an AP's PMKID received from the Supplicant 
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  I   - pBSSID   - pointer to AP's BSSID address 
+*  I   - pmkID    - AP's PMKID
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_addPMKID (admCtrl_t * pAdmCtrl, macAddress_t *pBSSID, pmkidValue_t pmkID)
+{
+   UINT8         cacheIndex;
+   TI_STATUS     status = NOK;
+
+   /* Try to find the pBSSId in the PMKID cache */
+   status = admCtrlWpa2_findPMKID (pAdmCtrl, pBSSID, NULL, &cacheIndex);
+
+   if(status == OK)
+   {
+       /* Entry for the bssid has been found; Update PMKID */
+       os_memoryCopy(pAdmCtrl->hOs, 
+                    (PVOID)&pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].pmkId,
+                    pmkID, PMKID_VALUE_SIZE);
+       /*pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].generationTs = os_timeStampMs(pAdmCtrl->hOs); */
+   }
+   else
+   {
+       /* The new entry is added to the next free entry. */
+       /* Copy the new entry to the next free place.     */
+       cacheIndex = pAdmCtrl->pmkid_cache.nextFreeEntry;
+       os_memoryCopy(pAdmCtrl->hOs, 
+                    (PVOID)&pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].bssId.addr,
+                    &(pBSSID->addr), MAC_ADDR_LEN);
+       os_memoryCopy(pAdmCtrl->hOs, 
+                    (PVOID)&pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].pmkId,
+                    (PVOID)pmkID, PMKID_VALUE_SIZE);
+
+       /* Update the next free entry index. (If the table is full, a new entry */
+       /* will override the oldest entries from the beginning of the table)    */
+       /* Update the number of entries. (it cannot be more than max cach size) */
+       pAdmCtrl->pmkid_cache.nextFreeEntry  = (cacheIndex + 1) % ADMCTRL_PMKID_CACHE_SIZE;
+
+       if(pAdmCtrl->pmkid_cache.entriesNumber < ADMCTRL_PMKID_CACHE_SIZE)
+          pAdmCtrl->pmkid_cache.entriesNumber ++;
+   }
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG, 
+         ("RSN   Add PMKID   Entry index is %d \n", cacheIndex));
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+        ("RSN:  BSSID: %.2X-%.2X-%.2X-%.2X-%.2X-%.2X  PMKID: %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X %.2X  \n",
+            pBSSID->addr[0], pBSSID->addr[1], pBSSID->addr[2], 
+            pBSSID->addr[3], pBSSID->addr[4], pBSSID->addr[5],
+            pmkID[0], pmkID[1], pmkID[2], pmkID[3],
+            pmkID[4], pmkID[5], pmkID[6], pmkID[7],
+            pmkID[8], pmkID[9], pmkID[10],pmkID[11],
+            pmkID[12],pmkID[13],pmkID[14],pmkID[15]));
+
+
+
+   return OK;
+}
+
+/**
+*
+* admCtrlWpa2_setPMKIDList 
+*
+* \b Description: 
+*
+* Set PMKID cache 
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl        - pointer to admCtrl context
+*  O   - pmkidList       - memory buffer where the procedure reads the PMKIDs from
+*                          Supplied by the caller procedure. 
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_setPMKIDList (admCtrl_t * pAdmCtrl, OS_802_11_PMKID *pmkidList)
+{
+    UINT8          neededLength, i = 0;
+    UINT8          NumOfEntries;
+    macAddress_t   macAddr;
+
+    /* Check the minimal buffer length */
+    if (pmkidList->Length < 2*sizeof(UINT32))
+    {
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+        ("RSN: Set PMKID list - Buffer size < min length (8 bytes). Supplied length is %d .\n",
+          pmkidList->Length));
+        return NOK;
+    }
+
+    /* Check the num of entries in the buffer: if 0 it means that */
+    /* PMKID cache has to be cleaned                              */
+    if(pmkidList->BSSIDInfoCount == 0)
+    {
+        admCtrlWpa2_resetPMKIDCache(pAdmCtrl);
+        return OK;
+    }
+
+    /* Check the buffer length */
+    NumOfEntries = (UINT8)pmkidList->BSSIDInfoCount;
+    neededLength =  2*sizeof(UINT32) + (NumOfEntries  *(MAC_ADDR_LEN + PMKID_VALUE_SIZE));
+
+    if(pmkidList->Length < neededLength)
+    {
+        /* Something wrong goes with the buffer */
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+        ("RSN: Set PMKID list - no enough room for %d entries; Needed length is %d. Supplied length is %d .\n",
+         NumOfEntries, neededLength,pmkidList->Length));
+        return NOK;
+    }
+
+    /*  Write  the PMKID to the PMKID cashe */
+    pmkidList->BSSIDInfoCount = NumOfEntries;
+    for (i = 0; i < NumOfEntries; i++ )
+    {
+        os_memoryCopy(pAdmCtrl->hOs, &macAddr.addr,
+                      &(pmkidList->osBSSIDInfo[i].BSSID), MAC_ADDR_LEN);
+         WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG,("admCtrlWpa2_setPMKIDList: Received new pre-auth AP\n"));
+         if (pAdmCtrl->numberOfPreAuthCandidates)
+         {
+            pAdmCtrl->numberOfPreAuthCandidates--;
+            if (pAdmCtrl->numberOfPreAuthCandidates == 0)
+            {
+               WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG,("Stopping the Pre-Auth timer since Pre-auth is finished\n"));
+               os_timerStop(pAdmCtrl->hOs, pAdmCtrl->preAuthTimerWpa2); 
+               /* Send PRE-AUTH end event to External Application */
+               admCtrl_notifyPreAuthStatus (pAdmCtrl, RSN_PRE_AUTH_END);
+            }
+
+            WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG,("admCtrlWpa2_setPMKIDList: %d APs left in candidate list\n",pAdmCtrl->numberOfPreAuthCandidates));
+
+         }
+        else
+        {
+           WLAN_REPORT_WARNING (pAdmCtrl->hReport, RSN_MODULE_LOG,("admCtrlWpa2_setPMKIDList: number of candidates was already zero...\n"));        
+        }
+        admCtrlWpa2_addPMKID(pAdmCtrl,&macAddr, (UINT8 *)pmkidList->osBSSIDInfo[i].PMKID);
+    }
+
+    return OK;
+
+}
+
+/**
+*
+* admCtrlWpa2_resetPMKIDCache 
+*
+* \b Description: 
+*
+* Reset PMKID Table 
+*
+* \b ARGS:
+*
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+TI_STATUS admCtrlWpa2_resetPMKIDCache (admCtrl_t *pAdmCtrl)
+{
+
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+         ("RSN:  Reset PMKID cache.  %d entries are deleted. \n",
+          pAdmCtrl->pmkid_cache.entriesNumber));
+
+   os_memoryZero(pAdmCtrl->hOs, (PVOID)&pAdmCtrl->pmkid_cache, sizeof(pmkid_cache_t));
+
+   return OK;
+}
+
+
+/**
+*
+* admCtrlWpa2_sendPMKIDCandidateListAfterDelay 
+*
+* \b Description: 
+*
+* New Candidate List of APs with the same SSID as the STA is connected to 
+* is generated and sent after the delay to the supplicant 
+* in order to retrieve the new PMKIDs for the APs.
+*
+* \b ARGS:
+*  I   - pAdmCtrl - pointer to admCtrl context
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+
+static void admCtrlWpa2_buildAndSendPMKIDCandList (TI_HANDLE hHandle, bssidList4PreAuth_t *apList)
+{
+
+    admCtrl_t         *pAdmCtrl = (admCtrl_t *)hHandle;
+    UINT8             candIndex =0, apIndex = 0, size =0;
+    paramInfo_t       param;
+    OS_802_11_PMKID_CANDIDATELIST  *pCandList;
+    UINT8             memBuff[PMKID_CAND_LIST_MEMBUFF_SIZE + sizeof(UINT32)];
+    dot11_RSN_t       *rsnIE = 0;
+    wpa2IeData_t      wpa2Data;
+    TI_STATUS         status = NOK;
+
+    /* Get SSID that the STA is accociated with    */
+    param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+    status          = siteMgr_getParam(pAdmCtrl->pRsn->hSiteMgr, &param);
+    if(status != OK)
+        return;
+
+    /* If the existing PMKID cache contains information for not relevant */
+    /* ssid (i.e. ssid was changed), clean up the PMKID cache and update */
+    /* the ssid in the PMKID cache */
+    if ((pAdmCtrl->pmkid_cache.ssid.len != param.content.siteMgrDesiredSSID.len) || 
+         (os_memoryCompare(pAdmCtrl->hOs, (UINT8 *)pAdmCtrl->pmkid_cache.ssid.ssidString,
+          (UINT8 *) param.content.siteMgrCurrentSSID.ssidString,
+                          pAdmCtrl->pmkid_cache.ssid.len) != 0))
+    {
+        admCtrlWpa2_resetPMKIDCache(pAdmCtrl);
+
+        os_memoryCopy(pAdmCtrl->hOs, (void *)pAdmCtrl->pmkid_cache.ssid.ssidString, 
+                      (void *)param.content.siteMgrCurrentSSID.ssidString,
+                      param.content.siteMgrCurrentSSID.len);
+        pAdmCtrl->pmkid_cache.ssid.len = param.content.siteMgrCurrentSSID.len;
+    }
+
+    /* Get list of APs of the SSID that the STA is associated with*/
+    /*os_memoryZero(pAdmCtrl->hOs, (PVOID)&apList, sizeof(bssidListBySsid_t));
+    status = siteMgr_GetApListBySsid (pAdmCtrl->pRsn->hSiteMgr, 
+                                      &param.content.siteMgrCurrentSSID,
+                                      &apList);
+    */
+    if((apList == NULL) || (apList->NumOfItems == 0))
+        return;
+        
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+        ("admCtrlWpa2_buildAndSendPMKIDCandList - Entry \n"));
+
+    /* fill the PMKID candidate list */
+    pCandList = (OS_802_11_PMKID_CANDIDATELIST *)(memBuff + sizeof(UINT32));
+    pCandList->Version = 1;
+    for (apIndex=0; apIndex<pAdmCtrl->pmkid_cache.entriesNumber; apIndex++)
+    {
+        pAdmCtrl->pmkid_cache.pmkidTbl[apIndex].preAuthenticate = FALSE;
+    }
+
+    /* Go over AP list and find APs supporting pre-authentication */
+    for(apIndex = 0; apIndex < apList->NumOfItems; apIndex++)
+    {
+        UINT8 *bssidMac, i = 0;
+
+        status = NOK;
+
+        if (apList->bssidList[apIndex].pRsnIEs==NULL)
+        {
+            continue;
+        }
+        /* Check is there RSN IE in this site */
+        rsnIE = 0;      
+        while( !rsnIE && (i < MAX_RSN_IE))
+        {
+            if(apList->bssidList[apIndex].pRsnIEs[i].hdr.eleId == RSN_IE_ID)
+            {
+                rsnIE  = &apList->bssidList[apIndex].pRsnIEs[i];
+                status = OK;
+            }
+            i ++;
+        }
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+            ("admCtrlWpa2_buildAndSendPMKIDCandList - rsnIE-hdr.eleId = %x \n", rsnIE->hdr.eleId));
+
+        if(status == OK)
+           status = admCtrlWpa2_parseIe(pAdmCtrl, (UINT8 *)rsnIE, &wpa2Data);
+
+        WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+            ("admCtrlWpa2_buildAndSendPMKIDCandList - parseIe status = %d \n", status));
+        if(status == OK)
+        {   
+            BOOL        preAuthStatus;
+            UINT8               cacheIndex;
+
+            preAuthStatus = admCtrlWpa2_getPreAuthStatus(pAdmCtrl, &apList->bssidList[apIndex].bssId, &cacheIndex);
+
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+                ("admCtrlWpa2_buildAndSendPMKIDCandList, preAuthStatus=%d \n", 
+                 preAuthStatus));
+
+            if (preAuthStatus)
+            {
+                pAdmCtrl->pmkid_cache.pmkidTbl[cacheIndex].preAuthenticate = TRUE;
+            }
+
+            bssidMac = (UINT8 *)apList->bssidList[apIndex].bssId.addr;
+            os_memoryCopy(pAdmCtrl->hOs, &(pCandList->CandidateList[candIndex].BSSID),
+                bssidMac, MAC_ADDR_LEN);
+            if(pAdmCtrl->preAuthSupport && (wpa2Data.preAuthentication))
+            {
+               pCandList->CandidateList[candIndex].Flags = 
+                                 OS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLE;
+            }
+            else
+            {
+                pCandList->CandidateList[candIndex].Flags = 0; 
+
+            }
+            WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+                ("RSN:  Candidate [%d] is   %.2X-%.2X-%.2X-%.2X-%.2X-%.2X , Flags=0x%x\n", candIndex,
+                  bssidMac[0], bssidMac[1], bssidMac[2], 
+                  bssidMac[3], bssidMac[4], bssidMac[5],
+                 pCandList->CandidateList[candIndex].Flags));
+            candIndex ++;
+        }
+        
+    }
+    /* Add candidates that have valid PMKID, but were not in the list */
+    for (apIndex=0; apIndex<pAdmCtrl->pmkid_cache.entriesNumber; apIndex++)
+    {
+        if (!pAdmCtrl->pmkid_cache.pmkidTbl[apIndex].preAuthenticate)
+        {
+            os_memoryCopy(pAdmCtrl->hOs, &(pCandList->CandidateList[candIndex].BSSID),
+                          (void *)pAdmCtrl->pmkid_cache.pmkidTbl[apIndex].bssId.addr, MAC_ADDR_LEN);
+            pCandList->CandidateList[apIndex].Flags = 
+                                 OS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLE;
+            candIndex++;
+        }
+    }
+
+
+    pCandList->NumCandidates = candIndex;
+
+    
+    /* Send Status Media specific indication to OS */
+    size = sizeof(OS_802_11_PMKID_CANDIDATELIST) + 
+           (candIndex - 1) * sizeof(OS_802_11_PMKID_CANDIDATE) + sizeof(UINT32);
+
+     /* Fill type of indication */
+    *(UINT32*)memBuff = os802_11StatusType_PMKID_CandidateList;
+
+    pCandList->NumCandidates = candIndex;
+
+    /* Store the number of candidates sent - needed for pre-auth finish event */
+    pAdmCtrl->numberOfPreAuthCandidates = candIndex;
+    /* Start the pre-authentication finish event timer */
+    /* If the pre-authentication process is not over by the time it expires - we send an event */
+    WLAN_REPORT_INFORMATION (pAdmCtrl->hReport, RSN_MODULE_LOG,("Starting PREAUTH timer (%d mSec)\n",pAdmCtrl->preAuthTimeout*candIndex));
+
+    os_timerStart(pAdmCtrl->hOs, pAdmCtrl->preAuthTimerWpa2, pAdmCtrl->preAuthTimeout*candIndex, FALSE);
+    EvHandlerSendEvent(pAdmCtrl->hEvHandler, IPC_EVENT_MEDIA_SPECIFIC,
+                        memBuff, size);
+
+    /* Send PRE-AUTH start event to External Application */
+    admCtrl_notifyPreAuthStatus (pAdmCtrl, RSN_PRE_AUTH_START);
+    WLAN_REPORT_INFORMATION(pAdmCtrl->hReport, RSN_MODULE_LOG,
+       ("RSN:  PMKID Candidate List with %d entries has been built and sent for ssid %s \n",
+        candIndex, pAdmCtrl->pmkid_cache.ssid.ssidString));
+
+    
+    return;
+
+}
+
+/**
+*
+* admCtrlWpa2_getPreAuthStatus 
+*
+* \b Description: 
+*
+* Returns the status of the Pre Auth for the BSSID. If the authentictaion mode
+ * is not WPA2, then FALSE will be returned.
+ * For WPA2 mode, if PMKID exists fro the BSSID and its liftime is valid 
+ * TRUE will be returned.
+ * Otherwise FALSE.
+* 
+* 
+*
+* \b ARGS:
+*  I   - pAdmCtrl - pointer to admCtrl context
+ * I   - givenAP  - required BSSID
+*  
+* \b RETURNS:
+*
+* OK on success, NOK on failure. 
+*
+* \sa 
+*/
+static BOOL admCtrlWpa2_getPreAuthStatus(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8  *cacheIndex)
+{
+    pmkidValue_t    PMKID;
+    
+    if (admCtrlWpa2_findPMKID (pAdmCtrl, givenAP, 
+                                 &PMKID, cacheIndex)!=OK)
+    {
+        return FALSE;
+    }
+    return TRUE;
+
+}
+
+static TI_STATUS admCtrlWpa2_startPreAuth(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList)
+{
+
+    admCtrlWpa2_buildAndSendPMKIDCandList (pAdmCtrl, pBssidList);
+    return OK;
+}
+
+static TI_STATUS admCtrlWpa2_get802_1x_AkmExists (admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists)
+{
+    *wpa_802_1x_AkmExists = pAdmCtrl->wpaAkmExists;
+    return OK;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: admCtrlWpa2_preAuthTimerExpire
+Routine Description: updates the preAuthStatus
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+void admCtrlWpa2_preAuthTimerExpire(TI_HANDLE hAdmCtrl)
+{
+    admCtrl_t         *pAdmCtrl = (admCtrl_t *)hAdmCtrl;
+    WLAN_REPORT_WARNING (pAdmCtrl->hReport, RSN_MODULE_LOG,("admCtrlWpa2_preAuthTimerExpire: PREAUTH EXPIRED !!!!!!!!"));
+    /* Send PRE-AUTH end event to External Application */
+    admCtrl_notifyPreAuthStatus (pAdmCtrl, RSN_PRE_AUTH_END);
+    pAdmCtrl->numberOfPreAuthCandidates = 0;
+   return;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/broadcastKey802_1x.c b/sta_dk_4_0_4_32/common/src/core/rsn/broadcastKey802_1x.c
new file mode 100644 (file)
index 0000000..8d0b61b
--- /dev/null
@@ -0,0 +1,357 @@
+/** \file broadcastKey802_1x.c
+ * \brief broadcast key 802.1x implementation
+ *
+ * \see broadcastKey802_1x.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   802.1x station broadcast key SM                             *
+ *   PURPOSE:   802.1x station broadcast key SM implementation                         *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+
+#include "broadcastKey802_1x.h"
+#include "mainKeysSm.h"
+
+
+TI_STATUS broadcastKey802_1x_start(struct _broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKey802_1x_stop(struct _broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKey802_1x_recvSuccess(struct _broadcastKey_t *pBroadcastKey, 
+                                                                       encodedKeyMaterial_t *pEncodedKeyMaterial);
+
+TI_STATUS broadcastKey802_1x_recvFailure(struct _broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKey802_1x_distribute(struct _broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKey802_1x_redistribute(struct _broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKey802_1x_event(struct _broadcastKey_t *pBroadcastKey,
+                                                         UINT8 event, 
+                                                         void *pData);
+
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_BroadcastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS broadcastKey802_1x_config(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS               status = NOK;
+       
+       /** Station broadcast key State Machine matrix */
+       fsm_actionCell_t    broadcastKey802_1x_matrix[BCAST_KEY_802_1X_NUM_STATES][BCAST_KEY_802_1X_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {       {BCAST_KEY_802_1X_STATE_START, (fsm_Action_t)broadcastKeySmNop},
+                       {BCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)broadcastKeySmNop},
+                       {BCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)broadcastKeySmNop},
+                       {BCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)broadcastKeySmUnexpected}
+               },
+       
+               /* next state and actions for START state */
+               {       {BCAST_KEY_802_1X_STATE_START, (fsm_Action_t)broadcastKeySmUnexpected},
+                       {BCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)broadcastKeySmNop},
+                       {BCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)broadcastKey802_1x_distribute},
+                       {BCAST_KEY_802_1X_STATE_START, (fsm_Action_t)broadcastKeySmNop}
+               },
+       
+               /* next state and actions for COMPLETE state */
+               {       {BCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)broadcastKeySmUnexpected},
+                       {BCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)broadcastKeySmNop},
+                       {BCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)broadcastKey802_1x_distribute},
+                       {BCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)broadcastKeySmUnexpected}
+               }
+       };
+
+
+       pBroadcastKey->start = broadcastKey802_1x_start;
+       pBroadcastKey->stop = broadcastKey802_1x_stop;
+       pBroadcastKey->recvFailure = broadcastKey802_1x_recvFailure;
+       pBroadcastKey->recvSuccess = broadcastKey802_1x_recvSuccess;
+
+       pBroadcastKey->currentState = BCAST_KEY_802_1X_STATE_IDLE;
+
+       status = fsm_Config(pBroadcastKey->pBcastKeySm, 
+                                               &broadcastKey802_1x_matrix[0][0], 
+                                               BCAST_KEY_802_1X_NUM_STATES, 
+                                               BCAST_KEY_802_1X_NUM_EVENTS, 
+                                               NULL, pBroadcastKey->hOs);
+
+
+
+       return status;
+}
+
+
+/**
+*
+* broadcastKey802_1x_event
+*
+* \b Description: 
+*
+* broadcast key state machine transition function
+*
+* \b ARGS:
+*
+*  I/O - currentState - current state in the state machine\n
+*  I   - event - specific event for the state machine\n
+*  I   - pData - Data for state machine action function\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+
+#ifdef REPORT_LOG
+
+static char *broadcastKey802_1x_stateDesc[BCAST_KEY_802_1X_NUM_STATES] = {
+               "STATE_IDLE",
+               "STATE_START",
+               "STATE_COMPLETE",
+       };
+       
+static char *broadcastKey802_1x_eventDesc[BCAST_KEY_802_1X_NUM_EVENTS] = {
+               "EVENT_START",
+               "EVENT_STOP",
+               "EVENT_SUCCESS",
+               "EVENT_FAILURE"
+       };
+
+#endif
+
+TI_STATUS broadcastKey802_1x_event(struct _broadcastKey_t *pBroadcastKey, UINT8 event, void *pData)
+{
+       TI_STATUS               status;
+       UINT8                   nextState;
+
+       status = fsm_GetNextState(pBroadcastKey->pBcastKeySm, pBroadcastKey->currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pBroadcastKey->hReport, RSN_MODULE_LOG,
+                                                 ("BROADCAST_KEY_SM: ERROR: failed getting next state\n"));
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pBroadcastKey->hReport, RSN_MODULE_LOG,
+                                                         ("STATION_BROADCAST_KEY_SM: <%s, %s> --> %s\n",
+                               broadcastKey802_1x_stateDesc[pBroadcastKey->currentState],
+                                                          broadcastKey802_1x_eventDesc[event],
+                                                          broadcastKey802_1x_stateDesc[nextState]));
+
+       status = fsm_Event(pBroadcastKey->pBcastKeySm, &pBroadcastKey->currentState, event, pData);
+
+       return status;
+}
+
+
+/**
+*
+* broadcastKey802_1x_start
+*
+* \b Description: 
+*
+* START event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa broadcastKey802_1x_stop()
+*/
+TI_STATUS broadcastKey802_1x_start(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS  status;
+       
+       status = broadcastKey802_1x_event(pBroadcastKey, BCAST_KEY_802_1X_EVENT_START, pBroadcastKey);
+
+       return status;
+}
+
+
+/**
+*
+* broadcastKey802_1x_stop
+*
+* \b Description: 
+*
+* START event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa broadcastKey802_1x_start()
+*/
+TI_STATUS broadcastKey802_1x_stop(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS  status;
+
+       status = broadcastKey802_1x_event(pBroadcastKey, BCAST_KEY_802_1X_EVENT_STOP, pBroadcastKey);
+
+       return status;
+}
+
+
+/**
+*
+* broadcastKey802_1x_recvSuccess
+*
+* \b Description: 
+*
+* SUCCESS event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*  I   - pEncodedKeyMaterial - Encoded key material \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+*/
+TI_STATUS broadcastKey802_1x_recvSuccess(struct _broadcastKey_t *pBroadcastKey, encodedKeyMaterial_t *pEncodedKeyMaterial)
+{
+       TI_STATUS  status;
+
+       pBroadcastKey->data.pEncodedKeyMaterial = pEncodedKeyMaterial;
+
+       status = broadcastKey802_1x_event(pBroadcastKey, BCAST_KEY_802_1X_EVENT_SUCCESS, pBroadcastKey);
+
+       return status;
+}
+
+
+/**
+*
+* broadcastKey802_1x_recvFailure
+*
+* \b Description: 
+*
+* FAILURE event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+*/
+TI_STATUS broadcastKey802_1x_recvFailure(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS  status;
+       
+       status = broadcastKey802_1x_event(pBroadcastKey, BCAST_KEY_802_1X_EVENT_FAILURE, pBroadcastKey);
+
+       return status;
+}
+
+
+/**
+*
+* broadcastKey802_1x_distribute
+*
+* \b Description: 
+*
+* Distribute broadcast key material to the driver and report the main key SM on broadcast complete.
+*
+* \b ARGS:
+*
+*  I   - pData - Encoded key material  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS broadcastKey802_1x_distribute(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS  status=NOK;
+       
+       if (pBroadcastKey->pKeyDerive->derive!=NULL)
+    {
+       status = pBroadcastKey->pKeyDerive->derive(pBroadcastKey->pKeyDerive, 
+                                                                                          pBroadcastKey->data.pEncodedKeyMaterial);
+    }
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       if (pBroadcastKey->pParent->reportBcastStatus!=NULL)
+    {
+       status = pBroadcastKey->pParent->reportBcastStatus(pBroadcastKey->pParent, OK);
+    }
+
+       return status;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/broadcastKeyNone.c b/sta_dk_4_0_4_32/common/src/core/rsn/broadcastKeyNone.c
new file mode 100644 (file)
index 0000000..42667a5
--- /dev/null
@@ -0,0 +1,162 @@
+/** \file broadcastKeyNone.c
+ * \brief broadcast key None implementation
+ *
+ * \see broadcastKeyNone.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   None station broadcast key SM                             *
+ *   PURPOSE:   None station broadcast key SM implementation                           *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+
+#include "broadcastKeyNone.h"
+#include "mainKeysSm.h"
+
+
+
+TI_STATUS broadcastKeyNone_distribute(struct _broadcastKey_t *pBroadcastKey, encodedKeyMaterial_t *pEncodedKeyMaterial);
+TI_STATUS broadcastKeyNone_start(struct _broadcastKey_t *pBroadcastKey);
+
+
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_BroadcastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS broadcastKeyNone_config(struct _broadcastKey_t *pBroadcastKey)
+{
+
+       pBroadcastKey->start = broadcastKeyNone_start;
+       pBroadcastKey->stop = broadcastKeySmNop;
+       pBroadcastKey->recvFailure = broadcastKeySmNop;
+       pBroadcastKey->recvSuccess = broadcastKeyNone_distribute;
+
+       pBroadcastKey->currentState = 0;
+
+       return OK;
+}
+
+
+/**
+*
+* broadcastKeyNone_start
+*
+* \b Description: 
+*
+* report the main key SM of broadcast complete, whithout wating for keys.
+*
+* \b ARGS:
+*
+*  I   - pBroadcastKey - context  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS broadcastKeyNone_start(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS       status=NOK;
+
+       if (pBroadcastKey->pParent->reportBcastStatus!=NULL)
+    {
+               status = pBroadcastKey->pParent->reportBcastStatus(pBroadcastKey->pParent, OK);
+    }
+
+       return status;
+}
+
+/**
+*
+* broadcastKeyNone_distribute
+*
+* \b Description: 
+*
+* Distribute broadcast key material to the driver and report the main key SM on broadcast complete.
+*
+* \b ARGS:
+*
+*  I   - pData - Encoded key material  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS broadcastKeyNone_distribute(struct _broadcastKey_t *pBroadcastKey, encodedKeyMaterial_t *pEncodedKeyMaterial)
+{
+       TI_STATUS  status=NOK;
+       
+       if (pBroadcastKey->pKeyDerive->derive!=NULL)
+    {
+        status = pBroadcastKey->pKeyDerive->derive(pBroadcastKey->pKeyDerive, 
+                                                   pEncodedKeyMaterial);
+    }
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       if (pBroadcastKey->pParent->reportBcastStatus!=NULL)
+    {
+        status = pBroadcastKey->pParent->reportBcastStatus(pBroadcastKey->pParent, OK);
+    }
+
+       return status;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/broadcastKeySM.c b/sta_dk_4_0_4_32/common/src/core/rsn/broadcastKeySM.c
new file mode 100644 (file)
index 0000000..fda047d
--- /dev/null
@@ -0,0 +1,226 @@
+/** \file broadcastKeySM.c
+ * \brief broadcast key SM implementation
+ *
+ * \see broadcastKeySM.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   broadcast key SM                               *
+ *   PURPOSE:   broadcast key SM implementation                                *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+
+#include "broadcastKeySM.h"
+#include "broadcastKey802_1x.h"
+#include "broadcastKeyNone.h"
+
+/** number of states in the state machine */
+#define        BCAST_KEY_MAX_NUM_STATES                3
+
+/** number of events in the state machine */
+#define        BCAST_KEY_MAX_NUM_EVENTS                4
+
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_BroadcastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+broadcastKey_t* broadcastKey_create(TI_HANDLE hOs)
+{
+       TI_STATUS                               status;
+       broadcastKey_t          *pBroadcastKey;
+
+       /* allocate key parser context memory */
+       pBroadcastKey = (broadcastKey_t*)os_memoryAlloc(hOs, sizeof(broadcastKey_t));
+       if (pBroadcastKey == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pBroadcastKey, sizeof(broadcastKey_t));
+
+       /* allocate memory for association state machine */
+       status = fsm_Create(hOs, &pBroadcastKey->pBcastKeySm, BCAST_KEY_MAX_NUM_STATES, BCAST_KEY_MAX_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pBroadcastKey, sizeof(broadcastKey_t));
+               return NULL;
+       }
+
+       pBroadcastKey->pKeyDerive = keyDerive_create(hOs);
+       if (pBroadcastKey->pKeyDerive == NULL)
+       {
+               fsm_Unload(hOs, pBroadcastKey->pBcastKeySm);
+               os_memoryFree(hOs, pBroadcastKey, sizeof(broadcastKey_t));
+               return NULL;
+       }
+
+       pBroadcastKey->hOs = hOs;
+
+       return pBroadcastKey;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_BroadcastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS broadcastKey_unload(struct _broadcastKey_t *pBroadcastKey)
+{
+       TI_STATUS               status;
+
+       status = keyDerive_unload(pBroadcastKey->pKeyDerive);
+       if (status != OK)
+       {
+               WLAN_OS_REPORT(("BCAST_KEY_SM: Error in unloading key derivation module\n"));
+       }
+
+       status = fsm_Unload(pBroadcastKey->hOs, pBroadcastKey->pBcastKeySm);
+       if (status != OK)
+       {
+               WLAN_OS_REPORT(("BCAST_KEY_SM: Error in unloading state machine\n"));
+       }
+
+       /* free key parser context memory */
+       os_memoryFree(pBroadcastKey->hOs, pBroadcastKey, sizeof(broadcastKey_t));
+
+       return OK;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_BroadcastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS broadcastKey_config(struct _broadcastKey_t *pBroadcastKey,
+                                                  rsn_paeConfig_t *pPaeConfig,
+                                                  struct _mainKeys_t *pParent,
+                                                  TI_HANDLE hReport,
+                                                  TI_HANDLE hOs)
+{
+       TI_STATUS               status = NOK;
+
+       pBroadcastKey->hReport = hReport;
+       pBroadcastKey->hOs = hOs;
+       pBroadcastKey->pParent = pParent;
+
+       /* configure according to the keyMng suite and cipher suite */
+       switch (pPaeConfig->keyExchangeProtocol)
+       {
+       case RSN_KEY_MNG_NONE:
+               status = broadcastKeyNone_config(pBroadcastKey);
+               break;
+       case RSN_KEY_MNG_802_1X:
+               if (pPaeConfig->broadcastSuite == RSN_CIPHER_NONE)
+               {
+                       status = broadcastKeyNone_config(pBroadcastKey);
+               } else {
+                       status = broadcastKey802_1x_config(pBroadcastKey);
+               }
+               break;
+    default:
+               status = broadcastKeyNone_config(pBroadcastKey);
+               break;
+       }
+
+       status = keyDerive_config(pBroadcastKey->pKeyDerive, pPaeConfig->broadcastSuite, pParent, hReport, hOs);
+
+       return status;
+}
+
+
+TI_STATUS broadcastKeySmUnexpected(struct _broadcastKey_t *pBroadcastKey)
+{
+       WLAN_REPORT_ERROR(pBroadcastKey->hReport, RSN_MODULE_LOG,
+                                         ("BROADCAST_KEY_SM: ERROR: UnExpected Event\n"));
+
+       return(NOK);
+}
+
+TI_STATUS broadcastKeySmNop(struct _broadcastKey_t *pBroadcastKey)
+{
+       return(OK);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrl.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrl.h
new file mode 100644 (file)
index 0000000..bdc1b23
--- /dev/null
@@ -0,0 +1,281 @@
+/** \file admCtrl.h
+ *  \brief Admission control API
+ *
+ *  \see admCtrl.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ADM_CTRL_H_
+#define _ADM_CTRL_H_
+
+#include "rsnApi.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _admCtrl_t      admCtrl_t;
+
+/* RSN admission control prototypes */
+
+typedef TI_STATUS (*admCtrl_setAuthSuite_t)(admCtrl_t *pAdmCtrl, authSuite_e authSuite);
+
+typedef TI_STATUS (*admCtrl_getAuthSuite_t)(admCtrl_t *pAdmCtrl, authSuite_e *pSuite);
+
+typedef TI_STATUS (*admCtrl_setNetworkMode_t)(admCtrl_t *pAdmCtrl, rsn_networkMode_t mode);
+
+typedef TI_STATUS (*admCtrl_setUcastCipherSuite_t)(admCtrl_t *pAdmCtrl, cipherSuite_e suite);
+
+typedef TI_STATUS (*admCtrl_setBcastCipherSuite_t)(admCtrl_t *pAdmCtrl, cipherSuite_e suite);
+
+typedef TI_STATUS (*admCtrl_getCipherSuite_t)(admCtrl_t *pAdmCtrl, cipherSuite_e *pSuite);
+
+typedef TI_STATUS (*admCtrl_setKeyMngSuite_t)(admCtrl_t *pAdmCtrl, rsn_keyMngSuite_e suite);
+
+typedef TI_STATUS (*admCtrl_setExtAuthMode_t)(admCtrl_t *pAdmCtrl, externalAuthMode_e extAuthMode);
+
+typedef TI_STATUS (*admCtrl_getExtAuthMode_t)(admCtrl_t *pAdmCtrl, externalAuthMode_e *pExtAuthMode);
+
+typedef TI_STATUS (*admCtrl_getInfoElement_t)(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
+
+typedef TI_STATUS (*admCtrl_setSite_t)(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+typedef TI_STATUS (*admCtrl_evalSite_t)(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
+
+typedef TI_STATUS (*admCtrl_setMixedMode_t)(admCtrl_t *pAdmCtrl, BOOL mixedMode);
+
+typedef TI_STATUS (*admCtrl_getMixedMode_t)(admCtrl_t *pAdmCtrl, BOOL *mixedMode);
+
+typedef TI_STATUS (*admCtrl_getAuthEncrCapability_t)(admCtrl_t *pAdmCtrl, 
+                                        rsnAuthEncrCapability_t   *authEncrCapability);
+
+typedef TI_STATUS (*admCtrl_setPMKIDlist_t)(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList);
+
+typedef TI_STATUS (*admCtrl_getPMKIDlist_t)(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList);
+
+typedef TI_STATUS (*admCtrl_resetPMKIDlist_t)(admCtrl_t *pAdmCtrl);
+
+typedef TI_STATUS (*admCtrl_sendPMKIDCandListAfterDelay_t)(admCtrl_t *pAdmCtrl, UINT32 delay);
+
+typedef TI_STATUS (*admCtrl_setPromoteFlags_t)(admCtrl_t *pAdmCtrl, UINT32 flags);
+
+typedef TI_STATUS (*admCtrl_getPromoteFlags_t)(admCtrl_t *pAdmCtrl, UINT32 *flags);
+
+typedef TI_STATUS (*admCtrl_getWPAMixedModeSupport_t)(admCtrl_t *pAdmCtrl, UINT32 *support);
+
+#ifdef EXC_MODULE_INCLUDED
+typedef TI_STATUS (*admCtrl_getNetworkEap_t)(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP *networkEap);
+
+typedef TI_STATUS (*admCtrl_setNetworkEap_t)(admCtrl_t *pAdmCtrl, OS_EXC_NETWORK_EAP networkEap);
+#endif
+
+
+typedef BOOL (*admCtrl_getPreAuthStatus_t)(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8 *cacheIndex);
+
+typedef TI_STATUS (*admCtrl_startPreAuth_t)(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList);
+
+typedef TI_STATUS (*admCtrl_get802_1x_AkmExists_t)(admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists);
+/* Constants */
+
+/* Flags for Any-WPA (WPA Mixed) mode) - set by the Supplicant  */
+#define ADMCTRL_WPA_OPTION_ENABLE_PROMOTE_AUTH_MODE  0x00000001
+#define ADMCTRL_WPA_OPTION_ENABLE_PROMOTE_CIPHER     0x00000002
+
+#define ADMCTRL_WPA_OPTION_MAXVALUE                  0x00000003
+
+
+/* Structures */
+
+/* PMKID cache structures                        */
+/* (PMKID cache used for WPA2 pre-authentication */
+
+#define PMKID_VALUE_SIZE  16
+typedef UINT8 pmkidValue_t[PMKID_VALUE_SIZE];
+
+#define PMKID_MAX_NUMBER 16
+
+typedef struct 
+{
+   macAddress_t bssId;
+   pmkidValue_t pmkId;
+   BOOL                        preAuthenticate;
+
+} pmkidEntry_t;
+
+#define ADMCTRL_PMKID_CACHE_SIZE 32
+
+typedef struct 
+{
+   ssid_t              ssid;
+   UINT8               entriesNumber;
+   UINT8               nextFreeEntry;
+   pmkidEntry_t        pmkidTbl[ADMCTRL_PMKID_CACHE_SIZE];
+} pmkid_cache_t;
+
+
+
+/* Admission control object */
+struct _admCtrl_t
+{
+       rsn_paeRole_t                   role;
+       authSuite_e                             authSuite;
+       rsn_networkMode_t               networkMode;
+       externalAuthMode_e              externalAuthMode;
+       cipherSuite_e                   unicastSuite;
+       cipherSuite_e                   broadcastSuite;
+       rsn_keyMngSuite_e               keyMngSuite;
+    BOOL                    wpaAkmExists;
+       BOOL                                    mixedMode;
+       UINT8                   AP_IP_Address[4];
+       UINT16                                  replayCnt;
+    UINT8                   aironetIeReserved[8];
+    BOOL                    encrInSw;
+    BOOL                    micInSw;
+    BOOL                    setSiteFirst;
+#ifdef EXC_MODULE_INCLUDED
+       OS_EXC_NETWORK_EAP              networkEapMode;
+#endif
+       BOOL                                    excSupport;
+       BOOL                                    proxyArpEnabled;
+
+       BOOL                    WPAMixedModeEnable;
+       UINT32                  WPAPromoteFlags;        
+
+       BOOL                    preAuthSupport;
+    UINT32                  preAuthTimeout;
+       UINT8                   MaxNumOfPMKIDs;
+       pmkid_cache_t           pmkid_cache;
+
+       struct _rsn_t                   *pRsn;
+       TI_HANDLE                               hMlme;
+       TI_HANDLE                               hRx;
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hOs;
+       TI_HANDLE                               hExcMngr;
+       TI_HANDLE                               hPowerMgr;
+       TI_HANDLE                               hEvHandler;
+
+
+       admCtrl_setAuthSuite_t                          setAuthSuite;
+       admCtrl_getAuthSuite_t                          getAuthSuite;
+       admCtrl_setNetworkMode_t                        setNetworkMode;
+       admCtrl_setUcastCipherSuite_t           setUcastSuite;
+       admCtrl_setBcastCipherSuite_t           setBcastSuite;
+       admCtrl_setExtAuthMode_t                        setExtAuthMode;
+       admCtrl_getExtAuthMode_t                        getExtAuthMode;
+       admCtrl_getCipherSuite_t                        getCipherSuite;
+       admCtrl_setKeyMngSuite_t                        setKeyMngSuite;
+       admCtrl_setMixedMode_t                  setMixedMode;
+       admCtrl_getMixedMode_t                  getMixedMode;
+       admCtrl_getInfoElement_t                        getInfoElement;
+       admCtrl_setSite_t                                       setSite;
+       admCtrl_evalSite_t                                      evalSite;
+       admCtrl_getAuthEncrCapability_t         getAuthEncrCap;
+       admCtrl_setPMKIDlist_t                  setPmkidList;
+       admCtrl_getPMKIDlist_t                  getPmkidList;
+       admCtrl_resetPMKIDlist_t                resetPmkidList;
+       admCtrl_setPromoteFlags_t        setPromoteFlags;
+       admCtrl_getPromoteFlags_t        getPromoteFlags;
+       admCtrl_getWPAMixedModeSupport_t getWPAMixedModeSupport;
+    admCtrl_get802_1x_AkmExists_t       get802_1x_AkmExists;
+
+
+#ifdef EXC_MODULE_INCLUDED
+       admCtrl_getNetworkEap_t                 getNetworkEap;
+       admCtrl_setNetworkEap_t                 setNetworkEap;
+#endif
+
+       admCtrl_getPreAuthStatus_t              getPreAuthStatus;
+       admCtrl_startPreAuth_t                  startPreAuth;
+
+    void                            *preAuthTimerWpa2;
+    UINT8                           numberOfPreAuthCandidates;
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+admCtrl_t* admCtrl_create(TI_HANDLE hOs);
+
+TI_STATUS admCtrl_config(TI_HANDLE hAdmCtrl,
+                      TI_HANDLE hMlme,
+                                         TI_HANDLE hRx,
+                                         TI_HANDLE hReport,
+                                         TI_HANDLE hOs,
+                                         struct _rsn_t *pRsn,
+                                         TI_HANDLE hExcMngr,
+                                         TI_HANDLE hPowerMgr,
+                      TI_HANDLE        hEvHandler,
+                                         rsnInitParams_t *pInitParam);
+
+TI_STATUS admCtrl_unload(admCtrl_t *pAdmCtrl);
+
+TI_STATUS admCtrlNone_config(admCtrl_t *pAdmCtrl);
+
+TI_STATUS admCtrlWpa_config(admCtrl_t *pAdmCtrl);
+
+TI_STATUS admCtrl_parseIe(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 **pIe, UINT8 IeId);
+
+TI_STATUS admCtrl_subConfig(TI_HANDLE hAdmCtrl);
+
+TI_STATUS admCtrl_nullSetPMKIDlist(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList);
+
+TI_STATUS admCtrl_nullGetPMKIDlist(admCtrl_t *pAdmCtrl, OS_802_11_PMKID  *pmkIdList);
+
+TI_STATUS admCtrl_resetPMKIDlist(admCtrl_t *pAdmCtrl);
+
+BOOL admCtrl_nullGetPreAuthStatus(admCtrl_t *pAdmCtrl, macAddress_t *givenAP, UINT8 *cacheIndex);
+
+TI_STATUS admCtrl_nullStartPreAuth(admCtrl_t *pAdmCtrl, bssidList4PreAuth_t *pBssidList);
+
+TI_STATUS admCtrl_nullGet802_1x_AkmExists(admCtrl_t *pAdmCtrl, BOOL *wpa_802_1x_AkmExists);
+
+void admCtrl_notifyPreAuthStatus (admCtrl_t *pAdmCtrl, preAuthStatusEvent_e newStatus);
+
+#endif /*  _ADM_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlNone.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlNone.h
new file mode 100644 (file)
index 0000000..4414b73
--- /dev/null
@@ -0,0 +1,80 @@
+/** \file admCtrlNone.h
+ *  \brief Admission control for None API
+ *
+ *  \see admCtrl.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ADM_CTRL_NONE_H_
+#define _ADM_CTRL_NONE_H_
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+
+/* RSN admission control prototypes */
+
+
+/* Structures */
+
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS admCtrlNone_config(admCtrl_t *pAdmCtrl);
+
+TI_STATUS admCtrlNone_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
+
+TI_STATUS admCtrlNone_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+TI_STATUS admCtrlNone_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
+
+#endif /*  _ADM_CTRL_NONE_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWep.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWep.h
new file mode 100644 (file)
index 0000000..cfe17f6
--- /dev/null
@@ -0,0 +1,80 @@
+/** \file admCtrlWep.h
+ *  \brief Admission control for EXC API
+ *
+ *  \see admCtrl.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ADM_CTRL_WEP_H_
+#define _ADM_CTRL_WEP_H_
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+
+/* RSN admission control prototypes */
+
+
+/* Structures */
+
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS admCtrlWep_config(admCtrl_t *pAdmCtrl);
+
+TI_STATUS admCtrlWep_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
+
+TI_STATUS admCtrlWep_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+TI_STATUS admCtrlWep_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
+
+#endif /*  _ADM_CTRL_WEP_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWpa.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWpa.h
new file mode 100644 (file)
index 0000000..87c9f78
--- /dev/null
@@ -0,0 +1,140 @@
+/** \file admCtrlWpa.h
+ *  \brief Admission control API
+ *
+ *  \see admCtrl.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                                        *
+ *   PURPOSE: Admission Control Module API                                     *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ADM_CTRL_WPA_H_
+#define _ADM_CTRL_WPA_H_
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+
+/* RSN admission control prototypes */
+
+
+/* Structures */
+
+
+
+#define MAX_WPA_UNICAST_SUITES      (RSN_CIPHER_CKIP+1)
+
+#define WPA_OUI_MAX_VERSION           0x1
+#define WPA_OUI_DEF_TYPE              0x1
+#define WPA_OUI_MAX_TYPE                         0x2
+
+#define WPA_GROUP_4_UNICAST_CAPABILITY_MASK    0x0002
+#define WPA_REPLAY_COUNTERS_CAPABILITY_MASK    0x000c
+#define WPA_REPLAY_GROUP4UNI_CAPABILITY_SHIFT  1
+#define WPA_REPLAY_COUNTERS_CAPABILITY_SHIFT   2
+
+#define WPA_IE_MIN_LENGTH                                      6
+#define WPA_IE_GROUP_SUITE_LENGTH                      10
+#define WPA_IE_MIN_PAIRWISE_SUITE_LENGTH       16
+#define WPA_IE_MIN_DEFAULT_LENGTH                      24
+#define WPA_IE_MIN_KEY_MNG_SUITE_LENGTH(pairwiseCnt) (18+4*pairwiseCnt)
+
+typedef enum 
+{
+       WPA_IE_KEY_MNG_NONE                             = 0,            /**< no key management available */
+       WPA_IE_KEY_MNG_801_1X                   = 1,            /**< "802.1X" key management - WPA default*/
+       WPA_IE_KEY_MNG_PSK_801_1X               = 2,            /**< "WPA PSK */
+       WPA_IE_KEY_MNG_CCKM                         = 3,                /**< WPA CCKM */
+       WPA_IE_KEY_MNG_NA                           = 4,                /**< NA */
+} keyMngSuite_e;
+
+
+#define        MAX_WPA_KEY_MNG_SUITES          (WPA_IE_KEY_MNG_CCKM+1)
+
+
+PACKED_STRUCT( wpaIePacket_t,
+
+       UINT8                           elementid;         /* WPA information element id is 0xDD */        
+       UINT8                           length;                    
+    UINT8                              oui[DOT11_OUI_LEN];
+       UINT8                           ouiType;
+    UINT16                             version;
+    UINT8                              groupSuite[DOT11_OUI_LEN+1];
+    UINT16                             pairwiseSuiteCnt;
+       UINT8                           pairwiseSuite[DOT11_OUI_LEN+1];
+       UINT16                          authKeyMngSuiteCnt;
+       UINT8                           authKeyMngSuite[DOT11_OUI_LEN+1];
+    UINT16                             capabilities;
+);
+
+
+/* WPA capabilities structure */
+typedef struct
+{
+
+    cipherSuite_e              broadcastSuite;
+    UINT16                             unicastSuiteCnt;
+       cipherSuite_e           unicastSuite[MAX_WPA_UNICAST_SUITES];
+       UINT16                          KeyMngSuiteCnt;
+       rsn_keyMngSuite_e       KeyMngSuite[MAX_WPA_KEY_MNG_SUITES];
+    UINT8                              bcastForUnicatst;
+       UINT8                           replayCounters;
+    BOOL excKp ;
+    BOOL excMic ;
+} wpaIeData_t;
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS admCtrlWpa_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
+
+TI_STATUS admCtrlWpa_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+TI_STATUS admCtrlWpa_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
+
+#endif /*  _ADM_CTRL_WPA_H_*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWpa2.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/admCtrlWpa2.h
new file mode 100644 (file)
index 0000000..30be765
--- /dev/null
@@ -0,0 +1,190 @@
+/** \file admCtrlWpa2.h
+ *  \brief Admission control header file for WPA2
+ *
+ *  \see admCtrl.c and admCtrlWpa2.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Admission Control                                             *
+ *   PURPOSE: Admission Control Header file for WPA2                        *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _ADM_CTRL_WPA2_H_
+#define _ADM_CTRL_WPA2_H_
+
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* WPA2 configuration parameters:                                       */
+/* defined here only for debugging purposes; should be moved from here  */
+
+#define WPA2_PRE_AUTHENTICATION_SUPPORT 1
+#define WPA2_PMKID_CACHE_SIZE           32
+#define WPA2_CANDIDATE_LIST_MAX_SIZE    16
+
+/* RSN admission control prototypes */
+
+
+/* Structures */
+
+
+
+#define MAX_WPA2_UNICAST_SUITES     (RSN_CIPHER_WEP104+1)
+#define MAX_WPA2_KEY_MNG_SUITES     (RSN_KEY_MNG_EXC+1)
+
+/* Cipher suites for group key sent in RSN IE are: WEP40, WEP104, TKIP, CCCMP */
+#define GRP_CIPHER_MAXNO_IN_RSNIE         4
+
+/* Cipher suites for unicast key sent in RSN IE are TKIP, CCMP, "use Group key"*/
+#define UNICAST_CIPHER_MAXNO_IN_RSNIE     3
+
+/* OUIs for cipher suites and appropriated values of cipherSuite_e (paramout.h file)
+ *
+ *   00-0F-AC-0   Use group cipher suite     RSN_CIPHER_NONE
+ *   00-0F-AC-1   WEP-40                     RSN_CIPHER_WEP
+ *   00-0F-AC-2   TKIP                       RSN_CIPHER_TKIP
+ *   00-0F-AC-3   Reserved                   RSN_CIPHER_WRAP   not used for WPA2
+ *   00-0F-AC-4   4                          RSN_CIPHER_CCMP
+ *   00-0F-AC-5   WEP-104                    RSN_CIPHER_WEP104
+ *   00-0F-AC 6   reserved 6 to 255          RSN_CIPHER_CKIP  - not used for WPA2
+ *
+ */
+
+/* Key management suites (Authentication and Key Management Protocol - AKMP)  */
+/* received in RSN IE                                                         */
+#define KEY_MGMT_SUITE_MAXNO_IN_RSN_IE  2
+
+/* OUIs for key management  
+*
+*   00-0F-AC-00  Reserved
+*   00-0F-AC-01  802.1X
+*   00-0F-AC-02  PSK
+*   00-0F-AC-03   reserved from 3 to 255
+*/
+
+/* WPA2 key management suites */
+#define WPA2_IE_KEY_MNG_NONE             0
+#define WPA2_IE_KEY_MNG_801_1X           1
+#define WPA2_IE_KEY_MNG_PSK_801_1X       2
+#define WPA2_IE_KEY_MNG_CCKM                    3
+#define WPA2_IE_KEY_MNG_NA               4
+
+
+#define WPA2_OUI_MAX_VERSION           0x1
+#define WPA2_OUI_DEF_TYPE              0x1
+#define WPA2_OUI_MAX_TYPE              0x2
+
+#define WPA2_PRE_AUTH_CAPABILITY_MASK               0x0001   /* bit 0 */
+#define WPA2_PRE_AUTH_CAPABILITY_SHIFT              0
+#define WPA2_GROUP_4_UNICAST_CAPABILITY_MASK        0x0002   /* bit 1 No Pairwise */
+#define WPA2_GROUP_4_UNICAST_CAPABILITY_SHIFT        1
+#define WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_MASK    0x000c   /* bit 2 and 3 */
+#define WPA2_PTK_REPLAY_COUNTERS_CAPABILITY_SHIFT   2
+#define WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_MASK    0x0030   /* bit 4 and 5 */
+#define WPA2_GTK_REPLAY_COUNTERS_CAPABILITY_SHIFT   4
+                                                             /* bit 6 - 15 - reserved */
+#define WPA2_IE_MIN_LENGTH                  4
+#define WPA2_IE_GROUP_SUITE_LENGTH          8
+#define WPA2_IE_MIN_PAIRWISE_SUITE_LENGTH   14
+#define WPA2_IE_MIN_DEFAULT_LENGTH          24
+#define WPA2_IE_MIN_KEY_MNG_SUITE_LENGTH(pairwiseCnt) (10+4*pairwiseCnt)
+
+
+
+
+/* WPA2 IE (RSN IE) packet structure                                          */
+/* This structure is used for outgoing packets, i.e. for association request  */
+/* For incoming packets (Beacon and Probe response from an AP) stucture of    */
+/* dot11_RSN_t type is used as more common stucture                           */
+PACKED_STRUCT( wpa2IePacket_t,
+
+    UINT8               elementid;           /* WPA2 IE (RSN IE) id is 0x30 */
+    UINT8               length;
+    UINT16              version;
+    UINT8               groupSuite[4];       /* OUI for broadcast suite */
+    UINT16              pairwiseSuiteCnt;
+    UINT8               pairwiseSuite[4];    /* OUI for 1 unicast suite */ 
+    UINT16              authKeyMngSuiteCnt;
+    UINT8               authKeyMngSuite[4];  /* OUI for 1 key mgmt suite */
+    UINT16              capabilities;
+    UINT16              pmkIdCnt;            /* only one PMKID is supported per AP */
+    UINT8               pmkId[PMKID_VALUE_SIZE];
+);
+
+
+/* WPA2 data parsed from RSN info element */
+typedef struct
+{
+
+    cipherSuite_e       broadcastSuite;
+    UINT16              unicastSuiteCnt;
+    cipherSuite_e       unicastSuite[MAX_WPA2_UNICAST_SUITES];
+    UINT16              KeyMngSuiteCnt;
+    UINT8               KeyMngSuite[MAX_WPA2_KEY_MNG_SUITES];
+    UINT8               preAuthentication;
+    UINT8               bcastForUnicatst;
+    UINT8               ptkReplayCounters;
+    UINT8               gtkReplayCounters;
+    UINT16              pmkIdCnt;
+    UINT8               pmkId[PMKID_VALUE_SIZE];
+} wpa2IeData_t;
+
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS admCtrlWpa2_config(admCtrl_t *pAdmCtrl);
+
+TI_STATUS admCtrlWpa2_getInfoElement(admCtrl_t *pAdmCtrl, UINT8 *pIe, UINT8 *pLength);
+
+TI_STATUS admCtrlWpa2_setSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen);
+
+TI_STATUS admCtrlWpa2_evalSite(admCtrl_t *pAdmCtrl, rsnData_t *pRsnData, bssType_e bssType, UINT32 *pEvaluation);
+
+void admCtrlWpa2_preAuthTimerExpire(TI_HANDLE hadmCtrl);
+
+#endif /*  _ADM_CTRL_WPA_H_*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKey802_1x.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKey802_1x.h
new file mode 100644 (file)
index 0000000..2b47808
--- /dev/null
@@ -0,0 +1,101 @@
+/** \file broadcastKeySM.h
+ *  \brief station broadcast key SM API
+ *
+ *  \see broadcastKeySM.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station broadcast key SM                                         *
+ *   PURPOSE: station broadcast key SM API                                         *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _BROADCAST_KEY_802_1X_H
+#define _BROADCAST_KEY_802_1X_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "broadcastKeySM.h"
+
+/* Constants */
+/** number of states in the state machine */
+#define        BCAST_KEY_802_1X_NUM_STATES             3
+
+/** number of events in the state machine */
+#define        BCAST_KEY_802_1X_NUM_EVENTS             4
+
+/* Enumerations */
+
+/** state machine states */
+typedef enum 
+{
+       BCAST_KEY_802_1X_STATE_IDLE                  = 0,
+       BCAST_KEY_802_1X_STATE_START                 = 1,
+       BCAST_KEY_802_1X_STATE_COMPLETE              = 2
+} broadcastKey802_1x_smStates;
+
+/** State machine events */
+typedef enum 
+{
+       BCAST_KEY_802_1X_EVENT_START                  = 0,
+       BCAST_KEY_802_1X_EVENT_STOP                   = 1,
+       BCAST_KEY_802_1X_EVENT_SUCCESS                = 2,
+       BCAST_KEY_802_1X_EVENT_FAILURE                            = 3
+} broadcastKey802_1x_smEvents;
+
+/* Enumerations */
+
+/* Typedefs */
+
+
+/* Structures */
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS broadcastKey802_1x_config(broadcastKey_t *pBroadcastKey);
+
+
+#endif /*  _BROADCAST_KEY_802_1X_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKeyNone.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKeyNone.h
new file mode 100644 (file)
index 0000000..cae6656
--- /dev/null
@@ -0,0 +1,77 @@
+/** \file broadcastKeyNone.h
+ *  \brief station broadcast key None API
+ *
+ *  \see broadcastKeySM.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station broadcast key SM                                         *
+ *   PURPOSE: station broadcast key SM API                                         *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _BROADCAST_KEY_NONE_H
+#define _BROADCAST_KEY_NONE_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "broadcastKeySM.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+
+/* Structures */
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS broadcastKeyNone_config(broadcastKey_t *pBroadcastKey);
+
+
+#endif /*  _BROADCAST_KEY_NONE_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKeySM.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/broadcastKeySM.h
new file mode 100644 (file)
index 0000000..5591aac
--- /dev/null
@@ -0,0 +1,116 @@
+/** \file broadcastKeySM.h
+ *  \brief station broadcast key SM API
+ *
+ *  \see broadcastKeySM.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station broadcast key SM                                         *
+ *   PURPOSE: station broadcast key SM API                                         *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _BROADCAST_KEY_SM_H
+#define _BROADCAST_KEY_SM_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _broadcastKey_t    broadcastKey_t;
+
+/* Main Sec SM functions */
+typedef TI_STATUS (*broadcastKeySmStart_t)(struct _broadcastKey_t *pBroadcastKey);
+typedef TI_STATUS (*broadcastKeySmStop_t)(struct _broadcastKey_t *pBroadcastKey);
+typedef TI_STATUS (*broadcastKeySmRecvSuccess_t)(struct _broadcastKey_t *pBroadcastKey, encodedKeyMaterial_t *pEncodedKeyMaterial);
+typedef TI_STATUS (*broadcastKeySmRecvFailure_t)(struct _broadcastKey_t *pBroadcastKey);
+
+/* Structures */
+
+/* State machine associated data structures. */
+typedef struct
+{
+       encodedKeyMaterial_t    *pEncodedKeyMaterial;
+} broadcastKeyData_t;
+
+struct _broadcastKey_t
+{
+       UINT8                               currentState;
+       fsm_stateMachine_t                      *pBcastKeySm;
+    broadcastKeyData_t                                 data;
+
+    struct _mainKeys_t                         *pParent;
+       struct _keyDerive_t                                     *pKeyDerive;
+       
+       TI_HANDLE                                       hReport;
+       TI_HANDLE                                       hOs;
+    
+    broadcastKeySmStart_t               start;
+    broadcastKeySmStop_t                stop;
+    broadcastKeySmRecvSuccess_t                        recvSuccess;
+    broadcastKeySmRecvFailure_t                        recvFailure;
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+broadcastKey_t* broadcastKey_create(TI_HANDLE hOs);
+
+TI_STATUS broadcastKey_unload(broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKey_config(broadcastKey_t *pBroadcastKey, 
+                                                  rsn_paeConfig_t *pPaeConfig, 
+                                                  struct _mainKeys_t *pParent,
+                                                  TI_HANDLE hReport,
+                                                  TI_HANDLE hOs);
+
+TI_STATUS broadcastKeySmUnexpected(struct _broadcastKey_t *pBroadcastKey);
+
+TI_STATUS broadcastKeySmNop(struct _broadcastKey_t *pBroadcastKey);
+
+#endif /*  _BROADCAST_KEY_SM_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/keyDerive.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/keyDerive.h
new file mode 100644 (file)
index 0000000..b3fc844
--- /dev/null
@@ -0,0 +1,100 @@
+/** \file unicastKeySM.h
+ *  \brief station unicast key SM API
+ *
+ *  \see unicastKeySM.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station unicast key SM                                           *
+ *   PURPOSE: station unicast key SM API                                           *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _KEY_DERIVE_H
+#define _KEY_DERIVE_H
+
+#include "paramOut.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _keyDerive_t    keyDerive_t;
+
+/* Main Sec SM functions */
+typedef TI_STATUS (*keyDeriveDerive_t)(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKeyMaterial);
+typedef TI_STATUS (*keyDeriveRemove_t)(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKeyMaterial);
+
+/* Structures */
+
+/* State machine associated data structures. */
+struct _keyDerive_t
+{
+       encodedKeyMaterial_t    key;
+
+       struct _mainKeys_t      *pMainKeys;
+       
+       TI_HANDLE                               hReport;
+       TI_HANDLE                           hOs;
+    
+       keyDeriveDerive_t               derive;
+       keyDeriveRemove_t               remove;
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+keyDerive_t* keyDerive_create(TI_HANDLE hOs);
+
+TI_STATUS keyDerive_unload(keyDerive_t *pKeyDerive);
+
+TI_STATUS keyDerive_config(keyDerive_t *pKeyDerive, 
+                                               cipherSuite_e cipher, 
+                                               struct _mainKeys_t *pParent,
+                                               TI_HANDLE hReport,
+                                               TI_HANDLE hOs);
+
+
+#endif /*  _KEY_DERIVE_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/keyParser.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/keyParser.h
new file mode 100644 (file)
index 0000000..58b1ab8
--- /dev/null
@@ -0,0 +1,113 @@
+/** \file keyParser.h
+ *  \brief key parser API
+ *
+ *  \see keyParser.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  Key Parser                                                   *
+ *   PURPOSE: key Parser module API                                    *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _KEY_PARSER_H
+#define _KEY_PARSER_H
+
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+/* Constants */
+#define MAX_REPLAY_COUNTER_LEN         8
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _keyParser_t    keyParser_t;
+
+/* RSN admission control prototypes */
+
+typedef TI_STATUS (*keyParser_recv_t)(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen);
+typedef TI_STATUS (*keyParser_config_t)(struct _keyParser_t *pKeyParser, TI_HANDLE hReport, TI_HANDLE hOs);
+typedef TI_STATUS (*keyParser_replayReset_t)(struct _keyParser_t *pKeyParser);
+typedef TI_STATUS (*keyParser_remove_t)(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen);
+
+/* Structures */
+
+struct _keyParser_t
+{
+       UINT8                                   replayCounter[MAX_REPLAY_COUNTER_LEN];
+
+       struct _mainKeys_t              *pParent;
+       struct _unicastKey_t    *pUcastKey;
+       struct _broadcastKey_t  *pBcastKey;
+
+       rsn_paeConfig_t         *pPaeConfig;
+
+       TI_HANDLE                               hReport;
+       TI_HANDLE                               hOs;
+    TI_HANDLE               hCtrlData;
+
+       keyParser_config_t              config;
+       keyParser_recv_t                recv;
+       keyParser_replayReset_t replayReset;
+       keyParser_remove_t              remove;
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+keyParser_t* keyParser_create(TI_HANDLE hOs);
+
+TI_STATUS keyParser_config(struct _keyParser_t *pKeyParser,
+                                               rsn_paeConfig_t *pPaeConfig,
+                        struct _unicastKey_t *pUcastKey,
+                        struct _broadcastKey_t *pBcastKey,
+                        struct _mainKeys_t *pParent,
+                                               TI_HANDLE hReport,
+                                               TI_HANDLE hOs,
+                        TI_HANDLE hCtrlData);
+
+TI_STATUS keyParser_unload(struct _keyParser_t *pKeyParser);
+
+TI_STATUS keyParser_nop(keyParser_t *pKeyParser);
+
+#endif /*  _KEY_PARSER_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/keyTypes.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/keyTypes.h
new file mode 100644 (file)
index 0000000..69773a1
--- /dev/null
@@ -0,0 +1,72 @@
+/** \file eapolParserMainInternal.h
+ * \brief EAPOL frame parser internal definitions header file.
+ *
+ *
+ * \see  eapolParseerMain.c,  eapolBuilderMain.h,  eapolBuilderMain.c, eapolParserMain.h
+*/
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:                                                                *
+ *   PURPOSE:                                                               *
+ *   CREATOR: Alexander Sirotkin.                                           *
+ *            Demiurg@ti.com                                                *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef  _KEY_TYPES_H
+#define  _KEY_TYPES_H
+
+#include "osTIType.h"
+
+/* Constatnts */
+
+
+#define SESSION_KEY_LEN                                16
+
+/* Structures */
+
+typedef struct
+{
+       UINT32  keyId;                          /**< Decoded key Id */
+       UINT32  keyLen;                                                 /**< Key length */
+       char    *pData;                                                 /**< Pointer to the material to derive the key from */
+} encodedKeyMaterial_t;
+
+
+#endif /*  _EAPOL_PARSER_INTERNAL_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainKeysSm.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainKeysSm.h
new file mode 100644 (file)
index 0000000..9def783
--- /dev/null
@@ -0,0 +1,142 @@
+/** \file mainKeysSm.h
+ *  \brief RSN main security SM
+ *
+ *  \see mainKeysSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mainKeysSm.h                                                                                               */
+/*    PURPOSE: RSN main security SM                                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MAIN_KEYS_SM_H
+#define _MAIN_KEYS_SM_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+#include "keyParser.h"
+#include "unicastKeySM.h"
+#include "broadcastKeySM.h"
+
+/* Constants */
+
+#define MAIN_KEYS_TIMEOUT                      20000
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _mainKeys_t    mainKeys_t;
+
+/* Main Sec SM functions */
+typedef TI_STATUS (*mainKeysSmStart_t)(struct _mainKeys_t *pMainKeys);
+typedef TI_STATUS (*mainKeysSmStop_t)(struct _mainKeys_t *pMainKeys);
+typedef TI_STATUS (*mainKeysSmReportUcastStatus_t)(struct _mainKeys_t *pMainKeys, TI_STATUS authStatus);
+typedef TI_STATUS (*mainKeysSmReportBcastStatus_t)(struct _mainKeys_t *pMainKeys, TI_STATUS authStatus);
+typedef TI_STATUS (*mainKeysSmReportReKey_t)(struct _mainKeys_t *pMainKeys);
+typedef TI_STATUS (*mainKeysSmSetKey_t)(struct _mainKeys_t *pMainKeys, securityKeys_t *pKey);
+typedef TI_STATUS (*mainKeysSmRemoveKey_t)(struct _mainKeys_t *pMainKeys, securityKeys_t *pKey);
+typedef TI_STATUS (*mainKeysSmSetDefaultKeyId_t)(struct _mainKeys_t *pMainKeys, UINT8 keyId);
+typedef TI_STATUS (*mainKeysSmGetSessionKey_t)(struct _mainKeys_t *pMainKeys, UINT8 *pKey, UINT32 *pKeyLen);
+
+/* Structures */
+
+typedef struct
+{
+       TI_STATUS               status;
+} mainKeysData_t;
+
+struct _mainKeys_t
+{
+       UINT8                               currentState;
+       UINT32                                                          keysTimeout;
+    mainKeysData_t                                             data;
+       fsm_stateMachine_t                      *pMainKeysSm;
+    BOOL                                               mainKeysTimeoutCounter;
+
+       TI_HANDLE                                                       timer;
+       TI_HANDLE                                                       hCtrlData;
+       TI_HANDLE                                       hReport;
+       TI_HANDLE                                       hOs;
+    TI_HANDLE                           hEvHandler;
+    TI_HANDLE                           hConn;
+    TI_HANDLE                           hRsn;
+       
+       keyParser_t                                                     *pKeyParser;
+       unicastKey_t                                            *pUcastSm;
+       broadcastKey_t                                          *pBcastSm;
+    struct _mainSec_t                          *pParent;
+
+    mainKeysSmStart_t                   start;
+    mainKeysSmStop_t                    stop;
+    mainKeysSmReportUcastStatus_t              reportUcastStatus;
+    mainKeysSmReportBcastStatus_t       reportBcastStatus;
+    mainKeysSmReportReKey_t                            reportReKey;
+       mainKeysSmSetKey_t                                      setKey; 
+       mainKeysSmRemoveKey_t                           removeKey;
+       mainKeysSmSetDefaultKeyId_t                     setDefaultKeyId;
+       mainKeysSmGetSessionKey_t                       getSessionKey;
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+mainKeys_t* mainKeys_create(TI_HANDLE hOs);
+
+TI_STATUS mainKeys_unload(mainKeys_t *pmainKeys);
+
+TI_STATUS mainKeys_config(mainKeys_t *pMainKeys, 
+                      rsn_paeConfig_t *pPaeConfig, 
+                      void *pParent,
+                                         TI_HANDLE             hReport,
+                                         TI_HANDLE             hOs,
+                      TI_HANDLE     hCtrlData,
+                      TI_HANDLE     hEvHandler,
+                      TI_HANDLE     hConn,
+                      TI_HANDLE     hRsn);
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainKeysSmInternal.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainKeysSmInternal.h
new file mode 100644 (file)
index 0000000..da7e535
--- /dev/null
@@ -0,0 +1,124 @@
+/** \file mainKeysSm.h
+ *  \brief RSN main security SM
+ *
+ *  \see mainKeysSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mainKeysSm.h                                                                                               */
+/*    PURPOSE: RSN main security SM                                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MAIN_KEYS_INTERNAL_H
+#define _MAIN_KEYS_INTERNAL_H
+
+#include "paramOut.h"
+#include "rsnApi.h"
+
+#include "mainKeysSm.h"
+
+/* Constants */
+
+
+/* Enumerations */
+
+/* Typedefs */
+
+/** state machine states */
+typedef enum 
+{
+       MAIN_KEYS_STATE_IDLE                  = 0,      
+       MAIN_KEYS_STATE_START                 = 1,      
+       MAIN_KEYS_STATE_UNICAST_COMPLETE      = 2,              
+       MAIN_KEYS_STATE_BROADCAST_COMPLETE    = 3,      
+       MAIN_KEYS_STATE_COMPLETE              = 4,
+    MAIN_KEYS_NUM_STATES
+} mainKeys_smStates;
+
+/** State machine events */
+typedef enum 
+{
+       MAIN_KEYS_EVENT_START                                   = 0,
+       MAIN_KEYS_EVENT_STOP                                    = 1,
+       MAIN_KEYS_EVENT_UCAST_COMPLETE                  = 2,
+       MAIN_KEYS_EVENT_BCAST_COMPLETE                  = 3,
+       MAIN_KEYS_EVENT_SESSION_TIMEOUOT                = 4,
+    MAIN_KEYS_NUM_EVENTS
+} mainKeys_smEvents;
+
+
+/* Main Sec SM functions */
+
+/* Structures */
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS mainKeys_start(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_stop(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_reportUcastStatus(struct _mainKeys_t *pMainKeys, TI_STATUS ucastStatus);
+TI_STATUS mainKeys_reportBcastStatus(struct _mainKeys_t *pMainKeys, TI_STATUS bcastStatus);
+void mainKeys_sessionTimeout(void *pMainKeys);
+TI_STATUS mainKeys_setKey(struct _mainKeys_t *pMainKeys, securityKeys_t *pKey);
+TI_STATUS mainKeys_removeKey(struct _mainKeys_t *pMainKeys, securityKeys_t *pKey);
+TI_STATUS mainKeys_setDefaultKeyId(struct _mainKeys_t *pMainKeys, UINT8 keyId);
+TI_STATUS mainKeys_getSessionKey(struct _mainKeys_t *pMainKeys, UINT8 *pKey, UINT32 *pKeyLen);
+
+TI_STATUS mainKeys_startIdle(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_stopStart(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_stopUcastComplete(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_bcastCompleteUcastComplete(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_smTimeOut(void* data);
+TI_STATUS mainKeys_stopBcastComplete(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_ucastCompleteBcastComplete(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeys_stopComplete(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeySmUnexpected(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeySmNop(struct _mainKeys_t *pMainKeys);
+TI_STATUS mainKeySmSetKeyCompleted(struct _mainKeys_t *pMainKeys);
+
+
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecKeysOnly.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecKeysOnly.h
new file mode 100644 (file)
index 0000000..2f0fb4c
--- /dev/null
@@ -0,0 +1,134 @@
+/** \file MainSecSm.h
+ *  \brief RSN main security SM
+ *
+ *  \see MainSecSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: MainSecSm.h                                                                                                */
+/*    PURPOSE: RSN main security SM                                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MAIN_SEC_KEYS_ONLY_H
+#define _MAIN_SEC_KEYS_ONLY_H
+
+#include "fsm.h"
+#include "mainSecSm.h"
+
+/* Constants */
+
+/** number of events in the state machine */
+#define        MAIN_SEC_KEYS_ONLY_NUM_EVENTS           4
+
+/** number of states in the state machine */
+#define        MAIN_SEC_KEYS_ONLY_NUM_STATES           4
+
+/* Enumerations */
+
+/* state machine states */
+typedef enum 
+{
+       MAIN_KO_STATE_IDLE                              = 0,
+       MAIN_KO_STATE_START                             = 1,
+       MAIN_KO_STATE_AUTHORIZED                = 2,
+       MAIN_KO_STATE_NONAUTHORIZED             = 3,
+} main_keysOnlyStates;
+
+/* State machine inputs */
+typedef enum 
+{
+       MAIN_KO_EVENT_START                             = 0,
+       MAIN_KO_EVENT_STOP                              = 1,
+       MAIN_KO_EVENT_KEYS_COMPLETE             = 2,
+       MAIN_KO_EVENT_SEC_ATTACK                = 3
+} main_keysOnlyEvents;
+
+
+/* Typedefs */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS mainSecKeysOnly_config(mainSec_t *pMainSec, 
+                            rsn_paeConfig_t *pPaeConfig);
+
+TI_STATUS mainSecKeysOnly_start(mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_stop(mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_setSessionKey(mainSec_t *pMainSec, UINT8* pKey, UINT8 keyLen);
+
+TI_STATUS mainSecKeysOnly_getSessionKey(mainSec_t *pMainSec, UINT8* pKey, UINT32* pKeyLen);
+
+TI_STATUS mainSecKeysOnly_reportKeysStatus(mainSec_t *pMainSec, TI_STATUS keyStatus);
+
+/* state machine functions */
+
+TI_STATUS mainSecKeysOnly_startIdle(struct _mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_stopStart(struct _mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_keysCompleteStart(struct _mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_keysTOStart(struct _mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_stopAuthorized(struct _mainSec_t *pMainSec);
+
+TI_STATUS mainSecKeysOnly_stopNonAuthorized(struct _mainSec_t *pMainSec);
+
+/* state machine action functions */
+
+TI_STATUS mainSecKeysOnly_StartMainKeySm(void* pData);
+
+TI_STATUS mainSecKeysOnly_StopMainKeySm(void* pData);
+
+TI_STATUS mainSecKeysOnly_ReportAuthSuccess(void* pData);
+
+TI_STATUS mainSecKeysOnly_ReportAuthFailure(void* pData);
+
+TI_STATUS mainSecKeysOnly_Nop(void* pData);
+
+TI_STATUS mainSecKeysOnly_unexpected(void* pData);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecNull.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecNull.h
new file mode 100644 (file)
index 0000000..312047c
--- /dev/null
@@ -0,0 +1,82 @@
+/** \file MainSecSm.h
+ *  \brief RSN main security SM
+ *
+ *  \see MainSecSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: MainSecSm.h                                                                                                */
+/*    PURPOSE: RSN main security SM                                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MAIN_SEC_NULL_SM_H
+#define _MAIN_SEC_NULL_SM_H
+
+#include "fsm.h"
+#include "mainSecSm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS mainSecSmNull_config(mainSec_t *pMainSec, 
+                            rsn_paeConfig_t *pPaeConfig);
+
+TI_STATUS mainSecSmNull_start(mainSec_t *pMainSec);
+
+TI_STATUS mainSecSmNull_stop(mainSec_t *pMainSec);
+
+TI_STATUS mainSecNull_reportKeysStatus(mainSec_t *pMainSec, TI_STATUS keysStatus);
+
+TI_STATUS mainSecNull_getAuthState(mainSec_t *pMainSec, TIWLN_SECURITY_STATE *supp1XState);
+
+TI_STATUS mainSecNull_reportAuthFailure(mainSec_t *pMainSec, authStatus_e authStatus) ;
+TI_STATUS mainSecNull_setAuthIdentity(mainSec_t *pMainSec, authIdentity_t *authIdentity);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecSm.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/mainSecSm.h
new file mode 100644 (file)
index 0000000..e774891
--- /dev/null
@@ -0,0 +1,157 @@
+/** \file MainSecSm.h
+ *  \brief RSN main security SM
+ *
+ *  \see MainSecSm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: MainSecSm.h                                                                                                */
+/*    PURPOSE: RSN main security SM                                                                       */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _MAIN_SEC_SM_H
+#define _MAIN_SEC_SM_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "rsn.h"
+#include "keyTypes.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _mainSec_t    mainSec_t;
+
+/* Main Sec SM functions */
+typedef TI_STATUS (*mainSecSmStart_t)(struct _mainSec_t *pMainSec);
+typedef TI_STATUS (*mainSecSmStop_t)(struct _mainSec_t *pMainSec);
+typedef TI_STATUS (*mainSecSmReportAuthStatus_t)(struct _mainSec_t *pMainSec, TI_STATUS authStatus);
+typedef TI_STATUS (*mainSecSmReportKeysStatus_t)(struct _mainSec_t *pMainSec, TI_STATUS keyStatus);
+typedef TI_STATUS (*mainSecSmReportReauthentication_t)(struct _mainSec_t *pMainSec);
+typedef TI_STATUS (*mainSecSmSetSessionKey_t)(struct _mainSec_t *pMainSec, UINT8* pKey, UINT8 keyLen);
+typedef TI_STATUS (*mainSecSmGetSessionKey_t)(struct _mainSec_t *pMainSec, UINT8* pKey, UINT32* pKeyLen);
+typedef TI_STATUS (*mainSecSmSetKey_t)(struct _mainSec_t *pMainSec, securityKeys_t *pKey);
+typedef TI_STATUS (*mainSecSmRemoveKey_t)(struct _mainSec_t *pMainSec, securityKeys_t *pKey);
+typedef TI_STATUS (*mainSecSmSetDefaultKeyId_t)(struct _mainSec_t *pMainSec, UINT8 keyId);
+typedef TI_STATUS (*mainSecSmEapolRecv_t)(struct _mainSec_t *pMainSec, UINT8 *pPacket);
+typedef TI_STATUS (*mainSecSm_getAuthIdentity_t)(struct _mainSec_t *pMainSec, authIdentity_t *authIdentity);
+typedef TI_STATUS (*mainSecSm_getAuthState_t)(struct _mainSec_t *pMainSec, TIWLN_SECURITY_STATE *secState);
+typedef TI_STATUS (*mainSecSm_reportAuthFailure_t)(struct _mainSec_t *pMainSec, authStatus_e authStatus);
+
+/* Structures */
+
+typedef struct
+{
+       rsn_paeConfig_t         *pPaeConfig;
+       UINT32                          heldPeriod;
+       UINT32                          startPeriod;
+       UINT32                          authPeriod;
+       UINT32                          maxStart;
+       UINT8                           *pUserId;
+       UINT8                           idLen;
+       UINT8                           *pUserPasswd;
+       UINT8                           pwdLen;
+} mainSecInitData_t;
+
+typedef struct
+{
+       TI_STATUS               status;
+} mainSecData_t;
+
+struct _mainSec_t
+{
+       UINT8                               currentState;
+    UINT32                                             startCount;
+       fsm_stateMachine_t                      *pMainSecSm;
+       BOOL                                            PrivacyOptionImplemented;
+    mainSecData_t                                              data;
+       UINT8                                                           sessionKey[SESSION_KEY_LEN];
+       UINT8                                                           sessionKeyLen;
+
+    struct _rsn_t                              *pParent;
+       TI_HANDLE                                       hReport;
+       TI_HANDLE                                       hOs;
+       
+    struct _mainKeys_t                  *pMainKeys; 
+    struct _keyParser_t                 *pKeyParser;
+
+    mainSecSmStart_t                    start;
+    mainSecSmStop_t                     stop;
+    mainSecSmReportAuthStatus_t         reportAuthStatus;
+    mainSecSmReportKeysStatus_t        reportKeysStatus;
+    mainSecSmReportReauthentication_t   reportReAuthenticate;
+       mainSecSmSetSessionKey_t                        setSessionKey;
+       mainSecSmGetSessionKey_t                        getSessionKey;
+       mainSecSmSetKey_t                                       setKey;
+       mainSecSmRemoveKey_t                            removeKey;
+       mainSecSmSetDefaultKeyId_t                      setDefaultKeyId;
+    mainSecSm_getAuthIdentity_t                getAuthIdentity;
+    mainSecSm_getAuthIdentity_t                setAuthIdentity;
+       mainSecSm_getAuthState_t                        getAuthState;
+    mainSecSm_reportAuthFailure_t       reportAuthFailure;
+
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+mainSec_t* mainSec_create(TI_HANDLE hOs);
+
+TI_STATUS mainSec_unload(mainSec_t *pMainSec);
+
+TI_STATUS mainSec_config(mainSec_t *pMainSec,
+                      mainSecInitData_t *pInitData, 
+                                         void *pParent,
+                                         TI_HANDLE hReport,
+                                         TI_HANDLE hOs,
+                      TI_HANDLE hCtrlData,
+                      TI_HANDLE hEvHandler,
+                      TI_HANDLE hConn,
+                      TI_HANDLE hHalCtrl);
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/rsn.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/rsn.h
new file mode 100644 (file)
index 0000000..c27de6e
--- /dev/null
@@ -0,0 +1,192 @@
+/** \file assocSM.h
+ *  \brief 802.11 Association SM
+ *
+ *  \see assocSM.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE: assocSM.h                                                  */
+/*    PURPOSE:  802.11 Association SM                                      */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef _RSN_H
+#define _RSN_H
+
+#include "rsnApi.h"
+#include "memMngrEx.h"
+#include "paramOut.h"
+#include "siteHash.h"
+
+/* Constants */
+
+#define RSN_MAX_NUMBER_OF_EVENTS        6
+#define RSN_MAX_NUMBER_OF_BANNED_SITES  16
+#define RSN_MIC_FAILURE_REPORT_WAIT     500
+#define RSN_MIC_FAILURE_TIMEOUT         (60000 + RSN_MIC_FAILURE_REPORT_WAIT)
+#define RSN_MAIN_KEYS_SESSION_TIMEOUT   RSN_AUTH_FAILURE_TIMEOUT 
+#define RSN_MIC_FAILURE_RE_KEY          3000
+
+/* Enumerations */
+typedef enum 
+{
+    MIC_FAILURE_FALSE,
+    MIC_FAILURE_TRUE,
+    MIC_FAILURE_BLOCK
+} rsn_micFailureStatus_e;
+
+typedef enum 
+{
+    GROUP_KEY_UPDATE_FALSE,
+    GROUP_KEY_UPDATE_TRUE
+} rsn_groupKeyUpdate_e;
+
+/* Typedefs */
+typedef struct _rsn_t   rsn_t;
+         
+typedef TI_STATUS (*rsn_eventCallback_t)(void* pCtx, void *pData);
+typedef TI_STATUS (*rsn_setPaeConfig_t)(rsn_t *pRsn, rsn_paeConfig_t *pPaeConfig);
+typedef TI_STATUS (*rsn_getNetworkMode_t)(rsn_t *pRsn, rsn_networkMode_t *pNetMode);
+
+typedef TI_STATUS (*rsn_setKey_t)(rsn_t *pMainSec, securityKeys_t *pKey);
+typedef TI_STATUS (*rsn_removeKey_t)(rsn_t *pMainSec, securityKeys_t *pKey);
+typedef TI_STATUS (*rsn_setDefaultKeyId_t)(rsn_t *pMainSec, UINT8 keyId);
+typedef TI_STATUS (*rsn_reportStatus_t)(rsn_t *pRsn, TI_STATUS rsnStatus);
+typedef TI_STATUS (*rsn_sendEapol_t)(rsn_t *pRsn, UINT8 *pPacket, UINT32 length);
+typedef TI_STATUS (*rsn_recvEapol_t)(rsn_t *pRsn, mem_MSDU_T *pMsdu);
+typedef TI_STATUS (*rsn_getSiteEntry_t)(rsn_t *pRsn, macAddress_t *macAddress, siteEntry_t *curSiteEntry);
+
+typedef struct
+{
+    rsn_eventCallback_t     eventFunc;
+    void                    *pCtx;
+} rsn_eventStruct_t;
+
+typedef struct
+{
+    char                id[MAX_IDENTITY_LEN];           /**< User identity string */
+    UINT8               idLength;                       /**< User identity string length */
+    char                password[MAX_PASSWD_LEN];       /**< User password string */
+    UINT8               pwdLength;                      /**< User password string length */
+} authIdentity_t;
+
+typedef struct 
+{
+    rsn_siteBanLevel_e      banLevel;
+    UINT32                  banStartedMs;
+    UINT32                  banDurationMs;
+    macAddress_t            siteBssid;
+} rsn_siteBanEntry_t;
+
+struct _rsn_t
+{
+    rsn_eventStruct_t       events[RSN_MAX_NUMBER_OF_EVENTS];
+    rsn_paeConfig_t         paeConfig;
+    BOOL                    PrivacyOptionImplemented;
+    
+    securityKeys_t          keys[MAX_KEYS_NUM];
+    BOOL                    keys_en [MAX_KEYS_NUM];
+    UINT8                   defaultKeyId;
+    BOOL                    defaultKeysOn;
+    BOOL                    wepDefaultKeys[MAX_KEYS_NUM];
+    BOOL                    wepStaticKey;
+    rsn_groupKeyUpdate_e    groupKeyUpdate;
+    OS_802_11_EAP_TYPES     eapType;
+
+    rsn_siteBanEntry_t      bannedSites[RSN_MAX_NUMBER_OF_BANNED_SITES];
+    UINT8                   numOfBannedSites;
+
+    TI_HANDLE               micFailureReportWaitTimer;
+    TI_HANDLE               micFailureReKeyTimer;
+
+    struct _admCtrl_t       *pAdmCtrl;
+    struct _mainSec_t       *pMainSecSm;
+
+    struct _keyParser_t     *pKeyParser;
+
+    TI_HANDLE               hTx;
+    TI_HANDLE               hRx;
+    TI_HANDLE               hConn;
+    TI_HANDLE               hCtrlData;
+    TI_HANDLE               hWhalCtrl;
+    TI_HANDLE               hMemMgr;
+    TI_HANDLE               hSiteMgr;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hOs;
+    TI_HANDLE               hExcMngr;
+    TI_HANDLE               hEvHandler;
+    TI_HANDLE               hSmeSm;
+    TI_HANDLE               hAPConn;
+    
+    rsn_setPaeConfig_t      setPaeConfig;
+    rsn_getNetworkMode_t    getNetworkMode;
+    rsn_setKey_t            setKey;
+    rsn_removeKey_t         removeKey;
+    rsn_setDefaultKeyId_t   setDefaultKeyId;
+    rsn_reportStatus_t      reportStatus;
+
+    UINT32                  rsnStartedTs;
+    UINT32                  rsnCompletedTs;
+};
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS rsn_reportStatus(rsn_t *pRsn, TI_STATUS status);
+
+TI_STATUS rsn_setPaeConfig(rsn_t *pRsn, rsn_paeConfig_t *pPaeConfig);
+
+TI_STATUS rsn_getNetworkMode(rsn_t *pRsn, rsn_networkMode_t *pNetMode);
+
+TI_STATUS rsn_setKey(rsn_t *pMainSec, securityKeys_t *pKey);
+
+TI_STATUS rsn_removeKey(rsn_t *pMainSec, securityKeys_t *pKey);
+
+TI_STATUS rsn_setDefaultKeyId(rsn_t *pMainSec, UINT8 keyId);
+
+TI_STATUS rsn_setDefaultKeys(rsn_t *pHandle);
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKey802_1x.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKey802_1x.h
new file mode 100644 (file)
index 0000000..76a5bce
--- /dev/null
@@ -0,0 +1,102 @@
+/** \file unicastKeySM.h
+ *  \brief station unicast key SM API
+ *
+ *  \see unicastKeySM.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station unicast key SM                                           *
+ *   PURPOSE: station unicast key SM API                                           *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _UNICAST_KEY_802_1X_H
+#define _UNICAST_KEY_802_1X_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "keyDerive.h"
+#include "unicastKeySM.h"
+
+/* Constants */
+/** number of states in the state machine */
+#define        UCAST_KEY_802_1X_NUM_STATES             3
+
+/** number of events in the state machine */
+#define        UCAST_KEY_802_1X_NUM_EVENTS             4
+
+/* Enumerations */
+
+/** state machine states */
+typedef enum 
+{
+       UCAST_KEY_802_1X_STATE_IDLE                  = 0,
+       UCAST_KEY_802_1X_STATE_START                 = 1,
+       UCAST_KEY_802_1X_STATE_COMPLETE              = 2
+} unicastKey802_1x_smStates;
+
+/** State machine events */
+typedef enum 
+{
+       UCAST_KEY_802_1X_EVENT_START                  = 0,
+       UCAST_KEY_802_1X_EVENT_STOP                   = 1,
+       UCAST_KEY_802_1X_EVENT_SUCCESS                = 2,
+       UCAST_KEY_802_1X_EVENT_FAILURE                            = 3
+} unicastKey802_1x_smEvents;
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+
+TI_STATUS unicastKey802_1x_config(struct _unicastKey_t *pUnicastKey);
+
+
+#endif /*  _UNICAST_KEY_802_1X_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKeyNone.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKeyNone.h
new file mode 100644 (file)
index 0000000..f303db3
--- /dev/null
@@ -0,0 +1,78 @@
+/** \file unicastKeyNone.h
+ *  \brief station unicast key None API
+ *
+ *  \see unicastKeyNone.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station unicast key None                                         *
+ *   PURPOSE: station unicast key None API                                         *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _UNICAST_KEY_NONE_H
+#define _UNICAST_KEY_NONE_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "keyDerive.h"
+#include "unicastKeySM.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+
+TI_STATUS unicastKeyNone_config(struct _unicastKey_t *pUnicastKey);
+
+
+#endif /*  _UNICAST_KEY_NONE_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKeySM.h b/sta_dk_4_0_4_32/common/src/core/rsn/inc/unicastKeySM.h
new file mode 100644 (file)
index 0000000..ee87a56
--- /dev/null
@@ -0,0 +1,118 @@
+/** \file unicastKeySM.h
+ *  \brief station unicast key SM API
+ *
+ *  \see unicastKeySM.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:  station unicast key SM                                           *
+ *   PURPOSE: station unicast key SM API                                           *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _UNICAST_KEY_SM_H
+#define _UNICAST_KEY_SM_H
+
+#include "paramOut.h"
+#include "fsm.h"
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "keyDerive.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+typedef struct _unicastKey_t    unicastKey_t;
+
+/* Main Sec SM functions */
+typedef TI_STATUS (*unicastKeySmStart_t)(struct _unicastKey_t *pUnicastKey);
+typedef TI_STATUS (*unicastKeySmStop_t)(struct _unicastKey_t *pUnicastKey);
+typedef TI_STATUS (*unicastKeySmRecvSuccess_t)(struct _unicastKey_t *pUnicastKey, encodedKeyMaterial_t *pEncodedKeyMaterial);
+typedef TI_STATUS (*unicastKeySmRecvFailure_t)(struct _unicastKey_t *pUnicastKey);
+
+/* Structures */
+
+/* State machine associated data structures. */
+typedef struct
+{
+       encodedKeyMaterial_t    *pEncodedKeyMaterial;
+} unicastKeyData_t;
+
+struct _unicastKey_t
+{
+       UINT8                               currentState;
+       fsm_stateMachine_t                      *pUcastKeySm;
+    unicastKeyData_t                                   data;
+
+    struct _mainKeys_t                         *pParent;
+       keyDerive_t                                                     *pKeyDerive;
+       
+       TI_HANDLE                                       hReport;
+       TI_HANDLE                                       hOs;
+    
+    unicastKeySmStart_t                start;
+    unicastKeySmStop_t                 stop;
+    unicastKeySmRecvSuccess_t                  recvSuccess;
+    unicastKeySmRecvFailure_t                  recvFailure;
+};
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+unicastKey_t* unicastKey_create(TI_HANDLE hOs);
+
+TI_STATUS unicastKey_unload(unicastKey_t *punicastKey);
+
+TI_STATUS unicastKey_config(struct _unicastKey_t *pUnicastKey, 
+                                                  rsn_paeConfig_t *pPaeConfig, 
+                                                  struct _mainKeys_t *pParent,
+                                                  TI_HANDLE hReport,
+                                                  TI_HANDLE hOs);
+
+TI_STATUS unicastKeySmUnexpected(struct _unicastKey_t *pUnicastKey);
+
+TI_STATUS unicastKeySmNop(struct _unicastKey_t *pUnicastKey);
+
+#endif /*  _UNICAST_KEY_SM_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDerive.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyDerive.c
new file mode 100644 (file)
index 0000000..24d7b01
--- /dev/null
@@ -0,0 +1,183 @@
+/** \file keyDeriveSM.c
+ * \brief station unicast key SM implementation
+ *
+ * \see keyDeriveSM.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   station unicast key SM                                          *
+ *   PURPOSE:   station unicast key SM implementation                                          *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+#include "keyDeriveWep.h"
+#include "keyDeriveTkip.h"
+#include "keyDeriveAes.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "keyDeriveCkip.h"
+#endif
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_KeyDeriveRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+keyDerive_t* keyDerive_create(TI_HANDLE hOs)
+{
+       keyDerive_t             *pKeyDerive;
+
+       /* allocate key parser context memory */
+       pKeyDerive = (keyDerive_t*)os_memoryAlloc(hOs, sizeof(keyDerive_t));
+       if (pKeyDerive == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pKeyDerive, sizeof(keyDerive_t));
+
+       pKeyDerive->hOs = hOs;
+
+       return pKeyDerive;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_KeyDeriveRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS keyDerive_unload(struct _keyDerive_t *pKeyDerive)
+{
+       /* free key parser context memory */
+       os_memoryFree(pKeyDerive->hOs, pKeyDerive, sizeof(keyDerive_t));
+
+       return OK;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_KeyDeriveRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS keyDerive_config(struct _keyDerive_t *pKeyDerive,
+                                               cipherSuite_e cipher,
+                                               struct _mainKeys_t *pMainKeys,
+                                               TI_HANDLE hReport,
+                                               TI_HANDLE hOs)
+{
+
+       TI_STATUS               status = NOK;
+
+       pKeyDerive->hReport = hReport;
+       pKeyDerive->hOs = hOs;
+       pKeyDerive->pMainKeys = pMainKeys;
+
+    switch (cipher)
+       {
+    case RSN_CIPHER_NONE:
+               status = keyDeriveNone_config(pKeyDerive);
+        break;
+       case RSN_CIPHER_WEP:
+    case RSN_CIPHER_WEP104:
+               status = keyDeriveWep_config(pKeyDerive);
+               break;
+       case RSN_CIPHER_TKIP:
+               status = keyDeriveTkip_config(pKeyDerive);
+               break;
+#ifdef EXC_MODULE_INCLUDED
+       case RSN_CIPHER_CKIP: 
+       status = keyDeriveCkip_config(pKeyDerive);
+               break;
+#endif
+
+       case RSN_CIPHER_AES_CCMP:
+               status = keyDeriveAes_config(pKeyDerive);
+               break;
+       default:
+               return NOK;
+       }
+
+       return status;
+}
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveAes.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveAes.c
new file mode 100644 (file)
index 0000000..abe4dde
--- /dev/null
@@ -0,0 +1,197 @@
+/** \file keyDeriveAes.c
+ * \brief AES encryption key derivation implementation.
+ *
+ * \see aesBroadcastKeyDerivation.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   AES broadcast key derivation                                *
+ *   PURPOSE:   AES broadcast key derivation                                *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+#include "keyDeriveAes.h"
+
+#include "mainKeysSm.h"
+
+/**
+*
+* keyDeriveAes_config
+*
+* \b Description: 
+*
+* AES broadcast key derivation configuration function: 
+*                      - Initializes the derive & remove callback functions
+* \b ARGS: 
+*
+*  None
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveAes_config(struct _keyDerive_t *pKeyDerive)
+{
+       pKeyDerive->derive = keyDeriveAes_derive;
+       pKeyDerive->remove = keyDeriveAes_remove;
+
+       return OK;
+}
+
+
+/**
+*
+* keyDeriveAes_derive
+*
+* \b Description: 
+*
+* AES key derivation function: 
+*                                      - Decodes the key material.
+*                                      - Distribute the decoded key material to the driver.
+*
+* \b ARGS: 
+*
+*  I - p - Pointer to the encoded key material.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveAes_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+       TI_STATUS status;
+       securityKeys_t  key;
+       keyMaterialAes_t   *keyMaterialAes = NULL;
+       
+       /* Small verification */
+       if ((pEncodedKey==NULL) || (pKeyDerive == NULL))
+       {
+               return NOK;
+       }
+       
+       if (pEncodedKey->keyLen < sizeof(keyMaterialAes_t))
+       {
+               WLAN_REPORT_ERROR(pKeyDerive->hReport, RSN_MODULE_LOG,
+                                               ("KEY_DERIVE_AES: ERROR: wrong key length %d !!!\n",
+                                               pEncodedKey->keyLen));
+               return NOK;
+       }
+
+       keyMaterialAes = (keyMaterialAes_t*)pEncodedKey->pData;
+
+       
+       /* Fill security key structure */
+       os_memoryZero(pKeyDerive->hOs, &key, sizeof(securityKeys_t));
+
+       key.keyType   = AES_KEY;
+       key.keyIndex  = (UINT8)pEncodedKey->keyId;
+       key.encLen    = DERIVE_AES_KEY_LEN;
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.encKey, pEncodedKey->pData + MAC_ADDR_LEN+KEY_RSC_LEN, 
+                         DERIVE_AES_KEY_LEN);
+
+       /* Copy MAC address key */
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.macAddress.addr, (void *)keyMaterialAes->macAddress, MAC_ADDR_LEN);
+
+       /* Copy RSC */
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.keyRsc, (void *)keyMaterialAes->keyRSC, KEY_RSC_LEN);
+
+       status = pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key);
+       if (status == OK)
+       {
+               os_memoryCopy(pKeyDerive->hOs, &pKeyDerive->key, pEncodedKey, sizeof(encodedKeyMaterial_t));
+       }
+       
+       return status;
+}
+
+/**
+*
+* keyDeriveAes_remove
+*
+* \b Description: 
+*
+* AES key remove function: 
+*                      - Remove the key material from the driver.
+*
+* \b ARGS: 
+*
+*  None.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveAes_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+       TI_STATUS status;
+       securityKeys_t  key;
+       
+       if ((pEncodedKey==NULL) || (pKeyDerive == NULL))
+       {
+               return NOK;
+       }
+       
+       if (pEncodedKey->keyLen != DERIVE_AES_KEY_LEN) 
+       {
+               return NOK;
+       }
+
+       os_memoryZero(pKeyDerive->hOs, &key, sizeof(securityKeys_t));
+       key.keyType  = AES_KEY;
+       key.keyIndex = (UINT8)pEncodedKey->keyId;
+       key.encLen   = (UINT16)pEncodedKey->keyLen;
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.macAddress.addr, pEncodedKey->pData, MAC_ADDR_LEN);
+
+       status = pKeyDerive->pMainKeys->removeKey(pKeyDerive->pMainKeys, &key);
+       if (status == OK)
+       {
+               os_memoryZero(pKeyDerive->hOs, &pKeyDerive->key, sizeof(encodedKeyMaterial_t));
+       }
+       
+       return status;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveAes.h b/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveAes.h
new file mode 100644 (file)
index 0000000..bf17388
--- /dev/null
@@ -0,0 +1,72 @@
+/** \file keyDeriveAes.h
+ *  \brief AES key derivation API
+ *
+ *  \see keyDeriveAes.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   AES encryption key derivation                               *
+ *   PURPOSE:   AES encryption key derivation API                           *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _KEY_DERIVE_AES_H
+#define _KEY_DERIVE_AES_H
+
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "keyDerive.h"
+
+#define DERIVE_AES_KEY_LEN 16   /* 128 bit key  */
+
+
+PACKED_STRUCT( keyMaterialAes_t,
+
+    UINT8   macAddress[MAC_ADDR_LEN];
+    UINT8   keyRSC[KEY_RSC_LEN]; 
+    UINT8   encKey[DERIVE_AES_KEY_LEN];
+);
+
+/* AES key derivation init function. */
+TI_STATUS keyDeriveAes_config(struct _keyDerive_t *pKeyDerive);
+
+TI_STATUS keyDeriveAes_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+TI_STATUS keyDeriveAes_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+
+#endif /*  _KEY_DERIVE_AES_H  */
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveTkip.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveTkip.c
new file mode 100644 (file)
index 0000000..7a4584c
--- /dev/null
@@ -0,0 +1,196 @@
+/** \file wepBroadcastKeyDerivation.c
+ * \brief WEP broadcast key derivation implementation.
+ *
+ * \see wepBroadcastKeyDerivation.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   WEP broadcast key derivation                                *
+ *   PURPOSE:   WEP broadcast key derivation                                *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+#include "keyDeriveTkip.h"
+
+#include "mainKeysSm.h"
+
+/**
+*
+* keyDeriveTkip_config
+*
+* \b Description: 
+*
+* TKIP key derivation init function: 
+*                                                      - Initializes the derive & remove callback functions
+*                                                      - Resets the key material in the system control block                                                           
+*
+* \b ARGS: 
+*
+*  None
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveTkip_config(struct _keyDerive_t *pKeyDerive)
+{
+    pKeyDerive->derive = keyDeriveTkip_derive;
+    pKeyDerive->remove = keyDeriveTkip_remove;
+
+    return OK;
+}
+
+
+/**
+*
+* keyDeriveTkip_derive
+*
+* \b Description: 
+*
+* TKIP key derivation function: 
+*                                                      - Decodes the key material.
+*                                                      - Distribute the decoded key material to the driver.
+*
+* \b ARGS: 
+*
+*  I - p - Pointer to the encoded key material.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveTkip_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+    TI_STATUS           status;
+    securityKeys_t      key;
+    keyMaterialTkip_t   *keyMaterialTkip;
+    
+    if (pEncodedKey==NULL)
+    {
+        return NOK;
+    }
+
+    key.keyType =      TKIP_KEY;
+    key.keyIndex = (UINT8)pEncodedKey->keyId;
+    key.encLen = KEY_DERIVE_TKIP_ENC_LEN;
+
+    
+    if (pEncodedKey->keyLen < sizeof(keyMaterialTkip_t))
+    {
+        WLAN_REPORT_ERROR(pKeyDerive->hReport, RSN_MODULE_LOG,
+                        ("KEY_DERIVE_TKIP: ERROR: wrong key length %d !!!\n", key.encLen));
+        return NOK;
+    }
+
+    keyMaterialTkip = (keyMaterialTkip_t*)pEncodedKey->pData;
+    /* Copy encryption key */
+    os_memoryCopy(pKeyDerive->hOs, (void *)key.encKey, (void *)keyMaterialTkip->encKey, KEY_DERIVE_TKIP_ENC_LEN);
+    if (pEncodedKey->keyId & 0x10000000)
+    {   /* Copy MIC RX */
+        os_memoryCopy(pKeyDerive->hOs, (void *)key.micTxKey, (void *)keyMaterialTkip->micRxKey, KEY_DERIVE_TKIP_MIC_LEN);
+        /* Copy MIC RX */
+        os_memoryCopy(pKeyDerive->hOs, (void *)key.micRxKey, (void *)keyMaterialTkip->micTxKey, KEY_DERIVE_TKIP_MIC_LEN);
+    }
+    else
+    {  /* Copy MIC RX */
+        os_memoryCopy(pKeyDerive->hOs, (void *)key.micRxKey, (void *)keyMaterialTkip->micRxKey, KEY_DERIVE_TKIP_MIC_LEN);
+        /* Copy MIC RX */
+        os_memoryCopy(pKeyDerive->hOs, (void *)key.micTxKey, (void *)keyMaterialTkip->micTxKey, KEY_DERIVE_TKIP_MIC_LEN);
+    }
+    
+    /* Copy MAC address key */
+    os_memoryCopy(pKeyDerive->hOs, (void *)key.macAddress.addr, (void *)keyMaterialTkip->macAddress, MAC_ADDR_LEN);
+    /* Copy RSC */
+    os_memoryCopy(pKeyDerive->hOs, (void *)key.keyRsc, (void *)keyMaterialTkip->keyRSC, KEY_RSC_LEN);
+
+
+    status = pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key);
+    if (status == OK)
+    {
+        os_memoryCopy(pKeyDerive->hOs, &pKeyDerive->key, pEncodedKey, sizeof(encodedKeyMaterial_t));
+    }
+
+    return status;
+}
+
+/**
+*
+* wepBroadcastKeyDerivationRemove
+*
+* \b Description: 
+*
+* WEP broadcast key removal function: 
+*                                                      - Remove the key material from the driver.
+*
+* \b ARGS: 
+*
+*  None.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveTkip_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+    TI_STATUS status;
+    securityKeys_t  key;
+
+    os_memoryZero(pKeyDerive->hOs, &key, sizeof(securityKeys_t));
+    key.keyType = TKIP_KEY;
+    key.keyIndex = (UINT8)pEncodedKey->keyId;
+    key.encLen = KEY_DERIVE_TKIP_ENC_LEN;
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.macAddress.addr, pEncodedKey->pData, MAC_ADDR_LEN);
+
+    status = pKeyDerive->pMainKeys->removeKey(pKeyDerive->pMainKeys, &key);
+    if (status == OK)
+    {
+        os_memoryZero(pKeyDerive->hOs, &pKeyDerive->key, sizeof(encodedKeyMaterial_t));
+    }
+
+    return status;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveTkip.h b/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveTkip.h
new file mode 100644 (file)
index 0000000..1b2cbde
--- /dev/null
@@ -0,0 +1,74 @@
+/** \file keyDeriveTkip.h
+ *  \brief TKIP key derivation API
+ *
+ *  \see keyDeriveTkip.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   WEP broadcast key derivation                                *
+ *   PURPOSE:   WEP broadcast key derivation API                            *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _KEY_DERIVE_TKIP_H
+#define _KEY_DERIVE_TKIP_H
+
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "keyDerive.h"
+
+#define KEY_DERIVE_TKIP_ENC_LEN 16
+#define KEY_DERIVE_TKIP_MIC_LEN 8
+
+PACKED_STRUCT( keyMaterialTkip_t,
+
+    UINT8   macAddress[MAC_ADDR_LEN];    
+    UINT8   keyRSC[KEY_RSC_LEN]; 
+    UINT8   encKey[KEY_DERIVE_TKIP_ENC_LEN];
+    UINT8   micRxKey[KEY_DERIVE_TKIP_MIC_LEN];
+    UINT8   micTxKey[KEY_DERIVE_TKIP_MIC_LEN];
+);
+
+/* WEP broadcast key derivation init function. */
+TI_STATUS keyDeriveTkip_config(struct _keyDerive_t *pKeyDerive);
+
+TI_STATUS keyDeriveTkip_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+TI_STATUS keyDeriveTkip_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+
+#endif /*  __INCLUDE_WEP_BROADCAST_KEY_DERIVATION_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveWep.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveWep.c
new file mode 100644 (file)
index 0000000..16d6c23
--- /dev/null
@@ -0,0 +1,240 @@
+/** \file wepBroadcastKeyDerivation.c
+ * \brief WEP broadcast key derivation implementation.
+ *
+ * \see wepBroadcastKeyDerivation.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   WEP broadcast key derivation                                *
+ *   PURPOSE:   WEP broadcast key derivation                                *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyDerive.h"
+#include "keyDeriveWep.h"
+
+#include "mainKeysSm.h"
+
+/**
+*
+* rsn_wepBroadcastKeyDerivationInit
+*
+* \b Description: 
+*
+* WEP broadcast key derivation init function: 
+*                                                      - Initializes the derive & remove callback functions
+*                                                      - Resets the key material in the system control block                                                           
+*
+* \b ARGS: 
+*
+*  None
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveWep_config(struct _keyDerive_t *pKeyDerive)
+{
+       pKeyDerive->derive = keyDeriveWep_derive;
+       pKeyDerive->remove = keyDeriveWep_remove;
+
+       return OK;
+}
+
+
+/**
+*
+* wepBroadcastKeyDerivationDerive
+*
+* \b Description: 
+*
+* WEP broadcast key derivation function: 
+*                                                      - Decodes the key material.
+*                                                      - Distribute the decoded key material to the driver.
+*
+* \b ARGS: 
+*
+*  I - p - Pointer to the encoded key material.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveWep_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+       TI_STATUS status;
+       securityKeys_t  key;
+       
+    if (pEncodedKey==NULL)
+    {
+        return NOK;
+    }
+       
+       if ((pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_40) && 
+               (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_104) && 
+               (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_232))
+       {       
+        WLAN_REPORT_ERROR(pKeyDerive->hReport, RSN_MODULE_LOG,
+                          ("DeriveWep_derive: ERROR: it is not WEP key lenghth (len=%d) !!!\n", pEncodedKey->keyLen));
+        return NOK;
+       }
+
+       key.keyType = WEP_KEY;
+       key.keyIndex = (UINT8)pEncodedKey->keyId;
+       key.encLen = (UINT16)pEncodedKey->keyLen;
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.encKey, pEncodedKey->pData, pEncodedKey->keyLen);
+
+       status = pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key);
+       if (status == OK)
+       {
+               os_memoryCopy(pKeyDerive->hOs, &pKeyDerive->key, pEncodedKey, sizeof(encodedKeyMaterial_t));
+       }
+       
+       return status;
+}
+
+/**
+*
+* wepBroadcastKeyDerivationRemove
+*
+* \b Description: 
+*
+* WEP broadcast key removal function: 
+*                                                      - Remove the key material from the driver.
+*
+* \b ARGS: 
+*
+*  None.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveWep_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+       TI_STATUS status;
+       securityKeys_t  key;
+       
+    os_memoryZero(pKeyDerive->hOs, &key, sizeof(securityKeys_t));
+       key.keyType = WEP_KEY;
+       key.keyIndex = (UINT8)pEncodedKey->keyId;
+       key.encLen = (UINT16)pKeyDerive->key.keyLen;
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.macAddress.addr, pEncodedKey->pData, MAC_ADDR_LEN);
+
+       status = pKeyDerive->pMainKeys->removeKey(pKeyDerive->pMainKeys, &key);
+       if (status == OK)
+       {
+               os_memoryZero(pKeyDerive->hOs, &pKeyDerive->key, sizeof(encodedKeyMaterial_t));
+       }
+       
+       return status;
+}
+
+
+
+TI_STATUS keyDeriveNone_config(struct _keyDerive_t *pKeyDerive)
+{
+       pKeyDerive->derive = keyDeriveNone_derive;
+       pKeyDerive->remove = keyDeriveNone_remove;
+
+       return OK;
+}
+
+
+TI_STATUS keyDeriveNone_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+       securityKeys_t  key;
+       
+    if (pEncodedKey==NULL)
+    {
+        return NOK;
+    }
+
+       if ((pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_40) && 
+               (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_104) && 
+               (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_232))
+       {       
+        return NOK;
+       }
+
+       key.keyType = WEP_KEY;
+       key.keyIndex = (UINT8)pEncodedKey->keyId;
+       key.encLen = (UINT16)pEncodedKey->keyLen;
+       os_memoryCopy(pKeyDerive->hOs, (void *)key.encKey, pEncodedKey->pData, pEncodedKey->keyLen);
+
+       pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key);
+       
+       return OK;
+}
+
+
+/**
+*
+* keyDeriveNone_remove
+*
+* \b Description: 
+*
+* WEP broadcast key removal function: 
+*                                                      - Remove the key material from the driver.
+*
+* \b ARGS: 
+*
+*  None.
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS keyDeriveNone_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
+{
+       
+    return OK;
+}
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveWep.h b/sta_dk_4_0_4_32/common/src/core/rsn/keyDeriveWep.h
new file mode 100644 (file)
index 0000000..45fc723
--- /dev/null
@@ -0,0 +1,75 @@
+/** \file wepBroadcastKeyDerivation.h
+ *  \brief WEP broadcast key derivation API
+ *
+ *  \see wepBroadcastKeyDerivation.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   WEP broadcast key derivation                                *
+ *   PURPOSE:   WEP broadcast key derivation API                            *
+ *                                                                          *
+ ****************************************************************************/
+
+#ifndef _KEY_DERIVE_WEP_H
+#define _KEY_DERIVE_WEP_H
+
+#include "rsnApi.h"
+#include "keyTypes.h"
+
+#include "keyDerive.h"
+
+
+#define DERIVE_WEP_KEY_LEN_40   5  /* 40 bit (5 byte) key */
+#define DERIVE_WEP_KEY_LEN_104  13 /* 104 bit (13 byte) key */
+#define DERIVE_WEP_KEY_LEN_232  29 /* 232 bit (29 byte) key */
+
+
+/* WEP broadcast key derivation init function. */
+TI_STATUS keyDeriveWep_config(struct _keyDerive_t *pKeyDerive);
+
+TI_STATUS keyDeriveWep_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+
+TI_STATUS keyDeriveWep_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+
+TI_STATUS keyDeriveNone_config(struct _keyDerive_t *pKeyDerive);
+
+TI_STATUS keyDeriveNone_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+
+TI_STATUS keyDeriveNone_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey);
+
+#endif /*  __INCLUDE_WEP_BROADCAST_KEY_DERIVATION_H*/
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyParser.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyParser.c
new file mode 100644 (file)
index 0000000..a69bf05
--- /dev/null
@@ -0,0 +1,181 @@
+/** \file keyParser.c
+ * \brief KEY parser module implementation.
+ *
+ * \see keyParser.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   KEY parser                                                  *
+ *   PURPOSE:   KEY parser implementation                                                                      *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "keyParser.h" 
+#include "keyParserExternal.h"
+#include "keyParserWep.h"
+
+TI_STATUS keyParserNone_config(keyParser_t *pKeyParser);
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_keyParserRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+keyParser_t* keyParser_create(TI_HANDLE hOs)
+{
+       keyParser_t             *pKeyParser;
+
+       /* allocate key parser context memory */
+       pKeyParser = (keyParser_t*)os_memoryCAlloc(hOs, 1, sizeof(keyParser_t));
+       if (pKeyParser == NULL)
+       {
+               return NULL;
+       }
+
+       pKeyParser->hOs = hOs;
+
+       return pKeyParser;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_keyParserRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS keyParser_unload(struct _keyParser_t *pKeyParser)
+{
+       /* free key parser context memory */
+       os_memoryFree(pKeyParser->hOs, pKeyParser, sizeof(keyParser_t));
+
+       return OK;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_keyParserRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS keyParser_config(struct _keyParser_t *pKeyParser,
+                                               rsn_paeConfig_t *pPaeConfig,
+                        struct _unicastKey_t *pUcastKey,
+                        struct _broadcastKey_t *pBcastKey,
+                        struct _mainKeys_t *pParent,
+                                               TI_HANDLE hReport,
+                                               TI_HANDLE hOs,
+                        TI_HANDLE hCtrlData)
+{
+    
+    pKeyParser->pParent = pParent;
+    pKeyParser->pUcastKey = pUcastKey;
+    pKeyParser->pBcastKey = pBcastKey;
+    pKeyParser->pPaeConfig = pPaeConfig;
+
+    pKeyParser->hReport = hReport;
+       pKeyParser->hOs = hOs;
+    pKeyParser->hCtrlData = hCtrlData;
+
+       keyParserExternal_config(pKeyParser);
+       
+       return OK;
+}
+
+
+
+TI_STATUS keyParserNone_config(keyParser_t *pKeyParser)
+{
+       pKeyParser->recv = NULL;
+       pKeyParser->replayReset = NULL;
+       
+       return OK;
+       
+}
+
+
+TI_STATUS keyParser_nop(keyParser_t *pKeyParser)
+{
+       WLAN_REPORT_INFORMATION(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                                ("KEY_PARSER: nop \n"));
+       
+       return OK;
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyParserExternal.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyParserExternal.c
new file mode 100644 (file)
index 0000000..cdf8e87
--- /dev/null
@@ -0,0 +1,409 @@
+/** \file keyParserExternal.c
+ * \brief External key parser implementation.
+ *
+ * \see keyParser.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   External Key Parser                                             *
+ *   PURPOSE:   EAP parser implementation                                   *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "report.h"
+#include "utils.h"
+
+#include "keyTypes.h"
+
+#include "keyParser.h"
+#include "keyParserExternal.h"
+#include "mainKeysSm.h"
+#include "mainSecSm.h"
+#include "admCtrl.h"
+
+#include "unicastKeySM.h"
+#include "broadcastKeySM.h"
+#include "DataCtrl_Api.h"
+
+#define  CKIP_KEY_LEN 16
+#define  TKIP_KEY_LEN 32
+#define  AES_KEY_LEN  16
+
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_keyParserRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS keyParserExternal_config(struct _keyParser_t *pKeyParser)
+{
+       pKeyParser->recv = keyParserExternal_recv;
+       pKeyParser->replayReset = keyParser_nop;
+       pKeyParser->remove = keyParserExternal_remove;
+       return OK;
+}
+
+
+/**
+*
+* keyParserExternal_recv
+*
+* \b Description: 
+*
+* External key Parser receive function:
+*                                                      - Called by NDIS (Windows)  upon receiving an External Key.
+*                                                      - Filters the following keys:                                                           
+*                                                              - Keys with invalid key index
+*                                                              - Keys with invalid MAC address
+*
+* \b ARGS:
+*
+*  I   - pKeyParser - Pointer to the keyParser context  \n
+*  I   - pKeyData - A pointer to the Key Data. \n
+*  I   - keyDataLen - The Key Data length. \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+*/
+
+TI_STATUS keyParserExternal_recv(struct _keyParser_t *pKeyParser,
+                                                 UINT8 *pKeyData, UINT32 keyDataLen)
+{
+       TI_STATUS                                               status;
+       OS_802_11_KEY                   *pKeyDesc;
+       encodedKeyMaterial_t                    encodedKeyMaterial;
+    paramInfo_t                                        macParam;
+       BOOL                            macEqual2Associated=FALSE;
+       BOOL                                                    macIsBroadcast=FALSE;
+    BOOL                            wepKey = FALSE;
+       UINT8                                                   broadcastMacAddr[MAC_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+       UINT8                                                   nullMacAddr[MAC_ADDR_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+    UINT8                           keyBuffer[MAC_ADDR_LEN+KEY_RSC_LEN+MAX_EXT_KEY_DATA_LENGTH];
+    
+
+    if (pKeyData == NULL)                             
+       {                                                 
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                                 ("EXT_KEY_PARSER: ERROR: NULL KEY Data\n"));
+               return NOK;
+       }
+       
+       pKeyDesc = (OS_802_11_KEY*)pKeyData;
+
+    /* copy the key data, mac address and RSC */
+       os_memoryCopy(pKeyParser->hOs, &keyBuffer[0], pKeyDesc->BSSID, MAC_ADDR_LEN);
+       /* configure keyRSC value (if needed) */
+    if (pKeyDesc->KeyIndex & EXT_KEY_RSC_KEY_MASK)
+       {       /* set key recieve sequence counter */
+        os_memoryCopy(pKeyParser->hOs, &keyBuffer[MAC_ADDR_LEN], (UINT8*)&(pKeyDesc->KeyRSC), KEY_RSC_LEN);
+       }
+    else
+    {
+        os_memoryZero(pKeyParser->hOs, &keyBuffer[MAC_ADDR_LEN], KEY_RSC_LEN);
+    }
+
+    /* check type and validity of keys */
+    /* check MAC Address validity */
+       macParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+       status = ctrlData_getParam(pKeyParser->hCtrlData, &macParam);
+
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                          ("EXT_KEY_PARSER: ERROR: Cannot get MAC address !!!\n"));
+        return NOK;
+       }
+
+       /* check key length */
+       if((pKeyDesc->KeyLength != WEP_KEY_LEN_40) && 
+               (pKeyDesc->KeyLength != WEP_KEY_LEN_104) && 
+               (pKeyDesc->KeyLength != WEP_KEY_LEN_232) &&
+               (pKeyDesc->KeyLength != CKIP_KEY_LEN) && 
+               (pKeyDesc->KeyLength != TKIP_KEY_LEN) && 
+               (pKeyDesc->KeyLength != AES_KEY_LEN) )
+               
+       {
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                ("EXT_KEY_PARSER: ERROR: Incorrect key length - %d \n", pKeyDesc->KeyLength));
+               return STATUS_BAD_KEY_PARAM;
+       }
+       if (!os_memoryCompare(pKeyParser->hOs, (void *)macParam.content.ctrlDataCurrentBSSID.addr, pKeyDesc->BSSID, MAC_ADDR_LEN))
+       {       
+        macEqual2Associated = TRUE;
+       }
+       if (!os_memoryCompare(pKeyParser->hOs, pKeyDesc->BSSID, broadcastMacAddr, MAC_ADDR_LEN))
+       {       
+        macIsBroadcast = TRUE;
+       }
+       if ((pKeyDesc->KeyLength == WEP_KEY_LEN_40) || 
+               (pKeyDesc->KeyLength == WEP_KEY_LEN_104) || 
+               (pKeyDesc->KeyLength == WEP_KEY_LEN_232))
+       {       /* In Add WEP the MAC address is nulled, since it's irrelevant */
+        macEqual2Associated = TRUE;
+        wepKey = TRUE;
+       }
+
+    if (pKeyDesc->KeyIndex & EXT_KEY_SUPP_AUTHENTICATOR_MASK)
+    {  /* The key is being set by an Authenticator - not allowed in IBSS mode */
+       if (pKeyParser->pParent->pParent->pParent->pAdmCtrl->networkMode == RSN_IBSS)
+        {      /* in IBSS only Broadcast MAC is allowed */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                               ("EXT_KEY_PARSER: ERROR: Authenticator set key in IBSS mode !!!\n"));
+               return NOK;
+        }
+
+    }
+
+    if (pKeyDesc->KeyIndex & EXT_KEY_REMAIN_BITS_MASK)
+    {  /* the reamining bits in the key index are not 0 (when they should be) */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                               ("EXT_KEY_PARSER: ERROR: Key index bits 8-27 should be 0 !!!\n"));
+               return STATUS_BAD_KEY_PARAM;
+    }
+    
+    encodedKeyMaterial.pData  = (char *) keyBuffer;
+       /* Check key length according to the cipher suite - TKIP, etc...??? */
+    if (wepKey)
+    {
+        if (!((pKeyDesc->KeyLength == WEP_KEY_LEN_40) || (pKeyDesc->KeyLength == WEP_KEY_LEN_104) 
+              || (pKeyDesc->KeyLength == WEP_KEY_LEN_232)))
+        {      /*Invalid key length*/
+            WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                             ("WEP_KEY_PARSER: ERROR: Invalid Key length: %d !!!\n", pKeyDesc->KeyLength));
+            return STATUS_BAD_KEY_PARAM;
+        }
+
+        os_memoryCopy(pKeyParser->hOs, &keyBuffer[0], pKeyDesc->KeyMaterial, pKeyDesc->KeyLength);
+        if (!os_memoryCompare(pKeyParser->hOs, nullMacAddr, pKeyDesc->BSSID, MAC_ADDR_LEN))
+        {   
+            macIsBroadcast = TRUE;
+        } 
+
+        encodedKeyMaterial.keyLen = pKeyDesc->KeyLength;
+    }
+    else /* this is TKIP or CKIP */
+    {   
+        if ((pKeyDesc->KeyLength == CKIP_KEY_LEN) && (pKeyParser->pPaeConfig->unicastSuite == RSN_CIPHER_CKIP))
+        {
+            os_memoryCopy(pKeyParser->hOs, &keyBuffer[0], pKeyDesc->KeyMaterial, pKeyDesc->KeyLength);
+            encodedKeyMaterial.keyLen = pKeyDesc->KeyLength;
+        }
+        else
+        {
+            os_memoryCopy(pKeyParser->hOs, &keyBuffer[MAC_ADDR_LEN+KEY_RSC_LEN],
+                        pKeyDesc->KeyMaterial, pKeyDesc->KeyLength);
+
+            encodedKeyMaterial.keyLen = MAC_ADDR_LEN+KEY_RSC_LEN+pKeyDesc->KeyLength;
+        }
+    }
+
+    encodedKeyMaterial.keyId  = pKeyDesc->KeyIndex;
+
+       WLAN_REPORT_INFORMATION(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                   ("EXT_KEY_PARSER: Key received keyId=%x, keyLen=%d \n",
+                                                   pKeyDesc->KeyIndex, pKeyDesc->KeyLength
+                             ));
+
+    if (pKeyDesc->KeyIndex & EXT_KEY_PAIRWISE_GROUP_MASK)
+    {  /* Pairwise key */
+        /* check that the lower 8 bits of the key index are 0 */
+        if (!wepKey && (pKeyDesc->KeyIndex & 0xff))
+        {
+                       WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                              ("EXT_KEY_PARSER: ERROR: Pairwise key must have index 0 !!!\n"));
+            return STATUS_BAD_KEY_PARAM;
+        }
+
+               if (macIsBroadcast)
+               {
+            WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                              ("EXT_KEY_PARSER: ERROR: Broadcast MAC address for unicast !!!\n"));
+                       return STATUS_BAD_KEY_PARAM;
+               }
+               if (pKeyDesc->KeyIndex & EXT_KEY_TRANSMIT_MASK)
+               {       /* tx only pairwase key */
+                       /* set unicast keys */
+               if (pKeyParser->pUcastKey->recvSuccess!=NULL)
+            {
+               status = pKeyParser->pUcastKey->recvSuccess(pKeyParser->pUcastKey, &encodedKeyMaterial);
+            }
+               } else {
+                       /* recieve only pairwase keys are not allowed */
+            WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+            ("EXT_KEY_PARSER: ERROR: recieve only pairwase keys are not allowed !!!\n"));
+            return STATUS_BAD_KEY_PARAM;
+               }
+
+    }
+    else
+    {   /* set broadcast keys */
+        if (!macIsBroadcast)
+        {      /* not broadcast MAC */
+               if (pKeyParser->pParent->pParent->pParent->pAdmCtrl->networkMode == RSN_IBSS)
+               {       /* in IBSS only Broadcast MAC is allowed */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                               ("EXT_KEY_PARSER: ERROR: not broadcast MAC in IBSS mode !!!\n"));
+               return STATUS_BAD_KEY_PARAM;
+               }
+               else if (!macEqual2Associated)
+               {       /* ESS mode and MAC is different than the associated one */
+                       /* save the key for later */
+                               status = OK; /* pKeyParser->pBcastKey->saveKey(pKeyParser->pBcastKey, &encodedKey);*/
+               }
+                       else
+                       {       /* MAC is equal to the associated one - configure immediately */
+                if (!wepKey)
+                               {
+                                       os_memoryCopy(pKeyParser->hOs, &keyBuffer[0], broadcastMacAddr, MAC_ADDR_LEN);
+                               }
+                       if (pKeyParser->pBcastKey->recvSuccess!=NULL)
+                {
+                                       status =  pKeyParser->pBcastKey->recvSuccess(pKeyParser->pBcastKey, &encodedKeyMaterial);
+                               }
+                       }
+        }
+               else
+               {   /* MAC is broadcast - configure immediately */
+                       if (!wepKey)
+                       {
+                               os_memoryCopy(pKeyParser->hOs, &keyBuffer[0], broadcastMacAddr, MAC_ADDR_LEN);
+                       }
+                       
+                       /* set broadcast key */
+                       if (pKeyParser->pBcastKey->recvSuccess!=NULL)
+                       {
+                               status =  pKeyParser->pBcastKey->recvSuccess(pKeyParser->pBcastKey, &encodedKeyMaterial);
+                       }
+
+                       if (pKeyDesc->KeyIndex & EXT_KEY_TRANSMIT_MASK)
+                       {       /* Group key used to transmit */
+                               /* set as unicast key as well */
+                               if (pKeyParser->pUcastKey->recvSuccess!=NULL)
+                               {
+                                       status = pKeyParser->pUcastKey->recvSuccess(pKeyParser->pUcastKey, &encodedKeyMaterial);
+                               }
+                       }
+               }
+    }
+                                 
+       return status;
+}
+
+
+
+
+TI_STATUS keyParserExternal_remove(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen)
+{
+       TI_STATUS                               status;
+       OS_802_11_KEY                   *pKeyDesc;
+    paramInfo_t                        macParam;
+       encodedKeyMaterial_t    encodedKeyMaterial;
+       UINT8                                   broadcastMacAddr[MAC_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+    UINT8                   keyBuffer[MAC_ADDR_LEN+KEY_RSC_LEN+MAX_EXT_KEY_DATA_LENGTH];
+
+       if (pKeyData == NULL)
+       {
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                                 ("EXT_KEY_PARSER: ERROR: NULL KEY Data\n"));
+               return NOK;
+       }
+       
+       pKeyDesc = (OS_802_11_KEY*)pKeyData;
+
+    if (pKeyDesc->KeyIndex & EXT_KEY_TRANSMIT_MASK)
+       {       /* Bit 31 should always be zero */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                 ("EXT_KEY_PARSER: ERROR: Remove TX bit in key index can't be 1\n"));
+               return NOK;
+       }
+       if (pKeyDesc->KeyIndex & EXT_KEY_REMAIN_BITS_MASK)
+       {       /* Bits 8-29 should always be zero */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                 ("EXT_KEY_PARSER: ERROR: Remove none zero key index\n"));
+               return NOK;
+       }
+       
+       encodedKeyMaterial.keyId = pKeyDesc->KeyIndex;
+       encodedKeyMaterial.keyLen = 0;
+    encodedKeyMaterial.pData = (char *) keyBuffer;
+
+       if (pKeyDesc->KeyIndex & EXT_KEY_PAIRWISE_GROUP_MASK)
+       {       /* delete all pairwise keys or for the current BSSID */
+               if (os_memoryCompare(pKeyParser->hOs, pKeyDesc->BSSID, broadcastMacAddr, MAC_ADDR_LEN))
+               {
+                       os_memoryCopy(pKeyParser->hOs, keyBuffer, pKeyDesc->BSSID, MAC_ADDR_LEN);
+               } else {
+                       macParam.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+                       status = ctrlData_getParam(pKeyParser->hCtrlData, &macParam);
+                       if (status != OK)
+                       {
+                               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                                 ("EXT_KEY_PARSER: ERROR: Cannot get MAC address !!!\n"));
+                               return NOK;
+                       }
+                       
+                       os_memoryCopy(pKeyParser->hOs, keyBuffer, (void *)macParam.content.ctrlDataCurrentBSSID.addr, MAC_ADDR_LEN);
+               }
+
+        status =  pKeyParser->pUcastKey->pKeyDerive->remove(pKeyParser->pUcastKey->pKeyDerive, &encodedKeyMaterial);
+       }
+       else
+       {       /* delete all group keys or for the current BSSID */
+               os_memoryCopy(pKeyParser->hOs, keyBuffer, broadcastMacAddr, MAC_ADDR_LEN);
+        status =  pKeyParser->pBcastKey->pKeyDerive->remove(pKeyParser->pUcastKey->pKeyDerive, &encodedKeyMaterial);
+       }
+
+       return status;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyParserExternal.h b/sta_dk_4_0_4_32/common/src/core/rsn/keyParserExternal.h
new file mode 100644 (file)
index 0000000..716704e
--- /dev/null
@@ -0,0 +1,98 @@
+/** \file keyParserExternal.h
+ *  \brief WEP Key PArser Header file
+ *
+ *  \see keyParser.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: keyParserExternal.h                                                                                        */
+/*    PURPOSE: External key parser                                                                                        */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _KEY_PARSER_EXTERNAL_H
+#define _KEY_PARSER_EXTERNAL_H
+
+#include "fsm.h"
+#include "keyParser.h"
+
+/* Constants */
+#define MAX_EXT_KEY_DATA_LENGTH   32
+
+
+#define EXT_KEY_TRANSMIT_MASK                          0x80000000              /*< bit 31 of key index field */
+#define EXT_KEY_PAIRWISE_GROUP_MASK                    0x40000000              /*< bit 30 of key index field */
+#define EXT_KEY_RSC_KEY_MASK                           0x20000000              /*< bit 29 of key index field */
+#define EXT_KEY_SUPP_AUTHENTICATOR_MASK                0x10000000              /*< bit 28 of key index field */
+#define EXT_KEY_REMAIN_BITS_MASK                       0x0FFFFF00              /*< remaining 20 bits in external key index */
+
+#define WEP_KEY_LEN_40  5  /* 40 bit (5 byte) key */
+#define WEP_KEY_LEN_104         13 /* 104 bit (13 byte) key */
+#define WEP_KEY_LEN_232         29 /* 232 bit (29 byte) key */
+
+                                                      
+/* Enumerations */                                    
+                                                      
+/* Typedefs */                                        
+               
+
+
+
+typedef struct
+{
+       UINT32          Length;                                                         /* The length of the whole structure */
+       UINT32          KeyIndex;                                                               /* The key index to add or remove */
+       UINT8           macAddress[MAC_ADDR_LEN];       /**< Remote station MAC address*/
+} keyParserExternal_keyRemoveDesc_t;
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS keyParserExternal_config(struct _keyParser_t *pKeyParser);
+
+TI_STATUS keyParserExternal_recv(struct _keyParser_t *pKeyParser,
+                                                 UINT8 *pPacket, UINT32 packetLen);
+
+TI_STATUS keyParserExternal_remove(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen);
+
+#endif /*_KEY_PARSER_EXTERNAL_H*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyParserWep.c b/sta_dk_4_0_4_32/common/src/core/rsn/keyParserWep.c
new file mode 100644 (file)
index 0000000..68e1cdd
--- /dev/null
@@ -0,0 +1,214 @@
+/** \file KeyParserWep.c
+ * \brief Wep key parser implementation.
+ *
+ * \see keyParser.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   Wep Key Parser                                             *
+ *   PURPOSE:   EAP parser implementation                                   *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "report.h"
+#include "utils.h"
+
+#include "keyTypes.h"
+
+#include "keyParser.h"
+#include "keyParserWep.h"
+#include "mainKeysSm.h"
+
+#include "unicastKeySM.h"
+#include "broadcastKeySM.h"
+
+
+TI_STATUS keyParserWep_recv(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen);
+TI_STATUS keyParserWep_remove(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen);
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_keyParserRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS keyParserWep_config(struct _keyParser_t *pKeyParser)
+{
+       pKeyParser->recv = keyParserWep_recv;
+       pKeyParser->replayReset = keyParser_nop;
+       pKeyParser->remove = keyParserWep_remove;
+       return OK;
+}
+
+
+/**
+*
+* keyParserWep_recv
+*
+* \b Description: 
+*
+* WEP key Parser receive function:
+*                                                      - Called by the utility or NDIS (Windows)  upon receiving a WEP Key.
+*                                                      - Filters the following keys:                                                           
+*                                                              - Per Client Keys
+*                                                              - Keys with size different than 40-bit, 104-bit and 232-bit
+*                                                              - Keys with invalid key index
+*
+* \b ARGS:
+*
+*  I   - pKeyParser - Pointer to the keyParser context  \n
+*  I   - pKeyData - A pointer to the Key Data. \n
+*  I   - keyDataLen - The Key Data length. \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+*/
+TI_STATUS keyParserWep_recv(struct _keyParser_t *pKeyParser,
+                                                 UINT8 *pKeyData, UINT32 keyDataLen)
+{
+       TI_STATUS                                       status;
+       OS_802_11_KEY                   *pKeyDesc;
+    securityKeys_t                  securityKey;
+       
+       if (pKeyData == NULL)
+       {
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                                 ("WEP_KEY_PARSER: ERROR: NULL KEY Data\n"));
+               return NOK;
+       }
+       
+       pKeyDesc = (OS_802_11_KEY*)pKeyData; 
+
+       if ((pKeyDesc->KeyLength < MIN_KEY_LEN ) || (pKeyDesc->KeyLength >= MAX_KEY_LEN ))
+    {
+        WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                          ("WEP_KEY_PARSER: ERROR: Key Length out of bounds=%d\n", pKeyDesc->KeyLength));
+        return NOK;
+    }
+
+    if (pKeyDesc->KeyIndex & WEP_KEY_REMAIN_BITS_MASK)
+    {  /* the reamining bits in the key index are not 0 (when they should be) */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                               ("WEP_KEY_PARSER: ERROR: Key index bits 8-29 should be 0 !!!\n"));
+               return NOK;
+    }
+
+    securityKey.keyType = WEP_KEY;
+    securityKey.encLen = (UINT16)pKeyDesc->KeyLength;
+    securityKey.keyIndex = pKeyDesc->KeyIndex;
+    os_memoryCopy(pKeyParser->hOs, (void *)securityKey.encKey, pKeyDesc->KeyMaterial, pKeyDesc->KeyLength);
+       
+    WLAN_REPORT_INFORMATION(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                   ("WEP_KEY_PARSER: Key received keyId=%x, keyLen=%d\n",
+                                                   pKeyDesc->KeyIndex, pKeyDesc->KeyLength));
+
+
+    /* We accept only 40, 104 or 232 -bit WEP keys*/
+    if (!((securityKey.encLen == WEP_KEY_LEN_40) || (securityKey.encLen == WEP_KEY_LEN_104) 
+          || (securityKey.encLen == WEP_KEY_LEN_232)))
+    {  /*Invalid key length*/
+        WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                         ("WEP_KEY_PARSER: ERROR: Invalid Key length: %d !!!\n", securityKey.encLen));
+        return NOK;
+    }
+    /* configure key for Tx and Rx */
+    if (pKeyDesc->KeyIndex & WEP_KEY_TRANSMIT_MASK)
+    {  /* configure default key for Tx - unicast */
+        status = pKeyParser->pParent->setDefaultKeyId(pKeyParser->pParent, (UINT8)securityKey.keyIndex);
+        if (status!=OK)
+        {
+            return status;
+        }        
+    }
+    /* configure key for Tx - unicast, and Rx - broadcast*/
+    status = pKeyParser->pParent->setKey(pKeyParser->pParent, &securityKey);
+
+       return status;
+}
+
+
+
+TI_STATUS keyParserWep_remove(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen)
+{
+       TI_STATUS                               status;
+       OS_802_11_KEY                   *pKeyDesc;
+       encodedKeyMaterial_t    encodedKeyMaterial;
+    UINT8                   keyBuffer[MAC_ADDR_LEN+KEY_RSC_LEN+MAX_WEP_KEY_DATA_LENGTH];
+
+       if (pKeyData == NULL)
+       {
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                                 ("EXT_KEY_PARSER: ERROR: NULL KEY Data\n"));
+               return NOK;
+       }
+       
+       pKeyDesc = (OS_802_11_KEY*)pKeyData;
+
+    if (pKeyDesc->KeyIndex & WEP_KEY_TRANSMIT_MASK)
+       {       /* Bit 31 should always be zero */
+               WLAN_REPORT_ERROR(pKeyParser->hReport, RSN_MODULE_LOG,
+                                                 ("WEP_KEY_PARSER: ERROR: Remove TX key index\n"));
+               return NOK;
+       }
+
+       encodedKeyMaterial.keyId = pKeyDesc->KeyIndex;
+       encodedKeyMaterial.keyLen = 0;
+    encodedKeyMaterial.pData = (char *) keyBuffer;
+    os_memoryCopy(pKeyParser->hOs, keyBuffer, pKeyDesc->BSSID, MAC_ADDR_LEN);
+
+       /* which should we delete ????*/
+    status =  pKeyParser->pBcastKey->pKeyDerive->remove(pKeyParser->pUcastKey->pKeyDerive, &encodedKeyMaterial);
+       return status;
+
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/keyParserWep.h b/sta_dk_4_0_4_32/common/src/core/rsn/keyParserWep.h
new file mode 100644 (file)
index 0000000..0a21aa8
--- /dev/null
@@ -0,0 +1,97 @@
+/** \file keyParserWep.h
+ *  \brief WEP Key PArser Header file
+ *
+ *  \see keyParser.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: keyParserWep.h                                                                                     */
+/*    PURPOSE: WEP key parser                                                                                     */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef _KEY_PARSER_WEP_H
+#define _KEY_PARSER_WEP_H
+
+#include "fsm.h"
+#include "keyParser.h"
+
+/* Constants */
+#define MAX_WEP_KEY_DATA_LENGTH   32
+
+#define WEP_KEY_TRANSMIT_MASK                  0x80000000              /*< bit 31 of key index field */
+#define WEP_KEY_PER_CLIENT_MASK                        0x40000000              /*< bit 30 of key index field */
+#define WEP_KEY_REMAIN_BITS_MASK               0x3FFFFF00              /*< bits 8-29 of key index field */
+
+
+
+#define WEP_KEY_LEN_40  5  /* 40 bit (5 byte) key */
+#define WEP_KEY_LEN_104         13 /* 104 bit (13 byte) key */
+#define WEP_KEY_LEN_232         29 /* 232 bit (29 byte) key */
+
+
+/* Enumerations */
+
+/* Typedefs */
+#pragma pack(1)
+typedef struct 
+{
+  UINT32 Length;                                                         /* The length of the whole structure */
+  UINT32 KeyIndex;                                                       /* The key index to add or remove */
+  UINT32 KeyLength;                                                      /* The length of the key data */
+  UINT8  KeyData [MAX_WEP_KEY_DATA_LENGTH];   /* WEP key data */
+} keyParserWep_keyDesc_t;
+#pragma pack()
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS keyParserWep_config(struct _keyParser_t *pKeyParser);
+
+TI_STATUS keyParserWep_recv(struct _keyParser_t *pKeyParser,
+                                                 UINT8 *pPacket, UINT32 packetLen);
+
+TI_STATUS keyParserWep_remove(struct _keyParser_t *pKeyParser, UINT8 *pKeyData, UINT32 keyDataLen);
+
+#endif /*_KEY_PARSER_WEP_H*/
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/mainKeysSm.c b/sta_dk_4_0_4_32/common/src/core/rsn/mainKeysSm.c
new file mode 100644 (file)
index 0000000..6768c2f
--- /dev/null
@@ -0,0 +1,1003 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 mainKeySM.c
+ * \brief Main key state machine implementation.
+ *
+ * \see mainKeySM.h
+*/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+/*#include "paramIn.h"*/
+
+#include "utils.h"
+#include "report.h"
+
+#include "rsn.h"
+#include "rsnApi.h"
+#include "smeApi.h"
+
+#include "mainSecSm.h"                         
+#include "keyParser.h" 
+#include "broadcastKeySM.h"
+#include "unicastKeySM.h"  
+
+#include "mainKeysSm.h"
+#include "mainKeysSmInternal.h"
+#include "DataCtrl_Api.h"
+#include "admCtrl.h"
+#include "EvHandler.h"
+#include "TI_IPC_Api.h"
+
+
+
+static TI_STATUS mainKeys_smEvent(struct _mainKeys_t *pMainKeys, UINT8 event, void* pData);
+
+/**
+*
+* mainKeys_create
+*
+* \b Description: 
+*
+* Allocate memory for the main security context, and create all the rest of the needed contexts.
+*
+* \b ARGS:
+*
+*  I - hOs - OS handle for OS operations.
+*
+* \b RETURNS:
+*
+*  pointer to main security context. If failed, returns NULL.
+*
+* \sa 
+*/
+mainKeys_t* mainKeys_create(TI_HANDLE hOs)
+{
+       mainKeys_t      *pHandle;
+       TI_STATUS               status;
+
+       /* allocate association context memory */
+       pHandle = (mainKeys_t*)os_memoryAlloc(hOs, sizeof(mainKeys_t));
+       if (pHandle == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pHandle, sizeof(mainKeys_t));
+
+       /* allocate memory for association state machine */
+       status = fsm_Create(hOs, &pHandle->pMainKeysSm, MAIN_KEYS_NUM_STATES, MAIN_KEYS_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pHandle, sizeof(mainKeys_t));
+               return NULL;
+       }
+
+       pHandle->timer = os_timerCreate(hOs, mainKeys_sessionTimeout, pHandle);
+       if (pHandle->timer == NULL)
+       {
+               fsm_Unload(hOs, pHandle->pMainKeysSm);
+               os_memoryFree(hOs, pHandle, sizeof(mainKeys_t));
+               return NULL;
+       }
+
+       pHandle->pKeyParser = keyParser_create(hOs);
+       if (pHandle->pKeyParser == NULL)
+       {
+               os_timerDestroy(hOs, pHandle->timer);
+               fsm_Unload(hOs, pHandle->pMainKeysSm);
+               os_memoryFree(hOs, pHandle, sizeof(mainKeys_t));
+               return NULL;
+       }
+
+       pHandle->pBcastSm = broadcastKey_create(hOs);
+       if (pHandle->pBcastSm == NULL)
+       {
+               keyParser_unload(pHandle->pKeyParser);
+               os_timerDestroy(hOs, pHandle->timer);
+               fsm_Unload(hOs, pHandle->pMainKeysSm);
+               os_memoryFree(hOs, pHandle, sizeof(mainKeys_t));
+               return NULL;
+       }
+
+       pHandle->pUcastSm = unicastKey_create(hOs);
+       if (pHandle->pBcastSm == NULL)
+       {
+               broadcastKey_unload(pHandle->pBcastSm);
+               keyParser_unload(pHandle->pKeyParser);
+               os_timerDestroy(hOs, pHandle->timer);
+               fsm_Unload(hOs, pHandle->pMainKeysSm);
+               os_memoryFree(hOs, pHandle, sizeof(mainKeys_t));
+               return NULL;
+       }
+    
+       pHandle->hOs = hOs;
+    
+       /* At first Timeout we will send MediaSpecific Event   */
+       /* At any other Timeout we will send the Timeout Event */
+
+       pHandle->mainKeysTimeoutCounter = FALSE;
+    
+       return pHandle;
+}
+
+/**
+*
+* mainKeys_config
+*
+* \b Description: 
+*
+* Init main security state machine state machine
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainKeys_config(mainKeys_t *pMainKeys, 
+                      rsn_paeConfig_t *pPaeConfig, 
+                      void *pParent,
+                                         TI_HANDLE             hReport,
+                                         TI_HANDLE             hOs,
+                      TI_HANDLE     hCtrlData,
+                      TI_HANDLE     hEvHandler,
+                      TI_HANDLE     hConn,
+                      TI_HANDLE     hRsn )
+
+{
+    TI_STATUS      status;
+
+       /** Main key State Machine matrix */
+       fsm_actionCell_t    mainKeysSM_matrix[MAIN_KEYS_NUM_STATES][MAIN_KEYS_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {       {MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeys_startIdle}, 
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeySmUnexpected}
+               },
+
+               /* next state and actions for START state */
+               {       {MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeySmUnexpected},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopStart}, 
+                       {MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_START, (fsm_Action_t)mainKeys_smTimeOut}
+               },
+
+               /* next state and actions for UNICAST COMPLETE state */
+               {       {MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopUcastComplete}, 
+                       {MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeys_bcastCompleteUcastComplete},
+                       {MAIN_KEYS_STATE_UNICAST_COMPLETE, (fsm_Action_t)mainKeys_smTimeOut}
+               },
+
+               /* next state and actions for BROADCAST COMPLETE state */
+               {       {MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopBcastComplete},
+                       {MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeys_ucastCompleteBcastComplete},
+                       {MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_BROADCAST_COMPLETE, (fsm_Action_t)mainKeys_smTimeOut}
+               },
+
+               /* next state and actions for COMPLETE state */
+               {       {MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmUnexpected},
+                       {MAIN_KEYS_STATE_IDLE, (fsm_Action_t)mainKeys_stopComplete},
+                       {MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmNop},
+                       {MAIN_KEYS_STATE_COMPLETE, (fsm_Action_t)mainKeySmUnexpected}
+               }
+       };
+
+       pMainKeys->hCtrlData = hCtrlData;
+       pMainKeys->hOs = hOs;
+       pMainKeys->hReport = hReport;
+    pMainKeys->hEvHandler = hEvHandler;
+    pMainKeys->hConn = hConn;
+    pMainKeys->hRsn = hRsn;
+
+    pMainKeys->pParent = pParent;
+       pMainKeys->keysTimeout = MAIN_KEYS_TIMEOUT;
+
+       pMainKeys->start = mainKeys_start;
+       pMainKeys->stop = mainKeys_stop;
+       pMainKeys->reportUcastStatus = mainKeys_reportUcastStatus;
+       pMainKeys->reportBcastStatus = mainKeys_reportBcastStatus;
+       pMainKeys->setKey = mainKeys_setKey;
+       pMainKeys->removeKey = mainKeys_removeKey;
+       pMainKeys->setDefaultKeyId = mainKeys_setDefaultKeyId;
+       pMainKeys->getSessionKey = mainKeys_getSessionKey;
+
+       pMainKeys->currentState = MAIN_KEYS_STATE_IDLE;
+
+    status = fsm_Config(pMainKeys->pMainKeysSm, &mainKeysSM_matrix[0][0], 
+                                               MAIN_KEYS_NUM_STATES, MAIN_KEYS_NUM_EVENTS, NULL, pMainKeys->hOs);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                       ("MAIN_KEYS_SM: Error in configuring SM\n"));
+               return status;
+       }
+
+       status = keyParser_config(pMainKeys->pKeyParser, 
+                              pPaeConfig, 
+                              pMainKeys->pUcastSm, 
+                              pMainKeys->pBcastSm, 
+                              pMainKeys, 
+                              hReport, 
+                              hOs,
+                              hCtrlData);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                       ("MAIN_KEYS_SM: Error in configuring key parser\n"));
+               return status;
+       }
+
+       status = broadcastKey_config(pMainKeys->pBcastSm, pPaeConfig, pMainKeys, hReport, hOs);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                       ("MAIN_KEYS_SM: Error in configuring broadcast key SM\n"));
+               return status;
+       }
+    
+       status = unicastKey_config(pMainKeys->pUcastSm, pPaeConfig, pMainKeys, hReport, hOs);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                       ("MAIN_KEYS_SM: Error in configuring unicast key SM\n"));
+               return status;
+       }
+       
+       return OK;
+}
+
+/**
+*
+* mainKeys_config
+*
+* \b Description: 
+*
+* Init main security state machine state machine
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainKeys_unload(mainKeys_t *pMainKeys)
+{
+       TI_STATUS       status;
+
+       if (pMainKeys == NULL)
+       {
+               return NOK;
+       }
+
+       status = fsm_Unload(pMainKeys->hOs, pMainKeys->pMainKeysSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                 ("MAIN_KEYS_SM: Error releasing FSM memory \n"));
+       }
+
+       os_timerStop(pMainKeys->hOs, pMainKeys->timer);
+    os_timerDestroy(pMainKeys->hOs, pMainKeys->timer);
+       
+    status = keyParser_unload(pMainKeys->pKeyParser);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                 ("MAIN_KEYS_SM: Error unloading key parser\n"));
+       }
+
+       status = broadcastKey_unload(pMainKeys->pBcastSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                 ("MAIN_KEYS_SM: Error unloading broadcast key SM\n"));
+       }
+
+       status = unicastKey_unload(pMainKeys->pUcastSm);
+    if (status != OK)
+       {
+               /* report failure but don't stop... */
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                 ("MAIN_KEYS_SM: Error unloading unicast key SM\n"));
+       }
+       
+       os_memoryFree(pMainKeys->hOs, pMainKeys, sizeof(mainKeys_t));
+
+    return OK;
+}
+
+
+/**
+*
+* rsn_mainKeySmStart
+*
+* \b Description: 
+*
+* START event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa rsn_mainKeySmStop()
+*/
+
+TI_STATUS mainKeys_start(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status;
+
+       status = mainKeys_smEvent(pMainKeys, MAIN_KEYS_EVENT_START, pMainKeys);
+
+       return status;
+}
+
+/**
+*
+* rsn_mainKeySmStop
+*
+* \b Description: 
+*
+* STOP event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa rsn_mainKeySmStart()
+*/
+
+TI_STATUS mainKeys_stop(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status;
+
+       status = mainKeys_smEvent(pMainKeys, MAIN_KEYS_EVENT_STOP, pMainKeys);
+
+       return status;
+}
+
+/**
+*
+* rsn_mainKeySmReportUnicastComplete
+*
+* \b Description: 
+*
+* UNICAST_COMPLETE event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa rsn_mainKeySmReportBroadcastComplete()
+*/
+
+TI_STATUS mainKeys_reportUcastStatus(struct _mainKeys_t *pMainKeys, TI_STATUS ucastStatus)
+{
+       TI_STATUS    status=NOK;
+    paramInfo_t  param;
+    externalAuthMode_e  extAuthMode;
+
+       if (ucastStatus == OK)
+       {
+
+        param.content.txDataCurrentPrivacyInvokedMode = TRUE;
+        param.paramType = TX_DATA_CURRENT_PRIVACY_INVOKE_MODE_PARAM;
+        txData_setParam(pMainKeys->pParent->pParent->hTx, &param);
+        status = pMainKeys->pParent->pParent->pAdmCtrl->getExtAuthMode(pMainKeys->pParent->pParent->pAdmCtrl, &extAuthMode);
+        if (status != OK)
+        {
+            return status;
+        }
+        if (extAuthMode >= RSN_EXT_AUTH_MODE_WPA)
+        {
+        param.content.txDataEapolEncryptionStatus = TRUE;
+        }
+        else
+        {
+            param.content.txDataEapolEncryptionStatus = FALSE;
+        }
+               param.paramType = TX_DATA_EAPOL_ENCRYPTION_STATUS_PARAM;
+               txData_setParam(pMainKeys->pParent->pParent->hTx, &param);
+               
+        status = mainKeys_smEvent(pMainKeys, MAIN_KEYS_EVENT_UCAST_COMPLETE, pMainKeys);
+       }
+
+       return status;
+}
+
+
+/**
+*
+* rsn_mainKeySmReportBroadcastComplete
+*
+* \b Description: 
+*
+* BROADCAST_COMPLETE event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa rsn_mainKeySmReportUnicastComplete()
+*/
+
+TI_STATUS mainKeys_reportBcastStatus(struct _mainKeys_t *pMainKeys, TI_STATUS bcastStatus)
+{
+       TI_STATUS  status=NOK;
+
+       if (bcastStatus == OK)
+       {
+               status = mainKeys_smEvent(pMainKeys, MAIN_KEYS_EVENT_BCAST_COMPLETE, pMainKeys);
+       }
+
+       return status;
+}
+
+/**
+*
+* mainKeySmSessionTimeout
+*
+* \b Description: 
+*
+* SESSION_TIMEOUOT event handler
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_setKey(struct _mainKeys_t *pMainKeys, securityKeys_t *pKey)
+{
+       return (pMainKeys->pParent->setKey(pMainKeys->pParent, pKey));
+}
+
+/**
+*
+* mainKeySmSessionTimeout
+*
+* \b Description: 
+*
+* SESSION_TIMEOUOT event handler
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_removeKey(struct _mainKeys_t *pMainKeys, securityKeys_t *pKey)
+{
+       return (pMainKeys->pParent->removeKey(pMainKeys->pParent, pKey));
+}
+
+/**
+*
+* mainKeySmSessionTimeout
+*
+* \b Description: 
+*
+* SESSION_TIMEOUOT event handler
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_setDefaultKeyId(struct _mainKeys_t *pMainKeys, UINT8 keyId)
+{
+       return (pMainKeys->pParent->setDefaultKeyId(pMainKeys->pParent, keyId));
+}
+
+/**
+*
+* mainKeySmSessionTimeout
+*
+* \b Description: 
+*
+* SESSION_TIMEOUOT event handler
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_getSessionKey(struct _mainKeys_t *pMainKeys, UINT8 *pKey, UINT32 *pKeyLen)
+{
+       TI_STATUS               status;
+
+       status = pMainKeys->pParent->getSessionKey(pMainKeys->pParent, pKey, pKeyLen);
+
+       return status;
+}
+
+/**
+*
+* mainKeySmSessionTimeout
+*
+* \b Description: 
+*
+* SESSION_TIMEOUOT event handler
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+void mainKeys_sessionTimeout(void *pMainKeys)
+{
+
+       mainKeys_smEvent(pMainKeys, MAIN_KEYS_EVENT_SESSION_TIMEOUOT, pMainKeys);
+
+}
+
+
+#ifdef REPORT_LOG
+
+static char *mainKeys_smStateDesc[MAIN_KEYS_NUM_STATES] = {
+               "STATE_IDLE",
+               "STATE_START",
+               "STATE_UNICAST_COMPLETE",
+               "STATE_BROADCAST_COMPLETE",
+               "STATE_COMPLETE",
+       };
+
+static char *mainKeys_smEventDesc[MAIN_KEYS_NUM_EVENTS] = {
+               "EVENT_START",
+               "EVENT_STOP",
+               "EVENT_UNICAST_COMPLETE",
+               "EVENT_BROADCAST_COMPLETE",
+               "EVENT_SESSION_TIMEOUOT"
+       };
+
+#endif
+
+static TI_STATUS mainKeys_smEvent(struct _mainKeys_t *pMainKeys, UINT8 event, void* pData)
+{
+       TI_STATUS               status;
+       UINT8           nextState;
+
+
+       status = fsm_GetNextState(pMainKeys->pMainKeysSm, pMainKeys->currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                                 ("MAIN_KEYS_SM: ERROR - failed getting next state \n"));
+
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pMainKeys->hReport, RSN_MODULE_LOG,
+                                        ("MAIN_KEYS_SM: <%s, %s> --> %s\n",
+                                         mainKeys_smStateDesc[pMainKeys->currentState],
+                                         mainKeys_smEventDesc[event],
+                                         mainKeys_smStateDesc[nextState]));
+
+       status = fsm_Event(pMainKeys->pMainKeysSm, &pMainKeys->currentState, event, pData);
+
+       return status;
+}
+/**
+*
+* mainKeySmStartSubKeySmsAndTimer
+*
+* \b Description: 
+*
+* Starts unicast & broadcast key SMs and session timer.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+
+TI_STATUS mainKeys_startIdle(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status;
+       
+       status = pMainKeys->pUcastSm->start(pMainKeys->pUcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       status = pMainKeys->pBcastSm->start(pMainKeys->pBcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       os_timerStart(pMainKeys->hOs, pMainKeys->timer, pMainKeys->keysTimeout, FALSE);
+       
+       status = pMainKeys->pKeyParser->replayReset(pMainKeys->pKeyParser);
+
+       return status;
+}
+
+
+/**
+*
+* mainKeySmStopSubKeySmsAndTimer
+*
+* \b Description: 
+*
+* Stops unicast & broadcast key SMs and session timer.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_stopStart(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status = OK;
+
+       status = pMainKeys->pUcastSm->stop(pMainKeys->pUcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       status = pMainKeys->pBcastSm->stop(pMainKeys->pBcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       os_timerStop(pMainKeys->hOs, pMainKeys->timer);
+       
+       return status;
+}
+
+
+/**
+*
+* mainKeySmStopSubKeySmsAndTimer
+*
+* \b Description: 
+*
+* Stops unicast & broadcast key SMs and session timer.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_stopUcastComplete(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status = OK;
+
+       status = pMainKeys->pUcastSm->stop(pMainKeys->pUcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       status = pMainKeys->pBcastSm->stop(pMainKeys->pBcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       os_timerStop(pMainKeys->hOs, pMainKeys->timer);
+       
+       return status;
+}
+
+/**
+*
+* mainKeySmReportComplete
+*
+* \b Description: 
+*
+* Report key complete to the main security SM.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_bcastCompleteUcastComplete(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status;
+
+    WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
+                      ("mainKeys_bcastCompleteUcastComplete - sending Interrogate \n"));
+       os_timerStop(pMainKeys->hOs, pMainKeys->timer);
+
+       status = pMainKeys->pParent->reportKeysStatus(pMainKeys->pParent, OK);
+
+       return status;
+}
+
+
+/**
+*
+* mainKeySmStopSubKeySmsAndTimer
+*
+* \b Description: 
+*
+* Stops unicast & broadcast key SMs and session timer.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_stopBcastComplete(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status = OK;
+
+       status = pMainKeys->pUcastSm->stop(pMainKeys->pUcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       status = pMainKeys->pBcastSm->stop(pMainKeys->pBcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       os_timerStop(pMainKeys->hOs, pMainKeys->timer);
+       
+       return status;
+}
+
+/**
+*
+* mainKeySmReportComplete
+*
+* \b Description: 
+*
+* Report key complete to the main security SM.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_ucastCompleteBcastComplete(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status;
+
+    WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
+                      ("mainKeys_ucastCompleteBcastComplete \n"));
+
+       os_timerStop(pMainKeys->hOs, pMainKeys->timer);
+       
+       status = pMainKeys->pParent->reportKeysStatus(pMainKeys->pParent, OK);
+
+       return status;
+}
+
+/**
+*
+* mainKeySmStopSubKeySmsAndTimer
+*
+* \b Description: 
+*
+* Stops unicast & broadcast key SMs and session timer.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_stopComplete(struct _mainKeys_t *pMainKeys)
+{
+       TI_STATUS  status = OK;
+
+       status = pMainKeys->pUcastSm->stop(pMainKeys->pUcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       status = pMainKeys->pBcastSm->stop(pMainKeys->pBcastSm);
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       return status;
+}
+
+/**
+*
+* mainKeySmLogMessage
+*
+* \b Description: 
+*
+* Prints Log messge.\n
+* Start session timer.
+*
+* \b ARGS:
+*
+*  I   - pData - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS mainKeys_smTimeOut(void* data)
+{
+       OS_802_11_AUTHENTICATION_REQUEST   *request;
+       UINT8                   AuthBuf[sizeof(UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];
+       paramInfo_t                             param;
+       TI_STATUS                               status;
+       struct _mainKeys_t              *pMainKeys = (struct _mainKeys_t *)data;
+
+
+       WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
+                                 ("MAIN_KEY_SM: TRAP: Session Timeout for station , mainKeysTimeoutCounter=%d\n",
+                   pMainKeys->mainKeysTimeoutCounter));
+
+       request = (OS_802_11_AUTHENTICATION_REQUEST *)(AuthBuf + sizeof(UINT32));
+       request->Length = sizeof(OS_802_11_AUTHENTICATION_REQUEST);
+
+       param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+       status = ctrlData_getParam(pMainKeys->hCtrlData, &param);
+       if (status != OK)
+       {               
+               return NOK;
+       }
+
+    WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
+                         ("current station is banned from the roaming candidates list for %d Ms\n",
+               RSN_MAIN_KEYS_SESSION_TIMEOUT));
+
+    rsn_banSite(pMainKeys->hRsn, param.content.ctrlDataCurrentBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_MAIN_KEYS_SESSION_TIMEOUT);
+       
+
+       /* mainKeysTimeoutCounter is a boolean variable, With states:   */
+       /* TRUE - It is a Timeout Association Event                                             */ 
+       /* FALSE - It is a Media specific Event                                                 */
+
+       if (!pMainKeys->mainKeysTimeoutCounter)
+       {
+               /* Fill Media specific indication fields and send to OS/User    */ 
+               os_memoryCopy(pMainKeys->hOs, request->BSSID, (void *)param.content.ctrlDataCurrentBSSID.addr, MAC_ADDR_LEN);
+       
+               request->Flags = OS_802_11_REQUEST_REAUTH;
+       
+               *(UINT32*)AuthBuf = os802_11StatusType_Authentication;
+       
+               WLAN_REPORT_INFORMATION(pMainKeys->hReport, RSN_MODULE_LOG,
+                         (" %d Ms\n",RSN_MAIN_KEYS_SESSION_TIMEOUT));
+       
+               EvHandlerSendEvent(pMainKeys->hEvHandler, IPC_EVENT_MEDIA_SPECIFIC, (UINT8*)AuthBuf,
+                                                       sizeof(UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST));
+       
+               os_timerStart(pMainKeys->hOs, pMainKeys->timer, pMainKeys->keysTimeout, FALSE);
+               pMainKeys->mainKeysTimeoutCounter = TRUE;
+       }
+       else
+       {
+        pMainKeys->mainKeysTimeoutCounter = FALSE;
+        rsn_reportAuthFailure(pMainKeys->hRsn, RSN_AUTH_STATUS_TIMEOUT);
+        conn_reportRsnStatus(pMainKeys->hConn, (mgmtStatus_e)STATUS_SECURITY_FAILURE);
+       }
+       return OK;
+}
+
+
+TI_STATUS mainKeySmUnexpected(struct _mainKeys_t *pMainKeys)
+{
+       WLAN_REPORT_ERROR(pMainKeys->hReport, RSN_MODULE_LOG,
+                                         ("MAIN_KEY_SM: ERROR UnExpected Event\n"));
+
+       return(OK);
+}
+
+TI_STATUS mainKeySmNop(struct _mainKeys_t *pMainKeys)
+{
+       return(OK);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/mainSecKeysOnly.c b/sta_dk_4_0_4_32/common/src/core/rsn/mainSecKeysOnly.c
new file mode 100644 (file)
index 0000000..1c0bea2
--- /dev/null
@@ -0,0 +1,443 @@
+/** \file mainSecSm.c
+ *  \brief 802.1X finite state machine header file
+ *
+ *  \see mainSecSm.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mainSecSm.c                                                                                                */
+/*    PURPOSE: Main Security State Machine API                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "fsm.h"
+#include "report.h"
+
+#include "DataCtrl_Api.h"
+#include "smeApi.h"
+
+#include "rsn.h"
+#include "rsnApi.h"
+#include "mainSecSm.h"
+#include "mainSecKeysOnly.h"
+
+#include "mainKeysSm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* functions */
+TI_STATUS mainSecKeysOnly_getAuthState(mainSec_t *pMainSec, TIWLN_SECURITY_STATE *supp1XState);
+
+TI_STATUS mainSecKeysOnly_reportAuthFailure(mainSec_t *pMainSec, authStatus_e authStatus) ;
+TI_STATUS mainSecKeysOnly_setAuthIdentity(mainSec_t *pMainSec, authIdentity_t *authIdentity);
+/**
+*
+* rsn_mainSecSmKeysOnlyInit
+*
+* \b Description: 
+*
+* Init main security state machine state machine
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecKeysOnly_config(mainSec_t *pMainSec, 
+                                                 rsn_paeConfig_t *pPaeConfig)
+{
+       TI_STATUS                               status;
+       /** Main 802.1X State Machine matrix */
+       fsm_actionCell_t        mainSecKeysOnly_matrix[MAIN_SEC_KEYS_ONLY_NUM_STATES][MAIN_SEC_KEYS_ONLY_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {{MAIN_KO_STATE_START, (fsm_Action_t)mainSecKeysOnly_startIdle},
+                {MAIN_KO_STATE_IDLE, (fsm_Action_t)mainSecKeysOnly_Nop},
+                {MAIN_KO_STATE_IDLE, (fsm_Action_t)mainSecKeysOnly_unexpected},
+                {MAIN_KO_STATE_IDLE, (fsm_Action_t)mainSecKeysOnly_unexpected}
+               },
+               /* next state and actions for START state */
+               {{MAIN_KO_STATE_START, (fsm_Action_t)mainSecKeysOnly_Nop},
+                {MAIN_KO_STATE_IDLE, (fsm_Action_t)mainSecKeysOnly_stopStart},
+                {MAIN_KO_STATE_AUTHORIZED, (fsm_Action_t)mainSecKeysOnly_keysCompleteStart},
+                {MAIN_KO_STATE_NONAUTHORIZED, (fsm_Action_t)mainSecKeysOnly_keysTOStart},
+               },
+               /* next state and actions for AUTHORIZED state */
+               {{MAIN_KO_STATE_AUTHORIZED, (fsm_Action_t)mainSecKeysOnly_unexpected},
+                {MAIN_KO_STATE_IDLE, (fsm_Action_t)mainSecKeysOnly_stopAuthorized},
+                {MAIN_KO_STATE_AUTHORIZED, (fsm_Action_t)mainSecKeysOnly_Nop},
+                {MAIN_KO_STATE_AUTHORIZED, (fsm_Action_t)mainSecKeysOnly_unexpected},
+               },
+               /* next state and actions for NONAUTORIZED state */
+               {{MAIN_KO_STATE_START, (fsm_Action_t)mainSecKeysOnly_unexpected},
+                {MAIN_KO_STATE_IDLE, (fsm_Action_t)mainSecKeysOnly_stopNonAuthorized},
+                {MAIN_KO_STATE_NONAUTHORIZED, (fsm_Action_t)mainSecKeysOnly_unexpected},
+                {MAIN_KO_STATE_NONAUTHORIZED, (fsm_Action_t)mainSecKeysOnly_unexpected},
+               }
+       };
+
+    status = fsm_Config(pMainSec->pMainSecSm, &mainSecKeysOnly_matrix[0][0], 
+                                               MAIN_SEC_KEYS_ONLY_NUM_STATES, MAIN_SEC_KEYS_ONLY_NUM_EVENTS, NULL, pMainSec->hOs);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG,
+                                                       ("MAIN_SEC_SM: Error in configuring full SM\n"));
+               return status;
+       }
+
+    pMainSec->currentState          = MAIN_KO_STATE_IDLE;
+       pMainSec->start                                 = mainSecKeysOnly_start;
+       pMainSec->stop                                  = mainSecKeysOnly_stop;
+       pMainSec->reportKeysStatus              = mainSecKeysOnly_reportKeysStatus;
+       pMainSec->getAuthState                  = (mainSecSm_getAuthState_t)mainSecKeysOnly_getAuthState;
+       pMainSec->reportReAuthenticate  = (mainSecSmReportReauthentication_t)mainSecKeysOnly_unexpected;
+       pMainSec->setSessionKey                 = (mainSecSmSetSessionKey_t)mainSecKeysOnly_unexpected;
+       pMainSec->getSessionKey                 = (mainSecSmGetSessionKey_t)mainSecKeysOnly_unexpected;
+       pMainSec->reportAuthStatus              = (mainSecSmReportAuthStatus_t)mainSecKeysOnly_unexpected;
+       pMainSec->getAuthIdentity               = (mainSecSm_getAuthIdentity_t)mainSecKeysOnly_unexpected;
+       pMainSec->setAuthIdentity               = (mainSecSm_getAuthIdentity_t)mainSecKeysOnly_setAuthIdentity;
+    pMainSec->reportAuthFailure     = (mainSecSm_reportAuthFailure_t)mainSecKeysOnly_reportAuthFailure;
+    
+    WLAN_REPORT_INFORMATION(pMainSec->hReport, RSN_MODULE_LOG,
+                    ("mainSecKeysOnly_config\n"));
+
+    return OK;
+}
+
+/**
+*
+* mainSecSmNull_Start
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecKeysOnly_start(mainSec_t *pMainSec)
+{
+    TI_STATUS status;
+
+    status = fsm_Event(pMainSec->pMainSecSm, &pMainSec->currentState, MAIN_KO_EVENT_START, pMainSec); 
+    
+    return status;
+}
+
+/**
+*
+* mainSecSmNull_Stop
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecKeysOnly_stop(mainSec_t *pMainSec)
+{
+    TI_STATUS status;
+
+    status = fsm_Event(pMainSec->pMainSecSm, &pMainSec->currentState, MAIN_KO_EVENT_STOP, pMainSec); 
+    
+    return status;
+}
+/**
+*
+* mainSecSmNull_Stop
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecKeysOnly_reportKeysStatus(mainSec_t *pMainSec, TI_STATUS keysStatus)
+{
+       TI_STATUS status;
+
+       pMainSec->data.status = keysStatus;
+
+       if (keysStatus == OK)
+       {
+               status = fsm_Event(pMainSec->pMainSecSm, &pMainSec->currentState, MAIN_KO_EVENT_KEYS_COMPLETE, pMainSec);
+       } else {
+               WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG,
+                                                       ("MAIN_SEC_SM: Error in Keys\n"));
+               status  = OK;
+       }
+
+       return status;
+}
+
+/**
+*
+* mainSecSmNull_setKey
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecKeysOnly_setSessionKey(mainSec_t *pMainSec, UINT8* pKey, UINT8 keyLen)
+{
+       os_memoryCopy(pMainSec->hOs, pMainSec->sessionKey, pKey, keyLen);
+       pMainSec->sessionKeyLen = keyLen;
+
+       return OK;
+}
+
+/**
+*
+* mainSecSmNull_setKey
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecKeysOnly_getSessionKey(mainSec_t *pMainSec, UINT8* pKey, UINT32* pKeyLen)
+{
+       os_memoryCopy(pMainSec->hOs, pKey, pMainSec->sessionKey, pMainSec->sessionKeyLen);
+       *pKeyLen = pMainSec->sessionKeyLen;
+
+       return OK;
+}
+
+
+
+/* State machine implementation functions */
+
+TI_STATUS mainSecKeysOnly_startIdle(struct _mainSec_t *pMainSec)
+{
+    TI_STATUS          status = OK;
+
+       WLAN_REPORT_SM(pMainSec->hReport, RSN_MODULE_LOG,
+                                                         ("MAIN_SEC_SM: mainSecKeysOnly_StartIdle...\n"));
+       status =  pMainSec->pMainKeys->start(pMainSec->pMainKeys);
+       
+       return status;
+}
+
+TI_STATUS mainSecKeysOnly_stopStart(struct _mainSec_t *pMainSec)
+{
+    TI_STATUS          status = OK;
+
+       WLAN_REPORT_SM(pMainSec->hReport, RSN_MODULE_LOG,
+                                                         ("MAIN_SEC_SM: mainSecKeysOnly_StopStart...\n"));
+       status =  pMainSec->pMainKeys->stop(pMainSec->pMainKeys);
+
+       return status;
+}
+
+TI_STATUS mainSecKeysOnly_keysCompleteStart(struct _mainSec_t *pMainSec)
+{
+    TI_STATUS          status = OK;
+
+       WLAN_REPORT_SM(pMainSec->hReport, RSN_MODULE_LOG,
+                                                         ("MAIN_SEC_SM: mainSecKeysOnly_KeysCompleteAuthenticated...\n"));
+       status =  pMainSec->pParent->reportStatus(pMainSec->pParent, pMainSec->data.status);
+       
+       return(status);
+}
+
+TI_STATUS mainSecKeysOnly_keysTOStart(struct _mainSec_t *pMainSec)
+{
+    TI_STATUS          status = OK;
+
+       return(status);
+}
+
+TI_STATUS mainSecKeysOnly_stopAuthorized(struct _mainSec_t *pMainSec)
+{
+    TI_STATUS          status = OK;
+
+       WLAN_REPORT_SM(pMainSec->hReport, RSN_MODULE_LOG,
+                                                         ("MAIN_SEC_SM: mainSecKeysOnly_StopAuthorized...\n"));
+       status =  pMainSec->pMainKeys->stop(pMainSec->pMainKeys);
+       
+       return(status);
+}
+
+TI_STATUS mainSecKeysOnly_stopNonAuthorized(struct _mainSec_t *pMainSec)
+{
+    TI_STATUS          status = OK;
+
+       WLAN_REPORT_SM(pMainSec->hReport, RSN_MODULE_LOG,
+                                                         ("MAIN_SEC_SM: mainSecKeysOnly_StopNonAuthorized...\n"));
+       status =  pMainSec->pMainKeys->stop(pMainSec->pMainKeys);
+       
+       return(status);
+}
+
+/* state machine action functions */
+
+TI_STATUS mainSecKeysOnly_Nop(void* pData)
+{
+       return(OK);
+}
+
+TI_STATUS mainSecKeysOnly_unexpected(void* pData)
+{
+       return NOK;
+}
+
+ /**
+*
+* mainSecKeysOnly_getAuthState:  \n 
+*
+* \b Description: 
+*
+* Get authentication state from supp1x SM.
+*
+* \b ARGS:
+*
+*  I   - pMainSec - pMainSec SM context  \n
+*  I   - authIdentity - pointer to authentication state \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+
+TI_STATUS mainSecKeysOnly_getAuthState(mainSec_t *pMainSec, TIWLN_SECURITY_STATE *secState)
+{
+       switch (pMainSec->currentState)
+       {
+       case MAIN_KO_STATE_START:
+               *secState = eSecurityStateAuthenticating;
+               break;
+
+       case MAIN_KO_STATE_AUTHORIZED:
+               *secState = eSecurityStateAuthenticated;
+               break;
+
+       case MAIN_KO_STATE_NONAUTHORIZED:
+               *secState = eSecurityStateNotAuthenticated ;
+               break;
+
+       default:
+               *secState = eSecurityStateHalted;
+               break;
+       }
+       
+       return OK;
+
+} /*mainSecKeysOnly_getAuthState*/
+
+
+TI_STATUS mainSecKeysOnly_reportAuthFailure(mainSec_t *pMainSec, authStatus_e authStatus) 
+{
+
+    return OK;
+}
+
+
+TI_STATUS mainSecKeysOnly_setAuthIdentity(mainSec_t *pMainSec, authIdentity_t *authIdentity)
+{
+
+       return OK;
+} 
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/mainSecNull.c b/sta_dk_4_0_4_32/common/src/core/rsn/mainSecNull.c
new file mode 100644 (file)
index 0000000..ca16238
--- /dev/null
@@ -0,0 +1,234 @@
+/** \file mainSecSm.c
+ *  \brief 802.1X finite state machine header file
+ *
+ *  \see mainSecSm.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: mainSecSm.c                                                                                                */
+/*    PURPOSE: Main Security State Machine API                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+#include "paramIn.h"
+
+#include "utils.h"
+#include "report.h"
+
+#include "DataCtrl_Api.h"
+#include "smeApi.h"
+
+#include "rsn.h"
+#include "rsnApi.h"
+#include "mainSecSm.h"
+#include "mainSecNull.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+
+/* functions */
+
+/**
+*
+* rsn_mainSecSmFullInit
+*
+* \b Description: 
+*
+* Init main security state machine state machine
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecSmNull_config(mainSec_t *pMainSec, 
+                            rsn_paeConfig_t *pPaeConfig)
+{
+    pMainSec->start = (mainSecSmStart_t)mainSecSmNull_start;
+       pMainSec->stop = mainSecSmNull_stop;
+       pMainSec->reportAuthStatus = NULL;
+       pMainSec->reportKeysStatus = mainSecNull_reportKeysStatus;
+       pMainSec->reportReAuthenticate = NULL;
+       pMainSec->getAuthIdentity  = NULL;
+       pMainSec->setAuthIdentity  = (mainSecSm_getAuthIdentity_t)mainSecNull_setAuthIdentity;
+    pMainSec->getAuthState = mainSecNull_getAuthState;
+    pMainSec->reportAuthFailure  = (mainSecSm_reportAuthFailure_t)mainSecNull_reportAuthFailure;
+    return OK;
+}
+
+/**
+*
+* mainSecSmNull_Start
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecSmNull_start(mainSec_t *pMainSec)
+{
+    TI_STATUS status;
+
+    status = rsn_reportStatus(pMainSec->pParent, OK); 
+    
+    return status;
+}
+
+/**
+*
+* mainSecSmNull_Stop
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecSmNull_stop(mainSec_t *pMainSec)
+{
+    return OK;
+}
+
+/**
+*
+* mainSecNull_reportKeysStatus
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSecNull_reportKeysStatus(mainSec_t *pMainSec, TI_STATUS keysStatus)
+{
+
+       return OK;
+} 
+/**
+*
+* mainSecKeysOnly_getAuthState:  \n 
+*
+* \b Description: 
+*
+* Get authentication state from supp1x SM.
+*
+* \b ARGS:
+*
+*  I   - pMainSec - pMainSec SM context  \n
+*  I   - authIdentity - pointer to authentication state \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+
+TI_STATUS mainSecNull_getAuthState(mainSec_t *pMainSec, TIWLN_SECURITY_STATE *secState)
+{
+       *secState = eSecurityStateHalted; 
+       return OK;
+
+} /*mainSecKeysOnly_getAuthState*/
+
+
+TI_STATUS mainSecSmNull_nop(mainSec_t *pMainSec)
+{
+       return OK;
+
+} /*mainSecKeysOnly_getAuthState*/
+
+
+TI_STATUS mainSecNull_reportAuthFailure(mainSec_t *pMainSec, authStatus_e authStatus) 
+{
+    return OK;
+}
+
+
+TI_STATUS mainSecNull_setAuthIdentity(mainSec_t *pMainSec, authIdentity_t *authIdentity)
+{
+
+       return OK;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/mainSecSm.c b/sta_dk_4_0_4_32/common/src/core/rsn/mainSecSm.c
new file mode 100644 (file)
index 0000000..b9dd1c3
--- /dev/null
@@ -0,0 +1,387 @@
+/** \file mainSecSm.c
+ *  \brief 802.1X finite state machine header file
+ *
+ *  \see mainSecSm.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE: mainSecSm.c                                                */
+/*    PURPOSE:  Main Security State Machine API                            */
+/*                                                                         */
+/***************************************************************************/
+
+#include "osApi.h"
+
+#include "paramOut.h"
+/*#include "paramIn.h"*/
+
+#include "utils.h"
+#include "report.h"
+
+#include "DataCtrl_Api.h"
+#include "smeApi.h"
+
+#include "rsn.h"
+#include "rsnApi.h"
+
+#include "mainSecSm.h"
+#include "mainSecNull.h"
+
+
+#include "mainSecKeysOnly.h"
+#include "mainKeysSm.h"
+
+/* Constants */
+
+/** number of events in the state machine */
+#define MAIN_SEC_MAX_NUM_EVENTS     7
+
+/** number of states in the state machine */
+#define MAIN_SEC_MAX_NUM_STATES     6
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+
+TI_STATUS mainSec_setKey(struct _mainSec_t *pMainSec, securityKeys_t *pKey);
+TI_STATUS mainSec_removeKey(struct _mainSec_t *pMainSec, securityKeys_t *pKey);
+TI_STATUS mainSec_setDefaultKeyId(struct _mainSec_t *pMainSec, UINT8 keyId);
+
+/* functions */
+
+/**
+*
+* mainSec_create
+*
+* \b Description: 
+*
+* Allocate memory for the main security context, and create all the rest of the needed contexts.
+*
+* \b ARGS:
+*
+*  I - hOs - OS handle for OS operations.
+*
+* \b RETURNS:
+*
+*  pointer to main security context. If failed, returns NULL.
+*
+* \sa 
+*/
+mainSec_t* mainSec_create(TI_HANDLE hOs)
+{
+    mainSec_t   *pHandle;
+    TI_STATUS       status;
+
+    /* allocate association context memory */
+    pHandle = (mainSec_t*)os_memoryAlloc(hOs, sizeof(mainSec_t));
+    if (pHandle == NULL)
+    {
+        return NULL;
+    }
+
+    os_memoryZero(hOs, pHandle, sizeof(mainSec_t));
+
+    /* allocate memory for association state machine */
+    status = fsm_Create(hOs, &pHandle->pMainSecSm, MAIN_SEC_MAX_NUM_STATES, MAIN_SEC_MAX_NUM_EVENTS);
+    if (status != OK)
+    {
+        os_memoryFree(hOs, pHandle, sizeof(mainSec_t));
+        return NULL;
+    }
+
+    pHandle->pMainKeys = mainKeys_create(hOs);
+    if (pHandle->pMainKeys == NULL)
+    {
+        fsm_Unload(hOs, pHandle->pMainSecSm);
+        os_memoryFree(hOs, pHandle, sizeof(mainSec_t));
+        return NULL;
+    }
+
+    pHandle->pKeyParser = pHandle->pMainKeys->pKeyParser;
+
+    
+    pHandle->hOs = hOs;
+    
+    return pHandle;
+}
+
+/**
+*
+* mainSec_config
+*
+* \b Description: 
+*
+* Init main security state machine state machine
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSec_config(mainSec_t *pMainSec, 
+                      mainSecInitData_t *pInitData, 
+                      void *pParent,
+                      TI_HANDLE hReport,
+                      TI_HANDLE hOs,
+                      TI_HANDLE hCtrlData,
+                      TI_HANDLE hEvHandler,
+                      TI_HANDLE hConn,
+                      TI_HANDLE hHalCtrl   )
+{
+    TI_STATUS               status;
+
+    pMainSec->setKey = mainSec_setKey;
+    pMainSec->removeKey = mainSec_removeKey;
+    pMainSec->setDefaultKeyId = mainSec_setDefaultKeyId;
+
+    pMainSec->pParent = pParent;
+    pMainSec->hReport = hReport;
+    pMainSec->hOs = hOs;
+
+    WLAN_REPORT_SM(pMainSec->hReport,RSN_MODULE_LOG, 
+                                  ("MainSec SM: config, authProtocol = %d, keyExchangeProtocol=%d, unicastSuite=%d, broadcastSuite=%d\n", 
+                    pInitData->pPaeConfig->authProtocol, pInitData->pPaeConfig->keyExchangeProtocol, 
+                    pInitData->pPaeConfig->unicastSuite, pInitData->pPaeConfig->broadcastSuite));
+
+    switch (pInitData->pPaeConfig->keyExchangeProtocol)
+    {
+    case RSN_KEY_MNG_NONE:
+        status = mainSecSmNull_config(pMainSec, pInitData->pPaeConfig);
+        break;
+    case RSN_KEY_MNG_802_1X:
+        status = mainSecKeysOnly_config(pMainSec, pInitData->pPaeConfig);
+        break;
+    default:
+        status = mainSecSmNull_config(pMainSec, pInitData->pPaeConfig);
+        break;
+    }
+
+    status  = mainKeys_config(pMainSec->pMainKeys, pInitData->pPaeConfig, pMainSec, pMainSec->hReport, pMainSec->hOs, 
+                           hCtrlData, hEvHandler, hConn, pMainSec->pParent);
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG,
+                          ("MAIN_SEC_SM: error in configuring mainKeys SM\n"));
+        return status;
+    }
+
+    WLAN_REPORT_SM(pMainSec->hReport, RSN_MODULE_LOG,
+                          ("MAIN_SEC_SM: successful configuration SM\n"));
+
+    return status;
+}
+
+/**
+*
+* mainSec_config
+*
+* \b Description: 
+*
+* Init main security state machine state machine
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSec_unload(mainSec_t *pMainSec)
+{
+    TI_STATUS   status;
+
+    if (pMainSec == NULL)
+    {
+        return NOK;
+    }
+
+    status = mainKeys_unload(pMainSec->pMainKeys);
+    if (status != OK)
+    {
+        /* report failure but don't stop... */
+        WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG,
+                          ("MAIN_SEC_SM: Error releasing Main Keys SM memory \n"));
+    }
+
+    status = fsm_Unload(pMainSec->hOs, pMainSec->pMainSecSm);
+    if (status != OK)
+    {
+        /* report failure but don't stop... */
+        WLAN_REPORT_ERROR(pMainSec->hReport, RSN_MODULE_LOG,
+                          ("MAIN_SEC_SM: Error releasing FSM memory \n"));
+    }
+
+    os_memoryFree(pMainSec->hOs, pMainSec, sizeof(mainSec_t));
+
+    return OK;
+}
+
+/**
+*
+* mainSec_setKey
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSec_setKey(struct _mainSec_t *pMainSec, securityKeys_t *pKey)
+{
+    TI_STATUS               status = OK;
+    
+    if ((pMainSec == NULL) || (pKey == NULL))
+    {
+        return NOK;
+    }
+
+    if (pKey->keyType != NULL_KEY)
+    {
+        WLAN_REPORT_INFORMATION(pMainSec->hReport, RSN_MODULE_LOG,
+                                ("MAIN_SEC_SM: setting key #%d, value = 0x%X 0x%X 0x%X 0x%X 0x%X\n",
+                                 pKey->keyIndex, (UINT8)pKey->encKey[0],
+                                 (UINT8)pKey->encKey[1],
+                                 (UINT8)pKey->encKey[2],
+                                 (UINT8)pKey->encKey[3],
+                                 (UINT8)pKey->encKey[4]));
+
+        status = pMainSec->pParent->setKey(pMainSec->pParent, pKey);
+    }
+    
+    return status;
+}
+
+/**
+*
+* mainSec_removeKey
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSec_removeKey(struct _mainSec_t *pMainSec, securityKeys_t *pKey)
+{
+    TI_STATUS               status = OK;
+    
+    if ((pMainSec == NULL) || (pKey == NULL))
+    {
+        return NOK;
+    }
+
+    if (pKey->keyType != NULL_KEY)
+    {
+        WLAN_REPORT_INFORMATION(pMainSec->hReport, RSN_MODULE_LOG,
+                                ("MAIN_SEC_SM: removing key #%d, \n",
+                                 pKey->keyIndex));
+
+        status = pMainSec->pParent->removeKey(pMainSec->pParent, pKey);
+    }
+    
+    return status;
+}
+
+/**
+*
+* mainSec_setDefaultKeyId
+*
+* \b Description: 
+*
+* Start the NULL main security SM. Reports success to the rsn module immediately.
+*
+* \b ARGS:
+*
+*  none
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS mainSec_setDefaultKeyId(struct _mainSec_t *pMainSec, UINT8 keyId)
+{
+    TI_STATUS               status = OK;
+
+    if (pMainSec == NULL)
+    {
+        return NOK;
+    }
+
+    status = pMainSec->pParent->setDefaultKeyId(pMainSec->pParent, keyId);
+    
+    return status;
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/rsn.c b/sta_dk_4_0_4_32/common/src/core/rsn/rsn.c
new file mode 100644 (file)
index 0000000..713b25c
--- /dev/null
@@ -0,0 +1,2109 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 rsn.c
+ *  \brief 802.11 rsniation SM source
+ *
+ *  \see rsnSM.h
+ */
+
+#include "osApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "utils.h"
+#include "report.h"
+#include "Ethernet.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl_prm.h"
+#include "DataCtrl_Api.h"
+#include "memMngrEx.h"
+#include "siteMgrApi.h"
+#include "smeApi.h"
+#include "mainSecSm.h"
+#include "admCtrl.h"
+#include "rsnApi.h"
+#include "rsn.h"
+#include "keyParser.h"
+#include "EvHandler.h"
+#include "TI_IPC_Api.h"
+#include "smeSmApi.h"
+#include "apConn.h"
+#include "802_11Defs.h"
+#include "public_infoele.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "admCtrlWpa.h"
+#include "excMngr.h"
+#include "admCtrlExc.h"
+#endif
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Global variables */
+
+/* Local function prototypes */
+TI_STATUS rsn_sendKeysNotSet(rsn_t *pRsn);
+void rsn_groupReKeyTimeout(TI_HANDLE hRsn);
+void rsn_micFailureReportTimeout(TI_HANDLE hRsn);
+static rsn_siteBanEntry_t * findEntryForInsert(TI_HANDLE hRsn);
+static rsn_siteBanEntry_t * findBannedSiteAndCleanup(TI_HANDLE hRsn, macAddress_t siteBssid);
+/* Comment out the call to clearBannedSiteList due to fail in WiFi mic attack test */
+/*static void clearBannedSiteList(TI_HANDLE hRsn);*/
+
+
+
+/* functions */
+
+/**
+*
+* rsn_Create - allocate memory for rsniation SM
+*
+* \b Description: 
+*
+* Allocate memory for rsniation SM. \n
+*       Allocates memory for Rsniation context. \n
+*       Allocates memory for rsniation timer. \n
+*       Allocates memory for rsniation SM matrix. \n
+*
+* \b ARGS:
+*
+*  I   - hOs - OS context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecKeysOnlyStop()
+*/
+TI_HANDLE rsn_create(TI_HANDLE hOs)
+{
+    rsn_t  *pRsn;
+
+    /* allocate rsniation context memory */
+    pRsn = (rsn_t*)os_memoryAlloc (hOs, sizeof(rsn_t));
+    if (pRsn == NULL)
+    {
+        return NULL;
+    }
+
+    os_memoryZero (hOs, pRsn, sizeof(rsn_t));
+    
+    /* create admission control */
+    pRsn->pAdmCtrl = admCtrl_create (hOs);
+    if (pRsn->pAdmCtrl == NULL)
+    {
+        os_memoryFree (hOs, pRsn, sizeof(rsn_t));
+        return NULL;
+    }
+
+    /* create main security SM */
+    pRsn->pMainSecSm = mainSec_create (hOs);
+    if (pRsn->pMainSecSm == NULL)
+    {
+        admCtrl_unload (pRsn->pAdmCtrl);
+        os_memoryFree (hOs, pRsn, sizeof(rsn_t));
+        return NULL;
+    }
+
+    pRsn->pKeyParser = pRsn->pMainSecSm->pKeyParser;
+    
+    pRsn->micFailureReportWaitTimer = os_timerCreate (hOs, rsn_micFailureReportTimeout, pRsn);
+    if (pRsn->micFailureReportWaitTimer == NULL)
+    {
+        mainSec_unload (pRsn->pMainSecSm);
+        admCtrl_unload (pRsn->pAdmCtrl);
+        os_memoryFree (hOs, pRsn, sizeof(rsn_t));
+        return NULL;
+    }
+    
+    pRsn->micFailureReKeyTimer = os_timerCreate (hOs, rsn_groupReKeyTimeout, pRsn);
+    if (pRsn->micFailureReKeyTimer == NULL)
+    {
+        os_timerDestroy (hOs, pRsn->micFailureReportWaitTimer);
+        mainSec_unload (pRsn->pMainSecSm);
+        admCtrl_unload (pRsn->pAdmCtrl);
+        os_memoryFree (hOs, pRsn, sizeof(rsn_t));
+        return NULL;
+    }
+    
+    pRsn->hOs = hOs;
+    
+    return pRsn;
+}
+
+
+/**
+*
+* rsn_Unload - unload rsniation SM from memory
+*
+* \b Description: 
+*
+* Unload rsniation SM from memory
+*
+* \b ARGS:
+*
+*  I   - hRsn - rsniation SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_mainSecKeysOnlyStop() 
+*/
+TI_STATUS rsn_unload (TI_HANDLE hRsn)
+{
+    rsn_t           *pRsn;
+    TI_STATUS       status;
+
+    if (hRsn == NULL)
+    {
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    os_timerStop (pRsn->hOs, pRsn->micFailureReportWaitTimer);
+    os_timerDestroy (pRsn->hOs, pRsn->micFailureReportWaitTimer);    
+    os_timerStop (pRsn->hOs, pRsn->micFailureReKeyTimer);
+    os_timerDestroy (pRsn->hOs, pRsn->micFailureReKeyTimer);
+    
+    status = admCtrl_unload (pRsn->pAdmCtrl);
+    status = mainSec_unload (pRsn->pMainSecSm);
+    
+    os_memoryFree (pRsn->hOs, hRsn, sizeof(rsn_t));
+
+    return status;
+}
+
+
+/**
+*
+* rsn_smConfig - configure a new rsniation SM
+*
+* \b Description: 
+*
+* Configure a new rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I   - hMlme - MLME SM context  \n
+*  I   - hSiteMgr - Site manager context  \n
+*  I   - hCtrlData - Control data context  \n
+*  I   - hTxData - TX data context  \n
+*  I   - hHalCtrl - Hal control context  \n
+*  I   - hReport - Report context  \n
+*  I   - hOs - OS context  \n
+*  I   - rsnTimeout - Rsniation SM timeout \n
+*  I   - rsnMaxCount - Max number of rsniation requests to send  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Create, rsn_Unload
+*/
+TI_STATUS rsn_config (TI_HANDLE         hRsn,
+                      TI_HANDLE         hTx,
+                      TI_HANDLE         hRx,
+                      TI_HANDLE         hConn,
+                      TI_HANDLE         hMlme,
+                      TI_HANDLE         hCtrlData,
+                      TI_HANDLE         hWhalCtrl,
+                      TI_HANDLE         hMemMgr,
+                      TI_HANDLE         hSiteMgr,
+                      TI_HANDLE         hReport,
+                      TI_HANDLE         hOs,
+                      TI_HANDLE         hExcMngr,
+                      TI_HANDLE         hPowerMgr,
+                      TI_HANDLE         hEvHandler,
+                      TI_HANDLE         hSmeSm,
+                      TI_HANDLE         hAPConn,
+                      rsnInitParams_t   *pInitParam)
+{
+    rsn_t       *pRsn;
+    TI_STATUS    status;
+    UINT8        keyIndex;
+
+    if (hRsn == NULL)
+    {
+        return NOK;
+    } 
+
+    pRsn = (rsn_t*)hRsn;
+
+    pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_FALSE;
+    pRsn->PrivacyOptionImplemented = TRUE;
+    
+    pRsn->hTx = hTx;
+    pRsn->hRx = hRx;
+    pRsn->hConn = hConn;
+    pRsn->hWhalCtrl = hWhalCtrl;
+    pRsn->hCtrlData = hCtrlData;
+    pRsn->hMemMgr = hMemMgr;
+    pRsn->hSiteMgr= hSiteMgr;
+    pRsn->hReport = hReport;
+    pRsn->hOs = hOs;
+    pRsn->hExcMngr = hExcMngr;
+    pRsn->hEvHandler = hEvHandler;
+    pRsn->hSmeSm = hSmeSm;
+    pRsn->hAPConn = hAPConn;
+
+    pRsn->setPaeConfig = rsn_setPaeConfig;
+    pRsn->getNetworkMode = rsn_getNetworkMode;
+    pRsn->setKey = rsn_setKey;
+    pRsn->removeKey = rsn_removeKey;
+    pRsn->reportStatus = rsn_reportStatus;
+    pRsn->setDefaultKeyId = rsn_setDefaultKeyId;
+    pRsn->defaultKeysOn = TRUE;
+    pRsn->eapType = OS_EAP_TYPE_NONE;
+    pRsn->numOfBannedSites = 0;
+
+    /* config the admission control with the authentication suite selected.
+       Admission control will configure the main security SM. */
+    status = admCtrl_config (pRsn->pAdmCtrl, hMlme, hRx, hReport, hOs, pRsn, hExcMngr, hPowerMgr, hEvHandler, pInitParam);
+    if (status != OK)
+    {
+        return status;
+    }            
+
+    /* Configure keys from registry */
+    if (pInitParam->privacyOn)
+    {
+        pRsn->wepStaticKey = TRUE;
+    }
+
+    pRsn->defaultKeyId = pInitParam->defaultKeyId;
+    for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
+    {
+        os_memoryCopy (hOs, &pRsn->keys[keyIndex], &pInitParam->keys[keyIndex], sizeof(securityKeys_t));
+        if (pRsn->keys[keyIndex].keyType != NULL_KEY)
+        {
+            pRsn->wepDefaultKeys[keyIndex] = TRUE;
+        }
+        pRsn->keys_en [keyIndex] = FALSE;
+    }
+
+    return status;
+}
+
+
+/**
+*
+* rsn_reconfig - re-configure a rsniation
+*
+* \b Description: 
+*
+* Re-configure rsniation 
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Create, rsn_Unload
+*/
+TI_STATUS rsn_reconfig (TI_HANDLE hRsn)
+{
+    rsn_t  *pRsn = (rsn_t *)hRsn;
+    UINT8   keyIndex;
+
+    /* Mark all keys as removed */
+    for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
+        pRsn->keys_en [keyIndex] = FALSE;       
+
+    return OK;
+}
+
+
+/** 
+*
+* rsn_setDefaultKeys - 
+*
+* \b Description: 
+*
+* 
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsn SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Stop, rsn_Recv
+*/
+TI_STATUS rsn_setDefaultKeys(rsn_t *pRsn)
+{
+    TI_STATUS       status = OK;
+    whalParamInfo_t whalParam;
+    UINT8           keyIndex;
+
+    for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
+    {
+        /* Set the WEP key to the HAL */
+        if (pRsn->wepDefaultKeys[keyIndex] /*pRsn->keys[keyIndex].encLen>0*/)
+        {
+            /* Change key type to WEP-key before setting*/
+            pRsn->keys[keyIndex].keyType = WEP_KEY;
+
+            status = pRsn->pMainSecSm->setKey (pRsn->pMainSecSm, &pRsn->keys[keyIndex]);
+
+            if (status != OK)
+            {
+                WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG,
+                                  ("RSN: Setting key #%d failed \n", keyIndex));
+                return status;
+            }
+        }
+    }
+
+    /* Now we configure default key ID to the HAL */
+    if (pRsn->defaultKeyId < MAX_KEYS_NUM)
+    {
+        whalParam.paramType = HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM;
+        whalParam.content.configureCmdCBParams.CB_buf = &pRsn->defaultKeyId;
+        whalParam.content.configureCmdCBParams.CB_Func = NULL;
+        whalParam.content.configureCmdCBParams.CB_handle = NULL;
+        status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam); 
+
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
+                           ("RSN: default key ID =%d \n", pRsn->defaultKeyId));
+    }
+
+    return status;
+}
+
+
+/** 
+*
+* rsn_Start - Start event for the rsniation SM
+*
+* \b Description: 
+*
+* Start event for the rsniation SM
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Stop, rsn_Recv
+*/
+TI_STATUS rsn_start(TI_HANDLE hRsn)
+{
+    TI_STATUS           status;
+    rsn_t               *pRsn;
+    cipherSuite_e       suite;
+    externalAuthMode_e  extAuthMode;
+    whalParamInfo_t     whalParam;
+
+    pRsn = (rsn_t*)hRsn;
+
+    if (pRsn == NULL)
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_start ...\n"));
+
+    pRsn->rsnStartedTs = os_timeStampMs (pRsn->hOs);
+
+    status = pRsn->pMainSecSm->start (pRsn->pMainSecSm);
+    /* Set keys that need to be set */
+    pRsn->defaultKeysOn = FALSE;
+    pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &suite);
+    pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &extAuthMode);
+
+    if (pRsn->wepStaticKey && ((suite == RSN_CIPHER_WEP) || (suite == RSN_CIPHER_CKIP)))
+    {   /* set default WEP keys */
+        status = rsn_sendKeysNotSet (pRsn);
+        pRsn->eapType = OS_EAP_TYPE_NONE;
+    }
+    else if (suite == RSN_CIPHER_NONE && extAuthMode != RSN_EXT_AUTH_MODE_OPEN)
+    {   /* remove previously WEP key for SHARED */
+        pRsn->wepStaticKey = FALSE;
+        status = rsn_removedDefKeys (pRsn);
+
+        /* Set None to HAL */
+        whalParam.paramType = HAL_CTRL_RSN_SECURITY_MODE_PARAM;
+        whalParam.content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)RSN_CIPHER_NONE;
+        status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
+
+    }
+    else if (suite==RSN_CIPHER_NONE)
+    {
+        pRsn->eapType = OS_EAP_TYPE_NONE;
+    }
+
+    return status;
+}
+
+
+TI_STATUS rsn_sendKeysNotSet(rsn_t *pRsn)
+{
+    UINT8           keyIndex;
+    OS_802_11_KEY   rsnOsKey;
+    TI_STATUS       status = OK;
+    
+    for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
+    {
+        if (pRsn->wepDefaultKeys[keyIndex])
+        {
+            rsnOsKey.KeyIndex  = pRsn->keys[keyIndex].keyIndex;
+            rsnOsKey.KeyLength = pRsn->keys[keyIndex].encLen;
+            rsnOsKey.Length    = sizeof(rsnOsKey);
+
+            /* Change key type to WEP-key before setting*/
+            pRsn->keys[keyIndex].keyType = WEP_KEY;
+
+            os_memoryCopy (pRsn->hOs, rsnOsKey.BSSID, 
+                           (void *)pRsn->keys[keyIndex].macAddress.addr, 
+                           MAC_ADDR_LEN);
+            os_memoryCopy (pRsn->hOs, &rsnOsKey.KeyRSC, 
+                           (void *)pRsn->keys[keyIndex].keyRsc, 
+                           KEY_RSC_LEN);
+            os_memoryCopy (pRsn->hOs, rsnOsKey.KeyMaterial, 
+                           (void *)pRsn->keys[keyIndex].encKey, 
+                           MAX_KEY_LEN /*pRsn->keys[keyIndex].encLen*/);
+           
+            /* Set WEP transmit key mask on the default key */
+            if (keyIndex == pRsn->defaultKeyId)
+            {
+                rsnOsKey.KeyIndex |= 0x80000000;
+            }
+
+            status = pRsn->pKeyParser->recv (pRsn->pKeyParser, (UINT8*)&rsnOsKey, sizeof(rsnOsKey));
+        }
+    }
+
+    return status;
+}
+
+
+TI_STATUS rsn_removedDefKeys (TI_HANDLE hRsn)
+{
+    UINT8  keyIndex;
+    rsn_t  *pRsn = (rsn_t*)hRsn;
+    
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                            ("rsn_removedDefKeys Enter \n"));
+    
+    for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
+    {
+        securityKeys_t   key;
+
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                ("rsn_removedDefKeys, Remove keyId=%d\n", keyIndex));
+       
+               pRsn->wepDefaultKeys[keyIndex] = FALSE;
+        os_memoryCopy (pRsn->hOs, &key, &pRsn->keys[keyIndex], sizeof(securityKeys_t));
+        pRsn->removeKey (pRsn, &key);
+       
+        /* Set WEP transmit key mask on the default key */
+        if (keyIndex == pRsn->defaultKeyId)
+        {
+            pRsn->defaultKeyId = 0;
+        }
+    }
+       /* Clear the band site list */
+    /* Comment out the call to clearBannedSiteList due to fail in WiFi mic attack test */
+    /*clearBannedSiteList(hRsn);*/
+
+    return OK;
+}
+
+
+/**
+*
+* rsn_Stop - Stop event for the rsniation SM
+*
+* \b Description: 
+*
+* Stop event for the rsniation SM
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Recv
+*/
+TI_STATUS rsn_stop (TI_HANDLE hRsn, BOOL removeKeys)
+{
+    TI_STATUS        status;
+    rsn_t           *pRsn;
+    UINT8            keyIndex;
+    securityKeys_t   key;
+
+    pRsn = (rsn_t*)hRsn;
+
+    if (pRsn == NULL)
+    {
+        return NOK;
+    }
+    
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                            ("RSN: calling STOP... removeKeys=%d\n", removeKeys));
+
+    for (keyIndex = 0; keyIndex < MAX_KEYS_NUM; keyIndex++)
+    {
+        os_memoryCopy (pRsn->hOs, &key, &pRsn->keys[keyIndex], sizeof(securityKeys_t));
+
+        if (!pRsn->wepDefaultKeys[keyIndex])
+        {      /* Remove only dynamic keys. Default keys are removed by calling: rsn_removedDefKeys() */
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                    ("rsn_stop, Remove keyIndex=%d, key.keyIndex=%d\n",keyIndex, key.keyIndex));
+            
+            WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)key.macAddress.addr, 6);
+
+            pRsn->removeKey (pRsn, &key);
+        }
+
+    }
+
+    os_timerStop (pRsn->hOs, pRsn->micFailureReportWaitTimer);
+
+    /* Stop the pre-authentication timer in case we are disconnecting */
+    os_timerStop (pRsn->hOs, pRsn->pAdmCtrl->preAuthTimerWpa2);
+
+    status = pRsn->pMainSecSm->stop (pRsn->pMainSecSm);
+
+    pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_FALSE;
+    pRsn->defaultKeysOn = TRUE;
+
+    if (removeKeys)
+    {   /* reset PMKID list if exist */
+        pRsn->pAdmCtrl->resetPmkidList (pRsn->pAdmCtrl);
+    }
+
+    return status;
+}
+
+
+/**
+*
+* rsn_GetParam - Get a specific parameter from the rsniation SM
+*
+* \b Description: 
+*
+* Get a specific parameter from the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_getParam(TI_HANDLE hRsn, paramInfo_t *pParam)
+{
+    rsn_t      *pRsn;
+    TI_STATUS   status = OK;
+
+    pRsn = (rsn_t*)hRsn;
+
+    if ((pRsn == NULL) || (pParam == NULL))
+    {
+        return NOK;
+    }
+
+    switch (pParam->paramType)
+    {
+    case RSN_PRIVACY_OPTION_IMPLEMENTED_PARAM:
+        pParam->content.rsnPrivacyOptionImplemented = TRUE;
+        break;
+
+    case RSN_KEY_PARAM:
+        pParam->content.pRsnKey = &pRsn->keys[pParam->content.pRsnKey->keyIndex];
+        if (pParam->content.pRsnKey->keyIndex == pRsn->defaultKeyId)
+        {
+            pParam->content.pRsnKey->keyIndex |= 0x80000000;
+            WLAN_REPORT_WARNING(pRsn->hReport, RSN_MODULE_LOG,  ("default Key: %d\n", pRsn->defaultKeyId));
+        }
+        break;
+
+    case RSN_SECURITY_STATE_PARAM:
+        status = pRsn->pMainSecSm->getAuthState (pRsn->pMainSecSm, (TIWLN_SECURITY_STATE*)&(pParam->content.rsnAuthState));
+        break;
+
+    case RSN_ENCRYPTION_STATUS_PARAM: 
+        status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &pParam->content.rsnEncryptionStatus);
+        break;
+
+    case RSN_EXT_AUTHENTICATION_MODE:
+        status = pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &pParam->content.rsnExtAuthneticationMode);
+        break;
+
+    case RSN_MIXED_MODE:
+        status = pRsn->pAdmCtrl->getMixedMode (pRsn->pAdmCtrl, &pParam->content.rsnMixedMode);
+        break;
+
+    case RSN_AUTH_ENCR_CAPABILITY:
+        status = pRsn->pAdmCtrl->getAuthEncrCap(pRsn->pAdmCtrl, pParam->content.pRsnAuthEncrCapability);
+        break;
+
+    case RSN_PMKID_LIST:
+        pParam->content.rsnPMKIDList.Length = pParam->paramLength;
+        status = pRsn->pAdmCtrl->getPmkidList (pRsn->pAdmCtrl, &pParam->content.rsnPMKIDList);
+        pParam->paramLength = pParam->content.rsnPMKIDList.Length + 2 * sizeof(UINT32);
+        break;
+
+    case RSN_PRE_AUTH_STATUS:
+        {
+            UINT8 cacheIndex;
+        
+            pParam->content.rsnPreAuthStatus = pRsn->pAdmCtrl->getPreAuthStatus (pRsn->pAdmCtrl, &pParam->content.rsnApMac, &cacheIndex);
+        }
+        break;
+
+    case  RSN_WPA_PROMOTE_AVAILABLE_OPTIONS:
+        status = pRsn->pAdmCtrl->getWPAMixedModeSupport (pRsn->pAdmCtrl, &pParam->content.rsnWPAMixedModeSupport);
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                               ("RSN: Get WPA Mixed MODE support  %d \n",pParam->content.rsnWPAMixedModeSupport));
+        break;
+
+    case RSN_WPA_PROMOTE_OPTIONS:
+        status = pRsn->pAdmCtrl->getPromoteFlags (pRsn->pAdmCtrl, 
+                                                  &pParam->content.rsnWPAPromoteFlags);
+                WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                               ("RSN: Get WPA promote flags  %d \n",pParam->content.rsnWPAPromoteFlags));
+        
+        break;
+
+#ifdef EXC_MODULE_INCLUDED
+    case RSN_EXC_NETWORK_EAP:
+        status = pRsn->pAdmCtrl->getNetworkEap (pRsn->pAdmCtrl, &pParam->content.networkEap);
+        break;
+#endif
+    case RSN_EAP_TYPE:
+        pParam->content.eapType = pRsn->eapType;
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                          ("RSN: Get RSN_EAP_TYPE eapType  %d \n", 
+                          pParam->content.eapType));  
+        break;
+
+    case WPA_801_1X_AKM_EXISTS:
+
+        status = pRsn->pAdmCtrl->get802_1x_AkmExists(pRsn->pAdmCtrl, &pParam->content.wpa_802_1x_AkmExists);
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                          ("RSN: Get WPA_801_1X_AKM_EXISTS  %d \n", 
+                          pParam->content.wpa_802_1x_AkmExists));  
+        break;
+
+    case RSN_DEFAULT_KEY_ID:
+        pParam->content.rsnDefaultKeyID = pRsn->defaultKeyId;
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+            ("RSN: Get RSN_DEFAULT_KEY_ID  %d \n", 
+            pParam->content.rsnDefaultKeyID));
+        break;
+
+    default:
+        return NOK;
+    }
+    
+    return status;
+}
+
+
+/**
+*
+* rsn_SetParam - Set a specific parameter to the rsniation SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_setParam (TI_HANDLE hRsn, paramInfo_t *pParam)
+{
+    rsn_t               *pRsn;
+    TI_STATUS           status=OK;
+    whalParamInfo_t     whalParam;
+
+    pRsn = (rsn_t*)hRsn;
+
+    if ((pRsn == NULL) || (pParam == NULL))
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                          ("RSN: Set rsn_setParam   %X \n", 
+                          pParam->paramType));
+
+    switch (pParam->paramType)
+    {
+
+    case RSN_DEFAULT_KEY_ID:
+    {
+        UINT8  defKeyId, i;
+
+        defKeyId = pParam->content.rsnDefaultKeyID;
+        
+        if(defKeyId >= MAX_KEYS_NUM)
+        {
+            WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG, 
+                    ("RSN: Error - the value of the default Key Id  is incorrect \n"));
+            return NOK;
+        }
+
+        /* Clean transmit flag (1 in the bit31) in the previous default key */
+        for(i = 0; i < MAX_KEYS_NUM; i++)
+        {
+            pRsn->keys[i].keyIndex &= 0x7FFFFFFF;
+        }
+
+        /* Set the default key ID value in the RSN data structure */ 
+        pRsn->defaultKeyId = defKeyId;
+
+        /* Set the default key ID in the HAL */
+        whalParam.paramType = HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM;
+        whalParam.content.configureCmdCBParams.CB_buf = &pRsn->defaultKeyId;
+        whalParam.content.configureCmdCBParams.CB_Func = NULL;
+        whalParam.content.configureCmdCBParams.CB_handle = NULL;
+        status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam); 
+
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
+                        ("RSN: default key ID =%d \n", pRsn->defaultKeyId));
+
+
+        status = RE_SCAN_NEEDED;
+        break;
+    }
+
+    case RSN_ADD_KEY_PARAM:
+    {
+        UINT8           keyIndex, i = 0;
+        cipherSuite_e   cipherSuite;
+
+        status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &cipherSuite);
+        if (status !=OK)
+        {
+            return status;
+        }
+        
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                      ("RSN: Set RSN_ADD_KEY_PARAM KeyIndex  %x , keyLength=%d\n", 
+                      pParam->content.rsnOsKey.KeyIndex,pParam->content.rsnOsKey.KeyLength));
+        keyIndex = (UINT8)pParam->content.rsnOsKey.KeyIndex;
+        if (keyIndex >= MAX_KEYS_NUM)
+        {
+            return NOK;
+        }
+       
+        status = pRsn->pKeyParser->recv (pRsn->pKeyParser, (UINT8*)&pParam->content.rsnOsKey, sizeof(pParam->content.rsnOsKey));
+
+        if (status==STATUS_BAD_KEY_PARAM)
+        {
+            return NOK;
+        }
+        /* If the Key is not BAD, it may be that WEP key is sent before WEP status is set, 
+            save the key, and set it later at rsn_start */
+         pRsn->keys[keyIndex].keyIndex = pParam->content.rsnOsKey.KeyIndex;
+         pRsn->keys[keyIndex].encLen = pParam->content.rsnOsKey.KeyLength;
+         os_memoryCopy (pRsn->hOs, (void *)pRsn->keys[keyIndex].macAddress.addr, pParam->content.rsnOsKey.BSSID, MAC_ADDR_LEN);
+         os_memoryCopy (pRsn->hOs, (void *)pRsn->keys[keyIndex].keyRsc, (UINT8*)&(pParam->content.rsnOsKey.KeyRSC), KEY_RSC_LEN);
+         os_memoryCopy (pRsn->hOs, (void *)pRsn->keys[keyIndex].encKey, pParam->content.rsnOsKey.KeyMaterial, MAX_KEY_LEN);
+           
+        /* Process the transmit flag (31-st bit of keyIndex).        */
+        /* If the added key has the TX bit set to TRUE (i.e. the key */
+        /* is the new transmit key (default key), update             */
+        /* RSN data def.key Id and clean this bit in all other keys  */
+        if (pParam->content.rsnOsKey.KeyIndex & 0x80000000)
+        {
+            pRsn->defaultKeyId = keyIndex;
+            
+            for (i = 0; i < MAX_KEYS_NUM; i ++)
+            {
+                if (i != keyIndex)
+                {
+                    pRsn->keys[i].keyIndex &= 0x7FFFFFFF;
+                }
+            }
+        }
+        
+        if (pRsn->defaultKeysOn)
+        {   /* This is a WEP default key */
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                         ("RSN_ADD_KEY_PARAM, Default key configured - keyIndex=%d-TRUE\n", keyIndex));
+
+            pRsn->wepDefaultKeys[keyIndex] = TRUE;
+            pRsn->wepStaticKey = TRUE;
+            status = OK;
+        }
+        break;
+    }
+    case RSN_REMOVE_KEY_PARAM:
+    {
+        UINT8           keyIndex;
+        cipherSuite_e   cipherSuite;
+
+        status = pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &cipherSuite);
+        if (status !=OK)
+        {
+            return status;
+        }
+        /*if (cipherSuite == RSN_CIPHER_NONE)
+        {
+            WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG, 
+                          ("RSN: Error Remove Wep/Key when no encryption \n"));
+            return NOK;
+        }*/
+
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                      ("RSN: Set RSN_REMOVE_KEY_PARAM KeyIndex  %x \n", 
+                      pParam->content.rsnOsKey.KeyIndex));
+        keyIndex = (UINT8)pParam->content.rsnOsKey.KeyIndex;
+        if (keyIndex >= MAX_KEYS_NUM)
+        {
+            return NOK;
+        }
+        
+        status = pRsn->pKeyParser->remove (pRsn->pKeyParser, 
+                                           (UINT8*)&pParam->content.rsnOsKey, 
+                                           sizeof(pParam->content.rsnOsKey));
+
+        if (status == OK)
+        {
+            pRsn->keys[keyIndex].keyType = NULL_KEY;
+            pRsn->keys[keyIndex].keyIndex &= 0x000000FF;
+        }
+
+        break;
+    }
+    
+    case RSN_ENCRYPTION_STATUS_PARAM: 
+        {
+            cipherSuite_e   cipherSuite;
+
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                              ("RSN: Set RSN_ENCRYPTION_STATUS_PARAM rsnEncryptionStatus  %d \n", 
+                              pParam->content.rsnEncryptionStatus));
+
+            pRsn->pAdmCtrl->getCipherSuite (pRsn->pAdmCtrl, &cipherSuite);
+            if (cipherSuite != pParam->content.rsnEncryptionStatus)
+            {
+                status = pRsn->pAdmCtrl->setUcastSuite (pRsn->pAdmCtrl, pParam->content.rsnEncryptionStatus);
+                status = pRsn->pAdmCtrl->setBcastSuite (pRsn->pAdmCtrl, pParam->content.rsnEncryptionStatus);
+                WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (" status = %d \n", status));
+            }
+            pRsn->defaultKeysOn = TRUE;
+        }
+        break;
+
+    case RSN_EXT_AUTHENTICATION_MODE:
+        {
+            externalAuthMode_e  extAuthMode;
+
+            pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &extAuthMode);
+            if (pParam->content.rsnExtAuthneticationMode!=extAuthMode)
+            {
+                WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                  ("RSN: Set RSN_EXT_AUTHENTICATION_MODE rsnExtAuthneticationMode  %d \n", 
+                                  pParam->content.rsnExtAuthneticationMode));  
+                
+                /*WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                        ("RSN: remove all Keys\n"));
+
+                for (keyIndex=0; keyIndex<MAX_KEYS_NUM; keyIndex++)
+                {
+                    os_memoryCopy(pRsn->hOs, &key, &pRsn->keys[keyIndex], sizeof(securityKeys_t));
+                    pRsn->removeKey(pRsn, &key);
+
+                }*/
+
+                status = pRsn->pAdmCtrl->setExtAuthMode (pRsn->pAdmCtrl, pParam->content.rsnExtAuthneticationMode);
+            }
+            pRsn->defaultKeysOn = TRUE;
+        }
+        break;
+
+#ifdef EXC_MODULE_INCLUDED
+    case RSN_EXC_NETWORK_EAP:
+        {
+            OS_EXC_NETWORK_EAP      networkEap;
+
+            pRsn->pAdmCtrl->getNetworkEap (pRsn->pAdmCtrl, &networkEap);
+            if (networkEap != pParam->content.networkEap)
+            {
+                WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                      ("RSN: Set RSN_EXC_NETWORK_EAP networkEap  %d \n", 
+                                      pParam->content.networkEap));  
+                
+                status = pRsn->pAdmCtrl->setNetworkEap (pRsn->pAdmCtrl, pParam->content.networkEap);
+                if (status == OK) 
+                {
+                    /*status = RE_SCAN_NEEDED;*/
+                }
+            }
+        }
+        break;
+#endif
+    case RSN_MIXED_MODE:
+        {
+            BOOL mixedMode;
+        
+            pRsn->pAdmCtrl->getMixedMode (pRsn->pAdmCtrl, &mixedMode);
+            if (mixedMode!=pParam->content.rsnMixedMode)
+            {
+                status = pRsn->pAdmCtrl->setMixedMode (pRsn->pAdmCtrl, pParam->content.rsnMixedMode);
+                
+                WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                  ("RSN: Set RSN_MIXED_MODE mixedMode  %d, status=%d \n",
+                                   pParam->content.rsnMixedMode, status));
+            }
+            break;
+        }
+
+    case RSN_PMKID_LIST:
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                               ("RSN: Set RSN_PMKID_LIST \n"));
+
+        WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                               (UINT8*)&pParam->content.rsnPMKIDList ,pParam->content.rsnPMKIDList.Length);
+         status = pRsn->pAdmCtrl->setPmkidList (pRsn->pAdmCtrl, 
+                                                &pParam->content.rsnPMKIDList);
+         if(status == OK)
+         {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                  ("RSN: Set RSN_PMKID_LIST:   %d PMKID entries has been added to the cache.\n",
+                                   pParam->content.rsnPMKIDList.BSSIDInfoCount));
+         }
+         else
+         {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                  ("RSN: Set RSN_PMKID_LIST failure"));
+         }
+        break;
+
+    case RSN_WPA_PROMOTE_OPTIONS:
+         status = pRsn->pAdmCtrl->setPromoteFlags (pRsn->pAdmCtrl, 
+                                                   pParam->content.rsnWPAPromoteFlags);
+         if(status == OK)
+         {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+             ("RSN: Set WPA promote options:  %d \n", pParam->content.rsnWPAPromoteFlags));
+         }
+         else
+         {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                  ("RSN: Set WPA promote options failure"));
+         }
+        break;
+
+    case RSN_EAP_TYPE:
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                          ("RSN: Set RSN_EAP_TYPE eapType  %d \n", 
+                          pParam->content.eapType));  
+
+        pRsn->eapType = pParam->content.eapType;
+               pRsn->defaultKeysOn = TRUE;
+        break;
+
+    default:
+        return NOK;
+    }
+
+    return status;
+}
+
+
+/**
+*
+* rsn_eventRecv - Set a specific parameter to the rsniation SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_reportStatus (rsn_t *pRsn, TI_STATUS rsnStatus)
+{
+    TI_STATUS           status = OK;
+    paramInfo_t         param;
+    externalAuthMode_e  extAuthMode;
+
+    if (pRsn == NULL)
+    {
+        return NOK;
+    }
+    
+    if (rsnStatus == OK)
+    {
+        /* set EAPOL encryption status according to authentication protocol */
+        pRsn->rsnCompletedTs = os_timeStampMs (pRsn->hOs);
+        
+        status = pRsn->pAdmCtrl->getExtAuthMode (pRsn->pAdmCtrl, &extAuthMode);
+        if (status != OK)
+        {
+            return status;
+        }
+
+        if (extAuthMode >= RSN_EXT_AUTH_MODE_WPA)
+        {
+            param.content.txDataEapolEncryptionStatus = TRUE;
+        } else {
+            param.content.txDataEapolEncryptionStatus = FALSE;
+        }
+
+        param.paramType = TX_DATA_EAPOL_ENCRYPTION_STATUS_PARAM;
+        txData_setParam (pRsn->hTx, &param);
+        
+        /* set WEP invoked mode according to cipher suite */
+        switch (pRsn->paeConfig.unicastSuite)
+        {
+        case RSN_CIPHER_NONE:
+            param.content.txDataCurrentPrivacyInvokedMode = FALSE;
+            break;
+        
+        default:
+            param.content.txDataCurrentPrivacyInvokedMode = TRUE;
+            break;
+        }
+
+        param.paramType = TX_DATA_CURRENT_PRIVACY_INVOKE_MODE_PARAM;
+        txData_setParam (pRsn->hTx, &param);
+        /* The value of exclude unencrypted should be as privacy invoked */
+        param.paramType = RX_DATA_EXCLUDE_UNENCRYPTED_PARAM;
+        rxData_setParam (pRsn->hRx, &param);
+        
+        param.paramType = RX_DATA_EXCLUDE_BROADCAST_UNENCRYPTED_PARAM;
+        if (pRsn->pAdmCtrl->mixedMode)
+        {   /* do not exclude Broadcast packets */
+            param.content.txDataCurrentPrivacyInvokedMode = FALSE;
+        }
+        rxData_setParam (pRsn->hRx, &param);
+    } 
+
+    else 
+        rsnStatus = (TI_STATUS)STATUS_SECURITY_FAILURE;
+
+    status = conn_reportRsnStatus (pRsn->hConn, (mgmtStatus_e)rsnStatus);
+
+    if (status!=OK)
+    {
+        return status;
+    }
+    
+    if (rsnStatus == OK)
+    {
+        EvHandlerSendEvent (pRsn->hEvHandler, IPC_EVENT_AUTH_SUCC, NULL, 0);
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                          ("RSN: rsn_reportStatus \n"));
+
+    return OK;
+}
+
+
+/**
+*
+* rsn_eventRecv - Set a specific parameter to the rsniation SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_setPaeConfig(rsn_t *pRsn, rsn_paeConfig_t *pPaeConfig)
+{
+    TI_STATUS           status;
+    mainSecInitData_t   initData;
+
+    if ((pRsn == NULL) || (pPaeConfig == NULL))
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                            ("RSN: Calling set PAE config..., unicastSuite = %d, broadcastSuite = %d \n", 
+                             pPaeConfig->unicastSuite, pPaeConfig->broadcastSuite));
+    
+    os_memoryCopy(pRsn->hOs, &pRsn->paeConfig, pPaeConfig, sizeof(rsn_paeConfig_t));
+
+    initData.pPaeConfig = &pRsn->paeConfig;
+
+    status = mainSec_config (pRsn->pMainSecSm, 
+                             &initData, 
+                             pRsn, 
+                             pRsn->hReport, 
+                             pRsn->hOs, 
+                             pRsn->hCtrlData,
+                             pRsn->hEvHandler, 
+                             pRsn->hConn, 
+                             pRsn->hWhalCtrl);
+
+    return status;
+}
+
+
+/**
+*
+* rsn_eventRecv - Set a specific parameter to the rsniation SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_getNetworkMode(rsn_t *pRsn, rsn_networkMode_t *pNetMode)
+{
+    paramInfo_t     param;
+    TI_STATUS       status;
+
+    param.paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;
+
+    status =  ctrlData_getParam (pRsn->hCtrlData, &param);
+
+    if (status == OK)
+    {
+        if (param.content.ctrlDataCurrentBssType == BSS_INFRASTRUCTURE)
+        {
+            *pNetMode = RSN_INFRASTRUCTURE;
+        } 
+        else 
+        {
+            *pNetMode = RSN_IBSS;
+        }
+    }
+    else 
+    {
+        return NOK;
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* rsn_eventRecv - Set a specific parameter to the rsniation SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_evalSite(TI_HANDLE hRsn, rsnData_t *pRsnData, bssType_e bssType, macAddress_t bssid, UINT32 *pMetric)
+{
+    rsn_t       *pRsn;
+    TI_STATUS       status;
+
+    if ((pRsnData == NULL) || (hRsn == NULL))
+    {
+        *pMetric = 0;
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    if (rsn_isSiteBanned(hRsn, bssid) == TRUE)
+    {
+        *pMetric = 0;
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site is banned!\n", __FUNCTION__));
+        return NOK;
+    }
+
+    status = pRsn->pAdmCtrl->evalSite (pRsn->pAdmCtrl, pRsnData, bssType, pMetric);
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: pMetric=%d status=%d\n", __FUNCTION__, *pMetric, status));
+
+    return status;
+}
+
+
+/**
+*
+* rsn_getInfoElement - 
+*
+* \b Description: 
+*
+* Get the RSN information element.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsn SM context  \n
+*  I/O - pRsnIe - Pointer to the return information element \n
+*  I/O - pRsnIeLen - Pointer to the returned IE's length \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS rsn_getInfoElement(TI_HANDLE hRsn, UINT8 *pRsnIe, UINT8 *pRsnIeLen)
+{
+    rsn_t       *pRsn;
+    TI_STATUS   status;
+
+    if ((hRsn == NULL) || (pRsnIe == NULL) || (pRsnIeLen == NULL))
+    {
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    status = pRsn->pAdmCtrl->getInfoElement (pRsn->pAdmCtrl, pRsnIe, pRsnIeLen);
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_getInfoElement pRsnIeLen= %d\n",*pRsnIeLen));
+
+    return status;   
+}
+
+
+#ifdef EXC_MODULE_INCLUDED
+/**
+*
+* rsn_getExcExtendedInfoElement - 
+*
+* \b Description: 
+*
+* Get the Aironet information element.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsn SM context  \n
+*  I/O - pRsnIe - Pointer to the return information element \n
+*  I/O - pRsnIeLen - Pointer to the returned IE's length \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS rsn_getExcExtendedInfoElement(TI_HANDLE hRsn, UINT8 *pRsnIe, UINT8 *pRsnIeLen)
+{
+    rsn_t       *pRsn;
+    TI_STATUS   status;
+
+    if ((hRsn == NULL) || (pRsnIe == NULL) || (pRsnIeLen == NULL))
+    {
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    status = admCtrlExc_getInfoElement (pRsn->pAdmCtrl, pRsnIe, pRsnIeLen);
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_getExcExtendedInfoElement pRsnIeLen= %d\n",*pRsnIeLen));
+
+    return status;    
+}
+#endif
+
+
+/**
+*
+* rsn_eventRecv - Set a specific parameter to the rsniation SM
+*
+* \b Description: 
+*
+* Set a specific parameter to the rsniation SM.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pParam - Parameter \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa rsn_Start, rsn_Stop
+*/
+TI_STATUS rsn_setSite(TI_HANDLE hRsn, rsnData_t *pRsnData, UINT8 *pAssocIe, UINT8 *pAssocIeLen)
+{
+    rsn_t      *pRsn;
+    TI_STATUS   status;
+
+    if ((pRsnData == NULL) || (hRsn == NULL))
+    {
+        *pAssocIeLen = 0;
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    status = pRsn->pAdmCtrl->setSite (pRsn->pAdmCtrl, pRsnData, pAssocIe, pAssocIeLen);
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_setSite ieLen= %d\n",pRsnData->ieLen));
+    return status;
+}
+
+
+TI_STATUS rsn_setKey (rsn_t *pRsn, securityKeys_t *pKey)
+{
+    TI_STATUS           status = OK;
+    whalParamInfo_t     whalParam;
+    paramInfo_t         param;
+    UINT8               keyIndex;
+       BOOL                            macIsBroadcast = FALSE;
+
+    keyIndex = (UINT8)pKey->keyIndex;
+    if ((pRsn == NULL) || (pKey == NULL) || (keyIndex >= MAX_KEYS_NUM))
+    {
+        return NOK;
+    }
+
+    /* 
+     * In full driver we use only WEP default keys. That's why we make sure that the macAddress is cleared.
+     * In GWSI we use WEP mapping key if the macAddress is not NULL.
+     */
+    if (pKey->keyType == WEP_KEY)
+    {
+        os_memoryZero(pRsn->hOs,(void*)pKey->macAddress.addr,
+           sizeof(macAddress_t)); 
+    }
+
+    if (pKey->keyType != NULL_KEY)
+    {
+        /* set the size to reserve for encryption to the tx */
+        /* update this parameter only in accordance with pairwise key setting */
+        if (!MAC_BROADCAST((&pKey->macAddress)))
+        {
+            param.paramType = TX_DATA_ENCRYPTION_FIELD_SIZE;
+            switch (pKey->keyType)
+            {
+                case TKIP_KEY:
+                    param.content.txDataEncryptionFieldSize = IV_FIELD_SIZE;
+                    break;
+                case AES_KEY:
+                    param.content.txDataEncryptionFieldSize = AES_AFTER_HEADER_FIELD_SIZE;
+                    break;
+                case NULL_KEY:
+                case WEP_KEY:
+                case EXC_KEY:
+                default:
+                    param.content.txDataEncryptionFieldSize = 0;
+                    break;
+            }
+
+            txData_setParam (pRsn->hTx, &param);
+        }
+               macIsBroadcast = MAC_BROADCAST((&pKey->macAddress));
+               if ((pRsn->keys[keyIndex].keyType != NULL_KEY )&&
+                       macIsBroadcast && !MAC_BROADCAST((&pRsn->keys[keyIndex].macAddress)))
+               {       /* In case a new Group key is set instead of a Unicast key, 
+                               first remove the UNIcast key from FW */
+                       rsn_removeKey(pRsn, &pRsn->keys[keyIndex]);
+               }
+        pRsn->keys[keyIndex].keyType = pKey->keyType;
+               pRsn->keys[keyIndex].keyIndex = keyIndex;
+        whalParam.paramType = HAL_CTRL_RSN_KEY_ADD_PARAM;
+        whalParam.content.configureCmdCBParams.CB_buf = (UINT8*) pKey;
+        whalParam.content.configureCmdCBParams.CB_Func = NULL;
+        whalParam.content.configureCmdCBParams.CB_handle = NULL;
+
+        if (macIsBroadcast)
+        {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                                    ("RSN: rsn_setKey, Group ReKey timer started\n"));
+            os_timerStop (pRsn->hOs, pRsn->micFailureReKeyTimer);
+            os_timerStart (pRsn->hOs, pRsn->micFailureReKeyTimer, RSN_MIC_FAILURE_RE_KEY, FALSE);
+            pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_TRUE;
+        }
+        /* Mark key as added */
+        pRsn->keys_en [keyIndex] = TRUE;
+
+        status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
+    }
+    
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                            ("RSN: rsn_setKey, KeyType=%d, KeyId = 0x%lx,encLen=0x%x\n",
+                             pKey->keyType,pKey->keyIndex, pKey->encLen));
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nEncKey = "));
+
+    WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->encKey, pKey->encLen);
+
+    if (pKey->keyType != WEP_KEY)
+    { 
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nMac address = "));
+        WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->macAddress.addr, MAC_ADDR_LEN);
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nRSC = "));
+        WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->keyRsc, KEY_RSC_LEN);
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nMic RX = "));
+        WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->micRxKey, MAX_KEY_LEN);
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("\nMic TX = "));
+        WLAN_REPORT_HEX_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, (UINT8 *)pKey->micTxKey, MAX_KEY_LEN);
+    }
+
+    return status; 
+}
+
+
+TI_STATUS rsn_removeKey (rsn_t *pRsn, securityKeys_t *pKey)
+{
+    TI_STATUS           status = OK;
+    whalParamInfo_t     whalParam;
+    UINT8               keyIndex;
+
+    keyIndex = (UINT8)pKey->keyIndex;
+    if ((pRsn == NULL) || (pKey == NULL) || (keyIndex >= MAX_KEYS_NUM))
+    {
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                            ("rsn_removeKey Entry, keyType=%d, keyIndex=0x%lx\n",pKey->keyType, keyIndex));
+
+    /* Now set to the RSN structure. */
+    if (pKey->keyType != NULL_KEY && pRsn->keys_en[keyIndex])
+    {
+        whalParam.paramType = HAL_CTRL_RSN_KEY_REMOVE_PARAM;
+        /*os_memoryCopy(pRsn->hOs, &whalParam.content.rsnKey, pKey, sizeof(securityKeys_t));*/
+        whalParam.content.configureCmdCBParams.CB_buf = (UINT8*) pKey;
+        whalParam.content.configureCmdCBParams.CB_Func = NULL;
+        whalParam.content.configureCmdCBParams.CB_handle = NULL;
+
+        /* If keyType is TKIP or AES, set the encLen to the KEY enc len - 16 */
+        if (pKey->keyType == TKIP_KEY || pKey->keyType == AES_KEY)
+        {
+            pKey->encLen = 16;
+            if (keyIndex != 0)
+            {   
+                const UINT8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+                /* 
+                 * if keyType is TKIP or AES, and the key index is broadcast, overwrite the MAC address as broadcast 
+                 * for removing the Broadcast key from the FW 
+                 */
+                os_memoryCopy (pRsn->hOs, (void *)&pKey->macAddress.addr[0], (void*)broadcast, MAC_ADDR_LEN);
+            }
+        }
+               else if (pKey->keyType == WEP_KEY)
+               {
+                       /* In full driver we use only WEP default keys. To remove it we make sure that the MAC address is NULL */
+                       os_memoryZero(pRsn->hOs,(void*)pKey->macAddress.addr,sizeof(macAddress_t)); 
+               }
+       
+        /* Mark key as deleted */
+        pRsn->keys_en[keyIndex] = FALSE;
+
+        status = whalCtrl_SetParam (pRsn->hWhalCtrl, &whalParam);
+        
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                      ("rsn_removeKey in whal, status =%d\n", status));
+
+        /* clean the key flags*/
+        pRsn->keys[keyIndex].keyIndex &= 0x000000FF;
+        pRsn->keys[keyIndex].keyType   = NULL_KEY;
+        pRsn->keys[keyIndex].encLen    = 0;
+        pRsn->wepDefaultKeys[keyIndex] = FALSE;        
+    }
+
+    return status; 
+}
+
+
+TI_STATUS rsn_setDefaultKeyId(rsn_t *pRsn, UINT8 keyId)
+{
+    TI_STATUS               status = OK;
+    whalParamInfo_t         whalParam;
+
+    if (pRsn == NULL)
+    {
+        return NOK;
+    }
+    pRsn->defaultKeyId = keyId;
+    /* Now we configure default key ID to the HAL */
+    whalParam.paramType = HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM;
+    whalParam.content.configureCmdCBParams.CB_buf = &keyId;
+    whalParam.content.configureCmdCBParams.CB_Func = NULL;
+    whalParam.content.configureCmdCBParams.CB_handle = NULL;
+    status = whalCtrl_SetParam(pRsn->hWhalCtrl, &whalParam); 
+    
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                        ("RSN: rsn_setDefaultKeyId, KeyId = 0x%lx\n",
+                         keyId));
+    return status;
+}
+
+
+TI_STATUS rsn_reportAuthFailure(TI_HANDLE hRsn, authStatus_e authStatus) 
+{
+    TI_STATUS    status = OK;
+    rsn_t       *pRsn;
+    paramInfo_t param;
+
+    if (hRsn==NULL)
+    {
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    /* Remove AP from candidate list for a specified amount of time */
+       param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+       status = ctrlData_getParam(pRsn->hCtrlData, &param);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG, 
+          ("rsn_reportAuthFailure, unable to retrieve BSSID \n"));
+       }
+    else
+    {
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG,
+             ("current station is banned from the roaming candidates list for %d Ms\n",
+              RSN_AUTH_FAILURE_TIMEOUT));
+
+        rsn_banSite(hRsn, param.content.ctrlDataCurrentBSSID, RSN_SITE_BAN_LEVEL_FULL, RSN_AUTH_FAILURE_TIMEOUT);
+    }
+
+       
+#ifdef EXC_MODULE_INCLUDED
+       WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                        ("CALLING rougeAP, status= %d \n",authStatus));
+    status = excMngr_rogueApDetected (pRsn->hExcMngr, authStatus);
+#endif
+    UNUSED(pRsn);
+    return status;
+}
+
+
+/******
+This is the CB function for mic failure event from the FW 
+*******/
+TI_STATUS rsn_reportMicFailure(TI_HANDLE hRsn, UINT8 *pType, UINT32 Length)
+{
+    rsn_t                               *pRsn = (rsn_t *) hRsn;
+    rsn_siteBanLevel_e                  banLevel;
+    OS_802_11_AUTHENTICATION_REQUEST    *request;
+    UINT8 AuthBuf[sizeof(UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];
+    paramInfo_t                         param;
+    UINT8                               failureType;
+
+    failureType = *pType;
+
+    if (((pRsn->paeConfig.unicastSuite == RSN_CIPHER_TKIP) && (failureType == KEY_TKIP_MIC_PAIRWISE)) ||
+        ((pRsn->paeConfig.broadcastSuite == RSN_CIPHER_TKIP) && (failureType == KEY_TKIP_MIC_GROUP)))
+    {
+        /* check if the MIC failure is group and group key update */
+        /* was performed during the last 3 seconds */
+        if ((failureType == KEY_TKIP_MIC_GROUP) &&
+            (pRsn->groupKeyUpdate == GROUP_KEY_UPDATE_TRUE))
+        {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                    ("%s: Group MIC failure ignored, key update was performed within the last 3 seconds.\n", __FUNCTION__));
+            return OK;
+        }
+
+        /* Prepare the Authentication Request */
+        request = (OS_802_11_AUTHENTICATION_REQUEST *)(AuthBuf + sizeof(UINT32));
+        request->Length = sizeof(OS_802_11_AUTHENTICATION_REQUEST);
+
+        param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;
+        if (ctrlData_getParam (pRsn->hCtrlData, &param) != OK)
+        {
+            return NOK;
+        }
+        
+        /* Generate 802 Media specific indication event */
+        *(UINT32*)AuthBuf = os802_11StatusType_Authentication;
+
+        os_memoryCopy (pRsn->hOs, request->BSSID, (void *)param.content.ctrlDataCurrentBSSID.addr, MAC_ADDR_LEN);
+
+        if (failureType == KEY_TKIP_MIC_PAIRWISE)
+        {
+            request->Flags = OS_802_11_REQUEST_PAIRWISE_ERROR;
+        }
+        else
+        {
+            request->Flags = OS_802_11_REQUEST_GROUP_ERROR;
+        }
+
+        EvHandlerSendEvent (pRsn->hEvHandler, 
+                            IPC_EVENT_MEDIA_SPECIFIC, 
+                            (UINT8*)AuthBuf,
+                            sizeof(UINT32) + sizeof(OS_802_11_AUTHENTICATION_REQUEST));
+
+        /* Update and check the ban level to decide what actions need to take place */
+        banLevel = rsn_banSite (hRsn, param.content.ctrlDataCurrentBSSID, RSN_SITE_BAN_LEVEL_HALF, RSN_MIC_FAILURE_TIMEOUT);
+        if (banLevel == RSN_SITE_BAN_LEVEL_FULL)
+        {
+            /* Site is banned so prepare to disconnect */
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                    ("%s: Second MIC failure, closing Rx port...\n", __FUNCTION__));
+
+            param.paramType = RX_DATA_PORT_STATUS_PARAM;
+            param.content.rxDataPortStatus = CLOSE;
+            rxData_setParam(pRsn->hRx, &param);
+
+            /* stop the mic failure Report timer and start a new one for 0.5 seconds */
+            os_timerStop(pRsn->hOs, pRsn->micFailureReportWaitTimer);
+            os_timerStart(pRsn->hOs, pRsn->micFailureReportWaitTimer, RSN_MIC_FAILURE_REPORT_WAIT, FALSE);
+        }
+        else
+        {
+            /* Site is only half banned so nothing needs to be done for now */
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+                    ("%s: First MIC failure, business as usual for now...\n", __FUNCTION__));
+        }
+    }
+
+    return OK;
+}
+
+
+void rsn_groupReKeyTimeout(TI_HANDLE hRsn)
+{
+    rsn_t *pRsn;
+
+    pRsn = (rsn_t*)hRsn;
+
+    if (pRsn == NULL)
+    {
+        return;
+    }
+
+    pRsn->groupKeyUpdate = GROUP_KEY_UPDATE_FALSE;
+}
+
+
+void rsn_micFailureReportTimeout(TI_HANDLE hRsn)
+{
+    rsn_t *pRsn;
+
+    pRsn = (rsn_t*)hRsn;
+
+    if (pRsn == NULL)
+    {
+        return;
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, 
+            ("%s: MIC failure reported, disassociating...\n", __FUNCTION__));
+
+    apConn_reportRoamingEvent (pRsn->hAPConn, ROAMING_TRIGGER_SECURITY_ATTACK, NULL);
+}
+
+
+/**
+*
+* rsn_resetPMKIDList - 
+*
+* \b Description: 
+*   Cleans up the PMKID cache.
+*   Called when SSID is being changed.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*/
+
+TI_STATUS rsn_resetPMKIDList(TI_HANDLE hRsn)
+{
+    rsn_t  *pRsn = (rsn_t*)hRsn;
+
+    if (!pRsn)
+        return NOK;
+
+    return (pRsn->pAdmCtrl->resetPmkidList (pRsn->pAdmCtrl));
+}
+
+
+void rsn_debugFunc(TI_HANDLE hRsn)
+{
+    rsn_t *pRsn;
+
+    if (hRsn == NULL)
+    {
+        return;
+    }
+    pRsn = (rsn_t*)hRsn;
+
+    WLAN_OS_REPORT(("rsnStartedTs, ts = %d\n", pRsn->rsnStartedTs));
+    WLAN_OS_REPORT(("rsnCompletedTs, ts = %d\n", pRsn->rsnCompletedTs));  
+}
+
+
+/**
+*
+* rsn_startPreAuth - 
+*
+* \b Description: 
+*
+* Start pre-authentication on a list of given BSSIDs.
+*
+* \b ARGS:
+*
+*  I   - hRsn - Rsniation SM context  \n
+*  I/O - pBssidList - list of BSSIDs that require Pre-Auth \n
+*
+* \b RETURNS:
+*
+*  OK if successful, NOK otherwise.
+*
+* \sa 
+*/
+TI_STATUS rsn_startPreAuth(TI_HANDLE hRsn, bssidList4PreAuth_t *pBssidList)
+{
+    rsn_t       *pRsn;
+    TI_STATUS    status;
+
+    if (hRsn == NULL || pBssidList == NULL)
+    {
+        return NOK;
+    }
+
+    pRsn = (rsn_t*)hRsn;
+
+    status = pRsn->pAdmCtrl->startPreAuth (pRsn->pAdmCtrl, pBssidList);
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("rsn_startPreAuth \n"));
+
+    return status;
+}
+
+
+/**
+ *
+ * isSiteBanned - 
+ *
+ * \b Description: 
+ *
+ * Returns whether or not the site with the specified Bssid is banned or not. 
+ *
+ * \b ARGS:
+ *
+ *  I   - hRsn - RSN module context \n
+ *  I   - siteBssid - The desired site's bssid \n
+ *
+ * \b RETURNS:
+ *
+ *  NOK iff site is banned.
+ *
+ */
+BOOL rsn_isSiteBanned(TI_HANDLE hRsn, macAddress_t siteBssid)
+{
+    rsn_t * pRsn = (rsn_t *) hRsn;
+    rsn_siteBanEntry_t * entry;
+
+    /* Check if site is in the list */
+    if ((entry = findBannedSiteAndCleanup(hRsn, siteBssid)) == NULL)
+    {
+        return FALSE;
+    }
+
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site %02X-%02X-%02X-%02X-%02X-%02X found with ban level %d...\n", __FUNCTION__, siteBssid.addr[0], siteBssid.addr[1], siteBssid.addr[2], siteBssid.addr[3], siteBssid.addr[4], siteBssid.addr[5], entry->banLevel));
+
+    return (entry->banLevel == RSN_SITE_BAN_LEVEL_FULL);
+}
+
+
+/**
+ *
+ * rsn_banSite - 
+ *
+ * \b Description: 
+ *
+ * Bans the specified site from being associated to for the specified duration.
+ * If a ban level of WARNING is given and no previous ban was in effect the
+ * warning is marked down but other than that nothing happens. In case a previous
+ * warning (or ban of course) is still in effect
+ *
+ * \b ARGS:
+ *
+ *  I   - hRsn - RSN module context \n
+ *  I   - siteBssid - The desired site's bssid \n
+ *  I   - banLevel - The desired level of ban (Warning / Ban)
+ *  I   - durationMs - The duration of ban in milliseconds
+ *
+ * \b RETURNS:
+ *
+ *  The level of ban (warning / banned).
+ *
+ */
+rsn_siteBanLevel_e rsn_banSite(TI_HANDLE hRsn, macAddress_t siteBssid, rsn_siteBanLevel_e banLevel, UINT32 durationMs)
+{
+    rsn_t * pRsn = (rsn_t *) hRsn;
+    rsn_siteBanEntry_t * entry;
+
+    /* Try finding the site in the list */
+    if ((entry = findBannedSiteAndCleanup(hRsn, siteBssid)) != NULL)
+    {
+        /* Site found so a previous ban is still in effect */ 
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site %02X-%02X-%02X-%02X-%02X-%02X found and has been set to ban level full!\n", __FUNCTION__, siteBssid.addr[0], siteBssid.addr[1], siteBssid.addr[2], siteBssid.addr[3], siteBssid.addr[4], siteBssid.addr[5]));
+
+        entry->banLevel = RSN_SITE_BAN_LEVEL_FULL;
+    }
+    else
+    {
+        /* Site doesn't appear in the list, so find a place to insert it */
+        WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site %02X-%02X-%02X-%02X-%02X-%02X added with ban level %d!\n", __FUNCTION__, siteBssid.addr[0], siteBssid.addr[1], siteBssid.addr[2], siteBssid.addr[3], siteBssid.addr[4], siteBssid.addr[5], banLevel));
+
+        entry = findEntryForInsert (hRsn);
+
+        entry->siteBssid = siteBssid;
+        entry->banLevel = banLevel;
+
+        pRsn->numOfBannedSites++;
+    }
+
+    entry->banStartedMs = os_timeStampMs (pRsn->hOs);
+    entry->banDurationMs = durationMs;
+
+    return entry->banLevel;
+}
+
+
+/**
+ *
+ * findEntryForInsert - 
+ *
+ * \b Description: 
+ *
+ * Returns a place to insert a new banned site. 
+ *
+ * \b ARGS:
+ *
+ *  I   - hRsn - RSN module context \n
+ *
+ * \b RETURNS:
+ *
+ *  A pointer to a suitable site entry.
+ *
+ */
+static rsn_siteBanEntry_t * findEntryForInsert(TI_HANDLE hRsn)
+{
+    rsn_t * pRsn = (rsn_t *) hRsn;
+
+    /* In the extreme case that the list is full we overwrite an old entry */
+    if (pRsn->numOfBannedSites == RSN_MAX_NUMBER_OF_BANNED_SITES)
+    {
+        WLAN_REPORT_ERROR(pRsn->hReport, RSN_MODULE_LOG,
+                ("%s: No room left to insert new banned site, overwriting old one!\n", __FUNCTION__));
+
+        return &(pRsn->bannedSites[0]);
+    }
+
+    return &(pRsn->bannedSites[pRsn->numOfBannedSites]);
+}
+
+
+/**
+ *
+ * findBannedSiteAndCleanup - 
+ *
+ * \b Description: 
+ *
+ * Searches the banned sites list for the desired site while cleaning up
+ * expired sites found along the way.
+ * 
+ * Note that this function might change the structure of the banned sites 
+ * list so old iterators into the list might be invalidated.
+ *
+ * \b ARGS:
+ *
+ *  I   - hRsn - RSN module context \n
+ *  I   - siteBssid - The desired site's bssid \n
+ *
+ * \b RETURNS:
+ *
+ *  A pointer to the desired site's entry if found,
+ *  NULL otherwise.
+ *
+ */
+static rsn_siteBanEntry_t * findBannedSiteAndCleanup(TI_HANDLE hRsn, macAddress_t siteBssid)
+{
+    rsn_t * pRsn = (rsn_t *) hRsn;
+    int iter;
+
+    for (iter = 0; iter < pRsn->numOfBannedSites; iter++)
+    {
+        /* If this entry has expired we'd like to clean it up */
+        if (os_timeStampMs(pRsn->hOs) - pRsn->bannedSites[iter].banStartedMs >= pRsn->bannedSites[iter].banDurationMs)
+        {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Found expired entry at index %d, cleaning it up...\n", __FUNCTION__, iter));
+
+            /* Replace this entry with the last one */
+            pRsn->bannedSites[iter] = pRsn->bannedSites[pRsn->numOfBannedSites - 1];
+            pRsn->numOfBannedSites--;
+
+            /* we now repeat the iteration on this entry */
+            iter--;
+
+            continue;
+        }
+
+        /* Is this the entry for the site we're looking for? */
+        if (MAC_EQUAL (&siteBssid, &pRsn->bannedSites[iter].siteBssid))
+        {
+            WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site %02X-%02X-%02X-%02X-%02X-%02X found at index %d!\n", __FUNCTION__, siteBssid.addr[0], siteBssid.addr[1], siteBssid.addr[2], siteBssid.addr[3], siteBssid.addr[4], siteBssid.addr[5], iter));
+
+            return &pRsn->bannedSites[iter];
+        } 
+    }
+
+    /* Entry not found... */
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s: Site %02X-%02X-%02X-%02X-%02X-%02X not found...\n", __FUNCTION__, siteBssid.addr[0], siteBssid.addr[1], siteBssid.addr[2], siteBssid.addr[3], siteBssid.addr[4], siteBssid.addr[5], iter));
+
+    return NULL;
+}
+
+/**
+ *
+ * clearBannedSiteList - 
+ *
+ * \b Description: 
+ *
+ * Clears the banned sites list.
+ * 
+ *
+ * \b ARGS:
+ *
+ *  I   - hRsn - RSN module context \n
+ *
+ * \b RETURNS:
+ *
+ *
+ */
+/* Comment out the call to clearBannedSiteList due to fail in WiFi mic attack test */
+/*
+static void clearBannedSiteList(TI_HANDLE hRsn)
+{
+    rsn_t * pRsn = (rsn_t *) hRsn;
+
+       pRsn->numOfBannedSites = 0;
+    WLAN_REPORT_INFORMATION(pRsn->hReport, RSN_MODULE_LOG, ("%s\n", __FUNCTION__));
+
+}
+*/
+
+
+#ifdef RSN_NOT_USED
+
+static INT16 convertAscii2Unicode(INT8* userPwd, INT16 len)
+{
+    INT16 i;
+    INT8 unsiiPwd[MAX_PASSWD_LEN];
+    
+
+    for (i=0; i<len; i++)
+    {
+        unsiiPwd[i] = userPwd[i];
+    }
+    for (i=0; i<len; i++)
+    {
+        userPwd[i*2] = unsiiPwd[i];
+        userPwd[i*2+1] = 0;
+    }
+    return (INT16)(len*2);     
+}
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/unicastKey802_1x.c b/sta_dk_4_0_4_32/common/src/core/rsn/unicastKey802_1x.c
new file mode 100644 (file)
index 0000000..dc61d5e
--- /dev/null
@@ -0,0 +1,370 @@
+/** \file unicastKey802_1x.c
+ * \brief station unicast key 802_1x implementation
+ *
+ * \see unicastKey802_1x.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   station unicast key 802_1x                                              *
+ *   PURPOSE:   station unicast key 802_1x implementation                                              *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "unicastKey802_1x.h"
+#include "mainKeysSm.h"
+
+/** number of states in the state machine */
+#define        UCAST_KEY_802_1X_MAX_NUM_STATES         3
+
+/** number of events in the state machine */
+#define        UCAST_KEY_802_1X_MAX_NUM_EVENTS         4
+
+
+TI_STATUS unicastKey802_1x_start(struct _unicastKey_t *pUnicastKey);
+
+TI_STATUS unicastKey802_1x_stop(struct _unicastKey_t *pUnicastKey);
+
+TI_STATUS unicastKey802_1x_recvSuccess(struct _unicastKey_t *pUnicastKey, 
+                                                                       encodedKeyMaterial_t *pEncodedKeyMaterial);
+
+TI_STATUS unicastKey802_1x_recvFailure(struct _unicastKey_t *pUnicastKey);
+
+TI_STATUS unicastKey802_1x_distribute(struct _unicastKey_t *pUnicastKey);
+
+TI_STATUS unicastKey802_1x_redistribute(struct _unicastKey_t *pUnicastKey);
+
+TI_STATUS unicastKey802_1x_event(struct _unicastKey_t *pUnicastKey,
+                                                         UINT8 event, 
+                                                         void *pData);
+
+
+
+/**
+*
+* Function  - Config KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_UnicastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS unicastKey802_1x_config(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS               status = NOK;
+
+       /** 802.1X Station unicast key State Machine matrix */
+       fsm_actionCell_t    unicastKey802_1x_matrix[UCAST_KEY_802_1X_NUM_STATES][UCAST_KEY_802_1X_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {       {UCAST_KEY_802_1X_STATE_START, (fsm_Action_t)unicastKeySmNop},
+                       {UCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)unicastKeySmNop},
+                       {UCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)unicastKeySmNop},
+                       {UCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)unicastKeySmUnexpected}
+               },
+       
+               /* next state and actions for START state */
+               {       {UCAST_KEY_802_1X_STATE_START, (fsm_Action_t)unicastKeySmUnexpected},
+                       {UCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)unicastKeySmNop},
+                       {UCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)unicastKey802_1x_distribute},
+                       {UCAST_KEY_802_1X_STATE_START, (fsm_Action_t)unicastKeySmNop}
+               },
+       
+               /* next state and actions for COMPLETE state */
+               {       {UCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)unicastKeySmUnexpected},
+                       {UCAST_KEY_802_1X_STATE_IDLE, (fsm_Action_t)unicastKeySmNop},
+                       {UCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)unicastKey802_1x_distribute},
+                       {UCAST_KEY_802_1X_STATE_COMPLETE, (fsm_Action_t)unicastKeySmUnexpected}
+               }
+       };
+
+
+       pUnicastKey->start = unicastKey802_1x_start;
+       pUnicastKey->stop = unicastKey802_1x_stop;
+       pUnicastKey->recvFailure = unicastKey802_1x_recvFailure;
+       pUnicastKey->recvSuccess = unicastKey802_1x_recvSuccess;
+
+       pUnicastKey->currentState = UCAST_KEY_802_1X_STATE_IDLE;
+
+       status = fsm_Config(pUnicastKey->pUcastKeySm, 
+                                               &unicastKey802_1x_matrix[0][0], 
+                                               UCAST_KEY_802_1X_NUM_STATES, 
+                                               UCAST_KEY_802_1X_NUM_EVENTS, 
+                                               NULL, pUnicastKey->hOs);
+
+       
+       return status;
+}
+
+
+
+/**
+*
+* unicastKey802_1x_event
+*
+* \b Description: 
+*
+* 802.1x station unicast key state machine transition function
+*
+* \b ARGS:
+*
+*  I/O - currentState - current state in the state machine\n
+*  I   - event - specific event for the state machine\n
+*  I   - pData - Data for state machine action function\n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa 
+*/
+#ifdef REPORT_LOG
+
+static char *unicastKey802_1x_stateDesc[UCAST_KEY_802_1X_NUM_STATES] = {
+               "STATE_IDLE",
+               "STATE_START",
+               "STATE_COMPLETE",
+       };
+       
+static char *unicastKey802_1x_eventDesc[UCAST_KEY_802_1X_NUM_EVENTS] = {
+               "EVENT_START",
+               "EVENT_STOP",
+               "EVENT_SUCCESS",
+               "EVENT_FAILURE"
+       };
+
+#endif
+
+TI_STATUS unicastKey802_1x_event(struct _unicastKey_t *pUnicastKey, UINT8 event, void *pData)
+{
+       TI_STATUS               status;
+       UINT8           nextState;
+
+       status = fsm_GetNextState(pUnicastKey->pUcastKeySm, pUnicastKey->currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_ERROR(pUnicastKey->hReport, RSN_MODULE_LOG,
+                                                 ("UNICAST_KEY_802_1x: ERROR: failed getting next state\n"));
+               return NOK;
+       }
+
+       WLAN_REPORT_INFORMATION(pUnicastKey->hReport, RSN_MODULE_LOG,
+                                                         ("STATION_UNICAST_KEY_802_1x: <%s, %s> --> %s\n",
+                               unicastKey802_1x_stateDesc[pUnicastKey->currentState],
+                                                          unicastKey802_1x_eventDesc[event],
+                                                          unicastKey802_1x_stateDesc[nextState]));
+
+       status = fsm_Event(pUnicastKey->pUcastKeySm, &pUnicastKey->currentState, event, pData);
+
+       return status;
+}
+
+
+/**
+*
+* unicastKey802_1x_start
+*
+* \b Description: 
+*
+* START event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa unicastKey802_1x_stop()
+*/
+TI_STATUS unicastKey802_1x_start(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS  status;
+       
+       status = unicastKey802_1x_event(pUnicastKey, UCAST_KEY_802_1X_EVENT_START, pUnicastKey);
+
+       return status;
+}
+
+
+/**
+*
+* unicastKey802_1x_stop
+*
+* \b Description: 
+*
+* START event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+* \sa unicastKey802_1x_start()
+*/
+TI_STATUS unicastKey802_1x_stop(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS  status;
+
+       status = unicastKey802_1x_event(pUnicastKey, UCAST_KEY_802_1X_EVENT_STOP, pUnicastKey);
+
+       return status;
+}
+
+
+/**
+*
+* unicastKey802_1x_recvSuccess
+*
+* \b Description: 
+*
+* SUCCESS event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*  I   - pEncodedKeyMaterial - Encoded key material \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+*/
+TI_STATUS unicastKey802_1x_recvSuccess(struct _unicastKey_t *pUnicastKey, encodedKeyMaterial_t *pEncodedKeyMaterial)
+{
+       TI_STATUS  status;
+
+       pUnicastKey->data.pEncodedKeyMaterial = pEncodedKeyMaterial;
+
+       status = unicastKey802_1x_event(pUnicastKey, UCAST_KEY_802_1X_EVENT_SUCCESS, pUnicastKey);
+
+       return status;
+}
+
+
+/**
+*
+* unicastKey802_1x_recvFailure
+*
+* \b Description: 
+*
+* FAILURE event handler
+*
+* \b ARGS:
+*
+*  I   - pCtrlB - station control block  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*
+*/
+TI_STATUS unicastKey802_1x_recvFailure(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS  status;
+       
+       status = unicastKey802_1x_event(pUnicastKey, UCAST_KEY_802_1X_EVENT_FAILURE, pUnicastKey);
+
+       return status;
+}
+
+
+/**
+*
+* unicastKey802_1x_distribute
+*
+* \b Description: 
+*
+* Distribute unicast key material to the driver and report the main key SM on unicast complete.
+*
+* \b ARGS:
+*
+*  I   - pData - Encoded key material  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS unicastKey802_1x_distribute(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS  status=NOK;
+       
+       if (pUnicastKey->pKeyDerive->derive!=NULL)
+    {
+       status = pUnicastKey->pKeyDerive->derive(pUnicastKey->pKeyDerive, 
+                                                                                                  pUnicastKey->data.pEncodedKeyMaterial);
+    }
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       if (pUnicastKey->pParent->setDefaultKeyId!=NULL)
+    {
+       status = pUnicastKey->pParent->setDefaultKeyId(pUnicastKey->pParent,
+                                                                                                  (UINT8)pUnicastKey->data.pEncodedKeyMaterial->keyId);
+    }
+       if (status != OK)
+       {
+               return status;
+       }
+
+       if (pUnicastKey->pParent->reportUcastStatus!=NULL)
+    {
+       status = pUnicastKey->pParent->reportUcastStatus(pUnicastKey->pParent, OK);
+    }
+
+       return status;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/unicastKeyNone.c b/sta_dk_4_0_4_32/common/src/core/rsn/unicastKeyNone.c
new file mode 100644 (file)
index 0000000..22dc270
--- /dev/null
@@ -0,0 +1,173 @@
+/** \file unicastKeyNone.c
+ * \brief station unicast key None implementation
+ *
+ * \see unicastKeyNone.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   station unicast key None                                            *
+ *   PURPOSE:   station unicast key None implementation                                                *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "unicastKeyNone.h"
+#include "mainKeysSm.h"
+
+
+TI_STATUS unicastKeyNone_start(struct _unicastKey_t *pUnicastKey);
+TI_STATUS unicastKeyNone_distribute(struct _unicastKey_t *pUnicastKey, encodedKeyMaterial_t *pEncodedKeyMaterial);
+
+
+
+/**
+*
+* Function  - Config KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_UnicastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS unicastKeyNone_config(struct _unicastKey_t *pUnicastKey)
+{
+
+       pUnicastKey->start = unicastKeyNone_start;
+       pUnicastKey->stop = unicastKeySmNop;
+       pUnicastKey->recvFailure = unicastKeySmNop;
+       pUnicastKey->recvSuccess = unicastKeyNone_distribute;
+
+       pUnicastKey->currentState = 0;
+
+       
+       return OK;
+}
+
+/**
+*
+* unicastKeyNone_start
+*
+* \b Description: 
+*
+* report the main key SM of unicast complete, whithout wating for keys.
+*
+* \b ARGS:
+*
+*  I   - pUnicastKey - context  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS unicastKeyNone_start(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS       status=NOK;
+
+       if (pUnicastKey->pParent->reportUcastStatus!=NULL)
+    {
+               status = pUnicastKey->pParent->reportUcastStatus(pUnicastKey->pParent, OK);
+    }
+
+       return status;
+}
+
+/**
+*
+* unicastKeyNone_distribute
+*
+* \b Description: 
+*
+* Distribute unicast key material to the driver and report the main key SM on unicast complete.
+*
+* \b ARGS:
+*
+*  I   - pData - Encoded key material  \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK otherwise.
+*/
+TI_STATUS unicastKeyNone_distribute(struct _unicastKey_t *pUnicastKey, encodedKeyMaterial_t *pEncodedKeyMaterial)
+{
+       TI_STATUS  status=NOK;
+       
+       if ((pUnicastKey==NULL) || (pEncodedKeyMaterial==NULL))
+    {
+        return NOK;
+    }
+    
+    if (pUnicastKey->pKeyDerive->derive!=NULL)
+    {
+        status = pUnicastKey->pKeyDerive->derive(pUnicastKey->pKeyDerive, 
+                                                       pEncodedKeyMaterial);
+    }
+       if (status != OK)
+       {
+               return NOK;
+       }
+
+       if (pUnicastKey->pParent->setDefaultKeyId!=NULL)
+    {
+        status = pUnicastKey->pParent->setDefaultKeyId(pUnicastKey->pParent,
+                                                       (UINT8)pEncodedKeyMaterial->keyId);
+    }
+       if (status != OK)
+       {
+               return status;
+       }
+
+       if (pUnicastKey->pParent->reportUcastStatus!=NULL)
+    {
+        status = pUnicastKey->pParent->reportUcastStatus(pUnicastKey->pParent, OK);
+    }
+
+       return status;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/rsn/unicastKeySM.c b/sta_dk_4_0_4_32/common/src/core/rsn/unicastKeySM.c
new file mode 100644 (file)
index 0000000..1e5a419
--- /dev/null
@@ -0,0 +1,224 @@
+/** \file unicastKeySM.c
+ * \brief station unicast key SM implementation
+ *
+ * \see unicastKeySM.h
+*/
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *                                                                          *
+ *   MODULE:   station unicast key SM                                          *
+ *   PURPOSE:   station unicast key SM implementation                                          *
+ *                                                                          *
+ ****************************************************************************/
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "rsnApi.h"
+
+#include "unicastKeySM.h"
+#include "unicastKey802_1x.h"
+#include "unicastKeyNone.h"
+
+/** number of states in the state machine */
+#define        UCAST_KEY_MAX_NUM_STATES                3
+
+/** number of events in the state machine */
+#define        UCAST_KEY_MAX_NUM_EVENTS                4
+
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_UnicastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+unicastKey_t* unicastKey_create(TI_HANDLE hOs)
+{
+       TI_STATUS                               status;
+       unicastKey_t            *pUnicastKey;
+
+       /* allocate key parser context memory */
+       pUnicastKey = (unicastKey_t*)os_memoryAlloc(hOs, sizeof(unicastKey_t));
+       if (pUnicastKey == NULL)
+       {
+               return NULL;
+       }
+
+       os_memoryZero(hOs, pUnicastKey, sizeof(unicastKey_t));
+
+       /* allocate memory for association state machine */
+       status = fsm_Create(hOs, &pUnicastKey->pUcastKeySm, UCAST_KEY_MAX_NUM_STATES, UCAST_KEY_MAX_NUM_EVENTS);
+       if (status != OK)
+       {
+               os_memoryFree(hOs, pUnicastKey, sizeof(unicastKey_t));
+               return NULL;
+       }
+
+       pUnicastKey->pKeyDerive = keyDerive_create(hOs);
+       if (pUnicastKey->pKeyDerive == NULL)
+       {
+               fsm_Unload(hOs, pUnicastKey->pUcastKeySm);
+               os_memoryFree(hOs, pUnicastKey, sizeof(unicastKey_t));
+               return NULL;
+       }
+
+       pUnicastKey->hOs = hOs;
+
+       return pUnicastKey;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_UnicastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS unicastKey_unload(struct _unicastKey_t *pUnicastKey)
+{
+       TI_STATUS               status;
+
+       status = keyDerive_unload(pUnicastKey->pKeyDerive);
+       if (status != OK)
+       {
+               WLAN_OS_REPORT(("BCAST_KEY_SM: Error in unloading key derivation module\n"));
+       }
+
+       status = fsm_Unload(pUnicastKey->hOs, pUnicastKey->pUcastKeySm);
+       if (status != OK)
+       {
+               WLAN_OS_REPORT(("BCAST_KEY_SM: Error in unloading state machine\n"));
+       }
+
+       /* free key parser context memory */
+       os_memoryFree(pUnicastKey->hOs, pUnicastKey, sizeof(unicastKey_t));
+
+       return OK;
+}
+
+/**
+*
+* Function  - Init KEY Parser module.
+*
+* \b Description: 
+*
+* Called by RSN Manager. 
+* Registers the function 'rsn_UnicastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
+*
+* \b ARGS:
+*
+*  
+* \b RETURNS:
+*
+*  TI_STATUS - 0 on success, any other value on failure. 
+*
+*/
+
+TI_STATUS unicastKey_config(struct _unicastKey_t *pUnicastKey,
+                                                rsn_paeConfig_t *pPaeConfig,
+                                                struct _mainKeys_t *pParent,
+                                                TI_HANDLE hReport,
+                                                TI_HANDLE hOs)
+{
+       TI_STATUS               status = NOK;
+
+       pUnicastKey->hReport = hReport;
+       pUnicastKey->hOs = hOs;
+       pUnicastKey->pParent = pParent;
+
+       /* configure according to the keyMng suite and cipher suite */
+    switch (pPaeConfig->keyExchangeProtocol)
+    {
+    case RSN_KEY_MNG_NONE:
+       status = unicastKeyNone_config(pUnicastKey);
+       break;
+    case RSN_KEY_MNG_802_1X:
+       if (pPaeConfig->unicastSuite == RSN_CIPHER_NONE)
+           {
+               status = unicastKeyNone_config(pUnicastKey);
+           } else {
+               status = unicastKey802_1x_config(pUnicastKey);
+           }
+       break;
+    default:
+           status = unicastKeyNone_config(pUnicastKey);
+           break;
+    }
+
+       status = keyDerive_config(pUnicastKey->pKeyDerive, pPaeConfig->unicastSuite, pParent, hReport, hOs);
+       
+       return status;
+}
+
+
+TI_STATUS unicastKeySmUnexpected(struct _unicastKey_t *pUnicastKey)
+{
+       WLAN_REPORT_ERROR(pUnicastKey->hReport, RSN_MODULE_LOG,
+                                         ("UNICAST_KEY_SM: ERROR: UnExpected Event\n"));
+
+       return(NOK);
+}
+
+TI_STATUS unicastKeySmNop(struct _unicastKey_t *pUnicastKey)
+{
+       return(OK);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/HealthMonitor/healthMonitor.c b/sta_dk_4_0_4_32/common/src/core/sme/HealthMonitor/healthMonitor.c
new file mode 100644 (file)
index 0000000..c4475b8
--- /dev/null
@@ -0,0 +1,535 @@
+/** \file healthMonitor.c
+ *  \brief Firmware Recovery Mechanism
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                          */
+/*      MODULE:     healthMonitor.c                                         */
+/*      PURPOSE:    Driver interface to OS abstraction layer                */
+/*                                                                          */
+/****************************************************************************/
+#include "healthMonitor.h"
+
+#ifdef _WINDOWS
+#endif 
+
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "siteMgrApi.h"
+#include "whalCtrl_api.h" 
+#include "PowerMgr_API.h"
+#include "currBss.h"
+#include "DataCtrl_Api.h"
+#include "TNETW_Driver_api.h"
+#include "srcApi.h"
+#include "SoftGeminiApi.h"
+#include "currBss.h"
+#include "whalCtrl_api.h"
+#include "public_host_int.h"
+#include "rsnApi.h"
+#ifdef DEBUG_FIRMWARE
+#include "whalCtrl.h"
+#endif
+
+#include "recoveryMgr_API.h"
+
+/* Keep-alive period */
+#define KEEP_ALIVE_TIEMOUT    10000
+
+
+static void healthMonitor_proccessFailureEvent (TI_HANDLE hHealthMonitor);
+static void healthMonitor_RSSI_CB (TI_HANDLE hHealthMonitor);
+
+
+#ifdef REPORT_LOG
+
+static char* sRecoveryTriggersNames [MAX_FAILURE_EVENTS] = 
+{
+    "NO_SCAN_COMPLETE_FAILURE",
+    "MBOX_FAILURE",
+    "HW_AWAKE_FAILURE",
+    "BUS_ERROR",
+    "DEVICE_ERROR",
+    "TX_STUCK",
+    "DISCONNECT_TIMEOUT",
+    "POWER_SAVE_FAILURE",
+    "MEASUREMENT_FAILURE",
+};
+
+#endif
+
+
+/***********************************************************************
+ *                        healthMonitor_create
+ ***********************************************************************
+DESCRIPTION: 
+           
+
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+TI_HANDLE healthMonitor_create (TI_HANDLE hOs)
+{
+    healthMonitor_t *pHealthMonitor;
+    /* Allocate memory for the health monitor object and nullify it */
+    pHealthMonitor = (healthMonitor_t*)os_memoryAlloc (hOs, sizeof(healthMonitor_t));
+    if (pHealthMonitor == NULL)
+    {
+        return NULL;
+    }
+    os_memoryZero (hOs, pHealthMonitor, sizeof(healthMonitor_t));
+
+    /* Store OS object handle */
+    pHealthMonitor->hOs = hOs;
+
+    /* Create periodic health check timer */
+    pHealthMonitor->hHealtheCheckTimer = os_timerCreate (hOs, healthMonitor_performTest, (TI_HANDLE)pHealthMonitor);
+    if (NULL == pHealthMonitor->hHealtheCheckTimer)
+    {
+        healthMonitor_unload ((TI_HANDLE)pHealthMonitor);
+        return NULL;
+    }
+
+    /* Create recovery request timer */
+    pHealthMonitor->hFailTimer = os_timerCreate (hOs, healthMonitor_proccessFailureEvent, (TI_HANDLE)pHealthMonitor);
+    if (NULL == pHealthMonitor->hFailTimer)
+    {
+        healthMonitor_unload ((TI_HANDLE)pHealthMonitor);
+        return NULL;
+    }
+
+    return (TI_HANDLE)pHealthMonitor;
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_config
+ ***********************************************************************
+DESCRIPTION:            
+
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+TI_STATUS healthMonitor_config (TI_HANDLE    hHealthMonitor, 
+                                TI_HANDLE    hReport,
+                                TI_HANDLE    hHalCtrl,
+                                TI_HANDLE    hSiteMgr,
+                                TI_HANDLE    hScr,
+                                TI_HANDLE    hSoftGemini,
+                                TI_HANDLE    hTnetwDrv,
+                                TI_HANDLE    hMemMgr,
+                                TI_HANDLE    hConfigMgr,
+                                TI_HANDLE    hTxData,
+                                TI_HANDLE    hCurrBss,
+                                TI_HANDLE    hRsn,
+                                healthMonitorInitParams_t *healthMonitorInitParams,
+                                                               TI_HANDLE    hRecoveryMgr)
+{
+    healthMonitor_t *pHealthMonitor = hHealthMonitor;
+    int i;
+
+    pHealthMonitor->hReport         = hReport;
+    pHealthMonitor->hHalCtrl        = hHalCtrl;
+    pHealthMonitor->hSiteMgr        = hSiteMgr;
+    pHealthMonitor->hScr            = hScr;
+    pHealthMonitor->hSoftGemini     = hSoftGemini;
+    pHealthMonitor->hTnetwDrv       = hTnetwDrv;
+    pHealthMonitor->hMemMgr         = hMemMgr;
+    pHealthMonitor->hConfigMgr      = hConfigMgr;
+    pHealthMonitor->hTxData         = hTxData;
+    pHealthMonitor->hCurrBss        = hCurrBss;
+    pHealthMonitor->hRsn            = hRsn;
+    pHealthMonitor->state           = HEALTH_MONITOR_STATE_DISCONNECTED;
+    pHealthMonitor->bRunSoftRecovery = FALSE;
+    pHealthMonitor->failureEvent    = (UINT32)NO_FAILURE;
+    pHealthMonitor->hRecoveryMgr    = hRecoveryMgr;
+
+    /* Registry configuration */
+    pHealthMonitor->bFullRecoveryEnable = healthMonitorInitParams->FullRecoveryEnable;
+    pHealthMonitor->timerInterval = healthMonitorInitParams->healthCheckPeriod;
+
+    for (i = 0; i < MAX_FAILURE_EVENTS; i++)
+    {
+        pHealthMonitor->recoveryTriggerEnabled[i] = healthMonitorInitParams->recoveryTriggerEnabled[i];
+    }
+
+    /* 
+     * Set the keep-alive Interval, which is used to signal at how many timer intervals
+     * a keep alive (null data) packet needs to be sent to the AP. A packet should be sent every
+     * KEEP_ALIVE_TIEMOUT seconds (default is 10 seconds).
+     */
+    if (pHealthMonitor->timerInterval != 0)
+    {
+        pHealthMonitor->keepAliveIntervals = KEEP_ALIVE_TIEMOUT / pHealthMonitor->timerInterval;
+    }
+    else
+    {
+        pHealthMonitor->keepAliveIntervals = 1;
+    }
+    pHealthMonitor->currentKeepAliveCounter = 0;
+
+    /* Register the failure event callback */
+    TnetwDrv_Register_CB (hTnetwDrv, 
+                          TNETW_DRIVER_EVENT_FAILURE, 
+                          (void *)healthMonitor_sendFailureEvent, 
+                          hHealthMonitor);
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_unload
+ ***********************************************************************
+DESCRIPTION: 
+           
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+TI_STATUS healthMonitor_unload (TI_HANDLE hHealthMonitor)
+{
+    healthMonitor_t *pHealthMonitor;
+
+    pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    if (pHealthMonitor != NULL)
+    {
+        if (NULL != pHealthMonitor->hHealtheCheckTimer)
+        {
+            /* Release the timer */
+            os_timerDestroy (pHealthMonitor->hOs, pHealthMonitor->hHealtheCheckTimer);
+        }
+
+        if (NULL != pHealthMonitor->hFailTimer)
+        {
+            /* Release the timer */
+            os_timerDestroy (pHealthMonitor->hOs, pHealthMonitor->hFailTimer);
+        }
+
+        /* Freeing the object should be called last !!!!!!!!!!!! */
+        os_memoryFree (pHealthMonitor->hOs, pHealthMonitor, sizeof(healthMonitor_t));
+    }
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_setState
+ ***********************************************************************
+DESCRIPTION: 
+           
+
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+void healthMonitor_setState (TI_HANDLE hHealthMonitor, healthMonitorState_e state)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    pHealthMonitor->state = state;
+
+    switch (state)
+    {
+    case HEALTH_MONITOR_STATE_DISCONNECTED:
+        /* Stop health monitor check */
+        os_timerStop (pHealthMonitor->hOs, pHealthMonitor->hHealtheCheckTimer);
+        break;
+
+    case HEALTH_MONITOR_STATE_CONNECTED:
+        /* Start health monitor check */
+        os_timerStart (pHealthMonitor->hOs, pHealthMonitor->hHealtheCheckTimer, pHealthMonitor->timerInterval, TRUE);
+        break;
+    }
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_suspendPeriodicTest
+ ***********************************************************************
+DESCRIPTION: 
+           
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+void healthMonitor_suspendPeriodicTest (TI_HANDLE hHealthMonitor)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    WLAN_REPORT_INFORMATION (pHealthMonitor->hReport, SITE_MGR_MODULE_LOG,
+                             ("%s: state=%d, suspend=%d\n", 
+                             __FUNCTION__, pHealthMonitor->state, pHealthMonitor->bSuspended));
+    
+    pHealthMonitor->bSuspended = TRUE;
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_resumePeriodicTest
+ ***********************************************************************
+DESCRIPTION: 
+           
+
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+void healthMonitor_resumePeriodicTest(TI_HANDLE hHealthMonitor)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    WLAN_REPORT_INFORMATION (pHealthMonitor->hReport, SITE_MGR_MODULE_LOG,
+                             ("%s: state=%d, suspend=%d\n",
+                             __FUNCTION__, pHealthMonitor->state, pHealthMonitor->bSuspended) );
+
+    pHealthMonitor->bSuspended = FALSE;
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_performTest
+ ***********************************************************************
+DESCRIPTION: every T s ( 5sec ) will be called by TX Power Adjust timer
+           
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+void healthMonitor_performTest (TI_HANDLE hHealthMonitor)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    if (FALSE == pHealthMonitor->bSuspended)
+    {
+        /*
+         * The following call is disabled, because there's no point to send health check command if
+         * the get RSSI is sent anyhow. When these operations will be
+         * separated, the health test should be returned.
+         */
+
+        /*
+        pHealthMonitor->numOfHealthTests++;
+      #ifdef USE_RECOVERY
+        whalCtrl_CheckHwStatus(pHealthMonitor->hHalCtrl);
+      #endif
+         */
+
+        /* NOTE: This call is important to update the siteMgr and roamingMgr, so be carefully if you wish to remove it */
+        whalCtrl_GetAsynRSSI (pHealthMonitor->hHalCtrl, 
+                              (PVOID)healthMonitor_RSSI_CB, 
+                              hHealthMonitor, 
+                              (PUINT8)&pHealthMonitor->statTable);
+
+        pHealthMonitor->currentKeepAliveCounter++;
+        if (pHealthMonitor->currentKeepAliveCounter >= pHealthMonitor->keepAliveIntervals)
+        {
+            siteMgr_keepAliveSendNullDataTimer (pHealthMonitor->hSiteMgr);
+            pHealthMonitor->currentKeepAliveCounter = 0;
+        }
+    }
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_RSSI_CB
+ ***********************************************************************
+DESCRIPTION:           
+
+INPUT:      
+
+OUTPUT:
+
+RETURN: 
+
+************************************************************************/
+void healthMonitor_RSSI_CB (TI_HANDLE hHealthMonitor)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+    /* Update Rx signal in currBss in order to check if roaming trigger on BG scan occured  */
+    /* and to update the site Mgr with the updated RSSI. (Those values are averaged)        */
+    currBSS_updateRxSignal (pHealthMonitor->hCurrBss,
+                            pHealthMonitor->statTable.snr,
+                            pHealthMonitor->statTable.rssi,
+                            TRUE);
+    if (pHealthMonitor->state == HEALTH_MONITOR_STATE_CONNECTED)
+    {
+        /* TX Power Adjust - if the RSSI is good lower the Tx Power */
+        siteMgr_checkTxPower( pHealthMonitor->hSiteMgr );
+    }
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_sendFailureEvent
+ ***********************************************************************
+DESCRIPTION:    Entry point for all low level modules to send a failure evrnt
+
+INPUT:          handle - health monitor handle
+                failureEvent - the error
+
+OUTPUT:
+
+RETURN:    
+
+************************************************************************/
+void healthMonitor_sendFailureEvent (TI_HANDLE hHealthMonitor, failureEvent_e failureEvent)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    /* Check the recovery process is already running */
+    if (pHealthMonitor->failureEvent < MAX_FAILURE_EVENTS)
+    {
+        WLAN_REPORT_WARNING (pHealthMonitor->hReport, SITE_MGR_MODULE_LOG,
+                             ("%s: recovery process is already running\n", __FUNCTION__));
+    }
+
+    /* Recovery is performed only if this trigger is enabled in the .INI file */
+    else if (TRUE == pHealthMonitor->recoveryTriggerEnabled[failureEvent])
+    {
+        pHealthMonitor->failureEvent = failureEvent;
+        /* 
+         * NOTE: start timer with minimum expiry for recovery will start
+         *       from the top of the stack 
+         */
+        os_timerStart (pHealthMonitor->hOs, pHealthMonitor->hFailTimer, 1, FALSE);
+    }
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_proccessFailureEvent
+ ***********************************************************************
+DESCRIPTION:    this is the central error function - will be passed as call back 
+                to the TnetWDriver modules. it will parse the error and dispatch the 
+                relevant action (recovery or not) 
+
+INPUT:          handle - health monitor handle
+                failureEvent - the error
+
+OUTPUT:
+
+RETURN:    
+
+************************************************************************/
+void healthMonitor_proccessFailureEvent (TI_HANDLE hHealthMonitor)
+{
+    healthMonitor_t *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+
+    /* Check failure event validity */
+    if (pHealthMonitor->failureEvent < MAX_FAILURE_EVENTS)
+    {
+        pHealthMonitor->recoveryTriggersNumber[pHealthMonitor->failureEvent] ++;
+
+        WLAN_OS_REPORT (("***** recovery trigger: %s *****\n", sRecoveryTriggersNames[pHealthMonitor->failureEvent]));
+
+        recoveryMgr_recoveryProcess(pHealthMonitor->hRecoveryMgr);/* CE20 */
+
+        pHealthMonitor->failureEvent = (UINT32)NO_FAILURE;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR (pHealthMonitor->hReport, SITE_MGR_MODULE_LOG,
+                           ("%s: unsupported failure event = %d\n", 
+                           pHealthMonitor->failureEvent));
+    }    
+}
+
+
+/***********************************************************************
+ *                        healthMonitor_printFailureEvents
+ ***********************************************************************
+DESCRIPTION:
+
+INPUT:
+
+OUTPUT:
+
+RETURN:
+************************************************************************/
+void healthMonitor_printFailureEvents(TI_HANDLE hHealthMonitor)
+{
+  #ifdef TI_DBG
+    healthMonitor_t  *pHealthMonitor = (healthMonitor_t*)hHealthMonitor;
+    int i;
+
+    WLAN_OS_REPORT(("-------------- STA Health Failure Statistics ---------------\n"));
+    WLAN_OS_REPORT(("FULL RECOVERY PERFORMED    = %d\n", pHealthMonitor->numOfRecoveryPerformed));
+    for (i = 0; i < MAX_FAILURE_EVENTS; i++)
+    {
+        WLAN_OS_REPORT(("%27s= %d\n",
+                        sRecoveryTriggersNames[ i ], pHealthMonitor->recoveryTriggersNumber[ i ]));
+    }
+    WLAN_OS_REPORT(("Maximum number of commands in mailbox queue = %d\n",whalCtrl_getMaxNumberOfCommandsInQueue(pHealthMonitor->hHalCtrl)));
+    WLAN_OS_REPORT(("Health Test Perfomrd       = %d\n", pHealthMonitor->numOfHealthTests));
+    WLAN_OS_REPORT(("\n"));
+
+  #ifdef USE_RECOVERY
+    whalCtrl_PrintHwStatus(pHealthMonitor->hHalCtrl);
+  #endif
+
+  #endif /* TI_DBG */
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/HealthMonitor/healthMonitor.h b/sta_dk_4_0_4_32/common/src/core/sme/HealthMonitor/healthMonitor.h
new file mode 100644 (file)
index 0000000..350ab0d
--- /dev/null
@@ -0,0 +1,129 @@
+/** \file healthMonitor.c
+ *  \brief Firmware Recovery Mechanizem
+ *
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                          */
+/*      MODULE:     healthMonitor.h                                         */
+/*      PURPOSE:    Driver interface to OS abstraction layer                */
+/*                                                                          */
+/****************************************************************************/
+
+#ifndef HEALTHMONITOR_H
+#define HEALTHMONITOR_H
+
+#include "paramOut.h"
+#include "whalCtrl_api.h"
+
+
+/* Config manager state machine defintions */
+typedef enum healthMonitorState_e
+{
+    HEALTH_MONITOR_STATE_DISCONNECTED = 0,
+    HEALTH_MONITOR_STATE_CONNECTED 
+
+} healthMonitorState_e;
+
+
+typedef struct
+{
+    /* handles to other modules */
+    TI_HANDLE            hOs;                    /**< handle to the OS object */
+    TI_HANDLE            hReport;                /**< handle to the report object */
+    TI_HANDLE            hHalCtrl;               /**< handle to the HAL CTRL object */
+    TI_HANDLE            hSiteMgr;               /**< handle to the site manager object */
+    TI_HANDLE            hScr;                   /**< handle to the SCR object */
+    TI_HANDLE            hSoftGemini;            /**< handle to the Soft Gemini object */
+    TI_HANDLE            hTnetwDrv;              /**< handle to the TNETW driver object */
+    TI_HANDLE            hMemMgr;                /**< handle to the memory manager object */
+    TI_HANDLE            hConfigMgr;             /**< handle to the config manager object */
+    TI_HANDLE            hTxData;                /**< handle to the TX data object */
+    TI_HANDLE            hHealtheCheckTimer;     /**< periodic health check timer handle */
+    TI_HANDLE            hCurrBss;               /**< handle to the currBss object */
+    TI_HANDLE            hFailTimer;             /**< failure event timer */
+    TI_HANDLE            hRsn;                   /**< handle to the RSN */
+    TI_HANDLE            hRecoveryMgr;           /**< handle to the Recovery Mgr object */
+    
+    /* Management variables */
+    UINT32               numOfHealthTests;       /**< number of health tests performed counter */
+    healthMonitorState_e state;                  /**< health monitor state */
+    BOOL                 bFullRecoveryEnable;    /**< full recovery enable flag */
+    BOOL                 bSuspended;             /**< suspend periodic test flag */
+    UINT32               timerInterval;          /**< health check interval */
+    BOOL                 bRunSoftRecovery;       /**< soft recovery flag */
+    BOOL                 recoveryTriggerEnabled [MAX_FAILURE_EVENTS];
+                                                 /**< recovery enable flags per trigger type */
+    UINT32               failureEvent;           /**< current recovery trigger */
+    UINT32               keepAliveIntervals;     /**< number of health monitor timer intervals at which keep alive should be sent */
+    UINT32               currentKeepAliveCounter;/**< counting how many timer intervals had passed w/o a keep alive */
+
+    /* Recoveries Statistics */
+    UINT32               recoveryTriggersNumber [MAX_FAILURE_EVENTS];                                                  
+                                                 /**< Number of times each recovery trigger occured */
+    UINT32               numOfRecoveryPerformed; /**< number of recoveries performed */
+    
+    ACXRoamingStatisticsTable_t statTable;       /**< needed by TX Power Adjust, to retrieve current rssi when beacon filter in ON */
+
+} healthMonitor_t;
+
+
+
+TI_HANDLE healthMonitor_create         (TI_HANDLE hOs);
+TI_STATUS healthMonitor_config         (TI_HANDLE hHealthMonitor, 
+                                        TI_HANDLE hReport,
+                                        TI_HANDLE hHalCtrl,
+                                        TI_HANDLE hSiteMgr,
+                                        TI_HANDLE hScr,
+                                        TI_HANDLE hSoftGemini,
+                                        TI_HANDLE hTnetwDrv,
+                                        TI_HANDLE hMemMgr,
+                                        TI_HANDLE hConfigMgr,
+                                        TI_HANDLE hTxData,
+                                        TI_HANDLE hCurrBss,
+                                        TI_HANDLE hRsn,
+                                        healthMonitorInitParams_t *healthMonitorInitParams,
+                                        TI_HANDLE hRecoveryMgr);
+TI_STATUS healthMonitor_unload         (TI_HANDLE hHealthMonitor);
+void healthMonitor_performTest         (TI_HANDLE hHealthMonitor);
+void healthMonitor_setState            (TI_HANDLE hHealthMonitor, healthMonitorState_e state);
+void healthMonitor_suspendPeriodicTest (TI_HANDLE hHealthMonitor);
+void healthMonitor_resumePeriodicTest  (TI_HANDLE hHealthMonitor);
+void healthMonitor_sendFailureEvent    (TI_HANDLE hHealthMonitor, failureEvent_e failureEvent);
+void healthMonitor_printFailureEvents  (TI_HANDLE hHealthMonitor);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/Inc/connApi.h b/sta_dk_4_0_4_32/common/src/core/sme/Inc/connApi.h
new file mode 100644 (file)
index 0000000..65dc417
--- /dev/null
@@ -0,0 +1,131 @@
+/** \file connApi.h
+ *  \brief connection module API
+ *
+ *  \see conn.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*       MODULE:       connApi.h                                                                                                                               */
+/*    PURPOSE: connection module API                                                                                   */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __CONN_API_H__
+#define __CONN_API_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "802_11Defs.h"
+#include "mlmeApi.h"
+
+/*
+ * Connection type enum
+ */
+typedef enum{
+       CONN_TYPE_FIRST_CONN    = 0,  /* Standart 802.11 association */
+       CONN_TYPE_ROAM           /* Perform roaming connection. (Re Association) */ 
+}connType_e;
+
+
+/* 
+       Prototype for connection status announcment, this function is called upon connection
+   lost or connection establishment.
+*/
+typedef TI_STATUS (*conn_status_callback_t)( TI_HANDLE hObj, mgmtStatus_e status, UINT32 uStatusCode);
+
+
+/* Connection interface functions prototypes */
+
+TI_HANDLE conn_create(TI_HANDLE hOs);
+
+TI_STATUS conn_config(TI_HANDLE        hConn, 
+                                  TI_HANDLE    hSiteMgr, 
+                                  TI_HANDLE    hSmeSm, 
+                                  TI_HANDLE    hMlmeSm, 
+                                  TI_HANDLE    hRsn,
+                                  TI_HANDLE    hRxData,
+                                  TI_HANDLE    hTxData,
+                                  TI_HANDLE    hReport,
+                                  TI_HANDLE    hOs,
+                                  TI_HANDLE    hPwrMngr,
+                                  TI_HANDLE    hCtrlData,
+                                  TI_HANDLE    hMeasurementMgr,
+                                  TI_HANDLE    hTrafficMonitor,
+                                  TI_HANDLE    hScr,
+                                  TI_HANDLE    hExcMngr,
+                                  TI_HANDLE    hQosMngr,
+                                  TI_HANDLE    hHalCtrl,
+                                  TI_HANDLE    hScanCnc,
+                                  TI_HANDLE    hCurrBss,
+                                  TI_HANDLE    hSwitchChannel,
+                                  TI_HANDLE    hEvHandler,
+                                  TI_HANDLE    hHealthMonitor,
+                                  TI_HANDLE    hMacServices,
+                   TI_HANDLE    hRegulatoryDomain,
+                                  TI_HANDLE    hSoftGemini,
+                                  connInitParams_t             *pConnInitParams);
+
+TI_STATUS conn_unLoad(TI_HANDLE hConn);
+
+TI_STATUS conn_setParam(TI_HANDLE              hConn, 
+                                        paramInfo_t    *pParam);
+
+TI_STATUS conn_getParam(TI_HANDLE              hConn, 
+                                        paramInfo_t    *pParam);
+
+TI_STATUS conn_start(TI_HANDLE hConn ,connType_e connType,
+                                               conn_status_callback_t  pConnStatusCB,
+                                               TI_HANDLE connStatCbObj,
+                                               BOOL disConEraseKeys,
+                                               BOOL reNegotiateTspec);
+void connInfraJoinCmdCmpltNotification(TI_HANDLE CB_handle);
+
+TI_STATUS conn_stop(TI_HANDLE hConn, disConnType_e disConnType,
+                                       mgmtStatus_e                    reason,
+                                       BOOL                                    disConEraseKeys,
+                                       conn_status_callback_t  pConnStatusCB,
+                                       TI_HANDLE                               connStatCbObj );
+
+
+TI_STATUS conn_ibssStaJoined(TI_HANDLE hConn);
+
+void conn_disConnFrameSentCBFunc(TI_HANDLE hConn);
+
+void conn_ibssPrintStatistics(TI_HANDLE hConn);
+
+#endif /* __CONN_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/Inc/siteMgrApi.h b/sta_dk_4_0_4_32/common/src/core/sme/Inc/siteMgrApi.h
new file mode 100644 (file)
index 0000000..4147b50
--- /dev/null
@@ -0,0 +1,177 @@
+/** \file siteMgrApi.h
+ *  \brief site manager module API
+ *
+ *  \see siteMgr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                  */
+/*    MODULE:   siteMgrApi.h                                                                */
+/*    PURPOSE:  site manager module API                                         */
+/*                                                                                                  */
+/***************************************************************************/
+#ifndef __SITE_MGR_API_H__
+#define __SITE_MGR_API_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "802_11Defs.h"
+#include "mlmeApi.h"
+#include "siteHash.h"
+#include "ScanCncnApi.h"
+#include "bssTypes.h"
+
+
+/* Site manager interface functions prototypes */
+
+TI_HANDLE siteMgr_create(TI_HANDLE hOs);
+
+TI_STATUS siteMgr_config(   TI_HANDLE       hSiteMgr,
+                        TI_HANDLE       hConn,
+                        TI_HANDLE       hSmeSm,
+                        TI_HANDLE       hCtrlData,
+                        TI_HANDLE       hRxData,
+                        TI_HANDLE       hTxData,
+                        TI_HANDLE       hRsn,
+                        TI_HANDLE       hAuth,
+                        TI_HANDLE       hAssoc,
+                        TI_HANDLE       hHalCtrl,
+                        TI_HANDLE       hMlmeSm,
+                        TI_HANDLE       hRegulatoryDomain,
+                        TI_HANDLE       hMeasurementMgr,
+                        TI_HANDLE       hApConn,
+                        TI_HANDLE       hCurrBss,
+                        TI_HANDLE       hReport,
+                        TI_HANDLE       hOs ,
+                        TI_HANDLE       hExcMngr,
+                        TI_HANDLE       hQosMngr,
+                        TI_HANDLE       thePowerMgrHandle,
+                        TI_HANDLE       hScr,
+                        TI_HANDLE       hEvHandler,
+                        TI_HANDLE       hMacServices,
+                        siteMgrInitParams_t     *pSiteMgrInitParams);
+
+TI_STATUS siteMgr_unLoad(TI_HANDLE hSiteMgr);
+
+TI_STATUS siteMgr_setParam(TI_HANDLE        hSiteMgr,
+                        paramInfo_t     *pParam);
+
+TI_STATUS siteMgr_getParam(TI_HANDLE        hSiteMgr, 
+                        paramInfo_t     *pParam);
+
+TI_STATUS siteMgr_join(TI_HANDLE    hSiteMgr);
+
+TI_STATUS siteMgr_forceInfraJoin(TI_HANDLE    hSiteMgr);
+TI_STATUS siteMgr_disJoin(TI_HANDLE hSiteMgr);
+
+TI_STATUS siteMgr_removeSelfSite(TI_HANDLE  hSiteMgr);
+
+TI_STATUS siteMgr_disSelectSite(TI_HANDLE   hSiteMgr);
+
+TI_STATUS systemConfig(siteMgr_t *pSiteMgr);
+
+TI_STATUS siteMgr_start(TI_HANDLE   hSiteMgr);
+
+TI_STATUS siteMgr_stop(TI_HANDLE    hSiteMgr);
+
+TI_STATUS siteMgr_resetSiteTable(TI_HANDLE  hSiteMgr, siteTablesParams_t*   pSiteTableParams);
+
+TI_STATUS siteMgr_removeNotReceivedSites(TI_HANDLE  hSiteMgr);
+
+TI_STATUS siteMgr_updatePrimarySiteFailStatus(TI_HANDLE hSiteMgr, 
+                                           BOOL bRemoveSite);
+
+TI_STATUS siteMgr_resetPrimarySiteAttemptsNumber(TI_HANDLE  hSiteMgr);
+
+TI_STATUS siteMgr_resetPrevPrimarySiteRssi(TI_HANDLE    hSiteMgr);
+
+TI_STATUS siteMgr_selectSite(TI_HANDLE  hSiteMgr);
+
+siteEntry_t* siteMgr_selectSiteFromTable(TI_HANDLE  hSiteMgr);
+
+void siteMgr_setNotReceivedParameter(TI_HANDLE  hSiteMgr, ssid_t* ssid , radioBand_e band);
+
+void siteMgr_resetAttemptsNumberParameter(TI_HANDLE hSiteMgr);
+
+void siteMgrControlLnaOperation(TI_HANDLE hSiteMgr, BOOL NextState);
+
+BOOL siteMgr_isCurrentBand24(TI_HANDLE  hSiteMgr);
+
+BOOL siteMgr_isThereCountryIEforCurrentBand(TI_HANDLE   hSiteMgr);
+
+BOOL siteMgr_isThereValidSSID (TI_HANDLE hSiteMgr);
+
+TI_STATUS pbccAlgorithm(TI_HANDLE hSiteMgr);
+
+TI_STATUS siteMgr_assocReport(TI_HANDLE hSiteMgr, UINT16 capabilities, BOOL bCiscoAP);
+
+void siteMgr_setCurrentTable(TI_HANDLE hSiteMgr, radioBand_e radioBand);
+
+void siteMgr_updateRates(TI_HANDLE hSiteMgr, BOOL dot11a, BOOL updateToOS);
+
+void siteMgr_bandParamsConfig(TI_HANDLE hSiteMgr, BOOL updateToOS);
+
+void siteMgr_ConfigRate(TI_HANDLE hSiteMgr);
+
+TI_STATUS siteMgr_getWMEParamsSite(TI_HANDLE hSiteMgr,ACParameters_t **pWME_ACParameters_t);
+
+TI_STATUS siteMgr_setWMEParamsSite(TI_HANDLE hSiteMgr,dot11_WME_PARAM_t *pDot11_WME_PARAM);
+
+void siteMgr_resetChannelList(TI_HANDLE hSiteMgr);
+
+siteEntry_t *siteMgr_findSiteEntry(TI_HANDLE hSiteMgrm, macAddress_t *bssid);
+
+TI_STATUS siteMgr_resetEventStatisticsHistory(TI_HANDLE hSiteMgr);
+
+void siteMgr_IsERP_Needed(TI_HANDLE hSiteMgr,BOOL *useProtection,BOOL *NonErpPresent,BOOL *barkerPreambleType);
+
+TI_STATUS siteMgr_updateNewApList (TI_HANDLE hSiteMgr);
+
+TI_STATUS siteMgr_overwritePrimarySite(TI_HANDLE hSiteMgr, bssEntry_t *newAP, BOOL requiredToStorePrevSite);
+
+void siteMgr_clearFirstBcnFlag(TI_HANDLE hSiteMgr);
+
+void siteMgr_setFirstBcnFlag(TI_HANDLE hSiteMgr);
+
+void siteMgr_checkTxPower(TI_HANDLE hSiteMgr);
+
+void siteMgr_printPrimarySiteDesc(TI_HANDLE hSiteMgr );
+
+void siteMgr_keepAliveSendNullDataTimer(TI_HANDLE hSiteMgr);
+
+#endif /* __SITE_MGR_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/Inc/smeSmApi.h b/sta_dk_4_0_4_32/common/src/core/sme/Inc/smeSmApi.h
new file mode 100644 (file)
index 0000000..95e3c42
--- /dev/null
@@ -0,0 +1,194 @@
+/** \file smeSmApi.h
+ *  \brief SME SM module API
+ *
+ *  \see smeSmApi.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*       MODULE:       smeSmApi.h                                                                                                                              */
+/*    PURPOSE: SME SM API                                                                                      */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __SME_SM_API_H__
+#define __SME_SM_API_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "ScanCncnApi.h"
+
+/* SME SM status definitions */
+
+typedef enum
+{
+       CONN_STATUS_SUCCESS      = 0,
+       CONN_STATUS_FAILURE      = 1,
+       CONN_STATUS_RECONNECTING = 2,
+} connStatus_e;
+
+typedef enum
+{
+       SELECT_STATUS_SUCCESS   = 0,
+       SELECT_STATUS_FAILURE   = 1,
+} selectStatus_t;
+
+/* SME SM interface functions prototypes */
+
+/************************************************************
+  Function: smeSm_create
+  Description: 
+ ************************************************************/ 
+TI_HANDLE smeSm_create(TI_HANDLE hOs);
+
+/************************************************************
+  Function: smeSm_config
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_config(TI_HANDLE               hSmeSm, 
+                                       TI_HANDLE               hConn,
+                                       TI_HANDLE               hScanCncn,
+                                       TI_HANDLE               hSiteMgr,
+                                       TI_HANDLE               hHalCtrl,
+                                       TI_HANDLE               hReport,
+                                       TI_HANDLE               hOs,
+                    TI_HANDLE          hEvHandler,
+                                       TI_HANDLE               hScr,
+                                       TI_HANDLE               hApConn,
+                                       TI_HANDLE               hCurrBss,
+                                       TI_HANDLE               hPowerMgr,
+                    TI_HANDLE       hRegulatoryDomain,
+                                       smeInitParams_t*        smeInitParams);
+
+/************************************************************
+  Function: smeSm_unLoad
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_unLoad(TI_HANDLE               hSmeSm);
+
+/************************************************************
+  Function: smeSm_start
+  Description: Called by configMgr_start
+ ************************************************************/ 
+TI_STATUS smeSm_start(TI_HANDLE                hSmeSm);
+
+
+/************************************************************
+  Function: smeSm_reselect
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_reselect(TI_HANDLE             hSmeSm);
+
+/************************************************************
+  Function: smeSm_stop
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_stop(TI_HANDLE         hSmeSm);
+
+/************************************************************
+  Function: smeSm_stopAndShutdown
+  Description: 
+ ************************************************************/ 
+void smeSm_stopAndShutdown(TI_HANDLE           hSmeSm);
+
+/************************************************************
+  Function: smeSm_getDriverShutdownStatus
+  Description: 
+ ************************************************************/ 
+UINT8 smeSm_getDriverShutdownStatus (TI_HANDLE         hSmeSm);
+
+/************************************************************
+  Function: smeSm_scanComplete
+  Description: 
+ ************************************************************/ 
+void smeSm_scanComplete( TI_HANDLE hSmeSm, scan_cncnResultStatus_e status,
+                         scan_frameInfo_t *frameInfo, UINT16 SPSStatus );
+
+
+/************************************************************
+  Function: smeSm_reportConnStatus
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_reportConnStatus(TI_HANDLE             hSmeSm, 
+                                                         mgmtStatus_e  status, 
+                                                         UINT32 uStatusCode);
+
+/************************************************************
+  Function: smeSm_reportSelectStatus
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_reportSelectStatus(TI_HANDLE           hSmeSm, 
+                                                               mgmtStatus_e    status);
+
+
+/************************************************************
+  Function: smeSm_setParam
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_setParam(TI_HANDLE                     hSmeSm,
+                                               paramInfo_t             *pParam);
+
+
+/************************************************************
+  Function: smeSm_getParam
+  Description: 
+ ************************************************************/ 
+TI_STATUS smeSm_getParam(TI_HANDLE                     hSmeSm, 
+                                               paramInfo_t             *pParam);
+
+
+#ifdef TI_DBG
+/************************************************************
+  Function: smeSm_dbgPrintObject
+  Description: 
+ ************************************************************/ 
+void smeSm_dbgPrintObject( TI_HANDLE hSmeSm );
+
+/************************************************************
+  Function: smeSm_resetStats
+  Description: 
+ ************************************************************/ 
+void smeSm_resetStats( TI_HANDLE hSmeSm );
+
+/************************************************************
+  Function: smeSm_printStats
+  Description: 
+ ************************************************************/ 
+void smeSm_printStats( TI_HANDLE hSmeSm );
+#endif /* TI_DBG */
+
+#endif /* __SME_SM_API_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/configMgr/configMgr.c b/sta_dk_4_0_4_32/common/src/core/sme/configMgr/configMgr.c
new file mode 100644 (file)
index 0000000..51325fd
--- /dev/null
@@ -0,0 +1,2340 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 configMgr.c
+ *  \brief Driver interface to OS abstraction layer
+ *
+ *  \see srcApi.h
+ */
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "srcApi.h"
+#include "report.h"
+#include "whalCtrl_api.h"
+#include "connApi.h"
+#include "siteMgrApi.h"
+#include "smeSmApi.h"
+#include "utils.h"
+#include "fsm.h"
+#include "configMgr.h"
+#include "DataCtrl_Api.h"
+#include "rsnApi.h"
+#include "scrApi.h"
+#include "MacServices_api.h"  
+#include "ScanCncnApi.h"
+#include "scanMngrApi.h"
+#include "regulatoryDomainApi.h"
+#include "measurementMgrApi.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#endif
+#include "SoftGeminiApi.h"
+#include "roamingMngrApi.h"
+#include "qosMngr_API.h"
+#include "whalCtrl.h"
+#include "TrafficMonitor.h"
+#include "PowerMgr_API.h"
+#include "EvHandler.h"
+#include "apConn.h"
+#include "currBss.h"
+#include "SwitchChannelApi.h"
+#include "ScanCncnAppApi.h"
+#include "healthMonitor.h"
+#include "wspVer.h"
+#include "Ethernet.h"
+#include "Core_AdaptTx.h"
+#include "TNETW_Driver_api.h"
+#include "rx.h"
+#include "Ctrl.h"
+
+#include "recoveryMgr_API.h"
+
+/****************************************************/
+/*      Local Functions                             */
+/****************************************************/
+static configMgr_t *createDriver(TI_HANDLE hOs,void *pWLAN_Images, initTable_t *pInitTable);
+
+static void configMgr_config (TI_HANDLE  hConfigManager);
+
+static int createCore(configMgr_t *pConfigManager, TI_HANDLE hOs, initTable_t *pInitTable);
+
+static  void configMgr_RetrieveFWInfo(configMgr_t *pConfigManager, initTable_t *pInitTable, whalCtrl_chip_t *pChip_Version);
+
+static TI_STATUS configCore(configMgr_t *pConfigManager, whalCtrl_chip_t *pChipVer);
+
+static void release_module(configMgr_t *pConfigManager);
+
+static void configParamsAccessTable(configMgr_t *pConfigManager);
+
+UINT32 configMgr_RegisterEvent(TI_HANDLE  hConfigMgr, PUCHAR pData, ULONG Length)
+{
+    configMgr_t *pConfigManager= (configMgr_t *)hConfigMgr;
+    
+    return EvHandlerRegisterEvent(pConfigManager->hEvHandler,pData,Length);
+}
+
+UINT32 configMgr_UnRegisterEvent(TI_HANDLE hConfigMgr, TI_HANDLE uEventID)
+{
+    configMgr_t *pConfigManager= (configMgr_t *)hConfigMgr;
+
+    return EvHandlerUnRegisterEvent(pConfigManager->hEvHandler,uEventID);
+}
+
+UINT32 configMgr_GetEventData(TI_HANDLE hConfigMgr, PUCHAR pData, ULONG* pLength)
+{
+   configMgr_t *pConfigManager= (configMgr_t *)hConfigMgr;
+
+   return EvHandlerGetEventData(pConfigManager->hEvHandler,pData,pLength);
+}
+
+
+/****************************************************/
+/*      Interface Functions Implementation          */
+/****************************************************/
+
+/************************************************************************
+ *                        configMgr_create                              *
+ ************************************************************************
+DESCRIPTION: Driver creation & configuration function, called by the OS abstraction layer, performs the following:
+                -   Create the driver
+                -   Configure the driver
+
+INPUT:      hOs -           Handle to OS
+            pInitTable -    Pointer to the init table as received from the OS abstraction layer
+
+OUTPUT:     pMac- MAC address of the device as read from the chip
+
+RETURN:     Handle to the driver
+
+************************************************************************/
+TI_HANDLE configMgr_create (TI_HANDLE         hOs,
+                            void             *pWLAN_Images,
+                            initTable_t      *pInitTable,
+                            macAddress_t     *pMac)
+{
+    configMgr_t  *pConfigManager;
+
+    /**************** 
+    Create the Driver 
+    *****************/
+    pConfigManager = createDriver(hOs, pWLAN_Images, pInitTable);
+
+    if (pConfigManager == NULL)
+    {
+        WLAN_OS_REPORT(("\n.....Configuration manager creation failure \n"));
+        return NULL;
+    }
+
+    WLAN_REPORT_INIT(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  
+        ("CREATED DRIVER\n"));
+
+    return (TI_HANDLE)pConfigManager;
+}
+
+
+/************************************************************************
+ *                        configMgr_init                                *
+ ************************************************************************
+DESCRIPTION: FW Code Download in partition
+
+INPUT:      hOs -           Handle to OS
+            TI_HANDLE       hConfigManager
+            pInitTable -    Pointer to the init table as received from the OS abstraction layer
+
+OUTPUT:     pMac- MAC address of the device as read from the chip
+
+RETURN:     Handle to the driver
+
+************************************************************************/
+TI_HANDLE configMgr_init (TI_HANDLE     hOs, 
+                          TI_HANDLE     hConfigManager, 
+                          void         *pWLAN_Images,
+                          initTable_t  *pInitTable,
+                          macAddress_t *pMacAddr)
+{
+    configMgr_t  *pConfigManager = (configMgr_t *)hConfigManager;
+
+    pConfigManager->pInitTable = pInitTable; 
+    pConfigManager->pMacAddr = pMacAddr;
+
+    /*
+     * Init the module and Download the FW code in partition
+     * At this stage it is very important that the pConfigManager has been created and linked to the HAL Ctrl
+     * so that if the first DMA ends before the user returns to wait for the end of DMA
+     * then the pConfigManager will have a valid value 
+     */
+    if (TnetwDrv_Init (pConfigManager->hTnetwDrv, 
+                       pConfigManager->hReport,
+                       pConfigManager->hMemMgr,
+                       hConfigManager,
+                       pWLAN_Images,
+                       &pInitTable->TnetwDrv_InitParams,
+                       configMgr_config) == TNETWIF_ERROR)
+    {
+        WLAN_OS_REPORT(("\n.....TNETW_Driver_Initialize: TNETW_Driver_Init failure \n"));
+        return NULL;
+    }
+
+    return pConfigManager->hTnetwDrv;
+}
+
+
+/************************************************************************
+DESCRIPTION: Driver creation & configuration function, called by the OS abstraction layer, performs the following:
+                -   Create the driver
+                -   Configure the driver
+
+INPUT:      hOs -           Handle to OS
+            pInitTable -    Pointer to the init table as received from the OS abstraction layer
+
+OUTPUT:     pMac- MAC address of the device as read from the chip
+
+RETURN:     Handle to the driver
+
+************************************************************************/
+static void configMgr_config (TI_HANDLE  hConfigManager)
+{
+    configMgr_t     *pConfigManager = (configMgr_t *)hConfigManager;
+    whalCtrl_chip_t  chipVer;
+    UINT8           *pMac;
+
+    /**************** 
+    Config the Driver 
+    *****************/
+    WLAN_OS_REPORT(("Initializing Config Manager...\n"));
+
+    if (configCore (pConfigManager, &chipVer) == NOK)
+    {
+        WLAN_OS_REPORT(("\n.....Configuration manager configuration failure\n"));
+        release_module (pConfigManager);
+        return;
+    }
+
+    pMac = (UINT8 *)chipVer.macAddress.addr;
+
+    os_memoryCopy (pConfigManager->hOs, 
+                   pConfigManager->pMacAddr, 
+                   (void *)pConfigManager->pInitTable->ctrlDataInitParams.ctrlDataDeviceMacAddress.addr, 
+                   MAC_ADDR_LEN);
+
+    pConfigManager->state = CFG_MGR_STATE_IDLE;     
+
+    /* Print the driver and firmware version and the mac address */
+    WLAN_OS_REPORT(("\n"));
+    WLAN_OS_REPORT(("--------------------------------------------------------------------\n"));
+    WLAN_OS_REPORT(("Driver Version  : %s\n", SW_VERSION_STR));
+    WLAN_OS_REPORT(("Firmware Version: %s\n", chipVer.fwVer));
+    WLAN_OS_REPORT(("Station ID      : %02X-%02X-%02X-%02X-%02X-%02X\n",
+                    pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5]));
+    WLAN_OS_REPORT(("--------------------------------------------------------------------\n"));
+    WLAN_OS_REPORT(("\n"));
+}
+
+
+/************************************************************************
+ *                        configMgr_start                               *
+ ************************************************************************
+DESCRIPTION: Driver start function, called by the OS abstraction layer in
+            order to start the driver after creation.
+            It enables the ISR and sends a start event to the driver's main state machine
+            If the the driver was in IDLE state, it sends a 'WakeUp' command to the chip.
+
+INPUT:      hConfigMgr -    Handle to the driver
+
+OUTPUT:
+
+RETURN:     OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_start(TI_HANDLE hConfigMgr)
+{
+    TI_STATUS  status = PARAM_VALUE_NOT_VALID;
+
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    switch (pConfigManager->state)
+   {
+    case CFG_MGR_STATE_IDLE :
+        pConfigManager->state = CFG_MGR_STATE_RUNNING;
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_IDLE, EVENT_START> --> STATE_RUNNING\n\n"));
+        status = smeSm_start(pConfigManager->hSmeSm);
+
+#ifdef SDIO_INTERRUPT_HANDLING_ON
+        whalCtr_SlaveAckMaskNotification(pConfigManager->hHalCtrl);
+#endif
+        break;
+
+
+   case CFG_MGR_STATE_RUNNING :
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("Got start command while not in RUNNING, ignoring the command"));
+        break;
+
+
+   case CFG_MGR_STATE_STOPPED:
+        pConfigManager->state = CFG_MGR_STATE_RUNNING;
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                         ("<STATE_STOPPED, EVENT_START> --> STATE_RUNNING\n\n"));
+        status = smeSm_start(pConfigManager->hSmeSm);
+        break;
+
+    }
+
+    return status;
+}
+
+
+/************************************************************************
+ *                        configMgr_stop                                *
+ ************************************************************************
+DESCRIPTION: Driver stop function, called by the OS abstraction layer in
+            order to stop the driver.
+            It sends a stop event to the driver main state mmachine
+            If the the driver was in RUNNING state, it sends a 'Sleep' command to the chip.
+
+INPUT:      hConfigMgr -    Handle to the driver
+
+OUTPUT:
+
+RETURN:     OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_stop(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    TI_STATUS   status  = PARAM_VALUE_NOT_VALID;
+
+   switch (pConfigManager->state)
+    {
+    case CFG_MGR_STATE_IDLE :
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                         ("<STATE_IDLE, EVENT_STOP> --> STATE_IDLE\n\n"));  
+        status = STATION_IS_NOT_RUNNING;
+        break;
+
+   case CFG_MGR_STATE_RUNNING :
+        pConfigManager->state = CFG_MGR_STATE_STOPPED;
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                         ("<STATE_RUNNING, EVENT_STOP> --> STATE_STOPPED\n\n"));
+        smeSm_stop(pConfigManager->hSmeSm);
+        break;
+   case CFG_MGR_STATE_STOPPED:
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                         ("<STATE_STOPPED, EVENT_STOP> --> STATE_STOPPED\n\n"));
+        status = STATION_IS_NOT_RUNNING;
+        break;
+
+    }
+
+   return status;
+}
+
+/****************************************************************************************
+ *                        configMgr_setParam                                            *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to set a parameter the driver.
+                If the parameter can not be set from outside the driver it returns a fialure status
+                The parameters is set to the module that uses as its father in the system
+                (refer to the file paramOut.h for more explanations)
+                If the father returns a RE_SCAN_NEEDED status, it restarts the main
+                state machine of the driver.
+
+
+INPUT:          hConfigMgr -    Handle to the driver
+                pParam  -       Pointer to the parameter
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_setParam(TI_HANDLE hConfigMgr, paramInfo_t *pParam)                          
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    TI_STATUS    status;
+    UINT32       moduleNumber;
+
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_SET_PARAM while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_SET_PARAM> --> STATE_RUNNING\n\n"));
+
+
+    if (!EXTERNAL_SET_ENABLE(pParam->paramType))
+        return EXTERNAL_SET_PARAM_DENIED;
+
+    moduleNumber = GET_PARAM_MODULE_NUMBER(pParam->paramType);
+
+    if  (moduleNumber > MAX_PARAM_MODULE_NUMBER)
+        return PARAM_MODULE_NUMBER_INVALID;
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                   ("ParamType=0x%x ModuleNumber=0x%x\n\n",pParam->paramType));
+
+    status = pConfigManager->paramAccessTable[moduleNumber - 1].set(pConfigManager->paramAccessTable[moduleNumber - 1].handle, pParam);
+    
+    if(status == RE_SCAN_NEEDED)
+        return smeSm_reselect(pConfigManager->hSmeSm);
+    else
+        return status;
+
+}
+
+/****************************************************************************************
+ *                        configMgr_getParam                                            *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to get a parameter the driver.
+                If the parameter can not be get from outside the driver it returns a fialure status
+                The parameters is get from the module that uses as its father in the system
+                (refer to the file paramOut.h for more explanations)
+
+
+INPUT:          hConfigMgr -    Handle to the driver
+                pParam  -       Pointer to the parameter
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_getParam (TI_HANDLE hConfigMgr, paramInfo_t *pParam)
+                          
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    UINT32       moduleNumber;
+
+    /* This is a unique parameter, it checks the driver running status, therefore we handle it here. */
+    if (pParam->paramType == DRIVER_STATUS_PARAM)
+    {
+        if (pConfigManager->state == CFG_MGR_STATE_RUNNING)
+            pParam->content.driverStatus = DRIVER_STATUS_RUNNING;
+        else
+            pParam->content.driverStatus = DRIVER_STATUS_IDLE;
+        return OK;
+    }
+
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_GET_PARAM while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_GET_PARAM> --> STATE_RUNNING\n\n"));
+
+    if (!EXTERNAL_GET_ENABLE(pParam->paramType))
+        return EXTERNAL_GET_PARAM_DENIED;
+
+    moduleNumber = GET_PARAM_MODULE_NUMBER(pParam->paramType);
+
+    if  (moduleNumber > MAX_PARAM_MODULE_NUMBER)
+        return PARAM_MODULE_NUMBER_INVALID;
+
+    return pConfigManager->paramAccessTable[moduleNumber - 1].get(pConfigManager->paramAccessTable[moduleNumber - 1].handle, pParam);
+}
+
+
+/****************************************************************************************
+ *                        configMgr_checkTxQueueSize                                            *
+ ****************************************************************************************
+DESCRIPTION:    Check Tx queue size
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on queue full
+
+************************************************************************/
+TI_STATUS configMgr_checkTxQueueSize(TI_HANDLE hConfigMgr,UINT8 qIndex)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    return txData_checkQueueSize(pConfigManager->hTxData, qIndex);
+}
+
+
+/****************************************************************************************
+ *                        configMgr_printTxQueues                                            *
+ ****************************************************************************************
+DESCRIPTION:    Tx queues print
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+
+************************************************************************/
+#ifdef TI_DBG
+void configMgr_printTxQueuesAndMemPolls(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    txData_printTxQosCounters(pConfigManager->hTxData);
+    txData_fullPrintDataMsduList(pConfigManager->hTxData);
+    memMngrPrint(pConfigManager->hMemMgr);
+}
+#endif
+
+
+/****************************************************************************************
+ *                        configMgr_sendMsdu                                            *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstract in layer in order to send a MSDU to the wlan network.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+                pMsdu       -   Pointer to the MSDU
+                packet_DTag -   NDIS packet user priority tag
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_sendMsdu (TI_HANDLE      hConfigMgr,
+                              mem_MSDU_T    *pMsdu,
+                              UINT8          packet_DTag)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    TI_STATUS  status = OK;     
+
+#ifdef TI_DBG
+    /* Add time stamp */
+    wlan_memMngrAddTimeStamp (pConfigManager->hMemMgr, pMsdu);
+
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_SEND_MSDU while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_SEND_MSDU> --> STATE_RUNNING\n\n"));
+#endif
+
+   WLAN_REPORT_DEBUG_TX(pConfigManager->hReport,("configMgr_sendMsdu Sending packet Lenght\n",pMsdu->dataLen));
+   status =  txData_sendPktToWlan(pConfigManager->hTxData, pMsdu, packet_DTag);
+   return status;
+}
+
+
+/****************************************************************************************
+ *                        configMgr_PollApPackets                                           *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to send VAD frame.
+                Calls the txData module corresponding function.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_PollApPackets(TI_HANDLE     hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_SEND_MSDU while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_SEND_VAD_FRAME> --> STATE_RUNNING\n\n"));
+
+    return txData_sendVadFrame(pConfigManager->hTxData, POLL_AP_PACKETS_FORCE_PS_POLL);
+}
+
+
+
+/****************************************************************************************
+ *                        configMgr_HandleBusTxn_Complete                                    *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order notify the driver that the DMA has finished
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_HandleBusTxn_Complete(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    whalCtrl_HandleBusTxn_Complete(pConfigManager->hHalCtrl);
+    return OK;
+}
+
+/****************************************************************************************
+ *                        configMgr_handleInterrupts                                    *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order notify the driver that a ISR arrived
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_handleInterrupts(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    return (TI_STATUS)whalCtrl_HandleInterrupts(pConfigManager->hHalCtrl);
+}
+
+/****************************************************************************************
+ *                        configMgr_enableInterrupts                                    *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to enable interrupts
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_enableInterrupts(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    whalCtrl_EnableInterrupts(pConfigManager->hHalCtrl);
+    return OK;
+}
+
+/****************************************************************************************
+ *                        configMgr_disableInterrupts                                   *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to disable interrupts
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_disableInterrupts(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    whalCtrl_DisableInterrupts(pConfigManager->hHalCtrl);
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        configMgr_disableRadio                                    *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to disable Radio
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_disableRadio(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_DISABLE_RADIO> --> STATE_RUNNING\n\n"));
+
+    /* Disable radio command is no longer active, and should be directed to the SME module. */
+    /* whalCtrl_DisableRadio(pConfigManager->hHalCtrl); */
+    return OK;
+
+}
+
+
+/****************************************************************************************
+ *                        configMgr_checkInterrupts                                     *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to let the driver check if
+                the receive interrupt is a driver's ISR.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+UINT32 configMgr_checkInterrupts(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    return whalCtrl_CheckInterrupts(pConfigManager->hHalCtrl);
+}
+
+
+/****************************************************************************************
+ *                        configMgr_ReadMacRegister                                     *
+ ****************************************************************************************
+DESCRIPTION:    API function for registers read/write
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:
+************************************************************************/
+UINT32 configMgr_ReadMacRegister(TI_HANDLE hConfigMgr, UINT32   addr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    return whalCtrlReadMacReg(pConfigManager->hHalCtrl, addr);
+}
+
+void  configMgr_WriteMacRegister(TI_HANDLE hConfigMgr, UINT32   addr, UINT32    val)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    whalCtrlWriteMacReg(pConfigManager->hHalCtrl, addr, val);
+}
+
+UINT32 configMgr_ReadPhyRegister(TI_HANDLE hConfigMgr, UINT32   addr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+        return whalCtrlReadPhyReg(pConfigManager->hHalCtrl, addr);
+}
+
+void configMgr_WritePhyRegister(TI_HANDLE hConfigMgr, UINT32    addr, UINT32    val)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    whalCtrlWritePhyReg(pConfigManager->hHalCtrl, addr, val);
+}
+
+/****************************************************************************************
+ *                        configMgr_isCardExist                                         *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to check if the card is inserted.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+BOOL configMgr_isCardExist(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    if (whalCtrl_isCardIn(pConfigManager->hHalCtrl) == TRUE)
+        return TRUE;
+    else
+    {
+        wlan_memMngrFreeAllOsAlocatesBuffer(pConfigManager->hMemMgr);
+        return FALSE;
+    }
+}
+
+/****************************************************************************************
+ *                        configMgr_areInputsFromOsDisabled                                         *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstractin layer in order to 
+                check if Inputs From OS are Disabled.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         TRUE  - recovery is in process, 
+                FALSE - recovery is not in process
+
+************************************************************************/
+BOOL configMgr_areInputsFromOsDisabled(TI_HANDLE hConfigMgr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    return (recoveryMgr_areInputsFromOsDisabled(pConfigManager->hRecoveryMgr));
+}
+
+/****************************************************************************************
+ *                        configMgr_allocBDs                                            *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction in order to allocate BDs from the memory manager pool.
+                Calls the memory manager corresponding function.
+
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+                bdNumber -      Number of BDs to allocate
+
+OUTPUT:         bdPtr    -      Pointer to return the link list of allocated BDs.
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_allocBDs(TI_HANDLE  hConfigMgr,
+                             UINT32     bdNumber,
+                             mem_BD_T** bdPtr)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+    TI_STATUS Status;
+
+#ifdef TI_DBG
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_ERROR(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_ALLOC_BDS while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_ALLOC_BDS> --> STATE_RUNNING\n\n"));
+#endif
+
+    Status = wlan_memMngrAllocBDs(pConfigManager->hMemMgr, bdNumber, bdPtr);
+    return Status;
+}
+
+/****************************************************************************************
+ *                        configMgr_allocMSDU                                           *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to allocate a MSDU and its associated
+                BDs and data buffers.
+                Calls the memory manager corresponding function.
+
+INPUT:          hConfigMgr  -   Handle to the driver
+                len         -   the length of the required data buffer
+                module      -   The module that requests the allocation.
+
+OUTPUT:         MSDUPtr  -      Pointer to return he allocated MSDU.
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_allocMSDU(TI_HANDLE    hConfigMgr,
+                              mem_MSDU_T** MSDUPtr,
+                              UINT32       len,
+                              allocatingModule_e module)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+#ifdef TI_DBG
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_ALLOC_MSDU while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_ALLOC_MSDU> --> STATE_RUNNING\n\n"));
+#endif
+
+    return wlan_memMngrAllocMSDU(pConfigManager->hMemMgr, MSDUPtr, len, OS_ABS_TX_MODULE);
+}
+
+/****************************************************************************************
+ *                        configMgr_allocMSDUBufferOnly                                         *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to allocate a MSDU only.
+                Calls the memory manager corresponding function.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+                module      -   The module that requests the allocation.
+
+OUTPUT:         MSDUPtr  -      Pointer to return he allocated MSDU.
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_allocMSDUBufferOnly(TI_HANDLE    hConfigMgr,
+                                        mem_MSDU_T** MSDUPtr,
+                                        allocatingModule_e module)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+#ifdef TI_DBG
+    if (pConfigManager->state != CFG_MGR_STATE_RUNNING)
+    {
+        WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  ("State machine error, EVENT_ALLOC_MSDU_BUFFER_ONLY while in IDLE state \n\n"));
+        return STATION_IS_NOT_RUNNING;
+    }
+
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_ALLOC_MSDU_BUFFER_ONLY> --> STATE_RUNNING\n\n"));
+#endif
+
+    return wlan_memMngrAllocMSDUBufferOnly(pConfigManager->hMemMgr, MSDUPtr, OS_ABS_TX_MODULE);
+}
+
+/****************************************************************************************
+ *                        configMgr_memMngrFreeMSDU                                         *
+ ****************************************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to free a MSDU.
+                Calls the memory manager corresponding function.
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+                handle      -   handle of the MSDU.
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_memMngrFreeMSDU(TI_HANDLE hConfigMgr, UINT32 handle)                                    
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigMgr;
+
+#ifdef TI_DBG
+    WLAN_REPORT_SM(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,
+                              ("<STATE_RUNNING, EVENT_FREE_MSDU> --> STATE_RUNNING\n\n"));
+#endif
+
+    wlan_memMngrFreeMSDU(pConfigManager->hMemMgr, handle);
+    return OK;
+}
+
+/****************************************************************************************
+ *                        configMgr_unLoad                                              *
+ ****************************************************************************************
+DESCRIPTION:    Driver unload function
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_unLoad(TI_HANDLE hConfigMgr)
+{
+    configMgr_t     *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    if (!pConfigManager)
+        return NOK;
+
+    whalCtrl_Stop(pConfigManager->hHalCtrl);
+
+    WLAN_OS_REPORT(("\nCONFIG_MGR,  UNLOAD:   *****  DESTROYING THE DRIVER  *****\n\n\n"));
+    release_module(pConfigManager);
+
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        configMgr_InitiateUnload                                              *
+ ****************************************************************************************
+DESCRIPTION:    Driver unload function
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_InitiateUnload(TI_HANDLE hConfigMgr)
+{
+    configMgr_t     *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    if (!pConfigManager)
+        return NOK;
+
+    smeSm_stopAndShutdown(pConfigManager->hSmeSm);
+
+    WLAN_OS_REPORT(("\nCONFIG_MGR,  UNLOAD:   *****  DESTROYING THE DRIVER  *****\n\n\n"));
+
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        configMgr_UnloadModules                                              *
+ ****************************************************************************************
+DESCRIPTION:    Driver unload function
+
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+TI_STATUS configMgr_UnloadModules(TI_HANDLE hConfigMgr)
+{
+    configMgr_t     *pConfigManager = (configMgr_t *)hConfigMgr;
+
+    if (!pConfigManager)
+        return NOK;
+
+    release_module(pConfigManager);
+
+    return OK;
+}
+
+/****************************************************************************************
+ *                        configMgr_DriverShutdownStatus                                              *
+ ****************************************************************************************
+DESCRIPTION:    return status of driver shutdown process 
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+UINT8 configMgr_DriverShutdownStatus(TI_HANDLE hConfigMgr)
+{
+   configMgr_t     *pConfigManager = (configMgr_t *)hConfigMgr;
+
+   return smeSm_getDriverShutdownStatus(pConfigManager->hSmeSm);
+}
+
+/****************************************************************************************
+ *                        configMgr_SlaveAckMaskNotification                                   *
+ ****************************************************************************************
+DESCRIPTION:    
+
+INPUT:          hConfigMgr  -   Handle to the driver
+
+OUTPUT:        
+
+RETURN:         void
+
+************************************************************************/
+
+void configMgr_SlaveAckMaskNotification(TI_HANDLE hConfigMgr)
+{
+    configMgr_t     *pConfigManager = (configMgr_t *)hConfigMgr;
+    whalCtr_SlaveAckMaskNotification(pConfigManager->hHalCtrl); 
+}
+
+/****************************************************************************************
+ *                        configMgr_getPacketHeaderLength                                   *
+ ****************************************************************************************
+DESCRIPTION:    Called by os to know reserved space for WLAN header.
+
+INPUT:          hConfigMgr  -   Handle to the driver
+                data        -   pointer to packet
+                txFlags     -   whether this frame is data or management
+OUTPUT:          
+
+RETURN:         void
+
+************************************************************************/
+
+UINT32 configMgr_getPacketHeaderLength(TI_HANDLE      hConfigMgr,
+                                       void           *pData,
+                                       UINT32         txFlags)
+{
+    configMgr_t          *pConfigManager = (configMgr_t *)hConfigMgr;
+    
+    /* returns TxDescriptor size + reserved place for the bus txn operation + actual header length */
+    return TX_TOTAL_OFFSET_BEFORE_DATA +
+        txData_GetWlanHeaderLength (pConfigManager->hTxData, pData, txFlags);
+}
+
+
+/****************************************************/
+/*      Local Functions Implementations             */
+/****************************************************/
+/****************************************************************************************
+ *                        createDriver                                              *
+ ****************************************************************************************
+DESCRIPTION:    Driver creation function. Performs the following:
+                -   Calls the create function of each module.
+                -   Each module returns a handle if successful and NULL otherwise.
+                -   If the creation of all the modules succeeded, the driver main handle is configured with the
+                        modules handles. Then the driver main handle is returned to the caller.
+                -   If one of the modules fails in creation, the function calls the release function of the driver
+                    and all the modules handles are free, including the driver main handle.
+                -   Some of the modules are called with an init table as a parameter.
+                -   The callbacks table is filled with the callbacks returned from the core, in the configuration phase,
+                    the HAL is configured with those callbacks.
+
+
+INPUT:          hOs        -    Handle to the OS
+                pInitTable -    Pointer to the init table as read from registry
+                pCoreCallbacks   -  Table of core callbacks functions to filled by the CORE
+
+OUTPUT:         Main Handle to the driver.
+
+RETURN:         Handle to the driver on success, NOK on failure
+
+************************************************************************/
+static configMgr_t *createDriver(TI_HANDLE hOs, void *pWLAN_Images, initTable_t *pInitTable)
+{
+    configMgr_t             *pConfigManager;
+    
+    /************************ 
+    Create the Config Manager 
+    *************************/
+    pConfigManager = os_memoryAlloc(hOs, sizeof(configMgr_t));
+    if (pConfigManager == NULL)
+    {
+        return NULL;
+    }
+    os_memoryZero (hOs, pConfigManager, sizeof(configMgr_t));
+    pConfigManager->hOs = hOs;
+
+    /************************** 
+    Create all the CORE modules 
+    ***************************/
+    if (createCore (pConfigManager ,hOs,  pInitTable) != OK)
+    {
+        WLAN_OS_REPORT(("\n createCore() Failed!!! \n"));
+        release_module(pConfigManager);
+        return NULL;
+    }
+    
+    WLAN_INIT_REPORT(("\n createDriver(): pConfigManager->hOs %x pConfigManager->hMemMgr %x!!! :\n\n",pConfigManager->hOs,pConfigManager->hMemMgr));
+
+    /************************** 
+    Configure the Report module 
+    ***************************/
+    if (report_config(pConfigManager->hReport, hOs, &pInitTable->TnetwDrv_InitParams.reportParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n Report configuration failure \n"));
+        release_module(pConfigManager);
+        return NULL;
+    }
+
+    /********************** 
+    Create the TNETW Driver 
+    ***********************/
+    pConfigManager->hTnetwDrv = TnetwDrv_Create(hOs);
+
+    if (pConfigManager->hTnetwDrv == NULL)
+    {
+        WLAN_OS_REPORT(("\n createDriver() !!! TnetwDrv_Create failed !!! \n"));
+        release_module(pConfigManager);
+        return NULL;
+    }
+
+    WLAN_INIT_REPORT(("\n createDriver(): pConfigManager %x pConfigManager->hTnetwDrv %x!!! :\n\n",pConfigManager,pConfigManager->hTnetwDrv));
+
+    /*************************************************************** 
+    TEMPORARY!!  -  get TNETW-Driver internal modules handles untill  
+                    the new TNETW-Driver architecture is completed!!
+    ****************************************************************/
+    TnetwDrv_TEMP_GetHandles (pConfigManager->hTnetwDrv, 
+                              &pConfigManager->hHalCtrl,
+                              &pConfigManager->hMacServices);
+    
+    WLAN_INIT_REPORT(("\nCONFIG_MGR,  INIT:       *****   CREATION SUCCESS    *****\n\n\n"));
+      
+    return pConfigManager;
+}
+
+/****************************************************************************************
+ *                        createCore                                   *
+ ****************************************************************************************
+DESCRIPTION:   Called by the CreateDriver to 
+                        - Create the CORE modules
+                        - Create the CORE Adapter module
+                        - Config the CORE Adapter module by giving it CORE callbacks
+
+INPUT:          TI_HANDLE hOs  -   Handle to OS
+                initTable_t *pInitTable - pointer to the Init table filled by the registry
+                coreCallbacks_t *pCoreCallbacks  - pointer to the CORE callbacks to be used by each module to fll it (Scan,CtrlData ..)
+
+OUTPUT:         TI_STATUS - OK on success else NOK
+
+RETURN:         void
+
+************************************************************************/
+static int createCore(configMgr_t *pConfigManager, TI_HANDLE hOs, initTable_t *pInitTable)
+{
+    /* Report module */
+    pConfigManager->hReport = report_create(hOs);
+    if (pConfigManager->hReport == NULL)
+    {
+        return NOK;
+    }
+
+    /* SCR module */
+    pConfigManager->hSCR = scr_create(hOs);
+    if (pConfigManager->hSCR == NULL)
+    {
+        return NOK;
+    }
+
+    /* Event Handler module */
+    pConfigManager->hEvHandler = EvHandlerInit(hOs);
+    if (pConfigManager->hEvHandler == NULL)
+    {
+        return NOK;
+    }
+
+    /* Connection module */
+    pConfigManager->hConn = conn_create(hOs);
+    if (pConfigManager->hConn == NULL)
+    {
+        return NOK;
+    }
+
+    /* Scan Concentrator module */
+    pConfigManager->hScanCncn = scanConcentrator_create(hOs);
+    if (pConfigManager->hScanCncn == NULL)
+    {
+        return NOK;
+    }
+
+    /* SME state machine module */
+    pConfigManager->hSmeSm = smeSm_create(hOs);
+    if (pConfigManager->hSmeSm == NULL)
+    {
+        return NOK;
+    }
+
+    /* Site manager module */
+    pConfigManager->hSiteMgr = siteMgr_create(hOs);
+    if (pConfigManager->hSiteMgr == NULL)
+    {
+        return NOK;
+    }
+
+    /* MLME SM module */
+    pConfigManager->hMlmeSm = mlme_create(hOs);
+    if (pConfigManager->hMlmeSm == NULL)
+    {
+        return NOK;
+    }
+
+    /* AUTH module */
+    pConfigManager->hAuth = auth_create(hOs);
+    if (pConfigManager->hAuth == NULL)
+    {
+        return NOK;
+    }
+
+    /* ASSOC module */
+    pConfigManager->hAssoc = assoc_create(hOs);
+    if (pConfigManager->hAssoc == NULL)
+    {
+        return NOK;
+    }
+
+    /* Rx data module */
+    pConfigManager->hRxData = rxData_create(hOs);
+    if (pConfigManager->hRxData == NULL)
+    {
+        return NOK;
+    }
+
+    /* Tx data module */
+    pConfigManager->hTxData = txData_create (&pInitTable->txDataInitParams, hOs);                                           
+    if (pConfigManager->hTxData == NULL)
+    {
+        return NOK;
+    }
+
+    /* Ctrl data module */
+    pConfigManager->hCtrlData = ctrlData_create(hOs);
+    if (pConfigManager->hCtrlData == NULL)
+    {
+        return NOK;
+    }
+
+    /* Traffic Monitor  */
+    pConfigManager->hTrafficMon = TrafficMonitor_create(hOs);
+    if (pConfigManager->hTrafficMon == NULL)
+    {
+        return NOK;
+    }
+
+    /* Memory Manager */
+    pConfigManager->hMemMgr = wlan_memMngrInit(hOs);
+    if (pConfigManager->hMemMgr == NULL)
+    {
+        return NOK;
+    }
+
+    /* RSN create code */
+    pConfigManager->hRsn = rsn_create(hOs);
+    if (pConfigManager->hRsn == NULL)
+    {
+        return NOK;
+    }
+
+    /* Regulatory Domain module */
+    pConfigManager->hRegulatoryDomain = regulatoryDomain_create(hOs);
+    if (pConfigManager->hRegulatoryDomain == NULL)
+    {
+        return NOK;
+    }
+
+    /* MeasurementMgr module */
+    pConfigManager->hMeasurementMgr = measurementMgr_create(hOs);
+    if (pConfigManager->hMeasurementMgr == NULL)
+    {
+        return NOK;
+    }
+
+    /* Soft Gemini module */
+    pConfigManager->hSoftGemini = SoftGemini_create(hOs);
+    if (pConfigManager->hSoftGemini == NULL)
+    {
+        return NOK;
+    }
+
+
+#ifdef EXC_MODULE_INCLUDED
+    pConfigManager->hExcMngr = excMngr_create(hOs);
+    if (pConfigManager->hExcMngr == NULL)
+    {
+        return NOK;
+    }
+#else
+    pConfigManager->hExcMngr = NULL;
+#endif
+
+    pConfigManager->hRoamingMngr = roamingMngr_create(hOs);
+    if (pConfigManager->hRoamingMngr == NULL)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hAPConnection = apConn_create(hOs);
+    if (pConfigManager->hAPConnection == NULL)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hCurrBss = currBSS_create(hOs);
+    if (pConfigManager->hCurrBss == NULL)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hQosMngr = qosMngr_create(hOs);
+    if (pConfigManager->hQosMngr == NULL)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hPowerMgr = PowerMgr_create(hOs);
+    if (pConfigManager->hPowerMgr == NULL)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hSwitchChannel = switchChannel_create(hOs);
+    if (pConfigManager->hSwitchChannel == NULL)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hScanMngr = scanMngr_create(hOs);
+    if (NULL == pConfigManager->hScanMngr)
+    {
+        return NOK;
+    }
+
+    pConfigManager->hHealthMonitor = healthMonitor_create(hOs);
+    if (NULL == pConfigManager->hHealthMonitor)
+    {
+        return NOK;
+    }
+
+    /* CORE ADAPTER CREATION */    
+
+    /* ADD CORE ADAPTER Tx CREATION */
+    CORE_AdaptTx_handle = CORE_AdaptTx_Create(hOs);
+    if (CORE_AdaptTx_handle == NULL)
+    {
+        return NOK;
+    }  
+
+    pConfigManager->hRecoveryMgr = recoveryMgr_create(hOs);
+#ifdef USE_RECOVERY
+    if (NULL == pConfigManager->hRecoveryMgr)
+    {
+        return NOK;
+    }
+#endif
+    WLAN_INIT_REPORT(("\nCONFIG_MGR,  INIT:       *****   CORE CREATION SUCCESS    *****\n\n\n"));
+
+    return OK;
+}
+
+
+/****************************************************************************************
+ *                        configCore                                              *
+ ****************************************************************************************
+DESCRIPTION:    Core configuration function. Performs the following:
+                -   Calls the config Params Access function.
+                -   Calls the config function of each module.
+                -   Each module is configured with the following parameters:
+                    -   List of handles to other modules that supply him services
+                    -   Init table (optional).
+                    -   Callbacks to be used (in the HAL cases)
+                -   In addition, the following parameters are read from the chip by the HAL and forwarded to the CORE:
+                    -   Chip MAC Address
+                    -   Chip regulatory domain
+                    -   Chip preamble
+                    -   Chip FW version and EEPROM version
+                    -   Radio type
+
+INPUT:          pConfigManager     -    Driver main handle
+                pInitTable          -   Pointer to the init table as read from registry
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+static TI_STATUS configCore (configMgr_t *pConfigManager, whalCtrl_chip_t *pChipVer)
+{
+    /************************/
+    /*      CONFIGURATION   */
+    /************************/
+    /*radioDisableParams_t    radioDisableParams;*/
+    Core_AdaptTx_config_t   Core_AdaptTx_config;
+
+    /* we first initialize the setParamTable & getParamTable based on the moduleParam_e */
+    configParamsAccessTable (pConfigManager);
+
+    /*
+     * Retrieve FW information from HAL
+     */
+    configMgr_RetrieveFWInfo (pConfigManager, pConfigManager->pInitTable, pChipVer);
+
+    /* CORE Adapter configuration is setting callback to each module */       
+
+    /* CORE ADAPTER TX module */
+    Core_AdaptTx_config.hMemMgr = pConfigManager->hMemMgr;  
+    Core_AdaptTx_config.hReport = pConfigManager->hReport;  
+    Core_AdaptTx_config.hTnetwDrv = pConfigManager->hTnetwDrv;
+    Core_AdaptTx_config.hTxData = pConfigManager->hTxData;
+    Core_AdaptTx_config.hCtrlData = pConfigManager->hCtrlData;
+
+    /* sendPacketComplete event callback */
+    /*Core_AdaptTx_config.TxCmplt_CB = pCoreCallbacks->ctrlData_TxCompleteStatusCB;*/
+    /*Core_AdaptTx_config.TxCmplt_CB_handle = pConfigManager->hCtrlData;*/
+
+    /* sendPacketTransfer event callback */
+    /*Core_AdaptTx_config.PacketTranfer_CB = pCoreCallbacks->txData_SendPacketTranferCB;*/
+    /*Core_AdaptTx_config.PacketTranfer_CB_handle = pConfigManager->hTxData;*/
+
+    /* queueFreeEvent event callback */
+    /*Core_AdaptTx_config.QueueFreeEvent_CB = pCoreCallbacks->txData_QueueFreeEventCB;*/
+    /*Core_AdaptTx_config.QueueFreeEvent_CB_handle = pConfigManager->hTxData;*/
+    WLAN_OS_REPORT(("Initializing Core Adapter Tx...\n"));
+    if (CORE_AdaptTx_Config (CORE_AdaptTx_handle, 
+                             &Core_AdaptTx_config, 
+                             &pConfigManager->pInitTable->txDataInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....CORE ADAPTER TX configuration failure \n"));
+            return NOK;
+    }
+    
+    /* SCR module */
+    WLAN_OS_REPORT(("Initializing SCR...\n"));
+    scr_init (pConfigManager->hSCR, pConfigManager->hReport);
+    
+    /* connection module */
+    WLAN_OS_REPORT(("Initializing Conn...\n"));
+    if (conn_config (pConfigManager->hConn, 
+                     pConfigManager->hSiteMgr,
+                     pConfigManager->hSmeSm, 
+                     pConfigManager->hMlmeSm,
+                     pConfigManager->hRsn, 
+                     pConfigManager->hRxData,
+                     pConfigManager->hTxData, 
+                     pConfigManager->hReport,
+                     pConfigManager->hOs, 
+                     pConfigManager->hPowerMgr,
+                     pConfigManager->hCtrlData, 
+                     pConfigManager->hMeasurementMgr,
+                     pConfigManager->hTrafficMon, 
+                     pConfigManager->hSCR,
+                     pConfigManager->hExcMngr, 
+                     pConfigManager->hQosMngr,
+                     pConfigManager->hHalCtrl, 
+                     pConfigManager->hScanCncn,    
+                     pConfigManager->hCurrBss, 
+                     pConfigManager->hSwitchChannel,
+                     pConfigManager->hEvHandler, 
+                     pConfigManager->hHealthMonitor,
+                     pConfigManager->hMacServices,
+                     pConfigManager->hRegulatoryDomain,
+                     pConfigManager->hSoftGemini,
+                     &pConfigManager->pInitTable->connInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....Conn configuration failure \n"));
+        return NOK;
+    }
+
+    /* Ctrl data module */
+    WLAN_OS_REPORT(("Initializing Ctrl Data...\n"));
+    if (ctrlData_config (pConfigManager->hCtrlData, 
+                         pConfigManager->hHalCtrl, 
+                         pConfigManager->hSiteMgr,
+                         pConfigManager->hTxData, 
+                         pConfigManager->hRxData, 
+                         pConfigManager->hOs, 
+                         pConfigManager->hReport, 
+                         pConfigManager->hMemMgr, 
+                         pConfigManager->hEvHandler, 
+                         pConfigManager->hAPConnection, 
+                         pConfigManager->hTrafficMon,
+                         conn_disConnFrameSentCBFunc, 
+                         pConfigManager->hConn, 
+                         &pConfigManager->pInitTable->ctrlDataInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....CTRL DATA configuration failure \n"));
+        return NOK;
+    }
+
+    /* Site manager module */
+    WLAN_OS_REPORT(("Initializing Site Manager...\n"));
+    if (siteMgr_config (pConfigManager->hSiteMgr, 
+                        pConfigManager->hConn, 
+                        pConfigManager->hSmeSm,
+                        pConfigManager->hCtrlData,
+                        pConfigManager->hRxData, 
+                        pConfigManager->hTxData,
+                        pConfigManager->hRsn, 
+                        pConfigManager->hAuth, 
+                        pConfigManager->hAssoc,
+                        pConfigManager->hHalCtrl,
+                        pConfigManager->hMlmeSm, 
+                        pConfigManager->hRegulatoryDomain,
+                        pConfigManager->hMeasurementMgr,
+                        pConfigManager->hAPConnection,
+                        pConfigManager->hCurrBss,
+                        pConfigManager->hReport, 
+                        pConfigManager->hOs,
+                        pConfigManager->hExcMngr,
+                        pConfigManager->hQosMngr,
+                        pConfigManager->hPowerMgr,
+                        pConfigManager->hSCR, 
+                        pConfigManager->hEvHandler, 
+                        pConfigManager->hMacServices,
+                        &pConfigManager->pInitTable->siteMgrInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....Site manager configuration failure \n"));
+        return NOK;
+    }
+
+    /* Note: must be configured after Site Manager object coonfiguration */
+    /* regulatory Domain module */
+    WLAN_OS_REPORT(("Initializing Regulatory Domain...\n"));
+    if (regulatoryDomain_config (pConfigManager->hRegulatoryDomain,
+                                 pConfigManager->hSiteMgr,
+                                 pConfigManager->hHalCtrl,
+                                 pConfigManager->hReport,
+                                 pConfigManager->hOs, 
+                                 pConfigManager->hSwitchChannel,
+                                 &pConfigManager->pInitTable->regulatoryDomainInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....Regulatory Domain configuration failure \n"));
+        return NOK;
+    }
+
+    /* scan concentrator module */
+    /* Note: must be configured after RegulatoryDomain object coonfiguration */
+    WLAN_OS_REPORT(("Initializing Scan Concentrator...\n"));
+    scanConcentrator_init (pConfigManager->hScanCncn, 
+                           pConfigManager->hHalCtrl,
+                           pConfigManager->hReport, 
+                           pConfigManager->hRegulatoryDomain,
+                           pConfigManager->hSiteMgr, 
+                           pConfigManager->hSCR, 
+                           pConfigManager->hMacServices,
+                           pConfigManager->hAPConnection, 
+                           pConfigManager->hEvHandler, 
+                           pConfigManager->hMlmeSm, 
+                           pConfigManager->hCtrlData,             
+                           pConfigManager->hHealthMonitor,
+                           &pConfigManager->pInitTable->scanConcentratorInitParams);
+    
+    /* AUTH module */
+    WLAN_OS_REPORT(("Initializing Auth...\n"));
+    if (auth_config (pConfigManager->hAuth, 
+                     pConfigManager->hMlmeSm, 
+                     pConfigManager->hRsn,
+                     pConfigManager->hReport, 
+                     pConfigManager->hOs,
+                     &pConfigManager->pInitTable->authInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....AUTH configuration failure \n"));
+        return NOK;
+    }
+
+    /* MLME SM module */
+    WLAN_OS_REPORT(("Initializing MLME...\n"));
+    if (mlme_config (pConfigManager->hMlmeSm, 
+                     pConfigManager->hAuth, 
+                     pConfigManager->hAssoc,
+                     pConfigManager->hSiteMgr, 
+                     pConfigManager->hCtrlData, 
+                     pConfigManager->hConn,
+                     pConfigManager->hTxData, 
+                     pConfigManager->hHalCtrl, 
+                     pConfigManager->hMemMgr,
+                     pConfigManager->hMeasurementMgr, 
+                     pConfigManager->hSwitchChannel,
+                     pConfigManager->hRegulatoryDomain, 
+                     pConfigManager->hReport, 
+                     pConfigManager->hOs,
+                     pConfigManager->hCurrBss, 
+                     pConfigManager->hAPConnection,
+                     pConfigManager->hScanCncn, 
+                     pConfigManager->hQosMngr, 
+                     (TI_HANDLE)pConfigManager) != OK)    
+    {
+        WLAN_OS_REPORT(("\n.....MLME SM configuration failure \n"));
+        return NOK;
+    }
+
+    /* ASSOC module */
+    WLAN_OS_REPORT(("Initializing Assoc...\n"));
+    if (assoc_config (pConfigManager->hAssoc,   
+                      pConfigManager->hMlmeSm, 
+                      pConfigManager->hRegulatoryDomain,
+                      pConfigManager->hSiteMgr, 
+                      pConfigManager->hCtrlData, 
+                      pConfigManager->hTxData,
+                      pConfigManager->hHalCtrl, 
+                      pConfigManager->hRsn, 
+                      pConfigManager->hReport,
+                      pConfigManager->hOs, 
+                      pConfigManager->hExcMngr,
+                      pConfigManager->hQosMngr,
+                      pConfigManager->hMeasurementMgr, 
+                      pConfigManager->hAPConnection, 
+                      &pConfigManager->pInitTable->assocInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....ASSOC configuration failure \n"));
+        return NOK;
+    }
+
+    /* Rx data module */
+    WLAN_OS_REPORT(("Initializing Rx Data...\n"));
+    if (rxData_config (pConfigManager->hRxData, 
+                       pConfigManager->hCtrlData, 
+                       pConfigManager->hTxData,
+                       pConfigManager->hTnetwDrv, 
+                       pConfigManager->hHalCtrl,
+                       pConfigManager->hMlmeSm,
+                       pConfigManager->hRsn, 
+                       pConfigManager->hSiteMgr,
+                       pConfigManager->hExcMngr, 
+                       pConfigManager->hOs,
+                       pConfigManager->hReport, 
+                       pConfigManager->hMemMgr,
+                       pConfigManager->hEvHandler,
+                       &pConfigManager->pInitTable->rxDataInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....RX DATA configuration failure \n"));
+        return NOK;
+    }
+
+    /* Tx data module */
+    WLAN_OS_REPORT(("Initializing Tx Data...\n"));
+    if (txData_config (pConfigManager->hTxData, 
+                       pConfigManager->hCtrlData, 
+                       pConfigManager->hTnetwDrv, 
+                       pConfigManager->hHalCtrl,
+                       pConfigManager->hOs, 
+                       pConfigManager->hReport, 
+                       pConfigManager->hMemMgr, 
+                       pConfigManager->hSiteMgr, 
+                       pConfigManager->hEvHandler, 
+                       pConfigManager->hQosMngr,
+                       pConfigManager->hPowerMgr) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....TX DATA configuration failure \n"));
+        return NOK;
+    }
+
+    /* Traffic data module */
+    WLAN_OS_REPORT(("Initializing Traffic Monitor...\n"));
+    if (TrafficMonitor_Init(pConfigManager->hTrafficMon,
+                            pConfigManager->hRxData,
+                            pConfigManager->hTxData) != OK)
+    {
+        WLAN_OS_REPORT(("\n..... TRAFFIC MONITOR  configuration failure \n"));
+        return NOK;
+    }
+
+    /* Memory Manager module */
+    WLAN_OS_REPORT(("Initializing Memory Manager...\n"));
+    if (wlan_memMngrConfigure (pConfigManager->hMemMgr, pConfigManager->hOs, pConfigManager->hReport) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....MEM MNGR configuration failure \n"));
+        return NOK;
+    }
+
+    /* sme state machine module */
+    WLAN_OS_REPORT(("Initializing SME...\n"));
+    if (smeSm_config (pConfigManager->hSmeSm, 
+                      pConfigManager->hConn, 
+                      pConfigManager->hScanCncn,
+                      pConfigManager->hSiteMgr, 
+                      pConfigManager->hHalCtrl, 
+                      pConfigManager->hReport, 
+                      pConfigManager->hOs, 
+                      pConfigManager->hEvHandler, 
+                      pConfigManager->hSCR, 
+                      pConfigManager->hAPConnection, 
+                      pConfigManager->hCurrBss,
+                      pConfigManager->hPowerMgr,
+                      pConfigManager->hRegulatoryDomain,
+                      &pConfigManager->pInitTable->smeInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....Sme state machine configuration failure \n"));
+        return NOK;
+    }
+
+    /* Rsn module */
+    WLAN_OS_REPORT(("Initializing RSN...\n"));
+    if (rsn_config (pConfigManager->hRsn, 
+                    pConfigManager->hTxData, 
+                    pConfigManager->hRxData, 
+                    pConfigManager->hConn,
+                    pConfigManager->hMlmeSm, 
+                    pConfigManager->hCtrlData, 
+                    pConfigManager->hHalCtrl,
+                    pConfigManager->hMemMgr, 
+                    pConfigManager->hSiteMgr,
+                    pConfigManager->hReport, 
+                    pConfigManager->hOs, 
+                    pConfigManager->hExcMngr,
+                    pConfigManager->hPowerMgr,
+                    pConfigManager->hEvHandler,
+                    pConfigManager->hSmeSm, 
+                    pConfigManager->hAPConnection,
+                    &pConfigManager->pInitTable->rsnInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....RSN configuration failure \n"));
+        return NOK;
+    }
+
+    /* MeasurementMgr module */
+    /* Note: must be configured after RegulatoryDomain object coonfiguration */
+    WLAN_OS_REPORT(("Initializing Measurement Manager...\n"));
+    if (measurementMgr_config (pConfigManager->hMeasurementMgr, 
+                               pConfigManager->hMacServices,
+                               pConfigManager->hRegulatoryDomain, 
+                               pConfigManager->hExcMngr,
+                               pConfigManager->hSiteMgr, 
+                               pConfigManager->hHalCtrl,
+                               pConfigManager->hMlmeSm, 
+                               pConfigManager->hTrafficMon,
+                               pConfigManager->hReport, 
+                               pConfigManager->hOs,
+                               pConfigManager->hSCR,
+                               pConfigManager->hHealthMonitor,
+                               pConfigManager->hAPConnection, 
+                               pConfigManager->hTxData,
+                               &pConfigManager->pInitTable->measurementInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....MeasurementMgr configuration failure \n"));
+        return NOK;
+    }
+
+#ifdef EXC_MODULE_INCLUDED
+
+    WLAN_OS_REPORT(("Initializing EXC Manager...\n"));
+    if (excMngr_config (pConfigManager->hExcMngr, 
+                        pConfigManager->hReport, 
+                        pConfigManager->hOs,
+                        pConfigManager->hRsn, 
+                        pConfigManager->hMemMgr,
+                        pConfigManager->hCtrlData, 
+                        pConfigManager->hTxData,
+                        pConfigManager->hSiteMgr, 
+                        pConfigManager->hAPConnection, 
+                        pConfigManager->hEvHandler,
+                        (TI_HANDLE)pConfigManager, 
+                        pConfigManager->hMeasurementMgr, 
+                        pConfigManager->hQosMngr, 
+                        &pConfigManager->pInitTable->excMngrParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....excMngr_config configuration failure \n"));
+        return NOK;
+    }
+
+#endif
+    /* Scan manager */
+    WLAN_OS_REPORT(("Initializing Scan Manager...\n"));
+    scanMngr_init (pConfigManager->hScanMngr, 
+                   pConfigManager->hReport, 
+                   pConfigManager->hRegulatoryDomain,
+                   pConfigManager->hScanCncn, 
+                   pConfigManager->hRoamingMngr, 
+                   pConfigManager->hSiteMgr,
+                   pConfigManager->hHalCtrl);
+
+
+
+    WLAN_OS_REPORT(("Initializing CurrBSS...\n"));
+    if (currBSS_init (pConfigManager->hCurrBss, 
+                      pConfigManager->hMlmeSm,
+                      pConfigManager->hPowerMgr,
+                      pConfigManager->hAPConnection, 
+                      pConfigManager->hSmeSm,
+                      pConfigManager->hHalCtrl, 
+                      pConfigManager->hReport, 
+                      pConfigManager->hMemMgr, 
+                      pConfigManager->hTxData, 
+                      pConfigManager->hSiteMgr, 
+                      pConfigManager->hScanMngr, 
+                      pConfigManager->hMacServices) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....currBSS_init configuration failure \n"));
+        return NOK;
+    }
+
+    WLAN_OS_REPORT(("Initializing AP Conn...\n"));
+    if (apConn_config (pConfigManager->hAPConnection, 
+                       pConfigManager->hReport, 
+                       pConfigManager->hCurrBss,
+                       pConfigManager->hRoamingMngr,
+                       pConfigManager->hSmeSm, 
+                       pConfigManager->hSiteMgr,
+                       pConfigManager->hExcMngr, 
+                       pConfigManager->hConn,
+                       pConfigManager->hRsn, 
+                       pConfigManager->hQosMngr,
+                       pConfigManager->hCtrlData,
+                       pConfigManager->hEvHandler,
+                       pConfigManager->hSCR,
+                       pConfigManager->hAssoc,
+                       pConfigManager->hRegulatoryDomain,
+                       &pConfigManager->pInitTable->apConnParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....apConn_config configuration failure \n"));
+        return NOK;
+    }
+
+    WLAN_OS_REPORT(("Initializing Roaming Manager...\n"));
+    if (roamingMngr_init (pConfigManager->hRoamingMngr, 
+                          pConfigManager->hReport,
+                          pConfigManager->hScanMngr,
+                          pConfigManager->hAPConnection) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....roamingMngr_config configuration failure \n"));
+        return NOK;
+    }
+
+    /* NOTE: must be after siteMgr & whalCtrl configurations !!!! */
+    WLAN_OS_REPORT(("Initializing QoS Manager...\n"));
+    if (qosMngr_config (pConfigManager->hQosMngr,   
+                        pConfigManager->hHalCtrl,
+                        pConfigManager->hSiteMgr, 
+                        pConfigManager->hReport,
+                        pConfigManager->hOs, 
+                        pConfigManager->hTxData,
+                        pConfigManager->hMeasurementMgr,
+                        pConfigManager->hSmeSm, 
+                        pConfigManager->hMemMgr,
+                        pConfigManager->hCtrlData,
+                        pConfigManager->hEvHandler, 
+                        pConfigManager->hExcMngr, 
+                        &pConfigManager->pInitTable->qosMngrInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....Qos Mngr configuration failure \n"));
+        return NOK;
+    }
+
+    WLAN_OS_REPORT(("Initializing Switch Channel...\n"));
+    if (switchChannel_config (pConfigManager->hSwitchChannel,
+                              pConfigManager->hHalCtrl,
+                              pConfigManager->hSiteMgr,
+                              pConfigManager->hSCR,
+                              pConfigManager->hRegulatoryDomain,
+                              pConfigManager->hAPConnection,
+                              pConfigManager->hReport,
+                              pConfigManager->hOs,
+                              pConfigManager->hHealthMonitor,
+                              &pConfigManager->pInitTable->SwitchChannelInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....SwitchChannel_config configuration failure \n"));
+        return NOK;
+    }
+
+    WLAN_OS_REPORT(("Initializing Health Monitor...\n"));
+    if (healthMonitor_config (pConfigManager->hHealthMonitor,
+                              pConfigManager->hReport,
+                              pConfigManager->hHalCtrl,
+                              pConfigManager->hSiteMgr,
+                              pConfigManager->hSCR,
+                              pConfigManager->hSoftGemini,
+                              pConfigManager->hTnetwDrv,
+                              pConfigManager->hMemMgr,
+                              (TI_HANDLE)pConfigManager,
+                              pConfigManager->hTxData,
+                              pConfigManager->hCurrBss,
+                              pConfigManager->hRsn,
+                              &pConfigManager->pInitTable->healthMonitorInitParams,
+                              pConfigManager->hRecoveryMgr) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....healthMonitor_config configuration failure \n"));
+        return NOK;
+    }
+
+    WLAN_OS_REPORT(("Initializing Power Manager...\n"));
+    if (PowerMgr_init (pConfigManager->hPowerMgr,
+                       pConfigManager->hMacServices,
+                       pConfigManager->hReport,
+                       pConfigManager->hSiteMgr,
+                       pConfigManager->hHalCtrl,
+                       pConfigManager->hTrafficMon,
+                       pConfigManager->hSoftGemini,
+                       &pConfigManager->pInitTable->PowerMgrInitParams) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....PowerMgr_init configuration failure \n"));
+        return NOK;
+    }
+
+    WLAN_OS_REPORT(("Initializing Recovery Mgr...\n"));
+    if (recoveryMgr_config(pConfigManager->hRecoveryMgr, 
+                           pConfigManager->hReport,
+                           pConfigManager->hTxData,
+                           pConfigManager->hTnetwDrv,
+                           pConfigManager->hSCR,     
+                           pConfigManager->hCurrBss, 
+                           pConfigManager->hPowerMgr,
+                           pConfigManager->hHealthMonitor,
+                                                  pConfigManager->hSoftGemini) != OK)
+    {
+        WLAN_OS_REPORT(("\n.....RecoveryMgr configuration failure \n"));
+        return NOK;
+    }
+
+       /* This must be called before calling SoftGemini_config, as the SG may trigger events from FW
+               which are enabled in this fucntion */
+       whalCtrl_exitFromInitModePart1(pConfigManager->hHalCtrl);
+
+    /* Soft Gemini module , should be configured after all the modules it uses */
+    WLAN_OS_REPORT(("Initializing Soft Gemini...\n"));
+    if (SoftGemini_config (pConfigManager->hSoftGemini,
+                           pConfigManager->hCtrlData,
+                           pConfigManager->hHalCtrl,
+                           pConfigManager->hReport,
+                           pConfigManager->hSCR,
+                           pConfigManager->hPowerMgr,
+                           (TI_HANDLE)pConfigManager,
+                           pConfigManager->hScanCncn,
+                           pConfigManager->hCurrBss,
+                           pConfigManager->hEvHandler,
+                           &pConfigManager->pInitTable->SoftGeminiInitParams) != OK)                                                                                
+    {
+        WLAN_OS_REPORT(("\n.....SoftGemini configuration failure \n"));
+        return NOK;
+    }
+
+    /* Notify the power authorization so the first min power level will be sent to the FW */
+       /* This will update the FW Power Level according to the defaultPowerLevel configured in Registry */
+    MacServices_powerAutho_ExitFromInit(pConfigManager->hMacServices);
+
+    /*
+    *  Exit from init mode should be before smeSM starts. this enable us to send
+    *  command to the MboxQueue(that store the command) while the interrupts are masked.
+    *  the interrupt would be enable at the end of the init process.
+    */
+       whalCtrl_exitFromInitModePart2(pConfigManager->hHalCtrl);
+    
+    WLAN_OS_REPORT(("Finished initializing modules.\n"));
+
+    WLAN_REPORT_INIT(pConfigManager->hReport, CONFIG_MGR_MODULE_LOG,  
+        ("EXIT FROM INIT\n"));
+
+    return OK;
+}
+
+
+/*
+ * configMgr_RetrieveFWInfo: 
+ * Retrieve FW information from HAL which the SNWSASettings returned 
+ * by GWSI_Configure does not contained
+ */
+static  void configMgr_RetrieveFWInfo(configMgr_t *pConfigManager, initTable_t *pInitTable, whalCtrl_chip_t *pChip_Version)
+{
+    /*
+     * Retrieve FW information from HAL
+     */
+    whalCtrl_GetFWInfo(pConfigManager->hHalCtrl, pChip_Version);
+
+    /* 
+     * Update complete the init table update 
+     * with the chip information received from the HAL
+     */
+    os_memoryCopy(pConfigManager->hOs, (void *)pInitTable->ctrlDataInitParams.ctrlDataDeviceMacAddress.addr, (void *)pChip_Version->macAddress.addr, MAC_ADDR_LEN);
+    os_memoryCopy(pConfigManager->hOs, pInitTable->siteMgrInitParams.siteMgrFwVersion, pChip_Version->fwVer, FW_VERSION_LEN);
+    os_memoryCopy(pConfigManager->hOs, &(pInitTable->siteMgrInitParams.siteMgrEEpromVersion), &(pChip_Version->e2Ver), sizeof(e2Version_t));
+    pInitTable->siteMgrInitParams.siteMgrRadioValues.siteMgr_radioType = pChip_Version->radioType;   
+}
+
+
+/****************************************************************************************
+ *                        configMgr_GetInitParams                                                *
+ ****************************************************************************************
+DESCRIPTION:    Retreive init table
+
+INPUT:          pConfigManager     - driver main handle
+
+OUTPUT:         ioBuffer           - init table
+                outBufLen          - init table length
+
+RETURN:         none
+
+************************************************************************/
+void configMgr_GetInitParams (TI_HANDLE hConfigManager, UINT8* ioBuffer, UINT16 *outBufLen)
+{
+    configMgr_t *pConfigManager = (configMgr_t *)hConfigManager;
+
+    TnetwDrv_GetInitParams (pConfigManager->hTnetwDrv, ioBuffer, outBufLen);
+}
+
+
+/****************************************************************************************
+ *                        release_module                                                *
+ ****************************************************************************************
+DESCRIPTION:    Driver free function. Performs the following:
+                -   Go over the vector, for each bit that is set, release the corresponding module.
+
+INPUT:          pConfigManager     -    Driver main handle
+                initVec         -       Vector that contains the bits of the modules which have to be free
+
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+static void release_module(configMgr_t *pConfigManager)
+{
+    if (pConfigManager->hScanMngr != NULL)
+    {
+        scanMngr_unload( pConfigManager->hScanMngr);
+    }
+
+    if (pConfigManager->hSiteMgr != NULL)
+    {
+        siteMgr_unLoad(pConfigManager->hSiteMgr);
+    }
+
+    if (pConfigManager->hSmeSm != NULL)
+    {
+        smeSm_unLoad(pConfigManager->hSmeSm);
+    }
+
+    if (pConfigManager->hConn != NULL)
+    {
+        conn_unLoad(pConfigManager->hConn);
+    }
+
+    if (pConfigManager->hTnetwDrv != NULL)
+    {
+        TnetwDrv_Destroy(pConfigManager->hTnetwDrv);
+    }
+
+    if (pConfigManager->hScanCncn != NULL)
+    {
+        scanConcentrator_release(pConfigManager->hScanCncn);
+    }
+
+    if (pConfigManager->hTrafficMon != NULL)
+    {
+        TrafficMonitor_Destroy(pConfigManager->hTrafficMon);
+    }
+
+    if (pConfigManager->hCtrlData != NULL)
+    {
+        ctrlData_unLoad(pConfigManager->hCtrlData);
+    }
+
+    if (pConfigManager->hTxData != NULL)
+    {
+        txData_unLoad(pConfigManager->hTxData);
+    }
+
+    if (pConfigManager->hRxData != NULL)
+    {
+        rxData_unLoad(pConfigManager->hRxData);
+    }
+
+    if (pConfigManager->hAssoc != NULL)
+    {
+        assoc_unload(pConfigManager->hAssoc);
+    }
+
+    if (pConfigManager->hAuth != NULL)
+    {
+        auth_unload(pConfigManager->hAuth);
+    }
+
+    if (pConfigManager->hMlmeSm != NULL)
+    {
+        mlme_unload(pConfigManager->hMlmeSm);
+    }
+
+    if (pConfigManager->hSCR != NULL)
+    {
+        scr_release(pConfigManager->hSCR);
+    }
+
+    if (pConfigManager->hEvHandler != NULL)
+    {
+         EvHandlerUnload(pConfigManager->hEvHandler);
+    }
+
+    if (pConfigManager->hMemMgr != NULL)
+    {
+        wlan_memMngrDestroy(pConfigManager->hMemMgr);
+    }
+
+    if (pConfigManager->hRsn != NULL)
+    {
+        rsn_unload(pConfigManager->hRsn);
+    }
+
+    if (pConfigManager->hRegulatoryDomain != NULL)
+    {
+        regulatoryDomain_destroy(pConfigManager->hRegulatoryDomain);
+    }
+
+    if (pConfigManager->hMeasurementMgr != NULL)
+    {
+        measurementMgr_destroy(pConfigManager->hMeasurementMgr);
+    }
+
+    if (pConfigManager->hSoftGemini != NULL)
+    {
+        SoftGemini_destroy(pConfigManager->hSoftGemini);
+    }
+
+#ifdef EXC_MODULE_INCLUDED
+    if (pConfigManager->hExcMngr != NULL)
+    {
+        excMngr_unload(pConfigManager->hExcMngr);
+    }
+#endif
+
+    if (pConfigManager->hRoamingMngr != NULL)
+    {
+        roamingMngr_unload(pConfigManager->hRoamingMngr);
+    }
+
+    if (pConfigManager->hQosMngr != NULL)
+    {
+        qosMngr_destroy(pConfigManager->hQosMngr);
+    }
+
+    if (pConfigManager->hPowerMgr != NULL)
+    {
+        PowerMgr_destroy(pConfigManager->hPowerMgr);
+    }
+
+    if (pConfigManager->hAPConnection != NULL)
+    {
+        apConn_unload(pConfigManager->hAPConnection);
+    }
+
+    if (pConfigManager->hCurrBss != NULL)
+    {
+        currBSS_unload(pConfigManager->hCurrBss);
+    }
+
+    if (pConfigManager->hSwitchChannel != NULL)
+    {
+        switchChannel_unload(pConfigManager->hSwitchChannel);
+    }
+
+    if (pConfigManager->hHealthMonitor != NULL)
+    {
+        healthMonitor_unload(pConfigManager->hHealthMonitor);
+    }
+
+    if (pConfigManager->hRecoveryMgr != NULL)
+    {
+        recoveryMgr_destroy(pConfigManager->hRecoveryMgr);
+    }
+
+    if (pConfigManager->hReport != NULL)
+    {
+        report_unLoad(pConfigManager->hReport);
+    }
+   
+    /***************************************************************
+    This is the config manager, it should be always the last module 
+    to release
+    ****************************************************************/
+    
+    utils_nullMemoryFree(pConfigManager->hOs, pConfigManager, sizeof(configMgr_t));
+}
+
+/****************************************************************************************
+ *                        configParamsAccessTable                                       *
+ ****************************************************************************************
+DESCRIPTION:    Called in the configuration phase by the driver, performs the following:
+                -   For each module that supply a Get/Set services to his parameters, fill the corresponding entry
+                    in the params access table with the following:
+                        -   Get function
+                        -   Set function
+                        -   Handle to the module
+                This table is used when Getting/Setting a parameter from the OS abstraction layer.
+
+INPUT:          pConfigManager     -    Driver main handle
+
+OUTPUT:
+
+RETURN:         OK on success, NOK on failure
+
+************************************************************************/
+static void configParamsAccessTable(configMgr_t *pConfigManager)
+{
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(AUTH_MODULE_PARAM) - 1].set = auth_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(AUTH_MODULE_PARAM) - 1].get = auth_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(AUTH_MODULE_PARAM) - 1].handle = pConfigManager->hAuth;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(ASSOC_MODULE_PARAM) - 1].set = assoc_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(ASSOC_MODULE_PARAM) - 1].get = assoc_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(ASSOC_MODULE_PARAM) - 1].handle = pConfigManager->hAssoc;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(RX_DATA_MODULE_PARAM) - 1].set = rxData_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(RX_DATA_MODULE_PARAM) - 1].get = rxData_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(RX_DATA_MODULE_PARAM) - 1].handle = pConfigManager->hRxData;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(TX_DATA_MODULE_PARAM) - 1].set = txData_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(TX_DATA_MODULE_PARAM) - 1].get = txData_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(TX_DATA_MODULE_PARAM) - 1].handle = pConfigManager->hTxData;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(CTRL_DATA_MODULE_PARAM) - 1].set = ctrlData_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(CTRL_DATA_MODULE_PARAM) - 1].get = ctrlData_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(CTRL_DATA_MODULE_PARAM) - 1].handle = pConfigManager->hCtrlData;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SITE_MGR_MODULE_PARAM) - 1].set = siteMgr_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SITE_MGR_MODULE_PARAM) - 1].get = siteMgr_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SITE_MGR_MODULE_PARAM) - 1].handle = pConfigManager->hSiteMgr;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(CONN_MODULE_PARAM) - 1].set = conn_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(CONN_MODULE_PARAM) - 1].get = conn_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(CONN_MODULE_PARAM) - 1].handle = pConfigManager->hConn;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(RSN_MODULE_PARAM) - 1].set = rsn_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(RSN_MODULE_PARAM) - 1].get = rsn_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(RSN_MODULE_PARAM) - 1].handle= pConfigManager->hRsn;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(HAL_CTRL_MODULE_PARAM) - 1].set = (paramFunc_t)whalCtrl_SetParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(HAL_CTRL_MODULE_PARAM) - 1].get = (paramFunc_t)whalCtrl_GetParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(HAL_CTRL_MODULE_PARAM) - 1].handle = pConfigManager->hHalCtrl;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(REPORT_MODULE_PARAM) - 1].set = (paramFunc_t)report_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(REPORT_MODULE_PARAM) - 1].get = (paramFunc_t)report_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(REPORT_MODULE_PARAM) - 1].handle = pConfigManager->hReport;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SME_SM_MODULE_PARAM) - 1].set = smeSm_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SME_SM_MODULE_PARAM) - 1].get = smeSm_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SME_SM_MODULE_PARAM) - 1].handle = pConfigManager->hSmeSm;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SCAN_CNCN_PARAM) - 1].set = scanConcentrator_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SCAN_CNCN_PARAM) - 1].get = scanConcentrator_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SCAN_CNCN_PARAM) - 1].handle = pConfigManager->hScanCncn;
+    
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SCAN_MNGR_PARAM) - 1].set = scanMngr_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SCAN_MNGR_PARAM) - 1].get = scanMngr_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SCAN_MNGR_PARAM) - 1].handle = pConfigManager->hScanMngr;
+    
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(MLME_SM_MODULE_PARAM) - 1].set = mlme_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(MLME_SM_MODULE_PARAM) - 1].get = mlme_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(MLME_SM_MODULE_PARAM) - 1].handle = pConfigManager->hMlmeSm;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(REGULATORY_DOMAIN_MODULE_PARAM) - 1].set = regulatoryDomain_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(REGULATORY_DOMAIN_MODULE_PARAM) - 1].get = regulatoryDomain_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(REGULATORY_DOMAIN_MODULE_PARAM) - 1].handle = pConfigManager->hRegulatoryDomain;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(MEASUREMENT_MODULE_PARAM) - 1].set = measurementMgr_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(MEASUREMENT_MODULE_PARAM) - 1].get = measurementMgr_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(MEASUREMENT_MODULE_PARAM) - 1].handle = pConfigManager->hMeasurementMgr;
+
+#ifdef EXC_MODULE_INCLUDED
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(EXC_MANAGER_MODULE_PARAM) - 1].set = excMngr_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(EXC_MANAGER_MODULE_PARAM) - 1].get = excMngr_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(EXC_MANAGER_MODULE_PARAM) - 1].handle = pConfigManager->hExcMngr;
+#endif
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(ROAMING_MANAGER_MODULE_PARAM) - 1].set = roamingMngr_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(ROAMING_MANAGER_MODULE_PARAM) - 1].get = roamingMngr_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(ROAMING_MANAGER_MODULE_PARAM) - 1].handle = pConfigManager->hRoamingMngr;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SOFT_GEMINI_PARAM) - 1].set = SoftGemini_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SOFT_GEMINI_PARAM) - 1].get = SoftGemini_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(SOFT_GEMINI_PARAM) - 1].handle = pConfigManager->hSoftGemini;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(QOS_MANAGER_PARAM) - 1].set = qosMngr_setParams;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(QOS_MANAGER_PARAM) - 1].get = qosMngr_getParams;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(QOS_MANAGER_PARAM) - 1].handle = pConfigManager->hQosMngr;
+
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(POWER_MANAGER_PARAM) - 1].set = powerMgr_setParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(POWER_MANAGER_PARAM) - 1].get = powerMgr_getParam;
+    pConfigManager->paramAccessTable[GET_PARAM_MODULE_NUMBER(POWER_MANAGER_PARAM) - 1].handle = pConfigManager->hPowerMgr;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/configMgr/configMgr.h b/sta_dk_4_0_4_32/common/src/core/sme/configMgr/configMgr.h
new file mode 100644 (file)
index 0000000..85186a8
--- /dev/null
@@ -0,0 +1,167 @@
+/** \file configMgr.h
+ *  \brief config manager module internal header file
+ *
+ *  \see configMgr.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   configMgr.h                                                 */
+/*    PURPOSE:  Config manager module internal header file                          */
+/*                                                                          */
+/***************************************************************************/
+#ifndef __CONFIG_MGR_H__
+#define __CONFIG_MGR_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "fsm.h"
+
+/* Config manager state machine defintions */
+typedef enum
+{
+    CFG_MGR_STATE_IDLE              = 0,
+    CFG_MGR_STATE_RUNNING           = 1,
+    CFG_MGR_STATE_STOPPED           = 2,
+} stateCfg_e;
+
+typedef struct
+{
+    paramFunc_t         set; 
+    paramFunc_t         get; 
+    TI_HANDLE           handle; 
+} paramAccess_t;
+
+/* Configuration manager handle */
+typedef struct 
+{
+    UINT8               state;
+    fsm_stateMachine_t  *pFsm;
+
+    paramAccess_t       paramAccessTable[MAX_PARAM_MODULE_NUMBER];
+
+    /* SME handles */
+    TI_HANDLE           hSmeSm;
+    TI_HANDLE           hSiteMgr;
+    TI_HANDLE           hConn;
+
+    /* MLME handles */
+    TI_HANDLE           hMlmeSm;
+    TI_HANDLE           hAuth;
+    TI_HANDLE           hAssoc;
+
+    /* Data handles */
+    TI_HANDLE           hRxData;
+    TI_HANDLE           hTxData;
+    TI_HANDLE           hCtrlData;
+    
+    /* Traffic Monitor */
+    TI_HANDLE           hTrafficMon;
+
+    /* RSN handle */
+    TI_HANDLE           hRsn;
+
+    /* HAL handles */
+    TI_HANDLE           hHalCtrl;
+
+    /* Network Control */
+    TI_HANDLE           hRegulatoryDomain;
+    TI_HANDLE           hMeasurementMgr;
+    TI_HANDLE           hSoftGemini;
+
+    /* EXC Manager*/
+    TI_HANDLE           hExcMngr;
+
+    /* Roaming Manager */
+    TI_HANDLE           hRoamingMngr;
+
+    /* QOS Manager */
+    TI_HANDLE           hQosMngr;
+
+    /* Utils handles */
+    TI_HANDLE           hReport;
+    TI_HANDLE           hMemMgr;
+
+    /* OS handle */
+    TI_HANDLE           hOs;
+
+    /* Power handles */
+    TI_HANDLE           hPowerMgr;
+    TI_HANDLE           hPowerSrv;
+
+    /* Event Handler Handles */
+    TI_HANDLE           hEvHandler;
+
+    /* AP Connection Handles */
+    TI_HANDLE           hAPConnection;
+
+    /* Current BSS Handles */
+    TI_HANDLE           hCurrBss;
+
+    /* SwitchChannel Handles */
+    TI_HANDLE           hSwitchChannel;
+
+    /* Services handles */
+    TI_HANDLE           hSCR;               /* SCR */
+    TI_HANDLE           hMacServices;       /* MacServices */
+
+    /* Management handles */
+    TI_HANDLE           hScanCncn;          /* Scan Concentrator */
+
+    /* Application handles */
+    TI_HANDLE           hScanMngr;          /* Scan Manager */
+
+    /* Health Monitor */
+    TI_HANDLE           hHealthMonitor;  
+
+       TI_HANDLE           hRecoveryMgr;
+
+    /* Core Callbacks pointers to be used in the config phase */
+    /*TI_HANDLE         hcoreCallbacks;*/
+
+    TI_HANDLE           hTnetwDrv;
+
+    /* Pointer to configuration parameters */
+    initTable_t        *pInitTable;
+
+    /* Pointer to driver's mac address */
+    macAddress_t       *pMacAddr;
+
+} configMgr_t;
+
+#endif /* __CONFIG_MGR_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/conn/conn.c b/sta_dk_4_0_4_32/common/src/core/sme/conn/conn.c
new file mode 100644 (file)
index 0000000..df26ad9
--- /dev/null
@@ -0,0 +1,725 @@
+/** \file conn.c
+ *  \brief connection module interface
+ *
+ *  \see conn.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**  
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************************************/
+/*                                                                                                                                                                                                     */
+/*             MODULE:         conn.c                                                                                                                                                  */
+/*             PURPOSE:        Connection module interface. The connection     itself is implemented in the files      */
+/*                                     connInfra, connIbss & connSelf. This file distributes the events received to    */
+/*                                     one of the modules based on the current connection type.                                                */                                                                                                                                      
+/*                                                                                                                                                                                                     */
+/****************************************************************************************************/
+
+
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "conn.h"
+#include "connApi.h"
+#include "connIbss.h"
+#include "connInfra.h"
+#include "802_11Defs.h"
+#include "utils.h"
+#include "smeApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "siteMgrApi.h"
+#include "smeSmApi.h"
+#include "scrApi.h"
+#include "healthMonitor.h"
+#include "qosMngr_API.h"
+
+#define CONN_INIT_BIT                                  1
+#define TIMER_INIT_BIT                                 2
+#define        IBSS_SM_INIT_BIT                                3
+#define        INFRA_SM_INIT_BIT                               4
+#define INFRA_DISASSOC_TIMER_INIT_BIT  6
+
+/* Local functions prototypes */
+
+static void conn_timeout(TI_HANDLE hConn);
+
+static void release_module(conn_t *pConn, UINT32 initVec);
+
+/* Interface functions Implementation */
+
+/************************************************************************
+ *                        conn_create                                                          *
+ ************************************************************************
+DESCRIPTION: Connection module creation function, called by the config mgr in creation phase 
+                               performs the following:
+                               -       Allocate the connection handle
+                               -       Create the connection timer
+                               -       Create the connection state machine
+                                                                                                   
+INPUT:      hOs -                      Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the connection module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE conn_create(TI_HANDLE hOs)
+{
+       conn_t                  *pConn;
+       UINT32                  initVec;
+       fsm_stateMachine_t *pFsm;
+       TI_STATUS status;
+
+       initVec = 0;
+
+       pConn = os_memoryAlloc(hOs, sizeof(conn_t));
+       if (pConn == NULL)
+               return NULL;
+
+       initVec |= (1<<CONN_INIT_BIT);
+
+    /* Rename to connSelfIbssTimer */
+       pConn->pTimer = os_timerCreate(hOs, conn_timeout, pConn);
+       if (pConn->pTimer == NULL)
+       {
+               release_module(pConn, initVec);
+               return NULL;
+       }
+       
+       initVec |= (1<<TIMER_INIT_BIT);
+       
+       
+       /* Creating connection Ibss SM */
+    status = fsm_Create(hOs, &pFsm, CONN_IBSS_NUM_STATES, CONN_IBSS_NUM_EVENTS);
+       if (status != OK)
+       {
+               release_module(pConn, initVec);
+               return NULL;
+       }
+       pConn->ibss_pFsm = pFsm;
+
+    initVec |= (1<<IBSS_SM_INIT_BIT);
+
+    /* Creating connection Infra SM */
+       status = fsm_Create(hOs, &pFsm, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS);
+       if (status != OK)
+       {
+               release_module(pConn, initVec);
+               return NULL;
+       }
+       pConn->infra_pFsm = pFsm;
+
+    initVec |= (1<<INFRA_SM_INIT_BIT);
+
+
+    /* ------- */
+
+       pConn->hOs = hOs;
+
+       return(pConn);
+}
+
+
+/************************************************************************
+ *                        conn_config                                                                  *
+ ************************************************************************
+DESCRIPTION: Connection module configuration function, called by the config mgr in configuration phase
+                               performs the following:
+                               -       Reset & initiailzes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hConn      -       Connection handle
+                       List of handles to be used by the module
+                       pConnInitParams -       Init table of the module.               
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_config(TI_HANDLE        hConn, 
+                                  TI_HANDLE    hSiteMgr, 
+                                  TI_HANDLE    hSmeSm, 
+                                  TI_HANDLE    hMlmeSm, 
+                                  TI_HANDLE    hRsn,
+                                  TI_HANDLE    hRxData,
+                                  TI_HANDLE    hTxData,
+                                  TI_HANDLE    hReport,
+                                  TI_HANDLE    hOs,
+                                  TI_HANDLE    hPwrMngr,
+                                  TI_HANDLE    hCtrlData,
+                                  TI_HANDLE    hMeasurementMgr,
+                                  TI_HANDLE    hTrafficMonitor,
+                                  TI_HANDLE    hScr,
+                                  TI_HANDLE    hExcMngr,
+                                  TI_HANDLE    hQosMngr,
+                                  TI_HANDLE    hHalCtrl,
+                                  TI_HANDLE    hScanCnc,
+                                  TI_HANDLE    hCurrBss,
+                                  TI_HANDLE    hSwitchChannel,
+                                  TI_HANDLE    hEvHandler,
+                                  TI_HANDLE    hHealthMonitor,
+                                  TI_HANDLE    hMacServices,
+                   TI_HANDLE    hRegulatoryDomain,
+                                  TI_HANDLE    hSoftGemini,
+                                  connInitParams_t             *pConnInitParams)
+{
+       conn_t *pConn = (conn_t *)hConn;
+
+       pConn->state = 0;
+       os_memoryZero(hOs, &(pConn->smContext), sizeof(connSmContext_t)); 
+       pConn->timeout                  = pConnInitParams->connSelfTimeout;
+       pConn->hSiteMgr                 = hSiteMgr;
+       pConn->hSmeSm                   = hSmeSm;
+       pConn->hMlmeSm                  = hMlmeSm;
+       pConn->hRsn                             = hRsn;
+       pConn->hRxData                  = hRxData;
+       pConn->hTxData                  = hTxData;
+       pConn->hReport                  = hReport;
+       pConn->hOs                              = hOs;
+       pConn->hPwrMngr                 = hPwrMngr;
+       pConn->hCtrlData                = hCtrlData;
+       pConn->hMeasurementMgr  = hMeasurementMgr;
+       pConn->hTrafficMonitor  = hTrafficMonitor;
+       pConn->hScr                             = hScr;
+       pConn->hExcMngr                 = hExcMngr;
+       pConn->hQosMngr                 = hQosMngr;
+       pConn->hHalCtrl                 = hHalCtrl;
+       pConn->hScanCnc                 = hScanCnc;
+       pConn->hCurrBss                 = hCurrBss;
+       pConn->hSwitchChannel   = hSwitchChannel;
+       pConn->hEvHandler               = hEvHandler;
+       pConn->hHealthMonitor   = hHealthMonitor;
+       pConn->hMacServices     = hMacServices;
+       pConn->hSoftGemini              = hSoftGemini;
+    pConn->hRegulatoryDomain = hRegulatoryDomain;
+       
+       pConn->connType                  = CONN_TYPE_FIRST_CONN;
+    pConn->ibssDisconnectCount = 0;
+
+       whalCtrl_EventMbox_RegisterForEvent(pConn->hHalCtrl,  HAL_EVENT_JOIN_CMPLT, 
+                                                                       (void *)connInfra_JoinCmpltNotification, pConn);
+
+       whalCtrl_EventMbox_Enable(pConn->hHalCtrl, HAL_EVENT_JOIN_CMPLT);
+       
+       WLAN_REPORT_INIT(hReport, CONN_MODULE_LOG,  (".....Connection configured successfully\n"));
+
+       return OK;
+}
+
+/************************************************************************
+ *                        conn_unLoad                                                                  *
+ ************************************************************************
+DESCRIPTION: Connection module unload function, called by the config mgr in the unlod phase 
+                               performs the following:
+                               -       Free all memory aloocated by the module
+                                                                                                   
+INPUT:      hConn      -       Connection handle.              
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_unLoad(TI_HANDLE hConn)
+{
+       UINT32                  initVec;
+       conn_t                  *pConn = (conn_t *)hConn;
+
+       if (!pConn)
+               return OK;
+
+       initVec = 0xFFFF;
+       release_module(pConn, initVec);
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        conn_setParam                                                                        
+ ***********************************************************************
+DESCRIPTION: Connection set param function, called by the following:
+                               -       config mgr in order to set a parameter from the OS abstraction layer.
+                               -       Form inside the driver
+                               In this fuction, the site manager configures the connection type in the select phase.
+                               The connection type is used to distribute the connection events to the corresponding connection SM      
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_setParam(TI_HANDLE              hConn, 
+                                        paramInfo_t    *pParam)
+{
+       conn_t *pConn = (conn_t *)hConn;
+
+       switch(pParam->paramType)
+       {
+       case CONN_TYPE_PARAM:
+               pConn->currentConnType = pParam->content.connType;
+               switch (pParam->content.connType)
+               {
+               case CONNECTION_IBSS:
+               case CONNECTION_SELF:
+                       return conn_ibssConfig(pConn);
+
+               case CONNECTION_INFRA:
+                       return conn_infraConfig(pConn);
+
+               default:
+                       WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Set connection type, type is not valid, %d\n\n", pParam->content.connType));
+                       return PARAM_VALUE_NOT_VALID;
+               }
+
+       case CONN_SELF_TIMEOUT_PARAM:
+               if ((pParam->content.connSelfTimeout < CONN_SELF_TIMEOUT_MIN) || (pParam->content.connSelfTimeout > CONN_SELF_TIMEOUT_MAX))
+                       return PARAM_VALUE_NOT_VALID;
+               pConn->timeout = pParam->content.connSelfTimeout;
+               break;
+
+       default:
+               WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Set param, Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        conn_getParam                                                                        
+ ***********************************************************************
+DESCRIPTION: Connection get param function, called by the following:
+                       -       config mgr in order to get a parameter from the OS abstraction layer.
+                       -       Fomr inside the dirver  
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_getParam(TI_HANDLE              hConn, 
+                                        paramInfo_t    *pParam)
+{
+       conn_t *pConn = (conn_t *)hConn;
+
+       switch(pParam->paramType)
+       {
+       case CONN_TYPE_PARAM:
+               pParam->content.connType = pConn->currentConnType;
+               break;
+
+       case CONN_SELF_TIMEOUT_PARAM:
+               pParam->content.connSelfTimeout = pConn->timeout;
+               break;
+       
+       default:
+               WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        conn_start                                                                   
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM in order to start the connection SM
+                        This function start the current connection SM  
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_start(TI_HANDLE hConn, connType_e connType,
+                                               conn_status_callback_t  pConnStatusCB,
+                                               TI_HANDLE connStatCbObj,
+                                               BOOL disConEraseKeys,
+                                               BOOL reNegotiateTspec)
+{
+       conn_t *pConn = (conn_t *)hConn;
+       paramInfo_t param;
+
+       pConn->pConnStatusCB = pConnStatusCB;
+       pConn->connStatCbObj = connStatCbObj;
+
+       pConn->connType = connType;
+       pConn->disConEraseKeys = disConEraseKeys;
+       
+       /* Initialize the DISASSOCIATE event parameters to default */ 
+       pConn->smContext.disAssocEventReason = STATUS_UNSPECIFIED;
+       pConn->smContext.disAssocEventStatusCode  = 0;
+
+       /* If requested, re-negotiate voice TSPEC */
+       param.paramType = QOS_MNGR_VOICE_RE_NEGOTIATE_TSPEC;
+       param.content.TspecConfigure.voiceTspecConfigure = reNegotiateTspec; 
+       param.content.TspecConfigure.videoTspecConfigure = reNegotiateTspec; 
+       qosMngr_setParams(pConn->hQosMngr, &param);
+
+       switch(pConn->currentConnType)
+       {
+       case CONNECTION_IBSS:
+               return conn_ibssSMEvent(&pConn->state, CONN_IBSS_CONNECT, (TI_HANDLE) pConn);
+
+       case CONNECTION_SELF:
+               return conn_ibssSMEvent(&pConn->state, CONN_IBSS_CREATE, (TI_HANDLE) pConn);
+
+       case CONNECTION_INFRA:
+               return conn_infraSMEvent(&pConn->state, CONN_INFRA_CONNECT, (TI_HANDLE) pConn);
+
+    default:
+               WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Start connection, invalid type %d\n\n", pConn->currentConnType));
+               return NOK;
+
+       }
+}
+
+/***********************************************************************
+ *                        conn_stop                                                                    
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM in order to stop the connection SM
+                        This function stop the current connection SM.  
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_stop(TI_HANDLE                          hConn, 
+                                       disConnType_e                   disConnType, 
+                                       mgmtStatus_e                    reason,
+                                       BOOL                                    disConEraseKeys,
+                                       conn_status_callback_t  pConnStatusCB,
+                                       TI_HANDLE                               connStatCbObj  )
+{
+       conn_t *pConn = (conn_t *)hConn;
+
+       pConn->pConnStatusCB = pConnStatusCB;
+       pConn->connStatCbObj = connStatCbObj;
+
+       pConn->disConnType               = disConnType;
+       pConn->disConnReasonToAP = reason;
+       pConn->disConEraseKeys   = disConEraseKeys;
+
+       /* 
+        * Mark the disconnection reason as unspecified to indicate that conn module has no information regarding the DISASSOCIATE event to be raised
+        * by the SME
+        */
+       pConn->smContext.disAssocEventReason = STATUS_UNSPECIFIED;
+       pConn->smContext.disAssocEventStatusCode  = 0;
+
+    WLAN_REPORT_INFORMATION(pConn->hReport, CONN_MODULE_LOG, ("conn_stop, disConnType %d, reason=%d, disConEraseKeys=%d\n\n", 
+                  disConnType, reason, disConEraseKeys));
+
+       switch(pConn->currentConnType)
+       {
+       case CONNECTION_IBSS:
+    case CONNECTION_SELF:
+        pConn->ibssDisconnectCount++;
+               return conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, (TI_HANDLE) pConn);
+
+       case CONNECTION_INFRA:
+               return conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, (TI_HANDLE) pConn);
+
+
+       default:
+               WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Stop connection, invalid type %d\n\n", pConn->currentConnType));
+               return NOK;
+       }
+}
+
+
+/***********************************************************************
+ *                        conn_reportMlmeStatus                                                                        
+ ***********************************************************************
+DESCRIPTION:   Called by the MLME SM when MLME status changed. 
+                               Valid only in the case that the current connection type is infrastructure
+                               The function calls the connection infra SM with MLME success or MLME failure 
+                               according to the status
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+                       status  -       MLME status
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_reportMlmeStatus(TI_HANDLE                      hConn, 
+                                                               mgmtStatus_e            status, UINT16 uStatusCode)
+{
+       conn_t *pConn = (conn_t *)hConn;
+
+       /* Save the reason for the use of the SME when triggering DISASSOCIATE event */ 
+       pConn->smContext.disAssocEventReason = status;
+       pConn->smContext.disAssocEventStatusCode = uStatusCode;
+
+       if (status == STATUS_SUCCESSFUL)
+       {
+               conn_infraSMEvent(&pConn->state, CONN_INFRA_MLME_SUCC, pConn);
+       }
+       else
+       {
+               WLAN_OS_REPORT(("-------------------------------------\n"));
+               WLAN_OS_REPORT(("               CONN LOST             \n"));
+               WLAN_OS_REPORT(("-------------------------------------\n"));
+
+               if( pConn->connType == CONN_TYPE_ROAM )
+                       pConn->disConnType = DISCONN_TYPE_IMMEDIATE;
+               else /* connType == CONN_TYPE_ESS */
+                       pConn->disConnType = DISCONN_TYPE_DEAUTH;
+
+        WLAN_REPORT_INFORMATION(pConn->hReport, CONN_MODULE_LOG, 
+                       ("conn_reportMlmeStatus, disAssocEventReason %d, disAssocEventStatusCode = %d, connType=%d, disConnType=%d \n", 
+            pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode, pConn->connType, pConn->disConnType));
+
+               conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, pConn);
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        conn_reportRsnStatus                                                                 
+ ***********************************************************************
+DESCRIPTION:   Called by the RSN SM when RSN status changed. 
+                               This function calls the current connection SM with RSN success or RSN failure based on the status       
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+                       status  -       RSN status
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_reportRsnStatus(TI_HANDLE                       hConn, 
+                                                       mgmtStatus_e            status)
+{
+       conn_t *pConn = (conn_t *)hConn;
+
+       /* Save the reason for the use of the SME when triggering DISASSOCIATE event. For now we just have STATUS_SECURITY_FAILURE */ 
+       pConn->smContext.disAssocEventReason = status;
+       pConn->smContext.disAssocEventStatusCode = 0; /* For now we don't use this parameter in RSN */
+
+       switch(pConn->currentConnType)
+       {
+       case CONNECTION_IBSS:
+       case CONNECTION_SELF:
+               if (status == STATUS_SUCCESSFUL)
+                       return conn_ibssSMEvent(&pConn->state, CONN_IBSS_RSN_SUCC, (TI_HANDLE) pConn);
+               else
+                       return conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, (TI_HANDLE) pConn);
+
+
+
+       case CONNECTION_INFRA:
+               if (status == STATUS_SUCCESSFUL)
+                       return conn_infraSMEvent(&pConn->state, CONN_INFRA_RSN_SUCC, (TI_HANDLE) pConn);
+               
+               else{ /* status == STATUS_SECURITY_FAILURE */
+                       /*
+                        * In infrastructure - if the connection is standard 802.11 connection (ESS) then
+                        * need to disassociate. In roaming mode, the connection is stopped without sending
+                        * the reassociation frame.
+                        */
+                       if( pConn->connType == CONN_TYPE_ROAM )
+                               pConn->disConnType = DISCONN_TYPE_IMMEDIATE;
+                       else /* connType == CONN_TYPE_ESS */
+                               pConn->disConnType = DISCONN_TYPE_DISASSOC;
+
+            WLAN_REPORT_INFORMATION(pConn->hReport, CONN_MODULE_LOG, ("conn_reportRsnStatus, disAssocEventReason %d, connType=%d, disConnType=%d \n\n", 
+                          pConn->smContext.disAssocEventReason, pConn->connType, pConn->disConnType));
+
+                       return conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONNECT, (TI_HANDLE) pConn);
+               }
+       case CONNECTION_NONE:
+               break;
+       }
+       
+       return OK;
+}
+
+/***********************************************************************
+ *                        conn_timeout                                                                 
+ ***********************************************************************
+DESCRIPTION:   Called by the OS abstraction layer when the self timer expired 
+                               Valid only if the current connection type is self
+                               This function calls the self connection SM with timeout event
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void conn_timeout(void *pContext)
+{
+       conn_t *pConn = (conn_t *)pContext;
+
+       switch(pConn->currentConnType)
+       {
+       case CONNECTION_IBSS:
+       case CONNECTION_SELF:
+               conn_ibssSMEvent(&pConn->state, CONN_IBSS_DISCONNECT, pConn);
+               break;
+
+       case CONNECTION_INFRA:
+               conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONN_COMPLETE, (TI_HANDLE) pConn);
+               healthMonitor_sendFailureEvent(pConn->hHealthMonitor, DISCONNECT_TIMEOUT);
+               break;
+
+       case CONNECTION_NONE:
+               break;
+       }
+
+       return;
+}
+
+
+/***********************************************************************
+ *                        conn_join                                                                    
+ ***********************************************************************
+DESCRIPTION:   Called by the site manager when detecting that another station joined our own created IBSS 
+                               Valid only if the current connection type is self
+                               This function calls the self connection SM with join event
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_ibssStaJoined(TI_HANDLE hConn)
+{
+       conn_t *pConn = (conn_t *)hConn;
+       conn_ibssSMEvent(&pConn->state, CONN_IBSS_STA_JOINED, pConn);
+       return OK;
+}
+
+/***********************************************************************
+ *                        release_module                                                                       
+ ***********************************************************************
+DESCRIPTION:   Called by the un load function
+                               Go over the vector, for each bit that is set, release the corresponding module.
+                                                                                                   
+INPUT:      hConn      -       Connection handle.
+                       initVec -       Vector that contains a bit set for each module thah had been initiualized
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void release_module(conn_t *pConn, UINT32 initVec)
+{
+       if (initVec & (1 << IBSS_SM_INIT_BIT))
+               fsm_Unload(pConn->hOs, pConn->ibss_pFsm);
+
+    if (initVec & (1 << INFRA_SM_INIT_BIT))
+               fsm_Unload(pConn->hOs, pConn->infra_pFsm);
+
+       if (initVec & (1 << TIMER_INIT_BIT))
+               utils_nullTimerDestroy(pConn->hOs, pConn->pTimer);
+
+       if (initVec & (1 << CONN_INIT_BIT))
+               utils_nullMemoryFree(pConn->hOs, pConn, sizeof(conn_t));
+
+       initVec = 0;
+}
+
+
+/***********************************************************************
+ *                        conn_waitToDisassoc                                                                  
+ ***********************************************************************
+DESCRIPTION:                 
+
+  INPUT:      hConn    -       Connection handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+void conn_disConnFrameSentCBFunc(TI_HANDLE hConn)
+{
+       conn_t *pConn = (conn_t *)hConn;
+       
+       conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONN_COMPLETE, (TI_HANDLE) pConn);
+}
+
+/**
+*
+* conn_ibssPrintStatistics
+*
+* \b Description: 
+*
+* Called by Site Manager when request to print statistics is requested from CLI  
+*
+* \b ARGS: Connection handle
+*
+* \b RETURNS:
+*
+*  None.
+*
+* \sa 
+*/
+void conn_ibssPrintStatistics(TI_HANDLE hConn)
+{
+#ifdef REPORT_LOG
+    conn_t *pConn = (conn_t *)hConn;
+
+    WLAN_OS_REPORT(("- IBSS Disconnect = %d\n", pConn->ibssDisconnectCount));
+    WLAN_OS_REPORT(("\n"));
+#endif
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/conn/connIbss.c b/sta_dk_4_0_4_32/common/src/core/sme/conn/connIbss.c
new file mode 100644 (file)
index 0000000..d3bb08d
--- /dev/null
@@ -0,0 +1,530 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 connIbss.c
+ *  \brief IBSS connection implementation
+ *
+ *  \see connIbss.h
+ */
+
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "conn.h"
+#include "connIbss.h"
+#include "fsm.h"
+#include "siteMgrApi.h"
+#include "smeSmApi.h"
+#include "rsnApi.h"
+#include "DataCtrl_Api.h"  
+#include "paramIn.h"
+#include "paramOut.h"
+#include "connApi.h"
+#include "EvHandler.h"
+#include "currBss.h"
+#include "TrafficMonitorAPI.h"
+#include "healthMonitor.h"
+
+/* Local functions prototypes */
+/* Local functions prototypes */
+static TI_STATUS idle_to_selfWait(void *pData);
+
+static TI_STATUS idle_to_rsnWait(void *pData);
+    
+static TI_STATUS selfWait_to_idle(void *pData);
+
+static TI_STATUS selfWait_to_rsnWait(void *pData);
+
+static TI_STATUS rsnWait_to_idle(void *pData);
+
+static TI_STATUS rsnWait_to_connected(void *pData);
+
+static TI_STATUS connected_to_idle(void *pData);
+
+static TI_STATUS actionUnexpected(void *pData);
+
+static TI_STATUS actionNop(void *pData);
+
+/********************************************/
+/*      Functions Implementations           */
+/********************************************/
+
+/***********************************************************************
+ *                        conn_ibssConfig                                   
+ ***********************************************************************
+DESCRIPTION: IBSS Connection configuration function, called by the conection set param function
+                in the selection phase. Configures the connection state machine to IBSS connection mode
+                                                                                                   
+INPUT:      hConn   -   Connection handle.
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_ibssConfig(conn_t *pConn)
+{
+
+    fsm_actionCell_t    smMatrix[CONN_IBSS_NUM_STATES][CONN_IBSS_NUM_EVENTS] =
+    {
+
+        /* next state and actions for IDLE state */
+        {   {STATE_CONN_IBSS_SELF_WAIT, idle_to_selfWait    },  /* CONN_IBSS_CREATE */
+            {STATE_CONN_IBSS_RSN_WAIT,  idle_to_rsnWait     },  /* CONN_IBSS_CONNECT    */
+            {STATE_CONN_IBSS_IDLE,      actionNop           },  /* CONN_IBSS_DISCONNECT */
+            {STATE_CONN_IBSS_IDLE,      actionUnexpected    },  /* CONN_IBSS_RSN_SUCC */
+            {STATE_CONN_IBSS_IDLE,      actionUnexpected    }   /* CONN_IBSS_STA_JOINED */
+        },
+
+        /* next state and actions for SELF_WAIT state */
+        {   {STATE_CONN_IBSS_SELF_WAIT, actionUnexpected    },  /* CONN_IBSS_CREATE */
+            {STATE_CONN_IBSS_SELF_WAIT, actionUnexpected    },  /* CONN_IBSS_CONNECT    */
+            {STATE_CONN_IBSS_IDLE,      selfWait_to_idle    },  /* CONN_IBSS_DISCONNECT */
+            {STATE_CONN_IBSS_SELF_WAIT, actionUnexpected    },  /* CONN_IBSS_RSN_SUCC */
+            {STATE_CONN_IBSS_RSN_WAIT,  selfWait_to_rsnWait }   /* CONN_IBSS_STA_JOINED */
+        },
+
+        /* next state and actions for RSN_WAIT state */
+        {   {STATE_CONN_IBSS_RSN_WAIT,  actionUnexpected    },  /* CONN_IBSS_CREATE */
+            {STATE_CONN_IBSS_RSN_WAIT,  actionUnexpected    },  /* CONN_IBSS_CONNECT    */
+            {STATE_CONN_IBSS_IDLE,      rsnWait_to_idle     },  /* CONN_IBSS_DISCONNECT */
+            {STATE_CONN_IBSS_CONNECTED, rsnWait_to_connected},  /* CONN_IBSS_RSN_SUCC */
+            {STATE_CONN_IBSS_RSN_WAIT,  actionNop           }   /* CONN_IBSS_STA_JOINED */
+        },
+
+        /* next state and actions for CONNECTED state */
+        {   {STATE_CONN_IBSS_CONNECTED, actionUnexpected    },  /* CONN_IBSS_CREATE */
+            {STATE_CONN_IBSS_CONNECTED, actionUnexpected    },  /* CONN_IBSS_CONNECT    */
+            {STATE_CONN_IBSS_IDLE,      connected_to_idle   },  /* CONN_IBSS_DISCONNECT */
+            {STATE_CONN_IBSS_CONNECTED, actionUnexpected    },  /* CONN_IBSS_RSN_SUCC */
+            {STATE_CONN_IBSS_RSN_WAIT,  actionNop           }   /* CONN_IBSS_STA_JOINED */
+        }
+        
+    };
+
+    return fsm_Config(pConn->ibss_pFsm, (fsm_Matrix_t)smMatrix, CONN_IBSS_NUM_STATES, CONN_IBSS_NUM_EVENTS, conn_ibssSMEvent, pConn->hOs);
+}
+
+
+/***********************************************************************
+ *                        conn_ibssSMEvent                                  
+ ***********************************************************************
+DESCRIPTION: IBSS Connection SM event processing function, called by the connection API
+                Perform the following:
+                -   Print the state movement as a result from the event
+                -   Calls the generic state machine event processing function which preform the following:
+                    -   Calls the correspoding callback function
+                    -   Move to next state
+                
+INPUT:      currentState    -   Pointer to the connection current state.
+            event   -   Received event
+            pConn   -   Connection handle
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+#ifdef REPORT_LOG
+
+static char *stateDesc[CONN_IBSS_NUM_STATES] = 
+    {
+        "STATE_CONN_IBSS_IDLE",
+        "STATE_CONN_IBSS_SELF_WAIT",
+        "STATE_CONN_IBSS_RSN_WAIT",
+        "STATE_CONN_IBSS_CONNECTED"
+    };
+
+static char *eventDesc[CONN_IBSS_NUM_EVENTS] = 
+    {
+        "CONN_IBSS_START",
+        "CONN_IBSS_CONNECT",
+        "CONN_IBSS_DISCONNECT",
+        "CONN_IBSS_RSN_SUCC",
+        "CONN_IBSS_STA_JOINED"
+    };
+
+#endif
+
+
+TI_STATUS conn_ibssSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn)
+{
+   conn_t *pConn = (conn_t *)hConn;
+    TI_STATUS       status;
+    UINT8       nextState;
+
+    status = fsm_GetNextState(pConn->ibss_pFsm, *currentState, event, &nextState);
+    if (status != OK)
+    {
+        WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, ("IBSS State machine error, failed getting next state\n"));
+        return(NOK);
+    }
+
+    WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, 
+                              ("IBSS: <%s, %s> --> %s\n\n",
+                               stateDesc[*currentState],
+                               eventDesc[event],
+                               stateDesc[nextState]));
+
+    status = fsm_Event(pConn->ibss_pFsm, currentState, event, (void *)pConn);
+
+    return status;
+}
+
+
+/************************************************************************************************************/
+/*      In the following section are listed the callback function used by the IBSS connection state machine */
+/************************************************************************************************************/
+
+
+
+/***********************************************************************
+ *                        idle_to_selfWait
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS idle_to_selfWait(void *pData)
+{
+    UINT16      randomTime;
+
+    /*Request from ELP to stay awake*/
+    MacServices_powerAutho_AwakeRequiredUpdate(((conn_t *)pData)->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_IBSS);
+
+    siteMgr_join(((conn_t *)pData)->hSiteMgr);
+
+    txData_disableTransmission(((conn_t *)pData)->hTxData, NO_DISABLE);
+
+    /* get a randomTime that is constructed of the lower 13 bits ot the system time to 
+       get a MS random time of ~8000 ms */
+    randomTime = os_timeStampMs(((conn_t *)pData)->hOs) & 0x1FFF;
+
+    /* Update current BSS connection type and mode */
+    currBSS_updateConnectedState(((conn_t *)pData)->hCurrBss, TRUE, BSS_INDEPENDENT);
+    os_timerStart(((conn_t *)pData)->hOs, ((conn_t *)pData)->pTimer, (((conn_t *)pData)->timeout + randomTime), FALSE);
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        idle_to_rsnWait
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS idle_to_rsnWait(void *pData)
+{
+    paramInfo_t param;
+
+    /*Request from ELP to stay awake*/
+    MacServices_powerAutho_AwakeRequiredUpdate(((conn_t *)pData)->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_IBSS);
+    
+    siteMgr_join(((conn_t *)pData)->hSiteMgr);
+
+    txData_disableTransmission(((conn_t *)pData)->hTxData, NO_DISABLE);
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = OPEN_EAPOL;
+    rxData_setParam(((conn_t *)pData)->hRxData, &param);
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = OPEN_EAPOL;
+    txData_setParam(((conn_t *)pData)->hTxData, &param);
+    
+    /*
+     *  Notify that the driver is associated to the supplicant\IP stack. 
+     */
+    EvHandlerSendEvent(((conn_t *)pData)->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);
+
+    /* Update current BSS connection type and mode */
+    currBSS_updateConnectedState(((conn_t *)pData)->hCurrBss, TRUE, BSS_INDEPENDENT);
+    
+    return rsn_start(((conn_t *)pData)->hRsn);
+}
+
+/***********************************************************************
+ *                        selfWait_to_idle
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS selfWait_to_idle(void *pData)
+{
+    paramInfo_t     param;  
+    os_timerStop(((conn_t *)pData)->hOs, ((conn_t *)pData)->pTimer);
+
+    
+    siteMgr_removeSelfSite(((conn_t *)pData)->hSiteMgr);
+
+    /* Update current BSS connection type and mode */
+    currBSS_updateConnectedState(((conn_t *)pData)->hCurrBss, FALSE, BSS_INDEPENDENT);
+    
+    /* Release ELP  */
+    MacServices_powerAutho_AwakeRequiredUpdate(((conn_t *)pData)->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_IBSS);
+
+    /* stop beacon generation  */
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    rxData_setParam(((conn_t *)pData)->hRxData, &param);
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    txData_setParam(((conn_t *)pData)->hTxData, &param);
+    
+    whalCtrl_FwDisconnect(((conn_t *)pData)->hHalCtrl, 
+                          RX_CONFIG_OPTION_MY_DST_MY_BSS, 
+                          RX_FILTER_OPTION_FILTER_ALL);
+
+    /* Inform the SME about the connection lost */
+    smeSm_reportConnStatus(((conn_t *)pData)->hSmeSm, STATUS_UNSPECIFIED, 0);
+
+    return OK;
+}
+
+
+
+/***********************************************************************
+ *                        selfWait_to_rsnWait
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS selfWait_to_rsnWait(void *pData)
+{
+    paramInfo_t param;
+
+    os_timerStop(((conn_t *)pData)->hOs, ((conn_t *)pData)->pTimer);
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = OPEN_EAPOL;
+    rxData_setParam(((conn_t *)pData)->hRxData, &param);
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = OPEN_EAPOL;
+    txData_setParam(((conn_t *)pData)->hTxData, &param);
+
+    /*
+     *  Notify that the driver is associated to the supplicant\IP stack. 
+     */
+    EvHandlerSendEvent(((conn_t *)pData)->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);
+
+    return rsn_start(((conn_t *)pData)->hRsn);
+}
+
+
+/***********************************************************************
+ *                        rsnWait_to_idle
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS rsnWait_to_idle(void *pData)
+{
+    paramInfo_t     param;  
+
+    rsn_stop(((conn_t *)pData)->hRsn, FALSE);
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    rxData_setParam(((conn_t *)pData)->hRxData, &param);
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    txData_setParam(((conn_t *)pData)->hTxData, &param);
+
+    /* Update current BSS connection type and mode */
+    currBSS_updateConnectedState(((conn_t *)pData)->hCurrBss, FALSE, BSS_INDEPENDENT);
+
+    
+    /* Release ELP  */
+    MacServices_powerAutho_AwakeRequiredUpdate(((conn_t *)pData)->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_IBSS);
+
+    /* stop beacon generation */
+    whalCtrl_FwDisconnect(((conn_t *)pData)->hHalCtrl, 
+                          RX_CONFIG_OPTION_MY_DST_MY_BSS, 
+                          RX_FILTER_OPTION_FILTER_ALL);
+
+
+
+    smeSm_reportConnStatus(((conn_t *)pData)->hSmeSm, STATUS_UNSPECIFIED, 0);
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        rsnWait_to_connected
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS rsnWait_to_connected(void *pData)
+{
+    paramInfo_t param;
+
+    conn_t *pConn=(conn_t *)pData;
+
+    ctrlData_start(pConn->hCtrlData);
+
+    TrafficMonitor_Start( pConn->hTrafficMonitor );
+
+    healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_CONNECTED);
+
+    siteMgr_start(pConn->hSiteMgr);
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = OPEN;
+    rxData_setParam(((conn_t *)pData)->hRxData, &param);
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = OPEN;
+    txData_setParam(((conn_t *)pData)->hTxData, &param);
+
+    
+    /* Update current BSS connection type and mode */
+    currBSS_updateConnectedState(pConn->hCurrBss, TRUE, BSS_INDEPENDENT);
+
+    return smeSm_reportConnStatus(((conn_t *)pData)->hSmeSm, STATUS_SUCCESSFUL, 0);
+}
+
+/***********************************************************************
+ *                        connected_to_idle
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS connected_to_idle(void *pData)
+{
+    conn_t *pConn=(conn_t *)pData;
+
+    TrafficMonitor_Stop(pConn->hTrafficMonitor);
+
+    healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_DISCONNECTED);
+
+    /* The logic of this action is identical to rsnWait_to_idle */
+    return rsnWait_to_idle(pConn);
+}
+
+
+
+/***********************************************************************
+ *                        actionUnexpected
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS actionUnexpected(void *pData) 
+{
+    conn_t *pConn = (conn_t *)pData; 
+    
+    WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG,  ("State machine error, unexpected Event\n\n"));
+    return OK;
+}
+
+/***********************************************************************
+ *                        actionNop
+ ***********************************************************************
+DESCRIPTION: 
+
+
+INPUT:   
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS actionNop(void *pData) 
+{
+    return OK;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/conn/connIbss.h b/sta_dk_4_0_4_32/common/src/core/sme/conn/connIbss.h
new file mode 100644 (file)
index 0000000..c3d5239
--- /dev/null
@@ -0,0 +1,81 @@
+/** \file connIbss.h
+ *  \brief IBSS connection header file
+ *
+ *  \see connIbss.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*       MODULE:       ibssConn.h                                                                                                                              */
+/*    PURPOSE: IBSS connection header file                                                                                     */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __CONN_IBSS_H__
+#define __CONN_IBSS_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "conn.h"
+
+/* IBSS connection SM events */
+typedef enum 
+{
+       CONN_IBSS_CREATE                = 0,  /* Sent when establishing new IBSS. */ 
+       CONN_IBSS_CONNECT                 ,   /* Sent when trying to join existing IBSS. */
+       CONN_IBSS_DISCONNECT      ,       /* Stops to connection */
+       CONN_IBSS_RSN_SUCC                ,   /* RSN keys are set to the HW */
+       CONN_IBSS_STA_JOINED      ,   /* Event sent when other STA joined our self IBSS */
+    CONN_IBSS_NUM_EVENTS            
+} connIbssEvent_e;
+
+/* IBSS connection states */
+typedef enum
+{
+       STATE_CONN_IBSS_IDLE            =0,
+       STATE_CONN_IBSS_SELF_WAIT       ,
+       STATE_CONN_IBSS_RSN_WAIT        ,
+       STATE_CONN_IBSS_CONNECTED       ,
+    CONN_IBSS_NUM_STATES    
+} conn_ibss_state_e;
+
+
+TI_STATUS conn_ibssConfig(conn_t *pConn);
+
+TI_STATUS conn_ibssSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn);
+
+#endif /* __CONN_IBSS_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/conn/connInfra.c b/sta_dk_4_0_4_32/common/src/core/sme/conn/connInfra.c
new file mode 100644 (file)
index 0000000..c0b0138
--- /dev/null
@@ -0,0 +1,985 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 connInfra.c
+ *  \brief Infra connection implementation
+ *
+ *  \see connInfra.h
+ */
+
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "conn.h"
+#include "connInfra.h"
+#include "fsm.h"
+#include "siteMgrApi.h"
+#include "smeSmApi.h"
+#include "rsnApi.h"
+#include "DataCtrl_Api.h"  
+#include "paramIn.h"
+#include "paramOut.h"
+#include "siteHash.h"
+#include "smeSm.h"
+#include "PowerMgr_API.h"
+#include "measurementMgrApi.h"
+#include "TrafficMonitorAPI.h"
+#include "qosMngr_API.h"
+#include "EvHandler.h"
+#include "SwitchChannelApi.h"
+#include "ScanCncnApi.h"
+#include "currBss.h"
+#include "EvHandler.h"
+#include "healthMonitor.h"
+#include "regulatoryDomainApi.h"
+#include "SoftGeminiApi.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#include "excTSMngr.h"
+#endif
+
+#define DISCONNECT_TIMEOUT      800
+
+/* Local functions prototypes */
+
+static TI_STATUS actionUnexpected(void *pData);
+
+static TI_STATUS actionNop(void *pData);
+
+static TI_STATUS Idle_to_ScrWait(void *pData);
+
+static TI_STATUS Idle_to_Idle(void *pData);
+
+static TI_STATUS ScrWait_to_idle(void *pData);
+
+static TI_STATUS ScrWait_to_JoinWait(void *pData);
+
+static TI_STATUS JoinWait_to_mlmeWait(void *pData);
+
+static TI_STATUS JoinWait_to_Idle(void *pData);
+
+static TI_STATUS mlmeWait_to_Idle(void *pData);
+
+static TI_STATUS mlmeWait_to_rsnWait(void *pData);
+
+static TI_STATUS rsnWait_to_disassociate(void *pData);
+
+static TI_STATUS rsnWait_to_configHW(void *pData);
+
+static TI_STATUS configHW_to_connected(void *pData);
+
+static TI_STATUS configHW_to_disassociate(void *pData);
+
+static TI_STATUS connect_to_disassociate(void *pData);
+
+static TI_STATUS connect_to_ScrWait(void *pData);
+
+static TI_STATUS disAssocc_to_idle(void *pData);
+
+
+
+static TI_STATUS stopModules( conn_t *pConn );
+
+void InfraConnSM_ScrCB( TI_HANDLE hConn, scr_clientRequestStatus_e requestStatus,
+                        scr_pendReason_e pendReason );
+
+int conn_MboxFlushFinishCb(TI_HANDLE pData,UINT16 MboxStatus, char *InterrogateParamsBuf);
+
+/********************************************/
+/*      Functions Implementations           */
+/********************************************/
+
+
+/***********************************************************************
+ *                        conn_infraConfig                                  
+ ***********************************************************************
+DESCRIPTION: Infra Connection configuration function, called by the conection set param function
+                in the selection phase. Configures the connection state machine to Infra connection mode
+                                                                                                   
+INPUT:      hConn   -   Connection handle.
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS conn_infraConfig(conn_t *pConn)
+{
+    fsm_actionCell_t    smMatrix[CONN_INFRA_NUM_STATES][CONN_INFRA_NUM_EVENTS] =
+    {
+        /* next state and actions for IDLE state */
+        {   {STATE_CONN_INFRA_SCR_WAIT, Idle_to_ScrWait},               /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_IDLE, actionNop       },                  /* "EVENT_SCR_SUCC"*/
+            {STATE_CONN_INFRA_IDLE, actionNop       },                  /* "EVENT_JOIN_CMD_CMPLT */
+            {STATE_CONN_INFRA_IDLE, Idle_to_Idle    },                  /* "EVENT_DISCONNECT"       */
+            {STATE_CONN_INFRA_IDLE, actionUnexpected},                  /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_IDLE, actionUnexpected},                  /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_IDLE, actionUnexpected},                  /* "EVENT_CONFIG_HW" */
+            {STATE_CONN_INFRA_IDLE, actionUnexpected}                   /* "EVENT_DISASSOC_FRAME_SENT" */
+        },
+
+        /* next state and actions for SCR_WAIT state */
+        {   {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected},              /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, ScrWait_to_JoinWait},    /* "EVENT_SCR_SUCC"*/
+            {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected},              /* "EVENT_JOIN_CMD_CMPLT */
+            {STATE_CONN_INFRA_IDLE,     ScrWait_to_idle},               /* "EVENT_DISCONNECT"       */
+            {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected},              /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected},              /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_SCR_WAIT, actionUnexpected},              /* "EVENT_CONFIG_HW "*/
+            {STATE_CONN_INFRA_SCR_WAIT, actionNop}                      /* "EVENT_DISASSOC_FRAME_SENT" */
+        },
+
+        /* next state and actions for WAIT_JOIN_CMPLT */
+        
+        {   {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_CONNECT"    */
+            {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_SCR_SUCC"*/
+            {STATE_CONN_INFRA_MLME_WAIT,       JoinWait_to_mlmeWait},   /* "EVENT_JOIN_CMD_CMPLT"   */
+            {STATE_CONN_INFRA_IDLE,            JoinWait_to_Idle},       /* "EVENT_DISCONNECT"       */
+            {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_CONFIG_HW"        */
+            {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}        /* "EVENT_DISASSOC_FRAME_SENT" */
+        
+        },
+
+        /* next state and actions for MLME_WAIT state */
+        {   {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_SCR_SUCC" */
+            {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_JOIN_CMD_CMPLT"*/
+            {STATE_CONN_INFRA_IDLE,      mlmeWait_to_Idle},             /* "EVENT_DISCONNECT"       */
+            {STATE_CONN_INFRA_RSN_WAIT,  mlmeWait_to_rsnWait},          /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_CONFIG_HW" */
+            {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}              /* "EVENT_DISASSOC_FRAME_SENT" */   
+        },
+        
+        /* next state and actions for RSN_WAIT state */
+        {   {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_SCR_SUCC" */
+            {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_JOIN_CMD_CMPLT"*/
+            {STATE_CONN_INFRA_DISASSOCC,    rsnWait_to_disassociate},   /* "EVENT_DISCONNECT" */
+            {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_CONFIG_HW,    rsnWait_to_configHW},       /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_CONFIG_HW"        */
+            {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected}           /* "EVENT_DISASSOC_FRAME_SENT" */
+        },
+        
+        /* next state and actions for CONFIG_HW state */
+        {   {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_SCR_SUCC" */
+            {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_JOIN_CMD_CMPLT"*/
+            {STATE_CONN_INFRA_DISASSOCC, configHW_to_disassociate},     /* "EVENT_DISCONNECT"       */
+            {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_CONNECTED, configHW_to_connected},        /* "EVENT_CONFIG_HW"        */
+            {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}              /* "EVENT_DISASSOC_FRAME_SENT" */   
+        },
+
+        /* next state and actions for CONNECTED state */
+        {   {STATE_CONN_INFRA_SCR_WAIT, connect_to_ScrWait},        /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_SCR_SUCC"*/
+            {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_JOIN_CMD_CMPLT" */
+            {STATE_CONN_INFRA_DISASSOCC, connect_to_disassociate},  /* "EVENT_DISCONNECT"       */
+            {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "STATE_CONN_INFRA_CONFIG_HW" */
+            {STATE_CONN_INFRA_CONNECTED, actionUnexpected}          /* "EVENT_DISASSOC_FRAME_SENT" */   
+        },
+        
+            /* next state and actions for STATE_CONN_INFRA_DISASSOCC state */
+        {   {STATE_CONN_INFRA_DISASSOCC, actionUnexpected},         /* "EVENT_CONNECT"  */
+            {STATE_CONN_INFRA_DISASSOCC, actionUnexpected},         /* "STATE_CONN_INFRA_SCR_WAIT"*/
+            {STATE_CONN_INFRA_DISASSOCC, actionUnexpected},         /* "EVENT_JOIN_CMD_CMPLT" */
+            {STATE_CONN_INFRA_DISASSOCC, actionUnexpected},         /* "EVENT_DISCONNECT" */
+            {STATE_CONN_INFRA_DISASSOCC, actionUnexpected},         /* "EVENT_MLME_SUCC"*/
+            {STATE_CONN_INFRA_DISASSOCC, actionUnexpected},         /* "EVENT_RSN_SUCC" */
+            {STATE_CONN_INFRA_DISASSOCC, actionNop       },         /* "STATE_CONN_INFRA_CONFIG_HW"  */
+            {STATE_CONN_INFRA_IDLE,      disAssocc_to_idle}         /* "EVENT_DISASSOC_FRAME_SENT" */       
+        }
+        
+    };
+
+    scr_registerClientCB( pConn->hScr, SCR_CID_CONNECT, InfraConnSM_ScrCB, pConn );
+
+    return fsm_Config(pConn->infra_pFsm, (fsm_Matrix_t)smMatrix, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS, conn_infraSMEvent, pConn->hOs);
+}
+
+/***********************************************************************
+ *                        conn_infraSMEvent                                 
+ ***********************************************************************
+DESCRIPTION: Infra Connection SM event processing function, called by the connection API
+                Perform the following:
+                -   Print the state movement as a result from the event
+                -   Calls the generic state machine event processing function which preform the following:
+                    -   Calls the correspoding callback function
+                    -   Move to next state
+                
+INPUT:      currentState    -   Pointer to the connection current state.
+            event   -   Received event
+            pConn   -   Connection handle
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+#ifdef REPORT_LOG
+
+static char *stateDesc[CONN_INFRA_NUM_STATES] = 
+    {
+        "STATE_INFRA_IDLE",
+        "STATE_INFRA_SCR_WAIT",
+        "STATE_INFRA_WAIT_JOIN_CMPLT",
+        "STATE_INFRA_MLME_WAIT",
+        "STATE_INFRA_RSN_WAIT",
+        "STATE_INFRA_CONFIG_HW",
+        "STATE_INFRA_CONNECTED",
+        "STATE_INFRA_DISASSOCC",
+    };
+
+
+static char *eventDesc[CONN_INFRA_NUM_EVENTS] = 
+    {
+        "EVENT_INFRA_CONNECT",
+        "EVENT_INFRA_SCR_SUCC",
+        "EVENT_INFRA_JOIN_CMD_CMPLT",
+        "EVENT_INFRA_DISCONNECT",
+        "EVENT_INFRA_MLME_SUCC",
+        "EVENT_INFRA_RSN_SUCC",
+        "EVENT_INFRA_HW_CONFIGURED",
+        "EVENT_INFRA_DISCONN_COMPLETE",
+    };
+
+#endif
+
+TI_STATUS conn_infraSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn)
+{
+   conn_t *pConn = (conn_t *)hConn;
+    TI_STATUS       status;
+    UINT8       nextState;
+
+    status = fsm_GetNextState(pConn->infra_pFsm, *currentState, event, &nextState);
+    if (status != OK)
+    {
+        WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, ("State machine error, failed getting next state\n"));
+        return(NOK);
+    }
+
+    WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG, 
+                              ("INFRA: <%s, %s> --> %s\n\n",
+                               stateDesc[*currentState],
+                               eventDesc[event],
+                               stateDesc[nextState]));
+
+    status = fsm_Event(pConn->infra_pFsm, currentState, event, (void *)pConn);
+
+    return status;
+}
+
+/************************************************************************************************************/
+/*      In the following section are listed the callback function used by the Infra connection state machine    */
+/************************************************************************************************************/
+
+/* JOIN, SET_DATA_PORT_NOTIFY, START_MLME */
+static TI_STATUS ScrWait_to_JoinWait(void *pData)
+{
+    TI_STATUS status;
+    conn_t *pConn = (conn_t *)pData; 
+
+    /* set Hw available for the duration of the connection */
+    MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
+
+    status = siteMgr_join(((conn_t *)pData)->hSiteMgr );
+    /* If the Join command was failed we report the SME that connection failure so it could exit connecting state */
+    if (status != OK)
+    {
+       WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG,  ("Join command has failed!\n"));       
+    }
+    return status;
+}
+
+
+static TI_STATUS JoinWait_to_mlmeWait(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData;
+
+    txData_start(pConn->hTxData);
+
+    param.paramType = REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM;
+    regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = OPEN_NOTIFY;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = OPEN_NOTIFY;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+    /* 
+     * Set the reassociation flag in the association logic.
+     */ 
+    param.paramType = MLME_RE_ASSOC_PARAM;
+
+    if( pConn->connType == CONN_TYPE_ROAM )
+        param.content.mlmeReAssoc = TRUE;
+    else 
+        param.content.mlmeReAssoc = FALSE;
+
+    status = mlme_setParam(pConn->hMlmeSm, &param);
+
+    return mlme_start(pConn->hMlmeSm);
+}
+
+
+/* STOP_MLME, SET_DATA_PORT_CLOSE, DIS_JOIN */
+static TI_STATUS mlmeWait_to_Idle(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData; 
+
+    status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
+    if (status != OK)
+        return status;
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    rxData_setParam(pConn->hRxData, &param);
+
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    txData_setParam(pConn->hTxData, &param);
+
+    /* set Hw not available now that the connection process failed */
+    MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
+    
+    whalCtrl_FwDisconnect(pConn->hHalCtrl, 
+                          RX_CONFIG_OPTION_MY_DST_MY_BSS, 
+                          RX_FILTER_OPTION_FILTER_ALL );
+
+#ifdef EXC_MODULE_INCLUDED
+    excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC);
+#endif
+
+    scr_clientComplete(pConn->hScr, SCR_CID_CONNECT );
+
+    pConn->scrRequested = FALSE;
+
+    /*
+     * Call the connection lost callback set by the SME or AP_CONN.
+     */
+    pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
+
+    return OK;
+}
+
+/* This function is called from the WAIT_FOR_JOIN_CB_CMPLT state (before mlme_start)
+  - all we need to do is call siteMgr_disJoin */
+static TI_STATUS JoinWait_to_Idle(void *pData)
+{
+    conn_t *pConn = (conn_t *)pData; 
+
+    whalCtrl_FwDisconnect(pConn->hHalCtrl, 
+                           RX_CONFIG_OPTION_MY_DST_MY_BSS,
+                           RX_FILTER_OPTION_FILTER_ALL );
+    
+    /* set Hw not available now that the connection process failed */
+    MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
+        
+    scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
+    pConn->scrRequested = FALSE;
+
+    /*
+     * Call the connection lost callback set by the SME or AP_CONN.
+     */
+       pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
+
+   return OK;
+}
+
+/* SET_DATA_PORT_EAPOL, START_RSN */
+static TI_STATUS mlmeWait_to_rsnWait(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData;
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = OPEN_EAPOL;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = OPEN_EAPOL;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+    /*
+     *  Notify that the driver is associated to the supplicant\IP stack. 
+     */
+    EvHandlerSendEvent(pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);
+
+    return rsn_start(pConn->hRsn);
+}
+
+
+
+/* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
+static TI_STATUS rsnWait_to_disassociate(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData;
+
+    status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
+    if (status != OK)
+        return status;
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+    /* Start the disconnect complete time out timer. 
+        This should be done BEFORE calling mlme_stop, which invokes Disconect Complete
+        event, which stops the timer. */
+    os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE);
+
+    status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
+
+    if (status != OK)
+        return status;
+
+    return OK;
+}
+
+
+/* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
+static TI_STATUS configHW_to_disassociate(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData;
+
+    status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys );
+    if (status != OK)
+        return status;
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+    /* Start the disconnect complete time out timer. 
+        This should be done BEFORE calling mlme_stop, which invokes Disconect Complete
+        event, which stops the timer. */
+    os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE);
+
+    status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
+    if (status != OK)
+        return status;
+
+    param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
+    regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
+
+    /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
+        supported rates, and stopModules clears all rates. */
+    stopModules(pConn);
+
+    return OK;
+}
+
+static TI_STATUS connect_to_disassociate(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData;
+
+    status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
+    if (status != OK)
+        return status;
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
+    regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
+
+    /* Start the disconnect complete time out timer. 
+        This should be done BEFORE calling mlme_stop, which invokes Disconect Complete
+        event, which stops the timer. */
+    os_timerStart(pConn->hOs, pConn->pTimer, DISCONNECT_TIMEOUT, FALSE);
+
+    status = mlme_stop( pConn->hMlmeSm, pConn->disConnType, pConn->disConnReasonToAP );
+    if (status != OK)
+        return status;
+
+    /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
+        supported rates, and stopModules clears all rates. */
+    stopModules(pConn);
+
+    return OK;
+
+}
+
+
+static TI_STATUS rsnWait_to_configHW(void *pData)
+{
+    conn_t *pConn=(conn_t *)pData;
+    TI_STATUS status;
+    static UINT8    buf[20]; /* for mailbox interrogate leave the "static" flag !!!*/
+    paramInfo_t     param;
+
+    /* Open the RX to DATA */
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = OPEN;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    status = ctrlData_start(pConn->hCtrlData);
+    if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
+         return status;
+      }
+
+    status = qosMngr_connect(pConn->hQosMngr);
+    if (status != OK)
+    {
+         WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
+         return status;
+    }
+
+    status = measurementMgr_connected(pConn->hMeasurementMgr);
+    if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
+         return status;
+      }
+
+    status = TrafficMonitor_Start(pConn->hTrafficMonitor);
+    if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pConn->hReport, CONN_MODULE_LOG, ("Infra Conn status=%d, have to return (%d)\n",status,__LINE__));
+         return status;
+      }
+
+    healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_CONNECTED);
+
+    switchChannel_start(pConn->hSwitchChannel);
+
+    scanConcentrator_switchToConnected( pConn->hScanCnc );
+
+    PowerMgr_startPS(pConn->hPwrMngr);
+    
+    whalCtrl_InterrogateMbox(pConn->hHalCtrl, (void *)conn_MboxFlushFinishCb,pData,&buf[0]);
+
+    return OK;
+}
+
+/* Interrogate command CB to indicates that the Mbox is flushed*/
+int conn_MboxFlushFinishCb(TI_HANDLE pData,UINT16 MboxStatus, char *InterrogateParamsBuf)
+{
+    conn_t *pConn = (conn_t *)pData;
+    return conn_infraSMEvent(&pConn->state, CONN_INFRA_HW_CONFIGURED, pConn);
+}
+
+
+static TI_STATUS configHW_to_connected(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn=(conn_t *)pData;
+
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = OPEN;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+#ifdef EXC_MODULE_INCLUDED
+    excMngr_updateIappInformation(pConn->hExcMngr, EXC_ASSOC_OK);
+#endif
+
+    /* Start keep alive process */
+    siteMgr_start(pConn->hSiteMgr);
+
+    scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
+    pConn->scrRequested = FALSE;
+
+    /* Update current BSS connection type and mode */
+    currBSS_updateConnectedState(pConn->hCurrBss, TRUE, BSS_INFRASTRUCTURE);
+
+    pConn->pConnStatusCB( pConn->connStatCbObj, STATUS_SUCCESSFUL, 0);
+
+    /* set Hw not available now that the connection process ended successfully */
+    MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
+
+       SoftGemini_SetPSmode(pConn->hSoftGemini);
+    
+       WLAN_OS_REPORT(("************ NEW CONNECTION ************\n"));
+    siteMgr_printPrimarySiteDesc(pConn->hSiteMgr);
+
+    return OK;
+}
+
+
+static TI_STATUS actionUnexpected(void *pData) 
+{
+    conn_t *pConn = (conn_t *)pData; 
+    
+    WLAN_REPORT_SM(pConn->hReport, CONN_MODULE_LOG,  ("State machine error, unexpected Event\n\n"));
+    return OK;
+}
+
+static TI_STATUS actionNop(void *pData) 
+{
+    return OK;
+}
+
+
+static TI_STATUS Idle_to_ScrWait(void *pData)
+{
+    scr_clientRequestStatus_e scrReplyStatus;
+    scr_pendReason_e scrPendReason;
+    
+    conn_t *pConn = (conn_t *)pData;
+
+    WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
+                             ("Infra Connnect SM: Requesting SCR.\n") );
+    scrReplyStatus = scr_clientRequest( pConn->hScr, SCR_CID_CONNECT, &scrPendReason );
+
+    pConn->scrRequested = TRUE;
+
+    /* request the SCR as application (either BG or FG) client, and act according to return status */
+    switch ( scrReplyStatus )
+    {
+    case SCR_CRS_PEND:
+        /* send a pend event to the SM */
+        WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, 
+                                 ("Infra Conn: SCR pending with pend reason: %d, stay in wait SCR state.\n",
+                                  scrPendReason) );
+        break;
+
+    case SCR_CRS_RUN:
+        /* send an SCR SUCCESS event to the SM */
+        WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: SCR acquired.\n") );
+        
+        conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn);
+        break;
+
+    default:
+        WLAN_REPORT_ERROR( pConn->hReport, CONN_MODULE_LOG,
+                             ("Infra Conn: SCR returned unrecognized status: %d.\n", scrReplyStatus) );
+        return NOK;
+    }
+
+    return OK;
+}
+
+
+
+void InfraConnSM_ScrCB( TI_HANDLE hConn, scr_clientRequestStatus_e requestStatus,
+                        scr_pendReason_e pendReason )
+{
+    conn_t *pConn = (conn_t *)hConn;
+
+    WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
+                             ("InfraConnSM_ScrCB called by SCR. Status is: %d.\n", requestStatus) );
+    
+    /* act according to the request staus */
+    switch ( requestStatus )
+    {
+    case SCR_CRS_RUN:
+        /* send an SCR SUCCESS event to the SM */
+        WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: SCR acquired.\n") );
+        
+        conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn);
+        break;
+
+    case SCR_CRS_FW_RESET:
+        /* Ignore FW reset, the MLME SM will handle re-try of the conn */
+        WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG, ("Infra Conn: Recovery occured.\n") );
+        break;
+
+    default:
+        WLAN_REPORT_ERROR( pConn->hReport, CONN_MODULE_LOG,
+                           ("Illegal SCR request status:%d, pend reason:%d.\n", 
+                           requestStatus, pendReason) );
+        break;
+    }
+    
+    return;
+}
+
+
+
+static TI_STATUS ScrWait_to_idle(void *pData)
+{
+    conn_t *pConn = (conn_t *)pData;
+
+    WLAN_REPORT_INFORMATION( pConn->hReport, CONN_MODULE_LOG,
+                             ("Infra Connnect SM: Stop event while in SCR wait, moving to IDLE.\n") );
+
+    scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
+    pConn->scrRequested = FALSE;
+
+    /*
+     * Call the connection lost callback set by the SME or AP_CONN.
+     */
+       pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
+
+    return OK;
+
+}
+
+
+static TI_STATUS stopModules( conn_t *pConn )
+{
+   
+    measurementMgr_disconnected(pConn->hMeasurementMgr);
+
+    rxData_stop(pConn->hRxData);
+
+    ctrlData_stop(pConn->hCtrlData);
+    
+    TrafficMonitor_Stop(pConn->hTrafficMonitor);
+
+    switchChannel_stop(pConn->hSwitchChannel);
+
+    healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_DISCONNECTED);
+
+    siteMgr_stop(pConn->hSiteMgr);
+
+    /* stopping power save */
+    PowerMgr_stopPS(pConn->hPwrMngr);
+
+    scanConcentrator_switchToNotConnected( pConn->hScanCnc );
+
+    /* Set Current BSS Module to stop triggerring roaming events */
+    currBSS_updateConnectedState(pConn->hCurrBss, FALSE, BSS_INFRASTRUCTURE);
+
+       SoftGemini_unSetPSmode(pConn->hSoftGemini);
+
+    return OK;
+}
+
+
+static TI_STATUS disAssocc_to_idle(void *pData)
+{
+    conn_t *pConn = (conn_t *)pData;
+
+    /* Stop the disconnect timeout timer. */
+    os_timerStop(((conn_t *)pData)->hOs, ((conn_t *)pData)->pTimer);
+
+    /* 
+     * Tx Data Stop and QoS disconnect must be called only after the disconnect (dissasociate/deauthenticate)
+     * has been sent, or else no TX complete is received!
+     */
+    txData_stop(pConn->hTxData);
+    qosMngr_disconnect(pConn->hQosMngr);
+
+#ifdef EXC_MODULE_INCLUDED
+    measurementMgr_disableTsMetrics(pConn->hMeasurementMgr, MAX_NUM_OF_AC);
+#endif
+
+    /* set Hw not available now that the connection process failed */
+    MacServices_powerAutho_AwakeRequiredUpdate(pConn->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_CONNECTION);
+
+    whalCtrl_FwDisconnect(pConn->hHalCtrl, 
+                          RX_CONFIG_OPTION_MY_DST_MY_BSS, 
+                          RX_FILTER_OPTION_FILTER_ALL);
+
+#ifdef EXC_MODULE_INCLUDED
+    excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC);
+#endif
+
+    /*
+     * Call the connection lost callback set by the SME or AP_CONN.
+     */
+       pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
+
+    /*
+     * In case of connection failuer we might get here without freeing the SCR.
+     */
+    if( pConn->scrRequested == TRUE ){
+         scr_clientComplete( pConn->hScr, SCR_CID_CONNECT );
+         pConn->scrRequested = FALSE;
+    }
+
+
+    return OK;
+
+}
+
+
+
+static TI_STATUS connect_to_ScrWait(void *pData)
+{
+    TI_STATUS status;
+    paramInfo_t param;
+    conn_t *pConn = (conn_t *)pData;
+    /*
+     * This function performs roaming by two steps:
+     * First - close the current connection without notify the SME.
+     * Second - start new connection in reassociation mode.
+     */ 
+
+
+    status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
+    if (status != OK)
+        return status;
+
+    param.paramType = RX_DATA_PORT_STATUS_PARAM;
+    param.content.rxDataPortStatus = CLOSE;
+    status = rxData_setParam(pConn->hRxData, &param);
+    if (status != OK)
+        return status;
+
+    param.paramType = TX_DATA_PORT_STATUS_PARAM;
+    param.content.txDataPortStatus = CLOSE;
+    status = txData_setParam(pConn->hTxData, &param);
+    if (status != OK)
+        return status;
+
+    status = mlme_stop(pConn->hMlmeSm, DISCONN_TYPE_IMMEDIATE, pConn->disConnReasonToAP);
+    if (status != OK)
+        return status;
+
+    param.paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
+    regulatoryDomain_setParam(pConn->hRegulatoryDomain, &param);
+
+#ifdef EXC_MODULE_INCLUDED
+    excMngr_updateIappInformation(pConn->hExcMngr, EXC_DISASSOC);
+#endif
+    /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
+        supported rates, and stopModules clears all rates. */
+    stopModules(pConn);
+
+    /* 
+     * Tx Data Stop and QoS disconnect must be called only after the disconnect (dissasociate/deauthenticate)
+     * has been sent. In this case no deauthenticate frame is sent bu still we keep the 
+     * order.
+     */
+    txData_stop(pConn->hTxData);
+    qosMngr_disconnect(pConn->hQosMngr);
+
+    /* 
+     * Start new connection.
+     */ 
+    Idle_to_ScrWait(pConn);
+
+    return OK;
+}
+
+static TI_STATUS Idle_to_Idle(void *pData)
+{
+    conn_t *pConn = (conn_t *)pData;
+
+    /* 
+     * In case we are in IDLE and getting DISCONNECT event, we need to inform
+     * the SME\AP_connection that we are disconnected. 
+     * Call the connection lost callback set by the SME or AP_CONN.
+     */
+       pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
+
+    return OK;
+}
+
+/***********************************************************************
+                connInfra_JoinCmpltNotification
+ ***********************************************************************
+DESCRIPTION: Call back upon receving Join Event Complete.
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     
+************************************************************************/
+TI_STATUS connInfra_JoinCmpltNotification(TI_HANDLE hconn)
+{
+    conn_t *pConn = (conn_t *)hconn;
+    
+    WLAN_REPORT_INFORMATION(pConn->hReport, SITE_MGR_MODULE_LOG,
+                           ("siteMgr_JoinCmplt: has been called\n"));
+
+   txData_disableTransmission(pConn->hTxData, NO_DISABLE);
+
+   if (pConn->currentConnType == CONNECTION_INFRA ) {
+       conn_infraSMEvent(&pConn->state, CONN_INFRA_JOIN_CMD_CMPLT, pConn);
+   }
+
+   return OK;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/conn/connInfra.h b/sta_dk_4_0_4_32/common/src/core/sme/conn/connInfra.h
new file mode 100644 (file)
index 0000000..b524814
--- /dev/null
@@ -0,0 +1,90 @@
+/** \file connInfra.h
+ *  \brief Infra connection header file
+ *
+ *  \see connInfra.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*       MODULE:       infraConn.h                                                                                                                             */
+/*    PURPOSE: Infrastructure connection header file                                                                                   */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __CONN_INFRA_H__
+#define __CONN_INFRA_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "conn.h"
+
+/* Infra connection SM events */
+typedef enum 
+{
+       CONN_INFRA_CONNECT                              = 0,
+       CONN_INFRA_SCR_SUCC ,
+    CONN_INFRA_JOIN_CMD_CMPLT ,
+       CONN_INFRA_DISCONNECT ,
+       CONN_INFRA_MLME_SUCC ,
+       CONN_INFRA_RSN_SUCC     ,
+       CONN_INFRA_HW_CONFIGURED ,
+       CONN_INFRA_DISCONN_COMPLETE ,
+    CONN_INFRA_NUM_EVENTS                      
+} connInfraEvent_e;
+
+/* Infra connection states */
+typedef enum
+{
+       STATE_CONN_INFRA_IDLE                    = 0,
+       STATE_CONN_INFRA_SCR_WAIT                                = 1,
+    STATE_CONN_INFRA_WAIT_JOIN_CMPLT         = 2,
+       STATE_CONN_INFRA_MLME_WAIT                           = 3,
+       STATE_CONN_INFRA_RSN_WAIT                            = 4,
+       STATE_CONN_INFRA_CONFIG_HW                       = 5,
+    STATE_CONN_INFRA_CONNECTED                      = 6,
+       STATE_CONN_INFRA_DISASSOCC                       = 7,
+    CONN_INFRA_NUM_STATES
+} infra_state_e;
+
+TI_STATUS conn_infraConfig(conn_t *pConn);
+
+TI_STATUS conn_infraSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn);
+
+TI_STATUS connInfra_JoinCmpltNotification(TI_HANDLE hconn);
+
+
+#endif /* __CONN_INFRA_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/conn/connSelf.h b/sta_dk_4_0_4_32/common/src/core/sme/conn/connSelf.h
new file mode 100644 (file)
index 0000000..d8c7572
--- /dev/null
@@ -0,0 +1,83 @@
+/** \file connSelf.h
+ *  \brief Self IBSS connection header file
+ *
+ *  \see connSelf.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*       MODULE:       connSelf.h                                                                                                                              */
+/*    PURPOSE: Self IBSS connection header file                                                                                        */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#if 0
+#ifndef __CONN_SELF_H__
+#define __CONN_SELF_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "conn.h"
+
+/* Self IBSS connection states */
+typedef enum
+{
+       CONN_SELF_STATE_IDLE                    = 0,
+       CONN_SELF_STATE_WAIT                = 1,
+       CONN_SELF_STATE_RSN_WAIT                = 2,
+       CONN_SELF_STATE_CONNECTED               = 3,
+    CONN_SELF_NUM_STATES            = 4,
+} smeState_t;
+
+typedef enum 
+{
+       CONN_SELF_START                                 = 0,
+       CONN_SELF_STOP                                  = 1,
+       CONN_SELF_RSN_SUCC                              = 2,
+       CONN_SELF_RSN_FAIL                              = 3,
+       CONN_SELF_STA_JOINED                    = 4,
+       CONN_SELF_TIMEOUT                               = 5,
+    CONN_SELF_NUM_EVENTS            = 6,
+} connSelfEvent_e;
+
+TI_STATUS conn_selfConfig(conn_t *pConn);
+
+TI_STATUS conn_selfSMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hConn);
+
+
+#endif /* __CONN_SELF_H__ */
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/select.c b/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/select.c
new file mode 100644 (file)
index 0000000..0872bfa
--- /dev/null
@@ -0,0 +1,1437 @@
+/** \file reportReplvl.c
+ *  \brief Report level implementation
+ *
+ *  \see reportReplvl.h 
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                                                                     */
+/*             MODULE: reportReplvl.c                                                                                                                          */
+/*    PURPOSE: Report level implementation                                                                                     */
+/*                                                                                                                                                                                                     */
+/***************************************************************************/
+#include "osTIType.h"
+#include "osApi.h"
+#include "siteHash.h"
+#include "smeSmApi.h"
+#include "utils.h"
+#include "smeApi.h"
+#include "rsnApi.h"
+#include "report.h"
+#include "whalCtrl_api.h"
+#include "connApi.h"
+#include "DataCtrl_Api.h"  
+#include "siteMgrApi.h"  
+#include "regulatoryDomainApi.h"
+#include "measurementMgrApi.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#include "TransmitPowerExc.h"
+#include "excRMMngr.h"
+#endif
+
+#include "qosMngr_API.h"
+
+
+/****************************************************************************
+                                                               MATRIC ISSUE                                                    
+       Each function in the select process returns a MATCH, NO_MATCH value in order to         
+       skip non relevant sites. In addition, some of the functions also measures a matching level of a site.
+       The matching level is returned as a bit map. The select function 'OR's those bit maps in order to 
+       select the site that has the biggest matching level. If a function returns a NO_MATCH value, the matching level of the
+       site is reset.
+       Following is the site matching level bit map structure.
+       Please notice, that if all the match functions returned MATCH for a site, its matric must be different than 0, 
+       because of the rates bits.
+       
+
+           31 - 24           23 - 20           20 - 16             15 - 10       9 - 8         7         6           5         4 - 0
+       +---------------+---------------+-----------------------+-------------+------------+----------+---------+-----------+-----------+
+       | Rx Level      | Privacy       | Attempts              |Rates        | Modulation |Preamble  | Channel | Spectrum  | Reserved  |
+       |                       |                       |                               |                     |                    |              |                 | management|                   |   
+       +---------------+---------------+-----------------------+-------------+------------+----------+---------+-----------+-----------+
+****************************************************************************/
+
+/* Matric bit map definition */
+typedef enum 
+{
+       /* Rx level */
+       METRIC_RX_LEVEL_MASK                    = 0xFF,
+       METRIC_RX_LEVEL_SHIFT                   = 24,
+
+       /* Privacy */
+       METRIC_PRIVACY_MASK                             = 0x0F,
+       METRIC_PRIVACY_SHIFT                    = 20,
+
+       /* Number of attempts */
+       METRIC_ATTEMPTS_NUMBER_MASK             = 0x0F,
+       METRIC_ATTEMPTS_NUMBER_SHIFT    = 16,
+       
+       
+       /* Rates */
+       METRIC_RATES_MASK                               = 0x3F,
+       METRIC_RATES_SHIFT                              = 10,
+
+       /* PBCC */
+       METRIC_MODULATION_MASK                  = 0x03,
+       METRIC_MODULATION_SHIFT                 = 8,
+       
+       /* Preamble*/
+       METRIC_PREAMBLE_MASK                    = 0x01,
+       METRIC_PREAMBLE_SHIFT                   = 7,
+
+       /* Channel */
+       METRIC_CHANNEL_MASK                             = 0x01,
+       METRIC_CHANNEL_SHIFT                    = 6,
+
+       /* Spectrum management Capability */
+       METRIC_SPECTRUM_MANAGEMENT_MASK = 0x01,
+       METRIC_SPECTRUM_MANAGEMENT_SHIFT= 5,
+
+       /* Priority Site */
+       METRIC_PRIORITY_SITE_MASK               = 0x01,
+       METRIC_PRIORITY_SITE_SHIFT              = 4,
+
+} matric_e;
+
+#define MAX_GB_MODE_CHANEL             14
+
+/* RSSI values boundaries and metric values for best, good, etc  signals */
+#define SELECT_RSSI_BEST_LEVEL      (-22)
+#define SELECT_RSSI_GOOD_LEVEL      (-38)
+#define SELECT_RSSI_NORMAL_LEVEL    (-56)
+#define SELECT_RSSI_POOR_LEVEL      (-72)
+#define SELECT_RSSI_BAD_LEVEL       (-82)
+
+
+#define  RSSI_METRIC_BEST      6
+#define  RSSI_METRIC_GOOD      5
+#define  RSSI_METRIC_NORMAL    4
+#define  RSSI_METRIC_POOR      3
+#define  RSSI_METRIC_BAD       2
+#define  RSSI_METRIC_NOSIGNAL  1
+
+/* Local functions prototypes */
+
+static match_e ssidMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite);
+
+
+static match_e bssidMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite);
+
+static match_e bssTypeMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite);
+
+static match_e ratesMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static match_e modulationTypeMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static match_e preambleTypeMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static match_e channelMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static match_e spectrumManagementMatchingLevel(siteMgr_t *pSiteMgr, UINT16 siteCapability, UINT32 *matchingLevel);
+
+static match_e rxLevelMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static match_e attemptsNumberMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static match_e prioritySiteMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel);
+
+static siteEntry_t *addSelfSite(siteMgr_t *pSiteMgr);
+
+static TI_STATUS sendProbeResponse(siteMgr_t *pSiteMgr, macAddress_t *pBssid);
+
+/* Interface functions Implementation */
+
+
+/***********************************************************************
+ *                        siteMgr_disSelectSite                                                                        
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM in order to dis select the primary site.
+                       The function set the primary site pointer to NULL and set its type to type regular      
+                                                                                                   
+INPUT:      hSiteMgr   -       site mgr handle.
+
+OUTPUT:                
+
+RETURN:     OK 
+
+************************************************************************/
+TI_STATUS siteMgr_disSelectSite(TI_HANDLE      hSiteMgr)
+{
+       siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+       /* This protection is because in the case that the BSS was LOST the primary site was removed already. */
+       if (pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
+       {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("siteMgr_disSelectSite REMOVE Primary ssid=%s, bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n",
+                   pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.ssidString,
+                   pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[0], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[1], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[2],
+                   pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[3], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[4], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[5] ));
+               
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType = SITE_REGULAR;
+               pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+               pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_selectSite                                                                   
+ ***********************************************************************
+DESCRIPTION: Site selection function. Called by the SME SM in order to select 
+                       the best site for teh station. 
+                       The function go over the site table, and for each site it calls the match functions
+                       If one fo the functions returns NO_MATCH from some reason, it skips the current site
+                       and move to the next one.
+                       The site that has the biggest bit map is chosen.
+                               -       If a site is chosen, the function calls the 'systemConfig()' function in order 
+                                       to configure the station with the chosen site attribute. Than it reports 
+                                       a select status success to the SME SM.
+                               -       If no site is chosen & the desired BSS type is infrastructure, it reports 
+                                       a select status failure to the SME SM.
+                               -       If no site is chosen but the desired BSS type is IBSS, we create a self site by adding an entry
+                                       to the site table, than we configure the system and reports a select status success to the SME SM.
+
+                       NOTE: if the reScanFlag is set, means we received a scan command from the utility while in the
+                                       previous scanning, we report a select status failure to the SME SM because a re scan is needed
+                                       and we don't perform a selection.
+                                       
+                                                                                                   
+INPUT:      hSiteMgr   -       site mgr handle.
+
+OUTPUT:                
+
+RETURN:     OK 
+
+************************************************************************/
+siteEntry_t* siteMgr_selectSiteFromTable(TI_HANDLE     hSiteMgr)
+{
+       UINT32          metric;
+       UINT32          prevMatchingLevel = 0;          
+       UINT8           siteIndex, tableIndex, numberOfSites = 0;
+       siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+       siteEntry_t *pSiteEntry, *pLastMatchSite = NULL;        
+       rsnData_t       rsnData;
+    dot11_RSN_t *pRsnIe;
+    UINT8       rsnIECount=0;
+    UINT8       curRsnData[255];
+    UINT8       length=0;
+       paramInfo_t     param;
+    radioBand_e radioBand;
+       BOOL            bRegulatoryDomainEnabled;
+
+       siteTablesParams_t* currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  
+                                                       ("SITE MATCH , Desired ssid (%s) len= (%d)\n\n", 
+                                                        pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString, 
+                                                        pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len));
+       
+
+    for (tableIndex = 0; tableIndex < NUM_OF_SITE_TABLE ; tableIndex++)
+       {
+               /* If regulatoryDomains is enable, it should be checked if Country IE was detected */
+               param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
+               regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
+               bRegulatoryDomainEnabled = param.content.regulatoryDomainEnabled;
+
+               if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+                       radioBand = RADIO_BAND_2_4_GHZ;
+               else
+                       radioBand = RADIO_BAND_5_0_GHZ;
+
+               /* Check if country code was received */
+               param.paramType                  = REGULATORY_DOMAIN_IS_COUNTRY_FOUND;
+               param.content.eRadioBand = radioBand;
+               regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
+
+               if( ( bRegulatoryDomainEnabled == TRUE) && ( !param.content.bIsCountryFound ) )
+               {
+                       if( radioBand == RADIO_BAND_2_4_GHZ)
+                               WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("There is no valid Country IE for 2.4G band\n"));
+                       else
+                               WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("There is no valid Country IE for 5G band\n"));
+
+                       if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+                       {
+                               /* change site table */
+                               if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+                {
+                    currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+/*                    siteMgr_updateRates(pSiteMgr, TRUE, TRUE);*/
+                }
+                               else
+                {
+                    currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+/*                    siteMgr_updateRates(pSiteMgr, FALSE, TRUE);*/
+                }
+                       }
+                       continue;
+               }
+                               
+               for (siteIndex = 0; siteIndex < currTable->maxNumOfSites; siteIndex++)
+               {
+                       pSiteEntry = &(currTable->siteTable[siteIndex]);
+                       
+                       length = 0;
+                       metric = 0;
+                       pSiteEntry->matchingLevel = 0;
+
+
+                       if(pSiteEntry->siteType == SITE_PRIMARY)
+                       {
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE PRIMARY, ssid (%s len= %d ),  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->ssid.ssidString, pSiteEntry->ssid.len, pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                       }
+
+                       
+                       if (pSiteEntry->siteType != SITE_REGULAR)
+                               continue;
+                       
+                       numberOfSites++;
+                       
+                       pSiteEntry->ssid.ssidString[pSiteEntry->ssid.len] = 0;
+                       if (ssidMatchingLevel(pSiteMgr, pSiteEntry) != MATCH)
+                       {               
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, ssid (%s len= %d ),  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->ssid.ssidString, pSiteEntry->ssid.len, pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+
+                       if (bssidMatchingLevel(pSiteMgr, pSiteEntry) != MATCH)
+                       {
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, bssid,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+
+                       if (bssTypeMatchingLevel(pSiteMgr, pSiteEntry) != MATCH)
+                       {
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, bss Type,  %X-%X-%X-%X-%X-%X\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, bss Type,  siteMgrDesiredBSSType=%d, bssType=%d\n",pSiteMgr->pDesiredParams->siteMgrDesiredBSSType, pSiteEntry->bssType));
+                               continue;
+                       }
+                       
+                       if (ratesMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, rates,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       } 
+                       pSiteEntry->matchingLevel |= metric << METRIC_RATES_SHIFT;
+                       
+                       
+                       /* Get the RSN IE data */
+                       pRsnIe = pSiteEntry->pRsnIe;
+            rsnIECount = 0;
+                       while ((length < pSiteEntry->rsnIeLen) && (rsnIECount < MAX_RSN_IE))
+                       {
+                               curRsnData[0+length] = pRsnIe->hdr.eleId;
+                               curRsnData[1+length] = pRsnIe->hdr.eleLen;
+                               os_memoryCopy(pSiteMgr->hOs, &curRsnData[2+length], (void *)pRsnIe->rsnIeData, pRsnIe->hdr.eleLen); 
+                               length += pRsnIe->hdr.eleLen+2;
+                               pRsnIe += 1;
+                rsnIECount++;
+                       }
+            if (length<pSiteEntry->rsnIeLen) 
+            {
+                WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  
+                                  ("siteMgr_selectSiteFromTable, RSN IE is too long: rsnIeLen=%d, MAX_RSN_IE=%d\n",
+                                    pSiteEntry->rsnIeLen, MAX_RSN_IE));
+                       }
+                       
+                       rsnData.pIe = (pSiteEntry->rsnIeLen==0) ? NULL :curRsnData;
+                       rsnData.ieLen = pSiteEntry->rsnIeLen;
+                       rsnData.privacy = pSiteEntry->privacy;
+                       
+                       if (rsn_evalSite(pSiteMgr->hRsn, &rsnData, pSiteEntry->bssType, pSiteEntry->bssid, &metric) != OK)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, RSN,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       
+                       pSiteEntry->matchingLevel |= metric << METRIC_PRIVACY_SHIFT;
+
+
+
+                       
+#if 0 /* TODO - Define 4x evaluation */        
+                       if (ctrlData_evalSite(pSiteMgr->hCtrlData, &pSiteEntry->fourXParams, &metric) != OK)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, RSN,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_4X_SHIFT;
+#endif 
+                       
+                       if (modulationTypeMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, modulation Type,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_MODULATION_SHIFT;
+                       
+                       if (preambleTypeMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, preamble,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_PREAMBLE_SHIFT;
+                       
+                       if (channelMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, channel,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_CHANNEL_SHIFT;
+                       
+                       if (spectrumManagementMatchingLevel(pSiteMgr,pSiteEntry->capabilities,&metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, spectrum management.\n\n"));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_SPECTRUM_MANAGEMENT_SHIFT;
+                       
+                       if (rxLevelMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, Rx level,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue; 
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_RX_LEVEL_SHIFT;
+                       
+                       if (attemptsNumberMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, Number of attempts,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_ATTEMPTS_NUMBER_SHIFT;
+
+                       if (prioritySiteMatchingLevel(pSiteMgr, pSiteEntry, &metric) != MATCH)
+                       {
+                               pSiteEntry->matchingLevel = 0;
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, priority Site,  %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+                               continue;
+                       }
+                       pSiteEntry->matchingLevel |= metric << METRIC_PRIORITY_SITE_SHIFT;
+                       
+                       if(pSiteEntry->matchingLevel > prevMatchingLevel)
+                       {
+                               prevMatchingLevel = pSiteEntry->matchingLevel;
+                               pLastMatchSite = pSiteEntry;
+                       }
+               }
+               if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+               {
+            /* change site table */
+            if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+            {
+                currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+/*                siteMgr_updateRates(pSiteMgr, TRUE, TRUE);*/
+            }
+            else
+            {
+                currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+ /*               siteMgr_updateRates(pSiteMgr, FALSE, TRUE);*/
+            }
+               }
+               else
+                       break;
+               
+       }
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("                             NUMBER OF SITES:        %d\n\n", numberOfSites));
+       
+       return pLastMatchSite;
+}
+
+TI_STATUS siteMgr_selectSite(TI_HANDLE hSiteMgr)
+{
+       radioBand_e radioBand;
+       paramInfo_t     param;
+       siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+       siteEntry_t* pLastMatchSite = siteMgr_selectSiteFromTable(hSiteMgr);
+
+       if (pLastMatchSite != NULL)
+       {
+               pSiteMgr->pSitesMgmtParams->pPrimarySite = pLastMatchSite;
+               pLastMatchSite->siteType = SITE_PRIMARY;        
+               
+               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SELECT SUCCESS FROM TABLE, bssid: %X-%X-%X-%X-%X-%X\n\n", pLastMatchSite->bssid.addr[0], pLastMatchSite->bssid.addr[1], pLastMatchSite->bssid.addr[2], pLastMatchSite->bssid.addr[3], pLastMatchSite->bssid.addr[4], pLastMatchSite->bssid.addr[5]));                
+               
+
+               /***************** Config Connection *************************/
+               param.paramType = CONN_TYPE_PARAM;      
+               if (pLastMatchSite->bssType == BSS_INDEPENDENT)
+                       param.content.connType = CONNECTION_IBSS;
+               else
+                       param.content.connType = CONNECTION_INFRA;
+               conn_setParam(pSiteMgr->hConn, &param);
+
+               return smeSm_reportSelectStatus(pSiteMgr->hSmeSm, (mgmtStatus_e)SELECT_STATUS_SUCCESS);
+       }
+
+       if ((pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_ANY) || 
+               (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT))   /* Means we can start our own BSS */
+       {
+               
+               if (pSiteMgr->pDesiredParams->siteMgrDesiredChannel >= SITE_MGR_CHANNEL_A_MIN)
+               {
+                       radioBand = RADIO_BAND_5_0_GHZ;
+               } 
+               else {
+                       radioBand = RADIO_BAND_2_4_GHZ;
+               }
+
+        /*
+        update the regulatory domain with the selected band
+        */
+               /* Check if the selected channel is valid according to regDomain */
+               param.paramType = REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES;
+               param.content.channelCapabilityReq.band = radioBand;
+               param.content.channelCapabilityReq.scanOption = ACTIVE_SCANNING;
+               param.content.channelCapabilityReq.channelNum = pSiteMgr->pDesiredParams->siteMgrDesiredChannel;
+               regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
+               if (!param.content.channelCapabilityRet.channelValidity)
+               {
+                       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("IBSS SELECT FAILURE  - No channel !!!\n\n"));
+                       return smeSm_reportSelectStatus(pSiteMgr->hSmeSm, (mgmtStatus_e)SELECT_STATUS_FAILURE);
+               }
+
+               pLastMatchSite = addSelfSite(pSiteMgr);
+               if (pLastMatchSite == NULL)
+               {
+                       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("IBSS SELECT FAILURE  - could not open self site !!!\n\n"));
+                       return smeSm_reportSelectStatus(pSiteMgr->hSmeSm, (mgmtStatus_e)SELECT_STATUS_FAILURE);
+               }
+               
+               pSiteMgr->pSitesMgmtParams->pPrimarySite = pLastMatchSite;
+               pLastMatchSite->siteType = SITE_SELF;
+       
+               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("%%%%%%%%%%%%%%       SELF SELECT SUCCESS, bssid: %X-%X-%X-%X-%X-%X   %%%%%%%%%%%%%%\n\n", pLastMatchSite->bssid.addr[0], pLastMatchSite->bssid.addr[1], pLastMatchSite->bssid.addr[2], pLastMatchSite->bssid.addr[3], pLastMatchSite->bssid.addr[4], pLastMatchSite->bssid.addr[5]));
+
+               /***************** Config Connection *************************/
+
+               param.paramType = CONN_TYPE_PARAM;                                                                                      /* Connection Type*/
+               param.content.connType = CONNECTION_SELF;
+               conn_setParam(pSiteMgr->hConn, &param);
+
+               return smeSm_reportSelectStatus(pSiteMgr->hSmeSm, (mgmtStatus_e)SELECT_STATUS_SUCCESS);
+       }
+       
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SELECT FAILURE \n\n"));
+
+       return smeSm_reportSelectStatus(pSiteMgr->hSmeSm, (mgmtStatus_e)SELECT_STATUS_FAILURE);
+}
+
+
+void siteMgr_setNotReceivedParameter(TI_HANDLE hSiteMgr, ssid_t* ssid , radioBand_e band)
+{
+       UINT8           siteIndex;
+       siteEntry_t *pSiteEntry;
+       siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+       siteTablesParams_t* currTable=NULL;
+
+
+       /*
+        * Set the propiate site table.
+        */
+       switch (band) {
+       case  RADIO_BAND_2_4_GHZ  :
+               currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+               break;
+
+       case RADIO_BAND_5_0_GHZ :
+               currTable = (siteTablesParams_t*)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+               break;
+
+       case RADIO_BAND_DUAL:
+       default:
+               WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("siteMgr_setNotReceivedParameter() invalid band.\n"));
+
+       }
+
+
+       /*
+        *  Increase the scanned sites "Not_Received" counter, this counter is used by the 
+        *  aging logic to clean old sites.
+        */
+       for (siteIndex = 0; siteIndex < currTable->maxNumOfSites; siteIndex++)
+       {
+               pSiteEntry = &(currTable->siteTable[siteIndex]);
+
+               /* Self site & null site are never aged out. */
+               if ((pSiteEntry->siteType == SITE_SELF) || (pSiteEntry->siteType == SITE_NULL) || (pSiteEntry->siteType == SITE_PRIMARY))
+                       continue;
+               
+               /* If scan for any ssid all sites are expected to be found, and all should be marked. */
+               if( utils_isAnySSID(ssid) )
+               {
+                       pSiteEntry->Not_Received++;
+               }
+               /* otherwise, the scan was a unicast scan, and thus only sites that match the desired SSID are marked*/
+               else 
+               {
+            if(os_memoryCompare(pSiteMgr->hOs, (UINT8 *)ssid->ssidString, (UINT8 *)pSiteEntry->ssid.ssidString, pSiteEntry->ssid.len) == 0)
+                       {
+                               pSiteEntry->Not_Received++;
+                       }
+               }   
+       } /* for (... all sites in table ) */
+}
+
+
+
+void siteMgr_resetAttemptsNumberParameter(TI_HANDLE    hSiteMgr)
+{
+       UINT8           siteIndex, tableIndex;
+       siteEntry_t *pSiteEntry;
+       siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+       siteTablesParams_t* currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+       
+       for (tableIndex = 0; tableIndex < NUM_OF_SITE_TABLE ; tableIndex++)
+       {
+               for (siteIndex = 0; siteIndex < currTable->maxNumOfSites; siteIndex++)
+               {
+                       pSiteEntry = &(currTable->siteTable[siteIndex]);
+
+                       /* Self site & null site are never aged out. */
+                       if ((pSiteEntry->siteType == SITE_SELF) || (pSiteEntry->siteType == SITE_NULL))
+                               continue;
+                       
+                       pSiteEntry->attemptsNumber = 0;
+               }
+               if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+               {
+                       /* change site table */
+                       if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+                               currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+                       else
+                               currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+               }
+               else
+                       break;
+
+       }
+}
+
+/* Local functions Implementation */
+
+/************************************************************************************************************/
+/*             Each functions of the following measures the matching level of a site for the specific attribute, 
+               for example: BSSId, SSID, etc...
+               The input is the site manager handle which contains the desired attributes, and a pointer 
+               to the site in the site table.
+               The function returns NO_MATCH if it is not possible to work with this site and MATCH otherwise.
+               Some of the functions, in a case of a MATCH, compute also the site matching level and returns it too.
+               This used later in the function 'siteMgr_selectSite()'.
+       */
+/************************************************************************************************************/
+
+static match_e ssidMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite)
+{
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len == 0)
+       {       /* match any site that is not hidden */
+        if (pSite->ssid.ssidString[0]=='\0') /* hidden ssid */
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Null SSID and hidden ssid \n\n"));
+            return NO_MATCH;
+        }
+        else
+        { 
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Null SSID and not hidden ssid \n\n"));
+            return MATCH;
+        }
+    }
+       if ((pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len == pSite->ssid.len) && 
+            (os_memoryCompare(pSiteMgr->hOs, (UINT8 *)pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString, (UINT8 *)pSite->ssid.ssidString, pSite->ssid.len) == 0))
+               return MATCH;
+
+       else
+               return NO_MATCH;
+}
+
+
+static match_e bssidMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite)
+{
+       /* If BSSID is NULL, return NO_MATCH */
+       if MAC_NULL((&(pSite->bssid)))
+               return NO_MATCH;
+
+       if MAC_BROADCAST((&(pSiteMgr->pDesiredParams->siteMgrDesiredBSSID)))
+               return MATCH;
+
+       if MAC_EQUAL((&(pSite->bssid)), (&(pSiteMgr->pDesiredParams->siteMgrDesiredBSSID)))
+               return MATCH;
+
+       return NO_MATCH;
+}
+
+static match_e bssTypeMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite)
+{
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_ANY)
+               return MATCH;
+
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == pSite->bssType)
+               return MATCH;
+
+       return NO_MATCH;
+}
+
+static match_e ratesMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+    UINT32 MatchedBasicRateMask;
+    UINT32 MatchedSupportedRateMask;
+    UINT32 MatchedMaxBasicRate;
+    UINT32 MatchedMaxActiveRate;
+       UINT32 StaTotalRates;
+       UINT32 SiteTotalRates;
+
+       /* If the basic or active rate are invalid (0), return NO_MATCH. */
+       if ((pSite->maxBasicRate == DRV_RATE_INVALID) || (pSite->maxActiveRate == DRV_RATE_INVALID)) 
+       {
+               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, 1.maxBasic=%d,maxActive=%d \n", pSite->maxBasicRate,pSite->maxActiveRate));
+               return NO_MATCH;
+       }
+       
+       if (DRV_RATE_MAX < pSite->maxBasicRate)
+       {
+               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, 1.maxBasic=%d,maxActive=%d \n", pSite->maxBasicRate,pSite->maxActiveRate));
+               return NO_MATCH;
+       }
+
+       if(pSite->channel <= 14)
+               siteMgr_updateRates(pSiteMgr, FALSE, TRUE);
+       else
+               siteMgr_updateRates(pSiteMgr, TRUE, TRUE);
+
+       StaTotalRates = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask
+                               | pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
+
+       SiteTotalRates = pSite->rateMask.basicRateMask | pSite->rateMask.supportedRateMask;
+    
+       MatchedBasicRateMask = SiteTotalRates 
+                               & pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
+                                                            
+
+    MatchedSupportedRateMask = SiteTotalRates &
+                               pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
+
+    if ((StaTotalRates & pSite->rateMask.basicRateMask) != pSite->rateMask.basicRateMask)
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SITE MATCH FAILURE, Basic or Supported Rates Doesn't Match \n"));
+        return NO_MATCH;
+
+    }
+
+    
+    MatchedMaxBasicRate = getMaxRatefromBitmap(MatchedBasicRateMask);
+    MatchedMaxActiveRate = getMaxRatefromBitmap(MatchedSupportedRateMask);
+
+    MatchedMaxActiveRate = MAX(MatchedMaxBasicRate,MatchedMaxActiveRate);
+
+       *matchingLevel = MatchedMaxActiveRate;
+       return MATCH;
+}
+
+static match_e modulationTypeMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+       /* If the desired modulation is CCK, we set the modulation bits off. */
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_CCK)
+       {
+               *matchingLevel = 0;
+               return MATCH;
+       }
+
+       /* Now, the desired modulation is PBCC */
+       if (pSite->beaconModulation == DRV_MODULATION_PBCC)             /* if the site current modulation is PBCC */
+       {        
+               *matchingLevel = 2;
+               return MATCH;
+       }
+       
+       if (pSite->probeModulation == DRV_MODULATION_PBCC)              /* if the site potential modulation is PBCC */
+       {        
+               *matchingLevel = 1;
+               return MATCH;
+       }
+       else                                                                                            /* the current modulation is CCK */
+       { 
+               *matchingLevel = 0;
+               return MATCH;
+       }
+}
+
+static match_e preambleTypeMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+       /* NOw, the chip preamble is SHORT */
+       /* If the desired preamble is LONG, we set the preamble bits off. */
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType == PREAMBLE_LONG)
+       {
+               *matchingLevel = 0;
+               return MATCH;
+       }
+
+       /* Now, the desired preamble is SHORT */
+       if (pSite->currentPreambleType == PREAMBLE_SHORT)       /* site preamble is SHORT */
+       {        
+               *matchingLevel = 1;
+               return MATCH;
+       }
+       else                                                                            /* site preamble is LONG */
+       { 
+               *matchingLevel = 0;
+               return MATCH;
+       }
+}
+
+static match_e channelMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+       paramInfo_t     tParam;
+       /*      when 802.11d is enabled, 
+       channels that are not valid for Active, will not be mach.*/
+       tParam.content.channel = pSite->channel;
+       tParam.paramType = REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED;
+       regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain, &tParam);
+       if ( !tParam.content.bIsChannelSupprted )
+       {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                       ("channelMatchingLevel: channel =%d isn't valid for Active and will not be matched.\n",
+                       pSite->channel));
+               return NO_MATCH;
+       }
+       
+       /* If the site channel is equal to the desired channel, we set the channel bit on. */
+       if (pSite->channel == pSiteMgr->pDesiredParams->siteMgrDesiredChannel)
+       {
+               *matchingLevel = 1;
+               return MATCH;
+       }
+       else                                                                            
+       { 
+               *matchingLevel = 0;
+               return MATCH;
+       }
+/*     return NO_MATCH; - unreachable*/
+
+}
+
+static match_e rxLevelMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+
+       if(pSite->rssi > SELECT_RSSI_BEST_LEVEL)
+               *matchingLevel = (UINT8)RSSI_METRIC_BEST;
+       else if (pSite->rssi > SELECT_RSSI_GOOD_LEVEL)
+               *matchingLevel = (UINT8)RSSI_METRIC_GOOD;
+       else if(pSite->rssi > SELECT_RSSI_NORMAL_LEVEL)
+               *matchingLevel = (UINT8)RSSI_METRIC_NORMAL;
+       else if (pSite->rssi > SELECT_RSSI_POOR_LEVEL)
+               *matchingLevel = (UINT8)RSSI_METRIC_POOR;
+       else if(pSite->rssi > SELECT_RSSI_BAD_LEVEL)
+               *matchingLevel = (UINT8)RSSI_METRIC_BAD;
+       else 
+               *matchingLevel = (UINT8)RSSI_METRIC_NOSIGNAL;
+
+       return MATCH;
+
+}
+
+static match_e attemptsNumberMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+       if(pSite->attemptsNumber > 0)
+       {
+               return NO_MATCH;
+       }
+       else
+       {
+               *matchingLevel = 0x0F - pSite->attemptsNumber;
+               return MATCH;
+       }
+}
+
+static match_e spectrumManagementMatchingLevel(siteMgr_t *pSiteMgr, UINT16 siteCapability, UINT32 *matchingLevel)
+{
+       paramInfo_t             param;
+       TI_STATUS               status;
+       /* If the site has spectrum management capabilty and the station 
+          spectrumManagementCapabilty is enabled, we set the spectrum management bit on. */
+       param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+       status = regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
+       if(status == OK && param.content.spectrumManagementEnabled)
+       {
+               if (siteCapability & DOT11_SPECTRUM_MANAGEMENT)
+                       *matchingLevel = 1;
+               else                                                                            
+                       *matchingLevel = 0;
+       }
+
+       return MATCH;
+}
+
+static match_e prioritySiteMatchingLevel(siteMgr_t *pSiteMgr, siteEntry_t *pSite, UINT32 *matchingLevel)
+{
+       /* If the site channel is equal to the desired channel, we set the channel bit on. */
+       if (pSite->prioritySite)
+       {
+               *matchingLevel = 1;
+               return MATCH;
+       }
+       else                                                                            
+       { 
+               *matchingLevel = 0;
+               return MATCH;
+       }
+/*     return NO_MATCH; - unreachable */
+}
+
+/***********************************************************************
+ *                        addSelfSite                                                                  
+ ***********************************************************************
+DESCRIPTION: This function is called if the selection fails and desired BSS type is IBSS
+                       That means we creating our own network and wait for other stations to join us.
+                       the best site for teh station. 
+                       Performs the following:
+                               -       If the desired BSSID is broadcast, we generate a random BSSId, otherwise we use the desired one.
+                               -       If the site table is full we remove the most old site
+                               -       We send a probe response with our oiwn desired attributes in order to add the site to the site table
+                                                                                                   
+INPUT:      pSiteMgr   -       site mgr handle.
+
+OUTPUT:                
+
+RETURN:     Pointer to rthe self site entry in the site table
+
+************************************************************************/
+siteEntry_t *addSelfSite(siteMgr_t *pSiteMgr)
+{
+       siteEntry_t                     *pSite;
+       macAddress_t            bssid; 
+
+       
+       if (utils_isJunkSSID(&(pSiteMgr->pDesiredParams->siteMgrDesiredSSID)) == TRUE)
+               return NULL ;
+
+       if MAC_BROADCAST((&(pSiteMgr->pDesiredParams->siteMgrDesiredBSSID)))
+       {
+               os_memoryCopy(pSiteMgr->hOs, (void *)bssid.addr, (void *)pSiteMgr->ibssBssid.addr, sizeof(macAddress_t));
+       }
+       else
+       {
+               os_memoryCopy(pSiteMgr->hOs, (void *)bssid.addr, (void *)pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr, sizeof(macAddress_t));  
+       }
+
+       if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel <= 14)
+       {
+               pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+        pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+       }
+       else
+       {
+               pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+               pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
+       }
+
+    siteMgr_ConfigRate(pSiteMgr);
+
+       /* First make sure that there is a place in the site table, if not, reomve the eldest site. */
+       if (pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->numOfSites == pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->maxNumOfSites)
+               removeEldestSite(pSiteMgr);
+
+       sendProbeResponse(pSiteMgr, &bssid);
+
+       /* Now find the site in the site table. */
+       pSite = findSiteEntry(pSiteMgr, &bssid);
+       if (pSite == NULL)
+       {
+               return NULL;
+       }
+       pSite->beaconModulation = pSite->probeModulation;
+       pSite->barkerPreambleType = PREAMBLE_UNSPECIFIED;
+
+       return pSite;
+       
+}
+
+/***********************************************************************
+ *                        sendProbeResponse                                                                    
+ ***********************************************************************
+DESCRIPTION: This function is called by the function 'addSelfSite()' in order to send a probe response
+                       to the site mgr. This will cause the site manager to add a new entry to the site table, the self site entry.
+
+INPUT:      pSiteMgr   -       site mgr handle.
+                       pBssid          -       Received BSSID
+
+OUTPUT:                
+
+RETURN:     OK
+
+************************************************************************/
+static TI_STATUS sendProbeResponse(siteMgr_t *pSiteMgr, macAddress_t *pBssid)
+{
+       mlmeFrameInfo_t         frame;
+       paramInfo_t                     param;
+       dot11_SSID_t            ssid;      
+       dot11_RATES_t           rates;     
+       dot11_FH_PARAMS_t       FHParamsSet;       
+       dot11_DS_PARAMS_t       DSParamsSet;       
+       dot11_CF_PARAMS_t       CFParamsSet;       
+       dot11_IBSS_PARAMS_t IBSSParamsSet;
+       UINT32                          len = 0, ofdmIndex = 0;
+    radioBand_e         band;
+       dot11_RATES_t           extRates;
+       UINT8                           ratesBuf[MAX_SUPPORTED_RATES];  
+       BOOL                            extRatesInd = FALSE;
+       
+       /* The easiest way to add a site to the site table is to simulate a probe frame. */
+       frame.subType = PROBE_RESPONSE;
+       os_memoryZero(pSiteMgr->hOs, &frame, sizeof(mlmeFrameInfo_t));
+               /* Initialize the frame fields */
+       frame.subType = PROBE_RESPONSE;
+       os_memoryZero(pSiteMgr->hOs, (void *)frame.content.iePacket.timestamp, TIME_STAMP_LEN);
+
+       /* Build  Beacon interval  */
+       frame.content.iePacket.beaconInerval = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
+
+       /* Build  capability field */
+       frame.content.iePacket.capabilities = 0;
+       frame.content.iePacket.capabilities |= (TRUE << CAP_IBSS_SHIFT); /* Bss type must be independent */
+
+       if ((pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType == PREAMBLE_SHORT))
+               frame.content.iePacket.capabilities |= (TRUE << CAP_PREAMBLE_SHIFT);
+
+       /* call RSN to get the privacy desired */
+       param.paramType = RSN_ENCRYPTION_STATUS_PARAM;
+       rsn_getParam(pSiteMgr->hRsn, &param);
+       if (param.content.rsnEncryptionStatus == RSN_CIPHER_NONE)
+       {
+               frame.content.iePacket.capabilities |= (FALSE << CAP_PRIVACY_SHIFT);
+       } else {
+               frame.content.iePacket.capabilities |= (TRUE << CAP_PRIVACY_SHIFT);
+       }
+       
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
+               frame.content.iePacket.capabilities |= (TRUE << CAP_PBCC_SHIFT);
+       
+    if (pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+    {
+        if(pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime == PHY_SLOT_TIME_SHORT)
+            frame.content.iePacket.capabilities |= (TRUE << CAP_SLOT_TIME_SHIFT);
+    }
+       
+       /* Build ssid */
+       os_memoryZero(pSiteMgr->hOs, (void *)ssid.serviceSetId, MAX_SSID_LEN);
+
+       if (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len == 0)
+               ssid.hdr.eleLen = 0;
+       else
+       {
+               os_memoryCopy(pSiteMgr->hOs, (void *)ssid.serviceSetId, (void *)pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString, pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len);
+               ssid.hdr.eleLen = pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len;
+       }
+       
+       if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel <= MAX_GB_MODE_CHANEL)
+               siteMgr_updateRates(pSiteMgr, FALSE, TRUE);
+       else
+               siteMgr_updateRates(pSiteMgr, TRUE, TRUE);
+
+       /* Build Rates */
+       bitMapToNetworkStringRates(pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask,
+                                                          pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask,
+                                                          ratesBuf, &len, &ofdmIndex);
+
+       if(pSiteMgr->siteMgrOperationalMode != DOT11_G_MODE ||
+       pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
+          ofdmIndex == len)
+       {
+               rates.hdr.eleId = DOT11_SUPPORTED_RATES_ELE_ID;
+               rates.hdr.eleLen = len;
+               os_memoryCopy(pSiteMgr->hOs, (void *)rates.rates, ratesBuf, rates.hdr.eleLen);
+       }
+       else
+       {
+               rates.hdr.eleId = DOT11_SUPPORTED_RATES_ELE_ID;
+               rates.hdr.eleLen = ofdmIndex;
+               os_memoryCopy(pSiteMgr->hOs, (void *)rates.rates, ratesBuf, rates.hdr.eleLen);
+
+               extRates.hdr.eleId = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
+               extRates.hdr.eleLen = len - ofdmIndex;
+               os_memoryCopy(pSiteMgr->hOs, (void *)extRates.rates, &ratesBuf[ofdmIndex], extRates.hdr.eleLen);
+               extRatesInd = TRUE;
+       }
+
+
+       /* Build FH */
+       os_memoryZero(pSiteMgr->hOs, &FHParamsSet, sizeof(dot11_FH_PARAMS_t));
+
+       /* Build DS */
+       DSParamsSet.hdr.eleLen = 1;
+       DSParamsSet.currChannel = pSiteMgr->pDesiredParams->siteMgrDesiredChannel;
+
+       /* Build CF */
+       os_memoryZero(pSiteMgr->hOs, &CFParamsSet, sizeof(dot11_CF_PARAMS_t));
+
+       /* Build IBSS */
+       os_memoryZero(pSiteMgr->hOs, &IBSSParamsSet, sizeof(dot11_IBSS_PARAMS_t));
+       IBSSParamsSet.hdr.eleLen = 2;
+       IBSSParamsSet.atimWindow = pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow;
+
+       frame.content.iePacket.pSsid = &ssid;
+       frame.content.iePacket.pRates = &rates;
+
+       if(extRatesInd)
+               frame.content.iePacket.pExtRates = &extRates;
+       else
+               frame.content.iePacket.pExtRates = NULL;
+
+       frame.content.iePacket.pFHParamsSet = &FHParamsSet;
+       frame.content.iePacket.pDSParamsSet = &DSParamsSet;
+       frame.content.iePacket.pCFParamsSet = &CFParamsSet;
+       frame.content.iePacket.pIBSSParamsSet = &IBSSParamsSet;
+
+    band = ( MAX_GB_MODE_CHANEL >= pSiteMgr->pDesiredParams->siteMgrDesiredChannel ? RADIO_BAND_2_4_GHZ : RADIO_BAND_5_0_GHZ );
+       /* Update site */
+       siteMgr_updateSite(pSiteMgr, pBssid, &frame ,pSiteMgr->pDesiredParams->siteMgrDesiredChannel, band, FALSE);
+       
+       return OK;
+}
+
+/***********************************************************************
+ *                        systemConfig                                                                 
+ ***********************************************************************
+DESCRIPTION: This function is called by the function 'siteMgr_selectSite()' in order to configure
+                       the system with the chosen site attribute.
+
+INPUT:      pSiteMgr   -       site mgr handle.
+
+OUTPUT:                
+
+RETURN:     OK
+
+************************************************************************/
+TI_STATUS systemConfig(siteMgr_t *pSiteMgr)
+{ 
+       paramInfo_t param;
+       siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+       rsnData_t       rsnData;
+       UINT8           rsnAssocIeLen;
+    dot11_RSN_t *pRsnIe;
+    UINT8       rsnIECount=0;
+    UINT8       curRsnData[255];
+    UINT16      length;
+    UINT16      capabilities;
+    UINT16      PktLength=0;
+    UINT8              *pIeBuffer=NULL;
+
+#ifdef EXC_MODULE_INCLUDED
+    UINT8        ExternTxPower;
+#endif
+       TI_STATUS       status;
+       slotTime_e      slotTime;
+       UINT32          StaTotalRates;
+       ACParameters_t *p_ACParametersDummy = NULL;
+
+
+       if (pPrimarySite->probeRecv)
+       {
+               pIeBuffer = pPrimarySite->probeRespBuffer;
+               PktLength = pPrimarySite->probeRespLength;
+       }
+    else if (pPrimarySite->beaconRecv)
+       {
+               pIeBuffer = pPrimarySite->beaconBuffer;
+               PktLength = pPrimarySite->beaconLength;
+       }
+               
+       pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
+       
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+               ("%s: Capabilities, Slot Time Bit = %d (capabilities = %d)\n", __FUNCTION__, (pPrimarySite->capabilities >> CAP_SLOT_TIME_SHIFT) & 1, pPrimarySite->capabilities));
+       
+       if(pPrimarySite->channel <= MAX_GB_MODE_CHANEL)
+       {
+               if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_B_MODE)
+               {
+                       pSiteMgr->siteMgrOperationalMode = DOT11_B_MODE;
+                       slotTime = PHY_SLOT_TIME_LONG;
+
+                       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                               ("%s: 11b Mode, Slot Time = %d\n", __FUNCTION__, (UINT8)slotTime));
+               }
+               else
+               {
+                       pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+
+                       if (((pPrimarySite->capabilities >> CAP_SLOT_TIME_SHIFT) & CAP_SLOT_TIME_MASK) == PHY_SLOT_TIME_SHORT)
+                       {
+                       slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                       ("%s: 11g Mode, Slot Time = %d (desired)\n", __FUNCTION__, (UINT8)slotTime));
+                       }
+                       else
+                       {
+                               slotTime = PHY_SLOT_TIME_LONG;
+
+                               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                       ("%s: 11g Mode, Slot Time = %d\n", __FUNCTION__, (UINT8) slotTime));
+                       }
+               }
+
+               pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+               pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+       }
+       else
+       {
+               pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
+               pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
+               slotTime = PHY_SLOT_TIME_SHORT;
+
+               WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                       ("%s: 11a Mode, Slot Time = %d\n", __FUNCTION__, (UINT8)slotTime));
+
+               pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+       }
+
+       /* since we are moving to the different band, the siteMgr should be reconfigured */
+       if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
+               siteMgr_bandParamsConfig(pSiteMgr, TRUE);
+
+       if(pPrimarySite->channel <= MAX_GB_MODE_CHANEL)
+               siteMgr_updateRates(pSiteMgr, FALSE, TRUE);
+       else
+               siteMgr_updateRates(pSiteMgr, TRUE, TRUE);
+
+       /* configure hal with common core-hal parameters */
+       whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, pSiteMgr->radioBand);
+
+       pPrimarySite->currentSlotTime = slotTime;
+       whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, slotTime);
+
+       /***************** Config HAL *************************/
+       /* Current Beacon Interval */
+       whalCtrl_SetBeaconInterval( pSiteMgr->hHalCtrl , pPrimarySite->beaconInterval);
+
+       /***************** Config Site Manager *************************/
+       /* L.M. Should be fixed, should take into account the AP's rates */ 
+       if(pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_CCK)
+               pSiteMgr->chosenModulation = DRV_MODULATION_CCK;
+       else if(pSiteMgr->pDesiredParams->siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
+       {
+               if(pPrimarySite->probeModulation != DRV_MODULATION_NONE)
+                       pSiteMgr->chosenModulation = pPrimarySite->probeModulation;
+               else
+                       pSiteMgr->chosenModulation = pPrimarySite->beaconModulation;
+       }
+       else
+               pSiteMgr->chosenModulation = DRV_MODULATION_OFDM;
+       
+       /* We use this variable in order tp perform the PBCC algorithm. */
+       pSiteMgr->currentDataModulation = pSiteMgr->chosenModulation;
+       /***************** Config Data CTRL *************************/
+       
+       param.paramType = CTRL_DATA_CURRENT_BSSID_PARAM;                                                        /* Current BSSID */
+       os_memoryCopy(pSiteMgr->hOs, &(param.content.ctrlDataCurrentBSSID), &(pPrimarySite->bssid), sizeof(macAddress_t));
+       ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+       param.paramType = CTRL_DATA_CURRENT_BSS_TYPE_PARAM;                                                     /* Current BSS Type */
+       param.content.ctrlDataCurrentBssType = pPrimarySite->bssType;
+       ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+       param.paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;                                        /* Current Preamble Type */
+       if ((pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType == PREAMBLE_SHORT) &&
+               (pPrimarySite->currentPreambleType == PREAMBLE_SHORT))
+               param.content.ctrlDataCurrentPreambleType = PREAMBLE_SHORT;
+       else
+               param.content.ctrlDataCurrentPreambleType = PREAMBLE_LONG;
+       ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+    /* Mutual Rates Matching */
+       StaTotalRates = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask |
+                                       pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
+
+
+    pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = StaTotalRates & 
+                                                                                                                  pPrimarySite->rateMask.supportedRateMask;
+       
+       pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = StaTotalRates &
+                                                                                                                       pPrimarySite->rateMask.basicRateMask;
+       if (pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask == 0)
+       {
+               pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = 
+                       pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
+       }
+
+    pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask);
+
+    pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask);
+
+    pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate = MAX(pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate,pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate);
+
+       param.paramType = CTRL_DATA_CURRENT_BASIC_RATE_PARAM;                                           /* Current Basic Rate */
+       param.content.ctrlDataCurrentBasicRate = (rate_e)pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate;
+       ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+       param.paramType = CTRL_DATA_CURRENT_BASIC_RATE_MASK_PARAM;
+       param.content.ctrlDataBasicRateBitMask = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
+       ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+       param.paramType = CTRL_DATA_CURRENT_BASIC_MODULATION_PARAM;                                             /* Current Mgmt Rate */
+       if ((pPrimarySite->maxBasicRate == DRV_RATE_1M) || (pPrimarySite->maxBasicRate == DRV_RATE_2M))
+               param.content.ctrlDataCurrentBasicModulationType = DRV_MODULATION_QPSK;
+       else if (pPrimarySite->maxBasicRate == DRV_RATE_22M)
+               param.content.ctrlDataCurrentBasicModulationType = DRV_MODULATION_PBCC;
+       else if (pPrimarySite->maxBasicRate < DRV_RATE_22M)
+               param.content.ctrlDataCurrentBasicModulationType = DRV_MODULATION_CCK;
+       else
+               param.content.ctrlDataCurrentBasicModulationType = DRV_MODULATION_OFDM;
+
+       ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+    param.paramType = CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM;
+    param.content.ctrlDataProtectionEnabled = pPrimarySite->useProtection;
+    ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+       ctrlData_setSite(pSiteMgr->hCtrlData, &pPrimarySite->fourXParams);
+
+       pbccAlgorithm(pSiteMgr);
+
+       /********** Set Site QOS protocol support *************/
+
+       /* Set WME Params */
+        status = siteMgr_getWMEParamsSite(pSiteMgr,&p_ACParametersDummy);
+        if(status == OK)
+        {
+                param.content.qosSiteProtocol = WME;
+        }
+        else
+        {
+                        param.content.qosSiteProtocol = NONE_QOS;
+        }
+
+       WLAN_REPORT_DEBUG_TX(pSiteMgr->hReport,
+        (" systemConfigt() : param.content.qosSiteProtoco %d\n", param.content.qosSiteProtocol));
+
+        param.paramType = QOS_MNGR_SET_SITE_PROTOCOL;
+        qosMngr_setParams(pSiteMgr->hQosMngr,&param);
+        
+     /* Set active protocol in qosMngr according to station desired mode and site capabilities 
+       Must be called BEFORE setting the "CURRENT_PS_MODE" into the QosMngr */
+     qosMngr_selectActiveProtocol(pSiteMgr->hQosMngr);
+
+        /* set PS capability parameter */
+        param.paramType = QOS_MNGR_CURRENT_PS_MODE;
+        if(pPrimarySite->APSDSupport == TRUE)
+                param.content.currentPsMode = PS_SCHEME_UPSD_TRIGGER;
+        else
+                param.content.currentPsMode = PS_SCHEME_LEGACY_PSPOLL;
+      qosMngr_setParams(pSiteMgr->hQosMngr,&param);
+
+     /* Set upsd/ps_poll configuration */
+     /* Must be done AFTER setting the active Protocol */
+     qosMngr_setAcPsDeliveryMode (pSiteMgr->hQosMngr);
+       
+       /***************** Config RSN *************************/
+    /* Get the RSN IE data */
+    pRsnIe = pPrimarySite->pRsnIe;
+       length=0;
+    rsnIECount = 0;
+    while ((length < pPrimarySite->rsnIeLen) && (pPrimarySite->rsnIeLen < 255) 
+           && (rsnIECount < MAX_RSN_IE))
+    {
+        curRsnData[0+length] = pRsnIe->hdr.eleId;
+        curRsnData[1+length] = pRsnIe->hdr.eleLen;
+        os_memoryCopy(pSiteMgr->hOs, &curRsnData[2+length], (void *)pRsnIe->rsnIeData, pRsnIe->hdr.eleLen); 
+        length += pRsnIe->hdr.eleLen+2;
+        pRsnIe += 1;
+        rsnIECount++;
+    }
+    if (length<pPrimarySite->rsnIeLen) 
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  
+                          ("siteMgr_selectSiteFromTable, RSN IE is too long: rsnIeLen=%d, MAX_RSN_IE=%d\n",
+                            pPrimarySite->rsnIeLen, MAX_RSN_IE));
+    }
+
+       rsnData.pIe = (pPrimarySite->rsnIeLen==0) ? NULL :curRsnData;
+       rsnData.ieLen = pPrimarySite->rsnIeLen;
+    rsnData.privacy = pPrimarySite->privacy; 
+    
+    rsn_setSite(pSiteMgr->hRsn, &rsnData, NULL, &rsnAssocIeLen);
+
+       /***************** Config RegulatoryDomain **************************/
+       
+#ifdef EXC_MODULE_INCLUDED
+       /* set EXC TPC if present */
+       if(Exc_ParseClientTP(pSiteMgr->hOs,pPrimarySite,&ExternTxPower,pIeBuffer,PktLength) == OK)
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                       ("Select Exc_ParseClientTP == OK: Dbm = %d\n",ExternTxPower));
+               param.paramType = REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED;
+               param.content.ExternTxPowerPreferred = ExternTxPower;
+               regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
+    }
+       /* Parse and save the EXC Version Number if exists */
+       excMngr_parseExcVer(pSiteMgr->hExcMngr, pIeBuffer, PktLength);
+
+#endif
+
+       /* Note: TX Power Control adjustment is now done through siteMgr_assocReport() */
+       if (pPrimarySite->powerConstraint>0)
+       {       /* setting power constraint */
+               param.paramType = REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM;
+               param.content.powerConstraint = pPrimarySite->powerConstraint;
+               regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
+       }
+
+
+       /***************** Config MeasurementMgr object **************************/
+    capabilities = pPrimarySite->capabilities;
+
+    /* Updating the Measurement Module Mode */
+    measurementMgr_setMeasurementMode(pSiteMgr->hMeasurementMgr, capabilities, 
+                                                                       pIeBuffer, PktLength);
+
+    
+       return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteHash.c b/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteHash.c
new file mode 100644 (file)
index 0000000..e1ded3f
--- /dev/null
@@ -0,0 +1,419 @@
+/** \file siteHash.c
+ *  \brief Site Hash implementation
+ *
+ *  \see siteHash.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                                                                                                     */
+/*             MODULE: siteHash.c                                                                                                      */
+/*    PURPOSE: Site Hash implementation                                                                        */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "siteMgrApi.h"
+#include "siteHash.h"
+#include "smeApi.h"
+#include "utils.h"
+
+
+/****************************************************************************************************************
+       
+       This file implements the site hash mechanism. This mechanism is used for faster access to the sites information.
+       It is compound of the following:
+               1.      hash function   -       which maps the 4 last bits of the BSSID to an entry in the hash table.
+               2.      hash table              -       each entry in the table points to a linked list of site entries
+               3.      site table              -       each entry holds a site information
+                                                                                                                       
+       In order to find a site in the site table, we operate the hash function on the site's BSSID.
+       We receive a hash entry. We go over the linked list pointed by this hash entry until we find the site entry.
+*****************************************************************************************************************/
+
+#define WLAN_NUM_OF_MISSED_SACNS_BEFORE_AGING 2
+
+
+/********************************************/
+/*             Functions Implementations                       */
+/********************************************/
+/************************************************************************
+ *                        siteMgr_resetSiteTable                                               *
+ ************************************************************************
+DESCRIPTION: reset the following things: 
+                               -       Mgmt parameters structure
+                               -       Site table
+                               -       Hash table
+                               -       Primary site pointer
+                               -       Number of sites
+                                                                                                   
+INPUT:      hSiteMgr                           -       Handle to site mgr      
+
+
+OUTPUT:                
+
+RETURN:     OK
+
+************************************************************************/
+TI_STATUS siteMgr_resetSiteTable(TI_HANDLE     hSiteMgr, siteTablesParams_t    *pSiteTableParams)
+{
+       int i;
+       siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+       os_memoryZero(pSiteMgr->hOs, &pSiteTableParams->siteTable[0], sizeof(siteEntry_t)*pSiteTableParams->maxNumOfSites); 
+
+       for (i = 0; i < pSiteTableParams->maxNumOfSites; i++)
+       {
+               pSiteTableParams->siteTable[i].index = i;
+               pSiteTableParams->siteTable[i].siteType = SITE_NULL;
+        pSiteTableParams->siteTable[i].beaconRecv = FALSE;
+        pSiteTableParams->siteTable[i].beaconReceiveAfterJoin = TRUE;
+                pSiteTableParams->siteTable[i].dtimPeriod = 1;
+       }
+
+       pSiteTableParams->numOfSites = 0;
+
+       pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
+
+       return OK;
+}
+
+/************************************************************************
+ *                       siteMgr_removeNotReceivedSites                                        *
+ ************************************************************************
+DESCRIPTION: 
+                                                                                                   
+INPUT:      
+
+OUTPUT:                
+
+RETURN:     OK
+
+************************************************************************/
+
+TI_STATUS siteMgr_removeNotReceivedSites(TI_HANDLE     hSiteMgr)
+{
+       UINT8           siteIndex, tableIndex;
+       siteEntry_t *pSiteEntry;
+       siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+       siteTablesParams_t* currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+       
+       for (tableIndex = 0; tableIndex < NUM_OF_SITE_TABLE ; tableIndex++)
+       {
+               for (siteIndex = 0; siteIndex < currTable->maxNumOfSites; siteIndex++)
+               {
+                       pSiteEntry = &(currTable->siteTable[siteIndex]);
+                       
+                       /* Self site & null site are never aged out. */
+                       if ((pSiteEntry->siteType == SITE_SELF) || (pSiteEntry->siteType == SITE_NULL))
+                               continue;
+                       
+                       if(pSiteEntry->Not_Received > WLAN_NUM_OF_MISSED_SACNS_BEFORE_AGING)
+                               removeSiteEntry(pSiteMgr, currTable, pSiteEntry);
+               }
+
+               /* change the current site table */
+               if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+                       currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+               else
+                       currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+
+       }
+       return OK;
+}
+
+/************************************************************************
+ *                        findSiteEntry                                                                        *
+ ************************************************************************
+DESCRIPTION: Perform the following things: 
+                       -       Compute the site's hash entry based on the site BSSID and hash function
+                       -       Look fotr the site entry in the linked list pointed by the hash entry
+                       -       If the site is found in the site table, returns a pointer to the site entry
+                       -       If the site is not found, return NULL.
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site mgr      
+                       mac                     -       The site BSSID          
+
+
+OUTPUT:                
+
+RETURN:     Pointer to the site entry if site found, NULL otherwise
+
+************************************************************************/
+siteEntry_t    *findSiteEntry(siteMgr_t                *pSiteMgr, 
+                                          macAddress_t         *mac)
+{
+    siteTablesParams_t      *pCurrentSiteTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+       siteEntry_t             *pSiteEntry;    
+    UINT8                   tableIndex=2, i;
+
+
+    do
+       {
+        tableIndex--;
+               for (i = 0; i < pCurrentSiteTable->maxNumOfSites; i++)
+               {
+                       pSiteEntry = &(pCurrentSiteTable->siteTable[i]);
+        
+               if MAC_EQUAL((&(pSiteEntry->bssid)), mac)
+               {
+                       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("FIND success, bssid: %X-%X-%X-%X-%X-%X\n\n", mac->addr[0], mac->addr[1], mac->addr[2], mac->addr[3], mac->addr[4], mac->addr[5]));
+                       return pSiteEntry;
+               }
+
+           }
+          if ((pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE) && (tableIndex==1))
+          {   /* change site table */
+              if (pCurrentSiteTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+              {
+                  pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+              }
+              else
+              {
+                  pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+              }
+          }
+
+    } while (tableIndex>0);
+
+
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  
+                            ("FIND failure, bssid: %X-%X-%X-%X-%X-%X\n\n", mac->addr[0], mac->addr[1], mac->addr[2], mac->addr[3], mac->addr[4], mac->addr[5]));
+
+
+       return NULL;
+}
+
+/************************************************************************
+ *                        findAndInsertSiteEntry                                                                       *
+ ************************************************************************
+DESCRIPTION: Perform the following things: 
+                       -       Compute the site's hash entry based on the site BSSID and hash function
+                       -       Look for the site entry in the linked list pointed by the hash entry
+                       -       If the site is found in the site table, returns a pointer to the site entry
+                       -       If the site is not found in the site table, tries to add the site 
+                               -       If succeeds, returns a pointer to the site entry
+                               -       Otherwise, returns NULL
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site mgr      
+                       mac                     -       The site BSSID          
+            band        -   The site band
+
+
+OUTPUT:                
+
+RETURN:     Pointer to the site entry if site found/inserted, NULL otherwise
+
+************************************************************************/
+siteEntry_t    *findAndInsertSiteEntry(siteMgr_t               *pSiteMgr, 
+                                                                       macAddress_t    *mac,
+                                    radioBand_e     band)
+{
+       UINT8               i, emptySiteIndex=0, nextSite2Remove=0;
+       siteEntry_t         *pSiteEntry, *pPrimarySite=pSiteMgr->pSitesMgmtParams->pPrimarySite;
+       sitesMgmtParams_t   *pSitesMgmtParams  = pSiteMgr->pSitesMgmtParams;
+       siteTablesParams_t  *pCurrentSiteTable;
+    BOOL                firstEmptySiteFound = FALSE;
+    UINT32              oldestTS;
+
+
+    /* choose site table according to AP's band */
+    if ( RADIO_BAND_2_4_GHZ == band )
+    {
+        pCurrentSiteTable = &(pSitesMgmtParams->dot11BG_sitesTables);
+    }
+    else if (RADIO_BAND_5_0_GHZ == band)
+    {
+        pCurrentSiteTable = (siteTablesParams_t*) &(pSitesMgmtParams->dot11A_sitesTables);
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("Bad band: %d\n\n", band));
+        pCurrentSiteTable = &(pSitesMgmtParams->dot11BG_sitesTables);
+    }
+        
+    /* Set the first TS to a site which is not the Primary site */
+    if (pPrimarySite != &(pCurrentSiteTable->siteTable[0]))
+       {
+        oldestTS = pCurrentSiteTable->siteTable[0].localTimeStamp;
+    }
+    else
+               {
+        oldestTS = pCurrentSiteTable->siteTable[1].localTimeStamp;
+               }
+
+    /* Loop all the sites till the desired MAC is found */
+    for (i = 0; i < pCurrentSiteTable->maxNumOfSites; i++)
+    {
+        pSiteEntry = &(pCurrentSiteTable->siteTable[i]);
+               
+        if MAC_EQUAL((&(pSiteEntry->bssid)), mac)
+               {
+
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("FIND success, bssid: %X-%X-%X-%X-%X-%X\n\n", mac->addr[0], mac->addr[1], mac->addr[2], mac->addr[3], mac->addr[4], mac->addr[5]));
+
+            return pSiteEntry;
+        }
+        else if (pSiteEntry->siteType == SITE_NULL)
+        {   /* Save the first empty site, in case the
+            desired MAC is not found */
+            if (!firstEmptySiteFound)
+       {
+                emptySiteIndex = i;
+                firstEmptySiteFound=TRUE;
+            }
+               
+        }
+        if ((oldestTS > pSiteEntry->localTimeStamp) && 
+            (pSiteEntry != pPrimarySite))
+        {   /* Save the oldest site's index, according to TS */
+            oldestTS = pSiteEntry->localTimeStamp;
+            nextSite2Remove = i;
+        }
+       }
+
+
+    if ((!firstEmptySiteFound) || (pCurrentSiteTable->numOfSites>=pCurrentSiteTable->maxNumOfSites))
+       {
+               /* No NULL entry has been found. Remove the oldest site */
+        pSiteEntry =  &(pCurrentSiteTable->siteTable[nextSite2Remove]);
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,
+                                ("INSERT failure, no free entry!, numOfSites=%d, removing site index=%d,\n \
+                                 bssid: %X-%X-%X-%X-%X-%X, ts=%d \n",
+                                 pCurrentSiteTable->numOfSites, nextSite2Remove,
+                                 pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], 
+                                 pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5],
+                                 pSiteEntry->localTimeStamp));
+        removeSiteEntry(pSiteMgr, pCurrentSiteTable, pSiteEntry);
+        emptySiteIndex = nextSite2Remove;
+
+       }
+
+
+       pCurrentSiteTable->numOfSites++; 
+
+       pSiteEntry = &(pCurrentSiteTable->siteTable[emptySiteIndex]);
+
+       /* fill the entry with the station mac */
+       MAC_COPY(pSiteMgr->hOs, (&(pSiteEntry->bssid)), mac);
+
+    /* Some parameters have to be initialized immediately after entry allocation */
+       /* We set fourXsupported for each site to TRUE,
+          It will be set to FALSE only if ProbeResponse without 4x IE
+          will be received for any specific site.
+          It is done in this way to ensure that even if the STA didn't receive
+          ProbeResponse from TI AP (received only Beacons), the AssociationReq
+          sent by the STA will include 4x IE */
+       pSiteEntry->fourXsupported = TRUE;
+
+    if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+        pSiteEntry->currentSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,
+                            ("INSERT success, bssid: %X-%X-%X-%X-%X-%X, band=%d, index=%d\n\n",
+                             mac->addr[0], mac->addr[1], mac->addr[2], mac->addr[3], mac->addr[4], mac->addr[5],
+                             band, emptySiteIndex));
+
+
+       return pSiteEntry;
+}
+
+/************************************************************************
+ *                        removeSiteEntry                                                              *
+ ************************************************************************
+DESCRIPTION: Removes the site entry from the site table
+                                                                                                   
+INPUT:      pSiteMgr              - Handle to site mgr
+            pCurrSiteTblParams - Pointer to current site table parameters   
+            hashPtr                       - Pointer to the site entry      
+
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+void removeSiteEntry(siteMgr_t  *pSiteMgr, 
+                     siteTablesParams_t  *pCurrSiteTblParams,
+                     siteEntry_t         *pSiteEntry)
+{
+       UINT8                   index; 
+
+       if (pSiteEntry == NULL)
+       {
+               WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("REMOVAL failure, site is NULL\n\n"));
+               return;
+       }
+
+       if (pCurrSiteTblParams->numOfSites == 0)
+       {
+               WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("REMOVAL failure, site table is empty\n\n"));
+               return;
+       }
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("removeSiteEntry REMOVE ssid=%s, bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n",
+                          pSiteEntry->ssid.ssidString,
+                          pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2],
+                          pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5] ));
+
+       pCurrSiteTblParams->numOfSites--;
+               
+       /* Now remove (exclude) hashPtr entry from the linked list */
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("REMOVAL success, bssid: %X-%X-%X-%X-%X-%X\n\n", pSiteEntry->bssid.addr[0], pSiteEntry->bssid.addr[1], pSiteEntry->bssid.addr[2], pSiteEntry->bssid.addr[3], pSiteEntry->bssid.addr[4], pSiteEntry->bssid.addr[5]));
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, (" SITE TABLE remaining entries number  %d \n", pCurrSiteTblParams->numOfSites));
+       
+       /* Clean the rest of the entry structure */
+       index = pSiteEntry->index;     /* keep the index of the siteTable entry */
+       os_memoryZero(pSiteMgr->hOs, pSiteEntry, sizeof(siteEntry_t));
+
+    /* This is not required!!!! - Remove!!*/
+       pSiteEntry->dtimPeriod = 1;
+       pSiteEntry->siteType = SITE_NULL;
+       pSiteEntry->index = index;   /* restore the index of the siteTable */
+
+       /* if removing previous primary site - update the link */
+       if (pSiteEntry == pSiteMgr->pSitesMgmtParams->pPrevPrimarySite)
+       {
+               pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = NULL;
+       }
+
+       return;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteHash.h b/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteHash.h
new file mode 100644 (file)
index 0000000..3187b58
--- /dev/null
@@ -0,0 +1,267 @@
+/** \file siteHash.h
+ *  \brief Hash & site table internal header file
+ *
+ *  \see siteHash.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   siteHash.h                                                  */
+/*    PURPOSE:  Hash & site table internal header file                      */
+/*                                                                          */
+/***************************************************************************/
+#ifndef __SITE_MGR_H__
+#define __SITE_MGR_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "802_11Defs.h"
+#include "DataCtrl_Api.h"
+#include "whalCtrl_api.h"
+
+#define MAX_RSN_IE          3
+
+/* site types */
+typedef enum
+{
+    SITE_PRIMARY        = 0,
+    SITE_SELF           = 1,
+    SITE_REGULAR        = 2,
+    SITE_NULL           = 3,
+} siteType_e;
+
+typedef struct
+{
+    UINT8   hopPattern;
+    UINT8   hopSet;
+    UINT16  dwellTime;
+} FHParams_t;
+
+/* A site entry contains all the site attribute received in beacon and probes
+    and data used to manage the site table and hash table */
+typedef struct siteEntry_t siteEntry_t;
+struct siteEntry_t
+{
+    /* The following fields, in addition with the BSSID is used for entry management */
+    UINT8                   index;
+    siteType_e              siteType;
+    UINT32                  localTimeStamp;
+    UINT32                  dtimTimeStamp;
+    UINT8                   tsfTimeStamp[TIME_STAMP_LEN];
+    UINT32                  osTimeStamp;
+
+
+
+    /* The following fields are used for the selection */
+    BOOL                    probeRecv;
+    BOOL                    beaconRecv;
+    BOOL                    beaconReceiveAfterJoin;
+    macAddress_t            bssid;
+    ssid_t                  ssid;
+    bssType_e               bssType;
+    rateMask_t              rateMask;
+    rate_e                  maxBasicRate;
+    rate_e                  maxActiveRate;
+    modulationType_e        beaconModulation;
+    modulationType_e        probeModulation;
+    preamble_e              currentPreambleType;
+    preamble_e              preambleAssRspCap;
+    preamble_e              barkerPreambleType;
+    slotTime_e              currentSlotTime;
+    slotTime_e              newSlotTime;
+    BOOL                    useProtection;
+    BOOL                    NonErpPresent;
+    UINT8                   channel;
+    UINT8                   attemptsNumber;
+    UINT8                   Not_Received;
+    UINT32                  matchingLevel;
+
+    BOOL                    privacy;
+    BOOL                    agility;
+    UINT16                  capabilities;
+    UINT16                  beaconInterval;
+    UINT8                   dtimPeriod;
+    UINT8                   snr;
+    rate_e                  rxRate;
+    INT32                   rssi;
+    dot11_4X_t              fourXParams;
+    BOOL                    fourXsupported;
+
+    /* Power Constraint */
+    UINT8                   powerConstraint;
+
+    /* AP Tx Power obtained from TPC Report */
+    UINT8                   APTxPower;
+
+    /* QOS */
+    BOOL                    WMESupported;
+    ACParameters_t          WMEParameters;
+    UINT8                   lastWMEParameterCnt;
+
+    /* UPSD */
+    BOOL                    APSDSupport;
+
+    /* The following fields are never updated */
+    UINT16                  atimWindow;
+    FHParams_t              FHParams;
+    dot11_RSN_t             pRsnIe[MAX_RSN_IE];
+    UINT8                   rsnIeLen;
+
+    mgmtStatus_e            failStatus;
+    BOOL                    prioritySite;
+    UINT8                   probeRespBuffer[MAX_BEACON_BODY_LENGTH];
+    UINT16                  probeRespLength;
+    UINT8                   beaconBuffer[MAX_BEACON_BODY_LENGTH];
+    UINT16                  beaconLength;
+
+    BOOL                    detectedWhileMeasuring;
+};
+
+typedef struct
+{
+    UINT8           numOfSites;
+    UINT8           maxNumOfSites;
+    siteEntry_t     siteTable[MAX_SITES_BG_BAND];
+}siteTablesParams_t;
+
+/* This struct is seperated from the above struct (siteTablesParams_t) for memory optimizations */
+typedef struct
+{
+    UINT8           numOfSites;
+    UINT8           maxNumOfSites;
+    siteEntry_t     siteTable[MAX_SITES_A_BAND];
+}siteTablesParamsBandA_t;
+
+/* Ths following structure is used to manage the sites */
+typedef struct
+{
+    siteTablesParamsBandA_t  dot11A_sitesTables;
+    siteTablesParams_t        dot11BG_sitesTables;
+    siteTablesParams_t        *pCurrentSiteTable;
+    siteEntry_t               *pPrimarySite;
+    siteEntry_t               *pPrevPrimarySite;
+} sitesMgmtParams_t;
+
+
+/* Site manager handle */
+typedef struct
+{
+    siteMgrInitParams_t *pDesiredParams;
+    sitesMgmtParams_t   *pSitesMgmtParams;
+
+    TI_HANDLE           hConn;
+    TI_HANDLE           hSmeSm;
+    TI_HANDLE           hCtrlData;
+    TI_HANDLE           hRxData;
+    TI_HANDLE           hTxData;
+    TI_HANDLE           hRsn;
+    TI_HANDLE           hAuth;
+    TI_HANDLE           hAssoc;
+    TI_HANDLE           hRegulatoryDomain;
+    TI_HANDLE           hMeasurementMgr;
+    TI_HANDLE           hHalCtrl;
+    TI_HANDLE           hMlmeSm;
+    TI_HANDLE           hMemMgr;
+    TI_HANDLE           hReport;
+    TI_HANDLE           hOs;
+    TI_HANDLE           hExcMngr;
+    TI_HANDLE           hApConn;
+    TI_HANDLE           hCurrBss;
+    TI_HANDLE           hQosMngr;
+    TI_HANDLE           hPowerMgr;
+    TI_HANDLE           hEvHandler;
+    TI_HANDLE           hMacServices;
+    TI_HANDLE           hScr;
+
+    UINT32              beaconSentCount;
+    UINT32              rxPacketsCount;
+    UINT32              txPacketsCount;
+
+    modulationType_e    chosenModulation;
+    modulationType_e    currentDataModulation;
+    dot11mode_e         siteMgrOperationalMode;
+    radioBand_e         radioBand;
+    radioBand_e         prevRadioBand;
+    
+    macAddress_t        ibssBssid;
+    BOOLEAN             bPostponedDisconnectInProgress;
+    BOOL                isAgingEnable;
+
+    /* TX Power Adjust */
+    UINT32              siteMgrTxPowerCheckTime;
+    BOOL                bTempTxPowerEnabled;
+
+    /* Scans procedures */
+    UINT8               numOfBeaconFiltering;
+    BOOL                keepAliveEnable;
+    /*UINT8             siteMgrDesiredBeaconFilterState;*/
+    beaconFilterParams_t    beaconFilterParams; /*contains the desired state*/
+
+
+    /*HW Request from Power Ctrl */
+    UINT32              DriverTestId;
+
+    BOOL                powerSaveLdMode;
+} siteMgr_t;
+
+
+
+siteEntry_t *findAndInsertSiteEntry(siteMgr_t       *pSiteMgr,
+                                    macAddress_t    *bssid,
+                                    radioBand_e     band);
+
+siteEntry_t *findSiteEntry(siteMgr_t        *pSiteMgr,
+                           macAddress_t     *bssid);
+
+void removeSiteEntry(siteMgr_t *pSiteMgr, siteTablesParams_t *pCurrSiteTblParams,
+                     siteEntry_t  *hashPtr);
+
+TI_STATUS removeEldestSite(siteMgr_t *pSiteMgr);
+
+TI_STATUS buildProbeReqTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate, ssid_t *pSsid, 
+                                                               radioBand_e radioBand);
+
+TI_STATUS buildProbeRspTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate);
+
+TI_STATUS buildNullTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate);
+
+TI_STATUS buildPsPollTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate);
+
+TI_STATUS buildQosNullDataTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate, UINT8 userPriority);
+
+#endif /* __SITE_MGR_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteMgr.c b/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/siteMgr.c
new file mode 100644 (file)
index 0000000..18ea43e
--- /dev/null
@@ -0,0 +1,5078 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 siteMgr.c
+ *  \brief Site Manager implementation
+ *
+ *  \see siteMgr.h
+ */
+
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "siteMgrApi.h"
+#include "siteHash.h"
+#include "smeApi.h"
+#include "utils.h"
+#include "connApi.h"
+#include "mlmeSm.h"
+#include "smeSmApi.h"
+#include "DataCtrl_Api.h"
+#include "regulatoryDomainApi.h"
+#include "rsnApi.h"
+#include "measurementMgrApi.h"
+#include "qosMngr_API.h"
+#include "PowerMgr_API.h"
+#include "EvHandler.h"
+#include "TI_IPC_Api.h"
+#include "MacServices_api.h" 
+#include "whalHwDefs.h"
+#include "apConn.h"
+#include "currBss.h"
+#include "PowerMgr.h"
+
+#ifdef EXC_MODULE_INCLUDED
+#include "excMngr.h"
+#endif
+#include "configMgr.h"
+
+/* definitions */
+
+#define JOIN_RATE_MASK_1M   0x01
+#define JOIN_RATE_MASK_2M   0x02
+#define JOIN_RATE_MASK_5_5M 0x04
+#define JOIN_RATE_MASK_11M  0x08
+#define JOIN_RATE_MASK_22M  0x10
+
+
+#define SITE_MGR_INIT_BIT           1
+#define TIMER_INIT_BIT              2
+#define DESIRED_PARAMS_INIT_BIT     3
+#define MGMT_PARAMS_INIT_BIT        4
+
+#define BUILT_IN_TEST_PERIOD 500
+
+#define KEEP_ALIVE_SEND_NULL_DATA_PERIOD  10000
+
+#define SITE_MGR_IBSS_AGING_TIMEOUT_DEF   10 * 1000        /* 10 seconds */
+
+#define DEAFULT_BEACON_FILTERING_NUM        (10)
+
+/* Reconfig constants */
+#define SCAN_FAIL_THRESHOLD_FOR_RECONFIG        4  /* After 4 times we reset the 580 register and still no AP found - make recovery */
+#define SCAN_FAIL_THRESHOLD_FOR_RESET_REG_580   90  /* After 90 times (45 seconds) and  no AP found - reset the 580 register */
+#define SCAN_FAIL_RECONFIG_ENABLED              TRUE
+#define SCAN_FAIL_RECONFIG_DISABLED             FALSE
+
+/* Local Macros */
+
+#define UPDATE_BEACON_INTERVAL(pSite, pFrameInfo)       pSite->beaconInterval = pFrameInfo->content.iePacket.beaconInerval
+
+#define UPDATE_CAPABILITIES(pSite, pFrameInfo)          pSite->capabilities = pFrameInfo->content.iePacket.capabilities
+
+#define UPDATE_PRIVACY(pSite, pFrameInfo)               pSite->privacy = ((pFrameInfo->content.iePacket.capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TRUE : FALSE
+
+#define UPDATE_AGILITY(pSite, pFrameInfo)               pSite->agility = ((pFrameInfo->content.iePacket.capabilities >> CAP_AGILE_SHIFT) & CAP_AGILE_MASK) ? TRUE : FALSE
+
+#define UPDATE_SLOT_TIME(pSite, pFrameInfo)             pSite->newSlotTime = ((pFrameInfo->content.iePacket.capabilities >> CAP_SLOT_TIME_SHIFT) & CAP_SLOT_TIME_MASK) ? PHY_SLOT_TIME_SHORT : PHY_SLOT_TIME_LONG
+#define UPDATE_PROTECTION(pSite, pFrameInfo)            pSite->useProtection = (pFrameInfo->content.iePacket.useProtection)
+
+#define UPDATE_SSID(pSite, pFrameInfo)                  if (pFrameInfo->content.iePacket.pSsid != NULL) { \
+                                                        pSite->ssid.len = pFrameInfo->content.iePacket.pSsid->hdr.eleLen; \
+        os_memoryCopy(pSiteMgr->hOs, (void *)pSite->ssid.ssidString, (void *)pFrameInfo->content.iePacket.pSsid->serviceSetId, pFrameInfo->content.iePacket.pSsid->hdr.eleLen) ;}
+
+#define UPDATE_CHANNEL(pSite, pFrameInfo, rxChannel)    if (pFrameInfo->content.iePacket.pDSParamsSet == NULL) \
+                                                            pSite->channel = rxChannel; \
+                                                        else \
+                                                            pSite->channel = pFrameInfo->content.iePacket.pDSParamsSet->currChannel;
+
+
+
+#define UPDATE_DTIM_PERIOD(pSite, pFrameInfo)           if (pFrameInfo->content.iePacket.pTIM != NULL) \
+                                                        pSite->dtimPeriod = pFrameInfo->content.iePacket.pTIM->dtimPeriod
+
+#define UPDATE_ATIM_WINDOW(pSite, pFrameInfo)           if (pFrameInfo->content.iePacket.pIBSSParamsSet != NULL) \
+                                                        pSite->atimWindow = pFrameInfo->content.iePacket.pIBSSParamsSet->atimWindow
+
+#define UPDATE_BEACON_AP_TX_POWER(pSite, pFrameInfo)    if (pFrameInfo->content.iePacket.TPCReport != NULL) \
+                                                        pSite->APTxPower = pFrameInfo->content.iePacket.TPCReport->transmitPower
+
+#define UPDATE_PROBE_AP_TX_POWER(pSite, pFrameInfo)     if (pFrameInfo->content.iePacket.TPCReport != NULL) \
+                                                        pSite->APTxPower = pFrameInfo->content.iePacket.TPCReport->transmitPower
+
+#define UPDATE_BSS_TYPE(pSite, pFrameInfo)              pSite->bssType = ((pFrameInfo->content.iePacket.capabilities >> CAP_ESS_SHIFT) & CAP_ESS_MASK) ? BSS_INFRASTRUCTURE : BSS_INDEPENDENT
+
+#define UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo)        pSite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs)
+
+#define UPDATE_DTIM_TIME(pSiteMgr, pSite, pFrameInfo)       pSite->dtimTimeStamp = os_timeStampMs(pSiteMgr->hOs)
+
+/* Updated from beacons */
+#define UPDATE_BEACON_MODULATION(pSite, pFrameInfo)     pSite->beaconModulation = ((pFrameInfo->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
+
+/* Updated from probes */
+#define UPDATE_PROBE_MODULATION(pSite, pFrameInfo)          pSite->probeModulation = ((pFrameInfo->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
+
+#define UPDATE_BEACON_RECV(pSite)                       pSite->beaconRecv = TRUE
+
+#define UPDATE_PROBE_RECV(pSite)                        pSite->probeRecv = TRUE
+
+
+#define UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen)              if (pRsnIe != NULL) { \
+                                                            UINT8 length=0, index=0;\
+                                                            pSite->rsnIeLen = rsnIeLen;\
+                                                            while ((length < pSite->rsnIeLen) && (index<MAX_RSN_IE)){\
+                                                                pSite->pRsnIe[index].hdr = pRsnIe->hdr;\
+                                                                os_memoryCopy(pSiteMgr->hOs, (void *)pSite->pRsnIe[index].rsnIeData, (void *)pRsnIe->rsnIeData, pRsnIe->hdr.eleLen);\
+                                                                length += (pRsnIe->hdr.eleLen+2); \
+                                                                pRsnIe += 1; \
+                                                                index++;}\
+                                                        } \
+                                                        else {pSite->rsnIeLen = 0;}
+
+#define UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo)    os_memoryCopy(pSiteMgr->hOs, pSite->tsfTimeStamp, (void *)pFrameInfo->content.iePacket.timestamp, TIME_STAMP_LEN)
+
+#define SET_ENTRY_FLAG_IN_SITE_TABLE(pSite)             pSite->Not_Received = 0
+
+
+
+
+/* Local  functions definitions*/
+
+static void update_apsd(siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
+
+static void release_module(siteMgr_t *pSiteMgr, UINT32 initVec);
+
+static void updateSiteInfo(siteMgr_t *pSiteMgr, mlmeFrameInfo_t *pFrameInfo, siteEntry_t    *pSite, UINT8 rxChannel);
+
+static void updateRates(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
+
+static void updateBeaconQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
+
+static void updateProbeQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
+
+static void updatePreamble(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
+
+static void updateFourX(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
+
+static TI_STATUS getBssidList(siteMgr_t *pSiteMgr, OS_802_11_BSSID_LIST_EX *bssidList, UINT32* pLength, BOOL allVarIes);
+
+static void getPrimarySiteDesc(siteMgr_t *pSiteMgr, OS_802_11_BSSID *pPrimarySiteDesc, BOOL supplyExtendedInfo);
+
+static TI_STATUS getPrimaryBssid(siteMgr_t *pSiteMgr, OS_802_11_BSSID_EX *primaryBssid, UINT32 *pLength);
+
+static rate_e translateRateMaskToValue(siteMgr_t *pSiteMgr, UINT32 rateMask);
+
+static void getSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet);
+
+static TI_STATUS setSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet);
+
+static void validateDesiredTxRate(rate_e desiredTxRate,modulationType_e desiredModulation,UINT32 suppRates,UINT32 *bitMap,BOOL *txDesiredRateSupported);
+
+static TI_STATUS calculateBssidListSize(siteMgr_t *pSiteMgr, UINT32 *pLength, BOOL allVarIes);
+
+static void siteMgr_externalConfigurationParametersSet(TI_HANDLE hSiteMgr);
+
+
+void siteMgr_gotFirstBcn(TI_HANDLE hSiteMgr);
+
+
+
+#define CHAN_FREQ_TABLE_SIZE        (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ))
+
+struct CHAN_FREQ {
+    UINT8       chan;
+    UINT32      freq;
+} ChanFreq[] = {
+    {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000},
+    {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000},
+    {9,2452000},
+    {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000},
+    {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000},
+    {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000},
+    {64,5320000},
+    {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000},
+    {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000},
+    {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000},
+    {153,5765000}, {157,5785000}, {161,5805000} };
+
+
+
+static UINT8 Freq2Chan(UINT32 freq)
+{
+    UINT32 i;
+
+    for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
+        if(ChanFreq[i].freq == freq) return ChanFreq[i].chan;
+
+    return 0;
+}
+
+
+static UINT32 Chan2Freq(UINT8 chan)
+{
+    UINT32 i;
+
+    for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
+        if(ChanFreq[i].chan == chan) return ChanFreq[i].freq;
+
+    return 0;
+}
+
+/************************************************************************
+*                        siteMgr_setTemporaryTxPower                    *
+*************************************************************************
+DESCRIPTION:   This function is used to start the Tx Power Control adjust mechanism
+                               in regulatoryDomain.
+
+INPUT:      bActivateTempFix             -   Whether the power should be adjusted 
+************************************************************************/
+void siteMgr_setTemporaryTxPower(siteMgr_t* pSiteMgr, BOOL bActivateTempFix)
+{
+       paramInfo_t         param;
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, 
+               ("siteMgr_setTemporaryTxPower is = %s \n", (bActivateTempFix ? "ON" : "OFF")));
+
+       /* Set the temporary Power Level via the Regulatory Domain*/
+       param.paramType = REGULATORY_DOMAIN_TEMPORARY_TX_ATTENUATION_PARAM;
+       param.content.bActivateTempPowerFix = bActivateTempFix;
+       regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
+}
+
+/* Interface functions Implementation */
+
+
+/*static void UPDATE_RSN_IE (siteMgr_t* pSiteMgr, siteEntry_t   *pSite, dot11_RSN_t *pRsnIe, UINT8 rsnIeLen)
+{
+
+    if (pRsnIe != NULL) {
+            UINT8 length=0, index=0;
+            pSite->rsnIeLen = rsnIeLen;
+            while ((length < pSite->rsnIeLen) && (index<MAX_RSN_IE)){
+                pSite->pRsnIe[index].hdr = pRsnIe->hdr;
+                os_memoryCopy(pSiteMgr->hOs, pSite->pRsnIe[index].rsnIeData, pRsnIe->rsnIeData, pRsnIe->hdr.eleLen);
+                length += (pRsnIe->hdr.eleLen+2);
+                pRsnIe += 1;
+                index++;}
+        }
+        else {pSite->rsnIeLen = 0;}
+}*/
+/************************************************************************
+ *                        siteMgr_create                                *
+ ************************************************************************
+DESCRIPTION: Site manager module creation function, called by the config mgr in creation phase
+                performs the following:
+                -   Allocate the site manager handle
+                -   Allocate the desired & mgmt params structure
+
+INPUT:      hOs             -   Handle to OS
+
+
+OUTPUT:
+
+
+RETURN:     Handle to the site manager module on success, NULL otherwise
+************************************************************************/
+TI_HANDLE siteMgr_create(TI_HANDLE hOs)
+{
+    siteMgr_t       *pSiteMgr;
+    UINT32          initVec;
+
+    initVec = 0;
+
+    pSiteMgr = os_memoryAlloc(hOs, sizeof(siteMgr_t));
+    if (pSiteMgr == NULL)
+        return NULL;
+
+    os_memoryZero(hOs, pSiteMgr, sizeof(siteMgr_t));
+
+    initVec |= (1 << SITE_MGR_INIT_BIT);
+
+    pSiteMgr->pDesiredParams = os_memoryAlloc(hOs, sizeof(siteMgrInitParams_t));
+    if (pSiteMgr->pDesiredParams == NULL)
+    {
+        release_module(pSiteMgr, initVec);
+        return NULL;
+    }
+
+    initVec |= (1 << DESIRED_PARAMS_INIT_BIT);
+
+    pSiteMgr->pSitesMgmtParams = os_memoryAlloc(hOs, sizeof(sitesMgmtParams_t));
+    if (pSiteMgr->pSitesMgmtParams == NULL)
+    {
+        release_module(pSiteMgr, initVec);
+        return NULL;
+    }
+
+    initVec |= (1 << MGMT_PARAMS_INIT_BIT);
+
+    pSiteMgr->hOs = hOs;
+
+    return(pSiteMgr);
+}
+
+
+
+/************************************************************************
+ *                        siteMgr_config                                    *
+ ************************************************************************
+DESCRIPTION: Site manager module configuration function, called by the config mgr in configuration phase
+                performs the following:
+                -   Reset & initiailzes local variables
+                -   Init the handles to be used by the module
+
+INPUT:      hSiteMgr    -   site manager handle
+            List of handles to be used by the module
+            pSiteMgrInitParams  -   Init table of the module, contains the following:
+                -   Parameters read from registry
+                -   Chip parameters
+
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_config(   TI_HANDLE       hSiteMgr,
+                        TI_HANDLE       hConn,
+                        TI_HANDLE       hSmeSm,
+                        TI_HANDLE       hCtrlData,
+                        TI_HANDLE       hRxData,
+                        TI_HANDLE       hTxData,
+                        TI_HANDLE       hRsn,
+                        TI_HANDLE       hAuth,
+                        TI_HANDLE       hAssoc,
+                        TI_HANDLE       hHalCtrl,
+                        TI_HANDLE       hMlmeSm,
+                        TI_HANDLE       hRegulatoryDomain,
+                        TI_HANDLE       hMeasurementMgr,
+                        TI_HANDLE       hApConn,
+                        TI_HANDLE       hCurrBss,
+                        TI_HANDLE       hReport,
+                        TI_HANDLE       hOs ,
+                        TI_HANDLE       hExcMngr,
+                        TI_HANDLE       hQosMngr,
+                        TI_HANDLE       thePowerMgrHandle,
+                        TI_HANDLE       hScr,
+                        TI_HANDLE       hEvHandler,
+                        TI_HANDLE       hMacServices,
+                        siteMgrInitParams_t     *pSiteMgrInitParams)
+{ 
+    siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    UINT32          timestamp;
+    slotTime_e      slotTime;
+    paramInfo_t     saParam;
+    TI_STATUS       status;
+
+    /* Init handles */
+    pSiteMgr->hConn                 = hConn;
+    pSiteMgr->hSmeSm                = hSmeSm;
+    pSiteMgr->hHalCtrl              = hHalCtrl;
+    pSiteMgr->hCtrlData             = hCtrlData;
+    pSiteMgr->hRxData               = hRxData;
+    pSiteMgr->hTxData               = hTxData;
+    pSiteMgr->hRsn                  = hRsn;
+    pSiteMgr->hAuth                 = hAuth;
+    pSiteMgr->hAssoc                = hAssoc;
+    pSiteMgr->hRegulatoryDomain     = hRegulatoryDomain;
+    pSiteMgr->hMeasurementMgr       = hMeasurementMgr;
+    pSiteMgr->hReport               = hReport;
+    pSiteMgr->hOs                   = hOs;
+    pSiteMgr->hMlmeSm               = hMlmeSm;
+    pSiteMgr->hAssoc                = hAssoc;
+    pSiteMgr->hReport               = hReport;
+    pSiteMgr->hExcMngr              = hExcMngr;
+    pSiteMgr->hApConn               = hApConn;
+    pSiteMgr->hCurrBss              = hCurrBss;
+    pSiteMgr->hQosMngr              = hQosMngr;
+    pSiteMgr->hPowerMgr             = thePowerMgrHandle;
+    pSiteMgr->hScr                  = hScr;
+    pSiteMgr->hEvHandler            = hEvHandler;
+    pSiteMgr->hMacServices          = hMacServices;
+
+       /* Reset counter for Tx Power Control adjustment */
+    pSiteMgr->siteMgrTxPowerCheckTime   = 0;
+
+    /* Init desired parameters */
+    os_memoryCopy(hOs, pSiteMgr->pDesiredParams, pSiteMgrInitParams, sizeof(siteMgrInitParams_t));
+
+    /* Init Beacon Filter Desired State */
+    pSiteMgr->beaconFilterParams.desiredState = pSiteMgrInitParams->beaconFilterParams.desiredState;
+    /* Init Beacon Filter numOfStored parameter */
+    pSiteMgr->beaconFilterParams.numOfStored = pSiteMgrInitParams->beaconFilterParams.numOfStored;
+
+    /* Init management params */
+    pSiteMgr->pSitesMgmtParams->dot11A_sitesTables.maxNumOfSites = MAX_SITES_A_BAND;
+    siteMgr_resetSiteTable(pSiteMgr,(siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables);
+    pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables.maxNumOfSites = MAX_SITES_BG_BAND;
+    siteMgr_resetSiteTable(pSiteMgr,&pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables);
+
+    /* calculate random BSSID for usage in IBSS */
+    timestamp = os_timeStampMs(pSiteMgr->hOs);
+    os_memoryCopy(pSiteMgr->hOs, (void *)&(pSiteMgr->ibssBssid.addr[0]), &timestamp, sizeof(UINT32));
+    pSiteMgr->ibssBssid.addr[0] = 0x00;
+    timestamp = os_timeStampMs(pSiteMgr->hOs);
+    os_memoryCopy(pSiteMgr->hOs, (void *)&(pSiteMgr->ibssBssid.addr[2]), &timestamp, sizeof(UINT32));
+
+    /* Get the Source MAC address in order to use it for AD-Hoc BSSID, solving Conexant ST issue for WiFi test */
+    saParam.paramType = CTRL_DATA_MAC_ADDRESS;
+    status = ctrlData_getParam(hCtrlData, &saParam);
+    if (status != OK)
+    {
+        WLAN_OS_REPORT(("\n ERROR !!! : siteMgr_config - Error in getting MAC address\n" ));
+        return NOK;
+    }
+    pSiteMgr->ibssBssid.addr[0] = 0x02;
+    pSiteMgr->ibssBssid.addr[1] = saParam.content.ctrlDataDeviceMacAddress.addr[1];
+    pSiteMgr->ibssBssid.addr[2] = saParam.content.ctrlDataDeviceMacAddress.addr[2];
+
+    pSiteMgr->keepAliveEnable = pSiteMgrInitParams->siteMgrDesiredkeepAliveEnable;
+    pSiteMgr->numOfBeaconFiltering = DEAFULT_BEACON_FILTERING_NUM;
+
+    switch(pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radioType)
+    {
+    case MAXIM:
+    pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
+        &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_maximRadioValues;
+    pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_2_4_GHZ;
+       WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("MAXIM  !!! \n"));
+    
+        break;
+
+    case RFMD:
+        pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
+            &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_rfmdRadioValues;
+        pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_2_4_GHZ;
+        WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("RFMD  !!! \n"));
+        break;
+
+    case RADIA_BG:
+    pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
+        &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radiaRadioValues;
+    pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_2_4_GHZ;
+       WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("RADIA bg  !!! \n"));
+       break;
+
+    case RADIA_ABG:
+    pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
+        &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radiaRadioValues;
+    pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_DUAL;
+    WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("RADIA abg  !!! \n"));
+
+        break;
+
+    default:
+    pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues = NULL;
+    WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                    ("!!!.....UnKnown Radio Type !!!\n"));          
+    }
+
+    pSiteMgr->beaconSentCount = 0;
+    pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow = 0;
+
+    if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+    {
+       if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL)
+       {
+           pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+           pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+           slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+           pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+       }
+       else if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ)
+       {
+           pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
+           pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+           pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+           slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+           pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+       }
+       else
+       {
+           pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_A_MODE;
+           pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
+           pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
+           slotTime = PHY_SLOT_TIME_SHORT;
+           pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+       }
+    }
+    else if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_G_MODE)
+    {
+        slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+        pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+        if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
+           (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ))
+        {
+            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+            pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
+
+        }
+        else
+        {
+            WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
+            return NOK;
+        }
+    }
+    else if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_B_MODE)
+    {
+        slotTime = PHY_SLOT_TIME_LONG;
+        pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+        if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
+           (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ))
+        {
+            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+            pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
+        }
+        else
+        {
+            WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
+            return NOK;
+        }
+    }
+    else
+    {
+        slotTime = PHY_SLOT_TIME_SHORT;
+        pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
+        if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
+           (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_5_0_GHZ))
+        {
+            pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
+            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+        }
+        else
+        {
+            WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
+            return NOK;
+        }
+    }
+
+
+    /* configure hal with common core-hal parameters */
+    whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, pSiteMgr->radioBand);
+    whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, slotTime);
+    siteMgr_ConfigRate(hSiteMgr);
+
+    WLAN_REPORT_INIT(hReport, SITE_MGR_MODULE_LOG,
+        (" SiteMgr - numOfElements = %d IETableSize = %d\n" , pSiteMgrInitParams->beaconFilterParams.numOfElements, pSiteMgrInitParams->beaconFilterParams.IETableSize)) ;
+    /*send the table regardless to the state*/
+    whalCtrl_SetBeaconFilterIETable(pSiteMgr->hHalCtrl ,(UINT8 *)&(pSiteMgrInitParams->beaconFilterParams.numOfElements), (UINT8 *)&(pSiteMgrInitParams->beaconFilterParams.IETable[0]) , (UINT8 *)&(pSiteMgrInitParams->beaconFilterParams.IETableSize)) ;
+
+    /*  At start-up Set the Beacon Filter state as the User required */
+    whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, pSiteMgrInitParams->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored);
+    
+    pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = NULL;
+
+    pSiteMgr->powerSaveLdMode = FALSE;
+
+    WLAN_REPORT_INIT(hReport, SITE_MGR_MODULE_LOG,  (".....Site manager configured successfully\n"));
+
+    return OK;
+}
+
+
+/************************************************************************
+ *                        siteMgr_unLoad                                    *
+ ************************************************************************
+DESCRIPTION: site manager module unload function, called by the config mgr in the unlod phase
+                performs the following:
+                -   Free all memory aloocated by the module
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_unLoad(TI_HANDLE hSiteMgr)
+{
+    UINT32          initVec;
+    siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if (!pSiteMgr)
+        return OK;
+
+    initVec = 0xFFFF;
+    release_module(pSiteMgr, initVec);
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_setParam
+ ***********************************************************************
+DESCRIPTION: site mgr set param function, called by the following:
+                -   config mgr in order to set a parameter from the OS abstraction layer.
+                In this fuction, the site manager OS abstraction layer configures the site manager to the desired params.
+                Sometimes it requires a re scan, depending in the parameter type
+
+INPUT:      hSiteMgr    -   Connection handle.
+            pParam  -   Pointer to the parameter
+
+OUTPUT:
+
+RETURN:     RE_SCAN_NEEDED if re scan needed, OK on success, NOK on failure
+
+************************************************************************/
+
+TI_STATUS siteMgr_setParam(TI_HANDLE        hSiteMgr,
+                        paramInfo_t     *pParam)
+{
+    siteMgr_t *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    OS_802_11_CONFIGURATION *pConfig;
+    UINT32      channel;
+    slotTime_e  slotTime;
+
+    switch(pParam->paramType)
+    {
+    case SITE_MGR_CONFIGURATION_PARAM:
+        pConfig = pParam->content.pSiteMgrConfiguration;
+
+/*      for(channel = 0; channel < SITE_MGR_CHANNEL_MAX+1; channel++)
+        {
+            if(pConfig->channel == pSiteMgr->pDesiredParams->siteMgrFreq2ChannelTable[channel])
+                break;
+        }*/
+
+        channel = Freq2Chan(pConfig->Union.channel);
+
+        if(channel == 0 || channel > SITE_MGR_CHANNEL_MAX)
+            return PARAM_VALUE_NOT_VALID;
+        else
+            pConfig->Union.channel = channel;
+
+        if((pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pConfig->Union.channel) ||
+           (pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pConfig->Union.channel) ||
+           (pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow != pConfig->ATIMWindow))
+        {
+            pSiteMgr->pDesiredParams->siteMgrDesiredChannel = (UINT8)pConfig->Union.channel;
+            pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval = (UINT16)pConfig->BeaconPeriod;
+            pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow = pConfig->ATIMWindow;
+        }
+
+        return OK;
+
+    case SITE_MGR_DESIRED_CHANNEL_PARAM:
+        if (pParam->content.siteMgrDesiredChannel > SITE_MGR_CHANNEL_MAX)
+            return PARAM_VALUE_NOT_VALID;
+
+        if (pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pParam->content.siteMgrDesiredChannel)
+            pSiteMgr->pDesiredParams->siteMgrDesiredChannel = (UINT8)pParam->content.siteMgrDesiredChannel;
+        return OK;
+
+    case SITE_MGR_DESIRED_BSSID_PARAM:
+            os_memoryCopy(pSiteMgr->hOs, (void *)pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr, (void *)pParam->content.siteMgrDesiredBSSID.addr, sizeof(macAddress_t));
+#if 0
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Set BSSID = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n", 
+                                                                              pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[0],
+                                                                              pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[1],
+                                                                              pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[2],
+                                                                              pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[3],
+                                                                              pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[4],
+                                                                              pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[5]));
+#endif
+           return OK;
+                
+
+
+    case SITE_MGR_DESIRED_SSID_PARAM: 
+
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                ("\nSet new SSID=%s (len=%d)  \n",
+                                 pParam->content.siteMgrDesiredSSID.ssidString,
+                                 pParam->content.siteMgrDesiredSSID.len));
+
+        if (pParam->content.siteMgrDesiredSSID.len > MAX_SSID_LEN)
+            return PARAM_VALUE_NOT_VALID;
+
+        os_memoryCopy(pSiteMgr->hOs, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, &pParam->content.siteMgrDesiredSSID, sizeof(ssid_t));
+        /* only add null at the end of the string if the string length is less than 32 bytes and so we have one char left
+           TODO: another byte must be added, and the alignment change MUST be tested (esp. in CLI commands with ssid_t */
+        if ( MAX_SSID_LEN > pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len )
+        {
+            pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len] = '\0';
+        }
+
+        /* increase the random IBSS BSSID calculated during init */
+        pSiteMgr->ibssBssid.addr[MAC_ADDR_LEN - 1] ++;
+
+        if (utils_isJunkSSID(&pSiteMgr->pDesiredParams->siteMgrDesiredSSID))
+        {
+            rsn_removedDefKeys(pSiteMgr->hRsn);
+        }
+        return RE_SCAN_NEEDED;
+
+
+    case SITE_MGR_DESIRED_BSS_TYPE_PARAM:
+         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                ("\nSet BssType = %d\n", pParam->content.siteMgrDesiredBSSType));
+        if (pParam->content.siteMgrDesiredBSSType > BSS_ANY)
+            return PARAM_VALUE_NOT_VALID;
+
+        if (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType != pParam->content.siteMgrDesiredBSSType)
+        {
+            pSiteMgr->pDesiredParams->siteMgrDesiredBSSType = pParam->content.siteMgrDesiredBSSType;
+
+                       /* If the new BSS type is NOT Ad_Hoc, We make sure that the rate masks are set to G */
+                        if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType != BSS_INDEPENDENT)
+
+            {
+                                pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+                 siteMgr_ConfigRate(pSiteMgr);
+            }
+
+            /* If the new BSS type is Ad_Hoc, increase the random BSSID calculated during init */
+            if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
+            {
+                pSiteMgr->ibssBssid.addr[MAC_ADDR_LEN - 1] ++;
+            }
+
+            /* go to B_ONLY Mode only if WiFI bit is Set*/
+            if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
+            {   /* Configuration For AdHoc when using external configuration */
+                if(pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == FALSE)
+                {
+                    siteMgr_externalConfigurationParametersSet(hSiteMgr);
+                }
+            }
+        }
+
+        return OK;
+
+    case SITE_MGR_DESIRED_MODULATION_TYPE_PARAM:
+        if ((pParam->content.siteMgrDesiredModulationType < DRV_MODULATION_CCK) ||
+            (pParam->content.siteMgrDesiredModulationType > DRV_MODULATION_OFDM))
+            return PARAM_VALUE_NOT_VALID;
+
+        if (pSiteMgr->pDesiredParams->siteMgrDesiredModulationType != pParam->content.siteMgrDesiredModulationType)
+        {
+            pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = pParam->content.siteMgrDesiredModulationType;
+            /* means that we are moving from non-pbcc network to pbcc */
+            if (pParam->content.siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
+                return RE_SCAN_NEEDED;
+            return OK;
+        }
+        return OK;
+
+    case SITE_MGR_BEACON_RECV:
+        if (!pPrimarySite)
+        {
+            return NO_SITE_SELECTED_YET;
+        }
+        pPrimarySite->beaconRecv = pParam->content.siteMgrBeaconRecv;
+        return OK;
+
+
+    case SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM:
+        if (pParam->content.siteMgrDesiredBeaconInterval < SITE_MGR_BEACON_INTERVAL_MIN)
+            return PARAM_VALUE_NOT_VALID;
+
+        if (pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval != pParam->content.siteMgrDesiredBeaconInterval)
+            pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval = pParam->content.siteMgrDesiredBeaconInterval;
+        return OK;
+
+    case SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM:
+        if ((pParam->content.siteMgrDesiredPreambleType != PREAMBLE_LONG) &&
+            (pParam->content.siteMgrDesiredPreambleType != PREAMBLE_SHORT))
+            return PARAM_VALUE_NOT_VALID;
+
+        if (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType != pParam->content.siteMgrDesiredPreambleType)
+        {
+            pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType = pParam->content.siteMgrDesiredPreambleType;
+        }
+        return OK;
+
+    case SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM:
+        return setSupportedRateSet(pSiteMgr, &(pParam->content.siteMgrDesiredSupportedRateSet));
+
+    case SITE_MGR_DESIRED_DOT11_MODE_PARAM:
+        if(pParam->content.siteMgrDot11Mode > DOT11_MAX_MODE)
+            return PARAM_VALUE_NOT_VALID;
+
+        if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode != pParam->content.siteMgrDot11Mode)
+        {
+            pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = pParam->content.siteMgrDot11Mode;
+
+            /* since the dot11ABAmode changed, the STA operational mode should be changed */
+            if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+            {
+                if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL)
+                {
+                    pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+                }
+                else if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ)
+                {
+                    pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
+                    pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+                }
+                else
+                {
+                    pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
+                    pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
+                }
+
+            }
+            else
+                pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
+
+            /* configure HAL with new parameters update rates and select site table */
+            pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
+            if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+            {
+                pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+                pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
+                slotTime = PHY_SLOT_TIME_SHORT;
+            }
+            else if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+            {
+                pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+                pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+                slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+            }
+            else
+            {
+                pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+                pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
+                slotTime = PHY_SLOT_TIME_LONG;
+            }
+
+            if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
+                siteMgr_bandParamsConfig(pSiteMgr, TRUE);
+
+            /* configure HAL */
+            whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, pSiteMgr->radioBand);
+            whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, slotTime);
+
+            /* If the BSS type is Ad_Hoc, increase the random BSSID calculated during init */
+            if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
+            {
+                pSiteMgr->ibssBssid.addr[MAC_ADDR_LEN - 1] ++;
+            }
+
+            /*siteMgr_resetAllSiteTables(pSiteMgr); */
+            return RE_SCAN_NEEDED;
+        }
+        return OK;
+
+    case SITE_MGR_OPERATIONAL_MODE_PARAM:
+
+        if(pParam->content.siteMgrDot11OperationalMode < DOT11_B_MODE ||
+            pParam->content.siteMgrDot11OperationalMode > DOT11_G_MODE )
+            return PARAM_VALUE_NOT_VALID;
+
+        pSiteMgr->siteMgrOperationalMode = pParam->content.siteMgrDot11OperationalMode;
+        break;
+
+
+    case SITE_MGR_USE_DRAFT_NUM_PARAM:
+        if(pParam->content.siteMgrUseDraftNum != DRAFT_5_AND_EARLIER &&
+           pParam->content.siteMgrUseDraftNum != DRAFT_6_AND_LATER)
+            return PARAM_VALUE_NOT_VALID;
+
+        if(pSiteMgr->pDesiredParams->siteMgrUseDraftNum != pParam->content.siteMgrUseDraftNum)
+        {
+            pSiteMgr->pDesiredParams->siteMgrUseDraftNum = pParam->content.siteMgrUseDraftNum;
+            return RE_SCAN_NEEDED;
+        }
+        return OK;
+
+    case SITE_MGR_RADIO_BAND_PARAM:
+        if((INT8)pParam->content.siteMgrRadioBand < RADIO_BAND_2_4_GHZ ||
+           (INT8)pParam->content.siteMgrRadioBand > RADIO_BAND_DUAL )
+            return PARAM_VALUE_NOT_VALID;
+
+        pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
+        pSiteMgr->radioBand = pParam->content.siteMgrRadioBand;
+        if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
+            siteMgr_bandParamsConfig(pSiteMgr, FALSE);
+
+        break;
+
+    case SITE_MGR_DESIRED_SLOT_TIME_PARAM:
+        if(pParam->content.siteMgrSlotTime != PHY_SLOT_TIME_LONG &&
+           pParam->content.siteMgrSlotTime != PHY_SLOT_TIME_SHORT)
+            return PARAM_VALUE_NOT_VALID;
+
+        if(pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime != pParam->content.siteMgrSlotTime)
+        {
+            if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+            {
+                pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = pParam->content.siteMgrSlotTime;
+                if(!pPrimarySite)
+                    whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime);
+                else if(pPrimarySite->bssType != BSS_INFRASTRUCTURE)
+                    whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime);
+            }
+
+        }
+        return OK;
+
+    case SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM:
+        {
+            int desiredStateBeforeChange = pSiteMgr->beaconFilterParams.desiredState;
+
+            /* Set the New Desired User request of Beacon Filter */
+            pSiteMgr->beaconFilterParams.desiredState = pParam->content.siteMgrDesiredBeaconFilterState;
+                
+            /* Check if the Desired  mode has changed - If not no need to send the MIB to the FW */
+            if ( pSiteMgr->beaconFilterParams.desiredState == desiredStateBeforeChange )
+            {
+                WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
+                    ("Beacon Filter already %s" , (TRUE == desiredStateBeforeChange)? "ENABLED":"DISABLED" ) );
+                break;
+            }
+
+            WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
+                ("\n New   Beacon Filter Desired State is : %s pSiteMgr->beaconFilterParams.currentState %s\n" , ( TRUE == (pSiteMgr->beaconFilterParams.desiredState) )?"ENABLED":"DISABLED",( TRUE == (pSiteMgr->beaconFilterParams.currentState) )?"ENABLED":"DISABLED"));
+
+
+            /* Check if the new Desired state is TRUE then Also check the Current State and then if FALSEdo not send the MIB to FW*/
+            if ( (TRUE == pSiteMgr->beaconFilterParams.desiredState ) && (FALSE == pSiteMgr->beaconFilterParams.currentState ))
+            {
+                WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
+                    ("\n New   Beacon Filter Desired State is TRUE But Current State is DISABLED So the MIBwill be sent Later !!!!"));
+
+            }
+            /* In any other cases the User required Beacon Filter Configuration will be sent to FW immediately */
+            else
+            {
+                WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
+                    ("\n New   Sending  Beacon Filter Desired State To FW !!!!"));
+
+                whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, pSiteMgr->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored);
+            }
+
+
+        }
+
+        break;
+
+    case SITE_MGR_DISASSOCIATE_PARAM:
+    case SITE_MGR_DEAUTHENTICATE_PARAM:
+        if(!pPrimarySite)
+            return OK;
+
+        else { /* Set Junk SSID */
+            pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len = 4;
+            pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[0]=1;
+            pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[1]=1;
+            pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[2]=1;
+            pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[3]=1;
+            return RE_SCAN_NEEDED;
+        }
+
+
+    case SITE_MGR_BSSID_LIST_SCAN_PARAM:
+#if 0
+        /* TODO - merge fix from WinCE version (and generalize it if time permits) */
+        /* Must return NOK in each case the scan is not actually performed */
+        if(!pPrimarySite)
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                ("Not connected to Network => do the BSSID_LIST_SCAN command\n"));
+            smeSm_startScan(pSiteMgr->hSmeSm);
+        } 
+
+        param.paramType = RX_DATA_COUNTERS_PARAM;
+        rxData_getParam(pSiteMgr->hRxData, &param);
+
+        /* get current received data frames counter */
+        currRxPacketsCount = param.content.siteMgrTiWlanCounters.DirectedFramesRecv;
+
+        if((pSiteMgr->rxPacketsCount + 1) < currRxPacketsCount)
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                ("Traffic is active now => ignoring the BSSID_LIST_SCAN command\n"));
+            return NOK;
+        }
+        else
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                ("Traffic is not active now => do the BSSID_LIST_SCAN command\n"));
+            smeSm_startScan(pSiteMgr->hSmeSm);
+
+        }
+    }
+#endif
+        return OK;
+
+    case SITE_MGR_LAST_RX_RATE_PARAM:
+        if (pPrimarySite != NULL)
+        {
+            pPrimarySite->rxRate = pParam->content.ctrlDataCurrentBasicRate;
+        }
+        break;
+
+    case SITE_MGR_CURRENT_CHANNEL_PARAM:
+        if (!pPrimarySite)
+        {
+            return NO_SITE_SELECTED_YET;
+        }
+        pPrimarySite->channel = pParam->content.siteMgrCurrentChannel;
+        break;
+
+    case SITE_MGR_CURRENT_SIGNAL_PARAM:
+        if (!pPrimarySite)
+        {
+            return NO_SITE_SELECTED_YET;
+        }
+
+        pPrimarySite->rssi = pParam->content.siteMgrCurrentSignal.rssi;
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Set param, Params is not supported, %d\n", pParam->paramType));
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_getParam
+ ***********************************************************************
+DESCRIPTION: Site mgr get param function, called by the following:
+            -   config mgr in order to get a parameter from the OS abstraction layer.
+            -   From inside the dirver
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            pParam  -   Pointer to the parameter
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_getParam(TI_HANDLE        hSiteMgr,
+                        paramInfo_t     *pParam)
+{
+    siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteEntry_t     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    TI_STATUS       status = OK;
+    UINT8           siteEntryIndex;
+    UINT32          dtimInterval;
+    UINT32          delta;
+    whalParamInfo_t whalParam;
+
+    switch(pParam->paramType)
+    {
+
+    case SITE_MGR_CONFIGURATION_PARAM:
+        pParam->content.pSiteMgrConfiguration->Length = sizeof(OS_802_11_CONFIGURATION);
+        pParam->content.pSiteMgrConfiguration->ATIMWindow = pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow;
+        pParam->content.pSiteMgrConfiguration->BeaconPeriod = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
+        pParam->content.pSiteMgrConfiguration->Union.channel =
+            Chan2Freq(pSiteMgr->pDesiredParams->siteMgrDesiredChannel);
+            /*pSiteMgr->pDesiredParams->siteMgrFreq2ChannelTable[pSiteMgr->pDesiredParams->siteMgrDesiredChannel];*/
+
+        if(pPrimarySite) {
+            pParam->content.pSiteMgrConfiguration->FHConfig.DwellTime = pPrimarySite->FHParams.dwellTime;
+            pParam->content.pSiteMgrConfiguration->FHConfig.HopPattern = pPrimarySite->FHParams.hopPattern;
+            pParam->content.pSiteMgrConfiguration->FHConfig.HopSet = pPrimarySite->FHParams.hopSet;
+        }
+        else {
+            pParam->content.pSiteMgrConfiguration->FHConfig.DwellTime = 0;
+            pParam->content.pSiteMgrConfiguration->FHConfig.HopPattern = 0;
+            pParam->content.pSiteMgrConfiguration->FHConfig.HopSet = 0;
+        }
+
+        pParam->content.pSiteMgrConfiguration->FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
+        break;
+
+    case SITE_MGR_DESIRED_CHANNEL_PARAM:
+        pParam->content.siteMgrDesiredChannel = pSiteMgr->pDesiredParams->siteMgrDesiredChannel;
+        break;
+
+    case SITE_MGR_DESIRED_BSSID_PARAM:
+        os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrDesiredBSSID, &pSiteMgr->pDesiredParams->siteMgrDesiredBSSID, sizeof(macAddress_t));
+        break;
+
+    case SITE_MGR_DESIRED_SSID_PARAM:
+        os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrDesiredSSID, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, sizeof(ssid_t));
+        break;
+
+    case SITE_MGR_DESIRED_BSS_TYPE_PARAM:
+        pParam->content.siteMgrDesiredBSSType = pSiteMgr->pDesiredParams->siteMgrDesiredBSSType;
+        break;
+
+    case SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM:
+        getSupportedRateSet(pSiteMgr, &(pParam->content.siteMgrDesiredSupportedRateSet));
+        break;
+
+    case SITE_MGR_DESIRED_MODULATION_TYPE_PARAM:
+        pParam->content.siteMgrDesiredModulationType = pSiteMgr->pDesiredParams->siteMgrDesiredModulationType;
+        break;
+
+    case SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM:
+        pParam->content.siteMgrDesiredBeaconInterval = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
+        break;
+
+    case SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM:
+        pParam->content.siteMgrDesiredPreambleType = pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType;
+        break;
+
+    case SITE_MGR_CURRENT_RADIO_TYPE_PARAM:
+        pParam->content.siteMgrRadioType = pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radioType;
+        break;
+
+    case SITE_MGR_CURRENT_SIGNAL_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrCurrentSignal.rssi = 0;
+            pParam->content.siteMgrCurrentSignal.snr = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+
+        pParam->content.siteMgrCurrentSignal.rssi = pPrimarySite->rssi;
+        pParam->content.siteMgrCurrentSignal.snr = pPrimarySite->snr;
+        break;
+
+    case SITE_MGR_POWER_CONSTRAINT_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.powerConstraint = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.powerConstraint = pPrimarySite->powerConstraint;
+        break;
+
+
+    case SITE_MGR_DTIM_PERIOD_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrDtimPeriod = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.siteMgrDtimPeriod = pPrimarySite->dtimPeriod;
+        break;
+
+    case SITE_MGR_BEACON_RECV:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrBeaconRecv = FALSE;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.siteMgrBeaconRecv = pPrimarySite->beaconRecv;
+        break;
+
+
+    case SITE_MGR_BEACON_INTERVAL_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.beaconInterval = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.beaconInterval = pPrimarySite->beaconInterval;
+        break;
+
+    case SITE_MGR_AP_TX_POWER_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.APTxPower = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.APTxPower = pPrimarySite->APTxPower;
+        break;
+
+    case SITE_MGR_SITE_CAPABILITY_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrSiteCapability = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.siteMgrSiteCapability = pPrimarySite->capabilities;
+        break;
+
+    case SITE_MGR_4X_PARAM:
+        if(!pPrimarySite)
+            return NO_SITE_SELECTED_YET;
+
+        pParam->content.siteMgrFourxParam = pPrimarySite->fourXsupported;
+        break;
+
+    case SITE_MGR_CURRENT_CHANNEL_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrCurrentChannel = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.siteMgrCurrentChannel = pPrimarySite->channel;
+        break;
+
+    case SITE_MGR_CURRENT_SSID_PARAM:
+        if (!pPrimarySite)
+        {
+            os_memoryZero(pSiteMgr->hOs, (void *)pParam->content.siteMgrCurrentSSID.ssidString, MAX_SSID_LEN);
+            pParam->content.siteMgrCurrentSSID.len = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        if(pPrimarySite->ssid.len == 0)
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_getParam: ssid length is zero, while primarySite is selected \n"));
+        os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrCurrentSSID, &pPrimarySite->ssid, sizeof(ssid_t));
+        break;
+
+
+    case SITE_MGR_CURRENT_BSS_TYPE_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrCurrentBSSType = pSiteMgr->pDesiredParams->siteMgrDesiredBSSType;
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Trying to get current BSS Type while no site is selected\n"));
+            
+        }
+        else{
+            pParam->content.siteMgrCurrentBSSType = pPrimarySite->bssType;
+        }
+
+        break;
+
+
+    case SITE_MGR_CURRENT_RATE_PAIR_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrCurrentRateMask.basicRateMask = 0;
+            pParam->content.siteMgrCurrentRateMask.supportedRateMask = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.siteMgrCurrentRateMask.basicRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
+        pParam->content.siteMgrCurrentRateMask.supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                ("SITE_MGR: bitmapBasicPrimary= 0x%X,bitMapBasicDesired = 0x%X,bitMapSuppPrimary = 0x%X, bitMapSuppDesired = 0x%X\n",
+                                pPrimarySite->rateMask.basicRateMask,pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask,
+                                pPrimarySite->rateMask.supportedRateMask,pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask));
+
+        break;
+
+    case SITE_MGR_CURRENT_MODULATION_TYPE_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrCurrentModulationType = DRV_MODULATION_NONE;
+            return NO_SITE_SELECTED_YET;
+        }
+        pParam->content.siteMgrCurrentModulationType = pSiteMgr->chosenModulation;
+        break;
+
+    case SITE_MGR_NEXT_DTIM_TIME_STAMP_PARAM:
+        if (!pPrimarySite)
+        {
+            pParam->content.siteMgrNextDtimTimeStamp = 0;
+            return NO_SITE_SELECTED_YET;
+        }
+        /* Convert TBTT to msec (*1024/1000) */
+        dtimInterval = (UINT32)pPrimarySite->beaconInterval * 1024 *
+             (UINT32)pPrimarySite->dtimPeriod / 1000 ;
+        delta = os_timeStampMs(pSiteMgr->hOs) - pPrimarySite->dtimTimeStamp;
+        if(delta < dtimInterval)
+            delta = 0;
+        pParam->content.siteMgrNextDtimTimeStamp = pPrimarySite->dtimTimeStamp + dtimInterval + delta;
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                ("Get DTIM - dtimTimeStamp=%d, dtimInterval=%d, delta=%d\n",
+                        pPrimarySite->dtimTimeStamp, dtimInterval, delta));
+        break;
+
+    case SITE_MGR_DESIRED_SLOT_TIME_PARAM:
+        pParam->content.siteMgrSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+        break;
+
+    case SITE_MGR_CURRENT_SLOT_TIME_PARAM:
+
+        if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+        {
+            if(!pPrimarySite)
+                pParam->content.siteMgrSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
+            else
+                pParam->content.siteMgrSlotTime = pPrimarySite->currentSlotTime;
+        }
+        else if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+            pParam->content.siteMgrSlotTime = PHY_SLOT_TIME_SHORT;
+        else
+            pParam->content.siteMgrSlotTime = PHY_SLOT_TIME_LONG;
+
+        break;
+
+    case SITE_MGR_BSSID_LIST_PARAM:
+        if (pParam->paramLength == 0)
+        {
+
+            calculateBssidListSize(pSiteMgr, &pParam->paramLength, FALSE);
+
+            return NOK;
+        } 
+        else 
+        {
+            status = getBssidList(pSiteMgr, pParam->content.pSiteMgrBssidList, &pParam->paramLength, FALSE);
+        }
+        break;
+
+    case SITE_MGR_BSSID_FULL_LIST_PARAM:
+        if (pParam->paramLength == 0)
+        {
+
+            calculateBssidListSize(pSiteMgr, &pParam->paramLength, TRUE);
+
+            return NOK;
+        } 
+        else 
+        {
+            status = getBssidList(pSiteMgr, pParam->content.pSiteMgrBssidList, &pParam->paramLength, TRUE);
+        }
+        break;
+
+    case SITE_MGR_LAST_BEACON_BUF_PARAM:
+        if (pPrimarySite != NULL)
+        {
+            if (pPrimarySite->probeRecv)
+            {
+                pParam->content.siteMgrLastBeacon.isBeacon = FALSE;
+                pParam->content.siteMgrLastBeacon.bufLength = pPrimarySite->probeRespLength;
+                pParam->content.siteMgrLastBeacon.buffer = pPrimarySite->probeRespBuffer;
+            }
+            else
+            {
+                pParam->content.siteMgrLastBeacon.isBeacon = TRUE;
+                pParam->content.siteMgrLastBeacon.bufLength = pPrimarySite->beaconLength;
+                pParam->content.siteMgrLastBeacon.buffer = pPrimarySite->beaconBuffer;
+            }
+        }
+        break;
+
+    case SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM:
+        {
+            if ( NULL != pSiteMgr )
+            {
+                pParam->content.siteMgrDesiredBeaconFilterState = pSiteMgr->beaconFilterParams.desiredState;
+            }
+            else
+            {
+                WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG ,("pSite = NULL ! No info available"));
+            }
+        }
+        break;
+
+    case SITE_MGR_GET_SELECTED_BSSID_INFO:
+        getPrimarySiteDesc(pSiteMgr, pParam->content.pSiteMgrPrimarySiteDesc, FALSE);
+        break;
+
+    case SITE_MGR_PRIMARY_SITE_PARAM:
+       status = getPrimaryBssid(pSiteMgr, (OS_802_11_BSSID_EX *)pParam->content.pSiteMgrSelectedSiteInfo, &pParam->paramLength);
+       break;
+
+
+    case SITE_MGR_TI_WLAN_COUNTERS_PARAM:
+        pParam->paramType = RX_DATA_COUNTERS_PARAM;
+        rxData_getParam(pSiteMgr->hRxData, pParam);
+
+        whalParam.paramType = HAL_CTRL_COUNTERS_PARAM;
+        whalCtrl_GetParam(pSiteMgr->hHalCtrl, &whalParam);
+        pParam->content.siteMgrTiWlanCounters.RecvNoBuffer = whalParam.content.halCtrlCounters.RecvNoBuffer;
+        pParam->content.siteMgrTiWlanCounters.FragmentsRecv = whalParam.content.halCtrlCounters.FragmentsRecv;
+        pParam->content.siteMgrTiWlanCounters.FrameDuplicates = whalParam.content.halCtrlCounters.FrameDuplicates;
+        pParam->content.siteMgrTiWlanCounters.FcsErrors = whalParam.content.halCtrlCounters.FcsErrors;
+        pParam->content.siteMgrTiWlanCounters.RecvError = whalParam.content.halCtrlCounters.RecvError;
+
+        pParam->paramType = AUTH_COUNTERS_PARAM;
+        auth_getParam(pSiteMgr->hAuth, pParam);
+        
+        pParam->paramType = ASSOC_COUNTERS_PARAM;
+        assoc_getParam(pSiteMgr->hAssoc, pParam);        
+        pParam->content.siteMgrTiWlanCounters.BeaconsXmit = pSiteMgr->beaconSentCount;
+        break;
+    
+    case SITE_MGR_EEPROM_VERSION_PARAM:
+        os_memoryCopy(pSiteMgr->hOs, &(pParam->content.siteMgrEEpromVersion), &(pSiteMgr->pDesiredParams->siteMgrEEpromVersion), sizeof(e2Version_t));
+        break;
+
+    case SITE_MGR_FIRMWARE_VERSION_PARAM:
+        os_memoryCopy(pSiteMgr->hOs, &(pParam->content.siteMgrFwVersion), &(pSiteMgr->pDesiredParams->siteMgrFwVersion), FW_VERSION_LEN);
+        break;
+
+    case SITE_MGR_DESIRED_TX_RATE_PARAM:
+        pParam->content.siteMgrDesiredTxRate = hostToUtilityRate(pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate);
+        break;
+
+    case SITE_MGR_CURRENT_TX_RATE_PARAM:
+        /* Collect txAttr from control */
+        {   txData_attr_t txAttr;
+            
+            ctrlData_getTxAttributes(pSiteMgr->hCtrlData, TX_DATA_DATA_MSDU, &txAttr, QOS_AC_BE);
+
+            pParam->content.siteMgrCurrentTxRate = hostToUtilityRate( txAttr.Rate );
+        }
+        break;
+
+    case SITE_MGR_DESIRED_DOT11_MODE_PARAM:
+                       pParam->content.siteMgrDot11Mode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
+        break;
+
+       case SITE_MGR_NETWORK_TYPE_IN_USE:
+               if (pPrimarySite)
+               { /* Connected - return the current mode */
+                       pParam->content.siteMgrDot11Mode = pSiteMgr->siteMgrOperationalMode;
+               }
+               else
+               { /* Disconnected - return the desired mode */
+                       pParam->content.siteMgrDot11Mode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
+               }
+        break;
+
+
+    case SITE_MGR_OPERATIONAL_MODE_PARAM:
+        pParam->content.siteMgrDot11OperationalMode = pSiteMgr->siteMgrOperationalMode;
+        break;
+
+    case SITE_MGR_USE_DRAFT_NUM_PARAM:
+        pParam->content.siteMgrUseDraftNum = pSiteMgr->pDesiredParams->siteMgrUseDraftNum;
+        break;
+
+    case SITE_MGR_RADIO_BAND_PARAM:
+        pParam->content.siteMgrRadioBand = pSiteMgr->radioBand;
+        break;
+
+    case SITE_MGR_CURRENT_PREAMBLE_TYPE_PARAM:
+        if (!pPrimarySite)
+            return NO_SITE_SELECTED_YET;
+
+        pParam->content.siteMgrCurrentPreambleType = pPrimarySite->currentPreambleType;
+        break;
+
+    case SITE_MGR_CURRENT_BSSID_PARAM:
+        if (pPrimarySite != NULL)
+        {
+            os_memoryCopy(pSiteMgr->hOs, (void *)pParam->content.siteMgrDesiredBSSID.addr, (void *)pPrimarySite->bssid.addr, MAC_ADDR_LEN);
+        }
+        break;
+
+    case SITE_MGR_LAST_RX_RATE_PARAM:
+        if (pPrimarySite != NULL)
+        {
+            pParam->content.ctrlDataCurrentBasicRate = pPrimarySite->rxRate;
+        }
+        break;
+
+    case SITE_MGR_PREV_SITE_BSSID_PARAM:
+        if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
+        {
+            return NOK;
+        }
+        os_memoryCopy(pSiteMgr->hOs, (void *)pParam->content.siteMgrDesiredBSSID.addr, (void *)pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->bssid.addr, MAC_ADDR_LEN);
+        break;
+
+    case SITE_MGR_PREV_SITE_SSID_PARAM:
+        if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
+        {
+            return NOK;
+        }
+        pParam->content.siteMgrDesiredSSID.len = pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len;
+        os_memoryCopy(pSiteMgr->hOs, (void *)pParam->content.siteMgrDesiredSSID.ssidString, (void *)pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.ssidString, pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len);
+        break;
+
+    case SITE_MGR_PREV_SITE_CHANNEL_PARAM:
+        if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
+        {
+            return NOK;
+        }
+        pParam->content.siteMgrDesiredChannel = pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->channel;
+        break;
+
+    case SITE_MGR_SITE_ENTRY_BY_INDEX:
+        siteEntryIndex = pParam->content.siteMgrIndexOfDesiredSiteEntry;
+        if(siteEntryIndex >= MAX_SITES_BG_BAND)
+        {
+            return NOK;
+        }
+        pParam->content.pSiteMgrDesiredSiteEntry =
+            (UINT8*)(&(pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[siteEntryIndex]));
+        break;
+
+    case SITE_MGR_CUR_NUM_OF_SITES:
+        pParam->content.siteMgrNumberOfSites = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->numOfSites;
+        break;
+
+    case SITE_MGR_CURRENT_TSF_TIME_STAMP:
+        os_memoryCopy(pSiteMgr->hOs, pParam->content.siteMgrCurrentTsfTimeStamp,
+                      pSiteMgr->pSitesMgmtParams->pPrimarySite->tsfTimeStamp,
+                      TIME_STAMP_LEN);
+        break;
+
+    case SITE_MGR_GET_AP_QOS_CAPABILITIES:
+       if (!pPrimarySite)
+        {
+            pParam->content.qosApCapabilities.uQOSFlag = 0;
+            pParam->content.qosApCapabilities.uAPSDFlag = 0;
+            return NOT_CONNECTED;
+        }
+       pParam->content.qosApCapabilities.uQOSFlag = pPrimarySite->WMESupported;
+       pParam->content.qosApCapabilities.uAPSDFlag = pPrimarySite->APSDSupport;
+        
+        break;
+
+    default:
+        {
+            UINT8* ptr = NULL;
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Get param, Params is not supported, %d\n", pParam->paramType));
+            *ptr=3;
+        }
+
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return status;
+}
+
+
+/***********************************************************************
+ *                        calculateHwGenTxRate
+ ***********************************************************************
+DESCRIPTION: Service routine, which calculates the HW generated frames rate
+             to be used.
+
+INPUT:      basicBitMap - bit map of basic rates
+            mode        - operating mode
+
+OUTPUT:
+
+RETURN:     rate
+
+************************************************************************/
+void calculateHwGenTxRate(siteMgr_t *pSiteMgr, rate_e *rate)
+{
+
+    UINT32 rateBitMap = 0;
+    modulationType_e modulation = DRV_MODULATION_NONE; /* Not used */
+    mgmtCtrlTxRateOption_e mgmtCtrlTxRateOption = pSiteMgr->pDesiredParams->siteMgrRegstryDesiredMgmtCtrlTxRateOption;
+    UINT32 mgmtCtrlDesiredTxRateBitMap = ((0x01) << (pSiteMgr->pDesiredParams->siteMgrRegstryDesiredMgmtCtrlTxRate -1));
+
+    
+    /* ratebitmap is the matched basic rate from the STA and AP */
+    if (pSiteMgr->pSitesMgmtParams->pPrimarySite->channel == SPECIAL_BG_CHANNEL)
+    {
+        rateBitMap = (UINT16)getBasicRateMaskForSpecialBGchannel() ;
+    }
+    else
+    {
+        rateBitMap = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
+    }
+
+    /* Check if the user request specific Rate */
+    if(mgmtCtrlTxRateOption == SPECIFIC_TX_RATE)
+    {
+        /* If the required rate is included in the matched basic rate, this specific rate is the only one to use */
+        if(rateBitMap & mgmtCtrlDesiredTxRateBitMap)
+        {
+            rateBitMap = mgmtCtrlDesiredTxRateBitMap;
+        }
+        else
+        {
+            /* If the specific required Tx Rate is not in the basic rate => Use Max basic rate */
+            mgmtCtrlTxRateOption = MAX_BASIC_TX_RATE;
+        }
+    }
+
+    /* Now calculate HW Tx rate according to the rate bitmap */
+    if(mgmtCtrlTxRateOption == MAX_BASIC_TX_RATE)
+        getMaxRate(rateBitMap,rate,&modulation,pSiteMgr->siteMgrOperationalMode);
+    else
+    {
+        /* If we are here , means: The mgmtCtrlTxRateOption is either MIN_BASIC_TX_RATE or SPECIFIC_TX_RATE. */
+        getMinRate(rateBitMap,rate,&modulation,pSiteMgr->siteMgrOperationalMode);
+
+    }
+}
+
+
+
+
+/***********************************************************************
+ *                        siteMgr_join
+ ***********************************************************************
+DESCRIPTION: Called by the connection state machine in order to join a BSS.
+                -   If the BSS is infrastructure, sets a NULL data template to the HAL
+                -   If the BSS is IBSS, sets a probe response & beacon template to the HAL
+            Call the HAL with the join parameters
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            JoinCompleteCB - join command complete callback function ptr
+            CB_handle - handle to pass to callback function
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_join(TI_HANDLE    hSiteMgr)
+{
+    siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    whalCtrl_joinBss_t      joinParams;
+    whalCtrl_setTemplate_t  templateStruct;
+    probeRspTemplate_t      probeRspTemplate;
+    nullDataTemplate_t      nullDataTemplate;
+    psPollTemplate_t        psPollTemplate;
+    QosNullDataTemplate_t   QosNullDataTemplate;
+    siteEntry_t             *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    rate_e                  rate;
+    paramInfo_t             param;
+
+
+    if (pPrimarySite == NULL)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Join BSS, Primary Site is NULL\n"));
+        return OK;
+    }
+
+    /* Configure the system according to parameters of Primary Site */
+    systemConfig(pSiteMgr);
+
+    joinParams.bssType = pPrimarySite->bssType;
+    joinParams.beaconInterval = pPrimarySite->beaconInterval;
+    joinParams.dtimInterval = pPrimarySite->dtimPeriod;
+    joinParams.pBSSID = (UINT8 *)&(pPrimarySite->bssid.addr);
+    joinParams.pSSID = (UINT8 *)&(pPrimarySite->ssid.ssidString);
+    joinParams.ssidLength = pPrimarySite->ssid.len;
+
+    joinParams.channel = pPrimarySite->channel;
+
+        if (joinParams.channel == SPECIAL_BG_CHANNEL)
+    {
+         joinParams.basicRateSet     = (UINT16)getBasicRateMaskForSpecialBGchannel() ;
+         joinParams.supportedRateSet = (UINT16)getSupportedRateMaskForSpecialBGchannel() ;
+    }
+    else /* != SPECIAL_BG_CHANNEL */
+    {
+        joinParams.basicRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
+        joinParams.supportedRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
+    }
+    calculateHwGenTxRate(pSiteMgr, &rate);
+    joinParams.hwGenCtrlTxRate = rate;
+
+    param.paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;
+    ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+    joinParams.preamble = param.content.ctrlDataCurrentPreambleType;
+     /*set the preamble before the join*/
+    whalCtrl_SetPreamble(pSiteMgr->hHalCtrl, joinParams.preamble);
+    
+    
+
+/*  
+ * Set the radio band and the HW management Tx rate according to operational mode.
+ * The HW management frames includes Beacon and Probe-Response (in IBSS). 
+ */
+    if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+    {
+        joinParams.radioBand = RADIO_BAND_5_0_GHZ;
+        joinParams.hwGenMgmtTxRate = DRV_RATE_6M;           
+    }
+    else
+    {
+        joinParams.radioBand = RADIO_BAND_2_4_GHZ;
+        joinParams.hwGenMgmtTxRate = DRV_RATE_2M;           
+    }
+
+    /* Now, Set templates to the HAL */
+    if (pPrimarySite->bssType == BSS_INDEPENDENT)
+    {
+        templateStruct.pTemplate = (UINT8 *)&probeRspTemplate;
+        templateStruct.templateType = PROBE_RESPONSE_TEMPLATE;
+        buildProbeRspTemplate(pSiteMgr, &templateStruct);
+        whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
+
+        /* We don't have to build a beacon template, because it is equal to probe response,
+        we only have to change the frame sup type */
+        probeRspTemplate.hdr.fc = ENDIAN_HANDLE_WORD(DOT11_FC_BEACON);
+        templateStruct.templateType = BEACON_TEMPLATE;
+        whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
+    }
+    else
+    {
+        templateStruct.pTemplate = (UINT8 *)&nullDataTemplate;
+        templateStruct.templateType = NULL_DATA_TEMPLATE;
+        buildNullTemplate(pSiteMgr, &templateStruct);
+        whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
+
+        /* Send PsPoll template to HAL */
+        templateStruct.pTemplate = (UINT8 *)&psPollTemplate;
+        templateStruct.templateType = PS_POLL_TEMPLATE;
+        buildPsPollTemplate(pSiteMgr, &templateStruct);
+        whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
+            
+        /* Set QOS Null data template to the firmware.
+            Note:  the AC to use with this template may change in QoS-manager. */
+        templateStruct.pTemplate = (UINT8 *)&QosNullDataTemplate;
+        templateStruct.templateType = QOS_NULL_DATA_TEMPLATE;
+        buildQosNullDataTemplate(pSiteMgr, &templateStruct, 0);
+        whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
+    }
+
+    /* Reset the Tx Power Control adjustment in RegulatoryDomain */
+    siteMgr_setTemporaryTxPower(pSiteMgr, FALSE);     
+    
+    /*
+    clear the beacon receive flag to indicates when receive a beacon after the join command.
+    need for PowerMgr_startPS() - must be called only after join command and then only after
+    receiving beacon of the primary site!
+    */
+    pPrimarySite->beaconReceiveAfterJoin = FALSE;
+     
+    /* Stop Tx till geting Join Event complete */
+    txData_disableTransmission(pSiteMgr->hTxData, DISABLE_IMMEDIATELY);
+    
+    /* This is the forbidden period to enable the current state from the cli, even if desired state is TRUE */
+    /* Also This is set to FALSE since the First Beaqcin shall be received for the Power Manager */
+    pSiteMgr->beaconFilterParams.currentState = FALSE;
+    whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, FALSE, pSiteMgr->beaconFilterParams.numOfStored);
+    
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport , SITE_MGR_MODULE_LOG , ("--          Beacon Filter Active Mode  Disable Beacon Filtering !!!  --\n"));
+
+    return (TI_STATUS)whalCtrl_JoinBss (((siteMgr_t *)hSiteMgr)->hHalCtrl, &joinParams);
+}
+
+/***********************************************************************
+ *                        siteMgr_forceInfraJoin
+ ***********************************************************************
+DESCRIPTION: Called by the connection state machine in order to join a BSS.
+                -   If the BSS is infrastructure, sets a NULL data template to the HAL
+                -   If the BSS is IBSS, sets a probe response & beacon template to the HAL
+            Call the HAL with the join parameters
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            JoinCompleteCB - join command complete callback function ptr
+            CB_handle - handle to pass to callback function
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_forceInfraJoin(TI_HANDLE    hSiteMgr)
+{
+    siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    whalCtrl_joinBss_t      joinParams;
+    UINT8                   junkBSSID[MAC_ADDR_LEN] = {0xAA,0xAA,0xAA,0xAA,0xAA,0xAA};
+    UINT8                   junkSSID[1] = {0x01};
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Force INFRA Join\n"));
+
+    joinParams.bssType = BSS_INFRASTRUCTURE;
+    joinParams.beaconInterval = 200;
+    joinParams.dtimInterval = 3;
+    joinParams.pBSSID = (UINT8 *)junkBSSID;
+    joinParams.pSSID = (UINT8 *)junkSSID;
+    joinParams.ssidLength = 1;
+
+    joinParams.channel = 11;
+
+    joinParams.basicRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
+    joinParams.supportedRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
+    
+    joinParams.hwGenCtrlTxRate = DRV_RATE_2M;
+    joinParams.hwGenMgmtTxRate = DRV_RATE_2M;        
+    joinParams.preamble = PREAMBLE_LONG;
+
+    if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+        joinParams.radioBand = RADIO_BAND_5_0_GHZ;
+    else
+        joinParams.radioBand = RADIO_BAND_2_4_GHZ;
+
+    /* Stop Tx till geting Join Event complete */
+    txData_disableTransmission(pSiteMgr->hTxData, DISABLE_IMMEDIATELY);
+    return (TI_STATUS)whalCtrl_JoinBss (((siteMgr_t *)hSiteMgr)->hHalCtrl, &joinParams);
+}
+
+/***********************************************************************
+ *                        siteMgr_disJoin
+ ***********************************************************************
+DESCRIPTION: Called by the connection state machine in order to dis join a BSS.
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_disJoin(TI_HANDLE hSiteMgr)
+{
+#if 0
+    siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    whalCtrl_joinBss_t      joinParams;
+    macAddress_t            dummyMac = {0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD};
+    ssid_t                  dummySsid;
+
+    joinParams.bssType = BSS_INFRASTRUCTURE;
+    joinParams.beaconInterval = SITE_MGR_BEACON_INTERVAL_DEF;
+    joinParams.dtimInterval = 1;
+    joinParams.channel = SITE_MGR_CHANNEL_DEF;
+
+    joinParams.pBSSID = (UINT8 *)&(dummyMac.addr);
+
+    dummySsid.len = 2;
+    os_memoryCopy(pSiteMgr->hOs, dummySsid.ssidString, "TI_WLAN", 7);
+    joinParams.pSSID = (UINT8 *)&(dummySsid.ssidString);
+    joinParams.ssidLength = dummySsid.len;
+
+    joinParams.basicRateSet = buildRatesBitMap(pSiteMgr, SITE_MGR_DEF_RATE_SET_MAX_BASIC_DEF);
+    joinParams.supportedRateSet = buildRatesBitMap(pSiteMgr, SITE_MGR_DEF_RATE_SET_MAX_ACTIVE_DEF);
+
+    return whalCtrl_JoinBss (((siteMgr_t *)hSiteMgr)->hHalCtrl, &joinParams);
+#else
+    return OK;
+#endif
+}
+
+/***********************************************************************
+ *                        siteMgr_removeSelfSite
+ ***********************************************************************
+DESCRIPTION: Called by the Self connection state machine in order to remove the self site from the site table.
+                Remove the site entry form the table and reset the primary site pointer
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_removeSelfSite(TI_HANDLE  hSiteMgr)
+{
+    siteMgr_t           *pSiteMgr  = (siteMgr_t *)hSiteMgr;
+    siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+
+    if(pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+    {
+        WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Remove self site Failure, pointer is NULL\n\n"));
+        return OK;
+    }
+
+    if(pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType != SITE_SELF)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Remove self site Failure, site is not self\n\n"));
+        return OK;
+    }
+
+    removeSiteEntry(pSiteMgr, currTable, pSiteMgr->pSitesMgmtParams->pPrimarySite);
+    pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_updateSite
+ ***********************************************************************
+DESCRIPTION: Called by the MLME parser upon receiving a beacon or probe response.
+            Performs the following:
+                -   Insert the site entry into the site hash table
+                -   Update the site information in the site table
+                -   If the site is the primary site, it handles the PBCC algorithm if needed
+                -   If the site is NULL (means it is the first frame received from this site)
+                    we update the site type to be regular
+                -   If the site type is self, we inform the self connection SM
+                    that another station joined the network we created
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            bssid       -   BSSID received
+            pFrameInfo  -   Frame content after the parsing
+            rxChannel   -   The channel on which frame was received
+            band        -   Band on which frame was received
+            measuring   -   Determines whether the beacon or probe response
+                            has been received while a beacon measurement
+                            took place
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_updateSite(TI_HANDLE          hSiteMgr,
+                          macAddress_t      *bssid,
+                          mlmeFrameInfo_t   *pFrameInfo,
+                          UINT8             rxChannel,
+                          radioBand_e       band,
+                          BOOL              measuring)
+{
+    siteEntry_t *pSite;
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    paramInfo_t param;
+
+
+    /* The following is not required, since the scanCncn is responsible to check
+        the channels validity before scanning.
+        The problem it caused was that when 802.11d is enabled, 
+        channels that are valid for Passive only, will not be updated.*/
+    /*if (isChannelSupprted(pSiteMgr->hRegulatoryDomain , rxChannel) == FALSE)
+    {
+        WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+            ("Channel ERROR - try to register a site that its channel (=%d) isn't in the regulatory domain.\n\
+            registration ABORTED!!!",
+            rxChannel));
+        return NOK;
+    }*/
+
+
+    pSite = findAndInsertSiteEntry(pSiteMgr, bssid, band);
+
+
+
+    if (pSite == NULL)
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Site Update failure, table is full, bssid: %X-%X-%X-%X-%X-%X\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
+        return OK;
+    }
+
+    updateSiteInfo(pSiteMgr, pFrameInfo, pSite, rxChannel);
+
+    if (measuring != FALSE)
+    {
+        pSite->detectedWhileMeasuring = TRUE;
+    }
+
+    switch(pSite->siteType)
+    {
+    case SITE_PRIMARY:
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("PRIMARY site updated, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
+        if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+        {
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_updateSite: Primary Site Is NULL\n"));
+            pSite->siteType = SITE_REGULAR;
+            break;
+        }
+        /* Now, if the following is TRUE we perform the PBCC algorithm: */
+        /* If the BSS type is infrastructure, &&
+            The chosen modulation is PBCC &&
+            The beacon modulation is not NONE &&
+            The current data modulation is different than the beacon modulation. */
+        if ((pSite->bssType == BSS_INFRASTRUCTURE) &&
+            (pSiteMgr->chosenModulation == DRV_MODULATION_PBCC) &&
+            (pSite->beaconModulation != DRV_MODULATION_NONE) &&
+            (pSiteMgr->currentDataModulation != pSite->beaconModulation))
+        {
+            pSiteMgr->currentDataModulation = pSite->beaconModulation;
+            pbccAlgorithm(pSiteMgr);
+        }
+
+        /* Now handle the slot time, first check if the slot time changed since the last
+           setting to the HAL ,and if yes set the new value */
+        if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
+           (pSite->bssType == BSS_INFRASTRUCTURE))
+        {
+            if (pSite->currentSlotTime != pSite->newSlotTime)
+            {
+                pSite->currentSlotTime = pSite->newSlotTime;
+                whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, pSite->currentSlotTime);
+            }
+        }
+
+        /* Now handle the current protection status */
+        if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
+           (pSite->bssType == BSS_INFRASTRUCTURE))
+        {
+            param.paramType = CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM;
+            param.content.ctrlDataProtectionEnabled = pSite->useProtection;
+            ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+        }
+
+        /* Now handle the current preamble type,
+           if desired preamble type is long, the ctrl data param should not be changed */
+        if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
+           (pSite->bssType == BSS_INFRASTRUCTURE) &&
+           (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType != PREAMBLE_LONG))
+        {
+            param.paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;
+            if((pSite->preambleAssRspCap == PREAMBLE_LONG) ||
+               (pSite->barkerPreambleType == PREAMBLE_LONG))
+                  {
+                param.content.ctrlDataCurrentPreambleType = PREAMBLE_LONG;
+            }
+            else
+                param.content.ctrlDataCurrentPreambleType = PREAMBLE_SHORT;
+
+            ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+             
+        }
+
+        /*
+         * NOTE: THIS MUST BE AFTER SETTING PREAMBLE TYPE 
+         */
+        if (pSiteMgr->chosenModulation != DRV_MODULATION_PBCC)
+        {            
+            if (pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate == DRV_RATE_AUTO)
+            {
+                param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
+                param.content.ctrlDataRateControlEnable = TRUE;
+                ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+            }
+            else
+            {
+                param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
+                param.content.ctrlDataRateControlEnable = FALSE;
+                ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+            }
+
+        }
+            break;
+
+    case SITE_NULL:
+        pSite->siteType = SITE_REGULAR;
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("REGULAR site added, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
+        break;
+
+    case SITE_SELF:
+        pSite->siteType = SITE_PRIMARY;
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SELF ----> PRIMARY site , bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
+        conn_ibssStaJoined(pSiteMgr->hConn);
+        break;
+
+    case SITE_REGULAR:
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("REGULAR site updated, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
+        break;
+
+    default:
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Setting site type failure, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
+        break;
+    }
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_start
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM in order to start the aging timer
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_start(TI_HANDLE   hSiteMgr)
+{
+    siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    /* update timestamp each time aging started (needed for quiet scan) */
+    if(pSiteMgr->pSitesMgmtParams->pPrimarySite)
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs);
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        siteMgr_stop
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM in order to stop site mgr timers
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_stop(TI_HANDLE    hSiteMgr)
+{
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_CheckRxSignalValidity
+ ***********************************************************************
+DESCRIPTION: Called by the mlme_parserRecv when receiving managment frame 
+                Find the ste in the site table and validate that the 
+                RSSI of that site signal is not lower then -80DB + not lower
+                then the exising site RSSI
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            rxLevel     -   Rx level the frame received in
+            bssid       -   BSSID of the frame
+
+OUTPUT:
+
+RETURN:     OK / NOK
+
+************************************************************************/
+TI_STATUS siteMgr_CheckRxSignalValidity(TI_HANDLE  hSiteMgr,
+                         INT8               rxLevel,
+                         UINT8              channel,
+                         macAddress_t       *bssid)
+{
+    siteEntry_t *pSite;
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    pSite = NULL;
+    pSite = findSiteEntry(pSiteMgr, bssid);
+
+    if (pSite != NULL)
+    {
+        if ((channel != pSite->channel) &&
+            (rxLevel < pSite->rssi))
+        {   /* Ignore wrong packets with lower RSSI that were detect as
+            ripples from different channels */
+            WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                              ("siteMgr_CheckRxSignalValidity:Rx RSSI =%d, on channel=%d, is lower then given RSSI =%d on channel=%d, dropping it.\n", 
+                               rxLevel,  channel, pSite->rssi, pSite->channel));
+            return NOK;
+        }
+    }
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_updateRxSignal
+ ***********************************************************************
+DESCRIPTION: Called by the Rx data when receiving a frae in the RX
+                Find the ste in the site table and updates the SNR and RSSI
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            snr         -   SNR the frame received in
+            rxLevel     -   Rx level the frame received in
+            bssid       -   BSSID of the frame
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_updateRxSignal(TI_HANDLE  hSiteMgr,
+                         UINT8              snr,
+                         INT8               rxLevel,
+                         rate_e             rate,
+                         macAddress_t       *bssid,
+                         BOOL               dataMsdu)
+{
+    siteEntry_t *pSite;
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    pSite = findSiteEntry(pSiteMgr, bssid);
+
+    if (pSite != NULL)
+    {
+        pSite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs);
+
+        pSite->snr = snr;
+
+    /* We check the rate just for finding error case */
+    switch(rate)
+        {
+        case DRV_RATE_1M:
+        case DRV_RATE_2M:
+        case DRV_RATE_5_5M:
+        case DRV_RATE_11M:
+        case DRV_RATE_22M:
+        case DRV_RATE_6M:
+        case DRV_RATE_9M:
+        case DRV_RATE_12M:
+        case DRV_RATE_18M:
+        case DRV_RATE_24M:
+        case DRV_RATE_36M:
+        case DRV_RATE_48M:
+        case DRV_RATE_54M:
+            pSite->rxRate = rate;
+            break;
+        default:
+            pSite->rxRate = (rate_e)0;
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                ("siteMgr_updateRxSignal:Rx Rate is GARBAGE!\nRx Rate = %d\n", rate));
+            break;
+        }
+        /* Is this is not a primary site, update rssi;
+           For the Primary site, we store average RSSI that is counted and updated from Current BSS module */
+        if (pSite->siteType != SITE_PRIMARY)
+        {
+            pSite->rssi = (INT8)rxLevel;
+        }
+    }
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        siteMgr_updatePrimarySiteFailStatus
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM when the connection with the primary site fails
+                If the primary site is NULL, return.
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+            bRemoveSite -   Whether to remove the site
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_updatePrimarySiteFailStatus(TI_HANDLE hSiteMgr,
+                                           BOOL bRemoveSite)
+{
+    siteMgr_t           *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+
+    if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+        return OK;
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+    (" SITE MGR: bRemoveSite = %d \n", bRemoveSite));
+
+    if (bRemoveSite) 
+    {
+        removeSiteEntry(pSiteMgr, currTable, pSiteMgr->pSitesMgmtParams->pPrimarySite);
+        pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
+    }
+    else       /* Currently never used */
+    {
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->failStatus = STATUS_UNSPECIFIED;
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->attemptsNumber++;
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->attemptsNumber &= 0x0F;
+    }
+
+    return OK;
+}
+
+
+
+/***********************************************************************
+ *          siteMgr_resetEventStatisticsHistory
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM when successing in establishing a connection with the primary site
+                If thr primary site is NULL, return.
+                Otherwise, reset the site rssi level
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_resetEventStatisticsHistory(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_resetPrimarySiteRssiPerLevelBeaconMissed: Primary Site Is NULL\n"));
+        return OK;
+    }
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        siteMgr_resetPrimarySiteAttemptsNumber
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM when successing in establishing a connection with the primary site
+                If thr primary site is NULL, return.
+                Otherwise, reset the site attemptsNumber counter.
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_resetPrimarySiteAttemptsNumber(TI_HANDLE  hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_resetPrimarySiteAttemptsNumber: Primary Site Is NULL\n"));
+        return OK;
+    }
+    pSiteMgr->pSitesMgmtParams->pPrimarySite->attemptsNumber = 0;
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_resetPrevPrimarySiteRssi
+ ***********************************************************************
+DESCRIPTION: Called by the SME SM when successing in establishing a connection with the primary site
+                If thr primary site is NULL, return.
+                Otherwise, reset the site attemptsNumber counter.
+
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS siteMgr_resetPrevPrimarySiteRssi(TI_HANDLE    hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite == NULL)
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                ("Previous Primary Site Is NULL\n"));
+        return OK;
+    }
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                            ("Resetting previous primary site RSSI\n"));
+    /*
+    pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->rssi = 0;
+    pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->attemptsNumber = 0;
+    */
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_isCurrentBand24
+ ***********************************************************************
+DESCRIPTION: The function checks the current operational mode and
+                returns if the current band is 2.4Ghz or 5Ghz.
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     TRUE if current band is 2.4Ghz, FALSE otherwise.
+
+************************************************************************/
+BOOL siteMgr_isCurrentBand24(TI_HANDLE  hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr =     (siteMgr_t *)hSiteMgr;
+
+    if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+        return FALSE;
+
+    return TRUE; /* 802.11b supports onlty 2.4G band */
+
+}
+
+
+/***********************************************************************
+ *                        siteMgr_isThereValidSSID
+ ***********************************************************************
+DESCRIPTION: checks if a valid SSID exists
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     TRUE if valid SSID found, FALSE if not
+
+************************************************************************/
+BOOL siteMgr_isThereValidSSID (TI_HANDLE hSiteMgr)
+{
+   paramInfo_t param;
+
+   param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+   siteMgr_getParam(hSiteMgr,&param);
+
+    if((utils_isAnySSID(&param.content.siteMgrDesiredSSID)) || (utils_isJunkSSID(&param.content.siteMgrDesiredSSID)))
+      return (FALSE);
+    else
+       return (TRUE);
+}
+
+/***********************************************************************
+ *                        removeEldestSite
+ ***********************************************************************
+DESCRIPTION: Called by the select when trying to create an IBSS and site table is full
+                Remove the eldest site from the table
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS removeEldestSite(siteMgr_t *pSiteMgr)
+{
+    int             i;
+    siteEntry_t     *pEldestSite = NULL, *pSiteTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable;
+    siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+    UINT32          currentTimsStamp = os_timeStampMs(pSiteMgr->hOs);
+    UINT32          biggestGap = 0;
+
+    for (i = 0; i < currTable->maxNumOfSites; i++)
+    {
+        if (biggestGap < ((UINT32)(currentTimsStamp - pSiteTable[i].localTimeStamp)))
+        {
+            biggestGap = ((UINT32)(currentTimsStamp - pSiteTable[i].localTimeStamp));
+            pEldestSite = &(pSiteTable[i]);
+        }
+    }
+
+    removeSiteEntry(pSiteMgr, currTable, pEldestSite);
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        update_apsd
+ ***********************************************************************
+DESCRIPTION:    Sets the site APSD support flag according to the
+                beacon's capabilities vector and the WME-params IE if exists.
+
+INPUT:      pSite       -   Pointer to the site entry in the site table
+            pFrameInfo  -   Frame information after the parsing
+            
+OUTPUT:     pSite->APSDSupport flag
+
+RETURN:     
+
+************************************************************************/
+static void update_apsd(siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
+{
+    /* If WME-Params IE is not included in the beacon, set the APSD-Support flag
+         only by the beacons capabilities bit map. */
+    if (pFrameInfo->content.iePacket.WMEParams == NULL)
+        pSite->APSDSupport = (((pFrameInfo->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TRUE : FALSE);
+
+    /* Else, set the APSD-Support flag if either the capabilities APSD bit or the 
+         WME-Params APSD bit indicate so. */
+    else
+        pSite->APSDSupport = ((((pFrameInfo->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TRUE : FALSE) ||
+        (((pFrameInfo->content.iePacket.WMEParams->ACInfoField >> AP_QOS_INFO_UAPSD_SHIFT) & AP_QOS_INFO_UAPSD_MASK) ? TRUE : FALSE));
+}
+
+
+/***********************************************************************
+ *                        release_module
+ ***********************************************************************
+DESCRIPTION:    Called by the un load function
+                Go over the vector, for each bit that is set, release the corresponding module.
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            initVec -   Vector that contains a bit set for each module thah had been initiualized
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void release_module(siteMgr_t *pSiteMgr, UINT32 initVec)
+{
+    if (initVec & (1 << MGMT_PARAMS_INIT_BIT))
+        utils_nullMemoryFree(pSiteMgr->hOs, pSiteMgr->pSitesMgmtParams, sizeof(sitesMgmtParams_t));
+
+    if (initVec & (1 << DESIRED_PARAMS_INIT_BIT))
+        utils_nullMemoryFree(pSiteMgr->hOs, pSiteMgr->pDesiredParams, sizeof(siteMgrInitParams_t));
+
+    if (initVec & (1 << SITE_MGR_INIT_BIT))
+        utils_nullMemoryFree(pSiteMgr->hOs, pSiteMgr, sizeof(siteMgr_t));
+
+    initVec = 0;
+}
+
+
+/***********************************************************************
+ *                        updateSiteInfo
+ ***********************************************************************
+DESCRIPTION:    Called upon receiving a beacon or probe response
+                Go over the vector, for each bit that is set, release the corresponding module.
+                Update theaite entry in the site table with the information received in the frame
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            pFrameInfo  -   Frame information after the parsing
+            pSite       -   Pointer to the site entry in the site table
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void updateSiteInfo(siteMgr_t *pSiteMgr, mlmeFrameInfo_t *pFrameInfo, siteEntry_t    *pSite, UINT8 rxChannel)
+{
+    paramInfo_t param;
+    BOOL        ssidUpdated;
+
+
+    SET_ENTRY_FLAG_IN_SITE_TABLE(pSite);
+    ssidUpdated = FALSE;
+
+    switch (pFrameInfo->subType)
+    {
+    case BEACON:
+
+        UPDATE_BEACON_INTERVAL(pSite, pFrameInfo);
+        
+        UPDATE_CAPABILITIES(pSite, pFrameInfo);
+        
+            if (utils_isIESSID_Broadcast(pFrameInfo->content.iePacket.pSsid) == FALSE)
+            {   /* And the SSID is not Broadcast */
+                ssidUpdated = TRUE;
+                UPDATE_SSID(pSite, pFrameInfo);
+            }
+
+        if (ssidUpdated)
+        {
+
+            UPDATE_PRIVACY(pSite, pFrameInfo);
+        }
+
+        update_apsd(pSite, pFrameInfo);
+
+        updatePreamble(pSiteMgr, pSite, pFrameInfo);
+
+        UPDATE_AGILITY(pSite, pFrameInfo);
+
+
+        if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+        {
+            UPDATE_SLOT_TIME(pSite, pFrameInfo);
+            UPDATE_PROTECTION(pSite, pFrameInfo);
+        }
+
+        updateRates(pSiteMgr, pSite, pFrameInfo);
+
+        if ((pFrameInfo->content.iePacket.pDSParamsSet != NULL)  &&
+            (pFrameInfo->content.iePacket.pDSParamsSet->currChannel!=rxChannel))
+        {
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, 
+                           ("updateSiteInfo, wrong CHANNELS:rxChannel=%d,currChannel=%d\n",
+                            rxChannel, pFrameInfo->content.iePacket.pDSParamsSet->currChannel));
+        }
+        else
+            UPDATE_CHANNEL(pSite, pFrameInfo , rxChannel);
+
+
+        UPDATE_BSS_TYPE(pSite, pFrameInfo);
+
+        if (pSite->bssType == BSS_INFRASTRUCTURE)
+            UPDATE_DTIM_PERIOD(pSite, pFrameInfo);
+
+        UPDATE_ATIM_WINDOW(pSite, pFrameInfo);
+
+        UPDATE_BEACON_AP_TX_POWER(pSite, pFrameInfo);
+
+        /* Updating QoS params */
+        updateBeaconQosParams(pSiteMgr, pSite, pFrameInfo);
+
+
+        /* updating CountryIE  */
+        if ((pFrameInfo->content.iePacket.country  != NULL) && 
+            (pFrameInfo->content.iePacket.country->hdr.eleLen != 0))
+        {
+            /* set the country info in the regulatory domain - If a different code was detected earlier
+               the regDomain will ignore it */
+            param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
+            param.content.pCountry = (country_t *)pFrameInfo->content.iePacket.country;
+            regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
+        }
+
+        /* Checking if this beacon is a DTIM i.e. DTIM count is zero */
+        if( (pFrameInfo->content.iePacket.pTIM != NULL) && (pFrameInfo->content.iePacket.pTIM->dtimCount == 0))
+        {
+            /* Update the DTIM beacon time */
+            UPDATE_DTIM_TIME(pSiteMgr, pSite, pFrameInfo);
+        }
+
+        UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo);
+
+        UPDATE_BEACON_MODULATION(pSite, pFrameInfo);
+
+        /* If the BSS type is independent, the beacon & probe modulation are equal,
+            It is important to update this field here for dynamic PBCC algorithm compatibility */
+        if (pSite->bssType == BSS_INDEPENDENT)
+            UPDATE_PROBE_MODULATION(pSite, pFrameInfo);
+
+
+        if (pSite->siteType == SITE_PRIMARY)
+        {
+           
+            if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+            {
+                WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("updateSiteInfo: Primary Site Is NULL\n"));
+                pSite->siteType = SITE_REGULAR;
+            }
+            else
+            {
+                /*  If the site that we got the beacon on is the primary site - which means we are either trying */
+                /*  to connect to it or we are already connected - send the EVENT_GOT_BEACON to the conn module (through the SME module) */
+                /*  so the conn module will be aware of the beacon status of the site it's trying to connect to */
+                
+#ifdef EXC_MODULE_INCLUDED
+                UINT8 ExternTxPower;
+
+                if (pFrameInfo->content.iePacket.cellTP != NULL)
+                {
+                    ExternTxPower = pFrameInfo->content.iePacket.cellTP->power;
+                }
+                else   /* Set to maximum possible. Note that we add +1 so that Dbm = 26 and not 25 */
+                {
+                    ExternTxPower = MAX_TX_POWER / DBM_TO_TX_POWER_FACTOR + 1;
+                }
+
+                param.paramType = REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED;
+                param.content.ExternTxPowerPreferred = ExternTxPower;
+                regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain, &param);
+#endif
+
+                               /* Updating the Tx Power according to the received Power Constraint  */
+                               if(pFrameInfo->content.iePacket.powerConstraint  != NULL)
+                               {   /* Checking if the recieved constraint is different from the one that is already known  */
+                                       if( pFrameInfo->content.iePacket.powerConstraint->powerConstraint != pSite->powerConstraint)
+                                       {   /* check if Spectrum Management is enabled */
+                                               param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
+                                               regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
+                                               if(param.content.spectrumManagementEnabled)
+                                               {   /* setting power constraint */
+                                                       pSite->powerConstraint = pFrameInfo->content.iePacket.powerConstraint->powerConstraint;
+                                                       param.paramType = REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM;
+                                                       param.content.powerConstraint = pSite->powerConstraint;
+                                                       regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
+
+                                               }
+                                       }
+                               }
+
+                if (pSite->beaconReceiveAfterJoin == FALSE)
+                {
+                    /*
+                    use for indicate to that it safe to call to PowerMgr_startPS() that can be call only
+                    after join command followed by beacon receive later.
+                    every join command the beaconReceiveAfterJoin flag is cleared therefor it will
+                    be true after the join command.
+
+                    the right follow is: join --> receive primary site beacon --> PowerMgr_startPS().
+
+                    Note: the beaconReceiveAfterJoin flag is in use for the SME path!
+                    */
+                    siteMgr_gotFirstBcn(pSiteMgr);
+                    /* set Hw not available now that the first beacon arrived */
+                    MacServices_powerAutho_AwakeRequiredUpdate(pSiteMgr->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_FIRST_BEACON);
+
+                    pSite->beaconReceiveAfterJoin = TRUE;
+
+                    WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
+                                            SITE_MGR_MODULE_LOG,
+                                            ("1st beacon after join command RECEIVED!!!\n"));
+        }
+
+            }
+        }
+
+        UPDATE_BEACON_RECV(pSite);
+        
+        if (ssidUpdated)
+        {
+            dot11_RSN_t *pRsnIe = pFrameInfo->content.iePacket.pRsnIe;
+            UINT8       rsnIeLen = pFrameInfo->content.iePacket.rsnIeLen;
+            UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen);
+        }
+
+
+        UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo);
+
+        break;
+
+
+    case PROBE_RESPONSE:
+
+        UPDATE_BEACON_INTERVAL(pSite, pFrameInfo);
+
+        UPDATE_CAPABILITIES(pSite, pFrameInfo);
+
+                ssidUpdated = TRUE;
+        if (pSite->siteType == SITE_PRIMARY)
+        {   /* Primary SITE */
+            if ((pFrameInfo->content.iePacket.pSsid != NULL) && 
+                (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len>0))
+            {   /* There's a desired SSID*/
+                if (os_memoryCompare(pSiteMgr->hOs, (UINT8*)(pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString), 
+                                     (UINT8*)(pFrameInfo->content.iePacket.pSsid->serviceSetId), pFrameInfo->content.iePacket.pSsid->hdr.eleLen)!=0)
+                {   /* Do not overwrite the primary site's SSID with a different than the desired SSID*/
+                    ssidUpdated = FALSE;
+                }
+                
+            }
+            else if (pFrameInfo->content.iePacket.pSsid == NULL)
+            {
+                WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                  ("updateSiteInfo PROBE_RESP, pSsid=NULL\n"));
+            }
+        }
+
+        if (ssidUpdated)
+        {
+            UPDATE_SSID(pSite, pFrameInfo);
+            UPDATE_PRIVACY(pSite, pFrameInfo);
+        }
+
+        update_apsd(pSite, pFrameInfo);
+
+
+        if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
+        {
+            UPDATE_PROTECTION(pSite, pFrameInfo);
+        }
+
+        updateFourX(pSiteMgr, pSite, pFrameInfo);
+
+        updatePreamble(pSiteMgr, pSite, pFrameInfo);
+
+        UPDATE_AGILITY(pSite, pFrameInfo);
+
+        updateRates(pSiteMgr, pSite, pFrameInfo);
+
+        if ((pFrameInfo->content.iePacket.pDSParamsSet != NULL)  &&
+            (pFrameInfo->content.iePacket.pDSParamsSet->currChannel!=rxChannel))
+        {
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, 
+                           ("updateSiteInfo, wrong CHANNELS:rxChannel=%d,currChannel=%d\n",
+                            rxChannel, pFrameInfo->content.iePacket.pDSParamsSet->currChannel));
+        }
+        else
+            UPDATE_CHANNEL(pSite, pFrameInfo, rxChannel);
+
+
+        UPDATE_BSS_TYPE(pSite, pFrameInfo);
+
+        UPDATE_ATIM_WINDOW(pSite, pFrameInfo);
+
+        UPDATE_PROBE_AP_TX_POWER(pSite, pFrameInfo);
+
+        /* Updating WME params */
+        updateProbeQosParams(pSiteMgr, pSite, pFrameInfo);
+
+
+        /* updating CountryIE  */
+        if ((pFrameInfo->content.iePacket.country  != NULL) && 
+            (pFrameInfo->content.iePacket.country->hdr.eleLen != 0))
+        {
+            /* set the country info in the regulatory domain - If a different code was detected earlier
+               the regDomain will ignore it */
+            param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
+            param.content.pCountry = (country_t *)pFrameInfo->content.iePacket.country;
+            regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
+        }
+
+        UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo);
+
+        UPDATE_PROBE_MODULATION(pSite, pFrameInfo);
+
+        /* If the BSS type is independent, the beacon & probe modulation are equal,
+            It is important to update this field here for dynamic PBCC algorithm compatibility */
+        if (pSite->bssType == BSS_INDEPENDENT)
+            UPDATE_BEACON_MODULATION(pSite, pFrameInfo);
+
+        UPDATE_PROBE_RECV(pSite);
+
+        if (ssidUpdated)
+        {
+            dot11_RSN_t *pRsnIe = pFrameInfo->content.iePacket.pRsnIe;
+            UINT8       rsnIeLen = pFrameInfo->content.iePacket.rsnIeLen;
+            UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen);
+
+        }
+
+        UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo);
+
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Site Update failure, un known frame sub type %d\n\n", pFrameInfo->subType));
+        break;
+    }
+}
+
+
+/***********************************************************************
+ *                        updateFourX
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'updateSiteInfo()'
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            pFrameInfo  -   Frame information after the parsing
+            pSite       -   Pointer to the site entry in the site table
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+static void updateFourX(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
+{
+    UINT8 ti_oui[] = TI_OUI;
+
+    /* It is done to overcome interop issues. We don't send AssocReq with 4x IE
+       if ProbeReq without 4x IE was received previously */
+    if (pFrameInfo->content.iePacket.fourXParams != NULL)
+    {
+        os_memoryCopy(pSiteMgr->hOs, &pSite->fourXParams, pFrameInfo->content.iePacket.fourXParams, pFrameInfo->content.iePacket.fourXParams->hdr.eleLen+sizeof( dot11_eleHdr_t));
+
+        if( (pSite->fourXParams.hdr.eleId != DOT11_4X_ELE_ID) ||
+            (pSite->fourXParams.hdr.eleLen > DOT11_4X_MAX_LEN) ||
+            (os_memoryCompare(pSiteMgr->hOs ,ti_oui, (PUINT8)pSite->fourXParams.fourXCapabilities, DOT11_OUI_LEN) != 0) )
+        {
+            pSite->fourXsupported = FALSE;
+        }
+    }
+    else
+        pSite->fourXsupported = FALSE;
+}
+
+/***********************************************************************
+ *                        updatePreamble
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'updateSiteInfo()'
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            pFrameInfo  -   Frame information after the parsing
+            pSite       -   Pointer to the site entry in the site table
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+static void updatePreamble(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
+{
+    pSite->currentPreambleType = ((pFrameInfo->content.iePacket.capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK) ? PREAMBLE_SHORT : PREAMBLE_LONG;
+
+    pSite->barkerPreambleType = pFrameInfo->content.iePacket.barkerPreambleMode;
+}
+
+/***********************************************************************
+ *                        updateBeaconQosParams
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'updateSiteInfo()'
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            pFrameInfo  -   Frame information after the parsing
+            pSite       -   Pointer to the site entry in the site table
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+
+static void updateBeaconQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
+{
+    /* Updating WME params */
+    if (pFrameInfo->content.iePacket.WMEParams  != NULL)
+    {
+        /* Checking if this is IE includes new WME Parameters */
+        if(( ((pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK ) != pSite->lastWMEParameterCnt) ||
+            (!pSite->WMESupported) )
+        {
+            pSite->WMESupported = TRUE;
+
+            /* Checking if this IE is information only or is a paremeters IE */
+            if(pFrameInfo->content.iePacket.WMEParams->OUISubType == dot11_WME_OUI_SUB_TYPE_PARAMS_IE)
+            {
+                if(pSite->siteType == SITE_PRIMARY)
+                {
+                    qosMngr_updateIEinfo(pSiteMgr->hQosMngr,(UINT8 *)(pFrameInfo->content.iePacket.WMEParams),WME);
+                }
+                /* updating the WME paraeters into the site table. */
+                os_memoryCopy(pSiteMgr->hOs, &pSite->WMEParameters, &(pFrameInfo->content.iePacket.WMEParams->WME_ACParameteres), sizeof( ACParameters_t));
+                pSite->lastWMEParameterCnt = (pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK;
+                WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("$$$$$$ WME parameters were updates according to beacon, cntSeq = %d\n",pSite->lastWMEParameterCnt));
+            }
+        }
+    }else
+    {
+        pSite->WMESupported = FALSE;
+        }
+
+}
+
+/***********************************************************************
+ *                        updateProbeQosParams
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'updateSiteInfo()'
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            pFrameInfo  -   Frame information after the parsing
+            pSite       -   Pointer to the site entry in the site table
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+static void updateProbeQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
+{
+    /* Updating WME params */
+    if (pFrameInfo->content.iePacket.WMEParams  != NULL)
+    {
+        /* Checking if this is IE includes new WME Parameters */
+        if(( ((pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK ) != pSite->lastWMEParameterCnt) ||
+            (!pSite->WMESupported) )
+        {
+            pSite->WMESupported = TRUE;
+
+            /* Checking if this IE is information only or is a paremeters IE */
+            if(pFrameInfo->content.iePacket.WMEParams->OUISubType == dot11_WME_OUI_SUB_TYPE_PARAMS_IE)
+            {
+                if(pSite->siteType == SITE_PRIMARY)
+                {
+                    qosMngr_updateIEinfo(pSiteMgr->hQosMngr,(UINT8 *)(pFrameInfo->content.iePacket.WMEParams),WME);
+                }
+                /* updating the WME paraeters into the site table. */
+                os_memoryCopy(pSiteMgr->hOs, &pSite->WMEParameters, &(pFrameInfo->content.iePacket.WMEParams->WME_ACParameteres), sizeof( ACParameters_t));
+                pSite->lastWMEParameterCnt = (pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK;
+                WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("$$$$$$ WME parameters were updates according to  probe response, cntSeq = %d\n",pSite->lastWMEParameterCnt));
+            }
+        }
+    }else
+    {
+        pSite->WMESupported = FALSE;
+        }
+
+}
+
+/***********************************************************************
+ *                        updateRates
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'updateSiteInfo()' in order to translate the rates received
+                in the beacon or probe response to rate used by the driver. Perfoms the following:
+                    -   Check the rates. validity. If rates are invalid, return
+                    -   Get the max active rate & max basic rate, if invalid, return
+                    -   Translate the max active rate and max basic rate from network rates to host rates.
+                        The max active & max basic rate are used by the driver from now on in all the processes:
+                        (selection, join, transmission, etc....)
+
+INPUT:      pSiteMgr    -   site mgr handle.
+            pFrameInfo  -   Frame information after the parsing
+            pSite       -   Pointer to the site entry in the site table
+
+OUTPUT:
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void updateRates(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
+{
+    UINT8   maxBasicRate = 0, maxActiveRate = 0;
+    UINT32  bitMapExtSupp = 0;
+    paramInfo_t param;
+
+    if (pFrameInfo->content.iePacket.pRates == NULL)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("updateRates, pRates=NULL, beacon & probeResp are: \n"));
+        WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, 
+                          (UINT8*)pFrameInfo->content.iePacket.pRates, pFrameInfo->content.iePacket.pRates->hdr.eleLen+2);
+        WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, 
+                          (UINT8*)pFrameInfo->content.iePacket.pRates, pFrameInfo->content.iePacket.pRates->hdr.eleLen+2);
+        return;
+    }
+
+    /* Update the rate elements */
+    maxBasicRate = getMaxBasicRatefromString((UINT8 *)pFrameInfo->content.iePacket.pRates->rates,pFrameInfo->content.iePacket.pRates->hdr.eleLen, maxBasicRate);
+    maxActiveRate = getMaxActiveRatefromString((UINT8 *)pFrameInfo->content.iePacket.pRates->rates,pFrameInfo->content.iePacket.pRates->hdr.eleLen, maxActiveRate);
+    
+    if(pFrameInfo->content.iePacket.pExtRates)
+    {
+        maxBasicRate = getMaxBasicRatefromString((UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,pFrameInfo->content.iePacket.pExtRates->hdr.eleLen, maxBasicRate);
+        maxActiveRate = getMaxActiveRatefromString((UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,pFrameInfo->content.iePacket.pExtRates->hdr.eleLen, maxActiveRate);
+    }
+
+
+    /*WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("1- maxBasicRate = 0x%X, maxActiveRate = 0x%X \n", maxBasicRate,maxActiveRate));*/
+
+    if (maxActiveRate == 0)
+        maxActiveRate = maxBasicRate;
+
+    /* Now update it from network to host rates */
+    pSite->maxBasicRate = networkToHostRate(maxBasicRate);
+
+    pSite->maxActiveRate = networkToHostRate(maxActiveRate);
+    if (pSite->maxActiveRate == DRV_RATE_INVALID)
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Network To Host Rate failure, no active network rate\n"));
+
+    if (pSite->maxBasicRate != DRV_RATE_INVALID)
+    {
+        if (pSite->maxActiveRate != DRV_RATE_INVALID)
+        {
+            pSite->maxActiveRate = MAX(pSite->maxActiveRate,pSite->maxBasicRate);
+        }
+    } else { /* in case some vendors don't specify basic rates */
+        WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Network To Host Rate failure, no basic network rate"));
+        pSite->maxBasicRate = pSite->maxActiveRate;
+    }
+
+    /* build rates bit map */
+    networkStringToBitMapSuppRates((UINT32 *)&pSite->rateMask.supportedRateMask,
+                                   (UINT8 *)pFrameInfo->content.iePacket.pRates->rates,
+                                   pFrameInfo->content.iePacket.pRates->hdr.eleLen);
+    networkStringToBitMapBasicRates((UINT32 *)&pSite->rateMask.basicRateMask,
+                                    (UINT8 *)pFrameInfo->content.iePacket.pRates->rates,
+                                    pFrameInfo->content.iePacket.pRates->hdr.eleLen);
+
+    if(pFrameInfo->content.iePacket.pExtRates)
+    {
+        networkStringToBitMapSuppRates(&bitMapExtSupp, (UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,
+                                       pFrameInfo->content.iePacket.pExtRates->hdr.eleLen);
+
+        pSite->rateMask.supportedRateMask |= bitMapExtSupp;
+
+        networkStringToBitMapBasicRates(&bitMapExtSupp, (UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,
+                                        pFrameInfo->content.iePacket.pExtRates->hdr.eleLen);
+
+        pSite->rateMask.basicRateMask |= bitMapExtSupp;
+    }
+    
+    
+    param.paramType = CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM;
+    param.content.ctrlDataCurrentRateMask = pSite->rateMask.supportedRateMask;
+    /* clear the 22Mbps bit in case the PBCC is not allowed */
+    if(pSiteMgr->currentDataModulation != DRV_MODULATION_PBCC && pSiteMgr->currentDataModulation != DRV_MODULATION_OFDM)
+    {
+      param.content.ctrlDataCurrentRateMask &= ~DRV_RATE_MASK_22_PBCC;
+    }
+    ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+    param.paramType = CTRL_DATA_CURRENT_BASIC_RATE_MASK_PARAM;
+    param.content.ctrlDataBasicRateBitMask = pSite->rateMask.basicRateMask;
+    ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+
+    /*WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("2- pSite->maxActiveRate = 0x%X, pSite->maxBasicRate = 0x%X \n", pSite->maxActiveRate,pSite->maxBasicRate));*/
+
+}
+
+/***********************************************************************
+ *                        getBssidList
+ ***********************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to get the BSSID list from the site table
+
+INPUT:      pSiteMgr    -   site mgr handle.
+
+OUTPUT:     bssidList   -   BSSID list pointer
+
+RETURN:
+
+************************************************************************/
+static TI_STATUS getBssidList(siteMgr_t *pSiteMgr, OS_802_11_BSSID_LIST_EX *bssidList, UINT32 *pLength, BOOL allVarIes)
+{
+    UINT8                   siteTableIndex, tableIndex, i, index, rsnIeLength;
+    siteEntry_t             *pSiteEntry;
+    OS_802_11_BSSID_EX      *pBssid;
+    OS_802_11_FIXED_IEs     *pFixedIes;
+    OS_802_11_VARIABLE_IEs  *pVarIes;
+    
+    UINT32                  length;
+    UINT8                   *pData;
+    UINT32                  len, firstOFDMloc = 0;
+    siteTablesParams_t      *currTable;
+    short                   numOfTables;
+
+    UINT8                  *pDesiredIe;
+    UINT8                   *pSiteEntryIeBuffer;
+    UINT16                  ieLength;
+       
+    UINT8                   wpsOuiBuffer[DOT11_WPS_OUI_LEN+1]=DOT11_WPS_OUI;
+
+#ifdef DBG_BSSIS_NAME_PRINT
+    UINT8                   tempName[33];
+#endif
+
+    numOfTables = NUM_OF_SITE_TABLE;
+
+
+    bssidList->NumberOfItems = 0;
+
+    calculateBssidListSize(pSiteMgr, &length, allVarIes);
+
+    if (length > *pLength)
+    {
+        *pLength = length;
+        return NOK;
+    }
+
+    length = sizeof(OS_802_11_BSSID_LIST_EX) - sizeof(OS_802_11_BSSID_EX);
+
+    pData = (UINT8*)&bssidList->Bssid[0];
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Entering getBssidList, length = %d, pData = 0x%X\n", *pLength, (UINT32)pData));
+
+    currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+
+    for (tableIndex = 0; tableIndex < numOfTables ; tableIndex++)
+    {
+        for (siteTableIndex = 0, i = 0; siteTableIndex < currTable->maxNumOfSites; siteTableIndex++)
+        {
+            pBssid = (OS_802_11_BSSID_EX*)pData;
+
+            pSiteEntry = &(currTable->siteTable[siteTableIndex]);
+
+            if (pSiteEntry->siteType == SITE_NULL)
+                continue;
+
+
+            /* MacAddress */
+            os_memoryCopy(pSiteMgr->hOs, (void *)pBssid->MacAddress, (void *)&(pSiteEntry->bssid.addr), MAC_ADDR_LEN);
+
+            
+            /* Capabilities */
+            pBssid->Union.Capabilities = pSiteEntry->capabilities;
+
+            /* SSID */
+            /* This line is in order to prevent presantation problems at the utility. */
+            os_memoryZero(pSiteMgr->hOs, &(pBssid->Ssid.Ssid), MAX_SSID_LEN);
+            if (pSiteEntry->ssid.len > MAX_SSID_LEN)
+            {
+                pSiteEntry->ssid.len = MAX_SSID_LEN;
+            }
+            os_memoryCopy(pSiteMgr->hOs, (void *)pBssid->Ssid.Ssid, &(pSiteEntry->ssid.ssidString), pSiteEntry->ssid.len);
+            pBssid->Ssid.SsidLength = pSiteEntry->ssid.len;
+
+            /* privacy */
+            pBssid->Privacy = pSiteEntry->privacy;
+
+            /* RSSI */
+
+            pBssid->Rssi = (pSiteEntry->rssi);
+
+            pBssid->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
+            pBssid->Configuration.BeaconPeriod = pSiteEntry->beaconInterval;
+            pBssid->Configuration.ATIMWindow = pSiteEntry->atimWindow;
+            pBssid->Configuration.Union.channel = Chan2Freq(pSiteEntry->channel);
+
+            pBssid->Configuration.FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
+            pBssid->Configuration.FHConfig.DwellTime = pSiteEntry->FHParams.dwellTime;
+            pBssid->Configuration.FHConfig.HopPattern = pSiteEntry->FHParams.hopPattern;
+            pBssid->Configuration.FHConfig.HopSet = pSiteEntry->FHParams.hopSet;
+
+            if  (pSiteEntry->bssType == BSS_INDEPENDENT)
+                pBssid->InfrastructureMode = os802_11IBSS;
+            else
+                pBssid->InfrastructureMode = os802_11Infrastructure;
+
+            /* SupportedRates */
+            os_memoryZero(pSiteMgr->hOs, (void *)pBssid->SupportedRates, sizeof(OS_802_11_RATES_EX));
+
+            bitMapToNetworkStringRates(pSiteEntry->rateMask.supportedRateMask,
+                                       pSiteEntry->rateMask.basicRateMask,
+                                       (UINT8 *)pBssid->SupportedRates,
+                                       &len, &firstOFDMloc);
+
+            /* set network type acording to band and rates */
+            if (currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+            {
+                if (firstOFDMloc == len)
+                {
+                    pBssid->NetworkTypeInUse = os802_11DS;
+                } else {
+                    pBssid->NetworkTypeInUse = os802_11OFDM24;
+                }
+            } else {
+                pBssid->NetworkTypeInUse = os802_11OFDM5;
+            }
+
+            pBssid->IELength = 0;
+
+            /* copy fixed IEs from site entry */
+            pFixedIes = (OS_802_11_FIXED_IEs*)&pBssid->IEs[pBssid->IELength];
+            os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, &pSiteEntry->localTimeStamp, sizeof(pSiteEntry->localTimeStamp));
+            pFixedIes->BeaconInterval = pSiteEntry->beaconInterval;
+            pFixedIes->Capabilities = pSiteEntry->capabilities;
+            pBssid->IELength += sizeof(OS_802_11_FIXED_IEs);
+            pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
+
+            if (!allVarIes)
+            {   /* copy only several variable IEs */
+
+                /* copy SSID */
+                pVarIes->ElementID = SSID_IE_ID;
+                pVarIes->Length = pSiteEntry->ssid.len;
+                os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pSiteEntry->ssid.ssidString, pSiteEntry->ssid.len);
+                pBssid->IELength += (pVarIes->Length + 2);
+    
+                /* copy RATES */
+                pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
+                pVarIes->ElementID = SUPPORTED_RATES_IE_ID;
+                bitMapToNetworkStringRates(pSiteEntry->rateMask.supportedRateMask, pSiteEntry->rateMask.basicRateMask,
+                                           (UINT8 *)pVarIes->data, &len, &firstOFDMloc);
+                pVarIes->Length = len;
+                pBssid->IELength += (pVarIes->Length + 2);
+    
+                /* copy FH */
+                pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
+                pVarIes->ElementID = FH_PARAMETER_SET_IE_ID;
+                pVarIes->Length = DOT11_FH_PARAMS_ELE_LEN;
+                os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, &pSiteEntry->FHParams.dwellTime, sizeof(pSiteEntry->FHParams.dwellTime));
+                os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[2], &pSiteEntry->FHParams.hopSet, sizeof(pSiteEntry->FHParams.hopSet));
+                os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[3], &pSiteEntry->FHParams.hopPattern, sizeof(pSiteEntry->FHParams.hopPattern));
+                pVarIes->data[4] = 1;
+                pBssid->IELength += (pVarIes->Length + 2);
+    
+                /* copy DS */
+                pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
+                pVarIes->ElementID = DS_PARAMETER_SET_IE_ID;
+                pVarIes->Length = DOT11_DS_PARAMS_ELE_LEN;
+                os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, &pSiteEntry->channel, DOT11_DS_PARAMS_ELE_LEN);
+                pBssid->IELength += (pVarIes->Length + 2);
+    
+                /* copy RSN information elements */
+                rsnIeLength = 0;
+                for (index=0; index<MAX_RSN_IE && pSiteEntry->pRsnIe[index].hdr.eleLen>0; index++)
+                {
+                    pVarIes =  (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength+rsnIeLength];
+                    pVarIes->ElementID = pSiteEntry->pRsnIe[index].hdr.eleId;
+                    pVarIes->Length = pSiteEntry->pRsnIe[index].hdr.eleLen;
+                    os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pSiteEntry->pRsnIe[index].rsnIeData, pSiteEntry->pRsnIe[index].hdr.eleLen);
+                    rsnIeLength += pSiteEntry->pRsnIe[index].hdr.eleLen+2;
+                    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                            ("RSN IE ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length));
+    
+                    WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, (UINT8 *)pVarIes->data,pVarIes->Length);
+                }
+    
+                pBssid->IELength += pSiteEntry->rsnIeLen;
+    
+                /* create information element for the WME/EXC.
+                    Note that the existence of these IEs should be considered as a fact that the site supports this feature.
+                    by alcel
+                */
+                if (pSiteEntry->WMESupported)
+                {
+                    /* oui */
+                    UINT8 ouiWME[3] = { 0x50,0xf2,0x01};
+                    dot11_WME_PARAM_t *pWMEParams; 
+        
+    
+                    /* fill in the general element  parameters */
+    
+                    pVarIes =  (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
+                    pVarIes->ElementID =DOT11_WME_ELE_ID;
+                    pVarIes->Length = DOT11_WME_PARAM_ELE_LEN;
+    
+                    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                            ("WMESupported ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length));
+    
+                    /* fill in the specific element  parameters */
+                    pWMEParams = (dot11_WME_PARAM_t *) pVarIes;
+                    os_memoryCopy(pSiteMgr->hOs,(void *)pWMEParams->OUI,ouiWME,3);
+                    pWMEParams->OUIType = dot11_WME_OUI_TYPE;
+                    pWMEParams->OUISubType = dot11_WME_OUI_SUB_TYPE_PARAMS_IE;
+                    pWMEParams->version = dot11_WME_VERSION;
+                    pWMEParams->ACInfoField = dot11_WME_ACINFO_MASK & pSiteEntry->lastWMEParameterCnt;
+    
+                    /* fill in the data  */
+    
+                    os_memoryCopy(pSiteMgr->hOs,&(pWMEParams->WME_ACParameteres),&(pSiteEntry->WMEParameters),sizeof(ACParameters_t));
+    
+    
+                    /* update the general length */
+    
+                    pBssid->IELength += (pVarIes->Length + 2);
+                }
+
+                               /* copy WPS information elements */
+                
+                               if ((pSiteEntry->probeRecv) &&
+                                       (pSiteEntry->siteType != SITE_PRIMARY))
+                               {
+                                       pSiteEntryIeBuffer = pSiteEntry->probeRespBuffer;
+                                       ieLength = pSiteEntry->probeRespLength;
+                               }
+                               else
+                               {
+                                       pSiteEntryIeBuffer = pSiteEntry->beaconBuffer;
+                                       ieLength = pSiteEntry->beaconLength;
+                               }
+                
+                               parseIeBuffer(pSiteMgr->hOs, pSiteEntryIeBuffer, ieLength, DOT11_WPS_ELE_ID, &pDesiredIe, wpsOuiBuffer, DOT11_WPS_OUI_LEN);
+
+                               if (pDesiredIe)
+                               {
+                                       pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
+                                       pVarIes->ElementID = DOT11_WPS_ELE_ID;
+                                       pVarIes->Length = *((UINT8*)(pDesiredIe + 1));
+                                       os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (UINT8*)(pDesiredIe+2), pVarIes->Length);
+
+                                       pBssid->IELength += (pVarIes->Length + 2);
+                               }
+            }
+            else
+            {   /* Copy all variable IEs */
+                
+                if ((pSiteEntry->probeRecv) &&
+                    (pSiteEntry->siteType != SITE_PRIMARY))
+                {
+                    pSiteEntryIeBuffer = pSiteEntry->probeRespBuffer;
+                    ieLength = pSiteEntry->probeRespLength;
+                }
+                else
+                {
+                    pSiteEntryIeBuffer = pSiteEntry->beaconBuffer;
+                    ieLength = pSiteEntry->beaconLength;
+                }
+                WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                        ("Copy all variable IEs Length=%x\n", ieLength));
+                WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                            pSiteEntryIeBuffer, ieLength);
+
+                os_memoryCopy(pSiteMgr->hOs, pVarIes, pSiteEntryIeBuffer, ieLength);
+
+                pBssid->IELength += ieLength;
+            }
+
+            pBssid->Length = sizeof(OS_802_11_BSSID_EX) + pBssid->IELength - 1;
+
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                    ("BSSID MAC = %x-%x-%x-%x-%x-%x\n",
+                                     pBssid->MacAddress[0], pBssid->MacAddress[1], pBssid->MacAddress[2],
+                                     pBssid->MacAddress[3], pBssid->MacAddress[4], pBssid->MacAddress[5]));
+
+#ifdef DBG_BSSIS_NAME_PRINT
+            os_memoryCopy(pSiteMgr->hOs, tempName, &pBssid->Ssid.Ssid[0], pBssid->Ssid.SsidLength);
+            tempName[pBssid->Ssid.SsidLength] ='\0';
+
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                    ("BSSID NAME = %s\n",tempName)) ;
+#endif
+
+
+            /* make sure length is 4 bytes aligned */
+            if (pBssid->Length % 4)
+            {
+                pBssid->Length += (4 - (pBssid->Length % 4));
+            }
+
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                    ("BSSID length after alignment = %d\n", pBssid->Length));
+
+            pData += pBssid->Length;
+            length += pBssid->Length;
+
+
+            i++;
+        }
+
+        bssidList->NumberOfItems += i;
+
+        if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+        {
+            /* change site table */
+            if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+                currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+            else
+                currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+        }
+        else
+            break;
+
+    }
+
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                      ("Exiting getBssidList, site count = %i, length = %d, pData = 0x%X\n",
+                      bssidList->NumberOfItems, length, (UINT32)pData));
+
+    *pLength = length;
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        getPrimaryBssid
+ ***********************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to get the BSSID list from the site table
+
+INPUT:      pSiteMgr    -   site mgr handle.
+
+OUTPUT:     bssidList   -   BSSID list pointer
+
+RETURN:
+
+************************************************************************/
+static TI_STATUS getPrimaryBssid(siteMgr_t *pSiteMgr, OS_802_11_BSSID_EX *primaryBssid, UINT32 *pLength)
+{
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    UINT32                  len, firstOFDMloc = 0;
+    OS_802_11_FIXED_IEs     *pFixedIes;
+    OS_802_11_VARIABLE_IEs  *pVarIes;
+    UINT32                  length;
+
+
+    if ((primaryBssid==NULL) || (pLength==NULL))
+    {
+        *pLength = 0;
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("getPrimaryBssid, one of the ptr is NULL, primaryBssid=%p,pLength=%p  \n",
+                           primaryBssid, pLength));
+        return NOK;
+
+    }
+
+    if (pPrimarySite==NULL)
+    {
+        *pLength = 0;
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("getPrimaryBssid, pPrimarySite is NULL \n"));
+        return NOK;
+
+    }
+    length = pPrimarySite->beaconLength + sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs);
+    if (length > *pLength)
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("getPrimaryBssid, insufficient length,  required length=%d, pLength=%d \n",
+                           length, *pLength));
+        *pLength = length;
+
+        return NOK;
+    }
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Entering getPrimaryBssid, length = %d\n", *pLength));
+
+    primaryBssid->Length = length; 
+    /* MacAddress */
+    os_memoryCopy(pSiteMgr->hOs, (void *)primaryBssid->MacAddress, (void *)&(pPrimarySite->bssid.addr), MAC_ADDR_LEN);
+        
+    /* Capabilities */
+    primaryBssid->Union.Capabilities = pPrimarySite->capabilities;
+
+    /* SSID */
+    os_memoryZero(pSiteMgr->hOs, &(primaryBssid->Ssid.Ssid), MAX_SSID_LEN);
+    if (pPrimarySite->ssid.len > MAX_SSID_LEN)
+    {
+        pPrimarySite->ssid.len = MAX_SSID_LEN;
+    }
+    os_memoryCopy(pSiteMgr->hOs, (void *)primaryBssid->Ssid.Ssid, (void *)&(pPrimarySite->ssid.ssidString), pPrimarySite->ssid.len);
+    primaryBssid->Ssid.SsidLength = pPrimarySite->ssid.len;
+
+    /* privacy */
+    primaryBssid->Privacy = pPrimarySite->privacy;
+
+    /* RSSI */
+    primaryBssid->Rssi = pPrimarySite->rssi;
+
+    /* NetworkTypeInUse & SupportedRates */
+    /* SupportedRates */
+    os_memoryZero(pSiteMgr->hOs, (void *)primaryBssid->SupportedRates, sizeof(OS_802_11_RATES_EX));
+
+    bitMapToNetworkStringRates(pPrimarySite->rateMask.supportedRateMask,
+                               pPrimarySite->rateMask.basicRateMask,
+                               (UINT8 *)primaryBssid->SupportedRates,
+                               &len, &firstOFDMloc);
+
+    /* set network type acording to band and rates */
+    if (pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX)
+    {
+        if (firstOFDMloc == len)
+        {
+            primaryBssid->NetworkTypeInUse = os802_11DS;
+        } else {
+            primaryBssid->NetworkTypeInUse = os802_11OFDM24;
+        }
+    } else {
+        primaryBssid->NetworkTypeInUse = os802_11OFDM5;
+    }
+
+    /* Configuration */
+    primaryBssid->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
+    primaryBssid->Configuration.BeaconPeriod = pPrimarySite->beaconInterval;
+    primaryBssid->Configuration.ATIMWindow = pPrimarySite->atimWindow;
+    primaryBssid->Configuration.Union.channel = Chan2Freq(pPrimarySite->channel);
+
+    primaryBssid->Configuration.FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
+    primaryBssid->Configuration.FHConfig.DwellTime = pPrimarySite->FHParams.dwellTime;
+    primaryBssid->Configuration.FHConfig.HopPattern = pPrimarySite->FHParams.hopPattern;
+    primaryBssid->Configuration.FHConfig.HopSet = pPrimarySite->FHParams.hopSet;
+
+    /* InfrastructureMode */
+    if  (pPrimarySite->bssType == BSS_INDEPENDENT)
+        primaryBssid->InfrastructureMode = os802_11IBSS;
+    else
+        primaryBssid->InfrastructureMode = os802_11Infrastructure;
+
+
+
+    primaryBssid->IELength = 0;
+
+    /* copy fixed IEs from site entry */
+    pFixedIes = (OS_802_11_FIXED_IEs*)&primaryBssid->IEs[primaryBssid->IELength];
+    os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, (void *)&pPrimarySite->localTimeStamp, sizeof(pPrimarySite->localTimeStamp));
+    pFixedIes->BeaconInterval = pPrimarySite->beaconInterval;
+    pFixedIes->Capabilities = pPrimarySite->capabilities;
+    primaryBssid->IELength += sizeof(OS_802_11_FIXED_IEs);
+    pVarIes = (OS_802_11_VARIABLE_IEs*)&primaryBssid->IEs[primaryBssid->IELength];
+
+    /* Coppy all variable IEs */
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                            ("Coppy all variable beaconLength=%d, IELength=%d\n", 
+                             pPrimarySite->beaconLength, primaryBssid->IELength));
+    WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                pPrimarySite->beaconBuffer, pPrimarySite->beaconLength);
+
+    os_memoryCopy(pSiteMgr->hOs, pVarIes, pPrimarySite->beaconBuffer, pPrimarySite->beaconLength);
+
+    primaryBssid->IELength += pPrimarySite->beaconLength;
+
+
+    primaryBssid->Length = sizeof(OS_802_11_BSSID_EX) + primaryBssid->IELength - 1;
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                            ("BSSID MAC = %x-%x-%x-%x-%x-%x\n",
+                             primaryBssid->MacAddress[0], primaryBssid->MacAddress[1], primaryBssid->MacAddress[2],
+                             primaryBssid->MacAddress[3], primaryBssid->MacAddress[4], primaryBssid->MacAddress[5]));
+
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                            ("primaryBssid is\n"));
+    WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                (UINT8*)primaryBssid, primaryBssid->Length);
+
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                      ("Exiting getBssidList, length =%d, IELength=%d \n", 
+                       primaryBssid->Length,
+                       primaryBssid->IELength));
+
+    *pLength = primaryBssid->Length;
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_printPrimarySiteDesc
+ ***********************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to get the primary site description
+
+INPUT:      pSiteMgr            -   site mgr handle.
+            supplyExtendedInfo  - If OS_802_11_BSSID_EX structure should be used (extended info)
+                                  (Assuming that if this function is called with TRUE, enough memory was allocated to hold the extended info)
+
+OUTPUT:     pPrimarySiteDesc    -   Primary site description pointer
+
+RETURN:
+
+************************************************************************/
+void siteMgr_printPrimarySiteDesc(TI_HANDLE hSiteMgr )
+{
+    siteMgr_t *pSiteMgr = (siteMgr_t*) hSiteMgr;
+#ifdef REPORT_LOG
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    macAddress_t *bssid = &pPrimarySite->bssid;
+#endif
+
+    WLAN_REPORT_INFORMATION( pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                             ("-- SSID  = %s \n",pPrimarySite->ssid.ssidString) );
+    WLAN_REPORT_INFORMATION( pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                             ("-- BSSID = %02X-%02X-%02X-%02X-%02X-%02X\n", 
+                              bssid->addr[0], bssid->addr[1], bssid->addr[2], 
+                              bssid->addr[3], bssid->addr[4], bssid->addr[5]) );
+}
+
+/***********************************************************************
+ *                        getPrimarySiteDesc
+ ***********************************************************************
+DESCRIPTION:    Called by the OS abstraction layer in order to get the primary site description
+
+INPUT:      pSiteMgr            -   site mgr handle.
+            supplyExtendedInfo  - If OS_802_11_BSSID_EX structure should be used (extended info)
+                                  (Assuming that if this function is called with TRUE, enough memory was allocated to hold the extended info)
+
+OUTPUT:     pPrimarySiteDesc    -   Primary site description pointer
+
+RETURN:
+
+************************************************************************/
+static void getPrimarySiteDesc(siteMgr_t *pSiteMgr, OS_802_11_BSSID *pPrimarySiteDesc, BOOL supplyExtendedInfo)
+{
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    OS_802_11_BSSID_EX *pExPrimarySiteDesc = (OS_802_11_BSSID_EX *) pPrimarySiteDesc;
+    UINT32  len, firstOFDMloc = 0;
+    OS_802_11_FIXED_IEs     *pFixedIes;
+    OS_802_11_VARIABLE_IEs  *pVarIes;
+    UINT8 rsnIeLength,index;
+    OS_802_11_RATES_EX  SupportedRates;
+
+
+    if (pPrimarySiteDesc == NULL)
+    {
+        return;
+    }
+    if (pPrimarySite == NULL)
+    {
+        os_memoryZero(pSiteMgr->hOs, pPrimarySiteDesc, sizeof(OS_802_11_BSSID));
+        return;
+    }
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, 
+                            ("getPrimarySiteDesc - enter\n"));
+
+    
+    /* If an "extended" request has been made - update the length accordingly */
+   if (supplyExtendedInfo == FALSE)
+    pPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID);
+   else
+    pPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID_EX);
+
+    /* MacAddress */
+    os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->MacAddress, (void *)&(pPrimarySite->bssid.addr), MAC_ADDR_LEN);
+
+    /* Capabilities */
+    pPrimarySiteDesc->Union.Capabilities = pPrimarySite->capabilities;
+
+    /* SSID */
+    os_memoryCopy(pSiteMgr->hOs, (void *)&(pPrimarySiteDesc->Ssid.Ssid[0]), (void *)&(pPrimarySite->ssid.ssidString[0]), pPrimarySite->ssid.len);
+    pPrimarySiteDesc->Ssid.SsidLength = pPrimarySite->ssid.len;
+
+    /* privacy */
+    pPrimarySiteDesc->Privacy = pPrimarySite->privacy;
+
+    /* RSSI */
+
+    pPrimarySiteDesc->Rssi = pPrimarySite->rssi;
+
+       bitMapToNetworkStringRates(pPrimarySite->rateMask.supportedRateMask,
+                                                          pPrimarySite->rateMask.basicRateMask,
+                                                          &SupportedRates[0],
+                                                          &len, &firstOFDMloc);
+
+    /* set network type acording to band and rates */
+    if (pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX)
+    {
+        if (firstOFDMloc == len)
+        {
+            pPrimarySiteDesc->NetworkTypeInUse = os802_11DS;
+        } else {
+            pPrimarySiteDesc->NetworkTypeInUse = os802_11OFDM24;
+        }
+    } else {
+        pPrimarySiteDesc->NetworkTypeInUse = os802_11OFDM5;
+    }
+
+
+    pPrimarySiteDesc->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
+    pPrimarySiteDesc->Configuration.BeaconPeriod = pPrimarySite->beaconInterval;
+    pPrimarySiteDesc->Configuration.ATIMWindow = pPrimarySite->atimWindow;
+    pPrimarySiteDesc->Configuration.Union.channel = pPrimarySite->channel;
+
+    pPrimarySiteDesc->Configuration.FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
+    pPrimarySiteDesc->Configuration.FHConfig.DwellTime = pPrimarySite->FHParams.dwellTime;
+    pPrimarySiteDesc->Configuration.FHConfig.HopPattern = pPrimarySite->FHParams.hopPattern;
+    pPrimarySiteDesc->Configuration.FHConfig.HopSet = pPrimarySite->FHParams.hopSet;
+
+    if  (pPrimarySite->bssType == BSS_INDEPENDENT)
+        pPrimarySiteDesc->InfrastructureMode = os802_11IBSS;
+    else
+        pPrimarySiteDesc->InfrastructureMode = os802_11Infrastructure;
+
+   /* SupportedRates */
+   if (supplyExtendedInfo == FALSE)
+      os_memoryZero(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, sizeof(OS_802_11_RATES));
+   else
+      os_memoryZero(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, sizeof(OS_802_11_RATES_EX));
+
+
+   if (supplyExtendedInfo == FALSE)
+       os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, (void *)SupportedRates, sizeof(OS_802_11_RATES));
+   else
+       os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, (void *)SupportedRates, sizeof(OS_802_11_RATES_EX));
+   
+
+   if (supplyExtendedInfo == TRUE)
+   {
+      pExPrimarySiteDesc->IELength = 0;
+
+     /* copy fixed IEs from site entry */
+     pFixedIes = (OS_802_11_FIXED_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
+     os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, (void *)&pPrimarySite->localTimeStamp, sizeof(pPrimarySite->localTimeStamp));
+     pFixedIes->BeaconInterval = pPrimarySite->beaconInterval;
+     pFixedIes->Capabilities = pPrimarySite->capabilities;
+     pExPrimarySiteDesc->IELength += sizeof(OS_802_11_FIXED_IEs);
+
+     /* copy variable IEs */
+     /* copy SSID */
+     pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
+     pVarIes->ElementID = SSID_IE_ID;
+     pVarIes->Length = pPrimarySite->ssid.len;
+     os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pPrimarySite->ssid.ssidString, pPrimarySite->ssid.len);
+     pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
+
+     /* copy RATES */
+     
+     pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
+     pVarIes->ElementID = SUPPORTED_RATES_IE_ID;
+     bitMapToNetworkStringRates(pPrimarySite->rateMask.supportedRateMask, pPrimarySite->rateMask.basicRateMask,
+                                (UINT8 *)pVarIes->data, &len, &firstOFDMloc);
+     pVarIes->Length = len;
+     pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
+
+     /* copy FH */
+     pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
+     pVarIes->ElementID = FH_PARAMETER_SET_IE_ID;
+     pVarIes->Length = DOT11_FH_PARAMS_ELE_LEN;
+     os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)&pPrimarySite->FHParams.dwellTime, sizeof(pPrimarySite->FHParams.dwellTime));
+     os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[2], (void *)&pPrimarySite->FHParams.hopSet, sizeof(pPrimarySite->FHParams.hopSet));
+     os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[3], (void *)&pPrimarySite->FHParams.hopPattern, sizeof(pPrimarySite->FHParams.hopPattern));
+     pVarIes->data[4] = 1;
+     pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
+
+     /* copy DS */
+     pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
+     pVarIes->ElementID = DS_PARAMETER_SET_IE_ID;
+     pVarIes->Length = DOT11_DS_PARAMS_ELE_LEN;
+     os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)&pPrimarySite->channel, DOT11_DS_PARAMS_ELE_LEN);
+     pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
+
+     /* copy RSN information elements */
+     rsnIeLength = 0;
+     for (index=0; index<MAX_RSN_IE && pPrimarySite->pRsnIe[index].hdr.eleLen>0; index++)
+       {
+            pVarIes =  (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength+rsnIeLength];
+         pVarIes->ElementID = pPrimarySite->pRsnIe[index].hdr.eleId;
+             pVarIes->Length = pPrimarySite->pRsnIe[index].hdr.eleLen;
+             os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pPrimarySite->pRsnIe[index].rsnIeData, pPrimarySite->pRsnIe[index].hdr.eleLen);
+             rsnIeLength += pPrimarySite->pRsnIe[index].hdr.eleLen+2;
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                    ("RSN IE ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length));
+
+            WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, (UINT8 *)pVarIes->data,pVarIes->Length);
+         }
+
+         pExPrimarySiteDesc->IELength += pPrimarySite->rsnIeLen;
+
+         pExPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID_EX) + pExPrimarySiteDesc->IELength - 1;
+
+         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                 ("BSSID MAC = %x-%x-%x-%x-%x-%x\n",
+                                  pExPrimarySiteDesc->MacAddress[0], pExPrimarySiteDesc->MacAddress[1], pExPrimarySiteDesc->MacAddress[2],
+                                  pExPrimarySiteDesc->MacAddress[3], pExPrimarySiteDesc->MacAddress[4], pExPrimarySiteDesc->MacAddress[5]));
+
+         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                 ("pExPrimarySiteDesc length before alignment = %d\n", pExPrimarySiteDesc->Length));
+
+         /* make sure length is 4 bytes aligned */
+         if (pExPrimarySiteDesc->Length % 4)
+         {
+            pExPrimarySiteDesc->Length += (4 - (pExPrimarySiteDesc->Length % 4));
+         }
+
+         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                 ("pExPrimarySiteDesc length after alignment = %d\n", pExPrimarySiteDesc->Length));
+
+        }
+
+}
+
+
+/***********************************************************************
+ *                        translateRateMaskToValue
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'siteMgr_config()' in order to translate the rate mask read
+                from registry to rate value
+
+INPUT:      pSiteMgr            -   site mgr handle.
+            rateMask            -   Rate mask
+
+OUTPUT:     The rate after the translation
+
+RETURN:
+
+************************************************************************/
+static rate_e translateRateMaskToValue(siteMgr_t *pSiteMgr, UINT32 rateMask)
+{
+    if (rateMask & DRV_RATE_MASK_54_OFDM)
+        return DRV_RATE_54M;
+    if (rateMask & DRV_RATE_MASK_48_OFDM)
+        return DRV_RATE_48M;
+    if (rateMask & DRV_RATE_MASK_36_OFDM)
+        return DRV_RATE_36M;
+    if (rateMask & DRV_RATE_MASK_24_OFDM)
+        return DRV_RATE_24M;
+    if (rateMask & DRV_RATE_MASK_22_PBCC)
+        return DRV_RATE_22M;
+    if (rateMask & DRV_RATE_MASK_18_OFDM)
+        return DRV_RATE_18M;
+    if (rateMask & DRV_RATE_MASK_12_OFDM)
+        return DRV_RATE_12M;
+    if (rateMask & DRV_RATE_MASK_11_CCK)
+        return DRV_RATE_11M;
+    if (rateMask & DRV_RATE_MASK_9_OFDM)
+        return DRV_RATE_9M;
+    if (rateMask & DRV_RATE_MASK_6_OFDM)
+        return DRV_RATE_6M;
+    if (rateMask & DRV_RATE_MASK_5_5_CCK)
+        return DRV_RATE_5_5M;
+    if (rateMask & DRV_RATE_MASK_2_BARKER)
+        return DRV_RATE_2M;
+    if (rateMask & DRV_RATE_MASK_1_BARKER)
+        return DRV_RATE_1M;
+
+    WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Translate rate mask to value, mask is 0x%X\n", rateMask));
+    if(pSiteMgr->siteMgrOperationalMode != DOT11_A_MODE)
+        return DRV_RATE_1M;
+    else
+        return DRV_RATE_6M;
+}
+
+
+/***********************************************************************
+ *                        getSupportedRateSet
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'siteMgr_getParam()' in order to get the supported rate set
+                Build an array of network rates based on the max active & max basic rates
+
+INPUT:      pSiteMgr            -   site mgr handle.
+
+OUTPUT:     pRatesSet           -   The array built
+
+RETURN:
+
+************************************************************************/
+static void getSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet)
+{
+    UINT32 dontCareParam;
+    UINT32 len = 0;
+
+    bitMapToNetworkStringRates(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask,
+                               pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask,
+                               (UINT8 *)pRatesSet->ratesString, &len, &dontCareParam);
+
+    pRatesSet->len = (UINT8) len;
+}
+
+/***********************************************************************
+ *                        setSupportedRateSet
+ ***********************************************************************
+DESCRIPTION:    Called by the function 'siteMgr_setParam()' in order to set the supported rate set
+                Go over the input array and set the max active & max basic rates. (after translation from network
+                rates to host rates ofcourse)
+                If max basic rate is bigger than the mac active one, print an error.
+                If the basic or active rate are different than the ones already stored by the site manager,
+                it returns RE_SCAN_NEEDED
+
+INPUT:      pSiteMgr            -   site mgr handle.
+            pRatesSet           -   The rates array received
+
+OUTPUT:
+
+RETURN:     RE_SCAN_NEEDED if re scan is needed, OK on success
+
+************************************************************************/
+static TI_STATUS setSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet)
+{
+    UINT8  i,j, drvRate;
+    rate_e maxActiveRate = (rate_e)0, maxBasicRate = (rate_e)0;
+    UINT32 suppBitMap, basicBitMap;
+    static  rate_e basicRates_G[]  = {DRV_RATE_1M,DRV_RATE_2M,DRV_RATE_5_5M,DRV_RATE_11M};
+    static rate_e basicRates_A[]  = {DRV_RATE_6M,DRV_RATE_12M,DRV_RATE_24M};
+    rate_e* currentBasicRates;
+    UINT32 currentBasicRatesLength;
+
+#ifndef NET_BASIC_MASK
+#define NET_BASIC_MASK      0x80    /* defined in common/src/utils/utils.c */
+#endif
+
+    if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+    {
+        currentBasicRates = &basicRates_A[0];
+        currentBasicRatesLength = sizeof(basicRates_A) / sizeof(basicRates_A[0]);
+    }
+    else
+    {
+        currentBasicRates = &basicRates_G[0];
+        currentBasicRatesLength = sizeof(basicRates_G) / sizeof(basicRates_G[0]);
+    }
+    
+        /* Basic rates must be supported. If one of 1M,2M,5.5M,11M is not supported fail.*/
+
+    for (j=0;j < currentBasicRatesLength;j++) 
+    {
+        for (i = 0; i < pRatesSet->len; i++)
+        {
+            drvRate = utilityToHostRate(pRatesSet->ratesString[i]);
+            if ((drvRate & ( NET_BASIC_MASK-1)) == currentBasicRates[j])
+                break;
+        }
+        /* not all the basic rates are supported! Failure*/
+        if (i == pRatesSet->len) 
+        {
+            WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Rates set must contain the basic set! Failing\n"));
+            return PARAM_VALUE_NOT_VALID;
+        }
+    }
+    
+    for (i = 0; i < pRatesSet->len; i++)
+    {
+        drvRate = utilityToHostRate(pRatesSet->ratesString[i]);
+        if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+        {
+            if(drvRate < DRV_RATE_6M)
+            {
+                WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the driver configured in 11a mode, but CCK rate appears\n"));
+                return PARAM_VALUE_NOT_VALID;
+            }
+        }
+        else if(pSiteMgr->siteMgrOperationalMode == DOT11_B_MODE)
+        {
+            if(drvRate >= DRV_RATE_6M)
+            {
+                WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the driver configured in 11b mode, but OFDM rate appears\n"));
+                return PARAM_VALUE_NOT_VALID;
+            }
+        }
+        maxActiveRate = MAX((rate_e)drvRate, maxActiveRate);
+    }
+
+    for (i = 0; i < pRatesSet->len; i++)
+    {
+        if (IS_BASIC_RATE(pRatesSet->ratesString[i]))
+            maxBasicRate = MAX(utilityToHostRate(pRatesSet->ratesString[i]), maxBasicRate);
+    }
+
+    /* If the basic rate is bigger than the supported one, we print an error */
+    if (pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic > pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the rates configuration is invalid, basic rate is bigger than supported, Max Basic: %d Max Supported: %d\n", pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic, pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive = maxActiveRate;
+    pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic = maxBasicRate;
+
+    
+    /* configure desired modulation */
+    if(maxActiveRate == DRV_RATE_22M)
+        pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_PBCC;
+    else if(maxActiveRate < DRV_RATE_22M)
+        pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_CCK;
+    else
+        pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_OFDM;
+
+
+    networkStringToBitMapSuppRates(&suppBitMap,
+                                   (UINT8 *)pRatesSet->ratesString,
+                                   pRatesSet->len);
+
+    networkStringToBitMapBasicRates(&basicBitMap,
+                                    (UINT8 *)pRatesSet->ratesString,
+                                    pRatesSet->len);
+
+    if((pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask != basicBitMap) ||
+       (pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask != suppBitMap))
+    {
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = suppBitMap;
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = basicBitMap;
+        pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = basicBitMap;
+        pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = suppBitMap;
+        /* Initialize Mutual Rates Matching */
+        pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
+        pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
+        pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask);
+        pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask);
+
+        return RE_SCAN_NEEDED;
+    }
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        pbccAlgorithm
+ ***********************************************************************
+DESCRIPTION:    Called by the following functions:
+                -   systemConfig(), in the system configuration phase after the selection
+                -   siteMgr_updateSite(), in a case of a primary site update & if a PBCC algorithm
+                    is needed to be performed
+                Performs the PBCC algorithm
+
+
+INPUT:      hSiteMgr            -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on always
+
+************************************************************************/
+TI_STATUS pbccAlgorithm(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    paramInfo_t param;
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+    UINT32      bitMap = 0;
+    BOOL        desiredTxRateSupported = FALSE;
+    UINT32      supportedRateMask ;
+
+
+    /* First set the data modulation. */
+    param.paramType = CTRL_DATA_CURRENT_MODULATION_TYPE_PARAM;                  /* Current Modulation Type */
+    param.content.ctrlDataCurrentModulationType = pSiteMgr->currentDataModulation;
+    ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+    if (pPrimarySite->channel == SPECIAL_BG_CHANNEL)
+        supportedRateMask = (getSupportedRateMaskForSpecialBGchannel() & pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask) ;
+    else
+        supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask ;
+
+    validateDesiredTxRate(pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate,
+                          pSiteMgr->currentDataModulation,
+                          supportedRateMask,
+                          &bitMap,
+                          &desiredTxRateSupported);
+
+    if(desiredTxRateSupported == FALSE)
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the rates configuration is invalid, desired tx rate is not supported => switched to auto"));
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = DRV_RATE_AUTO;
+    }
+
+    param.paramType = CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM;
+    param.content.ctrlDataCurrentRateMask = supportedRateMask;
+    /* clear the 22Mbps bit in case the PBCC is not allowed */
+    if(pSiteMgr->currentDataModulation != DRV_MODULATION_PBCC &&
+       pSiteMgr->currentDataModulation != DRV_MODULATION_OFDM)
+            param.content.ctrlDataCurrentRateMask &= ~DRV_RATE_MASK_22_PBCC;
+    ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+    param.paramType = CTRL_DATA_CURRENT_ACTIVE_RATE_PARAM;
+
+    param.content.ctrlDataCurrentActiveRate = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate;
+    ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+
+    /*
+     * NOTE: THIS MUST BE AFTER SETTING PREAMBLE TYPE 
+     */
+    
+    if (pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate == DRV_RATE_AUTO)
+    {
+        param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
+        param.content.ctrlDataRateControlEnable = TRUE;
+        ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+    }
+    else
+    {
+        param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
+        param.content.ctrlDataRateControlEnable = FALSE;
+        ctrlData_setParam(pSiteMgr->hCtrlData, &param);
+    }
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        validateDesiredTxRate
+ ***********************************************************************
+DESCRIPTION:    Called by the following functions:
+                -   pbccAlgorithm()
+
+
+INPUT:      desiredTxRate           -   configured desired tx rate.
+            desiredModulation       -   configured desired tx modulation.
+            suppRates               -   rates, supported by both STA and primary site.
+
+OUTPUT:     bitMap                  -   rates bit map to be set to the ctrlData module
+            txDesiredRateSupported  -   indication whether the desired tx rate supported
+                                        by both STA and the primary site.
+RETURN:     OK on always
+
+************************************************************************/
+void validateDesiredTxRate(rate_e desiredTxRate, modulationType_e desiredModulation,
+                           UINT32 suppRates, UINT32 *bitMap, BOOL *txDesiredRateSupported)
+{
+
+    UINT32  maskTable[DRV_RATE_MAX+1] =
+                                        {DRV_RATE_MASK_AUTO,
+                                         DRV_RATE_MASK_1_BARKER,
+                                         DRV_RATE_MASK_2_BARKER,
+                                         DRV_RATE_MASK_5_5_CCK,
+                                         DRV_RATE_MASK_11_CCK,
+                                         DRV_RATE_MASK_22_PBCC
+                                         ,DRV_RATE_MASK_6_OFDM,
+                                         DRV_RATE_MASK_9_OFDM,
+                                         DRV_RATE_MASK_12_OFDM,
+                                         DRV_RATE_MASK_18_OFDM,
+                                         DRV_RATE_MASK_24_OFDM,
+                                         DRV_RATE_MASK_36_OFDM,
+                                         DRV_RATE_MASK_48_OFDM,
+                                         DRV_RATE_MASK_54_OFDM
+                                        };
+
+    if(desiredModulation != DRV_MODULATION_PBCC)
+    {
+        if(desiredTxRate == DRV_RATE_22M)
+            *bitMap = DRV_RATE_MASK_11_CCK;
+        else
+            *bitMap = maskTable[desiredTxRate];
+    }
+    else
+        *bitMap = maskTable[desiredTxRate];
+
+    if((suppRates & maskTable[desiredTxRate]) || (desiredTxRate == DRV_RATE_AUTO))
+        *txDesiredRateSupported = TRUE;
+    else
+        *txDesiredRateSupported = FALSE;
+}
+
+/***********************************************************************
+ *                        siteMgr_assocReport
+ ***********************************************************************
+DESCRIPTION:    Called by the following functions:
+                -   assoc_recv()
+
+
+INPUT:      hSiteMgr            -   siteMgr handle.
+            capabilities        -   assoc rsp capabilities field.
+                       bCiscoAP                        -   whether we are connected to a Cisco AP. Used for Tx Power Control adjustment
+OUTPUT:
+
+RETURN:     OK on always
+
+************************************************************************/
+TI_STATUS siteMgr_assocReport(TI_HANDLE hSiteMgr, UINT16 capabilities, BOOL bCiscoAP)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+
+    /* handle AP's preamble capability */
+    pPrimarySite->preambleAssRspCap = ((capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK)  ? PREAMBLE_SHORT : PREAMBLE_LONG;
+
+       /*
+        * Enable/Disable the ATx Power Control adjustment.
+        * When we are connected to Cisco AP - TX Power Control adjustment is disabled.
+        */
+       pSiteMgr->bTempTxPowerEnabled = ( !bCiscoAP ) && ( pSiteMgr->pDesiredParams->TxPowerControlOn );
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+               ("%s: Tx Power Control adjustment is %d\n",__FUNCTION__, pSiteMgr->bTempTxPowerEnabled));
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        siteMgr_setWMEParamsSite
+ ***********************************************************************
+DESCRIPTION:    Set the WME params as received from the associated
+                AP. The function is called by the QoS Mgr
+                after receving association response succefully.
+
+INPUT:      hSiteMgr    -   SiteMgr handle.
+
+OUTPUT:     pDot11_WME_PARAM_t - pointer to the WME Param IE.
+
+RETURN:     OK on always
+
+************************************************************************/
+TI_STATUS siteMgr_setWMEParamsSite(TI_HANDLE hSiteMgr,dot11_WME_PARAM_t *pDot11_WME_PARAM)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+
+    if( pPrimarySite == NULL )
+    {
+        return OK;
+    }
+
+    if( pDot11_WME_PARAM == NULL )
+    {
+        pPrimarySite->WMESupported = FALSE;
+        return OK;
+    }
+
+    /* Update the WME params */
+    os_memoryCopy(pSiteMgr->hOs,&pPrimarySite->WMEParameters,&pDot11_WME_PARAM->WME_ACParameteres,sizeof(ACParameters_t));
+    pPrimarySite->lastWMEParameterCnt = (pDot11_WME_PARAM->ACInfoField & dot11_WME_ACINFO_MASK);
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("$$$$$$ WME parameters were updates according to association response, cntSeq = %d\n",pPrimarySite->lastWMEParameterCnt));
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        siteMgr_getWMEParamsSite
+ ***********************************************************************
+DESCRIPTION:    Get the WME params as recieved from the associated
+                AP. The function is called by the Qos Mgr in order
+                to set all WME parameters to the core and Hal
+
+INPUT:      hSiteMgr    -   SiteMgr handle.
+
+OUTPUT:     pWME_ACParameters_t - pointer to the WME Param.
+
+RETURN:     OK if there are valid WME parameters , NOK otherwise.
+
+************************************************************************/
+TI_STATUS siteMgr_getWMEParamsSite(TI_HANDLE hSiteMgr,ACParameters_t **pWME_ACParameters_t)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+
+    if(pPrimarySite->WMESupported == TRUE)
+    {
+        *pWME_ACParameters_t = &pPrimarySite->WMEParameters;
+        return OK;
+    }
+    else
+    {
+        *pWME_ACParameters_t = NULL;
+        return NOK;
+    }
+
+}
+
+
+
+/***********************************************************************
+ *                        calculateBssidListSize
+ ***********************************************************************
+DESCRIPTION:    Calculate the size of memory buffer required for BSSID
+                List.
+
+
+INPUT:      hSiteMgr            -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     OK on always
+
+************************************************************************/
+static TI_STATUS calculateBssidListSize(siteMgr_t *pSiteMgr, UINT32 *pLength, BOOL allVarIes)
+{
+    UINT32 siteTableIndex, tableIndex;
+    UINT32 length;
+    siteEntry_t* pSiteEntry;
+    siteTablesParams_t* currTable;
+
+    *pLength = sizeof(OS_802_11_BSSID_LIST_EX) - sizeof(OS_802_11_BSSID_EX);
+
+    currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
+
+    for (tableIndex = 0; tableIndex < NUM_OF_SITE_TABLE ; tableIndex++)
+    {
+        for (siteTableIndex = 0; siteTableIndex < currTable->maxNumOfSites; siteTableIndex++)
+        {
+            pSiteEntry = (siteEntry_t*)&currTable->siteTable[siteTableIndex];
+
+            if (pSiteEntry->siteType != SITE_NULL)
+            {
+                if (allVarIes)
+                {
+                    length = sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs);
+                    if (pSiteEntry->probeRecv)
+                    {
+                        length += pSiteEntry->probeRespLength;
+                    }
+                    else
+                    {
+                        length += pSiteEntry->beaconLength;
+                    }
+                             
+                }
+                else
+                {
+                    length = (sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) +
+                              (pSiteEntry->ssid.len + 2) + (MAX_SUPPORTED_RATES + 2) +
+                              (DOT11_FH_PARAMS_ELE_LEN + 2) + (DOT11_DS_PARAMS_ELE_LEN +2) +
+                              pSiteEntry->rsnIeLen);
+                    /* WME information element by alcel*/
+                    if (pSiteEntry->WMESupported)
+                    {
+                        /* length of element + header*/
+                        length += (DOT11_WME_ELE_LEN + 2);
+                    }
+                }
+
+                /* make sure length is 4 bytes aligned */
+                if (length % 4)
+                {
+                    length += (4 - (length % 4));
+                }
+
+                *pLength += length;
+
+                WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                        ("BSSID length =%d on table index %d \n", length, tableIndex));
+
+            }
+        }
+
+
+        if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
+        {
+            /* change site table */
+            if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
+                currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+            else
+                currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+        }
+        else
+            break;
+
+    }
+
+    return OK;
+}
+
+
+
+
+
+
+
+
+/***********************************************************************
+ *                        siteMgr_setCurrentTable
+ ***********************************************************************
+DESCRIPTION:
+
+INPUT:      hSiteMgr    -   SiteMgr handle.
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+void siteMgr_setCurrentTable(TI_HANDLE hSiteMgr, radioBand_e radioBand)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if(radioBand == RADIO_BAND_2_4_GHZ)
+        pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
+    else
+        pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
+}
+
+
+
+/***********************************************************************
+ *                        siteMgr_updateRates
+ ***********************************************************************
+DESCRIPTION:
+
+INPUT:      hSiteMgr    -   SiteMgr handle.
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+
+void siteMgr_updateRates(TI_HANDLE hSiteMgr, BOOL dot11a, BOOL updateToOS)
+{
+    UINT32                  statusData;
+    rate_e                  txDesiredRate;
+    UINT32                  localSuppRateMask, localBasicRateMask;
+
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    localSuppRateMask = pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask;
+    localBasicRateMask = pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask;
+
+
+    validateRatesVsBand(&localSuppRateMask, &localBasicRateMask, dot11a);
+
+    pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = localBasicRateMask;
+    pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = localSuppRateMask;
+
+     /* Initialize Mutual Rates Matching */
+    pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
+    pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
+    pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask);
+    pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask);
+
+
+    /*If we are in dual mode and we are only scanning A band we don't have to set the siteMgrCurrentDesiredTxRate.*/
+    if (updateToOS == TRUE)
+    {
+        /* Validate that the masks and tx rate are OK */
+        txDesiredRate = pSiteMgr->pDesiredParams->siteMgrRegstryDesiredTxRate;
+
+        validateRates((UINT32 *)&pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask,
+                      (UINT32 *)&pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask,
+                          (UINT32 *)&txDesiredRate,
+                          &pSiteMgr->pDesiredParams->siteMgrDesiredModulationType, dot11a);
+
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = txDesiredRate;
+    }
+    pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic = translateRateMaskToValue(pSiteMgr, pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask);
+    pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive = translateRateMaskToValue(pSiteMgr, pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask);
+
+    if (updateToOS == TRUE) {
+        /* report the desired rate to OS */
+        statusData = hostToUtilityRate(pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive);
+
+        EvHandlerSendEvent(pSiteMgr->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
+    }
+
+}
+
+/***********************************************************************
+ *                        siteMgr_bandParamsConfig
+ ***********************************************************************
+DESCRIPTION:
+
+INPUT:      hSiteMgr    -   SiteMgr handle.
+
+OUTPUT:
+
+RETURN:
+
+************************************************************************/
+void siteMgr_bandParamsConfig(TI_HANDLE hSiteMgr,  BOOL updateToOS)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    /* reconfig rates */
+    if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
+        siteMgr_updateRates(hSiteMgr, TRUE, updateToOS);
+    else
+        siteMgr_updateRates(hSiteMgr, FALSE, updateToOS);
+
+    /* go to B_ONLY Mode only if WiFI bit is Set*/
+    if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
+    {   /* Configuration For AdHoc when using external configuration */
+        if (pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == FALSE)
+        {
+            siteMgr_externalConfigurationParametersSet(hSiteMgr);
+        }
+    }
+
+}
+
+void siteMgr_keepAliveSendNullDataTimer(TI_HANDLE hSiteMgr)
+{
+    paramInfo_t param;
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    UINT32      txPacketsCount = 0;
+    UINT32      TxQid;
+
+    if ((pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL) &&
+        (pSiteMgr->pSitesMgmtParams->pPrimarySite->bssType != BSS_INFRASTRUCTURE))
+    {   /* No need for kepp alive when not in Infra */
+        return;
+    }
+    param.paramType = TX_DATA_COUNTERS_PARAM;
+    txData_getParam(pSiteMgr->hTxData, &param);
+    /* get current tx data frames counter */
+    for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
+        txPacketsCount += param.content.pTxDataCounters[TxQid].XmitOk;
+
+    if (pSiteMgr->txPacketsCount==txPacketsCount)
+    {  /* send NULL data */
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("siteMgr_keepAliveSendNullDataTimer\n"));
+
+        /* sending null frame with power save bit set to off (if keepAliveEnable in the registry)
+          Note: the Hardware modify the PS bit according to the current PS mode. */
+        if(pSiteMgr->keepAliveEnable == TRUE)
+        {
+            txData_sendNullFrame(pSiteMgr->hTxData, FALSE, SITE_MGR_MODULE);
+        }
+        txPacketsCount++;
+
+    }
+    pSiteMgr->txPacketsCount=txPacketsCount;
+
+}
+
+void siteMgr_ConfigRate(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    BOOL        dot11a;
+    dot11mode_e OperationMode ;
+
+    OperationMode = pSiteMgr->siteMgrOperationalMode;
+
+    /* reconfig rates */
+    if(OperationMode == DOT11_A_MODE)
+        dot11a = TRUE;
+    else
+        dot11a = FALSE;
+
+    /*
+    ** Specific change to ch 14, that channel is only used in Japan, and is limited
+    ** to rates 1,2,5.5,11
+    */
+    if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel == SPECIAL_BG_CHANNEL)
+    {
+        if(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode] > BASIC_RATE_SET_1_2_5_5_11)
+            pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode] = BASIC_RATE_SET_1_2_5_5_11;
+
+
+        if(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode] > SUPPORTED_RATE_SET_1_2_5_5_11)
+            pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode] = SUPPORTED_RATE_SET_1_2_5_5_11;
+    }
+
+    pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask =
+        translateBasicRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode], dot11a);
+
+    pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask =
+        translateSupportedRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode], dot11a);
+
+    siteMgr_updateRates(pSiteMgr, dot11a, TRUE);
+
+        /* go to B_ONLY Mode only if WiFI bit is Set*/
+    if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
+    {   /* Configuration For AdHoc when using external configuration */
+        if (pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == FALSE)
+        {
+            siteMgr_externalConfigurationParametersSet(hSiteMgr);
+        }
+    }
+}
+
+static void siteMgr_externalConfigurationParametersSet(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    /* Overwrite the parameters for AdHoc with External Configuration */
+
+    if( ((pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_A_MODE) ||
+        (pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)) &&
+        !pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc && pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
+        return;
+
+
+    if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
+    {
+        pSiteMgr->siteMgrOperationalMode = DOT11_B_MODE;
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_1_2_5_5_11, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = DRV_RATE_AUTO;
+        pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_1_2_5_5_11, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrRegstryDesiredTxRate = DRV_RATE_AUTO;
+        pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = PHY_SLOT_TIME_LONG;
+
+        whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, RADIO_BAND_2_4_GHZ);
+        whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, PHY_SLOT_TIME_LONG);
+
+    }
+    else
+    {
+        if(pSiteMgr->radioBand == RADIO_BAND_2_4_GHZ)
+            pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
+        else
+            pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_ALL, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = DRV_RATE_AUTO;
+        pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_ALL, FALSE);
+        pSiteMgr->pDesiredParams->siteMgrRegstryDesiredTxRate = DRV_RATE_AUTO;
+
+        pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = PHY_SLOT_TIME_LONG;
+
+        whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, PHY_SLOT_TIME_LONG);
+    }
+}
+
+void siteMgr_checkTxPower(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t           *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if ( (pSiteMgr->pSitesMgmtParams->pPrimarySite) && (pSiteMgr->bTempTxPowerEnabled)
+        && (++pSiteMgr->siteMgrTxPowerCheckTime >= pSiteMgr->pDesiredParams->TxPowerCheckTime) )
+        {
+            pSiteMgr->siteMgrTxPowerCheckTime = 0; /* reset counter for next check */
+
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                ("%s: RSSI = %d TxPowerRssiThresh = %d TxPowerRssiRestoreThresh = %D\n", 
+                               __FUNCTION__, pSiteMgr->pSitesMgmtParams->pPrimarySite->rssi,
+                               pSiteMgr->pDesiredParams->TxPowerRssiThresh,pSiteMgr->pDesiredParams->TxPowerRssiRestoreThresh));
+
+        if ((pSiteMgr->pSitesMgmtParams->pPrimarySite->rssi) >= (INT32) (0 - pSiteMgr->pDesiredParams->TxPowerRssiThresh))
+        {
+            /* activate Tx Power Control adjustment */
+                       siteMgr_setTemporaryTxPower(pSiteMgr, TRUE);  
+        }
+        else if (pSiteMgr->pSitesMgmtParams->pPrimarySite->rssi <= (INT32) (0 - pSiteMgr->pDesiredParams->TxPowerRssiRestoreThresh))
+        {
+                       /* deactivate Tx Power Control adjustment */
+                       siteMgr_setTemporaryTxPower(pSiteMgr, FALSE);  
+        }
+    }
+}
+
+TI_STATUS siteMgr_saveProbeRespBuffer(TI_HANDLE hSiteMgr, macAddress_t  *bssid, UINT8 *pProbeRespBuffer, UINT32 length)
+{
+    siteEntry_t *pSite;
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if ((pSiteMgr==NULL) || (pProbeRespBuffer==NULL) || (length>=MAX_MGMT_BODY_LENGTH))
+    {
+        return NOK;
+    }
+
+    pSite = findSiteEntry(pSiteMgr, bssid);
+    if (pSite==NULL)
+    {
+        /*WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("siteMgr_saveProbeRespBuffer: site doesn't exist\n"));*/
+        return NOK;
+
+    }
+
+    os_memoryCopy(pSiteMgr->hOs, pSite->probeRespBuffer, pProbeRespBuffer, length);
+    pSite->osTimeStamp = os_timeStampMs(pSiteMgr->hOs);
+    pSite->probeRespLength = length;
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("siteMgr_saveProbeRespBuffer: BSSID=%x-%x-%x-%x-%x-%x, TSF=%x-%x-%x-%x-%x-%x-%x-%x, \n ts=%d, rssi=%d\n channel = %d \n",
+                           pSite->bssid.addr[0], pSite->bssid.addr[1], pSite->bssid.addr[2],
+                           pSite->bssid.addr[3], pSite->bssid.addr[4], pSite->bssid.addr[5],
+                           pSite->tsfTimeStamp[0], pSite->tsfTimeStamp[1], pSite->tsfTimeStamp[2], pSite->tsfTimeStamp[3],
+                           pSite->tsfTimeStamp[4], pSite->tsfTimeStamp[5], pSite->tsfTimeStamp[6], pSite->tsfTimeStamp[7],
+                           pSite->osTimeStamp,  pSite->rssi, pSite->channel));
+
+    return OK;
+}
+
+TI_STATUS siteMgr_saveBeaconBuffer(TI_HANDLE hSiteMgr, macAddress_t *bssid, UINT8 *pBeaconBuffer, UINT32 length)
+{
+    siteEntry_t *pSite;
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+
+    if ((pSiteMgr==NULL) || (pBeaconBuffer==NULL) || (length>=MAX_MGMT_BODY_LENGTH))
+    {
+        return NOK;
+    }
+
+    pSite = findSiteEntry(pSiteMgr, bssid);
+    if (pSite==NULL)
+    {
+        /*WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("siteMgr_saveBeaconBuffer: site doesn't exist\n"));*/
+        return NOK;
+
+    }
+
+    os_memoryCopy(pSiteMgr->hOs, pSite->beaconBuffer, pBeaconBuffer, length);
+    pSite->osTimeStamp = os_timeStampMs(pSiteMgr->hOs);
+    pSite->beaconLength = length;
+
+    /*if (pSiteMgr->pSitesMgmtParams->pPrimarySite!=NULL)
+    {
+        if (!os_memoryCompare(pSiteMgr->hOs, pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.ssidString, pSite->ssid.ssidString, pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.len))
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                                  ("siteMgr_saveBeaconBuffer: BSSID=%x-%x-%x-%x-%x-%x, TSF=%x-%x-%x-%x-%x-%x-%x-%x, \n ts=%d, rssi=%d \n",
+                                   pSite->bssid.addr[0], pSite->bssid.addr[1], pSite->bssid.addr[2],
+                                   pSite->bssid.addr[3], pSite->bssid.addr[4], pSite->bssid.addr[5],
+                                   pSite->tsfTimeStamp[0], pSite->tsfTimeStamp[1], pSite->tsfTimeStamp[2], pSite->tsfTimeStamp[3],
+                                   pSite->tsfTimeStamp[4], pSite->tsfTimeStamp[5], pSite->tsfTimeStamp[6], pSite->tsfTimeStamp[7],
+                                   pSite->osTimeStamp,  pSite->rssi));
+        }
+    }*/
+    pSite->ssid.ssidString[pSite->ssid.len] = '\0';
+
+    /*WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
+                          ("siteMgr_saveBeaconBuffer: BSSID=%x-%x-%x-%x-%x-%x, SSID=%s, \n ts=%d, rssi=%d\n channel = %d \n",
+                           pSite->bssid.addr[0], pSite->bssid.addr[1], pSite->bssid.addr[2],
+                           pSite->bssid.addr[3], pSite->bssid.addr[4], pSite->bssid.addr[5],
+                           pSite->ssid.ssidString, pSite->osTimeStamp,  pSite->rssi, pSite->channel));
+
+    */
+    return OK;
+}
+
+
+void siteMgr_resetChannelList(TI_HANDLE hSiteMgr)
+{
+    UINT8       index;
+    siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
+
+    if (hSiteMgr==NULL)
+    {
+        return;
+    }
+
+    for (index=0; index < pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->maxNumOfSites; index++)
+    {
+        if (pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[index].siteType != SITE_NULL)
+        {
+            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[index].prioritySite = FALSE;
+        }
+    }
+
+}
+
+
+siteEntry_t *siteMgr_findSiteEntry(TI_HANDLE hSiteMgrm, macAddress_t *bssid)
+{
+    return (findSiteEntry(hSiteMgrm, bssid));
+}
+
+
+
+void siteMgr_IsERP_Needed(TI_HANDLE hSiteMgr,BOOL *useProtection,BOOL *NonErpPresent,BOOL *barkerPreambleType)
+{
+    siteMgr_t       *pSiteMgr = (siteMgr_t*)hSiteMgr;
+    paramInfo_t     param;
+    siteEntry_t     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+
+    *useProtection = FALSE;
+    *NonErpPresent = FALSE;
+    *barkerPreambleType = FALSE;
+
+    param.paramType = CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM;
+    ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+
+    /* On WifiAdhoc (for band B) The STa should not include in the beacon an ERP IE (see WiFi B  clause 2.2, 5.8.2) */
+    if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
+    {
+        /* Return the default => ERP is not needed */
+        return;
+    }
+
+    /* check if STA is connected */
+    if (pPrimarySite)
+    {
+        if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE || pSiteMgr->siteMgrOperationalMode == DOT11_DUAL_MODE)
+        {
+            if(param.content.ctrlDataIbssProtecionType == ERP_PROTECTION_STANDARD)
+            {
+                if(pPrimarySite->siteType == SITE_SELF)
+                {
+                    if(pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX) /* if channel B&G*/
+                    {
+                            *useProtection = TRUE;
+                            *NonErpPresent = TRUE;
+                            *barkerPreambleType = TRUE;
+                    }
+                }
+                else if(pPrimarySite->bssType == BSS_INDEPENDENT)
+                {
+                    if(pPrimarySite->useProtection == TRUE)
+                        *useProtection = TRUE;
+                    if(pPrimarySite->NonErpPresent == TRUE)
+                        *NonErpPresent = TRUE;
+                    if(pPrimarySite->barkerPreambleType == PREAMBLE_SHORT)
+                        *barkerPreambleType = TRUE;
+                }
+            }
+        }
+    }
+}
+
+
+
+
+void siteMgr_gotFirstBcn(TI_HANDLE hSiteMgr)
+{
+        siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
+        int status ;
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  
+                                ("siteMgr_gotFirstBcn: dtimPeriod=%d, beaconInterval=%d\n",
+                                pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod,
+                                pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval));
+
+    /* Check if the Beacon Filter Desired State is TRUE */
+    pSiteMgr->beaconFilterParams.currentState = TRUE;
+    /* If the Beacon Filter was TRUE then send it to FW if not do not do nothing */
+    if( TRUE == pSiteMgr->beaconFilterParams.desiredState )
+    {
+        if ( (status = whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, pSiteMgr->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored)) != OK)
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
+                              POWER_MANAGER_MODULE_LOG,
+                              ("%s(%d) - Error N.%d in configuring beacon filtering !\n",
+                              __FILE__,__LINE__,status));
+        }
+        else
+        {           
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport,SITE_MGR_MODULE_LOG , ("--          Beacon Filter Enable Beacon Filtering MIB Was Sent to FW !!!  --\n"));
+        }
+    }
+    else
+    {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport,SITE_MGR_MODULE_LOG , ("--          Beacon Filter Disable Beacon Filtering - Do not send to FW Already Disabled !!!  --\n"));
+    }
+
+    whalCtrl_setDtimPeriod(pSiteMgr->hHalCtrl, pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod,
+                            pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval);
+
+    /* The power mode configuration gets overridden by the above DTIM period */
+    /* configuration. We use this call to send it again to the firmware. */
+    PowerMgr_reloadPowerMode(pSiteMgr->hPowerMgr);
+}
+
+void siteMgr_clearFirstBcnFlag(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
+
+    /* This is set to FALSE since the First Beaqcin should be received for the first beacon mechanism */
+       pSiteMgr->beaconFilterParams.currentState = FALSE;
+       whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, FALSE, pSiteMgr->beaconFilterParams.numOfStored);
+       
+
+    /* set Hw available until we get the first beacon */
+    MacServices_powerAutho_AwakeRequiredUpdate(pSiteMgr->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_FIRST_BEACON);
+
+    if(pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconReceiveAfterJoin = FALSE;
+}
+
+void siteMgr_setFirstBcnFlag(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
+
+    /* set Hw not available until now that the connection was closed */
+    MacServices_powerAutho_AwakeRequiredUpdate(pSiteMgr->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_FIRST_BEACON);
+    
+    if(pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
+        pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconReceiveAfterJoin = TRUE;
+}
+
+/**
+*
+* siteMgr_overwritePrimarySite
+*
+* \b Description: 
+*
+* This function sets new AP as a primary site and, if requested, stores previous
+* AP's info; called during roaming
+*
+* \b ARGS:
+*
+*  I   - pCurrBSS - Current BSS handle \n
+*  
+* \b RETURNS:
+*
+*  OK on success, NOK on failure.
+*
+* \sa 
+*/
+TI_STATUS siteMgr_overwritePrimarySite(TI_HANDLE hSiteMgr, bssEntry_t *newAP, BOOL requiredToStorePrevSite)
+{
+    siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
+    siteEntry_t *newApEntry;
+    mlmeIEParsingParams_t *ieListParseParams = mlmeParser_getParseIEsBuffer(pSiteMgr->hMlmeSm);
+
+    WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("siteMgr_overwritePrimarySite: new site bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n",
+               newAP->BSSID.addr[0], newAP->BSSID.addr[1], newAP->BSSID.addr[2],
+               newAP->BSSID.addr[3], newAP->BSSID.addr[4], newAP->BSSID.addr[5]));
+
+    /* If previous primary site present, and requested to save it - store it */
+    if (requiredToStorePrevSite)
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
+                                SITE_MGR_MODULE_LOG,
+                                ("siteMgr_overwritePrimarySite: required to store prev prim site \n"));
+        /* Store latest primary site, make ite a regular site */
+        pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+        pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->siteType = SITE_REGULAR;
+    }
+    else
+    {
+        WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
+                                SITE_MGR_MODULE_LOG,
+                                ("siteMgr_overwritePrimarySite: not required to store prev prim site \n"));
+        if (pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
+        {
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Removing Primary ssid=%s, bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n",
+            pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.ssidString,
+            pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[0], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[1], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[2],
+            pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[3], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[4], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[5] ));
+
+            pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType  = SITE_REGULAR;
+            pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconRecv = FALSE;
+            pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconReceiveAfterJoin = TRUE;
+
+            pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
+        }
+        else
+        {
+            WLAN_REPORT_ERROR(pSiteMgr->hReport,
+                                    SITE_MGR_MODULE_LOG,
+                                    ("siteMgr_overwritePrimarySite: primary site is NULL \n"));
+        }
+
+    }
+
+    /* Find not occupied entry in site table, and store new AP BSSID in */
+    /* If pPrimarySite is not set to NULL, store it in pPrevSite before updating */
+    newApEntry = findAndInsertSiteEntry(pSiteMgr, &(newAP->BSSID), newAP->band);
+
+    if (newApEntry != NULL)
+    {
+        /* Zero frame content */
+        os_memoryZero(pSiteMgr->hOs, ieListParseParams, sizeof(mlmeIEParsingParams_t));
+
+        /* Update parameters of new AP */
+        newApEntry->rssi            = newAP->RSSI;
+        newApEntry->bssType         = BSS_INFRASTRUCTURE;
+        newApEntry->dtimPeriod      = 1;
+        newApEntry->rxRate          = (rate_e)newAP->rxRate;
+        /* Mark the site as regular in order to prevent from calling Power manager during beacon parsing */
+        newApEntry->siteType        = SITE_REGULAR; 
+
+        os_memoryCopy(pSiteMgr->hOs, &newApEntry->ssid, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, sizeof(ssid_t));
+
+        if (newAP->resultType == SCAN_RFT_PROBE_RESPONSE)
+        {
+            ieListParseParams->frame.subType = PROBE_RESPONSE;
+            siteMgr_saveProbeRespBuffer(hSiteMgr, &(newAP->BSSID), newAP->pBuffer, newAP->bufferLength);
+        }
+        else
+        {
+            ieListParseParams->frame.subType = BEACON;
+            siteMgr_saveBeaconBuffer(hSiteMgr, &(newAP->BSSID), newAP->pBuffer, newAP->bufferLength);
+        }
+        ieListParseParams->band = newAP->band;
+        ieListParseParams->rxChannel = newAP->channel;
+        ieListParseParams->myBssid = FALSE;
+
+        ieListParseParams->frame.content.iePacket.pRsnIe = NULL;
+        ieListParseParams->frame.content.iePacket.rsnIeLen = 0;
+        ieListParseParams->frame.content.iePacket.barkerPreambleMode = PREAMBLE_UNSPECIFIED;
+        os_memoryCopy(pSiteMgr->hOs, (void *)ieListParseParams->frame.content.iePacket.timestamp, (void *)&newAP->lastRxTSF, TIME_STAMP_LEN);
+        ieListParseParams->frame.content.iePacket.beaconInerval     = newAP->beaconInterval;
+        ieListParseParams->frame.content.iePacket.capabilities  = newAP->capabilities;
+
+        if (mlmeParser_parseIEs(pSiteMgr->hMlmeSm, newAP->pBuffer, newAP->bufferLength, ieListParseParams) != OK)
+        {
+            /* Error in parsing Probe response packet - exit */
+            return NOK;
+        }
+
+        siteMgr_updateSite(hSiteMgr, &(newAP->BSSID), &ieListParseParams->frame, newAP->channel, newAP->band, FALSE);
+
+        /* Select the entry as primary site */
+        newApEntry->siteType = SITE_PRIMARY;
+        pSiteMgr->pSitesMgmtParams->pPrimarySite = newApEntry;
+        return OK;
+    }
+    else
+    {
+        return NOK;
+    }
+}
+
+#if 0
+/***********************************************************************
+                siteMgr_updateLowPriorityTimeout
+ ***********************************************************************
+DESCRIPTION: Call to the PowerCtrl with the new claculated low priority
+             timeout that is depend on the:
+             - short/long doze.
+             - beacon filtering number.
+             - beacon interval.
+
+INPUT:      hSiteMgr    -   site mgr handle.
+
+OUTPUT:
+
+RETURN:     UINT32 - the timeout in mSec.
+
+************************************************************************/
+static void siteMgr_updateLowPriorityTimeout(TI_HANDLE hSiteMgr)
+{
+    siteMgr_t *pSiteMgr = (siteMgr_t*)hSiteMgr;
+    UINT32 lowPriorityTimeout = 0;
+
+    if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
+    {
+        lowPriorityTimeout = SITE_MGR_IBSS_AGING_TIMEOUT_DEF;
+    }
+    else
+    {
+        /*
+        If the pPrimarySite is NULL then we cannot update the aging timeout
+        */
+        if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
+        {
+            WLAN_REPORT_ERROR(pSiteMgr->hReport,
+                              SITE_MGR_MODULE_LOG,
+                              ("there is NO primary site! pPrimarySite is NULL\n"));
+            return;
+        }
+        else
+        {
+            /*
+            in shortDoze and active mode the system behaviour is the same as regarding to
+            beacon evnets. On each beacon the TNET is awake and should received the beacon
+            */
+            if(pSiteMgr->powerSaveLdMode == FALSE)
+            {
+                lowPriorityTimeout = pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval;
+            }
+            else
+            /*
+            In longDoze, the interval time should based on  numOfBeaconFiltering * Dtim interval
+            */
+            {
+                /*
+                if beacon filtering disable.
+                */
+                if ( 0 == pSiteMgr->numOfBeaconFiltering )
+                {
+                    lowPriorityTimeout = pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod * pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval;
+                }
+                else
+                {
+                    lowPriorityTimeout = pSiteMgr->numOfBeaconFiltering * pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod * pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval;
+                }
+            }
+
+            WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
+                                    SITE_MGR_MODULE_LOG,
+                                    ("siteMgr_calcLowPriorityTimeout: lowPriorityTimeout = %d, BeaconInterval = %d, DtimPeriod = %d,powerSaveLdMode = %d, numOfBeaconFiltering = %d\n",
+                                    lowPriorityTimeout,
+                                    pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval,
+                                    pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod,
+                                    pSiteMgr->powerSaveLdMode,
+                                    pSiteMgr->numOfBeaconFiltering));
+        }
+    }
+
+    if (lowPriorityTimeout != 0)
+    {
+#ifdef NO_HAL_VOB
+        whalCtrl_setLowPriorityTimeout(pSiteMgr->hHalCtrl,
+                                       lowPriorityTimeout);
+#endif
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport,
+                          SITE_MGR_MODULE_LOG,
+                          ("illegal lowPriorityTimeout (=%d), configuration ABORTED!\n",lowPriorityTimeout));
+    }
+}
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/templates.c b/sta_dk_4_0_4_32/common/src/core/sme/siteMgr/templates.c
new file mode 100644 (file)
index 0000000..099bb45
--- /dev/null
@@ -0,0 +1,594 @@
+/** \file reportReplvl.c
+ *  \brief Report level implementation
+ *
+ *  \see reportReplvl.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*             MODULE: reportReplvl.c                                                                                                                          */
+/*    PURPOSE: Report level implementation                                                                                     */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "siteHash.h"
+#include "utils.h"
+#include "rsnApi.h"
+#include "regulatoryDomainApi.h"
+#include "siteMgrApi.h"
+
+/********************************************/
+/*             Functions Implementations                       */
+/********************************************/
+
+/************************************************************************
+ *                        buildNullTemplate                                                            *
+ ************************************************************************
+DESCRIPTION: This function build a NULL data template to set to the HAL 
+                               when joining an infrastructure network
+                               performs the following:
+                               -       Build a template & set the template len, the template type is set in the site mgr
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site manager  
+                       pTemplate       -       Pointer to the template structure               
+
+
+OUTPUT:                
+
+
+RETURN:     OK
+
+************************************************************************/
+TI_STATUS buildNullTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate)
+{
+       paramInfo_t                     param;
+       UINT32                          size;
+       nullDataTemplate_t      *pBuffer = (nullDataTemplate_t  *)pTemplate->pTemplate;
+       siteEntry_t                     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+       UINT16                          fc;
+
+       os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(nullDataTemplate_t));
+
+       /*
+        * Header First
+        */
+       /* Set destination address */
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.DA.addr), &(pPrimarySite->bssid), MAC_ADDR_LEN);  
+
+       /* Set BSSID address */
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.BSSID.addr), &(pPrimarySite->bssid), MAC_ADDR_LEN);  
+
+       /* Build Source address */
+       param.paramType = CTRL_DATA_MAC_ADDRESS;
+       ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.SA.addr), &(param.content.ctrlDataDeviceMacAddress), MAC_ADDR_LEN);  
+       
+       fc = DOT11_FC_DATA_NULL_FUNCTION;
+       fc |= (TRUE << DOT11_FC_TO_DS_SHIFT);
+
+       pBuffer->hdr.fc = ENDIAN_HANDLE_WORD(fc);
+
+       size = sizeof(dot11_mgmtHeader_t);
+
+       pTemplate->templateLen = size;
+       
+       return OK;
+}
+
+/************************************************************************
+ *                        buildProbeReqTemplate                                                        *
+ ************************************************************************
+DESCRIPTION: This function build a probe request template to set to the HAL in the scan process.
+                               performs the following:
+                               -       Build a template & set the template len, the template type is set in the site mgr
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site manager  
+                       pTemplate       -       Pointer to the template structure               
+                       pSsid           -       Desired SSID
+
+
+OUTPUT:                
+
+
+RETURN:     OK
+
+************************************************************************/
+TI_STATUS buildProbeReqTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate, ssid_t *pSsid, radioBand_e radioBand)
+{
+       paramInfo_t                     param;
+       char                            *pBuf;
+       int i;
+       probeReqTemplate_t      *pBuffer = (probeReqTemplate_t  *)pTemplate->pTemplate;
+       UINT32                          size;
+       dot11_RATES_t           *pDot11Rates;   
+       UINT32                          len = 0, ofdmIndex = 0;
+       UINT32                          suppRatesLen, extSuppRatesLen;
+       UINT8                           ratesBuf[MAX_SUPPORTED_RATES];  
+       UINT32                          supportedRateMask,basicRateMask;        
+
+       os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(probeReqTemplate_t));
+
+       /*
+        * Header First
+        */
+       /* Set destination address */
+       for (i = 0; i < MAC_ADDR_LEN; i++)
+               pBuffer->hdr.DA.addr[i] = 0xFF;
+
+       /* Set BSSID address */
+
+       for (i = 0; i < MAC_ADDR_LEN; i++)
+               pBuffer->hdr.BSSID.addr[i] = 0xFF;
+
+       /* Build Source address */
+       param.paramType = CTRL_DATA_MAC_ADDRESS;
+       ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.SA.addr), &(param.content.ctrlDataDeviceMacAddress), MAC_ADDR_LEN);  
+       
+       pBuffer->hdr.fc = ENDIAN_HANDLE_WORD(DOT11_FC_PROBE_REQ);
+
+       size = sizeof(dot11_mgmtHeader_t);
+       pBuf = (char *)&(pBuffer->infoElements);
+       
+   /*
+       * Informataion elements
+       */
+       /* SSID */
+       ((dot11_SSID_t *)(pBuf))->hdr.eleId = DOT11_SSID_ELE_ID;
+       ((dot11_SSID_t *)(pBuf))->hdr.eleLen = pSsid->len;
+       os_memoryCopy(pSiteMgr->hOs, pBuf + sizeof(dot11_eleHdr_t), (void *)pSsid->ssidString, pSsid->len);
+       size += sizeof(dot11_eleHdr_t) + pSsid->len;
+       pBuf += sizeof(dot11_eleHdr_t) + pSsid->len;
+
+       /* Rates */
+       pDot11Rates = (dot11_RATES_t *) pBuf;
+
+    /* 
+     * Supported rates in probe request will always use the default rates for BG or A bands,
+     * regardless of the STA desired rates.
+     */
+    if (radioBand == RADIO_BAND_2_4_GHZ)
+    {
+        /* Basic rates: 1,2,5.5,11 */  
+               basicRateMask = translateBasicRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[DOT11_G_MODE], FALSE);
+        /* Extended: 6,9,12,18,24,36,48,54 */
+        supportedRateMask = translateSupportedRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[DOT11_G_MODE], FALSE);
+    }
+    else if (radioBand == RADIO_BAND_5_0_GHZ)
+    {   /* Basic rates: 6,12,24 */
+        basicRateMask = translateBasicRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[DOT11_A_MODE], TRUE);
+         /* Extended: 9,18,24,36,48,54 */
+        supportedRateMask = translateSupportedRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[DOT11_A_MODE], TRUE);
+       }
+       else
+       {
+        WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  
+            ("buildProbeReqTemplate, radioBand =%d ???\n",radioBand));
+        /* Use default and pray for the best */
+        /* Basic rates: 1,2,5.5,11 */  
+        basicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
+        /* Extended: 6,9,12,18,24,36,48,54 */
+        supportedRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_UP_TO_54, FALSE);
+       }
+       
+       bitMapToNetworkStringRates(supportedRateMask,
+                                                          basicRateMask,
+                           ratesBuf, &len, &ofdmIndex);
+
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  
+                            ("buildProbeReqTemplate, supportedRateMask=0x%x, basicRateMask=0x%x, len=%d, ofdmIndex=%d, radioBand =%d\n",
+                             supportedRateMask,basicRateMask,len, ofdmIndex, radioBand));
+
+    
+    if(radioBand == RADIO_BAND_5_0_GHZ ||
+       pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
+          ofdmIndex == len)
+       {
+               pDot11Rates->hdr.eleId = DOT11_SUPPORTED_RATES_ELE_ID;
+               pDot11Rates->hdr.eleLen = len;
+               os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr.eleLen);
+               size += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               pBuf += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);               
+       }
+       else
+       {
+               pDot11Rates->hdr.eleId = DOT11_SUPPORTED_RATES_ELE_ID;
+               pDot11Rates->hdr.eleLen = ofdmIndex;
+               os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr.eleLen);
+               suppRatesLen = pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               pDot11Rates = (dot11_RATES_t *) (pBuf + suppRatesLen); 
+               pDot11Rates->hdr.eleId = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
+               pDot11Rates->hdr.eleLen = len - ofdmIndex;
+               os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr.eleLen);
+               extSuppRatesLen = pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               size += suppRatesLen + extSuppRatesLen;
+               pBuf += suppRatesLen + extSuppRatesLen;         
+       }
+
+       pTemplate->templateLen = size;
+       
+       return OK;
+}
+
+/************************************************************************
+ *                        buildProbeRspTemplate                                                        *
+ ************************************************************************
+DESCRIPTION: This function build a probe response template to set to the HAL 
+                               when joining an IBSS network.
+                               performs the following:
+                               -       Build a template & set the template len, the template type is set in the site mgr
+                               -       The template is built based on the chosen site attributes
+
+                       NOTE: This function is used to build beacon template too.
+                       The site manager set the template type (after thos function returns) to beacon or probe response accordingly.
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site manager  
+                       pTemplate       -       Pointer to the template structure               
+
+
+OUTPUT:                
+
+
+RETURN:     OK
+
+************************************************************************/
+TI_STATUS buildProbeRspTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate)
+{
+       paramInfo_t                     param;
+       UINT8                           *pBuf;
+       probeRspTemplate_t      *pBuffer = (probeRspTemplate_t  *)pTemplate->pTemplate;
+       siteEntry_t                     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+       int i;
+       UINT32                          size;
+       dot11_RATES_t           *pDot11Rates;
+       dot11_ERP_t         *pdot11Erp;
+       UINT32                          len = 0, ofdmIndex = 0;
+       BOOL                            extRates = FALSE;
+       BOOL                useProtection,NonErpPresent,barkerPreambleType;
+       UINT8                           ratesBuf[MAX_SUPPORTED_RATES];
+       UINT32                          supportedRateMask,basicRateMask;
+
+       os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(probeRspTemplate_t));
+
+       /*
+        * Header First
+        */
+       /* Set destination address */
+       for (i = 0; i < MAC_ADDR_LEN; i++)
+               pBuffer->hdr.DA.addr[i] = 0xFF;
+
+       /* Set BSSID address */
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.BSSID.addr), &(pPrimarySite->bssid), MAC_ADDR_LEN);  
+
+       /* Build Source address */
+       param.paramType = CTRL_DATA_MAC_ADDRESS;
+       ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.SA.addr), &(param.content.ctrlDataDeviceMacAddress), MAC_ADDR_LEN);  
+       
+       pBuffer->hdr.fc = ENDIAN_HANDLE_WORD(DOT11_FC_PROBE_RESP);
+
+       size = sizeof(dot11_mgmtHeader_t);
+       pBuf = (UINT8 *)pBuffer->timeStamp;
+   /*
+       * Fixed Fields
+       */
+       /* we skip the timestamp field */
+       size += TIME_STAMP_LEN;
+       pBuf += TIME_STAMP_LEN;
+
+       /* Beacon interval */
+       *((UINT16 *)pBuf) = pPrimarySite->beaconInterval;
+       size += FIX_FIELD_LEN;
+       pBuf += FIX_FIELD_LEN;
+
+       /* capabilities */
+       *((UINT16 *)pBuf) = pPrimarySite->capabilities;
+       size += FIX_FIELD_LEN;
+       pBuf += FIX_FIELD_LEN;
+
+       /*
+       * Informataion elements
+       */
+       /* SSID */
+       ((dot11_SSID_t *)(pBuf))->hdr.eleId = DOT11_SSID_ELE_ID;
+       ((dot11_SSID_t *)(pBuf))->hdr.eleLen = pPrimarySite->ssid.len;
+       os_memoryCopy(pSiteMgr->hOs, pBuf + sizeof(dot11_eleHdr_t), (void *)pPrimarySite->ssid.ssidString, pPrimarySite->ssid.len);
+       size += sizeof(dot11_eleHdr_t) + pPrimarySite->ssid.len;
+       pBuf += sizeof(dot11_eleHdr_t) + pPrimarySite->ssid.len;
+
+       /* Rates */
+
+       pDot11Rates = (dot11_RATES_t *) pBuf;
+
+       if (pPrimarySite->channel == SPECIAL_BG_CHANNEL) 
+       {
+               supportedRateMask = getSupportedRateMaskForSpecialBGchannel() ;
+               basicRateMask     = getBasicRateMaskForSpecialBGchannel();
+       }
+       else
+       {
+               supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
+               basicRateMask     = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
+       }
+       
+       bitMapToNetworkStringRates(supportedRateMask,
+                                                          basicRateMask,
+                                                          ratesBuf, &len, &ofdmIndex);
+
+    if(pSiteMgr->siteMgrOperationalMode != DOT11_G_MODE ||
+       pSiteMgr->pDesiredParams->siteMgrUseDraftNum == DRAFT_5_AND_EARLIER ||
+          ofdmIndex == len)
+       {
+               pDot11Rates->hdr.eleId = DOT11_SUPPORTED_RATES_ELE_ID;
+               pDot11Rates->hdr.eleLen = len;
+               os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr.eleLen);
+               size += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               pBuf += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);               
+       }
+       else
+       {
+               pDot11Rates->hdr.eleId = DOT11_SUPPORTED_RATES_ELE_ID;
+               pDot11Rates->hdr.eleLen = ofdmIndex;
+               os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, ratesBuf, pDot11Rates->hdr.eleLen);
+               size += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               pBuf += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               extRates = TRUE;
+       }
+
+       /* DS */
+       ((dot11_DS_PARAMS_t *)(pBuf))->hdr.eleId = DOT11_DS_PARAMS_ELE_ID;
+       ((dot11_DS_PARAMS_t *)(pBuf))->hdr.eleLen = DOT11_DS_PARAMS_ELE_LEN;
+       ((dot11_DS_PARAMS_t *)(pBuf))->currChannel = pPrimarySite->channel;
+       size += sizeof(dot11_eleHdr_t) + DOT11_DS_PARAMS_ELE_LEN;
+       pBuf += sizeof(dot11_eleHdr_t) + DOT11_DS_PARAMS_ELE_LEN;
+
+       /* IBSS */
+       ((dot11_IBSS_PARAMS_t *)(pBuf))->hdr.eleId = DOT11_IBSS_PARAMS_ELE_ID;
+       ((dot11_IBSS_PARAMS_t *)(pBuf))->hdr.eleLen = DOT11_IBSS_PARAMS_ELE_LEN;
+#if 1
+       ((UINT8 *)&((dot11_IBSS_PARAMS_t *)(pBuf))->atimWindow)[0] = ((UINT8 *)&pPrimarySite->atimWindow)[0];
+       ((UINT8 *)&((dot11_IBSS_PARAMS_t *)(pBuf))->atimWindow)[1] = ((UINT8 *)&pPrimarySite->atimWindow)[1];
+#else /* fix for WinCE */
+       COPY_UNALIGNED_WORD(((UINT8 *)&((dot11_IBSS_PARAMS_t *)(pBuf))->atimWindow), &pPrimarySite->atimWindow);
+#endif
+       pPrimarySite->atimWindow = ENDIAN_HANDLE_WORD(pPrimarySite->atimWindow);
+
+       size += sizeof(dot11_eleHdr_t) + DOT11_IBSS_PARAMS_ELE_LEN;
+       pBuf += sizeof(dot11_eleHdr_t) + DOT11_IBSS_PARAMS_ELE_LEN;
+
+       /* Add country Information Element */
+       param.paramType = REGULATORY_DOMAIN_ENABLED_PARAM;
+       regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
+
+       if(     param.content.regulatoryDomainEnabled == TRUE )
+       {
+        /* get country IE */
+        param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
+               regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain, &param);
+
+        /* Check if a country IE was found */
+               if(param.content.pCountry != NULL)
+               {
+                       *pBuf = DOT11_COUNTRY_ELE_ID;
+                       pBuf += 1;
+                       size += 1;
+                       *pBuf = (UINT8)param.content.pCountry->len;
+                       pBuf += 1;
+                       size += 1;
+                       os_memoryCopy(pSiteMgr->hOs, pBuf , &param.content.pCountry->countryIE, param.content.pCountry->len);
+                       pBuf += param.content.pCountry->len;
+                       size += param.content.pCountry->len;
+               }
+       }
+        
+       /*ERP IE*/
+       siteMgr_IsERP_Needed(pSiteMgr,&useProtection,&NonErpPresent,&barkerPreambleType);
+       if (useProtection || NonErpPresent || barkerPreambleType)
+       {
+               pdot11Erp = (dot11_ERP_t *) pBuf;
+               pdot11Erp->hdr.eleId = DOT11_ERP_IE_ID;
+               pdot11Erp->hdr.eleLen = 1;
+               if (NonErpPresent)
+                       pdot11Erp->ctrl |= ERP_IE_NON_ERP_PRESENT_MASK;
+               if (useProtection)
+                       pdot11Erp->ctrl |= ERP_IE_USE_PROTECTION_MASK;
+               if (barkerPreambleType)
+                       pdot11Erp->ctrl |= ERP_IE_BARKER_PREAMBLE_MODE_MASK;
+               size += pdot11Erp->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               pBuf += pdot11Erp->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               
+       }
+
+
+       /* Extended supported rates IE */
+       if(extRates)
+       {
+               pDot11Rates = (dot11_RATES_t *) pBuf;
+               pDot11Rates->hdr.eleId = DOT11_EXT_SUPPORTED_RATES_ELE_ID;
+               pDot11Rates->hdr.eleLen = len - ofdmIndex;
+               os_memoryCopy(pSiteMgr->hOs, (void *)pDot11Rates->rates, &ratesBuf[ofdmIndex], pDot11Rates->hdr.eleLen);
+               size += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);
+               pBuf += pDot11Rates->hdr.eleLen + sizeof(dot11_eleHdr_t);       
+       }
+
+    /* no need to insert RSN information elements */
+                
+       pTemplate->templateLen = size;
+       WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Probe response template len = %d\n",size));
+       
+       return OK;
+}
+
+/************************************************************************
+ *                        buildPsPollTemplate                                                  *
+ ************************************************************************
+DESCRIPTION: This function build a ps poll template
+                               performs the following:
+                               -       Build a template & set the template len, the template type is set in the site mgr
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site manager  
+                       pTemplate       -       Pointer to the template structure               
+                       pSsid           -       Desired SSID
+
+OUTPUT:                
+
+RETURN:     OK
+************************************************************************/
+TI_STATUS buildPsPollTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate)
+{
+    paramInfo_t                        param;
+    whalParamInfo_t     whalParam;
+       UINT32                          size;
+       psPollTemplate_t        *pBuffer = (psPollTemplate_t *)pTemplate->pTemplate;
+       siteEntry_t                     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+       UINT16                          fc;
+
+       os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(psPollTemplate_t));
+
+       /*
+        * Header First
+        */
+       
+       /* Set BSSID address */
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.BSSID.addr), &(pPrimarySite->bssid), MAC_ADDR_LEN);  
+
+       /* Build Source address */
+       param.paramType = CTRL_DATA_MAC_ADDRESS;
+       ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.TA.addr), &(param.content.ctrlDataDeviceMacAddress), MAC_ADDR_LEN);  
+       
+    /*
+    **   Building the Frame Control word (16 bits)
+    ** ---------------------------------------------
+    ** Type = Control
+    ** SubType = Power Save (PS) POLL,  */
+    fc = DOT11_FC_PS_POLL;
+    /*
+    ** setting the Power Management bit in the Frame control field
+    ** to be "Power Save mode"
+    */
+    fc |= (0x1 << DOT11_FC_PWR_MGMT_SHIFT);
+
+    pBuffer->hdr.fc = ENDIAN_HANDLE_WORD(fc);
+
+    /*
+    **   Association ID
+    ** -----------------
+    */
+    whalParam.paramType = HAL_CTRL_AID_PARAM;
+    whalCtrl_GetParam (pSiteMgr->hHalCtrl, &whalParam) ;
+
+    /* AID should have its two MSB bit Set to "1"*/
+    pBuffer->hdr.AID = whalParam.content.halCtrlAid | 0xC000;
+
+       size = sizeof(dot11_PsPollFrameHeader_t);
+
+       pTemplate->templateLen = size;
+       
+
+
+       return OK;
+}
+
+
+/************************************************************************
+ *                        buildQosNullDataTemplate                                                     *
+ ************************************************************************
+DESCRIPTION: This function build a qos null data template
+                               performs the following:
+                               -       Build a template & set the template len, the template type is set in the site mgr
+                                                                                                   
+INPUT:      pSiteMgr   -       Handle to site manager  
+                       pTemplate       -       Pointer to the template structure               
+                       pSsid           -       Desired SSID
+
+OUTPUT:                
+
+RETURN:     OK
+************************************************************************/
+TI_STATUS buildQosNullDataTemplate(siteMgr_t *pSiteMgr, whalCtrl_setTemplate_t *pTemplate, UINT8 userPriority)
+{
+       paramInfo_t                     param;
+       UINT32                          size;
+       QosNullDataTemplate_t   *pBuffer = (QosNullDataTemplate_t       *)pTemplate->pTemplate;
+       siteEntry_t                     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
+       UINT16                          fc;
+
+       os_memoryZero(pSiteMgr->hOs, pBuffer, sizeof(QosNullDataTemplate_t));
+
+       /*
+        * Header First
+        */
+       /* Set destination address */
+    if (pPrimarySite)
+    {
+         os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.address1.addr), &(pPrimarySite->bssid), MAC_ADDR_LEN);  
+
+         /* Set BSSID address */
+         os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.address3.addr), &(pPrimarySite->bssid), MAC_ADDR_LEN);  
+    }
+    else
+    {
+         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("No Primary site so cannot fill QosNullData template\n"));
+    }
+
+       /* Build Source address */
+       param.paramType = CTRL_DATA_MAC_ADDRESS;
+       ctrlData_getParam(pSiteMgr->hCtrlData, &param);
+       os_memoryCopy(pSiteMgr->hOs, &(pBuffer->hdr.address2.addr), &(param.content.ctrlDataDeviceMacAddress), MAC_ADDR_LEN);  
+
+       fc = DOT11_FC_DATA_NULL_QOS;
+       fc |= (TRUE << DOT11_FC_TO_DS_SHIFT);
+
+    pBuffer->hdr.qosControl = (userPriority << QOS_CONTROL_UP_SHIFT);
+
+       pBuffer->hdr.fc = ENDIAN_HANDLE_WORD(fc);
+
+       size = sizeof(dot11_header_t);
+
+       pTemplate->templateLen = size;
+       
+       return OK;    
+}
+   
+   
+   
+   
+   
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSm.c b/sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSm.c
new file mode 100644 (file)
index 0000000..a1f5fe9
--- /dev/null
@@ -0,0 +1,1223 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 smeSm.c
+ *  \brief SME SM implementation
+ *
+ *  \see smeSm.h
+ */
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "srcApi.h"
+#include "report.h"
+#include "connApi.h"
+#include "siteMgrApi.h"
+#include "smeSmApi.h"
+#include "utils.h"  
+#include "fsm.h"  
+#include "smeSm.h" 
+#include "smeApi.h" 
+#include "DataCtrl_Api.h"
+#include "regulatoryDomainApi.h"
+#include "TrafficMonitorAPI.h"
+#include "PowerMgr_API.h"
+#include "EvHandler.h"
+#include "TI_IPC_Api.h"
+#include "ScanCncnApi.h"
+#ifdef EXC_MODULE_INCLUDED
+#include "DataCtrl_Api.h"
+#endif
+#include "apConn.h"
+
+
+/* State Machine Functions */
+static TI_STATUS idle_to_interScan(void *pData);
+
+static TI_STATUS interScan_to_scanning(void *pData);
+
+static TI_STATUS interScan_to_idle(void *pData);
+
+static TI_STATUS scan_to_idle(void *pData);
+
+static TI_STATUS scan_to_scan(void *pData);
+
+static TI_STATUS scan_to_select(void *pData);
+
+static TI_STATUS scan_to_interScan(void *pData);
+
+static TI_STATUS select_to_InterScan(void *pData);
+
+static TI_STATUS select_to_connect(void *pData);
+
+static TI_STATUS connecting_To_Disconnecting(void *pData);
+
+static TI_STATUS connecting_to_connected(void *pData);
+
+static TI_STATUS connecting_to_selecting(void *pData);
+
+static TI_STATUS connected_to_interScan(void *pData);
+
+static TI_STATUS connected_To_disconnecting(void *pData);
+
+static TI_STATUS disconnecting_to_interScan(void *pData);
+
+
+/* Local functions prototypes */
+static TI_STATUS actionUnexpected(void *pData);
+
+static TI_STATUS actionNop(void *pData);
+
+static TI_STATUS smeCallScan(void *pData);
+
+static TI_STATUS chooseScanBand(smeSm_t* pSmeSm, radioBand_e *band);
+
+static TI_STATUS smeSm_changeBandParams(TI_HANDLE      hSmeSm, radioBand_e radioBand);
+
+static TI_STATUS smeSm_startInterScanTimeout(TI_HANDLE hSmeSm);
+
+static TI_STATUS smeSm_stopInterScanTimeout(TI_HANDLE hSmeSm);
+
+static void             smeSm_sendDisassociateEvent(smeSm_t* pSmeSm);
+
+/****************************************************/
+/*             Interface Functions Implementations                     */
+/****************************************************/
+
+
+/***********************************************************************
+ *                        smeSm_smCreate                                                                       
+ ***********************************************************************
+DESCRIPTION: State machine creation function, called by the SME SM API. Allocates the state machine 
+                                                                                                   
+INPUT:      hOs        -       OS handle.
+
+OUTPUT:                
+
+RETURN:     State machine pointer on success, NULL otherwise
+
+************************************************************************/
+fsm_stateMachine_t *smeSm_smCreate(TI_HANDLE hOs)
+{
+       TI_STATUS status;
+       fsm_stateMachine_t *pFsm;
+
+       status = fsm_Create(hOs, &pFsm, SME_SM_NUM_STATES, SME_SM_NUM_EVENTS);
+       
+       if (status != OK)
+               return NULL;
+
+       return pFsm;
+}
+
+/***********************************************************************
+ *                        smeSm_smConfig                                                                       
+ ***********************************************************************
+DESCRIPTION: State machine configuration function, called by the SME SM API. Configures the state machine 
+                                                                                                   
+INPUT:      pSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_smConfig(smeSm_t *pSmeSm)
+{
+    paramInfo_t param;
+
+       fsm_actionCell_t    smMatrix[SME_SM_NUM_STATES][SME_SM_NUM_EVENTS] =
+       {
+               /* next state and actions for IDLE state */
+               {
+                       {SME_SM_STATE_INTER_SCAN, idle_to_interScan},       /*  "EVENT_START",                   */
+                       {SME_SM_STATE_IDLE, actionUnexpected},                  /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_IDLE, actionUnexpected},                  /*  "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_IDLE, actionUnexpected},                  /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_IDLE, actionUnexpected},                  /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_IDLE, actionUnexpected},                  /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_IDLE, actionUnexpected},                  /*  "EVENT_CONN_FAILURE",                  */
+                       {SME_SM_STATE_IDLE, actionNop},                         /*  "EVENT_RESELECT",                */
+                       {SME_SM_STATE_IDLE, actionNop},                         /*  "EVENT_DISCONNECT"*/
+               },
+
+               /* next state and actions for SCANNING state */
+               {       
+                       {SME_SM_STATE_SCANNING, actionUnexpected},          /*  "EVENT_START",                   */
+                       {SME_SM_STATE_IDLE,      scan_to_idle},                         /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_SELECTING, scan_to_select},           /*  "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_SCANNING, actionUnexpected},          /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_SCANNING, actionUnexpected},          /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_SCANNING, actionUnexpected},          /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_SCANNING, actionUnexpected},          /*  "EVENT_CONN_FAILURE",                  */
+                       {SME_SM_STATE_SCANNING, scan_to_scan},              /*  "EVENT_RESELECT",*/
+                       {SME_SM_STATE_INTER_SCAN, scan_to_interScan},           /*  "EVENT_DISCONNECT"*/
+               },
+
+               /* next state and actions for SELECTING state */
+               {       
+                       {SME_SM_STATE_SELECTING, actionUnexpected},         /*  "EVENT_START",                   */
+                       {SME_SM_STATE_SELECTING, actionUnexpected},                     /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_SELECTING, actionUnexpected},         /*  "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_CONNECTING, select_to_connect},       /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_INTER_SCAN, select_to_InterScan},         /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_SELECTING, actionUnexpected},         /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_SELECTING, actionUnexpected},         /*  "EVENT_CONN_FAILURE",                   */
+               {SME_SM_STATE_SELECTING, actionUnexpected},         /*  "EVENT_RESELECT",                */
+                       {SME_SM_STATE_SELECTING, actionUnexpected},         /*  "EVENT_DISCONNECT",*/
+               },
+
+               /* next state and actions for CONNECTING state */
+               {       
+                       {SME_SM_STATE_SCANNING,      actionUnexpected},               /*  "EVENT_START",                   */
+                       {SME_SM_STATE_DISCONNECTING, connecting_To_Disconnecting},    /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_CONNECTING,    actionUnexpected},               /*  "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_CONNECTING,    actionUnexpected},               /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_CONNECTING,    actionUnexpected},               /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_CONNECTED,     connecting_to_connected},        /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_SELECTING,     connecting_to_selecting},        /*  "EVENT_CONN_FAILURE",                  */
+                       {SME_SM_STATE_DISCONNECTING, connecting_To_Disconnecting},    /*  "EVENT_RESELECT",               */
+                       {SME_SM_STATE_DISCONNECTING, connecting_To_Disconnecting},    /*  "EVENT_DISCONNECT", */
+               },
+
+               /* next state and actions for CONNECTED state */
+               {       
+                       {SME_SM_STATE_SCANNING, actionUnexpected},                                      /*  "EVENT_START",                   */
+                       {SME_SM_STATE_DISCONNECTING, connected_To_disconnecting},               /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_CONNECTED, actionUnexpected},                                             /* "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_CONNECTED, actionUnexpected},                                             /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_CONNECTED, actionUnexpected},                                             /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_CONNECTED, actionUnexpected},                                     /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_INTER_SCAN, connected_to_interScan},                      /*  "EVENT_CONN_FAILURE",                   */
+                       {SME_SM_STATE_DISCONNECTING, connected_To_disconnecting},       /*  "EVENT_RESELECT",                */
+                       {SME_SM_STATE_DISCONNECTING     ,connected_To_disconnecting},           /*  "EVENT_DISCONNECT",*/
+               },
+
+           /* next state and actions for DISCONNECTING state */
+               {       
+                       {SME_SM_STATE_DISCONNECTING,      actionNop},                                   /*  "EVENT_START",                   */
+                       {SME_SM_STATE_DISCONNECTING,      actionNop},                                   /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_DISCONNECTING, actionUnexpected},                                 /*  "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_DISCONNECTING, actionUnexpected},                                 /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_DISCONNECTING, actionUnexpected},                                 /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_DISCONNECTING, actionUnexpected},                                 /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_INTER_SCAN, disconnecting_to_interScan},                  /*  "EVENT_CONN_FAILURE",                  */
+                       {SME_SM_STATE_DISCONNECTING,       actionNop},                              /*  "EVENT_RESELECT",               */
+                       {SME_SM_STATE_DISCONNECTING,       actionNop},                              /*  "EVENT_DISCONNECT",*/
+               },
+
+
+               /* next state and actions for STATE_INTER_SCAN_TIMEOUT state */
+               {
+                       {SME_SM_STATE_INTER_SCAN, actionUnexpected},          /*  "EVENT_START",                   */
+                       {SME_SM_STATE_IDLE, interScan_to_idle},                           /*  "EVENT_STOP",                    */
+                       {SME_SM_STATE_INTER_SCAN, actionUnexpected},          /*  "EVENT_SCAN_COMPLETE",           */
+                       {SME_SM_STATE_INTER_SCAN, actionUnexpected},          /*  "EVENT_SELECT_SUCCESS",          */
+                       {SME_SM_STATE_INTER_SCAN, actionUnexpected},          /*  "EVENT_SELECT_FAILURE",          */
+                       {SME_SM_STATE_INTER_SCAN, actionUnexpected},          /*  "EVENT_CONN_SUCCESS",            */
+                       {SME_SM_STATE_INTER_SCAN, actionUnexpected},          /*  "EVENT_CONN_FAILURE",                  */
+                       {SME_SM_STATE_SCANNING, interScan_to_scanning},       /*  "EVENT_RESELECT",                */
+                       {SME_SM_STATE_INTER_SCAN, actionNop},                             /*  "EVENT_DISCONNECT",*/
+               },
+       
+       };
+
+       pSmeSm->dualBandReScanFlag = FALSE;
+       pSmeSm->reScanFlag = FALSE;
+       pSmeSm->radioOn    = FALSE;
+    pSmeSm->immediateShutdownRequired = FALSE;
+       
+    /* if desired SSID is junk SSID, don't connect (until new SSID is set) */
+    param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+    siteMgr_getParam( pSmeSm->hSiteMgr, &param );
+    
+    if ( utils_isJunkSSID( &(param.content.siteMgrDesiredSSID) ) )
+    {
+        pSmeSm->connectEnabled = FALSE;
+    }
+    else
+    {
+        pSmeSm->connectEnabled = TRUE;
+    }
+
+       /* First event should indicate to the upper layer that STA is disassociated. */
+       pSmeSm->DisAssoc.mgmtStatus = STATUS_UNSPECIFIED;
+       pSmeSm->DisAssoc.uStatusCode = 0;
+       smeSm_sendDisassociateEvent(pSmeSm);
+
+#ifdef TI_DBG
+       /* clear statistics */
+       smeSm_resetStats( (TI_HANDLE)pSmeSm );
+#endif
+
+       return fsm_Config(pSmeSm->pFsm, (fsm_Matrix_t)smMatrix, SME_SM_NUM_STATES, SME_SM_NUM_EVENTS, smeSm_SMEvent, pSmeSm->hOs);
+}
+
+/***********************************************************************
+ *                        smeSm_smUnLoad                                                                       
+ ***********************************************************************
+DESCRIPTION: State machine unload function, called by the SME SM API. Unloads the state machine 
+                                                                                                   
+INPUT:      hOs                -       OS handle.
+                       pFsm    -       Pointer to the state machine
+
+OUTPUT:                
+
+RETURN:     State machine pointer on success, NULL otherwise
+
+************************************************************************/
+TI_STATUS smeSm_smUnLoad(TI_HANDLE hOs, fsm_stateMachine_t *pFsm)
+{
+       fsm_Unload(hOs, pFsm);
+       
+       return OK;
+}
+
+/***********************************************************************
+ *                        smeSm_SMEvent                                                                        
+ ***********************************************************************
+DESCRIPTION: SME SM event processing function, called by the SME SM API
+                               Perform the following:
+                               -       Print the state movement as a result from the event
+                               -       Calls the generic state machine event processing function which preform the following:
+                                       -       Calls the corresponding callback function
+                                       -       Move to next state
+                               
+INPUT:         currentState    -       Pointer to the connection current state.
+                       event   -       Received event
+                       pSmeSm  -       SME SM handle
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+#ifdef REPORT_LOG
+
+static char *stateDesc[SME_SM_NUM_STATES] = 
+       {
+               "STATE_IDLE",
+               "STATE_SCANNING",
+               "STATE_SELECTING",
+               "STATE_CONNECTING",
+               "STATE_CONNECTED",
+               "STATE_DISCONNECTING",
+               "STATE_INTER_SCAN",
+       };
+
+static char *eventDesc[SME_SM_NUM_EVENTS] = 
+       {
+               "EVENT_START",
+               "EVENT_STOP",
+               "EVENT_SCAN_COMPLETE",
+               "EVENT_SELECT_SUCCESS",
+               "EVENT_SELECT_FAILURE",
+               "EVENT_CONN_SUCCESS",
+               "EVENT_CONN_FAILURE",
+               "EVENT_RESELECT",
+               "EVENT_DISCONNECT",
+       };
+
+#endif
+
+
+TI_STATUS smeSm_SMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hSmeSm)
+{
+   smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+       TI_STATUS               status;
+       UINT8           nextState;
+
+       status = fsm_GetNextState(pSmeSm->pFsm, *currentState, event, &nextState);
+       if (status != OK)
+       {
+               WLAN_REPORT_SM(pSmeSm->hReport, SME_SM_MODULE_LOG, ("State machine error, failed getting next state\n"));
+               return(NOK);
+       }
+
+       WLAN_REPORT_SM(pSmeSm->hReport, SME_SM_MODULE_LOG, 
+                                                         ("<%s, %s> --> %s\n\n",
+                                                          stateDesc[*currentState],
+                                                          eventDesc[event],
+                                                          stateDesc[nextState]));
+
+       status = fsm_Event(pSmeSm->pFsm, currentState, event, (void *)pSmeSm);
+
+       return status;
+}
+
+
+/************************************************************************************************************/
+/*             In the following section are listed the callback function used by the SME state machine                         */
+/************************************************************************************************************/
+
+/* START_SCAN */ 
+TI_STATUS sme_startScan(void *pData)
+{
+       paramInfo_t     param;
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+   
+   /*
+       * Support Dual Mode Operation
+       */ 
+
+    radioBand_e        band; 
+
+       /*
+        * If scan is disabled then send self scan complete event, skipping the scan procedure.
+        */ 
+       if (pSmeSm->scanEnabled != SCAN_ENABLED)
+       {
+               if (pSmeSm->scanEnabled == SKIP_NEXT_SCAN) 
+               {
+                       pSmeSm->scanEnabled = SCAN_ENABLED;
+               }
+               return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE , pSmeSm);
+       }
+       
+
+    /* if performing a dual band rescan now */
+    if ( TRUE == pSmeSm->dualBandReScanFlag )
+    {
+        /* mark that no more scans are needed */
+        pSmeSm->dualBandReScanFlag = FALSE;
+               chooseScanBand(pSmeSm, &band);
+               smeSm_changeBandParams(pSmeSm, band);
+    }
+    else
+    {
+        param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
+        siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+
+        if(param.content.siteMgrDot11Mode == DOT11_DUAL_MODE) 
+        {
+               pSmeSm->dualBandReScanFlag = TRUE;
+               chooseScanBand(pSmeSm, &band);
+               smeSm_changeBandParams(pSmeSm, band);
+        }
+    }
+
+    return smeCallScan(pData);
+}
+
+
+/* RESTART_SCAN when exiting from IDLE state*/ 
+static TI_STATUS idle_to_interScan(void *pData)
+{
+       smeSm_t         *pSmeSm = (smeSm_t *)pData;
+
+       pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
+
+    /* Set the SCR group to inter SCAN */
+    scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
+
+    /*
+        * If the connection is enabled then initiate "reselect" event that moves the
+        * SM into scan state. 
+        */
+       if( pSmeSm->connectEnabled ){
+               return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT , pSmeSm);
+       }
+       /* connectEnabled is FALSE, need to stay at this state until it will be changed. */
+
+       return OK;
+}
+
+
+
+TI_STATUS interScan_to_scanning(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+       
+       pSmeSm->bSendDisAssocEvent = FALSE; 
+       
+       smeSm_stopInterScanTimeout(pSmeSm);
+               
+    /* Set SCR to "first connection" */
+       scr_setGroup( pSmeSm->hScr, SCR_GID_CONNECT );
+
+#ifdef TI_DBG
+       /* update statistics - count scan attempts for connection */
+       pSmeSm->smeStats.currentNumberOfScanAttempts++;
+#endif
+       return (sme_startScan(pData));
+}
+
+
+
+static TI_STATUS disconnecting_to_interScan(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
+
+    scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
+    
+    siteMgr_disSelectSite(pSmeSm->hSiteMgr);
+
+       /*
+        *  Notify that the driver is disassociated to the supplicant\IP stack. 
+        */
+       smeSm_sendDisassociateEvent(pSmeSm);
+
+       if (!pSmeSm->scanEnabled) 
+       {
+               pSmeSm->connectEnabled = FALSE;
+       }
+
+       /* Radio ON and connection is enabled go to scanning */
+       if( pSmeSm->radioOn )
+       {
+               if(     pSmeSm->connectEnabled )
+                       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT , pSmeSm);
+
+               else {
+                       /* Radio is on but connection is disabled, stay at interScan state 
+                               without starting the interscan timer. */
+       
+                       /* SCR is set to enable only APP scan */
+                       return OK;
+               }
+       }       
+
+       else{ 
+                       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP , pSmeSm);
+       }
+}
+
+
+static TI_STATUS connected_to_interScan(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
+       
+       siteMgr_disSelectSite(pSmeSm->hSiteMgr);
+
+       scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
+
+       /*
+        *  Notify that the driver is associated to the supplicant\IP stack. 
+        */
+       smeSm_sendDisassociateEvent(pSmeSm);
+
+       if (!pSmeSm->scanEnabled) 
+       {
+               pSmeSm->connectEnabled = FALSE;
+       }
+
+       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT , pSmeSm);
+}
+
+
+static TI_STATUS select_to_InterScan(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+               
+       siteMgr_disSelectSite(pSmeSm->hSiteMgr);
+
+       /* SCR is set to enable only APP scan */
+    scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
+    
+    if (pSmeSm->connectEnabled)
+       {
+               smeSm_startInterScanTimeout(pSmeSm);
+       }
+
+       if ((pSmeSm->bSendDisAssocEvent == TRUE) || (pSmeSm->scanEnabled == FALSE))
+    {
+               /*
+                *  Notify that the driver is disassociated to the supplicant\IP stack. 
+                */
+               smeSm_sendDisassociateEvent(pSmeSm);
+       }
+
+       return OK;
+}
+
+
+
+static TI_STATUS scan_to_interScan(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+       
+       /* SCR is set to enable only APP scan */
+       scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
+
+       pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
+
+       if (pSmeSm->connectEnabled)
+       {
+               smeSm_startInterScanTimeout(pSmeSm);
+       }
+
+       return OK;
+
+}
+
+
+/* STOP_SCAN, START_SCAN */ 
+static TI_STATUS scan_to_scan(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+       
+       WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG, ("Setting reScanFlag to ON\n"));
+       
+       pSmeSm->reScanFlag = TRUE;
+       
+       scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
+       
+       return OK;
+}
+
+
+
+/* CANCEL INTER_SCAN TIMEOUT*/ 
+static TI_STATUS interScan_to_idle(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       smeSm_stopInterScanTimeout(pSmeSm);
+       
+    /* Change shutdown status flag to indicate SME is in IDLE state */
+    pSmeSm->shutDownStatus |= DRIVER_SHUTDOWN_SME_STOPPED;
+
+       /* Set SCR state to "Idle" */
+    scr_setGroup( pSmeSm->hScr, SCR_GID_IDLE );
+    
+       return OK;
+       
+}
+
+
+/* Stop current scanning and  go to idle */ 
+static TI_STATUS scan_to_idle(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       /* stopping the current active scan process */
+       scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
+
+    /* Change shutdown status flag to indicate SME is in IDLE state */
+    pSmeSm->shutDownStatus |= DRIVER_SHUTDOWN_SME_STOPPED;
+
+       /* Set the SCR group to "idle" */
+    scr_setGroup( pSmeSm->hScr, SCR_GID_IDLE );
+
+       return OK;
+}
+
+/* SELECT */ 
+static TI_STATUS scan_to_select(void *pData)
+{
+       smeSm_t                 *pSmeSm = (smeSm_t *)pData;
+
+       if (!pSmeSm->connectEnabled)
+       {
+               return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_FAILURE, pSmeSm);
+       }
+
+       siteMgr_resetAttemptsNumberParameter(pSmeSm->hSiteMgr);
+
+       return siteMgr_selectSite(pSmeSm->hSiteMgr);
+}
+
+
+
+/* START_TX, CONNECT */ 
+static TI_STATUS select_to_connect(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+    paramInfo_t param;
+
+       /* From this moment forward we will send DisAssociation event even if the connection failed */
+       pSmeSm->bSendDisAssocEvent = TRUE;
+
+    /* if we are about o start an IBSS, the conn SM will wait for few seconds before sending connection
+       failure indication, so that the SME will rescan for IBSSes with the same SSID. To enable application
+       scan during this period, in this case ONLY we change here the SCR group ID to inter scan */
+       param.paramType = CONN_TYPE_PARAM;
+       conn_getParam(pSmeSm->hConn, &param);
+       if (CONNECTION_SELF == param.content.connType)
+       {
+        /* Set SCR group to inter-scan */
+        scr_setGroup( pSmeSm->hScr, SCR_GID_INTER_SCAN );
+       }
+
+       /* Configure QoS manager not to renegotiate TSPECs as this is first time connection */
+       return conn_start(pSmeSm->hConn, CONN_TYPE_FIRST_CONN, smeSm_reportConnStatus, pSmeSm, FALSE, FALSE);
+}  
+
+
+
+
+/* Stop the connecting and go to disconnecting */ 
+static TI_STATUS connecting_To_Disconnecting(void *pData)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       conn_stop(pSmeSm->hConn, DISCONN_TYPE_DEAUTH, STATUS_UNSPECIFIED,
+                                          TRUE, smeSm_reportConnStatus, pSmeSm);
+
+       return OK;
+}
+
+
+/* Stop the connection and go to disconnecting */ 
+static TI_STATUS connected_To_disconnecting(void *pData)
+{
+       TI_STATUS status;
+       paramInfo_t             param;
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       scr_setGroup( pSmeSm->hScr, SCR_GID_CONNECT );
+
+       param.paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM;
+       siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+       
+       if(param.content.siteMgrDesiredBSSType == BSS_INFRASTRUCTURE)
+       {
+               /* Call the AP connection to perform disconnect - If immidiateShutdownRequired is TRUE, no need to send DISASSOC frame */
+                status = apConn_stop(pSmeSm->hApConn, TRUE, pSmeSm->immediateShutdownRequired);
+       }
+       else 
+       {
+           /* In IBSS disconnect is done directly with the connection SM */ 
+               status = conn_stop(pSmeSm->hConn, DISCONN_TYPE_DEAUTH, STATUS_UNSPECIFIED,
+                                                  TRUE, smeSm_reportConnStatus,pSmeSm);
+               if (status != OK)
+               {
+                       WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
+                       return status; 
+               }
+       }
+
+
+       return OK;
+}
+
+/* RESET_ATTEMPTS_NUMBER, START_SITE_AGING, START_DATA_ALGO */ 
+/* CONNECTING -> CONNECTED due to event CONN_SUCC */
+static TI_STATUS connecting_to_connected(void *pData)
+{
+       TI_STATUS status;
+       paramInfo_t     param;
+       
+       smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       /* Reset the DisAssociation reason since the SME saves that last reason, and if a new connection was made and than aborted by
+          unspecified reason - no one will clear this value */
+       pSmeSm->DisAssoc.mgmtStatus = STATUS_UNSPECIFIED;
+       pSmeSm->DisAssoc.uStatusCode = 0;
+
+       status = siteMgr_resetPrevPrimarySiteRssi(pSmeSm->hSiteMgr);
+       if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
+         return status; 
+      }
+
+       status = siteMgr_resetPrimarySiteAttemptsNumber(pSmeSm->hSiteMgr);
+       if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
+         return status; 
+      }
+
+       status = siteMgr_resetEventStatisticsHistory(pSmeSm->hSiteMgr);
+       if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
+         return status; 
+      }
+    
+
+       param.paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM;
+       siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+       if (param.content.siteMgrDesiredBSSType == BSS_INFRASTRUCTURE)
+       {
+               /* Start the AP connection */
+               apConn_start(pSmeSm->hApConn, siteMgr_isThereValidSSID(pSmeSm->hSiteMgr));
+       }
+
+    /* Set SCR group to connected */
+    scr_setGroup( pSmeSm->hScr, SCR_GID_CONNECTED );
+
+#ifdef TI_DBG
+       /* update statistics - scan attempts for connection histogran */
+       if ( SCAN_ATTAMEPTS_HISTOGRAM_SIZE < pSmeSm->smeStats.currentNumberOfScanAttempts )
+       {
+               pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ SCAN_ATTAMEPTS_HISTOGRAM_SIZE - 1 ]++;
+       }
+       else
+       {
+               pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ pSmeSm->smeStats.currentNumberOfScanAttempts - 1 ]++;
+       }
+       pSmeSm->smeStats.currentNumberOfScanAttempts = 0;
+#endif
+    return OK; 
+}
+
+
+
+/* STOP_RX, STOP_TX, UPDATE_PRIMARY_SITE_FAIL_STATUS,  */ 
+static TI_STATUS connecting_to_selecting(void *pData)
+{
+       TI_STATUS status;
+       paramInfo_t     param;
+    smeSm_t *pSmeSm = (smeSm_t *)pData;
+
+       conn_stop(pSmeSm->hConn, DISCONN_TYPE_IMMEDIATE, STATUS_UNSPECIFIED,
+                         TRUE, smeSm_reportConnStatus,pSmeSm); 
+
+       /* Remove primary site */
+       status = siteMgr_updatePrimarySiteFailStatus(pSmeSm->hSiteMgr, TRUE);
+       if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
+         return status; 
+      }
+       
+       status = siteMgr_disSelectSite(pSmeSm->hSiteMgr);
+       if (status != OK)
+      {
+         WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("SME status=%d, have to return (%d)\n",status,__LINE__));
+         return status; 
+      }
+
+       /* If we are in IBSS mode we don't try to select another site */
+       param.paramType = SITE_MGR_DESIRED_BSS_TYPE_PARAM;
+       siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+
+       if(param.content.siteMgrDesiredBSSType == BSS_INDEPENDENT)
+               return smeSm_reportSelectStatus(pSmeSm, (mgmtStatus_e)SELECT_STATUS_FAILURE);
+       else
+               return siteMgr_selectSite(pSmeSm->hSiteMgr);
+}
+
+
+
+
+static TI_STATUS chooseScanBand(smeSm_t* pSmeSm, radioBand_e *band)
+{              
+       paramInfo_t     param;
+
+    param.paramType = SITE_MGR_DESIRED_DOT11_MODE_PARAM;
+    siteMgr_getParam( pSmeSm->hSiteMgr, &param );
+
+       /* if working in dual band, select band according to dualBandReScanFlag */
+    if ( param.content.siteMgrDot11Mode == DOT11_DUAL_MODE )
+    {
+        *band = ( TRUE == pSmeSm->dualBandReScanFlag ? RADIO_BAND_5_0_GHZ : RADIO_BAND_2_4_GHZ);
+    }  
+    /* if not working in dual band, return site manager current band */
+    else
+    {
+       param.paramType = SITE_MGR_RADIO_BAND_PARAM;
+           siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+           *band = pSmeSm->currBand = param.content.siteMgrRadioBand;
+    }
+       return OK;                              
+}
+
+
+
+static TI_STATUS smeCallScan(void *pData)
+{
+    smeSm_t    *pSmeSm = (smeSm_t *)pData;
+    paramInfo_t param;
+       scan_Params_t* pScanParams = &(pSmeSm->scanParams);
+       sme_scan_Params_t       *pSmeScanParams;
+       scan_normalChannelEntry_t *pChanEntry;
+       int     chan, k;
+
+       /* 
+        * Check in which band we are in and prepare the scan command.
+        */
+    pScanParams->scanType = SCAN_TYPE_NORMAL_ACTIVE;
+    pScanParams->Tid = 0;
+
+
+    param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
+    siteMgr_getParam( pSmeSm->hSiteMgr, &param );
+
+    if ( DOT11_A_MODE == param.content.siteMgrDot11OperationalMode )
+       {       
+        pScanParams->band = RADIO_BAND_5_0_GHZ;
+               pSmeScanParams  = &(pSmeSm->scanParamsA);
+       }
+    else
+       {
+         pScanParams->band = RADIO_BAND_2_4_GHZ;
+                pSmeScanParams  = &(pSmeSm->scanParamsBG);
+       }
+
+        pScanParams->probeRequestRate  = pSmeScanParams->probeRequestRate;
+        pScanParams->numOfChannels             = pSmeScanParams->numOfChannels;
+        pScanParams->probeReqNumber            = pSmeScanParams->probeReqNumber;
+
+        WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
+                                       ("Global Scan Params: Rate=0x%x, Prob#=%d, Channels#=%d\n",
+                                        pScanParams->probeRequestRate, pScanParams->probeReqNumber, 
+                                        pScanParams->numOfChannels));  
+
+        for( chan=0; chan < pScanParams->numOfChannels; chan++ )
+        {
+               pChanEntry = &(pScanParams->channelEntry[chan].normalChannelEntry);
+               
+               /* Fill channel ID */
+               pChanEntry->channel = pSmeScanParams->channelsList[chan];
+               
+               /* Set broadcast BSSID */
+               for ( k = 0; k < 6; k++ ) pChanEntry->bssId.addr[ k ] = 0xff;
+
+               /* Set min & max dwell time */
+               pChanEntry->minChannelDwellTime = pSmeScanParams->minDwellTime;
+               pChanEntry->maxChannelDwellTime = pSmeScanParams->maxDwellTime;
+
+               /* Set up early termination params. */  
+               pChanEntry->earlyTerminationEvent =  SCAN_DEFAULT_EARLY_TERMINATION_EVENT;
+               pChanEntry->ETMaxNumOfAPframes = SCAN_DEFAULT_EARLY_TERMINATION_NUM_OF_FRAMES;
+               
+               /* Set desired tx power */ 
+               pChanEntry->txPowerDbm = pSmeScanParams->txPowerDbm;
+
+               WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
+                                       ("Chan %d: CH=%d , DwellTime Min=%d Max=%d, ET=%d, TxPowr=%d, \n",
+                                        chan,
+                                        pScanParams->channelEntry[chan].normalChannelEntry.channel,
+                                        pScanParams->channelEntry[chan].normalChannelEntry.minChannelDwellTime,
+                                        pScanParams->channelEntry[chan].normalChannelEntry.maxChannelDwellTime,
+                                        pScanParams->channelEntry[chan].normalChannelEntry.earlyTerminationEvent,
+                                        pScanParams->channelEntry[chan].normalChannelEntry.txPowerDbm));
+        } /* Channel list setting */
+
+
+    /*
+     * Set the desired SSID (if any)
+     */
+    param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+    siteMgr_getParam( pSmeSm->hSiteMgr, &param );
+
+    if ( utils_isAnySSID( &(param.content.siteMgrDesiredSSID) ) ) 
+    {
+        pScanParams->desiredSsid.len = 0;
+    }
+    else
+    {
+        pScanParams->desiredSsid.len = param.content.siteMgrDesiredSSID.len;
+        os_memoryCopy( pSmeSm->hOs, (void *)pScanParams->desiredSsid.ssidString,
+                       (void *)param.content.siteMgrDesiredSSID.ssidString,
+                       param.content.siteMgrDesiredSSID.len );
+    }
+
+
+
+       /*
+        * Prepare scan complete's aging, by increasing the scanned sites 
+        * scan attemps counter. The counter will be checked upon scan complete,  
+        * and the sites with no update scan results will be dropped.   
+        */
+       siteMgr_setNotReceivedParameter(pSmeSm->hSiteMgr, &(pScanParams->desiredSsid), pScanParams->band );
+
+#ifdef TI_DBG
+       /* scan results count statistics - nullify the count before starting scan */
+       pSmeSm->smeStats.currentNumberOfScanResults = 0;
+#endif
+
+       /* 
+        * Set and send the scan command. 
+        */
+    if (scanConcentrator_scan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER, pScanParams ) != 
+            SCAN_CRS_SCAN_RUNNING)
+       {
+       /* imitate scan complete event if scan could not be performed.*/
+               smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE, pSmeSm);
+       }
+
+       return OK;
+}
+
+
+static TI_STATUS actionUnexpected(void *pData) 
+{
+       smeSm_t *pSmeSm = (smeSm_t *)pData; 
+       
+       WLAN_REPORT_SM(pSmeSm->hReport, SME_SM_MODULE_LOG,  ("State machine error, unexpected Event\n\n"));
+       return OK;
+}
+
+
+
+static TI_STATUS actionNop(void *pData)
+{
+       return OK;
+}
+
+
+
+static TI_STATUS smeSm_changeBandParams(TI_HANDLE      hSmeSm, radioBand_e radioBand)
+{
+       paramInfo_t     param;
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       /* change dot11 mode */
+       param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
+       if(radioBand == RADIO_BAND_2_4_GHZ)
+               param.content.siteMgrDot11OperationalMode = DOT11_G_MODE;
+       else
+               param.content.siteMgrDot11OperationalMode = DOT11_A_MODE;
+
+       siteMgr_setParam(pSmeSm->hSiteMgr, &param);
+       
+       param.paramType = SITE_MGR_RADIO_BAND_PARAM;
+       param.content.siteMgrRadioBand = radioBand;
+       siteMgr_setParam(pSmeSm->hSiteMgr, &param);
+       
+       siteMgr_setCurrentTable(pSmeSm->hSiteMgr, radioBand);
+       
+       /* configure hal with common core-hal parameters */
+       whalCtrl_SetRadioBand(pSmeSm->hHalCtrl, radioBand);
+       
+       return OK;
+}
+
+/***********************************************************************
+ *                        smeSm_startInterScanTimeout                                                                  
+ ***********************************************************************
+DESCRIPTION: Starts interscan timeout
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS smeSm_startInterScanTimeout(TI_HANDLE hSmeSm)
+{
+       smeSm_t                 *pSmeSm = (smeSm_t *)hSmeSm;
+       paramInfo_t             param;
+
+       /* If the SME scan is disabled, (scan is performed by the application)
+        * don't start the inter scan timeout
+        */
+       if (pSmeSm->scanEnabled == SCAN_DISABLED)
+       {
+               return OK;
+       }
+
+       if (pSmeSm->scanEnabled == SKIP_NEXT_SCAN) 
+       {
+               pSmeSm->scanEnabled = SCAN_ENABLED;
+       }
+
+       param.paramType = SITE_MGR_DESIRED_BSS_TYPE_PARAM;
+       siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+
+       if (param.content.siteMgrDesiredBSSType == BSS_INDEPENDENT)
+       {
+               os_timerStart(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer, IBSS_INTER_SCAN_PERIOD, FALSE);
+       }
+       else 
+       {       
+               os_timerStart(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer, pSmeSm->interScanTimeout, FALSE);   
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        smeSm_stopInterScanTimeout                                                                   
+ ***********************************************************************
+DESCRIPTION: Stops scan timeout
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static TI_STATUS smeSm_stopInterScanTimeout(TI_HANDLE hSmeSm)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       os_timerStop(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
+       return OK;
+}
+
+/***********************************************************************
+*                        smeSm_sendDisassociateEvent                                                                   
+***********************************************************************
+DESCRIPTION: Send disassociate event with the reason
+
+INPUT:      pSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+static void smeSm_sendDisassociateEvent(smeSm_t* pSmeSm)
+{
+       OS_802_11_DISASSOCIATE_REASON_T eventReason;
+
+       WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG, 
+               ("%s uDissconnectType = %d, uStatusCode = %d\n",__FUNCTION__, pSmeSm->DisAssoc.mgmtStatus, pSmeSm->DisAssoc.uStatusCode));
+
+       /* Convert reason to OS layer */
+       switch(pSmeSm->DisAssoc.mgmtStatus)
+       {
+       case STATUS_UNSPECIFIED:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_UNSPECIFIED;
+               break;
+       case STATUS_AUTH_REJECT:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_AUTH_REJECT;
+           break;
+       case STATUS_ASSOC_REJECT:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_ASSOC_REJECT;
+           break;
+       case STATUS_SECURITY_FAILURE:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_SECURITY_FAILURE;
+               break;
+       case STATUS_AP_DEAUTHENTICATE:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_AP_DEAUTHENTICATE;
+               break;
+       case STATUS_AP_DISASSOCIATE:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_AP_DISASSOCIATE;
+               break;
+       case STATUS_ROAMING_TRIGGER:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_ROAMING_TRIGGER;
+               break;
+       default:
+               eventReason.eDisAssocType = OS_DISASSOC_STATUS_UNSPECIFIED; 
+           break;
+       }
+       /* Use the same status code for OS */
+       eventReason.uStatusCode          = pSmeSm->DisAssoc.uStatusCode;
+
+       EvHandlerSendEvent(pSmeSm->hEvHandler, IPC_EVENT_DISASSOCIATED, (UINT8*)&eventReason, sizeof(OS_802_11_DISASSOCIATE_REASON_T));
+
+       /* Reset status after sending the event */
+       pSmeSm->DisAssoc.mgmtStatus = STATUS_UNSPECIFIED;
+       pSmeSm->DisAssoc.uStatusCode = 0;
+}
+
+#ifdef TI_DBG
+/***********************************************************************
+ *                        smeSm_resetStats                                                                     
+ ***********************************************************************
+DESCRIPTION: Reset SME statistics
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+void smeSm_resetStats( TI_HANDLE hSmeSm )
+{
+       smeSm_t* pSmeSm = (smeSm_t*)hSmeSm;
+
+       os_memoryZero( pSmeSm->hOs, &(pSmeSm->smeStats), sizeof(smeSmStats_t) );
+}
+
+/***********************************************************************
+ *                        smeSm_printStats                                                                     
+ ***********************************************************************
+DESCRIPTION: Print SME statistics
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+void smeSm_printStats( TI_HANDLE hSmeSm )
+{
+       smeSm_t* pSmeSm = (smeSm_t*)hSmeSm;
+
+       WLAN_OS_REPORT(("----------------------- SME statistics -----------------------\n\n"));
+       WLAN_OS_REPORT(("Scan attempts histogram:\n"));
+       WLAN_OS_REPORT(("------------------------\n\n"));
+       WLAN_OS_REPORT(("Attempts: %6d %6d %6d %6d %6d %6d %6d %6d\n", 1, 2, 3, 4, 5, 6, 7, 8));
+       WLAN_OS_REPORT(("Count:    %6d %6d %6d %6d %6d %6d %6d %6d\n\n", pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 0 ],
+                                       pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 1 ], pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 2 ],
+                                       pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 3 ], pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 4 ],
+                                       pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 5 ], pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 6 ],
+                                       pSmeSm->smeStats.scanAttemptsForConnectionHistogram[ 7 ]));
+       WLAN_OS_REPORT(("Scan result count histogram:\n"));
+       WLAN_OS_REPORT(("----------------------------\n\n"));
+       WLAN_OS_REPORT(("Results: %6d %6d %6d %6d %6d %6d %6d %6d\n", 0, 1, 2, 3, 4, 5, 6, 7));
+       WLAN_OS_REPORT(("Scans:   %6d %6d %6d %6d %6d %6d %6d %6d\n\n", pSmeSm->smeStats.scanResulCountHistogram[ 0 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 1 ], pSmeSm->smeStats.scanResulCountHistogram[ 2 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 3 ], pSmeSm->smeStats.scanResulCountHistogram[ 4 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 5 ], pSmeSm->smeStats.scanResulCountHistogram[ 6 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 7 ]));
+       WLAN_OS_REPORT(("Results: %6d %6d %6d %6d %6d %6d %6d %6d\n", 8, 9, 10, 11, 12, 13, 14, 15));
+       WLAN_OS_REPORT(("Scans:   %6d %6d %6d %6d %6d %6d %6d %6d\n", pSmeSm->smeStats.scanResulCountHistogram[ 8 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 9 ], pSmeSm->smeStats.scanResulCountHistogram[ 10 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 11 ], pSmeSm->smeStats.scanResulCountHistogram[ 12 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 13 ], pSmeSm->smeStats.scanResulCountHistogram[ 14 ],
+                                       pSmeSm->smeStats.scanResulCountHistogram[ 15 ]));
+}
+
+/***********************************************************************
+ *                        smeSm_dbgPrintObject                                                                 
+ ***********************************************************************
+DESCRIPTION: Print the SME object
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     
+
+************************************************************************/
+void smeSm_dbgPrintObject( TI_HANDLE hSmeSm )
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       WLAN_OS_REPORT(("Current SME State is <%s>\n",stateDesc[pSmeSm->state]));
+}
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSm.h b/sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSm.h
new file mode 100644 (file)
index 0000000..a201bee
--- /dev/null
@@ -0,0 +1,169 @@
+/** \file      smeSm.h
+ *  \brief SME SM internal header file
+ *
+ *  \see smeSm.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                     */
+/*       MODULE:       smeSm.h                                                                                                         */
+/*    PURPOSE: SME SM internal header file                                                                     */
+/*                                                                                                                                                     */
+/***************************************************************************/
+#ifndef __SME_SM_H__
+#define __SME_SM_H__
+
+#include "osTIType.h"
+#include "paramOut.h"
+#include "paramIn.h"
+#include "fsm.h"
+#include "802_11Defs.h"
+#include "ScanCncnApi.h"
+
+#define IBSS_INTER_SCAN_PERIOD                 20
+#define SCAN_ATTAMEPTS_HISTOGRAM_SIZE  8
+#define SCAN_RESULT_HISTOGRAM_SIZE             16
+
+/* SME SM definitions */
+typedef enum
+{
+       SME_SM_STATE_IDLE                                    = 0,
+       SME_SM_STATE_SCANNING                        = 1,
+       SME_SM_STATE_SELECTING                       = 2,
+       SME_SM_STATE_CONNECTING                      = 3,
+       SME_SM_STATE_CONNECTED                       = 4,
+       SME_SM_STATE_DISCONNECTING                   = 5,
+       SME_SM_STATE_INTER_SCAN                  = 6,
+       SME_SM_NUM_STATES                    = 7
+} sme_sm_states_e;
+
+
+typedef enum 
+{
+       SME_SM_EVENT_START                                              = 0,
+       SME_SM_EVENT_STOP                                               = 1,
+       SME_SM_EVENT_SCAN_COMPLETE                          = 2,
+       SME_SM_EVENT_SELECT_SUCCESS                             = 3,
+       SME_SM_EVENT_SELECT_FAILURE                             = 4,
+       SME_SM_EVENT_CONN_SUCCESS                               = 5,
+       SME_SM_EVENT_CONN_FAILURE                               = 6,
+       SME_SM_EVENT_RESELECT                                   = 7,
+       SME_SM_EVENT_DISCONNECT                                 = 8,
+       SME_SM_NUM_EVENTS                       = 9
+} sme_sm_events_e;
+
+
+typedef struct
+{
+       mgmtStatus_e                    mgmtStatus;             /* Contains the last DisAssociation reason towards upper layer                                  */
+       UINT32                                  uStatusCode;    /* Extra information to the reason. i.e. packet status code or roaming trigger  */
+} DisAssocReason_t;
+
+typedef struct
+{
+       BOOL                            RadioStandByEnable;
+       radioStandByState_t     lastRadioStandByState; 
+       UINT16                          radioStandByBitNumber;
+       BOOL                            GPIO13_debug;
+} sme_radioDisableParameters_t;
+
+#ifdef TI_DBG
+typedef struct
+{
+       UINT8   currentNumberOfScanResults;
+       UINT32  scanResulCountHistogram[ SCAN_RESULT_HISTOGRAM_SIZE ];
+       UINT8   currentNumberOfScanAttempts;
+       UINT32  scanAttemptsForConnectionHistogram[ SCAN_ATTAMEPTS_HISTOGRAM_SIZE ];
+} smeSmStats_t;
+#endif
+
+/* SME SM handle */
+typedef struct 
+{
+       UINT8                           state;  
+       DisAssocReason_t        DisAssoc;
+       fsm_stateMachine_t      *pFsm;
+       scanEnabledOptions_e scanEnabled;
+       BOOL                            reScanFlag;
+       BOOL                            dualBandReScanFlag;
+       radioBand_e             currBand;
+       BOOL                            bSendDisAssocEvent;
+       TI_HANDLE                       hConn;
+       TI_HANDLE                       hScanCncn;
+       TI_HANDLE                       hSiteMgr;
+       TI_HANDLE                       hHalCtrl;
+       TI_HANDLE                       hRegulatoryDomain;
+    TI_HANDLE           hPowerMgr;
+       TI_HANDLE                       hReport;
+       TI_HANDLE                       hOs;
+       TI_HANDLE                       hEvHandler;
+       TI_HANDLE                       hScr;
+       TI_HANDLE                       hApConn;
+       TI_HANDLE                       hCurrBss;
+
+       void                            *interScanTimeoutTimer;
+       UINT32                          interScanTimeout;
+       UINT32                          interScanTimeoutMin;
+       UINT32                          interScanTimeoutMax;
+       UINT32                          interScanTimeoutDelta;
+    sme_scan_Params_t   scanParamsBG;
+    sme_scan_Params_t   scanParamsA;
+       BOOL                            radioOn;
+    BOOL                immediateShutdownRequired; /* Flag to indicate whether DISASSOC packet should be sent to AP or not - used to instruct AP-Conn when stopping */
+       BOOL                            connectEnabled;
+       scan_Params_t           scanParams; /*  Though this is a temporary command, we keep it as 
+                                                                               class member to avoid stack overflow. */
+    UINT8               shutDownStatus; /* Internal shutdown status - used to indicate SME move to IDLE during unload process */
+#ifdef TI_DBG
+       smeSmStats_t            smeStats;
+#endif
+} smeSm_t;
+
+
+fsm_stateMachine_t *smeSm_smCreate(TI_HANDLE hOs);
+
+TI_STATUS smeSm_smConfig(smeSm_t *pSmeSm);
+
+TI_STATUS smeSm_smUnLoad(TI_HANDLE hOs, fsm_stateMachine_t *pFsm);
+
+TI_STATUS smeSm_SMEvent(UINT8 *currentState, UINT8 event, TI_HANDLE hSmeSm);
+
+TI_STATUS sme_startScan(void *pData);
+
+#endif /* __SME_SM_H__ */
+
+
diff --git a/sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSmApi.c b/sta_dk_4_0_4_32/common/src/core/sme/smeSm/smeSmApi.c
new file mode 100644 (file)
index 0000000..f32a101
--- /dev/null
@@ -0,0 +1,737 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 smeSmApi.c
+ *  \brief SME SM API implementation
+ * 
+ *  The state machine itself is implemented in the file        smeSm.c.                                
+ *
+ *  \see smeSmApi.h
+ */
+
+#include "report.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "smeSm.h"
+#include "smeApi.h"
+#include "smeSmApi.h"
+#include "utils.h"
+#include "802_11Defs.h"
+#include "regulatoryDomainApi.h"
+#include "siteMgrApi.h"
+#include "connApi.h"
+#include "EvHandler.h"
+#include "TI_IPC_Api.h"
+
+
+#define WLAN_INTER_SCAN_DELTA 10
+
+/* State machine definitions */
+#define SME_INIT_BIT                   1
+#define SM_INIT_BIT                            2
+#define TIMER_INIT_BIT                 3
+
+/* Local functions prototypes */
+
+static void release_module(smeSm_t *pSmeSm, UINT32 initVec);
+
+void smeSm_InterScanTimeoutCB(TI_HANDLE     hSmeSm);
+
+
+/* Interface functions Implementation */
+
+/************************************************************************
+ *                        smeSm_create                                                         *
+ ************************************************************************
+DESCRIPTION: SME SM module creation function, called by the config mgr in creation phase 
+                               performs the following:
+                               -       Allocate the SME SM handle
+                               -       Create the SME state machine
+                                                                                                   
+INPUT:      hOs -                      Handle to OS            
+
+
+OUTPUT:                
+
+RETURN:     Handle to the SME SM module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE smeSm_create(TI_HANDLE hOs)
+{
+       smeSm_t                 *pSmeSm;
+       UINT32                  initVec;
+
+       initVec = 0;
+
+       pSmeSm = os_memoryAlloc(hOs, sizeof(smeSm_t));
+       if (pSmeSm == NULL)
+               return NULL;
+       os_memoryZero(hOs, pSmeSm, sizeof(smeSm_t)); /* Dm: Fix */
+       
+       initVec |= (1 << SME_INIT_BIT);
+
+       pSmeSm->pFsm = smeSm_smCreate(hOs);
+       if (pSmeSm->pFsm == NULL)
+       {
+               release_module(pSmeSm, initVec);
+               return NULL;
+       }
+       
+       initVec |= (1 << SM_INIT_BIT);
+
+       pSmeSm->hOs     = hOs;
+
+       pSmeSm->interScanTimeoutTimer = os_timerCreate(hOs, smeSm_InterScanTimeoutCB, pSmeSm);
+       if(pSmeSm->interScanTimeoutTimer == NULL)
+       {
+               release_module(pSmeSm, initVec);
+           WLAN_OS_REPORT(("FATAL ERROR: smeSm_create(): Error Creating smeSm - Aborting\n"));
+               return NULL;
+       }
+       initVec |= (1 << TIMER_INIT_BIT);
+
+       return(pSmeSm);
+}
+
+/************************************************************************
+ *                        smeSm_config                                                                 *
+ ************************************************************************
+DESCRIPTION: SME SM module configuration function, called by the config mgr in configuration phase
+                               performs the following:
+                               -       Reset & initiailzes local variables
+                               -       Init the handles to be used by the module
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle
+                       List of handles to be used by the module
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_config(TI_HANDLE               hSmeSm, 
+                                       TI_HANDLE                   hConn,
+                                       TI_HANDLE                   hScanCncn,
+                                       TI_HANDLE                   hSiteMgr,
+                                       TI_HANDLE                   hHalCtrl,
+                                       TI_HANDLE                   hReport,
+                                       TI_HANDLE                   hOs,
+                    TI_HANDLE              hEvHandler,
+                                       TI_HANDLE                   hScr,
+                                       TI_HANDLE                   hApConn,
+                                       TI_HANDLE                   hCurrBss,
+                                       TI_HANDLE                   hPowerMgr,
+                    TI_HANDLE           hRegulatoryDomain,
+                                       smeInitParams_t*        smeInitParams)
+
+{
+       TI_STATUS status;
+       int index;
+       
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       pSmeSm->state = SME_SM_STATE_IDLE;
+       pSmeSm->hConn                   = hConn;
+       pSmeSm->hScanCncn               = hScanCncn;
+       pSmeSm->hSiteMgr                = hSiteMgr;
+       pSmeSm->hHalCtrl                = hHalCtrl;
+       pSmeSm->hReport                 = hReport;
+       pSmeSm->hOs                             = hOs;
+    pSmeSm->hEvHandler         = hEvHandler;
+       pSmeSm->hScr                    = hScr;
+       pSmeSm->hApConn                 = hApConn;
+       pSmeSm->hCurrBss                = hCurrBss;
+       pSmeSm->hPowerMgr               = hPowerMgr;
+    pSmeSm->hRegulatoryDomain = hRegulatoryDomain;
+
+       /* interscan timeout values */
+       pSmeSm->scanEnabled                             = (scanEnabledOptions_e)smeInitParams->EnableFirstConnScan; 
+    pSmeSm->interScanTimeoutMin        = smeInitParams->InterScanIntervalMin;
+    pSmeSm->interScanTimeoutMax        = smeInitParams->InterScanIntervalMax;
+    pSmeSm->interScanTimeoutDelta      = smeInitParams->InterScanIntervalDelta;
+    pSmeSm->shutDownStatus = 0;
+
+
+       /* 
+        *    Setting scan parameters for band 2.4Ghtz
+        */
+       os_memoryCopy(hOs, &(pSmeSm->scanParamsBG), &(smeInitParams->scanParamsBG), sizeof(sme_scan_Params_t)); 
+       /* The channel list is represented as char string terminate in zeros. */
+       
+       for( index = 0; 
+                ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsBG.channelsList[index] != 0)); 
+                index++ );
+
+       pSmeSm->scanParamsBG.numOfChannels = index;
+
+       /* 
+        *    Setting scan parameters for band 5.0Ghtz
+        */
+       os_memoryCopy(hOs, &(pSmeSm->scanParamsA), &(smeInitParams->scanParamsA), sizeof(sme_scan_Params_t));
+       
+       for( index = 0; 
+                ((index < MAX_NUMBER_OF_CHANNELS_PER_SCAN )&&(pSmeSm->scanParamsA.channelsList[index] != 0)); 
+                index++ );
+
+       pSmeSm->scanParamsA.numOfChannels = index;
+
+
+    
+    /* register to scan result callback */
+    scanConcentrator_registerScanResultCB( pSmeSm->hScanCncn, SCAN_SCC_DRIVER, smeSm_scanComplete, hSmeSm );
+
+       status = smeSm_smConfig(pSmeSm);
+
+       if (status != OK)
+               WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG,  (".....Sme state machine configuration Failure\n"));
+       else
+               WLAN_REPORT_INIT(hReport, SME_SM_MODULE_LOG,  (".....Sme state machine configuration Success\n"));
+
+       return status;
+}
+
+/************************************************************************
+ *                        smeSm_getDriverShutdownStatus                                                                        *
+ ************************************************************************
+DESCRIPTION: Return shutdown status of driver.
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.          
+
+OUTPUT:                
+
+RETURN:     shutdown status of driver (SME/HAL)
+
+************************************************************************/
+UINT8 smeSm_getDriverShutdownStatus (TI_HANDLE         hSmeSm)
+{
+       smeSm_t                 *pSmeSm = (smeSm_t *)hSmeSm;
+    return (pSmeSm->shutDownStatus);
+}
+
+
+/************************************************************************
+ *                        smeSm_unLoad                                                                 *
+ ************************************************************************
+DESCRIPTION: SME SM module unload function, called by the config mgr in the unlod phase 
+                               performs the following:
+                               -       Free all memory allocated by the module
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.          
+
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_unLoad(TI_HANDLE               hSmeSm)
+{
+       UINT32                  initVec;
+       smeSm_t                 *pSmeSm = (smeSm_t *)hSmeSm;
+
+       if (!pSmeSm)
+               return OK;
+
+       initVec = 0xFFFF;
+       release_module(pSmeSm, initVec);
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        smeSm_start                                                                  
+ ***********************************************************************
+DESCRIPTION: Called by the configuration module in order to start the driver
+                        Calls the SME SM with a start event
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_start(TI_HANDLE                hSmeSm)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       pSmeSm->radioOn = TRUE;
+    pSmeSm->immediateShutdownRequired = FALSE;
+
+       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_START, pSmeSm);
+}
+
+
+
+/***********************************************************************
+ *                        smeSm_restart                                                                        
+ ***********************************************************************
+DESCRIPTION: Called by the configuration module in order to start the driver
+                        Calls the SME SM with a start event
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_reselect(TI_HANDLE             hSmeSm)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+       paramInfo_t                     param;
+
+       /* For new SSID reset interScanTimeout */
+       pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMin;
+
+       /* 
+               Junk SSID is used for disabling connection attempts, if it is 
+          set the driver will be stopped at "inter scan" state.
+       */    
+
+       param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
+       siteMgr_getParam(pSmeSm->hSiteMgr, &param);
+
+       if (utils_isJunkSSID(&param.content.siteMgrDesiredSSID))
+       {
+               pSmeSm->connectEnabled    = FALSE;
+
+               WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
+                                       ("Sme Set JUNK SSID\n"));
+               
+               if( pSmeSm->state == SME_SM_STATE_SCANNING )
+                       /* If in scanning stop the scan, the disconnect event will
+                          be sent by the scan complete function. */
+                       scanConcentrator_stopScan( pSmeSm->hScanCncn, SCAN_SCC_DRIVER );
+               else
+                       smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
+       }
+       else 
+       {
+               pSmeSm->connectEnabled    = TRUE;
+               smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
+       }
+
+       return OK;
+}
+
+
+/***********************************************************************
+ *                        smeSm_stop                                                                   
+ ***********************************************************************
+DESCRIPTION: Called by the configuration module in order to stop the driver
+                        Calls the SME SM with a stop event
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_stop(TI_HANDLE         hSmeSm)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       pSmeSm->radioOn = FALSE;
+    pSmeSm->immediateShutdownRequired = FALSE;    
+
+       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
+}
+
+/***********************************************************************
+ *                        smeSm_stopAndShutdown                                                                        
+ ***********************************************************************
+DESCRIPTION: Called by the configuration module in order to stop the driver
+                        Calls the SME SM with a stop event
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+void smeSm_stopAndShutdown(TI_HANDLE           hSmeSm)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       pSmeSm->radioOn = FALSE;
+    pSmeSm->immediateShutdownRequired = TRUE;
+
+       smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_STOP, pSmeSm);
+}
+
+/***********************************************************************
+ *                        smeSm_scanComplete                                                                   
+ ***********************************************************************
+DESCRIPTION: Called by the site manager When scan is completed
+                        Calls the SME SM with a scan complete event
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+void smeSm_scanComplete( TI_HANDLE hSmeSm, scan_cncnResultStatus_e status,
+                         scan_frameInfo_t *frameInfo, UINT16 SPSStatus )
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+    /* if this call is due to a scan result received, simply store it in the site mngr */
+       if ( SCAN_CRS_RECEIVED_FRAME == status )
+    {
+               siteMgr_updateSite( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->parsedIEs, frameInfo->channel, frameInfo->band, FALSE);
+        if ( BEACON == frameInfo->parsedIEs->subType )
+        {
+            siteMgr_saveBeaconBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
+        }
+        else
+        {
+            siteMgr_saveProbeRespBuffer( pSmeSm->hSiteMgr, frameInfo->bssId, frameInfo->buffer, frameInfo->bufferLength );
+        }
+#ifdef TI_DBG
+               /* update statistics - count one more result that was received */
+               pSmeSm->smeStats.currentNumberOfScanResults++;
+#endif
+        return;
+    }
+
+#ifdef TI_DBG
+       /* update statistics - update scan results histogram */
+       if ( SCAN_RESULT_HISTOGRAM_SIZE <= pSmeSm->smeStats.currentNumberOfScanResults )
+       {
+               pSmeSm->smeStats.scanResulCountHistogram[ SCAN_RESULT_HISTOGRAM_SIZE -1 ]++;
+       }
+       else
+       {
+               pSmeSm->smeStats.scanResulCountHistogram[ pSmeSm->smeStats.currentNumberOfScanResults ]++;
+       }
+       pSmeSm->smeStats.currentNumberOfScanResults = 0;
+#endif
+
+       WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
+                               ("smeSm_scanComplete\n"));
+
+    siteMgr_removeNotReceivedSites(pSmeSm->hSiteMgr);
+
+       if ( pSmeSm->connectEnabled ) 
+    {
+           /* check for rescan and perform scan when it is on */
+               if ( TRUE == pSmeSm->reScanFlag )
+        {
+                   WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
+                                     ("SME_SM: doing additional scan due to reScanFlag = ON\n") );
+                   pSmeSm->reScanFlag = FALSE;
+                       sme_startScan(pSmeSm);
+               } 
+        /* check for dual band rescan */
+               else if ( TRUE == pSmeSm->dualBandReScanFlag )
+        {
+                   WLAN_REPORT_INFORMATION( pSmeSm->hReport, SME_SM_MODULE_LOG,
+                                     ("SME_SM: doing additional scan due to dualBandReScanFlag = ON\n") );
+                       sme_startScan(pSmeSm);
+        }
+        else
+        {
+                       smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SCAN_COMPLETE, pSmeSm);
+               }
+       } 
+       else
+    {
+               /* If connection is disabled then send disconnect event, the SM will
+                * move into inter scan state
+                */
+               pSmeSm->reScanFlag = FALSE;     /* (Just to make sure) */
+        pSmeSm->dualBandReScanFlag = FALSE;
+               smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_DISCONNECT, pSmeSm);
+       }
+}
+
+
+/***********************************************************************
+ *                        smeSm_reportConnStatus                                       
+ ***********************************************************************
+DESCRIPTION: Called by the connection module when connection status changes
+                        Calls the SME SM with a connection suceess or connection failure based on the status
+                                                                                                   
+INPUT:      hSmeSm             -       SME SM handle.
+                       statusType      -       Connection status
+                       uStatusCode -   extra information to statusType (usually status code of the packet)
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_reportConnStatus(TI_HANDLE     hSmeSm, mgmtStatus_e statusType, UINT32 uStatusCode)                                                     
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       WLAN_REPORT_INFORMATION(pSmeSm->hReport, SME_SM_MODULE_LOG,  
+               ("%s statusType = %d, uStatusCode = %d \n",__FUNCTION__, statusType, uStatusCode));
+
+       switch(statusType)
+       {
+               case STATUS_SUCCESSFUL:
+                       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_SUCCESS, pSmeSm);
+
+               /*
+               *  The next section handles connection failures, all cases are sending same event to SM. 
+               */              
+               case            STATUS_AUTH_REJECT:                                                                             
+               case            STATUS_ASSOC_REJECT:                                                                            
+               case            STATUS_SECURITY_FAILURE:                                   
+               case            STATUS_AP_DEAUTHENTICATE:       
+               case            STATUS_AP_DISASSOCIATE:
+               case            STATUS_ROAMING_TRIGGER:         
+                       pSmeSm->DisAssoc.mgmtStatus  = statusType;
+                       pSmeSm->DisAssoc.uStatusCode = uStatusCode;
+                       /* Note that in case of unspecified status we won't update the status. This is done since this function could be called twice */
+                       /* for example: apConn called this function and than SME called conn_stop and this function is called again                                       */
+               case            STATUS_UNSPECIFIED:                                        
+
+                       return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_CONN_FAILURE, pSmeSm);
+
+       default:
+               WLAN_REPORT_WARNING(pSmeSm->hReport, SME_SM_MODULE_LOG,  
+                       ("%s unknown statusType = %d\n",__FUNCTION__, statusType));
+
+               break;
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        smeSm_reportSelectStatus                                                                     
+ ***********************************************************************
+DESCRIPTION: Called by the selection function
+                        Calls the SME SM with a selection suceess or selection failure based on the status
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+                       status  -       selection status
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_reportSelectStatus(TI_HANDLE           hSmeSm, 
+                                                               mgmtStatus_e    status)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+       
+       if (status == SELECT_STATUS_SUCCESS)
+               return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_SUCCESS, pSmeSm);
+       else
+               return smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_SELECT_FAILURE, pSmeSm);
+}
+
+
+/***********************************************************************
+ *                        smeSm_startScan                                                                      
+ ***********************************************************************
+DESCRIPTION: Timer callback, on expiration of which, scan started
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+void smeSm_InterScanTimeoutCB(TI_HANDLE     hSmeSm)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       if ( pSmeSm->connectEnabled )
+       {
+               pSmeSm->interScanTimeout += pSmeSm->interScanTimeoutDelta;
+
+               if( pSmeSm->interScanTimeout > pSmeSm->interScanTimeoutMax )
+                       pSmeSm->interScanTimeout = pSmeSm->interScanTimeoutMax;
+
+               smeSm_SMEvent(&pSmeSm->state, SME_SM_EVENT_RESELECT, pSmeSm);
+       }
+}
+
+
+/***********************************************************************
+ *                        release_module                                                                       
+ ***********************************************************************
+DESCRIPTION:   Called by the un load function
+                               Go over the vector, for each bit that is set, release the corresponding module.
+                                                                                                   
+INPUT:      hConn      -       SME SM handle.
+                       pSmeSm  -       Vector that contains a bit set for each module thah had been initiualized
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+static void release_module(smeSm_t *pSmeSm, UINT32 initVec)
+{
+
+       if (initVec & (1 << SM_INIT_BIT))
+               smeSm_smUnLoad(pSmeSm->hOs, pSmeSm->pFsm);
+
+       if (initVec & (1 << TIMER_INIT_BIT))
+       {
+               os_timerStop(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
+               utils_nullTimerDestroy(pSmeSm->hOs, pSmeSm->interScanTimeoutTimer);
+       }
+
+       if (initVec & (1 << SME_INIT_BIT))
+               utils_nullMemoryFree(pSmeSm->hOs, pSmeSm, sizeof(smeSm_t));
+
+
+       initVec = 0;
+}
+
+/***********************************************************************
+ *                        smeSm_setParam                                                                       
+ ***********************************************************************
+DESCRIPTION: SME SM set param function, called by the following:
+                               -       config mgr in order to set a parameter from the OS abstraction layer.
+                               -       Form inside the driver
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_setParam(TI_HANDLE                     hSmeSm,
+                                               paramInfo_t             *pParam)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       switch(pParam->paramType)
+       {
+       case SME_SCAN_ENABLED_PARAM:
+               if (pSmeSm->scanEnabled != pParam->content.smeSMScanEnabled)
+               {
+                       if ((pParam->content.smeSMScanEnabled == SCAN_ENABLED) &&
+                               (pSmeSm->scanEnabled == SKIP_NEXT_SCAN))
+                       {
+                               /* Requested to st scanEnable to TRUE; 
+                                 if we are about to skip the nextcoming scan, ignore the request */
+                               break;
+                       }
+                       if ((pParam->content.smeSMScanEnabled == SKIP_NEXT_SCAN) &&
+                               (pSmeSm->scanEnabled == SCAN_DISABLED))
+                       {
+                               /* Requested to st scanEnable to SKIP_NEXT_SCAN 
+                                  while it is currently set to FALSE - error, ignore the request */
+                               WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG, 
+                                                                  ("Set param, error changing scan enabled param from %d to %d\n",
+                                                                       pSmeSm->scanEnabled, pParam->content.smeSMScanEnabled));
+                               break;
+                       }
+                       pSmeSm->scanEnabled = pParam->content.smeSMScanEnabled;
+               }
+               break;
+
+       default:
+               WLAN_REPORT_ERROR( pSmeSm->hReport, SME_SM_MODULE_LOG, 
+                                                  ("Set param, Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
+
+/***********************************************************************
+ *                        smeSm_getParam                                                                       
+ ***********************************************************************
+DESCRIPTION: SME SM get param function, called by the following:
+                       -       config mgr in order to get a parameter from the OS abstraction layer.
+                       -       Fomr inside the dirver  
+                                                                                                   
+INPUT:      hSmeSm     -       SME SM handle.
+                       pParam  -       Pointer to the parameter                
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS smeSm_getParam(TI_HANDLE                     hSmeSm, 
+                                               paramInfo_t             *pParam)
+{
+       smeSm_t *pSmeSm = (smeSm_t *)hSmeSm;
+
+       switch(pParam->paramType)
+       {
+       case SITE_MGR_CONNECTION_STATUS_PARAM:
+               switch (pSmeSm->state)
+               {
+               case SME_SM_STATE_IDLE:
+               case SME_SM_STATE_INTER_SCAN:
+                       pParam->content.smeSmConnectionStatus = eDot11Idle;
+                       break;
+               case SME_SM_STATE_SCANNING:
+                       pParam->content.smeSmConnectionStatus = eDot11Scaning;
+                       break;
+               case SME_SM_STATE_CONNECTING:
+                       pParam->content.smeSmConnectionStatus = eDot11Connecting;
+                       break;
+               default: 
+                       pParam->content.smeSmConnectionStatus = eDot11Associated;
+                       break;
+               }
+               break;
+
+       case SME_SM_STATE_PARAM:
+               pParam->content.smeSmState = pSmeSm->state;
+               break;
+
+       case SME_SCAN_ENABLED_PARAM:
+               pParam->content.smeSMScanEnabled = pSmeSm->scanEnabled;
+               break;
+
+       default:
+               WLAN_REPORT_ERROR(pSmeSm->hReport, SME_SM_MODULE_LOG, ("Get param, Params is not supported, %d\n\n", pParam->paramType));
+               return PARAM_NOT_SUPPORTED;
+       }
+
+       return OK;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/srv/inc/scrApi.h b/sta_dk_4_0_4_32/common/src/core/srv/inc/scrApi.h
new file mode 100644 (file)
index 0000000..b86d1bf
--- /dev/null
@@ -0,0 +1,268 @@
+/** \file ScrApi.h
+ *  \brief This file include public definitions for the SCR module, comprising its API.
+ *  \author Ronen Kalish
+ *  \date 01-Dec-2004
+ */
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCRAPI_H__
+#define __SCRAPI_H__
+
+#include "osTIType.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+/** \enum scr_modeId_e 
+ * \brief enumerates the different modes available in the system       
+ */
+typedef enum
+{
+       SCR_MID_NORMAL = 0,                     /**< Normal mode          */
+       SCR_MID_SG,                                     /**< Soft Gemini mode */
+       SCR_MID_NUM_OF_MODES
+} scr_modeId_e;
+
+/** \enum scr_groupId_e 
+ * \brief enumerates the different groups available in the system
+ */
+typedef enum
+{
+    SCR_GID_IDLE = 0,           /**< STA is idle */
+    SCR_GID_INTER_SCAN,         /**< STA is disconnected, SME waits for next scan */
+    SCR_GID_CONNECT,            /**< STA is trying to conenct */
+    SCR_GID_CONNECTED,          /**< STA is connected */
+    SCR_GID_ROAMING,            /**< STA is performing roaming to another AP */
+    SCR_GID_NUM_OF_GROUPS
+} scr_groupId_e;
+
+
+/** \enum scr_clientId_e 
+ * \brief enumerates the different clients available in the system
+ */
+typedef enum
+{
+    SCR_CID_APP_SCAN = 0,    /* lowest priority */
+    SCR_CID_DRIVER_FG_SCAN,
+       SCR_CID_CONT_SCAN,
+    SCR_CID_EXC_MEASURE,
+    SCR_CID_BASIC_MEASURE,
+       SCR_CID_CONNECT,
+    SCR_CID_IMMED_SCAN,
+       SCR_CID_SWITCH_CHANNEL,         /* highest priority */
+       SCR_CID_NUM_OF_CLIENTS,
+    SCR_CID_NO_CLIENT
+} scr_clientId_e;
+
+/** \enum scr_clientRequestStatus_e 
+ * \brief enumerates the status reports the client may receive
+ */
+typedef enum 
+{
+       SCR_CRS_RUN = 0,            /**< the client can use the channel */
+    SCR_CRS_PEND,               /**< the channel is in use, The client may wait for it. */
+    SCR_CRS_ABORT,              /**< client should abort it's use of the channel */
+    SCR_CRS_FW_RESET            /**< Notification of recovery (client should elect what to do) */
+} scr_clientRequestStatus_e;
+
+/** \enum scr_pendReason_e 
+ * \brief enumerates the different reasons which can cause a client request to return with pend status.
+ */
+typedef enum
+{
+    SCR_PR_OTHER_CLIENT_ABORTING = 0,          /**< 
+                                                                                        * The requesting client is waiting for a client with lower priority  
+                                                                                        * to abort operation
+                                                                                        */
+       SCR_PR_OTHER_CLIENT_RUNNING,                            /**<
+                                                                                        * The requesting client is waiting for a client that cannot be aborted
+                                                                                        * to finish using the channel.
+                                                                                        */
+    SCR_PR_DIFFERENT_GROUP_RUNNING,         /**< The current SCR group is different than the client's group */
+       SCR_PR_NONE                             /**< The client is not pending */
+} scr_pendReason_e;
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+ /** \typedef scr_abortReason_e
+  * \brief Defines the function prototype a client should register as callback.
+  */
+typedef void (*scr_callback_t)( TI_HANDLE hClient, 
+                                scr_clientRequestStatus_e requestStatus, 
+                                scr_pendReason_e pendReason );
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Creates the SCR object
+ *
+ * Function Scope \e Public.\n
+ * \param hOS - handle to the OS object.\n
+ * \return a handle to the SCR object.\n
+ */
+TI_HANDLE scr_create( TI_HANDLE hOS );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Finalizes the SCR object (freeing memory)
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ */
+void scr_release( TI_HANDLE hScr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Initializes the SCR object
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param hReport - handle to the report module.\n
+ */
+void scr_init( TI_HANDLE hScr, TI_HANDLE hReport );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Registers the callback function to be used per client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param client - the client ID.\n
+ * \param callbackFunc - the address of the callback function to use.\n
+ * \param callbackObj - the handle of the object to pass to the callback function (the client object).\n
+ */
+void scr_registerClientCB( TI_HANDLE hScr, 
+                           scr_clientId_e client,
+                           scr_callback_t callbackFunc, 
+                           TI_HANDLE callbackObj );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Notifies the running process upon a firmware reset.
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ */
+void scr_notifyFWReset( TI_HANDLE hScr );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-April-2005\n
+ * \brief Changes the current SCR group.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param newGroup - the new group to use.\n
+ */
+void scr_setGroup( TI_HANDLE hScr, scr_groupId_e newGroup );
+
+/**
+ * \author Yuval Adler\n
+ * \date 23-1l-2005\n
+ * \brief Changes the current SCR mode. This function is called from Soft Gemini module only \n
+ *           when changing mode - clients that are not valid in the new group/mode are aborted  \n
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param newMode - the new mode to use.\n
+ */
+void scr_setMode( TI_HANDLE hScr, scr_modeId_e newMode );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Request the channel use by a client
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param client - the client ID requesting the channel.\n
+ * \param pPendReason - the reason for a pend reply.\n
+ * \return The request status.\n
+ * \retval SCR_CRS_REJECT the channel cannot be allocated to this client.
+ * \retval SCR_CRS_PEND the channel is currently busy, and this client had been placed on the waiting list.
+ * \retval SCR_CRS_RUN the channel is allocated to this client.
+ */
+scr_clientRequestStatus_e scr_clientRequest( TI_HANDLE hScr, scr_clientId_e client, scr_pendReason_e* pPendReason );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Notifies the SCR that the client doe not require the channel any longer
+ *
+ * This function can be called both by clients that are in possession of the channel, and by
+ * clients that are pending to use the channel.\n
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param client - the client releasing the channel.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+void scr_clientComplete( TI_HANDLE hScr, scr_clientId_e client );
+
+#endif /* __SCRAPI_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/core/srv/scr/scr.c b/sta_dk_4_0_4_32/common/src/core/srv/scr/scr.c
new file mode 100644 (file)
index 0000000..76ccb1a
--- /dev/null
@@ -0,0 +1,757 @@
+/** \file Scr.c
+ *  \brief This file include the SCR module implementation
+ *  \author Ronen Kalish
+ *  \date 01-Dec-2004
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "report.h"
+#include "scr.h"
+#include "osApi.h"
+
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/**
+ * \brief This array holds configuration values for abort others field for different clients.\n
+ */
+static scr_clientId_e abortOthers[ SCR_CID_NUM_OF_CLIENTS ] = 
+/* APP_SCAN           DRV_FG             CONT_SCAN          EXC_MSR            BASIC_MSR          CONNECT                IMMED_SCN              SWITCH_CHNL*/
+ { SCR_CID_NO_CLIENT, SCR_CID_NO_CLIENT, SCR_CID_NO_CLIENT, SCR_CID_NO_CLIENT, SCR_CID_NO_CLIENT, SCR_CID_BASIC_MEASURE, SCR_CID_BASIC_MEASURE, SCR_CID_BASIC_MEASURE };
+
+/**
+ * \brief This array holds configuration values for the client status field for different clients and groups. \n
+ */
+static BOOLEAN clientStaus [SCR_MID_NUM_OF_MODES][ SCR_GID_NUM_OF_GROUPS ][ SCR_CID_NUM_OF_CLIENTS ] = 
+                               {       /* This is the table for Normal mode    */
+                                       {/* client status for idle group */
+                        { FALSE,    /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ },
+                       /* client status for inter scan gorup */
+                        { TRUE,     /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ },
+                       /* client status for connect group */
+                        { FALSE,    /**< client status for SCR_CID_APP_SCAN */
+                          TRUE,     /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          TRUE,     /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ },                       
+                       /* client status for connected group */
+                        { TRUE,     /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          TRUE,     /**< client status for SCR_CID_CONT_SCAN */
+                          TRUE,     /**< client status for SCR_CID_EXC_MEASURE */
+                          TRUE,     /**< client status for SCR_CID_BASIC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          TRUE,     /**< client status for SCR_CID_SWITCH_CHANNEL */ },
+                       /* client status for roaming group */
+                        { FALSE,    /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          TRUE,     /**< client status for SCR_CID_CONNECT */
+                          TRUE,     /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ }
+                    },
+
+                                       /* This is the table for the Soft gemini mode   */
+
+                                       { /* client status for idle group */
+                        { FALSE,    /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ },
+                       /* client status for inter scan gorup */
+                        { TRUE,     /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ },
+                       /* client status for connect group */
+                        { FALSE,    /**< client status for SCR_CID_APP_SCAN */
+                          TRUE,     /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          TRUE,     /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ },                       
+                       /* client status for connected group */
+                        { TRUE,     /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          TRUE,     /**< client status for SCR_CID_CONT_SCAN */
+                          TRUE,     /**< client status for SCR_CID_EXC_MEASURE */
+                          TRUE,     /**< client status for SCR_CID_BASIC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_CONNECT */
+                          FALSE,    /**< client status for SCR_CID_IMMED_SCAN */
+                          TRUE,     /**< client status for SCR_CID_SWITCH_CHANNEL */ },
+                       /* client status for roaming group */
+                        { FALSE,    /**< client status for SCR_CID_APP_SCAN */
+                          FALSE,    /**< client status for SCR_CID_DRIVER_FG_SCAN */
+                          FALSE,    /**< client status for SCR_CID_CONT_SCAN */
+                          FALSE,    /**< client status for SCR_CID_EXC_MEASURE */
+                          FALSE,    /**< client status for SCR_CID_BASIC_MEASURE */
+                          TRUE,     /**< client status for SCR_CID_CONNECT */
+                          TRUE,     /**< client status for SCR_CID_IMMED_SCAN */
+                          FALSE,    /**< client status for SCR_CID_SWITCH_CHANNEL */ }
+                    }
+                               };
+
+                               
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Creates the SCR object
+ *
+ * Function Scope \e Public.\n
+ * \param hOS - handle to the OS object.\n
+ * \return a handle to the SCR object.\n
+ */
+TI_HANDLE scr_create( TI_HANDLE hOS )
+{
+    /* allocate the SCR object */
+    scr_t *pScr = os_memoryAlloc( hOS, sizeof(scr_t) );
+
+    if ( NULL == pScr )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to create SCR module") );
+        return NULL;
+    }
+
+    /* store the OS handle */
+    pScr->hOS = hOS;
+
+    return pScr;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Finalizes the SCR object (freeing memory)
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ */
+void scr_release( TI_HANDLE hScr )
+{
+    scr_t *pScr = (scr_t*)hScr;
+
+    os_memoryFree( pScr->hOS, hScr, sizeof(scr_t) );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Initializes the SCR object
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param hReport - handle to the report module.\n
+ */
+void scr_init( TI_HANDLE hScr, TI_HANDLE hReport )
+{
+    int i;
+    scr_t *pScr = (scr_t*)hScr;
+
+    /* store the report object */
+    pScr->hReport = hReport;
+
+    /* mark current group as idle */
+    pScr->currentGroup = SCR_GID_IDLE;
+
+       /* mark current mode as normal */
+       pScr->currentMode = SCR_MID_NORMAL;
+
+    /* signal not within request process */
+    pScr->statusNotficationPending = FALSE;
+
+    /* mark that no client is currently running */
+    pScr->runningClient = SCR_CID_NO_CLIENT;
+
+    /* initialize client array */
+    for ( i = 0; i < SCR_CID_NUM_OF_CLIENTS; i++ )
+    {
+        pScr->clientArray[ i ].state = SCR_CS_IDLE;
+        pScr->clientArray[ i ].currentPendingReason = SCR_PR_NONE;
+        pScr->clientArray[ i ].clientRequestCB = NULL;
+        pScr->clientArray[ i ].ClientRequestCBObj = NULL;
+    }
+    
+    WLAN_REPORT_INIT( hReport, SCR_MODULE_LOG,  (".....SCR configured successfully\n"));
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Registers the callback function to be used per client.
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param client - the client ID.\n
+ * \param callbackFunc - the address of the callback function to use.\n
+ * \param callbackObj - the handle of the object to pass to the callback function (the client object).\n
+ */
+void scr_registerClientCB( TI_HANDLE hScr, 
+                           scr_clientId_e client,
+                           scr_callback_t callbackFunc, 
+                           TI_HANDLE callbackObj )
+{
+    scr_t *pScr = (scr_t*)hScr;
+
+#ifdef TI_DBG
+    if (client >= SCR_CID_NUM_OF_CLIENTS)
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                           ("Attempting to register callback for invalid client %d\n", client) );
+        return;
+    }
+#endif
+    pScr->clientArray[ client ].clientRequestCB = callbackFunc;
+    pScr->clientArray[ client ].ClientRequestCBObj = callbackObj;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Notifies the running process upon a firmware reset.
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ */
+void scr_notifyFWReset( TI_HANDLE hScr )
+{
+    scr_t *pScr = (scr_t*)hScr;
+
+    /* if a client is currently running, notify it of the recovery event */
+    if ( SCR_CID_NO_CLIENT != pScr->runningClient )
+    {
+        WLAN_REPORT_INFORMATION( pScr->hReport, 
+                                 SCR_MODULE_LOG, 
+                                 ("FW reset occured. Client %d Notified.\n", pScr->runningClient) );
+        if ( NULL != pScr->clientArray[ pScr->runningClient ].clientRequestCB )
+        {
+            pScr->clientArray[ pScr->runningClient ].clientRequestCB( pScr->clientArray[ pScr->runningClient ].ClientRequestCBObj,
+                                                                      SCR_CRS_FW_RESET, SCR_PR_NONE );
+        }
+        else
+        {
+            WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                               ("Trying to call client %d callback, which is NULL\n", pScr->runningClient) );
+        }
+    }
+#ifdef TI_DBG
+    else
+    {
+        WLAN_REPORT_INFORMATION( pScr->hReport, 
+                                 SCR_MODULE_LOG, 
+                                 ("FW reset occured. No client was running.\n") );
+    }
+#endif
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 27-April-2005\n
+ * \brief Changes the current SCR group.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param newGroup - the new group to use.\n
+ */
+void scr_setGroup( TI_HANDLE hScr, scr_groupId_e newGroup )
+{
+    scr_t *pScr = (scr_t*)hScr;
+    int i,highestPending;
+
+    WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG, ("Setting group %d.\n", newGroup) );
+
+#ifdef TI_DBG
+    if (newGroup >= SCR_GID_NUM_OF_GROUPS)
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                           ("Attempting to set invalid group to %d\n", newGroup) );
+        return;
+    }
+#endif
+
+    /* keep the new group */
+    pScr->currentGroup = newGroup;
+
+    /* for all pending clients */
+    for ( i = 0; i < SCR_CID_NUM_OF_CLIENTS; i++ )
+    {
+        /* if the pending reason has escalated */
+        if ( (pScr->clientArray[ i ].state == SCR_CS_PENDING) && /* the client is pending */
+             (pScr->clientArray[ i ].currentPendingReason < SCR_PR_DIFFERENT_GROUP_RUNNING) && /* the client was enabled in the previous group */
+             (FALSE == clientStaus[pScr->currentMode][ newGroup ][ i ]) ) /* the client is not enabled in the new group */
+        {
+            /* mark the new pending reason */
+            pScr->clientArray[ i ].currentPendingReason = SCR_PR_DIFFERENT_GROUP_RUNNING;
+            
+            /* notify the client of the change, using its callback */
+            if ( NULL != pScr->clientArray[ i ].clientRequestCB )
+            {
+                pScr->clientArray[ i ].clientRequestCB( pScr->clientArray[ i ].ClientRequestCBObj, 
+                                                        SCR_CRS_PEND, SCR_PR_DIFFERENT_GROUP_RUNNING );
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                   ("Trying to call client %d callback, which is NULL\n", i) );
+            }
+        }
+    }
+
+       /* if no client is running call the client with the highest pending client  */
+       /* because now , after group change , clients can be enabled                            */
+       if ( SCR_CID_NO_CLIENT == pScr->runningClient )
+    {
+               highestPending = scrFindHighest( hScr, SCR_CS_PENDING, (UINT8)(SCR_CID_NUM_OF_CLIENTS - 1), 0 );
+               if (SCR_CID_NO_CLIENT != highestPending)
+               {
+                       pScr->clientArray[ highestPending ].state = SCR_CS_RUNNING;
+            pScr->clientArray[ highestPending ].currentPendingReason = SCR_PR_NONE;
+            pScr->runningClient = (scr_clientId_e)highestPending;
+                       if ( NULL != pScr->clientArray[ highestPending ].clientRequestCB )
+            {
+                pScr->clientArray[ highestPending ].clientRequestCB( pScr->clientArray[ highestPending ].ClientRequestCBObj, 
+                                                        SCR_CRS_RUN, SCR_PR_NONE );
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                   ("Trying to call client %d callback, which is NULL\n", highestPending) );
+            }
+        }
+       }
+
+}
+
+/**
+ * \author Yuval Adler\n
+ * \date 23-Nov-2005\n
+ * \brief Changes the current SCR mode.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param newMode - the new mode to use.\n
+ */
+void scr_setMode( TI_HANDLE hScr, scr_modeId_e newMode )
+{
+    scr_t *pScr = (scr_t*)hScr;
+    int i,highestPending;
+
+    WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG, ("Setting mode %d.\n", newMode) );
+
+#ifdef TI_DBG
+    if (newMode >= SCR_MID_NUM_OF_MODES)
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                           ("Attempting to set invalid mode to %d\n", newMode) );
+        return;
+    }
+#endif
+
+    /* keep the new mode */
+    pScr->currentMode= newMode;
+       
+       /* Stage I : if someone is running and shouldn't be running in the new mode - Abort it */
+       if ( SCR_CID_NO_CLIENT != pScr->runningClient && 
+               (FALSE == clientStaus[ pScr->currentMode ][ pScr->currentGroup ][ pScr->runningClient ]) )
+       {
+               /* abort the running client */
+               pScr->clientArray[ pScr->runningClient ].state = SCR_CS_ABORTING;
+               if ( NULL != pScr->clientArray[ pScr->runningClient ].clientRequestCB )
+               {
+                       WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG,
+                                                                        ("Sending abort request to client %d\n", pScr->runningClient) );
+                       pScr->clientArray[ pScr->runningClient ].clientRequestCB( pScr->clientArray[ pScr->runningClient ].ClientRequestCBObj,
+                                                                                                                                         SCR_CRS_ABORT,
+                                                                                                                                         SCR_PR_NONE );
+               }
+               else
+               {
+                       WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                                          ("Trying to call client %d callback, which is NULL\n", pScr->runningClient) );
+               }
+
+       }
+
+       /* Stage II : notify escalated pending reason   */
+       /* for all pending clients */
+    for ( i = 0; i < SCR_CID_NUM_OF_CLIENTS; i++ )
+    {
+        /* if the pending reason has escalated */
+        if ( (pScr->clientArray[ i ].state == SCR_CS_PENDING) && /* the client is pending */
+             (pScr->clientArray[ i ].currentPendingReason < SCR_PR_DIFFERENT_GROUP_RUNNING) && /* the client was enabled in the previous group */
+             (FALSE == clientStaus[ pScr->currentMode ][ pScr->currentGroup ][ i ]) ) /* the client is not enabled in the new group/mode */
+        {
+            /* mark the new pending reason */
+            pScr->clientArray[ i ].currentPendingReason = SCR_PR_DIFFERENT_GROUP_RUNNING;
+            
+            /* notify the client of the change, using its callback */
+            if ( NULL != pScr->clientArray[ i ].clientRequestCB )
+            {
+                pScr->clientArray[ i ].clientRequestCB( pScr->clientArray[ i ].ClientRequestCBObj, 
+                                                        SCR_CRS_PEND, SCR_PR_DIFFERENT_GROUP_RUNNING );
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                   ("Trying to call client %d callback, which is NULL\n", i) );
+            }
+        }
+    }
+
+   
+       /* Stage III : call Highest Pending Client who is enabled in the new mode       */
+       if ( SCR_CID_NO_CLIENT == pScr->runningClient )
+    {
+               highestPending = scrFindHighest( hScr, SCR_CS_PENDING, (UINT8)(SCR_CID_NUM_OF_CLIENTS - 1), 0 );
+               if (SCR_CID_NO_CLIENT != highestPending)
+               {
+                       pScr->clientArray[ highestPending ].state = SCR_CS_RUNNING;
+            pScr->clientArray[ highestPending ].currentPendingReason = SCR_PR_NONE;
+            pScr->runningClient = (scr_clientId_e)highestPending;
+                       if ( NULL != pScr->clientArray[ highestPending ].clientRequestCB )
+            {
+                pScr->clientArray[ highestPending ].clientRequestCB( pScr->clientArray[ highestPending ].ClientRequestCBObj, 
+                                                        SCR_CRS_RUN, SCR_PR_NONE );
+            }
+            else
+            {
+                WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                   ("Trying to call client %d callback, which is NULL\n", highestPending) );
+            }
+        }
+       }
+
+}
+
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Request the channel use by a client
+ *
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param client - the client ID requesting the channel.\n
+ * \param pPendReason - the reason for a pend reply.\n
+ * \return The request status.\n
+ * \retval SCR_CRS_REJECT the channel cannot be allocated to this client.
+ * \retval SCR_CRS_PEND the channel is currently busy, and this client had been placed on the waiting list.
+ * \retval SCR_CRS_RUN the channel is allocated to this client.
+ */
+scr_clientRequestStatus_e scr_clientRequest( TI_HANDLE hScr, scr_clientId_e client, scr_pendReason_e* pPendReason )
+{
+    scr_t *pScr = (scr_t*)hScr;
+
+    WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG, ("Client %d requesting the channel.\n", client) );
+
+#ifdef TI_DBG
+    if (client >= SCR_CID_NUM_OF_CLIENTS)
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                           ("Attempting to request SCR for invalid client %d\n", client) );
+        return SCR_CRS_PEND;
+    }
+#endif
+    
+    *pPendReason = SCR_PR_NONE;
+
+    /* check if already inside a request - shouldn't happen!!! */
+    if ( TRUE == pScr->statusNotficationPending )
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG, ("request call while already in request!\n") );
+        return SCR_CRS_PEND;
+    }
+
+    /* check if current running client is requesting */
+    if ( client == pScr->runningClient )
+    {
+        WLAN_REPORT_WARNING( pScr->hReport, SCR_MODULE_LOG, ("Client %d re-requesting SCR\n", client) );
+        return SCR_CRS_RUN;
+    }
+    
+    /* check if the client is enabled in the current group */
+    if ( TRUE != clientStaus[ pScr->currentMode ][ pScr->currentGroup ][ client ])
+    {
+        pScr->clientArray[ client ].state = SCR_CS_PENDING;
+        pScr->clientArray[ client ].currentPendingReason = *pPendReason = SCR_PR_DIFFERENT_GROUP_RUNNING;
+        return SCR_CRS_PEND;
+    }
+        
+    /* check if a there's no running client at the moment */
+    if ( SCR_CID_NO_CLIENT == pScr->runningClient )
+    {
+        /* no running or aborted client - allow access */
+               WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG,
+                                                                ("channel allocated to client: %d\n", client) );
+               pScr->clientArray[ client ].state = SCR_CS_RUNNING;
+        pScr->runningClient = client;
+        return SCR_CRS_RUN;
+    }
+    
+    /* check if any client is aborting at the moment */
+    if ( SCR_CS_ABORTING == pScr->clientArray[ pScr->runningClient ].state )
+    {
+               /* a client is currently aborting, but there still might be a pending client with higher priority
+                  than the client currently requesting the SCR. If such client exists, the requesting client is
+                  notified that it is pending because of this pending client, rather than the one currently aborting.
+               */
+        scr_clientId_e highestPending;
+               highestPending = (scr_clientId_e)scrFindHighest( hScr, SCR_CS_PENDING, (UINT8)(SCR_CID_NUM_OF_CLIENTS - 1), client );
+               if ( (SCR_CID_NO_CLIENT == highestPending) ||
+             (highestPending < client) )
+               {
+            /* if the requesting client has higher priority than the current highest priority pending client,
+               the current highest priority pending client should be notified that its pending reason has 
+               changed (it is no longer waiting for current running client to abort, but for the requesting
+               client to finish, once the current has aborted */
+            if ( (highestPending != SCR_CID_NO_CLIENT) &&
+                 (SCR_PR_OTHER_CLIENT_ABORTING == pScr->clientArray[ highestPending ].currentPendingReason) )
+            {
+
+                               if ( NULL != pScr->clientArray[ highestPending ].clientRequestCB )
+                {
+                    pScr->clientArray[ highestPending ].clientRequestCB( pScr->clientArray[ highestPending ].ClientRequestCBObj,
+                                                                         SCR_CRS_PEND, SCR_PR_OTHER_CLIENT_RUNNING );
+                }
+                else
+                {
+                    WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                       ("Trying to call client %d callback, which is NULL\n", highestPending) );
+                }
+            }
+                       pScr->clientArray[ client ].currentPendingReason = *pPendReason = SCR_PR_OTHER_CLIENT_ABORTING;
+               }
+               else
+               {
+                       pScr->clientArray[ client ].currentPendingReason = *pPendReason = SCR_PR_OTHER_CLIENT_RUNNING;
+               }
+               pScr->clientArray[ client ].state = SCR_CS_PENDING;
+        return SCR_CRS_PEND;
+    }
+    /* check if a client with higher priority is running */
+    if (pScr->runningClient > client)
+    {
+        pScr->clientArray[ client ].state = SCR_CS_PENDING;
+               pScr->clientArray[ client ].currentPendingReason = *pPendReason = SCR_PR_OTHER_CLIENT_RUNNING;
+        return SCR_CRS_PEND;
+    }
+
+    /* if the client is not supposed to abort lower priority clients */
+    if ( (SCR_CID_NO_CLIENT == abortOthers[ client ]) || /* client is not supposed to abort any other client */
+         (pScr->runningClient > abortOthers[ client ]) ) /* client is not supposed to abort running client */
+    {
+        /* wait for the lower priority client */
+        pScr->clientArray[ client ].state = SCR_CS_PENDING;
+               pScr->clientArray[ client ].currentPendingReason = *pPendReason = SCR_PR_OTHER_CLIENT_RUNNING;
+        return SCR_CRS_PEND;
+    }
+
+    /* at this point, there is a lower priority client running, that should be aborted: */
+    /* mark the requesting client as pending (until the abort process will be completed) */
+    pScr->clientArray[ client ].state = SCR_CS_PENDING;
+
+    /* mark that we are in the middle of a request (if a re-entrance will occur in the complete) */
+    pScr->statusNotficationPending = TRUE;
+
+    /* abort the running client */
+    pScr->clientArray[ pScr->runningClient ].state = SCR_CS_ABORTING;
+    if ( NULL != pScr->clientArray[ pScr->runningClient ].clientRequestCB )
+    {
+               WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG,
+                                                                ("Sending abort request to client %d\n", pScr->runningClient) );
+               pScr->clientArray[ pScr->runningClient ].clientRequestCB( pScr->clientArray[ pScr->runningClient ].ClientRequestCBObj,
+                                                                  SCR_CRS_ABORT,
+                                                                  SCR_PR_NONE );
+    }
+    else
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                           ("Trying to call client %d callback, which is NULL\n", pScr->runningClient) );
+    }
+
+    /* mark that we have finished the request process */
+    pScr->statusNotficationPending = FALSE;
+
+    /* return the current status (in case the completion changed the client status to run) */
+    if ( SCR_CS_RUNNING == pScr->clientArray[ client ].state )
+    {
+               WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG,
+                                                                ("channel allocated to client: %d\n", client) );
+        return SCR_CRS_RUN;
+    }
+    else
+    {
+               pScr->clientArray[ client].currentPendingReason = *pPendReason = SCR_PR_OTHER_CLIENT_ABORTING;
+        return SCR_CRS_PEND;
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Notifies the SCR that the client doe not require the channel any longer
+ *
+ * This function can be called both by clients that are in possession of the channel, and by
+ * clients that are pending to use the channel.\n
+ * Function Scope \e Public.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param client - the client releasing the channel.\n
+ * \return OK if successful, NOK otherwise.\n
+ */
+void scr_clientComplete( TI_HANDLE hScr, scr_clientId_e client )
+{
+    int highestPending;
+    scr_t *pScr = (scr_t*)hScr;
+
+    WLAN_REPORT_INFORMATION( pScr->hReport, SCR_MODULE_LOG, ("Client %d releasing the channel.\n", client) );
+
+#ifdef TI_DBG
+    if (client >= SCR_CID_NUM_OF_CLIENTS)
+    {
+        WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                           ("Attempting to release SCR for invalid client %d\n", client) );
+        return;
+    }
+#endif
+
+    /* mark client state as idle */
+    pScr->clientArray[ client ].state = SCR_CS_IDLE;
+       pScr->clientArray[ client ].currentPendingReason = SCR_PR_NONE;
+
+    /* if completing client is running (or aborting) */
+    if ( pScr->runningClient == client )   
+    {
+        /* mark no running client */
+        pScr->runningClient = SCR_CID_NO_CLIENT;
+
+        /* find the pending client with highest priority */
+        highestPending = scrFindHighest( hScr, SCR_CS_PENDING, (UINT8)(SCR_CID_NUM_OF_CLIENTS-1), 0 );
+    
+        /* if a pending client exists */
+        if ( SCR_CID_NO_CLIENT != highestPending )
+        {
+            /* mark the client with highest priority as running */
+            pScr->clientArray[ highestPending ].state = SCR_CS_RUNNING;
+            pScr->clientArray[ highestPending ].currentPendingReason = SCR_PR_NONE;
+            pScr->runningClient = (scr_clientId_e)highestPending;
+        
+            /* if the SCR is not called from within a client request (re-entrance) */
+            if ( FALSE == pScr->statusNotficationPending )
+            {
+                if ( NULL != pScr->clientArray[ highestPending ].clientRequestCB )
+                {
+                    pScr->clientArray[ highestPending ].clientRequestCB( pScr->clientArray[ highestPending ].ClientRequestCBObj,
+                                                                         SCR_CRS_RUN, SCR_PR_NONE );
+                }
+                else
+                {
+                    WLAN_REPORT_ERROR( pScr->hReport, SCR_MODULE_LOG,
+                                       ("Trying to call client %d callback, which is NULL\n", highestPending) );
+                }
+            }
+        }
+    }
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Searches the client database for a client with matching state, from startFrom to endAt (inclusive).
+ * \brief Only searches for clients that are enabled at the current group!!!!\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param requiredState - the state to match.\n
+ * \param startFrom - the highest priority to begin searching from.\n
+ * \param endAt - the lowest priority to include in the search 
+ * \return the client ID if found, -1 otherwise.\n
+ */
+INT8 scrFindHighest( TI_HANDLE hScr,
+                     scr_clientState_e requiredState,
+                     int startFrom,
+                     int endAt )
+{
+    int i;
+    scr_t *pScr = (scr_t*)hScr;
+
+    /* loop on all clients, from start to end */
+    for ( i = startFrom; i >= endAt; i-- )
+    {
+        /* check if the client state matches the required state */
+        if ( (TRUE == clientStaus[ pScr->currentMode ][ pScr->currentGroup ][ i ]) && /* client is enabled in current group */
+             (requiredState == pScr->clientArray[ i ].state) ) /* client is in required state */
+        {
+            /* and if so, return the client index */
+            return i;
+        }
+    }
+
+    return SCR_CID_NO_CLIENT;
+}
diff --git a/sta_dk_4_0_4_32/common/src/core/srv/scr/scr.h b/sta_dk_4_0_4_32/common/src/core/srv/scr/scr.h
new file mode 100644 (file)
index 0000000..879c62d
--- /dev/null
@@ -0,0 +1,143 @@
+/** \file Scr.h
+ *  \brief This file includes internal (private) definitions to the SCR module
+ *  \author Ronen Kalish
+ *  \date 01-Dec-2004
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __SCR_H__
+#define __SCR_H__
+
+#include "scrApi.h"
+
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+
+ /*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/** \enum scr_clientState_e 
+ * \brief enumerates the different states a client may be in .\n
+ */
+typedef enum
+{
+    SCR_CS_IDLE = 0,    /**< client is idle */
+    SCR_CS_PENDING,     /**< client is pending to use the channel */
+    SCR_CS_RUNNING,     /**< client is using the channel */
+    SCR_CS_ABORTING     /**< 
+                         * client was using the channel, but was aborted, 
+                         * and complete notification is expected.
+                         */
+} scr_clientState_e;
+
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+
+/** \struct scr_client_t
+ * \brief This structure contains information for a specific client
+ */
+typedef struct
+{
+       scr_clientState_e       state;                                      /**< the client current state */
+       scr_callback_t          clientRequestCB;                            /**< the client's callback function */
+       TI_HANDLE                   ClientRequestCBObj;                         /**< the client's object */
+    scr_pendReason_e    currentPendingReason;                       /**< 
+                                                                     * the reason why this client is pending
+                                                                     * (if at all)
+                                                                     */
+} scr_client_t;
+
+/** \struct scr_t
+ * \brief This structure contains the SCR object data
+ */
+typedef struct
+{
+    TI_HANDLE                  hOS;                                    /**< a handle to the OS object */
+    TI_HANDLE               hReport;                                /**< a handle to the report object */
+       BOOLEAN                     statusNotficationPending;               /**< 
+                                                                     * whether the SCR is in the process of  
+                                                                     * notifying a status change to a client
+                                                                     * (used to solve re-entrance problem)
+                                                                     */
+    scr_clientId_e          runningClient;                          /**< 
+                                                                     * The index of the current running client 
+                                                                     * (-1 if none)
+                                                                     */
+    scr_groupId_e           currentGroup;                           /**< the current group */
+       scr_modeId_e                    currentMode;                                                    /**< the current mode */
+    scr_client_t               clientArray[ SCR_CID_NUM_OF_CLIENTS ];  /**< array holding all clients' info */
+} scr_t;
+
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+/**
+ * \author Ronen Kalish\n
+ * \date 01-Dec-2004\n
+ * \brief Searches the client database for a client with matching state, from startFrom to endAt\n
+ *
+ * Function Scope \e Private.\n
+ * \param hScr - handle to the SCR object.\n
+ * \param requiredState - the state to match.\n
+ * \param startFrom - the highest priority to begin searching from.\n
+ * \param endAt - the lowest priority to include in the search.\n
+ * \return the client ID if found, SCR_CID_NO_CLIENT otherwise.\n
+ */
+INT8 scrFindHighest( TI_HANDLE hScr,
+                     scr_clientState_e requiredState,
+                     int startFrom,
+                     int endAt );
+
+#endif /* __SCR_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalCtrl_api.h b/sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalCtrl_api.h
new file mode 100644 (file)
index 0000000..16f5859
--- /dev/null
@@ -0,0 +1,900 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_CTRL_API_H
+#define _WHAL_CTRL_API_H
+
+#include "whalCtrl_prm.h"
+#include "public_infoele.h"
+#include "whalBus_Defs.h"
+#include "MacServices_api.h"
+
+
+#define MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES       8
+#define MAX_CHANNELS_IN_REG_DOMAIN     40
+
+#define                CTS_TO_SELF_DISABLE             0
+#define                CTS_TO_SELF_ENABLE              1
+
+#define MAX_TEMPLATE_SIZE      256
+typedef struct
+{
+       UINT32  Size;
+       UINT8   Buffer[MAX_TEMPLATE_SIZE];
+} TemplateParams_T;
+
+typedef enum
+{
+    NULL_DATA_TEMPLATE = 0,
+    BEACON_TEMPLATE,        
+    PROBE_REQUEST_TEMPLATE,     
+    PROBE_RESPONSE_TEMPLATE,
+    QOS_NULL_DATA_TEMPLATE,
+    PS_POLL_TEMPLATE,
+} whalCtrl_templateType_e;
+
+typedef enum{
+    WHAL_WME = 0,
+    WHAL_NONE_QOS,
+}whalCtrl_qosProtocols_e;
+
+/* Do not change the order */
+typedef enum
+{
+    PS_DISABLE = 0,
+    PS_ENABLE = 1,
+} whalCtrl_psState_e;
+
+typedef enum
+{
+    PS_POLL_ACCESS_MNGR_GEN= 0,
+    PS_POLL_HOST_ECPU_GEN,
+} whalCtrl_psPollGen_e;
+
+typedef enum
+{
+       ENTER_PS_FAIL,
+       ENTER_PS_SUCCESS,
+       EXIT_PS_FAIL,
+       EXIT_PS_SUCCESS,
+}Hw_Event_PS_Status;
+
+/** Available cipher suites for admission control */
+typedef enum
+{
+    HAL_CTRL_CIPHER_NONE     = 0,        /**< no chpiher suite */
+    HAL_CTRL_CIPHER_WEP      = 1,        /**< WEP-40 chpiher suite */
+    HAL_CTRL_CIPHER_TKIP     = 2,        /**< TKIP chpiher suite */
+    HAL_CTRL_CIPHER_AES_WRAP = 3,        /**< AES WRAP chpiher suite */
+    HAL_CTRL_CIPHER_AES_CCMP = 4,        /**< AES CCMP chpiher suite */
+    HAL_CTRL_CIPHER_WEP104   = 5,        /**< WEP-104 chpiher suite */
+    HAL_CTRL_CIPHER_CKIP     = 6,        /**< CKIP chpiher suite */
+    HAL_CTRL_CIPHER_UNKNOWN  = 255       /**< UNKNOWN chpiher suite */
+} halCtrl_CipherSuite_e;
+
+
+/*
+ *     The Event Mail Box ID : Clients That expected an event should
+ *                                                     register,Mask/UnMask Events with this ID
+ */
+
+typedef enum 
+{
+    /*Regular events*/
+       HAL_EVENT_MEASUREMENT_START,                    /*0*/ 
+       HAL_EVENT_SCAN_CMPLT,                                   /*1*/ 
+       HAL_EVENT_CALIB_CMPLT,                                  /*2*/ 
+       HAL_EVENT_RSSI_LEVEL,                                   /*3*/ 
+       HAL_EVENT_PS_REPORT,                                    /*4*/ 
+       HAL_EVENT_SYNCHRONIZATION_TIMEOUT,              /*5*/ 
+       HAL_EVENT_HEALTH_REPORT,                                /*6*/ 
+       HAL_EVENT_ACI,                                                  /*7*/ 
+       HAL_EVENT_DEBUG_MESSAGE,                                /*8*/ 
+       HAL_EVENT_MAC_STATUS,                                   /*9*/ 
+       HAL_EVENT_DISCONNECT_COMPLETE,                  /*10*/
+    HAL_EVENT_JOIN_CMPLT,                                      /*11*/
+       HAL_EVENT_SWITCH_CHANNEL_CMPLT,                 /*12*/
+       HAL_EVENT_BSS_LOSE,                                             /*13*/
+       HAL_EVENT_MAX_TX_RETRY,                                 /*14*/
+    HAL_EVENT_MEASUREMENT_COMPLETE,                    /*15*/
+       HAL_EVENT_AP_DISCOVERY_COMPLETE,                /*16*/
+       HAL_EVENT_SPS_SCAN_CMPLT,                               /*17*/
+       HAL_EVENT_BSS_REGAIN,                                   /*18*/
+       HAL_EVENT_RSSI_LEVEL_REGAIN,                    /*19*/
+       HAL_EVENT_LOW_SNR,                                              /*20*/
+       HAL_EVENT_SOFT_GEMINI_SENSE,                    /*21*/
+       HAL_EVENT_SOFT_GEMINI_PREDICTION,               /*22*/
+       HAL_EVENT_SOFT_GEMINI_AVALANCHE,                /*23*/
+    HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE,     /*24*/
+    HAL_EVENT_PSPOLL_DELIVERY_FAILURE,      /*25*/
+    HAL_EVENT_BSS_RESET,                   /*26*/
+       HAL_EVENT_ALL,      /* 27 */
+       MAX_NUM_OF_EVENT, /* 28 */
+}Hw_Event_ID;   
+
+
+typedef struct
+{
+    macAddress_t    macAddress;
+    preamble_e      preamble;
+    radioType_e     radioType;
+    radioBand_e     radioBand;
+    UINT8           fwVer[FW_VERSION_LEN]; /* Firmware version - null terminated string*/
+    e2Version_t     e2Ver;                 /* EEPROM version*/
+} whalCtrl_chip_t;  
+
+typedef struct
+{
+    TI_HANDLE                  hRxXfer; 
+       TI_HANDLE                       hTxXfer;
+       TI_HANDLE                       hTxResult;
+       TI_HANDLE                       hTxHwQueue; 
+       TI_HANDLE                       hReport; 
+       TI_HANDLE                       hMemMgr;
+       TI_HANDLE                       hEventMbox;
+       TI_HANDLE                       hFwEvent;
+    TI_HANDLE           hCmdQueue;
+#ifdef TI_DBG
+       TI_HANDLE                       hDebugTrace;
+#endif /* TI_DBG */
+} whalCtrl_config_t;
+
+
+
+typedef struct
+{
+    bssType_e   bssType;
+    UINT16      beaconInterval;
+    UINT16      dtimInterval;
+    UINT8       channel;
+    UINT8*      pBSSID;
+    UINT8*      pSSID;
+    UINT8       ssidLength;
+    rate_e      hwGenCtrlTxRate;
+    rate_e      hwGenMgmtTxRate;               /* Beacon and Probe-Response Tx rate (in IBSS). */
+    UINT16      basicRateSet;       
+    UINT16      supportedRateSet;   
+    radioBand_e radioBand;
+    preamble_e  preamble;
+} whalCtrl_joinBss_t;
+
+typedef struct
+{
+    whalCtrl_templateType_e templateType;
+    UINT8*                  pTemplate;
+    UINT32                  templateLen;
+} whalCtrl_setTemplate_t;
+
+PACKED_STRUCT( whalCtrl_antennaDiversityOptions_t,
+
+    uint8   enableRxDiversity;
+    uint8   rxSelectedAntenna;
+    uint8   enableTxDiversity;
+    uint8   txSelectedAntenna;
+    uint8   rxTxSharedAnts;
+);
+
+typedef enum
+{
+     STOP_NOISE_HIST  = 0,
+     START_NOISE_HIST = 1
+} NoiseHistogramCmd_e;
+
+typedef struct
+{
+    NoiseHistogramCmd_e     cmd;
+    UINT16                  sampleInterval;
+    UINT8                   ranges[MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES];
+} whalCtrl_noiseHistogram_t;
+
+/* use this struct when expecting a CB after a CONFIGURE_ACTION */
+PACKED_STRUCT( acxStatisitcs_t,
+
+    UINT32  FWpacketReceived;
+    UINT32  HALpacketReceived;
+);
+
+PACKED_STRUCT( mediumOccupancy_t,
+
+    interogateCmdHdr_t  mediumOccupCmdHdr;
+    UINT32  MediumUsage;
+    UINT32  Period;
+);
+
+PACKED_STRUCT( tsf_dtim_mib_t,
+
+    interogateCmdHdr_t  tsf_dtim_mibCmdHdr;
+    uint32 CurrentTSFHigh;
+    uint32 CurrentTSFLow;
+    uint32 lastTBTTHigh;
+    uint32 lastTBTTLow;
+    uint8 LastDTIMCount;
+    uint8 Reserved[3];
+);
+
+
+typedef struct 
+{
+       UINT16          BeaconRxTimeout;
+       UINT16          BroadcastRxTimeout;
+       UINT8           RxBroadcastInPs;
+} BcnBrcOptions_t;
+
+typedef struct
+{
+       UINT8           numberOfIEs;
+       UINT8           IETable[BEACON_FILTER_TABLE_MAX_SIZE];
+       UINT8           IETableSize;
+} beaconFilterIETable_t;
+
+
+typedef struct
+{
+    UINT8   beaconListenInterval;
+    UINT8   beaconFiltering;
+    UINT8   DTIMListenInterval;
+    UINT8   NConsecutiveBeaconMiss;
+    UINT8   hangoverPeriod;
+       UINT8   HwPsPollResponseTimeout;
+       UINT32  BaseBandWakeUpTime;
+    UINT32  beaconReceiveTime;
+    BOOLEAN beaconMissInterruptEnable;
+    BOOLEAN rxBroadcast;
+    BOOLEAN hwPsPoll;
+    
+
+       /* powerMgmtConfig IE */
+    BOOLEAN    ps802_11Enable;
+    UINT8              needToSendNullData;  
+    UINT8              numNullPktRetries; 
+    UINT8              hangOverPeriod;
+    UINT16             NullPktRateModulation; 
+
+       /* PMConfigStruct */
+       BOOLEAN         ELPEnable;
+       UINT32          BBWakeUpTime;
+       UINT32          PLLlockTime;
+
+       /* AcxBcnBrcOptions */
+       BcnBrcOptions_t BcnBrcOptions;
+
+       /* ACXWakeUpCondition */
+    PowerMgr_TnetWakeOn_e tnetWakeupOn;  
+    UINT8      listenInterval;
+
+    /* No answer after Ps-Poll work-around */
+    UINT8  ConsecutivePsPollDeliveryFailureThreshold;
+} whalCtrl_powerMgmtConfig_t;
+
+typedef struct
+{
+    
+       /* powerMgmtConfig IE */
+    BOOLEAN                                    ps802_11Enable;
+    UINT8                                              needToSendNullData;  
+    UINT8                                              numNullPktRetries; 
+    UINT8                                              hangOverPeriod;
+    UINT16                                     NullPktRateModulation;
+    void *                                             powerSaveCBObject;
+    MacServices_powerSaveCmdResponseCB_t       powerSavecmdResponseCB;
+       
+       
+} whalCtrl_powerSaveParams_t;
+
+/*MULTIPLE QUEUES STRUCTURE */
+
+typedef struct
+{
+    UINT16      txopLimit;
+    UINT16      rxTimeout;
+    UINT8       aifsn;
+    UINT8       cwMin;
+    UINT16      cwMax;
+    UINT8       acId;
+    UINT8       shortRetryLimit;
+    UINT8       longRetryLimit;
+    UINT8       retryPreemption;
+    UINT8       txopContinuation;
+       UINT8       PsParameters;
+} whaCtrl_acTrafficParams_t;
+
+
+typedef struct  
+{
+       UINT8              acId;
+    UINT8              qId;
+    UINT16                    percentOfBlockHighThreshold; /* Sum of ACs > numTxMemBlks in ~10%    */
+    UINT16                    percentOfBlockLowThreshold;  /* Sum of ACs <  numTxMemBlks           */
+} acQueuesParams_t; 
+
+
+typedef enum{
+       HAL_CTRL_AC_NOT_ADMITTED,
+       HAL_CTRL_AC_WAIT_ADMISSION,
+       HAL_CTRL_AC_ADMITTED
+} whalCtrl_trafficAdmState_e;
+
+typedef enum{
+       HAL_CTRL_UNIDIRECTION,
+       HAL_CTRL_BIDIRECTION,
+} whalCtrl_streamDirection_e;
+
+typedef enum{
+       HAL_CTRL_ADDTS_RESPONSE_ACCEPT = 0,
+/*     HAL_CTRL_ADDTS_RESPONSE_REJECT,  - according to the standard*/
+       HAL_CTRL_ADDTS_RESPONSE_AP_PARAM_INVALID = 253,
+       HAL_CTRL_ADDTS_RESPONSE_TIMEOUT = 254,
+       HAL_CTRL_TSPEC_DELETED_BY_AP = 255,
+} whalCtrl_addtsRaeasonCode_e;
+
+typedef enum{
+       HAL_CTRL_HIGH_THRESHOLD_CROSS,
+       HAL_CTRL_LOW_THRESHOLD_CROSS,
+} whalCtrl_thresholdCross_e;
+
+typedef enum{
+       HAL_CTRL_CROSS_ABOVE,
+       HAL_CTRL_CROSS_BELOW,
+} whalCtrl_thresholdCrossDirection_e;
+
+typedef struct{
+       UINT32 acID;
+       thresholdCross_e thresholdCross;
+} tspecRateCross_t;
+
+typedef struct{
+       UINT32 acID;
+       UINT32 thresholdCross;
+       UINT32 thresholdCrossDirection;
+} mediumTimeCross_t;
+
+/************************************/
+/*      QOS edcf params             */
+/************************************/
+
+/*=================== Mesurement =====================*/
+
+typedef struct 
+
+{
+       uint32      ConfigOptions;
+    uint32      FilterOptions;
+       uint32      duration;
+       Channel_e   channel;
+       RadioBand_e band;
+} whalCtrl_MeasurementParameters_t;
+
+typedef struct 
+
+{
+       uint32          ConfigOptions;
+    uint32             FilterOptions;
+       uint32          scanDuration;
+       uint16          scanOptions;
+       uint8           numOfProbRqst;
+       TxdRateSet_t    txdRateSet;
+       uint8                   txPowerDbm;    
+} whalCtrl_ApDiscoveryParameters_t;
+
+/*=======================================================*/
+
+
+typedef struct
+{
+    /* ACXLowRSSITriggerParameters */
+       INT8   rssiThreshold;
+    UINT8  rssiFilterWeight;
+    UINT8  rssiFilterDepth;
+    UINT8  lowRSSIEventType;
+
+    /* ACXLowSNRTriggerParameters */
+    UINT8  snrThreshold;
+    UINT8  snrFilterWeight;
+    UINT8  snrFilterDepth;
+    UINT8  lowSNREventType;
+
+       /* ACXConsNackTriggerParameters */
+    UINT8  maxTxRetry;
+
+       /* ACXBssLossTsfSynchronize */
+    UINT16  TsfMissThreshold;
+    UINT16  BssLossTimeout;
+} whalCtrl_roamingTriggerCmd_t;
+
+
+typedef struct
+{
+    UINT8              channelNumber;
+    UINT8           switchTime;
+    UINT8           txFlag;
+       UINT8                   flush;
+} whalCtrl_switchChannelCmd_t;
+
+typedef scan_Params_t whalCtrl_scan_t;
+
+
+PACKED_STRUCT( whalCtrl_counters_t,
+
+    UINT32  RecvError;            /* the number of frames that a NIC receives but does not indicate to the protocols due to errors*/
+    UINT32  RecvNoBuffer;         /* the number of frames that the NIC cannot receive due to lack of NIC receive buffer space     */
+    UINT32  FragmentsRecv;
+    UINT32  FrameDuplicates;
+    UINT32  FcsErrors;
+);
+
+/*
+PACKED_STRUCT(whalCtrl_PLT_TX_Continues_t,
+       UINT8 rate;
+       UINT8 chID;
+       UINT8 preamble;
+       UINT8 bandID;
+       UINT8 Modulation;
+       UINT8 TestMode;
+);
+
+PACKED_STRUCT(whalCtrl_PLT_TX_CW_t,
+       UINT8 chID;
+       UINT8 bandID;
+);
+*/
+
+PACKED_STRUCT(whalCtrl_WriteRegister_t,
+       UINT32 RegAdress;
+       UINT32 RegData;
+);
+
+
+typedef struct
+{
+    uint8       channel;
+    int8        maxRegPower;
+} whalCtrl_RegulatoryChannelPowerConstraint_t;
+
+typedef struct 
+{
+    uint8       numberOfChannels;
+    RadioBand_e band;
+    whalCtrl_RegulatoryChannelPowerConstraint_t channelListConstraint[MAX_CHANNELS_IN_REG_DOMAIN];
+} whalCtrl_RegulatoryPowerConstraint_t;
+
+typedef struct  
+{
+    INFO_ELE_HDR
+    int8           powerConstraintOnBss;  /* The attenuation from the regulatory */
+                                            /* power constraint as declared by the AP */
+                                            /* Units: dBm*/
+                                            /* Range: -20 - 30*/
+} whalCtrl_ApPowerConstraint_t;
+
+typedef struct  
+{
+    INFO_ELE_HDR
+    uint8           attenuation;            /* Attenuation from the maximum radio transmit */
+                                            /* power as declared by the driver/application*/
+                                            /* Units: dB*/
+                                            /* Range: 0 - 20*/
+} whalCtrl_PowerAttenuation_t;
+
+typedef struct  
+{
+    INFO_ELE_HDR
+    int8            currentTransmitPower;   /* Current transmit power of the radio.*/
+                                                /* Units: dBm*/
+} whalCtrl_GetCurrentTxPower_t;
+
+/*
+ *     TX Ack Policy
+ */
+typedef struct 
+{
+       AckPolicy_e  AckPolicy;
+       UINT8 AcId;
+}AcAckPolicy_t;
+
+typedef union
+{
+
+    
+        /* HAL Control section */
+        UINT16                  halCtrlRtsThreshold;
+               UINT8                                   halCtrlCtsToSelf;
+               rxTimeOut_t                             halCtrlRxTimeOut;
+        UINT16                  halCtrlFragThreshold;
+        UINT16                  halCtrlListenInterval;
+        UINT16                  halCtrlCurrentBeaconInterval;
+        UINT8                   halCtrlTxPowerDbm;
+        txAntenna_e             halCtrlTxAntenna;
+        rxAntenna_e             halCtrlRxAntenna;
+        UINT8                   halCtrlAifs;
+        BOOL                    halCtrlTxMemPoolQosAlgo;
+        BOOL                    halCtrlClkRunEnable;
+        whalCtrl_counters_t     halCtrlCounters;
+
+               PltTxContinues_t        PltTxContinues;
+               TestCmdChannelBand_t    PltCW;
+        PLT_MIB_t               PltMib;
+               
+
+        UINT8                   halCtrlCurrentChannel;
+
+        UINT8                   earlyWakeup;
+               
+        /* tx data qos related parameters */
+        txDataQosParams_t       txDataQosParams;
+        
+        /*
+         *     WME Tx Parameters 
+         */
+
+               /* ac queues parameters */
+               acQueuesParams_t acQueuesParams;
+
+        /* Access Category Ack Policy */
+        AcAckPolicy_t                  AcAckPolicy;
+        /* Qos Type For Tx Descriptor */
+        qosProtocols_e          halCtrlTxQosType;
+        /* ac traffic parameters */
+        whaCtrl_acTrafficParams_t  acTrafficParams;
+        /* queue params */
+        acQueuesParams_t        acQueuesParam;
+
+               /* ac Qos parameters */
+               queueTrafficParams_t    *pQueueTrafficParams;
+      
+        /* Security related parameters */
+#ifdef EXC_MODULE_INCLUDED
+        BOOL                    rsnExcSwEncFlag;
+        BOOL                    rsnExcMicFieldFlag;
+#endif
+        halCtrl_CipherSuite_e   rsnEncryptionStatus;
+        UINT8                   rsnHwEncDecrEnable; /* 0- disable, 1- enable*/
+        securityKeys_t                 *pRsnKey;
+        UINT8                   rsnDefaultKeyID;
+
+        /*
+        Power Control
+        */
+
+               powerAutho_PowerPolicy_e minPowerPolicy;
+        
+        /* Measurements section */
+        acxStatisitcs_t             acxStatisitics;
+        mediumOccupancy_t           mediumOccupancy;
+        BOOLEAN                     halTxOpContinuation;
+
+               tsf_dtim_mib_t                          fwTsfDtimInfo;
+
+        interogateCmdCBParams_t        interogateCmdCBParams;
+               configureCmdCBParams_t  configureCmdCBParams;
+
+               txRatePolicy_t                  *pTxRatePlicy;
+
+        /* Antenna diversity options */
+        whalCtrl_antennaDiversityOptions_t antennaDiversityOptions;
+        UINT8                   antennaNum;
+        
+        /* WARNING!!! This section is used to set/get internal params only. */
+        UINT16                  halCtrlAid;
+               
+
+               SoftGeminiEnableModes_e    SoftGeminiEnable;
+               SoftGeminiParam_t     SoftGeminiParam;
+               
+               UINT32                  halCtrlMaxRxMsduLifetime;
+        
+               /* Utils section */
+               UINT8                   SeverityTable[WLAN_MAX_SEVERITIES];
+               UINT8                   ModuleTable[WLAN_MAX_LOG_MODULES];
+               UINT32                  reportPPMode;
+        UINT32          osDbgState;
+
+               /* Beacon Broadcast options */
+               BcnBrcOptions_t BcnBrcOptions;
+
+        /* PLT tests */
+        TI_STATUS             PltRxCalibrationStatus;
+
+}whalParamContents;
+
+
+typedef struct{
+
+    UINT32              paramType;
+    UINT32              paramLength;
+       whalParamContents       content;
+}whalParamInfo_t;
+
+typedef enum
+{
+    GWSI_TX_CB_MODULE_OWNER               = 0x0100,  /* WHAL TX MODULE */
+    GWSI_RX_CB_MODULE_OWNER               = 0x0200,     /* WHAL RX MODULE */
+    GWSI_EVENT_IND_CB_MODULE_OWNER        = 0x0400,     /* WHAL HW EVENT MBOX */
+
+    /*
+    Last CB module owner- DO NOT TOUCH!
+    */
+    GWSI_CB_LAST_MODULE_OWNER                    = 0x0500
+
+}   GwsiCB_ModuleOwner_e;
+
+typedef enum 
+{
+    PLT_RX_PER_START,
+    PLT_RX_PER_STOP,
+    PLT_RX_PER_CLEAR,
+    PLT_RX_PER_GETRESULTS,
+    PLT_RX_PER_START_PH2,
+    PLT_RX_PER_MAX    /* Must be last*/
+}PLT_RxPerCmd_e;
+
+
+typedef enum
+{
+       /* Tx Data Path Callbacks */
+    GWSI_TX_SEND_PACKET_TRANSFER_CB       =  GWSI_TX_CB_MODULE_OWNER | 0x01,  /* WHAL TX MODULE */
+    GWSI_TX_SEND_PACKET_COMPLETE_CB       =  GWSI_TX_CB_MODULE_OWNER | 0x02,  /* WHAL TX MODULE */
+    GWSI_TX_QUEUE_FREE_EVENT_CB                          =  GWSI_TX_CB_MODULE_OWNER | 0x03,  /* WHAL TX MODULE */
+
+       /* Rx Data Path Callbacks */
+    GWSI_RX_REQUEST_FOR_BUFFER_CB         =  GWSI_RX_CB_MODULE_OWNER | 0x01,  /* WHAL RX MODULE */
+    GWSI_RX_RECEIVE_PACKET_CB                    =  GWSI_RX_CB_MODULE_OWNER | 0x02,  /* WHAL RX MODULE */
+
+}GwsiCB_Type_e;
+
+typedef enum
+{
+       /* Tx Data Path Callbacks */
+    HAL_INT_SEND_PACKET_TRANSFER       =  0x00 ,       /* WHAL TX MODULE */
+    HAL_INT_SEND_PACKET_COMPLETE                       ,       /* WHAL TX MODULE */
+    HAL_INT_QUEUE_FREE_EVENT                           ,       /* WHAL TX MODULE */
+
+       /* Rx Data Path Callbacks */
+    HAL_INT_RECEIVE_PACKET                     =  0x10 ,  /* WHAL RX MODULE */
+    HAL_INT_REQUEST_FOR_BUFFER                         ,  /* WHAL RX MODULE */
+       
+       /* Ctrl Callbacks */
+       HAL_INT_COMMAND_COMPLETE                =  0x20 ,       
+       
+       HAL_INTERNAL_EVENT_FAILURE                      
+
+}Hw_RegisterID_e;
+
+/*
+ * WHAL CTRL Class API
+ */         
+TI_HANDLE whalCtrl_Create (TI_HANDLE hOs);
+int  whalCtrl_Stop              (TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_Config    (TI_HANDLE hWhalCtrl, TI_HANDLE hTNETW_Driver, whalCtrl_config_t* pWhalCtrlCfg,UINT32 *pFWImage);
+TI_HANDLE whalCtrl_GetTnetwifHandle (TI_HANDLE hWhalCtrl);
+TI_HANDLE whalCtrl_GetWhalParams (TI_HANDLE hWhalCtrl);
+int  whalCtrl_ConfigHw       (TI_HANDLE hWhalCtrl, TnetwDrv_InitParams_t* pInitParams, void *fCb, TI_HANDLE hCb);
+int  whalCtrl_ReConfig          (TI_HANDLE hWhalCtrl, int DoReJoin);
+void whalCtrl_RecoveryEnded  (TI_HANDLE hWhalCtrl);
+int  whalCtrl_Destroy    (TI_HANDLE pWhalCtrl);
+void whalCtrl_Register_CB      (TI_HANDLE pWhalCtrl,tiUINT32 CallBackID,void *CBFunc,TI_HANDLE CBObj);
+void                   whalCtrl_PreRecoveryProcess(TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_FinalizeDownload (TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_FinalizeOnFailure (TI_HANDLE hWhalCtrl);
+
+/* 
+ *     Set/Get API
+ */
+int            whalCtrl_setRxFilters            (TI_HANDLE hWhalCtrl, UINT32 RxConfigOption, UINT32 RxFilterOption);
+int     whalCtrl_GetRxFilters          (TI_HANDLE hWhalCtrl, UINT32* pRxConfigOption, UINT32* pRxFilterOption);
+int  whalCtrl_setRxDataFiltersParams(TI_HANDLE hWhalCtrl, BOOL enabled, filter_e defaultAction);
+int  whalCtrl_setRxDataFilter   (TI_HANDLE hWhalCtrl, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns);
+int  whalCtrl_getRxDataFiltersStatistics(TI_HANDLE hWhalCtrl, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int  whalCtrl_SetMacAddress     (TI_HANDLE hWhalCtrl, macAddress_t *macAddr);
+int  whalCtrl_SetTemplate       (TI_HANDLE pWhalCtrl, whalCtrl_setTemplate_t* pTemplateParams);
+int  whalCtrl_SetTemplateWithCB (TI_HANDLE hWhalCtrl, whalCtrl_setTemplate_t* pTemplateParams,void *CBFunc,TI_HANDLE CBObj);
+TemplateParams_T * whalCtrl_GetTemplate(TI_HANDLE hWhalCtrl, whalCtrl_templateType_e templateType);
+int            whalCtrl_SetSlotTime            (TI_HANDLE hWhalCtrl, slotTime_e SlotTimeVal);
+int    whalCtrl_SetPreamble        (TI_HANDLE hWhalCtrl, preamble_e preambleVal);
+int     whalCtrl_SetFrameRate       (TI_HANDLE hWhalCtrl, rate_e txFrmRate, BOOL bCtrlFrame);
+int            whalCtrl_SetBeaconFiltering      (TI_HANDLE hWhalCtrl, UINT8 beaconFilteringStatus, UINT8 numOfBeaconsToBuffer);
+int            whalCtrl_GetBeaconFiltering      (TI_HANDLE hWhalCtrl);
+
+int            whalCtrl_SetBeaconFilterIETable(TI_HANDLE hWhalCtrl, UINT8* numberOfIEs, UINT8 * IETable, UINT8* IETableSize);
+int            whalCtrl_GetBeaconFilterIETable(TI_HANDLE hWhalCtrl, UINT8* numberOfIEs, UINT8 * IETable, UINT8* IETableSize);
+int            whalCtrl_SetarpIpAddressesTable(TI_HANDLE hWhalCtrl, IpAddress_t * IP_addr, UINT8 isEnabled , IPver_e IP_ver);
+int            whalCtrl_SetarpIpFilterEnabled(TI_HANDLE hWhalCtrl,UINT8 isEnabled );
+int            whalCtrl_SetGroupAddressesTable(TI_HANDLE hWhalCtrl, UINT8 numGroupAddrs, macAddress_t *Group_addr,UINT8 isEnabled);
+int     whalCtrl_GetGroupAddressesTable(TI_HANDLE hWhalCtrl, UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr);
+
+int            whalCtrl_SetCwMin                        (TI_HANDLE hWhalCtrl, UINT8 CwMin);
+int            whalCtrl_getSend4xWackInfo   (TI_HANDLE hWhalCtrl, UINT8 *Send4xWackInfo);
+int            whalCtrl_setSend4xWackInfo   (TI_HANDLE hWhalCtrl, UINT8 Send4xWackInfo);
+void   whalCtrl_SetBeaconInterval   (TI_HANDLE hWhalCtrl , UINT16 Val);
+UINT16  whalCtrl_GetBeaconInterval   (TI_HANDLE hWhalCtrl);
+void    whalCtrl_SetInfoElemEventMask(TI_HANDLE hWhalCtrl,UINT32 eventMask);
+
+int            whalCtrl_getTsf                          (TI_HANDLE hwHalCtrl, UINT32 *pTsf);
+int            whalCtrl_setDtimPeriod           (TI_HANDLE hWhalCtrl, UINT8 dtimPeriod, UINT16 TBTT);
+UINT8   whalCtrl_GetDtimCount        (TI_HANDLE hWhalCtrl);
+
+TI_STATUS  whalCtrl_SetParam            (TI_HANDLE pWhalCtrl, whalParamInfo_t* pParamInfo);
+TI_STATUS  whalCtrl_GetParam            (TI_HANDLE pWhalCtrl, whalParamInfo_t* pParamInfo);
+
+int whalCtrl_ElpCtrl_SetMode(TI_HANDLE hWhalCtrl, elpCtrl_Mode_e mode);
+int whalCtrl_setBetParams(TI_HANDLE hWhalCtrl, UINT8 Enable, UINT8 MaximumConsecutiveET);
+
+/*
+ *     Read/Write Reg API
+ */
+UINT32  whalCtrlReadMacReg             (TI_HANDLE hWhalCtrl, UINT32 addr);
+void   whalCtrlWriteMacReg             (TI_HANDLE hWhalCtrl, UINT32 addr, UINT32       val);
+UINT32  whalCtrlReadPhyReg             (TI_HANDLE hWhalCtrl, UINT32 addr);
+void   whalCtrlWritePhyReg             (TI_HANDLE hWhalCtrl, UINT32 addr, UINT32       val);
+int            whalCtrl_GetRadioStandByState(TI_HANDLE hWhalCtrl);
+TI_STATUS  whalCtrl_GetFWInfo  (TI_HANDLE hWhalCtrl, whalCtrl_chip_t *pChip_Version);
+
+
+/*
+ *     Rx API
+ */
+int  whalCtrl_resetMacRx               (TI_HANDLE hWhalCtrl);
+
+/*
+ *     Tx API
+ */
+
+int     whalCtrl_DisableTx                     (TI_HANDLE hWhalCtrl);
+int     whalCtrl_EnableTx                      (TI_HANDLE hWhalCtrl);
+UINT32  whalCtrl_GetTime                       (TI_HANDLE hWhalCtrl);
+void   whalCtrl_resetTxCounters        (TI_HANDLE hWhalCtrl);
+void   whalCtrl_updateSecuritySeqNum(TI_HANDLE hWhalCtrl, UINT8 securitySeqNumLsByte);
+/*
+ *     Radio Handle API
+ */
+int  whalCtrl_SetRadioBand      (TI_HANDLE hWhalCtrl, radioBand_e RadioBand);
+int  whalCtrl_SwitchChannel            (TI_HANDLE hWhalCtrl , UINT8 channel);
+
+/*
+ *     Recovery API
+ */
+int  whalCtrl_CheckMailboxCb   (TI_HANDLE hWhalCtrl,UINT16 MboxStatus,char *InterrogateParamsBuf);
+int  whalCtrl_SetPacketDetectionThreshold (TI_HANDLE hWhalCtrl, UINT8 PDThreshold);
+int  whalCtrl_SetEnergyDetection (TI_HANDLE hWhalCtrl, BOOL energyDetection);
+int  whalCtrl_CheckHwStatus     (TI_HANDLE hWhalCtrl);
+int  whalCtrl_InitHwStatus      (TI_HANDLE hWhalCtrl);
+int  whalCtrl_PrintHwStatus     (TI_HANDLE hWhalCtrl);
+int  whalCtrl_PeriodicCheckMailboxCb(TI_HANDLE hWhalCtrl,UINT16 MboxStatus,char *InterrogateParamsBuf);
+void whalCtrl_ResetBusAfterHardBoot(TI_HANDLE hWhalCtrl);
+
+/*
+ *     Event Mail Box API
+ */
+int  whalCtrl_EventMbox_RegisterForEvent(TI_HANDLE hWhalCtrl, int EventBit, void *CbFunc, void *CbObj);
+int  whalCtrl_EventMbox_Disable                        (TI_HANDLE hWhalCtrl, int EventBit);
+int  whalCtrl_EventMbox_Enable                 (TI_HANDLE hWhalCtrl, int EventBit);
+
+/*
+ *     LNA API
+ */
+int  whalCtrl_LNAControl               (TI_HANDLE hWhalCtrl, UINT8 LNAControlField);
+
+/*
+ *     HW Interrupt API
+ */
+void whalCtrl_HandleBusTxn_Complete(TI_HANDLE hWhalCtrl);
+int whalCtrl_HandleInterrupts  (TI_HANDLE pWhalCtrl);
+void whalCtrl_EnableInterrupts (TI_HANDLE pWhalCtrl);
+void whalCtrl_DisableInterrupts (TI_HANDLE pWhalCtrl);
+UINT32  whalCtrl_CheckInterrupts       (TI_HANDLE pWhalCtrl);
+void  whalCtr_SlaveAckMaskNotification (TI_HANDLE hWhalCtrl);
+
+
+
+/*
+ *     Power Ctrl API
+ */
+TI_STATUS whalCtrl_powerMgmtConfig(TI_HANDLE theWhalCtrlHandle,
+                                       whalCtrl_powerSaveParams_t* powerSaveParams);
+/*                                   whalCtrl_powerMgmtConfig_t thePowerMgmtConfig);*/
+TI_STATUS whalCtrl_wakeUpCondition(TI_HANDLE theWhalCtrlHandle,
+                                   whalCtrl_powerMgmtConfig_t thePowerMgmtConfig);
+TI_STATUS whalCtrl_PMConfig(TI_HANDLE theWhalCtrlHandle,
+                            whalCtrl_powerMgmtConfig_t thePowerMgmtConfig);
+TI_STATUS whalCtrl_BcnBrcOptions(TI_HANDLE theWhalCtrlHandle,
+                            whalCtrl_powerMgmtConfig_t thePowerMgmtConfig);
+TI_STATUS whalCtrl_SetMinPowerLevel(TI_HANDLE theWhalCtrlHandle,
+                                                                       powerAutho_PowerPolicy_e minPowerPolicy);
+TI_STATUS whalCtrl_GetMinPowerLevel(TI_HANDLE theWhalCtrlHandle,
+                                                                       powerAutho_PowerPolicy_e* minPowerPolicy);
+
+
+/*
+ * Measurement API     
+ */
+int whalCtrl_NoiseHistogramCmd  (TI_HANDLE hWhalCtrl, whalCtrl_noiseHistogram_t* pNoiseHistParams);
+INT8 whalCtrl_convertRSSIToRxLevel(TI_HANDLE hWhalCtrl, INT32 rssiVal);
+int whalCtrl_getMaxNumberOfCommandsInQueue (TI_HANDLE hWhalCtrl);
+int whalCtrl_InterrogateGwsiStatisitics(TI_HANDLE hWhalCtrl, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int whalCtrl_InterrogateGwsiCounters(TI_HANDLE hWhalCtrl, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int whalCtrl_InterrogateMbox(TI_HANDLE hWhalCtrl , void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf);
+int  whalCtrl_JoinBss                  (TI_HANDLE pWhalCtrl, whalCtrl_joinBss_t* pJoinBssParams);
+int  whalCtrl_ReJoin                   (TI_HANDLE hWhalCtrl);
+BOOL whalCtrl_isCardIn                 (TI_HANDLE hWhalCtrl);
+int  whalCtrl_SendGenCmd               (TI_HANDLE hWhalCtrl, char* pBuf, UINT32 Length);
+void whalCtrl_exitFromInitMode(TI_HANDLE hWhalCtrl);
+void whalCtrl_exitFromInitModePart1(TI_HANDLE hWhalCtrl);
+void whalCtrl_exitFromInitModePart2(TI_HANDLE hWhalCtrl);
+int  whalCtrl_IsCardInstalled  (TI_HANDLE hWhalCtrl) ;
+
+/* ----------------------------------------------------------------------------------
+                         Scan Functions
+   ----------------------------------------------------------------------------------*/
+int    whalCtrl_StartScan       (TI_HANDLE hWhalCtrl, whalCtrl_scan_t* pScanVals, BOOLEAN bHighPriority , void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+int whalCtrl_StartSPSScan    (TI_HANDLE hWhalCtrl, whalCtrl_scan_t* pScanVals , void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+int whalCtrl_StopScan           (TI_HANDLE pWhalCtrl ,void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+int whalCtrl_StopSPSScan     (TI_HANDLE hWhalCtrl , void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+
+TI_STATUS whalCtrl_SetSplitScanTimeOut (TI_HANDLE hWhalCtrl, UINT32 uTimeOut);
+
+int whalCtrl_SwitchChannelCmd (TI_HANDLE hWhalCtrl, whalCtrl_switchChannelCmd_t* pSwitchChannelCmd);
+int whalCtrl_SwitchChannelCancelCmd (TI_HANDLE hWhalCtrl, UINT8 channel);
+
+/* ----------------------------------------------------------------------------------
+                        Roaming Trigger  Functions
+   ----------------------------------------------------------------------------------*/
+int whalCtrl_SetSNRParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd);
+int whalCtrl_SetRSSIParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd);
+int whalCtrl_SetMaxTxRetryParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd);
+int whalCtrl_SetBssLossTsfThresholdParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd);
+int whalCtrl_GetAverageRSSI (TI_HANDLE hWhalCtrl, INT8* averageRSSI);
+int whalCtrl_FwDisconnect(TI_HANDLE hWhalCtrl, UINT32 ConfigOptions, UINT32 FilterOptions);
+int whalCtrl_GetAsynRSSI (TI_HANDLE hWhalCtrl,void *CB_Func, TI_HANDLE CB_handle, PUINT8 CB_Buf);
+
+/* ----------------------------------------------------------------------------------
+                        Measurement  Functions
+   ----------------------------------------------------------------------------------*/
+int whalCtrl_measurementCmd (TI_HANDLE hWhalCtrl, whalCtrl_MeasurementParameters_t* pMeasurementParams,
+                             void* CommandResponseCB, TI_HANDLE CB_handle);
+int whalCtrl_measurementStop (TI_HANDLE hWhalCtrl, void* CommandResponseCB, TI_HANDLE CB_handle);
+int whalCtrl_ApDiscoveryCmd (TI_HANDLE hWhalCtrl, whalCtrl_ApDiscoveryParameters_t* pMeasurementParams);
+int whalCtrl_ApDiscoveryStop (TI_HANDLE hWhalCtrl);
+
+/* ----------------------------------------------------------------------------------
+                        PLT  Functions
+   ----------------------------------------------------------------------------------*/
+int whalCtrl_RxPER(TI_HANDLE hWhalCtrl, PLT_RxPerCmd_e eRxPerCmd, TI_HANDLE CB_Handle, void *CB_Func);
+int whalCtrl_TxCW(TI_HANDLE hWhalCtrl, TestCmdChannelBand_t* PltTxCarrier, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int whalCtrl_TxContinues(TI_HANDLE hWhalCtrl, PltTxContinues_t* pPLT_TX_Continues, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int whalCtrl_WriteRegister(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf);
+int whalCtrl_ReadRegister(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf);
+int whalCtrl_ReadMib(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf);
+int whalCtrl_WriteMib(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib);
+
+#endif /* _WHAL_CTRL_API_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalCtrl_prm.h b/sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalCtrl_prm.h
new file mode 100644 (file)
index 0000000..14f9857
--- /dev/null
@@ -0,0 +1,52 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_CTRL_PRM_H
+#define _WHAL_CTRL_PRM_H
+
+#define MIN_FRAG_THRESHOLD_VAL         256
+#define MAX_FRAG_THRESHOLD_VAL         2346
+
+#define MIN_LONG_RETRY_LIMIT_VAL       1
+#define MAX_LONG_RETRY_LIMIT_VAL       255
+
+#define MIN_SHORT_RETRY_LIMIT_VAL      1
+#define MAX_SHORT_RETRY_LIMIT_VAL      255
+
+#define MIN_RTS_THRESHOLD_VAL          0
+#define MAX_RTS_THRESHOLD_VAL          2347
+#endif /* _WHAL_CTRL_PRM_H*/
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalTx_api.h b/sta_dk_4_0_4_32/common/src/hal/Export_Inc/whalTx_api.h
new file mode 100644 (file)
index 0000000..db1dbb3
--- /dev/null
@@ -0,0 +1,88 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_TX_API_H
+#define _WHAL_TX_API_H
+
+#include "memMngrEx.h"
+#include "whalCtrl_api.h"
+#include "whalBus_Defs.h"
+
+typedef struct
+{
+       /* call-backs */
+       TxCompleteStatusCB_t TxCmplt_CB;
+
+       SendPacketTranferCB_t PacketTranfer_CB;
+       
+       TI_HANDLE hReport; /* handle to the reporter module*/
+       TI_HANDLE hMemMgr; /* handle to the memory manager module*/ 
+       TI_HANDLE hWhalCtrl;
+} whalTx_config_t;
+
+TI_HANDLE whalTx_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl);
+TI_STATUS whalTx_Config (TI_HANDLE hWhalTx, whalTx_config_t* pWhalTxCfg);
+UINT8 whalTx_GetAcUsedHwBlks(TI_HANDLE hWhalTx, UINT8 AcID);
+void whalTx_resetQosCounters(TI_HANDLE hWhalTx);
+void whalTx_Register_CB(TI_HANDLE hWhalTx,tiUINT32 CallBackID,void *CBFunc,TI_HANDLE CBObj);
+
+
+
+
+
+
+/************************************************************************************************
+*****************************   NEW HAL FUNCTIONS AND STRUCTS    ********************************
+************************************************************************************************/
+
+
+TI_STATUS whalTx_SendPacket (TI_HANDLE hWhalTx,
+                                                        const void * aFrame,
+                                                        UINT32       aLength,
+                                                        UINT32       aMaxTransmitRate,
+                                                        UINT32       aQueueId,
+                                                        UINT32       aPowerLevel,
+                                                        BOOL             aMore,
+                                                        UINT32       aPacketId,
+                                                        UINT8        aTxRateClassId,
+                             UINT32       aExpiryTime,
+                                                        void         *aReserved);
+
+
+
+
+int whalTx_Destroy (TI_HANDLE hWhalTx);
+
+#endif /* _WHAL_TX_API_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_commands.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_commands.h
new file mode 100644 (file)
index 0000000..6cd6e90
--- /dev/null
@@ -0,0 +1,1693 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef PUBLIC_COMMANDS_H
+#define PUBLIC_COMMANDS_H
+
+
+#include "public_types.h"
+#include "public_radio.h"
+
+typedef enum
+{
+    CMD_RESET           = 0,
+    CMD_INTERROGATE     = 1,    /*use this to read information elements*/
+    CMD_CONFIGURE       = 2,    /*use this to write information elements*/
+    CMD_ENABLE_RX       = 3,
+    CMD_ENABLE_TX       = 4,
+    CMD_DISABLE_RX      = 5,
+    CMD_DISABLE_TX      = 6,
+    CMD_SCAN            = 8,
+    CMD_STOP_SCAN       = 9,
+    CMD_VBM             = 10,
+    CMD_START_JOIN      = 11,
+    CMD_SET_KEYS        = 12,
+    CMD_READ_MEMORY     = 13,
+    CMD_WRITE_MEMORY    = 14,
+
+    CMD_BEACON          = 19,
+    CMD_PROBE_RESP      = 20,
+    CMD_NULL_DATA       = 21,
+    CMD_PROBE_REQ       = 22,
+    CMD_TEST            = 23,
+
+    CMD_RADIO_CALIBRATE     = 25,   /* OBSOLETE !!!*/
+
+    CMD_ENABLE_RX_PATH      = 27,   /* OBSOLETE !!! (what is the difference from CMD_ENABLE_RX)*/
+    CMD_NOISE_HIST      = 28,
+    CMD_RX_RESET        = 29,
+
+    CMD_PS_POLL         = 30,
+    CMD_QOS_NULL_DATA   = 31,
+
+    CMD_LNA_CONTROL     = 32,
+    CMD_SET_BCN_MODE    = 33,
+
+    CMD_MEASUREMENT      = 34,
+    CMD_STOP_MEASUREMENT = 35,
+    CMD_DISCONNECT       = 36,
+    CMD_SET_PS_MODE      = 37,
+
+    CMD_CHANNEL_SWITCH   = 38,
+    CMD_STOP_CHANNEL_SWICTH = 39,
+
+    CMD_AP_DISCOVERY     = 40,
+    CMD_STOP_AP_DISCOVERY = 41,
+
+    CMD_SPS_SCAN = 42,
+    CMD_STOP_SPS_SCAN = 43,
+    
+    CMD_HEALTH_CHECK     = 45,     
+    CMD_DEBUG            = 46, 
+       CMD_TRIGGER_SCAN_TO  = 47,
+
+NUM_COMMANDS,
+    MAX_COMMAND_ID = 0xFFFF
+} Command_enum;
+
+#ifdef HOST_COMPILE
+typedef uint16 Command_e;
+#else
+typedef Command_enum Command_e;
+#endif
+
+
+#ifdef HOST_COMPILE
+
+#define        CMD_MAILBOX_IDLE                        0
+#define     CMD_STATUS_SUCCESS                         1
+#define     CMD_STATUS_UNKNOWN_CMD                     2
+#define     CMD_STATUS_UNKNOWN_IE                      3
+#define                CMD_STATUS_REJECT_MEAS_SG_ACTIVE        11
+#define     CMD_STATUS_RX_BUSY                         13
+#define     CMD_STATUS_INVALID_PARAM                   14
+#define     CMD_STATUS_TEMPLATE_TOO_LARGE              15 
+#define     CMD_STATUS_OUT_OF_MEMORY                   16 
+#define     CMD_STATUS_STA_TABLE_FULL                  17
+#define     CMD_STATUS_RADIO_ERROR                     18
+#define     CMD_STATUS_WRONG_NESTING                   19
+#define     CMD_STATUS_TIMEOUT                         21 /* Driver internal use.*/
+#define     CMD_STATUS_FW_RESET                        22 /* Driver internal use.*/
+#define     MAX_COMMAND_STATUS                         MAX_POSITIVE16
+
+#else
+
+typedef enum
+{
+       CMD_MAILBOX_IDLE                        =  0,
+    CMD_STATUS_SUCCESS                         =  1,
+    CMD_STATUS_UNKNOWN_CMD                     =  2,
+    CMD_STATUS_UNKNOWN_IE                      =  3,
+       CMD_STATUS_REJECT_MEAS_SG_ACTIVE        = 11,
+    CMD_STATUS_RX_BUSY                         = 13,
+    CMD_STATUS_INVALID_PARAM                   = 14,
+    CMD_STATUS_TEMPLATE_TOO_LARGE              = 15, 
+    CMD_STATUS_OUT_OF_MEMORY                   = 16, 
+    CMD_STATUS_STA_TABLE_FULL                  = 17,
+    CMD_STATUS_RADIO_ERROR                     = 18,
+    CMD_STATUS_WRONG_NESTING                   = 19,
+    CMD_STATUS_TIMEOUT                         = 21, /* Driver internal use.*/
+    CMD_STATUS_FW_RESET                        = 22, /* Driver internal use.*/
+    MAX_COMMAND_STATUS                         = MAX_POSITIVE16
+} CommandStatus_enum;
+
+#endif
+
+#ifdef HOST_COMPILE
+typedef uint16 CommandStatus_e;
+#else
+typedef CommandStatus_enum CommandStatus_e;
+#endif
+
+
+#ifdef FW_RUNNING_AS_STA
+#define MAX_CMD_PARAMS 572
+#else
+#define MAX_CMD_PARAMS 384
+#endif
+
+#define DEBUG_INDICATOR      0x8000    
+
+typedef struct
+{
+    Command_e cmdID;
+    CommandStatus_e cmdStatus;
+    uint8 parameters[MAX_CMD_PARAMS];
+} Command_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_RESET
+       Desc:     This command resets all state machines in the WiLink to their power 
+                 up state and restarts the eCPU. This command has no parameters. After 
+                         issuing this command, the host must reconfigure the adapter before 
+                         normal operations resume.
+                 In general, the host should only use this command if the WiLink has 
+                         stopped functioning properly.
+    Params:      None.
+       Note:     The WiLink does not return a response/status message for this command.
+       
+******************************************************************************/
+
+
+/******************************************************************************
+
+    ID:                  CMD_INTERROGATE
+       Desc:     This command requests an information element from the WiLink. The 
+                 interface for this command is somewhat different from other commands 
+                         since the interface is bi-directional and asymmetric. 
+                 The host structure consists of the Command ID, a Command Status 
+                         (returned by WiLink) place holder, and the Information Element Heading
+                         (ID and expected length).
+                 The response to that command is a buffer of the information element's 
+                         actual values returned by the WiLink just after the command is issued.
+                         The response to that command is a buffer of the information element's 
+              actual values returned by the WiLink just after the command is issued.
+       Params:   InfoElement_t - see below.
+                         
+       
+******************************************************************************/
+/*
+Description of InfoElement structure - defined in "public_infoele.h"
+offset length  source  description
+====== ======  ======  ===========
+0              2               host    Information Element ID - contains the ID of the requested 
+                        information element (refer to InfoElement_enum in 
+                                               pblic_infoele.h). In response to this command, the WiLink 
+                                               writes the requested information element to the response area 
+                                               for the command mailbox.
+2              4               wilink  Length - the length of the response (different for each IE
+                                               according to definitions in public_infoele.h).
+4       Length wilink  IE payload according to definition in public_infoele.h.
+*/
+
+
+
+/******************************************************************************
+
+    ID:                  CMD_CONFIGURE
+       Desc:     This command configures an information element in the WiLink. 
+    Params:      InfoElement_t - see below.
+
+******************************************************************************/
+/*
+Description of InfoElement structure - defined in "public_infoele.h"
+offset length  source  description
+====== ======  ======  ===========
+0              2               host    Information Element ID - contains the ID of the requested 
+                        information element (refer to InfoElement_enum in 
+                                               pblic_infoele.h). In response to this command, the WiLink 
+                                               writes the requested information element to the response area 
+                                               for the command mailbox.
+2              4               host    Length - the length of the response (different for each IE
+                                               according to definitions in public_infoele.h).
+4       Length host    IE payload according to definition in public_infoele.h.
+*/
+
+
+/******************************************************************************
+
+    ID:                  CMD_ENABLE_RX
+       Desc:     This command enables the normal reception of frames. 
+    Params:      Channel Number - this field indicates the radio channel on which to
+                                  receive data. This parameter also sets the channel on
+                                                          which to transmit. The last channel number used, 
+                                                          regardless of the order in which the ENABLE_RX and 
+                                                          ENABLE_TX commands are issued, is the channel number 
+                                                          for both RX and TX. This command must be issued after 
+                                                          the host has set all necessary configuration elements 
+                                                          appropriately.
+       
+******************************************************************************/
+
+
+
+/******************************************************************************
+
+    ID:                  CMD_ENABLE_TX
+       Desc:     This command enables the normal transmission of frames.  
+    Params:      Channel Number - this field indicates the radio channel on which to
+                                  transmit data. This parameter also sets the channel on
+                                                          which to receive. The last channel number used, 
+                                                          regardless of the order in which the ENABLE_RX and 
+                                                          ENABLE_TX commands are issued, is the channel number 
+                                                          for both RX and TX. This command must be issued after
+                                                          the host has set all necessary configuration elements
+                                                          appropriately.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_DISABLE_RX
+       Desc:     This command disables the normal reception of packets over the 
+                 Baseband interface. 
+    Params:      None
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_DISABLE_TX
+       Desc:     This command disables the normal transmission of frames. 
+    Params:      None.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_SCAN
+       Desc:     This command instructs the WiLink to scan for BSS/IBSSs. The host 
+                         may perform either an active scan or a passive scan. During an active
+                         scan, the WiLink transmits a probe request on the specified channel(s) 
+                         and then listens for beacon/probe responses. During a passive scan, the 
+                         WiLink monitors the specified channel(s) for beacons.
+                 The WiLink sends SCAN_COMPLETE event to notify the host when it has 
+                         completed a scan.
+       Params:   ScanParameters_t - see below
+       
+******************************************************************************/
+/*
+Offset Length  Definition
+0              8               RX filters for Scan (refer to ACXRxConfigStruct)
+8              2               Scan options (Band select, Voice mode and Scan type = Active/Passive)
+10             1               NumChannels 
+11             1               Number of Probe requests (used for Active scan)
+12             2               Probe request rate & modulation
+14             1               AC trigger (for Voice mode only)
+15             1               SSID length
+16             32              SSID string (Null terminated)
+48             2               Channel [0] ScanMinDuration
+50             2               Channel [0] ScanMaxDuration 
+52             6               Channel [0] BSSID (4 bytes LOW and 2 bytes HIGH)
+58             1               Channel [0].bit0-3: Early Termination count. Bit 4-5: Condition
+59             1               Channel [0] TX power level for Scan (0 means do not change - other values:1-5)
+60             1               Channel [0] Channel  
+61             3               Channel [0] Reserved
+64-404 340             Optional Channel [1] - Channel [15] - same format as Channel [0] fields above.
+*/
+
+/* Defines for Rx "ConfigOptions".*/
+/* Only bits 2-10 can be configured by the Driver".*/
+#define CFG_RX_SERIAL           BIT_0    /* 0 = use parallel interface,         1 = use serial interface from ACX101- not valid.*/
+#define CFG_RX_RAW              BIT_1    /* 1 = write all data from baseband to frame buffer including PHY header.*/
+#define CFG_RX_FCS              BIT_2    /* 1 = write FCS to end of frame in memory, 0 = do not write FCS to memory.*/
+#define CFG_RX_ALL_GOOD         BIT_3    /* promiscuous mode, receive all good frames.*/
+#define CFG_UNI_FILTER_EN       BIT_4    /* local MAC address filter enable.*/
+#define CFG_BSSID_FILTER_EN     BIT_5    /* BSSID filter enable.*/
+#define CFG_MC_FILTER_EN        BIT_6    /* 0 = receive all multicast,          1 = use one or both multicast address filters.*/
+#define CFG_MC_ADDR0_EN         BIT_7    /* 1 = receive frames from mc_addr0,   0 = do not use this filter.*/
+#define CFG_MC_ADDR1_EN         BIT_8    /* 1 = receive frames from mc_addr1,   0 = do not use this filter .*/
+#define CFG_BC_REJECT_EN        BIT_9    /* 0 = receive all broadcast,          1 = filter all broadcast.*/
+#define CFG_SSID_FILTER_EN      BIT_10   /* SSID Filter Enable.*/
+#define CFG_RX_INT_FCS_ERROR    BIT_11   /* 1 = give rx complete interrupt for FCS errors.*/
+#define CFG_RX_INT_ENCRYPTED    BIT_12   /* 1 = only give rx header interrupt if frame is encrypted.*/
+#define CFG_RX_WR_RX_STATUS     BIT_13   /* 0 = do not write three status words, 1 = write three receive status words to top of rx'd MPDU.*/
+#define CFG_RX_FILTER_NULTI     BIT_14   /* 1 = filter multicast/broadcast frame if SA matchs local MAC addr->.*/
+#define CFG_RX_RESERVE          BIT_15   /* reserve.*/
+#define CFG_RX_TIMESTAMP_TSF    BIT_16   /* 1 = sample frame's' arrival time in 32bits TSF, 0 = write it in MAC time stamp.*/
+
+
+/* Defines for Rx "FilterOptions".*/
+/* The rx filter enables control what type of receive frames will be rejected or received by the rx hardware*/
+/* 1 = frame is written to memory,*/
+/* 0 = not written to memory, rejected.*/
+#define CFG_RX_RSV_EN       BIT_0  /* reserved types and subtypes.*/
+#define CFG_RX_RCTS_ACK     BIT_1  /* rts, cts, ack frames.*/
+#define CFG_RX_PRSP_EN      BIT_2  /* probe response.*/
+#define CFG_RX_PREQ_EN      BIT_3  /* probe request.*/
+#define CFG_RX_MGMT_EN      BIT_4  /* type = management.*/
+#define CFG_RX_FCS_ERROR    BIT_5  /* frames with FCS errors.*/
+#define CFG_RX_DATA_EN      BIT_6  /* type = data.*/
+#define CFG_RX_CTL_EN       BIT_7  /* type = control.*/
+#define CFG_RX_CF_EN        BIT_8  /* contention free frames.*/
+#define CFG_RX_BCN_EN       BIT_9  /* beacons.*/
+#define CFG_RX_AUTH_EN      BIT_10 /* authentication, deauthentication.*/
+#define CFG_RX_ASSOC_EN     BIT_11 /* association related frames (all 5 subtypes \96 assoc req/resp,*/
+
+
+typedef struct
+{
+#ifdef FW_RUNNING_AS_AP
+    uint16          ConfigOptions;
+    uint16          FilterOptions;
+#else
+    uint32          ConfigOptions;
+    uint32          FilterOptions;
+#endif
+} ACXRxConfigStruct;
+
+/*
+TxdRateSet_t definition
+Bit     Description
+===     ===========
+0-12    Every one of bits 0-12 specifies rate described in the column on left. Only
+        one bit could be set for the command, all other should be zeroed.
+0       1 MBPS 
+1       2 MBPS 
+2       5.5 MBPS       
+3       6 MBPS 
+4       9 MBPS 
+5       11 MBPS        
+6       12 MBPS        
+7       18 MBPS        
+8       22 MBPS        
+9       24 MBPS        
+10      36 MBPS        
+11      48 MBPS        
+12      54 MBPS        
+13      Unused (set to 0).
+14      PBCC - When this bit is set, the WiLink transmits probe requests with PBCC 
+        modulation.
+        Notes:
+           Does not apply (set to 0) for rates 1 and 2 Mbps.
+           Does not apply (set to 0) for RevG-OFDM rates.
+15      Preamble - When this bit is set, the WiLink transmits probe requests with a 
+                   short preamble. When this bit is clear, the WiLink transmits the 
+                                  frame with a long preamble.
+                   Notes:
+                     Must be LONG (0) for 1Mbps rate.
+                                    Does not apply (set to 0) for RevG-OFDM rates.
+
+If neither the PBCC bit or OFDM rate are set, then the modulation format for probe 
+requests is CCK for 5.5 or 11 Mbps or DBPSK/DQPSK for 1 and 2 Mbps.
+*/
+
+/* ScanOptions bit mask field.*/
+#define SCAN_ACTIVE         0
+#define SCAN_PASSIVE        1   /* 1 = passive scan, 0 = active scan*/
+#define SCAN_5GHZ_BAND      2   /* 1 = scan channel list in 5 Ghz band, 0 = scan channel list in 2.4 Ghz band*/
+#define TRIGGERED_SCAN      4   /* 1 = Triggered scan, 0 = Normal scan*/
+#define SCAN_PRIORITY_HIGH  8   /* 1 = High priority scan, 0 = Low priority scan*/
+typedef uint8 TidTrigger_t;
+
+/* General scan parameters.*/
+typedef struct
+{
+    ACXRxConfigStruct  rxCfg;         /* Rx filter to be used for each channel scan. */
+                                      /* The BSSID filter enable will be set (by the */
+                                         /* scan process) to ON for a specific channel if*/
+                                         /* the BSSID of this channel is a unicast address.*/
+                                         /* Otherwise it will be set to OFF (Refer to */
+                                         /* ACXRxConfig IE in public_infoele.h).*/
+
+    uint16             scanOptions;   /* This bitwise field indicates the scan options. */
+                                         /* Bits [3:15] are reserved. */
+                                         /* Bits [0:2] are defined as follows: */
+                                      /* Scan Type (bit 0) - When this bit is set, the */
+                                         /*  WiLink performs a passive scan. When this bit*/
+                                         /*  is cleared, the WiLink performs an active scan. */
+                                             /* Band Select (bit 1) - When this bit is set, the*/
+                                         /*  WiLink scans the specified channels in the */
+                                         /*  5GHz band. When this bit is cleared, the */
+                                         /*  WiLink scans the specified channels in the */
+                                         /*  2.4GHz band. */
+                                             /* Voice mode (bit 2) - When this bit is set, */
+                                         /*  the request is for a voice scan. When this bit*/
+                                         /*  is cleared, the request is for a normal scan. */
+                                             /* Scan priority (bit 3) - When this bit is set, */
+                                         /*  the request is for a high priority scan. When*/
+                                         /*  this bit is cleared, the request is for a low*/
+                                         /*  priority scan.*/
+               
+    uint8              numChannels;   /* Number of scan channels in the list (minimum is*/
+                                         /* 1, maximum is 30).*/
+
+    uint8              numOfProbRqst; /* This field indicates the number of probe */
+                                         /* requests to send per channel, in active scan. */
+       
+    TxdRateSet_t       txdRateSet;    /* This bitwise field specifies the rate and */
+                                         /* modulation to transmit the probe request during*/
+                                         /* an active scan. The allowable values for this */
+                                         /* field are listed in the above table (refer to */
+                                         /* TxdRateSet). It is not used for passive scans.*/
+   
+    TidTrigger_t       tidTrigger;    /* used for TidTriggered scan only.*/
+
+    uint8              ssidLength;    /* This field specifies the size of the SSID, */
+                                         /* which can be up to 32 bytes long. If this field*/
+                                         /* equals to zero, SSID filter is not applied. */
+       
+    uint32             ssidStr[8];    /* This field specifies the SSID packets from that*/
+                                         /* are relevant for the Scan result. The WiLink*/
+                                         /* uses this information to filter beacon, probe*/
+                                         /* response frames (if the SSID length field of */
+                                         /* this command structure is not zero) */
+} BasicScanParameters_t;
+
+
+
+#define SCAN_ET_COND_MASK  0x30
+#define SCAN_ET_COUNT_MASK 0x0F
+
+#define SCAN_MAX_NUM_OF_CHANNELS 16
+
+/* Early Termination condition (bits 4-5) - This field can have one of the following */
+/* values (note that bits 0-3 indicates Early Termination count): */
+typedef enum 
+{
+    ET_COND_DISABLE = 0x00,          /* Disable - No early termination condition.*/
+
+       ET_COND_BEACON  = 0x10,          /* Beacon only. When this value is selected, the */
+                                            /* Early Termination count field specifies the */
+                                                                        /* maximum number of beacons to collect before */
+                                                                        /* ending a scan. */
+
+    ET_COND_PROBE_RESP = 0x20,       /* Probe responses only. When this value is */
+                                        /* selected, the Early Termination count field */
+                                                                        /* specifies the maximum number of probe responses*/
+                                                                        /* to collect before ending a scan. */
+
+    ET_COND_BEACON_PROBE_RESP = 0x30,/* Beacon/probe response. When this value is */
+                                        /* selected, the Early Termination count field */
+                                                                        /* specifies the maximum number of beacons or probe*/
+                                                                        /* responses to collect before ending a scan. */
+                                                                        
+    ET_COND_INVALID = 0xFF
+} ETCondition_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 ETCondition_e;
+#else
+typedef ETCondition_enum ETCondition_e;
+#endif
+
+
+typedef uint8 ETCondCount_t;
+
+
+
+#define PROCESS_SCAN_IS_HIGH(pScanParameters) ((pScanParameters)->basicScanParameters.scanOptions & SCAN_PRIORITY_HIGH)
+#define PROCESS_SCAN_IS_LOW(pScanParameters) ((PROCESS_SCAN_IS_HIGH(pScanParameters)) == 0)
+
+
+/* Per-Channel scan parameters.*/
+typedef struct
+{
+
+    uint32        scanMinDuration;    /* For active scans, this field specifies the */
+                                      /* minimum amount of time, in time units (TUs), */
+                                      /* to wait for a frame on a channel. This */
+                                      /* parameter is not used for passive scans. The*/
+                                      /*  value can range from 0 to 65535 TUs */
+                                      /* (67.1 seconds). */
+
+    uint32        scanMaxDuration;    /* For active scans, this field specifies the */
+                                         /* maximum amount of time, in time units (TUs), */
+                                         /* to wait for a probe response on a channel.*/
+                                         /* For passive scans, this field specifies the */
+                                         /* amount of time, in time units (TUs), to listen*/
+                                         /* on a channel. The value can range from 0 to */
+                                         /* 65535 TUs (67.1 seconds). */
+       
+
+    uint32        bssIdL;             /* 32 LSBits of BSSID of the AP to scan for. */
+                                         /* If scanning on this channel any BSSID, this */
+                                         /* field shall be set to broadcast BSSID. */
+
+    uint16        bssIdH;             /* 16 MSBits of BSSID of the AP to scan for.*/
+
+    ETCondCount_t ETCondCount;        /* bit 0-3: Early Termination count - This field */
+                                         /*          defines the maximum number of beacons*/
+                                         /*          or probe responses or both (according*/
+                                         /*          to condition) to collect before ending*/
+                                         /*          a scan.*/
+       
+                                         /* Bit 4-5: Early Termination Condition (refer */
+                                         /*          to ETCondition_enum).*/
+                       
+    uint8         txPowerAttenuation; /* TX power level to be used per channel scanned. */
+                                         /* If 0, leave normal TX power level for this */
+                                         /* channel. Range: 0 - 20 [dB].*/
+       
+    Channel_e     channel;            /* Channel number to scan, valid range 0-255 */
+                                         /* (1-14 for 802.11b). */
+    uint8                padding[3];             /* for alignment to 32 bits boundry*/
+} BasicScanChannelParameters_t;
+
+/* The Scan command structure.*/
+typedef struct
+{
+    BasicScanParameters_t basicScanParameters; /* refer to BasicScanParameters_t */
+                                                  /* definition*/
+
+    BasicScanChannelParameters_t basicScanChannelParameters[SCAN_MAX_NUM_OF_CHANNELS];
+} ScanParameters_t;
+
+/*****************************************************************************
+
+    ID:                  CMD_TRIGGER_SCAN_TO
+       Desc:     This Command will configure the enhanced Trigger Scan Timeout 
+                               information.
+                         To use legacy Trigger Scan, configure the parameter to 0
+    Params:      None
+       
+******************************************************************************/
+typedef struct 
+{
+       uint32  SlicedScanTimeOut;                      /* 0 - Split Scan Disable
+                                                                                  any other value will represent the timeout 
+                                                                                  for each channel "mini scan" in uSec */
+}enhancedTriggerTO_t;
+
+
+
+/*****************************************************************************
+
+    ID:                  CMD_STOP_SCAN
+       Desc:     This command instructs the WiLink to terminate any scan in progress. 
+                 After processing this command, the WiLink returns to its previous state
+                         (the state before the scan was started) and generates the SCAN_COMPLETE
+                         information message. 
+    Params:      None
+       
+******************************************************************************/
+
+
+
+/******************************************************************************
+
+    ID:                  CMD_VBM
+       Desc:     This command specifies the contents of the beacon TIM template stored
+                 in the WiLink.   
+    Params:      VBMUpdateRequest_t - see below.
+       Note:     Second part of Beacon template
+
+******************************************************************************/
+typedef struct 
+{
+    uint8 identity;       /* TIM IE ID*/
+    uint8 length;         /* TIM IE Length*/
+    uint8 DTIM_count;
+    uint8 DTIM_period;
+    uint8 BitMap_ctrl;
+    uint8 PVB_field[251]; /* Partial Virtual Bitmap*/
+} TIMStruct_t;
+
+
+typedef struct
+{
+    uint16 len;           /* length*/
+    uint8  padding[2];    /* for alignment to 32 bits boundry*/
+    TIMStruct_t tim;
+} VBMUpdateRequest_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_START_JOIN
+       Desc:     This command instructs the WiLink to either join a BSS or IBSS, or 
+                 start an IBSS. When the device has joined the BSS or IBSS the Join 
+                         Complete event is raised to the host.  
+    Params:      StartJoinRequest_t - see below.
+
+******************************************************************************/
+
+#define JOIN_CMD_CTRL_TX_FLUSH         0x80 // When this bit is set, the firmware will flush all Tx 
+                                                   // frames in the pipe and will not transmit them.
+#define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE  0x01 // When this bit is set, the firmware will support 
+                                                       // early wakeup time
+
+typedef enum
+{
+    BSS_TYPE_IBSS = 0,
+    BSS_TYPE_STA_BSS = 2,
+    BSS_TYPE_AP_BSS = 3,
+    MAX_BSS_TYPE = 0xFF
+} BssType_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 BSS_e;
+#else
+typedef BssType_enum BSS_e;
+#endif
+
+#define MAX_SSID_STR_LEN_BYTESX4 8
+/*
+BasicRateSet_t definition
+Bit     Description
+===     ===========
+0       When this bit is set, 1 MBPS is a member of the basic rate set.        
+1       When this bit is set, 2 MBPS is a member of the basic rate set.        
+2       When this bit is set, 5.5 MBPS is a member of the basic rate set.      
+3       Must be set to 0.      
+4       Must be set to 0.      
+5       When this bit is set, 11 MBPS is a member of the basic rate set.       
+6       Must be set to 0.      
+7       Must be set to 0.      
+8       When this bit is set, 22 MBPS is a member of the basic rate set.       
+9-15    Must be set to 0.      
+
+Note: For OFDM, the control response frame rates 6, 9, 12, 18, 24 and 36 Mbps are the
+      default values and are not configurable. Contact your TI representative for 
+         information.
+*/
+
+
+typedef struct
+{
+    uint32            bssIdL;        /* This field indicates the 32 LSBits of the MAC*/
+                                        /* address of the BSS to join. */
+                                     /* Note: To correctly generate beacon frames, the */
+                                        /* byte order of the BSS ID field must be */
+                                        /* reversed. for example, if the MAC address of */
+                                        /* the AP is 00 7E 99 11 22 33, program the BSS */
+                                        /* ID field as 33 22 11 99 7E 00.*/
+               
+    uint16            bssIdH;        /* This field indicates the 16 MSBits of the MAC*/
+                                        /* address of the BSS to join. */
+
+    uint16            beaconInterval;/* This field specifies the time between target */
+                                        /* beacon transmission times (TBTTs), in time */
+                                        /* units (TUs). Valid values are 1 to 1024.*/
+       
+#ifdef FW_RUNNING_AS_STA
+    ACXRxConfigStruct rxFilter;      /* This filed is the Rx filter configuration for*/
+                                        /* the device while connected to the BSS or IBSS.*/
+                                        /* This setting is overridden in case of a */
+                                        /* measurement or a scan activity and is reset */
+                                        /* after these activities end.*/
+#endif
+    BasicRateSet_t    basicRateSet;  /* For 802.11b, this field specifies the control*/
+                                        /* response frame rate for the BSS or IBSS (that*/
+                                        /* is, the BSSBasicRateSet parameter in the */
+                                        /* 802.11 Specification). The WiLink uses this */
+                                        /* field to determine the rate at which to */
+                                        /* transmit control frame responses (such as ACK */
+                                        /* or CTS frames). The format of this field is */
+                                        /* shown in the above table (refer to */
+                                        /* BasicRateSet_t).*/
+       
+    uint8             dtimInterval;  /* This field specifies the number of beacon */
+                                        /* intervals between DTIM beacon frames. The host*/
+                                        /* is only required to set this field when the */
+                                        /* BSS Type is infrastructure BSS (STA) or AP. */
+                                        /* For an independent BSS, the host should set */
+                                        /* this field to 1.*/
+       
+    Rate_e            txCtrlFrmRate; /* OBSOLETE (replaced by ACX_FW_GEN_FRAME_RATES)*/
+    Mod_e             txCtrlFrmMod;  /* OBSOLETE (replaced by ACX_FW_GEN_FRAME_RATES)*/
+
+    BSS_e             bssType;       /* bits 0-2: This bitwise field specifies the type */
+                                        /*  of BSS to start or join (Refer to BssType_enum). */
+                                        /* bit 4: Band - The radio band in which to join*/
+                                        /*  or start.*/
+                                     /*  0 - 2.4GHz band       */
+                                        /*  1 - 5GHz band*/
+                                        /* bits 3, 5-7: Reserved*/
+
+    Channel_e         channelNumber; /* This field specifies the channel number of the*/
+                                        /* BSS to join or start. Valid values are 1 to 14. */
+                                        /* If the specified channel is not allowed in the*/
+                                        /* regulatory domain, the command is rejected and*/
+                                        /* the status code 0x0005 is returned in the */
+                                        /* Command Status field.*/
+       
+    uint8             ssidLength;    /* This field specifies the size of the SSID, which*/
+                                        /* can be up to 32 bytes long.*/
+       
+    uint32              ssidStr[MAX_SSID_STR_LEN_BYTESX4];
+                                        /* This field specifies the SSID of the BSS to */
+                                        /* start or join. The WiLink uses this information*/
+                                        /* to filter beacon, probe response and probe */
+                                        /* request frames (if configured to do so in bit 10*/
+                                        /* in the Receive Configuration field of the */
+                                        /* ACXRxConfig information element). */
+                                        /* It also uses this information to determine if a*/
+                                        /* probe response should be transmitted in */
+                                        /* response to a received probe request.*/
+       
+    uint8             ctrl;          /* Join command control field (refer to */
+                                        /* JoinCmdCtrl_enum).*/
+
+    Rate_e            txMgmtFrmRate; /* OBSOLETE (replaced by ACX_FW_GEN_FRAME_RATES)*/
+    Mod_e             txMgmtFrmMod;  /* OBSOLETE (replaced by ACX_FW_GEN_FRAME_RATES)*/
+    uint8               reserved1;
+} StartJoinRequest_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_SET_KEYS
+       Desc:     The host issues this command to manage the WEP key cache in the WiLink. 
+                 The host can issue this command during the configuration or operation 
+                         phase.  
+    Params:      SetKey_t - see below.
+
+******************************************************************************/
+
+#define NUM_ACCESS_CATEGORIES_COPY 4 
+
+#define MAX_KEY_SIZE 32
+
+typedef enum
+{
+    KEY_ADD_OR_REPLACE = 1,             /* Add or replace a key in the WEP cache*/
+       KEY_REMOVE         = 2,             /* Remove a key from the WEP cache*/
+       KEY_SET_ID         = 3,             /* Set Key ID*/
+    MAX_KEY_ACTION     = MAX_POSITIVE16 /* force this enum to be uint16*/
+} KeyAction_enum;
+
+#ifdef HOST_COMPILE
+typedef uint16 KeyAction_e;
+#else
+typedef KeyAction_enum KeyAction_e;
+#endif
+
+typedef enum
+{
+    KEY_WEP_DEFAULT       = 0,
+    KEY_WEP_ADDR          = 1,
+    KEY_AES_GROUP         = 4,
+    KEY_AES_PAIRWISE      = 5,
+    KEY_WEP_GROUP         = 6,
+    KEY_TKIP_MIC_GROUP    = 10,
+    KEY_TKIP_MIC_PAIRWISE = 11
+} KeyType_enum;
+
+/*
+Key Size+Key Data table (valid value)
+KeyType_enum  Key Type                   Valid Key Size        Key Data Field Format
+============  ========                   ==============    =====================
+0x00          WEP default key            5, 13, 29             Key Size bytes of key data
+
+0x01          WEP key mapping key            5, 13, 29         Key Size bytes of key data
+
+0x04          AES Group Key                  16                16 bytes of key data
+
+0x05          AES Pairwise Key           16                16 bytes of key data
+
+0x0A          TKIP and MIC Group Key      32                16 bytes of TKIP key data
+                                                        8 bytes of Rx MIC key data
+                                                        8 bytes of Tx MIC key data
+
+0x0B          TKIP and MIC Pairwise Key   32                16 bytes of TKIP key data
+                                                        8 bytes of Rx MIC key data
+                                                        8 bytes of Tx MIC key data
+*/
+
+#ifdef HOST_COMPILE
+typedef uint8 KeyType_e;
+#else
+typedef KeyType_enum KeyType_e;
+#endif
+
+
+typedef enum
+{
+    NO_KEY            =  0,
+    KEY_SIZE_WEP_64   =  5,
+    KEY_SIZE_WEP_128  = 13,
+    KEY_SIZE_WEP_256  = 29,
+    KEY_SIZE_TKIP     = MAX_KEY_SIZE
+} KeySize_enum;                      /* WEP keysizes reflect 3 bytes appended from IV.*/
+
+#ifdef HOST_COMPILE
+typedef uint8 KeySize_e;
+#else
+typedef KeySize_enum KeySize_e;
+#endif
+
+
+typedef struct
+{
+    uint8 addr[MAC_ADDR_SIZE]; /* This field specifies the MAC address of the station to*/
+                                  /* add or remove from the WEP key cache. This field is */
+                                  /* ignored if a WEP default key is being added or removed.*/
+       
+    KeyAction_e action;        /* This field specifies the action to be performed.*/
+                                  /* Refer to KeyAction_enum.*/
+
+    uint16      reserved;
+    KeySize_e   keySize;       /* This field indicates the size of the key in bytes */
+                                  /* being added. Valid values are listed in the Valid Key */
+                                  /* Size column in the above "Key Size+Key Data table". */
+
+    KeyType_e   type;          /* This field indicates the type of key being added.*/
+                                  /* Valid values are listed in the Value column in the*/
+                                  /* KeyType_enum.*/
+
+    uint8       ssidProfile;   /* This field indicates the SSID profile for which the */
+                                  /* key is set.*/
+    uint8       id;            /* Key ID - For TKIP and AES key types, this field */
+                                  /* indicates the value that should be inserted into the*/
+                                  /* KeyID field of frames transmitted using this key */
+                                  /* entry. For WEP default key types, this field indicates*/
+                                  /* the ID of the key to add or remove. */
+                                  /* For WEP key mapping key types, this field is ignored.*/
+                                  /* Valid values for this field are 0 to 3.*/
+    
+    uint8       reserved2[6];  
+    uint8       key[MAX_KEY_SIZE];
+                                  /* This field holds the security key data to add to the*/
+                                  /* STA table. The format of this field varies depending*/
+                                  /* on the type field. The format of this field for each*/
+                                  /* key type is described in the Key Data Field Format */
+                                  /* column in the "Key Size+Key Data table", above.*/
+
+    uint16      AcSeqNum16[NUM_ACCESS_CATEGORIES_COPY]; 
+                                  /* This field indicates the lower part of the PN\IV */
+                                  /* sequence number that is used, for the four Access*/
+                                  /* Categories.*/
+
+    uint32      AcSeqNum32[NUM_ACCESS_CATEGORIES_COPY]; 
+                                  /* This field indicates the higher part of the PN\IV */
+                                  /* sequence number that is used, for four Access */
+                                  /* Categories.*/
+    
+} SetKey_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_READ_MEMORY
+       Desc:     The host issues this command to read the WiLink device 
+                 memory/registers. 
+    Params:      ReadWriteCommand_t - see below.
+       Note:     The Base Band address has special handling (16 bits registers and
+                 addresses). For more information, see the hardware specification.
+
+******************************************************************************/
+/******************************************************************************
+
+    ID:                  CMD_WRITE_MEMORY
+       Desc:     The host issues this command to write the WiLink device memory/registers. 
+    Params:      ReadWriteCommand_t - see below.
+       Note:     The Base Band address has special handling (16 bits registers and
+                 addresses). For more information, see the hardware specification.
+
+******************************************************************************/
+
+#define MAX_READ_SIZE 256
+
+typedef struct
+{
+    uint32 addr;                 /* The address of the memory to read from or write to.*/
+    uint32 size;                 /* The amount of data in bytes to read from or write */
+                                    /* to the WiLink device.*/
+    uint8  value[MAX_READ_SIZE]; /* The actual value read from or written to the Wilink.*/
+                                    /* The source of this field is the Host in WRITE */
+                                    /* command or the Wilink in READ command.*/
+} ReadWriteCommand_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_BEACON
+       Desc:     This command specifies the contents of the beacon template stored in 
+                 the WiLink. 
+    Params:      PktTemplate_t - see below.
+
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_PROBE_RESP
+       Desc:     This command specifies the contents of the probe response template
+                 stored in the WiLink.  
+    Params:      PktTemplate_t - see below.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_NULL_DATA
+       Desc:     This command specifies the contents of the Null data template
+                 stored in the WiLink. 
+    Params:      PktTemplate_t - see below.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_PROBE_REQ
+       Desc:     This command specifies the contents of the probe request template
+                 stored in the WiLink.  
+    Params:      PktTemplate_t - see below.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_PS_POLL
+       Desc:     This command specifies the contents of the PS-poll template
+                 stored in the WiLink.  
+    Params:      PktTemplate_t - see below.
+       
+******************************************************************************/
+
+
+/******************************************************************************
+
+    ID:                  CMD_QOS_NULL_DATA
+       Desc:     This command specifies the contents of the QOS-Null template
+                 stored in the WiLink.  
+    Params:      PktTemplate_t - see below.
+       
+******************************************************************************/
+/* Template command data structure.*/
+#define MAX_TEMPLATES_SIZE 300
+typedef struct 
+{
+       uint16 len;
+       uint8  templateStart[MAX_TEMPLATES_SIZE]; 
+} PktTemplate_t;
+
+
+/******************************************************************************
+
+      ID:        CMD_TEST
+       Desc:   The TEST command can be issued immediately after the firmware has 
+                 been downloaded, with no further configuration of the WiLink required.
+                 Full initialization of the WiLink is not required to invoke the TEST 
+                 command and perform the radio test function.
+                 After testing, the system must be reset.
+                 Test parameters can be modified while a test is executing. 
+                 For instance, the host program can change the channel without resetting
+                 the system.
+       
+      Params:    TestCmd_t - see below.
+                 The returned values are copied to the cmd/sts MB replacing  the command
+                 (similar to the interrogate mechanism).
+
+******************************************************************************/
+typedef enum
+{
+    TEST_CMD_FCC                            = 0x01,
+    TEST_CMD_TELEC                                                     = 0x02,
+    TEST_CMD_PLT_FCC_TELEC_TX_STOP                     = 0x04,
+    TEST_CMD_PLT_GAIN_GET                      = 0x05,
+    TEST_CMD_PLT_GAIN_ADJUST                           = 0x06, 
+    TEST_CMD_PLT_TXPOWER_CAL_START                     = 0x07, 
+    TEST_CMD_PLT_TXPOWER_CAL_STOP                      = 0x08, 
+    TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER         = 0x09,
+       TEST_CMD_PLT_RX_CALIBRATION                             = 0x0a,
+    TEST_CMD_RADIO_TUNE                                        = 0x0b,
+    TEST_CMD_RX_PER_START                                  = 0x0c,
+    TEST_CMD_RX_PER_STOP                                   = 0x0d,
+    MAX_TEST_CMD_ID                                                    = 0xFF
+} TestCmdID_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 TestCmdID_e;
+#else
+typedef TestCmdID_enum TestCmdID_e;
+#endif
+
+/******************************************************************************/
+typedef enum
+{
+       TEST_MODE_HOST_ORIGINATED_DATA                          = 0x00,
+       TEST_MODE_FIXED_SEQ_NUMBER                                      = 0x00,
+       TEST_MODE_FW_ORIGINATED_DATA                                    = 0x01,
+       TEST_MODE_RANDOM_DATA                                                   = 0x05,
+       TEST_MODE_ZOZO_DATA                                                     = 0x09,
+       TEST_MODE_FILLING_PATERN_MASK                                   = 0x0F,
+       TEST_MODE_DELAY_REQUIRED                                                = 0x10,
+       TEST_MODE_DISABLE_SRCRAMBLING_FLAG                      = 0x20
+}TestModeCtrlTypes_e;
+
+#ifdef HOST_COMPILE
+typedef uint8 FccTestType_e;
+#else
+typedef TestModeCtrlTypes_e FccTestType_e;
+#endif
+
+/******************************************************************************/
+#define        TEST_SEQ_NUM_MODE_FIXED                         (0)
+#define     TEST_SEQ_NUM_MODE_INCREMENTED              (1)
+
+/******************************************************************************
+
+  TestCmdId :  TEST_CMD_FCC - Tx continuous test
+
+  Description:  Continuous transmit series of numbers with a valid MAC header
+                as was received from driver.
+                               However there is no 802.11 air access compliance. 
+
+  Params:      PERTxCfg_t fcc - see below.
+
+******************************************************************************/
+#define NUM_OF_MAC_ADDR_ELEMENTS 6
+typedef struct PERTxCfg_t
+{
+                       /*input parameters*/
+            uint32 numFrames;       /* number of frams to transmit, 0 = endless*/
+            uint32 interFrameGap;   /* time gap in uSec */          
+            uint32 seqNumMode;      /* Fixed / Incremented */
+            uint32 frameBodySize;    /* length of Mac Payload */       
+            uint8 channel;          /*channel number*/
+            uint8 dataRate;         /* MBps 1,2,11,22,... 54           */
+            uint8 modPreamble;         /* CTL_PREAMBLE 0x01 */           
+            uint8 band;                                /* {BAND_SELECT_24GHZ 0x00 | BAND_SELECT_5GHZ 0x01} */          
+            uint8 modulation;          /* {PBCC_MODULATION_MASK |OFDM_MODULATION_MASK }*/      
+            FccTestType_e testModeCtrl;     
+            uint8 dest[NUM_OF_MAC_ADDR_ELEMENTS];          /* set to hard codded default {0,0,0xde,0xad,0xbe,0xef}; */        
+} PERTxCfg_t;
+
+/******************************************************************************
+   TestCmdId :         TEST_CMD_TELEC
+
+   Description:        Generate carrier wave in a specific channel and band                                         
+
+   Params:             TestCmdChannelBand_t        telec  - see below.
+
+******************************************************************************/
+typedef struct 
+{
+                       /*input parameters*/
+           Channel_e    channel;                /*Channel number*/
+           RadioBand_e  band;           /* {BAND_SELECT_24GHZ 0x00 | BAND_SELECT_5GHZ 0x01} */         
+           uint8        padding[2];     /* padding to 32 bit */
+} TestCmdChannelBand_t;
+
+/******************************************************************************
+
+  TestCmdId :          TEST_CMD_PLT_GAIN_GET
+
+       Description: Retrieves the TX chain gain settings.         
+
+  Params:              PltGainGet_t       gainGet - see public_radio.h
+
+
+******************************************************************************/
+
+/******************************************************************************
+
+       TestCmdId:      TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER
+       
+       Description: This PLT function provides the all information required by 
+                                       the upper driver in order to update the NVS image.
+                                       It received a parameter defining the type of update 
+                                       information required and provides an array of elements 
+                                       defining the data bytes to be written to the NVS image 
+                                       and the byte offset in which they should be written.         
+ Params:     PltNvsResultsBuffer_t nvsUpdateBuffer  - see public_radio.h
+    
+
+*****************************************************************************/
+
+
+/******************************************************************************
+
+  TestCmdId :  TEST_CMD_PLT_GAIN_ADJUST
+
+       Description: retrieves the TX chain gain settings.                        
+
+       Params:     int32                txGainAdjust
+
+*****************************************************************************/
+
+/******************************************************************************
+
+  TestCmdId :  TEST_CMD_PLT_RX_CALIBRATION
+
+       Description: Used as part of the  RX calibration procedure, call this 
+                       function for every calibration channel. 
+                       The response for that function indicates only that command had been received by th FW,
+                       and not that the calibration procedure had been finished.
+                       The upper layer need to wait amount of ((numOfSamples*intervalBetweenSamplesUsec).
+                       To make sure that the RX  calibration  completed. before calling to the next command.
+                       
+       Params:     PltRxCalibrationRequest_t    rxCalibration 
+  
+  ******************************************************************************/
+typedef struct PltRxCalibrationRequest_t
+{
+       int32           expectedRssi;                           /* The calibration generated signal power (db) */
+       int32           intervalBetweenSamplesUsec; /* uSec - recommended value 100 */
+    uint8              channel;
+    RadioBand_e     band;
+    int16              numOfSamples;                           /* recommended value  1000*/
+}PltRxCalibrationRequest_t;
+
+/******************************************************************************
+
+TestCmdId :    TEST_CMD_PLT_TXPOWER_CAL_START
+
+Description: 
+
+Params:     PltTxCalibrationRequest_t   
+
+******************************************************************************/
+typedef struct 
+{
+       uint8                   refTxPower;
+       uint8                   padding[3];
+}PltTxCalibrationRequest_t;
+
+/******************************************************************************
+       TestCmd_t - the main PLT structure              
+*******************************************************************************/
+typedef struct TestCmd_t
+{
+    union
+    {
+           PERTxCfg_t                                  fcc;
+           TestCmdChannelBand_t                                telec;
+           PltGainGet_t                                gainGet;
+           PltNvsResultsBuffer_t                       nvsUpdateBuffer;
+           PltRxCalibrationRequest_t           rxCalibration;
+           uint32                                      txGainAdjust;
+           TestCmdChannelBand_t                radioTune;
+                  PltTxCalibrationRequest_t            txCalibration;
+    }testCmd_u;
+    TestCmdID_e                testCmdId;
+       int8                    padding[3];     
+}TestCmd_t;
+
+
+
+/******************************************************************************
+
+    ID:                  CMD_NOISE_HIST
+       Desc:     This command starts/stops the noise histogram measurements.
+    Params:      NoiseHistRequest_t - see below.
+
+******************************************************************************/
+#define NOISE_HIST_LEN 8
+
+typedef enum 
+{
+    NOISE_HIST_STOP,
+    NOISE_HIST_START,
+    NOISE_HIST_INVALID = MAX_POSITIVE16 /* Force to be 16 bits enum*/
+} NoiseHistMode_enum;
+
+#ifdef HOST_COMPILE
+typedef uint16 NoiseHistMode_e;
+#else
+typedef NoiseHistMode_enum NoiseHistMode_e;
+#endif
+
+typedef struct
+{
+    NoiseHistMode_e mode;             /* Start or stop the FW engine. */
+                                         /* Possible values are 1 (Start) and 0 (Stop).*/
+
+    uint16 sampleIntervalUSec;        /* The time interval in usec between measurements.*/
+                                         /* Valid values are between 100us (default) and */
+                                         /* 2ms (with 100us jumps). This parameter is */
+                                         /* relevant only when Mode is Start (1).*/
+               
+    uint8  thresholds[NOISE_HIST_LEN];/* An array of eight 8 bit thresholds. The FW */
+                                         /* takes noise measurements, once every */
+                                         /* SampleIntervalUSec interval. If the measured */
+                                         /* noise level is between the threshold[X] and */
+                                         /* threshold[X 1], then the FW increments the */
+                                         /* noise histogram counter[X]. */
+                                         /* The counters are read via the */
+                                         /* ACXNoiseHistogramResults IE. This parameter is */
+                                         /* relevant only when Mode is Start (1).*/
+} NoiseHistRequest_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_RX_RESET
+       Desc:     This command resets the MAC Rx path. After the command is issued, 
+                 the MAC Rx path is reset the next time a frame is received (in the PHY
+                         Rx Header interrupt).
+    Params:      None.
+       Note:     This command is for TI internal use only.
+
+******************************************************************************/
+
+
+/******************************************************************************
+
+    ID:                  CMD_LNA_CONTROL
+       Desc:     This command controls the LNA state. 
+    Params:      LNAControl_t - see below.
+
+******************************************************************************/
+
+typedef enum
+{
+    LNA_MODE_MANUAL,    /* 0: The LNA is set to manual mode and is turned off.*/
+       LNA_MODE_AUTO,      /* 1: The LNA is set to automatic mode.*/
+    LNA_MODE_INVALID = 0xFF
+} LnaMode_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 LnaMode_e;
+#else
+typedef LnaMode_enum LnaMode_e;
+#endif
+
+typedef struct
+{
+       LnaMode_e LNAControlField; /* refer to LnaMode_enum*/
+    uint8        padding[3];      /* for alignment to 32 bits boundry*/
+} LNAControl_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_MEASUREMENT
+       Desc:     This command instructs the WiLink device to begin a basic channel 
+                 load measurement on the specified channel. When the measurement 
+                         process actually starts running the WilLink device will raise the 
+                         Measurement Started event. When the measurement process completes as
+                         a result of the end of the measurement duration or a STOP_MEASUREMENT
+                         command, the WilLink device will raise a Measurement Complete event. 
+    Params:      MeasurementParameters_t - see below.
+
+******************************************************************************/
+typedef struct 
+{
+    ACXRxConfigStruct rxFilter; /* This field is the Rx filter configuration for the */
+                                   /* device while the measurement process is running. */
+                                   /* When the process ends the previous Rx filter */
+                                   /* configuration is reset. The filter configuration is*/
+                                   /* composed of two 32 bit registers. When they are set*/
+                                   /* to 0xFFFFFFFF the Rx filter configuration is not*/
+                                   /* changed.*/
+       
+    uint32 duration;            /* Specifies the measurement process duration in */
+                                   /* microseconds. The value of 0 means infinite duration*/
+                                   /* in which only a STOP_MEASUREMENT command can*/
+                                   /* stop the measurement process.*/
+       
+    Channel_e channel;          /* Channel number on which the measurement is performed,*/
+                                   /* valid range 0-255 (1-14 for 802.11b).*/
+       
+    RadioBand_e band;           /* Specifies the band to which the channel belongs. */
+                                   /* 0 - 2.4GHz */
+                                   /* 1 - 5GHz , */
+                                   /* 0xFF - Current band.*/
+
+    uint8 padding[2];           /* for alignment to 32 bits boundry*/
+} MeasurementParameters_t;
+
+/******************************************************************************
+
+    ID:                  CMD_STOP_MEASUREMENT
+       Desc:     This command instructs the WiLink to terminate any measurement in 
+                 progress. After processing this command, the WiLink returns to its 
+                         previous state (the state before the measurement was started) and 
+                         generates the Measurment Complete event. 
+    Params:      None.
+
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_DISCONNECT
+       Desc:     This command instructs the WiLink device to stop all BSS or IBSS activity.
+                 The device will cancel all of its TSF dependent events and activities. 
+                         Power Save dependent activities are an exception to this, therefore 
+                         the host must exit Power Save mode by issuing the SET_PS_MODE command 
+                         before calling this command. When this command is complete the Disconnect
+                         Complete event is raised to the host and the WiLink device is allowed 
+                         to enter the configured low power state. 
+    Params:      DisconnectParameters_t - see below.
+       
+******************************************************************************/
+typedef struct
+{
+    ACXRxConfigStruct rxFilter; /* This field is the Rx filter configuration for the*/
+                                   /* device that is set after the disconnection is */
+                                   /* complete. */
+       
+       
+} DisconnectParameters_t;
+
+
+/******************************************************************************
+
+    ID:                  CMD_SET_PS_MODE
+       Desc:     This command turns ON/OFF Power save protocol on the WiLink. 
+                 After HW configuration, FW sends Null data packet to the AP with Power 
+                         Management bit set accordingly to the field "Mode" of this command 
+                         structure. After processing this command, the FW generates the 
+                         PS_COMPLETE event.
+    Params:      PSModeParameters_t - see below.
+
+******************************************************************************/
+
+typedef enum
+{
+    STATION_ACTIVE_MODE,
+    STATION_POWER_SAVE_MODE
+} StationPSMode_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 StationPowerSaveMode_e;
+#else
+typedef StationPSMode_enum StationPowerSaveMode_e;
+#endif
+
+/*
+TxdRateSet_t definition
+Bit     Description
+===     ===========
+0-12    Every one of bits 0-12 specifies rate described in the column on left. Only
+        one bit could be set for the command, all other should be zeroed.
+0       1 MBPS 
+1       2 MBPS 
+2       5.5 MBPS       
+3       6 MBPS 
+4       9 MBPS 
+5       11 MBPS        
+6       12 MBPS        
+7       18 MBPS        
+8       22 MBPS        
+9       24 MBPS        
+10      36 MBPS        
+11      48 MBPS        
+12      54 MBPS        
+13      Unused (set to 0).
+14      PBCC - When this bit is set, the WiLink transmits probe requests with PBCC 
+        modulation.
+15      Preamble - When this bit is set, the WiLink transmits probe requests with a 
+                   short preamble. When this bit is clear, the WiLink transmits the 
+                                  frame with a long preamble.
+If neither the PBCC bit or OFDM rate are set, then the modulation format for probe 
+requests is CCK for 5.5 or 11 Mbps or DBPSK/DQPSK for 1 and 2 Mbps.
+*/
+
+typedef struct
+{
+    StationPowerSaveMode_e mode;         /* This field specifies the future Power save*/
+                                            /* protocol mode of the system. */
+                                            /* When set, Power save protocol is enabled. */
+                                            /* When cleared, Power save protocol is */
+                                            /* disabled (refer to StationPSMode_enum).*/
+       
+    uint8                  needToSendNullData;
+    uint8 numberOfRetries;               /* This field specifies the maximum allowed */
+                                            /* number of retries of the Null data packet */
+                                            /* that FW will send after switching the */
+                                            /* Power Save Protocol mode.*/
+
+    uint8 hangOverPeriod;                /* This field specifies the hangover period, */
+                                            /* which is the time in TUs during which the */
+                                            /* WiLink remains awake after sending an MPDU */
+                                            /* with the Power Save bit set, indicating that*/
+                                            /* the station is to go into Power Save mode. */
+                                            /* Setting bit 0 does not affect the hangover */
+                                            /* period.*/
+       
+    TxdRateSet_t rateToTransmitNullData; /* This bitwise field specifies the rate and */
+                                            /* modulation to transmit the Null data packet*/
+                                            /* to the AP. refer to above table */
+                                            /* (TxdRateSet_t). */
+       
+    uint8 padding[2];                    /* for alignment to 32 bits boundry*/
+} PSModeParameters_t;
+
+/******************************************************************************
+
+    ID:                  CMD_CHANNEL_SWITCH
+       Desc:     This command instructs the WiLink to switch serving channel at the given
+                 time. Once the channel switch is performed, the Channel Switch Complete
+                         event is raised to the host.  
+    Params:      ChannelSwitchParameters_t - see below.
+
+******************************************************************************/
+typedef struct
+{
+    Channel_e channel;  /* The new serving channel.*/
+    uint8 switchTime;   /* Relative time of the serving channel switch in TBTT units.*/
+    Bool_e txSuspend;   /* 1: Suspend TX till switch time; */
+                           /* 0: Do not suspend TX*/
+    Bool_e flush;       /* 1: Flush TX at switch time; */
+                           /* 0: Do not flush*/
+       
+} ChannelSwitchParameters_t;
+
+/******************************************************************************
+
+    ID:                  CMD_STOP_CHANNEL_SWICTH
+       Desc:     This command instructs the WiLink device to cancel performing a 
+                 pending channel switch event command. 
+    Params:      None.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_AP_DISCOVERY
+       Desc:     This command instructs the WiLink device to perform an AP discovery 
+                 measurement on a single channel. This command can only be issued after 
+                 a measurement process has been started by the WiLink device as a result
+                 of a previous Measurement command. The Measurement command specifies the 
+                 channel on which the AP discovery is performed. Once the "AP discovery" 
+                 measurement is completed either by a STOP_AP_DISCOVERY command or when 
+                 the duration has expired, it will send an "AP discovery complete event" 
+                 to the host.  
+    Params:      ApDiscoveryParameters_t - see below.
+
+******************************************************************************/
+/*
+TxdRateSet_t definition
+Bit     Description
+===     ===========
+0-12    Every one of bits 0-12 specifies rate described in the column on left. Only
+        one bit could be set for the command, all other should be zeroed.
+0       1 MBPS 
+1       2 MBPS 
+2       5.5 MBPS       
+3       6 MBPS 
+4       9 MBPS 
+5       11 MBPS        
+6       12 MBPS        
+7       18 MBPS        
+8       22 MBPS        
+9       24 MBPS        
+10      36 MBPS        
+11      48 MBPS        
+12      54 MBPS        
+13      Unused (set to 0).
+14      PBCC - When this bit is set, the WiLink transmits probe requests with PBCC 
+        modulation.
+        Notes:
+           Does not apply (set to 0) for rates 1 and 2 Mbps.
+           Does not apply (set to 0) for RevG-OFDM rates.
+15      Preamble - When this bit is set, the WiLink transmits probe requests with a 
+                   short preamble. When this bit is clear, the WiLink transmits the 
+                                  frame with a long preamble.
+                   Notes:
+                     Must be LONG (0) for 1Mbps rate.
+                                    Does not apply (set to 0) for RevG-OFDM rates.
+
+If neither the PBCC bit or OFDM rate are set, then the modulation format for probe 
+requests is CCK for 5.5 or 11 Mbps or DBPSK/DQPSK for 1 and 2 Mbps.
+*/
+typedef struct
+{
+    ACXRxConfigStruct rxFilter; /* This field is the Rx filter configuration for the */
+                                   /* device while the AP Discovery process is running. */
+                                   /* When the process ends the previous Rx filter */
+                                   /* configuration is reset. The filter configuration is*/
+                                   /* composed of two 32 bit registers. When they are set */
+                                   /* to 0xFFFFFFFF the Rx filter configuration is not */
+                                   /* changed.*/
+       
+    uint32 scanDuration;        /* This field specifies the amount of time, in time*/
+                                   /* units (TUs), to perform the AP discovery. The value*/
+                                   /* can range from 0 to 65535 TUs (67.1 seconds). */
+       
+    uint16 scanOptions;         /* This field specifies whether the AP discovery is */
+                                   /* performed by an active scan or a passive scan. */
+                                   /* 0 - ACTIVE, 1 - PASSIVE.*/
+       
+    uint8  numOfProbRqst;       /* This field indicates the number of probe requests to*/
+                                   /* send per channel, when active scan is specified. */
+                                /* Note: for EXC measurement this value should be set */
+                                   /*       to 1.*/
+       
+    uint8 txPowerAttenuation;   /* TX power level to be used for sending probe requests*/
+                                   /* when active scan is specified. */
+                                   /* If 0, leave normal TX power level for this channel. */
+
+    TxdRateSet_t txdRateSet;    /* This bitwise field specifies the rate and modulation*/
+                                   /* to transmit the probe request when an active scan is*/
+                                   /* specified. Refer to above descrption ob TxdRateSet.*/
+    uint8 padding[3];           /* for alignment to 32 bits boundry*/
+} ApDiscoveryParameters_t;
+
+/******************************************************************************
+
+    ID:                  CMD_STOP_AP_DISCOVERY
+       Desc:     This command instructs the WiLink to terminate the AP Discovery 
+                 measurement in progress. After processing this command, the WiLink 
+                         returns to its previous state  and generates the AP Discovery Complete
+                         Event. 
+    Params:      None.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_SPS_SCAN
+       Desc:     This command instructs the WiLink to perform a scheduled passive 
+                 scan for BSS/IBSSs. The WiLink monitors the specified channel(s) 
+                         for beacons. The WiLink sends Scheduled Scan Complete event to notify
+                         the host when it has completed a scan. 
+    Params:      InfoElement_t - see below.
+
+******************************************************************************/
+/* Scheduled - General scan parameters.*/
+typedef struct
+{
+    ACXRxConfigStruct rxCfg;         /* Rx filter to be used for each channel scan. */
+                                        /* The BSSID filter enable will be set (by the scan*/
+                                        /* process) to ON for a specific channel if the*/
+                                        /* BSSID of this channel is a unicast address. */
+                                        /* Otherwise it will be set to OFF (Refer to */
+                                        /* ACXRxConfigStruct).*/
+       
+    uint32            scanCmdTime_h; /* This filed is the latest 32 MSBits of TSF known*/
+                                        /* at the time the SPS command was issued. When the*/
+                                        /* scan process is about to begin, this value is */
+                                        /* used to determine if the AP has performed a */
+                                        /* recovery by comparing this value to the current*/
+                                        /* TSF. (An AP that has performed a recovery should*/
+                                        /* have a lower TSF then the one that was saved).*/
+       
+    uint32            scanCmdTime_l; /* This filed is the latest 32 LSBits of TSF known*/
+                                        /* at the time the SPS command was issued. */
+
+    uint16            scanOptions;   /* This bitwise field indicates the scan options. */
+                                        /* Bits [0,2:15] are reserved. */
+                                        /* Bit 1 is defined as follows:*/
+                                        /*  Band Select - When this bit is set, the WiLink*/
+                                        /*                scans the specified channels in */
+                                        /*                the 5GHz band. */
+                                        /*                When this bit is cleared, the */
+                                        /*                WiLink scans the specified */
+                                        /*                channels in the 2.4GHz band. */
+
+       
+    uint8             numChannels;   /* Number of scan channels in the list (minimum */
+                                        /* (minimumis 1, maximum is 30).*/
+       
+    uint8                    padding;       /* for alignment to 32 bits boundry*/
+} ScheduledGeneralParameters_t;
+
+
+/* Scheduled - Per-Channel scan parameters.*/
+typedef struct
+{
+    uint32 scanStartTime;      /* Duration in microseconds of the scan on this channel */
+                                  /* (Scan could be aborted before this duration in case of*/
+                                  /* early termination condition met on the channel). */
+       
+    uint32 scanMaxDuration;    /* Lower 4 bytes of TSF time in microseconds when the */
+                                  /* scan should start listening on the desired channel. */
+
+    uint32 bssIdL;             /* 32 LSBits of BSSID of the AP to scan for. If scanning */
+                                  /* on this  channel any BSSID, this field shall be set */
+                                  /* to broadcast BSSID. */
+       
+    uint16 bssIdH;             /* 16 MSBits of BSSID of the AP to scan for. */
+
+    ETCondCount_t ETCondCount; /* bit 0-3: Early Termination count - This field */
+                                  /*          defines the maximum number of beacons*/
+                                  /*          or probe responses or both (according*/
+                                  /*          to condition) to collect before ending*/
+                                  /*          a scan.*/
+       
+                                  /* Bit 4-5: Early Termination Condition (refer */
+                                  /*          to ETCondition_enum).*/
+    Channel_e     channel;     /* Channel number to scan, valid range 0-255 */
+                                  /* (1-14 for 802.11b).*/
+} ScheduledChannelParameters_t;
+
+
+/* The Scheduled Scan command structure.*/
+typedef struct
+{
+    ScheduledGeneralParameters_t scheduledGeneralParameters;
+    ScheduledChannelParameters_t scheduledChannelParameters[SCAN_MAX_NUM_OF_CHANNELS];
+} ScheduledScanParameters_t;
+
+/******************************************************************************
+
+    ID:                  CMD_STOP_SPS_SCAN
+       Desc:     This command instructs the WiLink to terminate a currently running 
+                 SPS or a pending SPS.. After processing this command, the WiLink 
+                         returns to its previous state and generates the Scheduled Scan 
+                         Complete Event. 
+    Params:      None.
+
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_HEALTH_CHECK
+       Desc:     This command instructs the WiLink to raise a MAC status event 
+                 which contains the current FCS Error counter. 
+    Params:      None.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    ID:                  CMD_DEBUG
+       Desc:      
+    Params:      debugCommnad_t - see below.
+
+******************************************************************************/
+#define MAX_DEBUG_PARAMETERS 10
+
+typedef struct
+{
+    uint32  id;
+    uint32  params[MAX_DEBUG_PARAMETERS];
+} debugCommnad_t;
+
+/* PLT public definitions*/
+#define TEST_CONTINUOUS 0x04       /* transmit frames contimuously */
+
+
+/*This typedef corresponds to the Fig 1 Frame Format for PER test given in PER test doc.*/
+#define PER_MODE_TX 1
+#define PER_MODE_RX 2
+#define INFRA   0x2         /* BSS is in Infrastructure mode */
+#define LOCAL_MEM_LAST      0x02000000
+#define PBCC_MODULATION_MASK 0x80
+#define OFDM_MODULATION_MASK 0x40
+#define BAND_SELECT_5GHZ     0x10
+#define CTL_PREAMBLE         0x01
+
+
+
+#endif /* PUBLIC_COMMANDS_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_descriptors.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_descriptors.h
new file mode 100644 (file)
index 0000000..a837718
--- /dev/null
@@ -0,0 +1,384 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef PUBLIC_DESCRIPTORS_H
+#define PUBLIC_DESCRIPTORS_H
+
+
+#include "public_types.h"
+
+
+/******************************************************************************
+
+       TX PATH
+        
+    The Tx path uses a double buffer and a TxControl structure, each located at a
+       fixed address in the device's memory. On startup, the host retrieves the pointers
+       to these addresses. A double buffer allows for continuous data flow towards the
+       device. The host keeps track of which buffer is available and alternates between
+       these two buffers on a per packet basis.
+    The size of each of the two buffers is large enough to hold the longest 802.3 
+       packet - maximum size Ethernet packet + header + descriptor.
+       TX complete indication will be received a-synchronously in a TX done cyclic buffer 
+       (txDoneRing) which is composed of 16 Tx Result Descriptors structures
+       and is used in a cyclic manner. refer to TxResultDescriptor_t structure.
+       
+    The TX (HOST) procedure is as follows:
+      1. Read the Tx path status (DataOutCount in TxPathStatus).
+         2. goto 1, if not possible. 
+            i.e. if DataInCount - DataOutCount >= HwBuffer size (2 for double buffer)).
+      3. Copy the packet (preceded by TxDescriptor), if possible. 
+            i.e. if DataInCount - DataOutCount < HwBuffer size (2 for double buffer).
+      4. increment DataInCount.
+      5. Inform the firmware by generating a firmware internal interrupt.
+      6. FW will increment DataOutCount after it reads the buffer.
+
+    The TX Complete procedure:
+      1. To get a TX complete indication the host enables the Tx Complete flag in the
+            TX Descriptor Structure (Refer to the Ctrl field in TxDescriptor_t).
+         2. For each packet with a Tx Complete field set, the firmware adds the transmit
+            results to the cyclic buffer (txDoneRing) and sets both done1and done2 to 1 to
+                indicate driver ownership. 
+      3. The firmware sends a Tx Complete interrupt to the host to trigger the host to
+            process the new data. Note: interrupt will be send per packet if TX complete 
+                indication was requested in TxDescriptor_t (see 1.) or per crossing Aggregation
+                threashold.
+      4. After receiving the Tx Complete interrupt, the host reads the TxDescriptorDone 
+            information in a cyclic manner and clears both done1 and done2 fields.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    TxDescriptor_t
+
+    the structure of the transmit Tx descriptor passed from the host, ahead of 
+       the transmitted packet.
+
+******************************************************************************/
+
+
+/* Because we are using a bit map, It is safer to enable the exact bits instead of field assignment */
+/* It is IMPORTENT to check that the bit defenitions are alligned to the bit map struct  */
+#define TX_COMPLETE_REQUIRED_BIT       0x80
+
+/*  TX attribute fields (txAttr of TxDesriptor structure)*/
+/*  ******************************************************/
+typedef        struct 
+{
+    unsigned      ratePolicy           :3; /* Rate Policy (class) index */
+    unsigned      ackPolicy                    :1; /* When set, no ack policy is expected*/
+    unsigned      pktType                      :2;     /* packet type: */
+                                           /* 0 - 802.11, */
+                                           /* 1 - 802.3,*/
+                                           /* 2 - IP, */
+                                           /* 3 - raw codec  */
+    unsigned      qosFrame                     :1;     /* If set, this is QoS-Null or QoS-Data*/
+    unsigned      txCmpltRequired      :1;     /* If set, the FW should trigger the TxComplete*/
+                                           /* interrupt for this packet*/
+    unsigned      xferPadding          :1;     /* If set, there is 2 bytes padding before  */
+                                           /* packet header*/
+    unsigned      reserved                     :7; /* padding*/
+} TxDescCtrl_t;
+
+
+#ifdef HOST_COMPILE 
+typedef uint16 TxAttr_t;
+#else
+typedef TxDescCtrl_t TxAttr_t;
+#endif
+
+/**************************************/
+/*  Double Buffer Descriptor Fields   */
+/**************************************/
+
+
+
+#define DoubleBufferDesc uint16 length; /* Length of payload, including headers.                               */  \
+    TxdRateSet_t     rate;          /* A bit mask that specifies the initial rate to be        */  \
+                                       /* used. Possible values are:                                                   */  \
+                                                                       /* 0x0001 - 1Mbits                                                                              */  \
+                                       /* 0x0002 - 2Mbits                                                                              */  \
+                                           /* 0x0004 - 5.5Mbits                                                                        */  \
+                                           /* 0x0008 - 6Mbits                                                                          */  \
+                                           /* 0x0010 - 9Mbits                                                                          */  \
+                                           /* 0x0020 - 11Mbits                                                                         */  \
+                                           /* 0x0040 - 12Mbits                                                                         */  \
+                                           /* 0x0080 - 18Mbits                                                                         */  \
+                                           /* 0x0100 - 22Mbits                                                                         */  \
+                                           /* 0x0200 - 24Mbits                                                                         */  \
+                                           /* 0x0400 - 36Mbits                                                                         */  \
+                                           /* 0x0800 - 48Mbits                                                                         */  \
+                                           /* 0x1000 - 54Mbits                                                                         */  \
+    uint32              expiryTime;    /* Time (in us) the packet can stay in the device               */  \
+                                       /* before the packet expires.                                                   */  \
+    uint8               xmitQueue;             /* The index of the Tx queue used for this packet.              */  \
+       uint8            descID;            /* Identifier of the packet. This ID is used by the         */  \
+                                       /* host for identifying the Tx Result of packet.                */  \
+    TxAttr_t            txAttr;                /* Bitwise fields - see TxDescCtrl_tdefinition above    */  \
+    uint16              fragThreshold; /* The FW should cut the packet to fragments by                 */      \
+                                       /* this size.                                                                                   */  \
+    uint8               numMemBlks;    /* Number of HW queue blocks to allocate for this               */  \
+                                       /* packet.                                                                                              */  \
+    uint8               reserved;      /* for padding to 32 bits boundry.                                              */  \
+
+
+
+
+typedef struct 
+{
+       DoubleBufferDesc
+}DbTescriptor;
+
+/******************************************************************************
+
+    TxResultDescriptor_t
+
+    the structure of the Tx result retrieved from FW upon TX completion.
+
+******************************************************************************/
+
+typedef enum
+{
+    TX_SUCCESS              = 0,     
+       TX_DMA_ERROR            = BIT_7,
+       TX_DISABLED             = BIT_6,
+       TX_RETRY_EXCEEDED       = BIT_5,
+       TX_TIMEOUT              = BIT_4,
+       TX_KEY_NOT_FOUND        = BIT_3,
+       TX_ENCRYPT_FAIL         = BIT_2,
+       TX_UNAVAILABLE_PRIORITY = BIT_1
+} TxDescStatus_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 TxDescStatus_e;
+#else
+typedef TxDescStatus_enum TxDescStatus_e;
+#endif
+
+typedef struct 
+{
+    uint8 done1;                     /* Ownership synchronization between the host and */
+                                        /* the firmware. If done1 and done2 are cleared, */
+                                        /* owned by the FW (no info ready). */
+       
+    uint8 descID;                    /* Packet Identifier - same value used in the Tx */
+                                        /* descriptor.*/
+
+    uint16 mediumUsage;              /* Total air access duration consumed by this */
+                                        /* packet, including all retrys and overheads.*/
+
+    uint32 mediumDelay;              /* Total media delay (from 1st EDCA AIFS counter until TX Complete).  */
+
+    uint32 fwHandlingTime;           /* The time passed from host xfer to Tx-complete.*/
+
+    uint8 lsbSecuritySequenceNumber; /* The LS-byte of the last TKIP sequence number. */
+                                        /* Saved per queue for recovery.*/
+       
+    uint8 ackFailures;               /* Retry count - The number of transmissions */
+                                        /* without successful ACK reception.*/
+
+    TxdRateSet_t actualRate;         /* The rate that succeeded getting ACK - */
+                                        /* Valid only if status=TX_SUCCESS.*/
+
+    uint16 reserved; 
+       TxDescStatus_e  status;          /* The status of the transmission, indicating */
+                                        /* success or one of several possible reasons for */
+                                        /* failure. Refer to TxDescStatus_enum, above.*/
+       
+    uint8 done2;                     /* Refer to done1.*/
+} TxResultDescriptor_t;
+
+
+
+/******************************************************************************
+
+       RX PATH
+
+    The Rx path uses a double buffer and an RxControl structure, each located at
+       a fixed address in the device memory. On startup, the host retrieves the 
+       pointers to these addresses. A double buffer allows for continuous data flow
+       towards the device. The host keeps track of which buffer is available and 
+       alternates between them on a per packet basis.
+    The size of each of the two buffers is large enough to hold the longest 802.3
+       packet.
+       A dedicated control block is used to manage the flow control between the host 
+       and the device. The procedure is interrupt driven.
+
+       The RX procedure is as follows:
+       1.      The device generates an interrupt each time a new packet is received and
+           the corresponding interrupt is enabled in the host. There are two different 
+               interrupt sources, one for each buffer. It is possible that both interrupt 
+               sources are set when both buffers in the double buffer are pending with Rx
+               data.
+       2.      Depending on flow control conditions, the host reads a packet from the 
+           appropriate buffer in the double buffer.
+       3.      The host triggers an interrupt in the device (using the HW mechanism of EOT), 
+           indicating the address of the buffer which has been read.
+       4.      The device services the complete interrupt and prepares the next Rx packet,
+           if available. In addition, the device updates the control block and issues
+               an interrupt to the host.
+       
+******************************************************************************/
+
+/******************************************************************************
+
+    RxPathStatusReg_t
+
+    The structure of the Rx Path Status register. This status register 
+       represents both the status of the double-buffer (xfer protocol) and the 
+       number of the pending packet in receive queue.
+       
+******************************************************************************/
+
+#ifdef HOST_COMPILE
+#define    RX_DESC_VALID_FCS         0x0001 
+#define    RX_DESC_MATCH_RXADDR1     0x0002 
+#define    RX_DESC_MCAST             0x0004 
+#define    RX_DESC_STAINTIM          0x0008 
+#define    RX_DESC_VIRTUAL_BM        0x0010
+#define    RX_DESC_BCAST             0x0020
+#define    RX_DESC_MATCH_SSID        0x0040
+#define    RX_DESC_MATCH_BSSID       0x0080
+#define    RX_DESC_ENCRYPTION_MASK   0x0300
+#define    RX_DESC_MEASURMENT        0x0400
+#define    RX_DESC_SEQNUM_MASK       0x1800
+#define           RX_DESC_MIC_FAIL                      0x2000
+#define           RX_DESC_DECRYPT_FAIL          0x4000
+typedef uint16 RxFlags_t;  
+#else
+typedef struct
+{
+    unsigned    validFcs        : 1; /* Indicates whether a received frame had a valid FCS*/
+
+    unsigned    matchRxAddr1    : 1; /* Indicates whether a received frame contained a */
+                                   /* matching receive address in Address 1.*/
+
+    unsigned    mcast           : 1; /* Indicates whether a received frame contains a */
+                                      /* unicast/directed or group receive address, bit 40*/
+                                      /* of Addr1 (0 = individual, 1 = group).*/
+
+    unsigned    StaInTIM        : 1; /* Indicates that the TIM in a Beacon frame contained*/
+                                      /* a 1 in the bit position representing this STA */
+                                      /* (i.e. the AP contains one or more buffered frame(s)*/
+                                      /* for this STA).*/
+
+    unsigned    virtualBM       : 1; /* If asserted, the VBM in a Beacon frame contained */
+                                      /* more than 1 asserted bit*/
+
+    unsigned    bcast           : 1; /* Indicates whether the received frame\92s address 1 */
+                                   /* is a broadcast address.*/
+
+    unsigned    matchSSID       : 1; /* Indicates whether the received frame containing */
+                                      /* a matching SSID (either broadcast or specific).*/
+
+    unsigned    matchBSSID      : 1; /* Indicates whether the received frame containing */
+                                      /* a matching BSSID (either broadcast or specific).*/
+
+    unsigned    encryption      : 2; /* This field indicates the encryption type of the */
+                                   /* packet: 00 - None, 01 - WEP, 10 - TKIP, 11 - AES*/
+
+    unsigned    measurement     : 1; /* Indicates whether the packet was received during */
+                                      /* measurement process or not*/
+
+    unsigned    seqnum          : 2; /* Sequence number of the current frame*/
+
+       unsigned        micFail                 : 1; /* MIC Fail indication */
+
+       unsigned        decryptFail             : 1; /* DECRYPT Fail indication */
+
+    unsigned    reserved2       : 1;
+} RxFlags_t;
+#endif
+
+/******************************************************************************
+
+    RxIfDescriptor_t
+
+    the structure of the Rx Descriptor recieved by HOST.
+
+******************************************************************************/
+
+typedef struct
+{
+    uint32          timestamp;     /* Timestamp in microseconds,     */
+    
+       uint16          length;        /* Length of payload (including headers)*/
+    
+       RxFlags_t       flags;         /* See RxFlags_t for details. */
+
+    uint8           type;          /* Protocol type: */
+                                      /* 0 - 802.11*/
+                                      /* 1 - 802.3*/
+                                      /* 2 - IP*/
+                                      /* 3 - Raw Codec*/
+
+    uint8           rate;          /* Recevied Rate:*/
+                                   /* 0x0A - 1MBPS*/
+                                   /* 0x14 - 2MBPS   */
+                                          /* 0x37 - 5_5MBPS */
+                                          /* 0x0B - 6MBPS   */
+                                          /* 0x0F - 9MBPS   */
+                                          /* 0x6E - 11MBPS  */
+                                          /* 0x0A - 12MBPS  */
+                                          /* 0x0E - 18MBPS  */
+                                          /* 0xDC - 22MBPS  */
+                                          /* 0x09 - 24MBPS  */
+                                          /* 0x0D - 36MBPS  */
+                                          /* 0x08 - 48MBPS  */
+                                          /* 0x0C - 54MBPS  */
+
+    uint8           modPre;        /* Modulation and Preamble of received packet*/
+    
+       uint8           chanNum;       /* The received channel*/
+    
+       uint8           band;          /* 0 - 2.4Ghz*/
+                                      /* 1 - 5Ghz*/
+    
+       int8            rssi;          /* RSSI value in db */
+    
+       uint8           rcpi;          /* RCPI value in db */
+    
+       uint8           snr;           /* SNR in db*/
+    
+} RxIfDescriptor_t;
+
+
+
+#endif /* PUBLIC_DESCRIPTORS_H*/
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_event_mbox.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_event_mbox.h
new file mode 100644 (file)
index 0000000..c5f9b26
--- /dev/null
@@ -0,0 +1,239 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 public_event_mbox.h
+ *  \brief Public header for the Event Mailbox FW<->Driver interface.
+ *
+ */
+
+#ifndef PUBLIC_EVENT_MBOX_H
+#define PUBLIC_EVENT_MBOX_H
+
+/******************************************************************************
+
+    EVENT MBOX
+     
+    The event mechanism is based on a pair of event buffers (buffers "A" and "B") in fixed locations
+    in the device's memory. The host processes one buffer (buffer "A") while the other buffer 
+    (buffer "B") continues to collect events. When the host is finished, it begins processing the 
+    other buffer ("B") while the first buffer ("A") collects, and so on.
+    If the host is not processing events, an interrupt is issued to the host signaling that a 
+    buffer is ready. The interrupt that the host receives indicates the appropriate event structure
+    buffer. Once the host finishes processing events from one buffer, 
+    it signals with an acknowledge interrupt (bit 0 in the INT_TRIG register) that the event buffer
+    is free. This interrupt triggers the device to send the next event structure if there are any 
+    collected events in it.
+
+    Note: Only one instance (the last) of each type of event is collected.
+       
+******************************************************************************/
+
+
+#include "public_types.h"
+#include "public_commands.h"
+
+
+
+/*************************************************************************
+
+  Events Enumeration 
+
+**************************************************************************/
+typedef enum 
+{
+    RESERVED1_EVENT_ID                       = BIT_0,
+    RESERVED2_EVENT_ID                       = BIT_1,
+    MEASUREMENT_START_EVENT_ID               = BIT_2,
+    SCAN_COMPLETE_EVENT_ID                   = BIT_3,
+    CALIBRATION_COMPLETE_EVENT_ID            = BIT_4,
+    ROAMING_TRIGGER_LOW_RSSI_EVENT_ID        = BIT_5,
+    PS_REPORT_EVENT_ID                       = BIT_6,
+    SYNCHRONIZATION_TIMEOUT_EVENT_ID         = BIT_7,
+    HEALTH_REPORT_EVENT_ID                   = BIT_8,
+    ACI_DETECTION_EVENT_ID                   = BIT_9,
+    DEBUG_REPORT_EVENT_ID                    = BIT_10,
+    MAC_STATUS_EVENT_ID                      = BIT_11,
+    DISCONNECT_EVENT_COMPLETE_ID             = BIT_12,
+    JOIN_EVENT_COMPLETE_ID                   = BIT_13,
+    CHANNEL_SWITCH_COMPLETE_EVENT_ID         = BIT_14,
+    BSS_LOSE_EVENT_ID                        = BIT_15,
+    ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID    = BIT_16,
+    MEASUREMENT_COMPLETE_EVENT_ID            = BIT_17,
+    AP_DISCOVERY_COMPLETE_EVENT_ID           = BIT_18,
+    SCHEDULED_SCAN_COMPLETE_EVENT_ID         = BIT_19,
+    PSPOLL_DELIVERY_FAILURE_EVENT_ID        = BIT_20,
+    RESET_BSS_EVENT_ID                       = BIT_21, 
+    REGAINED_BSS_EVENT_ID                    = BIT_22,
+    ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID   = BIT_23,
+    ROAMING_TRIGGER_LOW_SNR_EVENT_ID         = BIT_24,
+    ROAMING_TRIGGER_REGAINED_SNR_EVENT_ID    = BIT_25,
+
+    DBG_EVENT_ID                             = BIT_26,
+    SOFT_GEMINI_SENSE_EVENT_ID               = BIT_27,
+    SOFT_GEMINI_PREDICTION_EVENT_ID          = BIT_28,
+    SOFT_GEMINI_AVALANCHE_EVENT_ID           = BIT_29,
+
+    PLT_RX_CALIBRATION_COMPLETE_EVENT_ID     = BIT_30,
+
+    EVENT_MBOX_ALL_EVENT_ID                  = MAX_POSITIVE32
+} EventMBoxId_e;
+
+/*************************************************************************
+
+  Specific Event Parameters 
+
+**************************************************************************/
+typedef enum
+{
+    SCHEDULED_SCAN_COMPLETED_OK = 0,
+    SCHEDULED_SCAN_TSF_ERROR    = 1
+} ScheduledScanReportStatus_enum;
+
+
+typedef enum
+{
+    CHANNEL_SWITCH_COMPLETE_OK,
+    CHANNEL_SWITCH_TSF_ERROR
+} ChannelSwitchReportStatus_enum;
+
+
+typedef enum
+{
+    ENTER_POWER_SAVE_FAIL    =  0,
+    ENTER_POWER_SAVE_SUCCESS =  1,
+    EXIT_POWER_SAVE_FAIL     =  2,
+    EXIT_POWER_SAVE_SUCCESS  =  3,
+    POWER_SAVE_STATUS_NUMBER
+} EventsPowerSave_enum;
+
+typedef enum
+{
+    TEST1_DBG_EVENT_ID = 0,
+    TEST2_DBG_EVENT_ID = 0x11,
+    LAST_DBG_EVENT_ID= 0xff
+}dbgEventId_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 ScheduledScanReportStatus_e;
+typedef uint8 ChannelSwitchReportStatus_e;
+typedef uint8 EventsPowerSave_e;
+typedef uint8 dbgEventId_e;
+#else
+typedef ScheduledScanReportStatus_enum ScheduledScanReportStatus_e;
+typedef ChannelSwitchReportStatus_enum ChannelSwitchReportStatus_e;
+typedef EventsPowerSave_enum EventsPowerSave_e;
+typedef dbgEventId_enum dbgEventId_e;
+#endif
+
+
+#define MAX_EVENT_REPORT_PARAMS 5
+typedef struct
+{ 
+    dbgEventId_e dbgEventId;  /*uint8*/
+    uint8       numberOfRelevantParams;
+    uint16      reservedPad16;
+    uint32      eventReportP1;
+    uint32      eventReportP2;
+    uint32      eventReportP3;
+}dbgEventRep_t;
+
+
+
+/*************************************************************************
+
+  The Event Mailbox structure in memory 
+
+**************************************************************************/
+typedef struct EventMailBox_t
+{
+    /* Events Bit Mask */
+    uint32 eventsVector;
+    uint32 eventsMask;
+    uint32 reserved1;
+    uint32 reserved2;
+
+    /* Events Data */
+    int8   averageRssiLevel;                /* Average RSSI value.  */
+                                            /* [ROAMING_TRIGGER_LOW_RSSI_EVENT_ID].*/
+
+    uint8  psStatus;                        /* refer to EventsPowerSave_enum.*/
+                                            /* [PS_REPORT_EVENT_ID].*/
+    
+    uint8  channelSwitchStatus;             /* Status of channel switch. Refer to*/
+                                            /* ChannelSwitchReportStatus_enum.*/
+                                            /* [CHANNEL_SWITCH_COMPLETE_EVENT_ID]*/
+    
+    uint8  scheduledScanStatus;             /* Status of scheduled scan. Refer to */
+                                            /* ScheduledScanReportStatus_enum.*/
+                                            /* [SCHEDULED_SCAN_COMPLETE_EVENT_ID]*/
+    
+    uint16 scheduledScanAttendedChannels;   /* Channels scanned by the Scheduled Scan. */
+                                            /* [SCHEDULED_SCAN_COMPLETE_EVENT_ID]*/
+
+    uint16 healthReport;                    /* Bit 0 is set in case of a fatal error in the device.*/
+                                            /* [HEALTH_REPORT_EVENT_ID].*/
+    
+    uint16 badFFTCorrelationCounter;        /* [ACI_DETECTION_EVENT_ID]*/
+
+    uint8  softGeminiSenseInfo;             /* Contains the type of the BT Coexistence sense event.*/
+                                            /* [SOFT_GEMINI_SENSE_EVENT_ID]*/
+
+    uint8  softGeminiProtectiveInfo;        /* Contains information from the BT activity prediction */
+                                            /* machine [SOFT_GEMINI_PREDICTION_EVENT_ID]*/
+    
+    uint32              reserved;
+    uint32 debugReport[2];                  /* [DBG_EVENT_ID]*/
+
+    /* 16 Header + 24 data = 40 bytes till here include new fields */
+
+    uint32 consFcsErrCnt;                   /* The number of FCS errors since the last event. */
+                                            /* If this number is larger then the last recorded */
+                                            /* number plus a threshold (20, by default), and no Rx*/
+                                            /* packet has been received in the last 500 ms, than the*/
+                                            /* MAC Rx module is reset. After 2 such resets (by */
+                                            /* default), the driver performs a full recovery */
+                                            /* process.  */
+                                            /* [MAC_STATUS_EVENT_ID]*/
+
+    dbgEventRep_t      dbgEventRep;         /* refer to dbgEventRep_t*/
+                                            /* [DBG_EVENT_ID]*/
+
+    uint8 averageSNRLevel;                  /* [ROAMING_TRIGGER_LOW_SNR_EVENT_ID]*/
+    uint8              padding[19];          /* for alignment to 32 bits boundry*/
+} EventMailBox_t;
+
+#endif /* PUBLIC_EVENT_MBOX_H*/
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_host_int.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_host_int.h
new file mode 100644 (file)
index 0000000..a7a4211
--- /dev/null
@@ -0,0 +1,105 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef PUBLIC_HOST_INT_H
+#define PUBLIC_HOST_INT_H
+
+#include "public_types.h"
+
+                
+/*************************************************************************
+
+    Host Interrupt Register (WiLink -> Host)
+**************************************************************************/
+
+#define ACX_INTR_RX0_DATA                      BIT_0   /* RX packet is ready in Xfer buffer #0*/
+#define ACX_INTR_TX_RESULT                     BIT_1   /* TX result(s) are in the TX complete buffer  */
+#define ACX_INTR_TX_XFR                                BIT_2   /* OBSOLETE*/
+#define ACX_INTR_RX1_DATA                      BIT_3   /* RX packet is ready in Xfer buffer #1*/
+#define ACX_INTR_EVENT_A                       BIT_4   /* Event was entered to Event MBOX #A*/
+#define ACX_INTR_EVENT_B               BIT_5   /* Event was entered to Event MBOX #B */
+#define ACX_INTR_WAKE_ON_HOST       BIT_6   /* OBSOLETE */
+#define ACX_INTR_TRACE_A               BIT_7   /* Trace meassge on MBOX #A*/
+#define ACX_INTR_TRACE_B            BIT_8   /* Trace meassge on MBOX #B*/
+#define ACX_INTR_CMD_COMPLETE       BIT_9   /* Command processing completion*/
+#define ACX_INTR_INIT_COMPLETE         BIT_14  /* Init sequence is done*/
+
+#define ACX_INTR_ALL                0xFFFFFFFF
+
+
+/*************************************************************************
+
+    Interrupt Trigger Register (Host -> WiLink)              
+  
+**************************************************************************/
+
+/******** Hardware to Embedded CPU Interrupts - first 32-bit register set ********/ 
+   
+#define INTR_TRIG_CMD       BIT_0   /* Host Command Interrupt. Setting this bit masks*/
+                                    /* the interrupt that the host issues to inform*/
+                                    /* the FW that it has sent a command*/
+                                    /* to the Wlan hardware Command Mailbox.*/
+    
+#define INTR_TRIG_EVENT_ACK BIT_1   /* Host Event Acknowlegde Interrupt. The host */
+                                    /* sets this bit to acknowledge that it received*/
+                                    /* the unsolicited information from the event*/
+                                    /* mailbox.*/
+                                       
+#define INTR_TRIG_TX_PROC0 BIT_2    /* The host sets this bit to inform the Wlan */
+                                    /* FW that a TX packet is in the XFER */
+                                    /* Buffer #0.*/
+                                       
+#define INTR_TRIG_RX_PROC0 BIT_3    /* The host sets this bit to inform the FW */
+                                    /* that it read a packet from RX XFER */
+                                    /* Buffer #0.*/
+
+#define INTR_TRIG_DEBUG_ACK BIT_4 
+    
+#define INTR_TRIG_STATE_CHANGED BIT_5
+        
+
+/******** Hardware to Embedded CPU Interrupts - second 32-bit register set ********/
+
+#define INTR_TRIG_RX_PROC1 BIT_17     /* The host sets this bit to inform the FW */
+                                     /* that it read a packet from RX XFER */
+                                     /* Buffer #1.  */
+
+#define INTR_TRIG_TX_PROC1 BIT_18    /* The host sets this bit to inform the Wlan */
+                                     /* hardware that a TX packet is in the XFER */
+                                     /* Buffer #1.*/
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_infoele.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_infoele.h
new file mode 100644 (file)
index 0000000..9a7d1c1
--- /dev/null
@@ -0,0 +1,2392 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 public_infoele.h
+ *  \brief Contains information element defines/structures used by the FW and host.
+ *
+ */
+
+#ifndef PUBLIC_INFOELE_H
+#define PUBLIC_INFOELE_H
+
+
+#include "public_types.h"
+#include "public_commands.h"
+#include "public_radio.h" 
+
+
+typedef enum
+{
+    ACX_WAKE_UP_CONDITIONS      = 0x0002,
+    ACX_MEM_CFG                 = 0x0003,
+    ACX_SLOT                    = 0x0004,
+    ACX_QUEUE_HEAD              = 0x0005, /* for MASTER mode only!!!*/
+    ACX_AC_CFG                  = 0x0007,
+    ACX_MEM_MAP                 = 0x0008,
+    ACX_AID                     = 0x000A,
+    ACX_RADIO_PARAM             = 0x000B, /* Not in use !!! */
+    ACX_CFG                     = 0x000C, /* Not in use !!!*/
+    ACX_FW_REV                  = 0x000D,
+    ACX_FCS_ERROR_CNT           = 0x000E, /* OBSOLETE (replaced by ACX_ERROR_CNT) !!!*/
+    ACX_MEDIUM_USAGE            = 0x000F,
+    ACX_RX_CFG                  = 0x0010,
+    ACX_TX_QUEUE_CFG            = 0x0011,
+    ACX_BSS_IN_PS               = 0x0012, /* for AP only (OBSOLETE???) */
+    ACX_STATISTICS              = 0x0013, /* Debug API*/
+    ACX_PWR_CONSUMPTION_STATISTICS  = 0x0014,
+    ACX_FEATURE_CFG             = 0x0015,
+    ACX_MISC_CFG                = 0x0017, /* Not in use !!!*/
+    ACX_TID_CFG                 = 0x001A,
+    ACX_CAL_ASSESSMENT          = 0x001E, /* OBSOLETE !!!*/
+    ACX_BEACON_FILTER_OPT       = 0x001F,
+    ACX_LOW_RSSI                = 0x0020,
+    ACX_NOISE_HIST              = 0x0021,
+    ACX_HDK_VERSION             = 0x0022, /* ???*/
+    ACX_PD_THRESHOLD            = 0x0023,
+    ACX_DATA_PATH_PARAMS        = 0x0024, /* WO*/
+       ACX_DATA_PATH_RESP_PARAMS   = 0x0024, /* RO*/
+    ACX_CCA_THRESHOLD           = 0x0025,
+    ACX_EVENT_MBOX_MASK         = 0x0026,
+#ifdef FW_RUNNING_AS_AP
+    ACX_DTIM_PERIOD             = 0x0027, /* for AP only !!!*/
+#else
+    ACX_WR_TBTT_AND_DTIM        = 0x0027, /* STA only*/
+#endif
+    ACX_ACI_OPTION_CFG          = 0x0029, /* OBSOLETE !!! (for 1251)*/
+    ACX_GPIO_CFG                = 0x002A, /* Not in use !!!*/
+    ACX_GPIO_SET                = 0x002B, /* Not in use !!!*/
+    ACX_PM_CFG                  = 0x002C, /* ??? (To Be Documented)*/
+    ACX_CONN_MONIT_PARAMS       = 0x002D,
+    ACX_AVERAGE_RSSI            = 0x002E, /* Not in use !!!*/
+    ACX_CONS_TX_FAILURE         = 0x002F,
+    ACX_BCN_DTIM_OPTIONS        = 0x0031,
+    ACX_SG_ENABLE               = 0x0032,
+    ACX_SG_CFG                  = 0x0033,
+    ACX_ANTENNA_DIVERSITY_CFG   = 0x0035, /* ??? (To Be Documented)*/
+       ACX_LOW_SNR                                     = 0x0037, /* To Be Documented*/
+    ACX_BEACON_FILTER_TABLE     = 0x0038,
+    ACX_ARP_IP_FILTER           = 0x0039,
+    ACX_ROAMING_STATISTICS_TBL  = 0x003B,
+    ACX_RATE_POLICY             = 0x003D, 
+    ACX_CTS_PROTECTION          = 0x003E, 
+    ACX_SLEEP_AUTH              = 0x003F,
+       ACX_PREAMBLE_TYPE                       = 0x0040,
+    ACX_ERROR_CNT               = 0x0041,
+       ACX_FW_GEN_FRAME_RATES      = 0x0042,
+       ACX_IBSS_FILTER                         = 0x0044,
+    ACX_SERVICE_PERIOD_TIMEOUT  = 0x0045,
+       ACX_TSF_INFO                = 0x0046,
+    ACX_CONFIG_PS_WMM           = 0x0049,
+    ACX_ENABLE_RX_DATA_FILTER   = 0x004A,
+    ACX_SET_RX_DATA_FILTER      = 0x004B,
+    ACX_GET_DATA_FILTER_STATISTICS = 0x004C,
+       ACX_POWER_LEVEL_TABLE       = 0x004D,
+    ACX_BET_ENABLE              = 0x0050,
+    DOT11_STATION_ID           =  0x1001,
+    DOT11_RX_MSDU_LIFE_TIME     = 0x1004,
+    DOT11_CUR_TX_PWR           =  0x100D,
+    DOT11_DEFAULT_KEY          =  0x1010,
+    DOT11_RX_DOT11_MODE        =  0x1012,
+    DOT11_RTS_THRESHOLD        =  0x1013, 
+    DOT11_GROUP_ADDRESS_TBL    =  0x1014,
+     
+    MAX_DOT11_IE = DOT11_GROUP_ADDRESS_TBL,
+       
+    MAX_IE = 0xFFFF   /*force enumeration to 16bits*/
+} InfoElement_enum;
+
+
+#ifdef HOST_COMPILE
+typedef uint16 InfoElement_e;
+#else
+typedef InfoElement_enum InfoElement_e;
+#endif
+
+
+typedef struct
+{
+    InfoElement_e id;
+    uint16 length;
+    uint32 dataLoc; /*use this to point to for following variable-length data*/
+} InfoElement_t;
+
+
+typedef struct 
+{
+    uint16 id;
+    uint16 len;
+} EleHdrStruct;
+
+
+#ifdef HOST_COMPILE
+#define INFO_ELE_HDR    EleHdrStruct    EleHdr;
+#else
+#define INFO_ELE_HDR
+#endif
+
+/******************************************************************************
+
+    Name:      ACX_WAKE_UP_CONDITIONS
+       Type:   Configuration
+       Access: Write Only
+       Length: 2
+
+******************************************************************************/
+typedef enum
+{
+       WAKE_UP_EVENT_BEACON_BITMAP             = 0x01, /* Wake on every Beacon*/
+       WAKE_UP_EVENT_DTIM_BITMAP               = 0x02, /* Wake on every DTIM*/
+       WAKE_UP_EVENT_N_DTIM_BITMAP             = 0x04, /* Wake on every Nth DTIM (Listen interval)*/
+       WAKE_UP_EVENT_N_BEACONS_BITMAP  = 0x08, /* Wake on every Nth Beacon (Nx Beacon)*/
+       WAKE_UP_EVENT_BITS_MASK                 = 0x0F
+} WakeUpEventBitMask_e;
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8  wakeUpConditionBitmap;      /* The host can set one bit only. */
+                                                                       /* WakeUpEventBitMask_e describes the Possible */
+                                                                       /* Wakeup configuration bits*/
+
+    uint8  listenInterval;                     /* 0 for Beacon and Dtim, */
+                                                                       /* xDtims (1-10) for Listen Interval and */
+                                                                       /* xBeacons (1-255) for NxBeacon*/
+    uint8  padding[2];              /* alignment to 32bits boundry   */
+}WakeUpCondition_t;
+
+/******************************************************************************
+
+    Name:      ACX_MEM_CFG
+       Type:   Configuration
+       Access: Write Only
+       Length: 12
+
+******************************************************************************/
+
+/* Host Bus/Memory Mode - The following table specifies the possible host bus modes and */
+/* memory organizations that the Wilink should use during operation. */
+typedef enum{
+    HOSTIF_PCI_MASTER_HOST_INDIRECT,
+    HOSTIF_PCI_MASTER_HOST_DIRECT,
+    HOSTIF_SLAVE,
+    HOSTIF_PKT_RING,  
+    HOSTIF_DONTCARE = 0xFF
+} HostIFConfig_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 HostIFConfig_e;
+#else
+typedef HostIFConfig_enum HostIFConfig_e;
+#endif
+
+typedef struct
+{
+       INFO_ELE_HDR
+    uint16  numStations;                               /* specifies the number of STAs to be supported. */
+                                                                               /* The FW uses this field to allocate memory */
+                                                                               /* for STA context data such as security keys*/
+    uint16  reserved1;
+    uint8   rxMemblockNumber;                  /* specifies the number of memory buffers that */
+                                                                               /* is allocated to the Rx memory pool. The */
+                                                                               /* actual number allocated may be less than*/
+                                                                               /* this number if there are not enough memory */
+                                                                               /* blocks left over for the Minimum Number of */
+                                                                               /* Tx Blocks. Returns the actual number of RX */
+                                                                               /* buffers allocated in the memory map*/
+    uint8   Reserved2;
+    uint8   numTxQueues;                               /* specifies the number of descriptor queues */
+                                                                               /* that are to be used for transmit operations. */
+                                                                               /* Valid values are 1 to 16*/
+
+    HostIFConfig_e hostifOptions;              /* specifies the memory configuration options */
+                                                                               /* for the adaptor. The format of this field */
+                                                                               /* is shown in HostIFConfig_enum.*/
+
+    uint8   txMinimumMemblockNumber;   /* specifies the minimum number of blocks that */
+                                                                               /* must be allocated to the TX pool. Follows */
+                                                                               /* this limit even if the Number of Rx Memory */
+                                                                               /* Blocks parameter is ignored.*/
+
+    uint8   numSsidProfiles;                   /* specifies the number of SSID profiles used */
+                                                                               /* in the AP. Enables working with different */
+                                                                               /* profiles for different stations.*/
+
+    uint16  debugBufferSize;                   /* This field specifies the number of words */
+                                                                               /* allocated for each debug buffer if the */
+                                                                               /* FW trace is enabled.*/
+#ifndef HOST_COMPILE
+    uint8   variableData;                              /* contents vary starting here - should be */
+    uint8   pedding[3];                                 /* aligned to 32 bits boundry*/
+#endif
+} ACXConfigMemory_t;
+
+typedef struct
+{
+    uint8 numDescs;
+    uint8  Reserved;
+    uint8  Type;
+    uint8  Priority;
+    uint32 dmaAddress;
+} ACXrxQueueConfig;
+
+typedef struct
+{
+    uint8  numDescs;
+    uint8  reserved1[2];
+    uint8  attributes;   /* QPriority_e qPriority;*/
+} ACXtxQueueConfig;
+
+#define QUEUE_CONFIG_MAX_TX_QUEUES     5
+
+typedef struct 
+{
+   ACXConfigMemory_t   memConfig;
+   ACXrxQueueConfig        RxQueueConfig;
+   ACXtxQueueConfig        TxQueueConfig[QUEUE_CONFIG_MAX_TX_QUEUES];
+} ACXConfigMemoryStruct_t; 
+
+
+
+/******************************************************************************
+
+    Name:      ACX_SLOT
+       Type:   Configuration
+       Access: Write Only
+       Length: 8
+
+******************************************************************************/
+
+typedef enum
+{
+    SLOT_TIME_LONG = 0,                /* the WiLink uses long (20 us) slots*/
+    SLOT_TIME_SHORT = 1,       /* the WiLink uses short (9 us) slots*/
+    DEFAULT_SLOT_TIME = SLOT_TIME_SHORT,
+    MAX_SLOT_TIMES = 0xFF
+} SlotTime_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 SlotTime_e;
+#else
+typedef SlotTime_enum SlotTime_e;
+#endif
+
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8      woneIndex;      /* reserved*/
+
+    SlotTime_e slotTime;       /* The slot size to be used. refer to SlotTime_enum.    */
+    uint8      reserved[6];
+} ACXSlot_t;
+
+/******************************************************************************
+
+    Name:      ACX_QUEUE_HEAD
+       Type:   Configuration
+       Access: Read Only
+       Length: 56
+       Note:   for MASTER mode only!!!
+
+******************************************************************************/
+
+typedef struct
+{
+    uint32 addr;
+    uint8  priority;
+    uint8  padding[3];
+} ACXoneQueueHead;
+
+#define NUM_ACCESS_CATEGORIES_QUEUES   5               /* This takes into account the */
+                                                                                               /* broadcast AC queue*/
+typedef struct
+{
+   INFO_ELE_HDR
+   uint32  *txMemBlkQ;
+   uint32  *rxMemBlkQ;
+   ACXoneQueueHead rxQueueHead;
+   ACXoneQueueHead txQueueHead[NUM_ACCESS_CATEGORIES_QUEUES];
+} ACXQosQueueHead_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_AC_CFG
+       Type:   Configuration
+       Access: Write Only
+       Length: 8
+
+******************************************************************************/
+typedef enum
+{
+       AC_BE = 0,                      /* Best Effort/Legacy*/
+       AC_BK = 1,                      /* Background*/
+       AC_VI = 2,                      /* Video*/
+       AC_VO = 3,                      /* Voice*/
+       AC_BCAST = 4,           /* Broadcast dummy access category*/
+       NUM_ACCESS_CATEGORIES = 4
+} AccessCategory_enum;
+
+#define AC_FAST_TEMPLATE                               4               /* Access Category for SG2.0 Fast CTS Tx */ 
+#define AC_REQUEST                                             0xfe    /* Special access category type for */
+                                                                                               /* requests*/
+#define AC_INVALID                                             0xff    /* Empty Access category in scheduler */
+                                                                                               /* Access Category DB*/
+
+#define AC_ANY_TID                                             0xFF    /* Any TID/AC for the Split Scan */
+
+/* following are defult values for the IE fields*/
+#define CWMIN_BK  15
+#define CWMIN_BE  15
+#define CWMIN_VI  7
+#define CWMIN_VO  3
+#define CWMAX_BK  1023
+#define CWMAX_BE  63
+#define CWMAX_VI  15
+#define CWMAX_VO  7
+#define AIFS_PIFS 1 /* slot number setting to start transmission at PIFS interval */
+#define AIFS_DIFS 2 /* slot number setting to start transmission at DIFS interval - */
+                                       /* normal DCF access */
+#define AIFSN_BK  7
+#define AIFSN_BE  3
+#define AIFSN_VI  AIFS_PIFS
+#define AIFSN_VO  AIFS_PIFS
+#define TXOP_BK   0
+#define TXOP_BE   0
+#define TXOP_VI   3008
+#define TXOP_VO   1504
+#define DEFAULT_AC_SHORT_RETRY_LIMIT 7
+#define DEFAULT_AC_LONG_RETRY_LIMIT 4
+
+/* rxTimeout values */
+#define NO_RX_TIMEOUT 0
+
+typedef struct 
+{
+       INFO_ELE_HDR
+       uint8   ac;                     /* Access Category - The TX queue's access category */
+                                               /* (refer to AccessCategory_enum)*/
+    uint8   cwMin;             /* The contention window minimum size (in slots) for */
+                                               /* the access class.*/
+    uint16  cwMax;             /* The contention window maximum size (in slots) for */
+                                               /* the access class.*/
+       uint8   aifsn;          /* The AIF value (in slots) for the access class.*/
+       uint8   reserved;
+       uint16  txopLimit;      /* The TX Op Limit (in microseconds) for the access class.*/
+} ACXAcCfg_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_MEM_MAP
+       Type:   Configuration
+       Access: Read Only
+       Length: 72
+       Note:   Except for the numTxMemBlks, numRxMemBlks fields, this is
+                       used in MASTER mode only!!!
+       
+******************************************************************************/
+#define MEM_MAP_NUM_FIELDS     18
+
+typedef struct
+{
+    INFO_ELE_HDR
+    void *codeStart;                           
+    void *codeEnd;                  
+    void *wepDefaultKeyStart;
+    void *wepDefaultKeyEnd;         
+    void *staTableStart;
+    void *staTableEnd;              
+    void *packetTemplateStart;
+    void *packetTemplateEnd;        
+    void *queueMemoryStart;
+    void *queueMemoryEnd; 
+    void *packetMemoryPoolStart;
+    void *packetMemoryPoolEnd;
+    void *debugBuffer1Start;
+    void *debugBuffer1End;
+    void *debugBuffer2Start;
+    void *debugBuffer2End;
+    uint32 numTxMemBlks;       /* Number of blocks that FW allocated for TX packets.*/
+    uint32 numRxMemBlks;       /* Number of blocks that FW allocated for RX packets.   */
+} MemoryMap_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_AID
+       Type:   Configuration
+       Access: Write Only
+       Length: 2
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint16  Aid;       /* The Association ID to the WiLink. The WiLink uses this */
+                                       /* field to determine when the STA's AID bit is set in a */
+                                       /* received beacon and when a PS Poll frame should be */
+                                       /* transmitted to the AP. The host configures this information */
+                                       /* element after it has associated with an AP. This information */
+                                       /* element does not need to be set in Ad Hoc mode.*/
+    uint8  padding[2];  /* alignment to 32bits boundry   */
+} ACXAid_t;
+
+/******************************************************************************
+
+    Name:      ACX_CFG
+       Type:   Configuration
+       Access: Write Only
+       Length: 25
+       Note:   Not in use !!! 
+
+******************************************************************************/
+
+typedef struct ACXConfig_variableEntry_t
+{
+    uint8 dot11_ID;
+    uint8 num_supported;
+    uint8 dot11_Table;  /*cast and deref this as array of Sizeof-dot11_ID-Type.*/
+    uint8 padding;              /* alignment to 32bits boundry   */
+} ACXConfig_variableEntry_t;
+
+
+typedef struct ACXConfigOptionsStruct_t
+{
+    INFO_ELE_HDR
+    char   nvsVer[8];
+    uint32 endMemLoc;
+    uint16 VendorSpecificArea;
+    uint8  dot11CCAModeSupported;
+    uint8  dot11DiversitySupport;
+    uint8  dot11ShortPreambleOptionImplemented;
+    uint8  dot11PBCCOptionImplemented;
+    uint8  dot11ChanneAgilityPresent;
+    uint8  dot11PHYType;
+    uint8  dot11TempType;
+    uint8  numVarEntries;
+    uint8  padding[2];  /* alignment to 32bits boundry   */
+
+    ACXConfig_variableEntry_t vardata;
+        /**/
+        /*Begin variable portion of Config data...*/
+        /**/
+} ACXConfigOptionsStruct_t;
+
+/******************************************************************************
+
+    Name:      ACX_FW_REV
+       Type:   Configuration
+       Access: Write Only
+       Length: 24
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+       char FWVersion[20];             /* The WiLink firmware version, an ASCII string x.x.x.x.x */
+                                                       /* that uniquely identifies the current firmware. */
+                                                       /* The left most digit is incremented each time a */
+                                                       /* significant change is made to the firmware, such as */
+                                                       /* WLAN new project.*/
+                                                       /* The second and third digit is incremented when major enhancements*/
+                                                       /* are added or major fixes are made.*/
+                                                       /* The fourth digit is incremented for each SP release */
+                            /* and it indicants the costumer private brench */
+                                                       /* The fifth digit is incremented for each build.*/
+               
+    uint32 HardWareVersion; /* This 4 byte field specifies the WiLink hardware version. */
+                                                       /* bits 0  - 15: Reserved.*/
+                                                       /* bits 16 - 23: Version ID - The WiLink version ID  */
+                                                       /*              (1 = first spin, 2 = second spin, and so on).*/
+                                                       /* bits 24 - 31: Chip ID - The WiLink chip ID. */
+} ACXRevision_t;
+
+/******************************************************************************
+
+    Name:      ACX_FCS_ERROR_CNT
+       Type:   Operation
+       Access: Read Only
+       Length: 4
+       Note:   OBSOLETE (replaced by ACX_ERROR_CNT) !!! 
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 FCSErrorCount;
+} ACXFCSErrorCount_t;
+
+/******************************************************************************
+
+    Name:      ACX_ERROR_CNT
+       Type:   Operation
+       Access: Read Only
+       Length: 12
+       
+******************************************************************************/
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 PLCPErrorCount;  /* The number of PLCP errors since the last time this */
+                               /* information element was interrogated. This field is */
+                               /* automatically cleared when it is interrogated.*/
+       
+    uint32 FCSErrorCount;   /* The number of FCS errors since the last time this */
+                               /* information element was interrogated. This field is */
+                               /* automatically cleared when it is interrogated.*/
+       
+    uint32 validFrameCount; /* The number of MPDU\92s without PLCP header errors received*/
+                            /* since the last time this information element was interrogated. */
+                            /* This field is automatically cleared when it is interrogated.*/
+
+    uint32 seqNumMissCount; /* the number of missed sequence numbers in the squentially */
+                            /* values of frames seq numbers */
+
+} ACXErrorCounters_t;
+
+/******************************************************************************
+
+    Name:      ACX_MEDIUM_USAGE
+       Type:   Configuration
+       Access: Read Only
+       Length: 8
+
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 mediumUsage; /* report to the host the value of medium usage registers*/
+    uint32 period;             /* report to the host the value of medium period registers*/
+} ACXMediumUsage_t;
+
+/******************************************************************************
+
+    Name:      ACX_RX_CFG
+       Type:   Filtering Configuration
+       Access: Write Only
+       Length: 8
+       
+******************************************************************************/
+/*
+ * Rx configuration (filter) information element
+ * ---------------------------------------------
+ */
+/*
+       RX ConfigOptions Table
+       Bit             Definition
+       ===             ==========
+       31:14   Reserved
+       13              Copy RX Status - when set, write three receive status words to top of 
+                       rx'd MPDU.
+                       When clear, do not write three status words (added rev 1.5)
+       12              Reserved
+       11              RX Complete upon FCS error - when set, give rx complete interrupt for 
+                       FCS errors, after the rx filtering, e.g. unicast frames not to us with 
+                       FCS error will not generate an interrupt
+       10              SSID Filter Enable - When set, the WiLink discards all beacon, 
+                       probe request, and probe response frames with an SSID that does not 
+                       match the SSID specified by the host in the START/JOIN command. 
+                       When clear, the WiLink receives frames with any SSID.
+       9               Broadcast Filter Enable - When set, the WiLink discards all broadcast 
+                       frames. When clear, the WiLink receives all received broadcast frames.
+       8:6             Reserved
+       5               BSSID Filter Enable - When set, the WiLink discards any frames with a 
+                       BSSID that does not match the BSSID specified by the host. 
+                       When clear, the WiLink receives frames from any BSSID.
+       4               MAC Addr Filter - When set, the WiLink discards any frames with a 
+                       destination address that does not match the MAC address of the adaptor. 
+                       When clear, the WiLink receives frames destined to any MAC address.
+       3               Promiscuous - When set, the WiLink receives all valid frames 
+                       (i.e., all frames that pass the FCS check). 
+                       When clear, only frames that pass the other filters specified are received.
+       2               FCS - When set, the WiLink includes the FCS with the received frame. 
+                       When clear, the FCS is discarded.
+       1               PLCP header - When set, write all data from baseband to frame buffer 
+                       including PHY header.
+       0               Reserved - Always equal to 0.
+
+       RX FilterOptions Table
+       Bit             Definition
+       ===             ==========
+       31:12   Reserved - Always equal to 0.
+       11              Association - When set, the WiLink receives all association related frames 
+                       (association request/response, reassocation request/response, and 
+                       disassociation). When clear, these frames are discarded.
+       10              Auth/De auth - When set, the WiLink receives all authentication and 
+                       de-authentication frames. When clear, these frames are discarded.
+       9               Beacon - When set, the WiLink receives all beacon frames. When clear, 
+                       these frames are discarded.
+       8               Contention Free - When set, the WiLink receives all contention free frames. 
+                       When clear, these frames are discarded.
+       7               Control - When set, the WiLink receives all control frames. 
+                       When clear, these frames are discarded.
+       6               Data - When set, the WiLink receives all data frames.   
+                       When clear, these frames are discarded.
+       5               FCS Error - When set, the WiLink receives frames that have FCS errors. 
+                       When clear, these frames are discarded.
+       4               Management - When set, the WiLink receives all management frames. 
+                       When clear, these frames are discarded.
+       3               Probe Request - When set, the WiLink receives all probe request frames. 
+                       When clear, these frames are discarded.
+       2               Probe Response - When set, the WiLink receives all probe response frames. 
+                       When clear, these frames are discarded.
+       1               RTS/CTS/ACK - When set, the WiLink receives all RTS, CTS and ACK frames. 
+                       When clear, these frames are discarded.
+       0               Rsvd Type/Sub Type - When set, the WiLink receives all frames that 
+                       have reserved frame types and sub types as defined by the 802.11 
+                       specification. 
+                       When clear, these frames are discarded.
+*/
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32          ConfigOptions;     /* The configuration of the receiver in the WiLink. */
+                                                                       /* "RX ConfigOptions Table" describes the format of */
+                                                                       /* this field.*/
+    uint32          FilterOptions;     /* The types of frames that the WiLink can receive. */
+                                                                       /* "RX FilterOptions Table" describes the format of */
+                                                                       /* this field.*/
+} ACXRxConfig_t;
+
+/******************************************************************************
+
+    Name:      ACX_BEACON_FILTER_OPT
+       Desc:   This information element enables the host to activate beacon filtering. 
+            The filter can only be activated when the STA is in PS mode. 
+            When activated, either the host is not notified about beacons whose 
+            unicast TIM bit is not set, or these beacons are buffered first and 
+            the host is notified only after the buffer reaches a predetermined size.
+            The host should not activate the filter if it configures the firmware 
+            to listen to broadcasts (see the VBM Options field in the 
+            ACXPowerMgmtOptions information element). The filter only affects beacons, 
+            and not other MSDUs - the firmware notifies the host immediately about 
+            their arrival.
+       Type:   Filtering Configuration
+       Access: Write Only
+       Length: 2
+******************************************************************************/
+typedef struct  
+{
+    INFO_ELE_HDR
+    uint8   enable;                /* Indicates whether the filter is enabled. */
+                                   /* 1 - enabled, 0 - disabled. */
+    uint8   maxNumOfBeaconsStored; /* The number of beacons without the unicast TIM */
+                                   /* bit set that the firmware buffers before */
+                                   /* signaling the host about ready frames. */
+                                      /* When set to 0 and the filter is enabled, beacons */
+                                      /* without the unicast TIM bit set are dropped.*/
+    uint8  padding[2];             /* alignment to 32bits boundry   */
+} ACXBeaconFilterOptions_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_BEACON_FILTER_TABLE
+       Desc:   This information element configures beacon filtering handling for the
+               set of information elements. An information element in a beacon can be 
+                       set to be: ignored (never compared, and changes will not cause beacon 
+                       transfer), checked (compared, and transferred in case of a change), or 
+                       transferred (transferred to the host for each appearance or disappearance).
+               The table contains all information elements that are subject to monitoring 
+                       for host transfer. 
+                       All information elements that are not in the table should be ignored for 
+                       monitoring.
+               This functionality is only enabled when beacon filtering is enabled by 
+                       ACX_BEACON_FILTER_OPT.
+       Type:   Filtering Configuration
+       Access: Write Only
+       Length: 101
+       Notes:  the field measuring the value of received beacons for which the device 
+               wakes up the host in ACX_BEACON_FILTER_OPT does not affect 
+                       this information element.
+       
+******************************************************************************/
+
+/*
+    ACXBeaconFilterEntry (not 221)
+    Byte Offset     Size (Bytes)    Definition 
+       ===========     ============    ==========
+       0                               1               IE identifier
+    1               1               Treatment bit mask
+
+    ACXBeaconFilterEntry (221)
+    Byte Offset     Size (Bytes)    Definition 
+    ===========     ============    ==========
+    0               1               IE identifier
+    1               1               Treatment bit mask
+    2               3               OUI
+    5               1               Type
+    6               2               Version
+
+
+    Treatment bit mask - The information element handling:
+                         bit 0 - The information element is compared and transferred
+                                                        in case of change.
+                         bit 1 - The information element is transferred to the host 
+                                                        with each appearance or disappearance.
+                         Note that both bits can be set at the same time.
+*/
+#define        BEACON_FILTER_TABLE_MAX_IE_NUM                                          (32)
+#define BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM         (6)
+#define BEACON_FILTER_TABLE_IE_ENTRY_SIZE                                      (2)
+#define BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE      (6)
+#define BEACON_FILTER_TABLE_MAX_SIZE   ((BEACON_FILTER_TABLE_MAX_IE_NUM * BEACON_FILTER_TABLE_IE_ENTRY_SIZE) + \
+                                         (BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM * BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE))
+
+typedef struct ACXBeaconFilterIETableStruct {
+       INFO_ELE_HDR
+       uint8 NumberOfIEs;                                                      /* The number of IE's in the table*/
+                                                /* 0 - clears the table.*/
+
+    uint8 padding[3];  /* alignment to 32bits boundry   */
+       uint8 IETable[BEACON_FILTER_TABLE_MAX_SIZE];
+} ACXBeaconFilterIETable_t;
+
+/******************************************************************************
+
+    Name:      ACX_ARP_IP_FILTER 
+       Type:   Filtering Configuration
+       Access: Write Only
+       Length: 20
+
+******************************************************************************/
+
+typedef struct  
+{    
+    INFO_ELE_HDR
+       uint8     ipVersion;       /* The IP version of the IP address: 4 - IPv4, 6 - IPv6.*/
+    uint8     arpFilterEnable; /* 1 - ARP filtering is enabled. */
+                                  /* 0 - ARP filtering is disabled.*/
+    uint8     padding[2];      /* alignment to 32bits boundry   */
+    uint8     address[16];     /* The IP address used to filter ARP packets. ARP packets */
+                                  /* that do not match this address are dropped. */
+                                  /* When the IP Version is 4, the last 12 bytes of */
+                                  /* the address are ignored.*/
+       
+} ACXConfigureIP_t;
+
+
+/******************************************************************************
+
+  Name:            ACX_IBSS_FILTER
+  Type:            Filtering Configuration
+  Access:      Write Only
+  Length:   1
+  
+******************************************************************************/
+typedef struct  
+{
+    INFO_ELE_HDR
+    uint8   enable; /* if set (i.e. IBSS mode), forward beacons from the same SSID*/
+                       /* (also from different BSSID), with bigger TSF then the this of */
+                       /* the current BSS.*/
+    uint8   padding[3]; /* alignment to 32bits boundry   */
+} ACXIBSSFilterOptions_t;
+
+
+/******************************************************************************
+
+  Name:            ACX_SERVICE_PERIOD_TIMEOUT
+  Type:            Configuration
+  Access:      Write Only
+  Length:   1
+  
+******************************************************************************/
+typedef struct 
+{    
+       INFO_ELE_HDR
+       uint16 PsPollTimeout; /* the maximum time that the device will wait to receive */
+                             /* traffic from the AP after transmission of PS-poll.*/
+       
+    uint16 UpsdTimeout;          /* the maximum time that the device will wait to receive */
+                             /* traffic from the AP after transmission from UPSD enabled*/
+                             /* queue.*/
+} ACXRxTimeout_t;
+
+/******************************************************************************
+
+    Name:      ACX_TX_QUEUE_CFG
+       Type:   Configuration
+       Access: Write Only
+       Length: 8
+       
+******************************************************************************/
+typedef struct
+{
+    INFO_ELE_HDR
+       uint8   qID;                                            /* The TX queue ID number.*/
+    uint8   padding[3];                 /* alignment to 32bits boundry   */
+    uint16     numberOfBlockHighThreshold; /* The maximum memory blocks allowed in the */
+                                                                               /* queue.*/
+    uint16     numberOfBlockLowThreshold;      /* The minimum memory blocks that are */
+                                                                               /* guaranteed for this queue.*/
+} ACXTxQueueCfg_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_BSS_IN_PS
+       Type:   Configuration
+       Access: Write Only
+       Length: 1
+       Note:   for AP only (OBSOLETE???)
+       
+******************************************************************************/
+
+typedef enum
+{
+    AP_POWER_ACTIVE_MODE = FALSE,
+    AP_POWER_SAVE_MODE = TRUE
+} APPowerMgmtMode_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 APPowerMgmtMode_e;
+#else
+typedef APPowerMgmtMode_enum APPowerMgmtMode_e;
+#endif
+
+
+typedef struct
+{
+    INFO_ELE_HDR
+    APPowerMgmtMode_e BSSinPowerSave;
+    uint8             padding[3];  /* alignment to 32bits boundry   */
+} ACXBSSPowerSave_t;
+
+
+
+/******************************************************************************
+
+    Name:      ACX_STATISTICS
+       Type:   Statistics
+       Access: Write Only
+       Length: 
+       Note:   Debug API
+
+******************************************************************************/
+
+typedef struct
+{
+    uint32 TxInternalDescOverflow;
+} TxStatistics_t;
+
+
+typedef struct
+{
+    uint32 RxOutOfMem;
+    uint32 RxHdrOverflow;
+    uint32 RxHWStuck;
+    uint32 RxDroppedFrame;
+    uint32 RxFcsErr;
+    uint32 RxXfrHintTrig;
+    uint32 RxPathReset;
+    uint32 RxResetCounter;
+} RxStatistics_t;
+
+
+typedef struct
+{
+    uint32 RxDMARequested;
+    uint32 RxDMAErrors;
+    uint32 TxDMARequested;
+    uint32 TxDMAErrors;
+} DMAStatistics_t;
+
+
+typedef struct
+{
+    uint32 Cmd_Cmplt;         /* Host command complete */
+    uint32 FIQs;              /* fiqisr() */
+    uint32 RxHeaders;         /* (INT_STS_ND & INT_TRIG_RX_HEADER) */
+    uint32 RxCompletes;       /* (INT_STS_ND & INT_TRIG_RX_CMPLT) */
+    uint32 RxMemOverflow;     /* (INT_STS_ND & INT_TRIG_NO_RX_BUF) */
+    uint32 RxRdys;            /* (INT_STS_ND & INT_TRIG_S_RX_RDY) */
+    uint32 IRQs;              /* irqisr() */
+    uint32 ACXTxProcs;        /* (INT_STS_ND & INT_TRIG_TX_PROC) */
+    uint32 DecryptDone;       /* (INT_STS_ND & INT_TRIG_DECRYPT_DONE) */
+    uint32 DMA0Done;          /* (INT_STS_ND & INT_TRIG_DMA0) */
+    uint32 DMA1Done;          /* (INT_STS_ND & INT_TRIG_DMA1) */
+    uint32 ACXTxExchComplete; /* (INT_STS_ND & INT_TRIG_TX_EXC_CMPLT) */
+    uint32 ACXCommands;       /* (INT_STS_ND & INT_TRIG_COMMAND) */
+    uint32 ACXRxProcs;        /* (INT_STS_ND & INT_TRIG_RX_PROC) */
+    uint32 HwPMModeChanges;   /* (INT_STS_ND & INT_TRIG_PM_802) */
+    uint32 HostAcknowledges;  /* (INT_STS_ND & INT_TRIG_ACKNOWLEDGE) */
+    uint32 PCI_PM;            /* (INT_STS_ND & INT_TRIG_PM_PCI) */
+    uint32 ACMWakeups;        /* (INT_STS_ND & INT_TRIG_ACM_WAKEUP) */
+    uint32 LowRssi;           /* (INT_STS_ND & INT_TRIG_LOW_RSSI) */
+} IsrStatistics_t;
+
+
+typedef struct WepStatistics_t
+{
+    uint32 WepAddrKeyCount;      /* Count of WEP address keys configured*/
+    uint32 WepDefaultKeyCount;   /* Count of default keys configured*/
+    uint32 reserved;
+    uint32 WepKeyNotFound;       /* count of number of times that WEP key not found on lookup*/
+    uint32 WepDecryptFail;       /* count of number of times that WEP key decryption failed*/
+    uint32 WepPackets;           /* WEP Packets Decrypted*/
+    uint32 WepInterrupt;         /* WEP Decrypt Interrupts*/
+} WepStatistics_t;
+
+
+#define PWR_STAT_MAX_CONT_MISSED_BCNS_SPREAD 10
+typedef struct PwrStatistics_t
+{
+    uint32 PSEnterCnt;          /* Count the amount of enters into power save mode (both PD & ELP)*/
+    uint32 ELPEnterCnt;         /* Count the amount of enters into ELP mode.*/
+    uint32 MissingBcnsCnt;      /* Count the amount of missing beacon interrupts to the host.*/
+    uint32 WakeOnHostCnt;       /* Count the amount of wake on host-access times.*/
+    uint32 WakeOnTimerExpCnt;   /* Count the amount of wake on timer-expire.*/
+    uint32 TxWithPSCnt;         /* Count the number of packets that were transmitted with PS bit set*/
+    uint32 TxWithoutPSCnt;      /* Count the number of packets that were transmitted with PS bit clear*/
+    uint32 RcvdBeaconsCnt;      /* Count the number of received beacons.*/
+    uint32 PowerSaveOffCnt;     /* Count the number of entering into PowerOn (power save off).*/
+    uint16 EnablePSCnt;         /* Count the number of entries into power save mode.*/
+    uint16 DisablePSCnt;        /* Count the number of exits from power save (not including the PS_FAIL route.*/
+    uint32 FixTsfPSCnt;         /* Count the number of times the TSF counter was adjusted because of drift.*/
+    uint32 ContMissBcnsSpread[PWR_STAT_MAX_CONT_MISSED_BCNS_SPREAD];  /* Gives statistics about the spread continuous missed beacons.*/
+                                    /* The 16 LSB are dedicated for the PS mode.*/
+                                    /* The 16 MSB are dedicated for the PS mode.*/
+                                    /* ContMissBcnsSpread[0] - single missed beacon.*/
+                                    /* ContMissBcnsSpread[1] - two continuous missed beacons.*/
+                                    /* ContMissBcnsSpread[2] - three continuous missed beacons.*/
+                                    /* ...*/
+                                    /* ContMissBcnsSpread[9] - ten and more continuous missed beacons.*/
+    uint32 RcvdAwakeBeaconsCnt; /* Count the number of beacons in awake mode.*/
+} PwrStatistics_t;
+
+
+typedef struct MicStatistics_t
+{
+    uint32 MicRxPkts;
+    uint32 MicCalcFailure;
+} MicStatistics_t;
+
+
+typedef struct AesStatisticsStruct
+{
+    uint32 AesEncryptFail;
+    uint32 AesDecryptFail;
+    uint32 AesEncryptPackets;
+    uint32 AesDecryptPackets;
+    uint32 AesEncryptInterrupt;
+    uint32 AesDecryptInterrupt;
+} AesStatistics_t;
+
+
+typedef struct EventStatistics_t
+{
+    uint32 heartbeat;
+    uint32 calibration;
+    uint32 rxMismatch;
+    uint32 rxMemEmpty;
+    uint32 rxPool;
+    uint32 oomLate;
+    uint32 phyTransmitError;
+    uint32 txStuck;
+} EventStatistics_t;
+
+
+typedef struct PsPollUpsdStatistics_t
+{
+    uint32 psPollTimeOuts;
+    uint32 upsdTimeOuts;
+    uint32 upsdMaxSPTime;
+    uint32 upsdMaxAPturn;
+    uint32 psPollMaxAPturn;
+    uint32 psPollUtilization;
+    uint32 upsdUtilization;
+} PsPollUpsdStatistics_t;
+
+
+typedef struct
+{
+    uint32 RxPrepBeaconDrop;
+    uint32 DescrHostIntTrigRxData;
+    uint32 BeaconBufferThresHostIntTrigRxData;
+    uint32 MissedBeaconHostIntTrigRxData;
+    uint32 TxXfrHostIntTrigRxData;
+} RxPipeStatistics_t;
+
+
+typedef struct ACXStatisticsStruct
+{
+    INFO_ELE_HDR
+    TxStatistics_t   tx;
+    RxStatistics_t   rx;
+    DMAStatistics_t  dma;
+    IsrStatistics_t  isr;
+    WepStatistics_t  wep;
+    PwrStatistics_t  pwr;
+    AesStatistics_t  aes;
+    MicStatistics_t  mic;
+    EventStatistics_t event;
+#ifdef FW_RUNNING_AS_STA
+    PsPollUpsdStatistics_t ps;
+    RxPipeStatistics_t rxp;
+#endif
+} ACXStatistics_t;
+
+/******************************************************************************
+
+    Name:      ACX_ROAMING_STATISTICS_TBL
+       Desc:   This information element reads the current roaming triggers 
+               counters/metrics. 
+       Type:   Statistics
+       Access: Read Only
+       Length: 6
+
+******************************************************************************/
+typedef struct 
+{
+       INFO_ELE_HDR
+       uint32 MissedBeacons; /* The current number of consecutive lost beacons*/
+       uint8  snr;           /* The current average SNR in db*/
+    int8   rssi;          /* The current average RSSI*/
+    uint8  padding[2];    /* alignment to 32bits boundry   */
+}ACXRoamingStatisticsTable_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_FEATURE_CFG
+       Desc:   Provides expandability for future features
+       Type:   Configuration
+       Access: Write Only
+       Length: 8
+       
+******************************************************************************/
+
+/* bit defines for Option: */
+#define FEAT_PCI_CLK_RUN_ENABLE     0x00000002 /* Enable CLK_RUN on PCI bus */
+
+/* bit defines for dataflowOptions: */
+#define DF_ENCRYPTION_DISABLE       0x00000001 /* When set, enable encription in FW.*/
+                                                                                               /* when clear, disable encription. */
+#define DF_SNIFF_MODE_ENABLE        0x00000080 /* When set, enable decryption in FW.*/
+                                                                                               /* when clear, disable decription. */
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 Options;         /* Data flow options - refer to above definitions*/
+    uint32 dataflowOptions; /* Data flow options - refer to above definitions*/
+} ACXFeatureConfig_t;
+
+
+
+/******************************************************************************
+
+    Name:      ACX_TID_CFG
+       Type:   Configuration
+       Access: Write Only
+       Length: 16
+       
+******************************************************************************/
+typedef enum
+{
+       CHANNEL_TYPE_DCF = 0,   /* DC/LEGACY*/
+       CHANNEL_TYPE_EDCF = 1,  /* EDCA*/
+       CHANNEL_TYPE_HCCA = 2,  /* HCCA*/
+       MAX_CHANNEL_TYPE = CHANNEL_TYPE_HCCA
+} ChannelType_enum;
+
+typedef enum
+{
+    PS_SCHEME_LEGACY         = 0, /* Regular PS: simple sending of packets*/
+    PS_SCHEME_UPSD_TRIGGER   = 1, /* UPSD: sending a packet triggers a UPSD downstream*/
+    PS_SCHEME_LEGACY_PSPOLL  = 2, /* Legacy PSPOLL: a PSPOLL packet will be sent before */
+                                                                 /* every data packet transmission in this queue.*/
+    PS_SCHEME_SAPSD          = 3, /* Scheduled APSD mode.*/
+    MAX_PS_SCHEME = PS_SCHEME_SAPSD
+} PSScheme_enum;
+
+typedef enum
+{
+       ACK_POLICY_LEGACY = 0,   /* ACK immediate policy*/
+       ACK_POLICY_NO_ACK = 1,   /* no ACK policy*/
+       ACK_POLICY_BLOCK  = 2,   /* block ack policy*/
+       MAX_ACK_POLICY = ACK_POLICY_BLOCK
+} AckPolicy_enum;
+
+
+#ifdef HOST_COMPILE
+typedef uint8 ChannelType_e;
+typedef uint8 PSScheme_e;
+typedef uint8 AckPolicy_e;
+#else
+typedef ChannelType_enum ChannelType_e;
+typedef PSScheme_enum PSScheme_e;
+typedef AckPolicy_enum AckPolicy_e;
+#endif
+
+
+/* rxTimeout values */
+#define NO_RX_TIMEOUT 0
+
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8      queueID;        /* The TX queue ID number (0-7).*/
+    uint8      channelType;    /* Channel access type for the queue.*/
+                                                   /* Refer to ChannelType_enum.*/
+    uint8      tsid;           /* for EDCA - the AC Index (0-3, refer to*/
+                               /* AccessCategory_enum).*/
+                            /* For HCCA - HCCA Traffic Stream ID (TSID) of */
+                               /* the queue (8-15).*/
+    PSScheme_e  psScheme;   /* The power save scheme of the specified queue.*/
+                               /* Refer to PSScheme_enum.*/
+       AckPolicy_e ackPolicy;  /* The TX queue ACK policy. */
+    uint8  padding[3];      /* alignment to 32bits boundry   */
+    uint32 APSDConf[2];     /* Not supported in this version !!!*/
+}ACXTIDConfig_t;
+
+
+
+/******************************************************************************
+
+    Name:      ACX_LOW_RSSI
+       Desc:   This information element configures the Low and Regained RSSI interrupt 
+            indicators. Low RSSI calculates the average RSSI by giving higher weight 
+            to the old samples than to the current sample.
+            The triggering of the Regained RSSI Event cannot be configured and 
+            is always an "Edge" indication.
+            The RSSI is reset on JoinBSS - the filter history CurrentRSSI is reset.
+            The average RSSI is calculated as follows: 
+            averageRssi = ((int32)((100-roamingTriggerParameters.lowRssi.rssiFilterWeight) * averageRssi) + 
+                          (int32)(roamingTriggerParameters.lowRssi.rssiFilterWeight * (int8)rxInfo->rxLevel)) / 100;
+       Type:   Configuration
+       Access: Write Only
+       Length: 4
+       
+******************************************************************************/
+
+typedef enum
+{
+    LOW_RSSI_EVENT_LEVEL = 0,  /* The event is a "Level" indication which keeps */
+                                      /* triggering as long as the average RSSI is below*/
+                                                          /* the threshold.*/
+
+       LOW_RSSI_EVENT_EDGE = 1    /* The event is an "Edge" indication which triggers*/
+                                  /* only when the RSSI threshold is crossed from above.*/
+} LowRSSIEventType_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 LowRSSIEventType_e;
+#else
+typedef LowRSSIEventType_enum LowRSSIEventType_e;
+#endif
+
+typedef struct
+{
+    INFO_ELE_HDR
+       int8  rssiThreshold;                 /* The threshold (in dBm) below (or above */
+                                            /* after low rssi indication) which the */
+                                            /* firmware generates an interrupt to the host. */
+                                            /* This parameter is signed.*/
+
+    uint8 rssiFilterWeight;              /* The weight of the current RSSI sample, */
+                                            /* before adding the new sample, that is used */
+                                            /* to calculate the average RSSI.*/
+
+       uint8 rssiFilterDepth;               /* The number of Beacons/Probe response frames */
+                                         /* that will be received before issuing the */
+                                            /* Low or Regained RSSI event*/
+       
+       LowRSSIEventType_e LowRSSIEventType; /* This parameter configures how the Low RSSI */
+                                            /* Event is triggered. */
+                                            /* Refer to LowRSSIEventType_enum.*/
+} ACXLowRSSITriggerParameters_t;
+
+/******************************************************************************
+
+    Name:      ACX_AVERAGE_RSSI
+       Type:   Configuration
+       Access: Read Only
+       Length: 8
+       Note:   Not in use !!!
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    int8 avaregeRSSI; /* in DBM*/
+    uint8 padding[3];  /* alignment to 32bits boundry   */
+} ACXAvaregeRSSI_t;
+
+/******************************************************************************
+
+    Name:      ACX_NOISE_HIST
+       Desc:   Noise Histogram activation is done by special command from host which
+            is responsible to read the results using this IE.
+       Type:   Configuration
+       Access: Read Only
+       Length: 48 (NOISE_HIST_LEN=8)
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 counters[NOISE_HIST_LEN]; /* This array of eight 32 bit counters describes */
+                                        /* the histogram created by the FW noise */
+                                        /* histogram engine.*/
+
+    uint32 numOfLostCycles;          /* This field indicates the number of measurement */
+                                        /* cycles with failure because Tx was active.*/
+
+    uint32 numOfTxHwGenLostCycles;   /* This field indicates the number of measurement */
+                                        /* cycles with failure because Tx (FW Generated)*/
+                                        /* was active.*/
+
+    uint32 numOfRxLostCycles;        /* This field indicates the number of measurement */
+                                        /* cycles because the Rx CCA was active. */
+} NoiseHistResult_t;
+
+/******************************************************************************
+
+    Name:      ACX_PD_THRESHOLD
+       Type:   Configuration
+       Access: Write Only
+       Length: 4
+
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 pdThreshold; /* The packet detection threshold in the PHY.*/
+} ACXPacketDetection_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_DATA_PATH_PARAMS
+       Desc:   configure Data path and Tx complete parameters
+       Type:   Configuration
+       Access: Write Only
+       Length: 12
+
+******************************************************************************/
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint16             rxPacketRingChunkSize;  /* size in bytes of each buffer in a */
+                                           /* multi-buffers transfer mechanism (size of */
+                                           /* largest possible packet).*/
+
+    uint16             txPacketRingChunkSize;  /* size in bytes of each buffer in a */
+                                           /* multi-buffers transfer mechanism (size of */
+                                           /* largest possible packet).*/
+
+    uint8      rxPacketRingChunkNum;   /* number of buffers in a multi-buffers */
+                                           /* transfer mechanism (2 for double buffer).*/
+
+    uint8      txPacketRingChunkNum;   /* number of buffers in a multi-buffers */
+                                           /* transfer mechanism (2 for double buffer).*/
+
+    uint8       txCompleteThreshold;   /* maximum number of packets that can be */
+                                           /* gathered in the TX complete ring before */
+                                           /* interrupt is generated.*/
+
+    uint8       txCompleteRingDepth;   /* number of pending (waiting to be read by*/
+                                           /* the Host) TX complete entries in cyclic ring.*/
+
+       uint32          txCompleteTimeOut;              /* the maximum time in micro-seconds since a */
+                                           /* packet enters the TX complete ring until */
+                                           /* interrupt is generated.*/
+} ACXDataPathParams_t;
+
+/******************************************************************************
+
+    Name:      ACX_DATA_PATH_RESP_PARAMS
+       Desc:   Get data path specific parameters.
+       Type:   Configuration
+       Access: Read Only
+       Length: 28
+    Note:   The interrogation of this IE can be done only after the configuration
+                       of the corresponding Data Path parameters IE.
+
+******************************************************************************/
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint16             rxPacketRingChunkSize; /* actual size in bytes of each buffer */
+                                          /* in a multi-buffers transfer mechanism.*/
+
+    uint16             txPacketRingChunkSize; /* actual size in bytes of each buffer */
+                                          /* in a multi-buffers transfer mechanism.*/
+
+    uint8      rxPacketRingChunkNum;  /* actual number of buffers in a */
+                                          /* multi-buffers transfer mechanism. */
+
+    uint8      txPacketRingChunkNum;  /* actual number of buffers in a */
+                                          /* multi-buffers transfer mechanism.*/
+
+    uint8       padding[2];            /* alignment to 32bits boundry   */
+    uint32             rxPacketRingAddr;      /* base address of the the multi-buffer space.*/
+
+    uint32             txPacketRingAddr;      /* base address of the the multi-buffer space.*/
+
+    uint32             rxControlAddr;         /* address of Rx Control register.*/
+
+    uint32             txControlAddr;         /* address of Rx Control register.*/
+
+    uint32             txCompleteAddr;        /* base address of Tx Complete ring.*/
+} ACXDataPathParamsResp_t;
+
+/******************************************************************************
+
+    Name:      ACX_RATE_POLICY
+       Type:   Configuration
+       Access: Write Only
+       Length: 132
+
+******************************************************************************/
+typedef enum
+{
+       RATE_CLASS_54M,
+       RATE_CLASS_48M,
+       RATE_CLASS_36M,
+       RATE_CLASS_24M,
+       RATE_CLASS_22M,
+       RATE_CLASS_18M,
+       RATE_CLASS_12M,
+       RATE_CLASS_11M,
+       RATE_CLASS_9M,
+       RATE_CLASS_6M,
+       RATE_CLASS_5_5M,
+       RATE_CLASS_2M,
+       RATE_CLASS_1M,
+       RATE_CLASSES_SIZE 
+} RatePolicy_enum;
+#define MAX_RATE_POLICIES       (8)
+
+/* 
+aflag definition
+bit field              description
+=========              ===========
+7:3                            Reserved
+2                              Preamble Type - The type of the preamble to be used by the policy. 
+                0 - long preamble, 
+                               1 - short preamble. 
+1                              Preamble Override - Indicates if the preamble type should be used in TX. 
+0                              Truncate - If set, then attempts to send a frame stop when the total 
+                valid per-rate attempts have been exhausted; 
+                               otherwise transmissions will continue at the lowest available rate 
+                               until the appropriate one of the Short Retry Limit, Long Retry Limit, 
+                               dot11MaxTransmitMsduLifetime, or MAX TX Life Time (in ACXTIDConfig), 
+                               if supported and supplied, is exhausted.
+*/
+
+
+/* definition of single rate policy*/
+typedef struct 
+{
+    uint8               rateClass[RATE_CLASSES_SIZE]; /* The number of attempts for TX */
+                                                         /* for each rate class.  */
+                                                         /* RatePolicy_enum describes the */
+                                                                                                         /* indices for the table.*/
+
+    uint8               shortRetryLimit;              /* The dot11ShortRetryLimit used */
+                                                      /* for Tx retries.*/
+
+    uint8               longRetryLimit;               /* The dot11LongRetryLimit used */
+                                                         /* for Tx retries.  */
+       
+    uint8               aflags;                       /* Flags controlling attributes */
+                                                         /* of the transmission. */
+                                                         /* see above description for the */
+                                                         /* structure of this field.*/
+}txAttrClass_t;
+     
+
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint32        numOfClasses;                    /* The number of transmission rate */
+                                                      /* fallback policy classes.*/
+
+    txAttrClass_t rateClasses[MAX_RATE_POLICIES];  /* Rate Policies table*/
+}ACXTxAttrClasses_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_FW_GEN_FRAME_RATES
+       Desc:   FW generated (template) frames rates and modulation. 
+       Type:   Configuration
+       Access: Write Only
+       Length: 4
+       
+******************************************************************************/
+
+/*
+Values for the Frame rate configuration
+Value  Transmit Rate
+=====   =============
+0x0A   1 Mbps
+0x14   2 Mbps
+0x37   5.5 Mbps
+0x6E   11 Mbps (CCK)
+0xDC   22 Mbps
+0x0B   6 Mbps
+0x0F   9 Mbps
+0x0A   12 Mbps
+0x0E   18 Mbps
+0x09   24 Mbps
+0x0D   36 Mbps
+0x08   48 Mbps
+0x0C   54 Mbps
+*/
+
+/*
+Values for the modulation configuration
+Value  Modulation
+=====   ==========
+0          CCK_LONG
+1       CCK_SHORT
+128        PBCC_LONG
+129        PBCC_SHORT
+64         OFDM
+*/
+
+typedef struct
+{
+       INFO_ELE_HDR
+       uint8   txCtrlFrmRate; /* This field indicates the rate at which the WiLink */
+                              /* transmits RTS, CTS, PS Poll and QoS-Null frames. */
+                              /* Valid values are listed in the above table.*/
+
+    uint8      txCtrlFrmMod;  /* Modultion type for the above template frame. */
+                           /* Valid values are listed in the above table.*/
+
+    uint8      txMgmtFrmRate; /* This field indicates the rate at which the WiLink */
+                              /* transmits beacon, probe response  frames. */
+                              /* If the host is configuring the WiLink as an AP or Ad Hoc */
+                              /* STA, you must configure the beacon template before the */
+                              /* START/JOIN command is issued. */
+                              /* Valid values are listed in the above table.*/
+
+    uint8      txMgmtFrmMod;  /* Modultion type for the above template frame.*/
+                           /* Valid values are listed in the above table.*/
+}ACXFwGeneratedFrameRates_t;
+
+/******************************************************************************
+
+    Name:      ACX_CTS_PROTECTION
+       Type:   Configuration
+       Access: Write Only
+       Length: 1
+       
+******************************************************************************/
+
+typedef struct 
+{
+       INFO_ELE_HDR
+       uint8   ctsProtectMode; /* This field is a flag enabling or disabling the*/
+                                   /* CTS-to-self protection mechanism:*/
+                                   /* 0 - disable, 1 - enable*/
+    uint8  padding[3];          /* alignment to 32bits boundry   */
+}ACXCtsProtection_t;
+
+/******************************************************************************
+
+    Name:      ACX_SLEEP_AUTH
+       Desc:   configuration of sleep authorization level
+       Type:   System Configuration
+       Access: Write Only
+       Length: 1
+
+******************************************************************************/
+
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint8   sleepAuth; /* The sleep level authorization of the device. */
+                          /* 0 - Always active*/
+                          /* 1 - Power down mode: light / fast sleep*/
+                       /* 2 - ELP mode: Deep / Max sleep*/
+               
+    uint8  padding[3]; /* alignment to 32bits boundry   */
+}ACXSleepAuth_t;
+
+/******************************************************************************
+
+    Name:      ACX_PREAMBLE_TYPE
+       Type:   Configuration
+       Access: Write Only
+       Length: 1
+       
+******************************************************************************/
+
+typedef enum
+{
+    ACX_PREAMBLE_LONG = 0,
+    ACX_PREAMBLE_SHORT = 1,
+    ACX_DEFAULT_PREAMBLE = ACX_PREAMBLE_LONG
+} Preamble_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 Preamble_e;
+#else
+typedef Preamble_enum Preamble_e;
+#endif
+
+
+typedef struct
+{
+    INFO_ELE_HDR
+    Preamble_e preamble; /* When set, the WiLink transmits beacon, probe response, */
+                            /* RTS and PS Poll frames with a short preamble. */
+                            /* When clear, the WiLink transmits the frame with a long */
+                            /* preamble.*/
+    uint8  padding[3];  /* alignment to 32bits boundry   */
+} ACXPreamble_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_CCA_THRESHOLD
+       Type:   Configuration
+       Access: Write Only
+       Length: 2
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint16 rxCCAThreshold; /* The Rx Clear Channel Assessment threshold in the PHY*/
+                              /* (the energy threshold).*/
+    Bool_e txEnergyDetection; 
+    uint8  padding;
+} ACXEnergyDetection_t;
+         
+
+/******************************************************************************
+
+    Name:      ACX_EVENT_MBOX_MASK
+       Type:   Operation
+       Access: Write Only
+       Length: 8
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 lowEventMask;   /* Indicates which events are masked and which are not*/
+                              /* Refer to EventMBoxId_enum in public_event_mbox.h.*/
+       
+    uint32 highEventMask;  /* Not in use (should always be set to 0xFFFFFFFF).*/
+} ACXEventMboxMask_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_WR_TBTT_AND_DTIM
+       Type:   Configuration
+       Access: Write Only
+       Length: 3
+       Note:   STA Only
+       
+******************************************************************************/
+#ifdef FW_RUNNING_AS_STA
+typedef struct
+{
+    INFO_ELE_HDR
+    uint16 tbtt;         /* Time in TUs between two consecutive Beacons*/
+    uint8  dtimInterval; /* DTIM interval: */
+                            /* For BSS: Number of TBTTs in a DTIM period (range: 1-10).*/
+                            /* For IBSS: value shall be set to 1.*/
+    uint8  padding;      /* alignment to 32bits boundry   */
+} ACXDtimPeriodCfg_t;
+#endif
+
+/******************************************************************************
+
+    Name:      ACX_DTIM_PERIOD
+       Type:   Configuration
+       Access: Write Only
+       Length: 2
+       Note:   for AP only !!!
+       
+******************************************************************************/
+#ifdef FW_RUNNING_AS_AP
+typedef struct
+{
+    uint16 dtimPeriod;
+    uint8  padding[2];  /* alignment to 32bits boundry   */
+} ACXDtimPeriodCfg_t;
+#endif
+
+
+/******************************************************************************
+
+    Name:      ACX_ACI_OPTION_CFG
+       Type:   Configuration
+       Access: Write Only
+       Length: 6
+       Note:   OBSOLETE !!! (for 1251) 
+
+******************************************************************************/
+
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint8 ACIMode;
+    uint8 inputCCA;
+    uint8 txCCA;
+    uint8 qualifiedCCA;
+    uint8 stompForRx;
+    uint8 stompForTx;
+    uint8 padding[2];  /* alignment to 32bits boundry   */
+} ACXConfigACI_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_PM_CFG
+       Desc:   Configure the power managment option.
+       Type:   Configuration
+       Access: Write Only
+       Length: 16
+       Note:   ??? (To Be Documented)
+
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    Bool32 ELPEnable;
+    Bool32 WakeOnGPIOenable;
+    uint32 BBWakeUpTime;
+    uint32 PLLlockTime;
+} ACXConfigPM_t;
+
+/******************************************************************************
+
+    Name:      ACX_CONN_MONIT_PARAMS
+       Desc:   This information element configures the SYNCHRONIZATION_TIMEOUT 
+               interrupt indicator. It configures the number of missed Beacons 
+                       before issuing the SYNCHRONIZATION_TIMEOUT event.
+       Type:   Configuration
+       Access: Write Only
+       Length: 8
+
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 TSFMissedThreshold; /* The number of consecutive beacons that can be */
+                                  /* lost before the WiLink raises the */
+                                  /* SYNCHRONIZATION_TIMEOUT event.*/
+
+    uint32 BSSLossTimeout;     /* The delay (in time units) between the time at */
+                                  /* which the device issues the SYNCHRONIZATION_TIMEOUT*/
+                                  /* event until, if no probe response or beacon is */
+                                  /* received a BSS_LOSS event is issued.*/
+} AcxConnectionMonitorOptions;
+
+/******************************************************************************
+
+    Name:      ACX_CONS_TX_FAILURE
+       Desc:   This information element configures the number of frames transmission
+               failures before issuing the "Max Tx Retry" event. The counter is 
+                       incremented only for unicast frames or frames that require Ack 
+       Type:   Configuration
+       Access: Write Only
+    Length: 1
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8 maxTxRetry; /* the number of frames transmission failures before */
+                      /* issuing the "Max Tx Retry" event*/
+    uint8  padding[3];  /* alignment to 32bits boundry   */
+} ACXConsTxFailureTriggerParameters_t;
+
+/******************************************************************************
+
+    Name:      ACX_LOW_SNR
+       Desc:   This information element configures the Low/Regained SNR interrupt 
+               indicator.
+       Type:   Configuration
+       Access: Write Only
+       Length: 4
+       Note:   To Be Documented
+
+******************************************************************************/
+
+typedef enum
+{
+    LOW_SNR_EVENT_LEVEL = 0,
+    LOW_SNR_EVENT_EDGE = 1
+} LowSNREventType_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 LowSNREventType_e;
+#else
+typedef LowSNREventType_enum LowSNREventType_e;
+#endif
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8        SNRThreshold;
+    uint8        SNRFilterWeight;
+    uint8  SNRFilterDepth;
+    LowSNREventType_e LowSNREventType;
+} ACXLowSNRTriggerParameters_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_BCN_DTIM_OPTIONS
+       Type:   Configuration
+       Access: Write Only
+       Length: 5
+       
+******************************************************************************/
+
+typedef struct 
+{    
+       INFO_ELE_HDR
+    uint16 beaconRxTimeOut;
+    uint16 broadcastTimeOut;
+    uint8  rxBroadcastInPS;  /* if set, enables receive of broadcast packets */
+                                /* in Power-Save mode.*/
+       uint8  consecutivePsPollDeliveryFailureThr;                     /* Consecutive PS Poll Fail before updating the Driver */
+    uint8  padding[2];       /* alignment to 32bits boundry   */
+} ACXBeaconAndBroadcastOptions_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_SG_ENABLE
+       Desc:   This command instructs the WiLink to set the Soft Gemini (BT co-existence)
+               state to either enable/disable or sense mode. 
+       Type:   Configuration
+       Access: Write Only
+       Length: 1
+       
+******************************************************************************/
+typedef struct
+{
+    INFO_ELE_HDR
+       uint8   Enable; /* specifies whether the SG feature will be enabled (0), */
+                       /* disabled(1), in a "sense not active" (3) mode in which */
+                       /* upon seeing BT activity a host interrupt will be sent or*/
+                       /* in a "sense active" (4) mode which specifies the device */
+                       /* should switch on the SG in response to the driver receiving */
+                       /* the host interrupt. */
+    uint8  padding[3];  /* alignment to 32bits boundry   */
+} ACXBluetoothWlanCoEnableStruct;
+
+/******************************************************************************
+
+    Name:      ACX_ANTENNA_DIVERSITY_CFG
+       Desc:   Set antenna diversity parameters
+       Type:   Configuration
+       Access: Write Only
+       Length: 7
+       Note:   ??? (To Be Documented)
+       
+******************************************************************************/
+
+/* Antenna Diversity Tx definitions*/
+typedef enum
+{
+    DIVS_TX_START_ANT1       = 0,     /* Start TX antenna 1.*/
+    DIVS_TX_START_ANT2       = 1,     /* Start TX antenna 2.*/
+    DIVS_TX_START_SWITCH     = 2     /* Switch starting Tx Antenna.    */
+} TxAntDivsStartOption_enum;
+
+
+/* Antenna Diversity Rx definitions*/
+typedef enum
+{
+    DIVS_RX_START_ANT1       = 0,     /* Start RX antenna 1.*/
+    DIVS_RX_START_ANT2       = 1,     /* Start RX antenna 2.*/
+    DIVS_RX_START_LAST_RX    = 2,     /* Start RX Last RX Antenna mode.*/
+    DIVS_RX_START_SWITCH     = 3     /* Switch starting Rx Antenna.    */
+} RxAntDivsStartOption_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 RxAntDivsStartOption_e;
+typedef uint8 TxAntDivsStartOption_e;
+#else
+typedef RxAntDivsStartOption_enum RxAntDivsStartOption_e;
+typedef TxAntDivsStartOption_enum TxAntDivsStartOption_e;
+#endif
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8                   enableRxDiversity;
+    RxAntDivsStartOption_e  rxSelectedAntenna;
+    uint8                   enableTxDiversity;
+    TxAntDivsStartOption_e  txSelectedAntenna;
+    uint8                   rxAntNum;
+    uint8                   txAntNum;
+    uint8                   rxTxSharedAnts;
+    uint8                   padding;  /* alignment to 32bits boundry   */
+} AcxSetAntennaDiversityOptions_t;
+
+
+
+/******************************************************************************
+
+    Name:      ACX_SG_CFG
+       Desc:   This command instructs the WiLink to set the Soft Gemini (BT co-existence) 
+               parameters to the desired values. 
+       Type:   Configuration
+       Access: Write Only
+       Length: 1
+       
+******************************************************************************/
+typedef struct
+
+{
+    INFO_ELE_HDR
+       RateIndex_e wlanRxMinConvertedRateToRespectBtHp; /* Range: 802.11 b,g Rates*/
+                                                                                                    /* The minimum rate of a received WLAN packet in the STA, */ 
+                                                                                                    /* during protective mode, of which a new BT-HP request */ 
+                                                                                                    /* during this Rx will always be respected and gain the antenna*/  
+
+       uint16 btHpMaxTime;                         /* the maximum length of time the BT HP */
+                                                   /* will be respected (Limitation on BT */
+                                                   /* HP time, afterwards will switch to LP).*/
+
+    uint16 wlanHpMaxTime;                       /* the maximum length of time the WLAN HP*/
+                                                   /* will be respected (Limitation on WLAN */
+                                                   /* HP time, afterwards will switch to LP).*/
+
+    uint16 senseDisableTimer;                   /* The time after the last BT activity */
+                                                   /* when the sense mode will return the */
+                                                   /* SG state to "SENSE_INACTIVE"*/
+
+    uint16 protectiveRxTimeBeforeBtHp;          /* The time before the next BT HP */
+                                                   /* instance in which to send the fast */
+                                                   /* CTS.*/
+
+    uint16 protectiveTxTimeBeforeBtHp;          /* The time before the next BT HP */
+                                                   /* instance in which to suspend the */
+                                                   /* WLAN TX*/
+       
+    uint16 protectiveRxTimeBeforeBtHpFastAp;    /* range: 10-20000    default: 1500*/
+    uint16 protectiveTxTimeBeforeBtHpFastAp;    /* range: 10-20000    default: 3000*/
+    uint16 protectiveWlanCycleTimeForFastAp;    /* range: 2000-65535  default: 8700*/
+    uint16 btAntiStarvationPeriod;                             /* range: 0 - 15000 (Msec) default: 1000 */
+    uint16 timeoutNextBtLpPacket;                              /* range 400-10000(Usec) default: 3000 */
+       
+       uint16 wakeUpTimeBeforeBeacon;              /* The default value is worse case of */
+                                                                                               /* BT DH5 traffic                     */
+       uint16 hpdmMaxGuardTime;                                        /* range: 0-50000(Usec) default: 1050*/
+
+       uint16 timeoutNextWlanPacket;                           /* Range: 100-50000(Usec) default:2550*/
+                                                                                               /* This timeout purpose is to prevent both BT & WLAN */
+                                                                                               /* antenna starvation. */
+
+    uint8  sgAntennaType;                       /* "0" - shared antenna ; */
+                                                   /* "1" - dual antenna.*/
+
+    uint8  signalingType;                       /* "0" - TI legacy signaling ; */
+                                                   /* "1" - Palau signaling       */
+
+    uint8  afhLeverageOn;                       /* How to receive information regarding */
+                                                   /* the AFH status of the BT. */
+                                                   /* "0" - no AFH;*/
+                                                   /* "1" - from dedicated GPIO.*/
+                                                   /* "2" - AFH on (from host).*/
+       
+    uint8  numberQuietCycle;                    /* the number of cycles during which no*/
+                                                   /* TX will be sent after 1 cycle of RX */
+                                                   /* transaction in protective mode*/
+
+    uint8  maxNumCts;                           /* The maximum number of CTSs that will*/
+                                                   /* be sent for receiving RX packet in */
+                                                   /* protective mode*/
+
+    uint8  numberOfWlanPackets;                 /* The number of WLAN packets */
+                                                   /* transferred in common mode before */
+                                                /* switching to the BT.*/
+
+    uint8  numberOfBtPackets;                   /* The number of BT packets transferred*/
+                                                   /* in common mode before switching to */
+                                                   /* the WLAN.*/
+                       
+    uint8  numberOfMissedRxForAvalancheTrigger; /* range: 1-255  default: 5*/
+    uint8  wlanElpHpSupport;                    /* range: 0-1    default: 1*/
+
+       uint8  btAntiStarvationNumberOfCyclesWithinThePeriod; /* range: 0 - 15  default: 4 */
+       
+    uint8  ackModeDuringBtLpInDualAnt;                  /* 0 or 1  */
+
+       
+    Bool_e allowPaSdToggleDuringBtActivityEnable; /* Allow PA_SD assertion/de-assertion */ 
+                                                  /* during enabled BT activity         */
+
+       Bool_e sgAutoModeNoCts;                                     /* Enable/Disable SG2.0 in auto mode: */
+                                                                                               /* Support Both Active & P.S modes */
+       
+       uint8  numOfBtHpRespectedReq;                           /*range: 0 - 20  default: 1*/   
+    
+} ACXBluetoothWlanCoParamsStruct;
+  
+
+
+/******************************************************************************
+
+    Name:      ACX_TSF_INFO
+       Type:   Operation
+       Access: Read Only
+       Length: 20
+
+******************************************************************************/
+typedef struct ACX_fwTSFInformation
+{
+    INFO_ELE_HDR
+    uint32 CurrentTSFHigh;
+    uint32 CurrentTSFLow;
+    uint32 lastTBTTHigh;
+    uint32 lastTBTTLow;
+    uint8 LastDTIMCount;
+    uint8  padding[3];  /* alignment to 32bits boundry   */
+}ACX_fwTSFInformation_t;
+
+
+
+/******************************************************************************
+
+    Name:      ACX_GPIO_CFG
+       Type:   Board Configuration
+       Access: Write Only
+       Length: 2
+       Note:   Not in use !!!
+       
+******************************************************************************/
+
+#ifndef _WINDOWS
+#define GPIO_DIR_OUTPUT    0
+#define GPIO_DIR_INPUT     1
+#endif /* ifndef _WINDOWS */
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8   number;
+    uint8   direction;
+    uint8   padding[2];  /* alignment to 32bits boundry   */
+} ACXConfigGPIO_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_GPIO_SET
+       Type:   Board Configuration
+       Access: Write Only
+       Length: 2
+       Note:   Not in use !!!
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8   number;
+    uint8   value;
+    uint8   padding[2];  /* alignment to 32bits boundry   */
+} ACXSetGPIO_t;
+
+/******************************************************************************
+
+    Name:      ACX_MISC_CFG
+       Type:   Board Configuration
+       Access: Read/Write
+       Length: 8
+       Note:   GPIO_OUT bits to be used for LEDs are defined in the
+                       NVS Miscellaneous table.  An API to NVS is used by the
+                       LED-Init routine to fill this table with the LED bit values.
+                       Not in use !!!
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint16 txActivityLed;      /* GPIO_OUT bit for this LED*/
+    uint16 fwInitLed;          /* GPIO_OUT bit for this LED*/
+    uint16 diagnosticLed;      /* GPIO_OUT bit for this LED*/
+    uint16 faaRadioOffGpio;    /* GPIO_OUT bit for the FAA Radio Off feature*/
+} ACXMisc_t;
+
+
+/******************************************************************************
+
+Name:  ACX_BET_ENABLE
+Desc:   Enable or Disable the Beacon Early Termination module. In addition initialized the
+        Max Dropped beacons parameter
+Type:  Configuration
+Access:        Write 
+Length: 6
+Note:  
+******************************************************************************/
+typedef struct
+
+{
+    INFO_ELE_HDR
+    uint8           Enable;                                     /* specifies if beacon early termination procedure is enabled or disabled: 0 \96 disabled, 1 \96 enabled */
+    uint8           MaximumConsecutiveET;           /* specifies the maximum number of consecutive beacons that may be early terminated. After this number is reached 
+                                                       at least one full beacon must be correctly received in FW before beacon ET resumes.  Legal range: 0 \96 255 */
+    uint8           padding[2];
+}ACXBet_Enable_t;
+
+
+/******************************************************************************
+
+    Name:      DOT11_STATION_ID
+       Desc:   This information element specifies the MAC Address assigned to the STA. 
+               This default value is the permanent MAC address that is stored in the 
+                       adaptor's non volatile memory. The host can change the MAC address; 
+                       however, the WiLink always reverts to the default value after power up 
+                       or reset.
+       Type:   Configuration
+       Access: Read / Write 
+       Length: 6
+       Note:   The byte order of the MAC address must be reversed in this field. 
+               For example, if the MAC address is 00 7E 99 11 22 33, this field must 
+                       read 33 22 11 99 7E 00.
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint8 dot11StationID[6]; /* The MAC address for the STA.*/
+    uint8 padding[2];  /* alignment to 32bits boundry   */
+} dot11StationIDStruct;
+
+
+/******************************************************************************
+
+    Name:      DOT11_RX_MSDU_LIFE_TIME
+       Type:   Operation
+       Access: Write Only
+       Length: 4
+       
+******************************************************************************/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 RxMsduLifeTime; /* The maximum amount of time, in TU, that the WiLink */
+                              /* should attempt to collect fragments of an MSDU before */
+                              /* discarding them. */
+                           /* The default value for this field is 512.*/
+} dot11RxMsduLifeTime_t;
+
+
+/******************************************************************************
+
+    Name:      DOT11_CUR_TX_PWR
+       Desc:   This IE indicates the maximum TxPower in Dbm/10 currently being used to transmit data.
+       Type:   Operation
+       Access: Write Only
+       Length: 1
+       
+******************************************************************************/
+
+typedef struct
+{ 
+    INFO_ELE_HDR
+    uint8 dot11CurrentTxPower; /* the max Power in Dbm/10 to be used to transmit data.*/
+    uint8  padding[3];  /* alignment to 32bits boundry   */
+} dot11CurrentTxPowerStruct ;
+
+
+
+/******************************************************************************
+
+    Name:      DOT11_DEFAULT_KEY
+       Desc:   This information element indicates the default key to use to encrypt
+               transmit frames.
+       Type:   Configuration
+       Access: Write Only
+       Length: 1
+       
+******************************************************************************/
+
+typedef enum
+{
+    DEFAULT_KEY_0 = 0,
+    DEFAULT_KEY_1,
+    DEFAULT_KEY_2,
+    DEFAULT_KEY_3,
+    MAX_NUM_WEP_DEFAULT_KEY
+} DefaultKey_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 DefaultKey_e;
+#else
+typedef DefaultKey_enum DefaultKey_e;
+#endif
+
+typedef struct
+{
+    INFO_ELE_HDR
+    DefaultKey_e DefaultKeyId; /*  refer to DefaultKey_enum*/
+    uint8  padding[3];  /* alignment to 32bits boundry   */
+} dot11WEPDefaultKeyId_t;
+
+
+/******************************************************************************
+
+    Name:      DOT11_RX_DOT11_MODE
+       Desc:   This IE indicates the current Rx Mode used by DSSS PHY.
+       Type:   Configuration
+       Access: Write Only
+    Length: 4
+       
+******************************************************************************/
+/*
+Possible values for Rx DOT11 Mode are the following:
+Value  Description
+=====   ===========
+3          11g - processing of both a and b packet formats is enabled
+2          11b - processing of b packet format is enabled
+1          11a - processing of a packet format is enabled
+0          undefined
+*/
+
+typedef struct
+{
+    INFO_ELE_HDR
+    uint32 dot11RxDot11Mode; /* refer to above table*/
+} dot11RxDot11ModeStruct;
+
+
+/******************************************************************************
+
+    Name:      DOT11_RTS_THRESHOLD 
+       Type:   Configuration
+       Access: Write Only
+       Length: 2
+
+******************************************************************************/
+
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint16  RTSThreshold; /* The number of octets in an MPDU, below which an */
+                             /* RTS/CTS handshake is not performed.*/
+       
+    uint8  padding[2];  /* alignment to 32bits boundry   */
+}dot11RTSThreshold_t;
+
+
+/******************************************************************************
+
+       Name:   DOT11_GROUP_ADDRESS_TBL
+       Desc:   The variable lengths of MAC addresses that are define as listening for
+               multicast. The field Number of groups identifies how many MAC Addresses 
+                       are relevant in that information element.
+       Type:   Configuration
+       Access: Write Only
+       Length: up to 50 bytes
+
+******************************************************************************/
+#define ADDRESS_GROUP_MAX              (8)
+#define ADDRESS_GROUP_MAX_LEN  (6 * ADDRESS_GROUP_MAX)
+typedef struct 
+{
+    INFO_ELE_HDR
+       uint8   fltrState;                               /* 1 - multicast filtering is enabled. */
+                                                    /* 0 - multicast filtering is disabled.*/
+
+    uint8   numOfGroups;                         /* number of relevant multicast */
+                                                    /* addresses.*/
+
+    uint8   padding[2];  /* alignment to 32bits boundary   */
+    uint8   dataLocation[ADDRESS_GROUP_MAX_LEN]; /* table of MAC addresses.*/
+}dot11MulticastGroupAddrStart_t;
+
+/******************************************************************************
+
+   ACX_CONFIG_PS_WMM (Patch for Wi-Fi Bug)
+
+******************************************************************************/
+
+typedef struct 
+{    
+    INFO_ELE_HDR
+    Bool32      ConfigPsOnWmmMode;  /* TRUE  - Configure PS to work on WMM mode - do not send the NULL/PS_POLL 
+                                               packets even if TIM is set.
+                                       FALSE - Configure PS to work on Non-WMM mode - work according to the 
+                                               standard. */
+} IEConfigPsWmm_t;
+
+/******************************************************************************
+
+    ACX_SET_RX_DATA_FILTER  
+
+******************************************************************************/
+/* data filter action */
+
+#ifdef HOST_COMPILE
+
+#define FILTER_DROP  0
+#define FILTER_SIGNAL  1
+#define FILTER_FW_HANDLE  2
+
+#else
+
+typedef enum {
+       FILTER_DROP = 0,
+       FILTER_SIGNAL  ,
+    FILTER_FW_HANDLE, 
+       FILTER_MAX  = 0xFF
+}filter_enum;
+
+#endif
+
+#ifdef HOST_COMPILE
+typedef uint8 filter_e;
+#else
+typedef filter_enum filter_e;
+#endif
+
+/* data filter command */
+#define REMOVE_FILTER   0
+#define ADD_FILTER      1
+
+/* limitation */
+#define MAX_DATA_FILTERS 4
+#define MAX_DATA_FILTER_SIZE 90
+
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint8                command; // 0-remove, 1-add
+    uint8                index;
+    filter_e             action;
+    uint8                numOfFields;
+    uint8                FPTable; //filter fields starts here. unknown size.
+} DataFilterConfig_t;
+
+/******************************************************************************
+
+    ACX_ENABLE_RX_DATA_FILTER  
+
+******************************************************************************/
+
+typedef struct  
+{
+    INFO_ELE_HDR
+    uint8       enable;
+    filter_e    action;
+} DataFilterDefault_t;
+
+
+/******************************************************************************
+
+    ACX_GET_DATA_FILTER_STATISTICS  
+
+******************************************************************************/
+
+typedef struct 
+{
+    INFO_ELE_HDR
+    uint32  unmatchedPacketsCount;
+    uint32  matchedPacketsCount[MAX_DATA_FILTERS];
+} ACXDataFilteringStatistics_t;
+
+
+/******************************************************************************
+
+Name:  ACX_POWER_LEVEL_TABLE
+Desc:   Retrieve Maximum Dbm per power level and sub-band.
+Type:  Configuration
+Access:        Read Only
+Length: 20 
+
+******************************************************************************/
+
+typedef struct
+{
+       INFO_ELE_HDR
+
+       uint8 txPowerTable[NUM_OF_SUB_BANDS][NUM_OF_POWER_LEVEL]; /* Maximun Dbm in Dbm/10 units */
+} PowerLevelTable_t;
+
+
+/******************************************************************************
+
+Name:  ACX_PWR_CONSUMPTION_STATISTICS
+Desc:   Retrieve time statistics of the different power states.
+Type:  Configuration
+Access:        Read Only
+Length: 20 
+
+******************************************************************************/
+
+typedef struct
+{
+       INFO_ELE_HDR
+    uint32 activeTimeCnt_Low;
+    uint32 activeTimeCnt_Hi;
+    uint32 powerDownTimeCnt_Low;
+    uint32 powerDownTimeCnt_Hi;
+    uint32 elpTimeCnt_Low;
+    uint32 elpTimeCnt_Hi;
+}ACXPowerConsumptionTimeStat_t;
+
+#endif // PUBLIC_INFOELE_H
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_radio.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_radio.h
new file mode 100644 (file)
index 0000000..94f4afc
--- /dev/null
@@ -0,0 +1,173 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 public_radio.h
+ *  \brief Contains information element defines/structures used by the TNETxxxx and host and Radio Module.
+ *
+ */
+
+/*
+=======================================================================================================================
+                      R E V I S I O N    H I S T O R Y
+
+  04/29/05  BRK  1. retrieved from ClearCase and added this rev. history
+                 2. added two new entries to RadioParamType_e  enum
+                 3. increased MAX_RADIO_PARAM_POWER_TABLE (from 20 to 56)
+                    - this is sort of a kludge, struct RadioParam_t  should have used an
+                      array pointer instead of an actual data block
+  06/10/05  BRK  changed MAX_RADIO_PARAM_POWER_TABLE for 1251 support (sort of a KLUDGE)
+  07/15/05  BRK  added RADIO_PABIAS_TABLE entry to RadioParamType_e  enum
+  04/12/06  MH   Added new run-time calibration state: RFPLL_CALIBRATION_NEEDED
+
+  Note: This code should only be edited with TAB stops set at 4
+=======================================================================================================================
+ */
+#ifndef PUBLIC_RADIO
+#define PUBLIC_RADIO
+
+// radio parameter to set
+ #ifdef TNETW1251
+#define MAX_RADIO_PARAM_POWER_TABLE  4*48   // cPowLmtTbl[] max size for ABG radios
+ #else
+#define MAX_RADIO_PARAM_POWER_TABLE  56     // cPowLmtTbl[] max size for BG radios
+ #endif
+#define MAX_RADIO_PARAM_LEN          MAX_RADIO_PARAM_POWER_TABLE
+
+#define RADIO_PARAM_POWER_TABLE_ENABLE        0x01  // mask for RADIO_PARAM_POWER_ENABLES usage
+#define RADIO_PARAM_POWER_LIMIT_TABLE_ENABLE  0x02  // mask for RADIO_PARAM_POWER_ENABLES usage
+#define RADIO_PARAM_POWER_ADJ_TABLE_ENABLE    0x04  // mask for RADIO_PARAM_POWER_ENABLES usage
+
+
+#define NUM_OF_SUB_BANDS        5
+#define NUM_OF_POWER_LEVEL      4
+
+#ifndef HOST_IF_ENUMS_DISABLED
+typedef enum RadioParamType_e
+{
+    RADIO_PARAM_POWER_TABLE = 1,
+    RADIO_PARAM_POWER_LIMIT_TABLE,
+    RADIO_PARAM_POWER_ADJ_TABLE,
+    RADIO_PARAM_POWER_ENABLES,
+    RADIO_PABIAS_TABLE,
+       RADIO_PARAM_POWER_LEVELS,
+    MAX_RADIO_PARAM_TYPE = 0x7FFFFFFF /* force this enum to be uint32 */
+} RadioParamType_e;
+#else
+typedef uint32 RadioParamType_e;
+#endif
+
+typedef struct RadioParam_t
+{
+    RadioParamType_e parameterType;
+    int8  parameter[MAX_RADIO_PARAM_LEN];
+} RadioParam_t;
+
+
+/******************************************************************************
+
+    Name:      ACX_CAL_ASSESSMENT
+       Type:   Configuration
+       Access: Write Only
+       Length: 4
+       Note:   OBSOLETE !!! (DO_CALIBRATION_IN_DRIVER is not defined)
+       
+******************************************************************************/
+
+typedef enum
+{
+    RUNTIME_CALIBRATION_NOT_NEEDED = 1,
+    RUNTIME_CALIBRATION_NEEDED = 2,
+    RFPLL_CALIBRATION_NEEDED = 3,
+    MAX_RUNTIME_CALIBRATION_OPTIONS = 0x7FFFFFFF // force this enum to be uint32 
+} RadioRuntimeCalState_enum;
+
+
+
+#ifdef HOST_COMPILE
+typedef uint32 RadioRuntimeCalState_e;
+#else
+typedef RadioRuntimeCalState_enum RadioRuntimeCalState_e;
+#endif
+
+/************************************************************************/
+/*                                                                                                                                             */      
+/*                                                     Commands section                            */
+/*                                                                                                                                             */
+/************************************************************************/
+
+
+/******************************************************************************
+
+       Name:       ACX_PLT_NVS_BUFFER_UPDATE 
+       TestCmdId:      TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER
+       Description: This PLT function provides the all information required by 
+                                       the upper driver in order to update the NVS image.
+                                       It received a parameter defining the type of update 
+                                       information required and provides an array of elements defining 
+                                       the data bytes to be written to the NVS image and the byte 
+                                       offset in which they should be written.         
+       Type:   PLT
+       Access: Read Only
+       Length: 420
+
+******************************************************************************/
+#define  NVS_RESULTS_MAX_NUM_OF_TABLES         4
+#define  NVS_RESULTS_MAX_UPDATE_TABLE_SIZE 100  
+
+typedef struct resultsBuffer_t 
+{
+        uint16   size;                                                               /* size of table*/
+     uint16   offset;                                                        /* offset in the binary image of the NVS file*/
+     uint8    data[NVS_RESULTS_MAX_UPDATE_TABLE_SIZE];/* the actual table data */
+}resultsBuffer_t;
+
+
+typedef struct PltNvsResultsBuffer_t
+{
+       resultsBuffer_t tables[NVS_RESULTS_MAX_NUM_OF_TABLES];  /* array of structures of type containing the tables*/
+       uint8                   numOfTables;                                        /* number of tables needed to be updated*/
+       uint8                   padding[3];
+}PltNvsResultsBuffer_t;
+
+
+typedef struct PltGainGet_t
+{
+            uint8 TxGain;            //Total TX chain gain according to the current setting
+            uint8 TxUpperBound;      //the max gain setting allowed
+            uint8 TxLowerBound;      //the min gain setting allowed
+            uint8 padding;           /* padding to 32 bit */
+}PltGainGet_t;
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_types.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/public_types.h
new file mode 100644 (file)
index 0000000..6c4b87d
--- /dev/null
@@ -0,0 +1,325 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 public_types.h
+ *  \brief Basic types and general macros, bit manipulations, etc.
+ *
+ */
+
+#ifndef PUBLIC_TYPES_H
+#define PUBLIC_TYPES_H
+
+
+/******************************************************************************
+
+    Basic definitions
+
+******************************************************************************/
+#ifndef uint8
+typedef unsigned char   uint8;
+#endif
+#ifndef uint16
+typedef unsigned short  uint16;
+#endif
+#ifndef uint32
+typedef unsigned long int    uint32;
+#endif
+
+#ifndef int8
+typedef signed char     int8;
+#endif
+#ifndef int16
+typedef short           int16;
+#endif
+#ifndef int32
+typedef long int        int32;
+#endif
+
+#ifndef TRUE
+#define TRUE  1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/* !! LAC - NULL definition conflicts with the compilers version.
+   I redid this definition to the ANSI version....
+    #define NULL 0
+*/
+#if !defined( NULL )
+#if defined( __cplusplus )
+#define NULL 0
+#else
+#define NULL ((void *)0)
+#endif
+#endif
+
+/* Bool_e should be used when we need it to be a byte. */
+typedef uint8           Bool_e;
+
+/* Bool32 should be used whenever possible for efficiency */
+typedef uint32          Bool32;
+
+/* to align enum to 32/16 bits */
+#define MAX_POSITIVE32 0x7FFFFFFF
+#define MAX_POSITIVE16 0x7FFF
+
+
+#define MAC_ADDR_SIZE 6
+
+#ifndef HOST_COMPILE
+#define HOST_COMPILE   /* temp fix for suppl build err */
+#endif
+
+#ifdef HOST_COMPILE
+#else
+typedef struct macAddress_t
+{
+    uint8 addr[MAC_ADDR_SIZE];
+}macAddress_t;
+#endif
+
+
+#define  BIT_0    0x00000001
+#define  BIT_1    0x00000002
+#define  BIT_2    0x00000004
+#define  BIT_3    0x00000008
+#define  BIT_4    0x00000010
+#define  BIT_5    0x00000020
+#define  BIT_6    0x00000040
+#define  BIT_7    0x00000080
+#define  BIT_8    0x00000100
+#define  BIT_9    0x00000200
+#define  BIT_10   0x00000400
+#define  BIT_11   0x00000800
+#define  BIT_12   0x00001000
+#define  BIT_13   0x00002000
+#define  BIT_14   0x00004000
+#define  BIT_15   0x00008000
+#define  BIT_16   0x00010000
+#define  BIT_17   0x00020000
+#define  BIT_18   0x00040000
+#define  BIT_19   0x00080000
+#define  BIT_20   0x00100000
+#define  BIT_21   0x00200000
+#define  BIT_22   0x00400000
+#define  BIT_23   0x00800000
+#define  BIT_24   0x01000000
+#define  BIT_25   0x02000000
+#define  BIT_26   0x04000000
+#define  BIT_27   0x08000000
+#define  BIT_28   0x10000000
+#define  BIT_29   0x20000000
+#define  BIT_30   0x40000000
+#define  BIT_31   0x80000000
+
+#define  BIT_32   0x00000001
+#define  BIT_33   0x00000002
+#define  BIT_34   0x00000004
+#define  BIT_35   0x00000008
+#define  BIT_36   0x00000010
+#define  BIT_37   0x00000020
+#define  BIT_38   0x00000040
+#define  BIT_39   0x00000080
+#define  BIT_40   0x00000100
+#define  BIT_41   0x00000200
+#define  BIT_42   0x00000400
+#define  BIT_43   0x00000800
+#define  BIT_44   0x00001000
+#define  BIT_45   0x00002000
+#define  BIT_46   0x00004000
+#define  BIT_47   0x00008000
+#define  BIT_48   0x00010000
+#define  BIT_49   0x00020000
+#define  BIT_50   0x00040000
+#define  BIT_51   0x00080000
+#define  BIT_52   0x00100000
+#define  BIT_53   0x00200000
+#define  BIT_54   0x00400000
+#define  BIT_55   0x00800000
+#define  BIT_56   0x01000000
+#define  BIT_57   0x02000000
+#define  BIT_58   0x04000000
+#define  BIT_59   0x08000000
+#define  BIT_60   0x10000000
+#define  BIT_61   0x20000000
+#define  BIT_62   0x40000000
+#define  BIT_63   0x80000000
+
+
+/******************************************************************************
+
+    CHANNELS, BAND & REG DOMAINS definitions
+
+******************************************************************************/
+
+
+typedef uint8 Channel_e;
+
+typedef enum
+{
+    RADIO_BAND_2_4GHZ = 0,  /* 2.4 Ghz band */
+    RADIO_BAND_5GHZ = 1,    /* 5 Ghz band */
+    RADIO_BAND_JAPAN_4_9_GHZ = 2,
+    DEFAULT_BAND = RADIO_BAND_2_4GHZ,
+    INVALID_BAND = 0xFE,
+    MAX_RADIO_BANDS = 0xFF
+} RadioBand_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 RadioBand_e;
+#else
+typedef RadioBand_enum RadioBand_e;
+#endif
+
+
+typedef enum
+{
+    NO_RATE      = 0,
+    RATE_1MBPS   = 0x0A,
+    RATE_2MBPS   = 0x14,
+    RATE_5_5MBPS = 0x37,
+    RATE_6MBPS   = 0x0B,
+    RATE_9MBPS   = 0x0F,
+    RATE_11MBPS  = 0x6E,
+    RATE_12MBPS  = 0x0A,
+    RATE_18MBPS  = 0x0E,
+    RATE_22MBPS  = 0xDC,
+    RATE_24MBPS  = 0x09,
+    RATE_36MBPS  = 0x0D,
+    RATE_48MBPS  = 0x08,
+    RATE_54MBPS  = 0x0C
+} Rate_enum;
+
+#ifdef HOST_COMPILE
+typedef uint8 Rate_e;
+#else
+typedef Rate_enum Rate_e;
+#endif
+
+typedef enum
+{
+       RATE_INDEX_1MBPS   =  0,
+       RATE_INDEX_2MBPS   =  1,
+       RATE_INDEX_5_5MBPS =  2,
+       RATE_INDEX_6MBPS   =  3,
+       RATE_INDEX_9MBPS   =  4,
+       RATE_INDEX_11MBPS  =  5,
+       RATE_INDEX_12MBPS  =  6,
+       RATE_INDEX_18MBPS  =  7,
+       RATE_INDEX_22MBPS  =  8,
+       RATE_INDEX_24MBPS  =  9,
+       RATE_INDEX_36MBPS  =  10,
+       RATE_INDEX_48MBPS  =  11,
+       RATE_INDEX_54MBPS  =  12,
+       RATE_INDEX_MAX     =  RATE_INDEX_54MBPS,
+       MAX_RATE_INDEX,
+       INVALID_RATE_INDEX = MAX_RATE_INDEX,
+       RATE_INDEX_ENUM_MAX_SIZE = 0x7FFFFFFF
+} RateIndex_e;
+
+#define SHORT_PREAMBLE_BIT   BIT_0 /* CCK or Barker depending on the rate */
+#define OFDM_RATE_BIT        BIT_6
+#define PBCC_RATE_BIT        BIT_7
+
+
+typedef enum
+{
+    CCK_LONG = 0,
+    CCK_SHORT = SHORT_PREAMBLE_BIT,
+    PBCC_LONG = PBCC_RATE_BIT,
+    PBCC_SHORT = PBCC_RATE_BIT | SHORT_PREAMBLE_BIT,
+    OFDM = OFDM_RATE_BIT
+} Mod_enum;
+
+#ifdef HOST_COMPILE
+typedef  uint8 Mod_e;
+#else
+typedef  Mod_enum Mod_e;
+#endif
+
+
+typedef uint16 BasicRateSet_t;
+
+
+/******************************************************************************
+
+Transmit-Descriptor RATE-SET field definitions...
+
+Define a new "Rate-Set" for TX path that incorporates the
+Rate & Modulation info into a single 16-bit field.
+
+TxdRateSet_t:
+  b15    - Indicates Preamble type (1=SHORT, 0=LONG).
+           Notes:
+             Must be LONG (0) for 1Mbps rate.
+             Does not apply (set to 0) for RevG-OFDM rates.
+  b14    - Indicates PBCC encoding (1=PBCC, 0=not).
+           Notes:
+             Does not apply (set to 0) for rates 1 and 2 Mbps.
+             Does not apply (set to 0) for RevG-OFDM rates.
+  b13    - Unused (set to 0).
+  b12-b0 - Supported Rate indicator bits as defined below.
+
+******************************************************************************/
+
+typedef uint16 TxdRateSet_t;
+
+
+/******************************************************************************
+    CHIP_ID definitions
+******************************************************************************/
+#define TNETW1150_PG10_CHIP_ID          0x04010101
+#define TNETW1150_PG11_CHIP_ID          0x04020101
+#define TNETW1150_CHIP_ID               0x04030101  /* 1150 PG2.0, 1250, 1350, 1450*/
+#define TNETW1350A_CHIP_ID              0x06010101
+#define TNETW1251_CHIP_ID_PG1_0         0x07010101
+#define TNETW1251_CHIP_ID_PG1_1         0x07020101
+#define TNETW1251_CHIP_ID_PG1_2                0x07030101
+
+#define IS_CHIP_PG_LESS_THEN_PG12()      ((CHIP_ID == TNETW1251_CHIP_ID_PG1_0) || (CHIP_ID == TNETW1251_CHIP_ID_PG1_1))
+
+/******************************************************************************
+Enable bits for SOC1251 PG1.2
+******************************************************************************/
+#define PDET_BINARY_OFFSET_EN   BIT_0
+#define STOP_TOGGLE_MONADC_EN   BIT_1
+#define RX_ADC_BIAS_DEC_EN      BIT_2
+#define RX_LNB_AND_DIGI_GAIN_EN BIT_3
+
+
+#endif /* PUBLIC_TYPES_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/ti_types.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/ti_types.h
new file mode 100644 (file)
index 0000000..aa461b0
--- /dev/null
@@ -0,0 +1,125 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _TYPES_H
+#define _TYPES_H
+#define TYPES_H
+
+/*typedef unsigned char      uint8;*/
+/*typedef unsigned short     uint16;*/
+/*typedef unsigned int       uint32;*/
+/*typedef tiULONGLONG          uint64;*/
+
+/*typedef char               int8;*/
+/*typedef short              int16;*/
+/*typedef int                int32;*/
+
+/*typedef uint8              MACAddress[6];*/
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define  BIT_0   0x00000001
+#define  BIT_1   0x00000002
+#define  BIT_2   0x00000004
+#define  BIT_3   0x00000008
+#define  BIT_4   0x00000010
+#define  BIT_5   0x00000020
+#define  BIT_6   0x00000040
+#define  BIT_7   0x00000080
+#define  BIT_8   0x00000100
+#define  BIT_9   0x00000200
+#define BIT_10   0x00000400
+#define BIT_11   0x00000800
+#define BIT_12   0x00001000
+#define BIT_13   0x00002000
+#define BIT_14   0x00004000
+#define BIT_15   0x00008000
+#define BIT_16   0x00010000
+#define BIT_17   0x00020000
+#define BIT_18   0x00040000
+#define BIT_19   0x00080000
+#define BIT_20   0x00100000
+#define BIT_21   0x00200000
+#define BIT_22   0x00400000
+#define BIT_23   0x00800000
+#define BIT_24   0x01000000
+#define BIT_25   0x02000000
+#define BIT_26   0x04000000
+#define BIT_27   0x08000000
+#define BIT_28   0x10000000
+#define BIT_29   0x20000000
+#define BIT_30   0x40000000
+#define BIT_31   0x80000000
+
+#define BIT_32   0x00000001
+#define BIT_33   0x00000002
+#define BIT_34   0x00000004
+#define BIT_35   0x00000008
+#define BIT_36   0x00000010
+#define BIT_37   0x00000020
+#define BIT_38   0x00000040
+#define BIT_39   0x00000080
+#define BIT_40   0x00000100
+#define BIT_41   0x00000200
+#define BIT_42   0x00000400
+#define BIT_43   0x00000800
+#define BIT_44   0x00001000
+#define BIT_45   0x00002000
+#define BIT_46   0x00004000
+#define BIT_47   0x00008000
+#define BIT_48   0x00010000
+#define BIT_49   0x00020000
+#define BIT_50   0x00040000
+#define BIT_51   0x00080000
+#define BIT_52   0x00100000
+#define BIT_53   0x00200000
+#define BIT_54   0x00400000
+#define BIT_55   0x00800000
+#define BIT_56   0x01000000
+#define BIT_57   0x02000000
+#define BIT_58   0x04000000
+#define BIT_59   0x08000000
+#define BIT_60   0x10000000
+#define BIT_61   0x20000000
+#define BIT_62   0x40000000
+#define BIT_63   0x80000000
+
+#endif /*_TYPES_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/whalHwDefs.h b/sta_dk_4_0_4_32/common/src/hal/FirmwareApi/whalHwDefs.h
new file mode 100644 (file)
index 0000000..40f864b
--- /dev/null
@@ -0,0 +1,85 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwDefs.h
+ *   PURPOSE: common hardware definitions
+ * 
+ ****************************************************************************/
+
+#ifndef WHAL_HW_DEFS_H
+#define WHAL_HW_DEFS_H
+
+/* 
+ * Tnetw registers h-files 
+ */
+#include "TnetwRegisters.h"
+#include "whalHwRegs.h"
+#include "tnetwCommon.h"
+/* 
+ * original firmware h-files 
+ */
+#include "public_commands.h"
+#include "public_event_mbox.h"
+#include "public_infoele.h"
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1130/TnetwRegisters.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1130/TnetwRegisters.h
new file mode 100644 (file)
index 0000000..aa226a2
--- /dev/null
@@ -0,0 +1,971 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef RGM_TNETW1150_H
+#define RGM_TNETW1150_H
+
+#include "public_types.h"
+
+
+/* Base addresses*/
+/* They are not used inside registers definition in purpose to allow this header file*/
+/* to be used as an easy reference to register -> address date base. Keep this as it*/
+/* is very powerful for debugging purpose.*/
+#define HOST_SLAVE_BASE        0x00300000
+#define INT_BASE               0x00300400
+#define REG_CONFIG_BASE        0x00300800
+#define CLK_BASE               0x00300C00
+#define SDMA_BASE              0x00301000
+#define AES_BASE               0x00301400
+#define WEP_BASE               0x00301800
+#define TKIP_BASE              0x00301C00
+#define SEEPROM_BASE   0x00302000
+#define PAR_HOST_BASE  0x00302400
+#define SDIO_BASE              0x00302800
+#define UART_BASE              0x00302C00
+#define USB11_BASE             0x00304000
+#define LDMA_BASE              0x00304400
+#define RX_BASE                        0x00304800
+#define ACCESS_BASE            0x00304c00
+#define TX_BASE                        0x00305000
+#define RMAC_CSR_BASE  0x00305400
+#define AFE_PM                 0x00305800
+#define VLYNQ_BASE             0x00308000
+#define PCI_BASE               0x00308400
+#define USB20_BASE             0x0030A000
+#define PHY_BASE               0x003C0000
+
+
+/* System DMA registers*/
+/* Order of registers was changed*/
+#define DMA_GLB_CFG                    (0x1000)
+#define DMA_HDESC_OFFSET               (0x1004)
+#define DMA_HDATA_OFFSET               (0x1008)
+#define DMA_CFG0                       (0x100C) /* SDMA_HOST_CFG0 changed*/
+#define DMA_CTL0                       (0x1010) /* SDMA_CTRL0 changed*/
+#define DMA_LENGTH0                    (0x1014)
+#define DMA_L_ADDR0                    (0x1018) /* SDMA_RD_ADDR ?*/
+#define DMA_L_PTR0                     (0x101C) /* SDMA_RD_OFFSET ?*/
+#define DMA_H_ADDR0                    (0x1020) /* SDMA_WR_ADDR ?*/
+#define DMA_H_PTR0                     (0x1024) /* SDMA_WR_OFFSET ?*/
+#define DMA_STS0                       (0x1028) /* Changed*/
+#define DMA_CFG1                       (0x1030) /* SDMA_HOST_CFG1 changed*/
+#define DMA_CTL1                       (0x1034) /* SDMA_CTRL1 changed*/
+#define DMA_LENGTH1                    (0x1038)
+#define DMA_L_ADDR1                    (0x103C)
+#define DMA_L_PTR1                     (0x1040)
+#define DMA_H_ADDR1                    (0x1044)
+#define DMA_H_PTR1                     (0x1048)
+#define DMA_STS1                       (0x104C)
+#define DMA_HFRM_PTR                   (0x1050) /* New ?*/
+#define DMA_DEBUG                      (0x1054) /* Changed*/
+
+/* Local DMA registers*/
+/* number changed from 4 to 2*/
+#define LDMA_DEBUG                     (0x4400)
+#define LDMA_CTL0                      (0x4404) /* Add 2 bits to support fix address (FIFO)*/
+#define LDMA_STATUS0                   (0x4408)
+#define LDMA_LENGTH0                   (0x440c)
+#define LDMA_RD_ADDR0                  (0x4410)
+#define LDMA_RD_OFFSET0                (0x4414)
+#define LDMA_WR_ADDR0                  (0x4418)
+#define LDMA_WR_OFFSET0                (0x441c)
+#define LDMA_CTL1                      (0x4428) /* Add 2 bits to support fix address (FIFO)*/
+#define LDMA_STATUS1                   (0x442c)
+#define LDMA_LENGTH1                   (0x4430)
+#define LDMA_RD_ADDR1                  (0x4434)
+#define LDMA_RD_OFFSET1                (0x4438)
+#define LDMA_WR_ADDR1                  (0x443c)
+#define LDMA_WR_OFFSET1                (0x4440)
+/* For TNETW compatability (if willbe )*/
+#define LDMA_CUR_RD_PTR0               LDMA_RD_ADDR0
+#define LDMA_CUR_WR_PTR0               LDMA_WR_ADDR0
+#define LDMA_CUR_RD_PTR1               LDMA_RD_ADDR1
+#define LDMA_CUR_WR_PTR1               LDMA_WR_ADDR1
+
+/* Host Slave registers*/
+#define SLV_SOFT_RESET                 (0x0000) /* self clearing*/
+#define SLV_REG_ADDR                   (0x0004)
+#define SLV_REG_DATA                   (0x0008)
+#define SLV_REG_ADATA                  (0x000c)
+#define SLV_MEM_CP                     (0x0010)
+#define SLV_MEM_ADDR                   (0x0014)
+#define SLV_MEM_DATA                   (0x0018)
+#define SLV_MEM_CTL                    (0x001c) /* bit 19 moved to PCMCIA_CTL*/
+#define SLV_END_CTL                    (0x0020) /* 2 bits moved to ENDIAN_CTL*/
+
+/* Timer registers*/
+/* Timer1/2 count MAC clocks*/
+/* Timer3/4/5 count usec*/
+#define TIM1_CTRL                      (0x0918)
+#define TIM1_LOAD                      (0x091C)
+#define TIM1_CNT                       (0x0920)
+#define TIM2_CTRL                      (0x0924)
+#define TIM2_LOAD                      (0x0928)
+#define TIM2_CNT                       (0x092C)
+#define TIM3_CTRL                      (0x0930)
+#define TIM3_LOAD                      (0x0934)
+#define TIM3_CNT                       (0x0938)
+#define TIM4_CTRL                      (0x093C)
+#define TIM4_LOAD                      (0x0940)
+#define TIM4_CNT                       (0x0944)
+#define TIM5_CTRL                      (0x0948)
+#define TIM5_LOAD                      (0x094C)
+#define TIM5_CNT                       (0x0950)
+
+/* Watchdog registers*/
+#define WDOG_CTRL                      (0x0954)
+#define WDOG_LOAD                      (0x0958)
+#define WDOG_CNT                       (0x095C)
+#define WDOG_STS                       (0x0960)
+#define WDOG_FEED                      (0x0964)
+
+/* Interrupt registers*/
+/* 64 bit interrupt sources registers ws ced. sme interupts were removed and new ones were added*/
+/* Order was changed*/
+#define FIQ_MASK                       (0x0400)
+#define FIQ_MASK_L                     (0x0400)
+#define FIQ_MASK_H                     (0x0404)
+#define FIQ_MASK_SET                   (0x0408)
+#define FIQ_MASK_SET_L                 (0x0408)
+#define FIQ_MASK_SET_H                 (0x040C)
+#define FIQ_MASK_CLR                   (0x0410)
+#define FIQ_MASK_CLR_L                 (0x0410)
+#define FIQ_MASK_CLR_H                 (0x0414)
+#define IRQ_MASK                       (0x0418)
+#define IRQ_MASK_L                     (0x0418)
+#define IRQ_MASK_H                     (0x041C)
+#define IRQ_MASK_SET                   (0x0420)
+#define IRQ_MASK_SET_L                 (0x0420)
+#define IRQ_MASK_SET_H                 (0x0424)
+#define IRQ_MASK_CLR                   (0x0428)
+#define IRQ_MASK_CLR_L                 (0x0428)
+#define IRQ_MASK_CLR_H                 (0x042C)
+#define ECPU_MASK                      (0x0448)
+#define FIQ_STS_L                      (0x044C)
+#define FIQ_STS_H                      (0x0450)
+#define IRQ_STS_L                      (0x0454)
+#define IRQ_STS_H                      (0x0458)
+#define INT_STS_ND                     (0x0464)
+#define INT_STS_RAW_L                  (0x0464)
+#define INT_STS_RAW_H                  (0x0468)
+#define INT_STS_CLR                    (0x04B4)
+#define INT_STS_CLR_L                  (0x04B4)
+#define INT_STS_CLR_H                  (0x04B8)
+#define INT_ACK                        (0x046C)
+#define INT_ACK_L                      (0x046C)
+#define INT_ACK_H                      (0x0470)
+#define INT_TRIG                       (0x0474)
+#define INT_TRIG_L                     (0x0474)
+#define INT_TRIG_H                     (0x0478)
+#define HOST_STS_L                     (0x045C)
+#define HOST_STS_H                     (0x0460)
+#define HOST_MASK                      (0x0430)
+#define HOST_MASK_L                    (0x0430)
+#define HOST_MASK_H                    (0x0434)
+#define HOST_MASK_SET                  (0x0438)
+#define HOST_MASK_SET_L                (0x0438)
+#define HOST_MASK_SET_H                (0x043C)
+#define HOST_MASK_CLR                  (0x0440)
+#define HOST_MASK_CLR_L                (0x0440)
+#define HOST_MASK_CLR_H                (0x0444)
+
+/* GPIO Interrupts*/
+#define GPIO_INT_STS                   (0x0484) /* 22 GPIOs*/
+#define GPIO_INT_ACK                   (0x047C)
+#define GPIO_INT_MASK                  (0x0480)
+#define GPIO_POS_MASK                  (0x04BC) /* New*/
+#define GPIO_NEG_MASK                  (0x04C0) /* New*/
+
+/* Protocol Interrupts*/
+#define PROTO_INT_STS                  (0x0490) /* Add 2 PHY->MAC source interrupts*/
+#define PROTO_INT_ACK                  (0x0488)
+#define PROTO_INT_MASK                 (0x048C)
+
+/* Host Interrupts*/
+#define HINT_MASK                      (0x0494)
+#define HINT_MASK_SET                  (0x0498)
+#define HINT_MASK_CLR                  (0x049C)
+#define HINT_STS_ND_MASKED             (0x04A0)
+#define HINT_STS_ND                       (0x04B0) /*1150 spec calls this HINT_STS_RAW*/
+#define HINT_STS_CLR                   (0x04A4)
+#define HINT_ACK                       (0x04A8)
+#define HINT_TRIG                      (0x04AC)
+
+/* Clock registers*/
+#define CLK_CFG                        (0x0C00) /* new ARM clock bit */
+#define CLK_CTRL                       (0x0C04) /* changed*/
+#define BLK_RST                        (0x0C08) /* changed*/
+#define CFG_USEC_STB                   (0x0C0C)
+#define ARM_GATE_CLK_REG               (0x0C10) /* new*/
+#define BUSY_STAT_REG                  (0x0C14) /* new*/
+#define CFG_PHY_CLK88                  (0x0C18)
+#define DYNAMIC_CLKGATE                (0x0C1C) /* new*/
+
+/* AES registers*/
+/* Major changes to this module*/
+#define AES_START                      (0x1400)
+#define AES_CFG                        (0x1404)
+#define AES_CTL                        (0x1408)
+#define AES_STATUS                     (0x140C)
+#define AES_LENGTH                     (0x1410)
+#define AES_RD_ADDR                    (0x1414)
+#define AES_RD_OFFSET                  (0x1418)
+#define AES_WR_ADDR                    (0x141C)
+#define AES_WR_OFFSET                  (0x1420)
+#define AES_CUR_RD_PTR                 (0x1424)
+#define AES_CUR_WR_PTR                 (0x1428)
+#define AES_KEY_0                      (0x142C)
+#define AES_KEY_1                      (0x1430)
+#define AES_KEY_2                      (0x1434)
+#define AES_KEY_3                      (0x1438)
+#define AES_NONCE_0                    (0x143C)
+#define AES_NONCE_1                    (0x1440)
+#define AES_NONCE_2                    (0x1444)
+#define AES_NONCE_3                    (0x1448)
+#define AES_MIC_0                      (0x144C)
+#define AES_MIC_1                      (0x1450)
+#define AES_MIC_2                      (0x1454)
+#define AES_MIC_3                      (0x1458)
+#define AES_ASSO_DATA_0                (0x145C)
+#define AES_ASSO_DATA_1                (0x1460)
+#define AES_ASSO_DATA_2                (0x1464)
+#define AES_ASSO_DATA_3                (0x1468)
+#define AES_NUM_OF_ROUNDS              (0x146C)
+#define AES_TX_QUEUE_PTR               (0x1470)
+#define AES_RX_QUEUE_PTR               (0x1474)
+#define AES_STACK                      (0x1478)
+#define AES_INT_RAW                    (0x147C)
+#define AES_INT_MASK                   (0x1480)
+#define AES_INT_STS                    (0x1484)
+
+/* WEP registers*/
+/* Order was changed*/
+#define DEC_CTL                        (0x1800)
+#define DEC_STATUS                     (0x1804)
+#define DEC_MBLK                       (0x1808)
+#define DEC_KEY_ADDR                   (0x180C)
+#define DEC_KEY_LEN                    (0x1810)
+#define DEC_ADDR_UPPER_BYTE            (0x1814) /* new*/
+#define DEC_LEN                        (0x1818)
+#define DEC_OFFSET                     (0x181C)
+#define DEC_WR_MBLK                    (0x1820)
+#define DEC_WR_OFFSET                  (0x1824)
+
+/* TKIP MICHAEL reisters*/
+/* order changed*/
+#define MCHL_START0                    (0x1C00)
+#define MCHL_DMV_START_MBLK0           (0x1C04) /* Changed to 23:5 format*/
+#define MCHL_DMV_CUR_MBLK0             (0x1C10)
+#define MCHL_DMV_OFFSET0               (0x1C08)
+#define MCHL_DMV_LENGTH0               (0x1C0C)
+#define MCHL_DMV_CFG0                  (0x1C14)
+#define MCHL_KEY_L0                    (0x1C18)
+#define MCHL_KEY_H0                    (0x1C1C)
+#define MCHL_MIC_L0                    (0x1C20)
+#define MCHL_MIC_H0                    (0x1C24)
+#define MCHL_START1                    (0x1C28)
+#define MCHL_DMV_START_MBLK1           (0x1C2C) /* Changed to 23:5 format*/
+#define MCHL_DMV_CUR_MBLK1             (0x1C38)
+#define MCHL_DMV_OFFSET1               (0x1C30)
+#define MCHL_DMV_LENGTH1               (0x1C34)
+#define MCHL_DMV_CFG1                  (0x1C3C)
+#define MCHL_KEY_L1                    (0x1C40)
+#define MCHL_KEY_H1                    (0x1C44)
+#define MCHL_MIC_L1                    (0x1C48)
+#define MCHL_MIC_H1                    (0x1C4C)
+#define MCHL_CTL0                      (0x1C50) /* new name MCHL_CTRL0*/
+#define MCHL_CTL1                      (0x1C54) /* new name MCHL_CTRL1*/
+#define MCHL_UPPER_BYTE_ADDR0          (0x1C58) /* new*/
+#define MCHL_UPPER_BYTE_ADDR1          (0x1C5C) /* new*/
+
+/* SEEPROM registers*/
+#define EE_CFG                         (0x0820)
+#define EE_CTL                         (0x2000)
+#define EE_DATA                        (0x2004)
+#define EE_ADDR                        (0x2008)
+
+/* Parallel Host (PCI/CARDBUS/PCMCIA/GS*/
+#define CIS_LADDR                      (0x2400)
+#define HI_CTL                         (0x2404)
+#define LPWR_MGT                       (0x2408)
+/*#define PDR0                         (0x04ec)*/
+/*#define PDR1                         (0x04f0)*/
+/*#define PDR2                         (0x04f4)*/
+/*#define PDR3                         (0x04f8)*/
+/*#define BAR2_ENABLE                  (0x04fc)*/
+/*#define BAR2_TRANS                   (0x0500)*/
+/*#define BAR2_MASK                    (0x0504)*/
+#define PCI_MEM_SIZE1                  (0x2428)
+#define PCI_MEM_OFFSET1                (0x242C)
+#define PCI_MEM_OFFSET2                (0x2430)
+/*#define PCI_IO_SIZE1                 (0x0514)*/
+/*#define PCI_IO_OFFSET1               (0x0518)*/
+/*#define PCI_IO_OFFSET2               (0x051c)*/
+/*#define PCI_CFG_OFFSET               (0x0520)*/
+#define PCMCIA_CFG                     (0x2444)
+#define PCMCIA_CTL                     (0x2448)
+#define PCMCIA_CFG2                    (0x244C) /* new*/
+#define SRAM_PAGE                      (0x2450)
+#define CFG_PULLUPDN                   (0x2454)
+#define CIS_MAP                        (0x2458) /* new*/
+#define ENDIAN_CTRL                    (0x245C) /* new*/
+#define GS_SLEEP_ACCESS                (0x2480) /* new*/
+#define PCMCIA_PWR_DN                  (0x04C4) 
+#define PCI_OUTPUT_DLY_CFG             (0x2464) /* new*/
+
+/* VLYNQ registers*/
+/* VLYNQ2 was removed from hardware*/
+#define VL1_REV_ID                     (0x8000) /* VLYNQ_REVISION*/
+#define VL1_CTL                        (0x8004) /* VLYNQ_ CONTROL*/
+#define VL1_STS                        (0x8008) /* VLYNQ_STATUS*/
+#define VLYNQ_INTVEC                   (0x800C)
+#define VL1_INT_STS                    (0x8010) /* VLYNQ_INTCR*/
+#define VL1_INT_PEND                   (0x8014) /* VLYNQ_INTSR*/
+#define VL1_INT_PTR                    (0x8018) /* VLYNQ_INTPTR*/
+#define VL1_TX_ADDR                    (0x801C) /* VLYNQ_TX_MAP_ADDR*/
+#define VL1_RX_SIZE1                   (0x8020) /* VLYNQ_RX_MAP_SIZE1*/
+#define VL1_RX_OFF1                    (0x8024) /* VLYNQ_RX_MAP_OFFSET1*/
+#define VL1_RX_SIZE2                   (0x8028) /* VLYNQ_RX_MAP_SIZE2*/
+#define VL1_RX_OFF2                    (0x802C) /* VLYNQ_RX_MAP_OFFSET2*/
+#define VL1_RX_SIZE3                   (0x8030) /* VLYNQ_RX_MAP_SIZE3*/
+#define VL1_RX_OFF3                    (0x8034) /* VLYNQ_RX_MAP_OFFSET3*/
+#define VL1_RX_SIZE4                   (0x8038) /* VLYNQ_RX_MAP_SIZE4*/
+#define VL1_RX_OFF4                    (0x803C) /* VLYNQ_RX_MAP_OFFSET4*/
+#define VL1_CHIP_VER                   (0x8040) /* VLYNQ_CHIP_VER*/
+#define VLYNQ_AUTONEG                  (0x8044)
+#define VLYNQ_MANNEG                   (0x8048)
+#define VLYNQ_NEGSTAT                  (0x804C)
+#define VLYNQ_ENDIAN                   (0x805C)
+#define VL1_INT_VEC3_0                 (0x8060) /* VLYNQ_HW_INT3TO0_CFG*/
+#define VL1_INT_VEC7_4                 (0x8064) /* VLYNQ_HW_INT7TO4_CFG*/
+/* VLYNQ Remote configuration registers*/
+#define VL1_REM_REV_ID                 (0x8080) /* VLYNQ_REM_REVISION*/
+#define VL1_REM_CTL                    (0x8084) /* VLYNQ_REM_ CONTROL*/
+#define VL1_REM_STS                    (0x8088) /* VLYNQ_REM_STATUS*/
+#define VLYNQ_REM_INTVEC               (0x808C)
+#define VL1_REM_INT_STS                (0x8090) /* VLYNQ_REM_INTCR*/
+#define VL1_REM_INT_PEND               (0x8094) /* VLYNQ_REM_INTSR*/
+#define VL1_REM_INT_PTR                (0x8098) /* VLYNQ_REM_INTPTR*/
+#define VL1_REM_TX_ADDR                (0x809C) /* VLYNQ_REM_TX_MAP_ADDR*/
+#define VL1_REM_RX_SIZE1               (0x80A0) /* VLYNQ_REM_RX_MAP_SIZE1*/
+#define VL1_REM_RX_OFF1                (0x80A4) /* VLYNQ_REM_RX_MAP_OFFSET1*/
+#define VL1_REM_RX_SIZE2               (0x80A8) /* VLYNQ_REM_RX_MAP_SIZE2*/
+#define VL1_REM_RX_OFF2                (0x80AC) /* VLYNQ_REM_RX_MAP_OFFSET2*/
+#define VL1_REM_RX_SIZE3               (0x80B0) /* VLYNQ_REM_RX_MAP_SIZE3*/
+#define VL1_REM_RX_OFF3                (0x80B4) /* VLYNQ_REM_RX_MAP_OFFSET3*/
+#define VL1_REM_RX_SIZE4               (0x80B8) /* VLYNQ_REM_RX_MAP_SIZE4*/
+#define VL1_REM_RX_OFF4                (0x80BC) /* VLYNQ_REM_RX_MAP_OFFSET4*/
+#define VL1_REM_CHIP_VER               (0x80C0) /* VLYNQ_REM_CHIP_VER*/
+#define VLYNQ_REM_AUTONEG              (0x80C4)
+#define VLYNQ_REM_MANNEG               (0x80C8)
+#define VLYNQ_REM_NEGSTAT              (0x80CC)
+#define VLYNQ_REM_ENDIAN               (0x80DC)
+#define VL1_REM_INT_VEC3_0             (0x80E0) /* VLYNQ_REM_HW_INT3TO0_CFG*/
+#define VL1_REM_INT_VEC7_4             (0x80E4) /* VLYNQ_REM_HW_INT7TO4_CFG*/
+
+/* PCIIF*/
+/**/
+#define PCI_ID_REG                     (0x8400)
+#define PCI_STATUS_SET_REG             (0x8410)
+#define PCI_STATUS_CLR_REG             (0x8414)
+#define PCI_HIMASK_SET_REG             (0x8420)
+#define PCI_HIMASK_CLR_REG             (0x8424)
+#define PCI_AMASK_SET_REG              (0x8430)
+#define PCI_AMASK_CLR_REG              (0x8434)
+#define PCI_CLKRUN_REG                 (0x8438)
+#define PCI_BE_VENDOR_ID_REG           (0x8500)
+#define PCI_BE_COMMAND_REG             (0x8504)
+#define PCI_BE_REVISION_REG            (0x8508)
+#define PCI_BE_CL_SIZE_REG             (0x850C)
+#define PCI_BE_BAR0_MASK_REG           (0x8510)
+#define PCI_BE_BAR1_MASK_REG           (0x8514)
+#define PCI_BE_BAR2_MASK_REG           (0x8518)
+#define PCI_BE_BAR3_MASK_REG           (0x851C)
+#define PCI_BE_CIS_PTR_REG             (0x8528)
+#define PCI_BE_SUBSYS_ID_REG           (0x852C)
+#define PCI_BE_CAP_PTR_REG             (0x8534)
+#define PCI_BE_INTR_LINE_REG           (0x853C)
+#define PCI_BE_PM_CAP_REG              (0x8540)
+#define PCI_BE_PM_CTRL_REG             (0x8544)
+#define PCI_BE_PM_D0_CTRL_REG          (0x8560)
+#define PCI_BE_PM_D1_CTRL_REG          (0x8564)
+#define PCI_BE_PM_D2_CTRL_REG          (0x8568)
+#define PCI_BE_PM_D3_CTRL_REG          (0x856C)
+#define PCI_BE_SLV_CFG_REG             (0x8580)
+#define PCI_BE_ARB_CTRL_REG            (0x8584)
+                                       
+#define FER                            (0x85A0) /* PCI_BE_STSCHG_FE_REG*/
+#define FEMR                           (0x85A4) /* PCI_BE_STSCHG_FEM_REG*/
+#define FPSR                           (0x85A8) /* PCI_BE_STSCHG_FPS_REG*/
+#define FFER                           (0x85AC) /* PCI_BE_STSCHG_FFE_REG*/
+
+#define PCI_BE_BAR0_TRANS_REG          (0x85C0)
+#define PCI_BE_BAR1_TRANS_REG          (0x85C4)
+#define PCI_BE_BAR2_TRANS_REG          (0x85C8)
+#define PCI_BE_BAR3_TRANS_REG          (0x85CC)
+#define PCI_BE_BAR4_TRANS_REG          (0x85D0)
+#define PCI_BE_BAR5_TRANS_REG          (0x85D4)
+#define PCI_BE_BAR0_REG                (0x85E0)
+#define PCI_BE_BAR1_REG                (0x85E4)
+#define PCI_BE_BAR2_REG                (0x85E8)
+#define PCI_BE_BAR3_REG                (0x85EC)
+
+#define PCI_PROXY_DATA                 (0x8700)
+#define PCI_PROXY_ADDR                 (0x8704)
+#define PCI_PROXY_CMD                  (0x8708)
+#define PCI_CONTROL                    (0x8710)
+
+/*#define CPC_REGION                   (f0100)*/
+/*#define VLYNQ1_BASE                  (f00a0)*/
+/*#define VLYNQ2_BASE                  (f00b0)*/
+/*#define SCR_IADDR1                   (f00c0)*/
+/*#define SCR_IDATA1                   (f00c0)*/
+/*#define SCR_IADDR2                   (f00c0)*/
+/*#define SCR_IDATA2                   (f00c0)*/
+
+/* SDIO/WSPI*/
+#define        CCCR_1                         (002800)
+#define        CCCR_2                         (002804)
+#define        CCCR_3                         (002808)
+#define        FUN_BASE_REG_1                 (00280C)
+#define        FUN_BASE_REG_2                 (002810)
+#define        FUN_BASE_REG_3                 (002814)
+#define        ADDR_MAP_SIZE_1                (002818)
+#define        ADDR_MAP_SIZE_2                (002820)
+#define        ADDR_MAP_SIZE_3                (002828)
+#define        ADDR_MAP_OFFSET_1              (00281C)
+#define        ADDR_MAP_OFFSET_2              (002824)
+#define        ADDR_MAP_OFFSET_3              (00282C)
+#define        ADDR_MAP_OFFSET_4              (002830)
+#define        CIS_OFFSET                     (002834)
+#define        CSA_OFFSET                     (002838)
+#define        DEBUG_REG_1                    (002840)
+#define        DEBUG_REG_2                    (00283C)
+#define        INTR_MASK                      (002844)
+#define        STATUS_REG                     (002848)
+#define        WR_ERR_LENGTH                  (00284C)
+#define        WR_ERR_ADDR                    (002850)
+#define        OCR                            (002858)
+
+/* UART*/
+/* TODO - fill in registers*/
+
+/* USB1.1 registers*/
+/**/
+#define USB_STS_CLR                    (0x4000)
+#define USB_STS_ND                     (0x4004)
+#define USB_INT_ACK                    (0x4008)
+#define USB_MASK                       (0x400c)
+#define USB_MASK_SET                   (0x4010)
+#define USB_MASK_CLR                   (0x4014)
+#define USB_WU                         (0x4018)
+#define USB_EP0_OUT_PTR                (0x401c)
+#define USB_EP0_OUT_VLD                (0x4020)
+#define USB_EP0_OUT_LEN                (0x4024)
+#define USB_EP0_IN_PTR                 (0x4028)
+#define USB_EP0_IN_VLD                 (0x402c)
+#define USB_EP0_IN_LEN                 (0x4030)
+#define USB_EP1_CFG                    (0x4034)
+#define USB_EP1_OUT_INT_CFG            (0x4038)
+#define USB_EP1_OUT_PTR                (0x403c)
+#define USB_EP1_OUT_VLD                (0x4040)
+#define USB_EP1_OUT_CUR_MBLK           (0x4044)
+#define USB_EP1_OUT_LEN                (0x4048)
+#define USB_EP1_IN_START_MBLK          (0x404c)
+#define USB_EP1_IN_LAST_MBLK           (0x4050)
+#define USB_EP1_IN_VLD                 (0x4054)
+
+#define USB_EP2_PTR                    (0x405c)
+#define USB_EP2_VLD                    (0x4060)
+#define USB_EP2_LEN                    (0x4064)
+#define USB_EP3_OUT_PTR0               (0x4068)
+#define USB_EP3_OUT_VLD0               (0x406c)
+#define USB_EP3_OUT_LEN0               (0x4070)
+#define USB_EP3_OUT_PTR1               (0x4074)
+#define USB_EP3_OUT_VLD1               (0x4078)
+#define USB_EP3_OUT_LEN1               (0x407c)
+#define USB_EP3_IN_PTR0                (0x4080)
+#define USB_EP3_IN_VLD0                (0x4084)
+#define USB_EP3_IN_LEN0                (0x4088)
+#define USB_EP3_IN_PTR1                (0x408c)
+#define USB_EP3_IN_VLD1                (0x4090)
+#define USB_EP3_IN_LEN1                (0x4094)
+#define USB_EP1_OUT_END_MBLK           (0x4098)
+#define USB_EP0_OUT_SETUP              (0x409c)
+#define USB_EP0_STALL                  (0x40a0)
+#define USB_EP1_IN_OFFSET              (0x40a4)
+
+/* Device Configuration registers*/
+#define SOR_CFG                        (0x0800)
+#define ECPU_CTRL                      (0x0804)
+#define HI_CFG                         (0x0808)
+#define EE_START                       (0x080C)
+
+/* IO Control registers*/
+#define SERIAL_HOST_IOCFG0             (0x0894) /* new*/
+#define SERIAL_HOST_IOCFG1             (0x0898) /* new*/
+#define SERIAL_HOST_IOCFG2             (0x089C) /* new*/
+#define SERIAL_HOST_IOCFG3             (0x08A0) /* new*/
+#define GPIO_IOCFG0                    (0x08F4) /* new*/
+#define GPIO_IOCFG1                    (0x08F8) /* new*/
+#define GPIO_IOCFG2                    (0x08FC) /* new*/
+#define GPIO_IOCFG3                    (0x0900) /* new*/
+#define CHIP_ID_B                      (0x5674) /* new*/
+#define CHIP_ID                        CHIP_ID_B/* Leave for TNETW compatability*/
+#define CHIP_ID_1251_PG10                 (0x7010101)
+#define CHIP_ID_1251_PG11                 (0x7020101)
+#define CHIP_ID_1251_PG12                 (0x7030101)
+
+#define SYSTEM                         (0x0810)
+#define PCI_ARB_CFG                    (0x0814)
+#define BOOT_IRAM_CFG                  (0x0818)
+#define ENABLE                         (0x5450)
+#define MBLK_CFG                       (0x5460)
+#define RS232_BITINTERVAL              (0x0824)
+#define TEST_PORT                      (0x096C)
+#define DEBUG_PORT                     (0x0970)
+
+/* GPIO registers*/
+#define GPIO_OE                        (0x082C) /* 22 GPIOs*/
+#define GPIO_OUT                       (0x0834)
+#define GPIO_IN                        (0x0830)
+#define GPO_CFG                        (0x083C)
+#define PWRDN_BUS_L                    (0x0844)
+#define PWRDN_BUS_H                    (0x0848)
+#define DIE_ID_L                       (0x088C)
+#define DIE_ID_H                       (0x0890)
+
+/* Power Management registers*/
+/* */
+#define ELP_START                      (0x5800)
+#define ELP_CFG_MODE                   (0x5804)
+#define ELP_CMD                        (0x5808)
+#define PLL_CAL_TIME                   (0x5810)
+#define CLK_REQ_TIME                   (0x5814)
+#define CLK_BUF_TIME                   (0x5818)
+
+#define CFG_PLL_SYNC_CNT               (0x5820) /* Points to the CFG_PLL_SYNC_CNT_xx registers set*/
+#define CFG_PLL_SYNC_CNT_I             (0x5820)
+#define CFG_PLL_SYNC_CNT_II            (0x5824)
+#define CFG_PLL_SYNC_CNT_III           (0x5828)
+
+#define CFG_ELP_SLEEP_CNT              (0x5830) /* Points to the CFG_ELP_SLEEP_CNT_xx registers set*/
+#define CFG_ELP_SLEEP_CNT_I            (0x5830)
+#define CFG_ELP_SLEEP_CNT_II           (0x5834)
+#define CFG_ELP_SLEEP_CNT_III          (0x5838)
+#define CFG_ELP_SLEEP_CNT_IV           (0x583c)
+
+#define ELP_SLEEP_CNT                  (0x5840) /* Points to the ELP_SLEEP_CNT_xx registers set*/
+#define ELP_SLEEP_CNT_I                (0x5840)
+#define ELP_SLEEP_CNT_II               (0x5844)
+#define ELP_SLEEP_CNT_III              (0x5848)
+#define ELP_SLEEP_CNT_IV               (0x584c)
+
+#define ELP_WAKE_UP_STS                (0x5850)
+#define CFG_SLP_CLK_SEL                (0x5860)
+#define CFG_SLP_CLK_EN                 (0x5870)
+
+#define CFG_WAKE_UP_EN_I               (0x5880)
+#define CFG_WAKE_UP_EN_II              (0x5884)
+#define CFG_WAKE_UP_EN_III             (0x5888)
+
+#define CFG_ELP_PWRDN_I                (0x5890)
+#define CFG_ELP_PWRDN_II               (0x5894)
+#define CFG_ELP_PWRDN_III              (0x5898)
+
+#define CFG_POWER_DOWN_I               (0x58a0)
+#define CFG_POWER_DOWN_II              (0x58a4)
+#define CFG_POWER_DOWN_III             (0x58a8)
+
+#define CFG_BUCK_TESTMODE_I            (0x58b0)
+#define CFG_BUCK_TESTMODE_II           (0x58b4)
+
+#define POWER_STATUS_I                 (0x58C0)
+#define POWER_STATUS_II                (0x58C4)
+
+#define DIGLDO_BIAS_PROG_I             (0x58d0)
+#define DIGLDO_BIAS_PROG_II            (0x58d4)
+
+#define LDO2P8_BIAS_PROG_I             (0x58e0)
+#define LDO2P8_BIAS_PROG_II            (0x58e4)
+
+#define ADCLDO_BIAS_PROG               (0x58f0)
+
+#define REFSYS_PROG_I                  (0x5910)
+#define REFSYS_PROG_II                 (0x5914)
+
+#define PM_TEST_I                      (0x5920)
+#define PM_TEST_II                     (0x5924)
+
+#define POR_PROG                       (0x5930)
+
+#define TEST_PIN_DIR_I                 (0x5940)
+#define TEST_PIN_DIR_II                (0x5944)
+
+#define PROC_CTL                       (0x5950)
+
+#define ADC_REF_WAKEUP_I               (0x5960)
+#define ADC_REF_WAKEUP_II              (0x5964)
+#define ADC_REF_WAKEUP_III             (0x5968)
+#define ADC_REF_WAKEUP_IV              (0x596C)
+
+#define VREG_WAKEUP_I                  (0x5970)
+#define VREG_WAKEUP_II                 (0x5974)
+#define VREG_WAKEUP_III                (0x5978)
+#define VREG_WAKEUP_IV                 (0x597C)
+
+#define PLL_WAKEUP_I                   (0x5980)
+#define PLL_WAKEUP_II                  (0x5984)
+#define PLL_WAKEUP_III                 (0x5988)
+#define PLL_WAKEUP_IV                  (0x598C)
+
+#define XTALOSC_WAKEUP_I               (0x5990)
+#define XTALOSC_WAKEUP_II              (0x5994)
+#define XTALOSC_WAKEUP_III             (0x5998)
+#define XTALOSC_WAKEUP_IV              (0x599C)
+
+/* ----------*/
+
+#define POWER_MGMT2                    (0x0840)
+#define POWER_MGMT                     (0x5098)
+#define MAC_HW_DOZE                    (0x090c)
+#define ECPU_SLEEP                     (0x0840)
+#define DOZE_CFG                       (0x54bc)
+#define DOZE2_CFG                      (0x081c)
+#define WAKEUP_CFG                     (0x54c0)
+#define WAKEUP_TIME_L                  (0x54c8)
+#define WAKEUP_TIME_H                  (0x54c4)
+
+/**/
+
+/*#define CPU_WAIT_CFG                 (f0020)*/
+/*#define CFG_QOS_ACM                  (f0046)*/
+
+/* Scratch Pad registers*/
+#define SCR_PAD0                       (0x5608)
+#define SCR_PAD1                       (0x560C)
+#define SCR_PAD2                       (0x5610)
+#define SCR_PAD3                       (0x5614)
+#define SCR_PAD4                       (0x5618)
+#define SCR_PAD4_SET                   (0x561C)
+#define SCR_PAD4_CLR                   (0x5620)
+#define SCR_PAD5                       (0x5624)
+#define SCR_PAD5_SET                   (0x5628)
+#define SCR_PAD5_CLR                   (0x562C)
+#define SCR_PAD6                       (0x5630)
+#define SCR_PAD7                       (0x5634)
+#define SCR_PAD8                       (0x5638)
+#define SCR_PAD9                       (0x563C)
+
+/* Spare registers*/
+#define SPARE_A1                       (0x0994)
+#define SPARE_A2                       (0x0998)
+#define SPARE_A3                       (0x099C)
+#define SPARE_A4                       (0x09A0)
+#define SPARE_A5                       (0x09A4)
+#define SPARE_A6                       (0x09A8)
+#define SPARE_A7                       (0x09AC)
+#define SPARE_A8                       (0x09B0)
+#define SPARE_B1                       (0x5420)
+#define SPARE_B2                       (0x5424)
+#define SPARE_B3                       (0x5428)
+#define SPARE_B4                       (0x542C)
+#define SPARE_B5                       (0x5430)
+#define SPARE_B6                       (0x5434)
+#define SPARE_B7                       (0x5438)
+#define SPARE_B8                       (0x543C)
+
+/* RMAC registers (Raleigh MAC)*/
+
+/* Station registers*/
+#define DEV_MODE                       (0x5464)
+#define STA_ADDR_L                     (0x546C)
+#define STA_ADDR_H                     (0x5470)
+#define BSSID_L                        (0x5474)
+#define BSSID_H                        (0x5478)
+#define AID_CFG                        (0x547C)
+#define BASIC_RATE_CFG                 (0x4C6C)
+#define BASIC_RATE_TX_CFG              (0x55F0)
+
+/* Protocol timers registers*/
+#define IFS_CFG0                       (0x5494)
+#define IFS_CFG1                       (0x5498)
+#define TIMEOUT_CFG                    (0x549C)
+#define CONT_WIND_CFG                  (0x54A0)
+#define BCN_INT_CFG                    (0x54A4)
+#define RETRY_CFG                      (0x54A8)
+#define DELAY_CFG                      (0x54B0)
+
+/* Hardware Override registers*/
+#define CCA_CFG                        (0x54CC)
+#define CCA_FILTER_CFG                 (0x5480)
+#define RADIO_PLL_CFG                  (0x555C)
+#define CCA_MON                        (0x54D0)
+#define TX_FRM_CTL                     (0x54D4)
+#define CONT_TX_EN                     (0x50EC)
+#define PHY_STANDBY_EN                 (0x5668)
+
+/* Transmit Setup registers*/
+#define TX_PING_PONG                   (0x5090)
+#define TX_CFG0                        (0x5000)
+#define TX_CFG1                        (0x5004)
+#define TX_CFG2                        (0x5008)
+#define MAX_LIFETIME                   (0x50FC)
+#define TX_PANG_SEL                    (0x50E0)
+#define TX_PANG0                       (0x50A0)
+#define TX_PING0                       (0x5010)
+#define TX_PONG0                       (0x5050)
+#define TX_PANG1                       (0x50A4)
+#define TX_PING1                       (0x5014)
+#define TX_PONG1                       (0x5054)
+#define TX_PANG2                       (0x50A8)
+#define TX_PING2                       (0x5018)
+#define TX_PONG2                       (0x5058)
+#define TX_PANG3                       (0x50AC)
+#define TX_PING3                       (0x501C)
+#define TX_PONG3                       (0x505C)
+#define TX_PANG4                       (0x50B0)
+#define TX_PING4                       (0x5020)
+#define TX_PONG4                       (0x5060)
+#define TX_PANG5                       (0x50B4)
+#define TX_PING5                       (0x5024)
+#define TX_PONG5                       (0x5064)
+#define TX_PANG6                       (0x50B8)
+#define TX_PING6                       (0x5028)
+#define TX_PONG6                       (0x5068)
+#define TX_PANG7                       (0x50BC)
+#define TX_PING7                       (0x502C)
+#define TX_PONG7                       (0x506C)
+#define TX_PANG8                       (0x50C0)
+#define TX_PING8                       (0x5030)
+#define TX_PONG8                       (0x5070)
+#define TX_PANG9                       (0x50C4)
+#define TX_PING9                       (0x5034)
+#define TX_PONG9                       (0x5074)
+#define TX_PANG10                      (0x50C8)
+#define TX_PING10                      (0x5038)
+#define TX_PONG10                      (0x5078)
+#define TX_PANG11                      (0x50CC)
+#define TX_PING11                      (0x503C)
+#define TX_PONG11                      (0x507C)
+
+/* Transmit Status registers*/
+#define TX_STATUS                      (0x509C)
+#define TX_PANG_EXCH                   (0x50D0)
+#define TX_PING_EXCH                   (0x5040)
+#define TX_PONG_EXCH                   (0x5080)
+#define TX_PANG_ATT                    (0x50D4)
+#define TX_PING_ATT                    (0x5044)
+#define TX_PONG_ATT                    (0x5084)
+#define TX_PANG_TIMESTAMP              (0x50DC)
+#define TX_PING_TIMESTAMP              (0x504C)
+#define TX_PONG_TIMESTAMP              (0x508C)
+
+/* Transmit State registers*/
+#define TX_STATE                       (0x5094)
+#define TX_PANG_OVRD_CFG               (0x50D8)
+#define TX_PING_OVRD_CFG               (0x5048)
+#define TX_PONG_OVRD_CFG               (0x5088)
+#define TX_HOLD_CFG                    (0x54D8)
+#define TSF_ADJ_CFG1                   (0x54DC)
+#define TSF_ADJ_CFG2                   (0x54E0)
+#define TSF_ADJ_CFG3                   (0x54E4)
+#define TSF_ADJ_CFG4                   (0x54E8)
+#define CFG_OFDM_TIMES0                (0x5648)
+#define CFG_OFDM_TIMES1                (0x564C)
+
+/* Beacon/Probe Response registers*/
+#define PRB_ADDR                       (0x54EC)
+#define PRB_LENGTH                     (0x54F0)
+#define BCN_ADDR                       (0x54F4)
+#define BCN_LENGTH                     (0x54F8)
+#define TIM_VALID0                     (0x54FC)
+#define TIM_ADDR0                      (0x5500)
+#define TIM_LENGTH0                    (0x5504)
+#define TIM_VALID1                     (0x5654)
+#define TIM_ADDR1                      (0x5658)
+#define TIM_LENGTH1                    (0x565C)
+#define TIM_SELECT                     (0x5660)
+#define TSF_CFG                        (0x5508)
+
+/* Other Hardware Generated Frames regi*/
+#define CTL_FRM_CFG                    (0x550C)
+#define MGMT_FRM_CFG                   (0x5510)
+#define CFG_ANT_SEL                    (0x5664)
+#define RMAC_ADDR_BASE                 (0x5680) /* new*/
+
+/* Protocol Interface Read Write Interf*/
+#define TXSIFS_TIMER                   (0x4C00)
+#define TXPIFS_TIMER                   (0x4C04)
+#define TXDIFS_TIMER                   (0x4C08)
+#define SLOT_TIMER                     (0x4C0C)
+#define BACKOFF_TIMER                  (0x4C10)
+#define BCN_PSP_TIMER                  (0x4C14)
+#define NAV                            (0x4C18)
+#define TSF_L                          (0x4C1C)
+#define TSF_H                          (0x4C20)
+#define TSF_PREV_L                     (0x4CC4) /* new */
+#define TSF_PREV_H                     (0x4CC8) /* new */
+#define TOUT_TIMER                     (0x4C2C)
+#define NEXT_TBTT_L                    (0x4C30)
+#define NEXT_TBTT_H                    (0x4C34)
+#define DTIM_CNT                       (0x4C38)
+#define CONT_WIND                      (0x4C3C)
+#define PRSP_REQ                       (0x4C40)
+#define PRSP_DA_L                      (0x4C44)
+#define PRSP_DA_H                      (0x4C48)
+#define PRSP_RETRY                     (0x4C4C)
+#define PSPOLL_REQ                     (0x4C50)
+#define NEXT_SEQ_NUM                   (0x4C54)
+#define PRSP_SEQ_NUM                   (0x4C58)
+#define BCN_SEQ_NUM                    (0x4C5C)
+#define MED_USAGE                      (0x4C24)
+#define MED_USAGE_TM                   (0x4C28)
+#define PRB_DLY                        (0x4C60)
+#define STA_SRC                        (0x4C64)
+#define STA_LRC                        (0x4C68)
+#define CFG_ACM                        (0x4C70)
+#define RAND_NUMB                      (0x4C6C)
+#define CFG_ACK_CTS_DOT11A             (0x4C74)
+#define CFG_ACK_CTS_DOT11B             (0x4C78)
+#define ACM_IFS_CFG0                   (0x4C7C)
+#define ACM_IFS_CFG1                   (0x4C80)
+#define ACM_IFS_CFG2                   (0x4C84)
+#define ACM_IFS_CFG3                   (0x4C88)
+#define ACK_CTS_FRM_CFG                (0x4C8C)
+#define CFG_RX_TSTMP_DLY0              (0x4C90)
+#define CFG_RX_TSTMP_DLY1              (0x4C94)
+#define CFG_RX_TSTMP_DLY2              (0x4C98)
+#define CFG_RX_TSTMP_DLY3              (0x4C9C)
+#define CCA_BUSY                       (0x4CA0)
+#define CCA_BUSY_CLR                   (0x4CA4)
+#define CCA_IDLE                       (0x4CA8)
+#define CCA_IDLE_CLR                   (0x4CAC)
+
+/* Receive Manager registers*/
+#define RX_HEAD_PTR                    (0x567C) /* new*/
+#define RX_TAIL_PTR                    (0x4898) /* new*/
+#define RX_CURR_PTR                    (0x5678) /* new*/
+#define RX_RESET                       (0x4800)
+#define RX_MODMODE                     (0x4838) /* new*/
+#define MAC_HEADER_BYTECNT             (0x4890)
+#define RX_MAC_BYTECNT_INT             (0x489C)
+#define MAC_HEADER_WORD0               (0x4868)
+#define MAC_HEADER_WORD1               (0x486C)
+#define MAC_HEADER_WORD2               (0x4870)
+#define MAC_HEADER_WORD3               (0x4874)
+#define MAC_HEADER_WORD4               (0x4878)
+#define MAC_HEADER_WORD5               (0x487C)
+#define MAC_HEADER_WORD6               (0x4880)
+#define MAC_HEADER_WORD7               (0x4884)
+#define MAC_HEADER_WORD8               (0x4888)
+#define MAC_HEADER_WORD9               (0x488C)
+#define RX_CFG                         (0x5514)
+#define RX_FILTER_CFG                  (0x55B4)
+#define RX_MC0_L                       (0x5518)
+#define RX_MC0_H                       (0x551C)
+#define RX_MC1_L                       (0x5520)
+#define RX_MC1_H                       (0x5524)
+#define STA_SSID0                      (0x4804)
+#define STA_SSID1                      (0x4808)
+#define STA_SSID2                      (0x480C)
+#define STA_SSID3                      (0x4810)
+#define STA_SSID4                      (0x4814)
+#define STA_SSID5                      (0x4818)
+#define STA_SSID6                      (0x481C)
+#define STA_SSID7                      (0x4820)
+#define SSID_LEN                       (0x4824)
+#define RX_FREE_MEM                    (0x5528)
+#define RX_CURR_MEM                    (0x552C)
+#define MAC_TIMESTAMP                  (0x5560) /* Check place*/
+#define RX_TIMESTAMP                   (0x5564)
+#define RX_FRM_PTR                     (0x5568)
+#define RX_FRM_LEN                     (0x556C)
+#define RX_PLCP_HDR                    (0x5570)
+#define RX_PLCP_SIGNAL                 (0x5574)
+#define RX_PLCP_SERVICE                (0x5578) /* 16 bits ?*/
+#define RX_PLCP_LENGTH                 (0x557C)
+#define RX_FRM_CTL                     (0x5580)
+#define RX_DUR_ID                      (0x5584)
+#define RX_ADDR1_L                     (0x5588)
+#define RX_ADDR1_H                     (0x558C)
+#define RX_ADDR2_L                     (0x5590)
+#define RX_ADDR2_H                     (0x5594)
+#define RX_ADDR3_L                     (0x5598)
+#define RX_ADDR3_H                     (0x559C)
+#define RX_SEQ_CTL                     (0x55A0)
+#define RX_WEP_IV                      (0x55A4)
+#define RX_TIME_L                      (0x55A8)
+#define RX_TIME_H                      (0x55AC)
+#define RX_STATUS                      (0x55B0)
+#define PLCP_ERR_CNT                   (0x4828)
+#define FCS_ERR_CNT                    (0x482C)
+#define RX_OVERFLOW_CNT                (0x4830)
+#define RX_DEBUG1                      (0x4858)
+#define RX_DEBUG2                      (0x485C)
+#define RX_QOS_CFG                     (0x4848)
+#define RX_QOS_CTL                     (0x4844)
+#define RX_QOS_STATUS                  (0x4854) /* new name RX_QOS_STS*/
+#define RX_TXOP_HOLDER_L               (0x484C)
+#define RX_TXOP_HOLDER_H               (0x4850)
+#define RX_FRM_CNT                     (0x4834) /* what is RX_FRM_CTR*/
+#define CONS_FCS_ERR_CNT               (0x483C)
+#define CONS_FCS_ERR_CFG               (0x4840)
+#define RX_QOS_CTL_MASK                (0x48A0) /* new*/
+#define RX_QOS_ACK_EN                  (0x48A4) /* new*/
+#define RX_QOS_NOACK_EN                (0x48A8) /* new*/
+#define RX_QOS_ACK_BITMAP              (0x48AC) /* new*/
+
+/* Baseband Processor registers*/
+#define SBB_CFG                        (0x55C8)
+#define SBB_ADDR                       (0x55D0)
+#define SBB_DATA                       (0x55D4)
+#define SBB_CTL                        (0x55D8)
+
+/* Radio Control Interface registers*/
+#define RCI_CTL                        (0x55DC)
+#define RCI_DATA                       (0x55E0)
+#define RCI_CFG1                       (0x55E4)
+#define RCI_CFG2                       (0x55E8)
+#define RCI_CFG3                       (0x55EC)
+
+#define TNET1150_LAST_REG_ADDR                 PCI_CONTROL
+
+
+/* Missing registers*/
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1130/whalHwRegs.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1130/whalHwRegs.h
new file mode 100644 (file)
index 0000000..fe3b148
--- /dev/null
@@ -0,0 +1,57 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwRegs.h
+ *   PURPOSE: Contains Wlan hardware registers defines/structures
+ *   
+ ****************************************************************************/
+
+#ifndef _WHAL_ACX_REGS_H
+#define _WHAL_ACX_REGS_H
+
+#include "TnetwRegisters.h"
+
+#define REG_DEVICE_VENDOR_ID                           PCI_BE_VENDOR_ID_REG
+#define ACX_VENDOR_ID                                          0x104C
+#define ACX_DEVICE_ID                                          0x9068  /* --- 1150*/
+#define ECPU_CONTROL_HALT                                      0x00000101                              
+#define ACX_CLK_CFG_ARM_80_MAC_40_MHZ          0x2
+#define ACX_MAC_REG_READ_WRITE_PREFIX       0x300000
+
+#endif   /* _WHAL_ACX_REGS_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1150/TnetwRegisters.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1150/TnetwRegisters.h
new file mode 100644 (file)
index 0000000..68fc0f9
--- /dev/null
@@ -0,0 +1,965 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef RGM_TNETW1150_H
+#define RGM_TNETW1150_H
+
+#include "public_types.h"
+
+
+/* Base addresses*/
+/* They are not used inside registers definition in purpose to allow this header file*/
+/* to be used as an easy reference to register -> address date base. Keep this as it*/
+/* is very powerful for debugging purpose.*/
+#define HOST_SLAVE_BASE        0x00300000
+#define INT_BASE               0x00300400
+#define REG_CONFIG_BASE        0x00300800
+#define CLK_BASE               0x00300C00
+#define SDMA_BASE              0x00301000
+#define AES_BASE               0x00301400
+#define WEP_BASE               0x00301800
+#define TKIP_BASE              0x00301C00
+#define SEEPROM_BASE   0x00302000
+#define PAR_HOST_BASE  0x00302400
+#define SDIO_BASE              0x00302800
+#define UART_BASE              0x00302C00
+#define USB11_BASE             0x00304000
+#define LDMA_BASE              0x00304400
+#define RX_BASE                        0x00304800
+#define ACCESS_BASE            0x00304c00
+#define TX_BASE                        0x00305000
+#define RMAC_CSR_BASE  0x00305400
+#define AFE_PM                 0x00305800
+#define VLYNQ_BASE             0x00308000
+#define PCI_BASE               0x00308400
+#define USB20_BASE             0x0030A000
+#define PHY_BASE               0x003C0000
+
+
+/* System DMA registers*/
+/* Order of registers was changed*/
+#define DMA_GLB_CFG                    (0x1000)
+#define DMA_HDESC_OFFSET               (0x1004)
+#define DMA_HDATA_OFFSET               (0x1008)
+#define DMA_CFG0                       (0x100C) /* SDMA_HOST_CFG0 changed*/
+#define DMA_CTL0                       (0x1010) /* SDMA_CTRL0 changed*/
+#define DMA_LENGTH0                    (0x1014)
+#define DMA_L_ADDR0                    (0x1018) /* SDMA_RD_ADDR ?*/
+#define DMA_L_PTR0                     (0x101C) /* SDMA_RD_OFFSET ?*/
+#define DMA_H_ADDR0                    (0x1020) /* SDMA_WR_ADDR ?*/
+#define DMA_H_PTR0                     (0x1024) /* SDMA_WR_OFFSET ?*/
+#define DMA_STS0                       (0x1028) /* Changed*/
+#define DMA_CFG1                       (0x1030) /* SDMA_HOST_CFG1 changed*/
+#define DMA_CTL1                       (0x1034) /* SDMA_CTRL1 changed*/
+#define DMA_LENGTH1                    (0x1038)
+#define DMA_L_ADDR1                    (0x103C)
+#define DMA_L_PTR1                     (0x1040)
+#define DMA_H_ADDR1                    (0x1044)
+#define DMA_H_PTR1                     (0x1048)
+#define DMA_STS1                       (0x104C)
+#define DMA_HFRM_PTR                   (0x1050) /* New ?*/
+#define DMA_DEBUG                      (0x1054) /* Changed*/
+
+/* Local DMA registers*/
+/* number changed from 4 to 2*/
+#define LDMA_DEBUG                     (0x4400)
+#define LDMA_CTL0                      (0x4404) /* Add 2 bits to support fix address (FIFO)*/
+#define LDMA_STATUS0                   (0x4408)
+#define LDMA_LENGTH0                   (0x440c)
+#define LDMA_RD_ADDR0                  (0x4410)
+#define LDMA_RD_OFFSET0                (0x4414)
+#define LDMA_WR_ADDR0                  (0x4418)
+#define LDMA_WR_OFFSET0                (0x441c)
+#define LDMA_CTL1                      (0x4428) /* Add 2 bits to support fix address (FIFO)*/
+#define LDMA_STATUS1                   (0x442c)
+#define LDMA_LENGTH1                   (0x4430)
+#define LDMA_RD_ADDR1                  (0x4434)
+#define LDMA_RD_OFFSET1                (0x4438)
+#define LDMA_WR_ADDR1                  (0x443c)
+#define LDMA_WR_OFFSET1                (0x4440)
+/* For TNETW compatability (if willbe )*/
+#define LDMA_CUR_RD_PTR0               LDMA_RD_ADDR0
+#define LDMA_CUR_WR_PTR0               LDMA_WR_ADDR0
+#define LDMA_CUR_RD_PTR1               LDMA_RD_ADDR1
+#define LDMA_CUR_WR_PTR1               LDMA_WR_ADDR1
+
+/* Host Slave registers*/
+#define SLV_SOFT_RESET                 (0x0000) /* self clearing*/
+#define SLV_REG_ADDR                   (0x0004)
+#define SLV_REG_DATA                   (0x0008)
+#define SLV_REG_ADATA                  (0x000c)
+#define SLV_MEM_CP                     (0x0010)
+#define SLV_MEM_ADDR                   (0x0014)
+#define SLV_MEM_DATA                   (0x0018)
+#define SLV_MEM_CTL                    (0x001c) /* bit 19 moved to PCMCIA_CTL*/
+#define SLV_END_CTL                    (0x0020) /* 2 bits moved to ENDIAN_CTL*/
+
+/* Timer registers*/
+/* Timer1/2 count MAC clocks*/
+/* Timer3/4/5 count usec*/
+#define TIM1_CTRL                      (0x0918)
+#define TIM1_LOAD                      (0x091C)
+#define TIM1_CNT                       (0x0920)
+#define TIM2_CTRL                      (0x0924)
+#define TIM2_LOAD                      (0x0928)
+#define TIM2_CNT                       (0x092C)
+#define TIM3_CTRL                      (0x0930)
+#define TIM3_LOAD                      (0x0934)
+#define TIM3_CNT                       (0x0938)
+#define TIM4_CTRL                      (0x093C)
+#define TIM4_LOAD                      (0x0940)
+#define TIM4_CNT                       (0x0944)
+#define TIM5_CTRL                      (0x0948)
+#define TIM5_LOAD                      (0x094C)
+#define TIM5_CNT                       (0x0950)
+
+/* Watchdog registers*/
+#define WDOG_CTRL                      (0x0954)
+#define WDOG_LOAD                      (0x0958)
+#define WDOG_CNT                       (0x095C)
+#define WDOG_STS                       (0x0960)
+#define WDOG_FEED                      (0x0964)
+
+/* Interrupt registers*/
+/* 64 bit interrupt sources registers ws ced. sme interupts were removed and new ones were added*/
+/* Order was changed*/
+#define FIQ_MASK                       (0x0400)
+#define FIQ_MASK_L                     (0x0400)
+#define FIQ_MASK_H                     (0x0404)
+#define FIQ_MASK_SET                   (0x0408)
+#define FIQ_MASK_SET_L                 (0x0408)
+#define FIQ_MASK_SET_H                 (0x040C)
+#define FIQ_MASK_CLR                   (0x0410)
+#define FIQ_MASK_CLR_L                 (0x0410)
+#define FIQ_MASK_CLR_H                 (0x0414)
+#define IRQ_MASK                       (0x0418)
+#define IRQ_MASK_L                     (0x0418)
+#define IRQ_MASK_H                     (0x041C)
+#define IRQ_MASK_SET                   (0x0420)
+#define IRQ_MASK_SET_L                 (0x0420)
+#define IRQ_MASK_SET_H                 (0x0424)
+#define IRQ_MASK_CLR                   (0x0428)
+#define IRQ_MASK_CLR_L                 (0x0428)
+#define IRQ_MASK_CLR_H                 (0x042C)
+#define ECPU_MASK                      (0x0448)
+#define FIQ_STS_L                      (0x044C)
+#define FIQ_STS_H                      (0x0450)
+#define IRQ_STS_L                      (0x0454)
+#define IRQ_STS_H                      (0x0458)
+#define INT_STS_ND                     (0x0464)
+#define INT_STS_RAW_L                  (0x0464)
+#define INT_STS_RAW_H                  (0x0468)
+#define INT_STS_CLR                    (0x04B4)
+#define INT_STS_CLR_L                  (0x04B4)
+#define INT_STS_CLR_H                  (0x04B8)
+#define INT_ACK                        (0x046C)
+#define INT_ACK_L                      (0x046C)
+#define INT_ACK_H                      (0x0470)
+#define INT_TRIG                       (0x0474)
+#define INT_TRIG_L                     (0x0474)
+#define INT_TRIG_H                     (0x0478)
+#define HOST_STS_L                     (0x045C)
+#define HOST_STS_H                     (0x0460)
+#define HOST_MASK                      (0x0430)
+#define HOST_MASK_L                    (0x0430)
+#define HOST_MASK_H                    (0x0434)
+#define HOST_MASK_SET                  (0x0438)
+#define HOST_MASK_SET_L                (0x0438)
+#define HOST_MASK_SET_H                (0x043C)
+#define HOST_MASK_CLR                  (0x0440)
+#define HOST_MASK_CLR_L                (0x0440)
+#define HOST_MASK_CLR_H                (0x0444)
+
+/* GPIO Interrupts*/
+#define GPIO_INT_STS                   (0x0484) /* 22 GPIOs*/
+#define GPIO_INT_ACK                   (0x047C)
+#define GPIO_INT_MASK                  (0x0480)
+#define GPIO_POS_MASK                  (0x04BC) /* New*/
+#define GPIO_NEG_MASK                  (0x04C0) /* New*/
+
+/* Protocol Interrupts*/
+#define PROTO_INT_STS                  (0x0490) /* Add 2 PHY->MAC source interrupts*/
+#define PROTO_INT_ACK                  (0x0488)
+#define PROTO_INT_MASK                 (0x048C)
+
+/* Host Interrupts*/
+#define HINT_MASK                      (0x0494)
+#define HINT_MASK_SET                  (0x0498)
+#define HINT_MASK_CLR                  (0x049C)
+#define HINT_STS_ND_MASKED             (0x04A0)
+#define HINT_STS_ND                       (0x04B0) /*1150 spec calls this HINT_STS_RAW*/
+#define HINT_STS_CLR                   (0x04A4)
+#define HINT_ACK                       (0x04A8)
+#define HINT_TRIG                      (0x04AC)
+
+/* Clock registers*/
+#define CLK_CFG                        (0x0C00) /* new ARM clock bit */
+#define CLK_CTRL                       (0x0C04) /* changed*/
+#define BLK_RST                        (0x0C08) /* changed*/
+#define CFG_USEC_STB                   (0x0C0C)
+#define ARM_GATE_CLK_REG               (0x0C10) /* new*/
+#define BUSY_STAT_REG                  (0x0C14) /* new*/
+#define CFG_PHY_CLK88                  (0x0C18)
+#define DYNAMIC_CLKGATE                (0x0C1C) /* new*/
+
+/* AES registers*/
+/* Major changes to this module*/
+#define AES_START                      (0x1400)
+#define AES_CFG                        (0x1404)
+#define AES_CTL                        (0x1408)
+#define AES_STATUS                     (0x140C)
+#define AES_LENGTH                     (0x1410)
+#define AES_RD_ADDR                    (0x1414)
+#define AES_RD_OFFSET                  (0x1418)
+#define AES_WR_ADDR                    (0x141C)
+#define AES_WR_OFFSET                  (0x1420)
+#define AES_CUR_RD_PTR                 (0x1424)
+#define AES_CUR_WR_PTR                 (0x1428)
+#define AES_KEY_0                      (0x142C)
+#define AES_KEY_1                      (0x1430)
+#define AES_KEY_2                      (0x1434)
+#define AES_KEY_3                      (0x1438)
+#define AES_NONCE_0                    (0x143C)
+#define AES_NONCE_1                    (0x1440)
+#define AES_NONCE_2                    (0x1444)
+#define AES_NONCE_3                    (0x1448)
+#define AES_MIC_0                      (0x144C)
+#define AES_MIC_1                      (0x1450)
+#define AES_MIC_2                      (0x1454)
+#define AES_MIC_3                      (0x1458)
+#define AES_ASSO_DATA_0                (0x145C)
+#define AES_ASSO_DATA_1                (0x1460)
+#define AES_ASSO_DATA_2                (0x1464)
+#define AES_ASSO_DATA_3                (0x1468)
+#define AES_NUM_OF_ROUNDS              (0x146C)
+#define AES_TX_QUEUE_PTR               (0x1470)
+#define AES_RX_QUEUE_PTR               (0x1474)
+#define AES_STACK                      (0x1478)
+#define AES_INT_RAW                    (0x147C)
+#define AES_INT_MASK                   (0x1480)
+#define AES_INT_STS                    (0x1484)
+
+/* WEP registers*/
+/* Order was changed*/
+#define DEC_CTL                        (0x1800)
+#define DEC_STATUS                     (0x1804)
+#define DEC_MBLK                       (0x1808)
+#define DEC_KEY_ADDR                   (0x180C)
+#define DEC_KEY_LEN                    (0x1810)
+#define DEC_ADDR_UPPER_BYTE            (0x1814) /* new*/
+#define DEC_LEN                        (0x1818)
+#define DEC_OFFSET                     (0x181C)
+#define DEC_WR_MBLK                    (0x1820)
+#define DEC_WR_OFFSET                  (0x1824)
+
+/* TKIP MICHAEL reisters*/
+/* order changed*/
+#define MCHL_START0                    (0x1C00)
+#define MCHL_DMV_START_MBLK0           (0x1C04) /* Changed to 23:5 format*/
+#define MCHL_DMV_CUR_MBLK0             (0x1C10)
+#define MCHL_DMV_OFFSET0               (0x1C08)
+#define MCHL_DMV_LENGTH0               (0x1C0C)
+#define MCHL_DMV_CFG0                  (0x1C14)
+#define MCHL_KEY_L0                    (0x1C18)
+#define MCHL_KEY_H0                    (0x1C1C)
+#define MCHL_MIC_L0                    (0x1C20)
+#define MCHL_MIC_H0                    (0x1C24)
+#define MCHL_START1                    (0x1C28)
+#define MCHL_DMV_START_MBLK1           (0x1C2C) /* Changed to 23:5 format*/
+#define MCHL_DMV_CUR_MBLK1             (0x1C38)
+#define MCHL_DMV_OFFSET1               (0x1C30)
+#define MCHL_DMV_LENGTH1               (0x1C34)
+#define MCHL_DMV_CFG1                  (0x1C3C)
+#define MCHL_KEY_L1                    (0x1C40)
+#define MCHL_KEY_H1                    (0x1C44)
+#define MCHL_MIC_L1                    (0x1C48)
+#define MCHL_MIC_H1                    (0x1C4C)
+#define MCHL_CTL0                      (0x1C50) /* new name MCHL_CTRL0*/
+#define MCHL_CTL1                      (0x1C54) /* new name MCHL_CTRL1*/
+#define MCHL_UPPER_BYTE_ADDR0          (0x1C58) /* new*/
+#define MCHL_UPPER_BYTE_ADDR1          (0x1C5C) /* new*/
+
+/* SEEPROM registers*/
+#define EE_CFG                         (0x0820)
+#define EE_CTL                         (0x2000)
+#define EE_DATA                        (0x2004)
+#define EE_ADDR                        (0x2008)
+
+/* Parallel Host (PCI/CARDBUS/PCMCIA/GS*/
+#define CIS_LADDR                      (0x2400)
+#define HI_CTL                         (0x2404)
+#define LPWR_MGT                       (0x2408)
+/*#define PDR0                         (0x04ec)*/
+/*#define PDR1                         (0x04f0)*/
+/*#define PDR2                         (0x04f4)*/
+/*#define PDR3                         (0x04f8)*/
+/*#define BAR2_ENABLE                  (0x04fc)*/
+/*#define BAR2_TRANS                   (0x0500)*/
+/*#define BAR2_MASK                    (0x0504)*/
+#define PCI_MEM_SIZE1                  (0x2428)
+#define PCI_MEM_OFFSET1                (0x242C)
+#define PCI_MEM_OFFSET2                (0x2430)
+/*#define PCI_IO_SIZE1                 (0x0514)*/
+/*#define PCI_IO_OFFSET1               (0x0518)*/
+/*#define PCI_IO_OFFSET2               (0x051c)*/
+/*#define PCI_CFG_OFFSET               (0x0520)*/
+#define PCMCIA_CFG                     (0x2444)
+#define PCMCIA_CTL                     (0x2448)
+#define PCMCIA_CFG2                    (0x244C) /* new*/
+#define SRAM_PAGE                      (0x2450)
+#define CFG_PULLUPDN                   (0x2454)
+#define CIS_MAP                        (0x2458) /* new*/
+#define ENDIAN_CTRL                    (0x245C) /* new*/
+#define GS_SLEEP_ACCESS                (0x2480) /* new*/
+#define PCMCIA_PWR_DN                  (0x04C4) 
+#define PCI_OUTPUT_DLY_CFG             (0x2464) /* new*/
+
+/* VLYNQ registers*/
+/* VLYNQ2 was removed from hardware*/
+#define VL1_REV_ID                     (0x8000) /* VLYNQ_REVISION*/
+#define VL1_CTL                        (0x8004) /* VLYNQ_ CONTROL*/
+#define VL1_STS                        (0x8008) /* VLYNQ_STATUS*/
+#define VLYNQ_INTVEC                   (0x800C)
+#define VL1_INT_STS                    (0x8010) /* VLYNQ_INTCR*/
+#define VL1_INT_PEND                   (0x8014) /* VLYNQ_INTSR*/
+#define VL1_INT_PTR                    (0x8018) /* VLYNQ_INTPTR*/
+#define VL1_TX_ADDR                    (0x801C) /* VLYNQ_TX_MAP_ADDR*/
+#define VL1_RX_SIZE1                   (0x8020) /* VLYNQ_RX_MAP_SIZE1*/
+#define VL1_RX_OFF1                    (0x8024) /* VLYNQ_RX_MAP_OFFSET1*/
+#define VL1_RX_SIZE2                   (0x8028) /* VLYNQ_RX_MAP_SIZE2*/
+#define VL1_RX_OFF2                    (0x802C) /* VLYNQ_RX_MAP_OFFSET2*/
+#define VL1_RX_SIZE3                   (0x8030) /* VLYNQ_RX_MAP_SIZE3*/
+#define VL1_RX_OFF3                    (0x8034) /* VLYNQ_RX_MAP_OFFSET3*/
+#define VL1_RX_SIZE4                   (0x8038) /* VLYNQ_RX_MAP_SIZE4*/
+#define VL1_RX_OFF4                    (0x803C) /* VLYNQ_RX_MAP_OFFSET4*/
+#define VL1_CHIP_VER                   (0x8040) /* VLYNQ_CHIP_VER*/
+#define VLYNQ_AUTONEG                  (0x8044)
+#define VLYNQ_MANNEG                   (0x8048)
+#define VLYNQ_NEGSTAT                  (0x804C)
+#define VLYNQ_ENDIAN                   (0x805C)
+#define VL1_INT_VEC3_0                 (0x8060) /* VLYNQ_HW_INT3TO0_CFG*/
+#define VL1_INT_VEC7_4                 (0x8064) /* VLYNQ_HW_INT7TO4_CFG*/
+/* VLYNQ Remote configuration registers*/
+#define VL1_REM_REV_ID                 (0x8080) /* VLYNQ_REM_REVISION*/
+#define VL1_REM_CTL                    (0x8084) /* VLYNQ_REM_ CONTROL*/
+#define VL1_REM_STS                    (0x8088) /* VLYNQ_REM_STATUS*/
+#define VLYNQ_REM_INTVEC               (0x808C)
+#define VL1_REM_INT_STS                (0x8090) /* VLYNQ_REM_INTCR*/
+#define VL1_REM_INT_PEND               (0x8094) /* VLYNQ_REM_INTSR*/
+#define VL1_REM_INT_PTR                (0x8098) /* VLYNQ_REM_INTPTR*/
+#define VL1_REM_TX_ADDR                (0x809C) /* VLYNQ_REM_TX_MAP_ADDR*/
+#define VL1_REM_RX_SIZE1               (0x80A0) /* VLYNQ_REM_RX_MAP_SIZE1*/
+#define VL1_REM_RX_OFF1                (0x80A4) /* VLYNQ_REM_RX_MAP_OFFSET1*/
+#define VL1_REM_RX_SIZE2               (0x80A8) /* VLYNQ_REM_RX_MAP_SIZE2*/
+#define VL1_REM_RX_OFF2                (0x80AC) /* VLYNQ_REM_RX_MAP_OFFSET2*/
+#define VL1_REM_RX_SIZE3               (0x80B0) /* VLYNQ_REM_RX_MAP_SIZE3*/
+#define VL1_REM_RX_OFF3                (0x80B4) /* VLYNQ_REM_RX_MAP_OFFSET3*/
+#define VL1_REM_RX_SIZE4               (0x80B8) /* VLYNQ_REM_RX_MAP_SIZE4*/
+#define VL1_REM_RX_OFF4                (0x80BC) /* VLYNQ_REM_RX_MAP_OFFSET4*/
+#define VL1_REM_CHIP_VER               (0x80C0) /* VLYNQ_REM_CHIP_VER*/
+#define VLYNQ_REM_AUTONEG              (0x80C4)
+#define VLYNQ_REM_MANNEG               (0x80C8)
+#define VLYNQ_REM_NEGSTAT              (0x80CC)
+#define VLYNQ_REM_ENDIAN               (0x80DC)
+#define VL1_REM_INT_VEC3_0             (0x80E0) /* VLYNQ_REM_HW_INT3TO0_CFG*/
+#define VL1_REM_INT_VEC7_4             (0x80E4) /* VLYNQ_REM_HW_INT7TO4_CFG*/
+
+/* PCIIF*/
+/**/
+#define PCI_ID_REG                     (0x8400)
+#define PCI_STATUS_SET_REG             (0x8410)
+#define PCI_STATUS_CLR_REG             (0x8414)
+#define PCI_HIMASK_SET_REG             (0x8420)
+#define PCI_HIMASK_CLR_REG             (0x8424)
+#define PCI_AMASK_SET_REG              (0x8430)
+#define PCI_AMASK_CLR_REG              (0x8434)
+#define PCI_CLKRUN_REG                 (0x8438)
+#define PCI_BE_VENDOR_ID_REG           (0x8500)
+#define PCI_BE_COMMAND_REG             (0x8504)
+#define PCI_BE_REVISION_REG            (0x8508)
+#define PCI_BE_CL_SIZE_REG             (0x850C)
+#define PCI_BE_BAR0_MASK_REG           (0x8510)
+#define PCI_BE_BAR1_MASK_REG           (0x8514)
+#define PCI_BE_BAR2_MASK_REG           (0x8518)
+#define PCI_BE_BAR3_MASK_REG           (0x851C)
+#define PCI_BE_CIS_PTR_REG             (0x8528)
+#define PCI_BE_SUBSYS_ID_REG           (0x852C)
+#define PCI_BE_CAP_PTR_REG             (0x8534)
+#define PCI_BE_INTR_LINE_REG           (0x853C)
+#define PCI_BE_PM_CAP_REG              (0x8540)
+#define PCI_BE_PM_CTRL_REG             (0x8544)
+#define PCI_BE_PM_D0_CTRL_REG          (0x8560)
+#define PCI_BE_PM_D1_CTRL_REG          (0x8564)
+#define PCI_BE_PM_D2_CTRL_REG          (0x8568)
+#define PCI_BE_PM_D3_CTRL_REG          (0x856C)
+#define PCI_BE_SLV_CFG_REG             (0x8580)
+#define PCI_BE_ARB_CTRL_REG            (0x8584)
+                                       
+#define FER                            (0x85A0) /* PCI_BE_STSCHG_FE_REG*/
+#define FEMR                           (0x85A4) /* PCI_BE_STSCHG_FEM_REG*/
+#define FPSR                           (0x85A8) /* PCI_BE_STSCHG_FPS_REG*/
+#define FFER                           (0x85AC) /* PCI_BE_STSCHG_FFE_REG*/
+
+#define PCI_BE_BAR0_TRANS_REG          (0x85C0)
+#define PCI_BE_BAR1_TRANS_REG          (0x85C4)
+#define PCI_BE_BAR2_TRANS_REG          (0x85C8)
+#define PCI_BE_BAR3_TRANS_REG          (0x85CC)
+#define PCI_BE_BAR4_TRANS_REG          (0x85D0)
+#define PCI_BE_BAR5_TRANS_REG          (0x85D4)
+#define PCI_BE_BAR0_REG                (0x85E0)
+#define PCI_BE_BAR1_REG                (0x85E4)
+#define PCI_BE_BAR2_REG                (0x85E8)
+#define PCI_BE_BAR3_REG                (0x85EC)
+
+#define PCI_PROXY_DATA                 (0x8700)
+#define PCI_PROXY_ADDR                 (0x8704)
+#define PCI_PROXY_CMD                  (0x8708)
+#define PCI_CONTROL                    (0x8710)
+
+/*#define CPC_REGION                   (f0100)*/
+/*#define VLYNQ1_BASE                  (f00a0)*/
+/*#define VLYNQ2_BASE                  (f00b0)*/
+/*#define SCR_IADDR1                   (f00c0)*/
+/*#define SCR_IDATA1                   (f00c0)*/
+/*#define SCR_IADDR2                   (f00c0)*/
+/*#define SCR_IDATA2                   (f00c0)*/
+
+/* SDIO/WSPI*/
+#define        CCCR_1                         (002800)
+#define        CCCR_2                         (002804)
+#define        CCCR_3                         (002808)
+#define        FUN_BASE_REG_1                 (00280C)
+#define        FUN_BASE_REG_2                 (002810)
+#define        FUN_BASE_REG_3                 (002814)
+#define        ADDR_MAP_SIZE_1                (002818)
+#define        ADDR_MAP_SIZE_2                (002820)
+#define        ADDR_MAP_SIZE_3                (002828)
+#define        ADDR_MAP_OFFSET_1              (00281C)
+#define        ADDR_MAP_OFFSET_2              (002824)
+#define        ADDR_MAP_OFFSET_3              (00282C)
+#define        ADDR_MAP_OFFSET_4              (002830)
+#define        CIS_OFFSET                     (002834)
+#define        CSA_OFFSET                     (002838)
+#define        DEBUG_REG_1                    (002840)
+#define        DEBUG_REG_2                    (00283C)
+#define        INTR_MASK                      (002844)
+#define        STATUS_REG                     (002848)
+#define        WR_ERR_LENGTH                  (00284C)
+#define        WR_ERR_ADDR                    (002850)
+#define        OCR                            (002858)
+
+/* UART*/
+/* TODO - fill in registers*/
+
+/* USB1.1 registers*/
+/**/
+#define USB_STS_CLR                    (0x4000)
+#define USB_STS_ND                     (0x4004)
+#define USB_INT_ACK                    (0x4008)
+#define USB_MASK                       (0x400c)
+#define USB_MASK_SET                   (0x4010)
+#define USB_MASK_CLR                   (0x4014)
+#define USB_WU                         (0x4018)
+#define USB_EP0_OUT_PTR                (0x401c)
+#define USB_EP0_OUT_VLD                (0x4020)
+#define USB_EP0_OUT_LEN                (0x4024)
+#define USB_EP0_IN_PTR                 (0x4028)
+#define USB_EP0_IN_VLD                 (0x402c)
+#define USB_EP0_IN_LEN                 (0x4030)
+#define USB_EP1_CFG                    (0x4034)
+#define USB_EP1_OUT_INT_CFG            (0x4038)
+#define USB_EP1_OUT_PTR                (0x403c)
+#define USB_EP1_OUT_VLD                (0x4040)
+#define USB_EP1_OUT_CUR_MBLK           (0x4044)
+#define USB_EP1_OUT_LEN                (0x4048)
+#define USB_EP1_IN_START_MBLK          (0x404c)
+#define USB_EP1_IN_LAST_MBLK           (0x4050)
+#define USB_EP1_IN_VLD                 (0x4054)
+
+#define USB_EP2_PTR                    (0x405c)
+#define USB_EP2_VLD                    (0x4060)
+#define USB_EP2_LEN                    (0x4064)
+#define USB_EP3_OUT_PTR0               (0x4068)
+#define USB_EP3_OUT_VLD0               (0x406c)
+#define USB_EP3_OUT_LEN0               (0x4070)
+#define USB_EP3_OUT_PTR1               (0x4074)
+#define USB_EP3_OUT_VLD1               (0x4078)
+#define USB_EP3_OUT_LEN1               (0x407c)
+#define USB_EP3_IN_PTR0                (0x4080)
+#define USB_EP3_IN_VLD0                (0x4084)
+#define USB_EP3_IN_LEN0                (0x4088)
+#define USB_EP3_IN_PTR1                (0x408c)
+#define USB_EP3_IN_VLD1                (0x4090)
+#define USB_EP3_IN_LEN1                (0x4094)
+#define USB_EP1_OUT_END_MBLK           (0x4098)
+#define USB_EP0_OUT_SETUP              (0x409c)
+#define USB_EP0_STALL                  (0x40a0)
+#define USB_EP1_IN_OFFSET              (0x40a4)
+
+/* Device Configuration registers*/
+#define SOR_CFG                        (0x0800)
+#define ECPU_CTRL                      (0x0804)
+#define HI_CFG                         (0x0808)
+#define EE_START                       (0x080C)
+
+/* IO Control registers*/
+#define SERIAL_HOST_IOCFG0             (0x0894) /* new*/
+#define SERIAL_HOST_IOCFG1             (0x0898) /* new*/
+#define SERIAL_HOST_IOCFG2             (0x089C) /* new*/
+#define SERIAL_HOST_IOCFG3             (0x08A0) /* new*/
+#define GPIO_IOCFG0                    (0x08F4) /* new*/
+#define GPIO_IOCFG1                    (0x08F8) /* new*/
+#define GPIO_IOCFG2                    (0x08FC) /* new*/
+#define GPIO_IOCFG3                    (0x0900) /* new*/
+#define CHIP_ID_B                      (0x5674) /* new*/
+#define CHIP_ID        CHIP_ID_B                               /* Leave for TNETW compatability*/
+#define CHIP_ID_1X50                              (0x4030101)
+
+#define SYSTEM                         (0x0810)
+#define PCI_ARB_CFG                    (0x0814)
+#define BOOT_IRAM_CFG                  (0x0818)
+#define ENABLE                         (0x5450)
+#define MBLK_CFG                       (0x5460)
+#define RS232_BITINTERVAL              (0x0824)
+#define TEST_PORT                      (0x096C)
+#define DEBUG_PORT                     (0x0970)
+
+/* GPIO registers*/
+#define GPIO_OE                        (0x082C) /* 22 GPIOs*/
+#define GPIO_OUT                       (0x0834)
+#define GPIO_IN                        (0x0830)
+#define GPO_CFG                        (0x083C)
+#define PWRDN_BUS_L                    (0x0844)
+#define PWRDN_BUS_H                    (0x0848)
+#define DIE_ID_L                       (0x088C)
+#define DIE_ID_H                       (0x0890)
+
+/* Power Management registers*/
+/* */
+#define ELP_START                      (0x5800)
+#define PLL_CAL_TIME                   (0x5810)
+
+#define CFG_PLL_SYNC_CNT               (0x5820) /* Points to the CFG_PLL_SYNC_CNT_xx registers set*/
+#define CFG_PLL_SYNC_CNT_I             (0x5820)
+#define CFG_PLL_SYNC_CNT_II            (0x5824)
+#define CFG_PLL_SYNC_CNT_III           (0x5828)
+
+#define CFG_ELP_SLEEP_CNT              (0x5830) /* Points to the CFG_ELP_SLEEP_CNT_xx registers set*/
+#define CFG_ELP_SLEEP_CNT_I            (0x5830)
+#define CFG_ELP_SLEEP_CNT_II           (0x5834)
+#define CFG_ELP_SLEEP_CNT_III          (0x5838)
+#define CFG_ELP_SLEEP_CNT_IV           (0x583c)
+
+#define ELP_SLEEP_CNT                  (0x5840) /* Points to the ELP_SLEEP_CNT_xx registers set*/
+#define ELP_SLEEP_CNT_I                (0x5840)
+#define ELP_SLEEP_CNT_II               (0x5844)
+#define ELP_SLEEP_CNT_III              (0x5848)
+#define ELP_SLEEP_CNT_IV               (0x584c)
+
+#define ELP_WAKE_UP_STS                (0x5850)
+#define CFG_SLP_CLK_SEL                (0x5860)
+#define CFG_SLP_CLK_EN                    (0x5870)
+
+#define CFG_WAKE_UP_EN_I               (0x5880)
+#define CFG_WAKE_UP_EN_II              (0x5884)
+#define CFG_WAKE_UP_EN_III             (0x5888)
+
+#define CFG_ELP_PWRDN_I                (0x5890)
+#define CFG_ELP_PWRDN_II               (0x5894)
+#define CFG_ELP_PWRDN_III              (0x5898)
+
+#define CFG_POWER_DOWN_I               (0x58a0)
+#define CFG_POWER_DOWN_II              (0x58a4)
+#define CFG_POWER_DOWN_III             (0x58a8)
+
+#define CFG_BUCK_TESTMODE_I            (0x58b0)
+#define CFG_BUCK_TESTMODE_II           (0x58b4)
+
+#define POWER_STATUS_I                 (0x58C0)
+#define POWER_STATUS_II                (0x58C4)
+
+#define DIGLDO_BIAS_PROG_I             (0x58d0)
+#define DIGLDO_BIAS_PROG_II            (0x58d4)
+
+#define LDO2P8_BIAS_PROG_I             (0x58e0)
+#define LDO2P8_BIAS_PROG_II            (0x58e4)
+
+#define ADCLDO_BIAS_PROG               (0x58f0)
+
+#define REFSYS_PROG_I                  (0x5910)
+#define REFSYS_PROG_II                 (0x5914)
+
+#define PM_TEST_I                      (0x5920)
+#define PM_TEST_II                     (0x5924)
+
+#define POR_PROG                       (0x5930)
+
+#define TEST_PIN_DIR_I                 (0x5940)
+#define TEST_PIN_DIR_II                (0x5944)
+
+#define PROC_CTL                       (0x5950)
+
+#define ADC_REF_WAKEUP_I               (0x5960)
+#define ADC_REF_WAKEUP_II              (0x5964)
+#define ADC_REF_WAKEUP_III             (0x5968)
+#define ADC_REF_WAKEUP_IV              (0x596C)
+
+#define VREG_WAKEUP_I                  (0x5970)
+#define VREG_WAKEUP_II                 (0x5974)
+#define VREG_WAKEUP_III                (0x5978)
+#define VREG_WAKEUP_IV                 (0x597C)
+
+#define PLL_WAKEUP_I                   (0x5980)
+#define PLL_WAKEUP_II                  (0x5984)
+#define PLL_WAKEUP_III                 (0x5988)
+#define PLL_WAKEUP_IV                  (0x598C)
+
+#define XTALOSC_WAKEUP_I               (0x5990)
+#define XTALOSC_WAKEUP_II              (0x5994)
+#define XTALOSC_WAKEUP_III             (0x5998)
+#define XTALOSC_WAKEUP_IV              (0x599C)
+
+/* ----------*/
+
+#define POWER_MGMT2                    (0x0840)
+#define POWER_MGMT                     (0x5098)
+#define MAC_HW_DOZE                    (0x090c)
+#define ECPU_SLEEP                     (0x0840)
+#define DOZE_CFG                       (0x54bc)
+#define DOZE2_CFG                      (0x081c)
+#define WAKEUP_CFG                     (0x54c0)
+#define WAKEUP_TIME_L                  (0x54c8)
+#define WAKEUP_TIME_H                  (0x54c4)
+
+/**/
+
+/*#define CPU_WAIT_CFG                 (f0020)*/
+/*#define CFG_QOS_ACM                  (f0046)*/
+
+/* Scratch Pad registers*/
+#define SCR_PAD0                       (0x5608)
+#define SCR_PAD1                       (0x560C)
+#define SCR_PAD2                       (0x5610)
+#define SCR_PAD3                       (0x5614)
+#define SCR_PAD4                       (0x5618)
+#define SCR_PAD4_SET                   (0x561C)
+#define SCR_PAD4_CLR                   (0x5620)
+#define SCR_PAD5                       (0x5624)
+#define SCR_PAD5_SET                   (0x5628)
+#define SCR_PAD5_CLR                   (0x562C)
+#define SCR_PAD6                       (0x5630)
+#define SCR_PAD7                       (0x5634)
+#define SCR_PAD8                       (0x5638)
+#define SCR_PAD9                       (0x563C)
+
+/* Spare registers*/
+#define SPARE_A1                       (0x0994)
+#define SPARE_A2                       (0x0998)
+#define SPARE_A3                       (0x099C)
+#define SPARE_A4                       (0x09A0)
+#define SPARE_A5                       (0x09A4)
+#define SPARE_A6                       (0x09A8)
+#define SPARE_A7                       (0x09AC)
+#define SPARE_A8                       (0x09B0)
+#define SPARE_B1                       (0x5420)
+#define SPARE_B2                       (0x5424)
+#define SPARE_B3                       (0x5428)
+#define SPARE_B4                       (0x542C)
+#define SPARE_B5                       (0x5430)
+#define SPARE_B6                       (0x5434)
+#define SPARE_B7                       (0x5438)
+#define SPARE_B8                       (0x543C)
+
+/* RMAC registers (Raleigh MAC)*/
+
+/* Station registers*/
+#define DEV_MODE                       (0x5464)
+#define STA_ADDR_L                     (0x546C)
+#define STA_ADDR_H                     (0x5470)
+#define BSSID_L                        (0x5474)
+#define BSSID_H                        (0x5478)
+#define AID_CFG                        (0x547C)
+#define BASIC_RATE_CFG                 (0x4C6C)
+#define BASIC_RATE_TX_CFG              (0x55F0)
+
+/* Protocol timers registers*/
+#define IFS_CFG0                       (0x5494)
+#define IFS_CFG1                       (0x5498)
+#define TIMEOUT_CFG                    (0x549C)
+#define CONT_WIND_CFG                  (0x54A0)
+#define BCN_INT_CFG                    (0x54A4)
+#define RETRY_CFG                      (0x54A8)
+#define DELAY_CFG                      (0x54B0)
+
+/* Hardware Override registers*/
+#define CCA_CFG                        (0x54CC)
+#define CCA_FILTER_CFG                 (0x5480)
+#define RADIO_PLL_CFG                  (0x555C)
+#define CCA_MON                        (0x54D0)
+#define TX_FRM_CTL                     (0x54D4)
+#define CONT_TX_EN                     (0x50EC)
+#define PHY_STANDBY_EN                 (0x5668)
+
+/* Transmit Setup registers*/
+#define TX_PING_PONG                   (0x5090)
+#define TX_CFG0                        (0x5000)
+#define TX_CFG1                        (0x5004)
+#define TX_CFG2                        (0x5008)
+#define MAX_LIFETIME                   (0x50FC)
+#define TX_PANG_SEL                    (0x50E0)
+#define TX_PANG0                       (0x50A0)
+#define TX_PING0                       (0x5010)
+#define TX_PONG0                       (0x5050)
+#define TX_PANG1                       (0x50A4)
+#define TX_PING1                       (0x5014)
+#define TX_PONG1                       (0x5054)
+#define TX_PANG2                       (0x50A8)
+#define TX_PING2                       (0x5018)
+#define TX_PONG2                       (0x5058)
+#define TX_PANG3                       (0x50AC)
+#define TX_PING3                       (0x501C)
+#define TX_PONG3                       (0x505C)
+#define TX_PANG4                       (0x50B0)
+#define TX_PING4                       (0x5020)
+#define TX_PONG4                       (0x5060)
+#define TX_PANG5                       (0x50B4)
+#define TX_PING5                       (0x5024)
+#define TX_PONG5                       (0x5064)
+#define TX_PANG6                       (0x50B8)
+#define TX_PING6                       (0x5028)
+#define TX_PONG6                       (0x5068)
+#define TX_PANG7                       (0x50BC)
+#define TX_PING7                       (0x502C)
+#define TX_PONG7                       (0x506C)
+#define TX_PANG8                       (0x50C0)
+#define TX_PING8                       (0x5030)
+#define TX_PONG8                       (0x5070)
+#define TX_PANG9                       (0x50C4)
+#define TX_PING9                       (0x5034)
+#define TX_PONG9                       (0x5074)
+#define TX_PANG10                      (0x50C8)
+#define TX_PING10                      (0x5038)
+#define TX_PONG10                      (0x5078)
+#define TX_PANG11                      (0x50CC)
+#define TX_PING11                      (0x503C)
+#define TX_PONG11                      (0x507C)
+
+/* Transmit Status registers*/
+#define TX_STATUS                      (0x509C)
+#define TX_PANG_EXCH                   (0x50D0)
+#define TX_PING_EXCH                   (0x5040)
+#define TX_PONG_EXCH                   (0x5080)
+#define TX_PANG_ATT                    (0x50D4)
+#define TX_PING_ATT                    (0x5044)
+#define TX_PONG_ATT                    (0x5084)
+#define TX_PANG_TIMESTAMP              (0x50DC)
+#define TX_PING_TIMESTAMP              (0x504C)
+#define TX_PONG_TIMESTAMP              (0x508C)
+
+/* Transmit State registers*/
+#define TX_STATE                       (0x5094)
+#define TX_PANG_OVRD_CFG               (0x50D8)
+#define TX_PING_OVRD_CFG               (0x5048)
+#define TX_PONG_OVRD_CFG               (0x5088)
+#define TX_HOLD_CFG                    (0x54D8)
+#define TSF_ADJ_CFG1                   (0x54DC)
+#define TSF_ADJ_CFG2                   (0x54E0)
+#define TSF_ADJ_CFG3                   (0x54E4)
+#define TSF_ADJ_CFG4                   (0x54E8)
+#define CFG_OFDM_TIMES0                (0x5648)
+#define CFG_OFDM_TIMES1                (0x564C)
+
+/* Beacon/Probe Response registers*/
+#define PRB_ADDR                       (0x54EC)
+#define PRB_LENGTH                     (0x54F0)
+#define BCN_ADDR                       (0x54F4)
+#define BCN_LENGTH                     (0x54F8)
+#define TIM_VALID0                     (0x54FC)
+#define TIM_ADDR0                      (0x5500)
+#define TIM_LENGTH0                    (0x5504)
+#define TIM_VALID1                     (0x5654)
+#define TIM_ADDR1                      (0x5658)
+#define TIM_LENGTH1                    (0x565C)
+#define TIM_SELECT                     (0x5660)
+#define TSF_CFG                        (0x5508)
+
+/* Other Hardware Generated Frames regi*/
+#define CTL_FRM_CFG                    (0x550C)
+#define MGMT_FRM_CFG                   (0x5510)
+#define CFG_ANT_SEL                    (0x5664)
+#define RMAC_ADDR_BASE                 (0x5680) /* new*/
+
+/* Protocol Interface Read Write Interf*/
+#define TXSIFS_TIMER                   (0x4C00)
+#define TXPIFS_TIMER                   (0x4C04)
+#define TXDIFS_TIMER                   (0x4C08)
+#define SLOT_TIMER                     (0x4C0C)
+#define BACKOFF_TIMER                  (0x4C10)
+#define BCN_PSP_TIMER                  (0x4C14)
+#define NAV                            (0x4C18)
+#define TSF_L                          (0x4C1C)
+#define TSF_H                          (0x4C20)
+#define TSF_PREV_L                     (0x4CC4) /* new */
+#define TSF_PREV_H                     (0x4CC8) /* new */
+#define TOUT_TIMER                     (0x4C2C)
+#define NEXT_TBTT_L                    (0x4C30)
+#define NEXT_TBTT_H                    (0x4C34)
+#define DTIM_CNT                       (0x4C38)
+#define CONT_WIND                      (0x4C3C)
+#define PRSP_REQ                       (0x4C40)
+#define PRSP_DA_L                      (0x4C44)
+#define PRSP_DA_H                      (0x4C48)
+#define PRSP_RETRY                     (0x4C4C)
+#define PSPOLL_REQ                     (0x4C50)
+#define NEXT_SEQ_NUM                   (0x4C54)
+#define PRSP_SEQ_NUM                   (0x4C58)
+#define BCN_SEQ_NUM                    (0x4C5C)
+#define MED_USAGE                      (0x4C24)
+#define MED_USAGE_TM                   (0x4C28)
+#define PRB_DLY                        (0x4C60)
+#define STA_SRC                        (0x4C64)
+#define STA_LRC                        (0x4C68)
+#define CFG_ACM                        (0x4C70)
+#define RAND_NUMB                      (0x4C6C)
+#define CFG_ACK_CTS_DOT11A             (0x4C74)
+#define CFG_ACK_CTS_DOT11B             (0x4C78)
+#define ACM_IFS_CFG0                   (0x4C7C)
+#define ACM_IFS_CFG1                   (0x4C80)
+#define ACM_IFS_CFG2                   (0x4C84)
+#define ACM_IFS_CFG3                   (0x4C88)
+#define ACK_CTS_FRM_CFG                (0x4C8C)
+#define CFG_RX_TSTMP_DLY0              (0x4C90)
+#define CFG_RX_TSTMP_DLY1              (0x4C94)
+#define CFG_RX_TSTMP_DLY2              (0x4C98)
+#define CFG_RX_TSTMP_DLY3              (0x4C9C)
+#define CCA_BUSY                       (0x4CA0)
+#define CCA_BUSY_CLR                   (0x4CA4)
+#define CCA_IDLE                       (0x4CA8)
+#define CCA_IDLE_CLR                   (0x4CAC)
+
+/* Receive Manager registers*/
+#define RX_HEAD_PTR                    (0x567C) /* new*/
+#define RX_TAIL_PTR                    (0x4898) /* new*/
+#define RX_CURR_PTR                    (0x5678) /* new*/
+#define RX_RESET                       (0x4800)
+#define RX_MODMODE                     (0x4838) /* new*/
+#define MAC_HEADER_BYTECNT             (0x4890)
+#define RX_MAC_BYTECNT_INT             (0x489C)
+#define MAC_HEADER_WORD0               (0x4868)
+#define MAC_HEADER_WORD1               (0x486C)
+#define MAC_HEADER_WORD2               (0x4870)
+#define MAC_HEADER_WORD3               (0x4874)
+#define MAC_HEADER_WORD4               (0x4878)
+#define MAC_HEADER_WORD5               (0x487C)
+#define MAC_HEADER_WORD6               (0x4880)
+#define MAC_HEADER_WORD7               (0x4884)
+#define MAC_HEADER_WORD8               (0x4888)
+#define MAC_HEADER_WORD9               (0x488C)
+#define RX_CFG                         (0x5514)
+#define RX_FILTER_CFG                  (0x55B4)
+#define RX_MC0_L                       (0x5518)
+#define RX_MC0_H                       (0x551C)
+#define RX_MC1_L                       (0x5520)
+#define RX_MC1_H                       (0x5524)
+#define STA_SSID0                      (0x4804)
+#define STA_SSID1                      (0x4808)
+#define STA_SSID2                      (0x480C)
+#define STA_SSID3                      (0x4810)
+#define STA_SSID4                      (0x4814)
+#define STA_SSID5                      (0x4818)
+#define STA_SSID6                      (0x481C)
+#define STA_SSID7                      (0x4820)
+#define SSID_LEN                       (0x4824)
+#define RX_FREE_MEM                    (0x5528)
+#define RX_CURR_MEM                    (0x552C)
+#define MAC_TIMESTAMP                  (0x5560) /* Check place*/
+#define RX_TIMESTAMP                   (0x5564)
+#define RX_FRM_PTR                     (0x5568)
+#define RX_FRM_LEN                     (0x556C)
+#define RX_PLCP_HDR                    (0x5570)
+#define RX_PLCP_SIGNAL                 (0x5574)
+#define RX_PLCP_SERVICE                (0x5578) /* 16 bits ?*/
+#define RX_PLCP_LENGTH                 (0x557C)
+#define RX_FRM_CTL                     (0x5580)
+#define RX_DUR_ID                      (0x5584)
+#define RX_ADDR1_L                     (0x5588)
+#define RX_ADDR1_H                     (0x558C)
+#define RX_ADDR2_L                     (0x5590)
+#define RX_ADDR2_H                     (0x5594)
+#define RX_ADDR3_L                     (0x5598)
+#define RX_ADDR3_H                     (0x559C)
+#define RX_SEQ_CTL                     (0x55A0)
+#define RX_WEP_IV                      (0x55A4)
+#define RX_TIME_L                      (0x55A8)
+#define RX_TIME_H                      (0x55AC)
+#define RX_STATUS                      (0x55B0)
+#define PLCP_ERR_CNT                   (0x4828)
+#define FCS_ERR_CNT                    (0x482C)
+#define RX_OVERFLOW_CNT                (0x4830)
+#define RX_DEBUG1                      (0x4858)
+#define RX_DEBUG2                      (0x485C)
+#define RX_QOS_CFG                     (0x4848)
+#define RX_QOS_CTL                     (0x4844)
+#define RX_QOS_STATUS                  (0x4854) /* new name RX_QOS_STS*/
+#define RX_TXOP_HOLDER_L               (0x484C)
+#define RX_TXOP_HOLDER_H               (0x4850)
+#define RX_FRM_CNT                     (0x4834) /* what is RX_FRM_CTR*/
+#define CONS_FCS_ERR_CNT               (0x483C)
+#define CONS_FCS_ERR_CFG               (0x4840)
+#define RX_QOS_CTL_MASK                (0x48A0) /* new*/
+#define RX_QOS_ACK_EN                  (0x48A4) /* new*/
+#define RX_QOS_NOACK_EN                (0x48A8) /* new*/
+#define RX_QOS_ACK_BITMAP              (0x48AC) /* new*/
+
+/* Baseband Processor registers*/
+#define SBB_CFG                        (0x55C8)
+#define SBB_ADDR                       (0x55D0)
+#define SBB_DATA                       (0x55D4)
+#define SBB_CTL                        (0x55D8)
+
+/* Radio Control Interface registers*/
+#define RCI_CTL                        (0x55DC)
+#define RCI_DATA                       (0x55E0)
+#define RCI_CFG1                       (0x55E4)
+#define RCI_CFG2                       (0x55E8)
+#define RCI_CFG3                       (0x55EC)
+
+#define TNET1150_LAST_REG_ADDR                 PCI_CONTROL
+
+
+/* Missing registers*/
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1150/whalHwRegs.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1150/whalHwRegs.h
new file mode 100644 (file)
index 0000000..fe3b148
--- /dev/null
@@ -0,0 +1,57 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwRegs.h
+ *   PURPOSE: Contains Wlan hardware registers defines/structures
+ *   
+ ****************************************************************************/
+
+#ifndef _WHAL_ACX_REGS_H
+#define _WHAL_ACX_REGS_H
+
+#include "TnetwRegisters.h"
+
+#define REG_DEVICE_VENDOR_ID                           PCI_BE_VENDOR_ID_REG
+#define ACX_VENDOR_ID                                          0x104C
+#define ACX_DEVICE_ID                                          0x9068  /* --- 1150*/
+#define ECPU_CONTROL_HALT                                      0x00000101                              
+#define ACX_CLK_CFG_ARM_80_MAC_40_MHZ          0x2
+#define ACX_MAC_REG_READ_WRITE_PREFIX       0x300000
+
+#endif   /* _WHAL_ACX_REGS_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1251/TnetwRegisters.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1251/TnetwRegisters.h
new file mode 100644 (file)
index 0000000..aa226a2
--- /dev/null
@@ -0,0 +1,971 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef RGM_TNETW1150_H
+#define RGM_TNETW1150_H
+
+#include "public_types.h"
+
+
+/* Base addresses*/
+/* They are not used inside registers definition in purpose to allow this header file*/
+/* to be used as an easy reference to register -> address date base. Keep this as it*/
+/* is very powerful for debugging purpose.*/
+#define HOST_SLAVE_BASE        0x00300000
+#define INT_BASE               0x00300400
+#define REG_CONFIG_BASE        0x00300800
+#define CLK_BASE               0x00300C00
+#define SDMA_BASE              0x00301000
+#define AES_BASE               0x00301400
+#define WEP_BASE               0x00301800
+#define TKIP_BASE              0x00301C00
+#define SEEPROM_BASE   0x00302000
+#define PAR_HOST_BASE  0x00302400
+#define SDIO_BASE              0x00302800
+#define UART_BASE              0x00302C00
+#define USB11_BASE             0x00304000
+#define LDMA_BASE              0x00304400
+#define RX_BASE                        0x00304800
+#define ACCESS_BASE            0x00304c00
+#define TX_BASE                        0x00305000
+#define RMAC_CSR_BASE  0x00305400
+#define AFE_PM                 0x00305800
+#define VLYNQ_BASE             0x00308000
+#define PCI_BASE               0x00308400
+#define USB20_BASE             0x0030A000
+#define PHY_BASE               0x003C0000
+
+
+/* System DMA registers*/
+/* Order of registers was changed*/
+#define DMA_GLB_CFG                    (0x1000)
+#define DMA_HDESC_OFFSET               (0x1004)
+#define DMA_HDATA_OFFSET               (0x1008)
+#define DMA_CFG0                       (0x100C) /* SDMA_HOST_CFG0 changed*/
+#define DMA_CTL0                       (0x1010) /* SDMA_CTRL0 changed*/
+#define DMA_LENGTH0                    (0x1014)
+#define DMA_L_ADDR0                    (0x1018) /* SDMA_RD_ADDR ?*/
+#define DMA_L_PTR0                     (0x101C) /* SDMA_RD_OFFSET ?*/
+#define DMA_H_ADDR0                    (0x1020) /* SDMA_WR_ADDR ?*/
+#define DMA_H_PTR0                     (0x1024) /* SDMA_WR_OFFSET ?*/
+#define DMA_STS0                       (0x1028) /* Changed*/
+#define DMA_CFG1                       (0x1030) /* SDMA_HOST_CFG1 changed*/
+#define DMA_CTL1                       (0x1034) /* SDMA_CTRL1 changed*/
+#define DMA_LENGTH1                    (0x1038)
+#define DMA_L_ADDR1                    (0x103C)
+#define DMA_L_PTR1                     (0x1040)
+#define DMA_H_ADDR1                    (0x1044)
+#define DMA_H_PTR1                     (0x1048)
+#define DMA_STS1                       (0x104C)
+#define DMA_HFRM_PTR                   (0x1050) /* New ?*/
+#define DMA_DEBUG                      (0x1054) /* Changed*/
+
+/* Local DMA registers*/
+/* number changed from 4 to 2*/
+#define LDMA_DEBUG                     (0x4400)
+#define LDMA_CTL0                      (0x4404) /* Add 2 bits to support fix address (FIFO)*/
+#define LDMA_STATUS0                   (0x4408)
+#define LDMA_LENGTH0                   (0x440c)
+#define LDMA_RD_ADDR0                  (0x4410)
+#define LDMA_RD_OFFSET0                (0x4414)
+#define LDMA_WR_ADDR0                  (0x4418)
+#define LDMA_WR_OFFSET0                (0x441c)
+#define LDMA_CTL1                      (0x4428) /* Add 2 bits to support fix address (FIFO)*/
+#define LDMA_STATUS1                   (0x442c)
+#define LDMA_LENGTH1                   (0x4430)
+#define LDMA_RD_ADDR1                  (0x4434)
+#define LDMA_RD_OFFSET1                (0x4438)
+#define LDMA_WR_ADDR1                  (0x443c)
+#define LDMA_WR_OFFSET1                (0x4440)
+/* For TNETW compatability (if willbe )*/
+#define LDMA_CUR_RD_PTR0               LDMA_RD_ADDR0
+#define LDMA_CUR_WR_PTR0               LDMA_WR_ADDR0
+#define LDMA_CUR_RD_PTR1               LDMA_RD_ADDR1
+#define LDMA_CUR_WR_PTR1               LDMA_WR_ADDR1
+
+/* Host Slave registers*/
+#define SLV_SOFT_RESET                 (0x0000) /* self clearing*/
+#define SLV_REG_ADDR                   (0x0004)
+#define SLV_REG_DATA                   (0x0008)
+#define SLV_REG_ADATA                  (0x000c)
+#define SLV_MEM_CP                     (0x0010)
+#define SLV_MEM_ADDR                   (0x0014)
+#define SLV_MEM_DATA                   (0x0018)
+#define SLV_MEM_CTL                    (0x001c) /* bit 19 moved to PCMCIA_CTL*/
+#define SLV_END_CTL                    (0x0020) /* 2 bits moved to ENDIAN_CTL*/
+
+/* Timer registers*/
+/* Timer1/2 count MAC clocks*/
+/* Timer3/4/5 count usec*/
+#define TIM1_CTRL                      (0x0918)
+#define TIM1_LOAD                      (0x091C)
+#define TIM1_CNT                       (0x0920)
+#define TIM2_CTRL                      (0x0924)
+#define TIM2_LOAD                      (0x0928)
+#define TIM2_CNT                       (0x092C)
+#define TIM3_CTRL                      (0x0930)
+#define TIM3_LOAD                      (0x0934)
+#define TIM3_CNT                       (0x0938)
+#define TIM4_CTRL                      (0x093C)
+#define TIM4_LOAD                      (0x0940)
+#define TIM4_CNT                       (0x0944)
+#define TIM5_CTRL                      (0x0948)
+#define TIM5_LOAD                      (0x094C)
+#define TIM5_CNT                       (0x0950)
+
+/* Watchdog registers*/
+#define WDOG_CTRL                      (0x0954)
+#define WDOG_LOAD                      (0x0958)
+#define WDOG_CNT                       (0x095C)
+#define WDOG_STS                       (0x0960)
+#define WDOG_FEED                      (0x0964)
+
+/* Interrupt registers*/
+/* 64 bit interrupt sources registers ws ced. sme interupts were removed and new ones were added*/
+/* Order was changed*/
+#define FIQ_MASK                       (0x0400)
+#define FIQ_MASK_L                     (0x0400)
+#define FIQ_MASK_H                     (0x0404)
+#define FIQ_MASK_SET                   (0x0408)
+#define FIQ_MASK_SET_L                 (0x0408)
+#define FIQ_MASK_SET_H                 (0x040C)
+#define FIQ_MASK_CLR                   (0x0410)
+#define FIQ_MASK_CLR_L                 (0x0410)
+#define FIQ_MASK_CLR_H                 (0x0414)
+#define IRQ_MASK                       (0x0418)
+#define IRQ_MASK_L                     (0x0418)
+#define IRQ_MASK_H                     (0x041C)
+#define IRQ_MASK_SET                   (0x0420)
+#define IRQ_MASK_SET_L                 (0x0420)
+#define IRQ_MASK_SET_H                 (0x0424)
+#define IRQ_MASK_CLR                   (0x0428)
+#define IRQ_MASK_CLR_L                 (0x0428)
+#define IRQ_MASK_CLR_H                 (0x042C)
+#define ECPU_MASK                      (0x0448)
+#define FIQ_STS_L                      (0x044C)
+#define FIQ_STS_H                      (0x0450)
+#define IRQ_STS_L                      (0x0454)
+#define IRQ_STS_H                      (0x0458)
+#define INT_STS_ND                     (0x0464)
+#define INT_STS_RAW_L                  (0x0464)
+#define INT_STS_RAW_H                  (0x0468)
+#define INT_STS_CLR                    (0x04B4)
+#define INT_STS_CLR_L                  (0x04B4)
+#define INT_STS_CLR_H                  (0x04B8)
+#define INT_ACK                        (0x046C)
+#define INT_ACK_L                      (0x046C)
+#define INT_ACK_H                      (0x0470)
+#define INT_TRIG                       (0x0474)
+#define INT_TRIG_L                     (0x0474)
+#define INT_TRIG_H                     (0x0478)
+#define HOST_STS_L                     (0x045C)
+#define HOST_STS_H                     (0x0460)
+#define HOST_MASK                      (0x0430)
+#define HOST_MASK_L                    (0x0430)
+#define HOST_MASK_H                    (0x0434)
+#define HOST_MASK_SET                  (0x0438)
+#define HOST_MASK_SET_L                (0x0438)
+#define HOST_MASK_SET_H                (0x043C)
+#define HOST_MASK_CLR                  (0x0440)
+#define HOST_MASK_CLR_L                (0x0440)
+#define HOST_MASK_CLR_H                (0x0444)
+
+/* GPIO Interrupts*/
+#define GPIO_INT_STS                   (0x0484) /* 22 GPIOs*/
+#define GPIO_INT_ACK                   (0x047C)
+#define GPIO_INT_MASK                  (0x0480)
+#define GPIO_POS_MASK                  (0x04BC) /* New*/
+#define GPIO_NEG_MASK                  (0x04C0) /* New*/
+
+/* Protocol Interrupts*/
+#define PROTO_INT_STS                  (0x0490) /* Add 2 PHY->MAC source interrupts*/
+#define PROTO_INT_ACK                  (0x0488)
+#define PROTO_INT_MASK                 (0x048C)
+
+/* Host Interrupts*/
+#define HINT_MASK                      (0x0494)
+#define HINT_MASK_SET                  (0x0498)
+#define HINT_MASK_CLR                  (0x049C)
+#define HINT_STS_ND_MASKED             (0x04A0)
+#define HINT_STS_ND                       (0x04B0) /*1150 spec calls this HINT_STS_RAW*/
+#define HINT_STS_CLR                   (0x04A4)
+#define HINT_ACK                       (0x04A8)
+#define HINT_TRIG                      (0x04AC)
+
+/* Clock registers*/
+#define CLK_CFG                        (0x0C00) /* new ARM clock bit */
+#define CLK_CTRL                       (0x0C04) /* changed*/
+#define BLK_RST                        (0x0C08) /* changed*/
+#define CFG_USEC_STB                   (0x0C0C)
+#define ARM_GATE_CLK_REG               (0x0C10) /* new*/
+#define BUSY_STAT_REG                  (0x0C14) /* new*/
+#define CFG_PHY_CLK88                  (0x0C18)
+#define DYNAMIC_CLKGATE                (0x0C1C) /* new*/
+
+/* AES registers*/
+/* Major changes to this module*/
+#define AES_START                      (0x1400)
+#define AES_CFG                        (0x1404)
+#define AES_CTL                        (0x1408)
+#define AES_STATUS                     (0x140C)
+#define AES_LENGTH                     (0x1410)
+#define AES_RD_ADDR                    (0x1414)
+#define AES_RD_OFFSET                  (0x1418)
+#define AES_WR_ADDR                    (0x141C)
+#define AES_WR_OFFSET                  (0x1420)
+#define AES_CUR_RD_PTR                 (0x1424)
+#define AES_CUR_WR_PTR                 (0x1428)
+#define AES_KEY_0                      (0x142C)
+#define AES_KEY_1                      (0x1430)
+#define AES_KEY_2                      (0x1434)
+#define AES_KEY_3                      (0x1438)
+#define AES_NONCE_0                    (0x143C)
+#define AES_NONCE_1                    (0x1440)
+#define AES_NONCE_2                    (0x1444)
+#define AES_NONCE_3                    (0x1448)
+#define AES_MIC_0                      (0x144C)
+#define AES_MIC_1                      (0x1450)
+#define AES_MIC_2                      (0x1454)
+#define AES_MIC_3                      (0x1458)
+#define AES_ASSO_DATA_0                (0x145C)
+#define AES_ASSO_DATA_1                (0x1460)
+#define AES_ASSO_DATA_2                (0x1464)
+#define AES_ASSO_DATA_3                (0x1468)
+#define AES_NUM_OF_ROUNDS              (0x146C)
+#define AES_TX_QUEUE_PTR               (0x1470)
+#define AES_RX_QUEUE_PTR               (0x1474)
+#define AES_STACK                      (0x1478)
+#define AES_INT_RAW                    (0x147C)
+#define AES_INT_MASK                   (0x1480)
+#define AES_INT_STS                    (0x1484)
+
+/* WEP registers*/
+/* Order was changed*/
+#define DEC_CTL                        (0x1800)
+#define DEC_STATUS                     (0x1804)
+#define DEC_MBLK                       (0x1808)
+#define DEC_KEY_ADDR                   (0x180C)
+#define DEC_KEY_LEN                    (0x1810)
+#define DEC_ADDR_UPPER_BYTE            (0x1814) /* new*/
+#define DEC_LEN                        (0x1818)
+#define DEC_OFFSET                     (0x181C)
+#define DEC_WR_MBLK                    (0x1820)
+#define DEC_WR_OFFSET                  (0x1824)
+
+/* TKIP MICHAEL reisters*/
+/* order changed*/
+#define MCHL_START0                    (0x1C00)
+#define MCHL_DMV_START_MBLK0           (0x1C04) /* Changed to 23:5 format*/
+#define MCHL_DMV_CUR_MBLK0             (0x1C10)
+#define MCHL_DMV_OFFSET0               (0x1C08)
+#define MCHL_DMV_LENGTH0               (0x1C0C)
+#define MCHL_DMV_CFG0                  (0x1C14)
+#define MCHL_KEY_L0                    (0x1C18)
+#define MCHL_KEY_H0                    (0x1C1C)
+#define MCHL_MIC_L0                    (0x1C20)
+#define MCHL_MIC_H0                    (0x1C24)
+#define MCHL_START1                    (0x1C28)
+#define MCHL_DMV_START_MBLK1           (0x1C2C) /* Changed to 23:5 format*/
+#define MCHL_DMV_CUR_MBLK1             (0x1C38)
+#define MCHL_DMV_OFFSET1               (0x1C30)
+#define MCHL_DMV_LENGTH1               (0x1C34)
+#define MCHL_DMV_CFG1                  (0x1C3C)
+#define MCHL_KEY_L1                    (0x1C40)
+#define MCHL_KEY_H1                    (0x1C44)
+#define MCHL_MIC_L1                    (0x1C48)
+#define MCHL_MIC_H1                    (0x1C4C)
+#define MCHL_CTL0                      (0x1C50) /* new name MCHL_CTRL0*/
+#define MCHL_CTL1                      (0x1C54) /* new name MCHL_CTRL1*/
+#define MCHL_UPPER_BYTE_ADDR0          (0x1C58) /* new*/
+#define MCHL_UPPER_BYTE_ADDR1          (0x1C5C) /* new*/
+
+/* SEEPROM registers*/
+#define EE_CFG                         (0x0820)
+#define EE_CTL                         (0x2000)
+#define EE_DATA                        (0x2004)
+#define EE_ADDR                        (0x2008)
+
+/* Parallel Host (PCI/CARDBUS/PCMCIA/GS*/
+#define CIS_LADDR                      (0x2400)
+#define HI_CTL                         (0x2404)
+#define LPWR_MGT                       (0x2408)
+/*#define PDR0                         (0x04ec)*/
+/*#define PDR1                         (0x04f0)*/
+/*#define PDR2                         (0x04f4)*/
+/*#define PDR3                         (0x04f8)*/
+/*#define BAR2_ENABLE                  (0x04fc)*/
+/*#define BAR2_TRANS                   (0x0500)*/
+/*#define BAR2_MASK                    (0x0504)*/
+#define PCI_MEM_SIZE1                  (0x2428)
+#define PCI_MEM_OFFSET1                (0x242C)
+#define PCI_MEM_OFFSET2                (0x2430)
+/*#define PCI_IO_SIZE1                 (0x0514)*/
+/*#define PCI_IO_OFFSET1               (0x0518)*/
+/*#define PCI_IO_OFFSET2               (0x051c)*/
+/*#define PCI_CFG_OFFSET               (0x0520)*/
+#define PCMCIA_CFG                     (0x2444)
+#define PCMCIA_CTL                     (0x2448)
+#define PCMCIA_CFG2                    (0x244C) /* new*/
+#define SRAM_PAGE                      (0x2450)
+#define CFG_PULLUPDN                   (0x2454)
+#define CIS_MAP                        (0x2458) /* new*/
+#define ENDIAN_CTRL                    (0x245C) /* new*/
+#define GS_SLEEP_ACCESS                (0x2480) /* new*/
+#define PCMCIA_PWR_DN                  (0x04C4) 
+#define PCI_OUTPUT_DLY_CFG             (0x2464) /* new*/
+
+/* VLYNQ registers*/
+/* VLYNQ2 was removed from hardware*/
+#define VL1_REV_ID                     (0x8000) /* VLYNQ_REVISION*/
+#define VL1_CTL                        (0x8004) /* VLYNQ_ CONTROL*/
+#define VL1_STS                        (0x8008) /* VLYNQ_STATUS*/
+#define VLYNQ_INTVEC                   (0x800C)
+#define VL1_INT_STS                    (0x8010) /* VLYNQ_INTCR*/
+#define VL1_INT_PEND                   (0x8014) /* VLYNQ_INTSR*/
+#define VL1_INT_PTR                    (0x8018) /* VLYNQ_INTPTR*/
+#define VL1_TX_ADDR                    (0x801C) /* VLYNQ_TX_MAP_ADDR*/
+#define VL1_RX_SIZE1                   (0x8020) /* VLYNQ_RX_MAP_SIZE1*/
+#define VL1_RX_OFF1                    (0x8024) /* VLYNQ_RX_MAP_OFFSET1*/
+#define VL1_RX_SIZE2                   (0x8028) /* VLYNQ_RX_MAP_SIZE2*/
+#define VL1_RX_OFF2                    (0x802C) /* VLYNQ_RX_MAP_OFFSET2*/
+#define VL1_RX_SIZE3                   (0x8030) /* VLYNQ_RX_MAP_SIZE3*/
+#define VL1_RX_OFF3                    (0x8034) /* VLYNQ_RX_MAP_OFFSET3*/
+#define VL1_RX_SIZE4                   (0x8038) /* VLYNQ_RX_MAP_SIZE4*/
+#define VL1_RX_OFF4                    (0x803C) /* VLYNQ_RX_MAP_OFFSET4*/
+#define VL1_CHIP_VER                   (0x8040) /* VLYNQ_CHIP_VER*/
+#define VLYNQ_AUTONEG                  (0x8044)
+#define VLYNQ_MANNEG                   (0x8048)
+#define VLYNQ_NEGSTAT                  (0x804C)
+#define VLYNQ_ENDIAN                   (0x805C)
+#define VL1_INT_VEC3_0                 (0x8060) /* VLYNQ_HW_INT3TO0_CFG*/
+#define VL1_INT_VEC7_4                 (0x8064) /* VLYNQ_HW_INT7TO4_CFG*/
+/* VLYNQ Remote configuration registers*/
+#define VL1_REM_REV_ID                 (0x8080) /* VLYNQ_REM_REVISION*/
+#define VL1_REM_CTL                    (0x8084) /* VLYNQ_REM_ CONTROL*/
+#define VL1_REM_STS                    (0x8088) /* VLYNQ_REM_STATUS*/
+#define VLYNQ_REM_INTVEC               (0x808C)
+#define VL1_REM_INT_STS                (0x8090) /* VLYNQ_REM_INTCR*/
+#define VL1_REM_INT_PEND               (0x8094) /* VLYNQ_REM_INTSR*/
+#define VL1_REM_INT_PTR                (0x8098) /* VLYNQ_REM_INTPTR*/
+#define VL1_REM_TX_ADDR                (0x809C) /* VLYNQ_REM_TX_MAP_ADDR*/
+#define VL1_REM_RX_SIZE1               (0x80A0) /* VLYNQ_REM_RX_MAP_SIZE1*/
+#define VL1_REM_RX_OFF1                (0x80A4) /* VLYNQ_REM_RX_MAP_OFFSET1*/
+#define VL1_REM_RX_SIZE2               (0x80A8) /* VLYNQ_REM_RX_MAP_SIZE2*/
+#define VL1_REM_RX_OFF2                (0x80AC) /* VLYNQ_REM_RX_MAP_OFFSET2*/
+#define VL1_REM_RX_SIZE3               (0x80B0) /* VLYNQ_REM_RX_MAP_SIZE3*/
+#define VL1_REM_RX_OFF3                (0x80B4) /* VLYNQ_REM_RX_MAP_OFFSET3*/
+#define VL1_REM_RX_SIZE4               (0x80B8) /* VLYNQ_REM_RX_MAP_SIZE4*/
+#define VL1_REM_RX_OFF4                (0x80BC) /* VLYNQ_REM_RX_MAP_OFFSET4*/
+#define VL1_REM_CHIP_VER               (0x80C0) /* VLYNQ_REM_CHIP_VER*/
+#define VLYNQ_REM_AUTONEG              (0x80C4)
+#define VLYNQ_REM_MANNEG               (0x80C8)
+#define VLYNQ_REM_NEGSTAT              (0x80CC)
+#define VLYNQ_REM_ENDIAN               (0x80DC)
+#define VL1_REM_INT_VEC3_0             (0x80E0) /* VLYNQ_REM_HW_INT3TO0_CFG*/
+#define VL1_REM_INT_VEC7_4             (0x80E4) /* VLYNQ_REM_HW_INT7TO4_CFG*/
+
+/* PCIIF*/
+/**/
+#define PCI_ID_REG                     (0x8400)
+#define PCI_STATUS_SET_REG             (0x8410)
+#define PCI_STATUS_CLR_REG             (0x8414)
+#define PCI_HIMASK_SET_REG             (0x8420)
+#define PCI_HIMASK_CLR_REG             (0x8424)
+#define PCI_AMASK_SET_REG              (0x8430)
+#define PCI_AMASK_CLR_REG              (0x8434)
+#define PCI_CLKRUN_REG                 (0x8438)
+#define PCI_BE_VENDOR_ID_REG           (0x8500)
+#define PCI_BE_COMMAND_REG             (0x8504)
+#define PCI_BE_REVISION_REG            (0x8508)
+#define PCI_BE_CL_SIZE_REG             (0x850C)
+#define PCI_BE_BAR0_MASK_REG           (0x8510)
+#define PCI_BE_BAR1_MASK_REG           (0x8514)
+#define PCI_BE_BAR2_MASK_REG           (0x8518)
+#define PCI_BE_BAR3_MASK_REG           (0x851C)
+#define PCI_BE_CIS_PTR_REG             (0x8528)
+#define PCI_BE_SUBSYS_ID_REG           (0x852C)
+#define PCI_BE_CAP_PTR_REG             (0x8534)
+#define PCI_BE_INTR_LINE_REG           (0x853C)
+#define PCI_BE_PM_CAP_REG              (0x8540)
+#define PCI_BE_PM_CTRL_REG             (0x8544)
+#define PCI_BE_PM_D0_CTRL_REG          (0x8560)
+#define PCI_BE_PM_D1_CTRL_REG          (0x8564)
+#define PCI_BE_PM_D2_CTRL_REG          (0x8568)
+#define PCI_BE_PM_D3_CTRL_REG          (0x856C)
+#define PCI_BE_SLV_CFG_REG             (0x8580)
+#define PCI_BE_ARB_CTRL_REG            (0x8584)
+                                       
+#define FER                            (0x85A0) /* PCI_BE_STSCHG_FE_REG*/
+#define FEMR                           (0x85A4) /* PCI_BE_STSCHG_FEM_REG*/
+#define FPSR                           (0x85A8) /* PCI_BE_STSCHG_FPS_REG*/
+#define FFER                           (0x85AC) /* PCI_BE_STSCHG_FFE_REG*/
+
+#define PCI_BE_BAR0_TRANS_REG          (0x85C0)
+#define PCI_BE_BAR1_TRANS_REG          (0x85C4)
+#define PCI_BE_BAR2_TRANS_REG          (0x85C8)
+#define PCI_BE_BAR3_TRANS_REG          (0x85CC)
+#define PCI_BE_BAR4_TRANS_REG          (0x85D0)
+#define PCI_BE_BAR5_TRANS_REG          (0x85D4)
+#define PCI_BE_BAR0_REG                (0x85E0)
+#define PCI_BE_BAR1_REG                (0x85E4)
+#define PCI_BE_BAR2_REG                (0x85E8)
+#define PCI_BE_BAR3_REG                (0x85EC)
+
+#define PCI_PROXY_DATA                 (0x8700)
+#define PCI_PROXY_ADDR                 (0x8704)
+#define PCI_PROXY_CMD                  (0x8708)
+#define PCI_CONTROL                    (0x8710)
+
+/*#define CPC_REGION                   (f0100)*/
+/*#define VLYNQ1_BASE                  (f00a0)*/
+/*#define VLYNQ2_BASE                  (f00b0)*/
+/*#define SCR_IADDR1                   (f00c0)*/
+/*#define SCR_IDATA1                   (f00c0)*/
+/*#define SCR_IADDR2                   (f00c0)*/
+/*#define SCR_IDATA2                   (f00c0)*/
+
+/* SDIO/WSPI*/
+#define        CCCR_1                         (002800)
+#define        CCCR_2                         (002804)
+#define        CCCR_3                         (002808)
+#define        FUN_BASE_REG_1                 (00280C)
+#define        FUN_BASE_REG_2                 (002810)
+#define        FUN_BASE_REG_3                 (002814)
+#define        ADDR_MAP_SIZE_1                (002818)
+#define        ADDR_MAP_SIZE_2                (002820)
+#define        ADDR_MAP_SIZE_3                (002828)
+#define        ADDR_MAP_OFFSET_1              (00281C)
+#define        ADDR_MAP_OFFSET_2              (002824)
+#define        ADDR_MAP_OFFSET_3              (00282C)
+#define        ADDR_MAP_OFFSET_4              (002830)
+#define        CIS_OFFSET                     (002834)
+#define        CSA_OFFSET                     (002838)
+#define        DEBUG_REG_1                    (002840)
+#define        DEBUG_REG_2                    (00283C)
+#define        INTR_MASK                      (002844)
+#define        STATUS_REG                     (002848)
+#define        WR_ERR_LENGTH                  (00284C)
+#define        WR_ERR_ADDR                    (002850)
+#define        OCR                            (002858)
+
+/* UART*/
+/* TODO - fill in registers*/
+
+/* USB1.1 registers*/
+/**/
+#define USB_STS_CLR                    (0x4000)
+#define USB_STS_ND                     (0x4004)
+#define USB_INT_ACK                    (0x4008)
+#define USB_MASK                       (0x400c)
+#define USB_MASK_SET                   (0x4010)
+#define USB_MASK_CLR                   (0x4014)
+#define USB_WU                         (0x4018)
+#define USB_EP0_OUT_PTR                (0x401c)
+#define USB_EP0_OUT_VLD                (0x4020)
+#define USB_EP0_OUT_LEN                (0x4024)
+#define USB_EP0_IN_PTR                 (0x4028)
+#define USB_EP0_IN_VLD                 (0x402c)
+#define USB_EP0_IN_LEN                 (0x4030)
+#define USB_EP1_CFG                    (0x4034)
+#define USB_EP1_OUT_INT_CFG            (0x4038)
+#define USB_EP1_OUT_PTR                (0x403c)
+#define USB_EP1_OUT_VLD                (0x4040)
+#define USB_EP1_OUT_CUR_MBLK           (0x4044)
+#define USB_EP1_OUT_LEN                (0x4048)
+#define USB_EP1_IN_START_MBLK          (0x404c)
+#define USB_EP1_IN_LAST_MBLK           (0x4050)
+#define USB_EP1_IN_VLD                 (0x4054)
+
+#define USB_EP2_PTR                    (0x405c)
+#define USB_EP2_VLD                    (0x4060)
+#define USB_EP2_LEN                    (0x4064)
+#define USB_EP3_OUT_PTR0               (0x4068)
+#define USB_EP3_OUT_VLD0               (0x406c)
+#define USB_EP3_OUT_LEN0               (0x4070)
+#define USB_EP3_OUT_PTR1               (0x4074)
+#define USB_EP3_OUT_VLD1               (0x4078)
+#define USB_EP3_OUT_LEN1               (0x407c)
+#define USB_EP3_IN_PTR0                (0x4080)
+#define USB_EP3_IN_VLD0                (0x4084)
+#define USB_EP3_IN_LEN0                (0x4088)
+#define USB_EP3_IN_PTR1                (0x408c)
+#define USB_EP3_IN_VLD1                (0x4090)
+#define USB_EP3_IN_LEN1                (0x4094)
+#define USB_EP1_OUT_END_MBLK           (0x4098)
+#define USB_EP0_OUT_SETUP              (0x409c)
+#define USB_EP0_STALL                  (0x40a0)
+#define USB_EP1_IN_OFFSET              (0x40a4)
+
+/* Device Configuration registers*/
+#define SOR_CFG                        (0x0800)
+#define ECPU_CTRL                      (0x0804)
+#define HI_CFG                         (0x0808)
+#define EE_START                       (0x080C)
+
+/* IO Control registers*/
+#define SERIAL_HOST_IOCFG0             (0x0894) /* new*/
+#define SERIAL_HOST_IOCFG1             (0x0898) /* new*/
+#define SERIAL_HOST_IOCFG2             (0x089C) /* new*/
+#define SERIAL_HOST_IOCFG3             (0x08A0) /* new*/
+#define GPIO_IOCFG0                    (0x08F4) /* new*/
+#define GPIO_IOCFG1                    (0x08F8) /* new*/
+#define GPIO_IOCFG2                    (0x08FC) /* new*/
+#define GPIO_IOCFG3                    (0x0900) /* new*/
+#define CHIP_ID_B                      (0x5674) /* new*/
+#define CHIP_ID                        CHIP_ID_B/* Leave for TNETW compatability*/
+#define CHIP_ID_1251_PG10                 (0x7010101)
+#define CHIP_ID_1251_PG11                 (0x7020101)
+#define CHIP_ID_1251_PG12                 (0x7030101)
+
+#define SYSTEM                         (0x0810)
+#define PCI_ARB_CFG                    (0x0814)
+#define BOOT_IRAM_CFG                  (0x0818)
+#define ENABLE                         (0x5450)
+#define MBLK_CFG                       (0x5460)
+#define RS232_BITINTERVAL              (0x0824)
+#define TEST_PORT                      (0x096C)
+#define DEBUG_PORT                     (0x0970)
+
+/* GPIO registers*/
+#define GPIO_OE                        (0x082C) /* 22 GPIOs*/
+#define GPIO_OUT                       (0x0834)
+#define GPIO_IN                        (0x0830)
+#define GPO_CFG                        (0x083C)
+#define PWRDN_BUS_L                    (0x0844)
+#define PWRDN_BUS_H                    (0x0848)
+#define DIE_ID_L                       (0x088C)
+#define DIE_ID_H                       (0x0890)
+
+/* Power Management registers*/
+/* */
+#define ELP_START                      (0x5800)
+#define ELP_CFG_MODE                   (0x5804)
+#define ELP_CMD                        (0x5808)
+#define PLL_CAL_TIME                   (0x5810)
+#define CLK_REQ_TIME                   (0x5814)
+#define CLK_BUF_TIME                   (0x5818)
+
+#define CFG_PLL_SYNC_CNT               (0x5820) /* Points to the CFG_PLL_SYNC_CNT_xx registers set*/
+#define CFG_PLL_SYNC_CNT_I             (0x5820)
+#define CFG_PLL_SYNC_CNT_II            (0x5824)
+#define CFG_PLL_SYNC_CNT_III           (0x5828)
+
+#define CFG_ELP_SLEEP_CNT              (0x5830) /* Points to the CFG_ELP_SLEEP_CNT_xx registers set*/
+#define CFG_ELP_SLEEP_CNT_I            (0x5830)
+#define CFG_ELP_SLEEP_CNT_II           (0x5834)
+#define CFG_ELP_SLEEP_CNT_III          (0x5838)
+#define CFG_ELP_SLEEP_CNT_IV           (0x583c)
+
+#define ELP_SLEEP_CNT                  (0x5840) /* Points to the ELP_SLEEP_CNT_xx registers set*/
+#define ELP_SLEEP_CNT_I                (0x5840)
+#define ELP_SLEEP_CNT_II               (0x5844)
+#define ELP_SLEEP_CNT_III              (0x5848)
+#define ELP_SLEEP_CNT_IV               (0x584c)
+
+#define ELP_WAKE_UP_STS                (0x5850)
+#define CFG_SLP_CLK_SEL                (0x5860)
+#define CFG_SLP_CLK_EN                 (0x5870)
+
+#define CFG_WAKE_UP_EN_I               (0x5880)
+#define CFG_WAKE_UP_EN_II              (0x5884)
+#define CFG_WAKE_UP_EN_III             (0x5888)
+
+#define CFG_ELP_PWRDN_I                (0x5890)
+#define CFG_ELP_PWRDN_II               (0x5894)
+#define CFG_ELP_PWRDN_III              (0x5898)
+
+#define CFG_POWER_DOWN_I               (0x58a0)
+#define CFG_POWER_DOWN_II              (0x58a4)
+#define CFG_POWER_DOWN_III             (0x58a8)
+
+#define CFG_BUCK_TESTMODE_I            (0x58b0)
+#define CFG_BUCK_TESTMODE_II           (0x58b4)
+
+#define POWER_STATUS_I                 (0x58C0)
+#define POWER_STATUS_II                (0x58C4)
+
+#define DIGLDO_BIAS_PROG_I             (0x58d0)
+#define DIGLDO_BIAS_PROG_II            (0x58d4)
+
+#define LDO2P8_BIAS_PROG_I             (0x58e0)
+#define LDO2P8_BIAS_PROG_II            (0x58e4)
+
+#define ADCLDO_BIAS_PROG               (0x58f0)
+
+#define REFSYS_PROG_I                  (0x5910)
+#define REFSYS_PROG_II                 (0x5914)
+
+#define PM_TEST_I                      (0x5920)
+#define PM_TEST_II                     (0x5924)
+
+#define POR_PROG                       (0x5930)
+
+#define TEST_PIN_DIR_I                 (0x5940)
+#define TEST_PIN_DIR_II                (0x5944)
+
+#define PROC_CTL                       (0x5950)
+
+#define ADC_REF_WAKEUP_I               (0x5960)
+#define ADC_REF_WAKEUP_II              (0x5964)
+#define ADC_REF_WAKEUP_III             (0x5968)
+#define ADC_REF_WAKEUP_IV              (0x596C)
+
+#define VREG_WAKEUP_I                  (0x5970)
+#define VREG_WAKEUP_II                 (0x5974)
+#define VREG_WAKEUP_III                (0x5978)
+#define VREG_WAKEUP_IV                 (0x597C)
+
+#define PLL_WAKEUP_I                   (0x5980)
+#define PLL_WAKEUP_II                  (0x5984)
+#define PLL_WAKEUP_III                 (0x5988)
+#define PLL_WAKEUP_IV                  (0x598C)
+
+#define XTALOSC_WAKEUP_I               (0x5990)
+#define XTALOSC_WAKEUP_II              (0x5994)
+#define XTALOSC_WAKEUP_III             (0x5998)
+#define XTALOSC_WAKEUP_IV              (0x599C)
+
+/* ----------*/
+
+#define POWER_MGMT2                    (0x0840)
+#define POWER_MGMT                     (0x5098)
+#define MAC_HW_DOZE                    (0x090c)
+#define ECPU_SLEEP                     (0x0840)
+#define DOZE_CFG                       (0x54bc)
+#define DOZE2_CFG                      (0x081c)
+#define WAKEUP_CFG                     (0x54c0)
+#define WAKEUP_TIME_L                  (0x54c8)
+#define WAKEUP_TIME_H                  (0x54c4)
+
+/**/
+
+/*#define CPU_WAIT_CFG                 (f0020)*/
+/*#define CFG_QOS_ACM                  (f0046)*/
+
+/* Scratch Pad registers*/
+#define SCR_PAD0                       (0x5608)
+#define SCR_PAD1                       (0x560C)
+#define SCR_PAD2                       (0x5610)
+#define SCR_PAD3                       (0x5614)
+#define SCR_PAD4                       (0x5618)
+#define SCR_PAD4_SET                   (0x561C)
+#define SCR_PAD4_CLR                   (0x5620)
+#define SCR_PAD5                       (0x5624)
+#define SCR_PAD5_SET                   (0x5628)
+#define SCR_PAD5_CLR                   (0x562C)
+#define SCR_PAD6                       (0x5630)
+#define SCR_PAD7                       (0x5634)
+#define SCR_PAD8                       (0x5638)
+#define SCR_PAD9                       (0x563C)
+
+/* Spare registers*/
+#define SPARE_A1                       (0x0994)
+#define SPARE_A2                       (0x0998)
+#define SPARE_A3                       (0x099C)
+#define SPARE_A4                       (0x09A0)
+#define SPARE_A5                       (0x09A4)
+#define SPARE_A6                       (0x09A8)
+#define SPARE_A7                       (0x09AC)
+#define SPARE_A8                       (0x09B0)
+#define SPARE_B1                       (0x5420)
+#define SPARE_B2                       (0x5424)
+#define SPARE_B3                       (0x5428)
+#define SPARE_B4                       (0x542C)
+#define SPARE_B5                       (0x5430)
+#define SPARE_B6                       (0x5434)
+#define SPARE_B7                       (0x5438)
+#define SPARE_B8                       (0x543C)
+
+/* RMAC registers (Raleigh MAC)*/
+
+/* Station registers*/
+#define DEV_MODE                       (0x5464)
+#define STA_ADDR_L                     (0x546C)
+#define STA_ADDR_H                     (0x5470)
+#define BSSID_L                        (0x5474)
+#define BSSID_H                        (0x5478)
+#define AID_CFG                        (0x547C)
+#define BASIC_RATE_CFG                 (0x4C6C)
+#define BASIC_RATE_TX_CFG              (0x55F0)
+
+/* Protocol timers registers*/
+#define IFS_CFG0                       (0x5494)
+#define IFS_CFG1                       (0x5498)
+#define TIMEOUT_CFG                    (0x549C)
+#define CONT_WIND_CFG                  (0x54A0)
+#define BCN_INT_CFG                    (0x54A4)
+#define RETRY_CFG                      (0x54A8)
+#define DELAY_CFG                      (0x54B0)
+
+/* Hardware Override registers*/
+#define CCA_CFG                        (0x54CC)
+#define CCA_FILTER_CFG                 (0x5480)
+#define RADIO_PLL_CFG                  (0x555C)
+#define CCA_MON                        (0x54D0)
+#define TX_FRM_CTL                     (0x54D4)
+#define CONT_TX_EN                     (0x50EC)
+#define PHY_STANDBY_EN                 (0x5668)
+
+/* Transmit Setup registers*/
+#define TX_PING_PONG                   (0x5090)
+#define TX_CFG0                        (0x5000)
+#define TX_CFG1                        (0x5004)
+#define TX_CFG2                        (0x5008)
+#define MAX_LIFETIME                   (0x50FC)
+#define TX_PANG_SEL                    (0x50E0)
+#define TX_PANG0                       (0x50A0)
+#define TX_PING0                       (0x5010)
+#define TX_PONG0                       (0x5050)
+#define TX_PANG1                       (0x50A4)
+#define TX_PING1                       (0x5014)
+#define TX_PONG1                       (0x5054)
+#define TX_PANG2                       (0x50A8)
+#define TX_PING2                       (0x5018)
+#define TX_PONG2                       (0x5058)
+#define TX_PANG3                       (0x50AC)
+#define TX_PING3                       (0x501C)
+#define TX_PONG3                       (0x505C)
+#define TX_PANG4                       (0x50B0)
+#define TX_PING4                       (0x5020)
+#define TX_PONG4                       (0x5060)
+#define TX_PANG5                       (0x50B4)
+#define TX_PING5                       (0x5024)
+#define TX_PONG5                       (0x5064)
+#define TX_PANG6                       (0x50B8)
+#define TX_PING6                       (0x5028)
+#define TX_PONG6                       (0x5068)
+#define TX_PANG7                       (0x50BC)
+#define TX_PING7                       (0x502C)
+#define TX_PONG7                       (0x506C)
+#define TX_PANG8                       (0x50C0)
+#define TX_PING8                       (0x5030)
+#define TX_PONG8                       (0x5070)
+#define TX_PANG9                       (0x50C4)
+#define TX_PING9                       (0x5034)
+#define TX_PONG9                       (0x5074)
+#define TX_PANG10                      (0x50C8)
+#define TX_PING10                      (0x5038)
+#define TX_PONG10                      (0x5078)
+#define TX_PANG11                      (0x50CC)
+#define TX_PING11                      (0x503C)
+#define TX_PONG11                      (0x507C)
+
+/* Transmit Status registers*/
+#define TX_STATUS                      (0x509C)
+#define TX_PANG_EXCH                   (0x50D0)
+#define TX_PING_EXCH                   (0x5040)
+#define TX_PONG_EXCH                   (0x5080)
+#define TX_PANG_ATT                    (0x50D4)
+#define TX_PING_ATT                    (0x5044)
+#define TX_PONG_ATT                    (0x5084)
+#define TX_PANG_TIMESTAMP              (0x50DC)
+#define TX_PING_TIMESTAMP              (0x504C)
+#define TX_PONG_TIMESTAMP              (0x508C)
+
+/* Transmit State registers*/
+#define TX_STATE                       (0x5094)
+#define TX_PANG_OVRD_CFG               (0x50D8)
+#define TX_PING_OVRD_CFG               (0x5048)
+#define TX_PONG_OVRD_CFG               (0x5088)
+#define TX_HOLD_CFG                    (0x54D8)
+#define TSF_ADJ_CFG1                   (0x54DC)
+#define TSF_ADJ_CFG2                   (0x54E0)
+#define TSF_ADJ_CFG3                   (0x54E4)
+#define TSF_ADJ_CFG4                   (0x54E8)
+#define CFG_OFDM_TIMES0                (0x5648)
+#define CFG_OFDM_TIMES1                (0x564C)
+
+/* Beacon/Probe Response registers*/
+#define PRB_ADDR                       (0x54EC)
+#define PRB_LENGTH                     (0x54F0)
+#define BCN_ADDR                       (0x54F4)
+#define BCN_LENGTH                     (0x54F8)
+#define TIM_VALID0                     (0x54FC)
+#define TIM_ADDR0                      (0x5500)
+#define TIM_LENGTH0                    (0x5504)
+#define TIM_VALID1                     (0x5654)
+#define TIM_ADDR1                      (0x5658)
+#define TIM_LENGTH1                    (0x565C)
+#define TIM_SELECT                     (0x5660)
+#define TSF_CFG                        (0x5508)
+
+/* Other Hardware Generated Frames regi*/
+#define CTL_FRM_CFG                    (0x550C)
+#define MGMT_FRM_CFG                   (0x5510)
+#define CFG_ANT_SEL                    (0x5664)
+#define RMAC_ADDR_BASE                 (0x5680) /* new*/
+
+/* Protocol Interface Read Write Interf*/
+#define TXSIFS_TIMER                   (0x4C00)
+#define TXPIFS_TIMER                   (0x4C04)
+#define TXDIFS_TIMER                   (0x4C08)
+#define SLOT_TIMER                     (0x4C0C)
+#define BACKOFF_TIMER                  (0x4C10)
+#define BCN_PSP_TIMER                  (0x4C14)
+#define NAV                            (0x4C18)
+#define TSF_L                          (0x4C1C)
+#define TSF_H                          (0x4C20)
+#define TSF_PREV_L                     (0x4CC4) /* new */
+#define TSF_PREV_H                     (0x4CC8) /* new */
+#define TOUT_TIMER                     (0x4C2C)
+#define NEXT_TBTT_L                    (0x4C30)
+#define NEXT_TBTT_H                    (0x4C34)
+#define DTIM_CNT                       (0x4C38)
+#define CONT_WIND                      (0x4C3C)
+#define PRSP_REQ                       (0x4C40)
+#define PRSP_DA_L                      (0x4C44)
+#define PRSP_DA_H                      (0x4C48)
+#define PRSP_RETRY                     (0x4C4C)
+#define PSPOLL_REQ                     (0x4C50)
+#define NEXT_SEQ_NUM                   (0x4C54)
+#define PRSP_SEQ_NUM                   (0x4C58)
+#define BCN_SEQ_NUM                    (0x4C5C)
+#define MED_USAGE                      (0x4C24)
+#define MED_USAGE_TM                   (0x4C28)
+#define PRB_DLY                        (0x4C60)
+#define STA_SRC                        (0x4C64)
+#define STA_LRC                        (0x4C68)
+#define CFG_ACM                        (0x4C70)
+#define RAND_NUMB                      (0x4C6C)
+#define CFG_ACK_CTS_DOT11A             (0x4C74)
+#define CFG_ACK_CTS_DOT11B             (0x4C78)
+#define ACM_IFS_CFG0                   (0x4C7C)
+#define ACM_IFS_CFG1                   (0x4C80)
+#define ACM_IFS_CFG2                   (0x4C84)
+#define ACM_IFS_CFG3                   (0x4C88)
+#define ACK_CTS_FRM_CFG                (0x4C8C)
+#define CFG_RX_TSTMP_DLY0              (0x4C90)
+#define CFG_RX_TSTMP_DLY1              (0x4C94)
+#define CFG_RX_TSTMP_DLY2              (0x4C98)
+#define CFG_RX_TSTMP_DLY3              (0x4C9C)
+#define CCA_BUSY                       (0x4CA0)
+#define CCA_BUSY_CLR                   (0x4CA4)
+#define CCA_IDLE                       (0x4CA8)
+#define CCA_IDLE_CLR                   (0x4CAC)
+
+/* Receive Manager registers*/
+#define RX_HEAD_PTR                    (0x567C) /* new*/
+#define RX_TAIL_PTR                    (0x4898) /* new*/
+#define RX_CURR_PTR                    (0x5678) /* new*/
+#define RX_RESET                       (0x4800)
+#define RX_MODMODE                     (0x4838) /* new*/
+#define MAC_HEADER_BYTECNT             (0x4890)
+#define RX_MAC_BYTECNT_INT             (0x489C)
+#define MAC_HEADER_WORD0               (0x4868)
+#define MAC_HEADER_WORD1               (0x486C)
+#define MAC_HEADER_WORD2               (0x4870)
+#define MAC_HEADER_WORD3               (0x4874)
+#define MAC_HEADER_WORD4               (0x4878)
+#define MAC_HEADER_WORD5               (0x487C)
+#define MAC_HEADER_WORD6               (0x4880)
+#define MAC_HEADER_WORD7               (0x4884)
+#define MAC_HEADER_WORD8               (0x4888)
+#define MAC_HEADER_WORD9               (0x488C)
+#define RX_CFG                         (0x5514)
+#define RX_FILTER_CFG                  (0x55B4)
+#define RX_MC0_L                       (0x5518)
+#define RX_MC0_H                       (0x551C)
+#define RX_MC1_L                       (0x5520)
+#define RX_MC1_H                       (0x5524)
+#define STA_SSID0                      (0x4804)
+#define STA_SSID1                      (0x4808)
+#define STA_SSID2                      (0x480C)
+#define STA_SSID3                      (0x4810)
+#define STA_SSID4                      (0x4814)
+#define STA_SSID5                      (0x4818)
+#define STA_SSID6                      (0x481C)
+#define STA_SSID7                      (0x4820)
+#define SSID_LEN                       (0x4824)
+#define RX_FREE_MEM                    (0x5528)
+#define RX_CURR_MEM                    (0x552C)
+#define MAC_TIMESTAMP                  (0x5560) /* Check place*/
+#define RX_TIMESTAMP                   (0x5564)
+#define RX_FRM_PTR                     (0x5568)
+#define RX_FRM_LEN                     (0x556C)
+#define RX_PLCP_HDR                    (0x5570)
+#define RX_PLCP_SIGNAL                 (0x5574)
+#define RX_PLCP_SERVICE                (0x5578) /* 16 bits ?*/
+#define RX_PLCP_LENGTH                 (0x557C)
+#define RX_FRM_CTL                     (0x5580)
+#define RX_DUR_ID                      (0x5584)
+#define RX_ADDR1_L                     (0x5588)
+#define RX_ADDR1_H                     (0x558C)
+#define RX_ADDR2_L                     (0x5590)
+#define RX_ADDR2_H                     (0x5594)
+#define RX_ADDR3_L                     (0x5598)
+#define RX_ADDR3_H                     (0x559C)
+#define RX_SEQ_CTL                     (0x55A0)
+#define RX_WEP_IV                      (0x55A4)
+#define RX_TIME_L                      (0x55A8)
+#define RX_TIME_H                      (0x55AC)
+#define RX_STATUS                      (0x55B0)
+#define PLCP_ERR_CNT                   (0x4828)
+#define FCS_ERR_CNT                    (0x482C)
+#define RX_OVERFLOW_CNT                (0x4830)
+#define RX_DEBUG1                      (0x4858)
+#define RX_DEBUG2                      (0x485C)
+#define RX_QOS_CFG                     (0x4848)
+#define RX_QOS_CTL                     (0x4844)
+#define RX_QOS_STATUS                  (0x4854) /* new name RX_QOS_STS*/
+#define RX_TXOP_HOLDER_L               (0x484C)
+#define RX_TXOP_HOLDER_H               (0x4850)
+#define RX_FRM_CNT                     (0x4834) /* what is RX_FRM_CTR*/
+#define CONS_FCS_ERR_CNT               (0x483C)
+#define CONS_FCS_ERR_CFG               (0x4840)
+#define RX_QOS_CTL_MASK                (0x48A0) /* new*/
+#define RX_QOS_ACK_EN                  (0x48A4) /* new*/
+#define RX_QOS_NOACK_EN                (0x48A8) /* new*/
+#define RX_QOS_ACK_BITMAP              (0x48AC) /* new*/
+
+/* Baseband Processor registers*/
+#define SBB_CFG                        (0x55C8)
+#define SBB_ADDR                       (0x55D0)
+#define SBB_DATA                       (0x55D4)
+#define SBB_CTL                        (0x55D8)
+
+/* Radio Control Interface registers*/
+#define RCI_CTL                        (0x55DC)
+#define RCI_DATA                       (0x55E0)
+#define RCI_CFG1                       (0x55E4)
+#define RCI_CFG2                       (0x55E8)
+#define RCI_CFG3                       (0x55EC)
+
+#define TNET1150_LAST_REG_ADDR                 PCI_CONTROL
+
+
+/* Missing registers*/
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1251/whalHwRegs.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/TNETW1251/whalHwRegs.h
new file mode 100644 (file)
index 0000000..fe3b148
--- /dev/null
@@ -0,0 +1,57 @@
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwRegs.h
+ *   PURPOSE: Contains Wlan hardware registers defines/structures
+ *   
+ ****************************************************************************/
+
+#ifndef _WHAL_ACX_REGS_H
+#define _WHAL_ACX_REGS_H
+
+#include "TnetwRegisters.h"
+
+#define REG_DEVICE_VENDOR_ID                           PCI_BE_VENDOR_ID_REG
+#define ACX_VENDOR_ID                                          0x104C
+#define ACX_DEVICE_ID                                          0x9068  /* --- 1150*/
+#define ECPU_CONTROL_HALT                                      0x00000101                              
+#define ACX_CLK_CFG_ARM_80_MAC_40_MHZ          0x2
+#define ACX_MAC_REG_READ_WRITE_PREFIX       0x300000
+
+#endif   /* _WHAL_ACX_REGS_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/TnetwServices/tnetwCommon.h b/sta_dk_4_0_4_32/common/src/hal/TnetwServices/tnetwCommon.h
new file mode 100644 (file)
index 0000000..dbb86d7
--- /dev/null
@@ -0,0 +1,430 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwRegs.h
+ *   PURPOSE: Contains Wlan hardware registers defines/structures
+ *   
+ ****************************************************************************/
+
+#ifndef _TNETW_COMMON_H
+#define _TNETW_COMMON_H
+
+#include "TnetwRegisters.h"
+
+#define IS_MASK_ON(  field, bitmask ) (  (bitmask) == ( (field) &  (bitmask) ) )
+#define IS_MASK_OFF( field, bitmask ) ( ~(bitmask) == ( (field) | ~(bitmask) ) )
+
+#define IS_ANY_BIT_ON( field, bitmask ) ( (field) & (bitmask) )
+#define ARE_ALL_BITS_ON( field, bitmask ) IS_MASK_ON( field, bitmask )
+
+#define MASK_BITS_ON(  field, bitmask ) ( (field) |=  (bitmask) ) 
+#define MASK_BITS_OFF( field, bitmask ) ( (field) &= ~(bitmask) )
+
+#define MASK_BITS_TOGGLE( field, bitmask ) ( (field) ^= (bitmask) )
+
+#define ACX_PHI_CCA_THRSH_ENABLE_ENERGY_D      0x140A
+#define ACX_PHI_CCA_THRSH_DISABLE_ENERGY_D     0xFFEF
+
+/*
+ * Wlan hardware Registers.
+ */
+
+/*======================================================================
+                      Interrupt Registers                               
+=======================================================================*/
+
+#define ACX_REG_INTERRUPT_TRIG         ( INT_TRIG )
+
+#define ACX_REG_INTERRUPT_TRIG_H        ( INT_TRIG_H )
+
+/*=============================================
+  Host Interrupt Mask Register - 32bit (RW)
+  ------------------------------------------  
+  Setting a bit in this register masks the
+  corresponding interrupt to the host.
+  0 - RX0              - Rx first dubble buffer Data Interrupt
+  1 - TXD              - Tx Data Interrupt
+  2 - TXXFR            - Tx Transfer Interrupt
+  3 - RX1              - Rx second dubble buffer Data Interrupt
+  4 - RXXFR            - Rx Transfer Interrupt
+  5 - EVENT_A  - Event Mailbox interrupt
+  6 - EVENT_B  - Event Mailbox interrupt
+  7 - WNONHST  - Wake On Host Interrupt
+  8 - TRACE_A  - Debug Trace interrupt
+  9 - TRACE_B  - Debug Trace interrupt
+ 10 - CDCMP            - Command Complete Interrupt
+ 11 -
+ 12 -
+ 13 -
+ 14 - ICOMP            - Initialization Complete Interrupt
+ 16 - SG SE            - Soft Gemini - Sense enable interrupt
+ 17 - SG SD            - Soft Gemini - Sense disable interrupt
+ 18 -                  - 
+ 19 -                  - 
+ 20 -                  - 
+ 21-                   - 
+ Default: 0x0001
+*==============================================*/
+#define ACX_REG_INTERRUPT_MASK                         ( HINT_MASK )
+
+/*=============================================
+  Host Interrupt Mask Set 16bit, (Write only) 
+  ------------------------------------------  
+ Setting a bit in this register sets          
+ the corresponding bin in ACX_HINT_MASK register
+ without effecting the mask                   
+ state of other bits (0 = no effect).         
+==============================================*/
+#define ACX_HINT_MASK_SET_REG          HINT_MASK_SET
+
+/*=============================================
+  Host Interrupt Mask Clear 16bit,(Write only)
+  ------------------------------------------  
+ Setting a bit in this register clears        
+ the corresponding bin in ACX_HINT_MASK register
+ without effecting the mask                   
+ state of other bits (0 = no effect).         
+=============================================*/
+#define ACX_HINT_MASK_CLR_REG          HINT_MASK_CLR
+
+/*=============================================
+  Host Interrupt Status Nondestructive Read   
+  16bit,(Read only)                           
+  ------------------------------------------  
+ The host can read this register to determine 
+ which interrupts are active.                 
+ Reading this register doesn't                
+ effect its content.                          
+=============================================*/
+#define ACX_REG_INTERRUPT_NO_CLEAR                     ( HINT_STS_ND )
+
+/*=============================================
+  Host Interrupt Status Clear on Read  Register
+  16bit,(Read only)                           
+  ------------------------------------------  
+ The host can read this register to determine 
+ which interrupts are active.                 
+ Reading this register clears it,             
+ thus making all interrupts inactive.         
+==============================================*/
+#define ACX_REG_INTERRUPT_CLEAR                                ( HINT_STS_CLR )
+
+/*=============================================
+  Host Interrupt Acknowledge Register         
+  16bit,(Write only)                          
+  ------------------------------------------  
+ The host can set individual bits in this     
+ register to clear (acknowledge) the corresp. 
+ interrupt status bits in the HINT_STS_CLR and
+ HINT_STS_ND registers, thus making the       
+ assotiated interrupt inactive. (0-no effect) 
+==============================================*/
+#define ACX_REG_INTERRUPT_ACK                          ( HINT_ACK )
+
+
+/*===============================================
+   Host Software Reset - 32bit RW 
+ ------------------------------------------
+    [31:1] Reserved 
+        0  SOFT_RESET Soft Reset  - When this bit is set,
+         it holds the Wlan hardware in a soft reset state. 
+         This reset disables all MAC and baseband processor 
+         clocks except the CardBus/PCI interface clock. 
+         It also initializes all MAC state machines except 
+         the host interface. It does not reload the
+         contents of the EEPROM. When this bit is cleared 
+         (not self-clearing), the Wlan hardware
+         exits the software reset state.
+===============================================*/
+#define ACX_REG_SLV_SOFT_RESET                         ( SLV_SOFT_RESET )
+       #define SLV_SOFT_RESET_BIT              0x00000001
+
+/*===============================================
+ EEPROM Burst Read Start  - 32bit RW 
+ ------------------------------------------
+ [31:1] Reserved 
+     0  ACX_EE_START -  EEPROM Burst Read Start 0
+        Setting this bit starts a burst read from 
+        the external EEPROM. 
+        If this bit is set (after reset) before an EEPROM read/write, 
+        the burst read starts at EEPROM address 0.
+        Otherwise, it starts at the address 
+        following the address of the previous access. 
+        TheWlan hardware hardware clears this bit automatically.
+        
+        Default: 0x00000000
+*================================================*/
+#define ACX_REG_EE_START                                       ( EE_START )
+       #define START_EEPROM_MGR        0x00000001
+
+/*=======================================================================
+                        Embedded ARM CPU Control
+========================================================================*/
+/*===============================================
+ Halt eCPU   - 32bit RW 
+ ------------------------------------------
+    0 HALT_ECPU Halt Embedded CPU - This bit is the 
+      compliment of bit 1 (MDATA2) in the SOR_CFG register. 
+      During a hardware reset, this bit holds 
+      the inverse of MDATA2.
+      When downloading firmware from the host, 
+      set this bit (pull down MDATA2). 
+      The host clears this bit after downloading the firmware into 
+      zero-wait-state SSRAM.
+      When loading firmware from Flash, clear this bit (pull up MDATA2) 
+      so that the eCPU can run the bootloader code in Flash
+    HALT_ECPU eCPU State
+    --------------------
+    1 halt eCPU
+    0 enable eCPU
+===============================================*/
+#define ACX_REG_ECPU_CONTROL                           ( ECPU_CTRL )
+
+
+/*=======================================================================
+                    Command/Information Mailbox Pointers
+========================================================================*/
+
+/*===============================================
+   Command Mailbox Pointer - 32bit RW 
+ ------------------------------------------
+    This register holds the start address of 
+    the command mailbox located in the Wlan hardware memory. 
+    The host must read this pointer after a reset to 
+    find the location of the command mailbox. 
+    The Wlan hardware initializes the command mailbox 
+    pointer with the default address of the command mailbox.
+    The command mailbox pointer is not valid until after 
+    the host receives the Init Complete interrupt from 
+    the Wlan hardware.
+===============================================*/
+#define REG_COMMAND_MAILBOX_PTR                                ( SCR_PAD0 ) 
+
+/*===============================================
+   Information Mailbox Pointer - 32bit RW 
+ ------------------------------------------
+    This register holds the start address of 
+    the information mailbox located in the Wlan hardware memory. 
+    The host must read this pointer after a reset to find 
+    the location of the information mailbox. 
+    The Wlan hardware initializes the information mailbox pointer 
+    with the default address of the information mailbox. 
+    The information mailbox pointer is not valid 
+    until after the host receives the Init Complete interrupt from
+    the Wlan hardware.
+===============================================*/
+#define REG_EVENT_MAILBOX_PTR                          ( SCR_PAD1 ) 
+
+
+/*=======================================================================
+                   Misc
+========================================================================*/
+
+
+#define REG_ENABLE_TX_RX                               ( ENABLE ) 
+/*
+ * Rx configuration (filter) information element
+ * ---------------------------------------------
+ */
+#define REG_RX_CONFIG                          ( RX_CFG ) 
+#define REG_RX_FILTER                          ( RX_FILTER_CFG ) 
+
+#define RX_CFG_ENABLE_PHY_HEADER_PLCP  0x0002  
+#define RX_CFG_PROMISCUOUS                             0x0008  /* promiscuous - receives all valid frames */
+#define RX_CFG_BSSID                                   0x0020  /* receives frames from any BSSID */
+#define RX_CFG_MAC                                             0x0010  /* receives frames destined to any MAC address */
+#define RX_CFG_ENABLE_ONLY_MY_DEST_MAC 0x0010  
+#define RX_CFG_ENABLE_ANY_DEST_MAC             0x0000  
+#define RX_CFG_ENABLE_ONLY_MY_BSSID            0x0020  
+#define RX_CFG_ENABLE_ANY_BSSID                        0x0000  
+#define RX_CFG_DISABLE_BCAST                   0x0200  /* discards all broadcast frames */
+#define RX_CFG_ENABLE_ONLY_MY_SSID             0x0400
+#define RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR 0x0800
+#define RX_CFG_COPY_RX_STATUS                  0x2000
+#define RX_CFG_TSF                                              0x10000
+
+#define RX_CONFIG_OPTION_ANY_DST_MY_BSS                ( RX_CFG_ENABLE_ANY_DEST_MAC     | RX_CFG_ENABLE_ONLY_MY_BSSID)
+#define RX_CONFIG_OPTION_MY_DST_ANY_BSS                ( RX_CFG_ENABLE_ONLY_MY_DEST_MAC | RX_CFG_ENABLE_ANY_BSSID)
+#define RX_CONFIG_OPTION_ANY_DST_ANY_BSS       ( RX_CFG_ENABLE_ANY_DEST_MAC     | RX_CFG_ENABLE_ANY_BSSID)
+#define RX_CONFIG_OPTION_MY_DST_MY_BSS         ( RX_CFG_ENABLE_ONLY_MY_DEST_MAC | RX_CFG_ENABLE_ONLY_MY_BSSID)
+
+#define RX_CONFIG_OPTION_FOR_SCAN           ( RX_CFG_ENABLE_PHY_HEADER_PLCP  | RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR | RX_CFG_COPY_RX_STATUS | RX_CFG_TSF)
+#define RX_CONFIG_OPTION_FOR_MEASUREMENT    ( RX_CFG_ENABLE_ANY_DEST_MAC )
+#define RX_CONFIG_OPTION_FOR_JOIN              ( RX_CFG_ENABLE_ONLY_MY_BSSID | RX_CFG_ENABLE_ONLY_MY_DEST_MAC  )
+#define RX_CONFIG_OPTION_FOR_IBSS_JOIN         ( RX_CFG_ENABLE_ONLY_MY_SSID | RX_CFG_ENABLE_ONLY_MY_DEST_MAC  )
+
+#define RX_FILTER_OPTION_DEF                   (/*CFG_RX_PRSP_EN |*/ /*CFG_RX_PREQ_EN |*/ CFG_RX_MGMT_EN | CFG_RX_DATA_EN | CFG_RX_CTL_EN | CFG_RX_BCN_EN | CFG_RX_AUTH_EN |CFG_RX_ASSOC_EN )
+#define RX_FILTER_OPTION_FILTER_ALL            0
+#define RX_FILTER_OPTION_DEF_PRSP_BCN  (  CFG_RX_PRSP_EN |  CFG_RX_MGMT_EN | CFG_RX_RCTS_ACK | CFG_RX_BCN_EN )
+#define RX_FILTER_OPTION_JOIN                  (   CFG_RX_MGMT_EN | CFG_RX_DATA_EN /*| CFG_RX_CTL_EN */| CFG_RX_BCN_EN | CFG_RX_AUTH_EN | CFG_RX_ASSOC_EN | CFG_RX_RCTS_ACK | CFG_RX_PRSP_EN)
+
+
+/*===============================================
+   Phy regs
+ ===============================================*/
+#define ACX_PHY_ADDR_REG                SBB_ADDR
+#define ACX_PHY_DATA_REG                SBB_DATA
+#define ACX_PHY_CTRL_REG                SBB_CTL
+#define ACX_PHY_REG_WR_MASK             0x00000001ul
+#define ACX_PHY_REG_RD_MASK             0x00000002ul    
+
+
+/*===============================================
+ EEPROM Read/Write Request 32bit RW 
+ ------------------------------------------
+ 1 EE_READ - EEPROM Read Request 1 - Setting this bit 
+   loads a single byte of data into the EE_DATA 
+   register from the EEPROM location specified in 
+   the EE_ADDR register. 
+   The Wlan hardware hardware clears this bit automatically. 
+   EE_DATA is valid when this bit is cleared.
+ 0 EE_WRITE  - EEPROM Write Request  - Setting this bit 
+   writes a single byte of data from the EE_DATA register into the
+   EEPROM location specified in the EE_ADDR register. 
+   The Wlan hardware hardware clears this bit automatically.
+*===============================================*/
+#define ACX_EE_CTL_REG                      EE_CTL
+#define EE_WRITE                            0x00000001ul
+#define EE_READ                             0x00000002ul
+
+/*===============================================
+ EEPROM Address  - 32bit RW 
+ ------------------------------------------
+ This register specifies the address 
+ within the EEPROM from/to which to read/write data.
+===============================================*/
+#define ACX_EE_ADDR_REG                     EE_ADDR
+
+/*===============================================
+ EEPROM Data  - 32bit RW 
+ ------------------------------------------
+    This register either holds the read 8 bits of 
+    data from the EEPROM or the write data 
+    to be written to the EEPROM.
+===============================================*/
+#define ACX_EE_DATA_REG                     EE_DATA
+
+/*===============================================
+ EEPROM Base Address  - 32bit RW 
+ ------------------------------------------
+    This register holds the upper nine bits 
+    [23:15] of the 24-bit Wlan hardware memory 
+    address for burst reads from EEPROM accesses. 
+    The EEPROM provides the lower 15 bits of this address. 
+    The MSB of the address from the EEPROM is ignored.
+===============================================*/
+#define ACX_EE_CFG                          EE_CFG  
+
+/*===============================================
+  GPIO Output Values  -32bit, RW
+ ------------------------------------------
+    [31:16]  Reserved 
+    [15: 0]  Specify the output values (at the output driver inputs) for
+             GPIO[15:0], respectively.
+===============================================*/
+#define ACX_GPIO_OUT_REG            GPIO_OUT
+#define ACX_MAX_GPIO_LINES          15
+
+/*===============================================
+  Contention window  -32bit, RW
+ ------------------------------------------
+    [31:26]  Reserved 
+    [25:16]  Max (0x3ff)
+    [15:07]  Reserved
+    [06:00]  Current contention window value - default is 0x1F
+===============================================*/
+#define ACX_CONT_WIND_CFG_REG    CONT_WIND_CFG
+#define ACX_CONT_WIND_MIN_MASK   0x0000007f
+#define ACX_CONT_WIND_MAX        0x03ff0000
+
+/*
+ * Indirect slave register/memory registers
+ * ----------------------------------------
+ */
+#define HW_SLAVE_REG_ADDR_REG          0x00000004
+#define HW_SLAVE_REG_DATA_REG          0x00000008
+#define HW_SLAVE_REG_CTRL_REG          0x0000000c
+
+#define SLAVE_AUTO_INC                         0x00010000
+#define SLAVE_NO_AUTO_INC                      0x00000000
+#define SLAVE_HOST_LITTLE_ENDIAN       0x00000000
+
+#define HW_SLAVE_MEM_ADDR_REG          SLV_MEM_ADDR
+#define HW_SLAVE_MEM_DATA_REG          SLV_MEM_DATA
+#define HW_SLAVE_MEM_CTRL_REG          SLV_MEM_CTL
+#define HW_SLAVE_MEM_ENDIAN_REG                SLV_END_CTL
+
+#define HW_FUNC_EVENT_INT_EN           0x8000
+#define HW_FUNC_EVENT_MASK_REG         0x00000034
+
+#define ACX_MAC_TIMESTAMP_REG  (MAC_TIMESTAMP)
+
+/*===============================================
+  HI_CFG Interface Configuration Register Values
+ ------------------------------------------
+===============================================*/
+#define HI_CFG_UART_ENABLE          0x00000004
+#define HI_CFG_RST232_ENABLE        0x00000008
+#define HI_CFG_CLOCK_REQ_SELECT     0x00000010
+#define HI_CFG_HOST_INT_ENABLE      0x00000020
+#define HI_CFG_VLYNQ_OUTPUT_ENABLE  0x00000040
+#define HI_CFG_HOST_INT_ACTIVE_LOW  0x00000080
+#define HI_CFG_UART_TX_OUT_GPIO_15  0x00000100
+#define HI_CFG_UART_TX_OUT_GPIO_14  0x00000200
+#define HI_CFG_UART_TX_OUT_GPIO_7   0x00000400
+
+/*
+ * NOTE: USE_ACTIVE_HIGH compilation flag should be defined in makefile
+ *       for platforms using active high interrupt level
+ */
+#ifdef USE_ACTIVE_HIGH
+#define HI_CFG_DEF_VAL              \
+        HI_CFG_UART_ENABLE |        \
+        HI_CFG_RST232_ENABLE |      \
+        HI_CFG_CLOCK_REQ_SELECT |   \
+        HI_CFG_HOST_INT_ENABLE
+#else
+#define HI_CFG_DEF_VAL              \
+        HI_CFG_UART_ENABLE |        \
+        HI_CFG_RST232_ENABLE |      \
+        HI_CFG_CLOCK_REQ_SELECT |   \
+        HI_CFG_HOST_INT_ENABLE |    \
+        HI_CFG_HOST_INT_ACTIVE_LOW
+#endif
+
+#endif   /* _TNETW_COMMON_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalCtrl.c b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalCtrl.c
new file mode 100644 (file)
index 0000000..c801924
--- /dev/null
@@ -0,0 +1,4473 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "txHwQueue_api.h"
+#include "txXfer_api.h"
+#include "txResult_api.h"
+#include "whalSecurity.h"
+#include "eventMbox_api.h" 
+#include "whalBus_Api.h"
+#include "TNETW_Driver_api.h"
+#include "commonTypes.h"
+#include "TNETW_Driver.h"
+#include "DebugTraceXfer_api.h"
+#include "FwEvent_api.h"
+
+/* 
+    Rx filter field is mostly hard-coded.
+   This filter value basically pass only valid beacons / probe responses. For exact bit description,
+   consult either the DPG or the FPG (or both, and Yoel...)
+*/
+#define CFG_RX_PRSP_EN_ 4
+#define CFG_RX_MGMT_EN_ 0x10
+#define CFG_RX_BCN_EN_  0x200
+#define RX_FILTER_CFG_ (CFG_RX_PRSP_EN_ | CFG_RX_MGMT_EN_ | CFG_RX_BCN_EN_)
+
+#define SIZE_OF_HEADER 4
+
+void whalCtrl_PrintAll (TI_HANDLE hWhalCtrl);
+
+
+#ifdef ROAMING_TRIGGER_DBG
+static void whalCtrl_dbg_RSSI_LEVEL(TI_HANDLE hWhalCtrl,char* str , UINT32 strLen);
+TI_STATUS whalCtrl_dbg_SYNCHRONIZATION(TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_dbg_BSS_LOSE(TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_dbg_MAX_TX_RETRY(TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_dbgRegisterRoamingEventCB(TI_HANDLE hWhalCtrl);
+int whalCtrl_dbgRoamingCommands (TI_HANDLE hWhalCtrl);
+#endif
+
+static int whalCtrl_ReadTemplateFrameMib(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf);
+static int whalCtrl_WriteTemplateFrameMib(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib);
+static int whalCtrl_PltMibSetBeaconFilterIETable(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib);
+static int whalCtrl_PltMibGetBeaconFilterIETable(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf);
+static int whalCtrl_PLT_ReadMIB_TxRatePolicy(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf);
+static int whalCtrl_PLT_WriteMIB_TxRatePolicy(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib);
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Create
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalCtrl_Create (TI_HANDLE hOs)
+{
+    WHAL_CTRL       *pWhalCtrl;
+    WlanParams_T    *pWlanParams;
+    DmaParams_T     *pDmaParams;
+
+    /* 
+    allocate the HAL Ctrl 
+    */
+    pWhalCtrl = (WHAL_CTRL *)os_memoryAlloc (hOs, sizeof(WHAL_CTRL));
+    if (pWhalCtrl == NULL)
+    {
+        WLAN_OS_REPORT(("whalCtrl_Create: Error memory Allocation\n"));
+        return NULL;
+    }
+    os_memoryZero (hOs, (void *)pWhalCtrl, sizeof(WHAL_CTRL));
+
+    pWhalCtrl->hOs = hOs;
+    pWhalCtrl->EncDecEnableFlag = FALSE;
+    
+    
+    /* 
+    Create the Params object
+    */
+    pWhalCtrl->pWhalParams = whal_params_Create (hOs,TRUE);
+    if (pWhalCtrl->pWhalParams == NULL)
+    {
+        WLAN_OS_REPORT(("whalCtrl_Create: Error whal_params_Create\n"));
+        whalCtrl_Destroy(pWhalCtrl);
+        return NULL;
+    }
+
+    /* Initialize the Params object database fields*/
+    pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+    pWlanParams->hwAccessMethod = HW_ACCESS_BUS_SLAVE_INDIRECT;
+    pWlanParams->maxSitesFragCollect = HAL_CTRL_SITE_FRAG_COLLECT_DEF;
+    pWlanParams->RtsThreshold       = HAL_CTRL_RTS_THRESHOLD_DEF; 
+    pWlanParams->bJoin              = FALSE;
+
+    /*soft gemini defaults*/
+    pWlanParams->SoftGeminiEnable   = SG_DISABLE;
+     
+
+    /*becon filter defaults*/
+    pWlanParams->beaconFilterParams.desiredState    = FALSE;
+    pWlanParams->beaconFilterParams.numOfElements   = DEF_NUM_STORED_FILTERS;
+    pWlanParams->beaconFilterIETable.numberOfIEs    = DEF_BEACON_FILTER_IE_TABLE_NUM;
+    pWlanParams->beaconFilterIETable.IETableSize        = BEACON_FILTER_IE_TABLE_DEF_SIZE;
+
+    
+    /* set the dma params */
+    pDmaParams = whal_ParamsGetDmaParams(pWhalCtrl->pWhalParams);
+    whal_ParamsSetDmaParams(pWhalCtrl->pWhalParams);
+    
+    
+
+    /* 
+    Configure the hardware control object 
+    */
+    pWhalCtrl->pHwCtrl = whal_hwCtrl_Create(hOs, pWhalCtrl->pWhalParams);   
+    if (pWhalCtrl->pHwCtrl == NULL)
+    {
+        WLAN_OS_REPORT(("whalCtrl_Create: Error whal_hwCtrl_Create\n"));
+        whalCtrl_Destroy(pWhalCtrl);
+        return NULL;
+    }
+    
+    /* set the Roaming  params */
+    /* Configure  the Low RSSI, the Low SNR and the Missed beacon Defaults */
+    whal_ParamsSetRoamingParams(pWhalCtrl->pWhalParams);
+
+    
+    /* 
+    Create the Security Object
+    */
+    pWhalCtrl->pWhalSecurity = whalSecur_Create (hOs, pWhalCtrl, pDmaParams->NumStations);
+
+    if (pWhalCtrl->pWhalSecurity == NULL)
+    {
+        WLAN_OS_REPORT(("whalCtrl_Create: Error whalSecur_Create\n"));
+        whalCtrl_Destroy(pWhalCtrl);
+        return NULL;
+    }
+    
+
+    WLAN_INIT_REPORT(("whalCtrl_Create end %x\n",(TI_HANDLE)pWhalCtrl));
+
+    return (pWhalCtrl);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetSetHwAddr
+ *
+ * Input    :
+ * Output   :
+ * Process  :  Configure the hardware control object
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_GetSetHwAddr (WHAL_CTRL* pWhalCtrl, TI_HANDLE hMemMgr,UINT32 *pFWImage)
+{
+    int Status;
+    UINT32 AcxRegAddr;
+    UINT32 AcxMemAddr;
+
+    /*
+     * Initiate and get the wlan hardware register and memory addresses
+     */
+    AcxRegAddr = (UINT32)os_hwGetRegistersAddr(pWhalCtrl->hOs);
+    AcxMemAddr = (UINT32)os_hwGetMemoryAddr(pWhalCtrl->hOs);
+
+    /* Get the handle of the Interrupt handler object */
+    pWhalCtrl->hWhalBus = whal_hwCtrl_GetBusHandle(pWhalCtrl->pHwCtrl);
+
+    /*
+     * Configure wlan hardware control object
+     */
+    Status = whal_hwCtrl_Config( pWhalCtrl->pHwCtrl,(TI_HANDLE)pWhalCtrl, 
+                                 whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams)->hwAccessMethod, 
+                                 AcxRegAddr, 
+                                 AcxMemAddr, 
+                                 pWhalCtrl->hReport, 
+                                 hMemMgr, 
+                                 pFWImage,
+
+                                 pWhalCtrl->hEventMbox);
+    if (Status == TNETWIF_ERROR)
+    {
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl_GetSetHwAddr: whal_hwCtrl_Config failure \n"));
+    }
+    
+    return Status;
+}
+
+
+typedef int (*fcallback_t) (TI_HANDLE);
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ConfigHwCb2
+ *
+ * Input    :
+ * Output   :
+ * Process  :  last configuration call to the low level hal
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+static int whalCtrl_ConfigHwCb2 (TI_HANDLE hWhalCtrl, TI_STATUS status)
+{
+    WHAL_CTRL    *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    if (status != OK)
+    {
+        return NOK;
+    }
+
+    /* Call the upper layer callback */
+    return (*((fcallback_t)pWhalCtrl->fCb)) (pWhalCtrl->hCb);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ConfigHwCb1
+ *
+ * Input    :
+ * Output   :
+ * Process  :  last configuration call to the low level hal
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+static int whalCtrl_ConfigHwCb1 (TI_HANDLE hWhalCtrl, TI_STATUS status)
+{
+    WHAL_CTRL    *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    DmaParams_T  *pDmaParams = whal_ParamsGetDmaParams (pWhalCtrl->pWhalParams);
+
+    /* 
+     * Store the addresses of the double buffer (Rx/Tx) 
+     * and the path status and control (Tx/Rx) in the corresponding modules
+     */
+       FwEvent_SetHwInfo (pWhalCtrl->hFwEvent, &(pWhalCtrl->pHwCtrl->DataPathParams));
+
+    txXfer_setHwInfo (pWhalCtrl->hTxXfer, &(pWhalCtrl->pHwCtrl->DataPathParams));    
+
+    txResult_setHwInfo (pWhalCtrl->hTxResult, &(pWhalCtrl->pHwCtrl->DataPathParams));
+
+    rxXfer_SetDoubleBufferAddr (pWhalCtrl->hRxXfer, &(pWhalCtrl->pHwCtrl->DataPathParams)); 
+
+    /* Provide number of HW Tx-blocks and descriptors to Tx-HW-Queue module */
+    txHwQueue_setHwInfo (pWhalCtrl->hTxHwQueue, pDmaParams);
+
+  #ifdef TI_DBG
+    /* Set the debug trace addresses */
+    debugTrace_ConfigHw (pWhalCtrl->hDebugTrace,
+                         (UINT32)pWhalCtrl->pHwCtrl->MemMap.debugBuffer1Start,
+                         (UINT32)pWhalCtrl->pHwCtrl->MemMap.debugBuffer2Start);
+  #endif /* TI_DBG */
+
+    /* 
+     * Register all health/sanityCheck/Recovery callbacks 
+     * --------------------------------------------------
+     *      DeviceError - CORE callback for full recovery
+     *      HealthReport - Event Mbox callback for extracting device error
+     *      MacStatus - Event Mbox callback for checkHwStatus FCS_ERR, RX_FREE_MEM regs
+     *      AciIndication - Event Mbox callback for accumulate SCR_PAD8 image
+     *      Mailbox error - Mailbox queue callback for case of timeout/error  
+     *      Power control error - PowerMngr callback in case of power ctrl timeout 
+     *      Failure event - CORE Callback in case of MailboxError or PowerCtrl error 
+     */
+  #ifdef USE_RECOVERY
+    whalCtrl_RegisterErrorsCallbacks (hWhalCtrl);
+  #endif
+
+  #ifdef ROAMING_TRIGGER_DBG
+    whalCtrl_dbgRegisterRoamingEventCB (hWhalCtrl);
+    whalCtrl_dbgRoamingCommands (hWhalCtrl);
+  #endif
+
+    return whal_hwInfoElemMiscTableGet (pWhalCtrl->pHwCtrl->pHwMboxConfig, 
+                                        &pWhalCtrl->misc,
+                                        (void *)whalCtrl_ConfigHwCb2,
+                                        hWhalCtrl);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ConfigHw
+ *
+ * Input    :
+ * Output   :
+ * Process  :  last configuration call to the low level hal
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_ConfigHw 
+(
+    TI_HANDLE              hWhalCtrl, 
+    TnetwDrv_InitParams_t *pInitParams, 
+    void                  *fCb,
+    TI_HANDLE              hCb
+)
+{
+    WHAL_CTRL       *pWhalCtrl      = (WHAL_CTRL *)hWhalCtrl;
+    TxParam_t       *pTxParams      = whal_ParamsGetTxParams (pWhalCtrl->pWhalParams);
+    WlanParams_T    *pWlanParams    = whal_ParamsGetWlanParams (pWhalCtrl->pWhalParams);
+    UINT8           acID;
+    int k = 0;
+
+    pWhalCtrl->fCb = fCb;
+    pWhalCtrl->hCb = hCb;
+       
+    if (NULL != pInitParams)
+    {
+    /* whalCtrl_init_t */
+    pWlanParams->PacketDetectionThreshold   = pInitParams->whalCtrl_init.packetDetectionThreshold;
+    pWlanParams->qosNullDataTemplateSize    = pInitParams->whalCtrl_init.qosNullDataTemplateSize;
+    pWlanParams->PsPollTemplateSize         = pInitParams->whalCtrl_init.PsPollTemplateSize;
+    pWlanParams->probeResponseTemplateSize  = pInitParams->whalCtrl_init.probeResponseTemplateSize;
+    pWlanParams->probeRequestTemplateSize   = pInitParams->whalCtrl_init.probeRequestTemplateSize;
+    pWlanParams->beaconTemplateSize         = pInitParams->whalCtrl_init.beaconTemplateSize;
+    pWlanParams->nullTemplateSize           = pInitParams->whalCtrl_init.nullTemplateSize;
+    /* Beacon broadcast options */
+    pWlanParams->BcnBrcOptions.BeaconRxTimeout      = pInitParams->whalCtrl_init.BeaconRxTimeout;
+    pWlanParams->BcnBrcOptions.BroadcastRxTimeout   = pInitParams->whalCtrl_init.BroadcastRxTimeout;
+    pWlanParams->BcnBrcOptions.RxBroadcastInPs      = pInitParams->whalCtrl_init.RxBroadcastInPs;
+
+    pWlanParams->ConsecutivePsPollDeliveryFailureThreshold = 
+        pInitParams->whalCtrl_init.ConsecutivePsPollDeliveryFailureThreshold;
+
+    pTxParams->txCompleteTimeout            = pInitParams->whalCtrl_init.txCompleteTimeout;
+    pTxParams->txCompleteThreshold          = pInitParams->whalCtrl_init.txCompleteThreshold;
+    
+    /* halCtrlConfigParams_t */
+    pWlanParams->RxEnergyDetection          = pInitParams->halCtrlConfigParams.halCtrlRxEnergyDetection;
+    pWlanParams->TxEnergyDetection          = pInitParams->halCtrlConfigParams.halCtrlTxEnergyDetection;
+    pWlanParams->ACIMode                    = pInitParams->halCtrlConfigParams.halCtrlACIMode;     
+    pWlanParams->inputCCA                   = pInitParams->halCtrlConfigParams.halCtrlInputCCA;    
+    pWlanParams->qualifiedCCA               = pInitParams->halCtrlConfigParams.halCtrlQualifiedCCA;
+    pWlanParams->stompForRx                 = pInitParams->halCtrlConfigParams.halCtrlStompForRx;  
+    pWlanParams->stompForTx                 = pInitParams->halCtrlConfigParams.halCtrlStompForTx;  
+    pWlanParams->txCCA                      = pInitParams->halCtrlConfigParams.halCtrlTxCCA;       
+    pWlanParams->RxDisableBroadcast         = pInitParams->halCtrlConfigParams.halCtrlRxDisableBroadcast;
+    pWlanParams->calibrationChannel2_4      = pInitParams->halCtrlConfigParams.halCtrlCalibrationChannel2_4;
+    pWlanParams->calibrationChannel5_0      = pInitParams->halCtrlConfigParams.halCtrlCalibrationChannel5_0;
+
+    /* Not used but need by Palau */
+    pWlanParams->RtsThreshold               = pInitParams->halCtrlConfigParams.halCtrlRtsThreshold;
+    pWlanParams->CtsToSelf                  = CTS_TO_SELF_DISABLE; 
+    
+    pWlanParams->WiFiWmmPS                                     = pInitParams->halCtrlConfigParams.WiFiWmmPS;
+
+    pWlanParams->MaxTxMsduLifetime          = pInitParams->halCtrlConfigParams.halCtrlMaxTxMsduLifetime;  
+    pWlanParams->MaxRxMsduLifetime          = pInitParams->halCtrlConfigParams.halCtrlMaxRxMsduLifetime;  
+
+    pWlanParams->rxTimeOut.psPoll           = pInitParams->halCtrlConfigParams.rxTimeOut.psPoll;  
+    pWlanParams->rxTimeOut.UPSD             = pInitParams->halCtrlConfigParams.rxTimeOut.UPSD;  
+
+    /* No used */
+    pWlanParams->FragmentThreshold          = pInitParams->halCtrlConfigParams.halCtrlFragThreshold;
+    pWlanParams->ListenInterval             = (UINT8)pInitParams->halCtrlConfigParams.halCtrlListenInterval;
+    pWlanParams->RateFallback               = pInitParams->halCtrlConfigParams.halCtrlRateFallbackRetry;        
+    pWlanParams->MacClock                   = pInitParams->halCtrlConfigParams.halCtrlMacClock;     
+    pWlanParams->ArmClock                   = pInitParams->halCtrlConfigParams.halCtrlArmClock;     
+    pWlanParams->Enable4x                   = pInitParams->halCtrlConfigParams.halCtrlEnable4x;
+    pWlanParams->TxCompleteThreshold        = pInitParams->halCtrlConfigParams.halCtrlTxCompleteThreshold;
+    
+    /* Configure ARP IP */
+    
+    pWlanParams->isArpIpFilteringEnabled =  pInitParams->arpIpFilterParams.isFilterEnabled ;
+    os_memoryCopy(pWhalCtrl->hOs,(void *)pWlanParams->arp_IP_addr.addr,(void *)pInitParams->arpIpFilterParams.arpIpInitParams.addr , IP_V4_ADDR_LEN) ;
+    
+    /* Configure address group */
+    pWlanParams->numGroupAddrs = pInitParams->macAddrFilterParams.numOfMacAddresses;
+    pWlanParams->isMacAddrFilteringnabled = pInitParams->macAddrFilterParams.isFilterEnabled;
+    
+    for (k = 0; k < pWlanParams->numGroupAddrs; k++)
+    {
+            os_memoryCopy (pWhalCtrl->hOs,(void*)pWlanParams->Group_addr[k].addr, (void*)pInitParams->macAddrFilterParams.macAddrTable[k].addr, MAC_ADDR_LEN);
+    }
+
+    /* Configure beacon timing (early wakeup parmeter) */
+    pWlanParams->earlyWakeUp = pInitParams->macPreambleParams.earlyWakeUp;
+
+    /* QoS configure queue */
+    for (acID = 0; acID < MAX_NUM_OF_AC; acID++)
+    {
+        /*
+         * Setting ac queues params for AccessCategoryCfg (TNET configuration)
+         */
+        pWlanParams->acQueuesParams[acID].acId                        = acID;
+        pWlanParams->acQueuesParams[acID].qId                         = acID;
+        pWlanParams->acQueuesParams[acID].percentOfBlockHighThreshold = pInitParams->whalCtrl_init.TxBlocksHighPercentPerAc[acID];
+        pWlanParams->acQueuesParams[acID].percentOfBlockLowThreshold  = pInitParams->whalCtrl_init.TxBlocksLowPercentPerAc[acID];
+    }
+    }
+
+    /*
+     * Configure the WLAN hardware after config all the hardware objects
+     */
+    if (whal_hwCtrl_ConfigHw (pWhalCtrl->pHwCtrl, (void *)whalCtrl_ConfigHwCb1, hWhalCtrl, FALSE) != OK)
+        return NOK;
+
+    return OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Config
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_Config (TI_HANDLE hWhalCtrl,TI_HANDLE hTNETW_Driver, whalCtrl_config_t* pWhalCtrlCfg,UINT32 *pFWImage)
+{
+    int                 Stt             = OK;
+
+    whalSecur_config_t  securCfg;
+    WHAL_CTRL           *pWhalCtrl      = (WHAL_CTRL *)hWhalCtrl;
+    WlanParams_T        *pWlanParams    = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+      
+    /* Save config parameters */
+    pWhalCtrl->hReport = pWhalCtrlCfg->hReport;
+    pWhalCtrl->hFwEvent = pWhalCtrlCfg->hFwEvent;
+    pWhalCtrl->hRxXfer = pWhalCtrlCfg->hRxXfer;
+    pWhalCtrl->hTxXfer = pWhalCtrlCfg->hTxXfer;
+    pWhalCtrl->hTxHwQueue = pWhalCtrlCfg->hTxHwQueue;
+    pWhalCtrl->hTxResult = pWhalCtrlCfg->hTxResult;
+    pWhalCtrl->hTNETW_Driver = hTNETW_Driver;
+    pWhalCtrl->hEventMbox = pWhalCtrlCfg->hEventMbox;
+    pWhalCtrl->hCmdQueue = pWhalCtrlCfg->hCmdQueue;
+#ifdef TI_DBG
+    pWhalCtrl->hDebugTrace = pWhalCtrlCfg->hDebugTrace;
+#endif /* TI_DBG */
+    /* 
+    Config the Params object 
+    */
+    whal_params_Config (pWhalCtrl->pWhalParams, pWhalCtrl->hReport);
+
+    /* 
+    Configure the security object
+    */
+    securCfg.hMemMgr = pWhalCtrlCfg->hMemMgr;
+    securCfg.hReport = pWhalCtrl->hReport;
+    if (whalSecur_Config (pWhalCtrl->pWhalSecurity, &securCfg) != OK)
+    {
+        WLAN_REPORT_ERROR (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG, ("Error on whalSecur_Config\n"));
+    }
+    
+    /* 
+    Initialize the Params object database fields
+    */
+
+    pWlanParams->FragmentationOnHal = 0;
+
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    /* NO pInitTableCopy in GWSI yet */
+    pWlanParams->RecoveryEnable     = 
+        ((TnetwDrv_InitParams_t*)(((TnetwDrv_t *)hTNETW_Driver)->pInitTableCopy))->halCtrlConfigParams.halCtrlRecoveryEnable;
+#endif /* GWSI_DRIVER */
+    
+    /* 
+    Call local function to configure the hardware control object 
+    */
+    /* This will at the end call the download function */
+    Stt = whalCtrl_GetSetHwAddr(pWhalCtrl, pWhalCtrlCfg->hMemMgr,pFWImage);
+    /*  This could return TNETWIF__ERROR,TNETWIF_COMPLETE or TNETWIF_PENDING */
+    return (TI_STATUS)Stt;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetTnetwifHandle
+ *
+ * Input    :
+ * Output   :
+ * Process  :  
+ * Note(s)  :  
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalCtrl_GetTnetwifHandle (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return whal_hwCtrl_GetTnentwifHandle (pWhalCtrl->pHwCtrl);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetTnetwifHandle
+ *
+ * Input    :
+ * Output   :
+ * Process  :  
+ * Note(s)  :  
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalCtrl_GetWhalParams (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return (TI_HANDLE)pWhalCtrl->pWhalParams;
+}
+
+
+/****************************************************************************
+ *                      whalCtrl_FinalizeDownload()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the remaining initialization after the download has finished 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whalCtrl_FinalizeDownload (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    /* Call the upper layer to finalize all download action and then send the InitComplete Callback */
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+    return TnetwDrv_InitHw_FinalizeDownload(pWhalCtrl->hTNETW_Driver);
+#else
+    /* GWSI SA deosn't suport recovery, so the normal finalize function is called directly */
+    return TnetwDrv_FinalizeDownload (pWhalCtrl->hTNETW_Driver);
+#endif
+}
+
+
+/****************************************************************************
+ *                      whalCtrl_FinalizeOnFailure()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the remaining initialization after the download has failed 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whalCtrl_FinalizeOnFailure (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    /* Call the upper layer to finalize all download */
+    return TnetwDrv_FinalizeOnFailure (pWhalCtrl->hTNETW_Driver);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Register_CB
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : 
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_Register_CB(TI_HANDLE hWhalCtrl,tiUINT32 CallBackID,void *CBFunc,TI_HANDLE CBObj)
+{
+    WHAL_CTRL* pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG, ("whalCtrl_Register_CB (Value = 0x%x)\n", CallBackID));
+
+    switch(CallBackID)
+    {
+    case HAL_INTERNAL_EVENT_FAILURE:
+        pWhalCtrl->FailureEvent_CB        = (failureEventCB_t)CBFunc;
+        pWhalCtrl->FailureEvent_CB_handle = CBObj;
+        /* Register all health/sanityCheck/Recovery callbacks 
+                DeviceError - CORE callback for full recovery
+                HealthReport - Event Mbox callback for extracting device error
+                MacStatus - Event Mbox callback for checkHwStatus FCS_ERR, RX_FREE_MEM regs
+                Mailbox error - Mailbox queue callback for case of timeout/error */
+      #ifdef USE_RECOVERY
+        whalCtrl_RegisterErrorsCallbacks(hWhalCtrl);
+      #else
+        CmdQueue_RegisterForErrorCB(pWhalCtrl->hCmdQueue, CBFunc, CBObj);
+      #endif 
+        break;
+    case HAL_INT_COMMAND_COMPLETE:
+        whalCtrl_RegisterCmdCompleteGenericCB(hWhalCtrl,CBFunc,CBObj);      
+        break;
+    default:
+        /* register to the Event MBOX the corresponding Callback */
+        whalCtrl_EventMbox_RegisterForEvent(hWhalCtrl, (int)(CallBackID), CBFunc, CBObj);
+        whalCtrl_EventMbox_Enable(hWhalCtrl, (int)(CallBackID));
+    }
+    
+    return;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_PreRecoveryProcess
+ *
+ * Input    : TI_HANDLE hWhalCtrl
+ * Output   :
+ * Process  : prepare for recovery - save all mbox callbacks
+ * Note(s)  : 
+ * -----------------------------------------------------------------------------
+ */
+
+void whalCtrl_PreRecoveryProcess(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL* pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    CmdQueue_StartReconfig( pWhalCtrl->hCmdQueue );
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetMacAddress
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetMacAddress(TI_HANDLE hWhalCtrl, macAddress_t *macAddr)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;  
+
+    return whal_hwCtrl_SetMacAddress(pWhalCtrl->pHwCtrl, macAddr);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetParam
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_SetParam (TI_HANDLE hWhalCtrl, whalParamInfo_t* pParamInfo)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    HwMboxConfig_T *pInfoElemConfig = whal_hwCtrl_GetMboxConfig(pWhalCtrl->pHwCtrl);
+    WlanParams_T *pWlanParams = &pWhalCtrl->pWhalParams->WlanParams;
+    TxParam_t    *pTxParams = whal_ParamsGetTxParams(pWhalCtrl->pWhalParams);
+
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("whalCtrl_SetParam : paramType=0x%X\n", pParamInfo->paramType));
+    
+    switch ((externalParam_e)pParamInfo->paramType)
+    {
+        case HAL_CTRL_RTS_THRESHOLD_PARAM:
+
+            if  (pParamInfo->content.halCtrlRtsThreshold > HAL_CTRL_RTS_THRESHOLD_MAX)
+            {
+                WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl########HAL_CTRL_RTS_THRESHOLD_PARAM: Value out of permitted range 0x%x\n",
+                       pParamInfo->content.halCtrlRtsThreshold));
+                return (PARAM_VALUE_NOT_VALID);
+            }
+
+            if (whal_hwInfoElemRtsThresholdSet (pInfoElemConfig,pParamInfo->content.halCtrlRtsThreshold) == OK)
+            {
+                WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl########HAL_CTRL_RTS_THRESHOLD_PARAM 0x%x\n",
+                                       pParamInfo->content.halCtrlRtsThreshold));
+                pWlanParams->RtsThreshold = pParamInfo->content.halCtrlRtsThreshold;
+            }
+
+
+            break;
+
+        case HAL_CTRL_CTS_TO_SELF_PARAM:
+
+            if (whal_hwInfoElemCtsToSelfSet (pInfoElemConfig, pParamInfo->content.halCtrlCtsToSelf) == OK)
+                pWlanParams->CtsToSelf = pParamInfo->content.halCtrlCtsToSelf;
+        else
+            return NOK;
+
+            break;
+
+        case HAL_CTRL_RX_TIME_OUT_PARAM:
+
+            if (whal_hwInfoElemRxTimeOutSet (pInfoElemConfig, &pParamInfo->content.halCtrlRxTimeOut) == OK)
+            {
+                pWlanParams->rxTimeOut.psPoll = pParamInfo->content.halCtrlRxTimeOut.psPoll;
+                pWlanParams->rxTimeOut.UPSD   = pParamInfo->content.halCtrlRxTimeOut.UPSD;  
+            }
+            break;
+
+
+        case HAL_CTRL_FRAG_THRESHOLD_PARAM:
+            if ((pParamInfo->content.halCtrlFragThreshold < HAL_CTRL_FRAG_THRESHOLD_MIN) ||
+                (pParamInfo->content.halCtrlFragThreshold > HAL_CTRL_FRAG_THRESHOLD_MAX))
+                return (PARAM_VALUE_NOT_VALID);
+
+            pWlanParams->FragmentThreshold  = pParamInfo->content.halCtrlFragThreshold;
+            pWlanParams->FragmentationOnHal = 0;
+            break;
+            
+    case HAL_CTRL_DOT11_MAX_RX_MSDU_LIFE_TIME:
+            if (whal_hwInfoElemRxMsduLifeTimeSet (pInfoElemConfig, pParamInfo->content.halCtrlMaxRxMsduLifetime) == OK)
+               pWlanParams->MaxRxMsduLifetime = (UINT32)pParamInfo->content.halCtrlMaxRxMsduLifetime;
+            break;
+        
+            case HAL_CTRL_ACX_STATISTICS_PARAM:
+            if (whal_hwInfoElemAcxStatisiticsSet (pInfoElemConfig) != OK)
+                return (NOK);
+            break;
+        
+        case HAL_CTRL_LISTEN_INTERVAL_PARAM:
+            if ((pParamInfo->content.halCtrlListenInterval < HAL_CTRL_LISTEN_INTERVAL_MIN) ||
+                (pParamInfo->content.halCtrlListenInterval > HAL_CTRL_LISTEN_INTERVAL_MAX))
+                return (PARAM_VALUE_NOT_VALID);
+
+            pWlanParams->ListenInterval = (UINT8)pParamInfo->content.halCtrlListenInterval;
+            break;
+                            
+        case HAL_CTRL_AID_PARAM:
+            pWlanParams->Aid = pParamInfo->content.halCtrlAid;
+            
+            /* Configure the ACXAID info element*/
+            if (whal_hwCtrl_AidSet (pWhalCtrl->pHwCtrl, pParamInfo->content.halCtrlAid) != OK)
+               return (NOK);
+            break;
+
+        case HAL_CTRL_RSN_HW_ENC_DEC_ENABLE_PARAM:
+
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                    (" whalCtrl########HW_ENC_DEC_ENABLE %d\n", pParamInfo->content.rsnHwEncDecrEnable));
+            
+            /* Set the Encryption/Decryption on the HW*/
+            if (whalSecur_HwEncDecrEnable (pWhalCtrl->pWhalSecurity, pParamInfo->content.rsnHwEncDecrEnable) != OK)
+                return (NOK);
+            break;
+
+        case HAL_CTRL_RSN_KEY_ADD_PARAM:
+
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl########KEY_ADD\n"));
+            
+            if (whalSecur_KeyAdd (pWhalCtrl->pWhalSecurity,
+                                 (securityKeys_t *) pParamInfo->content.configureCmdCBParams.CB_buf,
+                                 FALSE,
+                                 pParamInfo->content.configureCmdCBParams.CB_Func, 
+                                 pParamInfo->content.configureCmdCBParams.CB_handle) != OK)
+                return (NOK);
+            break;
+
+        case HAL_CTRL_RSN_KEY_REMOVE_PARAM:
+    
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl########KEY_REMOVE\n"));
+    
+            if (whalSecur_KeyRemove (pWhalCtrl->pWhalSecurity, 
+                                    (securityKeys_t *) pParamInfo->content.configureCmdCBParams.CB_buf,
+                                    FALSE,
+                                    pParamInfo->content.configureCmdCBParams.CB_Func, 
+                                    pParamInfo->content.configureCmdCBParams.CB_handle) != OK)
+                return (NOK);
+            break;
+
+        case HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM:
+            if ((int) *pParamInfo->content.configureCmdCBParams.CB_buf > MAX_DEFAULT_KEY_ID)
+                return (PARAM_VALUE_NOT_VALID);
+
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl########DEFAULT_KEY_ID %d\n",
+                                   (UINT8)pParamInfo->content.rsnDefaultKeyID));
+            
+            if (whalSecur_DefaultKeyIdSet(pWhalCtrl->pWhalSecurity,
+                                 *pParamInfo->content.interogateCmdCBParams.CB_buf,
+                                 pParamInfo->content.interogateCmdCBParams.CB_Func, 
+                                 pParamInfo->content.interogateCmdCBParams.CB_handle) != OK)
+                return (NOK);
+
+            break;
+
+        case HAL_CTRL_RSN_SECURITY_MODE_PARAM:
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                    (" whalCtrl########SECURITY_MODE_SET %d\n", pParamInfo->content.rsnEncryptionStatus));
+            if (whalSecur_SecurModeSet (pWhalCtrl->pWhalSecurity, (cipherSuite_e)pParamInfo->content.rsnEncryptionStatus) != OK)
+                return (NOK);
+            break;
+
+#ifdef EXC_MODULE_INCLUDED
+        case HAL_CTRL_RSN_EXC_SW_ENC_ENABLE_PARAM:
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                    (" whalCtrl########EXC_SW_ENC_ENABLE %d\n", pParamInfo->content.rsnExcSwEncFlag));
+#ifdef CKIP_ENABLED
+            if (whalSecur_SwEncEnable (pWhalCtrl->pWhalSecurity, pParamInfo->content.rsnExcSwEncFlag) != OK)
+                return (NOK);
+#endif
+            /* when SW encryption is ON, HW encryption should be turned OFF and vice versa */
+            
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                    (" whalCtrl: Set HwEncDecrEnable to %d\n", !pParamInfo->content.rsnExcSwEncFlag));
+                
+            /* Set the Encryption/Decryption on the HW*/
+            if (whalSecur_HwEncDecrEnable (pWhalCtrl->pWhalSecurity, (BOOL)(!(pParamInfo->content.rsnExcSwEncFlag))) != OK)
+                return (NOK);
+            break;
+
+        case HAL_CTRL_RSN_EXC_MIC_FIELD_ENABLE_PARAM:
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                    (" whalCtrl########EXC_MIC_FIELD_ENABLE %d\n", pParamInfo->content.rsnExcMicFieldFlag));
+#ifdef CKIP_ENABLED
+            if (whalSecur_MicFieldEnable (pWhalCtrl->pWhalSecurity, pParamInfo->content.rsnExcMicFieldFlag) != OK)
+                return (NOK);
+#endif
+            break;
+#endif /* EXC_MODULE_INCLUDED*/
+
+        case HAL_CTRL_TX_POWER_PARAM:
+            
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                    (" whalCtrl########TX_POWER_LEVEL old = %d new = %d\n", 
+                                                                       pTxParams->TxPowerDbm, pParamInfo->content.halCtrlTxPowerDbm));
+
+                       if ( pTxParams->TxPowerDbm == pParamInfo->content.halCtrlTxPowerDbm)
+                       {       /* Save up time if we set the same value */
+                               return TX_POWER_SET_SAME_VALUE;
+                       }
+
+            pTxParams->TxPowerDbm = pParamInfo->content.halCtrlTxPowerDbm;
+            
+            /* configure the wlan hardware */
+            if (whal_hwInfoElemTxPowerSet (pInfoElemConfig,
+                                                &pTxParams->TxPowerDbm) != OK)
+                return (NOK);
+            break;
+
+
+        case HAL_CTRL_SG_ENABLE_PARAM:
+            return (TI_STATUS)whal_hwCtrl_SoftGeminiEnable(pWhalCtrl->pHwCtrl,(SoftGeminiEnableModes_e)pParamInfo->content.SoftGeminiEnable);
+
+        case HAL_CTRL_SG_CONFIG_PARAM:
+            return (TI_STATUS)whal_hwCtrl_SetSoftGeminiParams(pWhalCtrl->pHwCtrl,&(pParamInfo->content.SoftGeminiParam));
+
+        case HAL_CTRL_ANTENNA_DIVERSITY_PARAMS:
+            /* save parameters */
+            whal_hwCtrl_SaveAntennaDiversityOptions (pWhalCtrl->pHwCtrl, &(pParamInfo->content.antennaDiversityOptions));
+            /* Configure FW with new parameters */
+            whal_hwCtrl_CurrentAntennaDiversitySendCmd (pWhalCtrl->pHwCtrl);
+            break;
+
+        case HAL_CTRL_TX_ANTENNA_PARAM:
+            /* save antenna number */
+            whal_hwCtrl_SetTxAntenna( pWhalCtrl->pHwCtrl, pParamInfo->content.antennaNum );
+            /* Write parameters to FW */
+            whal_hwCtrl_CurrentAntennaDiversitySendCmd( pWhalCtrl->pHwCtrl );
+            break;
+
+        case HAL_CTRL_RX_ANTENNA_PARAM:
+            /* save antenna number */
+            whal_hwCtrl_SetRxAntenna( pWhalCtrl->pHwCtrl, pParamInfo->content.antennaNum );
+            /* Write parameters to FW */
+            whal_hwCtrl_CurrentAntennaDiversitySendCmd( pWhalCtrl->pHwCtrl );
+            break;
+
+    /*
+     *  TX Parameters 
+     */ 
+
+    case HAL_CTRL_TX_RATE_CLASS_PARAMS:
+        return (TI_STATUS)whal_hwCtrl_TxRatePolicy(pWhalCtrl->pHwCtrl,pParamInfo->content.pTxRatePlicy);
+/*      break; */
+
+    case HAL_CTRL_QUEUES_PARAMS:
+        os_memoryCopy (pWhalCtrl->hOs, &pWhalCtrl->pWhalParams->WlanParams.QtrafficParams,
+                       pParamInfo->content.pQueueTrafficParams, sizeof(queueTrafficParams_t));
+
+        return (TI_STATUS)whal_hwCtrl_TrafficConf(pWhalCtrl->pHwCtrl,pParamInfo->content.pQueueTrafficParams);
+/*      break; */
+
+    case HAL_CTRL_AC_PARAMS:
+        os_memoryCopy (pWhalCtrl->hOs, &pWhalCtrl->pWhalParams->WlanParams.acQosParams,
+                       pParamInfo->content.configureCmdCBParams.CB_buf, sizeof(acQosParams_t));
+        return (TI_STATUS)whal_hwCtrl_AcParamsConf(pWhalCtrl->pHwCtrl,&pParamInfo->content.configureCmdCBParams);
+/*      break; */
+
+        
+    
+#if 0
+
+    /*Tx Ack/No Ack*/
+    case HAL_CTRL_TX_ACK_POLICY:
+            return (whal_ParamsSetAccessCategoryAckPolicy(pWhalCtrl->pWhalParams, 
+                                                          pParamInfo->content.AcAckPolicy.AckPolicy,
+                                                          pParamInfo->content.AcAckPolicy.AcId));
+            break;
+
+#endif
+
+    case HAL_CTRL_MIN_POWER_LEVEL:
+        whalCtrl_SetMinPowerLevel(pWhalCtrl,
+                                    pParamInfo->content.minPowerPolicy);
+            break;
+
+    
+    case HAL_CTRL_CLK_RUN_ENABLE:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                (" whalCtrl_SetParam: CLK_RUN_ENABLE %d\n", pParamInfo->content.halCtrlClkRunEnable));
+
+        /* Set the Encryption/Decryption on the HW*/
+        if (whal_hwCtrl_ClkRunEnableSet (pWhalCtrl->pHwCtrl, pParamInfo->content.halCtrlClkRunEnable) != OK)
+            return (NOK);
+        break;
+
+    case HAL_CTRL_EARLY_WAKEUP:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                (" whalCtrl_SetParam: SET EARLY WAKEUP to %d\n", pParamInfo->content.earlyWakeup));
+        pWlanParams->earlyWakeUp = pParamInfo->content.earlyWakeup;
+        break;
+
+        /* PLT params */    
+    case HAL_CTRL_PLT_WRITE_MIB:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_WRITE_MIB(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_WriteMib(hWhalCtrl, &pParamInfo->content.PltMib);
+        
+/*        break; */
+        
+    case HAL_CTRL_PLT_RX_PER_START:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_RX_PER_START(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_RxPER(pWhalCtrl, PLT_RX_PER_START, 
+            pParamInfo->content.interogateCmdCBParams.CB_handle, 
+            pParamInfo->content.interogateCmdCBParams.CB_Func);            
+/*        break; */
+        
+    case HAL_CTRL_PLT_RX_PER_STOP:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_RX_PER_STOP(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_RxPER(pWhalCtrl, PLT_RX_PER_STOP, 
+            pParamInfo->content.interogateCmdCBParams.CB_handle, 
+            pParamInfo->content.interogateCmdCBParams.CB_Func);            
+/*        break; */
+        
+    case HAL_CTRL_PLT_RX_PER_CLEAR:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_RX_PER_CLEAR(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_RxPER(pWhalCtrl, PLT_RX_PER_CLEAR, 
+            pParamInfo->content.interogateCmdCBParams.CB_handle, 
+            pParamInfo->content.interogateCmdCBParams.CB_Func);            
+/*        break; */
+    case HAL_CTRL_PLT_TX_CW:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_TX_CW(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_TxCW(pWhalCtrl, &pParamInfo->content.PltCW,
+                                NULL, NULL, NULL);
+        /*break;*/
+        
+    case HAL_CTRL_PLT_TX_CONTINUES:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_TX_CONTINUES(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_TxContinues(pWhalCtrl, &pParamInfo->content.PltTxContinues,
+                                    NULL, NULL, NULL);
+        /*break;*/
+
+    case HAL_CTRL_PLT_TX_STOP:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_TX_STOP(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whal_hwCmdBit_perTxStop(pWhalCtrl->pHwCtrl->pHwMboxCmdBit, 
+                                       NULL, NULL, NULL);
+        /*break;*/
+        
+    case HAL_CTRL_PLT_WRITE_REGISTER:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_WRITE_REGISTER(0x%x) \n", __FUNCTION__, pParamInfo->paramType));
+        return (TI_STATUS)whalCtrl_WriteRegister(pWhalCtrl, pParamInfo->content.interogateCmdCBParams.CB_handle, pParamInfo->content.interogateCmdCBParams.CB_Func, pParamInfo->content.interogateCmdCBParams.CB_buf);
+/*        break;  */
+        
+    default:
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport,
+                      HAL_CTRL_MODULE_LOG,
+                      ("%s(%d) - whalCtrl_SetParam - ERROR - Param is not supported, %d\n\n",
+                       __FILE__,__LINE__,pParamInfo->paramType));
+        return (PARAM_NOT_SUPPORTED);
+    }
+    
+    return (OK);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetParam
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_GetParam (TI_HANDLE hWhalCtrl, whalParamInfo_t* pParamInfo)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    WlanParams_T *pWlanParams = &pWhalCtrl->pWhalParams->WlanParams;
+    HwMboxConfig_T *pInfoElemConfig = whal_hwCtrl_GetMboxConfig(pWhalCtrl->pHwCtrl);
+    TxParam_t      *pTxParams = whal_ParamsGetTxParams(pWhalCtrl->pWhalParams);
+
+    switch ((externalParam_e)pParamInfo->paramType)
+    {
+        case HAL_CTRL_RTS_THRESHOLD_PARAM:
+            pParamInfo->content.halCtrlRtsThreshold = pWlanParams->RtsThreshold;
+            break;
+        
+        case HAL_CTRL_FRAG_THRESHOLD_PARAM:
+            pParamInfo->content.halCtrlFragThreshold = pWlanParams->FragmentThreshold;
+            break;
+
+        case HAL_CTRL_COUNTERS_PARAM:
+            /* Constant zero because the ACX last buffer next pointer is always pointed
+               to itself, so it's like an endless buffer*/
+            pParamInfo->content.halCtrlCounters.RecvNoBuffer = 0;
+            pParamInfo->content.halCtrlCounters.FragmentsRecv = 0; /* not supported;*/
+            pParamInfo->content.halCtrlCounters.FrameDuplicates = 0;/* not supported*/
+            pParamInfo->content.halCtrlCounters.FcsErrors = pWhalCtrl->pWhalParams->GenCounters.FcsErrCnt;
+            pParamInfo->content.halCtrlCounters.RecvError = pWhalCtrl->pWhalParams->GenCounters.FcsErrCnt;
+            break;
+        
+        case HAL_CTRL_LISTEN_INTERVAL_PARAM:
+            pParamInfo->content.halCtrlListenInterval = pWlanParams->ListenInterval;
+            break;
+                            
+        case HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM:
+            /* Not implemented */
+            return NOK;
+/*            break; */
+
+        case HAL_CTRL_TX_POWER_PARAM:
+            pParamInfo->content.halCtrlTxPowerDbm = pTxParams->TxPowerDbm;
+            break;
+        
+        case HAL_CTRL_ACX_STATISTICS_PARAM:
+            /* Not implemented */
+         #if 0
+            {
+                acxStatisitcs_t     acxStatisitics;
+                pParamInfo->content.acxStatisitics.FWpacketReceived = acxStatisitics.FWpacketReceived;
+                /* Not supported */
+                pParamInfo->content.acxStatisitics.HALpacketReceived = 0; 
+            }
+         #endif
+            return NOK;
+
+        case HAL_CTRL_MEDIUM_OCCUPANCY_PARAM:
+            if (whal_hwInfoElemMediumOccupancyGet (pInfoElemConfig,
+                                                   pParamInfo->content.interogateCmdCBParams) != OK)
+                return (NOK);
+
+            break;
+
+        case HAL_CTRL_TSF_DTIM_MIB:
+            if (whal_hwInfoElemTfsDtimGet(pInfoElemConfig,
+                                          pParamInfo->content.interogateCmdCBParams) != OK)
+                return (NOK);
+            
+            break;
+
+
+    case HAL_CTRL_AID_PARAM:
+        if (whal_hwCtrl_CurrentAssociationIdGet(pWhalCtrl->pHwCtrl,
+                                     &(pParamInfo->content.halCtrlAid)) != OK)
+            return (NOK);
+
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                (" AID 2 %d\n", pParamInfo->content.halCtrlAid));
+
+
+        break;
+
+    case HAL_CTRL_NOISE_HISTOGRAM_PARAM:
+        if (whal_hwInfoElemNoiseHistogramResultsGet (pInfoElemConfig,
+                                                     pParamInfo->content.interogateCmdCBParams) != OK)
+        {
+            return (NOK);
+        }
+
+        break;
+
+    case HAL_CTRL_TX_ANTENNA_PARAM:
+        /* get antenna number */
+        whal_hwCtrl_GetTxAntenna( pWhalCtrl->pHwCtrl, &(pParamInfo->content.antennaNum) );
+        break;
+
+    case HAL_CTRL_RX_ANTENNA_PARAM:
+        /* get antenna number */
+        whal_hwCtrl_GetRxAntenna( pWhalCtrl->pHwCtrl, &(pParamInfo->content.antennaNum) );
+        break;
+
+    case HAL_CTRL_CURRENT_CHANNEL:
+        /* get current channel number */
+        pParamInfo->content.halCtrlCurrentChannel = whal_ParamsGetRadioChannel( pWhalCtrl->pWhalParams );
+
+    case HAL_CTRL_MIN_POWER_LEVEL:
+        whalCtrl_GetMinPowerLevel(pWhalCtrl, &pParamInfo->content.minPowerPolicy);
+        break;
+
+        /*SNR and RSSI belongs to the same MIB, and the relevant CB is passed here*/
+    case HAL_CTRL_RSSI_LEVEL_PARAM:
+    case HAL_CTRL_SNR_RATIO_PARAM:
+        /* Retrive the Callback function and read buffer pointer that are in fact stored in the TIWLAN_ADAPTER and then send it to the Command Mailbox */
+        whalCtrl_GetAsynRSSI (pWhalCtrl,pParamInfo->content.interogateCmdCBParams.CB_Func, pParamInfo->content.interogateCmdCBParams.CB_handle , pParamInfo->content.interogateCmdCBParams.CB_buf);
+        break;
+
+    case HAL_CTRL_BCN_BRC_OPTIONS:
+        pParamInfo->content.BcnBrcOptions.BeaconRxTimeout    = pWlanParams->BcnBrcOptions.BeaconRxTimeout;
+        pParamInfo->content.BcnBrcOptions.BroadcastRxTimeout = pWlanParams->BcnBrcOptions.BroadcastRxTimeout;
+        pParamInfo->content.BcnBrcOptions.RxBroadcastInPs    = pWlanParams->BcnBrcOptions.RxBroadcastInPs;
+        break;
+
+    case HAL_CTRL_DOT11_MAX_RX_MSDU_LIFE_TIME:
+        pParamInfo->content.halCtrlMaxRxMsduLifetime = pWlanParams->MaxRxMsduLifetime;
+        break;
+        
+        
+        /* PLT params */    
+    case HAL_CTRL_PLT_RX_PER_GET_RESULTS:
+        return (TI_STATUS)whalCtrl_RxPER(pWhalCtrl, PLT_RX_PER_GETRESULTS, 
+            pParamInfo->content.interogateCmdCBParams.CB_handle, 
+            pParamInfo->content.interogateCmdCBParams.CB_Func);            
+/*        break; */
+        
+    case HAL_CTRL_PLT_READ_MIB:
+        return (TI_STATUS)whalCtrl_ReadMib(pWhalCtrl, 
+            pParamInfo->content.interogateCmdCBParams.CB_handle,
+            pParamInfo->content.interogateCmdCBParams.CB_Func, 
+            pParamInfo->content.interogateCmdCBParams.CB_buf);
+        
+/*        break; */
+        
+    case HAL_CTRL_PLT_READ_REGISTER:        
+        whalCtrl_ReadRegister(pWhalCtrl, pParamInfo->content.interogateCmdCBParams.CB_handle,
+            pParamInfo->content.interogateCmdCBParams.CB_Func, 
+            pParamInfo->content.interogateCmdCBParams.CB_buf);
+        break;
+
+    case HAL_CTRL_PLT_RX_TX_CAL:
+         WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  ("%s - HAL_CTRL_PLT_RX_TX_CAL(0x%x) \n", __FUNCTION__, pParamInfo->paramType));         
+         return (TI_STATUS)whal_hwCmdBit_TestCmd(pWhalCtrl->pHwCtrl->pHwMboxCmdBit,                                       
+                                      pParamInfo->content.interogateCmdCBParams.CB_Func, 
+                                      pParamInfo->content.interogateCmdCBParams.CB_handle,
+                                      (TestCmd_t*)pParamInfo->content.interogateCmdCBParams.CB_buf);
+         /*break*/
+
+    case HAL_CTRL_PLT_RX_CAL_STATUS:
+         whal_hwCmdBit_GetPltRxCalibrationStatus( pWhalCtrl->pHwCtrl->pHwMboxCmdBit, 
+                                                  &(pParamInfo->content.PltRxCalibrationStatus) );
+         return OK;
+         /* break */
+
+    case HAL_CTRL_CTS_TO_SELF_PARAM:
+        pParamInfo->content.halCtrlCtsToSelf = pWlanParams->CtsToSelf;        
+        break;
+
+    case HAL_CTRL_TX_RATE_CLASS_PARAMS:
+        pParamInfo->content.pTxRatePlicy = whal_hwCtrl_GetTxRatePolicy(pWhalCtrl->pHwCtrl);
+        break;
+
+    case HAL_CTRL_SG_CONFIG_PARAM:
+        return (TI_STATUS)whal_hwCtrl_GetSoftGeminiParams(pWhalCtrl->pHwCtrl,
+                                      pParamInfo->content.interogateCmdCBParams.CB_Func, 
+                                      pParamInfo->content.interogateCmdCBParams.CB_handle,
+                                      (void*)pParamInfo->content.interogateCmdCBParams.CB_buf);
+
+    case HAL_CTRL_REVISION:
+        return (TI_STATUS)whal_hwInfoElemAcxRevisionGet (pInfoElemConfig,
+                                                         pParamInfo->content.interogateCmdCBParams.CB_Func, 
+                                                         pParamInfo->content.interogateCmdCBParams.CB_handle,
+                                                         (void*)pParamInfo->content.interogateCmdCBParams.CB_buf);
+
+       case HAL_CTRL_RSN_SECURITY_MODE_PARAM:
+               pParamInfo->content.rsnEncryptionStatus = (halCtrl_CipherSuite_e)whalSecur_SecurModeGet (pWhalCtrl->pWhalSecurity);
+
+               WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                               (" whalCtrl########SECURITY_MODE_GET %d\n", pParamInfo->content.rsnEncryptionStatus));
+        break; 
+
+    case HAL_CTRL_EARLY_WAKEUP:
+        WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                (" whalCtrl_SetParam: GET EARLY WAKEUP is %d\n", pWlanParams->earlyWakeUp));
+        pParamInfo->content.earlyWakeup = pWlanParams->earlyWakeUp;
+
+        break; 
+
+       case HAL_CTRL_POWER_LEVEL_TABLE_PARAM:
+               if (whal_hwInfoElemPowerLevelTableGet (pInfoElemConfig,
+                       pParamInfo->content.interogateCmdCBParams) != OK)
+               {
+                       return (NOK);
+               }
+
+               break;
+    case HAL_CTRL_POWER_CONSUMPTION:
+        whalCtrl_getConsumptionStatistics(pWhalCtrl->pHwCtrl->pHwMboxConfig, 
+                    pParamInfo->content.interogateCmdCBParams.CB_Func,
+                    pParamInfo->content.interogateCmdCBParams.CB_handle, 
+                    (void*)pParamInfo->content.interogateCmdCBParams.CB_buf);
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport,
+            HAL_CTRL_MODULE_LOG,
+            ("%s(%d) - whalCtrl_GetParam - ERROR - Param is not supported, %d\n\n",
+            __FILE__,__LINE__,pParamInfo->paramType));
+        return (PARAM_NOT_SUPPORTED);
+/*        break; */
+    }
+
+    return (OK);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_setRxFilters
+ *
+ * Input    :
+ * Output   :
+ * Process  :  Configures the Rx filters
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_setRxFilters(TI_HANDLE hWhalCtrl, UINT32 RxConfigOption, UINT32 RxFilterOption)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return whal_hwCtrl_setRxFilters(pWhalCtrl->pHwCtrl, RxConfigOption, RxFilterOption);
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_GetRxFilters
+*
+* Input    :
+* Output   :
+* Process  :  Configures the Rx filters
+* Note(s)  :  Done
+* -----------------------------------------------------------------------------
+*/
+int  whalCtrl_GetRxFilters      (TI_HANDLE hWhalCtrl, UINT32* pRxConfigOption, UINT32* pRxFilterOption)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return whal_hwCtrl_GetRxFilters(pWhalCtrl->pHwCtrl, pRxConfigOption, pRxFilterOption);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+* Function : whalCtrl_getRxDataFiltersStatistics
+*
+* Input    : Retrieve Statistics
+* Output   :
+* Process  :
+* Note(s)  : Done
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_getRxDataFiltersStatistics(TI_HANDLE hWhalCtrl, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf)
+{
+    WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+
+    whal_hwInfoElemGetRxDataFiltersStatistics(pWhalCtrl->pHwCtrl->pHwMboxConfig, CB_Func, CB_handle, CB_Buf);
+
+    return OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_setRxDataFiltersParams
+ *
+ * Input    :   enabled             - 0 to disable data filtering, any other value to enable.
+ *              defaultAction       - The default action to take on non-matching packets.
+ * Output   :
+ * Process  :  Enable or disable the Rx Data Filtering feature.
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_setRxDataFiltersParams(TI_HANDLE hWhalCtrl, BOOL enabled, filter_e defaultAction)
+{
+    WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+
+    pWhalCtrl->pWhalParams->WlanParams.rxFilterDefaultEnable = enabled;
+    pWhalCtrl->pWhalParams->WlanParams.rxFilterDefaultAction = defaultAction;
+
+    return whal_hwCtrl_setRxDataFiltersParams(pWhalCtrl->pHwCtrl, enabled, defaultAction);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_setRxDataFilter
+ *
+ * Input    :   index               - Index of the Rx Data filter
+ *              command             - Disable or enable the filter
+ *              action              - Action to take on packets matching the pattern
+ *              numFieldPatterns    - Number of field patterns in the filter
+ *              lenFieldPatterns    - Length of the field pattern series
+ *              fieldPatterns       - Series of field patterns
+ * Output   :
+ * Process  :  Adds or removes the Rx Data Filter at the specified entry.
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_setRxDataFilter(TI_HANDLE hWhalCtrl, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns)
+{
+    WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+
+    pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterCommand = command;
+    pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterAction = action;
+    pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterNumFieldPatterns = numFieldPatterns;
+    pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterLenFieldPatterns = lenFieldPatterns;
+
+    os_memoryCopy(pWhalCtrl->hOs, (pWhalCtrl->pWhalParams->WlanParams.rxFilterCgf[index].rxFilterFieldPatterns), 
+                  fieldPatterns, lenFieldPatterns);
+
+    return whal_hwCtrl_setRxDataFilter(pWhalCtrl->pHwCtrl, index, command, action, numFieldPatterns, lenFieldPatterns, fieldPatterns);
+}
+
+
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetarpIpAddressesTable
+ *
+ * Input    :
+ * Output   :
+ * Process  :  Configures the ARP table
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetarpIpAddressesTable(TI_HANDLE hWhalCtrl, IpAddress_t * IP_addr, UINT8 isEnabled , IPver_e IP_ver)
+{
+    WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+
+    return whal_hwCtrl_SetarpIpAddressesTable(pWhalCtrl->pHwCtrl, IP_addr, isEnabled , IP_ver);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+* Function : whalCtrl_GetGroupIpAddressesTable
+*
+* Input    :
+* Output   :
+* Process  :  Retrieve the ARP IP address table
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_GetGroupIpAddressesTable(TI_HANDLE hWhalCtrl, UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    return whal_hwCtrl_GetGroupAddressesTable(pWhalCtrl->pHwCtrl, 
+        pisEnabled, pnumGroupAddrs, Group_addr);
+}
+
+
+/*
+* ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetarpIpFilterEnabled
+ *
+ * Input    :
+ * Output   :
+ * Process  :  Configures the ARP table
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetarpIpFilterEnabled(TI_HANDLE hWhalCtrl,UINT8 isEnabled )
+{
+    WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+    return whal_hwCtrl_SetarpIpFilterEnabled(pWhalCtrl->pHwCtrl, isEnabled ) ;
+    
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_StartScan
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_StartScan (TI_HANDLE hWhalCtrl, whalCtrl_scan_t* pScanVals, BOOLEAN bHighPriority ,void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    BasicScanChannelParameters_t* chanPtr;
+    ScanParameters_t    tnetScanParams;
+
+    UINT8*              pBSSID;
+    int i;
+
+    /* Convert general scan data to tnet structure */
+    tnetScanParams.basicScanParameters.tidTrigger = pScanVals->Tid;
+    tnetScanParams.basicScanParameters.numOfProbRqst = pScanVals->probeReqNumber;
+    tnetScanParams.basicScanParameters.ssidLength = pScanVals->desiredSsid.len;
+    os_memoryCopy( pWhalCtrl->hOs, (void *)tnetScanParams.basicScanParameters.ssidStr, 
+                   (void *)pScanVals->desiredSsid.ssidString, tnetScanParams.basicScanParameters.ssidLength );
+    
+    /* 
+        scan options field is composed of scan type and band selection. 
+        First, use the lookup table to convert the scan type 
+    */                  
+
+    tnetScanParams.basicScanParameters.scanOptions = 0;
+
+    switch ( pScanVals->scanType )
+    {
+    case SCAN_TYPE_NORMAL_ACTIVE : 
+        tnetScanParams.basicScanParameters.scanOptions = SCAN_ACTIVE;
+        break;
+    
+    case SCAN_TYPE_NORMAL_PASSIVE : 
+        tnetScanParams.basicScanParameters.scanOptions = SCAN_PASSIVE;
+        break;
+    
+    case SCAN_TYPE_TRIGGERED_ACTIVE :
+        tnetScanParams.basicScanParameters.scanOptions = SCAN_ACTIVE | TRIGGERED_SCAN;
+        break;
+    
+    case SCAN_TYPE_TRIGGERED_PASSIVE :
+        tnetScanParams.basicScanParameters.scanOptions = SCAN_PASSIVE | TRIGGERED_SCAN;
+        break;
+
+    default:
+        WLAN_REPORT_ERROR( pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                           ("Invalid scan type:%d\n", pScanVals->scanType) );
+        return NOK;
+    }
+
+    /* Add the band selection */
+    if ( RADIO_BAND_5_0_GHZ == pScanVals->band )
+    {
+        tnetScanParams.basicScanParameters.scanOptions |= SCAN_5GHZ_BAND;
+    }
+
+    /* Add high priority bit */
+    if ( bHighPriority )
+    {
+        tnetScanParams.basicScanParameters.scanOptions |= SCAN_PRIORITY_HIGH;
+    }
+
+    tnetScanParams.basicScanParameters.scanOptions = ENDIAN_HANDLE_WORD( tnetScanParams.basicScanParameters.scanOptions );
+
+    /* important note: BSSID filter (0x0010) is DISABLED, because the FW sets it according
+       to BSSID value (broadcast does not filter, any other value will */
+    tnetScanParams.basicScanParameters.rxCfg.ConfigOptions = 0x12802 ;
+    tnetScanParams.basicScanParameters.rxCfg.FilterOptions = ENDIAN_HANDLE_LONG( RX_FILTER_CFG_ );
+
+    /* If the SSID is not broadcast SSID, also filter according to SSID */
+    if ( FALSE == utils_isAnySSID( &(pScanVals->desiredSsid) ) )
+    {
+        tnetScanParams.basicScanParameters.rxCfg.ConfigOptions |= 0x0400;
+    }
+    tnetScanParams.basicScanParameters.rxCfg.ConfigOptions = ENDIAN_HANDLE_LONG( tnetScanParams.basicScanParameters.rxCfg.ConfigOptions );
+
+    /* Rate conversion is done in the HAL */
+    whalUtils_ConvertAppRatesBitmap(pScanVals->probeRequestRate, 0, &(tnetScanParams.basicScanParameters.txdRateSet));
+    tnetScanParams.basicScanParameters.txdRateSet = ENDIAN_HANDLE_WORD( tnetScanParams.basicScanParameters.txdRateSet );
+    
+    tnetScanParams.basicScanParameters.numChannels = ENDIAN_HANDLE_WORD( pScanVals->numOfChannels );
+
+    /* copy channel specific scan data to HAL structure */
+    for ( i = 0; i < pScanVals->numOfChannels; i++ )
+    {
+        int j;
+        UINT8*  macAddr;
+
+        macAddr = (UINT8*)&tnetScanParams.basicScanChannelParameters[ i ].bssIdL;
+
+        /* copy the MAC address, upside down (CHIP structure) */
+        for ( j = 0; j < MAC_ADDR_LEN; j++ )
+        {
+            macAddr[ j ] = pScanVals->channelEntry[ i ].normalChannelEntry.bssId.addr[ MAC_ADDR_LEN - 1 - j ];
+        }
+        tnetScanParams.basicScanChannelParameters[ i ].scanMinDuration = 
+            ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].normalChannelEntry.minChannelDwellTime );
+        tnetScanParams.basicScanChannelParameters[ i ].scanMaxDuration = 
+            ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime );
+        tnetScanParams.basicScanChannelParameters[ i ].ETCondCount = 
+            pScanVals->channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes |
+            pScanVals->channelEntry[ i ].normalChannelEntry.earlyTerminationEvent;
+        tnetScanParams.basicScanChannelParameters[ i ].txPowerAttenuation = 
+            pScanVals->channelEntry[ i ].normalChannelEntry.txPowerDbm;
+        tnetScanParams.basicScanChannelParameters[ i ].channel = 
+            pScanVals->channelEntry[ i ].normalChannelEntry.channel;
+    }
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("RxCfg = 0x%x\n \
+                              RxFilterCfg = 0x%x\n \
+                              scanOptions = 0x%x\n \
+                              numChannels = %d\n \
+                              probeNumber = %d\n \
+                              probeRateModulation = 0x%x\n \
+                              tidTrigger = %d\n" , 
+                              tnetScanParams.basicScanParameters.rxCfg.ConfigOptions, 
+                              tnetScanParams.basicScanParameters.rxCfg.FilterOptions,
+                              tnetScanParams.basicScanParameters.scanOptions, 
+                              tnetScanParams.basicScanParameters.numChannels, 
+                              tnetScanParams.basicScanParameters.numOfProbRqst,
+                              tnetScanParams.basicScanParameters.txdRateSet, 
+                              tnetScanParams.basicScanParameters.tidTrigger));
+    
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("Channel      BSSID           MinTime     MaxTime     ET     TxPower   probChan\n"));
+   
+    for( i=0; i < pScanVals->numOfChannels; i++)
+    {
+        chanPtr = &tnetScanParams.basicScanChannelParameters[i];
+        pBSSID = (UINT8*)&chanPtr->bssIdL;
+
+        WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("%6d   %02x:%02x:%02x:%02x:%02x:%02x    %5d %5d %2d %5d %5d\n",i,  
+            pBSSID[5],pBSSID[4],pBSSID[3],pBSSID[2],pBSSID[1],pBSSID[0],
+            chanPtr->scanMinDuration, chanPtr->scanMaxDuration, chanPtr->ETCondCount,
+            chanPtr->txPowerAttenuation,    chanPtr->channel));
+    }
+    /* Send the scan command*/
+    return (whal_hwCtrl_StartScan (pWhalCtrl->pHwCtrl, &tnetScanParams , ScanCommandResponseCB , CB_handle));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_StartSPSScan
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_StartSPSScan( TI_HANDLE hWhalCtrl, whalCtrl_scan_t* pScanVals, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    ScheduledScanParameters_t   tnetSPSScanParams;
+    int i;
+
+    /* Convert general scan data to TNET structure */
+    tnetSPSScanParams.scheduledGeneralParameters.scanOptions = SCAN_PASSIVE;
+    /* Add the band selection */
+    if ( RADIO_BAND_5_0_GHZ == pScanVals->band )
+    {
+        tnetSPSScanParams.scheduledGeneralParameters.scanOptions |= SCAN_5GHZ_BAND;
+    }
+    tnetSPSScanParams.scheduledGeneralParameters.scanOptions = ENDIAN_HANDLE_WORD( tnetSPSScanParams.scheduledGeneralParameters.scanOptions );
+
+    /* important note: BSSID filter (0x0010) is DISABLED, because the FW sets it according
+       to BSSID value (broadcast does not filter, any other value will */
+    /* If the SSID is not broadcast SSID, also filter according to SSID */
+    tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions = 0x12802;
+    tnetSPSScanParams.scheduledGeneralParameters.rxCfg.FilterOptions = ENDIAN_HANDLE_LONG( RX_FILTER_CFG_ );
+    tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions = ENDIAN_HANDLE_LONG( tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions );
+
+    /* latest TSF value - used to discover TSF error (AP recovery) */
+    tnetSPSScanParams.scheduledGeneralParameters.scanCmdTime_h = ENDIAN_HANDLE_LONG( INT64_HIGHER(pScanVals->latestTSFValue) );
+    tnetSPSScanParams.scheduledGeneralParameters.scanCmdTime_l = ENDIAN_HANDLE_LONG( INT64_LOWER(pScanVals->latestTSFValue) );
+
+    tnetSPSScanParams.scheduledGeneralParameters.numChannels = pScanVals->numOfChannels;
+
+    /* copy channel specific scan data to HAL structure */
+    for ( i = 0; i < pScanVals->numOfChannels; i++ )
+    {
+        int j;
+        UINT8*  macAddr;
+
+        macAddr = (UINT8*)&tnetSPSScanParams.scheduledChannelParameters[ i ].bssIdL;
+
+        /* copy the MAC address, upside down (CHIP structure) */
+        for ( j = 0; j < MAC_ADDR_LEN; j++ )
+        {
+            macAddr[ j ] = pScanVals->channelEntry[ i ].normalChannelEntry.bssId.addr[ MAC_ADDR_LEN - 1 - j ];
+        }
+        tnetSPSScanParams.scheduledChannelParameters[ i ].scanMaxDuration = 
+            ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].SPSChannelEntry.scanDuration );
+        tnetSPSScanParams.scheduledChannelParameters[ i ].scanStartTime = 
+            ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].SPSChannelEntry.scanStartTime );
+        tnetSPSScanParams.scheduledChannelParameters[ i ].ETCondCount =
+            pScanVals->channelEntry[ i ].SPSChannelEntry.ETMaxNumOfAPframes | 
+            pScanVals->channelEntry[ i ].SPSChannelEntry.earlyTerminationEvent;
+        tnetSPSScanParams.scheduledChannelParameters[ i ].channel = 
+            pScanVals->channelEntry[ i ].SPSChannelEntry.channel;
+    }
+#ifdef TI_DBG
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("RxCfg = 0x%x\n \
+                              RxFilterCfg = 0x%x\n \
+                              scanOptions = 0x%x\n \
+                              numChannels = %d\n",
+                              tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions, 
+                              tnetSPSScanParams.scheduledGeneralParameters.rxCfg.FilterOptions,
+                              tnetSPSScanParams.scheduledGeneralParameters.scanOptions, 
+                              tnetSPSScanParams.scheduledGeneralParameters.numChannels));
+    
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("Channel      BSSID           StartTime     Duration     ET     probChan\n"));
+   
+    for( i=0; i < tnetSPSScanParams.scheduledGeneralParameters.numChannels; i++)
+    {
+        ScheduledChannelParameters_t* chanPtr = &tnetSPSScanParams.scheduledChannelParameters[ i ];
+        UINT8* pBSSID = (UINT8*)&chanPtr->bssIdL;
+
+        WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("%6d   %02x:%02x:%02x:%02x:%02x:%02x    %5d %5d %2d %5d\n",i,  
+            pBSSID[5],pBSSID[4],pBSSID[3],pBSSID[2],pBSSID[1],pBSSID[0],
+            chanPtr->scanStartTime, chanPtr->scanMaxDuration, chanPtr->ETCondCount,
+            chanPtr->channel));
+    }
+#endif /* TI_DBG */
+
+    /* Send the scan command*/
+    return (whal_hwCtrl_StartSPSScan (pWhalCtrl->pHwCtrl, &tnetSPSScanParams, ScanCommandResponseCB,CB_handle));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_StopScan
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_StopScan (TI_HANDLE hWhalCtrl , void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return (whal_hwCtrl_StopScan (pWhalCtrl->pHwCtrl, ScanCommandResponseCB, CB_handle));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_StopSPSScan
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_StopSPSScan (TI_HANDLE hWhalCtrl, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return (whal_hwCtrl_StopSPSScan (pWhalCtrl->pHwCtrl, ScanCommandResponseCB, CB_handle));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetSplitScanTimeOut
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+
+TI_STATUS whalCtrl_SetSplitScanTimeOut (TI_HANDLE hWhalCtrl, UINT32 uTimeOut)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    /* Go all the way to the CmdQueue - According to new architecture ??? */
+    return (TI_STATUS)(CmdQueue_Command (pWhalCtrl->hCmdQueue, CMD_TRIGGER_SCAN_TO, (char*)&uTimeOut, sizeof(uTimeOut)));
+    
+}
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_JoinBss
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_JoinBss (TI_HANDLE hWhalCtrl, whalCtrl_joinBss_t* pJoinBssParams)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    WlanParams_T *pWlanParams       = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+#ifdef TI_DBG
+    UINT8 dbgSsidStr[33];
+    BssInfoParams_T *pBssInfoParams = whal_ParamsGetBssInfoParams(pWhalCtrl->pWhalParams);
+#endif /* TI_DBG */
+
+
+    /* for debug purpose, can be removed later*/
+    if (pJoinBssParams->ssidLength > 32)
+        pJoinBssParams->ssidLength = 32;
+
+#ifdef TI_DBG
+    os_memoryCopy(pWhalCtrl->hOs, (void *)dbgSsidStr, (void *)pJoinBssParams->pSSID, pJoinBssParams->ssidLength);
+    dbgSsidStr[pJoinBssParams->ssidLength] = '\0';
+
+    /* HW generate packets - CTS - should be at CCK rates only */
+    if ((pJoinBssParams->radioBand == RADIO_BAND_2_4_GHZ) &&
+        (pJoinBssParams->hwGenCtrlTxRate > DRV_RATE_11M))
+    {
+        pJoinBssParams->hwGenCtrlTxRate = DRV_RATE_2M; /* default value, if no CCK rate is in the basic rates */
+        if(pJoinBssParams->basicRateSet & DRV_RATE_MASK_1_BARKER) pJoinBssParams->hwGenCtrlTxRate = DRV_RATE_1M;
+        if(pJoinBssParams->basicRateSet & DRV_RATE_MASK_2_BARKER) pJoinBssParams->hwGenCtrlTxRate = DRV_RATE_2M;
+        if(pJoinBssParams->basicRateSet & DRV_RATE_MASK_5_5_CCK)  pJoinBssParams->hwGenCtrlTxRate = DRV_RATE_5_5M;
+        if(pJoinBssParams->basicRateSet & DRV_RATE_MASK_11_CCK)   pJoinBssParams->hwGenCtrlTxRate = DRV_RATE_11M;
+
+        WLAN_REPORT_WARNING(pWhalCtrl->hReport,HAL_CTRL_MODULE_LOG,
+            ("%s  hwGenCtrlTxRate > 11 !!! changed to %d (rate_e)\n",__FUNCTION__,pJoinBssParams->hwGenCtrlTxRate));
+
+    }
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n whalCtrl_JoinBss :\n \
+                              bssType = %d\n \
+                              beaconInterval = %d\n \
+                              dtimInterval = %d\n \
+                              channel = %d \n \
+                              BSSID = %x-%x-%x-%x-%x-%x \n \
+                              SSID = %s \n \
+                              ssidLength = %d \n \
+                              basicRateSet = 0x%x \n \
+                              supportedRateSet = 0x%x \n ",
+                              pJoinBssParams->bssType, 
+                              pJoinBssParams->beaconInterval,
+                              pJoinBssParams->dtimInterval, 
+                              pJoinBssParams->channel,
+                              pJoinBssParams->pBSSID[0],
+                              pJoinBssParams->pBSSID[1],
+                              pJoinBssParams->pBSSID[2],
+                              pJoinBssParams->pBSSID[3],
+                              pJoinBssParams->pBSSID[4],
+                              pJoinBssParams->pBSSID[5],
+                              dbgSsidStr, 
+                              pJoinBssParams->ssidLength,
+                              pJoinBssParams->basicRateSet,
+                              pJoinBssParams->supportedRateSet));
+
+      WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                              ("RadioBand = %d \n \
+                                Ctrl = 0x%x \n \
+                                hwGenCtrlTxRate = 0x%x  \n \
+                                hwGenMgmtTxRate = 0x%x  \n \
+                                preamble = 0x%x \n",
+                                pJoinBssParams->radioBand,
+                                pBssInfoParams->Ctrl,
+                                pJoinBssParams->hwGenCtrlTxRate, 
+                                pJoinBssParams->hwGenMgmtTxRate,
+                                pJoinBssParams->preamble));
+#endif /* TI_DBG */
+    /*
+     * save Bss info parameters
+     */
+    whal_ParamsSetReqBssType(pWhalCtrl->pWhalParams, pJoinBssParams->bssType);
+    whal_ParamsSetBssId(pWhalCtrl->pWhalParams, (char *)pJoinBssParams->pBSSID);
+    whal_ParamsSetSsid(pWhalCtrl->pWhalParams, (char *)pJoinBssParams->pSSID, pJoinBssParams->ssidLength);
+    whal_ParamsSetBeaconInterval(pWhalCtrl->pWhalParams, (UINT16)pJoinBssParams->beaconInterval);
+    whal_ParamsSetDtimCount(pWhalCtrl->pWhalParams, (UINT8)pJoinBssParams->dtimInterval);
+    whal_ParamsSetRadioChannel(pWhalCtrl->pWhalParams, pJoinBssParams->channel);
+    whal_ParamsSetRadioBand(pWhalCtrl->pWhalParams, pJoinBssParams->radioBand);
+    whal_ParamsSetBasicRatesSet(pWhalCtrl->pWhalParams, pJoinBssParams->basicRateSet);
+    whal_ParamsSetSupportedRatesSet(pWhalCtrl->pWhalParams, pJoinBssParams->supportedRateSet);
+    
+    /*
+     *  Save the frame rates in whalParams and configure it to the Fw later. That command was previously included
+     *  in the join command and it is now separated. 
+     */
+    /* Set the Ctrl frames rate and modulation */
+    whal_ParamsSetHwGenTxParams(pWhalCtrl->pWhalParams, pJoinBssParams->hwGenCtrlTxRate, TRUE);
+    /* Set the Management frame rate and modulation */
+    whal_ParamsSetHwGenTxParams(pWhalCtrl->pWhalParams, pJoinBssParams->hwGenMgmtTxRate, FALSE);
+     
+
+    /* In case we're joining a new BSS, reset the TKIP/AES sequence counter. */
+    /* The firmware resets its own counter - so we won't have mismatch in the following TX complete events */
+    pWhalCtrl->pHwCtrl->SecuritySeqNumLow = 0;
+    pWhalCtrl->pHwCtrl->SecuritySeqNumHigh = 0;
+
+    pWlanParams->bJoin = TRUE;
+    /*
+     * call the hardware to start/join the bss
+     */
+    return whal_hwCtrl_StartJoin(pWhalCtrl->pHwCtrl, pJoinBssParams->bssType, NULL, NULL);
+    
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ReJoinBss
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_ReJoinBss (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return whal_hwCtrl_ReJoinBss ((TI_HANDLE)pWhalCtrl->pHwCtrl);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Stop
+ *
+ * Input    : None
+ * Output   :
+ * Process  : Send command to the ACX to instruct it to enter a low-power sleep
+ *            state
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_Stop (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    whal_hwCtrl_Stop (pWhalCtrl->pHwCtrl);
+    
+    return (OK);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetTemplate
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetTemplate (TI_HANDLE hWhalCtrl, whalCtrl_setTemplate_t* pTemplateParams)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    HwMboxCmd_T *pHwCmd = whal_hwCtrl_GetMboxCmd(pWhalCtrl->pHwCtrl);
+    TemplateListParams_T *pWhalTemplates = &pWhalCtrl->pWhalParams->TemplateList;
+    int Stt;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("Template Type=%x :: size=%d\n", pTemplateParams->templateType , pTemplateParams->templateLen));
+
+    switch(pTemplateParams->templateType)
+    {
+        case BEACON_TEMPLATE:
+            pWhalTemplates->Beacon.Size = pTemplateParams->templateLen;
+            os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->Beacon.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+            Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,
+                                                        CMD_BEACON,NULL,NULL);
+            break;
+        case PROBE_RESPONSE_TEMPLATE:
+            pWhalTemplates->ProbeResp.Size = pTemplateParams->templateLen;
+            os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->ProbeResp.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+            Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,
+                                                        CMD_PROBE_RESP,NULL,NULL);
+            break;
+        case PROBE_REQUEST_TEMPLATE:
+            pWhalTemplates->ProbeReq.Size = pTemplateParams->templateLen;
+            os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->ProbeReq.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+            Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,
+                                                        CMD_PROBE_REQ,NULL,NULL);
+            break;
+        case NULL_DATA_TEMPLATE:
+            pWhalTemplates->NullData.Size = pTemplateParams->templateLen;
+            os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->NullData.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+            Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,
+                                                        CMD_NULL_DATA,NULL,NULL);
+            break;
+        case PS_POLL_TEMPLATE:
+            pWhalTemplates->PsPoll.Size = pTemplateParams->templateLen;
+            os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->PsPoll.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+            Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,
+                                                        CMD_PS_POLL,NULL,NULL);
+            break;
+        case QOS_NULL_DATA_TEMPLATE:
+            pWhalTemplates->QosNullData.Size = pTemplateParams->templateLen;
+            os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->QosNullData.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+            Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,
+                                                        CMD_QOS_NULL_DATA,NULL,NULL);
+            break;
+        default:
+            Stt = NOK;
+            break;
+    }
+
+    return (Stt);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetTemplateWithCB
+ *
+ * Input    :   Same as whalCtrl_SetTemplate but with CB
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetTemplateWithCB (TI_HANDLE hWhalCtrl, whalCtrl_setTemplate_t* pTemplateParams,void *CBFunc,TI_HANDLE CBObj)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    HwMboxCmd_T *pHwCmd = whal_hwCtrl_GetMboxCmd(pWhalCtrl->pHwCtrl);
+    TemplateListParams_T *pWhalTemplates = &pWhalCtrl->pWhalParams->TemplateList;
+    int Stt;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("%s Template Type=%x :: size=%d\n",__FUNCTION__,pTemplateParams->templateType , pTemplateParams->templateLen));
+
+    switch(pTemplateParams->templateType)
+    {
+
+    case PROBE_REQUEST_TEMPLATE:
+        pWhalTemplates->ProbeReq.Size = pTemplateParams->templateLen;
+        os_memoryCopy(pWhalCtrl->hOs, (void *)&pWhalTemplates->ProbeReq.Buffer, (void *)pTemplateParams->pTemplate, pTemplateParams->templateLen);
+        Stt = whal_hwMboxCmd_ConfigureTemplateFrame(pHwCmd, pTemplateParams->pTemplate, (UINT16)pTemplateParams->templateLen,CMD_PROBE_REQ,CBFunc,CBObj);
+        break;
+    default:
+            WLAN_REPORT_ERROR (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("%s not implemented yet !!!\n",__FUNCTION__,pTemplateParams->templateType , pTemplateParams->templateLen));
+            Stt = NOK;
+            break;
+    }
+
+    return (Stt);
+}
+/*
+ * ----------------------------------------------------------------------------
+ Function : whalCtrl_GetTemplate
+ *
+ * Input    :  pWhalCtrl - handle to whal ctrl object
+ *             templateType - type of template to retrieve
+ * Output   :  The template buffer that is saved in the Hal
+ * Process  :  If the template type is legal the template buffer and length are
+ *             returned. Otherwise NULL is returned
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TemplateParams_T * whalCtrl_GetTemplate(TI_HANDLE hWhalCtrl, whalCtrl_templateType_e templateType)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    TemplateParams_T * returnTemplate;
+    
+    switch(templateType)
+    {
+    case BEACON_TEMPLATE:
+        returnTemplate = &pWhalCtrl->pWhalParams->TemplateList.Beacon;
+        break;
+    case PROBE_RESPONSE_TEMPLATE:
+        returnTemplate = &pWhalCtrl->pWhalParams->TemplateList.ProbeResp;
+        break;
+    case PROBE_REQUEST_TEMPLATE:
+        returnTemplate = &pWhalCtrl->pWhalParams->TemplateList.ProbeReq;
+        break;
+    case NULL_DATA_TEMPLATE:
+        returnTemplate = &pWhalCtrl->pWhalParams->TemplateList.NullData;
+        break;
+    default:
+        returnTemplate = NULL;
+        break;
+    }
+
+    return (returnTemplate);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Destroy
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_Destroy (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    DmaParams_T  *pDmaParams=NULL;
+
+    if (pWhalCtrl == NULL)
+        return OK;
+
+    if (pWhalCtrl->pWhalParams != NULL)
+    {
+    pDmaParams = whal_ParamsGetDmaParams(pWhalCtrl->pWhalParams);
+    }
+
+    if( (pDmaParams != NULL) && (pWhalCtrl->pWhalSecurity != NULL) )
+    {
+    if (whalSecur_Destroy (pWhalCtrl->pWhalSecurity, pDmaParams->NumStations) != OK)
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl_Destroy: whalSecur_Destroy failure \n"));
+    }
+    
+    if (pWhalCtrl->pHwCtrl != NULL)
+    {
+    if (whal_hwCtrl_Destroy (pWhalCtrl->pHwCtrl) != OK)
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,  (" whalCtrl_Destroy: whal_hwCtrl_Destroy failure \n"));
+    }
+
+    if (pWhalCtrl->pWhalParams != NULL)
+    {
+    whal_params_Destroy(pWhalCtrl->pWhalParams);
+    }
+    
+    /* free the whalCtrl data structure*/
+    os_memoryFree (pWhalCtrl->hOs, pWhalCtrl, sizeof(WHAL_CTRL));
+    
+    return (OK);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetWhalParamsHandle()
+ ****************************************************************************
+ * DESCRIPTION: Return the handle of the whal params object.
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: handle of the WhalParams object
+ ****************************************************************************/
+WhalParams_T *whalCtrl_GetWhalParamsHandle(WHAL_CTRL *pWhalCtrl)
+{
+    return pWhalCtrl->pWhalParams;
+}
+
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : Handle DMA Done interrupt 
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_HandleBusTxn_Complete(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    /*
+    At this point the interrupts are masked!
+    it register at this position and remove its request after the interrupts are enabled again.
+    */
+    whalBus_TNETWIF_HandleBusTxn_Complete(pWhalCtrl->hWhalBus);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : Enable/Disable/Check/Handle interrupts - call HwCtrl object
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_HandleInterrupts (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    /*
+    At this point the interrupts are masked!
+    it register at this position and remove its request after the interrupts are enabled again.
+    */
+    return FwEvent(pWhalCtrl->hFwEvent);
+}
+
+void whalCtrl_EnableInterrupts (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    FwEvent_EnableInterrupts(pWhalCtrl->hFwEvent);
+}
+
+void whalCtrl_DisableInterrupts (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    FwEvent_DisableInterrupts(pWhalCtrl->hFwEvent);
+}
+
+UINT32  whalCtrl_CheckInterrupts  (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return FwEvent_CheckInterrupts(pWhalCtrl->hFwEvent);
+}
+
+
+void  whalCtr_SlaveAckMaskNotification (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    FwEvent_StateChanged(pWhalCtrl->hFwEvent);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_isCardIn
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+BOOL whalCtrl_isCardIn (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return whalBus_FwCtrl_isCardIn(pWhalCtrl->pHwCtrl->hWhalBus);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_setSend4xWackInfo
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_setSend4xWackInfo(TI_HANDLE hWhalCtrl, UINT8 Send4xWackInfo)
+{
+    /* not implemented */
+    return NOK;
+}
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_getSend4xWackInfo
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_getSend4xWackInfo(TI_HANDLE hWhalCtrl, UINT8 *Send4xWackInfo)
+{
+    /* not implemented */
+    return NOK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetSlotTime
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetSlotTime (TI_HANDLE hWhalCtrl, slotTime_e SlotTimeVal)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    pWhalCtrl->pWhalParams->WlanParams.SlotTime = SlotTimeVal;      
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG, ("whalCtrl_SetSlotTime : Slot time = %d\n",
+              SlotTimeVal));
+
+    /* Configure the new Slot-Time value to the FW. */
+    return whal_hwCtrl_SetSlotTime(pWhalCtrl->pHwCtrl, SlotTimeVal);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetPreamble
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetPreamble (TI_HANDLE hWhalCtrl, preamble_e preambleVal)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    pWhalCtrl->pWhalParams->WlanParams.preamble= preambleVal;      
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG, ("whalCtrl_SetPreamble : preamble = %d\n",
+              preambleVal));
+
+    return whal_hwCtrl_SetPreamble(pWhalCtrl->pHwCtrl, preambleVal);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetFrameRate
+ *
+ * Input    : bCtrlFrame - Whether to set new Ctrl rate+modulation or new Mgmt rate+modulation 
+ * Output   :
+ * Process  :
+ * Note(s)  : Modulation is determined using the rate and the previously configured preamble
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetFrameRate (TI_HANDLE hWhalCtrl,
+                            rate_e   txFrmRate,
+                            BOOL     bCtrlFrame)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    whal_ParamsSetHwGenTxParams (pWhalCtrl->pWhalParams, txFrmRate, bCtrlFrame);            
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG, 
+                ("whalCtrl_SetFrameRate : txCtrlFrmRate = %d , txCtrlFrmModulation = %d , txMgmtFrmRate = %d , txMgmtFrmModulation = %d\n",
+                pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmRate,pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmModulation, 
+                pWhalCtrl->pWhalParams->BssInfoParams.txMgmtFrmRate,pWhalCtrl->pWhalParams->BssInfoParams.txMgmtFrmModulation));
+
+    return whal_hwCtrl_SetFrameRate(pWhalCtrl->pHwCtrl,
+                                    pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmRate,
+                                    pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmModulation,
+                                    pWhalCtrl->pWhalParams->BssInfoParams.txMgmtFrmRate,
+                                    pWhalCtrl->pWhalParams->BssInfoParams.txMgmtFrmModulation);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetCwMin
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetCwMin (TI_HANDLE hWhalCtrl, UINT8 CwMin)
+{
+  WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    pWhalCtrl->pWhalParams->WlanParams.CwMin = CwMin;
+    return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetPacketDetectionThreshold
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetPacketDetectionThreshold (TI_HANDLE hWhalCtrl, UINT8 PDThreshold)
+{
+  WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+  
+  pWhalCtrl->pWhalParams->WlanParams.PacketDetectionThreshold = PDThreshold;
+    return whal_hwCtrl_PacketDetectionThreshold(pWhalCtrl->pHwCtrl, &PDThreshold);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetEnergyDetection
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetEnergyDetection (TI_HANDLE hWhalCtrl, BOOL energyDetection)
+{
+  WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return whal_hwCtrl_SetEnergyDetection(pWhalCtrl->pHwCtrl, energyDetection);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SwitchChannel
+ *
+ * Input    : channel - newChannelNumber
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SwitchChannel(TI_HANDLE hWhalCtrl , UINT8 channel)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return whal_hwCtrl_switchChannel(pWhalCtrl->pHwCtrl, channel);
+    
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_DisableTx
+ *
+ * Input    : None
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_DisableTx(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return whal_hwCtrl_DisableTx(pWhalCtrl->pHwCtrl);
+    
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_EnableTx
+ *
+ * Input    : None
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_EnableTx(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+        
+    return whal_hwCtrl_EnableTx(pWhalCtrl->pHwCtrl, whal_ParamsGetRadioChannel(pWhalCtrl->pWhalParams));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetTime
+ *
+ * Input    : None
+ * Output   :
+ * Process  :
+ * Note(s)  : Get Mac time from the Event Mbox (For Tx expiry Time)
+ * -----------------------------------------------------------------------------
+ */
+UINT32  whalCtrl_GetTime(TI_HANDLE hWhalCtrl)
+{
+    return 0;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_setDtimPeriod
+ *
+ * Input    : dtimPeriod - new Dtim Period
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_setDtimPeriod(TI_HANDLE hWhalCtrl, UINT8 dtimPeriod, UINT16 TBTT)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    UINT8 localDtimPeriod = (UINT8)dtimPeriod;
+    UINT16 localTBTT = (UINT16)TBTT;
+
+    whal_ParamsSetDtimCount(pWhalCtrl->pWhalParams, (UINT8)dtimPeriod);
+    whal_hwInfoElemDtimPeriodSet (pWhalCtrl->pHwCtrl->pHwMboxConfig, &localDtimPeriod, &localTBTT);
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_setDtimPeriod: DITIM=%d TBTT=%d\n",localDtimPeriod,localTBTT));
+
+    return OK;  
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetDtimCount
+ *
+ * Input    :
+ * Output   : UINT8
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+UINT8 whalCtrl_GetDtimCount(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    return whal_ParamsGetDtimCount(pWhalCtrl->pWhalParams);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_InterrogateMbox
+ *
+ * Input    :
+ * Output   : UINT8
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_InterrogateMbox(TI_HANDLE hWhalCtrl , void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf)
+{
+   WHAL_CTRL           *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+     
+   whal_hwInfoElemStationIdForRecoveryGet (pWhalCtrl->pHwCtrl->pHwMboxConfig, CB_Func, CB_handle, CB_Buf);
+   
+   return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_InterrogateGwsiStatisitics
+ *
+ * Input    : Retrieve Statistics
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_InterrogateGwsiStatisitics(TI_HANDLE hWhalCtrl, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf)
+{
+   WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+     
+   whal_hwInfoElemAcxReadGwsiStatisiticsGet (pWhalCtrl->pHwCtrl->pHwMboxConfig, CB_Func, CB_handle, CB_Buf);
+
+   return OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_InterrogateGwsiCounters
+ *
+ * Input    : Retrieve Counters
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_InterrogateGwsiCounters(TI_HANDLE hWhalCtrl, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf)
+{
+   WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+     
+   whal_hwInfoElemAcxReadGwsiCountersGet (pWhalCtrl->pHwCtrl->pHwMboxConfig, CB_Func, CB_handle, CB_Buf);
+
+   return OK;
+}
+
+    
+/* ----------------------------------------------------------------------------
+ * Function : whalCtrl_getTsf
+ *
+ * Input    : hwHalCtrl handle, pTsf container for the FW mac timer
+ * Output   :
+ * Process  :
+ * Note(s)  : The time will be in usec
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_getTsf(TI_HANDLE hwHalCtrl, UINT32 *pTsf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hwHalCtrl;
+
+    if (pTsf == NULL){
+            WLAN_REPORT_FATAL_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                ("whalCtrl_getTsf: got pTsf paramerter as NULL\n"));
+
+        return NOK;
+    }
+
+    return(whal_hwCtrl_getTsf(pWhalCtrl->pHwCtrl, pTsf));
+}
+
+
+int whalCtrl_SendGenCmd (TI_HANDLE hWhalCtrl, char* pBuf, UINT32 Length)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;  
+    short CmdId;
+    
+    if ((Length < CMD_DISABLE_RX) || (pBuf == NULL)){
+        WLAN_REPORT_REPLY(pWhalCtrl->hReport, HAL_HW_DATA_MODULE_LOG,
+        ("whalCtrl_SendGenCmd: Parameter error\n"));
+
+        return NOK;
+    }
+
+    os_memoryCopy(pWhalCtrl, (void *)&CmdId, (void *)pBuf, sizeof(CmdId));
+    return (whal_hwCtrl_GenCmd(pWhalCtrl->pHwCtrl, CmdId, pBuf+SIZE_OF_HEADER, (Length - SIZE_OF_HEADER)));
+}
+
+
+int whalCtrl_IsCardInstalled(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    return whalBus_FwCtrl_isCardIn(pWhalCtrl->pHwCtrl->hWhalBus);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetBeaconInterval
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_SetBeaconInterval(TI_HANDLE hWhalCtrl , UINT16 Val)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    whal_ParamsSetBeaconInterval(pWhalCtrl->pWhalParams ,Val);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetBeaconInterval
+ *
+ * Input    :
+ * Output   : UINT16
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+UINT16 whalCtrl_GetBeaconInterval(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    return whal_ParamsGetBeaconInterval(pWhalCtrl->pWhalParams);
+}
+
+
+/****************************************************************************
+ *                      whalCtrl_exitFromInitMode()
+ ****************************************************************************
+ * DESCRIPTION: change the interrupt module to work in operational mode
+ *              and the Queue to work in Async Mode
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK.
+ ****************************************************************************/
+void whalCtrl_exitFromInitMode(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    /* Notify Event MailBox about init complete */
+    eventMbox_InitComplete (pWhalCtrl->hEventMbox);
+
+    /*
+    this call must be the last cmd send to the FW because upon its completion the os_complete will be called 
+    */
+    
+    whal_hwInfoElemStationIdGet (pWhalCtrl->pHwCtrl->pHwMboxConfig,
+                                     (void*)((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->fConfigureEndCB,
+                                     ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->fConfigureEndObj,
+                                     &pWhalCtrl->pHwCtrl->mbox);
+
+    /* 
+     * In case of full asynchronous mode the code below is executed earlier -
+     * upon starting configuring the firmware via command mailbox
+     */
+
+  #if defined(USE_SYNC_API)
+
+    whalBus_ExitFromInitMode (pWhalCtrl->hWhalBus); 
+    os_enableIrq (pWhalCtrl->hOs);
+
+  #endif
+}
+
+/****************************************************************************
+ *                      whalCtrl_exitFromInitModePart1()
+ ****************************************************************************
+ * DESCRIPTION: Notify Event MailBox about init complete 
+ *              
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK.
+ ****************************************************************************/
+void whalCtrl_exitFromInitModePart1(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    /* Notify Event MailBox about init complete */
+    eventMbox_InitComplete (pWhalCtrl->hEventMbox);
+
+}
+
+/****************************************************************************
+ *                      whalCtrl_exitFromInitModePart2()
+ ****************************************************************************
+ * DESCRIPTION: change the interrupt module to work in operational mode
+ *              and the Queue to work in Async Mode
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK.
+ ****************************************************************************/
+void whalCtrl_exitFromInitModePart2(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+
+    /*
+    this call must be the last cmd send to the FW because upon its completion the os_complete will be called 
+    */
+    
+    whal_hwInfoElemStationIdGet (pWhalCtrl->pHwCtrl->pHwMboxConfig,
+                                     (void*)((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->fConfigureEndCB,
+                                     ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->fConfigureEndObj,
+                                     &pWhalCtrl->pHwCtrl->mbox);
+
+    /* 
+     * In case of full asynchronous mode the code below is executed earlier -
+     * upon starting configuring the firmware via command mailbox
+     */
+
+  #if defined(USE_SYNC_API)
+
+    whalBus_ExitFromInitMode (pWhalCtrl->hWhalBus); 
+    os_enableIrq (pWhalCtrl->hOs);
+
+  #endif
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_NoiseHistogramCmd
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_NoiseHistogramCmd(TI_HANDLE hWhalCtrl, whalCtrl_noiseHistogram_t* pNoiseHistParams)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;  
+
+    /* Send the Noise Histogram command*/
+    return (whal_hwCtrl_NoiseHistogramCmd(pWhalCtrl->pHwCtrl, pNoiseHistParams));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_powerMgmtOptionsConfig
+ *
+ * Input    : 1) TI_HANDLE - handle to the WhalCtrl object.
+ *
+ * Output   :  TI_STATUS - OK on success else NOK.
+ *
+ * Process  : configuration of the power managment options mailbox command.
+ *
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_powerMgmtConfig(TI_HANDLE theWhalCtrlHandle,
+                                    whalCtrl_powerSaveParams_t* powerSaveParams)                                            
+ /*whalCtrl_powerMgmtConfig_t thePowerMgmtConfig)*/
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)theWhalCtrlHandle;
+    
+
+    
+    int powerMgmtConfStatus;
+
+    /*
+    breaking the debug information into 2 section due to the fact that this message is
+    too long and exceed message buffer limitation.
+    */
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,
+                            HAL_CTRL_MODULE_LOG,
+                            ("whalCtrlPowerSaveParams -:\n\
+                             ps802_11Enable = 0x%X\n\
+                             hangOverPeriod = 0x%X\n\
+                 needToSendNullData = 0x%X\n\
+                 numNullPktRetries = 0x%X\n\
+                             NullPktRateModulation = 0x%X\n",
+                             powerSaveParams->ps802_11Enable,
+                             powerSaveParams->hangOverPeriod,
+                 powerSaveParams->needToSendNullData,
+                 powerSaveParams->numNullPktRetries,
+                             powerSaveParams->NullPktRateModulation));
+
+
+    /*
+    PowerMgmtOptions IE
+    */
+
+    powerMgmtConfStatus = whal_hwCtrl_PowerMgmtConfigurationSet (pWhalCtrl->pHwCtrl,
+                                                                powerSaveParams);
+
+    return (TI_STATUS)powerMgmtConfStatus;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetBeaconFiltering
+ *
+ * Input    : UINT8, UINT8
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetBeaconFiltering(TI_HANDLE hWhalCtrl, UINT8 beaconFilteringStatus, UINT8 numOfBeaconsToBuffer)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+
+    pWhalCtrl->pWhalParams->WlanParams.beaconFilterParams.desiredState = beaconFilteringStatus;
+    pWhalCtrl->pWhalParams->WlanParams.beaconFilterParams.numOfElements = numOfBeaconsToBuffer;
+
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,
+                            HAL_CTRL_MODULE_LOG,
+                            ("whalCtrl_SetBeaconFiltering  :\n\
+                              beaconFilteringStatus = %s \n\
+                              numberOfBeaconsToBuffer = %d\n",
+                              (beaconFilteringStatus == FALSE) ? "BUFFERING" : "FILTERING",
+                              numOfBeaconsToBuffer));
+    
+    return whal_hwCtrl_SetBeaconFiltering(pWhalCtrl->pHwCtrl, beaconFilteringStatus, numOfBeaconsToBuffer);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetBeaconFiltering
+ *
+ * Input    : UINT8, UINT8
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_GetBeaconFiltering(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    if ( NULL == pWhalCtrl )
+    {
+        WLAN_OS_REPORT(("whalCtrl_GetBeaconFiltering-hWhalCtrl = NULL !"));
+        return NOK ;
+    }
+    else
+    {
+        if ( NULL == pWhalCtrl->pWhalParams )
+        {
+            WLAN_REPORT_ERROR(pWhalCtrl->hReport , HAL_CTRL_MODULE_LOG , ("whalCtrl_GetBeaconFiltering : pWhalParams = NULL !!!")) ;
+            return NOK ;
+        }
+        return (OK);
+    }
+    
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetBeaconFilterIETable
+ *
+ * Input    : Number of IE in table, Table, Table szie
+ * Output   :
+ * Process  : transfer paramaters to the HAL, check for size limit
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetBeaconFilterIETable(TI_HANDLE hWhalCtrl, UINT8 *numberOfIEs, UINT8 * IETable, UINT8 *IETableSize)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    
+    if (*IETableSize > BEACON_FILTER_TABLE_MAX_SIZE)
+    {
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport,
+                          HAL_CTRL_MODULE_LOG,
+                          ("whalCtrl_SetBeaconFilterIETable : Table size is too big %d (>%d)\n",
+            *IETableSize, BEACON_FILTER_TABLE_MAX_SIZE));    
+        return PARAM_VALUE_NOT_VALID;
+    }
+    
+    os_memoryZero (pWhalCtrl->hOs, (void *)pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETable, BEACON_FILTER_TABLE_MAX_SIZE);
+    os_memoryCopy(pWhalCtrl->hOs, (void *)pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETable, (void *)IETable, *IETableSize);
+    pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.numberOfIEs  = *numberOfIEs;
+    pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETableSize  = *IETableSize;
+
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,
+                            HAL_CTRL_MODULE_LOG,
+                            ("whalCtrl_SetBeaconFilterIETable : \n\
+                              Number of IE = %d \n\
+                              IETable = 0x%p \n\
+                              IETableSize = %d\n",
+                              *numberOfIEs, IETable, *IETableSize));     
+    
+    return whal_hwCtrl_SetBeaconFilterIETable(pWhalCtrl->pHwCtrl, numberOfIEs, IETable, IETableSize ) ;
+}
+  
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_wakeUpCondition
+ *
+ * Input    : 1) TI_HANDLE - handle to the WhalCtrl object.
+ *
+ * Output   :  TI_STATUS - OK on success else NOK.
+ *
+ * Process  : configuration of the power managment options mailbox command.
+ *
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_wakeUpCondition(TI_HANDLE theWhalCtrlHandle,
+                                   whalCtrl_powerMgmtConfig_t thePowerMgmtConfig)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)theWhalCtrlHandle;
+    whalCtrl_powerMgmtConfig_t *pPowerMgmtOptionsConfig = &thePowerMgmtConfig;
+    int status;
+
+    /*
+    breaking the debug information into 2 section due to the fact that this message is
+    too long and exceed message buffer limitation.
+    */
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,
+                            HAL_CTRL_MODULE_LOG,
+                            ("whalCtrl_wakeUpCondition :\n\
+                             listenInterval = 0x%X\n",
+                             pPowerMgmtOptionsConfig->listenInterval));
+                             
+    status = whal_hwCtrl_wakeUpCondition (pWhalCtrl->pHwCtrl,
+                                         pPowerMgmtOptionsConfig);
+
+    return (TI_STATUS)status;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_PMConfig
+ *
+ * Input    : 1) TI_HANDLE - handle to the WhalCtrl object.
+ *
+ * Output   :  TI_STATUS - OK on success else NOK.
+ *
+ * Process  : configuration of the power managment options mailbox command.
+ *
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_PMConfig(TI_HANDLE theWhalCtrlHandle,
+                            whalCtrl_powerMgmtConfig_t thePowerMgmtConfig)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)theWhalCtrlHandle;
+    whalCtrl_powerMgmtConfig_t *pPowerMgmtOptionsConfig = &thePowerMgmtConfig;
+    TI_STATUS  status;
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,
+                            HAL_CTRL_MODULE_LOG,
+                            ("whalCtrl_PMConfig :\n\
+                             ELPEnable = 0x%X\n\
+                             BBWakeUpTime = 0x%X\n\
+                             PLLlockTime = 0x%X\n",
+                             pPowerMgmtOptionsConfig->ELPEnable,
+                             pPowerMgmtOptionsConfig->BBWakeUpTime,
+                             pPowerMgmtOptionsConfig->PLLlockTime));
+
+    status = (TI_STATUS)whal_hwCtrl_PMConfig (pWhalCtrl->pHwCtrl, pPowerMgmtOptionsConfig);
+    return status;
+}
+    
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_BcnBrcOptions
+ *
+ * Input    : 1) TI_HANDLE - handle to the WhalCtrl object.
+ *
+ * Output   :  TI_STATUS - OK on success else NOK.
+ *
+ * Process  : configuration of the power managment options mailbox command.
+ *
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_BcnBrcOptions(TI_HANDLE theWhalCtrlHandle,
+                            whalCtrl_powerMgmtConfig_t thePowerMgmtConfig)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)theWhalCtrlHandle;
+    whalCtrl_powerMgmtConfig_t *pPowerMgmtBcnBrcOptions = &thePowerMgmtConfig;
+    TI_STATUS  status;
+
+    /* Just take the last configured parameter of ConsecutivePsPollDeliveryFailureThreshold */
+    pPowerMgmtBcnBrcOptions->ConsecutivePsPollDeliveryFailureThreshold = 
+        (whal_ParamsGetWlanParams (pWhalCtrl->pWhalParams))->ConsecutivePsPollDeliveryFailureThreshold;
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,
+                            HAL_CTRL_MODULE_LOG,
+                            ("whalCtrl_BcnBrcOptions :\n\
+                             BeaconRxTimeout = 0x%X\n\
+                             BroadcastRxTimeout = 0x%X\n\
+                             RxBroadcastInPs = 0x%X\n",
+                             pPowerMgmtBcnBrcOptions->BcnBrcOptions.BeaconRxTimeout,
+                             pPowerMgmtBcnBrcOptions->BcnBrcOptions.BroadcastRxTimeout,
+                             pPowerMgmtBcnBrcOptions->BcnBrcOptions.RxBroadcastInPs));
+
+    status = (TI_STATUS)whal_hwCtrl_BcnBrcOptions (pWhalCtrl->pHwCtrl, pPowerMgmtBcnBrcOptions);
+    return status;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_RegisterCmdCompleteGenericCB
+ *
+ * Input    : 1) hWhalCtrl - this
+ *            2) CbFunc    - The Callback   
+ *            
+ *
+ * Note(s)  :  None
+ * -----------------------------------------------------------------------------
+ */
+int  whalCtrl_RegisterCmdCompleteGenericCB(TI_HANDLE hWhalCtrl, void *CbFunc, void *CbObj)
+{
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return CmdQueue_RegisterCmdCompleteGenericCB(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue,CbFunc,CbObj);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_EventMbox_RegisterForEvent
+ *
+ * Input    : 1) hWhalCtrl - this
+ *            2) EventBit  - The Event id 
+ *            3) CbFunc    - The Callback
+ *            4) CbObj     - The Callback Handle
+ *
+ * Note(s)  :  None
+ * -----------------------------------------------------------------------------
+ */
+int  whalCtrl_EventMbox_RegisterForEvent(TI_HANDLE hWhalCtrl, int EventBit, void *CbFunc, void *CbObj)
+{
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return eventMbox_RegisterEventCB(pWhalCtrl->hEventMbox, 
+                                             EventBit, CbFunc, CbObj);
+}
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_EventMbox_Disable
+ *
+ * Input    : 1) hWhalCtrl - this
+ *            2) EventBit  - The Event id 
+ *
+ * Note(s)  :  None
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_EventMbox_Disable(TI_HANDLE hWhalCtrl, int EventBit)
+{
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    return eventMbox_EvMask(pWhalCtrl->hEventMbox, EventBit);
+}
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_EventMbox_Enable
+ *
+ * Input    : 1) hWhalCtrl - this
+ *            2) EventBit  - The Event id 
+ *
+ * Note(s)  :  None
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_EventMbox_Enable(TI_HANDLE hWhalCtrl, int EventBit)
+{
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl; 
+
+    return eventMbox_EvUnMask(pWhalCtrl->hEventMbox, EventBit);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetRadioStandByState
+ *
+ * Input    : 
+ *
+ * Note(s)  :  None
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_GetRadioStandByState(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl; 
+
+    return whalBus_FwCtrl_GetRadioStandByState(pWhalCtrl->pHwCtrl->hWhalBus);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetFWInfo
+ *
+ * Input    :
+ * Output   :  FWInfo
+ * Process  :  Retrieves the FWInfo
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS  whalCtrl_GetFWInfo   (TI_HANDLE hWhalCtrl, whalCtrl_chip_t *pChip_Version)
+{
+    int i;
+    char *StaId;
+
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+
+    /*
+     * return parameters from the wlan hardware
+     */
+    StaId = (char *)(whal_ParamsGetSrcMac(pWhalCtrl->pWhalParams));
+    for (i=0; i<6; i++)
+    {
+        pChip_Version->macAddress.addr[i] = StaId[i];
+    }
+    pChip_Version->preamble = (preamble_e)pWlanParams->preamble;
+
+
+    /* update the EEPROM version*/
+    pChip_Version->e2Ver.major = pWlanParams->majorE2Ver;
+    pChip_Version->e2Ver.minor = pWlanParams->minorE2Ver;
+    
+    /*
+     * get radio number and type
+     */
+    {
+        UINT32 RadioType;
+        UINT32 RadioNumber;
+        
+        whalCtrl_getRadioNumber(hWhalCtrl, &RadioType, &RadioNumber);
+        
+        pChip_Version->radioType = (radioType_e)RadioType;
+        pChip_Version->e2Ver.last = RadioNumber;
+    }
+    
+    /* update the firmware version*/
+    os_memoryCopy(pWhalCtrl->hOs, (void *)pChip_Version->fwVer,
+                  (void *)(whal_ParamsGetFwVersion(pWhalCtrl->pWhalParams)), FW_VERSION_LEN);
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("FW version is %s\n", pChip_Version->fwVer));
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("E2 Major version is %d\n", pChip_Version->e2Ver.major));
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("E2 Minor version is %d\n", pChip_Version->e2Ver.minor));
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("E2 Last version is %d\n", pChip_Version->e2Ver.last));
+
+    return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SwitchChannelCmd
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SwitchChannelCmd (TI_HANDLE hWhalCtrl, whalCtrl_switchChannelCmd_t* pSwitchChannelCmd)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n SwitchChannelCmd :\n \
+                              channelNumber = %d\n \
+                              switchTime = %d\n \
+                              txFlag = %d\n \
+                              flush = %d \n ",
+                             pSwitchChannelCmd->channelNumber,
+                             pSwitchChannelCmd->switchTime,
+                             pSwitchChannelCmd->txFlag,
+                             pSwitchChannelCmd->flush));
+
+    /*
+     * save Bss info parameters
+     */
+    pWhalCtrl->pWhalParams->BssInfoParams.RadioChannel = pSwitchChannelCmd->channelNumber;
+
+    /*
+     * call the hardware to start/join the bss
+     */
+    return whal_hwCtrl_SwitchChannelCmd(pWhalCtrl->pHwCtrl, pSwitchChannelCmd);
+
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SwitchChannelCancelCmd
+ *
+ * Input    :
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SwitchChannelCancelCmd (TI_HANDLE hWhalCtrl, UINT8 channel)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n whalCtrl_SwitchChannelCancelCmd :\n "));
+
+    /*
+     * save Bss info parameters
+     */
+    pWhalCtrl->pWhalParams->BssInfoParams.RadioChannel = channel;
+    
+    /*
+     * call the hardware to start/join the bss
+     */
+    return whal_hwCtrl_SwitchChannelCancelCmd(pWhalCtrl->pHwCtrl);
+
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetRSSIParamsCmd
+ *
+ * Input    :   pointer to stuct "whalCtrl_roamingTriggerCmd_t", but only the 
+ *              following parameters are relevant;
+ *              RSSIthreshold
+ *              RSSIFilterWeight
+ *              RSSIFilterDepth
+ *
+ * Output   :
+ * Process  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetRSSIParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n SetRSSIParamsCmd :\n \
+                              RSSIthreshold = %d\n \
+                              RSSIFilterWeight = %d\n \
+                              RSSIFilterDepth = %d \n ",
+                              pRoamingTriggerCmd->rssiThreshold,
+                              pRoamingTriggerCmd->rssiFilterWeight,
+                              pRoamingTriggerCmd->rssiFilterDepth));
+
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.rssiThreshold = pRoamingTriggerCmd->rssiThreshold;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.rssiFilterWeight = pRoamingTriggerCmd->rssiFilterWeight;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.rssiFilterDepth = pRoamingTriggerCmd->rssiFilterDepth;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.lowRSSIEventType = pRoamingTriggerCmd->lowRSSIEventType;
+
+    return   whal_hwCtrl_SetRSSIParams( pWhalCtrl->pHwCtrl, pRoamingTriggerCmd);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetSNRParamsCmd
+ *
+ * Input    :   
+ *
+ * Output   :
+ * Process  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetSNRParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t *pRoamingTriggerCmd)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n whalCtrl_SetSNRParamsCmd :\n \
+                              SNRThreshold = %d\n \
+                              SNRFilterWeight = %d\n \
+                              SNRFilterDepth = %d \n \
+                              EdgeLevel = %d \n ",
+                              pRoamingTriggerCmd->snrThreshold,
+                              pRoamingTriggerCmd->snrFilterWeight,
+                              pRoamingTriggerCmd->snrFilterDepth,
+                              pRoamingTriggerCmd->lowSNREventType));
+
+
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.snrThreshold        =  pRoamingTriggerCmd->snrThreshold;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.snrFilterWeight         =  pRoamingTriggerCmd->snrFilterWeight;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.snrFilterDepth      =  pRoamingTriggerCmd->snrFilterDepth;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.lowSNREventType     =  pRoamingTriggerCmd->lowSNREventType;
+
+    return whal_hwCtrl_SetSNRParams(pWhalCtrl->pHwCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetMaxTxRetryParamsCmd
+ *
+ * Input    :   pointer to stuct "whalCtrl_roamingTriggerCmd_t", but only the 
+ *              following parameters are relevant;
+ *              maxTxRetry
+ *
+ * Output   :
+ * Process  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetMaxTxRetryParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n SetMaxTxRetryParamsCmdCmd :\n \
+                              maxTxRetry = %d \n ",
+                              pRoamingTriggerCmd->maxTxRetry));
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.maxTxRetry = pRoamingTriggerCmd->maxTxRetry;
+
+    return   whal_hwCtrl_SetMaxTxRetryParams(pWhalCtrl->pHwCtrl, pRoamingTriggerCmd);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetBssLossTsfThresholdParamsCmd
+ *
+ * Input    :   pointer to stuct "whalCtrl_roamingTriggerCmd_t", but only the 
+ *              following parameters are relevant;
+ *              BssLossTimeout
+ *              TsfMissThreshold
+ *
+ * Output   :
+ * Process  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetBssLossTsfThresholdParamsCmd (TI_HANDLE hWhalCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n whalCtrl_SetBssLossTsfThresholdParamsCmd :\n \
+                              BssLossTimeout = %d\n \
+                              TsfMissThreshold = %d \n ",
+                              pRoamingTriggerCmd->BssLossTimeout,
+                              pRoamingTriggerCmd->TsfMissThreshold));
+
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.BssLossTimeout = pRoamingTriggerCmd->BssLossTimeout;
+    pWhalCtrl->pWhalParams->WlanParams.roamTriggers.TsfMissThreshold = pRoamingTriggerCmd->TsfMissThreshold;
+
+    return   whal_hwCtrl_SetBssLossTsfThresholdParams(  pWhalCtrl->pHwCtrl, pRoamingTriggerCmd);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetAverageRSSI
+ *
+ * Input    :   averageRSSI - pointer for return verage RSSI result
+ *
+ * Output   :   averageRSSI
+ * Process  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_GetAverageRSSI (TI_HANDLE hWhalCtrl, INT8* averageRSSI)
+{
+#ifdef TI_DBG /* remove the #ifdef TI_DBG when implementing this function */
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n GetAverageRSSI :\n \
+                              averageRSSI = NOT IMPLEMENTED\n"));
+#endif /* TI_DBG */
+    return NOK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetAverageRSSI
+ *
+ * Input    :   averageRSSI - pointer for return verage RSSI result
+ *
+ * Output   :   averageRSSI
+ * Process  :
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_GetAsynRSSI (TI_HANDLE hWhalCtrl,void *CB_Func, TI_HANDLE CB_handle, PUINT8 CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    int status ;
+
+    status = whal_hwCtrl_GetAsynRSSI(pWhalCtrl->pHwCtrl,CB_Func,CB_handle,CB_Buf);
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                            ("\n whalCtrl_GetAsynRSSI AYNC!!!! :\n "));
+
+    return status;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_FwDisconnect
+ * Input    : None
+ * Output   :
+ * Process  :
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+
+int whalCtrl_FwDisconnect(TI_HANDLE hWhalCtrl, UINT32 ConfigOptions, UINT32 FilterOptions)
+{
+    WHAL_CTRL *pWhalCtrl        = (WHAL_CTRL *)hWhalCtrl;  
+    WlanParams_T *pWlanParams   = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
+
+    pWlanParams->bJoin = FALSE;
+
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("Sending FW disconnect, ConfigOptions=%x, FilterOPtions=%x\n",
+                              ConfigOptions, FilterOptions));
+
+    return whal_hwCtrl_FwDisconnect(pWhalCtrl->pHwCtrl, ConfigOptions, FilterOptions);
+    
+} /* whalCtrl_FwDisconnect()*/
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_resetTxCounters
+ * Input    : None
+ * Output   :
+ * Process  : Reset the HAL Tx statistics counters.
+ * Note(s)  : Done
+ * -----------------------------------------------------------------------------
+ */
+
+void whalCtrl_resetTxCounters(TI_HANDLE hWhalCtrl)
+{
+/*
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    whalBus_resetTxCounters(pWhalCtrl->hWhalBus);
+*/
+}
+
+
+/*---------------------------------------------------------
+  debug commands for testing the Roaming trigger functions
+-----------------------------------------------------------*/
+#ifdef ROAMING_TRIGGER_DBG
+int whalCtrl_dbgRoamingCommands (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    whalCtrl_roamingTriggerCmd_t roamingTriggerCmd;
+    whalCtrl_roamingTriggerCmd_t *pCmd ;
+    int stt1, stt4;
+    INT8 rssiVal ;
+
+    pCmd = &roamingTriggerCmd ;
+
+    pCmd->rssiFilterDepth   = 15;
+    pCmd->rssiFilterWeight  = 20;
+    pCmd->rssiThreshold     = -70;
+    pCmd->lowRSSIEventType  = 0;
+    stt1 = whalCtrl_SetRSSIParamsCmd (pWhalCtrl, pCmd);
+
+    pCmd->maxTxRetry        = 10;   
+    stt1 = whalCtrl_SetMaxTxRetryParamsCmd (pWhalCtrl, pCmd);
+
+    pCmd->BssLossTimeout    = 1;
+    pCmd->TsfMissThreshold  = 6;
+    stt1 = whalCtrl_SetBssLossTsfThresholdParamsCmd (pWhalCtrl, pCmd);
+
+    stt4 = whalCtrl_GetAverageRSSI(pWhalCtrl,&rssiVal);
+    
+    return (OK);
+}
+
+
+TI_STATUS whalCtrl_dbgRegisterRoamingEventCB(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    whalCtrl_EventMbox_RegisterForEvent(pWhalCtrl, 
+                                        HAL_EVENT_RSSI_LEVEL, 
+                                        (void *)whalCtrl_dbg_RSSI_LEVEL, 
+                                        pWhalCtrl);
+    whalCtrl_EventMbox_Enable(pWhalCtrl, HAL_EVENT_RSSI_LEVEL);
+
+    whalCtrl_EventMbox_RegisterForEvent(pWhalCtrl, 
+                                        HAL_EVENT_SYNCHRONIZATION_TIMEOUT, 
+                                        (void *)whalCtrl_dbg_SYNCHRONIZATION, 
+                                        pWhalCtrl);
+    whalCtrl_EventMbox_Enable(pWhalCtrl, HAL_EVENT_SYNCHRONIZATION_TIMEOUT);
+
+    whalCtrl_EventMbox_RegisterForEvent(pWhalCtrl, 
+                                        HAL_EVENT_BSS_LOSE, 
+                                        (void *)whalCtrl_dbg_BSS_LOSE, 
+                                        pWhalCtrl);
+    whalCtrl_EventMbox_Enable(pWhalCtrl, HAL_EVENT_BSS_LOSE);
+
+    whalCtrl_EventMbox_RegisterForEvent(pWhalCtrl, 
+                                        HAL_EVENT_MAX_TX_RETRY, 
+                                        (void *)whalCtrl_dbg_MAX_TX_RETRY, 
+                                        pWhalCtrl);
+    whalCtrl_EventMbox_Enable(pWhalCtrl, HAL_EVENT_MAX_TX_RETRY);
+
+    return (OK);
+}
+
+
+
+
+
+static void whalCtrl_dbg_RSSI_LEVEL(TI_HANDLE hWhalCtrl,char* str , UINT32 strLen)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    INT8       averageRssi ;
+
+    os_memoryCopy(pWhalCtrl->hOs, (void *)&averageRssi, (void *)str, strLen);
+
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, SITE_MGR_MODULE_LOG,
+                           ("got event: whalCtrl_dbg_RSSI_LEVEL, averageRssi=0x%x\n",averageRssi));
+
+}
+
+TI_STATUS whalCtrl_dbg_SYNCHRONIZATION(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, SITE_MGR_MODULE_LOG,
+                           ("got event: whalCtrl_dbg_SYNCHRONIZATION\n"));
+
+    return OK;
+}
+
+TI_STATUS whalCtrl_dbg_BSS_LOSE(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, SITE_MGR_MODULE_LOG,
+                           ("got event: whalCtrl_dbg_BSS_LOSE\n"));
+
+    return OK;
+}
+
+TI_STATUS whalCtrl_dbg_MAX_TX_RETRY(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, SITE_MGR_MODULE_LOG,
+                           ("got event: whalCtrl_dbg_MAX_TX_RETRY\n"));
+
+    return OK;
+}
+#endif
+/*---------------------------------------------------------
+  debug commands for testing the Roaming trigger functions
+-----------------------------------------------------------*/
+
+
+/****************************************************************************
+ *                      whalCtrl_measurementParams()
+ ****************************************************************************
+ * DESCRIPTION: send Command for measurement configuration 
+ *              to the mailbox
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_measurementCmd (TI_HANDLE hWhalCtrl, whalCtrl_MeasurementParameters_t *pMeasurementParams,
+                             void* CommandResponseCB, TI_HANDLE CB_handle)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return (whal_hwCtrl_measurement (pWhalCtrl->pHwCtrl, pMeasurementParams, CommandResponseCB, CB_handle));
+}
+
+/****************************************************************************
+ *                      whalCtrl_measurementStop()
+ ****************************************************************************
+ * DESCRIPTION: send Command for stoping measurement  
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_measurementStop (TI_HANDLE hWhalCtrl,void* CommandResponseCB, TI_HANDLE CB_handle)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return (whal_hwCtrl_measurementStop (pWhalCtrl->pHwCtrl, CommandResponseCB, CB_handle));
+}
+
+/****************************************************************************
+ *                      whalCtrl_ApDiscoveryCmd()
+ ****************************************************************************
+ * DESCRIPTION: send Command for AP Discovery 
+ *              to the mailbox
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_ApDiscoveryCmd (TI_HANDLE hWhalCtrl, whalCtrl_ApDiscoveryParameters_t* pApDiscoveryParams)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return (whal_hwCtrl_ApDiscovery (pWhalCtrl->pHwCtrl, pApDiscoveryParams));
+}
+
+/****************************************************************************
+ *                      whalCtrl_ApDiscoveryStop()
+ ****************************************************************************
+ * DESCRIPTION: send Command for stoping AP Discovery
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_ApDiscoveryStop (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return (whal_hwCtrl_ApDiscoveryStop (pWhalCtrl->pHwCtrl));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetGroupIpAddressesTable
+ *
+ * Input    :
+ * Output   :
+ * Process  :  Configures the Group table
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_SetGroupAddressesTable(TI_HANDLE hWhalCtrl, 
+                                      UINT8 numGroupAddrs, 
+                                      macAddress_t *Group_addr,
+                                      UINT8 isEnabled)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    if ( numGroupAddrs > MAX_MULTICAST_GROUP_ADDRS) 
+    {
+            WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+                    ("whalCtrl_SetGroupAddressesTable: numGroupAddrs=%d !!!\n", numGroupAddrs));        
+        return PARAM_VALUE_NOT_VALID;
+    }
+    return whal_hwCtrl_SetGroupAddressesTable(pWhalCtrl->pHwCtrl, 
+                                              numGroupAddrs, Group_addr,isEnabled);
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_GetGroupIpAddressesTable
+*
+* Input    :
+* Output   :
+* Process  :  Retrieve the Group table
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_GetGroupAddressesTable(TI_HANDLE hWhalCtrl,UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    return whal_hwCtrl_GetGroupAddressesTable(pWhalCtrl->pHwCtrl, 
+        pisEnabled, pnumGroupAddrs, Group_addr);
+}
+
+
+/****************************************************************************
+ *                      whalCtrl_ElpCtrl_SetMode()
+ ****************************************************************************
+ * DESCRIPTION: wrapper function for the lower TNETWIF_ElpCtrl_Mode
+ * 
+ * INPUTS:  
+ *      hWhalCtrl       The current context handle
+ *      mode            The ElpCtrl mode
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_ElpCtrl_SetMode(TI_HANDLE hWhalCtrl, elpCtrl_Mode_e mode)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    
+    return whalBus_TNETWIF_ElpCtrl_SetMode(pWhalCtrl->hWhalBus, mode);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetMinPowerLevel
+ *
+ * Input    :   1) theWhalCtrlHandle - handle to the WhalCtrl object.
+ *          2) minPowerPolicy - the min power policy to set
+ *
+ * Output   :  TI_STATUS - OK on success else NOK.
+ *
+ * Process  : configuration of the min power policy to the FW.
+ *
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+ TI_STATUS whalCtrl_SetMinPowerLevel(TI_HANDLE theWhalCtrlHandle,
+                                    powerAutho_PowerPolicy_e minPowerPolicy)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)theWhalCtrlHandle;
+    WlanParams_T *pWlanParams = &pWhalCtrl->pWhalParams->WlanParams;
+
+    /* save th eparameter inside the WlanParams */
+    pWlanParams->minPowerLevel = minPowerPolicy;
+    
+    return (TI_STATUS)whal_hwCtrl_MinPowerLevelSet(pWhalCtrl->pHwCtrl,minPowerPolicy);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_GetMinPowerLevel
+ *
+ * Input    :   1) theWhalCtrlHandle - handle to the WhalCtrl object.
+ *          2) minPowerPolicy - a pointer to the min power policy to get
+ *
+ * Output   :  TI_STATUS - OK on success else NOK.
+ *
+ * Process  : gets the min power policy that was configured to the FW.
+ *
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+ TI_STATUS whalCtrl_GetMinPowerLevel(TI_HANDLE theWhalCtrlHandle,
+                                    powerAutho_PowerPolicy_e* minPowerPolicy)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)theWhalCtrlHandle;
+    WlanParams_T *pWlanParams = &pWhalCtrl->pWhalParams->WlanParams;
+
+    /* save th eparameter inside the WlanParams */
+    *minPowerPolicy = pWlanParams->minPowerLevel;
+    
+    return OK;
+}
+
+
+
+ /*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetInfoElemEventMask
+ *
+ * Input    :  eventMask - Vector to be Masked
+ *
+ * Process  : set FW with the Masked Vector
+ *
+ * Note(s)  : called from eventMbox.c
+ * -----------------------------------------------------------------------------
+ */
+ void whalCtrl_SetInfoElemEventMask(TI_HANDLE hWhalCtrl,UINT32 eventMask)
+ {
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)hWhalCtrl;
+
+    whal_hwInfoElemEventMaskSet (pWhalCtrl->pHwCtrl->pHwMboxConfig, eventMask);
+ }
+
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_RxPER
+*
+* Input    :    
+*
+* Output   :    
+* Process  :
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_RxPER(TI_HANDLE hWhalCtrl, PLT_RxPerCmd_e eRxPerCmd, TI_HANDLE CB_Handle, void *CB_Func)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    int status ;
+    status = whal_hwCmdBit_RxPER(pWhalCtrl->pHwCtrl->pHwMboxCmdBit, eRxPerCmd, CB_Handle, CB_Func);
+    return status;
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_TxCW
+*
+* Input    :    
+*
+* Output   :    
+* Process  :
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_TxCW(TI_HANDLE hWhalCtrl, TestCmdChannelBand_t* PltTxCarrier, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    int status ;
+    
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, 
+        ("whalCtrl_TxCW: chID = %d bandID = %d\n ",
+        PltTxCarrier->channel,
+        PltTxCarrier->band));
+    
+    status = whal_hwCmdBit_Telec(pWhalCtrl->pHwCtrl->pHwMboxCmdBit,PltTxCarrier->channel, PltTxCarrier->band, CB_Func, CB_handle, CB_Buf);
+    return status;
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_TxContinues
+*
+* Input    :    
+*
+* Output   :    
+* Process  :
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_TxContinues(TI_HANDLE hWhalCtrl, PltTxContinues_t* pPLT_TX_Continues, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    int status ;
+
+       status = whal_hwCmdBit_Fcc(pWhalCtrl->pHwCtrl->pHwMboxCmdBit,
+                      pPLT_TX_Continues->chID, pPLT_TX_Continues->rate,
+                                         pPLT_TX_Continues->preamble, pPLT_TX_Continues->band,
+                      pPLT_TX_Continues->InterPacketDelay, pPLT_TX_Continues->mode, pPLT_TX_Continues->NumOfFrames,
+                      pPLT_TX_Continues->aSeqNumMode, pPLT_TX_Continues->aPacketLength, (uint8*)&(pPLT_TX_Continues->aPeerMacAddr),
+                      CB_Func, CB_handle, CB_Buf);
+    return status;
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_WriteRegister
+*
+* Input    :    
+*
+* Output   :    
+* Process  :
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_WriteRegister(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    int status ;
+    
+    status = whal_hwCmdBit_WriteRegister(pWhalCtrl->pHwCtrl->pHwMboxCmdBit, CB_Handle, CB_Func, CB_Buf);
+    return status;
+}
+
+
+/*
+* ----------------------------------------------------------------------------
+* Function : whalCtrl_ReadRegister
+*
+* Input    :    
+*
+* Output   :    
+* Process  :
+* -----------------------------------------------------------------------------
+*/
+int whalCtrl_ReadRegister(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    int status ;
+    
+    status = whal_hwCmdBit_ReadRegister(pWhalCtrl->pHwCtrl->pHwMboxCmdBit, CB_Handle, CB_Func, CB_Buf);
+    return status;
+}
+
+/****************************************************************************************
+*                        whalCtrl_ReadMib()                                 
+****************************************************************************************
+DESCRIPTION:      Read configuration information and statistics
+
+  INPUT:          
+  
+    OUTPUT:
+    
+      RETURN:         
+      
+************************************************************************/
+int whalCtrl_ReadMib(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    PLT_MIB_t* pMibBuf = (PLT_MIB_t*)CB_Buf;
+    CmdQueue_InterrogateCB_t RetFunc = (CmdQueue_InterrogateCB_t)CB_Func;
+    TI_STATUS Status;
+    
+    
+    
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_ReadMib :pMibBuf %p:\n",pMibBuf));
+    
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_ReadMib :aMib %x:\n",pMibBuf->aMib));
+    
+    switch (pMibBuf->aMib)
+    {
+    case PLT_MIB_dot11StationId:
+    /* 
+    * Use the Station ID CallBack as the Read MIB Cb to get back context 
+        */
+        return(whalCtrl_InterrogateMbox(hWhalCtrl , CB_Func, CB_Handle, CB_Buf)); 
+/*  break; */
+        
+    case PLT_MIB_dot11MaxReceiveLifetime:
+        {
+            whalParamInfo_t ParamInfo; 
+            ParamInfo.paramType = (UINT32)HAL_CTRL_DOT11_MAX_RX_MSDU_LIFE_TIME;
+            ParamInfo.paramLength = sizeof(ParamInfo.content.halCtrlMaxRxMsduLifetime);
+            Status = whalCtrl_GetParam(hWhalCtrl, &ParamInfo);
+            pMibBuf->aData.MaxReceiveLifeTime = ParamInfo.content.halCtrlMaxRxMsduLifetime / 1024; /* converting from usecs to TUs*/
+            pMibBuf->Length = sizeof(pMibBuf->aData.MaxReceiveLifeTime);
+            RetFunc(CB_Handle, Status, (void*)pMibBuf);
+        }
+        break;
+        
+        
+    case PLT_MIB_dot11GroupAddressesTable:
+        {
+            Status = (TI_STATUS)whalCtrl_GetGroupAddressesTable(
+                hWhalCtrl, 
+                &pMibBuf->aData.GroupAddressTable.bFilteringEnable,
+                &pMibBuf->aData.GroupAddressTable.nNumberOfAddresses,
+                pMibBuf->aData.GroupAddressTable.GroupTable);
+            
+               pMibBuf->Length = sizeof(pMibBuf->aData.GroupAddressTable.bFilteringEnable) + 
+                                 sizeof(pMibBuf->aData.GroupAddressTable.nNumberOfAddresses) +
+                                 pMibBuf->aData.GroupAddressTable.nNumberOfAddresses * sizeof(macAddress_t);
+            
+            RetFunc(CB_Handle, Status, CB_Buf);
+        }
+
+        break;
+        
+    case PLT_MIB_ctsToSelf:
+        {
+            whalParamInfo_t ParamInfo;          
+            ParamInfo.paramType = (UINT32)HAL_CTRL_CTS_TO_SELF_PARAM;
+            ParamInfo.paramLength = sizeof(ParamInfo.content.halCtrlCtsToSelf);
+            Status = whalCtrl_GetParam(hWhalCtrl, &ParamInfo);
+            pMibBuf->aData.CTSToSelfEnable = ParamInfo.content.halCtrlCtsToSelf;
+            pMibBuf->Length = sizeof(pMibBuf->aData.CTSToSelfEnable);
+            RetFunc(CB_Handle, Status, CB_Buf);
+        }
+        break;
+        
+    case PLT_MIB_arpIpAddressesTable:
+        {
+            IpAddress_t IpAddress;  
+            IPver_e IPver;
+            UINT8 Enable;
+            TI_STATUS status;
+            
+            pMibBuf->Length = sizeof(PLT_MIB_ArpIpAddressesTable_t);
+            status = (TI_STATUS)whalCtrl_GetArpIpAddressesTable(pWhalCtrl->pHwCtrl, 
+                                                    &IpAddress, 
+                                                    &Enable,
+                                                    &IPver);
+            if (status == OK)
+            {
+                pMibBuf->aData.ArpIpAddressesTable.FilteringEnable = Enable;         
+
+                if (IP_VER_4 == IPver) /* IP_VER_4 only */
+                {
+                    os_memoryCopy(pWhalCtrl->hOs,
+                        (PVOID)pMibBuf->aData.ArpIpAddressesTable.addr, 
+                        (PVOID)IpAddress.addr,
+                        IP_V4_ADDR_LEN);                    
+                }
+                else
+                {
+                    status = NOK;
+                }
+            }
+            RetFunc(CB_Handle, status, CB_Buf);
+            return status;
+        }
+
+
+        /*break; Unreachble code*/
+        
+    case PLT_MIB_templateFrame:
+        whalCtrl_ReadTemplateFrameMib(hWhalCtrl, CB_Handle, CB_Func,  CB_Buf);
+        break;
+        
+    case PLT_MIB_rxFilter:
+        {
+            UINT32 RxConfigOption;
+            UINT32 RxFilterOption;
+            
+            pMibBuf->Length = 1;
+            pMibBuf->aData.RxFilter = 0;
+
+            /*Get RX filter data*/
+            Status = (TI_STATUS)whalCtrl_GetRxFilters(pWhalCtrl, &RxConfigOption, &RxFilterOption);
+            if (OK == Status)
+            {
+                /*Translate to MIB bitmap*/
+                if ((RxConfigOption & RX_CFG_MAC) == RX_CFG_ENABLE_ANY_DEST_MAC)
+                    pMibBuf->aData.RxFilter |= PLT_MIB_RX_FILTER_PROMISCOUS_SET;
+                
+                if ((RxConfigOption & RX_CFG_BSSID) == RX_CFG_ENABLE_ONLY_MY_BSSID)
+                    pMibBuf->aData.RxFilter |= PLT_MIB_RX_FILTER_BSSID_SET;
+            }
+            RetFunc(CB_Handle, Status, CB_Buf);         
+        }
+        break;
+
+    case PLT_MIB_beaconFilterIETable:
+        return (whalCtrl_PltMibGetBeaconFilterIETable(hWhalCtrl, CB_Handle, CB_Func, CB_Buf));
+/*        break; */
+
+    case PLT_MIB_txRatePolicy:
+        return (whalCtrl_PLT_ReadMIB_TxRatePolicy(hWhalCtrl, CB_Handle, CB_Func, CB_Buf));
+/*      break; */
+        
+
+    case PLT_MIB_countersTable:
+        return(whalCtrl_InterrogateGwsiCounters (hWhalCtrl , CB_Func, CB_Handle, CB_Buf));
+/*      break; */
+
+
+    case PLT_MIB_statisticsTable:
+        return (whalCtrl_InterrogateGwsiStatisitics(hWhalCtrl , CB_Func, CB_Handle, CB_Buf));
+/*        break; */
+
+    default:
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("whalCtrl_ReadMib:MIB aMib 0x%x Not supported\n",pMibBuf->aMib));
+        return NOK;
+    }
+    return OK;
+    
+}
+
+/****************************************************************************************
+*                        whalCtrl_WriteMib()                                 
+****************************************************************************************
+DESCRIPTION:      Set configuration information
+
+INPUT:          
+
+OUTPUT:
+
+RETURN:         
+
+************************************************************************/
+int whalCtrl_WriteMib(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+   
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_WriteMib :pMib %p:\n",pMib));
+    
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_WriteMib :aMib %x:\n",pMib->aMib));
+
+    WLAN_REPORT_HEX_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        (PUINT8)pMib, min(sizeof(PLT_MIB_t), pMib->Length));
+    
+    if (NULL == pMib)
+    {
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_WriteMib :pMib = NULL !!\n"));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+  
+    switch (pMib->aMib)
+    {   
+    case PLT_MIB_dot11MaxReceiveLifetime:
+        {
+            whalParamInfo_t ParamInfo;
+            ParamInfo.paramType = (UINT32)HAL_CTRL_DOT11_MAX_RX_MSDU_LIFE_TIME;
+            ParamInfo.paramLength = sizeof(ParamInfo.content.halCtrlMaxRxMsduLifetime);
+            ParamInfo.content.halCtrlMaxRxMsduLifetime = pMib->aData.MaxReceiveLifeTime;
+            ParamInfo.content.halCtrlMaxRxMsduLifetime *= 1024; /* converting from TUs to usecs */
+            return whalCtrl_SetParam(hWhalCtrl, &ParamInfo);
+        }
+/*        break;  */
+        
+    case PLT_MIB_ctsToSelf:
+        {
+            whalParamInfo_t ParamInfo;
+            ParamInfo.paramType = (UINT32)HAL_CTRL_CTS_TO_SELF_PARAM;
+            ParamInfo.paramLength = sizeof(ParamInfo.content.halCtrlCtsToSelf);
+            ParamInfo.content.halCtrlCtsToSelf = pMib->aData.CTSToSelfEnable;
+            return whalCtrl_SetParam(hWhalCtrl, &ParamInfo);
+        }
+/*        break; */
+        
+    case PLT_MIB_dot11GroupAddressesTable: 
+        {
+            
+            if ( NULL == pMib->aData.GroupAddressTable.GroupTable)
+            {
+                WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                    ("whalCtrl_WriteMib(PLT_MIB_dot11GroupAddressesTable) :GroupTable = NULL !!\n"));
+                return PARAM_VALUE_NOT_VALID;
+            }
+            
+            return whalCtrl_SetGroupAddressesTable(hWhalCtrl, 
+                pMib->aData.GroupAddressTable.nNumberOfAddresses,
+                pMib->aData.GroupAddressTable.GroupTable,
+                pMib->aData.GroupAddressTable.bFilteringEnable);
+        }
+/*        break;  */
+        
+    case PLT_MIB_arpIpAddressesTable:
+        {
+            IpAddress_t IpAddress;
+            IpAddress.addr[0] =  pMib->aData.ArpIpAddressesTable.addr[0];
+            IpAddress.addr[1] =  pMib->aData.ArpIpAddressesTable.addr[1];
+            IpAddress.addr[2] =  pMib->aData.ArpIpAddressesTable.addr[2];
+            IpAddress.addr[3] =  pMib->aData.ArpIpAddressesTable.addr[3];
+
+            WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                ("whalCtrl_WriteMib(PLT_MIB_arpIpAddressesTable) IpAddress:\n"));
+            WLAN_REPORT_HEX_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                        (PUINT8)&IpAddress, 4);
+
+            return whalCtrl_SetarpIpAddressesTable(hWhalCtrl, 
+                &IpAddress,
+                pMib->aData.ArpIpAddressesTable.FilteringEnable,
+                IP_VER_4);
+        }
+/*        break; */
+        
+    case PLT_MIB_templateFrame:
+        return whalCtrl_WriteTemplateFrameMib(hWhalCtrl, pMib);
+/*        break; */
+        
+    case PLT_MIB_beaconFilterIETable:
+        return whalCtrl_PltMibSetBeaconFilterIETable(hWhalCtrl, pMib);
+/*        break;  */
+        
+    case PLT_MIB_rxFilter:
+        {
+            UINT32 whal_rx_filter = 0;
+            tiUINT8 Mib_Rx_Filter = pMib->aData.RxFilter;
+            
+            /* 
+            * Construct the WHAL rx filter element
+            */
+            if (Mib_Rx_Filter & PLT_MIB_RX_FILTER_PROMISCOUS_SET )
+            {
+                WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,HAL_CTRL_MODULE_LOG,("\n whalCtrl_WriteMib PLT_MIB_rxFilter - RX_CFG_ENABLE_ANY_DEST_MAC\n")) ;
+                whal_rx_filter = RX_CFG_ENABLE_ANY_DEST_MAC;
+            }
+            else
+            {
+                whal_rx_filter = RX_CFG_ENABLE_ONLY_MY_DEST_MAC;
+                WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,HAL_CTRL_MODULE_LOG,("\n halCtrl_WriteMib PLT_MIB_rxFilter - RX_CFG_ENABLE_ONLY_MY_DEST_MAC\n")) ;
+            }
+            
+            if ( Mib_Rx_Filter & PLT_MIB_RX_FILTER_BSSID_SET )
+            {
+                whal_rx_filter = whal_rx_filter | RX_CFG_ENABLE_ONLY_MY_BSSID;
+                WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,HAL_CTRL_MODULE_LOG,("\n halCtrl_WriteMib PLT_MIB_rxFilter - RX_CFG_ENABLE_ONLY_MY_BSSID\n")) ;
+            }
+            else
+            {
+                whal_rx_filter = whal_rx_filter | RX_CFG_ENABLE_ANY_BSSID;
+                WLAN_REPORT_INFORMATION(pWhalCtrl->hReport,HAL_CTRL_MODULE_LOG,("\n halCtrl_WriteMib PLT_MIB_rxFilter - RX_CFG_ENABLE_ANY_BSSID\n") );
+            }
+            
+            /*
+            * Activates the whalCtrl_setRxFilters function 
+            */
+            return whalCtrl_setRxFilters(hWhalCtrl, whal_rx_filter, RX_FILTER_OPTION_DEF);
+            
+        }
+/*        break;  */
+
+    case PLT_MIB_txRatePolicy:
+        return whalCtrl_PLT_WriteMIB_TxRatePolicy(hWhalCtrl, pMib);
+/*      break;  */
+
+    default:
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport,
+            HAL_CTRL_MODULE_LOG,
+            ("%s(%d) - whalCtrl_WriteMib - ERROR - MIB element not supported, %d\n\n",
+            __FILE__,__LINE__,pMib->aMib));
+        
+        return NOK;
+        
+    } /* switch */
+    
+/*    return OK;*/
+}
+
+
+int whalCtrl_ReadTemplateFrameMib(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    PLT_MIB_t* pMibBuf = (PLT_MIB_t*)CB_Buf;
+    CmdQueue_InterrogateCB_t RetFunc = (CmdQueue_InterrogateCB_t)CB_Func;
+    TemplateParams_T* pTemplateParams;
+    whalCtrl_templateType_e templateType;
+      
+    switch(pMibBuf->aData.TemplateFrame.FrameType)
+    {
+    case PLT_TEMPLATE_TYPE_BEACON:
+        templateType = BEACON_TEMPLATE;
+        pMibBuf->aData.TemplateFrame.Rate = pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmRateDriverFormat; 
+        break;
+
+    case PLT_TEMPLATE_TYPE_PROBE_REQUEST:
+        templateType = PROBE_REQUEST_TEMPLATE;
+        pMibBuf->aData.TemplateFrame.Rate = DRV_RATE_INVALID;
+        break;
+        
+    case PLT_TEMPLATE_TYPE_NULL_FRAME:
+        {
+            TI_HANDLE hHalCtrl;
+            TI_HANDLE hMacServices;
+            TnetwDrv_TEMP_GetHandles(pWhalCtrl->hTNETW_Driver, &hHalCtrl, &hMacServices);
+            pMibBuf->aData.TemplateFrame.Rate = MacServices_powerSrv_GetRateModulation(hMacServices);
+            templateType = NULL_DATA_TEMPLATE;
+        }
+        break;
+
+    case PLT_TEMPLATE_TYPE_PROBE_RESPONSE:
+        templateType = PROBE_RESPONSE_TEMPLATE;
+        pMibBuf->aData.TemplateFrame.Rate = pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmRateDriverFormat; 
+        break;
+
+    case PLT_TEMPLATE_TYPE_QOS_NULL_FRAME:
+        templateType = QOS_NULL_DATA_TEMPLATE;
+        pMibBuf->aData.TemplateFrame.Rate = pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmRateDriverFormat; 
+        break;
+
+    case PLT_TEMPLATE_TYPE_PS_POLL:
+        templateType = PS_POLL_TEMPLATE;
+        pMibBuf->aData.TemplateFrame.Rate = pWhalCtrl->pWhalParams->BssInfoParams.txCtrlFrmRateDriverFormat; 
+        break;
+    default:
+           WLAN_REPORT_ERROR(pWhalCtrl->hReport,
+                HAL_CTRL_MODULE_LOG,
+                ("%s(%d) - whalCtrl_ReadTemplateFrameMib - ERROR - template is not supported, %d\n\n",
+                __FILE__,__LINE__,pMibBuf->aData.TemplateFrame.FrameType));
+            return PARAM_NOT_SUPPORTED;
+        }
+   
+    pTemplateParams =  whalCtrl_GetTemplate(hWhalCtrl, templateType);
+    
+    if (pTemplateParams)
+    {
+        pMibBuf->Length = pTemplateParams->Size + 10;
+        
+        pMibBuf->aData.TemplateFrame.Length = pTemplateParams->Size;
+        
+        os_memoryCopy(pWhalCtrl->hOs,
+            pMibBuf->aData.TemplateFrame.Data,
+            pTemplateParams->Buffer,
+            pTemplateParams->Size);
+        
+    
+        pMibBuf->aData.TemplateFrame.Rate = whalUtils_DRV_RATE2GwsiRate(pMibBuf->aData.TemplateFrame.Rate);
+        RetFunc(CB_Handle, OK, CB_Buf);
+        return OK;
+    }
+
+    RetFunc(CB_Handle, NOK, CB_Buf); 
+    return NOK;
+}
+
+int whalCtrl_WriteTemplateFrameMib(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    rate_e rate;
+    whalCtrl_setTemplate_t   whal_set_template_s;
+    
+    
+    /*convert the rate to driver rate*/
+    rate = (rate_e)whalUtils_GwsiRate2DRV_RATE(pMib->aData.TemplateFrame.Rate);
+    
+    /* 
+    * Construct the template MIB element
+    */
+    switch(pMib->aData.TemplateFrame.FrameType)
+    {
+    case PLT_TEMPLATE_TYPE_BEACON:
+        whal_set_template_s.templateType = BEACON_TEMPLATE;
+
+        /* Set new Mgmt rate (write it to Fw along with the modulation) */
+        whalCtrl_SetFrameRate(hWhalCtrl, rate, FALSE);
+        
+        break;
+        
+    case PLT_TEMPLATE_TYPE_PROBE_REQUEST:
+        whal_set_template_s.templateType = PROBE_REQUEST_TEMPLATE;
+        break;
+        
+    case PLT_TEMPLATE_TYPE_NULL_FRAME:
+        {
+            TI_HANDLE hHalCtrl;
+            TI_HANDLE hMacServices;
+            TnetwDrv_TEMP_GetHandles(pWhalCtrl->hTNETW_Driver, &hHalCtrl, &hMacServices);
+            
+            whal_set_template_s.templateType = NULL_DATA_TEMPLATE;
+            MacServices_powerSrv_SetRateModulation(hMacServices,
+                (UINT16)whalUtils_GwsiRate2DRV_RATE_MASK(pMib->aData.TemplateFrame.Rate));
+        }
+        break;
+        
+    case PLT_TEMPLATE_TYPE_PROBE_RESPONSE:
+        whal_set_template_s.templateType = PROBE_RESPONSE_TEMPLATE;
+
+        /* Set new Mgmt rate (write it to Fw along with the modulation) */        
+        whalCtrl_SetFrameRate(hWhalCtrl, rate, FALSE);
+        
+        break;
+        
+    case PLT_TEMPLATE_TYPE_QOS_NULL_FRAME:
+        whal_set_template_s.templateType = QOS_NULL_DATA_TEMPLATE;
+
+        /* Set new Ctrl rate (write it to Fw along with the modulation) */        
+        whalCtrl_SetFrameRate(hWhalCtrl, rate, TRUE);
+        
+        break;
+        
+    case PLT_TEMPLATE_TYPE_PS_POLL:
+        whal_set_template_s.templateType = PS_POLL_TEMPLATE;
+
+        /* Set new Ctrl rate (write it to Fw along with the modulation) */        
+        whalCtrl_SetFrameRate(hWhalCtrl, rate, TRUE);
+        
+        break;
+        
+    default:
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport,
+            HAL_CTRL_MODULE_LOG,
+            ("%s(%d) - whalCtrl_WriteTemplateFrameMib - ERROR - template is not supported, %d\n\n",
+            __FILE__,__LINE__,pMib->aData.TemplateFrame.FrameType));
+        return PARAM_NOT_SUPPORTED;
+    }
+    
+    whal_set_template_s.templateLen = pMib->aData.TemplateFrame.Length;
+    whal_set_template_s.pTemplate = (UINT8 *) &(pMib->aData.TemplateFrame.Data);
+    
+    
+    return whalCtrl_SetTemplate(hWhalCtrl, &whal_set_template_s);
+}
+
+int whalCtrl_PltMibSetBeaconFilterIETable(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+    UINT8 numOf221IE = 0 ;
+    UINT8 i = 0 ;
+    UINT8 IETableLen = 0 ;
+    UINT8 numOfIEs = 0 ;
+    UINT8 *IETable = NULL ;
+    
+    numOfIEs = pMib->aData.BeaconFilter.iNumberOfIEs;
+    IETable = pMib->aData.BeaconFilter.iIETable;
+    /*find the actual IETableLen */
+    for ( i = 0 ; i < numOfIEs ; i++ )
+    {
+        if ( IETable[IETableLen] == 0xdd )
+        {
+             IETableLen += 8;
+             numOf221IE++;
+        }
+        else
+            IETableLen += 2;
+    }
+    
+    WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("\nwhalCtrl_PltMibSetBeaconFilterIETable,IETable=0x%x Num Of IE=%d ( including %d 221 ) - Table Len=%d\n",
+        IETable , numOfIEs , numOf221IE , IETableLen ));
+    
+    return whalCtrl_SetBeaconFilterIETable(hWhalCtrl, &numOfIEs, IETable, &IETableLen);
+}
+
+int whalCtrl_PltMibGetBeaconFilterIETable(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf)
+{
+    PLT_MIB_t* pMib = (PLT_MIB_t*)CB_Buf;
+    CmdQueue_InterrogateCB_t RetFunc = (CmdQueue_InterrogateCB_t)CB_Func;
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    UINT8 IETableSize = 0;
+
+
+    /*Get params*/
+    pMib->aData.BeaconFilter.iNumberOfIEs = pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.numberOfIEs;
+    IETableSize = pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETableSize;
+                  
+    os_memoryZero (pWhalCtrl->hOs, 
+                   pMib->aData.BeaconFilter.iIETable,
+                   sizeof(pMib->aData.BeaconFilter.iIETable));
+
+    os_memoryCopy(pWhalCtrl->hOs, 
+                  pMib->aData.BeaconFilter.iIETable,
+                  pWhalCtrl->pWhalParams->WlanParams.beaconFilterIETable.IETable,
+                  IETableSize);
+    pMib->Length = IETableSize + 1;     
+
+    RetFunc(CB_Handle, OK, CB_Buf); 
+    return OK;
+
+}
+
+/**
+ * \author \n
+ * \date \n
+ * \brief Coordinates between legacy TxRatePolicy implementation and the MIB format: \n
+ *        Converts the pGwsi_txRatePolicy back to whal commands 
+ *        Activates the whal whalCtrl_set function 
+ * Function Scope \e Public.\n
+ * \param  - \n
+ * \return \n
+ */
+
+int whalCtrl_PLT_WriteMIB_TxRatePolicy(TI_HANDLE hWhalCtrl, PLT_MIB_t* pMib)                /* Pointer to the MIB data*/
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    whalParamInfo_t param;
+
+    if (NULL == pMib)
+    {
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("ERROR : whalCtrl_PLT_WriteMIB_TxRatePolicy pMib=NULL !!!"));
+    }
+
+
+    param.paramType = (UINT32)HAL_CTRL_TX_RATE_CLASS_PARAMS;
+    param.content.pTxRatePlicy = &pMib->aData.txRatePolicy;
+
+    /*
+     * Call WhalCtrl Set I/F
+     */
+    return(whalCtrl_SetParam(hWhalCtrl, &param));
+}
+
+/**
+ * \author \n
+ * \date \n
+ * \brief Coordinates between legacy TxRatePolicy implementation and the MIB format: \n
+ *        Converts the pGwsi_txRatePolicy back to whal commands 
+ *        Activates the whal whalCtrl_set function 
+ * Function Scope \e Public.\n
+ * \param  - \n
+ * \return \n
+ */
+
+int whalCtrl_PLT_ReadMIB_TxRatePolicy(TI_HANDLE hWhalCtrl, TI_HANDLE CB_Handle, void* CB_Func, void* CB_Buf)
+{
+    PLT_MIB_t* pMib = (PLT_MIB_t*)CB_Buf;
+    CmdQueue_InterrogateCB_t RetFunc = (CmdQueue_InterrogateCB_t)CB_Func;
+    whalParamInfo_t     param;
+    tiUINT32 Status = OK;
+
+
+    param.paramType = (UINT32)HAL_CTRL_TX_RATE_CLASS_PARAMS;
+    whalCtrl_GetParam(hWhalCtrl, &param);
+    if (param.content.pTxRatePlicy == NULL)
+        Status = NOK;
+
+    /*Copy the data form the param to the MIB*/
+    pMib->aData.txRatePolicy = *param.content.pTxRatePlicy;
+    pMib->Length = pMib->aData.txRatePolicy.numOfRateClasses * sizeof(pMib->aData.txRatePolicy.rateClass[0]) + 
+                       sizeof(pMib->aData.txRatePolicy.numOfRateClasses);
+    RetFunc(CB_Handle, Status, CB_Buf);
+    return Status;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_updateSecuritySeqNum
+ *
+ * Process  : Update the current TKIP/AES security-sequence-number according to the last
+ *              Tx data packet seq-number, for reloading it to the FW in case of recovery.
+ *            The complete 32 bit number is deduced from the 8 LS bits provided by the FW
+ *              in the Tx-Result, assuming the total number is never incremented in more 
+ *              than 255 per one packet (limited by max fragments per packet).
+ *
+ * Input    : 1) theWhalCtrlHandle - handle to the WhalCtrl object.
+ *            2) securitySeqNumLsByte - the LS byte of the last Tx frame security-sequence-number.
+ *
+ * -----------------------------------------------------------------------------
+ */
+ void whalCtrl_updateSecuritySeqNum(TI_HANDLE hWhalCtrl, UINT8 securitySeqNumLsByte)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)hWhalCtrl;
+    HwCtrl_T  *pHwCtrl   = (HwCtrl_T *)pWhalCtrl->pHwCtrl;
+
+    /* If 8 lsb wrap around occurred (new < old). */
+    if ( (UINT16)securitySeqNumLsByte < (pHwCtrl->SecuritySeqNumLow & 0xFF))
+    {
+        /* Increment the upper byte of the 16 lsb. */       
+        pHwCtrl->SecuritySeqNumLow += 0x100;
+        
+        /* If 16 bit wrap around occurred, increment the upper 32 bit. */
+        if( !(pHwCtrl->SecuritySeqNumLow & 0xFF00) )
+            pHwCtrl->SecuritySeqNumHigh++;
+    }
+
+    /* Save new sequence number 8 lsb (received from the FW). */
+    pHwCtrl->SecuritySeqNumLow &= 0xFF00;
+    pHwCtrl->SecuritySeqNumLow |= (UINT16)securitySeqNumLsByte;
+}
+
+
+ /*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_setBetParams
+ *
+ * Input    :   enabled               - 0 to disable BET, 0 to disable BET
+ *              MaximumConsecutiveET  - Max number of consecutive beacons
+ *                                      that may be early terminated.
+ * Output   :
+ * Process  :  Configures Beacon Early Termination information element.
+ * Note(s)  :  None
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_setBetParams(TI_HANDLE hWhalCtrl, UINT8 Enable, UINT8 MaximumConsecutiveET)
+{
+    WHAL_CTRL * pWhalCtrl = (WHAL_CTRL *) hWhalCtrl;
+
+    pWhalCtrl->pWhalParams->WlanParams.BetEnable = Enable;
+    pWhalCtrl->pWhalParams->WlanParams.MaximumConsecutiveET = MaximumConsecutiveET;
+
+    return whal_hwCtrl_setBetParams(pWhalCtrl->pHwCtrl, Enable, MaximumConsecutiveET);
+}
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalCtrl.h b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalCtrl.h
new file mode 100644 (file)
index 0000000..a39c953
--- /dev/null
@@ -0,0 +1,120 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_CTRL_H
+#define _WHAL_CTRL_H
+
+#include "whalCommon.h"
+#include "whalParams.h"
+#include "whalHwCtrl.h"
+
+#include "rxXfer_api.h"
+
+
+/* CLASS WHAL_CTRL*/
+typedef struct _WHAL_CTRL
+{
+    WhalParams_T*  pWhalParams;
+
+    ReadWriteCommand_t printRegsBuf;    
+    
+    scanCompleteCB_t ScanCmplt_CB;
+    void*            ScanCmplt_CB_handle;
+
+    MacStatusCB_t    MacStatusCB_CB;
+    void*            MacStatusCB_CB_handle;
+
+    HealthReportCB_t HealthReportCB_CB;
+    void*            HealthReportCB_handle;
+
+    AciIndicationCB_t AciIndicationCB_CB;
+    void*             AciIndicationCB_handle;
+
+    failureEventCB_t FailureEvent_CB;
+    void*            FailureEvent_CB_handle;
+    
+
+    BOOL EncDecEnableFlag; /* flag to designates whether the Hw encrypt and decrypt
+                              facility on WEP options IE already enabled*/
+
+    TI_HANDLE hOs;
+    TI_HANDLE hReport;
+    TI_HANDLE hTNETW_Driver;
+
+    TI_HANDLE hFwEvent;
+    TI_HANDLE hTxXfer;
+    TI_HANDLE hTxResult;
+    TI_HANDLE hTxHwQueue;
+    TI_HANDLE hRxXfer;
+    TI_HANDLE hEventMbox;
+    struct _WHAL_SECURITY* pWhalSecurity;
+        
+    struct _HwCtrl_T *pHwCtrl; /* Pointer to the LL_HAL acxCtrl module*/
+    TI_HANDLE   hWhalBus; /* Pointer to the LL_HAL acxCtrl module*/
+    TI_HANDLE   hCmdQueue;
+
+    /* Init stage callback function pointer and handle */ 
+    void     *fCb;
+    TI_HANDLE hCb;
+    
+    ACXMisc_t misc;
+
+#ifdef TI_DBG
+    TI_HANDLE hDebugTrace;
+#endif /* TI_DBG */
+
+} WHAL_CTRL;
+
+
+WhalParams_T *whalCtrl_GetWhalParamsHandle(WHAL_CTRL *pWhalCtrl);
+void whalCtrl_MacStatus_CB(TI_HANDLE hWhalCtrl, char* MacStatus , UINT32 strLen);
+void whalCtrl_HealthReoprt_CB(TI_HANDLE hWhalCtrl, char* MacStatus , UINT32 strLen);
+void whalCtrl_registerDump(TI_HANDLE hWhalCtrl);
+int  whalCtrl_RegisterCmdCompleteGenericCB(TI_HANDLE hWhalCtrl, void *CbFunc ,void *CbObj);
+int  whalCtrl_RegisterErrorsCallbacks(TI_HANDLE hWhalCtrl);
+int  whalCtrl_ReJoinBss (TI_HANDLE hWhalCtrl);
+TI_STATUS whalCtrl_getRadioNumber(TI_HANDLE hWhalCtrl, UINT32 *outRadioType, UINT32 *outRadioNumber);
+TI_STATUS whalCtrl_FinalizeDownload(TI_HANDLE hWhalCtrl);
+/* Used for Memory or Registers reading/writing*/
+typedef enum
+{
+   TNETW_INTERNAL_RAM = 0,
+   TNETW_MAC_REGISTERS = 1,
+   TNETW_PHY_REGISTERS = 2,
+} readWrite_MemoryType_e;
+
+void    whalCtrl_Print_Mem_Regs (TI_HANDLE hWhalCtrl, UINT32 addr, UINT32 len, readWrite_MemoryType_e memType);
+int     whalCtrl_Set_Mem_Regs (TI_HANDLE hWhalCtrl, UINT32 address, UINT32 len, UINT32 aWriteVal, readWrite_MemoryType_e memType);
+#endif /* _WHAL_CTRL_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalDebug.c b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalDebug.c
new file mode 100644 (file)
index 0000000..8bf2dc9
--- /dev/null
@@ -0,0 +1,346 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/****************************************************************************
+ *
+ *   MODULE:  whalDebug.c
+ *   PURPOSE: Handle Debug requests in the Hal
+ *
+ *     Register Mac/Phy Read/Write
+ *     Register Dump
+ *     Register RxDump
+ *     Register TxDump
+ *     Debug trace print
+ *     
+ ****************************************************************************/
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+#include "commonTypes.h"
+#include "CmdQueue_api.h"
+#include "whalBus_Api.h"
+#include "TNETW_Driver.h"
+
+/************************************************
+ *                  definitions                 *
+ ************************************************/
+#define BB_REGISTER_ADDR_BASE           0x820000  /*phony address used by host access*/
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrlReadMacReg
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+UINT32 whalCtrlReadMacReg(TI_HANDLE hWhalCtrl, UINT32 addr)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       
+       return whalBus_MacRegRead(pWhalCtrl->pHwCtrl->hWhalBus, addr);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrlWriteMacReg
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrlWriteMacReg(TI_HANDLE hWhalCtrl, UINT32 addr, UINT32      val)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       whalBus_MacRegWrite(pWhalCtrl->pHwCtrl->hWhalBus, addr, val);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrlReadPhyReg
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+UINT32 whalCtrlReadPhyReg(TI_HANDLE hWhalCtrl, UINT32 addr)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       return whalBus_PhyRegRead(pWhalCtrl->pHwCtrl->hWhalBus, addr);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrlWritePhyReg
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrlWritePhyReg(TI_HANDLE hWhalCtrl, UINT32 addr, UINT32      val)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       whalBus_PhyRegWrite(pWhalCtrl->pHwCtrl->hWhalBus, addr, val);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_PrintAll
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+#ifdef TI_DBG
+void whalCtrl_PrintAll (TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       WLAN_OS_REPORT((" whalCtrl_PrintAll: \n\n"));
+       
+       CmdQueue_Print(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue);
+       
+       whalBus_PrintInfo(pWhalCtrl->hWhalBus, BUS_PRINT_ALL, 0);
+
+       whal_hwInfoElemMemoryMapPrint(pWhalCtrl->pHwCtrl->pHwMboxConfig);                       
+       whal_hwInfoElemStatisticsPrint(pWhalCtrl->pHwCtrl->pHwMboxConfig);
+       
+       whal_ParamsHwNvramPrint(pWhalCtrl->pWhalParams);                        
+}
+#endif
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_getMaxNumberOfCommandsInQueue
+ *
+ * Input    : 
+ * Output   :
+ * Process  : returns the maximum number of commands in the mailbox queue ever
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_getMaxNumberOfCommandsInQueue (TI_HANDLE hWhalCtrl)
+{
+   WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;    
+   return (CmdQueue_GetMaxNumberOfCommands(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_PrintMailBoxHistory
+ *
+ * Input    : 
+ * Output   :
+ * Process  : Prints the mailbox command history
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+
+void whalCtrl_PrintMailBoxHistory (TI_HANDLE hWhalCtrl)
+{
+#ifdef TI_DBG
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;   
+       CmdQueue_PrintHistory(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, 5);
+#endif
+}
+                          
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_PrintMem_Regs_CB
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_PrintMem_Regs_CB (TI_HANDLE hWhalCtrl, UINT32 cmdCbStatus)
+{
+    int i;
+    UINT8   *pBuf;
+    UINT32  result;
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+    if (cmdCbStatus != OK)
+    {
+        WLAN_OS_REPORT((" whalCtrl_PrintMem_Regs_CB: command complete error \n\n"));
+        return;
+    }
+
+    result = (((UINT32)pWhalCtrl->printRegsBuf.addr)&0xFFFF0000);
+    
+    switch (result)
+    {
+        case ACX_MAC_REG_READ_WRITE_PREFIX:
+                WLAN_OS_REPORT(("MAC REGS (Base=0x%08x) = 0x%08x\n", ((UINT32)pWhalCtrl->printRegsBuf.addr)&0xFFFF,
+                                *(UINT32*)(pWhalCtrl->printRegsBuf.value)));
+                break;
+
+        case BB_REGISTER_ADDR_BASE:
+                WLAN_OS_REPORT(("PHY REGS (Base=0x%08x) = 0x%08x\n", ((UINT32)pWhalCtrl->printRegsBuf.addr)&0xFFFF,
+                            *(UINT32*)(pWhalCtrl->printRegsBuf.value)));
+                break;
+
+        default: /* Memory*/
+                for (i=0, pBuf=pWhalCtrl->printRegsBuf.value; i<256; i+=16, pBuf+=16)
+                {
+                    WLAN_REPORT_REPLY(pWhalCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                      ("PrintBuf: 0x%08x: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", 
+                                       pWhalCtrl->printRegsBuf.addr+i, 
+                                       pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7], 
+                                       pBuf[8], pBuf[9], pBuf[10], pBuf[11], pBuf[12], pBuf[13], pBuf[14], pBuf[15]));
+                }
+                break;
+    }
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Print_Mem_Regs
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Reading from memory or registers is done through IE (interrogate)
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_Print_Mem_Regs (TI_HANDLE hWhalCtrl, UINT32 address, UINT32 len, readWrite_MemoryType_e memType)
+{
+    ReadWriteCommand_t  AcxCmd_ReadMemory; 
+    ReadWriteCommand_t* pCmd = &AcxCmd_ReadMemory;
+
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       os_memoryZero(pWhalCtrl->hOs, (void *)pCmd, sizeof(*pCmd));
+    
+    switch (memType)
+    {
+        case TNETW_INTERNAL_RAM:
+            pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(address);
+            pCmd->size = ENDIAN_HANDLE_LONG(len);
+            break;
+             
+        case TNETW_MAC_REGISTERS:
+            pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(( (address&0xFFFF) | ACX_MAC_REG_READ_WRITE_PREFIX ));
+            pCmd->size = 4;
+            break;
+    
+        case TNETW_PHY_REGISTERS:
+            pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(( (address&0xFFFF) | BB_REGISTER_ADDR_BASE ));
+            pCmd->size = 4;
+            break;
+    
+        default:
+            WLAN_OS_REPORT((" whalCtrl_Print_Mem_Regs: ERROR, wrong memory type %d\n\n", memType));
+            return;
+    }
+    
+    os_memoryZero (pWhalCtrl->hOs, (void *)&pWhalCtrl->printRegsBuf, sizeof(pWhalCtrl->printRegsBuf));
+    
+    CmdQueue_CommandWithCb(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, CMD_READ_MEMORY, (char *)pCmd, 
+                                sizeof(*pCmd), (void *)whalCtrl_PrintMem_Regs_CB, hWhalCtrl, 
+                                &pWhalCtrl->printRegsBuf);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_Set_Mem_Regs
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Writing to memory or registers is done through command to the ACX
+ *            This function overrides the len parameter and write only 4 bytes!
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_Set_Mem_Regs (TI_HANDLE hWhalCtrl, UINT32 address, UINT32 len, UINT32 aWriteVal, 
+                           readWrite_MemoryType_e memType)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    ReadWriteCommand_t  AcxCmd_WriteMemory; 
+    ReadWriteCommand_t* pCmd = &AcxCmd_WriteMemory;
+
+       os_memoryZero(pWhalCtrl->hOs, (void *)pCmd, sizeof(*pCmd));
+    
+    switch (memType)
+    {
+        case TNETW_INTERNAL_RAM:
+            pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(address);
+            pCmd->size = ENDIAN_HANDLE_LONG(len);
+            WLAN_OS_REPORT((" whalCtrl_Set_Mem_Regs: write to Internal Ram addr=0x%x Val=0x%x\n\n", pCmd->addr, aWriteVal));
+            break;
+             
+        case TNETW_MAC_REGISTERS:
+            pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG( (address&0xFFFF) | ACX_MAC_REG_READ_WRITE_PREFIX);
+            pCmd->size = ENDIAN_HANDLE_LONG(len);
+            WLAN_OS_REPORT((" whalCtrl_Set_Mem_Regs: write to Mac register addr=0x%x Val=0x%x\n\n", pCmd->addr, aWriteVal));
+            break;
+    
+        case TNETW_PHY_REGISTERS:
+            pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG( (address&0xFFFF) | BB_REGISTER_ADDR_BASE);
+            pCmd->size = ENDIAN_HANDLE_LONG(len);
+            WLAN_OS_REPORT((" whalCtrl_Set_Mem_Regs: write to Phy register addr=0x%x Val=0x%x\n\n", pCmd->addr, aWriteVal));
+            break;
+    
+        default:
+            WLAN_OS_REPORT((" whalCtrl_Print_Mem_Regs: ERROR, wrong memory type 0x%x\n\n", memType));
+            return NOK;
+    }
+    
+    os_memoryCopy (pWhalCtrl->hOs, (void *)pCmd->value, (void *)&aWriteVal, pCmd->size);
+
+    return (CmdQueue_Command(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, CMD_WRITE_MEMORY, (char *)pCmd, sizeof(*pCmd)));
+}
+
+                          
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalParams.c b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalParams.c
new file mode 100644 (file)
index 0000000..92685ff
--- /dev/null
@@ -0,0 +1,1579 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalParams.c
+ *   PURPOSE: Holds all the whal parameters
+ * 
+ ****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "802_11Defs.h"
+#include "whalParams.h"
+#include "whalBus_Api.h"
+
+/******************************* definitions ********************************/
+#define HW_MODULATION_PBCC     0x80
+#define HW_MODULATION_OFDM     0x40 
+
+/*
+ * Internals
+ */
+void whal_ParamsInitDmaParams   (WhalParams_T *pWhalParams);
+int  whal_ParamsInitWlanParams  (WhalParams_T *pWhalParams);
+int  whal_ParamsInitBssInfoParams(WhalParams_T *pWhalParams, BOOL TxFlashEnable);
+int  whal_ParamsInitGenParams   (WhalParams_T *pWhalParams);
+int  whal_ParamsInitHwInfoParams (WhalParams_T *pWhalParams);
+int  whal_ParamsInitGenCounters         (WhalParams_T *pWhalParams);
+void whal_ParamsSetQidToAcTable  (WhalParams_T *pWhalParams,UINT8 Qid,UINT8 AcId);
+
+/****************************************************************************
+ *                      whal_params_Create()
+ ****************************************************************************
+ * DESCRIPTION:        Create the whal parameters(data base) object
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The Created object
+ ****************************************************************************/
+WhalParams_T *whal_params_Create(TI_HANDLE hOs, BOOL TxFlashEnable)
+{
+       WhalParams_T *pObj;
+
+       pObj = os_memoryAlloc(hOs, sizeof(WhalParams_T));
+       if (pObj == NULL)
+               return NULL;
+
+       os_memoryZero(hOs, (void *)pObj, sizeof(WhalParams_T));
+
+       pObj->hOs = hOs;
+
+       whal_ParamsInitDmaParams(pObj);
+       whal_ParamsInitGenParams(pObj);
+       whal_ParamsInitBssInfoParams(pObj,TxFlashEnable);
+       whal_ParamsInitWlanParams(pObj);
+       whal_ParamsInitGenCounters(pObj);
+
+       return(pObj);
+}
+
+/****************************************************************************
+ *                      whal_params_Destroy()
+ ****************************************************************************
+ * DESCRIPTION:        Destroy the object 
+ * 
+ * INPUTS:     
+ *             WhalParams_T            The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_params_Destroy(WhalParams_T *pWhalParams)
+{
+       if (pWhalParams)
+               os_memoryFree(pWhalParams->hOs, pWhalParams, sizeof(WhalParams_T));
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_params_Config()
+ ****************************************************************************
+ * DESCRIPTION:        Config the object 
+ * 
+ * INPUTS:     
+ *             pWhalParams             The object
+ *             hReport                 The reports objects
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_params_Config(WhalParams_T *pWhalParams, TI_HANDLE hReport)
+{
+       pWhalParams->hReport = hReport;
+       return OK;
+}
+
+/*
+ * -------------------------------------------------------------------------- 
+ *                     DmaParams_T - Rx/Tx Queues and Bufs params
+ * -------------------------------------------------------------------------- 
+ */
+/* defaults for large queue size */
+#define DEFAULT_UCAST_PRIORITY         0
+#define DEFAULT_RX_Q_PRIORITY          0
+
+#define DEFAULT_NUM_STATIONS           1
+#define DEFAULT_RXQ_PRIORITY           0               /* low 0 .. 15 high  */
+#define DEFAULT_RXQ_TYPE                       0x07    /* All frames, Data/Ctrl/Mgmt -- not documented well */
+
+/* only for AP */
+#define DEFAULT_NUM_BCAST_TX_DESC              16  /*  8 increase number of BC frames */
+#define DEFAULT_BCAST_PRIORITY         0x81
+
+/****************************************************************************
+ *                      whal_ParamsInitDmaParams()
+ ****************************************************************************
+ * DESCRIPTION:        Initiate DmaParams to the default values
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+void whal_ParamsInitDmaParams(WhalParams_T *pWhalParams)
+{
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetDmaParams()
+ ****************************************************************************
+ * DESCRIPTION:        return DmaParams pointer
+ ****************************************************************************/
+DmaParams_T *whal_ParamsGetDmaParams(WhalParams_T *pWhalParams) 
+{      
+       return (&pWhalParams->DmaParams); 
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetDmaParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new DmaParams
+ ****************************************************************************/
+int whal_ParamsSetDmaParams(WhalParams_T *pWhalParams) 
+{      
+       DmaParams_T *pDmaParams = whal_ParamsGetDmaParams(pWhalParams);
+       int i;
+
+       /* Initialize the Params object database fields*/
+       pDmaParams->rxMemBlkNumber              = 35;                                                   /*pInitParams->rxMemBlkNumber;*/
+       pDmaParams->txMinMemBlkNumber   = 64;                                                   /*pInitParams->txMinMemBlkNumber;*/
+       pDmaParams->BlockSize                   = HAL_CTRL_ACX_BLOCK_SIZE_DEF;  /*pInitParams->blockSize;*/
+       pDmaParams->NumRxQueues                 = 1;
+       pDmaParams->NumTxQueues                 = MAX_NUM_OF_TX_QUEUES;                 /*pInitParams->numTxQueues;*/
+       pDmaParams->RxNumDesc                   = HAL_CTRL_ACX_RX_DESC_DEF;             /*pInitParams->rxDescNum;*/
+       /* TRACE_BUFFER_MAX_SIZE is UINT32 so multiply by 4 to have the actual length */
+       pDmaParams->TraceBufferSize             = (TRACE_BUFFER_MAX_SIZE * 4);  /*pInitParams->TraceBufferSize;*/
+    pDmaParams->TraceBufferDoPrint     = FALSE;                                                /*pInitParams->bDoPrint;*/
+
+       if ((pDmaParams->NumTxQueues > MAX_NUM_OF_TX_QUEUES) || (pDmaParams->NumTxQueues < 1) )
+       {
+               WLAN_REPORT_REPLY(pWhalParams->hReport, HAL_HW_CTRL_MODULE_LOG,
+                       ("\nwhal_ParamsSetDmaParams: numTxQueues is invalid, setting it to 1. numTxQueues=%d\n",pDmaParams->NumTxQueues ));
+               pDmaParams->NumTxQueues = 1;
+       }
+       
+       for (i=0;i<pDmaParams->NumTxQueues;i++)
+       {
+               pDmaParams->TxNumDesc[i]        = HAL_CTRL_ACX_TX_DESC_DEF;             /*pInitParams->tx_attrib_queue[i].numDesc;*/
+               pDmaParams->TxQPriority[i]      = i;                                                    /*pInitParams->tx_attrib_queue[i].priority;             */
+       }
+
+       /* default values */
+       pDmaParams->RxQPriority                 = DEFAULT_RX_Q_PRIORITY;
+       pDmaParams->NumStations                 = DEFAULT_NUM_STATIONS;
+       pDmaParams->RxQueue_Priority    = DEFAULT_RXQ_PRIORITY;
+       pDmaParams->RxQueue_Type                = DEFAULT_RXQ_TYPE;
+
+       /* only for AP */
+#ifdef CONFIGURE_BSS_TYPE_AP 
+       pDmaParams->NumTxQueues                 = 2;
+       pDmaParams->TxNumDesc[1]                = DEFAULT_NUM_BCAST_TX_DESC;
+       pDmaParams->TxQPriority[1]              = DEFAULT_BCAST_PRIORITY;
+#endif
+
+       return OK; 
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetRoamingParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new DmaParams
+ ****************************************************************************/
+int whal_ParamsSetRoamingParams(WhalParams_T *pWhalParams) 
+{      
+       
+       pWhalParams->WlanParams.roamTriggers.rssiThreshold              =  RSSI_DEFAULT_THRESHOLD;
+       pWhalParams->WlanParams.roamTriggers.rssiFilterWeight           =  RSSI_DEFAULT_WEIGHT;
+       pWhalParams->WlanParams.roamTriggers.rssiFilterDepth            =  RSSI_DEFAULT_DEPTH;
+       pWhalParams->WlanParams.roamTriggers.lowRSSIEventType   = LOW_RSSI_EVENT_LEVEL;
+
+       pWhalParams->WlanParams.roamTriggers.snrThreshold               = SNR_DEFAULT_THRESHOLD;
+       pWhalParams->WlanParams.roamTriggers.snrFilterWeight            = SNR_DEFAULT_WEIGHT;
+       pWhalParams->WlanParams.roamTriggers.snrFilterDepth             = SNR_DEFAULT_DEPTH;
+       pWhalParams->WlanParams.roamTriggers.lowSNREventType    = LOW_SNR_EVENT_LEVEL;
+
+       pWhalParams->WlanParams.roamTriggers.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
+       pWhalParams->WlanParams.roamTriggers.TsfMissThreshold = OUT_OF_SYNC_DEFAULT_THRESHOLD;
+       
+       return OK; 
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsSetQueueParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new QueueParams
+ ****************************************************************************/
+int whal_ParamsSetQueueParams(WhalParams_T *pWhalParams,queueTrafficParams_t *pQtrafficParams) 
+{      
+       pWhalParams->QueuesParams.isQueueConfigured[pQtrafficParams->queueID] = TRUE;
+       os_memoryCopy(pWhalParams->hOs,(void *)&(pWhalParams->QueuesParams.queues[pQtrafficParams->queueID]),(void *)pQtrafficParams,sizeof(queueTrafficParams_t));
+       
+       return OK;
+}
+/****************************************************************************
+ *                      whal_ParamsSetAcParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new QueueParams
+ ****************************************************************************/
+
+void whal_ParamsSetAcParams(WhalParams_T *pWhalParams,acQosParams_t *pAcQosParams)
+{
+       pWhalParams->AcParams.isAcConfigured[pAcQosParams->ac] = TRUE;
+       os_memoryCopy(pWhalParams->hOs,(void *)&(pWhalParams->AcParams.ac[pAcQosParams->ac]),(void *)pAcQosParams,sizeof(acQosParams_t));
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetTxParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new DmaParams
+ ****************************************************************************/
+TxParam_t *whal_ParamsGetTxParams (WhalParams_T *pWhalParams)
+{
+       return (&pWhalParams->TxParams);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetTrafficParams()
+ ****************************************************************************
+ * DESCRIPTION:        Traffic Parameters :(IE ACX_TID_CFG)
+ ****************************************************************************/
+int whal_ParamsSetTrafficParams(WhalParams_T *pWhalParams,whaCtrl_acTrafficParams_t* pTconfParams) 
+{       
+       os_memoryCopy(pWhalParams->hOs,
+                                 (void *)&(pWhalParams->TxParams.halTrafficParams[pTconfParams->acId]),
+                                 (void *)pTconfParams,sizeof(whaCtrl_acTrafficParams_t));
+       
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetTxRateClassParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new TxRateParams
+ ****************************************************************************/
+void whal_ParamsSetTxRateClassParams(WhalParams_T *pWhalParams,txRatePolicy_t *pTxRatePolicy)
+{
+       UINT8 i;
+       txRateClass_t *pTxRateClass;
+
+       for(i = 0; i < pTxRatePolicy->numOfRateClasses; i++)
+       {
+               pTxRateClass = &pTxRatePolicy->rateClass[i];
+               os_memoryCopy(pWhalParams->hOs,(void *)&(pWhalParams->BssInfoParams.TxRateClassParams.rateClass[i]),(void *)pTxRateClass,sizeof(txRateClass_t));
+       }
+
+       pWhalParams->BssInfoParams.TxRateClassParams.numOfRateClasses = pTxRatePolicy->numOfRateClasses;
+
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetTxRateClassParams()
+ ****************************************************************************
+ * DESCRIPTION:        set new TxRateParams
+ ****************************************************************************/
+txRatePolicy_t* whal_ParamsGetTxRateClassParams(WhalParams_T *pWhalParams)
+{
+    return &pWhalParams->BssInfoParams.TxRateClassParams;
+}
+/****************************************************************************
+ *                      whal_ParamsGetTxParams()
+ ****************************************************************************
+ *     Traffic Parameters :(IE ACX_TID_CFG)
+ ****************************************************************************/
+whaCtrl_acTrafficParams_t* whal_ParamsGetTrafficParams(WhalParams_T *pWhalParams,UINT8 AcID) 
+{       
+       return (&pWhalParams->TxParams.halTrafficParams[AcID]);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetAccessCategoryParams()
+ ****************************************************************************
+ * DESCRIPTION:        Access Category Parameters :(IE ACX_AC_CFG)
+ ****************************************************************************/
+int whal_ParamsSetAccessCategoryParams(WhalParams_T *pWhalParams,acQueuesParams_t* pAcQueuesParams) 
+{
+
+       /* Calculate the Qid from the Ac and save in a local table */
+       whal_ParamsSetQidToAcTable(pWhalParams, pAcQueuesParams->qId, pAcQueuesParams->acId);
+
+       os_memoryCopy(pWhalParams->hOs, 
+                                 (void *)&(pWhalParams->TxParams.halAcQueueParams[pAcQueuesParams->qId]),
+                                 (void *)pAcQueuesParams, sizeof(acQueuesParams_t));
+
+       return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsSetAccessCategoryAckPolicy()
+ ****************************************************************************
+ * DESCRIPTION:        set Ac Ack Policy according to Ac ID , No Ack = 0, Ack = 1
+ ****************************************************************************/
+int whal_ParamsSetAccessCategoryAckPolicy(WhalParams_T *pWhalParams, BOOL AckPolicy,UINT8 AcID)
+{      
+       WLAN_REPORT_INFORMATION(pWhalParams->hReport, HAL_HW_CTRL_MODULE_LOG,
+       ("\n whal_ParamsSetAccessCategoryAckPolicy: Set Access Category =%d  to Ack Policy = %d \n", AcID, AckPolicy));
+
+       pWhalParams->TxParams.AckPolicy[AcID] = AckPolicy;
+
+       return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsSetQidToAcTable()
+ ****************************************************************************
+ * DESCRIPTION:        set Qid according to Queue ID
+ ****************************************************************************/
+void whal_ParamsSetQidToAcTable(WhalParams_T *pWhalParams,UINT8 Qid,UINT8 AcId)
+{
+
+       pWhalParams->TxParams.QidToAcTable[Qid] = AcId;
+
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetAcIdFromQid()
+ ****************************************************************************
+ * DESCRIPTION:        Get the Ac Id according to the Queue id 
+ ****************************************************************************/
+UINT8 whal_ParamsGetAcIdFromQid(WhalParams_T *pWhalParams,UINT8 Qid)
+{
+       return (pWhalParams->TxParams.QidToAcTable[Qid]);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetAtimWindow()
+ ****************************************************************************
+ * DESCRIPTION:        return the ATim Window
+ ****************************************************************************/
+UINT16 whal_ParamsGetAtimWindow                (WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->BssInfoParams.ATimWindow);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetAtimWindow()
+ ****************************************************************************
+ * DESCRIPTION:        set the ATim Window
+ ****************************************************************************/
+void whal_ParamsSetAtimWindow(WhalParams_T *pWhalParams, UINT16 ATimWindow)
+{
+       pWhalParams->BssInfoParams.ATimWindow = ATimWindow;
+}
+
+/* 
+ * -------------------------------------------------------------------------- 
+ *                                                     Bss Info params
+ * -------------------------------------------------------------------------- 
+ */
+
+#define DEFAULT_HW_GEN_PREAMBLE_TYPE   CCK_LONG        /* Long Preamble */
+#define DEFAULT_HW_GEN_TX_RATE                 RATE_2MBPS  
+#define DEFAULT_HW_GEN_TX_RATE_DRIVER_FORMAT   DRV_RATE_2M
+
+int genMacCopy(char *Mac2, char *Mac1)
+{
+       register int MacSize=6;
+
+       while(MacSize--)
+               *Mac2++ = *Mac1++;
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_ParamsInitBssInfoParams()
+ ****************************************************************************
+ * DESCRIPTION:        Initiate BssInfo to the default values
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    
+ ****************************************************************************/
+int whal_ParamsInitBssInfoParams(WhalParams_T *pWhalParams, BOOL TxFlashEnable)
+{
+       BssInfoParams_T *pBssInfoParams = &pWhalParams->BssInfoParams;
+
+
+       pBssInfoParams->txCtrlFrmRateDriverFormat = DEFAULT_HW_GEN_TX_RATE_DRIVER_FORMAT;
+       pBssInfoParams->txCtrlFrmModulation = DEFAULT_HW_GEN_PREAMBLE_TYPE;
+       pBssInfoParams->txCtrlFrmRate           = DEFAULT_HW_GEN_TX_RATE;
+
+       pBssInfoParams->txMgmtFrmModulation = DEFAULT_HW_GEN_PREAMBLE_TYPE;
+       pBssInfoParams->txMgmtFrmRate           = DEFAULT_HW_GEN_TX_RATE;
+
+       pBssInfoParams->RadioChannel = DEFAULT_HW_RADIO_CHANNEL;
+       pBssInfoParams->Ctrl = 0;
+
+       /* Intilaize the ctrl field in the BSS join structure */
+       /* Only bit_7 in the ctrl field is vurrently in use.
+         If bit_7 is on => Doing Tx flash before joining new AP */
+       if(TxFlashEnable)
+               pBssInfoParams->Ctrl |= JOIN_CMD_CTRL_TX_FLUSH;
+       
+       return OK;
+}
+  
+/****************************************************************************
+ *                      whal_ParamsGetBssInfoParams()
+ ****************************************************************************
+ * DESCRIPTION:        return pointer to the BssInfo params
+ ****************************************************************************/
+BssInfoParams_T *whal_ParamsGetBssInfoParams(WhalParams_T *pWhalParams)
+{
+       return (&pWhalParams->BssInfoParams);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetRadioChannel()
+ ****************************************************************************
+ * DESCRIPTION:        return the radio channel 
+ ****************************************************************************/
+UINT8 whal_ParamsGetRadioChannel(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->BssInfoParams.RadioChannel);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetRadioChannel()
+ ****************************************************************************
+ * DESCRIPTION:        set the radio channel 
+ ****************************************************************************/
+void whal_ParamsSetRadioChannel(WhalParams_T *pWhalParams, int Channel)
+{
+       pWhalParams->BssInfoParams.RadioChannel = (UINT8)Channel;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetDefaultChannel()
+ ****************************************************************************
+ * DESCRIPTION:        return the default channel to start from 
+ ****************************************************************************/
+UINT8 whal_ParamsGetDefaultChannel(WhalParams_T *pWhalParams)
+{
+       WlanParams_T *pWlanParams = &pWhalParams->WlanParams;
+
+       if (RADIO_BAND_5_0_GHZ == pWlanParams->RadioBand)
+       {
+               return pWlanParams->calibrationChannel5_0;
+       }
+       else
+       {
+               return pWlanParams->calibrationChannel2_4;
+       }
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetReqBssType()
+ ****************************************************************************
+ * DESCRIPTION:        set the bss type (driver enum)
+ ****************************************************************************/
+void whal_ParamsSetReqBssType(WhalParams_T *pWhalParams, int Val)
+{
+       pWhalParams->BssInfoParams.ReqBssType = Val;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetReqBssType()
+ ****************************************************************************
+ * DESCRIPTION:        get the bss type (driver enum)
+ ****************************************************************************/
+UINT8 whal_ParamsGetReqBssType(WhalParams_T *pWhalParams)
+{
+       return pWhalParams->BssInfoParams.ReqBssType;
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetBssType()
+ ****************************************************************************
+ * DESCRIPTION:        set the bss type (public enum)
+ ****************************************************************************/
+void whal_ParamsSetBssType(WhalParams_T *pWhalParams, int Val)
+{
+       pWhalParams->BssInfoParams.BssType = Val;
+}
+/****************************************************************************
+ *                      whal_ParamsSetRadioBand()
+ ****************************************************************************
+ * DESCRIPTION:        set the radio band 
+ ****************************************************************************/
+void whal_ParamsSetRadioBand(WhalParams_T *pWhalParams, int RadioBand)
+{
+       pWhalParams->WlanParams.RadioBand = (UINT8)RadioBand;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetRadioBand()
+ ****************************************************************************
+ * DESCRIPTION:        get the radio band
+ ****************************************************************************/
+UINT8  whal_ParamsGetRadioBand(WhalParams_T *pWhalParams)
+{
+               return (pWhalParams->WlanParams.RadioBand);
+}
+
+ /****************************************************************************
+ *                      whal_ParamsSetPowerSaveState()
+ ****************************************************************************
+ * DESCRIPTION:        set the power save state 
+ ****************************************************************************/
+void whal_ParamsSetPowerSaveState(WhalParams_T *pWhalParams, UINT8 CurrPowerSaveState)
+{
+       pWhalParams->WlanParams.CurrPowerSaveState = (UINT8)CurrPowerSaveState;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetPowerSaveState()
+ ****************************************************************************
+ * DESCRIPTION:        get the power save state 
+ ****************************************************************************/
+UINT8  whal_ParamsGetPowerSaveState(WhalParams_T *pWhalParams)
+{
+               return (pWhalParams->WlanParams.CurrPowerSaveState);
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsGetBssType()
+ ****************************************************************************
+ * DESCRIPTION:        return the bss type 
+ ****************************************************************************/
+UINT8 whal_ParamsGetBssType(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->BssInfoParams.BssType);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetBeaconInterval()
+ ****************************************************************************
+ * DESCRIPTION:        set the beacon interval 
+ ****************************************************************************/
+void whal_ParamsSetBeaconInterval(WhalParams_T *pWhalParams, UINT16 Val)
+{
+       pWhalParams->BssInfoParams.BeaconInterval = Val;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetBeaconInterval()
+ ****************************************************************************
+ * DESCRIPTION:        return the beacon interval
+ ****************************************************************************/
+UINT16 whal_ParamsGetBeaconInterval(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->BssInfoParams.BeaconInterval);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetDtimCount()
+ ****************************************************************************
+ * DESCRIPTION:        set the dtim count interval 
+ ****************************************************************************/
+void whal_ParamsSetDtimCount(WhalParams_T *pWhalParams, UINT8 Val)
+{
+       pWhalParams->BssInfoParams.DtimInterval = Val;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetDtimCount()
+ ****************************************************************************
+ * DESCRIPTION:        return the Dtim count interval
+ ****************************************************************************/
+UINT8 whal_ParamsGetDtimCount(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->BssInfoParams.DtimInterval);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetBssId()
+ ****************************************************************************
+ * DESCRIPTION:        return the Bss Id
+ ****************************************************************************/
+UINT8 *whal_ParamsGetBssId(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->BssInfoParams.BssId);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetBssId()
+ ****************************************************************************
+ * DESCRIPTION:        set the Bss Id
+ ****************************************************************************/
+void whal_ParamsSetBssId(WhalParams_T *pWhalParams, char *BssId)
+{
+    genMacCopy((char *)pWhalParams->BssInfoParams.BssId, BssId);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetElm_Ssid()
+ ****************************************************************************
+ * DESCRIPTION:        return the SSID info element
+ ****************************************************************************/
+dot11_SSID_t  *whal_ParamsGetElm_Ssid(WhalParams_T *pWhalParams)
+{
+       return (&pWhalParams->BssInfoParams.WlanElm_Ssid);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetSsid()
+ ****************************************************************************
+ * DESCRIPTION:        set the SSID
+ ****************************************************************************/
+void whal_ParamsSetSsid(WhalParams_T *pWhalParams, char *InputSsid, UINT8 SsidLength)
+{
+       BssInfoParams_T *pBssInfoParams = &pWhalParams->BssInfoParams;
+
+       pBssInfoParams->WlanElm_Ssid.hdr.eleLen = SsidLength;
+       os_memoryZero(pWhalParams->hOs, (void *)pBssInfoParams->WlanElm_Ssid.serviceSetId, 
+                                 sizeof(pBssInfoParams->WlanElm_Ssid.serviceSetId));
+       os_memoryCopy(pWhalParams->hOs, (void *)pBssInfoParams->WlanElm_Ssid.serviceSetId, (void *)InputSsid, SsidLength);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetBasicRates()
+ ****************************************************************************
+ * DESCRIPTION:        set the basic rate set
+ ****************************************************************************/
+void whal_ParamsSetBasicRatesSet(WhalParams_T *pWhalParams, UINT16 BasicRateSet)
+{    
+       pWhalParams->BssInfoParams.BasicRateSet = BasicRateSet;
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetHwGenTxParams()
+ ****************************************************************************
+ * DESCRIPTION:        set the hardware and firmware generated Tx rate (convert to HW coding).
+ *
+ ****************************************************************************/
+void whal_ParamsSetHwGenTxParams(WhalParams_T *pWhalParams, rate_e TxRate, BOOL bCtrlFrame)
+{ 
+       /* Set The Rate & modulation for CTS, RTS, and PS-Poll frames (not including CTS-protection). */
+       if (bCtrlFrame)
+       {
+           pWhalParams->BssInfoParams.txCtrlFrmRateDriverFormat = TxRate;
+           whalUtils_ConvertAppRate(TxRate,  &pWhalParams->BssInfoParams.txCtrlFrmRate);
+           whalUtils_FindHwModulationByDrvRate(TxRate, &pWhalParams->BssInfoParams.txCtrlFrmModulation, pWhalParams->WlanParams.preamble); 
+       }
+       /* Set The Rate & modulation for Beacon and Probe-Response frames (IBSS). */
+       else
+       {
+               whalUtils_ConvertAppRate(TxRate, &pWhalParams->BssInfoParams.txMgmtFrmRate);
+               whalUtils_FindHwModulationByDrvRate(TxRate, &pWhalParams->BssInfoParams.txMgmtFrmModulation, pWhalParams->WlanParams.preamble);
+       }
+}
+/****************************************************************************
+ *                      whal_ParamsSetBasicRates()
+ ****************************************************************************
+ * DESCRIPTION:        set the basic rate set
+ ****************************************************************************/
+void whal_ParamsSetSupportedRatesSet(WhalParams_T *pWhalParams, UINT16 SupportedRateSet)
+{
+       pWhalParams->BssInfoParams.SupportedRateSet = SupportedRateSet;
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsGetMacPreambleParams()
+ ****************************************************************************
+ * DESCRIPTION:        return pointer to the Mac Preamble Params
+ ****************************************************************************/
+void   whal_ParamsGetMacPreambleParams(WhalParams_T *pWhalParams, UINT8* earlyWakeUp)
+{      
+    *earlyWakeUp = pWhalParams->WlanParams.earlyWakeUp;
+}
+
+
+/* 
+ * -------------------------------------------------------------------------- 
+ *                                                     wlan params
+ * -------------------------------------------------------------------------- 
+ */
+
+#define DEFAULT_CW_MIN 15
+#define DEFAULT_USE_DEVICE_ERROR_INTERRUPT     1
+
+/****************************************************************************
+ *                      whal_ParamsInitWlanParams()
+ ****************************************************************************
+ * DESCRIPTION:        Initiate GenParams to the default values
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    
+ ****************************************************************************/
+int whal_ParamsInitWlanParams(WhalParams_T *pWhalParams)
+{
+       WlanParams_T *pWlanParams = &pWhalParams->WlanParams;
+
+       /* 
+        * init filters as station (start/join with BssType will overwrite the values)
+        */
+       whal_ParamsSetRxFilter(pWhalParams, RX_CONFIG_OPTION_MY_DST_MY_BSS, RX_FILTER_OPTION_FILTER_ALL);
+
+       pWlanParams->UseDeviceErrorInterrupt = DEFAULT_USE_DEVICE_ERROR_INTERRUPT;
+       
+       /*
+        * All other params are zero and will be set externally on the Create/Config phase
+        */
+
+       return OK;
+}                                                               
+
+/****************************************************************************
+ *                      whal_ParamsGetWlanParams()
+ ****************************************************************************
+ * DESCRIPTION:        return pointer to the GenParams
+ ****************************************************************************/
+WlanParams_T *whal_ParamsGetWlanParams(WhalParams_T *pWhalParams)
+{
+       return (&pWhalParams->WlanParams);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetFragmentThreshold()
+ ****************************************************************************
+ * DESCRIPTION:        set the fragmentation threshold 
+ ****************************************************************************/
+void whal_ParamsSetFragmentThreshold(WhalParams_T *pWhalParams, int FragSize)
+{
+       pWhalParams->WlanParams.FragmentThreshold = FragSize;
+}
+
+/****************************************************************************
+ *                      whal_ParamsPrintFragmentThreshold()
+ ****************************************************************************
+ * DESCRIPTION:        print the fragmentation threshold 
+ ****************************************************************************/
+void whal_ParamsPrintFragmentThreshold(WhalParams_T *pWhalParams)
+{
+       WLAN_REPORT_REPLY(pWhalParams->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("\n FragmentThreshold = %d\n", pWhalParams->WlanParams.FragmentThreshold));
+}
+
+/****************************************************************************
+ *                      whal_ParamsPrintFragmentThreshold()
+ ****************************************************************************
+ * DESCRIPTION:        print the fragmentation threshold 
+ ****************************************************************************/
+UINT8 whal_ParamsIsFragmentOnHal(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->WlanParams.FragmentationOnHal);
+}
+/****************************************************************************
+ *                      whal_ParamsGetFragmentThreshold()
+ ****************************************************************************
+ * DESCRIPTION:        return the fragmentation threshold
+ ****************************************************************************/
+UINT32 whal_ParamsGetFragmentThreshold(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->WlanParams.FragmentThreshold);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetFragmentThreshold()
+ ****************************************************************************
+ * DESCRIPTION:        return the fragmentation threshold
+ ****************************************************************************/
+UINT8 whal_ParamsGetMaxSitesFragCollect(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->WlanParams.maxSitesFragCollect);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetRtsThreshold()
+ ****************************************************************************
+ * DESCRIPTION:        set the rts threshold 
+ ****************************************************************************/
+void whal_ParamsSetRtsThreshold(WhalParams_T *pWhalParams, int RtsSize)
+{
+       pWhalParams->WlanParams.RtsThreshold = RtsSize;
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetListenInterval()
+ ****************************************************************************
+ * DESCRIPTION:        set the Listen Interval 
+ ****************************************************************************/
+void whal_ParamsSetListenInterval(WhalParams_T *pWhalParams, UINT8 Val)
+{
+       pWhalParams->WlanParams.ListenInterval = Val;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetListenInterval()
+ ****************************************************************************
+ * DESCRIPTION:        get the Listen Interval
+ ****************************************************************************/
+UINT8 whal_ParamsGetListenInterval(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->WlanParams.ListenInterval);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetRxFilter()
+ ****************************************************************************
+ * DESCRIPTION:        set the wlan hardware filters
+ ****************************************************************************/
+void whal_ParamsSetRxFilter(WhalParams_T *pWhalParams, UINT32 RxConfigOption, UINT32 RxFilterOption)
+{
+       pWhalParams->WlanParams.RxConfigOption = RxConfigOption;
+       pWhalParams->WlanParams.RxFilterOption = RxFilterOption;
+
+       pWhalParams->WlanParams.RxConfigOption |= RX_CFG_ENABLE_PHY_HEADER_PLCP;
+
+#if defined (TNETW_MASTER_MODE) || defined (TNETW_USB_MODE)
+       pWhalParams->WlanParams.RxConfigOption |= RX_CFG_COPY_RX_STATUS;
+#endif 
+
+       if(pWhalParams->WlanParams.RxDisableBroadcast)
+               pWhalParams->WlanParams.RxConfigOption |= RX_CFG_DISABLE_BCAST;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetRxFilter()
+ ****************************************************************************
+ * DESCRIPTION:        Get the wlan hardware filters
+ ****************************************************************************/
+void whal_ParamsGetRxFilter(WhalParams_T *pWhalParams, UINT32* pRxConfigOption, UINT32* pRxFilterOption)
+{
+       *pRxConfigOption = pWhalParams->WlanParams.RxConfigOption;
+       *pRxFilterOption = pWhalParams->WlanParams.RxFilterOption;
+}
+
+
+/****************************************************************************
+*                      whal_ParamsSetarpIpAddressesTable()
+****************************************************************************
+* DESCRIPTION: set the wlan hardware filters
+****************************************************************************/
+void whal_ParamsSetarpIpAddressesTable(WhalParams_T * pWhalParams, IpAddress_t * IP_addr, IPver_e IP_ver)
+{    
+    pWhalParams->WlanParams.arp_IP_ver = IP_ver;
+
+    if (IP_ver == IP_VER_4) 
+    {
+        os_memoryCopy(pWhalParams->hOs,  (PVOID)pWhalParams->WlanParams.arp_IP_addr.addr,  (PVOID)IP_addr, IP_V4_ADDR_LEN);
+    }
+    else /* IP_VER_6*/
+    {
+        os_memoryCopy(pWhalParams->hOs,  (PVOID)pWhalParams->WlanParams.arp_IP_addr.addr,  (PVOID)IP_addr, IP_V6_ADDR_LEN);
+    }
+}
+
+/****************************************************************************
+*                      whal_ParamsGetarpIpAddressesTable()
+****************************************************************************
+* DESCRIPTION: get the wlan hardware filters
+****************************************************************************/
+void whal_ParamsGetarpIpAddressesTable(WhalParams_T * pWhalParams, IpAddress_t * IP_addr, IPver_e* pIP_ver)
+{
+    
+    *pIP_ver = (IPver_e)pWhalParams->WlanParams.arp_IP_ver;
+
+    if (*pIP_ver == IP_VER_4) 
+    {
+        os_memoryCopy(pWhalParams->hOs,  (PVOID)IP_addr,  (PVOID)pWhalParams->WlanParams.arp_IP_addr.addr, IP_V4_ADDR_LEN);
+    }
+    else /* IP_VER_6*/
+    {
+        os_memoryCopy(pWhalParams->hOs,  (PVOID)IP_addr,  (PVOID)pWhalParams->WlanParams.arp_IP_addr.addr, IP_V6_ADDR_LEN);
+    }
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsSetarpIpFilterEnabled()
+ ****************************************************************************
+ * DESCRIPTION:        set the wlan hardware filters
+ ****************************************************************************/
+void whal_ParamsSetarpIpFilterEnabled(WhalParams_T * pWhalParams, UINT8 isEnabled)
+{
+       if ( NULL != pWhalParams )
+       {
+               pWhalParams->WlanParams.isArpIpFilteringEnabled = isEnabled;
+       }
+
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetarpIpFilterEnabled()
+ ****************************************************************************
+ * DESCRIPTION:        set the wlan hardware filters
+ ****************************************************************************/
+void whal_ParamsGetarpIpFilterEnabled(WhalParams_T * pWhalParams, UINT8* pisEnabled)
+{
+       if ( NULL != pWhalParams )
+       {
+               *pisEnabled = pWhalParams->WlanParams.isArpIpFilteringEnabled;
+       }
+}
+
+/****************************************************************************
+*                      whal_ParamsSetGroupAddressesTable()
+****************************************************************************
+* DESCRIPTION: set the Group addr table
+****************************************************************************/
+void whal_ParamsSetGroupAddressesTable(WhalParams_T *pWhalParams, UINT8 isEnabled, UINT8 numGroupAddrs, macAddress_t *Group_addr)
+{
+       int i;
+       
+       pWhalParams->WlanParams.numGroupAddrs = numGroupAddrs;
+    pWhalParams->WlanParams.isMacAddrFilteringnabled = isEnabled;
+       
+       for ( i=0 ; i < numGroupAddrs; i++) 
+       {
+               os_memoryCopy(pWhalParams->hOs, (PVOID)&(pWhalParams->WlanParams.Group_addr[i]), (PVOID)&(Group_addr->addr[MAC_ADDR_SIZE*i]), MAC_ADDR_SIZE);
+       }
+
+}
+
+/****************************************************************************
+*                      whal_ParamsGetGroupAddressesTable()
+****************************************************************************
+* DESCRIPTION: get the Group addr table
+****************************************************************************/
+void   whal_ParamsGetGroupAddressesTable(WhalParams_T *pWhalParams, UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr)
+{
+       int i;
+       
+       *pnumGroupAddrs = pWhalParams->WlanParams.numGroupAddrs;
+    *pisEnabled = pWhalParams->WlanParams.isMacAddrFilteringnabled;
+
+       os_memoryZero(pWhalParams->hOs, Group_addr, sizeof(Group_addr));
+       for (i=0 ; i < *pnumGroupAddrs; i++) 
+       {
+               os_memoryCopy(pWhalParams->hOs, (void *)&(Group_addr->addr[MAC_ADDR_SIZE*i]), &pWhalParams->WlanParams.Group_addr[i], MAC_ADDR_SIZE);
+       }
+
+}
+
+
+/****************************************************************************
+ *                      whal_ParamsGetCurrAntenna()
+ ****************************************************************************
+ * DESCRIPTION:        get the current antenna setting
+ ****************************************************************************/
+UINT8 whal_ParamsGetCurrAntenna(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->WlanParams.CurrAntenna);
+}
+
+/* 
+ * -------------------------------------------------------------------------- 
+ *                                                     General params
+ * -------------------------------------------------------------------------- 
+ */
+
+#define DEFAULT_TRACE_ENABLE                   0
+#define DEFAULT_TRACE_OUT                              0
+
+#define DEFAULT_PBCC_DYNAMIC_ENABLE_VAL                0
+#define DEFAULT_PBCC_DYNAMIC_INTERVAL          500     /* ticks */
+#define DEFAULT_PBCC_DYNAMIC_IGNORE_MCAST      0
+
+/****************************************************************************
+ *                      whal_ParamsInitGenParams()
+ ****************************************************************************
+ * DESCRIPTION:        Initiate GenParams to the default values
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    
+ ****************************************************************************/
+int whal_ParamsInitGenParams(WhalParams_T *pWhalParams)
+{
+       GenParams_T *pGenParams = &pWhalParams->GenParams;
+
+       whal_ParamsSetPbccDynamicEnableVal(pWhalParams, DEFAULT_PBCC_DYNAMIC_ENABLE_VAL);
+       pGenParams->PbccDynamicInterval = DEFAULT_PBCC_DYNAMIC_INTERVAL;
+       pGenParams->PbccDynamicIgnoreMcast      = DEFAULT_PBCC_DYNAMIC_IGNORE_MCAST;
+
+
+       pGenParams->TraceEnable                 = DEFAULT_TRACE_ENABLE;
+       pGenParams->TraceOut                    = DEFAULT_TRACE_OUT;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_ParamsInitGenCounters()
+ ****************************************************************************
+ * DESCRIPTION:        Initiate GenCounters to the default values
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    
+ ****************************************************************************/
+int whal_ParamsInitGenCounters(WhalParams_T *pWhalParams)
+{
+       GenCounters_T *pGenCounters = &pWhalParams->GenCounters;
+                                                                                         
+       pGenCounters->FcsErrCnt = 0;
+
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetGenParams()
+ ****************************************************************************
+ * DESCRIPTION:        return pointer to the GenParams
+ ****************************************************************************/
+GenParams_T *whal_ParamsGetGenParams(WhalParams_T *pWhalParams)
+{
+       return (&pWhalParams->GenParams);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetPbccDynamicEnableVal()
+ ****************************************************************************
+ * DESCRIPTION:        return the use of Dynamic pbcc enable 
+ ****************************************************************************/
+UINT32 whal_ParamsGetPbccDynamicEnableVal(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->GenParams.PbccDynamicEnable);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetPbccDynamic()
+ ****************************************************************************
+ * DESCRIPTION:        set the use of Dynamic pbcc enable 
+ ****************************************************************************/
+void whal_ParamsSetPbccDynamicEnableVal(WhalParams_T *pWhalParams, int EnableVal)
+{
+       pWhalParams->GenParams.PbccDynamicEnable = EnableVal;
+
+       if (EnableVal)
+               whal_ParamsSetRxFilter(pWhalParams, (UINT16)RX_CONFIG_OPTION_ANY_DST_ANY_BSS, (UINT16)RX_FILTER_OPTION_DEF);
+       else
+               whal_ParamsSetRxFilter(pWhalParams, (UINT16)RX_CONFIG_OPTION_ANY_DST_MY_BSS, (UINT16)RX_FILTER_OPTION_DEF);
+}
+
+/*
+ * -------------------------------------------------------------------------- 
+ *                                                     Wlan hardware Info params
+ * -------------------------------------------------------------------------- 
+ */
+
+/****************************************************************************
+ *                      whal_ParamsInitHwInfoParams()
+ ****************************************************************************
+ * DESCRIPTION:        Initiate Hw info params
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    
+ ****************************************************************************/
+int whal_ParamsInitHwInfoParams(WhalParams_T *pWhalParams)
+{
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetSrcMac()
+ ****************************************************************************
+ * DESCRIPTION:        return the AP mac address
+ ****************************************************************************/
+UINT8 *whal_ParamsGetSrcMac(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->HwInfoParams.SrcMacAddr);
+}
+
+/****************************************************************************
+ *                      whal_ParamsSetSrcMac()
+ ****************************************************************************
+ * DESCRIPTION:        set the SrcMac
+ ****************************************************************************/
+void whal_ParamsSetSrcMac(WhalParams_T *pWhalParams, char *SrcMac)
+{
+       genMacCopy((char *)pWhalParams->HwInfoParams.SrcMacAddr, SrcMac);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetRadioType()
+ ****************************************************************************
+ * DESCRIPTION:        return the Radio type from the ConfigOptions
+ ****************************************************************************/
+char whal_ParamsGetRadioType(WhalParams_T *pWhalParams)
+{
+       return (pWhalParams->WlanParams.radioType);
+}
+
+/****************************************************************************
+ *                      whal_ParamsHwNvramPrint()
+ ****************************************************************************
+ * DESCRIPTION:        Print ConfigOptions
+ ****************************************************************************/
+void whal_ParamsHwNvramPrint(WhalParams_T *pWhalParams)
+{
+ /* for future use */
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetAcxVersion()
+ ****************************************************************************
+ * DESCRIPTION:        return wlan hardware/software version
+ ****************************************************************************/
+ACXRevision_t *whal_ParamsGetAcxVersion(WhalParams_T *pWhalParams)
+{
+       return (&pWhalParams->HwInfoParams.AcxVersion);
+}
+
+/****************************************************************************
+ *                      whal_ParamsGetFwVersion()
+ ****************************************************************************
+ * DESCRIPTION:        return wlan firmware version
+ ****************************************************************************/
+UINT8 *whal_ParamsGetFwVersion(WhalParams_T *pWhalParams)
+{
+    return (UINT8 *)(pWhalParams->HwInfoParams.AcxVersion.FWVersion);
+}
+
+/****************************************************************************
+ *                      whal_ParamsPrintFwVersion()
+ ****************************************************************************
+ * DESCRIPTION:        print the fw version
+ ****************************************************************************/
+void whal_ParamsPrintFwVersion(WhalParams_T *pWhalParams)
+{      
+#ifdef TI_DBG
+       UINT8 *StaId = whal_ParamsGetSrcMac(pWhalParams);
+
+    WLAN_REPORT_INIT (pWhalParams->hReport, 
+                      HAL_HW_CTRL_MODULE_LOG, 
+                      ("Firmware version: %s\n", 
+                      pWhalParams->HwInfoParams.AcxVersion.FWVersion));
+    WLAN_REPORT_INIT (pWhalParams->hReport, 
+                      HAL_HW_CTRL_MODULE_LOG, 
+                      ("Station Id: %02X-%02X-%02X-%02X-%02X-%02X\n", 
+                      StaId[0], StaId[1], StaId[2], StaId[3], StaId[4], StaId[5]));
+#endif /* TI_DBG */
+}
+    
+/****************************************************************************
+ *                      whal_ParamsGetTraceBufferSize()
+ ****************************************************************************
+ * DESCRIPTION:        get trace buffer size
+ ****************************************************************************/
+UINT32 whal_ParamsGetTraceBufferSize(WhalParams_T *pWhalParams)
+{
+       return pWhalParams->DmaParams.TraceBufferSize;
+}
+/*
+ * -------------------------------------------------------------------------- 
+ *                                                     Convert functions
+ * -------------------------------------------------------------------------- 
+ */
+
+int whalUtils_ConvertHwRate(UINT8 HwRate, UINT8 HwModulation, rate_e *AppRate, modulationType_e *AppModulation)
+{
+       rate_e Rate = DRV_RATE_AUTO;
+       modulationType_e Modulation = DRV_MODULATION_NONE;
+       int Stt = OK;
+
+       switch (HwRate)
+       {
+               case RATE_1MBPS:                Rate = DRV_RATE_1M;             Modulation = DRV_MODULATION_QPSK;       break;
+               case RATE_2MBPS:                Rate = DRV_RATE_2M;             Modulation = DRV_MODULATION_QPSK;       break;         
+               case RATE_5_5MBPS:              Rate = DRV_RATE_5_5M;   Modulation = DRV_MODULATION_CCK;        break;
+               case RATE_11MBPS:               Rate = DRV_RATE_11M;    Modulation = DRV_MODULATION_CCK;        break;
+               case RATE_22MBPS:           Rate = DRV_RATE_22M;        Modulation = DRV_MODULATION_PBCC;       break;         
+               case RATE_6MBPS:                Rate = DRV_RATE_6M;             Modulation = DRV_MODULATION_OFDM;       break;
+               case RATE_9MBPS:                Rate = DRV_RATE_9M;             Modulation = DRV_MODULATION_OFDM;       break;
+               case RATE_18MBPS:               Rate = DRV_RATE_18M;    Modulation = DRV_MODULATION_OFDM;       break;
+               case RATE_24MBPS:               Rate = DRV_RATE_24M;    Modulation = DRV_MODULATION_OFDM;       break;
+               case RATE_36MBPS:               Rate = DRV_RATE_36M;    Modulation = DRV_MODULATION_OFDM;       break;
+               case RATE_48MBPS:               Rate = DRV_RATE_48M;    Modulation = DRV_MODULATION_OFDM;       break;
+               case RATE_54MBPS:               Rate = DRV_RATE_54M;    Modulation = DRV_MODULATION_OFDM;       break;
+               default:                                Rate = DRV_RATE_1M;             Modulation = DRV_MODULATION_NONE;
+                       Stt = NOK;
+                       break;
+       }
+  
+       /* patch for 12M (same code as 1M) */
+       if ((HwRate == RATE_12MBPS) && (HwModulation == HW_MODULATION_OFDM))
+       {
+               Rate = DRV_RATE_12M;    Modulation = DRV_MODULATION_OFDM;
+       }
+
+       if (Stt == OK)
+       {
+               *AppRate = Rate;
+               *AppModulation = Modulation;
+       }
+
+       return Stt;
+}
+
+
+int  whalUtils_ConvertAppRate (rate_e AppRate, UINT8 *HwRate)
+{
+       UINT8 Rate = 0;
+       int Stt = OK;
+
+       switch (AppRate)
+       {
+               /*
+                *      The handle for 5.5/11/22 PBCC was removed !!!
+                */
+
+               case DRV_RATE_1M:                       Rate = RATE_1MBPS;                      break;
+               case DRV_RATE_2M:                       Rate = RATE_2MBPS;                      break;
+               case DRV_RATE_5_5M:             Rate = RATE_5_5MBPS;            break;
+               case DRV_RATE_11M:                      Rate = RATE_11MBPS;                     break;
+               case DRV_RATE_22M:                      Rate = RATE_22MBPS;                     break;
+               case DRV_RATE_6M:                       Rate = RATE_6MBPS;                      break;
+               case DRV_RATE_9M:                       Rate = RATE_9MBPS;                      break;
+               case DRV_RATE_12M:                      Rate = RATE_12MBPS;                     break;
+               case DRV_RATE_18M:                      Rate = RATE_18MBPS;                     break;
+               case DRV_RATE_24M:                      Rate = RATE_24MBPS;                     break;
+               case DRV_RATE_36M:                      Rate = RATE_36MBPS;                     break;
+               case DRV_RATE_48M:                      Rate = RATE_48MBPS;                     break;
+               case DRV_RATE_54M:                      Rate = RATE_54MBPS;                     break;
+
+               default:
+            WLAN_OS_REPORT(("%s wrong app rate = %d\n",__FUNCTION__,AppRate));
+                       Stt = NOK;
+                       break;
+       }
+
+       if (Stt == OK)
+               *HwRate = Rate;
+       else
+               *HwRate = RATE_1MBPS; 
+
+       return (Stt);
+}
+
+int  whalUtils_FindHwModulationByDrvRate (rate_e AppRate, UINT8 *HwModu, UINT8 preamble)
+{
+       int Stt = OK;
+
+
+       switch (AppRate)
+       {
+               /*
+                *      The handle for 5.5/11/22 PBCC was removed !!!
+                */
+
+               case DRV_RATE_1M:                       
+            *HwModu = CCK_LONG;                
+            break;
+
+               case DRV_RATE_2M:                                       
+               case DRV_RATE_5_5M:                             
+               case DRV_RATE_11M:                              
+            if (preamble == 0) /* PREAMBLE_LONG*/
+                *HwModu = CCK_LONG;
+            else
+                *HwModu = CCK_SHORT;
+            break;
+
+        case DRV_RATE_22M:                             
+            if (preamble == 0) /* PREAMBLE_LONG*/
+                *HwModu = PBCC_LONG;
+            else
+                *HwModu = PBCC_SHORT;
+            break;
+
+               case DRV_RATE_6M:                       
+               case DRV_RATE_9M:                       
+               case DRV_RATE_12M:                      
+               case DRV_RATE_18M:                      
+               case DRV_RATE_24M:                      
+               case DRV_RATE_36M:                      
+               case DRV_RATE_48M:                      
+               case DRV_RATE_54M:              
+            *HwModu = OFDM;                    
+            break;
+       default:
+            WLAN_OS_REPORT(("%s wrong rate = %d\n",__FUNCTION__,AppRate));
+                       *HwModu = CCK_LONG;
+                       Stt = NOK;
+                       break;
+       }
+
+       return (Stt);
+}
+
+
+
+int whalUtils_ConvertAppRatesBitmap(UINT32 AppRatesBitmap, UINT32 AppModulation, UINT16 *HwRatesBitmap)
+{
+       UINT16 RatesBitmap = 0;
+   
+       if (AppRatesBitmap & DRV_RATE_MASK_1_BARKER)    RatesBitmap |= HW_BIT_RATE_1MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_2_BARKER)    RatesBitmap |= HW_BIT_RATE_2MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_5_5_CCK)             RatesBitmap |= HW_BIT_RATE_5_5MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_11_CCK)              RatesBitmap |= HW_BIT_RATE_11MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_22_PBCC)             RatesBitmap |= HW_BIT_RATE_22MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_6_OFDM)              RatesBitmap |= HW_BIT_RATE_6MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_9_OFDM)              RatesBitmap |= HW_BIT_RATE_9MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_12_OFDM)             RatesBitmap |= HW_BIT_RATE_12MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_18_OFDM)             RatesBitmap |= HW_BIT_RATE_18MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_24_OFDM)             RatesBitmap |= HW_BIT_RATE_24MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_36_OFDM)             RatesBitmap |= HW_BIT_RATE_36MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_48_OFDM)             RatesBitmap |= HW_BIT_RATE_48MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_54_OFDM)             RatesBitmap |= HW_BIT_RATE_54MBPS;
+       
+       *HwRatesBitmap = RatesBitmap;
+
+       return (OK);
+}
+
+int whalUtils_ConvertHwRatesBitmap(UINT8 HwRatesBitmap, UINT8 HwModulation, UINT32 *AppRate, UINT32 *AppModulation)
+{
+       UINT16 RatesBitmap = 0;
+
+       if (HwRatesBitmap & HW_BIT_RATE_1MBPS)                  RatesBitmap |= DRV_RATE_MASK_1_BARKER;
+       if (HwRatesBitmap & HW_BIT_RATE_2MBPS)                  RatesBitmap |= DRV_RATE_MASK_2_BARKER;
+       if (HwRatesBitmap & HW_BIT_RATE_5_5MBPS)                RatesBitmap |= DRV_RATE_MASK_5_5_CCK;
+       if (HwRatesBitmap & HW_BIT_RATE_11MBPS)                 RatesBitmap |= DRV_RATE_MASK_11_CCK;
+       if (HwRatesBitmap & HW_BIT_RATE_22MBPS)                 RatesBitmap |= DRV_RATE_MASK_22_PBCC;
+       if (HwRatesBitmap & HW_BIT_RATE_6MBPS)                  RatesBitmap |= DRV_RATE_MASK_6_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_9MBPS)                  RatesBitmap |= DRV_RATE_MASK_9_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_12MBPS)                 RatesBitmap |= DRV_RATE_MASK_12_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_18MBPS)                 RatesBitmap |= DRV_RATE_MASK_18_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_24MBPS)                 RatesBitmap |= DRV_RATE_MASK_24_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_36MBPS)                 RatesBitmap |= DRV_RATE_MASK_36_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_48MBPS)                 RatesBitmap |= DRV_RATE_MASK_48_OFDM;
+       if (HwRatesBitmap & HW_BIT_RATE_54MBPS)                 RatesBitmap |= DRV_RATE_MASK_54_OFDM;
+               
+       *AppRate = RatesBitmap;
+
+       return (OK);
+}
+
+void whalUtils_ConvertBitmapToMaxRate(UINT16 HwRatesBitmap, UINT8 *HwModulation, UINT8 *HwRate)
+{
+       /*
+       * !!!!!! MUST KEEP THE ORDER
+       */
+       if (HwRatesBitmap & HW_BIT_RATE_54MBPS)
+       {
+               *HwRate = RATE_54MBPS;
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_48MBPS)
+       {
+               *HwRate = RATE_48MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_36MBPS)
+       {
+               *HwRate = RATE_36MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_24MBPS)
+       {
+               *HwRate = RATE_24MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_22MBPS)
+       {
+               *HwRate = RATE_22MBPS; 
+               *HwModulation = HW_MODULATION_PBCC;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_18MBPS)
+       {
+               *HwRate = RATE_18MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_12MBPS)
+       {
+               *HwRate = RATE_12MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_11MBPS)
+       {
+               *HwRate = RATE_11MBPS;
+               *HwModulation = HW_MODULATION_PBCC;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_9MBPS)
+       {
+               *HwRate = RATE_9MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_6MBPS)
+       {
+               *HwRate = RATE_6MBPS; 
+               *HwModulation = HW_MODULATION_OFDM;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_5_5MBPS)
+       {
+               *HwRate = RATE_5_5MBPS;
+               *HwModulation = HW_MODULATION_PBCC;
+       }
+       else if (HwRatesBitmap & HW_BIT_RATE_2MBPS)
+       {
+               *HwRate = RATE_2MBPS; 
+               *HwModulation = HW_MODULATION_PBCC;
+       }
+       else 
+       {
+               *HwRate = RATE_1MBPS; 
+               *HwModulation = HW_MODULATION_PBCC;
+       }
+}
+
+/* Note the difference between this function and the next one */
+UINT32  whalUtils_GwsiRate2DRV_RATE (UINT32 gwsiRate)
+{
+       switch (gwsiRate)
+       {
+               /*
+                *      The handle for 33 removed !!!
+                */
+
+               case GWSI_1Mbits:       return          DRV_RATE_1M; /* break; */
+               case GWSI_2Mbits:       return  DRV_RATE_2M;    /*break; */
+               case GWSI_5_5Mbits:     return  DRV_RATE_5_5M;  /*break; */
+               case GWSI_6Mbits        :       return  DRV_RATE_6M; /* break; */       
+               case GWSI_9Mbits        :       return  DRV_RATE_9M; /* break; */       
+               case GWSI_11Mbits:      return  DRV_RATE_11M; /*        break; */       
+               case GWSI_12Mbits:      return  DRV_RATE_12M; /*        break; */       
+               case GWSI_18Mbits:      return  DRV_RATE_18M; /*        break; */       
+               case GWSI_22Mbits:      return  DRV_RATE_22M; /*        break; */       
+               case GWSI_24Mbits:      return  DRV_RATE_24M; /*        break; */       
+               case GWSI_36Mbits:      return  DRV_RATE_36M; /*        break; */       
+               case GWSI_48Mbits:      return  DRV_RATE_48M; /*        break; */       
+               case GWSI_54Mbits:      return  DRV_RATE_54M; /*        break; */       
+               
+               default:
+                       
+                       return          DRV_RATE_1M;
+               /*      break; */
+       }
+}
+
+rateMask_e  whalUtils_GwsiRate2DRV_RATE_MASK (UINT32 gwsiRate)
+{
+       switch (gwsiRate)
+       {
+               case GWSI_1Mbits:       return  DRV_RATE_MASK_1_BARKER;  
+               case GWSI_2Mbits:       return  DRV_RATE_MASK_2_BARKER;       
+               case GWSI_5_5Mbits:     return  DRV_RATE_MASK_5_5_CCK;         
+               case GWSI_6Mbits:       return  DRV_RATE_MASK_6_OFDM;       
+               case GWSI_9Mbits:       return  DRV_RATE_MASK_9_OFDM;      
+               case GWSI_11Mbits:      return  DRV_RATE_MASK_11_CCK;                  
+               case GWSI_12Mbits:      return  DRV_RATE_MASK_12_OFDM;          
+               case GWSI_18Mbits:      return  DRV_RATE_MASK_18_OFDM;          
+               case GWSI_22Mbits:      return  DRV_RATE_MASK_22_PBCC;         
+               case GWSI_24Mbits:      return  DRV_RATE_MASK_24_OFDM;         
+               case GWSI_36Mbits:      return  DRV_RATE_MASK_36_OFDM;         
+               case GWSI_48Mbits:      return  DRV_RATE_MASK_48_OFDM;         
+               case GWSI_54Mbits:      return  DRV_RATE_MASK_54_OFDM;         
+                                                                                                                                 
+               default:                        return  DRV_RATE_MASK_1_BARKER;
+       }
+}
+
+UINT32  whalUtils_DRV_RATE2GwsiRate (UINT32 Rate)
+{
+       switch (Rate)
+       {
+               /*
+                *      The handle for 33 removed !!!
+                */
+
+               case DRV_RATE_1M:       return   GWSI_1Mbits; /*        break;*/
+               case DRV_RATE_2M:       return  GWSI_2Mbits;  /*        break;*/
+               case DRV_RATE_5_5M:     return  GWSI_5_5Mbits;/*   break;*/
+               case DRV_RATE_6M:       return  GWSI_6Mbits     ; /*    break;*/        
+               case DRV_RATE_9M:       return  GWSI_9Mbits     ; /*    break;*/        
+               case DRV_RATE_11M:      return  GWSI_11Mbits; /*        break;*/        
+               case DRV_RATE_12M:      return  GWSI_12Mbits; /*        break;*/        
+               case DRV_RATE_18M:      return  GWSI_18Mbits; /*        break;*/        
+               case DRV_RATE_22M:      return  GWSI_22Mbits; /*        break;*/        
+               case DRV_RATE_24M:      return  GWSI_24Mbits; /*        break;*/        
+               case DRV_RATE_36M:      return  GWSI_36Mbits; /*        break;*/        
+               case DRV_RATE_48M:      return  GWSI_48Mbits; /*        break;*/        
+               case DRV_RATE_54M:      return  GWSI_54Mbits; /*        break;*/        
+               
+               default:
+                       return          GWSI_1Mbits;
+       /*              break; */
+       }
+}
+
+UINT32  whalUtils_DRV_RATE_MASK2GwsiRate (rateMask_e rateMask)
+{
+       switch (rateMask)
+       {
+               case DRV_RATE_MASK_1_BARKER:    return  GWSI_1Mbits;     
+               case DRV_RATE_MASK_2_BARKER:    return  GWSI_2Mbits;          
+               case DRV_RATE_MASK_5_5_CCK:     return  GWSI_5_5Mbits;         
+               case DRV_RATE_MASK_6_OFDM:      return  GWSI_6Mbits;        
+               case DRV_RATE_MASK_9_OFDM:      return  GWSI_9Mbits;       
+               case DRV_RATE_MASK_11_CCK:      return  GWSI_11Mbits;                  
+               case DRV_RATE_MASK_12_OFDM:     return  GWSI_12Mbits;           
+               case DRV_RATE_MASK_18_OFDM:     return  GWSI_18Mbits;           
+               case DRV_RATE_MASK_22_PBCC:     return  GWSI_22Mbits;          
+               case DRV_RATE_MASK_24_OFDM:     return  GWSI_24Mbits;          
+               case DRV_RATE_MASK_36_OFDM:     return  GWSI_36Mbits;          
+               case DRV_RATE_MASK_48_OFDM:     return  GWSI_48Mbits;          
+               case DRV_RATE_MASK_54_OFDM:     return  GWSI_54Mbits;          
+                                                                                                                                 
+               default:                        return  GWSI_1Mbits;
+       }
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalParams.h b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalParams.h
new file mode 100644 (file)
index 0000000..8023b93
--- /dev/null
@@ -0,0 +1,522 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalParams.h
+ *   PURPOSE: Holds all the whal parameters
+ * 
+ ****************************************************************************/
+
+#ifndef _WHAL_PARAMS_H
+#define _WHAL_PARAMS_H
+
+#include  "802_11Defs.h"
+#include  "whalHwDefs.h"
+#include  "whalCtrl_api.h"
+#include  "whalBus_Defs.h"
+#include  "commonTypes.h"
+
+#define MAX_FRAGMENTATION_THRESHOLD     2312
+#define MAX_SSID_SIZE       32
+
+ /* Trace Buffer Size (DebugTraceXfer Buffer)
+   Mote : The Trace Buffer Size are in UINT32 (1024 bytes,and 2048 for both buffers) */
+#define TRACE_BUFFER_MAX_SIZE 256 
+
+
+#define DEFAULT_HW_RADIO_CHANNEL        11
+
+
+/* Constants */
+
+/* RSSI roaming trigger configuration */
+/* minimal amount of packets to count in average RSSI before actually reporting trigger */
+#define RSSI_DEFAULT_DEPTH  (10) 
+/* the weight in % of the new packet relative to the previous average value of RSSI */
+#define RSSI_DEFAULT_WEIGHT (10) 
+#define RSSI_DEFAULT_THRESHOLD  (-80) 
+
+/* SNR roaming trigger configuration */
+/* minimal amount of packets to count in average SNR before actually reporting trigger */
+#define SNR_DEFAULT_DEPTH   (10) 
+/* the weight in % of the new packet relative to the previous average value of SNR */
+#define SNR_DEFAULT_WEIGHT  (10) 
+#define SNR_DEFAULT_THRESHOLD   (0) 
+
+/* 'No beacon' roaming trigger configuration */
+/* Number of consecutive beacons (or DTIM periods) missed before 
+  'Out of Sync' event is raised */
+#define OUT_OF_SYNC_DEFAULT_THRESHOLD   (10)
+/* IBSS - Number of consecutive beacons (or DTIM periods) missed before 
+  'Out of Sync' event is raised */
+#define OUT_OF_SYNC_IBSS_THRESHOLD  (200)
+/* period of time between 'Out of sync' and 'No beacon' events */
+#define NO_BEACON_DEFAULT_TIMEOUT       (100) /* in tu-s*/
+
+/* Consecutive NACK roaming trigger configuration */
+#define NO_ACK_DEFAULT_THRESHOLD    (20) 
+
+/* Low Rx rate roaming trigger configuration */
+#define LOW_RATE_DEFAULT_THRESHOLD  (2) 
+
+typedef struct
+{
+    UINT8    rxFilterCommand;
+    filter_e rxFilterAction;
+    UINT8    rxFilterNumFieldPatterns;
+    UINT8    rxFilterLenFieldPatterns;
+    UINT8    rxFilterFieldPatterns[MAX_DATA_FILTER_SIZE];
+
+}RxFilterConfig_t;
+
+/* 
+ * Dot11 params
+ * ------------
+ */
+
+
+typedef struct
+{
+    UINT16  RtsThreshold;
+    UINT8   CtsToSelf;
+    rxTimeOut_t rxTimeOut;
+    UINT16  FragmentThreshold;
+    UINT8   ListenInterval;
+    UINT16  Capabilities;
+    UINT32  MaxTxMsduLifetime;
+    UINT32  MaxRxMsduLifetime;
+    UINT8   calibrationChannel2_4;
+    UINT8   calibrationChannel5_0;
+    UINT16  Aid;
+    UINT8   CurrAntenna;
+    UINT8   TxAntenna;
+    UINT8   RxAntenna;
+    UINT8   Hw_TxAntenna;
+    UINT8   Hw_RxAntenna;
+    UINT16  CwMin;
+
+    UINT8   RateFallback;
+    UINT32  RxConfigOption;
+    UINT32  RxFilterOption;
+       UINT8   BetEnable;             
+       UINT8   MaximumConsecutiveET;
+    UINT8   TxCompleteThreshold;
+    BOOL    WiFiWmmPS;
+
+    /* ARP IP Addr table*/
+    UINT32  arp_IP_ver;
+    UINT32  isArpIpFilteringEnabled ;
+    IpAddress_t arp_IP_addr;
+
+    /*mac addresses filter*/
+    UINT8 isMacAddrFilteringnabled ;
+    UINT8 numGroupAddrs;
+    macAddress_t Group_addr[MAX_MULTICAST_GROUP_ADDRS];
+
+    UINT32  FeatureOptions;
+    UINT32  FeatureDataFlowOptions;
+    UINT8   SlotTime;
+    UINT8   preamble;
+    UINT8   RadioBand;
+    UINT8   MacClock;
+    UINT8   ArmClock;
+    UINT8   Enable4x;
+    UINT8   CurrPowerSaveState;
+    SoftGeminiEnableModes_e SoftGeminiEnable;
+    SoftGeminiParam_t SoftGeminiParams;
+
+    UINT8   maxSitesFragCollect;
+    UINT8   hwAccessMethod;
+
+    UINT8   FragmentationOnHal;
+
+    UINT32  nullTemplateSize;
+
+    UINT32  beaconTemplateSize;
+    
+
+    UINT32  probeRequestTemplateSize;
+    UINT32  probeResponseTemplateSize;
+    UINT32  PsPollTemplateSize;
+    UINT32  qosNullDataTemplateSize;
+
+    BOOL    RxEnergyDetection;
+    BOOL    TxEnergyDetection;
+
+    UINT8   PacketDetectionThreshold;
+    UINT8   FcsErrThrsh;
+    UINT8   UseDeviceErrorInterrupt;
+    BOOL    RetryPreemption;
+
+    UINT32  radioType;
+    UINT32  minorE2Ver;
+    UINT32  majorE2Ver;
+    UINT32  bugfixE2Ver;
+    BOOL    RxDisableBroadcast; /* this flag indicate if to discards all broadcast frames */
+    BOOL    RecoveryEnable;  /* Indicate if the recovery process is enabled */
+    BOOL    bJoin;              /* Indicate if the station is joined */
+    /* hardware ACI parameters */
+    UINT8   ACIMode;
+    UINT8   inputCCA;
+    UINT8   qualifiedCCA;
+    UINT8   stompForRx;
+    UINT8   stompForTx;
+    UINT8   txCCA;
+
+    UINT8   AntDiversity ;
+
+    acQueuesParams_t acQueuesParams[MAX_NUM_OF_AC];
+
+    /* Parameters for roaming triggers configuration */
+    whalCtrl_roamingTriggerCmd_t roamTriggers;
+
+    /* antenna diversity parameters */
+    whalCtrl_antennaDiversityOptions_t antennaDiversityOptions;
+
+    /* power control param */
+    powerAutho_PowerPolicy_e minPowerLevel;
+
+    BcnBrcOptions_t BcnBrcOptions;
+
+    UINT8           ConsecutivePsPollDeliveryFailureThreshold;
+
+    beaconFilterIETable_t beaconFilterIETable;
+    beaconFilterParams_t beaconFilterParams;
+    
+    queueTrafficParams_t QtrafficParams;
+    acQosParams_t acQosParams;
+
+    /*mac preamble*/
+    UINT8 earlyWakeUp;
+
+    /* Rx Data Filter */
+    BOOL rxFilterDefaultAction;
+    filter_e rxFilterDefaultEnable;
+    RxFilterConfig_t rxFilterCgf[MAX_DATA_FILTERS];
+    
+} WlanParams_T;
+
+
+/* 
+ * BssInfo params
+ * --------------
+ */
+
+typedef struct
+{
+    UINT8           ReqBssType;
+    UINT8           BssType;
+    UINT16          BeaconInterval;
+    UINT8           DtimInterval; 
+    UINT8           RadioChannel;
+
+    UINT8           BssId[MAC_ADDR_SIZE];
+    dot11_SSID_t    WlanElm_Ssid;
+    
+    txRatePolicy_t  TxRateClassParams; /* Policy for recovery   */  
+    UINT16          BasicRateSet;   
+    UINT16          SupportedRateSet;
+    rate_e          txCtrlFrmRateDriverFormat;
+    UINT8           txCtrlFrmRate;
+    UINT8           txCtrlFrmModulation;
+    UINT8           Ctrl; /* Only bit 7 is currently in use , bit 7 indicates if to flash the Tx queues */
+    UINT8           txMgmtFrmRate;
+    UINT8           txMgmtFrmModulation;
+    UINT16          ATimWindow;     /* ATIM window of IBSS*/
+                                    /* Note that when ATIM window is zero the*/
+                                    /* initiated IBSS does not support powersave*/
+    UINT8           DefaultPreamble;/* Specifies the PLCP preamble type used*/
+                                    /* 0 for long preamble*/
+                                    /* 1 for short preamble*/
+
+
+    
+} BssInfoParams_T;
+
+/* 
+ * General params
+ * --------------
+ */
+
+typedef struct
+{
+    int     UseTxDataInterrupt;
+
+    UINT8   TraceEnable;
+    UINT8   TraceOut;
+
+    UINT32  PbccDynamicEnable;
+    UINT32  PbccDynamicInterval;
+    UINT32  PbccDynamicIgnoreMcast;
+} GenParams_T;
+
+
+/* 
+ * General counters
+ * ----------------
+ */
+
+typedef struct
+{
+    UINT32  FcsErrCnt;
+} GenCounters_T;
+
+
+/*
+ * HwInfoParams_t - wlan hardware info
+ * -----------------------------------
+ */
+typedef struct
+{
+    UINT8                   SrcMacAddr[MAC_ADDR_SIZE];
+    UINT32                  Pad0;
+    UINT32                  Pad1;
+    ACXRevision_t           AcxVersion;             /* Fw version (read from the wlan hardware) */
+} HwInfo_T;
+
+
+/*
+ * queuesParam_T - Queue params for Quality Of Service
+ * ------------------------------------------
+ */
+typedef struct
+{
+    queueTrafficParams_t        queues[MAX_NUM_OF_TX_QUEUES];
+    BOOL                        isQueueConfigured[MAX_NUM_OF_TX_QUEUES];
+} QueuesParam_t;
+
+typedef struct 
+{
+    acQosParams_t               ac[MAX_NUM_OF_AC];
+    BOOL                        isAcConfigured[MAX_NUM_OF_AC];
+}AcConfParam_t;
+
+typedef struct
+{
+    /* Tx Parameters */
+    UINT8               TxPowerDbm;
+    
+    UINT16              txCompleteTimeout;
+    UINT8               txCompleteThreshold;
+
+    UINT8               QidToAcTable[MAX_NUM_OF_TX_QUEUES];
+    BOOL                AckPolicy[MAX_NUM_OF_AC];
+
+    /* Information Elements */
+    acQueuesParams_t    halAcQueueParams[MAX_NUM_OF_AC];
+    whaCtrl_acTrafficParams_t   halTrafficParams[MAX_NUM_OF_AC];
+
+} TxParam_t;
+
+
+/* 
+ * Templates params
+ * ----------------
+ */
+
+
+
+typedef struct
+{
+    TemplateParams_T    Beacon;
+    TemplateParams_T    ProbeReq;
+    TemplateParams_T    ProbeResp;
+    TemplateParams_T    NullData;
+    TemplateParams_T    PsPoll;
+    TemplateParams_T    QosNullData;
+} TemplateListParams_T;
+
+/*
+ * ----------------------------------------------------------------
+ *                  MAIN PARAMETERS STRUCTURE
+ * ----------------------------------------------------------------
+ */
+typedef struct _WhalParams_T
+{
+    DmaParams_T             DmaParams;      /* Rx/Tx queue parameters   */
+    QueuesParam_t           QueuesParams;   /* Queues params for QOS    */
+    AcConfParam_t           AcParams;       /* AC params for QoS        */
+    TxParam_t               TxParams;       /* Tx params for QOS        */
+    WlanParams_T            WlanParams;     /* Wlan parameters          */
+    BssInfoParams_T         BssInfoParams;  /* Bss information          */
+    GenParams_T             GenParams;      /* General parameters       */
+    HwInfo_T                HwInfoParams;   /* Hw eeprom, hw versions   */
+    GenCounters_T           GenCounters;    /* General counters         */
+    TemplateListParams_T    TemplateList;   /* templates for recovery   */
+
+    TI_HANDLE hOs;
+    TI_HANDLE hReport;
+
+} WhalParams_T;
+
+/*
+ * ----------------------------------------------------------------
+ *                  WHAL pARAMS OBJECT API
+ * ----------------------------------------------------------------
+ */
+WhalParams_T *whal_params_Create(TI_HANDLE hOs, BOOL TxFlashEnable);
+int whal_params_Destroy(WhalParams_T *pWhalParams);
+int whal_params_Config (WhalParams_T *pWhalParams, TI_HANDLE hReport);
+
+/* 
+ * DmaParams - Rx/Tx queue parameters
+ */
+DmaParams_T *whal_ParamsGetDmaParams(WhalParams_T *pWhalParams);
+int whal_ParamsSetDmaParams(WhalParams_T *pWhalParams);
+
+/* 
+ * WlanParams api 
+ */
+
+int     whal_ParamsSetRoamingParams(WhalParams_T *pWhalParams) ;
+WlanParams_T *whal_ParamsGetWlanParams(WhalParams_T *pWhalParams);
+void   whal_ParamsSetFragmentThreshold  (WhalParams_T *pWhalParams, int FragSize);
+UINT32 whal_ParamsGetFragmentThreshold  (WhalParams_T *pWhalParams);
+UINT8  whal_ParamsIsFragmentOnHal       (WhalParams_T *pWhalParams);
+void   whal_ParamsPrintFragmentThreshold(WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetMaxSitesFragCollect(WhalParams_T *pWhalParams);
+void   whal_ParamsSetRtsThreshold       (WhalParams_T *pWhalParams, int RtsSize);
+void   whal_ParamsSetListenInterval     (WhalParams_T *pWhalParams, UINT8 Val);
+UINT8  whal_ParamsGetListenInterval     (WhalParams_T *pWhalParams);
+void   whal_ParamsSetRxFilter           (WhalParams_T *pWhalParams, UINT32 RxConfigOption, UINT32 RxFilterOption);
+void   whal_ParamsGetRxFilter           (WhalParams_T *pWhalParams, UINT32* pRxConfigOption, UINT32* pRxFilterOption);
+void   whal_ParamsSetarpIpAddressesTable(WhalParams_T *pWhalParams, IpAddress_t * IP_addr, IPver_e IP_ver);
+void   whal_ParamsGetarpIpAddressesTable(WhalParams_T * pWhalParams, IpAddress_t * IP_addr, IPver_e* pIP_ver);
+void   whal_ParamsSetarpIpFilterEnabled(WhalParams_T *pWhalParams, UINT8 isEnabled);
+void   whal_ParamsGetarpIpFilterEnabled(WhalParams_T *pWhalParams, UINT8* pisEnabled);
+void   whal_ParamsSetGroupAddressesTable(WhalParams_T *pWhalParams, UINT8 isEnabled, UINT8 numGroupAddrs, macAddress_t *Group_addr);
+void   whal_ParamsGetGroupAddressesTable(WhalParams_T *pWhalParams, UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr);
+UINT8  whal_ParamsGetCurrAntenna        (WhalParams_T *pWhalParams);
+void   whal_ParamsSetPowerSaveState(WhalParams_T *pWhalParams, UINT8 CurrPowerSaveState);
+UINT8  whal_ParamsGetPowerSaveState(WhalParams_T *pWhalParams);
+
+
+/* 
+ * Bss Info Params api 
+ */
+BssInfoParams_T *whal_ParamsGetBssInfoParams(WhalParams_T *pWhalParams);
+UINT8   *whal_ParamsGetBssId        (WhalParams_T *pWhalParams);
+void     whal_ParamsSetBssId        (WhalParams_T *pWhalParams, char *BssId);
+void     whal_ParamsSetSsid         (WhalParams_T *pWhalParams, char *Ssid, UINT8 SsidLength);
+dot11_SSID_t *whal_ParamsGetElm_Ssid(WhalParams_T *pWhalParams);
+void   whal_ParamsSetReqBssType     (WhalParams_T *pWhalParams, int Val);
+UINT8  whal_ParamsGetReqBssType(WhalParams_T *pWhalParams);
+void   whal_ParamsSetBssType        (WhalParams_T *pWhalParams, int Val);
+void whal_ParamsSetRadioBand(WhalParams_T *pWhalParams, int RadioBand);
+UINT8  whal_ParamsGetRadioBand(WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetBssType        (WhalParams_T *pWhalParams);
+void   whal_ParamsSetBeaconInterval (WhalParams_T *pWhalParams, UINT16 Val);
+UINT16 whal_ParamsGetBeaconInterval (WhalParams_T *pWhalParams);
+void   whal_ParamsSetDtimCount      (WhalParams_T *pWhalParams, UINT8 Val);
+UINT8  whal_ParamsGetDtimCount      (WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetRadioChannel   (WhalParams_T *pWhalParams);
+void   whal_ParamsSetRadioChannel   (WhalParams_T *pWhalParams, int Channel);
+void   whal_ParamsSetBasicRatesSet  (WhalParams_T *pWhalParams, UINT16 BasicRateSet);
+void   whal_ParamsSetSupportedRatesSet(WhalParams_T *pWhalParams, UINT16 SupportedRateSet);
+void   whal_ParamsSetHwGenTxParams  (WhalParams_T *pWhalParams, rate_e TxRate, BOOL bCtrlFrame);
+UINT8  whal_ParamsGetDefaultChannel (WhalParams_T *pWhalParams);
+void whal_ParamsSetTxRateClassParams(WhalParams_T *pWhalParams,txRatePolicy_t *pTxRatePolicy);
+txRatePolicy_t* whal_ParamsGetTxRateClassParams(WhalParams_T *pWhalParams);
+void   whal_ParamsSetAtimWindow     (WhalParams_T *pWhalParams, UINT16 ATimWindow);
+UINT16 whal_ParamsGetAtimWindow     (WhalParams_T *pWhalParams);
+void   whal_ParamsSetDefaultPreamble(WhalParams_T *pWhalParams, UINT8 DefaultPreamble);
+UINT8  whal_ParamsGetDefaultPreamble(WhalParams_T *pWhalParams);
+UINT32 whal_ParamsGetTraceBufferSize(WhalParams_T *pWhalParams);
+void   whal_ParamsGetMacPreambleParams(WhalParams_T *pWhalParams, UINT8* earlyWakeUp);
+
+
+/* 
+ * general AP parameters 
+ */
+GenParams_T *whal_ParamsGetGenParams    (WhalParams_T *pWhalParams);
+UINT32 whal_ParamsGetPbccDynamicEnableVal(WhalParams_T *pWhalParams);
+void   whal_ParamsSetPbccDynamicEnableVal(WhalParams_T *pWhalParams, int Val);
+
+/* 
+ * Wlan hardware info params 
+ */
+UINT8   *whal_ParamsGetSrcMac   (WhalParams_T *pWhalParams);
+void     whal_ParamsSetSrcMac   (WhalParams_T *pWhalParams, char *SrcMac);
+char whal_ParamsGetRadioType    (WhalParams_T *pWhalParams);
+void whal_ParamsHwNvramPrint    (WhalParams_T *pWhalParams);
+ACXRevision_t *whal_ParamsGetAcxVersion(WhalParams_T *pWhalParams);
+void whal_ParamsPrintFwVersion  (WhalParams_T *pWhalParams);
+UINT8 *whal_ParamsGetFwVersion  (WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetE2MajorVersion (WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetE2MinorVersion (WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetE2LastVersion (WhalParams_T *pWhalParams);
+UINT8  whal_ParamsGetTiInternalVer (WhalParams_T *pWhalParams);
+
+/*
+ * ----------------------------------------------------------------
+ *                          WME TX PARAMETERS
+ * ----------------------------------------------------------------
+ */
+
+int whal_ParamsSetQueueParams(WhalParams_T *pWhalParams,queueTrafficParams_t *pQtrafficParams) ;
+void whal_ParamsSetAcParams(WhalParams_T *pWhalParams,acQosParams_t *pAcQosParams);
+
+
+TxParam_t* whal_ParamsGetTxParams (WhalParams_T *pWhalParams);
+
+/*
+ *  Traffic Parameters: (IE ACX_TID_CFG)
+ */
+int whal_ParamsSetTrafficParams(WhalParams_T *pWhalParams,whaCtrl_acTrafficParams_t* pTconfParams) ;
+whaCtrl_acTrafficParams_t* whal_ParamsGetTrafficParams(WhalParams_T *pWhalParams, UINT8 AcID);
+
+/*
+ *  Access Category Parameters :(IE ACX_AC_CFG)
+ */
+int whal_ParamsSetAccessCategoryParams(WhalParams_T *pWhalParams,acQueuesParams_t* pTconfParams) ;
+
+/*
+ *  Qos Type : use in the Tx Descriptor 
+ */
+BOOL whal_ParamsGetQosMode(WhalParams_T *pWhalParams);
+int   whal_ParamsSetQosMode(WhalParams_T *pWhalParams,qosProtocols_e QosType);
+
+/*
+ *  Ack Policy Parameters: use in the Tx Descriptor 
+ */
+int   whal_ParamsSetAccessCategoryAckPolicy(WhalParams_T *pWhalParams,BOOL AckPolicy, UINT8 Qid);
+
+/*
+ *  
+ */
+UINT8 whal_ParamsGetAcIdFromQid(WhalParams_T *pWhalParams,UINT8 Qid);
+
+#endif /*_WHAL_PARAMS_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalRadio.c b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalRadio.c
new file mode 100644 (file)
index 0000000..d40bd20
--- /dev/null
@@ -0,0 +1,190 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalRadio.c
+ *   PURPOSE: Handle all radio aspects in the Hal
+ *
+ *  RSSI 
+ *             Set RSSI params to the firmware
+ *             Conversion function From/To RxLevel/RSSI
+ *     TxPowerLevel
+ *             Overide the default radioTxLevel table
+ *     
+ ****************************************************************************/
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+#include "commonTypes.h"
+#include "eventMbox_api.h"
+#include "whalBus_Api.h"
+
+/* Conversion Factors */
+#define RADIA_BG_FACTOR         93
+#define RADIA_ABG_FACTOR        93
+#define RADIA_BG_CRT_FACTOR     98
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_SetRadioBand
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+
+int whalCtrl_SetRadioBand (TI_HANDLE hWhalCtrl, radioBand_e RadioBand)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       pWhalCtrl->pWhalParams->WlanParams.RadioBand = RadioBand;               
+       
+       return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_convertRSSIToRxLevel
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+INT8 whalCtrl_convertRSSIToRxLevel(TI_HANDLE hWhalCtrl, INT32 rssiVal)
+{
+    WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;   
+    INT8       rxLevel;
+
+    switch(pWhalCtrl->pWhalParams->WlanParams.radioType)
+    {
+    case RADIO_MAXIM2820_ID:  /* Not Supported at the moment */
+        rxLevel = 0;
+        break;
+    case RADIO_RFMD_ID:       /* Not Supported at the moment */
+        rxLevel = 0;
+        break;
+    case RADIO_RADIA_BG_ID:    
+        rxLevel = (INT8)(rssiVal + RADIA_BG_FACTOR);
+        break;
+    case RADIO_RADIA_ABG_ID:    
+        rxLevel = (INT8)(rssiVal + RADIA_ABG_FACTOR);
+        break;
+    case RADIO_RADIA_BG_CRT_ID: 
+        rxLevel = (INT8)(rssiVal + RADIA_BG_CRT_FACTOR);
+        break;
+    case RADIO_RADIA_WBR_ID: 
+        rxLevel = (UINT8)(rssiVal + RADIA_BG_CRT_FACTOR);
+        break;
+    case RADIO_RADIA_DCR_ID: 
+       case RADIO_RADIA_DCR_1251_ID:
+        rxLevel = (UINT8)(rssiVal + RADIA_BG_CRT_FACTOR);
+        break;
+    default: 
+        rxLevel = 0;
+        WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("whalCtrl_convertRSSIToRxLevel: Error - Unknown radio type!\n"));
+        break;
+    }
+
+       return rxLevel;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_getRadioNumber
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+TI_STATUS whalCtrl_getRadioNumber(TI_HANDLE hWhalCtrl, UINT32 *outRadioType, UINT32 *outRadioNumber)
+{
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)hWhalCtrl;
+       WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams); 
+       UINT32 RadioType;
+
+       *outRadioNumber = pWlanParams->radioType;
+
+       switch (pWlanParams->radioType)
+       {
+               case RADIO_RADIA_BG_ID:
+                       RadioType = RADIA_BG;
+                       WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                                        ("Radio Type is : RADIA BG\n"));
+                       break;
+
+               case RADIO_RADIA_ABG_ID:
+                       RadioType = RADIA_ABG;
+                       WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                                        ("Radio Type is : RADIA ABG\n"));
+                       break;
+
+               case RADIO_RADIA_BG_CRT_ID:
+                       RadioType = RADIA_BG;
+                       WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                                        ("Radio Type is : RADIA BG (crt)\n"));
+                       break;
+
+        case RADIO_RADIA_WBR_ID:
+            RadioType = RADIA_ABG;
+            WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                 ("Radio Type is : RADIO ABG (wbr)\n"));
+            break;
+
+        case RADIO_RADIA_DCR_ID:
+               case RADIO_RADIA_DCR_1251_ID:
+            RadioType = RADIA_ABG;
+            WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                 ("Radio Type is : RADIO ABG (dcr)\n"));
+            break;
+
+               default:
+                       RadioType = UNKNOWN_RADIO_TYPE;
+                       WLAN_OS_REPORT (("FATAL ERR: Radio Type is : 0x%x - UNKNOWN\n", pWlanParams->radioType));
+                       break;
+       }
+
+       *outRadioType = RadioType;
+       return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalRecovery.c b/sta_dk_4_0_4_32/common/src/hal/hl_ctrl/whalRecovery.c
new file mode 100644 (file)
index 0000000..1a746c4
--- /dev/null
@@ -0,0 +1,552 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalRecovery.c
+ *   PURPOSE: Handle Recovery and ACI in the Hal
+ *
+ *     Recovery
+ *             CheckHwStatus - called periodically from the CORE to check the following triggers:
+ *                     Consecutive fcs error
+ *                     CheckMailbox - call interrogate with callback (only print)
+ *                     RxFreeMem register image
+ *                     TxQueue 
+ *                     TxQueue 
+ *             Mailbox error - call the CORE failure event MBOX_FAILURE
+ *             Event mailbox
+ *                     MacStatus event - receive the register value for CONS_FCS_ERR and Rx_FREE_MEM triggers
+ *                     Health event - device error callback to CORE  
+ *             PowerCtrl timeout fail - call the CORE failure event HW_AWAKE_FAILURE
+ *             StopHal - called from the CORE as first step in the recovery process
+ *             Reconfig - called from the CORE as second step in the recovery process
+ *     LNA/ACI
+ *             ACI event - get SCR_PAD8 value, accumulate it locally for later read/write by the CORE
+ *  Rx reset
+ *             API to access the RX_RESET register
+ *
+ *     Issues
+ *             Add API to 
+ *             Move the whalCtrl_hwStatus_t from HwCtrl into Recovery object
+ *             Remove CheckMailbox in CheckHwStatus
+ *             Device error is not enabled
+ *
+ ****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+#include "eventMbox_api.h" 
+#include "CmdQueue_api.h"
+#include "whalBus_Api.h"
+#include "shmBus.h"
+#include "whalHwAccess.h"
+#include "TNETW_Driver.h"
+#include "FwEvent_api.h"
+
+#ifdef USE_RECOVERY
+
+/* Aci Indication Callback */
+/* typedef void (*AciIndicationCB_t)(TI_HANDLE handle, char* str , UINT32 strLen);*/
+
+
+void whalCtrl_HealthReoprt_CB(TI_HANDLE hWhalCtrl, char* Report , UINT32 strLen);
+void whalCtrl_MacStatus_CB(TI_HANDLE hWhalCtrl, char* Status , UINT32 strLen);
+int  whalCtrl_PeriodicCheckMailboxCb(TI_HANDLE hWhalCtrl, UINT16 MboxStatus,char *InterrogateParamsBuf);
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_RegisterCallbacks
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Register all health/sanityCheck/Recovery callbacks 
+ * --------------------------------------------------
+ *             DeviceError - CORE callback for full recovery
+ *             HealthReport - Event Mbox callback for extracting device error
+ *             MacStatus - Event Mbox callback for checkHwStatus FCS_ERR, RX_FREE_MEM regs
+ *             AciIndication - Event Mbox callback for accumulate SCR_PAD8 image
+ *             Mailbox error - Mailbox queue callback for case of timeout/error  
+ *             Power control error - PowerMngr callback in case of power ctrl timeout 
+ *             Failure event - CORE Callback in case of MailboxError or PowerCtrl error 
+ *                     
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_RegisterErrorsCallbacks(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL                  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       /*FW events : BUS_ERROR and DEVICE_ERROR*/
+       pWhalCtrl->HealthReportCB_CB = whalCtrl_HealthReoprt_CB;
+       pWhalCtrl->HealthReportCB_handle = pWhalCtrl;
+
+       eventMbox_RegisterEventCB (pWhalCtrl->hEventMbox, HAL_EVENT_HEALTH_REPORT,(void*)pWhalCtrl->HealthReportCB_CB, pWhalCtrl);
+       /* The health report event will be enabled in the ConfigHw stage */
+       
+
+
+       /*FW events : FCS_ERROR and HEALTH_TEST_OK*/
+       pWhalCtrl->MacStatusCB_CB = whalCtrl_MacStatus_CB;
+       pWhalCtrl->MacStatusCB_CB_handle = pWhalCtrl;
+       
+       eventMbox_RegisterEventCB(pWhalCtrl->hEventMbox, HAL_EVENT_MAC_STATUS, (void*)pWhalCtrl->MacStatusCB_CB, pWhalCtrl);
+       eventMbox_EvUnMask(pWhalCtrl->hEventMbox, HAL_EVENT_MAC_STATUS);
+
+       
+       /* Register For Error Of Mailbox in case of timeout */
+       CmdQueue_RegisterForErrorCB(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, (void *)whalCtrl_CheckMailboxCb, hWhalCtrl);
+       
+#ifdef HW_ACCESS_SDIO
+       TNETWIF_RegisterBusFailureEventCB(((whalBus_T *)(pWhalCtrl->pHwCtrl->hWhalBus))->hTNETWIF,
+                                                 (void *)whalCtrl_HealthReoprt_CB,pWhalCtrl);
+#endif
+
+       return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_CheckHwStatus
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *             CheckFcsError
+ *                     Test the register CONS_FCR_ERR value that came periodically in event
+ *                     Try to recover by setting RX_RESET 
+ *                     Disable full recovery by StaDk_4.1 team !!!!!!!!!!!
+ *             CheckMailbox
+ *                     Call interrogate (with callback) to StationId IE
+ *                     The callback is just for print
+ *                     There is no need for this trigger because of the event mechanizm
+ *             CheckRxFreeMem
+ *                     Test the register RX_FREE_MEM value that came periodically in event
+ *             CheckTxQueue
+ *                     Check the queue is not empty and no tx complete 
+ *             CheckRxQueue
+ *                     Disabled 
+ *                     
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_CheckHwStatus(TI_HANDLE hWhalCtrl)
+{
+    WHAL_CTRL                  *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       
+#if 0
+       WLAN_REPORT_FATAL_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                       ("whalCtrl_CheckHwStatus: Start test\n"));
+#endif
+       /* 
+        * Trigger the FW health test command and wait for results. 
+        * -------------------------------------------------------
+        */
+    whal_hwCtrl_healthCheck(pWhalCtrl->pHwCtrl);
+
+       return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_RecoveryEnded
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *             aanouce all the modules about the end of the recovery proccess.
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_RecoveryEnded(TI_HANDLE hWhalCtrl)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+
+       /*Change the State of the mboxQueue and the interrupt Module and 
+       After recovery we should enable back all interrupts according to the last interrupt shadow mask*/
+       whalCtrl_exitFromInitMode(hWhalCtrl);
+    
+    /* 
+    Indicates the MboxQueue that Reconfig Ended in Order To Call the CallBacks
+       That Was saved before the recovery process started 
+       */
+       CmdQueue_EndReconfig(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue);
+       
+       WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                        ("whalCtrl_ReConfig: End  (%d)\n", os_timeStampMs(pWhalCtrl->hOs)));
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ReConfigCb
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *      Do firmware download 
+ *      Run the firmware
+ *      Configure stage (ConfigHw)
+ *      Re-Join if needed
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+static int whalCtrl_ReConfigCb (TI_HANDLE hWhalCtrl, TI_STATUS status)
+{
+    WHAL_CTRL      *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    WlanParams_T   *pWlanParams = whal_ParamsGetWlanParams (pWhalCtrl->pWhalParams);
+    whalParamInfo_t param;
+       
+
+    if (status != OK)
+    {
+        WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("whalCtrl_ReConfig: whal_hwCtrl_ConfigHw failed\n"));
+        return NOK;
+    }
+
+    whalSecur_HwEncDecrEnable (pWhalCtrl->pWhalSecurity, 1);
+
+    /* Re-config roaming thresholds */
+    /* SNR */
+       whal_hwCtrl_SetSNRParams(pWhalCtrl->pHwCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+    
+    /* RSSI */
+    whalCtrl_SetRSSIParamsCmd (pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+    /* Max consecutive NACK */
+    whalCtrl_SetMaxTxRetryParamsCmd (pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+    /* Out of sync */
+    whalCtrl_SetBssLossTsfThresholdParamsCmd (pWhalCtrl, &pWhalCtrl->pWhalParams->WlanParams.roamTriggers);
+
+
+  #ifdef DO_CALIBRATION_IN_DRIVER
+    /* Perform single calibration for APP scan usage. */
+    whalCtrl_sendRadioAction (pWhalCtrl, MANUAL_CALIB);
+  #endif /* DO_CALIBRATION_IN_DRIVER */
+
+    /* Join (use the local parameters), otherwise the core will reconnect */
+    if (pWlanParams->bJoin)
+    {
+        /* Set TxRatePolicy */
+        param.paramType = HAL_CTRL_TX_RATE_CLASS_PARAMS;
+        param.content.pTxRatePlicy = &pWhalCtrl->pWhalParams->BssInfoParams.TxRateClassParams;
+    
+        whalCtrl_SetParam (pWhalCtrl->pHwCtrl, &param);
+        
+        status = (TI_STATUS)whalCtrl_ReJoinBss (hWhalCtrl);
+        if (status != OK)
+        {
+            WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                ("whalCtrl_ReConfig: whalCtrl_ReJoinBss failed\n"));
+            return NOK;
+        }
+        whal_hwCtrl_AidSet (pWhalCtrl->pHwCtrl, pWhalCtrl->pWhalParams->WlanParams.Aid);       
+    
+        /* Slot time must be setting after doing join */
+        whal_hwCtrl_SetSlotTime (pWhalCtrl->pHwCtrl, (slotTime_e)pWhalCtrl->pWhalParams->WlanParams.SlotTime);               
+
+        /* Re-config security keys, default key Id and encryption/decryption control to the FW */
+        if (whalSecur_KeysReconfig (pWhalCtrl->pWhalSecurity) != OK)
+        {
+            WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                ("whalCtrl_ReConfig: ## whalSecur_KeysReconfig failed\n"));
+            return NOK;
+        }
+    }
+
+    return OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ReConfig
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *      Do firmware download 
+ *      Run the firmware
+ *      Configure stage (ConfigHw)
+ *      Re-Join if needed
+ * Note(s)  :  Done
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_ReConfig (TI_HANDLE hWhalCtrl, int DoReJoin)
+{
+    WHAL_CTRL    *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams (pWhalCtrl->pWhalParams);
+    int           Stt;
+    
+    if (!pWlanParams->RecoveryEnable)
+    {
+        WLAN_OS_REPORT(("Recovery is disabled in registry, abort recovery process\n"));
+        return OK;
+    }
+    
+  #if 0
+    /* L.M. PATCH for card eject */
+    if (!whalBus_FwCtrl_isCardIn (pWhalCtrl->pHwCtrl->hWhalBus))
+    {
+        WLAN_REPORT_REPLY (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                          ("whalCtrl_ReConfig: card was removed => not proceeding\n"));
+        return OK;
+    }
+  #endif/*_WINDOWS*/
+
+    /*
+     * Initiate the wlan hardware (FW download).
+     * -----------------------------------------
+     */
+    WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                             ("whalCtrl_ReConfig: Start(%d)\n", os_timeStampMs (pWhalCtrl->hOs)));
+    Stt = whal_hwCtrl_Initiate (pWhalCtrl->pHwCtrl);
+    if (Stt != OK)
+    {
+        WLAN_REPORT_ERROR (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+            ("whalCtrl_ReConfig: whal_hwCtrl_Initiate failed\n"));
+        return NOK;
+    }
+
+    /* Configure the WLAN hardware */
+    Stt = whal_hwCtrl_ConfigHw (pWhalCtrl->pHwCtrl, (void *)whalCtrl_ReConfigCb, hWhalCtrl, TRUE);
+    
+    return OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_CheckMailboxCb
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *             When the command mailbox queue identify mailbox error or timeout, it will call 
+ *             to this function to handle the error.
+ *             Call the CORE callback with MBOX_FAILURE type to do the recovery
+ *             
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_CheckMailboxCb(TI_HANDLE hWhalCtrl,UINT16 MboxStatus, char *InterrogateParamsBuf)
+{
+
+       WHAL_CTRL                       *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       whalCtrl_hwStatus_t *pHwStatus = &pWhalCtrl->pHwCtrl->HwStatus;
+
+       if(MboxStatus != OK)
+       {
+               ++pHwStatus->NumMboxFailures;
+        WLAN_REPORT_WARNING(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+        ("whalCtrl_PeriodicCheckMailboxCb: Periodic intorregate check - Command mailbox failure was occur \n errors failure # %d "
+                       ,pHwStatus->NumMboxFailures));
+
+               /* Indicating Upper Layer about Mbox Error */
+               pWhalCtrl->FailureEvent_CB(pWhalCtrl->FailureEvent_CB_handle,MBOX_FAILURE);
+       }
+
+       return OK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_MacStatus_CB
+ *                     : Callback from the EventMbox in case Mac status Event Occur 
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_MacStatus_CB(TI_HANDLE hWhalCtrl, char* Status , UINT32 strLen)
+{
+       WHAL_CTRL       *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       UINT32          currFcsCounter;
+       
+
+   /* The FCS error is updated by the MacStatus event from the firmware */
+       currFcsCounter = (*(UINT32*)Status);
+
+       WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                       ("whalCtrl_MacStatus_CB: Mac Status report currFcsCounter=%d LastConsFcsCounter=%d\n", 
+             currFcsCounter));
+
+       /* This event shouldn't be received, so it is not passed on to anybody */
+}
+
+#define                HEALTH_REPORT_DEVICE_ERROR_BIT  BIT_0
+#define     HEALTH_REPORT_HOST2FW_SEQ_ERROR BIT_1
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_HealthReoprt_CB
+ *                     : Callback from the EventMbox in case HealthReport Event Occur 
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+
+void whalCtrl_HealthReoprt_CB(TI_HANDLE hWhalCtrl, char* Report , UINT32 strLen)
+{
+       WHAL_CTRL       *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       UINT16          HealthReport = *((UINT16*)Report);
+       
+       if(HealthReport & HEALTH_REPORT_DEVICE_ERROR_BIT)
+       { 
+               WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                       ("whalCtrl_HealthReoprt_CB: Firmware reports about DEVICE_ERROR, handle by callback"));
+               /* Indicating Upper Layer about Device Error */
+               pWhalCtrl->FailureEvent_CB(pWhalCtrl->FailureEvent_CB_handle, DEVICE_ERROR);
+       }
+    else
+        if(HealthReport & HEALTH_REPORT_HOST2FW_SEQ_ERROR)
+                       /* For USB Health Check */
+        {
+            WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                ("whalCtrl_HealthReoprt_CB: Firmware reports about HOST2FW_SEQ_ERROR"));
+            /* This shall invoke softice, if occure we will handle this case locally*/
+           /*  ASSERT(0);*/
+        }
+        else
+                       if (HealthReport & HEALTH_REPORT_BUS_ERROR) 
+                       {
+                               WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                                                       ("whalCtrl_HealthReoprt_CB: Low level bus driver reported bus error. Performing hardware reset of the bus\n"));
+
+                               pWhalCtrl->FailureEvent_CB(pWhalCtrl->FailureEvent_CB_handle, BUS_ERROR);
+                       }
+               else
+        {
+            WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
+                                ("whalCtrl_HealthReoprt_CB: UnKnown Health report ID 0x%x ", (int)HealthReport));
+        }
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_resetMacRx
+ *
+ * Input    : 
+ * Output   : 
+ * Process  : Reset the Rx.
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_resetMacRx (TI_HANDLE hWhalCtrl)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;  
+       
+       WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,("whalCtrl_resetMacRx:\n"));
+       
+       return whal_HwCtrl_resetMacRx (pWhalCtrl->pHwCtrl);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_PrintHwStatus
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *             Print the Recovery status
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_PrintHwStatus(TI_HANDLE hWhalCtrl)
+{
+#ifdef REPORT_LOG
+
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       whalCtrl_hwStatus_t *pHwStatus = &pWhalCtrl->pHwCtrl->HwStatus;
+
+    WLAN_OS_REPORT(("--------------- whalCtrl_PrintHwStatus ---------------\n\n"));
+       WLAN_OS_REPORT(("NumMboxErrDueToPeriodicBuiltInTestCheck = %d\n", pHwStatus->NumMboxErrDueToPeriodicBuiltInTestCheck));
+       WLAN_OS_REPORT(("NumMboxFailures = %d\n", pHwStatus->NumMboxFailures));
+
+#endif
+       
+       return OK;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_ResetBusAfterHardBoot
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ *             Restart the buss access layer after hard boot. 
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+void whalCtrl_ResetBusAfterHardBoot(TI_HANDLE hWhalCtrl)
+{
+       
+#ifdef HW_ACCESS_SDIO
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       whalBus_ReConfig( pWhalCtrl->hWhalBus );
+#endif
+
+}
+
+#endif /* USE_RECOVERY */
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalCtrl_LNAControl
+ *
+ * Input    : LNAControlField, 0=> Turn Off , 1=> Turn On
+ * Output   : 
+ * Process  :
+ *             Call the mailbox (need to be called directly without HwCtrl)
+ * Note(s)  : Done 
+ * -----------------------------------------------------------------------------
+ */
+int whalCtrl_LNAControl (TI_HANDLE hWhalCtrl, UINT8 LNAControlField)
+{
+       WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;  
+       
+       WLAN_REPORT_INFORMATION(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,("whalCtrl_LNAControl: Set LAN to %d\n",LNAControlField));
+       
+       return whal_HwCtrl_LNAControl (pWhalCtrl->pHwCtrl, LNAControlField);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_data/whalDefrag.c b/sta_dk_4_0_4_32/common/src/hal/hl_data/whalDefrag.c
new file mode 100644 (file)
index 0000000..949365d
--- /dev/null
@@ -0,0 +1,241 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "whalDefrag_api.h"
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : findAndInsertEndpointIndex
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+static int findAndInsertEndpointIndex (TI_HANDLE hWhalDefrag, UINT8* mac, UINT8* idx)
+{
+       UINT8 i;
+       WHAL_DEFRAG *pWhalDefrag = (WHAL_DEFRAG *)hWhalDefrag;
+       
+       /* first search for the endpoint*/
+       for (i=0; i<pWhalDefrag->numCollectEntry; i++)
+       {
+               if ((pWhalDefrag->endpntMngr[i].inUse == TRUE) && 
+                       (os_memoryCompare (pWhalDefrag->hOs, pWhalDefrag->endpntMngr[i].srcMac, mac, MAC_ADDR_LEN) == 0))
+               {
+                       *idx = i;
+                       return OK;
+               }
+       }
+                                               
+       /* endpoint not found, now try to locate unused entry and insert the endpoint*/
+       for (i=0; i<pWhalDefrag->numCollectEntry; i++)
+       {
+               if (pWhalDefrag->endpntMngr[i].inUse == FALSE)
+               {
+                       pWhalDefrag->endpntMngr[i].inUse = TRUE;
+            os_memoryCopy (pWhalDefrag->hOs, pWhalDefrag->endpntMngr[i].srcMac, mac, MAC_ADDR_LEN);
+                       *idx = i;
+                       return OK;
+               }
+       }
+       
+       /* no free entry found*/
+       return NOK;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalDefrag_Create
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalDefrag_Create (TI_HANDLE hWhalCtrl, TI_HANDLE hOs, UINT8 numCollectEntries)
+{
+       UINT8 i;
+       WHAL_DEFRAG* pWhalDefrag;
+       
+       pWhalDefrag = (WHAL_DEFRAG *)os_memoryAlloc (hOs, sizeof(WHAL_DEFRAG));
+       if (pWhalDefrag == NULL)
+               return NULL;
+
+       os_memoryZero (hOs, pWhalDefrag, sizeof(WHAL_DEFRAG));
+
+       pWhalDefrag->hWhalCtrl = (WHAL_CTRL *)hWhalCtrl; 
+       pWhalDefrag->hOs = hOs;
+
+       /* get the number of fragment collection entries from HAL DB*/ 
+       pWhalDefrag->numCollectEntry = numCollectEntries;
+       
+       /* Create EndPoint objects*/
+       for (i=0; i<pWhalDefrag->numCollectEntry; i++)
+       {
+               pWhalDefrag->pWhalEndpntEnt[i] = whalEndpnt_Create (hWhalCtrl, hOs);
+               if (pWhalDefrag->pWhalEndpntEnt[i] == NULL)
+               {
+                       whalDefrag_Destroy(pWhalDefrag);
+                       return NULL;
+               }
+       }
+
+       return((TI_HANDLE)pWhalDefrag);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalDefrag_Config
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalDefrag_Config (TI_HANDLE hWhalDefrag, whalDefrag_config_t* pWhalDefragCfg)
+{
+       UINT8 i;
+       whalEndpnt_config_t whalEndpntCfg;
+       whalEndpnt_config_t* pWhalEndpntCfg     = &whalEndpntCfg;
+       WHAL_DEFRAG *pWhalDefrag = (WHAL_DEFRAG *)hWhalDefrag;
+       
+       /* Save configuration parameters */
+       pWhalDefrag->hReport = pWhalDefragCfg->hReport;
+       pWhalDefrag->hMemMngr = pWhalDefragCfg->hMemMngr;
+
+       /* Config EndPoint object */
+       pWhalEndpntCfg->hReport = pWhalDefrag->hReport;
+       pWhalEndpntCfg->hMemMngr = pWhalDefrag->hMemMngr;
+
+       for (i=0; i<pWhalDefrag->numCollectEntry; i++)
+                whalEndpnt_Config (pWhalDefrag->pWhalEndpntEnt[i], pWhalEndpntCfg);
+
+       return (OK);
+}                          
+    
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalDefrag_MpduCollect
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+collectStatus_e whalDefrag_MpduCollect (TI_HANDLE hWhalDefrag, mem_MSDU_T* pMpdu, mem_MSDU_T** pMsdu)
+{
+    UINT8 index;
+       dot11_header_t* pHeader;
+       UINT32          moreFrag;
+       collectStatus_e rc;
+       WHAL_DEFRAG *pWhalDefrag = (WHAL_DEFRAG *)hWhalDefrag;
+       UINT8 *bssid = whal_ParamsGetBssId(pWhalDefrag->hWhalCtrl->pWhalParams);
+       
+       if (pMpdu == NULL)
+               return (MPDU_DROP);
+
+       /*
+        * if the received bssid isn't match the current bssid we wan't to filter the those fragments,
+        * we don't expect to get fragments without the current bssid.
+        */
+       pHeader = (dot11_header_t*)((pMpdu->firstBDPtr->data) + memMgr_BufOffset(pMpdu->firstBDPtr));
+    moreFrag = (pHeader->fc & DOT11_FC_MORE_FRAG);
+       if(moreFrag && (os_memoryCompare(pWhalDefrag->hOs,(void *)bssid,(void *)pHeader->address2.addr,MAC_ADDR_LEN)!=0))
+       {
+               if (wlan_memMngrFreeMSDU(pWhalDefrag->hMemMngr, pMpdu->handle) != OK)
+                       WLAN_REPORT_ERROR(pWhalDefrag->hReport, HAL_RX_MODULE_LOG,
+                                         ("whalDefrag_MpduCollect: drop mpdu because moreFrag = %d && bssid = 0x%x   \n",moreFrag,pHeader->address2.addr[0],pHeader->address2.addr[1],pHeader->address2.addr[2],pHeader->address2.addr[3],pHeader->address2.addr[4],pHeader->address2.addr[5]));
+                       return (MPDU_DROP);
+       }
+
+       if (findAndInsertEndpointIndex (hWhalDefrag, (UINT8 *)pHeader->address2.addr, &index) == OK)
+       {
+               rc = whalEndpnt_FragCollect (pWhalDefrag->pWhalEndpntEnt[index], pMpdu, pMsdu);
+               
+        if (whalEndpnt_IsCollect (pWhalDefrag->pWhalEndpntEnt[index]) == FALSE)
+                       pWhalDefrag->endpntMngr[index].inUse = FALSE;
+               
+               return (rc);
+       }
+       else
+       {
+               WLAN_REPORT_ERROR(pWhalDefrag->hReport, HAL_RX_MODULE_LOG, 
+                                                  (" whalDefrag_MpduCollect: findAndInsertEndpointIndex failure, MPDU drop\n"));
+               if (wlan_memMngrFreeMSDU(pWhalDefrag->hMemMngr, pMpdu->handle) != OK)
+                       WLAN_REPORT_ERROR(pWhalDefrag->hReport, HAL_RX_MODULE_LOG,
+                                                         ("whalDefrag_MpduCollect: ERROR wlan_memMngrFreeMSDU failure \n"));
+               return (MPDU_DROP);
+       }
+}                   
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalDefrag_Destroy
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalDefrag_Destroy (TI_HANDLE hWhalDefrag)
+{
+       UINT8 i;
+       WHAL_DEFRAG *pWhalDefrag = (WHAL_DEFRAG *)hWhalDefrag;
+
+       if (pWhalDefrag == NULL)
+               return OK;
+
+       for (i=0; i<pWhalDefrag->numCollectEntry; i++)
+       {
+               /* Destroy EndPoint object */
+               if (whalEndpnt_Destroy (pWhalDefrag->pWhalEndpntEnt[i]) != OK)
+                       WLAN_REPORT_ERROR(pWhalDefrag->hReport, HAL_RX_MODULE_LOG, 
+                                                          (" whalDefrag_Destroy: whalEndpnt_Destroy failure \n"));
+       }
+                                                        
+       os_memoryFree (pWhalDefrag->hOs, pWhalDefrag, sizeof(WHAL_DEFRAG));
+       
+       return (OK);
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_data/whalDefrag_api.h b/sta_dk_4_0_4_32/common/src/hal/hl_data/whalDefrag_api.h
new file mode 100644 (file)
index 0000000..5e24243
--- /dev/null
@@ -0,0 +1,96 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_DEFRAG_API_H
+#define _WHAL_DEFRAG_API_H
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "memMngrEx.h"
+#include "whalEndpntEnt_api.h"
+
+#define MAX_SITES_FRAGMENT_COLLECTION          10
+
+/* CLASS WHAL_DEFRAG*/
+typedef struct
+{
+   UINT8 srcMac[MAC_ADDR_LEN];
+   BOOL  inUse;
+} whalDefrag_entMngr_t;
+
+typedef struct _WHAL_DEFRAG
+{
+       UINT32  duplicateCnt;
+       UINT32  mpduCnt;
+       UINT32  msduCnt;
+       UINT8   numCollectEntry;
+       
+       whalDefrag_entMngr_t endpntMngr[MAX_SITES_FRAGMENT_COLLECTION];
+       WHAL_ENDPNT* pWhalEndpntEnt[MAX_SITES_FRAGMENT_COLLECTION];     /* Pointer to the HL_HAL endpoint entry module*/
+
+       WHAL_CTRL* hWhalCtrl;       /* Pointer to the HL_HAL control module*/ 
+       
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMngr;
+} WHAL_DEFRAG;
+
+typedef struct 
+{
+       TI_HANDLE hReport; /* handle to the reporter module*/
+       TI_HANDLE hMemMngr; /* handle to the memory manager module*/ 
+} whalDefrag_config_t;
+
+typedef struct 
+{
+       UINT32  duplicateCnt;
+       UINT32  mpduCnt;
+       UINT32  msduCnt;
+} whalDefrag_counters_t;
+
+
+
+/* WHAL DEFRAG Class API*/                         
+TI_HANDLE whalDefrag_Create (TI_HANDLE hWhalCtrl, TI_HANDLE hOs, UINT8 numCollectEntries);
+
+int whalDefrag_Config (TI_HANDLE hWhalDefrag, whalDefrag_config_t* pWhalDefragCfg);
+
+collectStatus_e whalDefrag_MpduCollect (TI_HANDLE hWhalDefrag, mem_MSDU_T* pMpdu, mem_MSDU_T** pMsdu);
+
+int whalDefrag_CountersGet (TI_HANDLE hWhalDefrag, whalDefrag_counters_t* pWhalDefragCntr);
+
+int whalDefrag_Destroy (TI_HANDLE hWhalDefrag);
+#endif /* _WHAL_DEFRAG_API_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_data/whalEndpntEnt.c b/sta_dk_4_0_4_32/common/src/hal/hl_data/whalEndpntEnt.c
new file mode 100644 (file)
index 0000000..7d4c36e
--- /dev/null
@@ -0,0 +1,283 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include "whalEndpntEnt_api.h"
+
+                    
+/* debug counters - temporary to remove*/
+UINT32         duplicateMpdu = 0;
+UINT32         msduFreeNotInOrder = 0;
+UINT32         mpduValidFrames = 0;
+UINT32         duplicateMsdu = 0;
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : collectEntryFree
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+static void collectEntryFree (collectEntry_t* pCollectEnt)
+{
+       pCollectEnt->seqNum             = 0; 
+       pCollectEnt->fragNum    = 0;
+       pCollectEnt->msduPtr    = NULL;
+       pCollectEnt->lastBdPtr  = NULL;
+       pCollectEnt->timeStamp  = 0;
+       pCollectEnt->collect    = FALSE;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalEndpnt_Create
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalEndpnt_Create (TI_HANDLE hWhalCtrl, TI_HANDLE hOs)
+{
+       WHAL_ENDPNT* pWhalEndpnt;
+
+       pWhalEndpnt = (WHAL_ENDPNT *)os_memoryAlloc (hOs, sizeof(WHAL_ENDPNT));
+       if (pWhalEndpnt == NULL)
+               return NULL;
+
+       os_memoryZero (hOs, pWhalEndpnt, sizeof(WHAL_ENDPNT));
+
+       pWhalEndpnt->pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       pWhalEndpnt->hOs = hOs;
+
+       return((TI_HANDLE)pWhalEndpnt);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalEndpnt_Config
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalEndpnt_Config (TI_HANDLE hWhalEndpnt, whalEndpnt_config_t* pWhalEndpntCfg)
+{
+       WHAL_ENDPNT* pWhalEndpnt = (WHAL_ENDPNT *)hWhalEndpnt;
+       
+       /* Save configuration parameters */
+       pWhalEndpnt->hReport = pWhalEndpntCfg->hReport;
+       pWhalEndpnt->hMemMngr = pWhalEndpntCfg->hMemMngr;
+       
+    return (OK);
+}                          
+                                                   
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalEndpnt_IsCollect
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+BOOL whalEndpnt_IsCollect (TI_HANDLE hWhalEndpnt)
+{
+       WHAL_ENDPNT* pWhalEndpnt = (WHAL_ENDPNT *)hWhalEndpnt;
+       
+       return (pWhalEndpnt->collectEntry.collect);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalEndpnt_FragCollect
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+collectStatus_e        whalEndpnt_FragCollect (TI_HANDLE hWhalEndpnt, mem_MSDU_T* pMpdu, mem_MSDU_T** pMsdu)
+{
+    dot11_header_t*    pHeader;
+    UINT32          fragNumber;
+    UINT32          seqNumber;
+    UINT32          moreFrag;
+       WHAL_ENDPNT*    pWhalEndpnt = (WHAL_ENDPNT *)hWhalEndpnt;
+       collectEntry_t* collectEnt      = &(pWhalEndpnt->collectEntry);
+    
+       
+       /* initial checking on the received MPDU*/
+       if ((pMpdu == NULL) || (pMpdu->firstBDPtr == NULL) || (pMpdu->lastBDPtr == NULL))
+               WLAN_REPORT_FATAL_ERROR(pWhalEndpnt->hReport, HAL_RX_MODULE_LOG, 
+                                                               (" whalEndpnt_FragCollect: original Mpdu pointers with NULL !\n"));
+       
+       *pMsdu = NULL;
+       pHeader = (dot11_header_t*)memMgr_MsduHdrAddr(pMpdu);
+
+       fragNumber = (pHeader->seqCtrl & 0x000F);
+    seqNumber  = (pHeader->seqCtrl & 0xFFF0) >> 4;
+    moreFrag = (pHeader->fc & DOT11_FC_MORE_FRAG);
+
+       if ((seqNumber == collectEnt->seqNum) && (collectEnt->collect == TRUE)) 
+       {
+               /* This MPDU belongs to the current collection of the MSDU */
+        if (fragNumber == (collectEnt->fragNum+1)) 
+               {
+            /* This is the next MPDU of the current MSDU */
+            /* Update the new MPDU */
+            collectEnt->fragNum++;
+                                                                                         /* (!!!YV) to change WLAN_HDR_LEN to pMpdu->headerLen*/ 
+                       collectEnt->msduPtr->dataLen += (pMpdu->dataLen - WLAN_HDR_LEN); /* Update MSDU length */
+            pMpdu->firstBDPtr->dataOffset += WLAN_HDR_LEN; /* Point to the start of the Data */
+            pMpdu->firstBDPtr->length -= WLAN_HDR_LEN;
+                       
+                       /* internal structure checking*/
+                       if (collectEnt->lastBdPtr == NULL)
+            {
+                               WLAN_REPORT_ERROR(pWhalEndpnt->hReport, HAL_RX_MODULE_LOG, 
+                                                                 (" whalEndpnt_FragCollect: collectEnt->lastBdPtr is NULL !!!!!!!!!!\n"));
+                               wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, pMpdu->handle);
+                               msduFreeNotInOrder++;
+                               return MPDU_DUP_DROP;
+            }
+                       collectEnt->lastBdPtr->nextBDPtr = pMpdu->firstBDPtr; /* Update the BD list */
+               collectEnt->lastBdPtr = pMpdu->lastBDPtr;
+                       collectEnt->msduPtr->lastBDPtr = pMpdu->lastBDPtr; 
+
+                       /* Recycle the recieved MPDU header only*/
+                       pMpdu->firstBDPtr = NULL;
+                       wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, pMpdu->handle);
+
+            mpduValidFrames++;
+        }
+        else if (fragNumber <= collectEnt->fragNum) 
+                        {
+                               /* Order ERROR or Duplication- NEED to Drop the recieved MPDU */
+                               wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, pMpdu->handle);
+                               duplicateMpdu++;
+                               return MPDU_DUP_DROP;
+                        }
+                        else
+                        {
+                               /* We lost one of the Fragments fragNumber > (collectEnt->fragNum+1)
+                                  Need to free all the Fragments of the current MSDU */
+                               wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, pMpdu->handle);
+                               wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, collectEnt->msduPtr->handle);
+                               collectEntryFree (collectEnt);
+                               msduFreeNotInOrder++;
+                               return MSDU_DROP;
+                        }
+    }
+    else 
+       {  
+               /* This MPDU is part of a new MSDU */
+        if (collectEnt->collect == TRUE) 
+               {
+            /* Still in the middle of collecting the previous MSDU
+               Need to drop the previous MSDU */
+            wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, collectEnt->msduPtr->handle);
+            collectEntryFree (collectEnt);
+            msduFreeNotInOrder++;
+        }
+        
+        if (fragNumber != 0) 
+               {
+            /* MPDU not in order. This is should first MPDU and must be 0
+                          Need to drop the MPDU */
+            wlan_memMngrFreeMSDU(pWhalEndpnt->hMemMngr, pMpdu->handle);
+            msduFreeNotInOrder++;
+                       WLAN_REPORT_INFORMATION(pWhalEndpnt->hReport, HAL_RX_MODULE_LOG, 
+                                                         (" whalEndpnt_FragCollect:  MPDU not in order. fragNumber = %d seqNumber = %d",
+                                                         fragNumber, seqNumber));
+               
+                       return MPDU_DROP;
+        }
+        
+       /* New MSDU */
+        mpduValidFrames++;
+        collectEnt->msduPtr = pMpdu;
+           collectEnt->lastBdPtr = pMpdu->lastBDPtr;
+        collectEnt->collect = TRUE;
+        collectEnt->seqNum = seqNumber;
+
+
+    }
+
+    /* Check if the MSDU collection finished */
+    if (!moreFrag) 
+       {
+        /* MSDU collection terminated */
+        *pMsdu = collectEnt->msduPtr;
+        collectEntryFree (collectEnt);
+        return MSDU_READY;
+    }
+
+
+    return MSDU_IN_PROGRESS;
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalEndpnt_Destroy
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalEndpnt_Destroy (TI_HANDLE hWhalEndpnt)
+{
+       WHAL_ENDPNT* pWhalEndpnt = (WHAL_ENDPNT *)hWhalEndpnt;
+
+       if (pWhalEndpnt)
+               os_memoryFree (pWhalEndpnt->hOs, pWhalEndpnt, sizeof(WHAL_ENDPNT));
+       
+       return (OK);
+}
+
+
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hl_data/whalEndpntEnt_api.h b/sta_dk_4_0_4_32/common/src/hal/hl_data/whalEndpntEnt_api.h
new file mode 100644 (file)
index 0000000..400f2d9
--- /dev/null
@@ -0,0 +1,94 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_ENDPNT_H
+#define _WHAL_ENDPNT_H
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "memMngrEx.h"
+
+/* CLASS WHAL_ENDPNT*/
+typedef enum 
+{
+    MSDU_READY = 0,
+    MSDU_IN_PROGRESS,
+    MPDU_DROP,
+    MPDU_DUP_DROP,
+       MSDU_DROP
+} collectStatus_e;
+
+typedef struct 
+{
+    UINT32          seqNum;    /* The sequence number of the last MSDU received from the station*/ 
+    UINT32          fragNum;   /* The fragment number of the last fragment received from the station*/ 
+       mem_MSDU_T*     msduPtr;   /* Pointer to the MSDU structure*/ 
+       mem_BD_T*               lastBdPtr; /* Pointer to the last fragment in the collection*/ 
+       UINT32                  timeStamp; /* A timestamp contains the receive time of the first fragment in the collection,
+                                                             if any*/ 
+       BOOL                    collect;        /* designates if the station is in a middle of a fragment collection*/
+} collectEntry_t;
+
+typedef struct _WHAL_ENDPNT
+{
+       collectEntry_t collectEntry;
+
+       WHAL_CTRL *pWhalCtrl;       /* Pointer to the HL_HAL control module*/ 
+
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMngr;
+
+} WHAL_ENDPNT;
+
+typedef struct 
+{
+       TI_HANDLE hReport; /* handle to the reporter module*/
+       TI_HANDLE hMemMngr; /* handle to the memory manager module*/ 
+} whalEndpnt_config_t;
+
+
+/* WHAL ENDPOINT Class API*/                       
+TI_HANDLE whalEndpnt_Create (TI_HANDLE hWhalCtrl, TI_HANDLE hOs);
+
+int whalEndpnt_Config (TI_HANDLE hWhalEndpnt, whalEndpnt_config_t* pWhalEndpntCfg);
+
+collectStatus_e        whalEndpnt_FragCollect (TI_HANDLE hWhalEndpnt, mem_MSDU_T* pMpdu, mem_MSDU_T** pMsdu);
+
+BOOL whalEndpnt_IsCollect (TI_HANDLE hWhalEndpnt);
+
+int whalEndpnt_Destroy (TI_HANDLE hWhalEnpnt);
+#endif /* _WHAL_ENDPNT_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwCtrl.c b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwCtrl.c
new file mode 100644 (file)
index 0000000..c969ca6
--- /dev/null
@@ -0,0 +1,3220 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwCtrl.c
+ *   PURPOSE: Implements action on the wlan hardware card (Reset, Run, SendCmd, Sw Download)
+ *
+ ****************************************************************************/
+
+#include "802_11Defs.h"
+#include "Ethernet.h"
+#include "whalCommon.h"
+  
+#include "whalCtrl_api.h"
+#include "whalHwDefs.h"
+#include "whalHwCtrl.h"
+#include "whalHwMboxCmd.h"
+#include "whalHwMboxConfig.h"
+#include "eventMbox_api.h"
+#include "whalParams.h"
+#include "commonTypes.h"
+#include "txResult_api.h"
+#include "TNETW_Driver_api.h"
+#include "TNETW_Driver.h"
+#include "whalSecurity.h"
+
+
+#define ACX_POWER_MGMT_OPTIONS_STRUCT_DEBUG 0
+
+int  whal_hwCtrl_ConfigTemplates(HwCtrl_T *pHwCtrl);
+int  whal_hwCtrl_ConfigQueues(HwCtrl_T *pHwCtrl, UINT32 MemoryStart);
+void whal_hwCtrl_OverridePhyRegsDefaults(HwCtrl_T *pHwCtrl);
+
+
+#define CF_FORM_FACTOR          3 /* Compact Flash*/
+
+#define CB_FORM_FACTOR          1 /* Card Bus */
+
+/****************************************************************************
+ *                      whal_hwCtrl_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the wlan hardware control object
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+HwCtrl_T *whal_hwCtrl_Create(TI_HANDLE hOs, WhalParams_T *pWhalParams)
+{
+    HwCtrl_T *pHwCtrl;
+
+    pHwCtrl = os_memoryAlloc(hOs, sizeof(HwCtrl_T));
+    if (pHwCtrl == NULL)
+        return NULL;
+
+    os_memoryZero(hOs, (void*)pHwCtrl, sizeof(HwCtrl_T));
+
+    pHwCtrl->hOs = hOs;
+    pHwCtrl->pWhalParams = pWhalParams;
+    pHwCtrl->pHwMboxCmd     = whal_hwMboxCmd_Create(hOs, pHwCtrl->pWhalParams);
+    pHwCtrl->pHwMboxCmdBit  = whal_hwMboxCmdBit_Create(hOs);
+    pHwCtrl->pHwMboxConfig  = whal_hwMboxConfig_Create(hOs);
+    pHwCtrl->hWhalBus       = whalBus_Create(hOs);
+
+    if ( (!pHwCtrl->pHwMboxCmd) || (!pHwCtrl->pHwMboxConfig) || (!pHwCtrl->hWhalBus) )
+    {
+        whal_hwCtrl_Destroy(pHwCtrl);
+        return NULL;
+    }
+
+    return(pHwCtrl);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object 
+ * 
+ * INPUTS:  
+ *      pHwCtrl     The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_Destroy(HwCtrl_T *pHwCtrl)
+{
+    if (pHwCtrl == NULL)
+        return OK;
+
+    whal_hwMboxCmd_Destroy(pHwCtrl->pHwMboxCmd);
+    whal_hwMboxCmdBit_Destroy(pHwCtrl->pHwMboxCmdBit);
+    whal_hwMboxConfig_Destroy(pHwCtrl->pHwMboxConfig);
+    whalBus_Destroy(pHwCtrl->hWhalBus);
+
+    os_memoryFree(pHwCtrl->hOs, pHwCtrl, sizeof(HwCtrl_T));
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetTnentwifHandle()
+ ****************************************************************************
+ * DESCRIPTION: Return TNETWIF handle 
+ * 
+ * INPUTS:  
+ *      pHwCtrl     The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: TNETWIF handle
+ ****************************************************************************/
+TI_HANDLE whal_hwCtrl_GetTnentwifHandle (HwCtrl_T *pHwCtrl)
+{
+    return whalBus_GetTnentwifHandle (pHwCtrl->hWhalBus);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_StartJoin()
+ ****************************************************************************
+ * DESCRIPTION: Enable Rx/Tx and send Start/Join command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_StartJoin(HwCtrl_T *pHwCtrl, bssType_e BssType, void *JoinCompleteCB, TI_HANDLE CB_handle)
+{
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+    UINT8 HwBssType;
+#ifdef TI_DBG  
+    UINT8 *pBssId = whal_ParamsGetBssId(pHwCtrl->pWhalParams);
+
+    WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                     ("whal_hwCtrl_StartJoin: Enable Tx, Rx and Start the Bss, type=%d\n", BssType));
+    WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                     ("------------------------------------------------------------\n"));
+    WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                     ("START/JOIN, SSID=%s, BSSID=%02X-%02X-%02X-%02X-%02X-%02X, Chan=%d\n", whal_ParamsGetElm_Ssid(pHwCtrl->pWhalParams)->serviceSetId, pBssId[0], pBssId[1], pBssId[2], pBssId[3], pBssId[4], pBssId[5], whal_ParamsGetRadioChannel(pHwCtrl->pWhalParams)));
+    WLAN_REPORT_INIT(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                     ("------------------------------------------------------------\n"));
+#endif /* TI_DBG */
+
+    /* 
+     * Set frame rates according to the values previously configured:
+     * Driver join -> as configured to whalCtrl_JoinBss()
+     * GWSI join   -> as configured to the template framed before, or default values
+     * Recovery    -> Saved parameters from last Join command
+     */
+    whal_hwCtrl_SetFrameRate(pHwCtrl,
+                             pHwCtrl->pWhalParams->BssInfoParams.txCtrlFrmRate,
+                             pHwCtrl->pWhalParams->BssInfoParams.txCtrlFrmModulation,
+                             pHwCtrl->pWhalParams->BssInfoParams.txMgmtFrmRate,
+                             pHwCtrl->pWhalParams->BssInfoParams.txMgmtFrmModulation);
+    /*
+     * set RxFilter (but don't write it to the FW, this is done in the join command),
+     * Configure templates content, ...
+     */
+    whal_hwCtrl_SetBssType(pHwCtrl, BssType, &HwBssType);
+
+    return whal_hwMboxCmd_StartBss(pHwMboxCmd, HwBssType, JoinCompleteCB, CB_handle);
+
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_switchChannel()
+ ****************************************************************************
+ * DESCRIPTION: Switching the serving channel 
+ * 
+ * INPUTS: channel  -   new channel number  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_switchChannel(HwCtrl_T *pHwCtrl,UINT8 channel)
+{
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+
+    return whal_hwMboxCmd_EnableTx(pHwMboxCmd,channel);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_DisableTx()
+ ****************************************************************************
+ * DESCRIPTION: Disable Tx path. 
+ * 
+ * INPUTS: None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_DisableTx(HwCtrl_T *pHwCtrl)
+{
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+
+    return whal_hwMboxCmd_DisableTx(pHwMboxCmd);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_EnableTx()
+ ****************************************************************************
+ * DESCRIPTION: Disable Tx path. 
+ * 
+ * INPUTS: channel  -   new channel number
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_EnableTx(HwCtrl_T *pHwCtrl, int channel)
+{
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+
+    return whal_hwMboxCmd_EnableTx(pHwMboxCmd, (UINT8)channel);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_EnableDataPath()
+ ****************************************************************************
+ * DESCRIPTION: Enable Rx/Tx and send Start/Join command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_EnableDataPath(HwCtrl_T *pHwCtrl)
+{
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+
+    whal_hwMboxCmd_EnableRx(pHwMboxCmd);
+    whal_hwMboxCmd_EnableTx(pHwMboxCmd, whal_ParamsGetDefaultChannel(pHwCtrl->pWhalParams));
+    
+
+#ifdef WDBG_POLLING /* (!!!) ONLY FOR DEBUG WHEN THERE ARE NO INTERRUPTS */
+
+    /* allocate OS timer memory */
+    hal_timer = os_timerCreate(pHwCtrl->hOs, whal_hwCtrl_RxPollingTimeout, (TI_HANDLE) pHwCtrl);
+    if (!hal_timer)
+        return NOK;
+
+    os_timerStart(pHwCtrl->hOs, hal_timer, 20, FALSE);
+#endif
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_EnableDataPath()
+ ****************************************************************************
+ * DESCRIPTION: Enable Rx/Tx and send Start/Join command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_DisableDataPath(HwCtrl_T *pHwCtrl)
+{
+#if 0
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+    /*
+     * L.M. removed because of two reasons: 
+     * 1. When the FW is dead, it only adds delay to recovery.
+     * 2. WSP does not have it.
+     */
+
+    whal_hwMboxCmd_DisableTx(pHwMboxCmd);
+    whal_hwMboxCmd_DisableRx(pHwMboxCmd);
+
+    
+/*  use FwEvent ... whalBus_hwIntr_Disable(pHwCtrl->hWhalBus, HAL_ALL_INTERRUPTS); */
+#endif
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetBssType()
+ ****************************************************************************
+ * DESCRIPTION: Set Bss type, set RxFilter 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetBssType(HwCtrl_T *pHwCtrl, bssType_e BssType, UINT8 *HwBssType)
+{
+    switch (BssType)
+    {
+    case BSS_AP:
+        whal_ParamsSetBssType(pHwCtrl->pWhalParams, BSS_TYPE_AP_BSS);
+        whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_ANY_DST_MY_BSS, RX_FILTER_OPTION_DEF);
+        break;
+
+    case BSS_INFRASTRUCTURE:
+        whal_ParamsSetBssType(pHwCtrl->pWhalParams, BSS_TYPE_STA_BSS);
+        whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_FOR_JOIN, RX_FILTER_OPTION_JOIN);
+        break;
+
+    case BSS_INDEPENDENT:
+        whal_ParamsSetBssType(pHwCtrl->pWhalParams, BSS_TYPE_IBSS);
+       #ifdef GWSI_LIB
+        /* In GWSI we filter with SSID. This is not done in the full driver because of RTP version. 
+          * In the future leave only GWSI option for both cases.
+          */
+        whal_ParamsSetRxFilter(pHwCtrl->pWhalParams,  RX_CONFIG_OPTION_FOR_IBSS_JOIN, RX_FILTER_OPTION_DEF);
+       #else
+        whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RX_CONFIG_OPTION_FOR_JOIN, RX_FILTER_OPTION_DEF);
+       #endif
+        break;
+
+    default: 
+        WLAN_REPORT_FATAL_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                                ("whal_hwCtrl_SetBssType: FATAL_ERROR, unknown BssType %d\n", BssType));
+        return NOK;
+    }
+
+    *HwBssType = whal_ParamsGetBssType(pHwCtrl->pWhalParams);
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_setRxFilters()
+ ****************************************************************************
+ * DESCRIPTION: Sets the filters according to the given configuration. 
+ * 
+ * INPUTS:  RxConfigOption  - The given Rx filters configuration
+ *          RxFilterOption  - The given Rx filters options
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_setRxFilters(HwCtrl_T *pHwCtrl, UINT32 RxConfigOption, UINT32 RxFilterOption)
+{
+    whal_ParamsSetRxFilter(pHwCtrl->pWhalParams, RxConfigOption, RxFilterOption);
+
+    return whal_hwInfoElemRxConfigSet (pHwCtrl->pHwMboxConfig,
+                                   &pHwCtrl->pWhalParams->WlanParams.RxConfigOption,
+                                       &pHwCtrl->pWhalParams->WlanParams.RxFilterOption);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetRxFilters()
+ ****************************************************************************
+ * DESCRIPTION: Sets the filters according to the given configuration. 
+ * 
+ * INPUTS:  RxConfigOption  - The given Rx filters configuration
+ *          RxFilterOption  - The given Rx filters options
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GetRxFilters(HwCtrl_T *pHwCtrl, UINT32* pRxConfigOption, UINT32* pRxFilterOption)
+{
+    whal_ParamsGetRxFilter(pHwCtrl->pWhalParams, pRxConfigOption, pRxFilterOption);
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                 whal_hwCtrl_setRxDataFiltersParams()
+ ****************************************************************************
+ * DESCRIPTION: Enables or disables Rx data filtering.
+ * 
+ * INPUTS:  enabled             - 0 to disable data filtering, any other value to enable.
+ *          defaultAction       - The default action to take on non-matching packets.
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_setRxDataFiltersParams(HwCtrl_T * pHwCtrl, BOOL enabled, filter_e defaultAction)
+{
+    return whal_hwInfoElemSetRxDataFiltersParams(pHwCtrl->pHwMboxConfig, enabled, defaultAction);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_setRxDataFilter()
+ ****************************************************************************
+ * DESCRIPTION: Sets the filters according to the given configuration. 
+ * 
+ * INPUTS:  index               - Index of the Rx Data filter
+ *          command             - Add or remove the filter
+ *          action              - Action to take on packets matching the pattern
+ *          numFieldPatterns    - Number of field patterns in the filter
+ *          lenFieldPatterns    - Length of the field pattern series
+ *          fieldPatterns       - Series of field patterns
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_setRxDataFilter(HwCtrl_T * pHwCtrl, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns)
+{
+    return whal_hwInfoElemSetRxDataFilter(pHwCtrl->pHwMboxConfig, 
+        index, command, action, numFieldPatterns, lenFieldPatterns, fieldPatterns);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetarpIpAddressesTable()
+ ****************************************************************************
+ * DESCRIPTION: Sets the ARP IP table according to the given configuration. 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetarpIpAddressesTable (HwCtrl_T *pHwCtrl, IpAddress_t *IP_addr, UINT8 isEnabled , IPver_e IP_ver)
+{
+    if ( NULL == IP_addr )
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+                    ("whal_hwCtrl_SetarpIpAddressesTable: Ip Addr ptr = NULL !!!\n"));  
+
+        return PARAM_VALUE_NOT_VALID ;
+    }
+
+    whal_ParamsSetarpIpAddressesTable(pHwCtrl->pWhalParams, IP_addr, IP_ver);
+    whal_ParamsSetarpIpFilterEnabled(pHwCtrl->pWhalParams, isEnabled);
+
+    WLAN_REPORT_DEBUG_CONTROL (pHwCtrl->hReport,
+                              ("\n  whal_hwCtrl_SetarpIpAddressesTable - ip filtering : %d.%d.%d.%d \n" , IP_addr->addr[0] , IP_addr->addr[1] , IP_addr->addr[2] , IP_addr->addr[3] )) ;
+
+    /* Set the new ip with the current state (e/d) */
+    return whal_hwInfoElemarpIpAddressesTableSet (pHwCtrl->pHwMboxConfig, 
+                                              IP_addr, 
+                                                  (UINT32)isEnabled);
+}
+
+ /****************************************************************************
+ *                      whalCtrl_GetArpIpAddressesTable()
+ ****************************************************************************
+ * DESCRIPTION: Sets the Group table according to the given configuration. 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_GetArpIpAddressesTable (HwCtrl_T *pHwCtrl, IpAddress_t *IP_addr, UINT8* pisEnabled , IPver_e* pIP_ver)
+{
+    if ( NULL == pHwCtrl ) 
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+            ("whalCtrl_GetArpIpAddressesTable  = pHwCtrl NULL !!!\n")); 
+
+        return PARAM_VALUE_NOT_VALID ;
+    }
+
+        if ( NULL ==  pHwCtrl->pWhalParams ) 
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+            ("whalCtrl_GetArpIpAddressesTable  = pHwCtrl->pWhalParams NULL !!!\n"));    
+
+        return PARAM_VALUE_NOT_VALID ;
+
+    }
+
+    whal_ParamsGetarpIpAddressesTable(pHwCtrl->pWhalParams, IP_addr, pIP_ver);
+    whal_ParamsGetarpIpFilterEnabled(pHwCtrl->pWhalParams, pisEnabled);
+    return OK;
+}
+
+ /****************************************************************************
+ *                      whal_hwCtrl_SetarpIpFilterEnabled()
+ ****************************************************************************
+ * DESCRIPTION: Enable\Disable the ARP filter 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetarpIpFilterEnabled(HwCtrl_T *pHwCtrl, UINT8 isEnabled ) 
+{
+    IpAddress_t *IP_addr = &(pHwCtrl->pWhalParams->WlanParams.arp_IP_addr) ;
+    if ( NULL == pHwCtrl )
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+                    ("whal_hwCtrl_SetarpIpFilterEnabled  = pHwCtrl NULL !!!\n"));   
+
+        return PARAM_VALUE_NOT_VALID ;
+    }
+
+    /* set the current ip address with the new state (e/d) */
+    whal_ParamsSetarpIpFilterEnabled(pHwCtrl->pWhalParams, isEnabled);
+    return whal_hwInfoElemarpIpAddressesTableSet (pHwCtrl->pHwMboxConfig,  
+                                              IP_addr,
+                                                  (UINT32)isEnabled);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetGroupAddressesTable()
+ ****************************************************************************
+ * DESCRIPTION: Sets the Group table according to the given configuration. 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetGroupAddressesTable (HwCtrl_T *pHwCtrl,
+                                        UINT8 numGroupAddrs, 
+                                        macAddress_t *Group_addr,
+                                        UINT8 isEnabled)
+{
+    if ( NULL == pHwCtrl ) 
+    {
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    if ( NULL == Group_addr)
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+                    ("whal_hwCtrl_SetGroupAddressesTable: numGroupAddrs=%d Group_addr=0x%x  !!!\n", numGroupAddrs , Group_addr));       
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+   /* Keeps the parameters in the whal */
+    whal_ParamsSetGroupAddressesTable(pHwCtrl->pWhalParams, isEnabled, numGroupAddrs, Group_addr);
+
+    /* Keeps the parameters in the whal for recovery */
+    return whal_hwInfoElemGroupAdressesTableSet (pHwCtrl->pHwMboxConfig, 
+                                                 &numGroupAddrs, 
+                                                 Group_addr,   
+                                                 &isEnabled);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetRtsThreshold()
+ ****************************************************************************
+ * DESCRIPTION: Sets the Rts Threshold. 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK  pWlanParams->RtsThreshold
+ ****************************************************************************/
+int whal_hwCtrl_SetRtsThreshold (HwCtrl_T *pHwCtrl,UINT16 RtsThreshold)
+{
+    return whal_hwInfoElemRtsThresholdSet (pHwCtrl->pHwMboxConfig, RtsThreshold);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_ConfigCb()
+ ****************************************************************************
+ * DESCRIPTION: Config the object 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static void whal_hwCtrl_ConfigCb (TI_HANDLE hHwCtrl, TI_STATUS status)
+{
+    HwCtrl_T     *pHwCtrl = (HwCtrl_T*)hHwCtrl; 
+    WHAL_CTRL    *pWhalCtrl = (WHAL_CTRL *)pHwCtrl->hWhalCtrl;
+    whal_hwMboxCmd_Config(pHwCtrl->pHwMboxCmd, ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, pHwCtrl->hReport);
+    CmdQueue_Config(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue,
+                    ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdMBox, pHwCtrl->hReport);
+    whal_hwMboxCmdBit_Config(pHwCtrl->hWhalCtrl, pHwCtrl->pHwMboxCmdBit, ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, pHwCtrl->hReport);
+    whal_hwMboxConfig_Config(pHwCtrl->pHwMboxConfig, ((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, pHwCtrl->hReport);
+
+    /* This will initiate the download to the FW */
+    status = whal_hwCtrl_Initiate (pHwCtrl);
+    if (status == TNETWIF_ERROR)
+    {
+        WLAN_REPORT_ERROR (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                           ("whal_hwCtrl_Config: failed to initialize\n"));
+    }
+}
+
+ /****************************************************************************
+ *                      whal_hwCtrl_GetGroupAddressesTable()
+ ****************************************************************************
+ * DESCRIPTION: Sets the Group table according to the given configuration. 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GetGroupAddressesTable (HwCtrl_T *pHwCtrl,
+                                        UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr)
+{
+    if ( NULL == pHwCtrl ) 
+    {
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    if ( (NULL == pisEnabled) || (NULL == pnumGroupAddrs) || (NULL == Group_addr))
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
+                    ("whal_hwCtrl_GetGroupAddressesTable: pisEnabled=0x%p pnumGroupAddrs=0x%p  Group_addr=0x%p !!!\n", pisEnabled , pnumGroupAddrs, Group_addr));       
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    whal_ParamsGetGroupAddressesTable(pHwCtrl->pWhalParams, pisEnabled, pnumGroupAddrs, Group_addr);
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_Config()
+ ****************************************************************************
+ * DESCRIPTION: Config the object 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whal_hwCtrl_Config
+(
+    HwCtrl_T   *pHwCtrl, 
+    TI_HANDLE   hWhalCtrl,
+    UINT8       AccessMode, 
+    UINT32      AcxRegAddr, 
+    UINT32      AcxMemAddr, 
+    TI_HANDLE   hReport, 
+    TI_HANDLE   hMemMgr,
+    UINT32     *pFWImage,
+    TI_HANDLE   hEventMbox
+)
+{
+    pHwCtrl->hReport = hReport;
+    pHwCtrl->hWhalCtrl = hWhalCtrl;
+    pHwCtrl->hEventMbox = hEventMbox;
+
+    /* 
+     * NOTE: Save firmware image parameters before the 1st TNETWIF call.
+     *       These parameters are passed from the user application and
+     *       may be lost in a case TNETWIF call is asynchronous. 
+     */
+    pHwCtrl->uFwBuf = pFWImage[0];
+    pHwCtrl->uFwAddr = pFWImage[1];
+    pHwCtrl->uEEEPROMBuf = pFWImage[2];
+    pHwCtrl->uEEEPROMLen = pFWImage[3];
+
+    return whalBus_Config (pHwCtrl->hWhalBus, 
+                           hWhalCtrl, 
+                           AccessMode, 
+                           AcxRegAddr, 
+                           AcxMemAddr, 
+                           hReport, 
+                           hMemMgr, 
+                           whal_hwCtrl_ConfigCb, 
+                           pHwCtrl);
+}   
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_FinalizeDownloadCb2()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the remaining initialization after the download has finished 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static void whal_hwCtrl_FinalizeDownloadCb2 (TI_HANDLE hHwCtrl, TI_STATUS status, void *pData)
+{
+    HwCtrl_T      *pHwCtrl = (HwCtrl_T *)hHwCtrl;     
+    whalCtrl_antennaDiversityOptions_t antennaDiversityOptions;                   
+
+    /* Print firmware version */
+    whal_ParamsPrintFwVersion (pHwCtrl->pWhalParams);
+
+    /*
+     * Configure antenna diversity parameters, same for both radio types.
+     * (the only difference between DCR and WBR is the antennas number, which is 
+     * hard-coded in the mbox config function per radio type 
+     */
+    antennaDiversityOptions.enableRxDiversity = FALSE;
+    antennaDiversityOptions.rxSelectedAntenna = DIVS_RX_START_ANT2;
+    antennaDiversityOptions.enableTxDiversity = FALSE;
+    antennaDiversityOptions.txSelectedAntenna = DIVS_TX_START_ANT2;
+    antennaDiversityOptions.rxTxSharedAnts = TRUE;
+    whal_hwCtrl_SaveAntennaDiversityOptions (pHwCtrl, &antennaDiversityOptions);
+
+    whalCtrl_FinalizeDownload (pHwCtrl->hWhalCtrl);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_FinalizeDownloadCb1()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the remaining initialization after the download has finished 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static void whal_hwCtrl_FinalizeDownloadCb1 (TI_HANDLE hHwCtrl, TI_STATUS status, void *pData)
+{
+    HwCtrl_T      *pHwCtrl = (HwCtrl_T *)hHwCtrl;     
+    ACXRevision_t *pACXRevision = whal_ParamsGetAcxVersion (pHwCtrl->pWhalParams);   
+    UINT8         *pStationId = ((dot11StationIDStruct*)pData)->dot11StationID;
+    UINT32         i;
+
+    /* Swap bytes of the station id */
+    for (i = 0; i < 3; i++)
+    {
+        UINT8 uTmp = pStationId[i];
+        pStationId[i] = pStationId[5 - i]; 
+        pStationId[5 - i] = uTmp; 
+    }
+
+    whal_ParamsSetSrcMac (pHwCtrl->pWhalParams, (char*)pStationId);
+
+    /* Get firmware version */
+    whal_hwInfoElemAcxRevisionGet (pHwCtrl->pHwMboxConfig, 
+                                   (void *)whal_hwCtrl_FinalizeDownloadCb2,
+                                   hHwCtrl,
+                                   pACXRevision);
+}
+                            
+
+/****************************************************************************
+ *                      whal_hwCtrl_FinalizeDownload()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the remaining initialization after the download has finished 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whal_hwCtrl_FinalizeDownload (TI_HANDLE hHwCtrl, BootAttr_T *pBootAttr)
+{
+    HwCtrl_T *pHwCtrl= (HwCtrl_T *)hHwCtrl;     
+
+    /* 
+     * Just comment it since we may need it in future version when we will read from the NVS the 
+     * Configure options (for example power levels)
+     */
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams (pHwCtrl->pWhalParams);
+    
+    /* Read NVS version */
+    pWlanParams->radioType   = pBootAttr->radioType;
+    pWlanParams->minorE2Ver  = pBootAttr->minorE2Ver;
+    pWlanParams->majorE2Ver  = pBootAttr->majorE2Ver;
+    pWlanParams->bugfixE2Ver = pBootAttr->bugfixE2Ver;
+    
+    /*
+     * Read config options (WLAN hardware EEPROM). Must be before any configuration 
+     * because the WLAN hardware put the data in the mbox after running the FW
+     * Not used by now but keep it in code since the data may be requested later on when the 
+     * NVS data will be read from the driver and not from the INI: 
+     * For example the number of power level 
+     * whal_hwInfoElemConfigOptionsRead(pHwCtrl->pHwMboxConfig, pConfigOptions);
+     */
+    if (whal_hwInfoElemStationIdGet (pHwCtrl->pHwMboxConfig, 
+                                     (void *)whal_hwCtrl_FinalizeDownloadCb1,
+                                     hHwCtrl,
+                                     &pHwCtrl->mbox) != OK)
+    {
+        WLAN_REPORT_ERROR (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                           ("whal_hwCtrl_Config: Error on whal_hwInfoElemStationIdGet\n"));
+        /* For driver debug only, don't return error */
+        /* return NOK; */
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_FinalizeOnFailure()
+ ****************************************************************************
+ * DESCRIPTION: Finalize all the initialization upon failure
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whal_hwCtrl_FinalizeOnFailure (TI_HANDLE hHwCtrl)
+{
+    HwCtrl_T *pHwCtrl= (HwCtrl_T *)hHwCtrl;     
+
+    return whalCtrl_FinalizeOnFailure (pHwCtrl->hWhalCtrl);
+}
+
+
+
+
+
+typedef int (*fcallback_t) (TI_HANDLE, TI_STATUS);
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_ConfigHwCb2()
+ ****************************************************************************
+ * DESCRIPTION: Configure the WLAN hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT: None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static int whal_hwCtrl_ConfigHwCb2 (HwCtrl_T *pHwCtrl, TI_STATUS status, void *pData)
+{
+    WlanParams_T   *pWlanParams = whal_ParamsGetWlanParams (pHwCtrl->pWhalParams);
+    UINT8          *pSrcMacAddr = whal_ParamsGetSrcMac (pHwCtrl->pWhalParams);
+    UINT32          acID; 
+    whalCtrl_powerMgmtConfig_t powerMgmtConfig;                   
+
+    /* Arrived from callback */
+    if (pData)
+    {
+        ACXDataPathParamsResp_t *pCfg = &pHwCtrl->DataPathParams;
+
+        WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, 
+            ("%s: rxPacketRingChunkSize = 0x%x,txPacketRingChunkSize = 0x%x,rxPacketRingAddr = 0x%x\n",
+            __FUNCTION__,pCfg->rxPacketRingChunkSize,pCfg->txPacketRingChunkSize,pCfg->rxPacketRingAddr));
+        
+        WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, 
+            ("(cont')%s: txPacketRingAddr = 0x%x,rxControlAddr = 0x%x,txControlAddr = 0x%x,txCompleteAddr = 0x%x\n",
+            __FUNCTION__,pCfg->txPacketRingAddr,pCfg->rxControlAddr,pCfg->txControlAddr,pCfg->txCompleteAddr));     
+
+        pCfg->rxPacketRingChunkSize = ENDIAN_HANDLE_WORD(pCfg->rxPacketRingChunkSize);
+        pCfg->txPacketRingChunkSize = ENDIAN_HANDLE_WORD(pCfg->txPacketRingChunkSize);
+        pCfg->rxPacketRingAddr      = ENDIAN_HANDLE_LONG(pCfg->rxPacketRingAddr); 
+        pCfg->txPacketRingAddr      = ENDIAN_HANDLE_LONG(pCfg->txPacketRingAddr);
+        pCfg->rxControlAddr         = ENDIAN_HANDLE_LONG(pCfg->rxControlAddr);   
+        pCfg->txControlAddr         = ENDIAN_HANDLE_LONG(pCfg->txControlAddr);   
+        pCfg->txCompleteAddr        = ENDIAN_HANDLE_LONG(pCfg->txCompleteAddr);
+    }
+
+    /* Configure WEP maximum space */
+    WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: WEP cache - none\n"));                  
+
+  #ifdef CORE_5_0 
+    whal_hwInfoElemMemoryMapPrint (pHwCtrl->pHwMboxConfig);
+  #endif
+
+    /* Override WLAN hardware defaults */
+    whal_hwInfoElemStationIdSet (pHwCtrl->pHwMboxConfig, pSrcMacAddr);
+    /* Configure the Rx Msdu Life Time (expiry time of de-fragmentation in FW) */
+    whal_hwInfoElemRxMsduLifeTimeSet (pHwCtrl->pHwMboxConfig, pWlanParams->MaxRxMsduLifetime);
+    whal_hwInfoElemRxConfigSet (pHwCtrl->pHwMboxConfig, &pWlanParams->RxConfigOption, &pWlanParams->RxFilterOption);
+
+  #if 0 
+    /* Use firmware default parameters for ant. which is ant 2 for both TX and RX */
+    whal_hwCtrl_CurrentAntennaDiversitySendCmd (pHwCtrl);
+  #endif
+
+    for (acID = 0; acID < MAX_NUM_OF_AC; acID++)
+    {
+        whal_hwCtrl_QueueConf (pHwCtrl, &pWlanParams->acQueuesParams[acID]);
+
+        /*
+         * NOTE: Set following parameters only if they were configured.
+         *       Otherwise, they contain garbage.
+         */
+
+        if (pHwCtrl->pWhalParams->AcParams.isAcConfigured[acID])
+        {
+            configureCmdCBParams_t configureCmdAc = {NULL,NULL,NULL};
+
+            configureCmdAc.CB_buf = (UINT8*)&pHwCtrl->pWhalParams->AcParams.ac[acID];
+            whal_hwCtrl_AcParamsConf (pHwCtrl, &configureCmdAc);
+        }
+
+        if (pHwCtrl->pWhalParams->QueuesParams.isQueueConfigured[acID])
+        {
+            whal_hwCtrl_TrafficConf (pHwCtrl, &pHwCtrl->pWhalParams->QueuesParams.queues[acID]);
+        }
+    }
+
+    whal_hwCtrl_PacketDetectionThreshold (pHwCtrl, &pHwCtrl->pWhalParams->WlanParams.PacketDetectionThreshold);
+    whal_hwCtrl_SetSlotTime (pHwCtrl, (slotTime_e )pWlanParams->SlotTime);
+    whal_hwCtrl_SetarpIpAddressesTable (pHwCtrl, 
+                                        &pWlanParams->arp_IP_addr, 
+                                        pWlanParams->isArpIpFilteringEnabled, 
+                                        IP_VER_4);
+    whal_hwCtrl_SetGroupAddressesTable (pHwCtrl, 
+                                        pWlanParams->numGroupAddrs, 
+                                        pWlanParams->Group_addr, 
+                                        pWlanParams->isMacAddrFilteringnabled);
+    whal_hwInfoElemRxTimeOutSet (pHwCtrl->pHwMboxConfig, &pWlanParams->rxTimeOut);
+    whal_hwCtrl_SetRtsThreshold (pHwCtrl, pWlanParams->RtsThreshold);
+    
+    /* Set The Beacon Filter in HAL */
+    whal_hwCtrl_SetBeaconFiltering (pHwCtrl, 
+                                    pWlanParams->beaconFilterParams.desiredState,
+                                    pWlanParams->beaconFilterParams.numOfElements);
+    whal_hwCtrl_SetBeaconFilterIETable (pHwCtrl, 
+                                        &pWlanParams->beaconFilterIETable.numberOfIEs,
+                                        pWlanParams->beaconFilterIETable.IETable,
+                                        &pWlanParams->beaconFilterIETable.IETableSize);
+
+    /* Set SG Params only in Init Phase. */
+    /* In recovery it will be handled in SoftGemini_hanfleRecovery() */
+    if (pData)
+    {
+        WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: Setting the Soft Gemini state\n"));    
+
+        /* Set the Soft Gemini state */
+        if (pWlanParams->SoftGeminiEnable == SG_SENSE_ACTIVE)
+        {
+            whal_hwCtrl_SoftGeminiEnable (pHwCtrl, SG_SENSE_NO_ACTIVITY);
+        }
+        else
+        {
+            whal_hwCtrl_SoftGeminiEnable (pHwCtrl, pWlanParams->SoftGeminiEnable);
+        }
+
+        /* Set the Soft Gemini params */
+        whal_hwCtrl_SetSoftGeminiParams (pHwCtrl, &pWlanParams->SoftGeminiParams);
+    }
+
+    /* For recovery decision */
+    eventMbox_EvUnMask (pHwCtrl->hEventMbox, HAL_EVENT_HEALTH_REPORT);
+    whal_hwCtrl_OverridePhyRegsDefaults (pHwCtrl);
+  #ifdef TNETW1150
+    whal_hwCtrl_SetACIConfiguration (pHwCtrl, 
+                                     pWlanParams->ACIMode, 
+                                     pWlanParams->inputCCA, 
+                                     pWlanParams->qualifiedCCA,
+                                     pWlanParams->stompForRx, 
+                                     pWlanParams->stompForTx, 
+                                     pWlanParams->txCCA);
+  #endif/*TNETW1150*/
+
+    /* Beacon broadcast options */
+    powerMgmtConfig.BcnBrcOptions = pWlanParams->BcnBrcOptions;
+    powerMgmtConfig.ConsecutivePsPollDeliveryFailureThreshold = pWlanParams->ConsecutivePsPollDeliveryFailureThreshold;
+    whal_hwCtrl_BcnBrcOptions (pHwCtrl, &powerMgmtConfig);
+
+    /* Enable rx/tx path on the hardware */
+    if (whal_hwCtrl_EnableDataPath (pHwCtrl) != OK)
+        return NOK;
+
+    /* ACX for a work around for Wi-Fi test */
+    whal_hwInfoElemWiFiWmmPSWASet (pHwCtrl->pHwMboxConfig, pWlanParams->WiFiWmmPS);
+
+    /* Enable the scan complete interrupt source */
+    eventMbox_EvUnMask (pHwCtrl->hEventMbox, HAL_EVENT_SCAN_CMPLT);
+    eventMbox_EvUnMask (pHwCtrl->hEventMbox, HAL_EVENT_SPS_SCAN_CMPLT);
+
+    /* Call the upper layer callback */
+    return (*((fcallback_t)pHwCtrl->fCb)) (pHwCtrl->hCb, OK);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_ConfigHwCb1()
+ ****************************************************************************
+ * DESCRIPTION: Configure the WLAN hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT: None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static int whal_hwCtrl_ConfigHwCb1 (HwCtrl_T *pHwCtrl, TI_STATUS status, void *pData)
+{
+    MemoryMap_t    *pMemMap = &pHwCtrl->MemMap;
+    DmaParams_T    *pDmaParams = whal_ParamsGetDmaParams (pHwCtrl->pWhalParams);
+    WlanParams_T   *pWlanParams = whal_ParamsGetWlanParams (pHwCtrl->pWhalParams);
+
+    /* Arrived from callback */
+    if (pData)
+    {
+        UINT32         *pSwap, i;
+
+        /* Solve endian problem (all fields are 32 bit) */
+        pSwap = (UINT32* )&(pMemMap->codeStart);
+        for (i = 0; i < MEM_MAP_NUM_FIELDS; i++)
+            pSwap[i] = ENDIAN_HANDLE_LONG(pSwap[i]);
+    }
+
+    /* Save number of TX blocks */
+    pDmaParams->NumTxBlocks = pMemMap->numTxMemBlks;
+
+    /* 
+     * Configure DataPath parameters to default 
+     * values and Read the Addresses of the FW data path buffers
+     */
+
+    /* Set Data path parameters to constant value to emulate the original double buffer*/
+    whal_hwInfoElemDataPathParamsSet (pHwCtrl->pHwMboxConfig, 
+                                      DP_RX_PACKET_RING_CHUNK_SIZE, 
+                                      DP_TX_PACKET_RING_CHUNK_SIZE, 
+                                      DP_RX_PACKET_RING_CHUNK_NUM, 
+                                      DP_TX_PACKET_RING_CHUNK_NUM, 
+                                      pWlanParams->TxCompleteThreshold, 
+                                      FW_TX_CMPLT_BLOCK_SIZE,
+                                      DP_TX_COMPLETE_TIME_OUT);
+
+    /* Arrived from callback */
+    if (pData)
+    {
+        /* Get the double buffers and registers address values */
+        return whal_hwInfoElemDataPathParamsGet (pHwCtrl->pHwMboxConfig, 
+                                                 &pHwCtrl->DataPathParams,
+                                                 (void *)whal_hwCtrl_ConfigHwCb2,
+                                                 pHwCtrl);
+    }
+
+    /* Called directly */
+    else
+    {
+        return whal_hwCtrl_ConfigHwCb2 (pHwCtrl, OK, NULL);
+    }
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_ConfigHw()
+ ****************************************************************************
+ * DESCRIPTION: Configure the WLAN hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT: None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_ConfigHw (HwCtrl_T *pHwCtrl, void *fCb, TI_HANDLE hCb, BOOL bRecovery)
+{
+    MemoryMap_t    *pMemMap = &pHwCtrl->MemMap;
+
+    /*
+     * The addresses of the Double buffer, The Tx Path Status, 
+     * Rx Path Status, Tx Path Control, Rx Path Control 
+     */
+    /* ACXDataPathParamsResp_t  *DataPathParam = &pHwCtrl->DataPathParams; */
+
+    /* 
+     * The DmaParams_T is the same struct as the halTxRxQueueGlobalsParams_t struct 
+     * but is defined in the whalBus_Defs.h and not in the paramOut.h as done by BCIL 
+     */
+    DmaParams_T    *pDmaParams = whal_ParamsGetDmaParams (pHwCtrl->pWhalParams);
+
+    pHwCtrl->fCb = fCb;
+    pHwCtrl->hCb = hCb; 
+
+    /* Configure the WLAN hardware memory (WEP, Templates, Queue, Buffers) */
+
+    /* Configure packet templates */
+    WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: templates \n"));                
+    whal_hwCtrl_ConfigTemplates (pHwCtrl);
+
+    /* Configure RX/TX queues */
+    WLAN_REPORT_INIT (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwCtrl_Configure: queues\n"));
+                     
+    /* Configure the weight among the different hardware queues */
+    whal_hwInfoElemConfigMemorySet (pHwCtrl->pHwMboxConfig, pDmaParams);
+
+    /* Extract total number of blocks in the pool */
+    if (bRecovery)
+        return whal_hwCtrl_ConfigHwCb1 (pHwCtrl, OK, NULL);
+    else
+        return whal_hwInfoElemMemoryMapGet (pHwCtrl->pHwMboxConfig, 
+                                         pMemMap, 
+                                         (void *)whal_hwCtrl_ConfigHwCb1,
+                                         pHwCtrl);
+}
+
+
+#ifdef TNETW1150
+/****************************************************************************
+ *                      whal_hwCtrl_SetACIConfiguration()
+ ****************************************************************************
+ * DESCRIPTION: Set the hardware ACI configuration
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetACIConfiguration (HwCtrl_T *pHwCtrl, UINT8 ACIMode,
+                                        UINT8 inputCCA, UINT8 qualifiedCCA,
+                                        UINT8 stompForRx, UINT8 stompForTx,
+                                        UINT8 txCCA)
+{
+   return (whal_hwInfoElemACIConfigurationSet (pHwCtrl->pHwMboxConfig, ACIMode,
+                                        inputCCA, qualifiedCCA, stompForRx,
+                                        stompForTx, txCCA));
+}
+#endif/*TNETW1150*/
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetMacAddress()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetMacAddress(HwCtrl_T *pHwCtrl, macAddress_t *macAddr)
+{
+    whal_ParamsSetSrcMac(pHwCtrl->pWhalParams, (char*)macAddr->addr);
+
+    return whal_hwInfoElemStationIdSet (pHwCtrl->pHwMboxConfig, (UINT8*)macAddr->addr);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_ConfigTemplates()
+ ****************************************************************************
+ * DESCRIPTION: Configure the packet templates 
+ *
+ *      AP          - beacon, probe response, tim
+ *      STA (INFRA) - probe request
+ *      STA (IBSS)  - beacon, probe response, probe request
+ *      know yet the bss type
+ * 
+ * INPUTS:      
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_ConfigTemplates(HwCtrl_T *pHwCtrl)
+{
+    UINT8 PartialVirtualBmap[DOT11_PARTIAL_VIRTUAL_BITMAP_MAX];
+    UINT8 BmapControl;
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pHwCtrl->pWhalParams);
+
+    /* 
+     * Probe request template 
+     */
+    whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->probeRequestTemplateSize,
+                                            CMD_PROBE_REQ,NULL,NULL); 
+
+    /* 
+     * Null Data template 
+     */
+    whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->nullTemplateSize,
+                                            CMD_NULL_DATA,NULL,NULL); 
+
+    /* 
+     * Ps Poll template 
+     */
+      whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->PsPollTemplateSize,
+                                            CMD_PS_POLL,NULL,NULL); 
+  
+    /* 
+     * Qos Null Data template
+     */
+      whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->qosNullDataTemplateSize,
+                                            CMD_QOS_NULL_DATA,NULL,NULL); 
+
+    /* 
+     * Probe response template 
+     */
+    whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->probeResponseTemplateSize,
+                                            CMD_PROBE_RESP,NULL,NULL); 
+    /* 
+     * Beacon template 
+     */
+    whal_hwMboxCmd_ConfigureTemplateFrame(pHwCtrl->pHwMboxCmd, NULL, pWlanParams->beaconTemplateSize,
+                                            CMD_BEACON,NULL,NULL); 
+
+    /* 
+     * Tim template, first reserve space (len=MAX), second init to empty 
+     */
+    BmapControl = 0;
+    os_memoryZero(pHwCtrl->hOs, (void*)PartialVirtualBmap, DOT11_PARTIAL_VIRTUAL_BITMAP_MAX);
+    whal_hwMboxCmd_TimTemplate(pHwCtrl->pHwMboxCmd, BmapControl, (char*)PartialVirtualBmap, DOT11_PARTIAL_VIRTUAL_BITMAP_MAX);
+    whal_hwMboxCmd_TimTemplate(pHwCtrl->pHwMboxCmd, BmapControl, (char*)PartialVirtualBmap, 1);
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetSlotTime()
+ ****************************************************************************
+ * DESCRIPTION: Set the Slot field in ACM_IFS_CFG1 hardware register
+ *
+ * INPUTS:  
+ *      SlotTimeVal     The Short SlotTime bit value in the Capabilities
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetSlotTime(HwCtrl_T *pHwCtrl, slotTime_e SlotTimeVal)
+{
+    UINT8        slotTime;
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,(" whal_hwCtrl_SetSlotTime: SlotTimeVal = 0x%x\n",SlotTimeVal));
+
+    if (SlotTimeVal == SLOT_TIME_LONG)
+        slotTime = (UINT8) SLOT_TIME_LONG;
+    else
+        slotTime = (UINT8) SLOT_TIME_SHORT;
+
+    return whal_hwInfoElemSlotTimeSet (pHwCtrl->pHwMboxConfig, &slotTime);
+
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetPreamble()
+ ****************************************************************************
+ * DESCRIPTION: Set the preamble in ?????? hardware register
+ *
+ * INPUTS:  
+ *      preambleVal     
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetPreamble(HwCtrl_T *pHwCtrl, Preamble_e preambleVal)
+{
+    UINT8        preamble;
+
+    preamble = (UINT8)preambleVal;
+
+    return whal_hwInfoElemPreambleSet (pHwCtrl->pHwMboxConfig, &preamble);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetFrameRate()
+ ****************************************************************************
+ * DESCRIPTION: Set the Frame Rate to HW
+ *
+ * INPUTS:  
+ *  Rate_e  txCtrlFrmRate;
+ *    Mod_e     txCtrlFrmMod;
+ *    Rate_e    txMgmtFrmRate;
+ *    Mod_e     txMgmtFrmMod;       
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetFrameRate (HwCtrl_T *pHwCtrl, 
+                                UINT8   txCtrlFrmRateVal,
+                                UINT8   txCtrlFrmModVal,
+                                UINT8   txMgmtFrmRateVal,
+                                UINT8   txMgmtFrmModVal)
+{
+    UINT8        txCtrlFrmRate;
+    UINT8        txCtrlFrmMod;
+    UINT8        txMgmtFrmRate;
+    UINT8        txMgmtFrmMod;
+    
+    txCtrlFrmRate   = txCtrlFrmRateVal;
+    txCtrlFrmMod        = txCtrlFrmModVal;
+    txMgmtFrmRate   = txMgmtFrmRateVal;
+    txMgmtFrmMod    = txMgmtFrmModVal;
+
+
+    return whal_hwInfoElemGeneratedFrameRateSet (pHwCtrl->pHwMboxConfig,
+                                                &txCtrlFrmRate,
+                                                &txCtrlFrmMod,
+                                                &txMgmtFrmRate,
+                                                 &txMgmtFrmMod);
+
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_PMConfig()
+ ****************************************************************************
+ * DESCRIPTION: Configure the wlan hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_PMConfig(HwCtrl_T *pHwCtrl, whalCtrl_powerMgmtConfig_t *pPMConfig)
+{
+    
+    ACXConfigPM_t AcxElm_PMConfig;
+    ACXConfigPM_t *pCfg = &AcxElm_PMConfig;
+
+
+    pCfg->BBWakeUpTime      = pPMConfig->BBWakeUpTime;
+
+    pCfg->ELPEnable         = pPMConfig->ELPEnable;
+
+    pCfg->PLLlockTime       = pPMConfig->PLLlockTime;
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport,
+                            HAL_HW_CTRL_MODULE_LOG,
+                            (" whal_hwCtrl_PMConfig  BBWakeUpTime=%d ELPEnable=%d PLLlockTime=%d WakeOnGPIOenable=0x%x\n"
+                             ,pCfg->BBWakeUpTime,pCfg->ELPEnable,pCfg->PLLlockTime,pCfg->WakeOnGPIOenable));
+
+    /*
+     * Set the desired features 
+     */
+    return whal_hwInfoElemAcxPMConfigSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_BcnBrcOptions()
+ ****************************************************************************
+ * DESCRIPTION: Configure the wlan hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_BcnBrcOptions(HwCtrl_T *pHwCtrl, whalCtrl_powerMgmtConfig_t *pPMConfig)
+{
+    ACXBeaconAndBroadcastOptions_t AcxElm_BcnBrcOptions;
+    ACXBeaconAndBroadcastOptions_t *pCfg = &AcxElm_BcnBrcOptions;
+
+
+    pCfg->beaconRxTimeOut       = pPMConfig->BcnBrcOptions.BeaconRxTimeout;
+
+    pCfg->broadcastTimeOut  = pPMConfig->BcnBrcOptions.BroadcastRxTimeout;
+
+    pCfg->rxBroadcastInPS       = pPMConfig->BcnBrcOptions.RxBroadcastInPs;
+
+    pCfg->consecutivePsPollDeliveryFailureThr = pPMConfig->ConsecutivePsPollDeliveryFailureThreshold;
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport,
+        HAL_HW_CTRL_MODULE_LOG,
+        (" whal_hwCtrl_BcnBrcOptions  BeaconRxTimeout=%d BroadcastRxTimeout=%d RxBroadcastInPs=0x%x ConsecutivePsPoll = %d\n"
+         ,pCfg->beaconRxTimeOut,pCfg->broadcastTimeOut,pCfg->rxBroadcastInPS,pCfg->consecutivePsPollDeliveryFailureThr));
+    /*
+     * Set the desired features 
+     */
+    return whal_hwInfoElemAcxBcnBrcOptionsSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_wakeUpCondition()
+ ****************************************************************************
+ * DESCRIPTION: Configure the wlan hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_wakeUpCondition(HwCtrl_T *pHwCtrl, whalCtrl_powerMgmtConfig_t *pPMConfig)
+{
+    WakeUpCondition_t AcxElm_WakeUpCondition;
+    WakeUpCondition_t *pCfg = &AcxElm_WakeUpCondition;
+
+
+    switch (pPMConfig->tnetWakeupOn)
+    {
+        case TNET_WAKE_ON_BEACON:
+            pCfg->wakeUpConditionBitmap = WAKE_UP_EVENT_BEACON_BITMAP;
+            break;
+        case TNET_WAKE_ON_DTIM:
+            pCfg->wakeUpConditionBitmap = WAKE_UP_EVENT_DTIM_BITMAP;
+            break;
+        case TNET_WAKE_ON_N_BEACON:
+            pCfg->wakeUpConditionBitmap = WAKE_UP_EVENT_N_BEACONS_BITMAP;
+            break;
+        case TNET_WAKE_ON_N_DTIM:
+            pCfg->wakeUpConditionBitmap = WAKE_UP_EVENT_N_DTIM_BITMAP;
+            break;
+        default:
+            pCfg->wakeUpConditionBitmap = WAKE_UP_EVENT_BEACON_BITMAP;
+            break;
+    }
+
+    pCfg->listenInterval        = pPMConfig->listenInterval;
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport,
+                            HAL_HW_CTRL_MODULE_LOG,
+                            (" whal_hwCtrl_wakeUpCondition  tnetWakeupOn=0x%x listenInterval=%d\n",pCfg->wakeUpConditionBitmap,pCfg->listenInterval));
+    /*
+     * Set the desired features 
+     */
+    return whal_hwInfoElemAcxwakeUpConditionSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_PowerMgmtConfigurationSet ()
+ ****************************************************************************
+ * DESCRIPTION: Set the ACX power management option IE
+ * 
+ * INPUTS: whalHwCtrl_powerMgmtOptionsConfig
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_PowerMgmtConfigurationSet (HwCtrl_T *pHwCtrl,
+                    whalCtrl_powerSaveParams_t* powerSaveParams)
+
+/*whalCtrl_powerMgmtConfig_t *thePowerMgmtOptionsConfig)*/
+{
+    whalCtrl_powerSaveParams_t AcxElm_PowerMgmtConfiguration;
+    whalCtrl_powerSaveParams_t *pCfg = &AcxElm_PowerMgmtConfiguration;
+
+
+        pCfg->ps802_11Enable    = powerSaveParams->ps802_11Enable;
+    pCfg->hangOverPeriod        = powerSaveParams->hangOverPeriod;
+        pCfg->needToSendNullData    = powerSaveParams->needToSendNullData;
+    pCfg->numNullPktRetries     = powerSaveParams->numNullPktRetries;
+    pCfg->powerSaveCBObject     = powerSaveParams->powerSaveCBObject;
+    pCfg->powerSavecmdResponseCB = powerSaveParams->powerSavecmdResponseCB;
+    /* Rate conversion is done in the HAL */
+    whalUtils_ConvertAppRatesBitmap(powerSaveParams->NullPktRateModulation, 0, &(pCfg->NullPktRateModulation));
+
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport,
+                            HAL_HW_CTRL_MODULE_LOG,
+                            (" whal_hwCtrl_PowerMgmtConfigurationSet  ps802_11Enable=0x%x hangOverPeriod=%d needToSendNullData=0x%x  numNullPktRetries=%d  NullPktRateModulation=0x%x\n"
+                             ,pCfg->ps802_11Enable,pCfg->hangOverPeriod,pCfg->needToSendNullData,pCfg->numNullPktRetries,pCfg->NullPktRateModulation));
+  
+    return(whal_hwMboxCmd_PowerMgmtConfiguration (pHwCtrl->pHwMboxCmd,pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_MinPowerLevelSet ()
+ ****************************************************************************
+ * DESCRIPTION: Set the min power level
+ * 
+ * INPUTS: 
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_MinPowerLevelSet (HwCtrl_T *pHwCtrl,
+                                powerAutho_PowerPolicy_e minPowerLevel)
+{
+    ACXSleepAuth_t AcxElm_SleepAuth;
+    ACXSleepAuth_t *pCfg = &AcxElm_SleepAuth;
+
+    /* in the info element the enums are in reverse */
+    switch(minPowerLevel)
+    {
+        case POWERAUTHO_POLICY_ELP:
+            pCfg->sleepAuth = 2;
+            break;
+        case POWERAUTHO_POLICY_AWAKE:
+            pCfg->sleepAuth = 0;
+            break;
+        default:
+            pCfg->sleepAuth = minPowerLevel;
+    }
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport,
+                            HAL_HW_CTRL_MODULE_LOG,
+                            (" whal_hwCtrl_MinPowerLevelSet  sleepAuth=%d\n",
+                            minPowerLevel));
+
+    /*
+     * Set the desired min power level
+     */
+    return whal_hwInfoElemAcxSleepAuthoSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_PowerMgmtOptionsPrint ()
+ ****************************************************************************
+ * DESCRIPTION: Print the ACX power management option
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_PowerMgmtOptionsPrint (HwCtrl_T *pHwCtrl)
+{
+    int Stt1, Stt2;
+    
+    ACXBeaconAndBroadcastOptions_t AcxElm_BcnBrcOptions;
+    ACXBeaconAndBroadcastOptions_t *pCfgBcnBrcOptions = &AcxElm_BcnBrcOptions;
+    
+    ACXDtimPeriodCfg_t AcxElm_TbttAndDtim;
+    ACXDtimPeriodCfg_t *pCfgTbttAndDtim = &AcxElm_TbttAndDtim;
+    
+    Stt1 = whal_hwInfoElemAcxBcnBrcOptionsGet (pHwCtrl->pHwMboxConfig, pCfgBcnBrcOptions);
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("BeaconRxTimeout=0x%X\n", pCfgBcnBrcOptions->beaconRxTimeOut));
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("BroadcastRxTimeout=0x%X\n", pCfgBcnBrcOptions->broadcastTimeOut));
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("RxBroadcastInPs=0x%X\n", pCfgBcnBrcOptions->rxBroadcastInPS));
+
+
+    Stt2 = whal_hwInfoElemDtimPeriodGet (pHwCtrl->pHwMboxConfig, 
+                                         &(pCfgTbttAndDtim->dtimInterval),
+                                         &(pCfgTbttAndDtim->tbtt));
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("Time Between Beacon(TBTT)=NOT IMPLEMENTED\n"));
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("dtimPeriod=NOT IMPLEMENTED\n"));
+
+    if ((Stt1 == OK) && (Stt2 == OK))
+        return(OK);
+    else
+        return(NOK);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetFeatureOptions()
+ ****************************************************************************
+ * DESCRIPTION: Configure the wlan hardware
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetEnergyDetection(HwCtrl_T *pHwCtrl, BOOL energyDetection)
+{
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pHwCtrl->pWhalParams);
+    UINT16 ccaThreshold = 0xefff;
+
+    pWlanParams->RxEnergyDetection = energyDetection;
+    
+    if (energyDetection) 
+        ccaThreshold = ACX_PHI_CCA_THRSH_ENABLE_ENERGY_D; /* enable energy detect */
+    else
+        ccaThreshold = ACX_PHI_CCA_THRSH_DISABLE_ENERGY_D; /* disable energy detect */
+    
+    whal_hwInfoElemCcaThresholdSet (pHwCtrl->pHwMboxConfig, &ccaThreshold, pWlanParams->TxEnergyDetection);
+
+    return OK;
+}
+
+
+#if defined(TNETW1150)
+/****************************************************************************
+ *                      whal_hwCtrl_ArmClockSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the arm clock
+ *  !!! Note that the firmware will set the slot time according to the new clock
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_ArmClockSet (HwCtrl_T *pHwCtrl, UINT32 ArmClock)
+{
+    WlanParams_T *pWlanParams = &pHwCtrl->pWhalParams->WlanParams;
+
+    pWlanParams->ArmClock = ArmClock;
+
+    WLAN_REPORT_REPLY(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_ArmClockSet: Arm=%d (Mac=%d)\n", pWlanParams->ArmClock, pWlanParams->MacClock));
+
+    /* Illegal combination Mac=80, Arm=40 ==> force setting 40/40*/
+    if ((pWlanParams->MacClock == HW_CLOCK_80_MHZ) && (pWlanParams->ArmClock == HW_CLOCK_40_MHZ))
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwCtrl_ArmClockSet: ---------- Illegal combination Mac=80, Arm=40 ==> force setting 40/40\n"));
+        pWlanParams->MacClock = HW_CLOCK_40_MHZ;
+    }
+
+    return whal_hwInfoElemFeatureConfigSet (pHwCtrl->pHwMboxConfig, pWlanParams->FeatureOptions, pWlanParams->FeatureDataFlowOptions);
+}
+#endif
+
+/****************************************************************************
+ *                      whal_hwCtrl_MacClockSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the mac clock
+ *  !!! Note that the firmware will set the slot time according to the new clock
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_MacClockSet (HwCtrl_T *pHwCtrl, UINT32 MacClock)
+{
+    WlanParams_T *pWlanParams = &pHwCtrl->pWhalParams->WlanParams;
+
+    pWlanParams->MacClock = MacClock;
+
+    /* force same clock - for printing */
+    pWlanParams->ArmClock = MacClock;
+    WLAN_REPORT_REPLY(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_MacClockSet: Mac=%d (Arm=%d)\n", pWlanParams->MacClock, pWlanParams->ArmClock));
+
+    /* Illegal combination Mac=80, Arm=40 ==> force setting 40/40*/
+    if ((pWlanParams->MacClock == HW_CLOCK_80_MHZ) && (pWlanParams->ArmClock == HW_CLOCK_40_MHZ))
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("whal_hwCtrl_MacClockSet: ---------- Illegal combination Mac=80, Arm=40 ==> force setting 40/40\n"));
+        pWlanParams->MacClock = HW_CLOCK_40_MHZ;
+    }
+
+    return whal_hwInfoElemFeatureConfigSet (pHwCtrl->pHwMboxConfig, pWlanParams->FeatureOptions, pWlanParams->FeatureDataFlowOptions);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_WepDefaultKeyAdd()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual default key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_WepDefaultKeyAdd (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle) 
+{
+    int Stt;
+
+    char MacAddr_Dummy[6];
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_ADD_OR_REPLACE,
+                                (char*)MacAddr_Dummy, 
+                                aSecurityKey->encLen, KEY_WEP_DEFAULT,
+                                aSecurityKey->keyIndex, 
+                                (char*)aSecurityKey->encKey, 0, 0,
+                                CB_Func, CB_handle);
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("whal_hwCtrl_WepDefaultKeyAdd: ## len=%d, id=%d encKey[5 entries]=0x %x %x %x %x %x\n", 
+                             aSecurityKey->encLen,
+                             aSecurityKey->keyIndex,
+                             aSecurityKey->encKey[0], aSecurityKey->encKey[1], aSecurityKey->encKey[2], aSecurityKey->encKey[3], aSecurityKey->encKey[4] ));
+
+    return Stt;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_WepDefaultKeyRemove()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual default key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_WepDefaultKeyRemove (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle) 
+{
+    int Stt;
+
+    char MacAddr_Dummy[6];
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_REMOVE,
+                                (char*)MacAddr_Dummy, 
+                                aSecurityKey->encLen, KEY_WEP_DEFAULT,
+                                aSecurityKey->keyIndex, 
+                                (char*)aSecurityKey->encKey, 0, 0,
+                                CB_Func, CB_handle);
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("whal_hwCtrl_WepDefaultKeyRemove: ## id=%d \n", 
+                             aSecurityKey->keyIndex));
+
+    return Stt;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_WepMappingKeyAdd()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual mapping key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_WepMappingKeyAdd (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+    int Stt;
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_ADD_OR_REPLACE,
+                                (char*)aSecurityKey->macAddress.addr, 
+                                aSecurityKey->encLen, KEY_WEP_ADDR,
+                                aSecurityKey->keyIndex, 
+                                (char*)aSecurityKey->encKey, 0, 0,
+                                CB_Func, CB_handle);
+    
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_WepMappingKeyAdd: ## len=%d, id=%d encKey[5 entries]=0x %x %x %x %x %x\n", 
+        aSecurityKey->encLen,
+        aSecurityKey->keyIndex,
+        aSecurityKey->encKey[0], aSecurityKey->encKey[1], aSecurityKey->encKey[2], aSecurityKey->encKey[3], aSecurityKey->encKey[4] ));
+
+
+    return Stt;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_WepMappingKeyRemove()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual mapping key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_WepMappingKeyRemove (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+    int Stt;
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_REMOVE,
+                                (char*)aSecurityKey->macAddress.addr, 
+                                aSecurityKey->encLen, KEY_WEP_ADDR,
+                                aSecurityKey->keyIndex, 
+                                (char*)aSecurityKey->encKey, 0, 0,
+                                CB_Func, CB_handle);
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_WepMappingKeyRemove: ## id=%d \n", 
+        aSecurityKey->keyIndex));
+
+    return Stt;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_TkipMicMappingKeyAdd()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual mapping key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_TkipMicMappingKeyAdd (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+    int Stt = OK;
+
+    UINT8   keyType;
+    UINT8   keyBuffer[KEY_SIZE_TKIP];
+
+    keyType = (IsMacAddressGroup(&(aSecurityKey->macAddress))==1) ? KEY_TKIP_MIC_GROUP: KEY_TKIP_MIC_PAIRWISE;
+
+    os_memoryCopy(pHwCtrl->hOs, (PVOID)(&keyBuffer[0]), (PVOID)aSecurityKey->encKey, 16);
+    os_memoryCopy(pHwCtrl->hOs, (PVOID)(&keyBuffer[16]), (PVOID)aSecurityKey->micRxKey, 8);
+    os_memoryCopy(pHwCtrl->hOs, (PVOID)(&keyBuffer[24]), (PVOID)aSecurityKey->micTxKey, 8);
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_ADD_OR_REPLACE,
+                                (char*)aSecurityKey->macAddress.addr, 
+                                KEY_SIZE_TKIP, keyType,
+                                aSecurityKey->keyIndex , 
+                                (char*)keyBuffer, pHwCtrl->SecuritySeqNumLow, pHwCtrl->SecuritySeqNumHigh,
+                                CB_Func, CB_handle);
+
+    return Stt;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_TkipMappingKeyAdd()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual mapping key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_TkipMicMappingKeyRemove (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+    int Stt;
+    /* UINT8 bcast[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; */
+
+    UINT8   keyType;
+
+    keyType = (IsMacAddressGroup(&(aSecurityKey->macAddress))==1) ? KEY_TKIP_MIC_GROUP: KEY_TKIP_MIC_PAIRWISE;
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_REMOVE,
+                                (char*)aSecurityKey->macAddress.addr, 
+                                aSecurityKey->encLen, keyType,
+                                aSecurityKey->keyIndex , 
+                                (char*)aSecurityKey->encKey, 0, 0,
+                                CB_Func, CB_handle);
+
+    return Stt;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_AesMappingKeyAdd()
+ ****************************************************************************
+ * DESCRIPTION: Set the actual Aes mapping key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+ int whal_hwCtrl_AesMappingKeyAdd    (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle)
+ {
+    int Stt;
+    UINT8   keyType;
+
+    keyType = IsMacAddressGroup(&(aSecurityKey->macAddress)) ? 
+                                        KEY_AES_GROUP: KEY_AES_PAIRWISE;
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_ADD_OR_REPLACE,
+        (char*)aSecurityKey->macAddress.addr, 
+        aSecurityKey->encLen, keyType,
+        aSecurityKey->keyIndex , 
+        (char*)aSecurityKey->encKey, pHwCtrl->SecuritySeqNumLow, pHwCtrl->SecuritySeqNumHigh,
+        CB_Func, CB_handle);
+    
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("whal_hwCtrl_AesMappingKeyAdd: SecuritySeqNumHigh=%ld, pHwCtrl->SecuritySeqNumLow=%ld \n", 
+                             pHwCtrl->SecuritySeqNumHigh, pHwCtrl->SecuritySeqNumLow));
+    
+
+    return Stt;
+
+ }
+
+
+ /****************************************************************************
+ *                      whal_hwCtrl_AesMappingKeyRemove()
+ ****************************************************************************
+ * DESCRIPTION: Remove  Aes mapping key
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+ int whal_hwCtrl_AesMappingKeyRemove    (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle)
+ {
+    int Stt;
+    UINT8   keyType;
+
+    keyType = IsMacAddressGroup(&(aSecurityKey->macAddress)) ? 
+                                        KEY_AES_GROUP: KEY_AES_PAIRWISE;
+
+    Stt = whal_hwMboxCmd_SetKey(pHwCtrl->pHwMboxCmd, KEY_REMOVE,
+        (char*)aSecurityKey->macAddress.addr, 
+        aSecurityKey->encLen, keyType,
+        aSecurityKey->keyIndex , 
+        (char*)aSecurityKey->encKey, 0, 0,
+        CB_Func, CB_handle);
+    
+    return Stt;
+ }
+
+/****************************************************************************
+ *                      whal_hwCtrl_DefaultKeyIdSet()
+ ****************************************************************************
+ * DESCRIPTION: Set the default key ID
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_DefaultKeyIdSet (HwCtrl_T *pHwCtrl, UINT8 aKeyIdVal, void *CB_Func, TI_HANDLE CB_handle)
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("whal_hwCtrl_DefaultKeyIdSet: ## Id=%d\n", aKeyIdVal));
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                            ("whal_hwCtrl_DefaultKeyIdSet: ## Id=%d\n", aKeyIdVal));
+
+    /* Set the default key Id */
+    return whal_hwInfoElemWepDefaultKeyIdSet (pHwCtrl->pHwMboxConfig, &aKeyIdVal, CB_Func, CB_handle);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_DefaultKeyIdGet()
+ ****************************************************************************
+ * DESCRIPTION: Get the default key ID
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_DefaultKeyIdGet (HwCtrl_T *pHwCtrl, UINT8 *pKeyIdVal)
+{
+    /* Get the default key Id */
+    return whal_hwInfoElemWepDefaultKeyIdGet (pHwCtrl->pHwMboxConfig, pKeyIdVal, NULL, NULL);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_Initiate()
+ ****************************************************************************
+ * DESCRIPTION: Download firmware code to the Hardware and run it
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+TI_STATUS whal_hwCtrl_Initiate (HwCtrl_T *pHwCtrl)
+{
+    WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pHwCtrl->pWhalParams);
+    BootAttr_T    BootAttr;
+    TI_STATUS     status;
+
+    BootAttr.MacClock = pWlanParams->MacClock;
+    BootAttr.ArmClock = pWlanParams->ArmClock;
+
+    if ((status = whalBus_FwCtrl_Boot (pHwCtrl->hWhalBus, (TI_HANDLE)pHwCtrl, &BootAttr)) == TNETWIF_ERROR)
+    {
+        WLAN_REPORT_WARNING (pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                             ("whal_hwCtrl_Initiate: whalBus_FwCtrl_Boot failure!!!\n"));
+    }
+
+    return status;
+}
+
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_Stop()
+ ****************************************************************************
+ * DESCRIPTION: Stop the Hardware firmware
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void whal_hwCtrl_Stop(HwCtrl_T *pHwCtrl)
+{
+
+#ifdef WDBG_POLLING /* (!!!) ONLY FOR DEBUG WHEN THERE ARE NO INTERRUPTS */
+    os_timerStop(pHwCtrl->hOs, hal_timer);
+#endif
+
+    /*
+     * Stop Acx Cpu
+     */
+    whalBus_FwCtrl_Halt(pHwCtrl->hWhalBus);
+    return;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetBusHandle()
+ ****************************************************************************
+ * DESCRIPTION: Return the handle of the Bus object.
+ *
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: handle of the HwIntr object
+ ****************************************************************************/
+TI_HANDLE whal_hwCtrl_GetBusHandle(HwCtrl_T *pHwCtrl)
+{
+    return pHwCtrl->hWhalBus;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetMboxConfig()
+ ****************************************************************************
+ * DESCRIPTION: Return the handle of the MboxConfig object.
+ *
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: handle of the MboxConfig object
+ ****************************************************************************/
+HwMboxConfig_T *whal_hwCtrl_GetMboxConfig(HwCtrl_T *pHwCtrl)
+{
+    return pHwCtrl->pHwMboxConfig;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetMboxCmd()
+ ****************************************************************************
+ * DESCRIPTION: Return the handle of the MboxCmd object.
+ *
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: handle of the MboxCmd object
+ ****************************************************************************/
+HwMboxCmd_T *whal_hwCtrl_GetMboxCmd(HwCtrl_T *pHwCtrl)
+{
+    return pHwCtrl->pHwMboxCmd;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_StartScan()
+ ****************************************************************************
+ * DESCRIPTION: Send Start Scan command 
+ * 
+ * INPUTS: None  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_StartScan (HwCtrl_T *pHwCtrl, ScanParameters_t* pScanVals, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+    return (whal_hwMboxCmd_StartScan (pHwCtrl->pHwMboxCmd, pScanVals, ScanCommandResponseCB,CB_handle));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_StartSPSScan()
+ ****************************************************************************
+ * DESCRIPTION: Send Start SPS Scan command 
+ * 
+ * INPUTS: None  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_StartSPSScan( HwCtrl_T *pHwCtrl, ScheduledScanParameters_t* pScanVals, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+    return (whal_hwMboxCmd_StartSPSScan (pHwCtrl->pHwMboxCmd, pScanVals, ScanCommandResponseCB, CB_handle));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_StopScan()
+ ****************************************************************************
+ * DESCRIPTION: Send Stop Scan command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_StopScan (HwCtrl_T *pHwCtrl, void *ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+    return(whal_hwMboxCmd_StopScan (pHwCtrl->pHwMboxCmd, ScanCommandResponseCB, CB_handle));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_StopSPSScan()
+ ****************************************************************************
+ * DESCRIPTION: Send Stop SPS Scan command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_StopSPSScan (HwCtrl_T *pHwCtrl, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+    return(whal_hwMboxCmd_StopSPSScan (pHwCtrl->pHwMboxCmd, ScanCommandResponseCB, CB_handle));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GenCmd()
+ ****************************************************************************
+ * DESCRIPTION: Send any command to hw MB command
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GenCmd(HwCtrl_T *pHwCtrl, short CmdID, char* pBuf, UINT32 Length)
+{
+    return (whal_hwMboxCmd_GenCmd(pHwCtrl->pHwMboxCmd, CmdID, pBuf, Length));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_isElpSupported ()
+ ****************************************************************************
+ * DESCRIPTION: Check if ELP feature is supported based on the HW device
+ *              
+ * INPUTS: 
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: ELP feature is supported/not
+ ****************************************************************************/
+BOOL whal_hwCtrl_isElpSupported (HwCtrl_T *pHwCtrl)
+{
+    return TRUE;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_AidSet()
+ ****************************************************************************
+ * DESCRIPTION: Set the AID
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_AidSet (HwCtrl_T *pHwCtrl, UINT16 aAidVal)
+{
+    /* Set the Aid */
+    return whal_hwInfoElemAidSet (pHwCtrl->pHwMboxConfig, &aAidVal);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_CurrentTxRxAntennaSendCmd()
+ ****************************************************************************
+ * DESCRIPTION: send Diversity command to F/W with the pre-stored antenna 
+ *              diversity parameters 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_CurrentAntennaDiversitySendCmd (HwCtrl_T *pHwCtrl)
+{
+    int status;
+
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,("whal_hwCtrl_CurrentRxAntennaSet\n"));
+    
+    /* Write the current antenna diversity values to the HW*/
+    if ( RADIO_RADIA_DCR_ID == pHwCtrl->pWhalParams->WlanParams.radioType )
+    {
+        status = whal_hwInfoElemAntennaDiversitySet (pHwCtrl->pHwMboxConfig, 
+                                                  &(pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions),
+                                                  1);
+    }
+    else
+    {
+        status = whal_hwInfoElemAntennaDiversitySet (pHwCtrl->pHwMboxConfig, 
+                                                  &(pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions),
+                                                  2);
+    }
+
+    return(status);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetTxAntenna()
+ ****************************************************************************
+ * DESCRIPTION: Save TX antenna
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetTxAntenna (HwCtrl_T *pHwCtrl, UINT8 TxAntenna)
+{
+    if (TxAntenna == 1)
+    {
+        pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.txSelectedAntenna = DIVS_TX_START_ANT1;
+    }
+    else if (TxAntenna == 2)
+    {
+        pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.txSelectedAntenna = DIVS_TX_START_ANT2;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwCtrl_SetTxAntenna: wrong antenna param %d\n", TxAntenna));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetTxAntenna()
+ ****************************************************************************
+ * DESCRIPTION: retrieve TX antenna
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GetTxAntenna (HwCtrl_T *pHwCtrl, UINT8* TxAntenna)
+{
+    if (pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.txSelectedAntenna == DIVS_RX_START_ANT1)
+    {
+        *TxAntenna = 1;
+    }
+    else if (pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.txSelectedAntenna == DIVS_RX_START_ANT2)
+    {
+        *TxAntenna = 2;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwCtrl_GetTxAntenna: wrong configured antenna param %d\n", pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.txSelectedAntenna));
+        return CONFIGURATION_NOT_VALID;
+    }
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetRxAntenna()
+ ****************************************************************************
+ * DESCRIPTION: Save RX antenna
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetRxAntenna (HwCtrl_T *pHwCtrl, UINT8 RxAntenna)
+{
+    if (RxAntenna == 1)
+    {
+        pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.rxSelectedAntenna = DIVS_RX_START_ANT1;
+    }
+    else if (RxAntenna == 2)
+    {
+        pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.rxSelectedAntenna = DIVS_RX_START_ANT2;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwCtrl_SetRxAntenna: wrong antenna param %d\n", RxAntenna));
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetRxAntenna()
+ ****************************************************************************
+ * DESCRIPTION: retrieve RX antenna
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GetRxAntenna (HwCtrl_T *pHwCtrl, UINT8* RxAntenna)
+{
+    if (pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.rxSelectedAntenna == DIVS_RX_START_ANT1)
+    {
+        *RxAntenna = 1;
+}
+    else if (pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.rxSelectedAntenna == DIVS_RX_START_ANT2)
+    {
+        *RxAntenna = 2;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+                          ("whal_hwCtrl_GetRxAntenna: wrong configured antenna param %d\n", pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions.rxSelectedAntenna));
+        return CONFIGURATION_NOT_VALID;
+    }
+
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SaveAntennaDiversityOptions()
+ ****************************************************************************
+ * DESCRIPTION: Save antenna diversity parameters
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SaveAntennaDiversityOptions (HwCtrl_T *pHwCtrl, 
+                                             whalCtrl_antennaDiversityOptions_t* pAntennaDivresityOptions )
+{
+    os_memoryCopy( pHwCtrl->hOs, (void*)&(pHwCtrl->pWhalParams->WlanParams.antennaDiversityOptions),
+                   (void*)pAntennaDivresityOptions, sizeof( whalCtrl_antennaDiversityOptions_t ) );
+    whal_hwCtrl_SetTxAntenna(pHwCtrl, pAntennaDivresityOptions->txSelectedAntenna);
+    whal_hwCtrl_SetRxAntenna(pHwCtrl, pAntennaDivresityOptions->rxSelectedAntenna);
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_CurrentAssociationIdGet()
+ ****************************************************************************
+ * DESCRIPTION: Get the current TX antenna 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_CurrentAssociationIdGet (HwCtrl_T *pHwCtrl, UINT16  *pAidVal)
+{
+    *pAidVal = pHwCtrl->pWhalParams->WlanParams.Aid;
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_OverridePhyRegsDefaults()
+ ****************************************************************************
+ * DESCRIPTION: Set phy register for short preamble problem
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+void whal_hwCtrl_OverridePhyRegsDefaults(HwCtrl_T *pHwCtrl)
+{
+    /* 
+     * Configure the energy detection 
+     */
+    whal_hwCtrl_SetEnergyDetection(pHwCtrl, pHwCtrl->pWhalParams->WlanParams.RxEnergyDetection);
+
+    /* 
+     * Disable OFDM receiver in channel 14 (overcome FCS errors problem) 
+     */
+    /* moved to the firmware */
+}
+
+
+int whal_hwCtrl_EncDecrSet (HwCtrl_T *pHwCtrl, BOOL aHwEncEnable, BOOL aHwDecEnable)
+{
+    WlanParams_T *pWlanParams = &pHwCtrl->pWhalParams->WlanParams;
+
+    if (aHwEncEnable)
+        pWlanParams->FeatureDataFlowOptions &= ~DF_ENCRYPTION_DISABLE;
+    else
+        pWlanParams->FeatureDataFlowOptions |= DF_ENCRYPTION_DISABLE;
+
+    /* Set bit DF_SNIFF_MODE_ENABLE to enable or prevent decryption in fw */
+    /* WARNING: Have to check how to control the decryption (which bit) and then set/reset
+                the  appropriate bit*/ 
+    if (aHwDecEnable)
+        pWlanParams->FeatureDataFlowOptions &= ~DF_SNIFF_MODE_ENABLE;
+    else
+        pWlanParams->FeatureDataFlowOptions |= DF_SNIFF_MODE_ENABLE;
+
+    return whal_hwInfoElemFeatureConfigSet (pHwCtrl->pHwMboxConfig, pWlanParams->FeatureOptions, pWlanParams->FeatureDataFlowOptions);
+}
+
+int whal_hwCtrl_ClkRunEnableSet (HwCtrl_T *pHwCtrl, BOOL aClkRunEnable)
+{
+    WlanParams_T *pWlanParams = &pHwCtrl->pWhalParams->WlanParams;
+
+    if (aClkRunEnable)
+        pWlanParams->FeatureDataFlowOptions |= FEAT_PCI_CLK_RUN_ENABLE;
+    else
+        pWlanParams->FeatureDataFlowOptions &= ~FEAT_PCI_CLK_RUN_ENABLE;
+
+    return whal_hwInfoElemFeatureConfigSet (pHwCtrl->pHwMboxConfig, pWlanParams->FeatureOptions, pWlanParams->FeatureDataFlowOptions);
+}
+
+int whal_hwCtrl_RxMsduFormatSet (HwCtrl_T *pHwCtrl, BOOL aRxMsduForamtEnable)
+{
+#if 1
+    /* WARNING:  Have to check how to control the Rx Frame format select (which bit)
+                 and then access the HW*/
+    return(OK);
+#else
+    WlanParams_T *pWlanParams = &pHwCtrl->pWhalParams->WlanParams;
+    if (aRxMsduForamtEnable)
+        pWlanParams->FeatureDataFlowOptions |= DATA_FLOW_RX_MSDU_FRAME;
+    else
+        pWlanParams->FeatureDataFlowOptions &= ~DATA_FLOW_RX_MSDU_FRAME;
+
+    return whal_hwInfoElemFeatureConfigSet (pHwCtrl->pHwMboxConfig, pWlanParams->FeatureOptions, pWlanParams->FeatureDataFlowOptions);
+#endif
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_getTsf()
+ ****************************************************************************
+ * DESCRIPTION: Get the current time stamp from the FW
+ * 
+ * INPUTS:  hwHalCtrl handle, pTsf container for the FW mac timer
+ * 
+ * OUTPUT:  pTsf FW mac timer
+ * 
+ * RETURNS: OK, NOK
+ *
+ * NOTES: The time will be in usec
+ ****************************************************************************/
+
+int whal_hwCtrl_getTsf(HwCtrl_T *pHwCtrl, UINT32 *pTsf)
+{
+    /* for debug only - Not implemented as direct access to register */
+    return(OK);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_NoiseHistogramCmd()
+ ****************************************************************************
+ * DESCRIPTION: Send Noise Histogram command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_NoiseHistogramCmd (HwCtrl_T *pHwCtrl, whalCtrl_noiseHistogram_t* pNoiseHistParams)
+{
+    return (whal_hwMboxCmd_NoiseHistogramCmd (pHwCtrl->pHwMboxCmd, pNoiseHistParams));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_TrafficConf()
+ ****************************************************************************
+ * DESCRIPTION: configure Queue traffic params
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int  whal_hwCtrl_TrafficConf(TI_HANDLE hHwCtrl, queueTrafficParams_t *pQtrafficParams)
+{
+    TI_STATUS   status;
+    HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,(" whal_hwCtrl_TrafficConf: pQtrafficParams->aQueueId = 0x%x , pQtrafficParams->channelType %x pQtrafficParams->tsid %d pQtrafficParams->dot11EDCATableMSDULifeTime %d \n",
+    pQtrafficParams->queueID,pQtrafficParams->channelType,pQtrafficParams->tsid,pQtrafficParams->dot11EDCATableMSDULifeTime));
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,("whal_hwCtrl_TrafficConf : psScheme = 0x%x , ackPolicy %d APSDConf[0] = 0x%x ,APSDConf[1] = 0x%x\n",pQtrafficParams->psScheme,pQtrafficParams->ackPolicy,pQtrafficParams->APSDConf[0],pQtrafficParams->APSDConf[1]));
+
+
+    /* Setting the queue configuration into the HW */
+    status = (TI_STATUS)whal_hwInfoElemQueueConfigurationSet (pHwCtrl->pHwMboxConfig,pQtrafficParams);  
+
+    /* Set the queue param object database fields according to the succeded configuration (for recovery) */
+    if (status == OK)
+        whal_ParamsSetQueueParams(pHwCtrl->pWhalParams,pQtrafficParams);
+
+    return status;
+}
+/****************************************************************************
+ *                      whal_hwCtrl_AcParamsConf()
+ ****************************************************************************
+ * DESCRIPTION: configure AC params
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+
+int whal_hwCtrl_AcParamsConf(TI_HANDLE hHwCtrl,configureCmdCBParams_t *pConfigureCommand)
+{
+    
+    TI_STATUS   status;
+    HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+    acQosParams_t *pAcQosParams = (acQosParams_t*)(pConfigureCommand->CB_buf);
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,(" whal_hwCtrl_AcParamsConf: Index = 0x%x, aCwMin = 0x%x, aCwMax = 0x%x, aAIFS = 0x%x, aTxOpLimit = 0x%x\n",
+    pAcQosParams->ac,pAcQosParams->cwMin,pAcQosParams->cwMax,pAcQosParams->aifsn,pAcQosParams->txopLimit));
+
+    /* Setting the AC configuration into the HW */
+
+    if (pConfigureCommand->CB_Func == NULL)    
+        status = (TI_STATUS)whal_hwInfoElemAcParamsConfigurationSet (pHwCtrl->pHwMboxConfig,pConfigureCommand);  
+    else
+        status = (TI_STATUS)whal_hwInfoElemAcParamsConfigurationGet (pHwCtrl->pHwMboxConfig,pConfigureCommand);  
+
+    /* Set the AC param object database fields according to the succeeded configuration (for recovery) */
+    if (status == OK)
+        whal_ParamsSetAcParams(pHwCtrl->pWhalParams,pAcQosParams);
+
+    return status;
+
+}
+/****************************************************************************
+ *                      whal_hwCtrl_AccessCategoryConf()
+ ****************************************************************************
+ * DESCRIPTION: Send Access Category Configuration 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int  whal_hwCtrl_QueueConf(TI_HANDLE hHwCtrl, acQueuesParams_t* pAcQueuesParams)
+{
+    TI_STATUS   status;
+    HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+
+    /* Setting the queue configuration into the HW */
+    status = (TI_STATUS)whal_hwInfoElemTxQueueCfgSet (pHwCtrl->pHwMboxConfig,
+                                             pAcQueuesParams, 
+                                           pHwCtrl->MemMap.numTxMemBlks);
+
+    /* Set the queue param object database fields according to the succeeds configuration (for recovery) */
+    if (status == OK)
+        whal_ParamsSetAccessCategoryParams(pHwCtrl->pWhalParams, pAcQueuesParams);
+    return status;
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_PacketDetectionThreshold()
+ ****************************************************************************
+ * DESCRIPTION: Send Noise Histogram command 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_PacketDetectionThreshold (TI_HANDLE hHwCtrl, UINT8* pPdThreshold)
+{
+    TI_STATUS   status;
+    HwCtrl_T    *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+    UINT32      packetDetection = *pPdThreshold;
+
+    /* Setting the queue configuration into the HW */
+    status = (TI_STATUS)whal_hwInfoElemPacketDetectionThresholdSet (pHwCtrl->pHwMboxConfig, &packetDetection);  
+    
+    return status;
+}
+
+
+
+/****************************************************************************
+ *                     whal_hwCtrl_SetBeaconFiltering
+ ****************************************************************************
+ * DESCRIPTION: Sets Beacon filtering state 
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetBeaconFiltering(HwCtrl_T *pHwCtrl, UINT8 beaconFilteringStatus, UINT8 numOfBeaconsToBuffer)
+{
+    ACXBeaconFilterOptions_t AcxElm_BeaconFilterOptions;
+    ACXBeaconFilterOptions_t *pCfg = &AcxElm_BeaconFilterOptions;
+    
+    pCfg->enable = beaconFilteringStatus;
+    pCfg->maxNumOfBeaconsStored = numOfBeaconsToBuffer;
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport , ("Set beacon filter to %d" , beaconFilteringStatus) ) ;
+    
+    return whal_hwInfoElemAcxBeaconFilterOptionsSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+
+/****************************************************************************
+ *                     whal_hwCtrl_SetBeaconFilterIETable
+ ****************************************************************************
+ * DESCRIPTION: Sets Beacon filtering state 
+ * 
+ * INPUTS:  None    
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetBeaconFilterIETable(HwCtrl_T *pHwCtrl, UINT8* numberOfIEs, UINT8 * IETable, UINT8* IETableSize)
+{
+    int counter = 0 ;
+    if ( NULL == pHwCtrl)
+    {
+        return PARAM_VALUE_NOT_VALID ;
+    }
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,
+                             ("\n  whal_hwCtrl_SetBeaconFilterIETable Beacon IE Table:\n"));
+        
+    for ( counter = 0 ; counter < * IETableSize ; counter++)
+    {
+        WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,
+                                 ("%2.x " , IETable[counter]));
+    }
+
+        WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,
+                                 ("\n "));
+
+
+    return whal_hwInfoElemAcxBeaconFilterIETableSet (pHwCtrl->pHwMboxConfig,
+                                                     numberOfIEs, 
+                                                     IETable, 
+                                                     IETableSize);
+}
+
+/****************************************************************************
+ *                      whal_HwCtrl_enableMboxAsyncMode()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK, NOK
+ *
+ * NOTES: 
+ ****************************************************************************/
+int whal_HwCtrl_enableMboxAsyncMode(HwCtrl_T *pHwCtrl)
+{
+    eventMbox_InitComplete(pHwCtrl->hEventMbox);
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_HwCtrl_resetMacRx()
+ ****************************************************************************
+ * DESCRIPTION: Reset the Rx Max module
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  
+ *
+ * RETURNS: OK, NOK
+ *
+ * NOTES:
+ ****************************************************************************/
+int whal_HwCtrl_resetMacRx(HwCtrl_T *pHwCtrl)
+{
+    return whal_hwMboxCmd_RxReset(pHwCtrl->pHwMboxCmd);
+}
+
+/****************************************************************************
+ *                      whal_HwCtrl_LNAControl()
+ ****************************************************************************
+ * DESCRIPTION: Control the LNA (On <-> Off)
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK, NOK
+ *
+ * NOTES: 
+ ****************************************************************************/
+int whal_HwCtrl_LNAControl(HwCtrl_T *pHwCtrl, UINT8 LNAControlField)
+{
+    return whal_hwMboxCmd_LNAControl(pHwCtrl->pHwMboxCmd, LNAControlField);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SwitchChannelCmd()
+ ****************************************************************************
+ * DESCRIPTION: Send Switch Channel command 
+ * 
+ * INPUTS: None  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SwitchChannelCmd (HwCtrl_T *pHwCtrl, whalCtrl_switchChannelCmd_t* pSwitchChannelCmd)
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_SwitchChannelCmd\n"));
+    return (whal_hwMboxCmd_SwitchChannelCmd (pHwCtrl->pHwMboxCmd, pSwitchChannelCmd));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SwitchChannelCmd()
+ ****************************************************************************
+ * DESCRIPTION: Send Switch Channel command 
+ * 
+ * INPUTS: None  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SwitchChannelCancelCmd (HwCtrl_T *pHwCtrl)
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_SwitchChannelCmd\n"));
+    return (whal_hwMboxCmd_SwitchChannelCancelCmd (pHwCtrl->pHwMboxCmd));
+}
+
+
+/*----------------------------------------*/
+/* Roaming Trigger Configuration Commands */
+/*----------------------------------------*/
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetSNRParameters()
+ ****************************************************************************
+ * DESCRIPTION: Set SNR parameters.
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetSNRParams(HwCtrl_T *pHwCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd) 
+{
+    ACXLowSNRTriggerParameters_t AcxElm_LowThresholdOptions;
+    AcxElm_LowThresholdOptions.SNRThreshold         = pRoamingTriggerCmd->snrThreshold ;        
+    AcxElm_LowThresholdOptions.SNRFilterWeight      = pRoamingTriggerCmd->snrFilterWeight ; 
+    AcxElm_LowThresholdOptions.SNRFilterDepth       = pRoamingTriggerCmd->snrFilterDepth ;      
+    AcxElm_LowThresholdOptions.LowSNREventType  = pRoamingTriggerCmd->lowSNREventType;
+    
+    
+    return whal_hwInfoElemAcxLowSNRThresholdSet (pHwCtrl->pHwMboxConfig, &AcxElm_LowThresholdOptions);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetRSSIParameters()
+ ****************************************************************************
+ * DESCRIPTION: Set RSSI parameters used by the TNET for its calulation 
+ *               that is used for generating of RSSI cross threshold interrupts.
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetRSSIParams(HwCtrl_T *pHwCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd) 
+{
+    ACXLowRSSITriggerParameters_t AcxElm_LowRSSIThresholdOptions;
+    ACXLowRSSITriggerParameters_t *pCfg = &AcxElm_LowRSSIThresholdOptions;
+
+    pCfg->rssiFilterDepth   = pRoamingTriggerCmd->rssiFilterDepth;
+    pCfg->rssiFilterWeight  = pRoamingTriggerCmd->rssiFilterWeight;
+    pCfg->rssiThreshold     = pRoamingTriggerCmd->rssiThreshold;
+    pCfg->LowRSSIEventType  = pRoamingTriggerCmd->lowRSSIEventType;
+    
+    return whal_hwInfoElemAcxLowRSSIThresholdSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetMaxTxRetryParameters()
+ ****************************************************************************
+ * DESCRIPTION: Set Max Tx retry parmaters.
+ *
+ * INPUTS:  
+ *      maxTxRetry             max Tx Retry
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetMaxTxRetryParams(HwCtrl_T *pHwCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd)
+{
+    ACXConsTxFailureTriggerParameters_t AcxElm_MaxTxRetry;
+    ACXConsTxFailureTriggerParameters_t *pCfg = &AcxElm_MaxTxRetry;
+
+    pCfg->maxTxRetry    = pRoamingTriggerCmd->maxTxRetry;
+    
+    return whal_hwInfoElemAcxSetMaxTxRetrySet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetAsynRSSI ()
+ ****************************************************************************
+ * DESCRIPTION: Get the Average RSSI
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GetAsynRSSI (HwCtrl_T *pHwCtrl,void *CB_Func, TI_HANDLE CB_handle, PUINT8 CB_Buf)
+{
+    int Stt;
+
+    Stt = whal_hwInfoElemRSSIGet (pHwCtrl->pHwMboxConfig, CB_Func, CB_handle, CB_Buf);
+                                         
+    return Stt;
+}
+
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetBssLossTsfThresholdParams()
+ ****************************************************************************
+ * DESCRIPTION: 
+ *              
+ *              
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: None
+ ****************************************************************************/
+int whal_hwCtrl_SetBssLossTsfThresholdParams(   HwCtrl_T *pHwCtrl,whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd) 
+{
+    AcxConnectionMonitorOptions AcxElm_BssLossTsfSynchronize;
+    AcxConnectionMonitorOptions *pCfg = &AcxElm_BssLossTsfSynchronize;
+
+    pCfg->BSSLossTimeout        = pRoamingTriggerCmd->BssLossTimeout;
+    pCfg->TSFMissedThreshold    = pRoamingTriggerCmd->TsfMissThreshold;
+    
+    return whal_hwInfoElemAcxBssLossTsfThresholdSet (pHwCtrl->pHwMboxConfig, pCfg);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_FwDisconnect()
+ ****************************************************************************
+ * DESCRIPTION: Disconnect. 
+ * 
+ * INPUTS: None
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_FwDisconnect(HwCtrl_T *pHwCtrl, uint32 ConfigOptions, uint32 FilterOptions)
+{
+    HwMboxCmd_T *pHwMboxCmd = pHwCtrl->pHwMboxCmd;
+
+    return whal_hwMboxCmd_FwDisconnect(pHwMboxCmd, ConfigOptions, FilterOptions);
+
+} /* whal_hwCtrl_FwDisconnect()*/
+
+
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_measurementParams()
+ ****************************************************************************
+ * DESCRIPTION: send Command for measurement configuration 
+ *              to the mailbox
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_measurement (HwCtrl_T *pHwCtrl, whalCtrl_MeasurementParameters_t* pMeasurementParams,
+                             void* MeasureCommandResponseCB, TI_HANDLE CB_handle)
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_measurementParams\n"));
+    return whal_hwMboxCmd_measurement (pHwCtrl->pHwMboxCmd, pMeasurementParams, 
+                                       MeasureCommandResponseCB, CB_handle);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_measurementStop()
+ ****************************************************************************
+ * DESCRIPTION: send Command for stoping measurement  
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_measurementStop (HwCtrl_T *pHwCtrl, void* MeasureCommandResponseCB, TI_HANDLE CB_handle)
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_measurementStop\n"));
+
+    return whal_hwMboxCmd_measurementStop (pHwCtrl->pHwMboxCmd, MeasureCommandResponseCB, CB_handle);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_ApDiscovery()
+ ****************************************************************************
+ * DESCRIPTION: send Command for AP Discovery 
+ *              to the mailbox
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_ApDiscovery (HwCtrl_T *pHwCtrl, whalCtrl_ApDiscoveryParameters_t* pApDiscoveryParams)
+
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_ApDiscovery\n"));
+
+    return( whal_hwMboxCmd_ApDiscovery (pHwCtrl->pHwMboxCmd, pApDiscoveryParams));
+
+}
+/****************************************************************************
+ *                      whal_hwCtrl_ApDiscoveryStop()
+ ****************************************************************************
+ * DESCRIPTION: send Command for stoping AP Discovery
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_ApDiscoveryStop (HwCtrl_T *pHwCtrl)
+
+
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwCtrl_ApDiscoveryStop\n"));
+    
+    return(whal_hwMboxCmd_ApDiscoveryStop (pHwCtrl->pHwMboxCmd));
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_healthCheck()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  
+ * 
+ * RETURNS: 
+ ****************************************************************************/
+int whal_hwCtrl_healthCheck (HwCtrl_T *pHwCtrl)
+{
+    WLAN_REPORT_INFORMATION(pHwCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("whal_hwMboxCmd_HealthCheck\n"));
+    
+    return(whal_hwMboxCmd_HealthCheck(pHwCtrl->pHwMboxCmd));
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_SoftGeminiEnable()
+ ****************************************************************************
+ * DESCRIPTION: Save Soft Gemini enable parameter
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SoftGeminiEnable (HwCtrl_T *pHwCtrl, 
+                                             SoftGeminiEnableModes_e SgEnable )
+{
+    /* copy params for recovery */
+    pHwCtrl->pWhalParams->WlanParams.SoftGeminiEnable = SgEnable;
+                    
+    return whal_hwInfoElemSoftGeminiEnableSet (pHwCtrl->pHwMboxConfig, SgEnable);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_SetSoftGeminiParams()
+ ****************************************************************************
+ * DESCRIPTION: Save Soft Gemini config parameter
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_SetSoftGeminiParams (HwCtrl_T *pHwCtrl, 
+                                             SoftGeminiParam_t *SgParam )
+{
+    /* copy params for recovery */
+    os_memoryCopy(pHwCtrl->hOs,(void*)&pHwCtrl->pWhalParams->WlanParams.SoftGeminiParams,
+                    (void*)SgParam,sizeof(SoftGeminiParam_t));
+                  
+    return whal_hwInfoElemSoftGeminiParamsSet (pHwCtrl->pHwMboxConfig,SgParam);
+}
+
+/****************************************************************************
+ *                      whal_hwCtrl_GetSoftGeminiParams()
+ ****************************************************************************
+ * DESCRIPTION: Get Soft Gemini config parameter
+ *
+ * INPUTS:
+ *
+ * OUTPUT:
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_GetSoftGeminiParams (HwCtrl_T *pHwCtrl, void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf)
+{                  
+    return whal_hwInfoElemSoftGeminiParamsGet (pHwCtrl->pHwMboxConfig, CB_Func, CB_handle, CB_Buf);
+}
+/****************************************************************************
+ *                      whal_hwCtrl_GxRatePolicy()
+ ****************************************************************************
+ * DESCRIPTION: Get TxRatePolicy params
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: txRatePolicy_t* - the TX rate policy
+ ****************************************************************************/
+
+txRatePolicy_t* whal_hwCtrl_GetTxRatePolicy(TI_HANDLE hHwCtrl)
+{
+    HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+    return whal_ParamsGetTxRateClassParams(pHwCtrl->pWhalParams);
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_TxRatePolicy()
+ ****************************************************************************
+ * DESCRIPTION: configure TxRatePolicy params
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+
+int whal_hwCtrl_TxRatePolicy(TI_HANDLE hHwCtrl,txRatePolicy_t *pTxRatePolicy)
+{
+    TI_STATUS   status = NOK;
+    HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+
+    UINT8 index;
+    txRateClass_t *pTxRateClass = pTxRatePolicy->rateClass;
+
+    WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,
+        ("%s_1, Num of classes = 0x%x\n",__FUNCTION__, pTxRatePolicy->numOfRateClasses));   
+
+    for(index = 0; index < pTxRatePolicy->numOfRateClasses; index++, pTxRateClass++)
+    {
+            WLAN_REPORT_DEBUG_CONTROL(pHwCtrl->hReport,
+                            ("%s_2loop, Index = %d, Short R = 0x%x, Long R = 0x%x, Flags = 0x%x Rates(HexDump) = \n",
+                            __FUNCTION__, index, 
+                            pTxRateClass->shortRetryLimit, pTxRateClass->longRetryLimit, pTxRateClass->flags));
+             
+            WLAN_REPORT_HEX_INFORMATION(pHwCtrl->hReport,
+                            HAL_HW_CTRL_MODULE_LOG,
+                            (PUINT8)pTxRateClass->txRate, sizeof(pTxRateClass->txRate));
+    }
+
+    /* Setting Rate Policy configuration into the HW */
+    status = (TI_STATUS)whal_hwInfoElemTxRatePolicyConfigurationSet (pHwCtrl->pHwMboxConfig, pTxRatePolicy);  
+
+    /* Set the Policy param object database fields according to the succeeded configuration (for recovery) */
+    if (status == OK)
+    {
+            whal_ParamsSetTxRateClassParams(pHwCtrl->pWhalParams,(txRatePolicy_t *)pTxRatePolicy);
+    }
+
+    return status;
+}
+
+
+/****************************************************************************
+ *                      whal_hwCtrl_ReJoinBss()
+ ****************************************************************************
+ * DESCRIPTION: 
+ * 
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_ReJoinBss (TI_HANDLE hHwCtrl)
+{
+    HwCtrl_T *pHwCtrl = (HwCtrl_T*)hHwCtrl;
+    BssInfoParams_T *pBssInfoParams = &pHwCtrl->pWhalParams->BssInfoParams;
+    TemplateListParams_T *pWhalTemplates = &pHwCtrl->pWhalParams->TemplateList;
+    HwMboxCmd_T *pHwCmd = whal_hwCtrl_GetMboxCmd (pHwCtrl);
+
+    /*
+     * Set the templates 
+     */
+    if (pWhalTemplates->Beacon.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->Beacon.Buffer, 
+                                               (UINT16)pWhalTemplates->Beacon.Size,
+                                               CMD_BEACON,
+                                               NULL,
+                                               NULL);
+    
+    if (pWhalTemplates->ProbeResp.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->ProbeResp.Buffer, 
+                                               (UINT16)pWhalTemplates->ProbeResp.Size,
+                                               CMD_PROBE_RESP,
+                                               NULL,
+                                               NULL);
+
+    if (pWhalTemplates->ProbeReq.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->ProbeReq.Buffer, 
+                                               (UINT16)pWhalTemplates->ProbeReq.Size,
+                                               CMD_PROBE_REQ,
+                                               NULL,
+                                               NULL);
+    
+    if (pWhalTemplates->NullData.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->NullData.Buffer, 
+                                               (UINT16)pWhalTemplates->NullData.Size,
+                                               CMD_NULL_DATA,
+                                               NULL,
+                                               NULL);
+    
+    if (pWhalTemplates->PsPoll.Size != 0)
+        whal_hwMboxCmd_ConfigureTemplateFrame (pHwCmd, 
+                                               pWhalTemplates->PsPoll.Buffer, 
+                                               (UINT16)pWhalTemplates->PsPoll.Size,
+                                               CMD_PS_POLL,
+                                               NULL,
+                                               NULL);
+
+    /*
+     * Call the hardware to start/join the BSS 
+     */
+    return whal_hwCtrl_StartJoin (pHwCtrl, (bssType_e)pBssInfoParams->ReqBssType, NULL, NULL);
+}
+
+/****************************************************************************
+ *                 whal_hwCtrl_setBetParams()
+ ****************************************************************************
+ * DESCRIPTION: Configures Beacon Early Termination information element.
+ * 
+ * Input    :   enabled               - 0 to disable BET, 0 to disable BET
+ *              MaximumConsecutiveET  - Max number of consecutive beacons
+ *                                      that may be early terminated.
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCtrl_setBetParams(HwCtrl_T * pHwCtrl, UINT8 Enable, UINT8 MaximumConsecutiveET)
+{
+    return whal_hwInfoElemBETSet(pHwCtrl->pHwMboxConfig, Enable, MaximumConsecutiveET);
+}
+
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwCtrl.h b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwCtrl.h
new file mode 100644 (file)
index 0000000..0be02ea
--- /dev/null
@@ -0,0 +1,329 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwCtrl.h
+ *   PURPOSE: Implements action on the Acx card (Reset, Run, SendCmd, Sw Download)
+ *
+ ****************************************************************************/
+
+#ifndef _WHAL_HW_CTRL_H
+#define _WHAL_HW_CTRL_H
+
+#include "whalCommon.h"
+#include "whalHwMboxCmd.h"
+#include "whalHwMboxCmdBit.h"
+#include "whalHwMboxConfig.h"
+#include "whalBus_Api.h"
+#include "whalCtrl.h"
+#include "whalCtrl_api.h"
+#include "whalParams.h"
+#include "CmdQueue_api.h"
+#include "commonTypes.h"
+
+
+typedef struct
+{  
+    /* Mbox */
+    UINT32     NumMboxFailures;
+    UINT32     NumMboxErrDueToPeriodicBuiltInTestCheck;
+
+} whalCtrl_hwStatus_t;
+                      
+typedef struct _HwCtrl_T
+{
+    MemoryMap_t             MemMap;
+    ACXDataPathParamsResp_t DataPathParams;
+
+    HwMboxConfig_T          *pHwMboxConfig;
+    HwMboxCmd_T             *pHwMboxCmd;
+    HwMboxCmdBit_T          *pHwMboxCmdBit;
+    struct WHAL_CTRL        *pWhalCtrl;
+    WhalParams_T            *pWhalParams;
+    whalCtrl_hwStatus_t     HwStatus;
+
+    UINT16                  SecuritySeqNumLow;
+    UINT32                  SecuritySeqNumHigh;
+
+    TI_HANDLE               *hHwRadio;
+
+    TI_HANDLE               hWhalBus;
+    TI_HANDLE               hOs;
+    TI_HANDLE               hReport;
+    TI_HANDLE               hWhalCtrl;
+    TI_HANDLE               hEventMbox;
+
+    UINT32                  uFwBuf;
+    UINT32                  uFwAddr; 
+    UINT32                  uEEEPROMBuf;
+    UINT32                  uEEEPROMLen; 
+    void                    *fCb;
+    TI_HANDLE               hCb;
+
+    dot11StationIDStruct    mbox;
+
+} HwCtrl_T;
+
+
+TI_STATUS  whal_hwCtrl_FinalizeDownload  (TI_HANDLE hHwCtrl, BootAttr_T *pBootAttr);
+TI_STATUS  whal_hwCtrl_FinalizeOnFailure (TI_HANDLE hHwCtrl);
+
+extern HwCtrl_T *whal_hwCtrl_Create(TI_HANDLE hOs, WhalParams_T *pWhalParams);
+extern int whal_hwCtrl_Destroy                         (HwCtrl_T *pHwCtrl);
+extern TI_STATUS whal_hwCtrl_Config(HwCtrl_T *pHwCtrl, TI_HANDLE hWhalCtrl,UINT8 AccessMode, UINT32 AcxRegAddr, 
+                                    UINT32 AcxMemAddr, TI_HANDLE hReport, TI_HANDLE hMemMgr,UINT32 *pFWImage,
+                                    TI_HANDLE hEventMbox);
+extern TI_HANDLE whal_hwCtrl_GetTnentwifHandle (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_ConfigHw                                (HwCtrl_T *pHwCtrl, void *fCb, TI_HANDLE hCb, BOOL bRecovery);
+extern TI_STATUS whal_hwCtrl_Initiate       (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_SetMacAddress           (HwCtrl_T *pHwCtrl, macAddress_t *macAddr);
+extern int whal_hwCtrl_StartJoin                       (HwCtrl_T *pHwCtrl, bssType_e BssType, void *JoinCompleteCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_SetBssType                      (HwCtrl_T *pHwCtrl, bssType_e BssType, UINT8 *HwBssType);
+extern int whal_hwCtrl_setRxFilters                    (HwCtrl_T *pHwCtrl, UINT32 RxConfigOption, UINT32 RxFilterOption);
+extern int whal_hwCtrl_GetRxFilters                    (HwCtrl_T *pHwCtrl, UINT32* pRxConfigOption, UINT32* pRxFilterOption);
+extern int whal_hwCtrl_setRxDataFiltersParams(HwCtrl_T * pHwCtrl, BOOL enabled, filter_e defaultAction);
+extern int whal_hwCtrl_setRxDataFilter      (HwCtrl_T *pHwCtrl, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns);
+extern int whal_hwCtrl_StartScan                       (HwCtrl_T *pHwCtrl, ScanParameters_t* pScanVals,void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_StartSPSScan         (HwCtrl_T *pHwCtrl, ScheduledScanParameters_t* pScanVals, void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_StopScan                                (HwCtrl_T *pHwCtrl, void *ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_StopSPSScan          (HwCtrl_T *pHwCtrl, void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_GenCmd                          (HwCtrl_T *pHwCtrl, short CmdID, char* pBuf, UINT32 Length);
+extern int whal_hwCtrl_EnableDataPath       (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_EnableTx                                (HwCtrl_T *pHwCtrl, int channel);
+extern int whal_hwCtrl_DisableTx                       (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_DisableDataPath      (HwCtrl_T *pHwCtrl);
+extern void whal_hwCtrl_Reset                  (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_PMConfig                                (HwCtrl_T *pHwCtrl, whalCtrl_powerMgmtConfig_t *pPMConfig);
+extern int whal_hwCtrl_BcnBrcOptions           (HwCtrl_T *pHwCtrl, whalCtrl_powerMgmtConfig_t *pPMConfig);
+extern int whal_hwCtrl_wakeUpCondition         (HwCtrl_T *pHwCtrl, whalCtrl_powerMgmtConfig_t *pPMConfig);
+extern int whal_hwCtrl_SetEnergyDetection      (HwCtrl_T *pHwCtrl, BOOL energyDetection);
+extern int whal_hwCtrl_WepDefaultKeyAdd     (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_WepDefaultKeyRemove  (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_WepMappingKeyAdd     (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_WepMappingKeyRemove  (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_AesMappingKeyAdd                (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_AesMappingKeyRemove  (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_TkipMicMappingKeyAdd    (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_TkipMicMappingKeyRemove (HwCtrl_T *pHwCtrl, securityKeys_t* aSecurityKey, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_TkipKeyEnable        (HwCtrl_T *pHwCtrl, char* MACaddr, BOOL aKey0RxEnable, BOOL aKey0TxEnable);
+extern int whal_hwCtrl_DefaultKeyIdSet         (HwCtrl_T *pHwCtrl, UINT8 aKeyIdVal, void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_DefaultKeyIdGet         (HwCtrl_T *pHwCtrl, UINT8 *pKeyIdVal);
+extern int whal_hwCtrl_SetBeaconFiltering      (HwCtrl_T *pHwCtrl, UINT8 beaconFilteringStatus, UINT8 numOfBeaconsToBuffer);
+
+extern int whal_hwCtrl_SetBeaconFilterIETable(HwCtrl_T *pHwCtrl, UINT8* numberOfIEs, UINT8 * IETable, UINT8* IETableSize);
+
+extern int whal_hwCtrl_GetGroupAddressesTable (HwCtrl_T *pHwCtrl,UINT8* pisEnabled, UINT8* pnumGroupAddrs, macAddress_t *Group_addr);
+extern int whal_hwCtrl_SetGroupAddressesTable (HwCtrl_T *pHwCtrl,UINT8 numGroupAddrs, macAddress_t *Group_addr, UINT8 isEnabled);
+extern int whal_hwCtrl_SetRtsThreshold (HwCtrl_T *pHwCtrl,UINT16 RtsThreshold);
+extern int whal_hwCtrl_SetarpIpAddressesTable(HwCtrl_T *pHwCtrl, IpAddress_t *IP_addr, UINT8 isEnabled , IPver_e IP_ver);
+extern int whalCtrl_GetArpIpAddressesTable (HwCtrl_T *pHwCtrl, IpAddress_t *IP_addr, UINT8* pisEnabled , IPver_e* pIP_ver);
+extern int whal_hwCtrl_SetarpIpFilterEnabled(HwCtrl_T *pHwCtrl, UINT8 isEnabled ) ;
+extern void whal_hwCtrl_Stop                           (HwCtrl_T *pHwCtrl);
+extern BOOL whal_hwCtrl_isElpSupported         (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_AidSet                          (HwCtrl_T *pHwCtrl, UINT16 aAidVal);
+
+extern int whal_hwCtrl_SaveAntennaDiversityOptions (HwCtrl_T *pHwCtrl, 
+                                                    whalCtrl_antennaDiversityOptions_t* pAntennaDivresityOptions);
+extern int whal_hwCtrl_CurrentAntennaDiversitySendCmd (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_SetTxAntenna (HwCtrl_T *pHwCtrl, UINT8 TxAntenna);
+extern int whal_hwCtrl_GetTxAntenna (HwCtrl_T *pHwCtrl, UINT8* TxAntenna);
+extern int whal_hwCtrl_SetRxAntenna (HwCtrl_T *pHwCtrl, UINT8 RxAntenna);
+extern int whal_hwCtrl_GetRxAntenna (HwCtrl_T *pHwCtrl, UINT8* RxAntenna);
+
+extern int whal_hwCtrl_PowerMgmtOptionsPrint(HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_PowerMgmtConfigurationSet (HwCtrl_T *pHwCtrl,
+                                                        whalCtrl_powerSaveParams_t* powerSaveParams);
+/*                                                                             whalCtrl_powerMgmtConfig_t *thePowerMgmtOptionsConfig);*/
+extern int whal_hwCtrl_switchChannel           (HwCtrl_T *pHwCtrl, UINT8 channel);
+extern int whal_hwCtrl_SetRegulatoryDomain     (HwCtrl_T *pHwCtrl, radioBand_e radioBand);
+extern int whal_hwCtrl_SetACIConfiguration     (HwCtrl_T *pHwCtrl, UINT8 ACIMode, UINT8 inputCCA, UINT8 qualifiedCCA,
+                                            UINT8 stompForRx, UINT8 stompFortTx, UINT8 txCCA);
+extern int whal_hwCtrl_CurrentAssociationIdGet (HwCtrl_T *pHwCtrl, UINT16  *pAidVal);
+
+extern int whal_HwCtrl_enableMboxAsyncMode     (HwCtrl_T *pHwCtrl);
+extern int whal_HwCtrl_resetMacRx (HwCtrl_T *pHwCtrl);
+extern int whal_HwCtrl_LNAControl (HwCtrl_T *pHwCtrl, UINT8 LNAControlField);
+extern int whal_hwCtrl_NoiseHistogramCmd (HwCtrl_T *pHwCtrl, whalCtrl_noiseHistogram_t* pNoiseHistParams);
+extern int whal_hwCtrl_SwitchChannelCmd (HwCtrl_T *pHwCtrl, whalCtrl_switchChannelCmd_t* pSwitchChannelCmd);
+extern int whal_hwCtrl_SwitchChannelCancelCmd (HwCtrl_T *pHwCtrl);
+
+extern int whal_hwCtrl_SetSNRParams(HwCtrl_T *pHwCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd) ;
+extern int whal_hwCtrl_SetRSSIParams(HwCtrl_T *pHwCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd) ;
+extern int whal_hwCtrl_SetMaxTxRetryParams(HwCtrl_T *pHwCtrl, whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd);
+extern int whal_hwCtrl_SetBssLossTsfThresholdParams(   HwCtrl_T *pHwCtrl,whalCtrl_roamingTriggerCmd_t* pRoamingTriggerCmd);
+extern int whal_hwCtrl_GetAsynRSSI (HwCtrl_T *pHwCtrl,void *CB_Func, TI_HANDLE CB_handle, PUINT8 CB_Buf);
+
+extern int whal_hwCtrl_ClkRunEnableSet  (HwCtrl_T *pHwCtrl, BOOL aClkRunEnable);
+
+extern int whal_hwCtrl_ArmClockSet (HwCtrl_T *pHwCtrl, UINT32 ArmClock);
+extern int whal_hwCtrl_MacClockSet (HwCtrl_T *pHwCtrl, UINT32 MacClock);
+
+extern TI_HANDLE whal_hwCtrl_GetBusHandle(HwCtrl_T *pHwCtrl);
+extern HwMboxConfig_T *whal_hwCtrl_GetMboxConfig(HwCtrl_T *pHwCtrl);
+extern HwMboxCmd_T    *whal_hwCtrl_GetMboxCmd(HwCtrl_T *pHwCtrl);
+
+extern int whal_hwCtrl_getTsf(HwCtrl_T *pHwCtrl, UINT32 *pTsf);
+
+extern int whal_hwCtrl_SetSlotTime     (HwCtrl_T *pHwCtrl, slotTime_e SlotTimeVal);
+extern int whal_hwCtrl_SetPreamble     (HwCtrl_T *pHwCtrl, Preamble_e preambleVal);
+int whal_hwCtrl_SetFrameRate(HwCtrl_T *pHwCtrl, 
+                                UINT8  txCtrlFrmRateVal,
+                                UINT8          txCtrlFrmModVal,
+                                UINT8          txMgmtFrmRateVal,
+                                UINT8          txMgmtFrmModVal);
+extern int whal_hwCtrl_EncDecrSet     (HwCtrl_T *pHwCtrl, BOOL aHwEncEnable, BOOL aHwDecEnable);
+extern int whal_hwCtrl_RxMsduFormatSet(HwCtrl_T *pHwCtrl, BOOL aRxMsduForamtEnable);
+extern int  whal_hwCtrl_PacketDetectionThreshold (TI_HANDLE hHwCtrl, UINT8* pPdThreshold);
+extern int whal_hwCtrl_FwDisconnect(HwCtrl_T *pHwCtrl, uint32 ConfigOptions, uint32 FilterOptions);
+extern int whal_hwCtrl_MinPowerLevelSet (HwCtrl_T *pHwCtrl, powerAutho_PowerPolicy_e minPowerLevel);
+
+extern int whal_hwCtrl_SoftGeminiEnable(HwCtrl_T *pHwCtrl,SoftGeminiEnableModes_e SgEnable);
+extern int whal_hwCtrl_SetSoftGeminiParams(HwCtrl_T *pHwCtrl,SoftGeminiParam_t *SgParam);
+int whal_hwCtrl_GetSoftGeminiParams (HwCtrl_T *pHwCtrl, void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf);
+extern int whal_hwCtrl_TxRatePolicy(TI_HANDLE hHwCtrl,txRatePolicy_t *pTxRatePolicy);
+extern txRatePolicy_t* whal_hwCtrl_GetTxRatePolicy(TI_HANDLE hHwCtrl);
+extern int whal_hwCtrl_ReJoinBss (TI_HANDLE hHwCtrl);
+int whal_hwCtrl_setBetParams(HwCtrl_T * pHwCtrl, UINT8 Enable, UINT8 MaximumConsecutiveET);
+
+/*
+ *     WME TX API
+ */
+extern int  whal_hwCtrl_TrafficConf(TI_HANDLE hHwCtrl, queueTrafficParams_t *pQtrafficParams);
+extern int  whal_hwCtrl_AcParamsConf(TI_HANDLE hHwCtrl,configureCmdCBParams_t *pConfigureCommand);
+extern int  whal_hwCtrl_QueueConf(TI_HANDLE hHwCtrl, acQueuesParams_t* pAcQueuesParams);
+
+#if 0
+extern int  whal_hwCtrl_TrafficConf       (TI_HANDLE hHwCtrl, whaCtrl_acTrafficParams_t* pAcTrafficParams);
+extern int  whal_hwCtrl_TxConfigOptions   (TI_HANDLE hHwCtrl);
+#endif
+
+/* Measurement */
+extern int whal_hwCtrl_measurement (HwCtrl_T *pHwCtrl, whalCtrl_MeasurementParameters_t* pMeasurementParams,
+                             void* MeasureCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_measurementStop (HwCtrl_T *pHwCtrl, void* MeasureCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwCtrl_ApDiscovery (HwCtrl_T *pHwCtrl, whalCtrl_ApDiscoveryParameters_t* pMeasurementParams);
+extern int whal_hwCtrl_ApDiscoveryStop (HwCtrl_T *pHwCtrl);
+extern int whal_hwCtrl_healthCheck (HwCtrl_T *pHwCtrl);
+
+
+/*
+PowerMgmtOption enum
+*/
+typedef enum
+{
+    /* beacon/dtim/listen interval */
+    POWER_MGMT_OPTIONS_WAKEUP_ON_ALL_BEACONS_VAL = 0x0,
+
+    POWER_MGMT_OPTIONS_WAKEUP_ON_ALL_DITMS_VAL = 0x1,
+
+    POWER_MGMT_OPTIONS_WAKEUP_ON_EVERY_LISTEN_INTERVAL_VAL = 0x2,
+
+    POWER_MGMT_OPTIONS_WAKEUP_ON_N_DITM_VAL = 0x5,
+
+    POWER_MGMT_OPTIONS_WAKEUP_ON_MASK = 0x7,
+
+    /* gpio/wake on host */
+    POWER_MGMT_OPTIONS_WAKEUP_ON_GPIO_OFFSET = 6,
+
+    POWER_MGMT_OPTIONS_WAKEUP_ON_GPIO_VAL = 1<<POWER_MGMT_OPTIONS_WAKEUP_ON_GPIO_OFFSET,
+
+    POWER_MGMT_OPTIONS_WAKEUP_ON_GPIO_MASK = 1<<POWER_MGMT_OPTIONS_WAKEUP_ON_GPIO_OFFSET,
+
+    /* 802.11 ps Enable */
+    POWER_MGMT_OPTIONS_PS_802_11_ENABLE_OFFSET = 7,
+
+    POWER_MGMT_OPTIONS_PS_802_11_ENABLE_VAL = 1<<POWER_MGMT_OPTIONS_PS_802_11_ENABLE_OFFSET,
+
+    POWER_MGMT_OPTIONS_PS_802_11_ENABLE_MASK = 1<<POWER_MGMT_OPTIONS_PS_802_11_ENABLE_OFFSET,
+
+    /* 802.11 ps Disable send of null data frame on exit from PS */
+    POWER_MGMT_OPTIONS_PS_802_11_DISABLE_NULL_DATA_SEND_ON_EXIT_OFFSET = 5,
+
+    POWER_MGMT_OPTIONS_PS_802_11_DISABLE_NULL_DATA_SEND_ON_EXIT_VAL = 1<<POWER_MGMT_OPTIONS_PS_802_11_DISABLE_NULL_DATA_SEND_ON_EXIT_OFFSET,
+
+    POWER_MGMT_OPTIONS_PS_802_11_DISABLE_NULL_DATA_SEND_ON_EXIT_MASK = 1<<POWER_MGMT_OPTIONS_PS_802_11_DISABLE_NULL_DATA_SEND_ON_EXIT_OFFSET,
+
+
+    /* Rx Broadcast (ignore broadcast / proxy arp) */
+    POWER_MGMT_OPTIONS_RX_BROADCAST_OFFEST = 0,
+
+    POWER_MGMT_OPTIONS_RX_BROADCAST_VAL = 1<<POWER_MGMT_OPTIONS_RX_BROADCAST_OFFEST,
+
+    POWER_MGMT_OPTIONS_RX_BROADCAST_MASK = 1<<POWER_MGMT_OPTIONS_RX_BROADCAST_OFFEST,
+
+    /* HW PS POLL */
+    POWER_MGMT_OPTIONS_HW_PS_POLL_OFFSET = 1,
+
+    POWER_MGMT_OPTIONS_HW_PS_POLL_OFF_VAL = 1<<POWER_MGMT_OPTIONS_HW_PS_POLL_OFFSET,
+
+    POWER_MGMT_OPTIONS_HW_PS_POLL_MASK = 1<<POWER_MGMT_OPTIONS_HW_PS_POLL_OFFSET
+
+}whalHwCtrl_PowerMgmtOptionsDefinitions;
+
+/*
+BeaconFiltering enum
+*/
+typedef enum
+{
+    /* beacon filtering activation */
+    BEACON_FILTER_DISABLE_VAL = 0,
+
+    BEACON_FILTER_ENABLE_VAL = 1
+
+}whalHwCtrl_BeaconFilteringOptionsDefinitions;
+
+
+/* 
+ * EEPROM defines
+ */
+/*******************
+ Radio constants
+ *******************/
+#define RADIO_MAXIM2820_ID    (0x0D)
+#define RADIO_RFMD_ID         (0x11)
+#define RADIO_RADIA_BG_ID     (0x16)
+#define RADIO_RADIA_ABG_ID    (0x17)
+#define RADIO_RADIA_BG_CRT_ID (0x19)
+#define RADIO_RADIA_CRT_ID    (0x19)
+#define RADIO_RADIA_WBR_ID    (0x1A)
+#define RADIO_RADIA_DCR_ID    (0x1B)
+#define RADIO_RADIA_DCR_1251_ID (0x1C)
+#define DEFAULT_RADIO_TYPE        RADIO_MAXIM2820_ID
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmd.c b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmd.c
new file mode 100644 (file)
index 0000000..ba6fa3c
--- /dev/null
@@ -0,0 +1,947 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwMboxCmd.c
+ *   PURPOSE: wlan hardware commands handler
+ * 
+ ****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalHwMboxCmd.h"
+#include "whalBus_Api.h"
+#include "CmdQueue_api.h"
+
+/* Local Macros */
+
+#define MAC_TO_VENDOR_PREAMBLE(mac) ((mac[0] << 16) | (mac[1] << 8) | mac[2])
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_Create()
+ ****************************************************************************
+ * DESCRIPTION:        Create the mailbox commands object
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    The Created object
+ ****************************************************************************/
+HwMboxCmd_T *whal_hwMboxCmd_Create(TI_HANDLE hOs, WhalParams_T *pWhalParams)
+{
+       HwMboxCmd_T *pObj;
+
+       pObj = os_memoryAlloc(hOs, sizeof(HwMboxCmd_T));
+       if (pObj == NULL)
+               return NULL;
+
+       os_memoryZero(hOs, (void *)pObj, sizeof(HwMboxCmd_T));
+
+       pObj->hOs = hOs;
+       pObj->pWhalParams = pWhalParams;
+
+       return(pObj);
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_Destroy()
+ ****************************************************************************
+ * DESCRIPTION:        Destroy the object 
+ * 
+ * INPUTS:     
+ *             pHwMboxCmd              The object to free
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_Destroy(HwMboxCmd_T *pHwMboxCmd)
+{
+       if (pHwMboxCmd)
+               os_memoryFree(pHwMboxCmd->hOs, pHwMboxCmd, sizeof(HwMboxCmd_T));
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_Config()
+ ****************************************************************************
+ * DESCRIPTION:        Configure the object 
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_Config(HwMboxCmd_T *pHwMboxCmd, TI_HANDLE hCmdMboxQueue, TI_HANDLE hReport)
+{
+       pHwMboxCmd->hReport = hReport;
+       pHwMboxCmd->hCmdMboxQueue = hCmdMboxQueue;
+       return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_StartBss()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the StartBss command fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_StartBss(HwMboxCmd_T *pHwMboxCmd, BSS_e BssType, void *JoinCompleteCB, TI_HANDLE CB_handle)
+{
+       StartJoinRequest_t AcxCmd_StartBss;
+       StartJoinRequest_t *pCmd = &AcxCmd_StartBss;
+       dot11_SSID_t *pWlanElm_Ssid = whal_ParamsGetElm_Ssid(pHwMboxCmd->pWhalParams);
+       BssInfoParams_T *pBssInfoParams = whal_ParamsGetBssInfoParams(pHwMboxCmd->pWhalParams);
+       UINT8 *BssId;
+       UINT8 *cmdBssId;
+       UINT16 HwBasicRatesBitmap;
+       UINT16 HwSupportedRatesBitmap;
+       int i; 
+       
+       os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(StartJoinRequest_t));
+
+       /*
+    * Set RxCfg and RxFilterCfg values
+    */
+    pCmd->rxFilter.ConfigOptions = ENDIAN_HANDLE_LONG( pHwMboxCmd->pWhalParams->WlanParams.RxConfigOption );
+    pCmd->rxFilter.FilterOptions = ENDIAN_HANDLE_LONG( pHwMboxCmd->pWhalParams->WlanParams.RxFilterOption );
+
+    pCmd->beaconInterval = ENDIAN_HANDLE_WORD(whal_ParamsGetBeaconInterval(pHwMboxCmd->pWhalParams));
+       pCmd->dtimInterval = whal_ParamsGetDtimCount(pHwMboxCmd->pWhalParams); 
+       pCmd->channelNumber = whal_ParamsGetRadioChannel(pHwMboxCmd->pWhalParams);
+       
+
+       pCmd->bssType = BssType;
+       
+       /* Add radio band */
+       pCmd->bssType |= whal_ParamsGetRadioBand (pHwMboxCmd->pWhalParams) << 4;
+    pCmd->ctrl = pBssInfoParams->Ctrl; /* Only bit 7 is currently in use in the Ctrl field, bit 7 indicates if to flash the Tx queues */
+
+       
+    /*
+        * BasicRateSet
+        * The wlan hardware uses pHwMboxCmd field to determine the rate at which to transmit 
+        * control frame responses (such as ACK or CTS frames)
+        */
+       whalUtils_ConvertAppRatesBitmap(pBssInfoParams->BasicRateSet, 0, &HwBasicRatesBitmap);
+
+       
+    /*
+        * SupportedRateSet
+        * The wlan hardware uses pHwMboxCmd information to determine which rates are allowed 
+        * when rate fallback is enabled
+        */
+       whalUtils_ConvertAppRatesBitmap(pBssInfoParams->SupportedRateSet, 0, &HwSupportedRatesBitmap);
+       pCmd->basicRateSet  = ENDIAN_HANDLE_WORD(HwBasicRatesBitmap);
+
+       /*
+        * ACX100_Frm_Rate
+        * pHwMboxCmd field indicates the rate at which the wlan hardware transmits 
+        * Beacon, Probe Response, RTS, and PS-Poll frames
+        */
+       pCmd->txCtrlFrmRate = pBssInfoParams->txCtrlFrmRate;
+
+       WLAN_REPORT_INFORMATION(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("txCtrlFrmRate = 0x%x\n", pCmd->txCtrlFrmRate));
+       /*
+        * PreambleOpt
+        * indicates the PLCP preamble type to use when transmitting 
+        * Beacon, Probe Response, RTS, and PS-Poll frames.
+        */
+       pCmd->txCtrlFrmMod = pBssInfoParams->txCtrlFrmModulation;
+
+       /* BSS ID - reversed order (see wlan hardware spec) */
+       BssId = whal_ParamsGetBssId(pHwMboxCmd->pWhalParams);
+    cmdBssId = (UINT8*)&pCmd->bssIdL;
+       for (i=0; i<MAC_ADDR_SIZE; i++)
+               cmdBssId[i] = BssId[MAC_ADDR_SIZE-1-i];
+
+    /* SSID string */ 
+    pCmd->ssidLength = pWlanElm_Ssid->hdr.eleLen;
+    os_memoryCopy(pHwMboxCmd->hOs, (void *)(pCmd->ssidStr),(void *)pWlanElm_Ssid->serviceSetId, pWlanElm_Ssid->hdr.eleLen);
+
+       /* Set the Frame Rate and The Frame Mode */
+       pCmd->txMgmtFrmRate = pBssInfoParams->txMgmtFrmRate;
+       pCmd->txMgmtFrmMod  = pBssInfoParams->txMgmtFrmModulation;
+
+    /* Send the command */
+       if(JoinCompleteCB == NULL)
+               return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_START_JOIN, (char *)pCmd, sizeof(*pCmd)));
+       else
+               return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_START_JOIN, (char *)pCmd, sizeof(*pCmd), (void *)JoinCompleteCB, CB_handle, NULL));
+
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_LNAControl()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the LNA control command fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_LNAControl(HwMboxCmd_T *pHwMboxCmd, UINT8 LNAControlField)
+{
+       LNAControl_t AcxCmd_LNAControl;
+       LNAControl_t *pCmd = &AcxCmd_LNAControl;
+       
+       pCmd->LNAControlField = LNAControlField;
+       
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_LNA_CONTROL , (char *)pCmd, sizeof(*pCmd)));
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_Reset()
+ ****************************************************************************
+ * DESCRIPTION:        Reset the Rx wlan hardware
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_RxReset(HwMboxCmd_T *pHwMboxCmd)
+{
+       /*
+        * no parameters 
+        */
+       
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_RX_RESET, NULL, 0));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_Reset()
+ ****************************************************************************
+ * DESCRIPTION:        Reset the wlan hardware
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_Reset(HwMboxCmd_T *pHwMboxCmd)
+{
+       /*
+        * no parameters 
+        */
+       
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_RESET, NULL, 0));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_EnableRx()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the EnableRx command fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_EnableRx(HwMboxCmd_T *pHwMboxCmd)
+{
+       UINT8 ChannelNumber;
+
+       ChannelNumber = whal_ParamsGetDefaultChannel(pHwMboxCmd->pWhalParams);
+
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_ENABLE_RX, (char *)&ChannelNumber, sizeof(UINT8)));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_EnableTx()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the EnableTx command fileds and send it to the mailbox
+ *                             Note: This Enable_TX command is used also for changing the serving 
+ *                             channel.
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_EnableTx(HwMboxCmd_T *pHwMboxCmd ,UINT8     defaultChannel)
+{
+       UINT8 ChannelNumber;
+       
+       ChannelNumber = defaultChannel;
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_ENABLE_TX, (char *)&ChannelNumber, sizeof(UINT8)));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_DisableRx()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the DisableRx command fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_DisableRx(HwMboxCmd_T *pHwMboxCmd)
+{
+       /*
+        * no parameters 
+        */
+       
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_DISABLE_RX, NULL, 0));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_DisableTx()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the DisableTx command fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_DisableTx(HwMboxCmd_T *pHwMboxCmd)
+{
+       /*
+        * no parameters 
+        */
+       
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_DISABLE_TX, NULL, 0));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_ConfigureTemplateFrame()
+ ****************************************************************************
+ * DESCRIPTION:        Generic function which sets the Fw with a template frame according
+ *              to the given template type.
+ * 
+ * INPUTS: templateType - CMD_BEACON, CMD_PROBE_REQ, CMD_PROBE_RESP etc.
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_ConfigureTemplateFrame(HwMboxCmd_T *pHwMboxCmd, UINT8 *pFrame, UINT16 FrameSize,
+                                          Command_e templateType, void *CBFunc,TI_HANDLE CBObj)
+{
+    PktTemplate_t AcxCmd_PktTemplate;
+       PktTemplate_t *pCmd = &AcxCmd_PktTemplate;
+
+    /* if the frame size is too big - we truncate the frame template */
+    if (FrameSize > MAX_TEMPLATES_SIZE)
+    {
+        WLAN_REPORT_ERROR(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("%s: Frame size (=%d) is bigger than MAX_TEMPLATES_SIZE(=%d) !!!\n",
+            __FUNCTION__,FrameSize,MAX_TEMPLATES_SIZE));
+
+        FrameSize = MAX_TEMPLATES_SIZE;
+    }
+    
+    /* if pFrame is NULL than it means that we just want to reserve place in Fw, and there is no need to copy */
+    if (pFrame != NULL) 
+    {
+        /* Set configuration fields */
+           os_memoryCopy(pHwMboxCmd->hOs, (void *)&pCmd->templateStart, (void *)pFrame, FrameSize);
+    }
+       pCmd->len = ENDIAN_HANDLE_WORD(FrameSize);
+
+    if (NULL == CBFunc)
+       {
+               return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, templateType, (char *)pCmd, FrameSize + sizeof(pCmd->len)));
+       }
+       else
+       {
+               return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, templateType, (char *)pCmd, FrameSize + sizeof(pCmd->len),
+                       CBFunc,CBObj,NULL));
+       }
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_TimTemplate()
+ ****************************************************************************
+ * DESCRIPTION:        Build the tim template fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_TimTemplate(HwMboxCmd_T *pHwMboxCmd, char BmapControl, char *PartialBmapVec, int PartialBmapLen)
+{ 
+       VBMUpdateRequest_t AcxCmd_ConfTim;
+       VBMUpdateRequest_t *pCmd = &AcxCmd_ConfTim;
+
+       /*
+        * Set command fields 
+        */
+       os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+
+       /* 
+        * Copy the fields and set sizes 
+        */
+       pCmd->tim.BitMap_ctrl = BmapControl;
+       /* dtimCount and dtimPeriod will be filled by the wlan hardware */
+       os_memoryCopy(pHwMboxCmd->hOs, (void *)pCmd->tim.PVB_field, (void *)PartialBmapVec, PartialBmapLen);
+       pCmd->tim.identity  = DOT11_TIM_ELE_ID;
+       pCmd->tim.length    = 3+PartialBmapLen;
+       pCmd->len = ENDIAN_HANDLE_WORD(5+PartialBmapLen);
+
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_VBM, (char *)pCmd, sizeof(*pCmd)));
+
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_SetKey()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the SetKey command fileds and send it to the mailbox
+ * 
+ * INPUTS: 
+ *             Action          - add/remove key
+ *             MacAddr         - relevant only for mapping keys
+ *             KeySize         - key size
+ *             KeyType         - default/mapping/TKIP
+ *             KeyId           - relevant only for default keys
+ *             Key                     - key data
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_SetKey(HwMboxCmd_T *pHwMboxCmd, int Action, char *MacAddr, int KeySize,
+                                                 int KeyType, int KeyId, char *Key, UINT16 SecuritySeqNumLow, UINT32 SecuritySeqNumHigh,
+                                                 void *CB_Func, TI_HANDLE CB_handle)
+{
+       SetKey_t AcxCmd_SetKey;
+       SetKey_t *pCmd = &AcxCmd_SetKey;
+
+       /*
+       * Set command fields
+       */
+       os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+
+       /*
+       * Command fields
+       */
+       os_memoryCopy(pHwMboxCmd->hOs, (void *)pCmd->addr, (void *)MacAddr, MAC_ADDR_SIZE);
+       if (KeySize > MAX_KEY_SIZE)
+       {
+               os_memoryCopy(pHwMboxCmd->hOs, (void *)pCmd->key, (void *)Key, MAX_KEY_SIZE);
+       } else {
+               os_memoryCopy(pHwMboxCmd->hOs, (void *)pCmd->key, (void *)Key, KeySize);
+       }
+       pCmd->action = (UINT8)Action;
+       pCmd->keySize = (UINT8)KeySize;
+       pCmd->type = (UINT8)KeyType;
+       pCmd->id = (UINT8)KeyId;
+       pCmd->ssidProfile = 0;
+
+       /*
+       * Preserve TKIP/AES security sequence number after recovery.
+       * Note that our STA Tx is currently using only one sequence-counter
+       * for all ACs (unlike the Rx which is separated per AC).
+       */
+       pCmd->AcSeqNum16[0] = SecuritySeqNumLow;
+       pCmd->AcSeqNum16[1] = 0;
+       pCmd->AcSeqNum16[2] = 0;
+       pCmd->AcSeqNum16[3] = 0;
+
+       pCmd->AcSeqNum32[0] = SecuritySeqNumHigh;
+       pCmd->AcSeqNum32[1] = 0;
+       pCmd->AcSeqNum32[2] = 0;
+       pCmd->AcSeqNum32[3] = 0;
+
+
+       WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("*********************** \n"));
+
+       WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("whal_hwMboxCmd_SetKey \n"));
+
+       WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("*********************** \n"));
+
+    WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("addr = %x:%x:%x:%x:%x:%x \n",
+         pCmd->addr[0], pCmd->addr[1], pCmd->addr[2], pCmd->addr[3], pCmd->addr[4], pCmd->addr[5] ));
+
+       WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+               (" key= %x\n, action= %d\n keySize= %d\n type= %d\n id= %d\n AcSeqNum16[0]= %d\n AcSeqNum32[0]= %d\n",
+               pCmd->key,pCmd->action,pCmd->keySize,pCmd->type, pCmd->id, pCmd->AcSeqNum16[0], pCmd->AcSeqNum32[0] ));
+
+       WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("*********************** \n"));
+
+       /*
+       * Send the command
+       */
+       if((CB_Func == NULL) || (CB_handle == NULL))
+       {
+               WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+                       ("*** whal_hwMboxCmd_SetKey:Calling CmdQueue_Command *** \n"));
+
+               return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_SET_KEYS, (char *)pCmd, sizeof(*pCmd)));
+       }
+       else
+       {
+               WLAN_REPORT_WARNING(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,
+                       ("!!! whal_hwMboxCmd_SetKey:CmdQueue_CommandwithCB !!! \n"));
+
+               return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_SET_KEYS, (char *)pCmd, sizeof(*pCmd), CB_Func, CB_handle, NULL));
+       }
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_Test()
+ ****************************************************************************
+ * DESCRIPTION:        Test NO WAIT (use EnableRx command)
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_Test(HwMboxCmd_T *pHwMboxCmd)
+{
+       UINT8 ChannelNumber = whal_ParamsGetRadioChannel(pHwMboxCmd->pWhalParams);
+       
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_ENABLE_RX, (char *)&ChannelNumber, sizeof(UINT8)));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_StartScan ()
+ ****************************************************************************
+ * DESCRIPTION:        Send SCAN Command
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_StartScan (HwMboxCmd_T *pHwMboxCmd, ScanParameters_t* pScanParams ,void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+               return CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue,CMD_SCAN, (char *)pScanParams,  sizeof(ScanParameters_t),
+                                 (void *)ScanCommandResponseCB, CB_handle, NULL /* void* CB_Buf */);
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_StartSPSScan ()
+ ****************************************************************************
+ * DESCRIPTION:        Send SPS SCAN Command
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_StartSPSScan (HwMboxCmd_T *pHwMboxCmd, ScheduledScanParameters_t* pScanParams, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+               return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_SPS_SCAN, (char *)pScanParams, sizeof(ScheduledScanParameters_t),
+                       (void *)ScanCommandResponseCB, CB_handle, NULL ));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_StopScan ()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the STOP_SCAN command fields and send it to the
+ *                             mailbox 
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_StopScan (HwMboxCmd_T *pHwMboxCmd, void *ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+       WLAN_REPORT_INFORMATION(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("whal_hwMboxCmd_StopScan: -------------- \n"));
+
+       if (NULL != ScanCommandResponseCB)
+               return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_SCAN, 0, 0, (void *)ScanCommandResponseCB,CB_handle,NULL));
+       else
+               return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_SCAN, 0, 0));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_StopSPSScan ()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the STOP_SPS_SCAN command fields and send it to the
+ *                             mailbox 
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_StopSPSScan (HwMboxCmd_T *pHwMboxCmd, void* ScanCommandResponseCB, TI_HANDLE CB_handle)
+{
+       WLAN_REPORT_INFORMATION(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("whal_hwMboxCmd_StopSPSScan: -------------- \n"));
+       if (NULL != ScanCommandResponseCB)
+               return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_SPS_SCAN, 0, 0, (void *)ScanCommandResponseCB, CB_handle, NULL ));
+       else
+               return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_SPS_SCAN, 0, 0));
+
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_GenCmd ()
+ ****************************************************************************
+ * DESCRIPTION:        Send any command
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_GenCmd(HwMboxCmd_T *pHwMboxCmd,short CmdId, char* pBuf, UINT32 Length)
+{
+       WLAN_REPORT_INFORMATION(pHwMboxCmd->hReport, HAL_HW_CTRL_MODULE_LOG,  
+               ("whal_hwMboxCmd_GenCmd: -------------- \n"));
+
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CmdId, pBuf, Length));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_NoiseHistogramCmd ()
+ ****************************************************************************
+ * DESCRIPTION:        Send NOISE_HISTOGRAM Command
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_NoiseHistogramCmd (HwMboxCmd_T *pHwMboxCmd, whalCtrl_noiseHistogram_t* pNoiseHistParams)
+{
+    NoiseHistRequest_t AcxCmd_NoiseHistogram;
+       NoiseHistRequest_t *pCmd = &AcxCmd_NoiseHistogram;
+
+    os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+
+    pCmd->mode = (uint16)pNoiseHistParams->cmd;
+    pCmd->sampleIntervalUSec = pNoiseHistParams->sampleInterval;
+
+    os_memoryCopy(pHwMboxCmd->hOs, (void *)&(pCmd->thresholds[0]), (void *)&(pNoiseHistParams->ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES);
+
+    /* Send the command */
+    return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_NOISE_HIST, (char *)pCmd, sizeof(*pCmd)));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_PowerMgmtConfiguration()
+ ****************************************************************************
+ * DESCRIPTION:        send Command for Power Management configuration 
+ *              to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_PowerMgmtConfiguration (HwMboxCmd_T *pHwMboxCmd,whalCtrl_powerSaveParams_t* powerSaveParams)
+/*whalCtrl_powerMgmtConfig_t* pPowerMgmtParams)*/
+{
+       PSModeParameters_t       Cmd_PowerMgmtCnf;
+       PSModeParameters_t *    pCmd = &Cmd_PowerMgmtCnf;
+
+       os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+
+       if(powerSaveParams->ps802_11Enable == TRUE)
+               pCmd->mode = 1;
+
+       else
+               pCmd->mode = 0;
+       
+       pCmd->hangOverPeriod                    = powerSaveParams->hangOverPeriod;
+       pCmd->needToSendNullData                = powerSaveParams->needToSendNullData;
+       pCmd->rateToTransmitNullData            = ENDIAN_HANDLE_WORD(powerSaveParams->NullPktRateModulation);
+       pCmd->numberOfRetries                   = powerSaveParams->numNullPktRetries;
+
+
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_SET_PS_MODE, (char *)pCmd, sizeof(*pCmd),(void *)powerSaveParams->powerSavecmdResponseCB,powerSaveParams->powerSaveCBObject,NULL));
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_SwitchChannelCmd ()
+ ****************************************************************************
+ * DESCRIPTION:        Send CMD_SWITCH_CHANNEL Command
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_SwitchChannelCmd (HwMboxCmd_T *pHwMboxCmd, whalCtrl_switchChannelCmd_t *pSwitchChannelCmd)
+{
+    ChannelSwitchParameters_t AcxCmd_SwitchChannel;
+       ChannelSwitchParameters_t *pCmd = &AcxCmd_SwitchChannel;
+
+    os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+
+    pCmd->channel = pSwitchChannelCmd->channelNumber;
+    pCmd->switchTime = pSwitchChannelCmd->switchTime;
+       pCmd->txSuspend = pSwitchChannelCmd->txFlag;
+       pCmd->flush = pSwitchChannelCmd->flush;
+
+    /* Send the command */
+    return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_CHANNEL_SWITCH, (char *)pCmd, sizeof(*pCmd)));
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_SwitchChannelCancelCmd ()
+ ****************************************************************************
+ * DESCRIPTION:        Send CMD_SWITCH_CHANNEL_CANCEL Command
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_SwitchChannelCancelCmd (HwMboxCmd_T *pHwMboxCmd)
+{
+
+    /* Send the command */
+    return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_CHANNEL_SWICTH, 0, 0));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_FwDisconnect()
+ ****************************************************************************
+ * DESCRIPTION:        Construct the Disconnect command fileds and send it to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_FwDisconnect(HwMboxCmd_T *pHwMboxCmd, uint32 ConfigOptions, uint32 FilterOptions)
+{
+    DisconnectParameters_t AcxCmd_Disconnect;
+       
+       AcxCmd_Disconnect.rxFilter.ConfigOptions = ConfigOptions;
+       AcxCmd_Disconnect.rxFilter.FilterOptions = FilterOptions;
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_DISCONNECT, (char *)&AcxCmd_Disconnect, sizeof(AcxCmd_Disconnect)));
+
+} /* whal_hwMboxCmd_FWDisconnect()*/
+
+
+
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_measurementParams()
+ ****************************************************************************
+ * DESCRIPTION:        send Command for measurement configuration 
+ *              to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_measurement (HwMboxCmd_T *pHwMboxCmd, whalCtrl_MeasurementParameters_t* pMeasurementParams,
+                                                               void* MeasureCommandResponseCB, TI_HANDLE CB_handle)
+{
+       MeasurementParameters_t Cmd_MeasurementParam;
+       MeasurementParameters_t *pCmd = &Cmd_MeasurementParam;
+
+       os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+       
+       pCmd->band =                                    pMeasurementParams->band;
+       pCmd->channel =                                 pMeasurementParams->channel;
+       pCmd->duration =                                ENDIAN_HANDLE_LONG(pMeasurementParams->duration);
+       pCmd->rxFilter.ConfigOptions =  ENDIAN_HANDLE_LONG(pMeasurementParams->ConfigOptions);
+       pCmd->rxFilter.FilterOptions =  ENDIAN_HANDLE_LONG(pMeasurementParams->FilterOptions);
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_MEASUREMENT, (char *)pCmd, sizeof(*pCmd),
+                                                                               (void *)MeasureCommandResponseCB, CB_handle, NULL));
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_measurementStop()
+ ****************************************************************************
+ * DESCRIPTION:        send Command for stoping measurement  
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_measurementStop (HwMboxCmd_T *pHwMboxCmd, void* MeasureCommandResponseCB, TI_HANDLE CB_handle)
+{
+       /*
+        * Send the command 
+        */
+    return (CmdQueue_CommandWithCb(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_MEASUREMENT, 0, 0,
+                                                                               (void *)MeasureCommandResponseCB, CB_handle, NULL));
+}
+/****************************************************************************
+ *                      whal_hwMboxCmd_ApDiscovery()
+ ****************************************************************************
+ * DESCRIPTION:        send Command for AP Discovery 
+ *              to the mailbox
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_ApDiscovery (HwMboxCmd_T *pHwMboxCmd, whalCtrl_ApDiscoveryParameters_t* pApDiscoveryParams)
+{
+       ApDiscoveryParameters_t Cmd_ApDiscovery;
+       ApDiscoveryParameters_t *pCmd = &Cmd_ApDiscovery;
+
+       os_memoryZero(pHwMboxCmd->hOs, (void *)pCmd, sizeof(*pCmd));
+       
+       pCmd->txPowerAttenuation = pApDiscoveryParams->txPowerDbm;
+       pCmd->numOfProbRqst = pApDiscoveryParams->numOfProbRqst;
+       pCmd->scanDuration      =  ENDIAN_HANDLE_LONG(pApDiscoveryParams->scanDuration);
+       pCmd->scanOptions       =  ENDIAN_HANDLE_WORD(pApDiscoveryParams->scanOptions);
+       pCmd->txdRateSet        =  ENDIAN_HANDLE_WORD(pApDiscoveryParams->txdRateSet);
+       pCmd->rxFilter.ConfigOptions =  ENDIAN_HANDLE_LONG(pApDiscoveryParams->ConfigOptions);
+       pCmd->rxFilter.FilterOptions =  ENDIAN_HANDLE_LONG(pApDiscoveryParams->FilterOptions);
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_AP_DISCOVERY, (char *)pCmd, sizeof(*pCmd)));
+}
+/****************************************************************************
+ *                      whal_hwMboxCmd_ApDiscoveryStop()
+ ****************************************************************************
+ * DESCRIPTION:        send Command for stoping AP Discovery
+ * 
+ * INPUTS: None        
+ * 
+ * OUTPUT:     None
+ * 
+ * RETURNS:    OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmd_ApDiscoveryStop (HwMboxCmd_T *pHwMboxCmd)
+{
+       /*
+        * Send the command 
+        */
+    return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_STOP_AP_DISCOVERY, 0, 0));
+
+}
+
+
+/****************************************************************************
+ *                      whal_hwMboxCmd_HealthCheck()
+ ****************************************************************************
+ * DESCRIPTION:        
+ * 
+ * INPUTS:     
+ * 
+ * OUTPUT:     
+ * 
+ * RETURNS:
+ ****************************************************************************/
+int whal_hwMboxCmd_HealthCheck(HwMboxCmd_T *pHwMboxCmd)
+{
+       /*
+        * no parameters 
+        */
+       
+       /*
+        * Send the command 
+        */
+       return (CmdQueue_Command(pHwMboxCmd->hCmdMboxQueue, CMD_HEALTH_CHECK, NULL, 0));
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmd.h b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmd.h
new file mode 100644 (file)
index 0000000..cf82004
--- /dev/null
@@ -0,0 +1,103 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwMboxCmd.h
+ *   PURPOSE: wlan hardware commands handler
+ * 
+ ****************************************************************************/
+
+#ifndef _WHAL_HW_MBOX_CMD_H
+#define _WHAL_HW_MBOX_CMD_H
+
+
+#include "whalCommon.h"
+#include "whalParams.h"
+#include "public_infoele.h"
+
+typedef struct _HwMboxCmd_T
+{
+       TI_HANDLE               hCmdMboxQueue;
+       WhalParams_T    *pWhalParams;
+
+       TI_HANDLE               hOs;
+       TI_HANDLE               hReport;
+    
+} HwMboxCmd_T;
+
+extern HwMboxCmd_T *whal_hwMboxCmd_Create(TI_HANDLE hOs, WhalParams_T *pWhalParams);
+extern int whal_hwMboxCmd_Destroy              (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_Config               (HwMboxCmd_T *pHwMboxCmd,TI_HANDLE hCmdMboxQueue, TI_HANDLE hReport);
+extern int whal_hwMboxCmd_Reset                                (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_RxReset                      (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_StartBss          (HwMboxCmd_T *pHwMboxCmd, BSS_e BssType, void *JoinCompleteCB, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_EnableRx                     (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_LNAControl           (HwMboxCmd_T *pHwMboxCmd, UINT8 LNAControlField);
+extern int whal_hwMboxCmd_EnableTx                     (HwMboxCmd_T *pHwMboxCmd,UINT8 channel);
+extern int whal_hwMboxCmd_DisableRx                    (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_DisableTx                    (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_InitMemory           (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_ConfigureTemplateFrame(HwMboxCmd_T *pHwMboxCmd, UINT8 *pFrame, UINT16 FrameSize,
+                                                 Command_e templateType, void *CBFunc,TI_HANDLE CBObj);
+extern int whal_hwMboxCmd_TimTemplate          (HwMboxCmd_T *pHwMboxCmd, char BmapControl, char *PartialBmapVec, int PartialBmapLen);
+extern int whal_hwMboxCmd_StartScan         (HwMboxCmd_T *pHwMboxCmd, ScanParameters_t* pScanParams ,void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_StartSPSScan      (HwMboxCmd_T *pHwMboxCmd, ScheduledScanParameters_t* pScanParams, void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+
+extern int whal_hwMboxCmd_StopScan                     (HwMboxCmd_T *pHwMboxCmd, void *ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_StopSPSScan       (HwMboxCmd_T *pHwMboxCmd, void* ScanCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_GenCmd                       (HwMboxCmd_T *pHwMboxCmd,short CmdId, char* pBuf, UINT32 Length);
+extern int whal_hwMboxCmd_WriteMemory          (HwMboxCmd_T *pHwMboxCmd, UINT32 Address, UINT32 Size,PVOID  pValue);
+extern int whal_hwMboxCmd_NoiseHistogramCmd (HwMboxCmd_T *pHwMboxCmd, whalCtrl_noiseHistogram_t* pNoiseHistParams);
+
+extern int whal_hwMboxCmd_SwitchChannelCmd (HwMboxCmd_T *pHwMboxCmd, whalCtrl_switchChannelCmd_t *pSwitchChannelCmd);
+extern int whal_hwMboxCmd_SwitchChannelCancelCmd (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_SetKey(HwMboxCmd_T *pHwMboxCmd, int Action, char *MacAddr, int KeySize, 
+                               int KeyType, int KeyId, char *Key, UINT16 SecuritySeqNumLow, UINT32 SecuritySeqNumHigh,
+                               void *CB_Func, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_PowerMgmtConfiguration (HwMboxCmd_T *pHwMboxCmd, whalCtrl_powerSaveParams_t* powerSaveParams);
+/*     whalCtrl_powerMgmtConfig_t* pPowerMgmtParams); */
+extern int whal_hwMboxCmd_StartNewScan (HwMboxCmd_T *pHwMboxCmd, whalCtrl_scan_t* pScanParams);
+extern int whal_hwMboxCmd_FwDisconnect(HwMboxCmd_T *pHwMboxCmd, uint32 ConfigOptions, uint32 FilterOptions);
+
+extern int whal_hwMboxCmd_measurement (HwMboxCmd_T *pHwMboxCmd, whalCtrl_MeasurementParameters_t* pMeasurementParams,
+                                                                          void* MeasureCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_measurementStop (HwMboxCmd_T *pHwMboxCmd, void* MeasureCommandResponseCB, TI_HANDLE CB_handle);
+extern int whal_hwMboxCmd_ApDiscovery (HwMboxCmd_T *pHwMboxCmd, whalCtrl_ApDiscoveryParameters_t* pMeasurementParams);
+extern int whal_hwMboxCmd_ApDiscoveryStop (HwMboxCmd_T *pHwMboxCmd);
+extern int whal_hwMboxCmd_HealthCheck(HwMboxCmd_T *pHwMboxCmd);
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmdBit.c b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmdBit.c
new file mode 100644 (file)
index 0000000..a397c66
--- /dev/null
@@ -0,0 +1,815 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwMboxCmdBit.c
+ *   PURPOSE: wlan hardware BIT commands handler
+ * 
+ ****************************************************************************/
+
+#include "whalCommon.h"
+#include "CmdQueue_api.h"
+#include "public_infoele.h"
+#include "commonTypes.h"
+#include "whalHwMboxCmdBit.h"
+
+
+
+/*******************************************
+ * Wlan hardware Test (BIT)
+ * =================
+ *
+ * Tests description:
+ * ==================
+ * FCC           = Continuous modulated transmission (should not emit carrier)
+ * TELEC         = Continuous unmodulated carrier transmission (carrier only)
+ * PER_TX_STOP   = Stops the TX test in progress (FCC or TELEC).
+ * ReadRegister  = Read a register value.
+ * WriteRegister = Sets a register value.
+* 
+* Rx PER test
+* ========
+* PerRxStart       = Start or resume the PER measurement. This function will put the device in promiscuous mode, and resume counters update.
+* PerRxStop        = Stop Rx PER measurements. This function stop counters update and make it is safe to read the PER test result.
+* PerRxGetResults  = Get the last Rx PER test results.
+* PerRxClear       = Clear the Rx PER test results. 
+ */
+
+enum
+{
+/* 0 */   TEST_MOD_QPSK,
+/* 1 */   TEST_MOD_CCK,
+/* 2 */   TEST_MOD_PBCC,
+
+   TEST_MOD_NUMOF
+};
+
+enum
+{
+/* 0 */   TEST_MOD_LONG_PREAMBLE,
+/* 1 */   TEST_MOD_SHORT_PREAMBLE
+};
+
+enum
+{
+/* 0 */   TEST_BAND_2_4GHZ,
+/* 1 */   TEST_BAND_5GHZ,
+/* 2 */   TEST_BAND_4_9GHZ
+};
+
+
+#define TEST_MOD_MIN_GAP           200
+#define TEST_MOD_MIN_TX_BODYLEN    0
+#define TEST_MOD_MAX_TX_BODYLEN    2304
+
+#define TEST_RX_CAL_SAFE_TIME      5000  /*uSec*/
+
+#define TEST_MOD_IS_GAP_OK(gap)     ((gap) >= TEST_MOD_MIN_GAP)
+
+#define TEST_MOD_IS_TX_BODYLEN_OK(len)  \
+   (INRANGE((len), TEST_MOD_MIN_TX_BODYLEN, TEST_MOD_MAX_TX_BODYLEN) && \
+   (((len) & 3) == 0) )
+
+#define TEST_MOD_IS_PREAMBLE_OK(p)  \
+   INRANGE((p), TEST_MOD_LONG_PREAMBLE, TEST_MOD_SHORT_PREAMBLE)
+
+
+void whal_hwCmdBit_RxPer_Clear_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
+void whal_hwCmdBit_RxPer_GetResults_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
+void whal_hwCmdBit_RxCal_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
+void whal_hwCmdBit_RxCal_Complete_Event_CB( TI_HANDLE objectHandle, char* str, UINT32 strLen );
+
+/****************************************************************************
+ *                      whal_hwMboxCmdBit_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the mailbox BIT commands object
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: The Created object
+ ****************************************************************************/
+HwMboxCmdBit_T *whal_hwMboxCmdBit_Create(TI_HANDLE hOs)
+{
+    HwMboxCmdBit_T *pObj;
+
+    pObj = os_memoryAlloc(hOs, sizeof(HwMboxCmdBit_T));
+    if (pObj == NULL)
+        return NULL;
+
+    os_memoryZero(hOs, (void *)pObj, sizeof(HwMboxCmdBit_T));
+
+    pObj->hOs = hOs;
+
+    return(pObj);
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmdBit_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object 
+ * 
+ * INPUTS:  
+ *      pHwMboxCmdBit       The object to free
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmdBit_Destroy(HwMboxCmdBit_T *pHwMboxCmdBit)
+{
+    if (pHwMboxCmdBit)
+    { 
+        whalCtrl_EventMbox_Disable( pHwMboxCmdBit->hWhalCtr, HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE );
+        os_memoryFree(pHwMboxCmdBit->hOs, pHwMboxCmdBit, sizeof(HwMboxCmdBit_T));
+    }
+    return OK;
+}
+
+/****************************************************************************
+ *                      whal_hwMboxCmdBit_Config()
+ ****************************************************************************
+ * DESCRIPTION: Configure the object 
+ * 
+ * INPUTS:  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwMboxCmdBit_Config(TI_HANDLE hWhalCtr, HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE hCmdQueue, TI_HANDLE hReport)
+{
+    pHwMboxCmdBit->hReport = hReport;
+    pHwMboxCmdBit->hCmdQueue = hCmdQueue;
+    pHwMboxCmdBit->hWhalCtr = hWhalCtr;
+
+    whalCtrl_EventMbox_RegisterForEvent( hWhalCtr, 
+                                         HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE,
+                                         (void *)whal_hwCmdBit_RxCal_Complete_Event_CB, 
+                                         (void*)pHwMboxCmdBit);
+
+    whalCtrl_EventMbox_Enable( hWhalCtr, HAL_EVENT_PLT_RX_CALIBRATION_COMPLETE );
+
+    pHwMboxCmdBit->PltData.RxTxCal.lastStatus = OK;
+    return OK;
+}
+
+/*******************
+ Helper functions
+ *******************/
+
+static void errPrint_ChID(HwMboxCmdBit_T *pHwMboxCmdBit, int chID)
+{
+    WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("Channel ID (%d) is out of range, use [%d..%d] for 2.4Ghz, [%d..%d] for 5Ghz and [%d %d %d] for 4.9Ghz.\n",
+         chID,
+         HAL_CTRL_CALIBRATION_CHANNEL_2_4_MIN, HAL_CTRL_CALIBRATION_CHANNEL_2_4_MAX,
+         HAL_CTRL_CALIBRATION_CHANNEL_5_0_MIN, HAL_CTRL_CALIBRATION_CHANNEL_5_0_MAX,
+         HAL_CTRL_CALIBRATION_CHANNEL_4_9_MIN, HAL_CTRL_CALIBRATION_CHANNEL_4_9_DEF, HAL_CTRL_CALIBRATION_CHANNEL_4_9_MAX));
+}
+
+static void errPrint_BandID(HwMboxCmdBit_T *pHwMboxCmdBit, int bandID)
+{
+        WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("PLT whal_hwCmdBit_Fcc: Wrong band parameter 0x%x(must be 0x%x for 2.4Ghz or 0x%x for 5Ghz or 0x%x for 4.9Ghz).\n",
+        bandID, TEST_BAND_2_4GHZ, TEST_BAND_5GHZ, TEST_BAND_4_9GHZ));
+}
+
+/* MACROS */
+int VALIDATE_BAND_CHID(HwMboxCmdBit_T *pHwMboxCmdBit, int chID, int bandID) 
+{
+   int minVal, maxVal;
+   switch(bandID)
+   {
+   case TEST_BAND_2_4GHZ:
+       minVal = HAL_CTRL_CALIBRATION_CHANNEL_2_4_MIN;
+       maxVal = HAL_CTRL_CALIBRATION_CHANNEL_2_4_MAX;
+    break;                                           
+
+   case TEST_BAND_5GHZ:
+       minVal = HAL_CTRL_CALIBRATION_CHANNEL_5_0_MIN;
+       maxVal = HAL_CTRL_CALIBRATION_CHANNEL_5_0_MAX;
+       break;
+
+    case TEST_BAND_4_9GHZ:
+       minVal = HAL_CTRL_CALIBRATION_CHANNEL_4_9_MIN;
+       maxVal = HAL_CTRL_CALIBRATION_CHANNEL_4_9_MAX;
+       break;
+
+   default:
+       errPrint_BandID(pHwMboxCmdBit, bandID);
+       return NOK;
+   }
+   if(!INRANGE(chID, minVal, maxVal))
+   {
+      errPrint_ChID(pHwMboxCmdBit, chID);
+      return NOK;
+   }
+   return(OK);
+}
+
+/****************************************************************************
+ *                       whal_hwCmdBit_Fcc()
+ ****************************************************************************
+ * DESCRIPTION: Performs FCC test
+ * 
+ * INPUTS: chID, rate, Modulation, preamble, band, TestMode
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCmdBit_Fcc(HwMboxCmdBit_T *pHwMboxCmdBit,
+                      int chID, 
+                      int rate, 
+                      int preamble, 
+                      int bandID,
+                      int InterPacketDelay,
+                      int TestMode,
+                      uint32 numFrames,
+                      uint32 seqNumMode,
+                      uint32 frameBodySize,
+                      uint8 *PeerMacAddr,
+                      void *CB_Func, TI_HANDLE CB_Handle, void *CB_Buf)
+{
+    int Modulation;
+    TestCmd_t TestCmd;
+    os_memoryZero(pHwMboxCmdBit->hOs, (void *)&TestCmd, sizeof(TestCmd));
+    
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+        ("whal_hwCmdBit_Fcc:\n chID = %d\n rate = %d preamble = %d, bandID %d, InterPacketDelay %d, TestMode %d numOfFrames %d\n ", 
+             chID,  rate,  preamble, 
+             bandID,  InterPacketDelay,  TestMode, numFrames));
+
+    /*Check Channel and band*/
+    if (VALIDATE_BAND_CHID(pHwMboxCmdBit, chID, bandID) == NOK)
+        return NOK;
+
+    /*Check rate and set Modulation*/
+    if ((rate >= 1) && (rate <= 4))
+        Modulation = MOD_CCK;
+    else if ((rate >= 6) && (rate <= 13))
+        Modulation =  MOD_OFDM;
+    else
+    {
+        WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,  
+            ("PLT whal_hwCmdBit_Fcc: Wrong rate parameter %d(must be 1-4 to CCK modulation  or 6-13 for OFDM modulation) .\n",
+            rate));
+        return NOK;
+    }
+
+     /*Set FW rate */
+    TestCmd.testCmd_u.fcc.dataRate = ConvertDrvRate2HwRate((rate_e)rate);
+
+    /*Validate preamble*/
+    if ((preamble!=0) && preamble != CTL_PREAMBLE)
+    {
+        WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("PLT whal_hwCmdBit_Fcc: Wrong preamble parameter 0x%x(must be (0x%x) for long preamble or short(0x%x)) .\n",
+        preamble, 0, CTL_PREAMBLE));
+
+        return NOK;
+    } 
+
+    /*Validate test mode*/
+    if ((TestMode != TEST_MODE_ZOZO_DATA) && (TestMode != TEST_MODE_RANDOM_DATA))
+    {
+        WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("PLT whal_hwCmdBit_Fcc: Wrong TestMode parameter 0x%x(must be RANDOM_DATA(0x%x) or ZOZO_DATA(0x%x)) .\n",
+        TestMode, TEST_MODE_RANDOM_DATA, TEST_MODE_ZOZO_DATA));
+        /*Not returning NOX for enabling GAP bit*/
+    }
+
+        /*Validate seq num mode*/
+    if ((seqNumMode != TEST_SEQ_NUM_MODE_FIXED) && (seqNumMode != TEST_SEQ_NUM_MODE_INCREMENTED))
+    {
+        WLAN_REPORT_REPLY(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("PLT whal_hwCmdBit_Fcc: Wrong seqNumMode parameter 0x%x(must be TEST_SEQ_NUM_MODE_FIXED(0x%x) or TEST_SEQ_NUM_MODE_INCREMENTED(0x%x)) .\n",
+        seqNumMode, TEST_SEQ_NUM_MODE_FIXED, TEST_SEQ_NUM_MODE_INCREMENTED));
+        
+        return NOK;
+    }
+
+    TestCmd.testCmd_u.fcc.seqNumMode = seqNumMode;
+    TestCmd.testCmd_u.fcc.frameBodySize = frameBodySize;
+    os_memoryCopy(pHwMboxCmdBit->hOs , TestCmd.testCmd_u.fcc.dest, PeerMacAddr,NUM_OF_MAC_ADDR_ELEMENTS);
+
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+        ("whal_hwCmdBit_Fcc: \n seqNumMode = %d ,frameBodySize = 0x%x", 
+             TestCmd.testCmd_u.fcc.seqNumMode, 
+             TestCmd.testCmd_u.fcc.frameBodySize));
+
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+        ("whal_hwCmdBit_Fcc: \n Dest = %02x:%02x:%02x:%02x:%02x:%02x", 
+             TestCmd.testCmd_u.fcc.dest[0],
+             TestCmd.testCmd_u.fcc.dest[1],
+             TestCmd.testCmd_u.fcc.dest[2],
+             TestCmd.testCmd_u.fcc.dest[3],
+             TestCmd.testCmd_u.fcc.dest[4],
+             TestCmd.testCmd_u.fcc.dest[5]));
+
+    TestCmd.testCmd_u.fcc.channel = chID;
+
+    switch (Modulation)
+    {
+    case MOD_PBCC:
+        Modulation = PBCC_MODULATION_MASK;
+        break;
+
+    case MOD_CCK:
+        Modulation = 0x00;
+        break;
+
+    case MOD_OFDM:
+        Modulation = OFDM_MODULATION_MASK;
+        break;
+    }
+    /*Build preamble parameter*/
+    TestCmd.testCmd_u.fcc.modPreamble = preamble;
+    TestCmd.testCmd_u.fcc.band = bandID;
+    TestCmd.testCmd_u.fcc.modulation = Modulation;
+
+    TestCmd.testCmd_u.fcc.testModeCtrl = TestMode;
+
+    /* Set command fields */
+    TestCmd.testCmdId = TEST_CMD_FCC; 
+
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+        ("whal_hwCmdBit_Fcc: \n AcxCmd_TestFCC.channel = %d ,AcxCmd_TestFCC.dataRate = 0x%x,  AcxCmd_TestFCC.modPreamble = 0x%x, AcxCmd_TestFCC.testModeCtrl = 0x%x\n ", 
+             TestCmd.testCmd_u.fcc.channel, 
+             TestCmd.testCmd_u.fcc.dataRate,
+             TestCmd.testCmd_u.fcc.modPreamble,
+             TestCmd.testCmd_u.fcc.testModeCtrl));
+    
+
+    /*Set InterPacketDelay*/
+    /*TestCmd.testCmd_u.fcc.interFrameGap = 1000 * InterPacketDelay; */ /*Convert ms to us*/
+    TestCmd.testCmd_u.fcc.interFrameGap = InterPacketDelay; /*(uSec)*/
+
+    /*Set numFrames */
+    TestCmd.testCmd_u.fcc.numFrames = numFrames;
+
+    return whal_hwCmdBit_TestCmd(pHwMboxCmdBit, CB_Func, CB_Handle, &TestCmd);
+}/* END whal_hwCmdBit_Fcc() */
+
+
+
+/****************************************************************************
+ *                      whal_hwCmdBit_Telec()
+ ****************************************************************************
+ * DESCRIPTION: Performs TELEC test
+ * 
+ * INPUTS: chID   - Channel number, between  1 (MIN_CHANNEL_ID) to  14 (MAX_CHANNEL_ID).
+ *         bandID - Band ID number, 0 - 2.4Ghz, 1 - 5Ghz.  
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCmdBit_Telec(HwMboxCmdBit_T *pHwMboxCmdBit, int chID, int bandID, void *CB_Func, TI_HANDLE CB_Handle, void *CB_Buf)
+{
+    TestCmd_t   TestCmd;
+    TestCmd_t  *pCmd = &TestCmd;
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+         ("whal_hwCmdBit_Telec: chID = %d bandID = %d\n ", chID, bandID));
+
+
+    /*Check Channel and band*/
+    if (VALIDATE_BAND_CHID(pHwMboxCmdBit, chID, bandID) == NOK)
+        return NOK;
+
+    /* Set command fields; param1 = chID, param2 = BandID */
+    os_memoryZero(pHwMboxCmdBit->hOs, (void *)pCmd, sizeof(*pCmd ));
+    pCmd->testCmdId = TEST_CMD_TELEC;
+    pCmd->testCmd_u.telec.channel = (UINT8)chID;
+    pCmd->testCmd_u.telec.band = (UINT8)bandID;
+    
+    /* Send the command */ 
+    return whal_hwCmdBit_TestCmd(pHwMboxCmdBit, CB_Func, CB_Handle, &TestCmd);
+}/* END whal_hwCmdBit_Telec() */
+
+/**************************
+    REGISTER HANDLING
+ *************************/
+
+/****************************************************************************
+ *                      whal_hwCmdBit_ReadRegister()
+ ****************************************************************************
+ * DESCRIPTION: Performs PLT read register
+ * 
+ * INPUTS: RegAddress - the address of the register to read
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK       
+ ****************************************************************************/
+ int whal_hwCmdBit_ReadRegister(HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE CB_Handle, void *CB_Func, void *CB_Buf)
+{        
+    ReadWriteCommand_t* pCmd = CB_Buf;
+
+     /* Send the command */  
+     return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_READ_MEMORY, (char *)pCmd, sizeof(*pCmd), CB_Func, CB_Handle, CB_Buf));         
+}/* END whal_hwCmdBit_ReadRegister() */
+
+
+/****************************************************************************
+ *                      whal_hwCmdBit_WriteRegister()
+ ****************************************************************************
+ * DESCRIPTION: Performs PLT write register
+ * 
+ * INPUTS:  RegAddress - the address of the register to write to
+ *          RegData - the data to write
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+ int whal_hwCmdBit_WriteRegister(HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE CB_Handle, void *CB_Func, void *Command_Buf)
+{   
+     
+     
+     /* Send the command */    
+     if (CB_Func)
+        return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_WRITE_MEMORY, (char *)Command_Buf, sizeof(ReadWriteCommand_t), CB_Func, CB_Handle, NULL));    
+     else
+        return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_WRITE_MEMORY, (char *)Command_Buf, sizeof(ReadWriteCommand_t)));
+}/* END whal_hwCmdBit_WriteRegister() */
+
+
+/****************************************************************************
+ *                      whal_hwCmdBit_perTxStop()
+ ****************************************************************************
+ * DESCRIPTION:   Packet Error Rate - stop test, no params.
+ *                Does not clear statistics.
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCmdBit_perTxStop(HwMboxCmdBit_T *pHwMboxCmdBit, void *CB_Func, TI_HANDLE CB_Handle, void *CB_Buf)
+{
+    TestCmd_t   TestCmd;
+    TestCmd_t  *pCmd = &TestCmd;
+
+    /* Set command fields*/
+    os_memoryZero(pHwMboxCmdBit->hOs, (void *)pCmd,  sizeof(*pCmd ));
+    pCmd->testCmdId = TEST_CMD_PLT_FCC_TELEC_TX_STOP;
+    
+    /* Send the command  */
+    return whal_hwCmdBit_TestCmd(pHwMboxCmdBit, CB_Func, CB_Handle, pCmd);
+}/* END whal_hwCmdBit_perTxStop() */
+  /****************************************************************************
+  *                      whal_hwCmdBit_RxPER()
+  ****************************************************************************
+  * DESCRIPTION:   RX PER main function - All other RX per function are called using this function
+  * INPUTS: None 
+  * 
+  * OUTPUT:  None
+  * 
+  * RETURNS: OK or NOK
+ ****************************************************************************/
+ int whal_hwCmdBit_RxPER(HwMboxCmdBit_T *pHwMboxCmdBit, PLT_RxPerCmd_e eRxPerCmd, TI_HANDLE CB_Handle, void *CB_Func)
+ {     
+     int ret = OK;     
+     ACXErrorCounters_t ACXErrorCounters;
+     TestCmd_t   TestCmd;
+     TestCmd_t  *pCmd = &TestCmd;
+
+
+
+     /*Defining a local function that will support the Rx PER process 
+     in a sync mode (for the core) as well as Async mode (for GWSI, as callbacks)*/
+     
+     CmdQueue_InterrogateCB_t PltRxPerCBArr[PLT_RX_PER_MAX] = 
+     {
+         NULL,                              //PLT_RX_PER_START
+         NULL,                              //PLT_RX_PER_STOP
+         whal_hwCmdBit_RxPer_Clear_CB,      //PLT_RX_PER_CLEAR
+         whal_hwCmdBit_RxPer_GetResults_CB  //PLT_RX_PER_GETRESULTS
+     };
+
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+         ("whal_hwCmdBit_RxPER eRxPerCmd=%d, CB_Handle=0x%p,  CB_Func=0x%p\n", eRxPerCmd, CB_Handle, CB_Func));
+
+     
+     /* 
+     * Set information element header
+     * Each call to ACX_ERROR_CNT - retrieve the F.W Rx Per and reset them.
+     */
+     ACXErrorCounters.EleHdr.id  = ACX_ERROR_CNT;
+     ACXErrorCounters.EleHdr.len = sizeof(ACXErrorCounters) - sizeof(EleHdrStruct);
+     
+     if ((UINT32)eRxPerCmd >=  (UINT32)PLT_RX_PER_MAX)
+         return PARAM_VALUE_NOT_VALID;
+     
+     pHwMboxCmdBit->PltData.RxPer.CB_Func = CB_Func;
+     pHwMboxCmdBit->PltData.RxPer.CB_Handle = CB_Handle;
+     pHwMboxCmdBit->PltData.RxPer.CB_RxPerCmd = eRxPerCmd;
+     
+     /* 
+     * Send the interrogation command
+     */
+     if((PLT_RX_PER_GETRESULTS == eRxPerCmd) || (PLT_RX_PER_CLEAR == eRxPerCmd))
+     {     
+     ret = CmdQueue_CmdInterrogateWithCb(pHwMboxCmdBit->hCmdQueue,
+         &ACXErrorCounters, sizeof(ACXErrorCounters), 
+         (void *) PltRxPerCBArr[eRxPerCmd], pHwMboxCmdBit,
+         &pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable);
+     return ret;
+ }
+
+     /* Set command fields*/
+     os_memoryZero(pHwMboxCmdBit->hOs, (void *)pCmd,  sizeof(*pCmd ));
+
+     if(PLT_RX_PER_START == eRxPerCmd)
+     {
+        pCmd->testCmdId = TEST_CMD_RX_PER_START;
+        /* Send the command  */
+        if (CB_Func != NULL) {
+            return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd),CB_Func , CB_Handle, NULL));
+        }
+        else
+        {
+            return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd) ));
+        }
+     }
+
+     if(PLT_RX_PER_STOP == eRxPerCmd)
+     {
+        pCmd->testCmdId = TEST_CMD_RX_PER_STOP;
+        /* Send the command  */
+        if (CB_Func != NULL) {
+           return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd),CB_Func, CB_Handle, NULL));
+        }
+        else
+        {
+            return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pCmd, sizeof(*pCmd) ));
+        }
+     }
+
+     return NOK;
+ }
+ /****************************************************************************
+ *                      whal_hwCmdBit_RxPer_Clear_CB()
+ ****************************************************************************
+ * DESCRIPTION:   Clear the RX per counters
+ *.
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+ void whal_hwCmdBit_RxPer_Clear_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf)
+ {
+     HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
+     CmdQueue_InterrogateCB_t CB_Func;
+     
+     /*Add the latest F.W. counter result to the total RX per counters*/
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.FCSErrorCount   = 0;
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.TotalFrameCount = 0; 
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.PLCPErrorCount  = 0; 
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.SeqNumMissCountRef = pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.seqNumMissCount; /* set as reference point for the mesurements */
+
+     
+     /* Call the saved CB function (if any)*/
+     if (pHwMboxCmdBit->PltData.RxPer.CB_Func)
+     {
+         CB_Func = (CmdQueue_InterrogateCB_t)(pHwMboxCmdBit->PltData.RxPer.CB_Func);
+         CB_Func(pHwMboxCmdBit->PltData.RxPer.CB_Handle, MboxStatus, &pHwMboxCmdBit->PltData.RxPer);
+     }
+ }
+ /****************************************************************************
+ *                      whal_hwCmdBit_RxPer_GetResults_CB()
+ ****************************************************************************
+ * DESCRIPTION:   Returns the accumulated counters.
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+  void whal_hwCmdBit_RxPer_GetResults_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf)
+ {
+     HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
+     CmdQueue_InterrogateCB_t CB_Func;
+     
+         
+     /*Accumulate the RX PER counters */
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.FCSErrorCount   += (UINT16)pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.FCSErrorCount;
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.PLCPErrorCount  += (UINT16)pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.PLCPErrorCount;
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.TotalFrameCount += (UINT16)pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.validFrameCount;
+     pHwMboxCmdBit->PltData.RxPer.PltRxPer.SeqNumMissCount  = (UINT16)(pHwMboxCmdBit->PltData.RxPer.ACXErrCountTable.seqNumMissCount - 
+                                                              pHwMboxCmdBit->PltData.RxPer.PltRxPer.SeqNumMissCountRef);          
+
+
+     /* Call the saved CB function (if any)*/
+     if (pHwMboxCmdBit->PltData.RxPer.CB_Func)
+     {
+         CB_Func = (CmdQueue_InterrogateCB_t)(pHwMboxCmdBit->PltData.RxPer.CB_Func);
+         CB_Func(pHwMboxCmdBit->PltData.RxPer.CB_Handle, MboxStatus, &(pHwMboxCmdBit->PltData.RxPer));
+     }
+ }
+
+/****************************************************************************
+ *                      whal_hwCmdBit_TestCmd()
+ ****************************************************************************
+ * DESCRIPTION:   
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwCmdBit_TestCmd(HwMboxCmdBit_T *pHwMboxCmdBit, void *CB_Func, TI_HANDLE CB_Handle, TestCmd_t* pTestCmd_Buf)
+{
+     int bIsCBfuncNecessary=TRUE;
+
+     WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+     ("%s CB_Handle=0x%p, CB_Func=0x%p, pTestCmd_Buf=%p\n",__FUNCTION__, CB_Handle, CB_Func, pTestCmd_Buf));
+
+     if (NULL == pTestCmd_Buf)
+     {
+         WLAN_REPORT_ERROR(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+         ("%s pTestCmd_Buf = NULL!!!\n",__FUNCTION__));
+
+         return NOK;
+     }
+
+     WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+     ("%s pTestCmd_Buf->testCmdId=%d\n",__FUNCTION__, pTestCmd_Buf->testCmdId));
+
+     WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+     ("%s pTestCmd_Buf (HEX DUMP):\n",__FUNCTION__)); 
+     WLAN_REPORT_HEX_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+         (PUINT8)pTestCmd_Buf, sizeof(TestCmd_t));
+
+
+     switch((TestCmdID_enum)pTestCmd_Buf->testCmdId)
+     {
+     case TEST_CMD_FCC:                          
+     case TEST_CMD_TELEC:                       
+     case TEST_CMD_PLT_FCC_TELEC_TX_STOP:
+     case TEST_CMD_RADIO_TUNE:
+        bIsCBfuncNecessary = FALSE;
+        break;
+
+     case TEST_CMD_PLT_GAIN_ADJUST:         
+     case TEST_CMD_PLT_TXPOWER_CAL_START:       
+     case TEST_CMD_PLT_TXPOWER_CAL_STOP:        
+     case TEST_CMD_PLT_GAIN_GET:                 
+     case TEST_CMD_PLT_GET_NVS_UPDATE_BUFFER:    
+         bIsCBfuncNecessary = TRUE; 
+         break;
+
+     case TEST_CMD_PLT_RX_CALIBRATION:
+         /* Mark that a calibration operation is pending */
+         pHwMboxCmdBit->PltData.RxTxCal.lastStatus = PENDING;
+         /* Save the CB for the command response (GWSI oriented) */
+         pHwMboxCmdBit->PltData.RxTxCal.CB_Func = CB_Func;
+         pHwMboxCmdBit->PltData.RxTxCal.CB_Handle = CB_Handle;
+
+         CB_Func = (void*)whal_hwCmdBit_RxCal_CB;
+         CB_Handle = (TI_HANDLE)pHwMboxCmdBit;
+         bIsCBfuncNecessary = TRUE; 
+         break;
+
+     default:
+     WLAN_REPORT_WARNING(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+     ("%s Unsupported TestCmdId (%d)\n",__FUNCTION__, pTestCmd_Buf->testCmdId));
+         break;
+     }
+
+    /* Send the command */
+    if (CB_Func)
+    {
+         return (CmdQueue_CommandWithCb(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pTestCmd_Buf, sizeof(*pTestCmd_Buf),
+                                        CB_Func, CB_Handle, (void*)pTestCmd_Buf));    
+    }
+    else
+    {
+        if (bIsCBfuncNecessary)
+            return NOK;
+        else
+            return (CmdQueue_Command(pHwMboxCmdBit->hCmdQueue, CMD_TEST, (char *)pTestCmd_Buf, sizeof(*pTestCmd_Buf) ));    
+    }
+     
+}/* END whal_hwCmdBit_TestCmd() */
+
+
+/****************************************************************************
+ *                      whal_hwCmdBit_RxCal_CB()
+ ****************************************************************************
+ * DESCRIPTION:   Returns the accumulated counters.
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+void whal_hwCmdBit_RxCal_CB(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf)
+{
+    HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
+    CmdQueue_InterrogateCB_t CB_Func;
+
+    WLAN_REPORT_INFORMATION(pHwMboxCmdBit->hReport, HAL_HW_CTRL_MODULE_LOG, 
+        ("%s MboxStatus = 0x%x\n",
+       __FUNCTION__, MboxStatus));
+
+    /* If there was an error in the RX Calibration command, mark the NOK status here rather than
+        from the RX calibration complete event callback function (the event won't be sent)*/
+    if (OK != MboxStatus)
+    {
+        pHwMboxCmdBit->PltData.RxTxCal.lastStatus = NOK;
+    }
+
+    /* Call the saved CB function (if any)*/
+    if (pHwMboxCmdBit->PltData.RxTxCal.CB_Func)
+    {
+        CB_Func = (CmdQueue_InterrogateCB_t)(pHwMboxCmdBit->PltData.RxTxCal.CB_Func);
+        CB_Func(pHwMboxCmdBit->PltData.RxTxCal.CB_Handle, MboxStatus, &pHwMboxCmdBit->PltData.RxTxCal);
+    }
+
+}
+
+ /****************************************************************************
+ *                      whal_hwCmdBit_RxCal_Complete_Event_CB()
+ ****************************************************************************
+ * DESCRIPTION:   Returns the accumulated counters.
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+void whal_hwCmdBit_RxCal_Complete_Event_CB( TI_HANDLE objectHandle, char* str, UINT32 strLen )
+{
+    HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
+
+    /* mark the status as completed */
+    pHwMboxCmdBit->PltData.RxTxCal.lastStatus = OK;
+}
+
+ /****************************************************************************
+ *                      whal_hwCmdBit_GetPltRxCalibrationStatus()
+ ****************************************************************************
+ * DESCRIPTION:   Returns whether the last RX calibration is pending.
+ * INPUTS: None 
+ * 
+ * OUTPUT:  None
+ * 
+ * RETURNS: None
+ ****************************************************************************/
+void whal_hwCmdBit_GetPltRxCalibrationStatus( TI_HANDLE objectHandle, TI_STATUS* pLastStatus  )
+{
+    HwMboxCmdBit_T *pHwMboxCmdBit = (HwMboxCmdBit_T*)objectHandle;
+
+    /* return the status of the last RX calibration */
+    *pLastStatus = pHwMboxCmdBit->PltData.RxTxCal.lastStatus;
+}
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmdBit.h b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxCmdBit.h
new file mode 100644 (file)
index 0000000..daf6b73
--- /dev/null
@@ -0,0 +1,116 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwMboxCmdBit.h
+ *   PURPOSE: wlan hardware BIT(Built-In Test) commands header file
+ * 
+ ****************************************************************************/
+
+#ifndef _WHAL_HW_MBOX_CMD_BIT_H
+#define _WHAL_HW_MBOX_CMD_BIT_H
+
+#include "whalCommon.h"
+#include "CmdQueue_api.h"
+
+/* Function prototypes */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+    void*                   CB_Func;              /* Pointer to callback function to be called with the results, if working in Async mode (GWSI).*/
+    TI_HANDLE               CB_Handle;
+    PLT_RxPerCmd_e          CB_RxPerCmd;          /* Enumerator of the invoked PLT command*/
+    PltRxPer_t              PltRxPer;             /* The accumulated FCS error and total packets counts */ 
+    ACXErrorCounters_t      ACXErrCountTable;     /* Last F.W. counters results */
+} HwMboxCmdBit_RxPer_t;
+
+typedef struct
+{
+    void*                   CB_Func;              /* Pointer to callback function to be called with the results, if working in Async mode (GWSI).*/
+    TI_HANDLE               CB_Handle;
+    TI_STATUS              lastStatus;
+    
+} HwMboxCmdBit_RxTxCal_t;
+
+typedef union
+{
+    HwMboxCmdBit_RxPer_t   RxPer;
+    HwMboxCmdBit_RxTxCal_t RxTxCal;
+}HwMboxCmdBit_u;
+
+typedef struct _HwMboxCmdBit_T
+{
+    HwMboxCmdBit_u           PltData;
+    TI_HANDLE                hCmdQueue;
+    TI_HANDLE                hOs;
+    TI_HANDLE                hReport;
+    TI_HANDLE                hWhalCtr;
+} HwMboxCmdBit_T;
+
+
+extern HwMboxCmdBit_T *whal_hwMboxCmdBit_Create(TI_HANDLE hOs);
+extern int whal_hwMboxCmdBit_Destroy(HwMboxCmdBit_T *this);
+extern int whal_hwMboxCmdBit_Config(TI_HANDLE hWhalCtr, HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE hCmdQueue, TI_HANDLE hReport);
+
+int whal_hwCmdBit_ReadRegister(HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE CB_Handle, void *CB_Func, void *CB_Buf);
+int whal_hwCmdBit_WriteRegister(HwMboxCmdBit_T *pHwMboxCmdBit, TI_HANDLE CB_Handle, void *CB_Func, void *Command_Buf);
+
+int whal_hwCmdBit_RxPER(HwMboxCmdBit_T *pHwMboxCmdBit, PLT_RxPerCmd_e eRxPerCmd, TI_HANDLE CB_Handle, void *CB_Func);
+
+int whal_hwCmdBit_TestCmd(HwMboxCmdBit_T *pHwMboxCmdBit, void *CB_Func, TI_HANDLE CB_handle, TestCmd_t* pTestCmd_Buf);
+
+void whal_hwCmdBit_GetPltRxCalibrationStatus( TI_HANDLE objectHandle, TI_STATUS* pLastStatus  );
+
+int whal_hwCmdBit_Fcc(HwMboxCmdBit_T *pHwMboxCmdBit,
+                      int chID, int rate, int preamble,int bandID,
+                      int InterPacketDelay, int TestMode, uint32 numFrames,
+                      uint32 seqNumMode, uint32 frameBodySize, uint8 *PeerMacAddr,
+                      void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf);
+
+int whal_hwCmdBit_Telec(HwMboxCmdBit_T *pHwMboxCmdBit, int chID, int bandID, void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf);
+
+int whal_hwCmdBit_perTxStop(HwMboxCmdBit_T *pHwMboxCmdBit, void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif   /* _WHAL_HW_MBOX_CMD_BIT_H */
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxConfig.c b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxConfig.c
new file mode 100644 (file)
index 0000000..19ab83d
--- /dev/null
@@ -0,0 +1,3048 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwMboxConfig.c
+ *   PURPOSE: Handle the wlan hardware information elements:
+ *
+ ****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "public_infoele.h"
+#include "CmdQueue_api.h"
+#include "whalHwMboxConfig.h"
+
+/****************************************************************************
+ *                      whal_hwMboxConfig_Create()
+ ****************************************************************************
+ * DESCRIPTION: Create the mailbox configuration commands object
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: The Created object
+ ****************************************************************************/
+HwMboxConfig_T* whal_hwMboxConfig_Create (TI_HANDLE hOs)
+{
+    HwMboxConfig_T* pObj;
+
+    pObj = os_memoryAlloc (hOs, sizeof(HwMboxConfig_T));
+    if (pObj == NULL)
+        return NULL;
+
+    os_memoryZero (hOs, (void *)pObj, sizeof(HwMboxConfig_T));
+
+    pObj->hOs = hOs;
+
+    return(pObj);
+}
+
+/****************************************************************************
+ *                      whal_hwMboxConfig_Destroy()
+ ****************************************************************************
+ * DESCRIPTION: Destroy the object
+ *
+ * INPUTS:
+ *      pHwMboxConfig       The object to free
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwMboxConfig_Destroy (HwMboxConfig_T* pHwMboxConfig)
+{
+    if (pHwMboxConfig)
+        os_memoryFree(pHwMboxConfig->hOs, pHwMboxConfig, sizeof(HwMboxConfig_T));
+
+    return (OK);
+}
+
+/****************************************************************************
+ *                      whal_hwMboxConfig_Config()
+ ****************************************************************************
+ * DESCRIPTION: Configure the object
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwMboxConfig_Config (HwMboxConfig_T* pHwMboxConfig,TI_HANDLE hCmdMboxQueue, TI_HANDLE hReport)
+{
+    pHwMboxConfig->hReport = hReport;
+    pHwMboxConfig->hCmdMboxQueue = hCmdMboxQueue;
+
+    return (OK);
+}
+
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemConfigMemorySet()
+ ****************************************************************************
+ * DESCRIPTION: Configure wlan hardware memory
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemConfigMemorySet (HwMboxConfig_T* pHwMboxConfig, DmaParams_T *pDmaParams)
+{   
+    ACXConfigMemoryStruct_t AcxElm_ConfigMemory;
+    ACXConfigMemoryStruct_t *pCfg = &AcxElm_ConfigMemory;
+    int Qid;
+    
+    os_memoryZero(pHwMboxConfig->hOs, (void *)pCfg, sizeof(*pCfg));
+    /*
+     * Set information element header
+     */
+    pCfg->memConfig.EleHdr.id = ACX_MEM_CFG;
+    pCfg->memConfig.EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /*
+     * Set configuration fields
+     */
+    pCfg->memConfig.numStations      = ENDIAN_HANDLE_WORD(pDmaParams->NumStations); /*(1)*/
+    pCfg->memConfig.rxMemblockNumber = pDmaParams->rxMemBlkNumber;  /*(60)*/
+    pCfg->memConfig.txMinimumMemblockNumber = pDmaParams->txMinMemBlkNumber; /*(60)*/
+    pCfg->memConfig.numTxQueues      = pDmaParams->NumTxQueues; /*(4)*/
+    pCfg->memConfig.hostifOptions    = 3; /*(3 - HOST_IF_PKT_RING)*/
+    pCfg->memConfig.numSsidProfiles = 1;
+    pCfg->memConfig.debugBufferSize  = ENDIAN_HANDLE_WORD(pDmaParams->TraceBufferSize/4); /*(4)*/
+    
+        /*
+     * Rx queue config
+     */
+    pCfg->RxQueueConfig.dmaAddress  = 0;  
+    pCfg->RxQueueConfig.numDescs    = (UINT8)pDmaParams->RxNumDesc;
+    pCfg->RxQueueConfig.Priority    = (UINT8)pDmaParams->RxQPriority;
+    pCfg->RxQueueConfig.Type        = pDmaParams->RxQueue_Type;
+
+    /*
+     * Tx queue config
+     */
+    for (Qid=0; Qid<pDmaParams->NumTxQueues; Qid++)
+    {
+        pCfg->TxQueueConfig[Qid].numDescs      = pDmaParams->TxNumDesc[Qid];
+        pCfg->TxQueueConfig[Qid].attributes    = pDmaParams->TxQPriority[Qid];
+    }
+
+    /* The structure contain array of TxQueueConfig_T
+     * The size of the array is QUEUE_CONFIG_MAX_TX_QUEUES buf the actual number of
+     * Queues are pCfg->NumTxQueues so the structure length must be fixed */
+    pCfg->memConfig.EleHdr.len -= (NUM_ACCESS_CATEGORIES_QUEUES - pDmaParams->NumTxQueues) * sizeof(ACXtxQueueConfig);
+
+    /*
+     * Send the configuration command
+     */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemDataPathParamsSet()
+ ****************************************************************************
+ * DESCRIPTION: configure Data path and TX complete parameters
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int  whal_hwInfoElemDataPathParamsSet (HwMboxConfig_T* pHwMboxConfig,UINT16 rxPacketRingChunkSize,
+                                       UINT16 txPacketRingChunkSize, UINT8 rxPacketRingChunkNum,
+                                       UINT8 txPacketRingChunkNum, UINT8 txCompleteThreshold,
+                                       UINT8  txCompleteRingDepth,   UINT32 txCompleteTimeOut)
+{
+    ACXDataPathParams_t DataPathParams;
+    ACXDataPathParams_t*  pCfg = &DataPathParams;
+
+    /*
+     * Set information element header
+     */
+    pCfg->EleHdr.id = ACX_DATA_PATH_PARAMS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+     /*
+     * Set configuration fields
+     */
+    pCfg->rxPacketRingChunkSize = ENDIAN_HANDLE_WORD(rxPacketRingChunkSize);
+    pCfg->txPacketRingChunkSize = ENDIAN_HANDLE_WORD(txPacketRingChunkSize );
+    pCfg->rxPacketRingChunkNum  = rxPacketRingChunkNum; 
+    pCfg->txPacketRingChunkNum  = txPacketRingChunkNum; 
+    pCfg->txCompleteThreshold   = txCompleteThreshold;  
+    pCfg->txCompleteRingDepth   = txCompleteRingDepth;
+    pCfg->txCompleteTimeOut     = txCompleteTimeOut;
+
+    /* Send the configuration command*/
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemDataPathParamsGet()
+ ****************************************************************************
+ * DESCRIPTION: Get data path specific parameters
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int  whal_hwInfoElemDataPathParamsGet (HwMboxConfig_T* pHwMboxConfig, ACXDataPathParamsResp_t* pCfg, void *fCb, TI_HANDLE hCb)
+{
+    int rc;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_DATA_PATH_PARAMS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command*/
+    if ((rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), fCb, hCb, pCfg)) == OK)
+    {
+    }
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemQueueHeadGet()
+ ****************************************************************************
+ * DESCRIPTION: Read the Queue addresses after memory init
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemQueueHeadGet (HwMboxConfig_T* pHwMboxConfig, int NumTxQueues, int pElem, void *fCb, TI_HANDLE hCb)
+{
+#if 0 /*Benzy: should be fixed after the firmware/driver integration*/
+    int Qid;
+    int Stt;
+
+    /* only interrogate is enabled to this info element */
+    if (aAction != INTERROGATE_ACTION)
+        return (NOK);
+
+    /*
+     * Set information element header
+     */
+    pElem->EleHdr.id  = ACX_QUEUE_HEAD;
+    pElem->EleHdr.len = sizeof(*pElem) - sizeof(EleHdrStruct);
+
+    /*
+     * Send the interrogation command, and fill the structure
+     */
+    if ((Stt=CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pElem, sizeof(*pElem), fCb, hCb, pElem)) != OK)
+        return (Stt);
+
+    /*
+     * Solve endian problem
+     */
+    pElem->rxMemBlkQ  = (UINT32 *)ENDIAN_HANDLE_LONG((UINT32)(pElem->rxMemBlkQ));
+    pElem->txMemBlkQ  = (UINT32 *)ENDIAN_HANDLE_LONG((UINT32)(pElem->txMemBlkQ));
+    pElem->rxQueueHead.addr = ENDIAN_HANDLE_LONG(pElem->rxQueueHead.addr);
+
+    for (Qid=0; Qid<NumTxQueues; Qid++)
+    {
+        pElem->txQueueHead[Qid].addr = ENDIAN_HANDLE_LONG(pElem->txQueueHead[Qid].addr);
+    }
+#endif
+    WLAN_OS_REPORT(("Command Disabled: whal_hwInfoElemQueueHeadGet\n"));
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemSlotTimeSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the Slot Time
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemSlotTimeSet (HwMboxConfig_T* pHwMboxConfig, UINT8* apSlotTime)                                
+{
+    int rc;
+    ACXSlot_t   AcxElm_SlotTime;
+    ACXSlot_t   *pCfg = &AcxElm_SlotTime;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_SLOT;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration fields */
+    /* woneIndex is not relevant to station implementation */
+    pCfg->woneIndex = STATION_WONE_INDEX;
+    pCfg->slotTime = *apSlotTime;
+
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: Sending info elem to firmware, Slot Time = %d\n", __FUNCTION__, (UINT8)pCfg->slotTime));
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemPreambleSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the Preamble
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemPreambleSet (HwMboxConfig_T* pHwMboxConfig, UINT8* apPreamble)
+{
+    int rc;
+    ACXPreamble_t   AcxElm_Preamble;
+    ACXPreamble_t   *pCfg = &AcxElm_Preamble;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_PREAMBLE_TYPE;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration fields */
+    /* woneIndex is not relevant to station implementation */
+    pCfg->preamble = *apPreamble;
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemGeneraedFrameRate()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the rate
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemGeneratedFrameRateSet (HwMboxConfig_T *pHwMboxConfig,
+                                          UINT8          *txCtrlFrmRate,
+                                          UINT8          *txCtrlFrmMod,
+                                          UINT8          *txMgmtFrmRate,
+                                          UINT8          *txMgmtFrmMod)
+{
+    int rc;
+    ACXFwGeneratedFrameRates_t   AcxElm_FrameRate;
+    ACXFwGeneratedFrameRates_t   *pCfg = &AcxElm_FrameRate;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_FW_GEN_FRAME_RATES;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration fields */
+    /* woneIndex is not relevant to station implementation */
+    pCfg->txCtrlFrmRate = *txCtrlFrmRate;
+    pCfg->txCtrlFrmMod  = *txCtrlFrmMod;
+    pCfg->txMgmtFrmRate = *txMgmtFrmRate;
+    pCfg->txMgmtFrmMod  = *txMgmtFrmMod;
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemRxConfigSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate RxConfig information element
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemRxConfigSet (HwMboxConfig_T* pHwMboxConfig, UINT32* apRxConfigOption, UINT32* apRxFilterOption)
+{
+    int rc;
+    ACXRxConfig_t AcxElm_RxConfig;
+    ACXRxConfig_t* pCfg = &AcxElm_RxConfig;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_RX_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration fields */
+    pCfg->ConfigOptions = ENDIAN_HANDLE_LONG(*apRxConfigOption);
+    pCfg->FilterOptions = ENDIAN_HANDLE_LONG(*apRxFilterOption);
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+/****************************************************************************
+ *                      whal_hwInfoElemBETSet()
+ ****************************************************************************
+ * DESCRIPTION: Configures Beacon Early Termination information element
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemBETSet(HwMboxConfig_T* pHwMboxConfig, UINT8 Enable, UINT8 MaximumConsecutiveET)
+{
+    int rc;
+    ACXBet_Enable_t ACXBet_Enable;
+    ACXBet_Enable_t* pCfg = &ACXBet_Enable;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_BET_ENABLE;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration fields */
+    pCfg->Enable = Enable;
+    pCfg->MaximumConsecutiveET = MaximumConsecutiveET;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: Sending info elem to firmware, Enable=%d, MaximumConsecutiveET=%d\n", 
+                __FUNCTION__, (UINT8)pCfg->Enable, (UINT8)pCfg->MaximumConsecutiveET));
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+/****************************************************************************
+*                 whal_hwInfoElemSetRxDataFiltersParams()
+*****************************************************************************
+* DESCRIPTION: Enables or disables Rx data filtering.
+*
+* INPUTS:  enabled             - 0 to disable data filtering, any other value to enable 
+*          defaultAction       - The default action to take on non-matching packets.
+*
+* OUTPUT:  None
+*
+* RETURNS: OK or NOK
+****************************************************************************/
+int whal_hwInfoElemSetRxDataFiltersParams(HwMboxConfig_T * pHwMboxConfig, BOOL enabled, filter_e defaultAction)
+{
+    DataFilterDefault_t dataFilterDefault;
+    DataFilterDefault_t * pCfg = &dataFilterDefault;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_ENABLE_RX_DATA_FILTER;
+    pCfg->EleHdr.len = 0;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: Rx Data Filter configuration:\n", __FUNCTION__));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: enabled = %d, defaultAction = %d\n", __FUNCTION__, enabled, defaultAction));
+
+    /* Set information element configuration fields */
+    pCfg->enable = enabled;
+    pCfg->action = defaultAction;
+    pCfg->EleHdr.len += sizeof(pCfg->enable) + sizeof(pCfg->action);
+
+    WLAN_REPORT_HEX_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG, (UINT8 *) pCfg, sizeof(dataFilterDefault));
+
+    return CmdQueue_CmdConfigure(pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+*                      whal_hwInfoElemSetRxDataFilter()
+*****************************************************************************
+* DESCRIPTION: Add/remove Rx Data filter information element.
+*
+* INPUTS:  index               - Index of the Rx Data filter
+*          command             - Add or remove the filter
+*          action              - Action to take on packets matching the pattern
+*          numFieldPatterns    - Number of field patterns in the filter
+*          lenFieldPatterns    - Length of the field pattern series
+*          fieldPatterns       - Series of field patterns
+*
+* OUTPUT:  None
+*
+* RETURNS: OK or NOK
+****************************************************************************/
+int whal_hwInfoElemSetRxDataFilter(HwMboxConfig_T * pHwMboxConfig, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns)
+{
+    UINT8 dataFilterConfig[sizeof(DataFilterConfig_t) + MAX_DATA_FILTER_SIZE];
+    DataFilterConfig_t * pCfg = (DataFilterConfig_t *) &dataFilterConfig;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_SET_RX_DATA_FILTER;
+    pCfg->EleHdr.len = 0;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: Rx Data Filter configuration:\n", __FUNCTION__));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: command = %d, index = %d, action = %d, numFieldPatterns = %d\n", __FUNCTION__,
+        command, index, action, numFieldPatterns));
+
+    /* Set information element configuration fields */
+    pCfg->command = command;
+    pCfg->index = index;
+    pCfg->EleHdr.len += sizeof(pCfg->command) + sizeof(pCfg->index);
+
+    /* When removing a filter only the index and command are to be sent */
+    if (command == ADD_FILTER)
+    {
+        pCfg->action = action;
+        pCfg->numOfFields = numFieldPatterns;
+        pCfg->EleHdr.len += sizeof(pCfg->action) + sizeof(pCfg->numOfFields);
+
+        if (fieldPatterns == NULL)
+        {
+            WLAN_REPORT_ERROR(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                ("%s: Null pattern table argument received!\n", __FUNCTION__));
+
+            return PARAM_VALUE_NOT_VALID;
+        }
+
+        os_memoryCopy(pHwMboxConfig->hOs, &pCfg->FPTable, fieldPatterns, lenFieldPatterns);
+        pCfg->EleHdr.len += lenFieldPatterns;
+    }
+
+    WLAN_REPORT_HEX_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG, (UINT8 *) pCfg, sizeof(dataFilterConfig));
+
+    return CmdQueue_CmdConfigure(pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(dataFilterConfig));
+}
+
+/****************************************************************************
+ *                      whal_hwInfoElemGetRxDataFiltersStatistics()
+ ****************************************************************************
+ * DESCRIPTION: Get the ACX GWSI counters 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemGetRxDataFiltersStatistics(HwMboxConfig_T * pHwMboxConfig, 
+                                              void * CB_Func, 
+                                              TI_HANDLE CB_handle, 
+                                              void * CB_Buf)
+{
+    ACXDataFilteringStatistics_t acx;
+    ACXDataFilteringStatistics_t * pCfg = &acx;
+
+    /* Set information element header */
+    pCfg->EleHdr.id  = ACX_GET_DATA_FILTER_STATISTICS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    WLAN_REPORT_HEX_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG, (UINT8 *) pCfg, sizeof(ACXDataFilteringStatistics_t));
+
+    /* Send the interrogation command */
+    return CmdQueue_CmdInterrogateWithCb(pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), CB_Func, CB_handle, CB_Buf);
+}
+
+
+/****************************************************************************
+ *                      whalCtrl_getConsumptionStatistics()
+ ****************************************************************************
+ * DESCRIPTION: Get the ACX Power consumption statistics 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whalCtrl_getConsumptionStatistics(HwMboxConfig_T * pHwMboxConfig, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf)
+{
+    ACXPowerConsumptionTimeStat_t acx;
+    ACXPowerConsumptionTimeStat_t * pCfg = &acx;
+
+    /* Set information element header */
+    pCfg->EleHdr.id  = ACX_PWR_CONSUMPTION_STATISTICS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    /* Send the interrogation command */
+    return CmdQueue_CmdInterrogateWithCb(pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), CB_Func, CB_handle, CB_Buf);
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemarpIpAddressesTableSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate ARP addr table information element for
+ *              ipV4 only
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemarpIpAddressesTableSet (HwMboxConfig_T* pHwMboxConfig, 
+                                           IpAddress_t *IP_addr,
+                                           UINT32 isFilteringEnabled)
+{
+    int rc;
+    ACXConfigureIP_t AcxElm_CmdConfigureIP;
+    ACXConfigureIP_t *pCfg = &AcxElm_CmdConfigureIP;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_ARP_IP_FILTER;
+    pCfg->EleHdr.len = sizeof(ACXConfigureIP_t) - sizeof(EleHdrStruct);
+
+    pCfg->arpFilterEnable = isFilteringEnabled;
+        
+    /* IP address */
+    /* Note that in the case of IPv4 it is assumed that the extra two bytes are zero */
+    os_memoryCopy (pHwMboxConfig->hOs, (PVOID)pCfg->address, (PVOID)IP_addr->addr, IP_V4_ADDR_LEN);
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,("ip filtering : %d.%d.%d.%d Enabled = %d \n" , pCfg->address[0] , pCfg->address[1] , pCfg->address[2] , pCfg->address[3] , isFilteringEnabled)) ;
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(ACXConfigureIP_t));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemGroupAdressesTableSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate Group addr table information element
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemGroupAdressesTableSet (HwMboxConfig_T* pHwMboxConfig, 
+                                       UINT8* numGroupAddrs, 
+                                       macAddress_t *Group_addr, 
+                                       UINT8* isEnabled)
+{
+    int i = 0;
+    int rc = OK;
+    UINT8   *tmpLoc = NULL;
+    dot11MulticastGroupAddrStart_t  AcxElm_CmdConfigureMulticastIp;
+    dot11MulticastGroupAddrStart_t* pCfg = &AcxElm_CmdConfigureMulticastIp;
+    
+    if ( NULL == pHwMboxConfig )
+    {
+        return PARAM_VALUE_NOT_VALID;
+    }
+    
+    os_memoryZero (pHwMboxConfig->hOs, (void *)pCfg, sizeof(dot11MulticastGroupAddrStart_t));
+
+    /* Set information element header */
+    pCfg->EleHdr.id = DOT11_GROUP_ADDRESS_TBL;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+     
+    pCfg->numOfGroups = *numGroupAddrs;
+    pCfg->fltrState = *isEnabled;
+    tmpLoc = pCfg->dataLocation;
+        
+    if (NULL != Group_addr)
+    {
+        for (i=0; i<*numGroupAddrs; i++) 
+        {
+            os_memoryCopy(pHwMboxConfig->hOs, (PVOID)&(tmpLoc[MAC_ADDR_SIZE*i]), (PVOID)&(Group_addr->addr[MAC_ADDR_SIZE*i]), MAC_ADDR_SIZE);
+            WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                ("whal_hwInfoElemGroupAdressesTable: MAC %x: %x:%x:%x:%x:%x:%x\n",
+                i,
+                tmpLoc[MAC_ADDR_SIZE*i+0] ,
+                tmpLoc[MAC_ADDR_SIZE*i+1] ,
+                tmpLoc[MAC_ADDR_SIZE*i+2] ,
+                tmpLoc[MAC_ADDR_SIZE*i+3] ,
+                tmpLoc[MAC_ADDR_SIZE*i+4] ,
+                tmpLoc[MAC_ADDR_SIZE*i+5]));        
+        }
+    }
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(dot11MulticastGroupAddrStart_t));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemStationIdSet ()
+ ****************************************************************************
+ * DESCRIPTION: Configure StationId information element to/from
+ *      the wlan hardware.
+ *      This information element specifies the MAC Address assigned to the
+ *      STATION or AP.
+ *      This default value is the permanent MAC address that is stored in the
+ *      adaptor's non-volatile memory.
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemStationIdSet 
+(
+    HwMboxConfig_T           *pHwMboxConfig, 
+    UINT8                    *apStationId
+) 
+{
+    int i;
+    int rc;
+    dot11StationIDStruct AcxElm_StationId;
+    dot11StationIDStruct* pCfg = &AcxElm_StationId;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_STATION_ID;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration field (reversed order, see docs)*/
+    for (i = 0; i < 6; i++)
+        pCfg->dot11StationID[i] = apStationId[5-i];
+
+    /* Send the configuration command*/
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemStationIdGet ()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate StationId information element to/from
+ *      the wlan hardware.
+ *      This information element specifies the MAC Address assigned to the
+ *      STATION or AP.
+ *      This default value is the permanent MAC address that is stored in the
+ *      adaptor's non-volatile memory.
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemStationIdGet 
+(
+    HwMboxConfig_T* pHwMboxConfig, 
+    void*           fCb,
+    TI_HANDLE       hCb,
+    void*           pCb
+) 
+{
+    int rc;
+    dot11StationIDStruct AcxElm_StationId;
+    dot11StationIDStruct* pCfg = &AcxElm_StationId;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_STATION_ID;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    if ((rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, 
+                                             pCfg, 
+                                             sizeof(*pCfg),
+                                             fCb,
+                                             hCb,
+                                             pCb)) == OK)
+    {
+    }
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemStationIdForRecoveryGet ()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate StationId information element to/from
+ *      the wlan hardware.
+ *      This information element specifies the MAC Address assigned to the
+ *      STATION or AP.
+ *      This default value is the permanent MAC address that is stored in the
+ *      adaptors non-volatile memory.
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemStationIdForRecoveryGet (HwMboxConfig_T* pHwMboxConfig,
+                                            void *CB_Func, TI_HANDLE CB_handle, dot11StationIDStruct* CB_Buf)
+{
+
+    dot11StationIDStruct AcxElm_StationId;
+    dot11StationIDStruct* pCfg = &AcxElm_StationId;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_STATION_ID;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), CB_Func, CB_handle, CB_Buf);
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemRSSIGet ()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate StationId information element to/from
+ *      the wlan hardware.
+ *      This information element specifies the MAC Address assigned to the
+ *      STATION or AP.
+ *      This default value is the permanent MAC address that is stored in the
+ *      adaptor's non-volatile memory.
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemRSSIGet (HwMboxConfig_T* pHwMboxConfig, void *CB_Func, TI_HANDLE CB_handle, PUINT8 CB_Buf)
+{
+    int rc;
+    ACXRoamingStatisticsTable_t AcxElm_GetAverageRSSI;
+    ACXRoamingStatisticsTable_t* pCfg = &AcxElm_GetAverageRSSI;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_ROAMING_STATISTICS_TBL;
+    pCfg->EleHdr.len = sizeof(ACXRoamingStatisticsTable_t) - sizeof(EleHdrStruct);
+    
+    rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(ACXRoamingStatisticsTable_t), CB_Func, CB_handle, CB_Buf);
+
+    /* Send the configuration command */
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemACIConfigurationSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the hardware ACI parameters
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemACIConfigurationSet (HwMboxConfig_T* pHwMboxConfig, UINT8 ACIMode,
+                                        UINT8 inputCCA, UINT8 qualifiedCCA,
+                                        UINT8 stompForRx, UINT8 stompForTx,
+                                        UINT8 txCCA)
+{
+    int rc;
+    ACXConfigACI_t AcxElm_AciConfig;
+    ACXConfigACI_t* pCfg = &AcxElm_AciConfig;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_ACI_OPTION_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set sequence number */
+    pCfg->ACIMode = ACIMode;
+    pCfg->inputCCA = inputCCA;
+    pCfg->qualifiedCCA = qualifiedCCA;
+    pCfg->stompForRx = stompForRx;
+    pCfg->stompForTx = stompForTx;
+    pCfg->txCCA = txCCA;
+
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+    
+    return rc;
+}
+
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemBssPowerSaveGet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the Bss in/not power save
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemBssPowerSaveGet (HwMboxConfig_T* pHwMboxConfig, UINT8* apBssInPs_Val)                                
+{
+    int rc;
+    ACXBSSPowerSave_t   AcxElm_BssPowerSave;
+    ACXBSSPowerSave_t   *pCfg = &AcxElm_BssPowerSave;
+
+    /* Set information element heade r*/
+    pCfg->EleHdr.id = ACX_BSS_IN_PS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set configuration fields */
+    pCfg->BSSinPowerSave = *apBssInPs_Val;
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemSoftGeminiEnableSet()
+ ****************************************************************************
+ * DESCRIPTION: Enable/Disable the BTH-WLAN  
+ *
+ * INPUTS:  Enable flag
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemSoftGeminiEnableSet (HwMboxConfig_T* pHwMboxConfig, SoftGeminiEnableModes_e SoftGeminiEnableModes)
+{
+    ACXBluetoothWlanCoEnableStruct        AcxElm_BluetoothWlanEnable;
+    ACXBluetoothWlanCoEnableStruct* pCfg = &AcxElm_BluetoothWlanEnable;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("whal_hwInfoElemSoftGeminiEnableSet: Enable flag = %d\n", SoftGeminiEnableModes));
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_SG_ENABLE;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set enable field */
+    pCfg->Enable = (UINT8)SoftGeminiEnableModes;
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemSoftGeminiParamsSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the BTH-WLAN co-exsistance   
+ *
+ * INPUTS:  Configuration structure pointer 
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemSoftGeminiParamsSet (HwMboxConfig_T* pHwMboxConfig, SoftGeminiParam_t *SoftGeminiParam)
+{
+    ACXBluetoothWlanCoParamsStruct          AcxElm_BluetoothWlanEnable;
+    ACXBluetoothWlanCoParamsStruct* pCfg = &AcxElm_BluetoothWlanEnable;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("whal_hwInfoElemSoftGeminiParamsSet. \n"));
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_SG_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    pCfg->afhLeverageOn         = SoftGeminiParam->afhLeverageOn;
+    pCfg->btHpMaxTime           = SoftGeminiParam->btHpMaxTime;
+    pCfg->maxNumCts             = SoftGeminiParam->maxNumCts;
+    pCfg->numberOfBtPackets     = SoftGeminiParam->numberOfBtPackets;
+    pCfg->numberOfWlanPackets   = SoftGeminiParam->numberOfWlanPackets;
+    pCfg->numberQuietCycle      = SoftGeminiParam->numberQuietCycle;
+    pCfg->protectiveRxTimeBeforeBtHp = SoftGeminiParam->protectiveRxTimeBeforeBtHp;
+    pCfg->protectiveTxTimeBeforeBtHp = SoftGeminiParam->protectiveTxTimeBeforeBtHp;
+    pCfg->protectiveRxTimeBeforeBtHpFastAp = SoftGeminiParam->protectiveRxTimeBeforeBtHpFastAp;
+    pCfg->protectiveTxTimeBeforeBtHpFastAp = SoftGeminiParam->protectiveTxTimeBeforeBtHpFastAp;
+    pCfg->protectiveWlanCycleTimeForFastAp = SoftGeminiParam->protectiveWlanCycleTimeForFastAp;
+    pCfg->senseDisableTimer     = SoftGeminiParam->senseDisableTimer;
+    pCfg->sgAntennaType         = SoftGeminiParam->sgAntennaType;
+    pCfg->signalingType         = SoftGeminiParam->signalingType;
+    pCfg->timeoutNextBtLpPacket = SoftGeminiParam->timeoutNextBtLpPacket;
+    pCfg->wlanHpMaxTime         = SoftGeminiParam->wlanHpMaxTime;
+    pCfg->numberOfMissedRxForAvalancheTrigger = SoftGeminiParam->numberOfMissedRxForAvalancheTrigger;
+    pCfg->wlanElpHpSupport      = SoftGeminiParam->wlanElpHpSupport;
+    pCfg->btAntiStarvationNumberOfCyclesWithinThePeriod = SoftGeminiParam->btAntiStarvationNumberOfCyclesWithinThePeriod;
+    pCfg->btAntiStarvationPeriod = SoftGeminiParam->btAntiStarvationPeriod;
+    pCfg->ackModeDuringBtLpInDualAnt = SoftGeminiParam->ackModeDuringBtLpInDualAnt;
+    pCfg->allowPaSdToggleDuringBtActivityEnable = SoftGeminiParam->allowPaSdToggleDuringBtActivityEnable;
+    pCfg->wakeUpTimeBeforeBeacon = SoftGeminiParam->wakeUpTimeBeforeBeacon;
+       pCfg->hpdmMaxGuardTime = SoftGeminiParam->hpdmMaxGuardTime;
+       pCfg->timeoutNextWlanPacket = SoftGeminiParam->timeoutNextWlanPacket;
+       pCfg->sgAutoModeNoCts = SoftGeminiParam->sgAutoModeNoCts;
+       pCfg->numOfBtHpRespectedReq = SoftGeminiParam->numOfBtHpRespectedReq;
+
+       /* Convert from pure number to Index. '0' is any rate */
+       if ( SoftGeminiParam->wlanRxMinRateToRespectBtHp )
+       {
+               pCfg->wlanRxMinConvertedRateToRespectBtHp = rateNumberToIndex((UINT8)SoftGeminiParam->wlanRxMinRateToRespectBtHp);
+
+               if (pCfg->wlanRxMinConvertedRateToRespectBtHp == INVALID_RATE_INDEX)
+               {
+                       WLAN_REPORT_ERROR(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                               ("%s wlanRxMinRateToRespectBtHp from %d to 0 (any rate). \n",
+                               __FUNCTION__, SoftGeminiParam->wlanRxMinRateToRespectBtHp));
+
+                       pCfg->wlanRxMinConvertedRateToRespectBtHp = RATE_INDEX_1MBPS;
+               }
+       }
+       else
+       {
+               pCfg->wlanRxMinConvertedRateToRespectBtHp = RATE_INDEX_1MBPS;
+       }
+
+       WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("%s wlanRxMinRateToRespectBtHp from %d to %d. \n",
+               __FUNCTION__, SoftGeminiParam->wlanRxMinRateToRespectBtHp, pCfg->wlanRxMinConvertedRateToRespectBtHp));
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+/****************************************************************************
+ *                      whal_hwInfoElemSoftGeminiParamsGet()
+ ****************************************************************************
+ * DESCRIPTION: Get the BTH-WLAN co-exsistance parameters from the Fw   
+ *
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemSoftGeminiParamsGet (HwMboxConfig_T* pHwMboxConfig, void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf)
+{
+    ACXBluetoothWlanCoParamsStruct          AcxElm_BluetoothWlanEnable;
+    ACXBluetoothWlanCoParamsStruct* pCfg = &AcxElm_BluetoothWlanEnable;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("whal_hwInfoElemSoftGeminiParamsGet. \n"));
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_SG_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the configuration command */
+    return CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(ACXBluetoothWlanCoParamsStruct), CB_Func, CB_handle, CB_Buf);
+}
+
+/****************************************************************************
+ *                      whal_hwInfoElemMemoryMapSet ()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate MemoryMap information element
+ *
+ * INPUTS:
+ *      AcxElm_MemoryMap_T *apMap   pointer to the memory map structure
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemMemoryMapSet 
+(
+    HwMboxConfig_T *pHwMboxConfig, 
+    MemoryMap_t    *apMap
+)
+{
+    int rc;  
+    MemoryMap_t SwapMap;
+    UINT32 *pSwap, *pOrig, i;
+
+    /* Set information element header */
+    SwapMap.EleHdr.id  = ACX_MEM_MAP;
+    SwapMap.EleHdr.len = sizeof(SwapMap) - sizeof(EleHdrStruct);
+
+    /* Solve endian problem (all fields are 32 bit) */
+    pOrig = (UINT32* )&apMap->codeStart;
+    pSwap = (UINT32* )&SwapMap.codeStart;
+    for (i = 0; i < MEM_MAP_NUM_FIELDS; i++)
+        pSwap[i] = ENDIAN_HANDLE_LONG(pOrig[i]);
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, &SwapMap, sizeof(SwapMap));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemMemoryMapGet ()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate MemoryMap information element
+ *
+ * INPUTS:
+ *      AcxElm_MemoryMap_T *apMap   pointer to the memory map structure
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemMemoryMapGet 
+(
+    HwMboxConfig_T *pHwMboxConfig, 
+    MemoryMap_t    *apMap,
+    void           *fCb,
+    TI_HANDLE       hCb
+)
+{
+    int rc;
+   
+    /* Set information element header */
+    apMap->EleHdr.id  = ACX_MEM_MAP;
+    apMap->EleHdr.len = sizeof(*apMap) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command */
+    if ((rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, apMap, sizeof(*apMap), fCb, hCb, apMap)) == OK)
+    {
+    }
+
+    return rc;
+}
+
+
+static int whal_hwInfoElemMemoryMapPrintCb (TI_HANDLE hHwMboxConfig, TI_STATUS status, void *pData)
+{
+#ifdef TI_DBG
+    HwMboxConfig_T *pHwMboxConfig = (HwMboxConfig_T *)hHwMboxConfig;
+    MemoryMap_t    *pMemMap = &pHwMboxConfig->MemMap;
+
+    /* Print the memory map */
+    WLAN_OS_REPORT (("whal_hwInfoElemMemoryMapPrint:\n"));
+    WLAN_OS_REPORT (("\tCode  (0x%08x, 0x%08x)\n\tWep  (0x%08x, 0x%08x)\n\tTmpl (0x%08x, 0x%08x)\n "
+                    "\tQueue (0x%08x, 0x%08x)\n\tPool (0x%08x, 0x%08x)\n\tTraceBuffer (A = 0x%08x, B = 0x%08x)\n",
+                    pMemMap->codeStart, pMemMap->codeEnd,
+                    pMemMap->wepDefaultKeyStart, pMemMap->wepDefaultKeyEnd,
+                    pMemMap->packetTemplateStart, pMemMap->packetTemplateEnd,
+                    pMemMap->queueMemoryStart, pMemMap->queueMemoryEnd,
+                    pMemMap->packetMemoryPoolStart, pMemMap->packetMemoryPoolEnd,
+                    pMemMap->debugBuffer1Start, pMemMap->debugBuffer2Start));
+#endif /* TI_DBG */
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemMemoryMapPrint ()
+ ****************************************************************************
+ * DESCRIPTION: Print some of the MemoryMap information element fields
+ *
+ * INPUTS:
+ *          HwMboxConfig_T* pHwMboxConfig pointer to the acx mailbox
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: None
+ ****************************************************************************/
+void whal_hwInfoElemMemoryMapPrint (HwMboxConfig_T* pHwMboxConfig)
+{
+    whal_hwInfoElemMemoryMapGet (pHwMboxConfig, 
+                                 &pHwMboxConfig->MemMap, 
+                                 (void *)whal_hwInfoElemMemoryMapPrintCb,
+                                 (TI_HANDLE)pHwMboxConfig);
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemConfigOptionsRead ()
+ ****************************************************************************
+ * DESCRIPTION: Read ConfigOption information element from the wlan hardware.
+ *      This is a special case where the data is already in the mailbox
+ *      after wlan hardware reset and no interrogate command should be sent.
+ *      This read-only IE provides information stored in the adaptor\92s
+ *      non-volatile memory to host.
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ *
+ * NOTE : This function is not in use and must be reexamined (especially the Fw-Driver API) 
+ *
+ ****************************************************************************/
+int whal_hwInfoElemConfigOptionsRead (HwMboxConfig_T* pHwMboxConfig, void* pElm)
+{   
+    WLAN_OS_REPORT(("%s not implemented\n",__FUNCTION__));
+    /* The ConfigOptions information element is ready after reset on the mailbox */
+    return 0;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxRevisionGet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the ACX revision (FW and HW version)
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxRevisionGet 
+(
+     HwMboxConfig_T *pHwMboxConfig, 
+     void           *fCb,
+     TI_HANDLE       hCb,
+     void           *pCb
+)
+{
+    ACXRevision_t   aElm;
+    ACXRevision_t  *apElm = &aElm; 
+    int rc;
+
+    /* Set information element header */
+    apElm->EleHdr.id  = ACX_FW_REV;
+    apElm->EleHdr.len = sizeof(*apElm) - sizeof(EleHdrStruct);
+
+    /* Send the command*/
+    rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, apElm, sizeof(*apElm), fCb, hCb, pCb);
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemWepDefaultKeyIdSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate The default Key Id
+ *
+ * INPUTS:
+ *      UINT8* Key    The default key id to use
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemWepDefaultKeyIdSet (HwMboxConfig_T* pHwMboxConfig, UINT8* apKeyVal,
+                                       void *CB_Func, TI_HANDLE CB_handle)
+{
+    int rc;
+    dot11WEPDefaultKeyId_t  WlanElm_WepDefaultKeyId;
+    dot11WEPDefaultKeyId_t  *pCfg = &WlanElm_WepDefaultKeyId;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_DEFAULT_KEY;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    pCfg->DefaultKeyId = *apKeyVal;
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigureWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), CB_Func, CB_handle);
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemWepDefaultKeyIdGet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate The default Key Id
+ *
+ * INPUTS:
+ *      UINT8* Key    The default key id to use
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemWepDefaultKeyIdGet (HwMboxConfig_T* pHwMboxConfig, UINT8* apKeyVal,
+                                       void *CB_Func, TI_HANDLE CB_handle)
+{
+    int rc = OK;
+    dot11WEPDefaultKeyId_t  WlanElm_WepDefaultKeyId;
+    dot11WEPDefaultKeyId_t  *pCfg = &WlanElm_WepDefaultKeyId;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = DOT11_DEFAULT_KEY;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Not implemented */
+
+  #if 0
+    *apKeyVal = pCfg->DefaultKeyId;
+  #endif
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAidSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the AID info element
+ *
+ * INPUTS:
+ *      UINT16* apAidVal     The AID value
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAidSet (HwMboxConfig_T* pHwMboxConfig, UINT16* apAidVal)
+{
+    int rc;
+    ACXAid_t    WlanElm_AID;
+    ACXAid_t    *pCfg = &WlanElm_AID;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_AID;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    pCfg->Aid = ENDIAN_HANDLE_WORD(*apAidVal);
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxwakeUpConditionSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the power management option
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxwakeUpConditionSet (HwMboxConfig_T* pHwMboxConfig,
+                                          WakeUpCondition_t* pWlanElm_wakeUpCondition)
+{
+    int rc;
+    WakeUpCondition_t* pCfg = pWlanElm_wakeUpCondition;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_WAKE_UP_CONDITIONS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxPMConfigSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the power management option
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxPMConfigSet (HwMboxConfig_T* pHwMboxConfig,
+                                   ACXConfigPM_t* pWlanElm_PowerMgmtOptions)
+{
+    int rc;
+    ACXConfigPM_t* pCfg = pWlanElm_PowerMgmtOptions;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_PM_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxSleepAuthoSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the power management option
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxSleepAuthoSet (HwMboxConfig_T* pHwMboxConfig,
+                                     ACXSleepAuth_t* pWlanElm_SleepAutho)
+{
+    int rc;
+    ACXSleepAuth_t* pCfg = pWlanElm_SleepAutho;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = ACX_SLEEP_AUTH;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxBcnBrcOptionsSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the power management option
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxBcnBrcOptionsSet (HwMboxConfig_T* pHwMboxConfig,
+                                        ACXBeaconAndBroadcastOptions_t* pWlanElm_BcnBrcOptions)
+{
+    int rc;
+    ACXBeaconAndBroadcastOptions_t* pCfg = pWlanElm_BcnBrcOptions;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_BCN_DTIM_OPTIONS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxBcnBrcOptionsGet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the power management option
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxBcnBrcOptionsGet (HwMboxConfig_T* pHwMboxConfig,
+                                        ACXBeaconAndBroadcastOptions_t* pWlanElm_BcnBrcOptions)
+{
+    ACXBeaconAndBroadcastOptions_t* pCfg = pWlanElm_BcnBrcOptions;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_BCN_DTIM_OPTIONS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* The STA does not support interrogate action for this Ie */
+    return NOK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemFeatureConfigSet()
+                                    ACXBeaconAndBroadcastOptions_t* pWlanElm_BcnBrcOptions,
+ ****************************************************************************
+ * DESCRIPTION: Configure the feature config info element
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int  whal_hwInfoElemFeatureConfigSet (HwMboxConfig_T* pHwMboxConfig,  UINT32 Options, UINT32 DataFlowOptions)
+{
+    ACXFeatureConfig_t  WlanElm_FeatureConfig;
+    ACXFeatureConfig_t  *pCfg = &WlanElm_FeatureConfig;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_FEATURE_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Set fields */
+    pCfg->Options = ENDIAN_HANDLE_LONG(Options);
+    pCfg->dataflowOptions = ENDIAN_HANDLE_LONG(DataFlowOptions);
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("whal_hwInfoElemFeatureConfigSet: ## Option=0x%x, DFOption=0x%x\n", Options, DataFlowOptions));
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAntennaDiversitySet ()
+ ****************************************************************************
+ * DESCRIPTION: Set antenna diversity parameters
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAntennaDiversitySet (HwMboxConfig_T* pHwMboxConfig, 
+                                     whalCtrl_antennaDiversityOptions_t* pAntennaDiversityOptions,
+                                     UINT32 antNum)
+{
+    AcxSetAntennaDiversityOptions_t ACXAntennaDiversityOptions;
+
+    WLAN_REPORT_INFORMATION( pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                             ("RX diversity enabled: %d TX diversity enabled:%d\n", 
+                              pAntennaDiversityOptions->enableRxDiversity,
+                              pAntennaDiversityOptions->enableTxDiversity) );
+    WLAN_REPORT_INFORMATION( pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                             ("Rx Antenna: %d TX antenna: %d\n",
+                              pAntennaDiversityOptions->rxSelectedAntenna,
+                              pAntennaDiversityOptions->txSelectedAntenna) );
+    WLAN_REPORT_INFORMATION( pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                             ("Share TX and RX antennas: %d\n",
+                              pAntennaDiversityOptions->rxTxSharedAnts) );
+    
+    /* Set information element header */
+    ACXAntennaDiversityOptions.EleHdr.id = ACX_ANTENNA_DIVERSITY_CFG;
+    ACXAntennaDiversityOptions.EleHdr.len = sizeof( AcxSetAntennaDiversityOptions_t ) - 
+                                                sizeof( EleHdrStruct );
+
+    /* Set information element fields */
+    ACXAntennaDiversityOptions.enableRxDiversity = pAntennaDiversityOptions->enableRxDiversity;
+    ACXAntennaDiversityOptions.rxSelectedAntenna = pAntennaDiversityOptions->rxSelectedAntenna;
+    ACXAntennaDiversityOptions.enableTxDiversity = pAntennaDiversityOptions->enableTxDiversity;
+    ACXAntennaDiversityOptions.txSelectedAntenna = pAntennaDiversityOptions->txSelectedAntenna;
+    ACXAntennaDiversityOptions.rxAntNum = antNum;
+    ACXAntennaDiversityOptions.txAntNum = antNum;
+    ACXAntennaDiversityOptions.rxTxSharedAnts = pAntennaDiversityOptions->rxTxSharedAnts;
+
+    /* Send the command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, 
+                                  &ACXAntennaDiversityOptions,
+                                  sizeof(AcxSetAntennaDiversityOptions_t));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemTxPowerSet ()
+ ****************************************************************************
+ * DESCRIPTION: Set the Tx power 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemTxPowerSet (HwMboxConfig_T* pHwMboxConfig, UINT8 *TxPowerDbm)
+{
+    dot11CurrentTxPowerStruct  dot11CurrentTxPower;
+    dot11CurrentTxPowerStruct  *pCfg = &dot11CurrentTxPower;
+    int rc;
+
+       WLAN_REPORT_INFORMATION( pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+               ("%s power = %d\n", __FUNCTION__, *TxPowerDbm));
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_CUR_TX_PWR;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    pCfg->dot11CurrentTxPower = *TxPowerDbm;
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxStatisiticsSet ()
+ ****************************************************************************
+ * DESCRIPTION: Set the ACX statistics counters to zero.
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxStatisiticsSet (HwMboxConfig_T* pHwMboxConfig)
+{
+    ACXStatistics_t  acx;
+    ACXStatistics_t  *pCfg = &acx;
+
+    /* Set information element header */
+    pCfg->EleHdr.id  = ACX_STATISTICS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the config command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxStatisiticsGet ()
+ ****************************************************************************
+ * DESCRIPTION: Get the ACX statistics that are required for basic measurement
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxStatisiticsGet (HwMboxConfig_T* pHwMboxConfig, acxStatisitcs_t *acxStatisitcs)
+{
+    ACXStatistics_t     acx;
+    ACXStatistics_t     *pCfg = &acx;
+    int rc = OK;
+
+    /* Set information element header */
+    pCfg->EleHdr.id  = ACX_STATISTICS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Not implemented */
+
+    /* Setting the output params */
+  #if 0
+    acxStatisitcs->FWpacketReceived = pCfg->isr.RxHeaders;
+  #endif
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxReadGwsiStatisiticsGet ()
+ ****************************************************************************
+ * DESCRIPTION: Get the ACX GWSI statistics 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxReadGwsiStatisiticsGet (HwMboxConfig_T * pHwMboxConfig, 
+                                              void * CB_Func, 
+                                              TI_HANDLE CB_handle, 
+                                              void * CB_Buf)
+{
+    ACXRoamingStatisticsTable_t acx;
+    ACXRoamingStatisticsTable_t * pCfg = &acx;
+
+    /* 
+     * Set information element header
+     */
+    pCfg->EleHdr.id  = ACX_ROAMING_STATISTICS_TBL;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* 
+     * Send the interrogation command
+     */
+    return CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), CB_Func, CB_handle, CB_Buf);
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxReadGwsiCountersGet ()
+ ****************************************************************************
+ * DESCRIPTION: Get the ACX GWSI counters 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxReadGwsiCountersGet (HwMboxConfig_T * pHwMboxConfig, 
+                                           void * CB_Func, 
+                                           TI_HANDLE CB_handle, 
+                                           void * CB_Buf)
+{
+    ACXErrorCounters_t acx;
+    ACXErrorCounters_t * pCfg = &acx;
+
+    /* 
+     * Set information element header
+     */
+    pCfg->EleHdr.id  = ACX_ERROR_CNT;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* 
+     * Send the interrogation command
+     */
+    return CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg), CB_Func, CB_handle, CB_Buf);
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemMediumOccupancyGet ()
+ ****************************************************************************
+ * DESCRIPTION: Get the Medium Occupancy.
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemMediumOccupancyGet (HwMboxConfig_T* pHwMboxConfig,
+                                       interogateCmdCBParams_t  mediumUsageCBParams)
+{
+    ACXMediumUsage_t    medium;
+    ACXMediumUsage_t    *pCfg = &medium;
+
+    /* Set information element header */
+    pCfg->EleHdr.id  = ACX_MEDIUM_USAGE;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command */
+    return CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg,
+                                          sizeof(*pCfg),
+                                          mediumUsageCBParams.CB_Func,
+                                          mediumUsageCBParams.CB_handle,
+                                          mediumUsageCBParams.CB_buf);
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemTfsDtimGet ()
+ ****************************************************************************
+ * DESCRIPTION: Get the Tsf and Dtim counter from Fw
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemTfsDtimGet (HwMboxConfig_T* pHwMboxConfig,
+                               interogateCmdCBParams_t  mediumUsageCBParams)
+{
+    ACX_fwTSFInformation_t    fwTsfDtimMib;
+    ACX_fwTSFInformation_t    *pCfg = &fwTsfDtimMib;
+    int sendOp = 0;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id  = ACX_TSF_INFO;
+    pCfg->EleHdr.len = sizeof(ACX_fwTSFInformation_t) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command*/
+    sendOp = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg,
+                                               sizeof(*pCfg), 
+                                               mediumUsageCBParams.CB_Func,
+                                               mediumUsageCBParams.CB_handle,
+                                               mediumUsageCBParams.CB_buf);
+    if (0 == sendOp)
+    {
+        WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("whal_hwInfoElemTfsDtimGet ACX_fwTSFInformation command sent with to FW wait for results\n"));
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("whal_hwInfoElemTfsDtimGet ACX_fwTSFInformation command not sent , FAILURE =%d\n" ,sendOp) );
+    }
+
+    return sendOp;
+}
+
+
+static int  whal_hwInfoElemStatisticsReadCB (HwMboxConfig_T* pHwMboxConfig,UINT16 MboxStatus, ACXStatistics_t* pElem);
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemStatisticsPrint ()
+ ****************************************************************************
+ * DESCRIPTION: Print the statistics from the input IE statistics
+ *
+ * INPUTS:
+ *          ACXStatisticsStruct* pElem  The Statistics information element
+ *                                      to be printed
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemStatisticsPrint (HwMboxConfig_T *pHwMboxConfig)
+{
+    int rc;
+
+    /* Set information element header */
+    pHwMboxConfig->pAcxStatistic.EleHdr.id  = ACX_STATISTICS;
+    pHwMboxConfig->pAcxStatistic.EleHdr.len = sizeof(pHwMboxConfig->pAcxStatistic) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command */
+    if ((rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, 
+                                             &pHwMboxConfig->pAcxStatistic, 
+                                             sizeof(pHwMboxConfig->pAcxStatistic),
+                                             (void *)whal_hwInfoElemStatisticsReadCB,
+                                             pHwMboxConfig,
+                                             &pHwMboxConfig->pAcxStatistic)) != OK)
+        return rc;
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemStatisticsReadCB ()
+ ****************************************************************************
+ * DESCRIPTION: Interrogate Statistics from the wlan hardware
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+static int whal_hwInfoElemStatisticsReadCB (HwMboxConfig_T* pHwMboxConfig, UINT16 MboxStatus, ACXStatistics_t* pElem)
+{
+    if (MboxStatus != OK)
+        return NOK;
+
+    /* Solve endian problem*/
+    /* Isr */
+    pElem->isr.ACXRxProcs       = ENDIAN_HANDLE_LONG(pElem->isr.ACXRxProcs);
+    pElem->isr.ACXTxProcs       = ENDIAN_HANDLE_LONG(pElem->isr.ACXTxProcs);
+    pElem->isr.Cmd_Cmplt        = ENDIAN_HANDLE_LONG(pElem->isr.Cmd_Cmplt);
+    pElem->isr.FIQs             = ENDIAN_HANDLE_LONG(pElem->isr.FIQs);
+    pElem->isr.RxHeaders        = ENDIAN_HANDLE_LONG(pElem->isr.RxHeaders);
+    pElem->isr.RxCompletes      = ENDIAN_HANDLE_LONG(pElem->isr.RxCompletes);
+    pElem->isr.RxMemOverflow    = ENDIAN_HANDLE_LONG(pElem->isr.RxMemOverflow);
+    pElem->isr.RxRdys           = ENDIAN_HANDLE_LONG(pElem->isr.RxRdys);
+    pElem->isr.IRQs             = ENDIAN_HANDLE_LONG(pElem->isr.IRQs);
+    pElem->isr.DecryptDone      = ENDIAN_HANDLE_LONG(pElem->isr.DecryptDone);
+    pElem->isr.DMA0Done         = ENDIAN_HANDLE_LONG(pElem->isr.DMA0Done);
+    pElem->isr.DMA1Done         = ENDIAN_HANDLE_LONG(pElem->isr.DMA1Done);
+    pElem->isr.ACXTxExchComplete= ENDIAN_HANDLE_LONG(pElem->isr.ACXTxExchComplete);
+    pElem->isr.ACXCommands      = ENDIAN_HANDLE_LONG(pElem->isr.ACXCommands);
+    pElem->isr.HwPMModeChanges  = ENDIAN_HANDLE_LONG(pElem->isr.HwPMModeChanges);
+    pElem->isr.HostAcknowledges = ENDIAN_HANDLE_LONG(pElem->isr.HostAcknowledges);
+    pElem->isr.PCI_PM           = ENDIAN_HANDLE_LONG(pElem->isr.PCI_PM);
+    pElem->isr.ACMWakeups       = ENDIAN_HANDLE_LONG(pElem->isr.ACMWakeups);
+
+    /* Rx */
+    pElem->rx.RxDroppedFrame    = ENDIAN_HANDLE_LONG(pElem->rx.RxDroppedFrame);
+    pElem->rx.RxFcsErr          = ENDIAN_HANDLE_LONG(pElem->rx.RxFcsErr);
+    pElem->rx.RxHdrOverflow     = ENDIAN_HANDLE_LONG(pElem->rx.RxHdrOverflow);
+    pElem->rx.RxHWStuck         = ENDIAN_HANDLE_LONG(pElem->rx.RxHWStuck);
+    pElem->rx.RxOutOfMem        = ENDIAN_HANDLE_LONG(pElem->rx.RxOutOfMem);
+    pElem->rx.RxXfrHintTrig     = ENDIAN_HANDLE_LONG(pElem->rx.RxXfrHintTrig);
+    pElem->rx.RxResetCounter    = ENDIAN_HANDLE_LONG(pElem->rx.RxResetCounter);
+
+    /* Tx */
+    pElem->tx.TxInternalDescOverflow = ENDIAN_HANDLE_LONG(pElem->tx.TxInternalDescOverflow);
+
+    /* Dma */
+    pElem->dma.RxDMARequested   = ENDIAN_HANDLE_LONG(pElem->dma.RxDMARequested);
+    pElem->dma.RxDMAErrors      = ENDIAN_HANDLE_LONG(pElem->dma.RxDMAErrors);
+    pElem->dma.TxDMARequested   = ENDIAN_HANDLE_LONG(pElem->dma.TxDMARequested);
+    pElem->dma.TxDMAErrors      = ENDIAN_HANDLE_LONG(pElem->dma.TxDMAErrors);
+
+    /* Wep */
+    pElem->wep.WepAddrKeyCount      = ENDIAN_HANDLE_LONG(pElem->wep.WepAddrKeyCount);
+    pElem->wep.WepDecryptFail       = ENDIAN_HANDLE_LONG(pElem->wep.WepDecryptFail);
+    pElem->wep.WepDefaultKeyCount   = ENDIAN_HANDLE_LONG(pElem->wep.WepDefaultKeyCount);
+    pElem->wep.WepKeyNotFound       = ENDIAN_HANDLE_LONG(pElem->wep.WepKeyNotFound);
+
+    /* PS */
+    pElem->pwr.PSEnterCnt           = ENDIAN_HANDLE_LONG(pElem->pwr.PSEnterCnt);
+    pElem->pwr.ELPEnterCnt          = ENDIAN_HANDLE_LONG(pElem->pwr.ELPEnterCnt);
+    pElem->pwr.MissingBcnsCnt       = ENDIAN_HANDLE_LONG(pElem->pwr.MissingBcnsCnt);
+    pElem->pwr.WakeOnHostCnt        = ENDIAN_HANDLE_LONG(pElem->pwr.WakeOnHostCnt);
+    pElem->pwr.WakeOnTimerExpCnt    = ENDIAN_HANDLE_LONG(pElem->pwr.WakeOnTimerExpCnt);
+    pElem->pwr.TxWithPSCnt          = ENDIAN_HANDLE_LONG(pElem->pwr.TxWithPSCnt);
+    pElem->pwr.TxWithoutPSCnt       = ENDIAN_HANDLE_LONG(pElem->pwr.TxWithoutPSCnt);
+    pElem->pwr.RcvdBeaconsCnt       = ENDIAN_HANDLE_LONG(pElem->pwr.RcvdBeaconsCnt);
+    pElem->pwr.PowerSaveOffCnt      = ENDIAN_HANDLE_LONG(pElem->pwr.PowerSaveOffCnt);
+    pElem->pwr.EnablePSCnt          = ENDIAN_HANDLE_LONG(pElem->pwr.EnablePSCnt);
+    pElem->pwr.DisablePSCnt         = ENDIAN_HANDLE_LONG(pElem->pwr.DisablePSCnt);
+    pElem->pwr.FixTsfPSCnt          = ENDIAN_HANDLE_LONG(pElem->pwr.FixTsfPSCnt);
+    pElem->pwr.ContMissBcnsSpread[0]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[0]);
+    pElem->pwr.ContMissBcnsSpread[1]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[1]);
+    pElem->pwr.ContMissBcnsSpread[2]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[2]);
+    pElem->pwr.ContMissBcnsSpread[3]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[3]);
+    pElem->pwr.ContMissBcnsSpread[4]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[4]);
+    pElem->pwr.ContMissBcnsSpread[5]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[5]);
+    pElem->pwr.ContMissBcnsSpread[6]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[6]);
+    pElem->pwr.ContMissBcnsSpread[7]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[7]);
+    pElem->pwr.ContMissBcnsSpread[8]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[8]);
+    pElem->pwr.ContMissBcnsSpread[9]= ENDIAN_HANDLE_LONG(pElem->pwr.ContMissBcnsSpread[9]);
+
+    pElem->ps.psPollTimeOuts        = ENDIAN_HANDLE_LONG(pElem->ps.psPollTimeOuts);
+    pElem->ps.upsdTimeOuts          = ENDIAN_HANDLE_LONG(pElem->ps.upsdTimeOuts);
+    pElem->ps.upsdMaxSPTime         = ENDIAN_HANDLE_LONG(pElem->ps.upsdMaxSPTime);
+    pElem->ps.upsdMaxAPturn         = ENDIAN_HANDLE_LONG(pElem->ps.upsdMaxAPturn); 
+    pElem->ps.psPollMaxAPturn       = ENDIAN_HANDLE_LONG(pElem->ps.psPollMaxAPturn);
+    pElem->ps.psPollUtilization     = ENDIAN_HANDLE_LONG(pElem->ps.psPollUtilization);
+    pElem->ps.upsdUtilization       = ENDIAN_HANDLE_LONG(pElem->ps.upsdUtilization);
+
+    /* Isr */
+    WLAN_OS_REPORT(("------  Isr statistics  -------------------\n"));
+    WLAN_OS_REPORT(("ACXRxProcs  = %8d\n", pElem->isr.ACXRxProcs));
+    WLAN_OS_REPORT(("RxHeaders   = %8d, RxCompletes       = %8d\n", pElem->isr.RxHeaders, pElem->isr.RxCompletes));
+    WLAN_OS_REPORT(("RxRdys      = %8d, RxMemOverflow     = %8d\n", pElem->isr.RxRdys, pElem->isr.RxMemOverflow));
+    WLAN_OS_REPORT(("ACXTxProcs  = %8d, ACXTxExchComplete = %8d\n", pElem->isr.ACXTxProcs, pElem->isr.ACXTxExchComplete));
+    WLAN_OS_REPORT(("DecryptDone       = %8d\n", pElem->isr.DecryptDone));
+    WLAN_OS_REPORT(("HwPMModeChanges   = %8d\n", pElem->isr.HwPMModeChanges));
+    WLAN_OS_REPORT(("HostAcknowledges  = %8d\n", pElem->isr.HostAcknowledges));
+    WLAN_OS_REPORT(("PCI_PM            = %8d\n", pElem->isr.PCI_PM));
+    WLAN_OS_REPORT(("ACMWakeups        = %8d\n", pElem->isr.ACMWakeups));
+    WLAN_OS_REPORT(("LowRSSI           = %8d\n", pElem->isr.LowRssi));
+    WLAN_OS_REPORT(("ACXCommands = %8d, Cmd_Cmplt= %8d\n", pElem->isr.ACXCommands, pElem->isr.Cmd_Cmplt));
+    WLAN_OS_REPORT(("DMA0Done    = %8d, DMA1Done = %8d\n", pElem->isr.DMA0Done, pElem->isr.DMA1Done));
+    WLAN_OS_REPORT(("IRQs = %8d, FIQs = %8d\n", pElem->isr.IRQs, pElem->isr.FIQs));
+
+    /* Rx */
+    WLAN_OS_REPORT(("------  Rx  statistics  -------------------\n"));
+    WLAN_OS_REPORT(("RxDroppedFrame    = %d\n", pElem->rx.RxDroppedFrame));
+    WLAN_OS_REPORT(("RxFcsErr      = %d\n", pElem->rx.RxFcsErr));
+    WLAN_OS_REPORT(("RxHdrOverflow     = %d\n", pElem->rx.RxHdrOverflow));
+    WLAN_OS_REPORT(("RxHWStuck         = %d\n", pElem->rx.RxHWStuck));
+    WLAN_OS_REPORT(("RxOutOfMem        = %d\n", pElem->rx.RxOutOfMem));
+    WLAN_OS_REPORT(("RxXfrHintTrig     = %d\n", pElem->rx.RxXfrHintTrig));
+    WLAN_OS_REPORT(("RxResetCounter    = %d\n", pElem->rx.RxResetCounter));
+
+    /* Tx */
+    WLAN_OS_REPORT(("------  Tx  statistics  -------------------\n"));
+    WLAN_OS_REPORT(("TxInDescOverflow  = %d\n", pElem->tx.TxInternalDescOverflow));
+
+    /* Dma */
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("------  Dma  statistics  -------------------\n"));
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("RxDMARequested  = %d\n", pElem->dma.RxDMARequested));
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("RxDMAErrors  = %d\n", pElem->dma.RxDMAErrors));
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("TxDMARequested  = %d\n", pElem->dma.TxDMARequested));
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("TxDMAErrors  = %d\n", pElem->dma.TxDMAErrors));
+
+    /* Wep */
+    WLAN_OS_REPORT(("------  Wep statistics  -------------------\n"));
+    WLAN_OS_REPORT(("WepDefaultKeyCount= %d\n", pElem->wep.WepDefaultKeyCount));
+    WLAN_OS_REPORT(("WepAddrKeyCount   = %d\n", pElem->wep.WepAddrKeyCount));
+    WLAN_OS_REPORT(("WepDecryptFail    = %d\n", pElem->wep.WepDecryptFail));
+    WLAN_OS_REPORT(("WepKeyNotFound    = %d\n", pElem->wep.WepKeyNotFound));
+
+    /* AES statistics */
+    WLAN_OS_REPORT(("------------  AES Statistics !!!!  ---------------\n"));
+    WLAN_OS_REPORT(("Aes Encryption Failure     = %8d, Aes Decryption Failure    = %8d\n", 
+                      pElem->aes.AesEncryptFail, pElem->aes.AesDecryptFail));
+
+    WLAN_OS_REPORT(("Aes Encrypted Packets      = %8d, Aes Decrypted Packets     = %8d\n", 
+               pElem->aes.AesEncryptPackets, pElem->aes.AesDecryptPackets));
+
+    WLAN_OS_REPORT(("Aes Encryption Interrupt   = %8d, Aes Decrryption Interrupt = %8d\n\n",
+              pElem->aes.AesEncryptInterrupt, pElem->aes.AesDecryptInterrupt));
+
+    /* events */
+    WLAN_OS_REPORT(("------  Events  -------------------\n"));
+    WLAN_OS_REPORT(("Heartbeat    = %d\n", pElem->event.heartbeat));
+
+    WLAN_OS_REPORT(("Calibration    = %d\n", pElem->event.calibration));
+    WLAN_OS_REPORT(("rxMismatch    = %d\n", pElem->event.rxMismatch));
+    WLAN_OS_REPORT(("rxMemEmpty    = %d\n", pElem->event.rxMemEmpty));
+    WLAN_OS_REPORT(("rxPool    = %d\n", pElem->event.rxPool));
+    WLAN_OS_REPORT(("oomLate  = %d\n", pElem->event.oomLate));
+    WLAN_OS_REPORT(("phyTransmitError    = %d\n", pElem->event.phyTransmitError));
+    WLAN_OS_REPORT(("txStuck    = %d\n", pElem->event.txStuck));
+
+    /* AES statistics */
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("------------  AES Statistics !!!!  ---------------\n"));
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("Aes Encryption Failure     = %8d, Aes Decryption Failure     = %8d\n", 
+                      pElem->aes.AesEncryptFail, pElem->aes.AesDecryptFail));
+
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("Aes Encrypted Packets      = %8d, Aes Decrypted Packets     = %8d\n", 
+               pElem->aes.AesEncryptPackets, pElem->aes.AesDecryptPackets));
+
+    WLAN_REPORT_REPLY(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  
+        ("Aes Encryption Interrupt   = %8d, Aes Decrryption Interrupt   = %8d\n", 
+              pElem->aes.AesEncryptInterrupt, pElem->aes.AesDecryptInterrupt));
+   /* PsPoll/Upsd */ 
+    WLAN_OS_REPORT(("----------- PsPoll / Upsd -----------\n"));
+    WLAN_OS_REPORT(("psPollTimeOuts     = %d\n",pElem->ps.psPollTimeOuts));
+    WLAN_OS_REPORT(("upsdTimeOuts       = %d\n",pElem->ps.upsdTimeOuts));
+    WLAN_OS_REPORT(("upsdMaxSPTime      = %d\n",pElem->ps.upsdMaxSPTime));
+    WLAN_OS_REPORT(("upsdMaxAPturn      = %d\n",pElem->ps.upsdMaxAPturn));
+    WLAN_OS_REPORT(("psPollMaxAPturn    = %d\n",pElem->ps.psPollMaxAPturn));
+    WLAN_OS_REPORT(("psPollUtilization  = %d\n",pElem->ps.psPollUtilization));
+    WLAN_OS_REPORT(("upsdUtilization    = %d\n",pElem->ps.upsdUtilization));
+
+    /* Power Save Counters */
+    WLAN_OS_REPORT(("------  Power management  ----------\n"));
+    WLAN_OS_REPORT(("PSEnterCnt    = %d\n", pElem->pwr.PSEnterCnt));
+    WLAN_OS_REPORT(("ELPEnterCnt    = %d\n", pElem->pwr.ELPEnterCnt));
+    if(pElem->pwr.RcvdBeaconsCnt != 0)
+    {
+        WLAN_OS_REPORT(("MissingBcnsCnt    = %d (percentage <= %d) \n", 
+                pElem->pwr.MissingBcnsCnt,
+                ((pElem->pwr.MissingBcnsCnt * 100) / (pElem->pwr.RcvdBeaconsCnt + pElem->pwr.MissingBcnsCnt)) ));
+    }
+    else
+    {
+        WLAN_OS_REPORT(("MissingBcnsCnt    = %d (percentage = 0) \n", pElem->pwr.MissingBcnsCnt));
+    }
+    WLAN_OS_REPORT(("WakeOnHostCnt    = %d\n", pElem->pwr.WakeOnHostCnt));
+    WLAN_OS_REPORT(("WakeOnTimerExpCnt    = %d\n", pElem->pwr.WakeOnTimerExpCnt));
+    WLAN_OS_REPORT(("TxWithPSCnt    = %d\n", pElem->pwr.TxWithPSCnt));
+    WLAN_OS_REPORT(("TxWithoutPSCnt    = %d\n", pElem->pwr.TxWithoutPSCnt));
+    WLAN_OS_REPORT(("RcvdBeaconsCnt    = %d\n", pElem->pwr.RcvdBeaconsCnt));
+    WLAN_OS_REPORT(("PowerSaveOffCnt    = %d\n", pElem->pwr.PowerSaveOffCnt));
+    WLAN_OS_REPORT(("EnablePS    = %d\n", pElem->pwr.EnablePSCnt));
+    WLAN_OS_REPORT(("DisablePS    = %d\n", pElem->pwr.DisablePSCnt));
+    WLAN_OS_REPORT(("FixTsfPSCnt    = %d\n\n", pElem->pwr.FixTsfPSCnt));
+    WLAN_OS_REPORT(("Single Missed Beacon           = %d\n", (pElem->pwr.ContMissBcnsSpread[0] & 0xFFFF)));
+    WLAN_OS_REPORT(("2 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[1] & 0xFFFF)));
+    WLAN_OS_REPORT(("3 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[2] & 0xFFFF)));
+    WLAN_OS_REPORT(("4 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[3] & 0xFFFF)));
+    WLAN_OS_REPORT(("5 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[4] & 0xFFFF)));
+    WLAN_OS_REPORT(("6 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[5] & 0xFFFF)));
+    WLAN_OS_REPORT(("7 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[6] & 0xFFFF)));
+    WLAN_OS_REPORT(("8 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[7] & 0xFFFF)));
+    WLAN_OS_REPORT(("9 Continuous Missed Beacons    = %d\n", (pElem->pwr.ContMissBcnsSpread[8] & 0xFFFF)));
+    WLAN_OS_REPORT((">=10 Continuous Missed Beacons = %d\n\n", (pElem->pwr.ContMissBcnsSpread[9] & 0xFFFF)));
+
+    WLAN_OS_REPORT(("RcvdAwakeBeaconsCnt    = %d\n", pElem->pwr.RcvdAwakeBeaconsCnt));
+    WLAN_OS_REPORT(("Single Missed Beacon        [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[0] >> 16)));
+    WLAN_OS_REPORT(("2 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[1] >> 16)));
+    WLAN_OS_REPORT(("3 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[2] >> 16)));
+    WLAN_OS_REPORT(("4 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[3] >> 16)));
+    WLAN_OS_REPORT(("5 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[4] >> 16)));
+    WLAN_OS_REPORT(("6 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[5] >> 16)));
+    WLAN_OS_REPORT(("7 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[6] >> 16)));
+    WLAN_OS_REPORT(("8 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[7] >> 16)));
+    WLAN_OS_REPORT(("9 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[8] >> 16)));
+    WLAN_OS_REPORT((">=10 Continuous Missed Beacons [Awake] = %d\n", (pElem->pwr.ContMissBcnsSpread[9] >> 16)));
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemFcsErrorCntGet ()
+ ****************************************************************************
+ * DESCRIPTION: Interrogate Fcs error counter from the ACX
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ *
+ * NOTE: This field (at the ACX) is automatically cleared when interrogated
+ ****************************************************************************/
+int whal_hwInfoElemFcsErrorCntGet (HwMboxConfig_T* pHwMboxConfig, UINT32* pFcsErrCnt)
+{
+    ACXFCSErrorCount_t  WlanElm_FcsError;
+    ACXFCSErrorCount_t  *pCfg = &WlanElm_FcsError;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = ACX_FCS_ERROR_CNT;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command*/
+
+    /* Not implemented */
+    {
+        /* Solve endian problem*/
+        /* *pFcsErrCnt = ENDIAN_HANDLE_LONG(pCfg->FCSErrorCount); */
+
+    }
+
+    return NOK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemMiscTableSet ()
+ ****************************************************************************
+ * DESCRIPTION: Interrogate Statistics from the wlan hardware
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemMiscTableSet
+(
+    HwMboxConfig_T *pHwMboxConfig, 
+    ACXMisc_t      *pCfg
+)
+{
+    int rc = OK;
+    ACXMisc_t  aCfg;
+
+    aCfg.EleHdr.id  = ACX_MISC_CFG;
+    aCfg.EleHdr.len = sizeof(ACXMisc_t) - sizeof(EleHdrStruct);
+
+    /* Solve endian problem */
+    aCfg.txActivityLed = ENDIAN_HANDLE_WORD(pCfg->txActivityLed);
+    aCfg.fwInitLed     = ENDIAN_HANDLE_WORD(pCfg->fwInitLed);
+    aCfg.diagnosticLed = ENDIAN_HANDLE_WORD(pCfg->diagnosticLed);
+
+    /* Send the interrogation command */
+    if ((rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, &aCfg, sizeof(aCfg))) != OK)
+    {
+    }
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemMiscTableGet ()
+ ****************************************************************************
+ * DESCRIPTION: Interrogate Statistics from the wlan hardware
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemMiscTableGet
+(
+    HwMboxConfig_T *pHwMboxConfig, 
+    ACXMisc_t      *pCfg,
+    void           *fCb,
+    TI_HANDLE       hCb
+)
+{
+    int rc = OK;
+
+    /* Set information element header */
+    pCfg->EleHdr.id  = ACX_MISC_CFG;
+    pCfg->EleHdr.len = sizeof(ACXMisc_t) - sizeof(EleHdrStruct);
+
+    /* Send the interrogation command */
+    if ((rc = CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(ACXMisc_t), fCb, hCb, pCfg)) != OK)
+    {
+    }
+
+    return rc;
+}
+
+
+#if 0
+/****************************************************************************
+ *                      whal_hwInfoElemTxTrafficCategorySet()
+ ****************************************************************************
+ * DESCRIPTION: Write the Traffic  configuration (For Quality Of Service)
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemTxTrafficCategorySet (HwMboxConfig_T* pHwMboxConfig, whaCtrl_acTrafficParams_t* pTconfParams)
+{
+    TrafficCategoryCfgType    TrafficCategoryCfg;
+    TrafficCategoryCfgType*   pCfg = &TrafficCategoryCfg;
+
+    os_memoryZero( pHwMboxConfig->hOs, (void *)pCfg, sizeof(*pCfg) );
+    
+    /*
+     * Set information element header
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_TID_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /*
+     * Set information element Data
+     * ==============================
+     */
+    pCfg->acId = pTconfParams->acId;
+    pCfg->aifsn = pTconfParams->aifsn;
+    pCfg->cwMax = pTconfParams->cwMax;
+    pCfg->cwMin = pTconfParams->cwMin;
+    pCfg->longRetryLimit = pTconfParams->longRetryLimit;
+    pCfg->shortRetryLimit = pTconfParams->shortRetryLimit;
+    pCfg->txopLimit = pTconfParams->txopLimit;
+    pCfg->rxTimeout = pTconfParams->rxTimeout;
+    pCfg->deliveryTriggerType = pTconfParams->PsParameters;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("whal_hwInfoElemTxTrafficCategory : \n"));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.acID= %d\n",pCfg->acId));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.aifsn= %d\n",pCfg->aifsn));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.cwMax= %d\n",pCfg->cwMax));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.cwMin= %d\n",pCfg->cwMin));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.longRetryLimit= %d\n",pCfg->longRetryLimit));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.shortRetryLimit= %d\n",pCfg->shortRetryLimit));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.rxTimeout= %d\n", pCfg->rxTimeout));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->cfg.edcfCfg.txopLimit= %d\n", pCfg->txopLimit));
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,  ("pCfg->deliveryTriggerType= %d\n", pCfg->deliveryTriggerType));
+
+    /*
+     * Send the configuration command
+     * ==============================
+     */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+#endif
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemQueueConfigurationSet()
+ ****************************************************************************
+ * DESCRIPTION: Write the Queue configuration (For Quality Of Service)
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemQueueConfigurationSet (HwMboxConfig_T* pHwMboxConfig,
+                                           queueTrafficParams_t* pQtrafficParams)
+{
+    ACXTIDConfig_t    TrafficCategoryCfg;
+    ACXTIDConfig_t *  pCfg = &TrafficCategoryCfg;
+
+    os_memoryZero (pHwMboxConfig->hOs, (void *)pCfg, sizeof(*pCfg));
+
+    /*
+     * Set information element header
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_TID_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /*
+     * Set information element Data
+     * ==============================
+     */
+    pCfg->queueID       = pQtrafficParams->queueID;
+    pCfg->channelType   = pQtrafficParams->channelType;
+    pCfg->tsid          = pQtrafficParams->tsid;
+    pCfg->psScheme      = pQtrafficParams->psScheme; 
+    pCfg->APSDConf[0]   = pQtrafficParams->APSDConf[0];
+    pCfg->APSDConf[1]   = pQtrafficParams->APSDConf[1];
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport,HAL_HW_CTRL_MODULE_LOG,
+        ("%s queueID = 0x%x, channelType = 0x%x, tsid = 0x%x, psScheme = 0x%x\n",
+            __FUNCTION__,pCfg->queueID,pCfg->channelType,pCfg->tsid,pCfg->psScheme));
+    
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport,HAL_HW_CTRL_MODULE_LOG,
+        ("APSDConf[0] = 0x%x, APSDConf[1] = 0x%x, len = 0x%x\n",
+            pCfg->APSDConf[0],pCfg->APSDConf[0],pCfg->EleHdr.len));
+
+    /*
+     * Send the configuration command
+     * ==============================
+     */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcParansConfigurationWrite()
+ ****************************************************************************
+ * DESCRIPTION: Write the AC configuration (For Quality Of Service)
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcParamsConfigurationSet (HwMboxConfig_T* pHwMboxConfig,
+                                              configureCmdCBParams_t *pConfigureCommand)
+{
+    ACXAcCfg_t     AcCfg;
+    ACXAcCfg_t    *pCfg  = &AcCfg;
+    acQosParams_t *pAcQosParams = (acQosParams_t*)(pConfigureCommand->CB_buf);
+
+    os_memoryZero (pHwMboxConfig->hOs, (void *)pCfg, sizeof(*pCfg));
+
+    /*
+     * Set information element header
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_AC_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /*
+     * Set information element Data
+     * ==============================
+     */
+
+    pCfg->ac        = pAcQosParams->ac;
+    pCfg->aifsn     = pAcQosParams->aifsn;
+    pCfg->cwMax     = ENDIAN_HANDLE_WORD(pAcQosParams->cwMax);
+    pCfg->cwMin     = pAcQosParams->cwMin;
+    pCfg->txopLimit = ENDIAN_HANDLE_WORD(pAcQosParams->txopLimit);
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport,HAL_HW_CTRL_MODULE_LOG,
+        ("whal_hwInfoElemAcParamsConfigurationWrite:\n ac = 0x%x, aifsn = 0x%x, cwMax = 0x%x, cwMin = 0x%x,txopLimit = 0x%x \n",
+        pCfg->ac,pCfg->aifsn,pCfg->cwMax,pCfg->cwMin,pCfg->txopLimit));
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport,HAL_HW_CTRL_MODULE_LOG,
+        ("whal_hwInfoElemAcParamsConfigurationWrite:\n ac = 0x%x, aifsn = 0x%x, cwMax = 0x%x, cwMin = 0x%x,txopLimit = 0x%x \n",
+        pCfg->ac,pCfg->aifsn,pCfg->cwMax,pCfg->cwMin,pCfg->txopLimit));
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcParansConfigurationGet()
+ ****************************************************************************
+ * DESCRIPTION: Write the AC configuration (For Quality Of Service)
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcParamsConfigurationGet (HwMboxConfig_T* pHwMboxConfig,
+                                             configureCmdCBParams_t *pConfigureCommand)
+{
+    ACXAcCfg_t  AcCfg;
+    ACXAcCfg_t *pCfg  = &AcCfg;
+    acQosParams_t *pAcQosParams = (acQosParams_t*)(pConfigureCommand->CB_buf);
+
+    os_memoryZero (pHwMboxConfig->hOs, (void *)pCfg, sizeof(*pCfg));
+
+    /*
+     * Set information element header
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_AC_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /*
+     * Set information element Data
+     * ==============================
+     */
+    pCfg->ac        = pAcQosParams->ac;
+    pCfg->aifsn     = pAcQosParams->aifsn;
+    pCfg->cwMax     = ENDIAN_HANDLE_WORD(pAcQosParams->cwMax);
+    pCfg->cwMin     = pAcQosParams->cwMin;
+    pCfg->txopLimit = ENDIAN_HANDLE_WORD(pAcQosParams->txopLimit);
+
+    return CmdQueue_CmdConfigureWithCb (pHwMboxConfig->hCmdMboxQueue, 
+                                        pCfg, 
+                                        sizeof(*pCfg),
+                                        pConfigureCommand->CB_Func,
+                                        pConfigureCommand->CB_handle);
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemTxQueueCfgSet()
+ ****************************************************************************
+ * DESCRIPTION: Write the Access category configuration (For Quality Of Service)
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemTxQueueCfgSet(HwMboxConfig_T* pHwMboxConfig,
+                                    acQueuesParams_t* pAcQueuesParams,
+                                 UINT32 numOfTxBlk)
+{
+    ACXTxQueueCfg_t    AccessCategory;
+    ACXTxQueueCfg_t *pCfg = &AccessCategory;
+    UINT16 HighblkRatio, LowBlkRatio;
+
+    /*
+     * Set information element header      
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_TX_QUEUE_CFG;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    /*
+     * Set information element Data
+     * ==============================
+     */
+    HighblkRatio = pAcQueuesParams->percentOfBlockHighThreshold;
+    LowBlkRatio  = pAcQueuesParams->percentOfBlockLowThreshold;
+
+    pCfg->qID = pAcQueuesParams->qId;
+    pCfg->numberOfBlockHighThreshold = ENDIAN_HANDLE_WORD((HighblkRatio * numOfTxBlk)/100);
+    pCfg->numberOfBlockLowThreshold  = ENDIAN_HANDLE_WORD((LowBlkRatio * numOfTxBlk)/100);
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, 
+                                  pCfg, 
+                                  sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemPacketDetectionThresholdSet()
+ ****************************************************************************
+ * DESCRIPTION:  Set the PacketDetection threshold
+ *
+ * INPUTS:  
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemPacketDetectionThresholdSet (HwMboxConfig_T* pHwMboxConfig, UINT32* pPdThreshold)
+{
+    ACXPacketDetection_t    PacketDetectionThresholdCfg;
+    ACXPacketDetection_t *pCfg = &PacketDetectionThresholdCfg;
+
+    /*
+     * Set information element header
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_PD_THRESHOLD;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    /*
+     * Set information element Data
+     * ==============================
+     */
+    pCfg->pdThreshold = ENDIAN_HANDLE_LONG(*pPdThreshold);
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: pdThreshold = 0x%x , len = 0x%x \n",__FUNCTION__,pCfg->pdThreshold,pCfg->EleHdr.len));
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemNoiseHistogramResultsGet()
+ ****************************************************************************
+ * DESCRIPTION: Get the Noise Histogram Measurement Results.
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemNoiseHistogramResultsGet (HwMboxConfig_T* pHwMboxConfig,
+                                             interogateCmdCBParams_t noiseHistCBParams)
+{
+    NoiseHistResult_t   results;
+    NoiseHistResult_t   *pCfg = &results;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id  = ACX_NOISE_HIST;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    return CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, 
+                                          pCfg, 
+                                          sizeof(*pCfg),
+                                          noiseHistCBParams.CB_Func,
+                                          noiseHistCBParams.CB_handle,
+                                          noiseHistCBParams.CB_buf);
+}
+
+/****************************************************************************
+*                      whal_hwInfoElemPowerLevelTableGet()
+****************************************************************************
+* DESCRIPTION: Get the Power level table from NVS.
+*
+* INPUTS:
+*
+* OUTPUT:  None
+*
+* RETURNS: OK or NOK
+****************************************************************************/
+int  whal_hwInfoElemPowerLevelTableGet          (HwMboxConfig_T *pHwMboxConfig, 
+                                                                                         interogateCmdCBParams_t powerLevelCBParams)
+{
+       PowerLevelTable_t   results;
+       PowerLevelTable_t   *pCfg = &results;
+
+       /* Set information element header*/
+       pCfg->EleHdr.id  = ACX_POWER_LEVEL_TABLE;
+       pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+       return CmdQueue_CmdInterrogateWithCb (pHwMboxConfig->hCmdMboxQueue, 
+               pCfg, 
+               sizeof(*pCfg), 
+               powerLevelCBParams.CB_Func,
+               powerLevelCBParams.CB_handle,
+               powerLevelCBParams.CB_buf);
+}                                                                      
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxBeaconFilterOptionsSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the beacon filtering option
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxBeaconFilterOptionsSet (HwMboxConfig_T* pHwMboxConfig,
+                                              ACXBeaconFilterOptions_t* pWlanElm_BeaconFilterOptions)
+{
+    int rc;
+    ACXBeaconFilterOptions_t* pCfg = pWlanElm_BeaconFilterOptions;
+    
+    if (NULL == pWlanElm_BeaconFilterOptions)
+    {
+        return NOK;
+    }
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_BEACON_FILTER_OPT;
+    pCfg->EleHdr.len = sizeof(ACXBeaconFilterOptions_t) - sizeof(EleHdrStruct);
+
+    /* Send the command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue,
+                                pCfg,
+                                sizeof(ACXBeaconFilterOptions_t));
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                     whal_hwInfoElemAcxBeaconFilterIETableSet
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the beacon filter IE table
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxBeaconFilterIETableSet (HwMboxConfig_T* pHwMboxConfig,
+                                              UINT8* numberOfIEs, 
+                                              UINT8* IETable,
+                                              UINT8* IETableSize)
+{
+    int rc = OK;
+    ACXBeaconFilterIETable_t beaconFilterIETableStruct;
+    ACXBeaconFilterIETable_t *pCfg = &beaconFilterIETableStruct;
+    
+    if (( NULL == IETable ) || ( NULL == pHwMboxConfig )) 
+    {
+        return PARAM_VALUE_NOT_VALID;
+    }
+
+    pCfg->EleHdr.id = ACX_BEACON_FILTER_TABLE;
+    pCfg->EleHdr.len = *IETableSize + 1; 
+    pCfg->NumberOfIEs = *numberOfIEs;
+        
+    os_memoryZero (pHwMboxConfig->hOs, (void *)pCfg->IETable, BEACON_FILTER_TABLE_MAX_SIZE);
+    os_memoryCopy (pHwMboxConfig->hOs, (void *)pCfg->IETable, (void *)IETable, *IETableSize);
+        
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(ACXBeaconFilterIETable_t));
+    
+    return rc;
+}
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxTxOptionsSet()
+ ****************************************************************************
+ * DESCRIPTION: Change the Event Vector Mask in the FW
+ * 
+ * INPUTS: MaskVector   The Updated Vector Mask
+ * 
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemEventMaskSet (HwMboxConfig_T* pHwMboxConfig, UINT32 MaskVector)
+{
+    int status;
+
+    ACXEventMboxMask_t EventMboxData;
+    ACXEventMboxMask_t *pCfg = &EventMboxData;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = ACX_EVENT_MBOX_MASK; 
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    pCfg->lowEventMask = MaskVector;
+    pCfg->highEventMask = 0xffffffff; /* Not in Use */
+
+    WLAN_REPORT_INFORMATION (pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG, ("whal_hwInfoElemEventMaskSet:\n"));
+
+    status = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+    
+    if (status != OK)
+    {
+        WLAN_REPORT_ERROR (pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+                          ("whal_hwInfoElemEventMaskSet: Error Configure Mask\n"));
+        return NOK;
+    }
+
+    return OK;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemCcaThresholdSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure Tx and Rx CCA detection
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemCcaThresholdSet (HwMboxConfig_T* pHwMboxConfig, UINT16* ccaThreshold, BOOL bTxEnergyDetection)
+{
+    int rc;
+    ACXEnergyDetection_t AcxElm_CcaThreshold;
+    ACXEnergyDetection_t *pCfg = &AcxElm_CcaThreshold;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_CCA_THRESHOLD;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    pCfg->rxCCAThreshold = ENDIAN_HANDLE_WORD(*ccaThreshold);
+    pCfg->txEnergyDetection = (Bool_e)bTxEnergyDetection;
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+    
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemDtimPeriodSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the Slot Time
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemDtimPeriodSet (HwMboxConfig_T* pHwMboxConfig, UINT8* dtimPeriod, UINT16*TBTT)
+{
+    int rc;
+    ACXDtimPeriodCfg_t AcxElm_DtimPeriod;
+    ACXDtimPeriodCfg_t *pCfg = &AcxElm_DtimPeriod;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_WR_TBTT_AND_DTIM;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    pCfg->dtimInterval = (*dtimPeriod);
+    pCfg->tbtt = ENDIAN_HANDLE_WORD(*TBTT);
+
+    /* Send the configuration command */
+    rc = CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+    
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemDtimPeriodGet()
+ ****************************************************************************
+ * DESCRIPTION: Configure/Interrogate the Slot Time
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemDtimPeriodGet (HwMboxConfig_T* pHwMboxConfig, UINT8* dtimPeriod, UINT16*TBTT)
+{
+    int rc = OK;
+    ACXDtimPeriodCfg_t AcxElm_DtimPeriod;
+    ACXDtimPeriodCfg_t *pCfg = &AcxElm_DtimPeriod;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_WR_TBTT_AND_DTIM;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    /* Not implemented */   
+  #if 0
+            *dtimPeriod = pCfg->dtimInterval;
+  #endif
+    
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxLowSNRThresholdSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the RSSI threshold parameters
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxLowSNRThresholdSet (HwMboxConfig_T* pHwMboxConfig,
+                                          ACXLowSNRTriggerParameters_t* AcxElm_LowThresholdOptions)
+{
+    /* Set information element header */
+    AcxElm_LowThresholdOptions->EleHdr.id = ACX_LOW_SNR;
+    AcxElm_LowThresholdOptions->EleHdr.len = sizeof(*AcxElm_LowThresholdOptions) - sizeof(EleHdrStruct);
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, AcxElm_LowThresholdOptions, sizeof(*AcxElm_LowThresholdOptions));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxLowRSSIThresholdSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the RSSI threshold parameters
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxLowRSSIThresholdSet (HwMboxConfig_T* pHwMboxConfig,
+                                           ACXLowRSSITriggerParameters_t* pWlanElm_LowRSSIThresholdOptions)
+{
+    ACXLowRSSITriggerParameters_t AcxElm_LowRSSIThresholdOptions;
+    ACXLowRSSITriggerParameters_t* pCfg = &AcxElm_LowRSSIThresholdOptions;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_LOW_RSSI;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    pCfg->rssiFilterDepth   = pWlanElm_LowRSSIThresholdOptions->rssiFilterDepth;
+    pCfg->rssiFilterWeight = pWlanElm_LowRSSIThresholdOptions->rssiFilterWeight;
+    pCfg->rssiThreshold = pWlanElm_LowRSSIThresholdOptions->rssiThreshold;
+    pCfg->LowRSSIEventType  = pWlanElm_LowRSSIThresholdOptions->LowRSSIEventType;
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxSetMaxTxRetrySet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the Max Tx Retry parameters
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxSetMaxTxRetrySet (HwMboxConfig_T* pHwMboxConfig,
+                                        ACXConsTxFailureTriggerParameters_t* pWlanElm_SetMaxTxRetry)
+{
+    ACXConsTxFailureTriggerParameters_t AcxElm_SetMaxTxRetry;
+    ACXConsTxFailureTriggerParameters_t* pCfg = &AcxElm_SetMaxTxRetry;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_CONS_TX_FAILURE;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    pCfg->maxTxRetry = pWlanElm_SetMaxTxRetry->maxTxRetry;
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxBssLossTsfThresholdSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the Bss Lost Timeout & TSF miss threshold
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxBssLossTsfThresholdSet (HwMboxConfig_T* pHwMboxConfig,                                            
+                                              AcxConnectionMonitorOptions* pWlanElm_BssLossTsfSynchronize)
+{
+    AcxConnectionMonitorOptions AcxElm_SetBssLossTsfThreshold;
+    AcxConnectionMonitorOptions* pCfg = &AcxElm_SetBssLossTsfThreshold;
+
+    /* Set information element header */
+    pCfg->EleHdr.id     = ACX_CONN_MONIT_PARAMS;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    pCfg->BSSLossTimeout        = pWlanElm_BssLossTsfSynchronize->BSSLossTimeout;
+    pCfg->TSFMissedThreshold    = pWlanElm_BssLossTsfSynchronize->TSFMissedThreshold;
+
+    /* Send the configuration command */
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemAcxGetAverageRSSIGet()
+ ****************************************************************************
+ * DESCRIPTION: Configure the Max Tx Retry parameters
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemAcxGetAverageRSSIGet (HwMboxConfig_T* pHwMboxConfig, INT8* averageRSSI)
+{
+    int rc = OK;
+    ACXAvaregeRSSI_t AcxElm_GetAverageRSSI;
+    ACXAvaregeRSSI_t* pCfg = &AcxElm_GetAverageRSSI;
+
+    /* Set information element header */
+    pCfg->EleHdr.id = ACX_AVERAGE_RSSI ;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    
+    /* Not implemented */
+  #if 0     
+    *averageRSSI = pCfg->avaregeRSSI;
+  #endif
+
+    return rc;
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemTxRatePolicyConfigurationSet()
+ ****************************************************************************
+ * DESCRIPTION: Write the TxRateClass configuration 
+ *
+ * INPUTS:
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemTxRatePolicyConfigurationSet (HwMboxConfig_T* pHwMboxConfig,
+                                         txRatePolicy_t *pTxRatePolicy)
+{
+    ACXTxAttrClasses_t  TxClassCfg;
+    ACXTxAttrClasses_t *pCfg  = &TxClassCfg;
+    UINT8 PolicyId;
+    
+    os_memoryZero (pHwMboxConfig->hOs, (void *)pCfg, sizeof(*pCfg));
+
+    /*
+     * Set information element header
+     * ==============================
+     */
+    pCfg->EleHdr.id = ACX_RATE_POLICY;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    pCfg->numOfClasses = pTxRatePolicy->numOfRateClasses;
+
+    for (PolicyId = 0; PolicyId < pTxRatePolicy->numOfRateClasses; PolicyId++)
+    {
+        os_memoryCopy (pHwMboxConfig->hOs,
+                       (void *)&(pCfg->rateClasses[PolicyId]),
+                       (void *)&(pTxRatePolicy->rateClass[PolicyId]),
+                       sizeof(txRateClass_t));
+    }
+    
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemRtsThresholdSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure The RTS threshold
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemRtsThresholdSet (HwMboxConfig_T* pHwMboxConfig,
+                                    UINT16 RtsThreshold)
+{
+    dot11RTSThreshold_t AcxElm_RtsThreshold;
+    dot11RTSThreshold_t *pCfg = &AcxElm_RtsThreshold;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_RTS_THRESHOLD;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    pCfg->RTSThreshold = RtsThreshold;
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemCtsToSelfSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure The Cts to self feature
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemCtsToSelfSet (HwMboxConfig_T* pHwMboxConfig, UINT8 CtsToSelf)
+{
+    ACXCtsProtection_t AcxElm_CtsToSelf;
+    ACXCtsProtection_t *pCfg = &AcxElm_CtsToSelf;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = ACX_CTS_PROTECTION;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    pCfg->ctsProtectMode = CtsToSelf;
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemRxMsduLifeTimeSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure The Cts to self feature
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemRxMsduLifeTimeSet (HwMboxConfig_T* pHwMboxConfig, UINT32 RxMsduLifeTime)
+{
+    dot11RxMsduLifeTime_t   AcxElm_RxMsduLifeTime;
+    dot11RxMsduLifeTime_t *pCfg = &AcxElm_RxMsduLifeTime;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = DOT11_RX_MSDU_LIFE_TIME;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+    pCfg->RxMsduLifeTime = RxMsduLifeTime;
+
+    WLAN_REPORT_INFORMATION(pHwMboxConfig->hReport, HAL_HW_CTRL_MODULE_LOG,
+        ("%s: RxMsduLifeTime = 0x%x, len = 0x%x\n",__FUNCTION__,pCfg->RxMsduLifeTime,pCfg->EleHdr.len));
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+
+/****************************************************************************
+ *                      whal_hwInfoElemRxTimeOutSet()
+ ****************************************************************************
+ * DESCRIPTION: Configure The Rx Time Out
+ *
+ * INPUTS:  None
+ *
+ * OUTPUT:  None
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemRxTimeOutSet (HwMboxConfig_T* pHwMboxConfig, rxTimeOut_t* pRxTimeOut)                            
+{
+    ACXRxTimeout_t AcxElm_rxTimeOut;
+    ACXRxTimeout_t *pCfg = &AcxElm_rxTimeOut;
+
+    /* Set information element header*/
+    pCfg->EleHdr.id = ACX_SERVICE_PERIOD_TIMEOUT;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    pCfg->PsPollTimeout = pRxTimeOut->psPoll;
+    pCfg->UpsdTimeout   = pRxTimeOut->UPSD;
+
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
+
+/****************************************************************************
+ *                      whal_hwInfoElemWiFiWmmPSWASet()
+ ****************************************************************************
+ * DESCRIPTION: Configure The PS for WMM
+ *
+ * INPUTS:   TRUE  - Configure PS to work on WMM mode - do not send the NULL/PS_POLL 
+ *                   packets even if TIM is set.
+ *           FALSE - Configure PS to work on Non-WMM mode - work according to the 
+ *                   standard
+ *
+ * RETURNS: OK or NOK
+ ****************************************************************************/
+int whal_hwInfoElemWiFiWmmPSWASet (HwMboxConfig_T* pHwMboxConfig, BOOL enableWA)
+{
+    IEConfigPsWmm_t  ConfigPsWmm;
+    IEConfigPsWmm_t *pCfg = &ConfigPsWmm;
+
+    /*
+     * Set information element header
+     */
+    pCfg->EleHdr.id = ACX_CONFIG_PS_WMM;
+    pCfg->EleHdr.len = sizeof(*pCfg) - sizeof(EleHdrStruct);
+
+    pCfg->ConfigPsOnWmmMode = enableWA;
+
+    /* Report the meesage only if we are using the WiFi patch */
+    if (enableWA)
+    {
+        WLAN_OS_REPORT(("%s PS is on WMM mode\n",__FUNCTION__));
+    }
+    
+    return CmdQueue_CmdConfigure (pHwMboxConfig->hCmdMboxQueue, pCfg, sizeof(*pCfg));
+}
diff --git a/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxConfig.h b/sta_dk_4_0_4_32/common/src/hal/hw_ctrl/whalHwMboxConfig.h
new file mode 100644 (file)
index 0000000..45836f4
--- /dev/null
@@ -0,0 +1,177 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalHwMboxConfig.h
+ *   PURPOSE: wlan hardware configuration information elements
+ * 
+ ****************************************************************************/
+
+#ifndef _WHAl_HW_MBOX_CONFIG_H
+#define _WHAl_HW_MBOX_CONFIG_H
+
+#include "whalCommon.h"
+#include "whalHwDefs.h"
+#include "whalCtrl_api.h"
+
+
+#define MAX_CONFIG_TX_QUEUES 5
+#define MAX_CONFIG_RX_QUEUES 5
+
+
+typedef struct
+{
+       UINT32 HwQueueAddr;
+       UINT8  HwQueueAttr;
+} QueueParams_T;
+
+
+typedef struct
+{
+       UINT32 BaseAddr;
+       UINT32 TxQueuesAddr;
+       UINT32 TxQueuesSize;
+       UINT32 RxQueuesAddr;
+       UINT32 RxQueuesSize;
+       UINT32 QindicatorAddr;
+       UINT32 QindicatorSize;
+       UINT32 NumTxQueues;
+       UINT32 NumRxQueues;
+       QueueParams_T TxQueuesParams[MAX_CONFIG_TX_QUEUES];
+       QueueParams_T RxQueuesParams[MAX_CONFIG_RX_QUEUES];
+} MemQueueParams_T;
+
+
+typedef struct _HwMboxConfig_T
+{
+    TI_HANDLE           hCmdMboxQueue;
+    TI_HANDLE           hOs;
+    TI_HANDLE           hReport;
+    ACXStatistics_t     pAcxStatistic;
+    MemoryMap_t         MemMap;
+} HwMboxConfig_T;
+
+
+HwMboxConfig_T* whal_hwMboxConfig_Create (TI_HANDLE hOs);
+int  whal_hwMboxConfig_Destroy               (HwMboxConfig_T *pHwMboxConfig);
+int  whal_hwMboxConfig_Config                (HwMboxConfig_T *pHwMboxConfig, TI_HANDLE hCmdMboxQueue, TI_HANDLE hReport);
+int  whal_hwInfoElemMemoryMapSet             (HwMboxConfig_T *pHwMboxConfig, MemoryMap_t *apMap);
+int  whal_hwInfoElemMemoryMapGet             (HwMboxConfig_T *pHwMboxConfig, MemoryMap_t *apMap, void *fCb, TI_HANDLE hCb);
+void whal_hwInfoElemMemoryMapPrint           (HwMboxConfig_T *pHwMboxConfig);
+int  whal_hwInfoElemRxConfigSet              (HwMboxConfig_T *pHwMboxConfig, UINT32* apRxConfigOption, UINT32* apRxFilterOption);
+int whal_hwInfoElemBETSet(HwMboxConfig_T* pHwMboxConfig, UINT8 Enable, UINT8 MaximumConsecutiveET);
+int  whal_hwInfoElemSetRxDataFiltersParams   (HwMboxConfig_T *pHwMboxConfig, BOOL enabled, filter_e defaultAction);
+int  whal_hwInfoElemSetRxDataFilter          (HwMboxConfig_T *pHwMboxConfig, UINT8 index, UINT8 command, filter_e action, UINT8 numFieldPatterns, UINT8 lenFieldPatterns, UINT8 * fieldPatterns);
+int  whal_hwInfoElemGetRxDataFiltersStatistics(HwMboxConfig_T * pHwMboxConfig, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int  whal_hwInfoElemStationIdSet             (HwMboxConfig_T *pHwMboxConfig, UINT8* apStationId);
+int  whal_hwInfoElemStationIdGet             (HwMboxConfig_T *pHwMboxConfig, void *fCb, TI_HANDLE hCb, void *pCb);
+int  whal_hwInfoElemConfigOptionsRead        (HwMboxConfig_T *pHwMboxConfig, void* pElm);
+int  whal_hwInfoElemAcxRevisionGet           (HwMboxConfig_T *pHwMboxConfig, void *fCb, TI_HANDLE hCb, void *pCb);
+int  whal_hwInfoElemWepDefaultKeyIdSet       (HwMboxConfig_T *pHwMboxConfig, UINT8* apKeyVal, void *CB_Func, TI_HANDLE CB_handle);
+int  whal_hwInfoElemWepDefaultKeyIdGet       (HwMboxConfig_T *pHwMboxConfig, UINT8* apKeyVal, void *CB_Func, TI_HANDLE CB_handle);
+int  whal_hwInfoElemStatisticsPrint          (HwMboxConfig_T *pHwMboxConfig);
+int  whal_hwInfoElemFcsErrorCntGet           (HwMboxConfig_T *pHwMboxConfig, UINT32* pFcsErrCnt);
+int  whal_hwInfoElemAcxPMConfigSet           (HwMboxConfig_T *pHwMboxConfig, ACXConfigPM_t* pWlanElm_PowerMgmtOptions);                                     
+int  whal_hwInfoElemAcxSleepAuthoSet         (HwMboxConfig_T *pHwMboxConfig, ACXSleepAuth_t* pWlanElm_SleepAutho);                                     
+int  whal_hwInfoElemAcxwakeUpConditionSet    (HwMboxConfig_T *pHwMboxConfig, WakeUpCondition_t* pWlanElm_wakeUpCondition);                                   
+int  whal_hwInfoElemFeatureConfigSet         (HwMboxConfig_T *pHwMboxConfig, UINT32 Options, UINT32 DataFlowOptions);
+int  whal_hwInfoElemAcxBeaconFilterOptionsSet(HwMboxConfig_T *pHwMboxConfig, ACXBeaconFilterOptions_t* pWlanElm_BeaconFilterOptions);                                          
+int  whal_hwInfoElemAcxBeaconFilterIETableSet(HwMboxConfig_T *pHwMboxConfig, UINT8* numberOfIEs, UINT8* IETable, UINT8* IETableSize);
+int  whal_hwInfoElemarpIpAddressesTableSet   (HwMboxConfig_T *pHwMboxConfig, IpAddress_t *IP_addr, UINT32 isFilteringEnabled); 
+int  whal_hwInfoElemGroupAdressesTableSet    (HwMboxConfig_T *pHwMboxConfig, UINT8* numGroupAddrs, macAddress_t *Group_addr, UINT8* isEnabled);
+int  whal_hwInfoElemAidSet                   (HwMboxConfig_T *pHwMboxConfig, UINT16* apAidVal);
+int  whal_hwInfoElemTxPowerSet                          (HwMboxConfig_T *pHwMboxConfig, UINT8 *TxPowerDbm);
+int  whal_hwInfoElemNoiseHistogramResultsGet (HwMboxConfig_T *pHwMboxConfig, interogateCmdCBParams_t noiseHistCBParams);
+int  whal_hwInfoElemPowerLevelTableGet          (HwMboxConfig_T *pHwMboxConfig, interogateCmdCBParams_t powerLevelCBParams);
+int  whal_hwInfoElemStationIdForRecoveryGet  (HwMboxConfig_T *pHwMboxConfig, void *CB_Func,TI_HANDLE CB_handle, dot11StationIDStruct *CB_Buf);
+int  whal_hwInfoElemSoftGeminiEnableSet      (HwMboxConfig_T *pHwMboxConfig, SoftGeminiEnableModes_e SoftGeminiEnableModes);
+int  whal_hwInfoElemSoftGeminiParamsSet      (HwMboxConfig_T *pHwMboxConfig, SoftGeminiParam_t *SoftGeminiParam);
+int  whal_hwInfoElemSoftGeminiParamsGet      (HwMboxConfig_T *pHwMboxConfig, void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf);
+int  whal_hwInfoElemAcxLowSNRThresholdSet    (HwMboxConfig_T *pHwMboxConfig, ACXLowSNRTriggerParameters_t* AcxElm_LowThresholdOptions);
+int  whal_hwInfoElemAcxLowRSSIThresholdSet   (HwMboxConfig_T *pHwMboxConfig, ACXLowRSSITriggerParameters_t* pWlanElm_LowRSSIThresholdOptions);
+int  whal_hwInfoElemAcxGetAverageRSSIGet     (HwMboxConfig_T *pHwMboxConfig, INT8* averageRSSI);
+int  whal_hwInfoElemAcxBssLossTsfThresholdSet(HwMboxConfig_T *pHwMboxConfig, AcxConnectionMonitorOptions* pWlanElm_BssLossTsfSynchronize);
+int  whal_hwInfoElemMiscTableSet             (HwMboxConfig_T *pHwMboxConfig, ACXMisc_t *pCfg);
+int  whal_hwInfoElemMiscTableGet             (HwMboxConfig_T *pHwMboxConfig, ACXMisc_t *pCfg, void *fCb, TI_HANDLE hCb);
+int  whal_hwInfoElemConfigMemorySet          (HwMboxConfig_T *pHwMboxConfig, DmaParams_T *pDmaParams);
+int  whal_hwInfoElemQueueHeadGet             (HwMboxConfig_T *pHwMboxConfig, int NumTxQueues, int pElem, void *fCb, TI_HANDLE hCb);
+int  whal_hwInfoElemSlotTimeSet              (HwMboxConfig_T *pHwMboxConfig, UINT8* apSlotTime);
+int  whal_hwInfoElemPreambleSet              (HwMboxConfig_T *pHwMboxConfig, UINT8* apPreamble);
+int  whal_hwInfoElemGeneratedFrameRateSet    (HwMboxConfig_T *pHwMboxConfig, UINT8* txCtrlFrmRate, UINT8* txCtrlFrmMod, UINT8* txMgmtFrmRate, UINT8* txMgmtFrmMod);
+int  whal_hwInfoElemAntennaDiversitySet      (HwMboxConfig_T *pHwMboxConfig, whalCtrl_antennaDiversityOptions_t* pAntennaDiversityOptions, UINT32 antNum );
+int  whal_hwInfoElemAcxStatisiticsGet        (HwMboxConfig_T *pHwMboxConfig, acxStatisitcs_t *acxStatisitcs);
+int  whal_hwInfoElemAcxReadGwsiStatisiticsGet(HwMboxConfig_T *pHwMboxConfig, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int  whal_hwInfoElemAcxReadGwsiCountersGet   (HwMboxConfig_T *pHwMboxConfig, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+int  whal_hwInfoElemAcxStatisiticsSet        (HwMboxConfig_T *pHwMboxConfig);
+int  whal_hwInfoElemMediumOccupancyGet       (HwMboxConfig_T *pHwMboxConfig, interogateCmdCBParams_t  interogateCmdCBParams);
+int  whal_hwInfoElemTfsDtimGet               (HwMboxConfig_T *pHwMboxConfig, interogateCmdCBParams_t  interogateCmdCBParams);
+int  whal_hwInfoElemEventMaskSet             (HwMboxConfig_T *pHwMboxConfig, UINT32 MaskVector);
+int  whal_hwInfoElemPacketDetectionThresholdSet
+                                             (HwMboxConfig_T *pHwMboxConfig, UINT32* pPdThreshold);
+int  whal_hwInfoElemCcaThresholdSet          (HwMboxConfig_T *pHwMboxConfig, UINT16* ccaThreshold, BOOL bTxEnergyDetection);
+int  whal_hwInfoElemDtimPeriodSet            (HwMboxConfig_T *pHwMboxConfig, UINT8* dtimPeriod, UINT16*TBTT);
+int  whal_hwInfoElemDtimPeriodGet            (HwMboxConfig_T *pHwMboxConfig, UINT8* dtimPeriod, UINT16*TBTT);
+int  whal_hwInfoElemTxRatePolicyConfigurationSet
+                                             (HwMboxConfig_T *pHwMboxConfig, txRatePolicy_t *pTxRatePolicy);                                        
+int  whal_hwInfoElemACIConfigurationSet      (HwMboxConfig_T *pHwMboxConfig, UINT8 ACIMode, UINT8 inputCCA, UINT8 qualifiedCCA, UINT8 stompForRx, UINT8 stompForTx, UINT8 txCCA);
+int  whal_hwInfoElemRSSIGet                  (HwMboxConfig_T *pHwMboxConfig, void *CB_Func, TI_HANDLE CB_handle, PUINT8 CB_Buf);
+int  whal_hwInfoElemTxConfigOptionsSet       (HwMboxConfig_T *pHwMboxConfig, UINT8 txCompleteThreshold, UINT16 txCompleteTimeout);
+int  whal_hwInfoElemRtsThresholdSet          (HwMboxConfig_T *pHwMboxConfig, UINT16 RtsThreshold);
+int  whal_hwInfoElemCtsToSelfSet             (HwMboxConfig_T *pHwMboxConfig, UINT8 CtsToSelf);
+int  whal_hwInfoElemAcxBcnBrcOptionsSet      (HwMboxConfig_T *pHwMboxConfig, ACXBeaconAndBroadcastOptions_t* pWlanElm_BcnBrcOptions);
+int  whal_hwInfoElemAcxBcnBrcOptionsGet      (HwMboxConfig_T *pHwMboxConfig, ACXBeaconAndBroadcastOptions_t* pWlanElm_BcnBrcOptions);
+int  whal_hwInfoElemWiFiWmmPSWASet           (HwMboxConfig_T *pHwMboxConfig, BOOL enableWA);
+
+
+int whalCtrl_getConsumptionStatistics        (HwMboxConfig_T * pHwMboxConfig, void * CB_Func, TI_HANDLE CB_handle, void * CB_Buf);
+
+
+/*
+ *     Data Path Configure API
+ */
+int  whal_hwInfoElemDataPathParamsSet        (HwMboxConfig_T *pHwMboxConfig, UINT16 rxPacketRingChunkSize, UINT16 txPacketRingChunkSize, UINT8 rxPacketRingChunkNum, UINT8 txPacketRingChunkNum, UINT8 txCompleteThreshold, UINT8 txCompleteRingDepth,UINT32 txCompleteTimeOut);
+int  whal_hwInfoElemDataPathParamsGet        (HwMboxConfig_T *pHwMboxConfig, ACXDataPathParamsResp_t* apDataPathParams, void *fCb, TI_HANDLE hCb);
+int  whal_hwInfoElemQueueConfigurationSet    (HwMboxConfig_T *pHwMboxConfig, queueTrafficParams_t *pQtrafficParams);
+int  whal_hwInfoElemAcParamsConfigurationSet (HwMboxConfig_T *pHwMboxConfig, configureCmdCBParams_t *pConfigureCommand);
+int  whal_hwInfoElemAcParamsConfigurationGet (HwMboxConfig_T *pHwMboxConfig, configureCmdCBParams_t *pConfigureCommand);
+int  whal_hwInfoElemAcxSetMaxTxRetrySet      (HwMboxConfig_T *pHwMboxConfig, ACXConsTxFailureTriggerParameters_t* pWlanElm_SetMaxTxRetry);
+int  whal_hwInfoElemTxQueueCfgSet            (HwMboxConfig_T *pHwMboxConfig, acQueuesParams_t* pAcQueuesParams, UINT32 numOfTxBlk);
+int  whal_hwInfoElemRxTimeOutSet             (HwMboxConfig_T *pHwMboxConfig, rxTimeOut_t* pRxTimeOut);
+int  whal_hwInfoElemRxMsduLifeTimeSet        (HwMboxConfig_T *pHwMboxConfig, UINT32 RxMsduLifeTime);
+                         
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/inc/release.h b/sta_dk_4_0_4_32/common/src/hal/inc/release.h
new file mode 100644 (file)
index 0000000..66339ca
--- /dev/null
@@ -0,0 +1,318 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**                                                                                                             
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/   
+                                                                                                             
+/**************************************************************************/                                                                                                             
+/*                                                                        */                                                                                                             
+/*   MODULE:  release.h                                                   */                                                                                                             
+/*   PURPOSE: release specific definitions file.                          */                                                                                                             
+/*                                                                        */                                                                                                             
+/**************************************************************************/                                                                                                             
+                                                                                                             
+                                                                                                             
+#ifndef _HAL_RELEASE_H_                                                                                                             
+#define _HAL_RELEASE_H_                                                                                                             
+                                                                                                             
+#define SW_VERSION_MAJOR       1
+#define SW_VERSION_MINOR       0
+#define SW_VERSION_PATCH       0
+#define SW_VERSION_BUILD       5
+                                                                                                    
+#define SW_VERSION_STR "1.0.0.5"
+                                                                                                    
+#define SW_RELEASE_MONTH       11
+#define SW_RELEASE_DAY         16
+#define SW_RELEASE_YEAR                2004
+
+
+#if 0
+/*
+----------------------------------------------------------------------------
+Hal Rev 1.0.0.5
+       - Optimization, Save bus access transactions on slave mode
+               - HwIntr, Trigger by writing trigger register and not by read/modify/write
+               - SetMpduInfo, Write Ctl/Ctl2 once, Clear OWN here 
+               - SetMpduInfo, Use local descriptor and prepare for SDIO
+               - TxQueue, don't check OWN in allocation
+               - TxBufs, Save access to block header, use exsiting value from CheckSize
+       - Fix Linux compilation problems
+       - Fix eepromless problems
+       - Don't use Self clearing on eeprom burst read
+
+Hal Rev 1.0.0.4
+       - Change Trace Buffer Defaults to send UDP trace and Print UDP trace on TSDT,
+         On every FW trace .
+       - Add Build\whal.dsp project file
+       - Fix access to SCR_PAD5 (only from BusAccess)
+       - Fix sending list of MSDU issue on USB
+
+Hal Rev 1.0.0.3 
+    - Set default channel according to Radio Band and reg domain, The firmware
+         is not handle enableTx on channel 0 anymore
+       - Merge from WSP7.2 HAL to get same baseline
+               - Add CMD_DEBUG_TRACE command to dynamically stop trace report 
+               - Add new health report bit for sequece number error - handle for now ASSERT(0)
+               - Add STAT_MSDU_DROP tx status
+               - Change USB Rx/Tx descriptors definition
+
+Hal Rev 1.0.0.2 
+    - Move Hal API h-files from common/src/inc into hal/Export_Inc
+
+Hal Rev 1.0.0.1 
+    - First release after moving the wlan-hal to vob
+       - The wlan-hal vob contain hal and BusAccess directories except the USB. 
+    - The base lable is WSP7.1.0.19
+       - Add this file.
+
+
+  
+-----------------------------------------------------------------------------
+*/     
+#endif   
+
+
+
+
+
+
+#if 0
+
+/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+
+  The release notes below is for bus access developement 
+  HAL1.0 branch stared only from WSP7.1.0.19 which already have most of 
+  the Hal/busAccess changes
+
+=====================================
+Build WSP7.1.0.19
+=====================================
+
+       Label DEV_WSP7.1.0.19_Eng_Drop - Merged from REL_WSP7.0.0.29_GA
+       Change Rx/Tx descriptors due to the new TX definitions
+       Add support of SwitchChannel event for the measurement
+       Add 1150 changes for Win98 build and CUDK
+       Move Privacy module from RSN to HAL
+       Use firmware 2.4.0.27 
+
+=====================================
+Build WSP7.1.0.18
+=====================================
+
+       Label DEV_WSP7.1.0.18_Eng_Drop
+       Filter for Msdu from other BSS with moreFrag bit
+       Merge from Label DEV_WSP7.0.0.25_BFT
+           Clean to mbox queue callbacks on recovery
+           Track owner for RX packet (Hal, Rx, MLME, OS) for check msdu leak
+           TxDescFlag contain now VO_SYNC_TRIG and DISASSOC_SYNC_TRIG
+           Change factor of host descriptors from 2 to 4
+           Set lastBDPtr to NULL in EXC (fix CKIP defrag bug)
+           Enable RxReset and recovry on TxStuck and mailbox
+           WSP 7.0.0.25 is after merge from STA_DK 4.1.0.42
+       Use Firmware 2.4.0.24 (meged from 2.3.0.28 + AES fixes)
+       Fix CheckMailbox initialization
+       Fix MSDU ownership check when tx in the rx context (WSP only)
+
+=====================================
+Build WSP7.1.0.17
+=====================================
+
+       Label DEV_WSP7.1.0.17_Eng_Drop  
+       Merge read/write mem/reg via mbox from Wsp7.2
+       Disable access to SCR_PAD5 on USB configuration stage 
+       Add sending the trace buffer to UDP port
+
+=====================================
+Build WSP7.1.0.16
+=====================================
+
+       Label DEV_WSP7.1.0.16_Eng_Drop  
+       Firmware 2.4.0.20
+               fix for calibration on DCR (register 0x2001 setting)
+               Fix Frag+AES
+               Fix channel 14 disable OFDM
+               Add Read/Write memory
+       Clean Security objects
+       Remove unused siteMgr_disableLna
+       Clean 1150 registers file
+       Fix ifdefs for USB
+       Merge from Label DEV_WSP7.0.0.19_BFT
+
+=====================================
+Build WSP7.1.0.15 
+=====================================
+
+       Label DEV_WSP7.1.0.15_Eng_Drop  
+       Merge from DEV_WSP_7.0.0.15_BFT
+       Move debug reg/mem print into bus access
+       Add setting of SCR_PAD5 in USB
+       Add support for trace buffer in USB
+       Add fix for check size per queue in USB
+       Merge the fix for CKIP low rate problem
+       Merge fix for trace debug and move utils to whal
+       Firmware 2.4.0.15
+
+=====================================
+Build WSP7.1.0.13 
+=====================================
+
+       Label DEV_WSP7.1.0.13_Eng_Drop  
+       Remove the use of Driver workspace 
+       Remove disable OFDM in channel 14 - moved to the firmware
+       Call energy detection (CCA threshold) through mailbox and not to register 
+       Merge USB make fixes
+       No voice cookie in the USB mode (if needed - add field in the tx desc)
+       Move direct registers access into bus access
+       Use the new DtimPeriod information element
+       Auto calibration disable on start (fix the problem in the firmware) - 
+       Auto calibration on SPARE_A2 and not A1
+       USB return always not in Radio Stand By 
+       Firmware 2.4.0.15 - AES fix, Chan 14 fix, Fix Calib on strat
+
+
+=====================================
+Build WSP7.1.0.12 
+=====================================
+
+       Remove TNETW1100 support
+       Merge USB objects
+
+=====================================
+Build WSP7.1.0.11 
+=====================================
+
+       Label DEV_WSP7.1.0.11_Eng_Drop  
+       Merge from DEV_7.0.0.14_BFT
+       Re-arrange master/slave defines
+       Remove UseTxInterrupt flag
+       Add 16 bytes for security slave mode in one place
+
+=====================================
+Build WSP7.1.0.10 
+=====================================
+
+       Label DEV_WSP7.1.0.10_Eng_Drop  
+       Fix for radio DCR calibration Issue (in the firmware) 
+       Integration fixes on trace buffer
+       Add whalRecovery, whalDebug, whalRadio files for whalCtrl object
+       Disable overide tx power level table on 1150
+       Split whalHwRegs, add tnetwCommon.h
+       Move TxDesc, TxQueue and rx/tx h-files to common
+       Remove MASTER_MODE from MboxCmd
+       Fix print rx registers
+       Firmware 2.4.0.9
+
+=====================================
+Build WSP7.1.0.9 
+=====================================
+
+       Label DEV_WSP7.1.0.9_Eng_Drop   
+       Merge from WSP_7.0.0.13
+       Create new TnetwServices directory with 1100/1130/1150 registers and macro definitions
+       Create new FirmwareApi directory with all firmware h-files
+       Re-arrange shmFwCtrl object and eepromless boot
+       Tx modules handle static Recovery counter NumEmptyCount
+
+       Merge Event mailbox 
+       Fix reg domain check error on WBR a/b/g radio
+
+       Add LNA from Event mailbox
+       Don't disable Auto calibration at startup (shmFwCtrl)
+       Add trace buffer print function in HwAccess
+       Set defualt recovery to ENABLE 
+       Firmware 2.4.0.6
+
+=====================================
+Build WSP7.1.0.8
+=====================================
+
+       Label DEV_WSP7.1.0.8_Eng_Drop   
+       Merge from 7.0.0.8
+
+=====================================
+Build WSP7.1.0.6 
+=====================================
+
+       Merge Bus access fixes from private branches
+
+=====================================
+Build WSP7.1.0.4 
+=====================================
+
+       Merge from 1150 branch
+
+=====================================
+Build WSP7.1.0.2 
+=====================================
+
+       Merge 1150 from WSP 6.9.0.14
+       Firmware 2.3.0.8
+
+=====================================
+Build WSP7.1.0.1
+=====================================
+
+       Based on DEV_WSP7.0.0.1_BFT
+       Bus access component :
+          Create new whalBus_Api.h file which export the bus access API 
+          Create new whalBus.c file which manage the bus access 
+          Move HwAccesss, HwIntr, HwEeprom and HwMbox objects from hw_ctrl to whalBus
+          Create new shmFwCtrl object to handle the firmware boot 
+          Create new shmUtils file to support common general utilities
+          Move Rx/Tx objects for the slave from hw_data to shm_slave directory
+          Move Rx/Tx objects for the master from hw_data to shm_master directory
+          Same h-file for Rx/Tx Master/Slave
+          whalHwTxQueue and whalHwDesc objects still have master mode code
+          ConfigHw into Rx/Tx Mater/Slave (from whalHwCtrl)
+       Hal changes :
+          Move the creation of HwAccess, HwIntr, HwMbox, HwEeprom Trace to Bus access
+          Replace the HwAccess, HwIntr objects functions with whalBus functions
+          Replace the usage of HwRx, HwTx objects handle and functions with whalBus
+          Move Firmware download and eepromless functions into shmFwCtrl
+          Remove Info mailbox
+          Call whalBus to config queue addresses (ConfigHw)
+          Move Utilities (print buffer, \85) from whalParams to shmUtils
+          Move DmaParams definitions to bus access 
+       System
+          Add bus access objects into source.mak
+          Add bus access include path to the makefile
+          Add DSP file
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
+#endif
+
+#endif /* _HAL_RELEASE_H_ */                                                                                                    
+                                                                                                       
+                                                                                                        
diff --git a/sta_dk_4_0_4_32/common/src/hal/inc/whalCommon.h b/sta_dk_4_0_4_32/common/src/hal/inc/whalCommon.h
new file mode 100644 (file)
index 0000000..95c76e3
--- /dev/null
@@ -0,0 +1,97 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  whalCommon.h
+ *   PURPOSE: common whal definitions
+ * 
+ ****************************************************************************/
+
+#ifndef WHAL_COMMON_H
+#define WHAL_COMMON_H
+
+#include "osTIType.h"
+/*#include "osApi.h"*/
+/*#include "paramIn.h"*/
+/*#include "paramOut.h"*/
+#include "report.h"
+#include "utils.h"
+/*#include "ti_types.h"*/
+
+/*
+ * hal reports 
+ */
+#define WLAN_REPORT_REPLY                      WLAN_REPORT_CONSOLE
+#define HAL_HW_CTRL_MODULE_LOG         HAL_CTRL_MODULE_LOG
+#define HAL_HW_RX_MODULE_LOG           HAL_RX_MODULE_LOG
+#define HAL_HW_TX_MODULE_LOG           HAL_TX_MODULE_LOG
+#define HAL_HW_DATA_MODULE_LOG         HAL_TX_MODULE_LOG
+#define HAL_TEST_MODULE_LOG                    HAL_CTRL_MODULE_LOG
+
+
+#if defined(HAL_ON_WIN)
+
+#ifdef HAL_ON_DRIVER
+#define os_report      DbgPrint 
+#endif
+
+
+/* whal utilities */
+int  whalUtils_ConvertHwRate                   (UINT8 HwRate, UINT8 HwModulation, rate_e *AppRate, modulationType_e *AppModulation);
+int  whalUtils_ConvertAppRatesBitmap (UINT32 AppRatesBitmap, UINT32 AppModulation, UINT16 *HwRatesBitmap);
+int  whalUtils_ConvertAppRate        (UINT32 AppRate, UINT32 AppModulation, UINT8 *HwRate);
+int  whalUtils_ConvertHwRatesBitmap  (UINT8 HwRatesBitmap, UINT8 HwModulation, UINT32 *AppRate, UINT32 *AppModulation);
+void  whalUtils_ConvertBitmapToMaxRate(UINT16 HwRatesBitmap, UINT8 *HwModulation, UINT8 *HwRate);
+int  whalUtils_FindHwModulationByDrvRate (UINT32 AppRate, UINT8 *HwModu, UINT8 preamble); 
+#else
+int  whalUtils_ConvertAppRate        (rate_e AppRate, UINT8 *HwRate);
+int  whalUtils_FindHwModulationByDrvRate (rate_e AppRate, UINT8 *HwModu, UINT8 preamble); 
+int  whalUtils_ConvertAppRatesBitmap (UINT32 AppRatesBitmap, UINT32 AppModulation, UINT16 *HwRatesBitmap);
+#endif /*HAL_ON_WIN*/
+
+UINT32  whalUtils_GwsiRate2DRV_RATE (UINT32 gwsiRate);
+rateMask_e  whalUtils_GwsiRate2DRV_RATE_MASK (UINT32 gwsiRate);
+UINT32  whalUtils_DRV_RATE2GwsiRate (UINT32 Rate);
+UINT32  whalUtils_DRV_RATE_MASK2GwsiRate (rateMask_e rateMask);
+
+
+/* User Callback for Queue */
+typedef void (*CmdQueue_InterrogateCB_t )(TI_HANDLE objectHandle,UINT16 MboxStatus,void *InterrogateParamsBuf);
+typedef void (*CmdQueue_CB_t )(TI_HANDLE objectHandle,UINT16 MboxStatus);
+typedef void (*CmdQueue_GenericCB_t )(TI_HANDLE objectHandle, UINT16 CmdType, UINT16 CmdID, UINT32 aStatus);
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/hal/inc/whalSecurity.h b/sta_dk_4_0_4_32/common/src/hal/inc/whalSecurity.h
new file mode 100644 (file)
index 0000000..84c2dcc
--- /dev/null
@@ -0,0 +1,117 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_SECURITY_H
+#define _WHAL_SECURITY_H
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalWep.h"
+#include "whalWpa.h"
+#ifdef CKIP_ENABLED
+#include "whalExc.h"
+#endif /* CKIP_ENABLED*/
+
+#define NO_OF_RECONF_SECUR_KEYS_PER_STATION            1 /* define the number of keys allocated on reconfigure 
+                                                                                                        data structure for each station*/
+#define NO_OF_EXTRA_RECONF_SECUR_KEYS                  3 
+
+typedef struct
+{
+       TI_HANDLE hReport; /* handle to the reporter module*/
+       TI_HANDLE hMemMgr; /* handle to the memory manager module*/ 
+} whalSecur_config_t;
+
+
+/* reconfigure security structure for reconfigure (FW reload) time*/
+typedef struct
+{
+       BOOL reconfHwEncEnable;         /* save the last HW encryption Enable flag for reconfigure time*/
+       BOOL reconfHwDecrEnable;        /* save the last HW decryption Enable flag for reconfigure time*/ 
+       BOOL isHwEncDecrEnableValid; 
+       
+       UINT8 reconfDefaultKeyId;       /* save the last configured defualt key ID for reconfigure time*/ 
+       BOOL  isDefaultKeyIdValid;      
+       
+       securityKeys_t* reconfKeys; /* save all the configured keys for reconfigure time, keys which
+                                                                  it's keyType are not NULL_KEY, are valid*/  
+} securReconf_t;
+
+
+/* CLASS WHAL_SECURITY*/
+typedef struct _WHAL_SECURITY
+{
+       UINT32 numOfStations;
+       cipherSuite_e securityMode;
+       securReconf_t reconfData;      /* reconfigure security structure for reconfigure (FW reload) time*/
+       
+       WHAL_CTRL       *pWhalCtrl;             /* Pointer to the HL_HAL control module*/ 
+       WHAL_WEP        *pWhalWep;
+       WHAL_WPA        *pWhalWpa;
+#ifdef CKIP_ENABLED
+       privacy_t   *pWhalPrivacy;
+       WHAL_EXC        *pWhalExc;
+#endif /*CKIP_ENABLED*/
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMgr;
+} WHAL_SECURITY;
+
+/* WHAL SECURITY Class API*/                       
+TI_HANDLE whalSecur_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl, UINT16 numOfStations);
+
+int whalSecur_Config (TI_HANDLE hWhalSecur, whalSecur_config_t* pWhalSecurCfg);
+
+int whalSecur_KeyAdd (TI_HANDLE hWhalSecur, securityKeys_t* apKey, BOOL reconfFlag, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalSecur_KeyRemove (TI_HANDLE hWhalSecur, securityKeys_t* apKey, BOOL reconfFlag, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalSecur_DefaultKeyIdSet (TI_HANDLE hWhalSecur, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalSecur_HwEncDecrEnable (TI_HANDLE hWhalSecur, BOOL aHwEncEnable);
+
+int whalSecur_SwEncEnable (TI_HANDLE hWhalSecur, BOOL aSwEncEnable);
+
+int whalSecur_MicFieldEnable (TI_HANDLE hWhalSecur, BOOL aMicFieldEnable);
+
+int whalSecur_SecurModeSet (TI_HANDLE hWhalSecur, cipherSuite_e aSecurMode);
+
+cipherSuite_e whalSecur_SecurModeGet (TI_HANDLE hWhalSecur);
+
+int whalSecur_KeysReconfig (TI_HANDLE hWhalSecur);
+
+int whalSecur_Destroy (TI_HANDLE hWhalSecur, UINT16 numOfStations);
+
+#endif /* _WHAL_SECURITY_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/inc/whalWep.h b/sta_dk_4_0_4_32/common/src/hal/inc/whalWep.h
new file mode 100644 (file)
index 0000000..fc29942
--- /dev/null
@@ -0,0 +1,70 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_WEP_H
+#define _WHAL_WEP_H
+
+#include "whalCommon.h"
+
+
+typedef struct
+{
+       TI_HANDLE hReport; /* handle to the reporter module*/
+       TI_HANDLE hMemMgr; /* handle to the memory manager module*/ 
+} whalWep_config_t;
+
+/* CLASS WHAL_WEP*/
+typedef struct _WHAL_WEP
+{
+       WHAL_CTRL *pWhalCtrl;           /* Pointer to the HL_HAL control module*/ 
+
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMgr;
+} WHAL_WEP;
+
+/* WHAL WEP Class API*/                            
+TI_HANDLE whalWep_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl);
+
+int whalWep_Config (TI_HANDLE hWhalWep, whalWep_config_t* pWhalWepCfg);
+
+int whalWep_KeyAdd (TI_HANDLE hWhalWep, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalWep_KeyRemove (TI_HANDLE hWhalWep, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalWep_DefaultKeyIdSet (TI_HANDLE hWhalWep, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalWep_Destroy (TI_HANDLE hWhalWep);
+#endif /* _WHAL_WEP_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/inc/whalWpa.h b/sta_dk_4_0_4_32/common/src/hal/inc/whalWpa.h
new file mode 100644 (file)
index 0000000..6c49dab
--- /dev/null
@@ -0,0 +1,80 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _WHAL_WPA_H
+#define _WHAL_WPA_H
+
+#include "whalCommon.h"
+
+#define WPA_MIC_FIELD_LEN      8
+#define WPA_TX_ICV_FIELD_SIZE 12 /* 4+8 bytes*/
+
+typedef struct
+{
+       TI_HANDLE hReport; /* handle to the reporter module*/
+       TI_HANDLE hMemMgr; /* handle to the memory manager module*/ 
+} whalWpa_config_t;
+
+/* CLASS WHAL_WPA*/
+typedef struct _WHAL_WPA
+{
+       UINT32 wepFailCounter;
+
+       WHAL_CTRL               *pWhalCtrl;             /* Pointer to the HL_HAL control module*/ 
+
+       TI_HANDLE hOs;
+       TI_HANDLE hReport;
+       TI_HANDLE hMemMgr;
+
+       keyType_e currTxKeyType;  /* key type of the current configured unicast key */ 
+} WHAL_WPA;
+
+/* WHAL WPA Class API*/                            
+TI_HANDLE whalWpa_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl);
+
+int whalWpa_Config (TI_HANDLE hWhalWep, whalWpa_config_t* pWhalWpaCfg);
+
+int whalWpa_MpduListFieldsAdd (TI_HANDLE hWhalWpa, mem_MSDU_T* pMpduList);     
+
+int whalWpa_MpduFieldsHandle (TI_HANDLE hWhalWpa, mem_MSDU_T* pMpdu);          
+
+int whalWpa_KeyAdd (TI_HANDLE hWhalWpa, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalWpa_KeyRemove (TI_HANDLE hWhalWpa, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalWpa_DefaultKeyIdSet (TI_HANDLE hWhalWpa, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle);
+
+int whalWpa_Destroy (TI_HANDLE hWhalWpa);
+#endif /* _WHAL_WPA_H*/
diff --git a/sta_dk_4_0_4_32/common/src/hal/security/whalSecurity.c b/sta_dk_4_0_4_32/common/src/hal/security/whalSecurity.c
new file mode 100644 (file)
index 0000000..fedc4fb
--- /dev/null
@@ -0,0 +1,511 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_Create
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :  
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalSecur_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl, UINT16 numOfStations)
+{
+       WHAL_SECURITY* pWhalSecur;
+
+       pWhalSecur = (WHAL_SECURITY *)os_memoryAlloc (hOs, sizeof(WHAL_SECURITY));
+       if (pWhalSecur == NULL)
+               return NULL;
+
+       os_memoryZero (hOs, (void *)pWhalSecur, sizeof(WHAL_SECURITY));
+
+       pWhalSecur->pWhalCtrl = (WHAL_CTRL*)hWhalCtrl; 
+       pWhalSecur->hOs = hOs;
+       pWhalSecur->securityMode = RSN_CIPHER_NONE;
+
+       pWhalSecur->pWhalWep = (WHAL_WEP*)whalWep_Create (hOs, hWhalCtrl);
+       if (pWhalSecur->pWhalWep == NULL)
+       {
+               whalSecur_Destroy(pWhalSecur, numOfStations);
+               return NULL;
+       }
+       pWhalSecur->pWhalWpa = (WHAL_WPA*)whalWpa_Create (hOs, hWhalCtrl);
+       if (pWhalSecur->pWhalWpa == NULL)
+       {
+               whalSecur_Destroy(pWhalSecur, numOfStations);
+               return NULL;
+       }
+#ifdef CKIP_ENABLED
+       pWhalSecur->pWhalPrivacy = (privacy_t*)privacy_create (hOs);
+       pWhalSecur->pWhalExc = (WHAL_EXC*)whalExc_Create(hOs, hWhalCtrl);
+       if (pWhalSecur->pWhalExc == NULL)
+       {
+               whalSecur_Destroy(pWhalSecur, numOfStations);
+               return NULL;
+       }
+#endif /* CKIP_ENABLED */
+       pWhalSecur->numOfStations = numOfStations;
+       pWhalSecur->reconfData.reconfKeys = (securityKeys_t*)os_memoryAlloc (hOs, 
+                                                                               (sizeof(securityKeys_t))*(numOfStations*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS));
+       os_memoryZero (hOs, (void *)pWhalSecur->reconfData.reconfKeys, 
+                                                                               (sizeof(securityKeys_t))*(numOfStations*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS));
+       
+       return ((TI_HANDLE)pWhalSecur);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_Config
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_Config (TI_HANDLE hWhalSecur, whalSecur_config_t* pWhalSecurCfg)
+{
+       UINT32 index;
+       whalWep_config_t wepCfg;
+       whalWpa_config_t wpaCfg;
+#ifdef CKIP_ENABLED
+       whalExc_config_t excCfg;
+#endif /* CKIP_ENABLED*/
+
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+
+       /* Reset all reconfig valid fields*/
+       pWhalSecur->reconfData.isHwEncDecrEnableValid = FALSE;
+       pWhalSecur->reconfData.isDefaultKeyIdValid = FALSE;  
+       for (index=0; index < ((pWhalSecur->numOfStations)*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS); index++)
+                       (pWhalSecur->reconfData.reconfKeys+index)->keyType = NULL_KEY;
+
+       /* Save configuration parameters */
+       pWhalSecur->hMemMgr = pWhalSecurCfg->hMemMgr;
+       pWhalSecur->hReport = pWhalSecurCfg->hReport;
+       
+
+       /* Config the wep sub-module*/
+       wepCfg.hMemMgr = pWhalSecur->hMemMgr;
+       wepCfg.hReport = pWhalSecur->hReport;
+       if (whalWep_Config (pWhalSecur->pWhalWep, &wepCfg) != OK)
+               return (NOK);                                                                                     
+
+       /* Config the wpa sub-module*/
+       wpaCfg.hMemMgr = pWhalSecur->hMemMgr; 
+       wpaCfg.hReport = pWhalSecur->hReport; 
+       if (whalWpa_Config (pWhalSecur->pWhalWpa, &wpaCfg) != OK)
+               return (NOK);
+       
+#ifdef CKIP_ENABLED
+    wpaCfg.pWhalPrivacy = pWhalSecur->pWhalPrivacy;
+       /* Config the privacy sub-module*/
+       if (privacy_config (pWhalSecur->pWhalPrivacy, 
+                                               pWhalSecur->hReport, pWhalSecur->hOs) != OK)
+               return (NOK);
+       excCfg.hMemMgr = pWhalSecur->hMemMgr;   
+       excCfg.hReport = pWhalSecur->hReport;  
+       excCfg.pWhalPrivacy = pWhalSecur->pWhalPrivacy;  
+       if (whalExc_Config (pWhalSecur->pWhalExc, &excCfg) != OK)
+               return (NOK);
+#endif /*CKIP_ENABLED */
+
+       return (OK);
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_KeyAdd
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_KeyAdd (TI_HANDLE hWhalSecur, securityKeys_t* pKey, BOOL reconfFlag, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+       UINT8          keyIdx     = (UINT8)pKey->keyIndex;
+
+       /* store the security key for reconfigure time (FW reload)*/
+       if (reconfFlag != TRUE)
+       {
+               if (keyIdx >= ((pWhalSecur->numOfStations)*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS))
+               {
+                       WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_SECURITY_MODULE_LOG,  
+                               ("whalSecur_KeyAdd: ERROR Key keyIndex field out of range =%d, range is (0 to %d)\n",
+                                pKey->keyIndex, (pWhalSecur->numOfStations)*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS-1));
+                       
+                       return (NOK);
+               }
+
+               if (pKey->keyType == NULL_KEY)
+               {
+                       WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_SECURITY_MODULE_LOG,  
+                                                               ("whalSecur_KeyAdd: ERROR KeyType is NULL_KEY\n"));
+                       
+                       return (NOK);
+               }
+
+               os_memoryCopy (pWhalSecur->hOs, 
+                               (void *)(pWhalSecur->reconfData.reconfKeys + keyIdx),
+                               (void *)pKey, sizeof(securityKeys_t));
+       }
+       
+       switch (pWhalSecur->securityMode)
+       {
+               case RSN_CIPHER_WEP:
+               case RSN_CIPHER_WEP104:
+                       return (whalWep_KeyAdd (pWhalSecur->pWhalWep, pKey, CB_Func, CB_handle));
+       
+               case RSN_CIPHER_TKIP:
+               case RSN_CIPHER_AES_CCMP:
+                       return (whalWpa_KeyAdd (pWhalSecur->pWhalWpa, pKey, CB_Func, CB_handle));
+
+               default:
+                       return (NOK);
+       }
+
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_KeyRemove
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_KeyRemove (TI_HANDLE hWhalSecur, securityKeys_t* pKey, BOOL reconfFlag, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+
+       switch (pWhalSecur->securityMode)
+       {
+               case RSN_CIPHER_WEP:
+               case RSN_CIPHER_WEP104:
+                       return (whalWep_KeyRemove (pWhalSecur->pWhalWep, pKey, CB_Func, CB_handle));
+       
+               case RSN_CIPHER_TKIP:
+               case RSN_CIPHER_AES_CCMP:
+                       return (whalWpa_KeyRemove (pWhalSecur->pWhalWpa, pKey, CB_Func, CB_handle));
+               
+               default:
+                       return (NOK);
+       }
+
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_DefaultKeyIdSet
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_DefaultKeyIdSet (TI_HANDLE hWhalSecur, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+
+       /* store the default key ID value for reconfigure time (FW reload)*/
+       pWhalSecur->reconfData.reconfDefaultKeyId = aKeyId;
+       
+       switch (pWhalSecur->securityMode)
+       {
+               case RSN_CIPHER_WEP:
+               case RSN_CIPHER_WEP104:
+                       pWhalSecur->reconfData.isDefaultKeyIdValid = TRUE;
+                       return (whalWep_DefaultKeyIdSet (pWhalSecur->pWhalWep, aKeyId, CB_Func, CB_handle));
+       
+               case RSN_CIPHER_TKIP:
+               case RSN_CIPHER_AES_CCMP:
+                       pWhalSecur->reconfData.isDefaultKeyIdValid = TRUE;
+                       return (whalWpa_DefaultKeyIdSet (pWhalSecur->pWhalWpa, aKeyId, CB_Func, CB_handle));
+
+               default:
+                       return (NOK);
+       }
+
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_HwEncDecrEnable
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_HwEncDecrEnable (TI_HANDLE hWhalSecur, BOOL aHwEncEnable)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+       
+       /* store the HW encryption Enable flag for reconfigure time (FW reload)*/
+       pWhalSecur->reconfData.reconfHwEncEnable = aHwEncEnable;
+
+       pWhalSecur->reconfData.isHwEncDecrEnableValid = TRUE;
+
+    return (whal_hwCtrl_EncDecrSet (pWhalSecur->pWhalCtrl->pHwCtrl, aHwEncEnable, aHwEncEnable));
+}
+
+#ifdef CKIP_ENABLED
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_SwEncEnable
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_SwEncEnable (TI_HANDLE hWhalSecur, BOOL aSwEncEnable)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+       
+       return (whalExc_swEncEnable (pWhalSecur->pWhalExc, aSwEncEnable));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_MicFieldEnable
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_MicFieldEnable (TI_HANDLE hWhalSecur, BOOL aMicFieldEnable)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+
+       return (whalExc_micFieldEnable (pWhalSecur->pWhalExc, aMicFieldEnable));
+}
+#endif /*CKIP_ENABLED*/
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_SecurModeSet
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_SecurModeSet (TI_HANDLE hWhalSecur, cipherSuite_e aSecurMode)
+{
+       UINT32 index;
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+       if (aSecurMode<=RSN_CIPHER_CKIP)
+       {
+               WLAN_REPORT_INFORMATION (pWhalSecur->hReport, HAL_SECURITY_MODULE_LOG,
+                                                               ("whalSecur_SecurModeSet: change security mode from %d --> %d\n",
+                                                            pWhalSecur->securityMode, aSecurMode));
+               /* check if security mode is equal to previous one*/
+               if (pWhalSecur->securityMode == aSecurMode)
+                       return (OK);
+
+               /* Reset all reconfig valid fields*/
+               pWhalSecur->reconfData.isHwEncDecrEnableValid = FALSE;
+               pWhalSecur->reconfData.isDefaultKeyIdValid = FALSE;  
+               for (index=0; index < ((pWhalSecur->numOfStations)*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS); index++)
+                               (pWhalSecur->reconfData.reconfKeys+index)->keyType = NULL_KEY;
+               
+        /* set the new security mode*/
+               pWhalSecur->securityMode = aSecurMode;
+
+#ifdef CKIP_ENABLED
+               /* Upon entering to RSN_PRIVACY_EXC mode, disable the excSwEnc and excMicField flags, 
+                  reset the privacy Enc sub-module */
+               if (aSecurMode == RSN_CIPHER_CKIP)
+               {
+                       if (whalExc_swEncEnable (pWhalSecur->pWhalExc, FALSE) != OK)
+                               return (NOK);
+
+                       if (whalExc_micFieldEnable (pWhalSecur->pWhalExc, FALSE) != OK)
+                               return (NOK);
+
+                       if (privacy_resetEnc (pWhalSecur->pWhalPrivacy) != OK)
+                               return (NOK);
+               }
+
+               privacy_setPrivacyMode(pWhalSecur->pWhalPrivacy, aSecurMode);
+#endif /* CKIP_ENABLED*/
+
+               /* disable defrag, duplicate detection on TNETW+EXC on chip level*/
+               if (pWhalSecur->securityMode==RSN_CIPHER_CKIP)
+                       /* YV- to add fragmentation control (if there is- artur ?)*/
+                       return (whal_hwCtrl_RxMsduFormatSet (pWhalSecur->pWhalCtrl->pHwCtrl, FALSE));
+               else
+                       /* YV- to add fragmentation control (if there is- artur ?)*/
+                       return (whal_hwCtrl_RxMsduFormatSet (pWhalSecur->pWhalCtrl->pHwCtrl, TRUE));
+               
+
+       }
+       else
+               return (NOK);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_SecurModeGet
+ *
+ * Input    : 
+ * Output   :  security mode
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+cipherSuite_e whalSecur_SecurModeGet (TI_HANDLE hWhalSecur)
+{
+       WHAL_SECURITY* pWhalSecur = (TI_HANDLE)hWhalSecur;
+
+       return pWhalSecur->securityMode;
+}
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_KeysReconfig
+ *
+ * Input    : 
+ * Output   :
+ * Process  : Reconfig security keys, default key Id and encryption/decryption 
+ *                       control to the FW
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_KeysReconfig (TI_HANDLE hWhalSecur)
+{
+       UINT32 index;
+       WHAL_SECURITY* pWhalSecur = (WHAL_SECURITY *)hWhalSecur;
+
+
+       if (pWhalSecur->securityMode != RSN_CIPHER_NONE)
+       {
+
+               /* set the keys to the HW*/
+               for (index=0; index < ((pWhalSecur->numOfStations)*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS); index++)
+               {
+                       if ((pWhalSecur->reconfData.reconfKeys+index)->keyType != NULL_KEY)
+                       {
+                               if (whalSecur_KeyAdd (pWhalSecur, pWhalSecur->reconfData.reconfKeys+index, TRUE, NULL, NULL) != OK)
+                               {
+                                       WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_SECURITY_MODULE_LOG,  
+                                               ("whalSecur_KeysReconfig: ERROR whalSecur_KeyAdd failure index=%d\n", index));
+                                       return (NOK);
+                               }   
+                       }
+               }
+       
+               if (pWhalSecur->reconfData.isDefaultKeyIdValid == TRUE)
+               {
+                       /* set the deafult key ID to the HW*/
+                       if (whalSecur_DefaultKeyIdSet (pWhalSecur, pWhalSecur->reconfData.reconfDefaultKeyId, NULL, NULL) != OK)
+                       {
+                               WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_SECURITY_MODULE_LOG,  
+                                       ("whalSecur_KeysReconfig: ERROR whalSecur_DefaultKeyIdSet failure \n"));
+                               return (NOK);
+                       }   
+               }
+       } /* pWhalSecur->securityMode != RSN_CIPHER_NONE */
+
+
+       /* set the encryption/decryption control on the HW*/   
+       if (whalSecur_HwEncDecrEnable (pWhalSecur, pWhalSecur->reconfData.reconfHwEncEnable) != OK)
+       {
+               WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_SECURITY_MODULE_LOG,  
+                       ("whalSecur_KeysReconfig: ERROR whalSecur_HwEncDecrEnable failure \n"));
+               return (NOK);
+       }   
+       
+       return (OK);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalSecur_Destroy
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  : Unload the HAL security module
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalSecur_Destroy (TI_HANDLE hWhalSecur, UINT16 numOfStations)
+{
+       WHAL_SECURITY* pWhalSecur = (WHAL_SECURITY *)hWhalSecur;
+
+       if (!pWhalSecur)
+               return OK;
+#ifdef CKIP_ENABLED
+       whalExc_Destroy (pWhalSecur->pWhalExc);
+       if (privacy_unload(pWhalSecur->pWhalPrivacy) != OK)
+               WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_CTRL_MODULE_LOG,  (" whalSecur_Destroy: privacy_unload failure \n"));
+#endif /* CKIP_ENABLED*/
+
+       if (whalWpa_Destroy (pWhalSecur->pWhalWpa) != OK)
+               WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_CTRL_MODULE_LOG,  (" whalSecur_Destroy: whalWpa_Destroy failure \n"));
+       if (whalWep_Destroy (pWhalSecur->pWhalWep) != OK)
+               WLAN_REPORT_ERROR(pWhalSecur->hReport, HAL_CTRL_MODULE_LOG,  (" whalSecur_Destroy: whalWep_Destroy failure \n"));
+
+       if (pWhalSecur->reconfData.reconfKeys)
+               os_memoryFree (pWhalSecur->hOs, pWhalSecur->reconfData.reconfKeys, 
+                                  (sizeof(securityKeys_t))*(numOfStations*NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS));
+       
+       os_memoryFree (pWhalSecur->hOs, pWhalSecur, sizeof(WHAL_SECURITY));
+       
+       return (OK);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/security/whalWep.c b/sta_dk_4_0_4_32/common/src/hal/security/whalWep.c
new file mode 100644 (file)
index 0000000..e504934
--- /dev/null
@@ -0,0 +1,187 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWep_Create
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalWep_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl)
+{
+       WHAL_WEP* pWhalWep;
+
+       pWhalWep = (WHAL_WEP *)os_memoryAlloc (hOs, sizeof(WHAL_WEP));
+       if (pWhalWep == NULL)
+               return NULL;
+
+       os_memoryZero (hOs, (void *)pWhalWep, sizeof(WHAL_WEP));
+
+       pWhalWep->pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       pWhalWep->hOs = hOs;
+       
+       return((TI_HANDLE)pWhalWep);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWep_Config
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWep_Config (TI_HANDLE hWhalWep, whalWep_config_t* pWhalWepCfg)
+{
+       WHAL_WEP* pWhalWep = (WHAL_WEP *)hWhalWep;
+
+       pWhalWep->hMemMgr = pWhalWepCfg->hMemMgr;
+       pWhalWep->hReport = pWhalWepCfg->hReport;
+
+       /* YV - need to move here, the settings of ACXWEPOptions IE configuration!!*/
+       /* which set the number of keys for which to reseve space in the WEP cache*/
+       
+       return (OK);
+}                          
+                                                   
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWep_KeyAdd
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWep_KeyAdd (TI_HANDLE hWhalWep, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_WEP* pWhalWep = (WHAL_WEP *)hWhalWep;
+    
+       /* Non WEP keys are trashed*/
+       if (pKey->keyType != WEP_KEY)
+               return (NOK);
+
+    /* Check for mapping key or default key */
+    if ( MAC_NULL(&pKey->macAddress) )
+    {
+        /* Configure the encKeys to the HW - default keys cache*/
+        return (whal_hwCtrl_WepDefaultKeyAdd (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
+    } 
+    else /* Use key mapping */
+    {
+        return (whal_hwCtrl_WepMappingKeyAdd (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
+    }
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWep_KeyRemove
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWep_KeyRemove (TI_HANDLE hWhalWep, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_WEP* pWhalWep = (WHAL_WEP *)hWhalWep;
+
+       /* Non WEP keys are trashed*/
+       if (pKey->keyType != WEP_KEY)
+               return (NOK);
+
+    /* Check for mapping key or default key */
+    if ( MAC_NULL(&pKey->macAddress) )
+    {
+           return (whal_hwCtrl_WepDefaultKeyRemove (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
+    }
+    else
+    {
+        return (whal_hwCtrl_WepMappingKeyRemove (pWhalWep->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
+    }
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWep_DefaultKeyIdSet
+ *
+ * Input    : 
+ * Output   :
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWep_DefaultKeyIdSet (TI_HANDLE hWhalWep, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_WEP *pWhalWep = (WHAL_WEP *)hWhalWep;
+
+       /* Configure the default key id to the HW*/
+       return (whal_hwCtrl_DefaultKeyIdSet (pWhalWep->pWhalCtrl->pHwCtrl, aKeyId, CB_Func, CB_handle));
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWep_Destroy
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  :
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWep_Destroy (TI_HANDLE hWhalWep)
+{
+       WHAL_WEP *pWhalWep = (WHAL_WEP *)hWhalWep;
+
+       if (pWhalWep)
+               os_memoryFree (pWhalWep->hOs, pWhalWep, sizeof(WHAL_WEP));
+       
+       return (OK);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/hal/security/whalWpa.c b/sta_dk_4_0_4_32/common/src/hal/security/whalWpa.c
new file mode 100644 (file)
index 0000000..e746203
--- /dev/null
@@ -0,0 +1,324 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "802_11Defs.h"
+#include "Ethernet.h"
+#include "whalCommon.h"
+#include "whalCtrl_api.h"
+#include "whalCtrl.h"
+#include "whalSecurity.h"
+#include "whalWpa.h"
+
+
+
+#undef WHAL_WPA_MODULE_LOG_PRINT_ENABLE
+
+static void    whal_MsduContentDump (TI_HANDLE hWhalWpa, mem_MSDU_T* pMsdu, char* str);
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whal_MsduContentDump
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  : 
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+static void    whal_MsduContentDump (TI_HANDLE hWhalWpa, mem_MSDU_T* pMsdu, char *str)
+{      
+#ifdef WHAL_WPA_MODULE_LOG_PRINT_ENABLE
+    UINT32 msduLen;
+       mem_BD_T* pCurrBd;
+       WHAL_WPA* pWhalWpa = (WHAL_WPA *)hWhalWpa;
+    
+       WLAN_REPORT_INFORMATION(pWhalWpa->hReport, HAL_SECURITY_MODULE_LOG,  
+                                       ("%s totalLen=%d^^^^^ \n", str, pMsdu->dataLen));
+       
+       msduLen = pMsdu->dataLen;
+       pCurrBd = pMsdu->firstBDPtr;
+       
+       while ((msduLen >= 0)&&(pCurrBd!=NULL))
+       {
+               WLAN_REPORT_INFORMATION(pWhalWpa->hReport, HAL_SECURITY_MODULE_LOG,  
+                       ("\nBdLen = %d\n", pCurrBd->length));
+               
+               HexDumpData((UINT8*)(pCurrBd->data+pCurrBd->dataOffset), pCurrBd->length);
+       
+               msduLen -=  pCurrBd->length;
+               pCurrBd =  pCurrBd->nextBDPtr;
+       }
+
+#endif /*WHAL_WPA_MODULE_LOG_PRINT_ENABLE*/
+}
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_Create
+ *
+ * Input    : 
+ * Output   :
+ * Process  : Create the WPA - security sub-module.
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+TI_HANDLE whalWpa_Create (TI_HANDLE hOs, TI_HANDLE hWhalCtrl)
+{
+       WHAL_WPA* pWhalWpa;
+
+       pWhalWpa = (WHAL_WPA *)os_memoryAlloc (hOs, sizeof(WHAL_WPA));
+       if (pWhalWpa == NULL)
+               return NULL;
+
+       os_memoryZero (hOs, (void *)pWhalWpa, sizeof(WHAL_WPA));
+
+       pWhalWpa->pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
+       pWhalWpa->hOs = hOs;
+       
+       return((TI_HANDLE)pWhalWpa);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_Config
+ *
+ * Input    : 
+ * Output   :
+ * Process  : Configure the WPA - security sub-module.
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWpa_Config (TI_HANDLE hWhalWpa, whalWpa_config_t* pWhalWpaCfg)
+{
+       WHAL_WPA* pWhalWpa = (WHAL_WPA *)hWhalWpa;
+
+       pWhalWpa->hReport = pWhalWpaCfg->hReport;
+       pWhalWpa->hMemMgr = pWhalWpaCfg->hMemMgr;
+
+       return (OK);
+}                          
+                                                   
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_MpduListFieldsAdd
+ *
+ * Input    : Transmitted MSDU
+ * Output   : MSDU after padding for TKIP EIV or AES RSN fields.
+ * Process  : Shift LLC+SNAP apart from WLAN header to add padding for EIV/RSN field. 
+ *                             
+ * Note(s)  : An LLC+SNAP is located just after the 802.11 header      
+ *                              on the first MPDU header only.
+ * -----------------------------------------------------------------------------
+ */
+int whalWpa_MpduListFieldsAdd (TI_HANDLE hWhalWpa, mem_MSDU_T* pMpduList)
+{
+       WHAL_WPA* pWhalWpa = (WHAL_WPA *)hWhalWpa;
+       UINT32 AddFieldSize;
+       UINT8 tempbuff[WLAN_SNAP_HDR_LEN + WLAN_4X_CONCAT_HDR_LEN];
+
+       /* 
+        * Check TX key type
+        * In case of TKIP we need to add bytes for IV
+        * For AES  we need to add 8 bytes
+        * For unified AES - always add 8 bytes
+        */
+       if(pWhalWpa->currTxKeyType == TKIP_KEY)
+       {
+               AddFieldSize = IV_FIELD_SIZE;
+       }
+       else
+       if(pWhalWpa->currTxKeyType == AES_KEY)
+       {
+               AddFieldSize = AES_AFTER_HEADER_FIELD_SIZE;
+       }
+       else
+               return OK;
+
+       /* Check if LLC+SNAP exist in the buffer of the header. */
+       if ( (memMgr_MsduFirstLen(pMpduList) == pMpduList->headerLen+WLAN_SNAP_HDR_LEN) || 
+                (memMgr_MsduFirstLen(pMpduList) == pMpduList->headerLen+WLAN_SNAP_HDR_LEN + WLAN_4X_CONCAT_HDR_LEN ) )
+       {
+               UINT8 *pHeaderEnd =     (UINT8*)( (UINT32)memMgr_BufData(pMpduList->firstBDPtr) +
+                       memMgr_BufOffset(pMpduList->firstBDPtr) + pMpduList->headerLen );
+
+               /* Copy LLC+SNAP to temp buffer. */
+               os_memoryCopy (pWhalWpa->hOs, (void *)tempbuff, (void *)pHeaderEnd, WLAN_SNAP_HDR_LEN + WLAN_4X_CONCAT_HDR_LEN);
+
+               /* Copy LLC+SNAP from temp buffer back to BD with required padding. */
+               os_memoryCopy (pWhalWpa->hOs, (void *)(pHeaderEnd + AddFieldSize), (void *)tempbuff, WLAN_SNAP_HDR_LEN + WLAN_4X_CONCAT_HDR_LEN);
+         
+               /* Clear padding field. */
+               os_memoryZero (pWhalWpa->hOs, (void *)pHeaderEnd, AddFieldSize);
+       }
+       else
+       {
+               WLAN_REPORT_WARNING(pWhalWpa->hReport, HAL_SECURITY_MODULE_LOG,  
+                     ("whalWpa_MpduListFieldsAdd:  ERROR: First Buffer Length Is Illegal !!!!!! \n"));
+       }
+
+       /* Update BD and MSDU sizes to include the padding. */
+       memMgr_MsduFirstLen(pMpduList) += AddFieldSize;
+       memMgr_MsduDataSize(pMpduList) += AddFieldSize;
+               
+       whal_MsduContentDump (pWhalWpa, pMpduList, "whalWpa_MpduListFieldsAdd: Exit (Tx Path) ");
+       return (OK);                      
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_KeyAdd
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  : Add key to the HW.
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWpa_KeyAdd (TI_HANDLE hWhalWpa, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_WPA*               pWhalWpa = (WHAL_WPA *)hWhalWpa;
+       /* Only WEP, TKIP, AES keys are handled*/
+       switch (pKey->keyType)
+       {
+               case WEP_KEY:
+                       /* Configure the encKeys to the HW - default keys cache*/
+                       return (whal_hwCtrl_WepDefaultKeyAdd (pWhalWpa->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
+               
+               case TKIP_KEY:
+                       /* Set the REAL TKIP key into the TKIP key cache*/
+                       if (whal_hwCtrl_TkipMicMappingKeyAdd (pWhalWpa->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle) != OK)
+                               return (NOK);
+
+                       break;
+               
+               case AES_KEY:
+                       if (whal_hwCtrl_AesMappingKeyAdd (pWhalWpa->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle) != OK)
+                               return (NOK);
+                       break;
+               
+               default:
+                       return (NOK);
+       }
+       
+       /* AES or TKIP key has been successfully added. Store the current */
+       /* key type of the unicast (i.e. transmit !) key                  */
+       if(!MAC_BROADCAST((&pKey->macAddress)))
+       {
+               pWhalWpa->currTxKeyType = pKey->keyType;
+       }
+
+       return (OK);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_KeyRemove
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  : Add key to the HW.
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWpa_KeyRemove (TI_HANDLE hWhalWpa, securityKeys_t* pKey, void *CB_Func, TI_HANDLE CB_handle)
+{
+       WHAL_WPA*               pWhalWpa = (WHAL_WPA *)hWhalWpa;
+
+       /* Only WEP, TKIP, AES keys are handled*/
+       switch (pKey->keyType)
+       {
+               case WEP_KEY:
+                       /* Configure the encKeys to the HW - default keys cache*/
+                       return (whal_hwCtrl_WepDefaultKeyRemove (pWhalWpa->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle));
+               
+               case TKIP_KEY:
+                       /* Configure the encKeys to the HW - mapping keys cache*/
+                       /* configure through SET_KEYS command */
+
+                       /* remove the TKIP key from the TKIP key cache*/
+                       if (whal_hwCtrl_TkipMicMappingKeyRemove (pWhalWpa->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle) != OK)
+                               return (NOK);
+
+                       break;
+               
+               case AES_KEY:
+                       if (whal_hwCtrl_AesMappingKeyRemove (pWhalWpa->pWhalCtrl->pHwCtrl, pKey, CB_Func, CB_handle) != OK)
+                               return (NOK);
+                       break;
+
+               
+               default:
+                       return (NOK);
+       }
+       
+       return (OK);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_DefaultKeyIdSet
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  : Configure the default key Id to the HW.
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWpa_DefaultKeyIdSet (TI_HANDLE hWhalWpa, UINT8 aKeyId, void *CB_Func, TI_HANDLE CB_handle)
+{
+       /* Do not configure the default key id to the HW, return OK to the caller*/
+       return (OK);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : whalWpa_Destroy
+ *
+ * Input    : 
+ * Output   :                                                                   
+ * Process  : Destroy the WPA - security sub-module.
+ * Note(s)  :
+ * -----------------------------------------------------------------------------
+ */
+int whalWpa_Destroy (TI_HANDLE hWhalWpa)
+{
+       WHAL_WPA *pWhalWpa = (WHAL_WPA *)hWhalWpa;
+
+       if (pWhalWpa)
+               os_memoryFree (pWhalWpa->hOs, pWhalWpa, sizeof(WHAL_WPA));
+       
+       return (OK);
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/inc/802_11Defs.h b/sta_dk_4_0_4_32/common/src/inc/802_11Defs.h
new file mode 100644 (file)
index 0000000..c5123a0
--- /dev/null
@@ -0,0 +1,1297 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************
+ *
+ *   MODULE:  802_11Defs.h
+ *   PURPOSE: Contains 802.11 defines/structures
+ *
+ ****************************************************************************/
+
+#ifndef _802_11_INFO_DEFS_H
+#define _802_11_INFO_DEFS_H
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "paramIn.h"
+
+/* FrameControl field of the 802.11 header  */
+
+/**/
+/* bit 15    14     13     12     11     10      9     8     7-4     3-2      1-0*/
+/* +-------+-----+------+-----+-------+------+------+----+---------+------+----------+*/
+/* | Order | WEP | More | Pwr | Retry | More | From | To | Subtype | Type | Protocol |*/
+/* |       |     | Data | Mgmt|       | Frag | DS   | DS |         |      | Version  |*/
+/* +-------+-----+------+-----+-------+------+------+----+---------+------+----------+*/
+/*     1      1      1     1      1       1      1     1       4       2        2*/
+
+
+#define DOT11_FC_PROT_VERSION_MASK   ( 3 << 0 )
+#define DOT11_FC_PROT_VERSION        ( 0 << 0 )
+
+#define DOT11_FC_TYPE_MASK           ( 3 << 2 )
+typedef enum
+{
+  DOT11_FC_TYPE_MGMT         = ( 0 << 2 ),
+  DOT11_FC_TYPE_CTRL         = ( 1 << 2 ),
+  DOT11_FC_TYPE_DATA         = ( 2 << 2 )
+} dot11_Fc_Type_e;
+
+#define DOT11_FC_SUB_MASK           ( 0x0f << 4 )
+typedef enum
+{
+  /* Management subtypes */
+  DOT11_FC_SUB_ASSOC_REQ     = (    0 << 4 ),
+  DOT11_FC_SUB_ASSOC_RESP    = (    1 << 4 ),
+  DOT11_FC_SUB_REASSOC_REQ   = (    2 << 4 ),
+  DOT11_FC_SUB_REASSOC_RESP  = (    3 << 4 ),
+  DOT11_FC_SUB_PROBE_REQ     = (    4 << 4 ),
+  DOT11_FC_SUB_PROBE_RESP    = (    5 << 4 ),
+  DOT11_FC_SUB_BEACON        = (    8 << 4 ),
+  DOT11_FC_SUB_ATIM          = (    9 << 4 ),
+  DOT11_FC_SUB_DISASSOC      = (   10 << 4 ),
+  DOT11_FC_SUB_AUTH          = (   11 << 4 ),
+  DOT11_FC_SUB_DEAUTH        = (   12 << 4 ),
+  DOT11_FC_SUB_ACTION        = (   13 << 4 ),
+
+  /* Control subtypes */
+  DOT11_FC_SUB_PS_POLL                = (   10 << 4 ),
+  DOT11_FC_SUB_RTS                    = (   11 << 4 ),
+  DOT11_FC_SUB_CTS                    = (   12 << 4 ),
+  DOT11_FC_SUB_ACK                    = (   13 << 4 ),
+  DOT11_FC_SUB_CF_END                 = (   14 << 4 ),
+  DOT11_FC_SUB_CF_END_CF_ACK          = (   15 << 4 ),
+
+  /* Data subtypes */
+  DOT11_FC_SUB_DATA                   = (    0 << 4 ),
+  DOT11_FC_SUB_DATA_CF_ACK            = (    1 << 4 ),
+  DOT11_FC_SUB_DATA_CF_POLL           = (    2 << 4 ),
+  DOT11_FC_SUB_DATA_CF_ACK_CF_POLL    = (    3 << 4 ),
+  DOT11_FC_SUB_NULL_FUNCTION          = (    4 << 4 ),
+  DOT11_FC_SUB_CF_ACK                 = (    5 << 4 ),
+  DOT11_FC_SUB_CF_POLL                = (    6 << 4 ),
+  DOT11_FC_SUB_CF_ACK_CF_POLL         = (    7 << 4 ),
+  DOT11_FC_SUB_DATA_QOS               = (    8 << 4 ),
+  DOT11_FC_SUB_DATA_NULL_QOS          = (   12 << 4 )
+} dot11_Fc_Sub_Type_e;
+
+#define  DOT11_FC_TYPESUBTYPE_MASK    ( DOT11_FC_TYPE_MASK | DOT11_FC_SUB_MASK )
+typedef enum
+{
+  DOT11_FC_ASSOC_REQ           = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_ASSOC_REQ           ),
+  DOT11_FC_ASSOC_RESP          = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_ASSOC_RESP          ),
+  DOT11_FC_REASSOC_REQ         = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_REASSOC_REQ         ),
+  DOT11_FC_REASSOC_RESP        = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_REASSOC_RESP        ),
+  DOT11_FC_PROBE_REQ           = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_PROBE_REQ           ),
+  DOT11_FC_PROBE_RESP          = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_PROBE_RESP          ),
+  DOT11_FC_BEACON              = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_BEACON              ),
+  DOT11_FC_ATIM                = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_ATIM                ),
+  DOT11_FC_DISASSOC            = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_DISASSOC            ),
+  DOT11_FC_AUTH                = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_AUTH                ),
+  DOT11_FC_DEAUTH              = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_DEAUTH              ),
+  DOT11_FC_ACTION              = ( DOT11_FC_TYPE_MGMT | DOT11_FC_SUB_ACTION              ),
+  DOT11_FC_PS_POLL             = ( DOT11_FC_TYPE_CTRL | DOT11_FC_SUB_PS_POLL             ),
+  DOT11_FC_RTS                 = ( DOT11_FC_TYPE_CTRL | DOT11_FC_SUB_RTS                 ),
+  DOT11_FC_CTS                 = ( DOT11_FC_TYPE_CTRL | DOT11_FC_SUB_CTS                 ),
+  DOT11_FC_ACK                 = ( DOT11_FC_TYPE_CTRL | DOT11_FC_SUB_ACK                 ),
+  DOT11_FC_CF_END              = ( DOT11_FC_TYPE_CTRL | DOT11_FC_SUB_CF_END              ),
+  DOT11_FC_CF_END_CF_ACK       = ( DOT11_FC_TYPE_CTRL | DOT11_FC_SUB_CF_END_CF_ACK       ),
+  DOT11_FC_DATA                = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_DATA                ),
+  DOT11_FC_DATA_CF_ACK         = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_DATA_CF_ACK         ),
+  DOT11_FC_DATA_CF_POLL        = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_DATA_CF_POLL        ),
+  DOT11_FC_DATA_CF_ACK_CF_POLL = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_DATA_CF_ACK_CF_POLL ),
+  DOT11_FC_DATA_NULL_FUNCTION  = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_NULL_FUNCTION       ),
+  DOT11_FC_CF_ACK              = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_CF_ACK              ),
+  DOT11_FC_CF_POLL             = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_CF_POLL             ),
+  DOT11_FC_CF_ACK_CF_POLL      = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_CF_ACK_CF_POLL      ),
+  DOT11_FC_DATA_QOS            = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_DATA_QOS            ),
+  DOT11_FC_DATA_NULL_QOS       = ( DOT11_FC_TYPE_DATA | DOT11_FC_SUB_DATA_NULL_QOS       )
+} dot11_Fc_Type_Sub_Type_e;
+
+typedef enum
+{
+  DOT11_FC_TO_DS               = ( 1 << 8  ),
+  DOT11_FC_FROM_DS             = ( 1 << 9  ),
+  DOT11_FC_MORE_FRAG           = ( 1 << 10 ),
+  DOT11_FC_RETRY               = ( 1 << 11 ),
+  DOT11_FC_PWR_MGMT            = ( 1 << 12 ),
+  DOT11_FC_MORE_DATA           = ( 1 << 13 ),
+  DOT11_FC_WEP                 = ( 1 << 14 ),
+  DOT11_FC_ORDER               = ( 1 << 15 )
+} dot11_Fc_Other_e;
+
+typedef enum
+{
+  DOT11_CAPABILITY_ESS               = ( 1 ),
+  DOT11_CAPABILITY_IESS              = ( 1 << 1 ),
+  DOT11_CAPABILITY_CF_POLLABE        = ( 1 << 2 ),
+  DOT11_CAPABILITY_CF_POLL_REQ       = ( 1 << 3 ),
+  DOT11_CAPABILITY_PRIVACY           = ( 1 << 4 ),
+  DOT11_CAPABILITY_PREAMBLE          = ( 1 << 5 ),
+  DOT11_CAPABILITY_PBCC              = ( 1 << 6 ),
+  DOT11_CAPABILITY_AGILE             = ( 1 << 7 ),
+} dot11_Capability_e;
+
+#define  DOT11_FC_TO_DS_SHIFT        8
+#define  DOT11_FC_FROM_DS_SHIFT      9
+#define  DOT11_FC_MORE_FRAG_SHIFT   10
+#define  DOT11_FC_RETRY_SHIFT       11
+#define  DOT11_FC_PWR_MGMT_SHIFT    12
+#define  DOT11_FC_MORE_DATA_SHIFT   13
+#define  DOT11_FC_WEP_SHIFT         14
+#define  DOT11_FC_ORDER_SHIFT       15
+
+#define IS_WEP_ON(fc)       ((TRUE << DOT11_FC_WEP_SHIFT) & (fc))
+#define IS_DATA(fc)         (((DOT11_FC_TYPE_MASK) & (fc)) == DOT11_FC_TYPE_DATA)
+#define IS_LEGACY_DATA(fc)  (((DOT11_FC_TYPESUBTYPE_MASK) & (fc)) == DOT11_FC_DATA)
+#define IS_AUTH(fc)         (((DOT11_FC_AUTH) & (fc)) == DOT11_FC_AUTH)
+#define IS_QOS_FRAME(fc)    ( (((fc) & (DOT11_FC_TYPESUBTYPE_MASK)) == DOT11_FC_DATA_QOS)   ||   \
+                              (((fc) & (DOT11_FC_TYPESUBTYPE_MASK)) == DOT11_FC_DATA_NULL_QOS) )
+
+
+
+#define TUs_TO_MSECs(x)     (((x) << 10) / 1000)
+
+#define TIME_STAMP_LEN  8
+
+/* SequenceControl field of the 802.11 header */
+/**/
+/* bit    15 - 4           3 - 0*/
+/* +-------------------+-----------+*/
+/* |  Sequence Number  | Fragment  |*/
+/* |                   |  Number   |*/
+/* +-------------------+-----------+*/
+/*         12                4*/
+
+typedef enum
+{
+  DOT11_SC_FRAG_NUM_MASK = ( 0xf   << 0 ),
+  DOT11_SC_SEQ_NUM_MASK  = ( 0xfff << 4 )
+} dot11_Sc_t;
+
+#define DOT11_QOS_CONTROL_ACK        0x0000
+#define DOT11_QOS_CONTROL_DONT_ACK   0x0020
+
+#pragma pack(1)
+PACKED_STRUCT( dot11_header_t,
+
+  UINT16        fc;
+  UINT16        duration;
+  macAddress_t  address1;
+  macAddress_t  address2;
+  macAddress_t  address3;
+  UINT16        seqCtrl;
+  UINT16        qosControl;
+/*  macAddress_t    address4;*/
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( legacy_dot11_header_t,
+
+  UINT16        fc;
+  UINT16        duration;
+  macAddress_t  address1;
+  macAddress_t  address2;
+  macAddress_t  address3;
+  UINT16        seqCtrl;
+);
+#pragma pack()
+
+
+
+#pragma pack(1)
+PACKED_STRUCT( dot11_mgmtHeader_t,
+
+  UINT16        fc;
+  UINT16        duration;
+  macAddress_t  DA;
+  macAddress_t  SA;
+  macAddress_t  BSSID;
+  UINT16        seqCtrl;
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( Wlan_LlcHeader_T,
+
+  UINT8     DSAP;
+  UINT8     SSAP;
+  UINT8     Control;
+  UINT8     OUI[3];
+  UINT16    Type;
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( dot11_PsPollFrameHeader_t,
+
+  UINT16        fc;
+  UINT16        AID;
+  macAddress_t  BSSID;
+  macAddress_t  TA;
+);
+#pragma pack()
+
+
+
+#define FCS_SIZE    4
+
+#define WLAN_HDR_LEN                            24
+#define WLAN_QOS_HDR_LEN                        26
+#define WLAN_SNAP_HDR_LEN                       8
+#define WLAN_WITH_SNAP_HEADER_MAX_SIZE          (WLAN_HDR_LEN + WLAN_SNAP_HDR_LEN)
+#define WLAN_WITH_SNAP_QOS_HEADER_MAX_SIZE      (WLAN_QOS_HDR_LEN + WLAN_SNAP_HDR_LEN)
+
+#define GET_MAX_HEADER_SIZE(macHeaderPointer,headerSize)   if( ( ((*(UINT16*)(macHeaderPointer)) & DOT11_FC_TYPESUBTYPE_MASK) == DOT11_FC_DATA_QOS ) || ( ((*(UINT16*)(macHeaderPointer)) & DOT11_FC_TYPESUBTYPE_MASK) == DOT11_FC_DATA_NULL_QOS ) ) *headerSize = WLAN_QOS_HDR_LEN; else *headerSize = WLAN_HDR_LEN;
+
+/* data body max length */
+#define MAX_DATA_BODY_LENGTH                2312
+
+/****************************************************************************************
+    The next table is defined in 802.11 spec section 7.2.2 for the address field contents :
+    To DS   From DS     Address 1    Address 2  Address 3    Address 4
+    -------------------------------------------------------------------
+    0           0           DA          SA          BSSID       N/A
+    0           1           DA          BSSID       SA          N/A
+    1           0           BSSID       SA          DA          N/A
+    1           1           RA          TA          DA          SA         
+    
+NOTE: We only support packets coming from within the DS (i.e. From DS = 0)
+*****************************************************************************************/
+/* return the destination address used in *dot11_header_t */
+#define GET_DA_FROM_DOT11_HEADER_T(pDot11Hdr)   ((pDot11Hdr->fc & DOT11_FC_TO_DS) ? (&pDot11Hdr->address3) : (&pDot11Hdr->address1)) 
+
+
+/*
+ * MANAGEMENT
+ * -----------------
+ */
+
+/* mgmt body max length */
+#define MAX_MGMT_BODY_LENGTH                2312
+/* maximal length of beacon body - note that actual beacons may actually be longer
+   than this size, at least according to the spec, but so far no larger beacon was seen */
+#define MAX_BEACON_BODY_LENGTH              300
+
+/* general mgmt frame structure */
+
+PACKED_STRUCT( dot11_mgmtFrame_t,
+
+    dot11_mgmtHeader_t  hdr;
+    char                body[MAX_MGMT_BODY_LENGTH];
+);
+
+/* Capabilities Information Field - IN THE AIR */
+/**/
+/*  bit  15      14       13         12        11         10      9      8      7   -   0*/
+/* +----------+------+----------+---------+----------+---------+------+-----+---------------+*/
+/* |  Channel |      |  Short   | Privacy | CF Poll  |   CF    |      |     |   RESERVED    |   */
+/* |  Agility | PBCC | Preamble |         | Request  | Pollable| IBSS | ESS |               |*/
+/* +----------+------+----------+---------+----------+---------+------+-----+---------------+   */
+/*       1        1       1          1         1          1       1      1*/
+
+
+/* Capabilities Information Field - IN THE MGMT SOFTWARE AFTER THE SWAP */
+/**/
+/* bit 15 - 8         7        6       5          4         3          2       1      0*/
+/* +------------+----------+------+----------+---------+----------+---------+------+-----+*/
+/* |            |  Channel |      |  Short   | Privacy | CF Poll  |   CF    |      |     |*/
+/* |  Reserved  |  Agility | PBCC | Preamble |         | Request  | Pollable| IBSS | ESS |*/
+/* +------------+----------+------+----------+---------+----------+---------+------+-----+*/
+/*       8            1        1       1          1         1          1       1      1*/
+
+
+
+typedef enum
+{ 
+  DOT11_CAPS_ESS             = ( 1 << 0 ),
+  DOT11_CAPS_IBSS            = ( 1 << 1 ),
+  DOT11_CAPS_CF_POLLABLE     = ( 1 << 2 ),
+  DOT11_CAPS_CF_POLL_REQUEST = ( 1 << 3 ),
+  DOT11_CAPS_PRIVACY         = ( 1 << 4 ),
+  DOT11_CAPS_SHORT_PREAMBLE  = ( 1 << 5 ),
+  DOT11_CAPS_PBCC            = ( 1 << 6 ),
+  DOT11_CAPS_CHANNEL_AGILITY = ( 1 << 7 ),
+  DOT11_SPECTRUM_MANAGEMENT  = ( 1 << 8 ),
+  DOT11_CAPS_QOS_SUPPORTED   = ( 1 << 9 ),
+  DOT11_CAPS_SHORT_SLOT_TIME = (1  << 10),
+
+  DOT11_CAPS_APSD_SUPPORT    = ( 1 << 11),
+} dot11_capabilities_e;
+
+typedef enum 
+{
+    /* ESS */
+    CAP_ESS_MASK            = 1,
+    CAP_ESS_SHIFT           = 0,
+
+    /* IBSS */
+    CAP_IBSS_MASK           = 1,
+    CAP_IBSS_SHIFT          = 1,
+
+    /* CF Pollable */
+    CAP_CF_POLL_MASK        = 1,
+    CAP_CF_POLL_SHIFT       = 2,
+    
+    /* CF Poll request */
+    CAP_CF_REQ_MASK         = 1,
+    CAP_CF_REQ_SHIFT        = 3,
+    
+    /* Privacy */
+    CAP_PRIVACY_MASK        = 1,
+    CAP_PRIVACY_SHIFT       = 4,
+
+    /* Short Preamble*/
+    CAP_PREAMBLE_MASK       = 1,
+    CAP_PREAMBLE_SHIFT      = 5,
+    
+    /* PBCC */
+    CAP_PBCC_MASK           = 1,
+    CAP_PBCC_SHIFT          = 6,
+    
+    /* Agile */
+    CAP_AGILE_MASK          = 1,
+    CAP_AGILE_SHIFT         = 7,
+
+    /* Slot time */
+    CAP_SLOT_TIME_MASK      = 1,
+    CAP_SLOT_TIME_SHIFT     = 10,
+
+    /* APSD */
+    CAP_APSD_MASK           = 1,
+    CAP_APSD_SHIFT          = 11,
+
+
+} wdrv_mgmtCapabilities_e;
+
+
+/*
+ * 802.11 Information elements
+ * ---------------------------
+ */
+
+
+PACKED_STRUCT( dot11_eleHdr_t,
+
+  UINT8 eleId;
+  UINT8 eleLen;
+);
+
+/* fixed fields lengths, except of currentAP & timestamp*/
+#define FIX_FIELD_LEN       2
+
+/* SSID Information Element */
+#define DOT11_SSID_ELE_ID   0
+
+PACKED_STRUCT( dot11_SSID_t,
+
+  dot11_eleHdr_t    hdr;
+  char              serviceSetId[MAX_SSID_LEN];
+);
+
+
+/* Supportted rates Information Element */
+#define DOT11_SUPPORTED_RATES_ELE_ID        1
+#define DOT11_EXT_SUPPORTED_RATES_ELE_ID        50
+
+PACKED_STRUCT( dot11_RATES_t,
+
+  dot11_eleHdr_t hdr;
+  UINT8 rates[MAX_SUPPORTED_RATES];
+);
+
+
+#define ERP_IE_NON_ERP_PRESENT_MASK         0x1
+#define ERP_IE_USE_PROTECTION_MASK          0x2
+#define ERP_IE_BARKER_PREAMBLE_MODE_MASK    0x4
+#define DOT11_ERP_IE_ID 42
+
+PACKED_STRUCT( dot11_ERP_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           ctrl;
+);
+
+/* RSN Information Element */
+#define DOT11_RSN_MAX                       255 
+
+PACKED_STRUCT( dot11_RSN_t,
+
+  dot11_eleHdr_t hdr;
+  UINT8 rsnIeData[DOT11_RSN_MAX];
+);
+
+/* general definitions needed by whalWpa.c and rsn.c */
+#define IV_FIELD_SIZE   4 
+#define ICV_FIELD_SIZE  4
+#define MIC_FIELD_SIZE  8 
+#define EIV_FIELD_SIZE  4
+#define WEP_AFTER_HEADER_FIELD_SIZE  IV_FIELD_SIZE
+#define TKIP_AFTER_HEADER_FIELD_SIZE (IV_FIELD_SIZE + EIV_FIELD_SIZE)
+#define AES_AFTER_HEADER_FIELD_SIZE  8
+
+
+/* DS params Information Element */
+#define DOT11_DS_PARAMS_ELE_ID      3
+#define DOT11_DS_PARAMS_ELE_LEN     1
+
+PACKED_STRUCT( dot11_DS_PARAMS_t,
+
+  dot11_eleHdr_t hdr;
+  UINT8  currChannel;
+);
+
+
+/* DS params Information Element */
+#define DOT11_IBSS_PARAMS_ELE_ID    6
+#define DOT11_IBSS_PARAMS_ELE_LEN   2
+
+PACKED_STRUCT( dot11_IBSS_PARAMS_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT16          atimWindow;
+);
+
+#define DOT11_FH_PARAMS_ELE_ID      2
+#define DOT11_FH_PARAMS_ELE_LEN     5
+
+PACKED_STRUCT( dot11_FH_PARAMS_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT16          dwellTime;
+    UINT8           hopSet;
+    UINT8           hopPattern;
+    UINT8           hopIndex;
+);
+
+/* tim Information Element */
+#define DOT11_TIM_ELE_ID    5
+#define DOT11_PARTIAL_VIRTUAL_BITMAP_MAX    251
+
+PACKED_STRUCT( dot11_TIM_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           dtimCount;
+    UINT8           dtimPeriod;
+    UINT8           bmapControl;
+    UINT8           partialVirtualBmap[DOT11_PARTIAL_VIRTUAL_BITMAP_MAX];
+);
+
+/* tim Information Element */
+#define DOT11_CF_ELE_ID             4
+#define DOT11_CF_PARAMS_ELE_LEN     6
+
+PACKED_STRUCT( dot11_CF_PARAMS_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           cfpCount;
+    UINT8           cfpPeriod;
+    UINT16          cfpMaxDuration;
+    UINT16          cfpDurRemain;
+);
+
+/* Challenge text Information Element */
+#define DOT11_CHALLENGE_TEXT_ELE_ID     16
+#define DOT11_CHALLENGE_TEXT_MAX        253
+
+PACKED_STRUCT( dot11_CHALLENGE_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           text[ DOT11_CHALLENGE_TEXT_MAX ];
+);
+
+
+/* Country Inforamtion Element */
+#define DOT11_COUNTRY_ELE_ID        7
+#define DOT11_COUNTRY_ELE_LEN_MAX   ( ((NUM_OF_MAX_TRIPLET_CHANNEL+1)*3) + !((NUM_OF_MAX_TRIPLET_CHANNEL&0x1)))
+
+PACKED_STRUCT( dot11_COUNTRY_t,
+
+    dot11_eleHdr_t  hdr;
+    countryIE_t     countryIE;
+);
+
+
+/* Power Constraint Information Element */
+#define DOT11_POWER_CONSTRAINT_ELE_ID       (32)
+#define DOT11_POWER_CONSTRAINT_ELE_LEN      (1)
+
+PACKED_STRUCT( dot11_POWER_CONSTRAINT_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           powerConstraint;
+);
+
+
+
+/* Power Capability Information Element */
+#define DOT11_CAPABILITY_ELE_ID         (33)
+#define DOT11_CAPABILITY_ELE_LEN        (2)
+
+PACKED_STRUCT( dot11_CAPABILITY_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           minTxPower;
+    UINT8           maxTxPower;
+);
+
+/* TPC request Information Element */
+#define DOT11_TPC_REQUEST_ELE_ID        (34)
+#define DOT11_TPC_REQUEST_ELE_LEN       (0)
+
+PACKED_STRUCT( dot11_TPC_REQUEST_t,
+
+    dot11_eleHdr_t  hdr;
+);
+
+/* TPC report Information Element */
+#define DOT11_TPC_REPORT_ELE_ID         (35)
+#define DOT11_TPC_REPORT_ELE_LEN        (2)
+
+PACKED_STRUCT( dot11_TPC_REPORT_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           transmitPower;
+    UINT8           linkMargin;
+);
+
+#ifdef EXC_MODULE_INCLUDED
+/* Cell Transmit Power Information Element */
+#define DOT11_CELL_TP_ELE_ID            (150)
+#define DOT11_CELL_TP_ELE_LEN           (6)
+
+PACKED_STRUCT( dot11_CELL_TP_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           oui[4];
+    UINT8           power;
+    UINT8           reerved;
+);
+
+#define   DOT11_CELL_TP \
+    dot11_CELL_TP_t         *cellTP;
+    
+#else
+#define   DOT11_CELL_TP
+#endif
+
+/* Channel Supported Information Element */
+#define DOT11_CHANNEL_SUPPORTED_ELE_ID  (36)
+#define DOT11_CHANNEL_SUPPORTED_ELE_LEN (26)
+
+PACKED_STRUCT( dot11_CHANNEL_SUPPORTED_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           supportedChannel[DOT11_CHANNEL_SUPPORTED_ELE_LEN];
+
+);
+
+/* Channel Switch Announcement Information Element */
+#define DOT11_CHANNEL_SWITCH_ELE_ID     (37)
+#define DOT11_CHANNEL_SWITCH_ELE_LEN    (3)
+
+PACKED_STRUCT( dot11_CHANNEL_SWITCH_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           channelSwitchMode;
+    UINT8           channelNumber;
+    UINT8           channelSwitchCount;
+);
+
+#define MAX_NUM_REQ (16)
+
+/* Measurement request Information Element */
+#define DOT11_MEASUREMENT_REQUEST_ELE_ID        (38)
+#define DOT11_MEASUREMENT_REQUEST_LEN           (2)
+#define DOT11_MEASUREMENT_REQUEST_ELE_LEN       (3 + DOT11_MEASUREMENT_REQUEST_LEN*MAX_NUM_REQ)
+
+PACKED_STRUCT( dot11_MEASUREMENT_REQUEST_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           measurementToken;
+    UINT8           measurementMode;
+    UINT8           measurementType;
+    UINT8           measurementRequests[DOT11_MEASUREMENT_REQUEST_LEN*MAX_NUM_REQ];
+);
+
+
+/* Measurement report Information Element */
+#define DOT11_MEASUREMENT_REPORT_ELE_ID     (39)
+#define DOT11_MAX_MEASUREMENT_REPORT_LEN    (4)
+#define DOT11_MIN_MEASUREMENT_REPORT_IE_LEN (3)
+#define DOT11_MEASUREMENT_REPORT_ELE_IE_LEN (DOT11_MIN_MEASUREMENT_REPORT_IE_LEN + DOT11_MAX_MEASUREMENT_REPORT_LEN*MAX_NUM_REQ)
+
+PACKED_STRUCT( dot11_MEASUREMENT_REPORT_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           measurementToken;
+    UINT8           measurementMode;
+    UINT8           measurementType;
+    UINT8           measurementReports[DOT11_MAX_MEASUREMENT_REPORT_LEN*MAX_NUM_REQ];
+);
+
+/* Quiet Information Element */
+#define DOT11_QUIET_ELE_ID              (40)
+#define DOT11_QUIET_ELE_LEN             (6)
+
+PACKED_STRUCT( dot11_QUIET_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           quietCount;
+    UINT8           quietPeriod;
+    UINT16          quietDuration;
+    UINT16          quietOffset;
+);
+
+
+/* QoS Capability Information Element */
+#define DOT11_QOS_CAPABILITY_ELE_ID     (46)
+#define DOT11_QOS_CAPABILITY_ELE_LEN    (1)
+
+#define AC_APSD_FLAGS_MASK              (1)
+#define Q_ACK_BITG_MASK                 (1)
+#define MAX_SP_LENGTH_MASK              (3)
+#define MORE_DATA_ACK_MASK              (1)
+
+#define AC_VO_APSD_FLAGS_SHIFT          (0)
+#define AC_VI_APSD_FLAGS_SHIFT          (1)
+#define AC_BK_APSD_FLAGS_SHIFT          (2)
+#define AC_BE_APSD_FLAGS_SHIFT          (3)
+#define Q_ACK_FLAGS_SHIFT               (4)
+#define MAX_SP_LENGTH_SHIFT             (5)
+#define MORE_DATA_ACK_SHIFT             (7)
+
+#define QOS_CONTROL_UP_SHIFT            (0)
+
+#define AP_QOS_INFO_UAPSD_MASK          (1)
+#define AP_QOS_INFO_UAPSD_SHIFT         (7)
+
+
+PACKED_STRUCT( dot11_QOS_CAPABILITY_IE_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           QosInfoField;
+);
+
+/* WPS Information Element */
+#define DOT11_WPS_ELE_ID       (221)
+#define DOT11_WPS_OUI          {0x00, 0x50, 0xF2, 0x04}
+#define DOT11_WPS_OUI_LEN      4
+
+/* WME Information Element */
+#define DOT11_WME_ELE_ID                (221)
+#define DOT11_WME_ELE_LEN               (7)
+
+PACKED_STRUCT( dot11_WME_IE_t,
+
+    dot11_eleHdr_t  hdr;
+    UINT8           OUI[3];
+    UINT8           OUIType;
+    UINT8           OUISubType;
+    UINT8           version;
+    UINT8           ACInfoField;
+);
+
+
+/* WME Parameter Information Element */
+#define DOT11_WME_PARAM_ELE_ID          (221)
+#define DOT11_WME_PARAM_ELE_LEN         (24)
+
+PACKED_STRUCT( dot11_WME_PARAM_t,
+
+    dot11_eleHdr_t      hdr;
+    UINT8               OUI[3];
+    UINT8               OUIType;
+    UINT8               OUISubType;
+    UINT8               version;
+    UINT8               ACInfoField;
+    UINT8               reserved;
+    ACParameters_t      WME_ACParameteres;
+);
+
+#define dot11_WPA_OUI_TYPE                  (1)
+#define dot11_WME_OUI_TYPE                  (2)
+#define dot11_WME_OUI_SUB_TYPE_IE           (0)
+#define dot11_WME_OUI_SUB_TYPE_PARAMS_IE    (1)
+#define dot11_WME_VERSION                   (1)
+#define dot11_WME_ACINFO_MASK               0x0f
+
+/* -------------------- TSPEC ----------------- */
+
+#pragma pack(1)
+PACKED_STRUCT( tsInfo_t,
+
+    UINT8   tsInfoArr[3];
+
+);
+#pragma pack()
+
+
+#pragma pack(1)
+
+/* This structure is part of the TSPEC structure. It was seperated since there are some cases (such as DEL_TS), which we dont need
+to send ALL the TSPEC structure, but only as far as TsInfo. The TSPEC structure contains this smaller structure */
+PACKED_STRUCT( dot11_WME_TSPEC_IE_hdr_t,
+
+    dot11_eleHdr_t  hdr;
+    
+    UINT8   OUI[3];
+    UINT8   oui_type;
+    UINT8   oui_subtype;
+    UINT8   version;
+
+    tsInfo_t tsInfoField;
+);
+
+
+PACKED_STRUCT( dot11_WME_TSPEC_IE_t,
+
+    dot11_WME_TSPEC_IE_hdr_t tHdr;
+
+    UINT16  nominalMSDUSize;
+    UINT16  maximumMSDUSize;
+    UINT32  minimumServiceInterval;
+    UINT32  maximumServiceInterval;
+    UINT32  inactivityInterval;
+    UINT32  suspensionInterval;
+    UINT32  serviceStartTime;
+    UINT32  minimumDataRate;
+    UINT32  meanDataRate;
+    UINT32  peakDataRate;
+    UINT32  maximumBurstSize;
+    UINT32  delayBound;
+    UINT32  minimumPHYRate;
+    UINT16  surplusBandwidthAllowance;
+    UINT16  mediumTime;
+);
+#pragma pack()
+
+#define WME_TSPEC_IE_ID                         221
+#define WME_TSPEC_IE_LEN                        61
+#define WME_TSPEC_IE_TSINFO_LEN                 9                
+#define WME_TSPEC_IE_OUI_TYPE                   0x02
+#define WME_TSPEC_IE_OUI_SUB_TYPE               0x02
+#define WME_TSPEC_IE_VERSION                    0x01
+
+/* OUI TYPE values that can be present in management packets inside Cisco vendor specific IE */
+typedef enum
+{
+    TS_METRIX_OUI_TYPE = 0x07,
+    TS_RATE_SET_OUI_TYPE = 0x08,
+    EDCA_LIFETIME_OUI_TYPE = 0x09
+} EXC_IE_OUI_TYPE_t;
+
+#define ADDTS_REQUEST_ACTION                    0x00
+#define ADDTS_RESPONSE_ACTION                   0x01
+#define DELTS_ACTION                            0x02
+
+#define ADDTS_STATUS_CODE_SUCCESS               0x00
+#define DELTS_CODE_SUCCESS                      0x00
+
+#define TS_INFO_0_TRAFFIC_TYPE_MASK             0x01
+#define TS_INFO_0_TSID_MASK                     0x1E
+#define TS_INFO_0_DIRECTION_MASK                0x60
+#define TS_INFO_0_ACCESS_POLICY_MASK            0x80
+
+#define TS_INFO_1_ACCESS_POLICY_MASK            0x01
+#define TS_INFO_1_AGGREGATION_MASK              0x02
+#define TS_INFO_1_APSD_MASK                     0x04    
+#define TS_INFO_1_USER_PRIORITY_MASK            0x38
+#define TS_INFO_1_TSINFO_ACK_POLICY_MASK        0xC0
+
+#define TS_INFO_2_SCHEDULE_MASK                 0x01
+#define TS_INFO_2_RESERVED_MASK                 0xF7    
+
+#define TRAFFIC_TYPE_SHIFT                      0
+#define TSID_SHIFT                              1
+#define DIRECTION_SHIFT                         5
+#define ACCESS_POLICY_SHIFT                     7
+#define AGGREGATION_SHIFT                       1
+#define APSD_SHIFT                              2   
+#define USER_PRIORITY_SHIFT                     3
+#define TSINFO_ACK_POLICY_SHIFT                 6
+#define SCHEDULE_SHIFT                          0
+#define RESERVED_SHIFT                          1
+#define SURPLUS_BANDWIDTH_ALLOW                 13  
+
+#define TS_INFO_0_ACCESS_POLICY_EDCA            0x1                 
+#define NORMAL_ACKNOWLEDGEMENT                  0x00        
+#define NO_SCHEDULE                             0x00        
+#define PS_UPSD                                 0x01
+#define EDCA_MODE                               0x08
+#define FIX_MSDU_SIZE                           0x8000
+
+
+/* 4X Information Element */
+#define DOT11_4X_ELE_ID     0xDD
+#define DOT11_4X_MAX_LEN    64
+#define DOT11_OUI_LEN       3
+#define TI_OUI              {0x08,0x00,0x28}
+#define WPA_IE_OUI          {0x00, 0x50, 0xf2}
+#define EXC_OUI             {0x00, 0x40, 0x96}
+
+
+#define _WlanTIcap_t(_) \
+        _(TI_CAP_4X_CONCATENATION, =        1) \
+        _(TI_CAP_4X_CONT_WINDOW, =          2) \
+        _(TI_CAP_4X_CONT_WINDOW_COMBO, =    3) \
+        _(TI_CAP_4X_TCP_ACK_EMUL, =         4) \
+        _(TI_CAP_TRICK_PACKET_ERP, =        5)
+
+PACKED_ENUM (WlanTIcap_t,_WlanTIcap_t);
+
+
+PACKED_STRUCT( dot11_4X_t,
+
+  dot11_eleHdr_t    hdr;
+  UINT8             fourXCapabilities[DOT11_4X_MAX_LEN];
+);
+
+/* Action field structure
+    used for extended management action such as spectrum management */ 
+
+PACKED_STRUCT( dot11_ACTION_FIELD_t,
+
+    UINT8   category;
+    UINT8   action;
+);
+
+
+/* Management frames sub types */
+typedef enum
+{
+    ASSOC_REQUEST       = 0,
+    ASSOC_RESPONSE      = 1,
+    RE_ASSOC_REQUEST    = 2,
+    RE_ASSOC_RESPONSE   = 3,
+    PROBE_REQUEST       = 4,
+    PROBE_RESPONSE      = 5,
+    BEACON              = 8,
+    ATIM                = 9,
+    DIS_ASSOC           = 10,
+    AUTH                = 11,
+    DE_AUTH             = 12,
+    ACTION              = 13,
+} dot11MgmtSubType_e;
+
+/* Management frames element IDs */
+typedef enum
+{
+    SSID_IE_ID                          = 0,
+    SUPPORTED_RATES_IE_ID               = 1,
+    FH_PARAMETER_SET_IE_ID              = 2,
+    DS_PARAMETER_SET_IE_ID              = 3,
+    CF_PARAMETER_SET_IE_ID              = 4,
+    TIM_IE_ID                           = 5,
+    IBSS_PARAMETER_SET_IE_ID            = 6,
+    COUNTRY_IE_ID                       = 7,
+    CHALLANGE_TEXT_IE_ID                = 16,
+    POWER_CONSTRAINT_IE_ID              = 32,
+    TPC_REPORT_IE_ID                    = 35,
+    CHANNEL_SWITCH_ANNOUNCEMENT_IE_ID   = 37,
+    QUIET_IE_ID                         = 40,
+    ERP_IE_ID                           = 42,
+    QOS_CAPABILITY_IE_ID                = 46,   
+    RSN_IE_ID                           = 48,
+    EXT_SUPPORTED_RATES_IE_ID           = 50,
+    EXC_EXT_1_IE_ID                     = 133,
+    EXC_EXT_2_IE_ID                     = 149,  
+    CELL_POWER_IE                       = 150, /*EXC*/
+    WPA_IE_ID                           = 221,
+    TI_4X_IE_ID                         = WPA_IE_ID
+
+} dot11MgmtIeId_e;
+
+/* Spectrum Management Action fields */
+typedef enum
+{
+    MEASUREMENT_REQUEST             = 0,
+    MEASUREMENT_REPORT              = 1,
+    TPC_REQUEST                     = 2,
+    TPC_REPORT                      = 3,
+    CHANNEL_SWITCH_ANNOUNCEMENT     = 4,
+} dot11ActionFrameTypes_e;
+
+/* Category fields (such as apectrum management)*/
+typedef enum
+{
+    CATAGORY_SPECTRUM_MANAGEMENT        = 0,
+    CATAGORY_QOS                        = 1,
+    WME_CATAGORY_QOS                    = 17,
+    CATAGORY_SPECTRUM_MANAGEMENT_ERROR  = 128,
+} dot11CategoryTypes_e;
+
+
+/* management templates to set to the HAL */
+
+PACKED_STRUCT( probeReqTemplate_t,
+
+    dot11_mgmtHeader_t  hdr;
+    char                infoElements[sizeof( dot11_SSID_t ) + 
+                                     sizeof( dot11_RATES_t ) +
+                                     sizeof( dot11_RATES_t )    ];
+);
+
+
+PACKED_STRUCT( probeRspTemplate_t,
+
+    dot11_mgmtHeader_t  hdr;
+    UINT8               timeStamp[TIME_STAMP_LEN];
+    UINT16              beaconInterval;
+    UINT16              capabilities;
+    char                infoElements[ sizeof( dot11_SSID_t ) + 
+                                      sizeof( dot11_RATES_t ) +
+                                      sizeof( dot11_RATES_t ) +
+                                      sizeof( dot11_DS_PARAMS_t ) +
+                                      sizeof( dot11_COUNTRY_t)      ];
+);
+
+
+PACKED_STRUCT( nullDataTemplate_t,
+
+    dot11_mgmtHeader_t  hdr;
+);
+
+
+PACKED_STRUCT( psPollTemplate_t,
+
+   dot11_PsPollFrameHeader_t   hdr;
+);
+
+
+PACKED_STRUCT( QosNullDataTemplate_t,
+
+   dot11_header_t   hdr;
+);
+
+#pragma pack(1)
+/* Traffic Stream Rate Set (TSRS) info-elements */
+PACKED_STRUCT( dot11_TSRS_STA_IE_t,
+    dot11_eleHdr_t  hdr;
+    UINT8           OUI[3];
+    UINT8           oui_type;
+    UINT8           tsid;
+    UINT8           tsNominalRate;
+);
+
+PACKED_STRUCT( dot11_TSRS_IE_t,
+    dot11_eleHdr_t  hdr;
+    UINT8           OUI[3];
+    UINT8           oui_type;
+    UINT8           tsid;
+    UINT8           tsRates[8];
+);
+
+/* MSDU lifetime info-element */
+PACKED_STRUCT( dot11_MSDU_LIFE_TIME_IE_t,
+    dot11_eleHdr_t  hdr;
+    UINT8           OUI[3];
+    UINT8           oui_type;
+    UINT8           tsid;
+    UINT16          msduLifeTime;
+);
+
+PACKED_STRUCT( dot11_TS_METRICS_IE_t,
+    dot11_eleHdr_t  hdr;
+    UINT8           OUI[3];
+    UINT8           oui_type;
+    UINT8           tsid;
+    UINT8           state;
+    UINT16          measureInterval;
+);
+
+PACKED_STRUCT( EXCv4IEs_t,
+    dot11_TSRS_IE_t             *trafficStreamParameter;
+    dot11_MSDU_LIFE_TIME_IE_t   *edcaLifetimeParameter;
+    dot11_TS_METRICS_IE_t       *tsMetrixParameter;
+);
+#pragma pack()
+
+/* Disassociation frame structure */
+#pragma pack(1)
+PACKED_STRUCT( disAssoc_t,
+
+    UINT16  reason;    
+);
+#pragma pack()
+
+/* (Re)Association response frame structure */
+#define ASSOC_RESP_FIXED_DATA_LEN 6
+#pragma pack(1)
+PACKED_STRUCT( assocRsp_t,
+
+    UINT16          capabilities;      
+    UINT16          status;    
+    UINT16          aid;       
+    dot11_RATES_t   *pRates;    
+    dot11_RATES_t   *pExtRates;
+    BOOL            useProtection;
+    BOOL            ciscoIEPresent;
+    preamble_e      barkerPreambleMode;
+    BOOL            NonErpPresent;  
+    dot11_4X_t                  *fourXParams;   
+    dot11_WME_PARAM_t           *WMEParams;
+    dot11_RSN_t                 *pRsnIe;
+    UINT8                       rsnIeLen;
+    dot11_QOS_CAPABILITY_IE_t   *QoSCapParameters;
+    dot11_WME_TSPEC_IE_t        *tspecVoiceParameters;
+    dot11_WME_TSPEC_IE_t        *tspecSignalParameters;
+    EXCv4IEs_t                  excIEs[MAX_NUM_OF_AC];
+);
+#pragma pack()
+
+
+/* Probe response frame structure */
+/* Please notice, the order of fields in the beacon must be identical to the order of 
+    field in the probe response. This is because of the parsing that is done by the site manager. */
+
+/* In case the removing the PACKED_STRUCT for beacon_probeRsp_t it's possible to merge the 2 structures below */
+
+#ifdef EXC_MODULE_INCLUDED
+
+PACKED_STRUCT( beacon_probeRsp_t,
+
+    char                        timestamp[TIME_STAMP_LEN];     
+    UINT16                      beaconInerval;     
+    UINT16                      capabilities;      
+    dot11_SSID_t                *pSsid;    
+    dot11_RATES_t               *pRates;
+    dot11_COUNTRY_t             *country;
+    dot11_POWER_CONSTRAINT_t    *powerConstraint;
+    dot11_CHANNEL_SWITCH_t      *channelSwitch;
+    dot11_QUIET_t               *quiet;
+    dot11_TPC_REPORT_t          *TPCReport;
+    dot11_CELL_TP_t             *cellTP;
+    dot11_WME_PARAM_t           *WMEParams;
+
+    dot11_RATES_t       *pExtRates;
+    BOOL            useProtection;
+    preamble_e      barkerPreambleMode;
+    BOOL                NonErpPresent;  
+    dot11_FH_PARAMS_t   *pFHParamsSet;     
+    dot11_DS_PARAMS_t   *pDSParamsSet;     
+    dot11_CF_PARAMS_t   *pCFParamsSet;     
+    dot11_IBSS_PARAMS_t *pIBSSParamsSet;
+    dot11_4X_t                  *fourXParams;           /* for probe response only */
+    dot11_RSN_t         *pRsnIe;
+    UINT8                rsnIeLen;
+    dot11_QOS_CAPABILITY_IE_t   *QoSCapParameters;
+    dot11_TIM_t                 *pTIM;                  /* for beacons only */
+);
+
+#else
+
+PACKED_STRUCT( beacon_probeRsp_t,
+
+    char                        timestamp[TIME_STAMP_LEN];     
+    UINT16                      beaconInerval;     
+    UINT16                      capabilities;      
+    dot11_SSID_t                *pSsid;    
+    dot11_RATES_t               *pRates;
+    dot11_COUNTRY_t             *country;
+    dot11_POWER_CONSTRAINT_t    *powerConstraint;
+    dot11_CHANNEL_SWITCH_t      *channelSwitch;
+    dot11_QUIET_t               *quiet;
+    dot11_TPC_REPORT_t          *TPCReport;
+    dot11_WME_PARAM_t           *WMEParams;
+    dot11_RATES_t       *pExtRates;
+    BOOL            useProtection;
+    preamble_e      barkerPreambleMode;
+    BOOL                NonErpPresent;  
+    dot11_FH_PARAMS_t   *pFHParamsSet;     
+    dot11_DS_PARAMS_t   *pDSParamsSet;     
+    dot11_CF_PARAMS_t   *pCFParamsSet;     
+    dot11_IBSS_PARAMS_t *pIBSSParamsSet;
+    dot11_4X_t                  *fourXParams;           /* for probe response only */
+    dot11_RSN_t         *pRsnIe;
+    UINT8                rsnIeLen;
+    dot11_QOS_CAPABILITY_IE_t   *QoSCapParameters;
+    dot11_TIM_t                 *pTIM;                  /* for beacons only */
+);
+
+#endif
+
+/* Authentication message frame structure */
+#pragma pack(1)
+PACKED_STRUCT( authMsg_t,
+
+    UINT16              authAlgo;      
+    UINT16              seqNum;    
+    UINT16              status;    
+    dot11_CHALLENGE_t   *pChallenge;       
+);
+#pragma pack()
+
+/* DeAuthentication message frame structure */
+#pragma pack(1)
+PACKED_STRUCT( deAuth_t,
+
+    UINT16  reason;    
+);
+#pragma pack()
+
+/* Action message frame structure */
+#pragma pack(1)
+PACKED_STRUCT( action_t,
+
+    UINT8   frameType;
+    UINT8   category;
+    UINT8   action;
+);
+#pragma pack()
+
+
+/* TPCReport message frame structure */
+#pragma pack(1)
+PACKED_STRUCT( TPCReport_t,
+
+    dot11_ACTION_FIELD_t    actionField;
+    UINT8   dialogToken;
+    dot11_TPC_REPORT_t  TPCReport;
+);
+#pragma pack()
+
+/* Measurement Report message frame structure */
+#pragma pack(1)
+PACKED_STRUCT( MeasurementReportFrame_t,
+
+    dot11_ACTION_FIELD_t    actionField;
+    UINT8   dialogToken;
+    dot11_MEASUREMENT_REPORT_t  measurementReportIE;
+);
+#pragma pack()
+
+typedef enum 
+{
+    STATUS_SUCCESSFUL                  =   0,
+    STATUS_UNSPECIFIED,                
+       STATUS_AUTH_REJECT,                     
+       STATUS_ASSOC_REJECT,                    
+    STATUS_SECURITY_FAILURE,   
+       STATUS_AP_DEAUTHENTICATE,       
+       STATUS_AP_DISASSOCIATE, 
+       STATUS_ROAMING_TRIGGER          
+
+} mgmtStatus_e;
+
+/* Used as a status code in case of STATUS_AUTH_REJECT or STATUS_ASSOC_REJECT that was not received at all */
+#define STATUS_PACKET_REJ_TIMEOUT      0xFFFF
+
+/* As defined in 802.11 spec section 7.3.1 - status codes for deAuth packet */
+#define STATUS_CODE_802_1X_AUTHENTICATION_FAILED 23
+
+/* map field included in measurement report IE (only in basic report) */
+typedef enum
+{
+  DOT11_BSS_ONLY                    = (0x01),
+  DOT11_OFDM_ONLY                   = (0x02),
+  DOT11_RADAR_AND_UNIDENTIFIED      = (0x0C),
+} dot11_Map_Sub_Field_e;
+
+
+/* MACROS */
+#define INRANGE(x,low,high)    (((x) >= (low)) && ((x) <= (high)))
+#define OUTRANGE(x,low,high)   (((x) < (low)) || ((x) > (high)))
+
+#define WLAN_4X_LEN_FIELD_LEN       2
+#define WLAN_DA_FIELD_LEN           6
+#define WLAN_DA_FIELD_OFFSET        16
+#define WLAN_BSSID_FIELD_OFFSET     4
+#define WLAN_SA_FIELD_OFFSET        10
+#define WLAN_CONCAT_HDR_LEN     (WLAN_4X_LEN_FIELD_LEN + WLAN_DA_FIELD_LEN) /* 2+6 = 8 */
+#define WLAN_CONCAT_HDR_OFFSET  (WLAN_HDR_LEN - WLAN_CONCAT_HDR_LEN) /* 24-8 = 16 */ 
+
+/* 4X definitions */
+#pragma pack(1)
+PACKED_STRUCT( Wdrv4xHeader_t,
+
+  UINT8         type;
+  UINT8         headerLen;
+  UINT16        txFlags;
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( dot11_DataMsduHeader_t,
+
+   dot11_header_t dot11Header;
+   Wlan_LlcHeader_T  snapHeader;
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( legacy_dot11_DataMsduHeader_t,
+
+   legacy_dot11_header_t dot11Header;
+   Wlan_LlcHeader_T  snapHeader;
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( dot114xMsdu_t,
+
+    legacy_dot11_DataMsduHeader_t msduHeader;
+    Wdrv4xHeader_t  header4x;
+);
+#pragma pack()
+
+#pragma pack(1)
+PACKED_STRUCT( Wdrv4xConcatHeader_t,
+
+  UINT16        len;
+  macAddress_t  SaDa;
+);
+#pragma pack()
+
+typedef enum 
+{
+    NOT_4X_MSDU    = -1,
+    CONCATENATION  = 1,
+    ACK_EMULATION  = 2,
+    MANAGMENT_4X   = 3
+} Wlan4XType_t;
+
+
+#define WLAN_HEADER_TYPE_CONCATENATION 0x01
+#define WLAN_CONCAT_HEADER_LEN 2
+
+#define WLAN_4X_CONCAT_HDR_LEN   4
+
+#define WLAN_4X_CONCAT_MORE_BIT   0x0001 
+
+
+#endif   /* _802_11_INFO_DEFS_H */
diff --git a/sta_dk_4_0_4_32/common/src/inc/Core_Api.h b/sta_dk_4_0_4_32/common/src/inc/Core_Api.h
new file mode 100644 (file)
index 0000000..fa08cd6
--- /dev/null
@@ -0,0 +1,74 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       Core.h                                                                                                 */
+/*    PURPOSE:                                                                                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _CORE_API_H_
+#define _CORE_API_H_
+
+#include "memMngrEx.h"
+#include "whalBus_Defs.h"
+#include "Core_AdaptTx.h"
+
+
+/*#if 1 /* IMPORT_FROM_4_0_1 */*/
+/*typedef struct*/
+/*{*/
+       /* Import the 4.0.1 Data Path Tx/Rx Callbacks */
+       /*CoreAdapt_TxCompleteStatusCB_t                ctrlData_TxCompleteStatusCB;*/
+       /*CoreAdapt_SendPacketTranferCB_t               txData_SendPacketTranferCB;*/
+       /*CoreAdapt_QueueFreeEventCB_t          txData_QueueFreeEventCB;*/
+       /*CoreAdapt_msduReceiveCB_t                     rxData_msduReceiveCB;   */
+
+       /*failureEventCB_t                                      healthMonitor_FailureEventCB;*/
+/*} coreCallbacks_t;*/
+
+/*#else*/
+
+/*typedef struct*/
+/*{*/
+/*     TxCompleteStatusCB_t    ctrlData_TxCompleteStatusCB;*/
+/*     msduReceiveCB_t                 rxData_msduReceiveCB;*/
+/*     scanCompleteCB_t                scan_scanCompleteCB;*/
+/*     failureEventCB_t                healthMonitor_FailureEventCB;*/
+/*} coreCallbacks_t;*/
+
+/*#endif*/
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/inc/Ethernet.h b/sta_dk_4_0_4_32/common/src/inc/Ethernet.h
new file mode 100644 (file)
index 0000000..3d30eb9
--- /dev/null
@@ -0,0 +1,165 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*       MODULE:       Ethernet.h                                                                                                     */
+/*    PURPOSE:                                                                                                                    */
+/*                                                                                                                                                */
+/***************************************************************************/
+#ifndef _ETHERNET_H_
+#define _ETHERNET_H_
+
+#pragma pack(1)
+typedef struct
+{
+  macAddress_t DstAddr;
+  macAddress_t SrcAddr;
+  UINT16               TypeLength;
+} EthernetHeader_t;
+#pragma pack()
+#define ETHERTYPE_802_1D      0x8100
+
+typedef struct
+{
+  macAddress_t DstAddr;
+  macAddress_t SrcAddr;
+  UINT16    Length;
+  UINT8        DSAP;
+  UINT8     SSAP;
+  UINT8     Control;
+  UINT8     OUI[3];
+  UINT16       Type;
+} LlcSnapHeader_t;
+#pragma pack()
+
+#define MAC_ADDRESS_GROUP_BIT  ( 0x01 )                /* in byte [ 0 ] of the MAC Address*/
+
+
+#define ETHERNET_HDR_LEN                                               14
+#define IEEE802_3_HDR_LEN                                              14 
+#define LLC_SNAP_HDR_LEN                                               20
+
+#define SNAP_CHANNEL_ID                                                        0xAA
+#define LLC_CONTROL_UNNUMBERED_INFORMATION             0x03
+#define ETHERNET_MAX_PAYLOAD_SIZE                              1500
+
+#define SNAP_OUI_802_1H_BYTE0                                  0x00
+#define SNAP_OUI_802_1H_BYTE1                                  0x00
+#define SNAP_OUI_802_1H_BYTE2                                  0xf8
+#define SNAP_OUI_802_1H_BYTES  { SNAP_OUI_802_1H_BYTE0, SNAP_OUI_802_1H_BYTE1, SNAP_OUI_802_1H_BYTE2 }
+
+#define SNAP_OUI_RFC1042_BYTE0                                 0x00
+#define SNAP_OUI_RFC1042_BYTE1                                 0x00
+#define SNAP_OUI_RFC1042_BYTE2                                 0x00
+#define SNAP_OUI_RFC1042_LEN                                   3
+#define SNAP_OUI_RFC1042_BYTES { SNAP_OUI_RFC1042_BYTE0, SNAP_OUI_RFC1042_BYTE1, SNAP_OUI_RFC1042_BYTE2 }
+
+
+typedef enum tETHERTYPES 
+{
+  ETHERTYPE_APPLE_AARP = 0x80f3,
+  ETHERTYPE_DIX_II_IPX = 0x8137
+
+} ETHERTYPES, *PETHERTYPES;
+
+
+static __inline BOOL IsMacAddressZero( macAddress_t *pMacAddr )
+{
+  return( (BOOL)( ( 0 == *                      (unsigned long *)pMacAddr ) &&
+                     ( 0 == *(unsigned short *)( ( (unsigned long *)pMacAddr ) + 1 ) ) ) );
+
+}
+
+
+static __inline void ClearMacAddress( macAddress_t *pMacAddr )
+{
+  *              (unsigned long *)pMacAddr                 = 0;
+  *(unsigned short *)( ( (unsigned long *)pMacAddr ) + 1 ) = 0;
+}
+
+
+static __inline BOOL IsMacAddressEqual( macAddress_t *pMacAddr1, macAddress_t *pMacAddr2 )
+{
+  return( (BOOL)( 
+          ( *                        (unsigned long *)pMacAddr1  == 
+            *                        (unsigned long *)pMacAddr2     ) &&
+
+          ( *( (unsigned short *)( ( (unsigned long *)pMacAddr1 ) + 1 ) ) == 
+            *( (unsigned short *)( ( (unsigned long *)pMacAddr2 ) + 1 ) )    ) ) );
+}
+
+static __inline void SetMacAddressBroadcast( macAddress_t *pMacAddr )
+{
+  *                      (unsigned long *)pMacAddr         = 0xffffffff;
+  *(unsigned short *)( ( (unsigned long *)pMacAddr ) + 1 ) = 0xffff;
+
+}
+
+
+static __inline BOOL IsMacAddressGroup( macAddress_t *pMACAddr )
+{
+  return( pMACAddr->addr[ 0 ] & MAC_ADDRESS_GROUP_BIT );
+}
+
+
+static __inline BOOL IsMacAddressDirected( macAddress_t *pMACAddr )
+{
+  return( !IsMacAddressGroup( pMACAddr ) );
+}
+
+
+
+static __inline BOOL IsMacAddressBroadcast( macAddress_t *pMacAddr )
+{
+/* In WinCE an adrress that is not divided by 4 causes exception here */
+   return( (BOOL)( ( 0xffff == *(unsigned short *)pMacAddr ) &&
+                   ( 0xffff == *(((unsigned short *)pMacAddr) + 1 ) ) &&
+                   ( 0xffff == *(((unsigned short *)pMacAddr) + 2 ) )));
+/*  return( (BOOL)( ( 0xffffffff == *                      (unsigned long *)pMacAddr ) &&
+                  ( 0xffff     == *(unsigned short *)( ( (unsigned long *)pMacAddr ) + 1 ) ) ) );*/
+
+}
+
+
+static __inline BOOL IsMacAddressMulticast( macAddress_t *pMACAddr )
+{
+  return( IsMacAddressGroup( pMACAddr ) && !IsMacAddressBroadcast( pMACAddr ) );
+}
+
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/inc/paramIn.h b/sta_dk_4_0_4_32/common/src/inc/paramIn.h
new file mode 100644 (file)
index 0000000..5229aab
--- /dev/null
@@ -0,0 +1,152 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __PARAM_IN_H__
+#define __PARAM_IN_H__
+
+#include "osTIType.h"
+#include "commonTypes.h"
+
+
+
+/* In this file are defined the parameter that are for internal use of the software only. */
+/* Following are the parameters numbers. Each module can have 256 parameters */
+typedef enum
+{
+    /* HAL Control section */
+    HAL_CTRL_AID_PARAM                                  = HAL_CTRL_MODULE_PARAM | 0x01,
+    HAL_CTRL_RSN_HW_ENC_DEC_ENABLE_PARAM                = HAL_CTRL_MODULE_PARAM | 0x02,  
+    HAL_CTRL_RSN_KEY_ADD_PARAM                          = HAL_CTRL_MODULE_PARAM | 0x03, 
+    HAL_CTRL_RSN_KEY_REMOVE_PARAM                       = HAL_CTRL_MODULE_PARAM | 0x04, 
+    HAL_CTRL_RSN_DEFAULT_KEY_ID_PARAM                   = HAL_CTRL_MODULE_PARAM | 0x05, 
+    HAL_CTRL_RSN_SECURITY_MODE_PARAM                   = HAL_CTRL_MODULE_PARAM | 0x06,  
+    HAL_CTRL_RSN_SECURITY_ALARM_CB_SET_PARAM            = HAL_CTRL_MODULE_PARAM | 0x07,  
+    HAL_CTRL_ACX_STATISTICS_PARAM                       = HAL_CTRL_MODULE_PARAM | 0x08,
+    HAL_CTRL_MEDIUM_OCCUPANCY_PARAM                     = HAL_CTRL_MODULE_PARAM | 0x09,
+    HAL_CTRL_DISABLE_POWER_MANAGEMENT_AUTO_CONFIG_PARAM = HAL_CTRL_MODULE_PARAM | 0x0a,
+    HAL_CTRL_ENABLE_POWER_MANAGEMENT_AUTO_CONFIG_PARAM  = HAL_CTRL_MODULE_PARAM | 0x0b,
+    HAL_CTRL_SG_ENABLE_PARAM                            = HAL_CTRL_MODULE_PARAM | 0x0c,
+    HAL_CTRL_SG_CONFIG_PARAM                            = HAL_CTRL_MODULE_PARAM | 0x0d,
+    
+
+#ifdef EXC_MODULE_INCLUDED
+    HAL_CTRL_RSN_EXC_SW_ENC_ENABLE_PARAM                = HAL_CTRL_MODULE_PARAM | 0x0e,  
+    HAL_CTRL_RSN_EXC_MIC_FIELD_ENABLE_PARAM             = HAL_CTRL_MODULE_PARAM | 0x0f,  
+#endif /* EXC_MODULE_INCLUDED*/
+    HAL_CTRL_TX_OP_LIMIT                                = HAL_CTRL_MODULE_PARAM | 0x10,
+    HAL_CTRL_NOISE_HISTOGRAM_PARAM                      = HAL_CTRL_MODULE_PARAM | 0x11,
+    HAL_CTRL_TSF_DTIM_MIB                               = HAL_CTRL_MODULE_PARAM | 0x12,
+    HAL_CTRL_REVISION                                   = HAL_CTRL_MODULE_PARAM | 0x13,
+       HAL_CTRL_POWER_LEVEL_TABLE_PARAM                                        = HAL_CTRL_MODULE_PARAM | 0x14,
+    /* Connection section */
+    CONN_TYPE_PARAM                                     = CONN_MODULE_PARAM | 0x01,
+
+    /* MLME section */
+    MLME_LEGACY_TYPE_PARAM                              = MLME_SM_MODULE_PARAM | 0x01,
+    MLME_RE_ASSOC_PARAM                                 = MLME_SM_MODULE_PARAM | 0x02,
+    MLME_TNET_WAKE_ON_PARAM                             = MLME_SM_MODULE_PARAM | 0x03,
+    MLME_CAPABILITY_PARAM                               = MLME_SM_MODULE_PARAM | 0x04,
+
+    /* Auth section */
+    AUTH_LEGACY_TYPE_PARAM                              = AUTH_MODULE_PARAM | 0x01,
+
+    /* RX data section */
+    RX_DATA_EAPOL_DESTINATION_PARAM                     = RX_DATA_MODULE_PARAM | 0x01,
+    RX_DATA_PORT_STATUS_PARAM                           = RX_DATA_MODULE_PARAM | 0x02,
+
+    /* TX data section */
+    TX_DATA_CURRENT_PRIVACY_INVOKE_MODE_PARAM           = TX_DATA_MODULE_PARAM | 0x01,  
+    TX_DATA_EAPOL_ENCRYPTION_STATUS_PARAM               = TX_DATA_MODULE_PARAM | 0x02,
+    TX_DATA_HAL_INTERFACE_STATUS_PARAM          = TX_DATA_MODULE_PARAM | 0x03,          
+    TX_DATA_802_11_POWER_SAVE_STATUS_PARAM              = TX_DATA_MODULE_PARAM | 0x04,          
+
+    /* CTRL data section */
+    CTRL_DATA_CURRENT_MODULATION_TYPE_PARAM             = CTRL_DATA_MODULE_PARAM | 0x01,
+    CTRL_DATA_CURRENT_BASIC_RATE_PARAM                  = CTRL_DATA_MODULE_PARAM | 0x02,
+    CTRL_DATA_CURRENT_BASIC_MODULATION_PARAM            = CTRL_DATA_MODULE_PARAM | 0x03,
+    CTRL_DATA_CURRENT_BASIC_RATE_MASK_PARAM             = CTRL_DATA_MODULE_PARAM | 0x04,
+    CTRL_DATA_CURRENT_ACTIVE_RATE_PARAM                 = CTRL_DATA_MODULE_PARAM | 0x05,
+
+
+    /* SiteMgr section */   
+    SITE_MGR_POWER_CONSTRAINT_PARAM                     = SITE_MGR_MODULE_PARAM | 0x01,
+    SITE_MGR_BEACON_INTERVAL_PARAM                      = SITE_MGR_MODULE_PARAM | 0x02,
+    SITE_MGR_RADIO_BAND_PARAM                           = SITE_MGR_MODULE_PARAM | 0x03,
+    SITE_MGR_NEXT_DTIM_TIME_STAMP_PARAM                 = SITE_MGR_MODULE_PARAM | 0x04,
+    SITE_MGR_SITE_CAPABILITY_PARAM                      = SITE_MGR_MODULE_PARAM | 0x05,
+    SITE_MGR_4X_PARAM                                   = SITE_MGR_MODULE_PARAM | 0x06,
+    SITE_MGR_RGSTRY_BASIC_RATE_SET_MASK                 = SITE_MGR_MODULE_PARAM | 0x08,
+    SITE_MGR_BEACON_RECV                                = SITE_MGR_MODULE_PARAM | 0x09,
+    SITE_MGR_DTIM_PERIOD_PARAM                          = SITE_MGR_MODULE_PARAM | 0x0A,
+
+
+    /* Previous Primary Site */
+    SITE_MGR_PREV_SITE_BSSID_PARAM                      = SITE_MGR_MODULE_PARAM | 0x0B,
+    SITE_MGR_PREV_SITE_SSID_PARAM                       = SITE_MGR_MODULE_PARAM | 0x0C,
+    SITE_MGR_PREV_SITE_CHANNEL_PARAM                    = SITE_MGR_MODULE_PARAM | 0x0D,
+    SITE_MGR_DESIRED_RSSI_GAP_THR_PARAM                 = SITE_MGR_MODULE_PARAM | 0x0E,
+    SITE_MGR_PRIORITY_PARAM                             = SITE_MGR_MODULE_PARAM | 0x0F,
+    /* Regulatory Domain section */
+    REGULATORY_DOMAIN_DISCONNECT_PARAM                  = REGULATORY_DOMAIN_MODULE_PARAM| 0x01,
+    REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM    = REGULATORY_DOMAIN_MODULE_PARAM| 0x02,
+    REGULATORY_DOMAIN_COUNTRY_PARAM                     = REGULATORY_DOMAIN_MODULE_PARAM| 0x03,
+    REGULATORY_DOMAIN_POWER_CAPABILITY_PARAM            = REGULATORY_DOMAIN_MODULE_PARAM| 0x04,
+    REGULATORY_DOMAIN_SUPPORTED_CHANNEL_PARAM           = REGULATORY_DOMAIN_MODULE_PARAM| 0x05,
+    REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM        = REGULATORY_DOMAIN_MODULE_PARAM| 0x06,
+    REGULATORY_DOMAIN_IS_CHANNEL_SUPPORTED              = REGULATORY_DOMAIN_MODULE_PARAM| 0x07,
+    REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED         = REGULATORY_DOMAIN_MODULE_PARAM| 0x08,
+    REGULATORY_DOMAIN_SET_CHANNEL_VALIDITY              = REGULATORY_DOMAIN_MODULE_PARAM| 0x09,
+    REGULATORY_DOMAIN_GET_SCAN_CAPABILITIES             = REGULATORY_DOMAIN_MODULE_PARAM| 0x0a,
+    REGULATORY_DOMAIN_ALL_SUPPORTED_CHANNELS            = REGULATORY_DOMAIN_MODULE_PARAM| 0x0b,
+    REGULATORY_DOMAIN_CHECK_COUNTRY_PARAM               = REGULATORY_DOMAIN_MODULE_PARAM| 0x0c,
+       REGULATORY_DOMAIN_IS_COUNTRY_FOUND                                      = REGULATORY_DOMAIN_MODULE_PARAM| 0x0d,
+    
+    /* measurement section */
+    MEASUREMENT_TRAFFIC_THRESHOLD_PARAM                 = MEASUREMENT_MODULE_PARAM| 0x01,
+    MEASUREMENT_GET_STATUS_PARAM                        = MEASUREMENT_MODULE_PARAM| 0x02,
+
+#ifdef EXC_MODULE_INCLUDED
+
+    EXC_CCKM_EXISTS                                     = EXC_MANAGER_MODULE_PARAM | 0x01,
+    EXC_NEIGHBOR_APS                                    = EXC_MANAGER_MODULE_PARAM | 0x02,
+#endif
+
+    
+}   internalParam_e;
+
+
+#endif /* __PARAM_IN_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/bufferPool.c b/sta_dk_4_0_4_32/common/src/utils/bufferPool.c
new file mode 100644 (file)
index 0000000..7de8ca5
--- /dev/null
@@ -0,0 +1,295 @@
+/** \file bufferPool.c
+ *  \brief This file include buffer pool module implementation
+ *  \author Ronen Kalish
+ *  \date 05-December-2005
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "bufferPool.h"
+#include "osApi.h"
+#include "report.h"
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Creates a buffer pool object
+ *
+ * Function Scope \e Public.\n
+ * \param hOS - handle to the OS object.\n
+ * \param numOfBuffers - the number of buffers to allocate for this pool.\n
+ * \param bufferSize - the size of each buffer in this pool.\n
+ * \return a handle to a buffer pool object, NULL if an error occurred.\n
+ */
+TI_HANDLE bufferPool_create( TI_HANDLE hOS, UINT32 numOfBuffers, UINT32 bufferSize )
+{
+    /* allocate the buffer pool object */
+    bufferPool_t *pBufferPool = os_memoryAlloc( hOS, sizeof(bufferPool_t) );
+    if ( NULL == pBufferPool )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to create buffer pool object") );
+        return NULL;
+    }
+
+    /* 
+     * adjust buffer size if necessary - the buffer must at least store the pointer to the
+     * next free buffer when it is free.
+     */
+    if ( sizeof( bufferPool_buffer_t ) > bufferSize )
+    {
+        bufferSize = sizeof( bufferPool_buffer_t );
+    }
+
+    /* nullify the buffer pool object */
+    os_memoryZero( hOS, pBufferPool, sizeof( bufferPool_t ) );
+
+    /* allocate the buffers */
+    pBufferPool->firstBuffer = pBufferPool->firstFreeBuffer = os_memoryAlloc( hOS, numOfBuffers * bufferSize );
+    if ( NULL == pBufferPool->firstBuffer )
+    {
+        WLAN_OS_REPORT( ("ERROR: Failed to allocate buffer storage space") );
+        bufferPool_destroy( (TI_HANDLE)pBufferPool );
+        return NULL;
+    }
+
+    /* store the OS handle */
+    pBufferPool->hOS = hOS;
+
+    /* store buffer pool information */
+    pBufferPool->bufferSize = bufferSize;
+    pBufferPool->numberOfBuffers = numOfBuffers;
+
+    /* initialize the free buffers list */
+    bufferPool_reinit( (TI_HANDLE)pBufferPool );
+
+#ifdef TI_DBG
+       /* initialize debug information */
+       os_memoryZero( pBufferPool->hOS, &(pBufferPool->bufferPoolDbg), sizeof( bufferPoolDbg_t ) );
+#endif /* TI_DBG */
+
+    return pBufferPool;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Configures a buffer pool object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ * \param hReport - handle to the report module.\n
+ */
+void bufferPool_config( TI_HANDLE hBufferPool, TI_HANDLE hReport )
+{
+    bufferPool_t* pBufferPool = (bufferPool_t*)hBufferPool;
+
+    /* keep the report handle */
+    pBufferPool->hReport = hReport;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief releasing a buffer pool object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ */
+void bufferPool_destroy( TI_HANDLE hBufferPool )
+{
+    bufferPool_t* pBufferPool = (bufferPool_t*)hBufferPool;
+
+    /* release the buffers storage space */
+    os_memoryFree( pBufferPool->hOS, pBufferPool->firstBuffer,
+                   pBufferPool->bufferSize * pBufferPool->numberOfBuffers );
+
+    /* release the buffer pool object */
+    os_memoryFree( pBufferPool->hOS, pBufferPool, sizeof(bufferPool_t) );
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Reinitializes the buffer pool object, by marking all buffers 
+ * \brief as unallocated.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ */
+void bufferPool_reinit( TI_HANDLE hBufferPool )
+{
+    bufferPool_t* pBufferPool = (bufferPool_t*)hBufferPool;
+    UINT32 i;
+
+    /* make the first free buffer point to the first buffer */
+    pBufferPool->firstFreeBuffer = pBufferPool->firstBuffer;
+
+    /* insert all buffers to free list - last buffer must point to NULL */
+    for ( i = 0; i < pBufferPool->numberOfBuffers - 1; i++ )
+    {
+        /* make the i'th buffer point to the next buffer */
+        *(bufferPool_buffer_t*)((char*)pBufferPool->firstBuffer + (pBufferPool->bufferSize * i)) = 
+            (bufferPool_buffer_t)((char*)pBufferPool->firstBuffer + (pBufferPool->bufferSize * (i+1)));
+    }
+
+    /* make the last buffer point to NULL */
+    *(bufferPool_buffer_t*)((char*)pBufferPool->firstBuffer + 
+        (pBufferPool->bufferSize * (pBufferPool->numberOfBuffers - 1))) = 
+            BUFFER_POOL_NO_BUFFER;
+
+#ifdef TI_DBG
+       /* mark that no buffers are allocated */
+       pBufferPool->bufferPoolDbg.numberOfUsedBuffers = 0;
+
+       /* mark all buffers as unallocated in the debug information */
+       for ( i = 0; i < BUFFER_POOL_MAX_NUM_OF_BUFFERS_FOR_DBG; i++ )
+       {
+               pBufferPool->bufferPoolDbg.bAllocated[ i ] = FALSE;
+       }
+#endif /* TI_DBG */
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Allocates a buffer.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ * \return a buffer object, BUFFER_POOL_NO_BUFFER indication if non is available.\n
+ */
+bufferPool_buffer_t bufferPool_allocateBuffer( TI_HANDLE hBufferPool )
+{
+    bufferPool_t* pBufferPool = (bufferPool_t*)hBufferPool;
+    bufferPool_buffer_t buffer;
+#ifdef TI_DBG
+       UINT32 bufferIndex;
+#endif
+
+    /* check if a buffer is available */
+    if ( BUFFER_POOL_NO_BUFFER == pBufferPool->firstFreeBuffer )
+    {
+#ifdef TI_DBG
+               pBufferPool->bufferPoolDbg.NumberOfDeclinedAllocations++;
+#endif /* TI_DBG */
+               return BUFFER_POOL_NO_BUFFER;
+    }
+
+    /* temporarily keep the first free buffer */
+    buffer = pBufferPool->firstFreeBuffer;
+
+    /* advance the first free buffer to point to the next buffer in the list */
+    pBufferPool->firstFreeBuffer = *(bufferPool_buffer_t*)((pBufferPool->firstFreeBuffer));
+
+#ifdef TI_DBG
+       /* increase the buffer in use count */
+       pBufferPool->bufferPoolDbg.numberOfUsedBuffers++;
+
+       /* count the successful allocation */
+       pBufferPool->bufferPoolDbg.NumberOfSuccessfulAllocations++;
+
+       /* mark the specific buffer as used */
+       bufferIndex = ((UINT8*)buffer - (UINT8*)pBufferPool->firstBuffer) / pBufferPool->bufferSize;
+       if ( bufferIndex < BUFFER_POOL_MAX_NUM_OF_BUFFERS_FOR_DBG )
+       {
+               pBufferPool->bufferPoolDbg.bAllocated[ bufferIndex ] = TRUE;
+       }
+#endif /* TI_DBG */
+
+    return buffer;
+}
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Returns a buffer to the pool.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ * \param buffer - the buffer object to return to the pool.\n
+ */
+void bufferPool_releaseBuffer( TI_HANDLE hBufferPool, bufferPool_buffer_t buffer )
+{
+    bufferPool_t* pBufferPool = (bufferPool_t*)hBufferPool;
+#ifdef TI_DBG
+       UINT32 bufferIndex;
+
+       /* check if the buffer is currently allocated */
+       bufferIndex = ((UINT8*)buffer - (UINT8*)pBufferPool->firstBuffer) / pBufferPool->bufferSize;
+
+       if ( (bufferIndex < BUFFER_POOL_MAX_NUM_OF_BUFFERS_FOR_DBG) &&
+                (FALSE == pBufferPool->bufferPoolDbg.bAllocated[ bufferIndex ]) )
+       {
+               /* count number of free attempts for already free buffers */
+               pBufferPool->bufferPoolDbg.NumberOfFreeBufferRefreed++;
+
+               WLAN_OS_REPORT(("%s: Trying to re-free Buffer %d\n", __FUNCTION__, bufferIndex));
+               return;
+       }
+       else
+       {
+               /* decrease the buffers in use count */
+               pBufferPool->bufferPoolDbg.numberOfUsedBuffers--;
+
+               /* mark that the specific buffer is not in use */
+               pBufferPool->bufferPoolDbg.bAllocated[ bufferIndex ] = FALSE;
+       }
+#endif /* TI_DBG */
+
+    /* make the newly released buffer point to the current first free buffer */
+    *((bufferPool_buffer_t*)buffer) = pBufferPool->firstFreeBuffer;
+
+    /* make the newly release buffer the first free buffer */
+    pBufferPool->firstFreeBuffer = buffer;
+}
+
+#ifdef TI_DBG
+/**
+ * \author Ronen Kalish\n
+ * \date 29-December-2005\n
+ * \brief Returns the buffer pool debug structure.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ */
+bufferPoolDbg_t *bufferPool_getDebugInformation( TI_HANDLE hBufferPool )
+{
+    bufferPool_t* pBufferPool = (bufferPool_t*)hBufferPool;
+
+       return &(pBufferPool->bufferPoolDbg);
+}
+#endif
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/bufferPool.h b/sta_dk_4_0_4_32/common/src/utils/bufferPool.h
new file mode 100644 (file)
index 0000000..9f53b05
--- /dev/null
@@ -0,0 +1,65 @@
+/** \file bufferPool.h
+ *  \brief This file include private definitions for the buffer pool object
+ *  \author Ronen Kalish
+ *  \date 05-December-2005
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "osTIType.h"
+#include "bufferPoolApi.h"
+
+#ifndef __BUFFER_POOL_H__
+#define __BUFFER_POOL_H__
+
+/** \struct bufferPool__t
+ * \brief This structure comprise the buffer pool object.\n
+ */
+typedef struct
+{
+    TI_HANDLE               hOS;                /**< handle to the OS object */
+    TI_HANDLE               hReport;            /**< handle to the report object */
+       UINT32                                  numberOfBuffers;    /**< The total number of buffers allocated for this pool */
+       UINT32                                  bufferSize;         /**< The size of buffers in this pool */
+    bufferPool_buffer_t     firstBuffer;        /**< memory block holding all buffers */
+    bufferPool_buffer_t     firstFreeBuffer;    /**< pointer to the first free buffer */
+#ifdef TI_DBG
+       bufferPoolDbg_t                 bufferPoolDbg;          /**< debug information */
+#endif /* TI_DBG */
+} bufferPool_t;
+
+#endif /* __BUFFER_POOL_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/bufferPoolApi.h b/sta_dk_4_0_4_32/common/src/utils/bufferPoolApi.h
new file mode 100644 (file)
index 0000000..69ba026
--- /dev/null
@@ -0,0 +1,202 @@
+/** \file bufferPoolApi.h
+ *  \brief This file include public definitions for the buffer pool data structure, 
+ *  \brief comprising its API.
+ *  \author Ronen Kalish
+ *  \date 05-December-2005
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "osTIType.h"
+
+#ifndef __BUFFER_POOL_API_H__
+#define __BUFFER_POOL_API_H__
+/*
+ ***********************************************************************
+ *     Constant definitions.
+ ***********************************************************************
+ */
+#define BUFFER_POOL_NO_BUFFER NULL
+
+#ifdef TI_DBG
+/* Maximum number of buffers being tracked in debug mode */
+#define BUFFER_POOL_MAX_NUM_OF_BUFFERS_FOR_DBG 1000
+#endif /* TI_DBG */
+
+/*
+ ***********************************************************************
+ *     Enums.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     Typedefs.
+ ***********************************************************************
+ */
+
+ /** \typedef bufferPool_buffer_t
+  * \brief Defines a buffer data type (pointer to void)
+  */
+typedef void* bufferPool_buffer_t;
+
+/*
+ ***********************************************************************
+ *     Structure definitions.
+ ***********************************************************************
+ */
+#ifdef TI_DBG
+/** \struct bufferPoolDbg_t
+ * \brief This structure holds buffer pool debug information.\n
+ */
+typedef struct
+{
+    UINT32                                     numberOfUsedBuffers;                            /**< 
+                                                                                                                                * The number of buffers currently 
+                                                                                                                                * not allocated in this pool
+                                                                                                                                */
+       UINT32                                  NumberOfSuccessfulAllocations;          /**< 
+                                                                                                                                * Number of allocation requests 
+                                                                                                                                * ended successfuly
+                                                                                                                                */
+       UINT32                                  NumberOfDeclinedAllocations;            /**< 
+                                                                                                                                * Number of failed allocation requests
+                                                                                                                                * due to no memory
+                                                                                                                                */
+       UINT32                                  NumberOfFreeBufferRefreed;                      /**<
+                                                                                                                                * Number of buffers for which free was 
+                                                                                                                                * called when they were already free
+                                                                                                                                */
+       BOOLEAN                                 bAllocated[ BUFFER_POOL_MAX_NUM_OF_BUFFERS_FOR_DBG ];
+                                                                                                                               /**< 
+                                                                                                                                * A boolean array indicating for each
+                                                                                                                                * buffer if its allocation status
+                                                                                                                                */
+} bufferPoolDbg_t;
+#endif /* TI_DBG */
+
+/*
+ ***********************************************************************
+ *     External data definitions.
+ ***********************************************************************
+ */
+
+/*
+ ***********************************************************************
+ *     External functions definitions
+ ***********************************************************************
+ */
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Creates a buffer pool object
+ *
+ * Function Scope \e Public.\n
+ * \param hOS - handle to the OS object.\n
+ * \param numOfBuffers - the number of buffers to allocate for this pool.\n
+ * \param bufferSize - the size of each buffer in this pool.\n
+ * \return a handle to a buffer pool object, NULL if an error occurred.\n
+ */
+TI_HANDLE bufferPool_create( TI_HANDLE hOS, UINT32 numOfBuffers, UINT32 bufferSize );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Configures a buffer pool object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ * \param hReport - handle to the report module.\n
+ */
+void bufferPool_config( TI_HANDLE hBufferPool, TI_HANDLE hReport );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief releasing a buffer pool object.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ */
+void bufferPool_destroy( TI_HANDLE hBufferPool );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Reinitializes the buffer pool object, by marking all buffers 
+ * \brief as unallocated.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ */
+void bufferPool_reinit( TI_HANDLE hBufferPool );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief Allocates a buffer.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ * \return a buffer object, BUFFER_POOL_NO_BUFFER indication if non is available.\n
+ */
+bufferPool_buffer_t bufferPool_allocateBuffer( TI_HANDLE hBufferPool );
+
+/**
+ * \author Ronen Kalish\n
+ * \date 05-December-2005\n
+ * \brief returns a buffer to the pool.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ * \param buffer - the buffer object to return to the pool.\n
+ */
+void bufferPool_releaseBuffer( TI_HANDLE hBufferPool, bufferPool_buffer_t buffer );
+
+#ifdef TI_DBG
+/**
+ * \author Ronen Kalish\n
+ * \date 29-December-2005\n
+ * \brief Returns the buffer pool debug structure.\n
+ *
+ * Function Scope \e Public.\n
+ * \param hbufferPool - handle to a buffer pool object.\n
+ */
+bufferPoolDbg_t *bufferPool_getDebugInformation( TI_HANDLE hBufferPool );
+#endif /* TI_DBG */
+
+#endif /* __BUFFER_POOL_API_H__ */
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/fsm.c b/sta_dk_4_0_4_32/common/src/utils/fsm.c
new file mode 100644 (file)
index 0000000..e25d594
--- /dev/null
@@ -0,0 +1,321 @@
+/** \file fsm.c
+ *  \brief finite state machine source code
+ *
+ *  \see fsm.h
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: fsm.c                                                                                                      */
+/*    PURPOSE: Finite State Machine source code                                                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "utils.h"
+#include "report.h"
+#include "fsm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+/**
+*
+* fsm_Init  - Initialize the FSM structure
+*
+* \b Description: 
+*
+* Init The FSM structure. If matrix argument is NULL, allocate memory for
+* new matrix.
+*
+* \b ARGS:
+*
+*  O   - pFsm - the generated FSM module  \n
+*  I   - noOfStates - Number of states in the module \n
+*  I   - noOfStates - Number of events in the module \n
+*  I/O - matrix - the state event matrix
+*  I   - transFunc - Transition finction for the state machine \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Event
+*/
+TI_STATUS fsm_Create(TI_HANDLE                         hOs,
+                               fsm_stateMachine_t              **pFsm,
+                               UINT8                                   MaxNoOfStates,
+                               UINT8                                   MaxNoOfEvents)
+{
+       /* check for perliminary conditions */
+       if ((pFsm == NULL) || (MaxNoOfStates == 0) || (MaxNoOfEvents == 0))
+       {
+               return NOK;
+       }
+
+       /* allocate memory for FSM context */
+       *pFsm = (fsm_stateMachine_t *)os_memoryAlloc(hOs, sizeof(fsm_stateMachine_t));
+       if (*pFsm == NULL)
+       {
+               return NOK;
+       }
+       os_memoryZero(hOs, (*pFsm), sizeof(fsm_stateMachine_t)); /* Dm: Fix */
+
+       /* allocate memory for FSM matrix */
+       (*pFsm)->stateEventMatrix = (fsm_Matrix_t)os_memoryAlloc(hOs, MaxNoOfStates * MaxNoOfEvents * sizeof(fsm_actionCell_t));
+       if ((*pFsm)->stateEventMatrix == NULL)
+       {
+               os_memoryFree(hOs, *pFsm, sizeof(fsm_stateMachine_t));
+               return NOK;
+       }
+       os_memoryZero(hOs, (*pFsm)->stateEventMatrix, 
+               (MaxNoOfStates * MaxNoOfEvents * sizeof(fsm_actionCell_t)));
+       /* update pFsm structure with parameters */
+       (*pFsm)->MaxNoOfStates = MaxNoOfStates;
+       (*pFsm)->MaxNoOfEvents = MaxNoOfEvents;
+
+       return(OK);
+}
+
+/**
+*
+* fsm_Unload  - free all memory allocated to FSM structure
+*
+* \b Description: 
+*
+* Unload the FSM structure.
+*
+* \b ARGS:
+*
+*  O   - pFsm - the generated FSM module  \n
+*  I   - noOfStates - Number of states in the module \n
+*  I   - noOfStates - Number of events in the module \n
+*  I/O - matrix - the state event matrix
+*  I   - transFunc - Transition finction for the state machine \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Event
+*/
+TI_STATUS fsm_Unload(TI_HANDLE                         hOs,
+                               fsm_stateMachine_t              *pFsm)
+{
+       /* check for perliminary conditions */
+       if (pFsm == NULL)
+       {
+               return NOK;
+       }
+
+       /* free memory of FSM matrix */
+       if (pFsm->stateEventMatrix != NULL)
+       {
+               os_memoryFree(hOs, pFsm->stateEventMatrix,
+                                         pFsm->MaxNoOfStates * pFsm->MaxNoOfEvents * sizeof(fsm_actionCell_t));
+       }
+
+       /* free memory for FSM context (no need to check for null) */
+       os_memoryFree(hOs, pFsm, sizeof(fsm_stateMachine_t));
+
+       return(OK);
+}
+
+/**
+*
+* fsm_Init  - Initialize the FSM structure
+*
+* \b Description: 
+*
+* Init The FSM structure. If matrix argument is NULL, allocate memory for
+* new matrix.
+*
+* \b ARGS:
+*
+*  O   - pFsm - the generated FSM module  \n
+*  I   - noOfStates - Number of states in the module \n
+*  I   - noOfStates - Number of events in the module \n
+*  I/O - matrix - the state event matrix
+*  I   - transFunc - Transition finction for the state machine \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Event
+*/
+TI_STATUS fsm_Config(fsm_stateMachine_t        *pFsm,
+                                 fsm_Matrix_t                  pMatrix,
+                                 UINT8                                 ActiveNoOfStates,
+                                 UINT8                                 ActiveNoOfEvents,
+                                 fsm_eventActivation_t transFunc,
+                                 TI_HANDLE                             hOs)
+{
+       /* check for perliminary conditions */
+       if ((pFsm == NULL) ||
+               (pMatrix == NULL))
+       {
+               return NOK;
+       }
+
+       if ((ActiveNoOfStates > pFsm->MaxNoOfStates) || 
+               (ActiveNoOfEvents > pFsm->MaxNoOfEvents))
+       {
+               return NOK;
+       }
+
+       /* copy matrix to FSM context */
+       os_memoryCopy(hOs, (void *)pFsm->stateEventMatrix, (void *)pMatrix,
+                                 ActiveNoOfStates * ActiveNoOfEvents * sizeof(fsm_actionCell_t));
+
+       /* update pFsm structure with parameters */
+       pFsm->ActiveNoOfStates = ActiveNoOfStates;
+       pFsm->ActiveNoOfEvents = ActiveNoOfEvents;
+       pFsm->transitionFunc = transFunc;
+       return(OK);
+}
+
+/**
+*
+* fsm_Event  - perform event transition in the matrix
+*
+* \b Description: 
+*
+* Perform event transition in the matrix
+*
+* \b ARGS:
+*
+*  I   - pFsm - the generated FSM module  \n
+*  I/O - currentState - current state of the SM \n
+*  I   - event - event causing transition \n
+*  I   - pData - data for activation function \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Init
+*/
+TI_STATUS fsm_Event(fsm_stateMachine_t         *pFsm,
+                                UINT8                                  *currentState,
+                                UINT8                                  event,
+                                void                                   *pData)
+{
+       UINT8           oldState;
+       TI_STATUS               status;
+
+       /* check for FSM existance */
+       if (pFsm == NULL)
+       {
+               return(NOK);
+       }
+
+       /* boundary check */
+       if ((*currentState >= pFsm->ActiveNoOfStates) || (event >= pFsm->ActiveNoOfEvents))
+       {
+               return(NOK);
+       }
+       
+       oldState = *currentState;
+       /* update current state */
+       *currentState = pFsm->stateEventMatrix[(*currentState * pFsm->ActiveNoOfEvents) + event].nextState;
+
+       /* activate transition function */
+       if( !(*pFsm->stateEventMatrix[(oldState * pFsm->ActiveNoOfEvents) + event].actionFunc) ) {
+           return(NOK);
+       }
+       status = (*pFsm->stateEventMatrix[(oldState * pFsm->ActiveNoOfEvents) + event].actionFunc)(pData);
+
+       return status;
+}
+
+
+/**
+*
+* fsm_GetNextState  - Retrun the next state for a given current state and an event.
+*
+* \b Description: 
+*
+* Retrun the next state for a given current state and an event.
+*
+* \b ARGS:
+*
+*  I   - pFsm - the generated FSM module  \n
+*  I   - currentState - current state of the SM \n
+*  I   - event - event causing transition \n
+*  O   - nextState - returned next state \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa 
+*/
+TI_STATUS fsm_GetNextState(fsm_stateMachine_t          *pFsm,
+                                               UINT8                                   currentState,
+                                               UINT8                                   event,
+                                               UINT8                                   *nextState)
+{
+       if (pFsm != NULL)
+       {
+               if ((currentState < pFsm->ActiveNoOfStates) && (event < pFsm->ActiveNoOfEvents))
+               {
+                       *nextState = pFsm->stateEventMatrix[(currentState * pFsm->ActiveNoOfEvents) + event].nextState;
+                       return(OK);
+               }
+       }
+       
+       return(NOK);
+}
+
+TI_STATUS action_nop(void *pData)
+{
+       return OK;
+}
diff --git a/sta_dk_4_0_4_32/common/src/utils/fsm.h b/sta_dk_4_0_4_32/common/src/utils/fsm.h
new file mode 100644 (file)
index 0000000..ef0f84e
--- /dev/null
@@ -0,0 +1,127 @@
+/** \file fsm.h
+ *  \brief finite state machine header file
+ *
+ *  \see fsm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                                                                                                */
+/*             MODULE: fsm.h                                                                                                      */
+/*    PURPOSE: Finite State Machine API                                                                   */
+/*                                                                                                                                                */
+/***************************************************************************/
+
+#ifndef __FSM_H__
+#define __FSM_H__
+
+#include "osTIType.h"
+#include "commonTypes.h"
+
+/* Constants */
+#define        MAX_DESC_STRING_LEN             64              
+
+
+/* Enumerations */
+
+/* Typedefs */
+
+/** state transition function */
+typedef        TI_STATUS (*fsm_eventActivation_t)(UINT8 *currState, UINT8 event, void* data);
+
+/** action function type definition */
+typedef TI_STATUS (*fsm_Action_t)(void* pData);
+
+/* Structures */
+
+/* State\Event cell */
+typedef  struct
+{
+       UINT8                   nextState;              /**< next state in transition */
+       fsm_Action_t    actionFunc;             /**< action function */
+} fsm_actionCell_t;
+
+/** matrix type */
+typedef        fsm_actionCell_t*               fsm_Matrix_t;
+
+/** general FSM structure */
+typedef struct
+{
+       fsm_Matrix_t                    stateEventMatrix;               /**< State\Event matrix */
+       UINT8                                   MaxNoOfStates;                  /**< Max Number of states in the matrix */
+       UINT8                                   MaxNoOfEvents;                  /**< Max Number of events in the matrix */
+       UINT8                                   ActiveNoOfStates;               /**< Active Number of states in the matrix */
+       UINT8                                   ActiveNoOfEvents;               /**< Active Number of events in the matrix */
+       fsm_eventActivation_t   transitionFunc;                 /**< State transition function */
+} fsm_stateMachine_t;
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS fsm_Create(TI_HANDLE                         hOs,
+                               fsm_stateMachine_t              **pFsm,
+                               UINT8                                   MaxNoOfStates,
+                               UINT8                                   MaxNoOfEvents);
+
+TI_STATUS fsm_Unload(TI_HANDLE                         hOs,
+                               fsm_stateMachine_t              *pFsm);
+
+TI_STATUS fsm_Config(fsm_stateMachine_t        *pFsm,
+                                 fsm_Matrix_t                  pMatrix,
+                                 UINT8                                 ActiveNoOfStates,
+                                 UINT8                                 ActiveNoOfEvents,
+                                 fsm_eventActivation_t transFunc,
+                                 TI_HANDLE                             hOs);
+
+TI_STATUS fsm_Event(fsm_stateMachine_t         *pFsm,
+                                UINT8                                  *currentState,
+                                UINT8                                  event,
+                                void                                   *pData);
+
+TI_STATUS fsm_GetNextState(fsm_stateMachine_t          *pFsm,
+                                               UINT8                                   currentState,
+                                               UINT8                                   event,
+                                               UINT8                                   *nextState);
+
+
+TI_STATUS action_nop(void *pData);
+
+
+#endif /* __FSM_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/utils/memMngrEx.c b/sta_dk_4_0_4_32/common/src/utils/memMngrEx.c
new file mode 100644 (file)
index 0000000..6fc7265
--- /dev/null
@@ -0,0 +1,1434 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+/**************************************************************************/
+/*                                                                        */
+/*  MODULE:  memMngr.c                                                */
+/*  PURPOSE: manage the SDRAM buffers for MSDU Data Buffers allocations   */
+/*                                                                        */
+/**************************************************************************/
+
+#include "memMngrEx.h"
+#include "osApi.h"
+#include "report.h"
+
+
+/*************************************************************************
+*                        wlan_memMngrInit                                *
+**************************************************************************
+* DESCRIPTION:  Init of the Memory Manager module. This function allocated
+*               all memroy resources needed for the MemMngr. It tallocate
+*               a pool of Msdu structure, pool of Bd structure, and
+*               number of pools of data buffers.
+*               
+* INPUT:        hOs - handle to Os abstraction layer
+*
+* OUTPUT:
+*
+* RETURN:       Handle to the allocated MemMngr control block
+**************************************************************************/
+TI_HANDLE wlan_memMngrInit(TI_HANDLE hOs)
+{
+    memMngr_t   *pMemMngr;
+    UINT32      count,i;
+    memMngrInit_t pMemMngrInit;
+
+    if( hOs  == NULL )
+    {
+        WLAN_OS_REPORT(("wlan_memMngrInit() : FATAL ERROR: OS handle Error - Aborting\n"));
+        return NULL;
+    }
+
+    /* structures for initialization of Memory manager */
+    pMemMngrInit.numOfPools = DEF_NUMBER_OF_BUF_POOLS;
+    pMemMngrInit.bufPoolInit[0].buffersSize = DEF_BUFFER_LENGTH_POOL_1;
+    pMemMngrInit.bufPoolInit[0].numOfbuffers = DEF_NUMBER_OF_BUFFERS_IN_POOL_1 ;
+    pMemMngrInit.bufPoolInit[1].buffersSize = DEF_BUFFER_LENGTH_POOL_2;
+    pMemMngrInit.bufPoolInit[1].numOfbuffers = DEF_NUMBER_OF_BUFFERS_IN_POOL_2;
+    pMemMngrInit.bufPoolInit[2].buffersSize = DEF_BUFFER_LENGTH_POOL_3;
+    pMemMngrInit.bufPoolInit[2].numOfbuffers = DEF_NUMBER_OF_BUFFERS_IN_POOL_3;
+
+    for( count = 0 ; count  < pMemMngrInit.numOfPools ; count++ )
+    {
+        if( pMemMngrInit.bufPoolInit[count].buffersSize > MAX_BUFFER_LENGTH ||
+            pMemMngrInit.bufPoolInit[count].buffersSize < MIN_BUFFER_LENGTH)
+        {
+            WLAN_OS_REPORT(("wlan_memMngrInit() : FATAL ERROR: Buffer length out of range - Aborting\n"));
+            return NULL;
+        }
+        if( count != 0 )
+        {
+            if(pMemMngrInit.bufPoolInit[count].buffersSize < pMemMngrInit.bufPoolInit[count-1].buffersSize )
+            {
+                WLAN_OS_REPORT(("wlan_memMngrInit() : FATAL ERROR: Buffer length's out of order - Aborting\n"));
+                return NULL;
+            }
+        }
+    }
+
+    /* alocate MemMngr module control block */
+    pMemMngr = os_memoryAlloc(hOs, (sizeof(memMngr_t)));
+    if(!pMemMngr) {
+        WLAN_OS_REPORT(("FATAL ERROR: Could not allocate pMemMngr - Aborting\n"));
+        return NULL;
+    }
+
+    os_memoryZero(hOs, pMemMngr, sizeof(memMngr_t));
+
+    pMemMngr->hOs = hOs;
+
+    pMemMngr->msduMaxNumber = DEF_NUMBER_OF_MSDUS; 
+    pMemMngr->bdMaxNumber = DEF_NUMBER_OF_BDS; 
+    pMemMngr->numFreeMSDU = pMemMngr->msduMaxNumber;
+    pMemMngr->numFreeBD = pMemMngr->bdMaxNumber;
+
+    pMemMngr->msduPool = (mem_MSDU_T*)os_memoryCAlloc(hOs, pMemMngr->msduMaxNumber, sizeof(mem_MSDU_T));
+    os_profile (hOs, 8, pMemMngr->msduMaxNumber * sizeof(mem_MSDU_T));
+
+    if (pMemMngr->msduPool == NULL) 
+    {
+        wlan_memMngrDestroy(pMemMngr);
+        WLAN_OS_REPORT(("FATAL ERROR: Could not allocate memory for MEM MNGR - Aborting\n"));
+        return NULL;
+    }
+
+    pMemMngr->bdPool = (mem_BD_T*)os_memoryCAlloc(hOs, pMemMngr->bdMaxNumber, sizeof(mem_BD_T));
+    os_profile (hOs, 8, pMemMngr->bdMaxNumber * sizeof(mem_BD_T));
+    
+    if (pMemMngr->bdPool == NULL) 
+    {
+        wlan_memMngrDestroy(pMemMngr);
+        WLAN_OS_REPORT(("FATAL ERROR: Could not allocate memory for MEM MNGR - Aborting\n"));
+        return NULL;
+    }
+
+    /* initialize buffer pools objects */
+    pMemMngr->currentNumberOfPools = pMemMngrInit.numOfPools;
+    for( count = 0 ; count  < pMemMngr->currentNumberOfPools  ; count++ )
+    {
+        pMemMngr->buffersPool[count].buffersSize = pMemMngrInit.bufPoolInit[count].buffersSize;
+
+        pMemMngr->buffersPool[count].numFreeDataBuf = pMemMngrInit.bufPoolInit[count].numOfbuffers;
+        
+        pMemMngr->buffersPool[count].dataBufMaxNumber = pMemMngrInit.bufPoolInit[count].numOfbuffers;
+        
+        if((pMemMngr->buffersPool[count].dataBufPool = (mem_DataBuf_T*)os_memoryCAlloc(hOs, 
+            pMemMngr->buffersPool[count].dataBufMaxNumber, sizeof(mem_DataBuf_T))) == NULL)
+        {
+            wlan_memMngrDestroy(pMemMngr);
+            WLAN_OS_REPORT(("FATAL ERROR: Could not allocate buffer pools  for MEM MNGR - Aborting\n"));
+            return NULL;
+        }
+        os_profile (hOs, 8, pMemMngr->buffersPool[count].dataBufMaxNumber * sizeof(mem_DataBuf_T));
+
+        pMemMngr->buffersPool[count].firstFreeDataBuf = pMemMngr->buffersPool[count].dataBufPool;
+        
+        os_memoryZero(hOs, pMemMngr->buffersPool[count].dataBufPool, 
+            (pMemMngr->buffersPool[count].numFreeDataBuf * sizeof(mem_DataBuf_T)));
+
+#ifdef TNETW_MASTER_MODE
+        if((pMemMngr->buffersPool[count].dataBufPoolPtr = (UINT8 *)os_memorySharedAlloc(hOs,
+            pMemMngr->buffersPool[count].buffersSize * pMemMngr->buffersPool[count].dataBufMaxNumber,
+            (void *)&pMemMngr->buffersPool[count].physicalDataBufPoolPtr)) == NULL)
+        {
+            wlan_memMngrDestroy(pMemMngr);
+            WLAN_OS_REPORT(("FATAL ERROR: Could not allocate buffers for MEM MNGR (count=%d / %d, size=%d) - Aborting\n",
+                count, pMemMngr->currentNumberOfPools, 
+                pMemMngr->buffersPool[count].buffersSize * pMemMngr->buffersPool[count].dataBufMaxNumber));
+            return NULL;
+        }
+#else
+        if((pMemMngr->buffersPool[count].dataBufPoolPtr = (UINT8 *)os_memoryAlloc(hOs,
+            pMemMngr->buffersPool[count].buffersSize * pMemMngr->buffersPool[count].dataBufMaxNumber)) == NULL)
+        {
+            wlan_memMngrDestroy(pMemMngr);
+            WLAN_OS_REPORT(("FATAL ERROR: Could not allocate buffers for MEM MNGR - Aborting\n"));
+            return NULL;
+        }
+#endif
+        os_profile (hOs, 8, pMemMngr->buffersPool[count].buffersSize * pMemMngr->buffersPool[count].dataBufMaxNumber);
+
+       /* alocate the buffers */
+        for (i = 0; i < pMemMngr->buffersPool[count].dataBufMaxNumber; ++i) 
+        {
+#ifdef TNETW_MASTER_MODE
+            pMemMngr->buffersPool[count].dataBufPool[i].data = (UINT8 *)
+                (pMemMngr->buffersPool[count].dataBufPoolPtr
+                + i*pMemMngr->buffersPool[count].buffersSize);
+
+            pMemMngr->buffersPool[count].dataBufPool[i].data_physical.u.LowPart = (ULONG)
+                (pMemMngr->buffersPool[count].physicalDataBufPoolPtr.u.LowPart + i*pMemMngr->buffersPool[count].buffersSize);
+#else
+
+            pMemMngr->buffersPool[count].dataBufPool[i].data = (UINT8 *)
+                (pMemMngr->buffersPool[count].dataBufPoolPtr
+                + i*pMemMngr->buffersPool[count].buffersSize);
+
+#endif
+
+            pMemMngr->buffersPool[count].dataBufPool[i].poolIndex = count;
+        }
+    }
+
+    /* chain the items in each list */
+    for (count = 0; count < pMemMngr->msduMaxNumber; ++count) {
+        pMemMngr->msduPool[count].handle = count;
+        if (count < pMemMngr->msduMaxNumber-1)  /* update next pointer except of the last one */
+            pMemMngr->msduPool[count].nextFreeMSDU = &(pMemMngr->msduPool[count+1]);
+    }
+    for (count = 0; count < pMemMngr->bdMaxNumber; ++count) {
+        pMemMngr->bdPool[count].handle = count;
+        if (count < pMemMngr->bdMaxNumber-1)    /* update next pointer except of the last one */
+            pMemMngr->bdPool[count].nextBDPtr = &(pMemMngr->bdPool[count+1]);
+    }
+    for (i = 0; i < pMemMngr->currentNumberOfPools; ++i) {
+        for (count = 0; count < pMemMngr->buffersPool[i].dataBufMaxNumber; ++count) {
+            pMemMngr->buffersPool[i].dataBufPool[count].handle = count;
+            if (count < pMemMngr->buffersPool[i].dataBufMaxNumber-1)        /* update next pointer except of the last one */
+                pMemMngr->buffersPool[i].dataBufPool[count].nextDataBuf = &(pMemMngr->buffersPool[i].dataBufPool[count+1]);
+        }
+    }
+
+    /* assign a pointer for the start of each list */
+    pMemMngr->firstFreeMSDU = pMemMngr->msduPool;
+    pMemMngr->firstFreeBD = pMemMngr->bdPool;
+
+    for(count=0 ; count < MAX_NUMBER_OF_MODULE; count++)
+        pMemMngr->moduleAllocCount[count] = 0;
+
+    if(( pMemMngr->hCriticalSectionProtect = os_protectCreate(hOs)) == NULL)
+    {
+        wlan_memMngrDestroy(pMemMngr);
+        WLAN_OS_REPORT(("FATAL ERROR: Could not Create Critical Section Protection for MEM MNGR - Aborting\n"));
+        return NULL;
+    }
+
+    return pMemMngr;
+}
+/***************************************************************************
+*                       wlan_memMngrConfigure                              *
+****************************************************************************
+* DESCRIPTION:  This function configures MemMngr module     
+* 
+* INPUTS:       hMemMngr - The object 
+*               hOs - Handle to the Os Abstraction Layer
+*               hReport - Handle to the Report object
+* OUTPUT:       
+* 
+* RETURNS:      OK - Configuration succesfull
+*               NOK - Configuration unsuccesfull
+***************************************************************************/
+TI_STATUS wlan_memMngrConfigure(TI_HANDLE hMemMngr, TI_HANDLE hOs, TI_HANDLE hReport)
+{
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    pMemMngr->hReport = hReport;
+
+    WLAN_REPORT_INIT(pMemMngr->hReport, MEM_MGR_MODULE_LOG,
+        (".....MemMngr configured successfully\n"));
+
+    return OK;
+}
+/***************************************************************************
+*                           wlan_memMngrDestroy                            *
+****************************************************************************
+* DESCRIPTION:  This function unload the tMemMngr module. It first free  
+*               the msdu pool, bd pool, data buffers pools and
+*               then free the tMemMngr control block
+* 
+* INPUTS:       hMemMngr - the object
+*       
+* OUTPUT:       
+* 
+* RETURNS:      OK - Unload succesfull
+*               NOK - Unload unsuccesfull
+***************************************************************************/
+
+TI_STATUS wlan_memMngrDestroy(TI_HANDLE hMemMngr)
+{
+    UINT32 count;
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    /* Free Msdu pool */
+    if(pMemMngr->msduPool)
+    {
+        os_memoryFree(pMemMngr->hOs, pMemMngr->msduPool,
+            sizeof(mem_MSDU_T)*pMemMngr->msduMaxNumber); 
+    }
+    /* Free Bd pool */
+    if(pMemMngr->bdPool)
+    {
+        os_memoryFree(pMemMngr->hOs, pMemMngr->bdPool,
+            sizeof(mem_BD_T)*pMemMngr->bdMaxNumber); 
+    }
+
+    /* free data buf pools according to the number of pools */
+    for( count = 0 ; count  < pMemMngr->currentNumberOfPools  ; count++ )
+    {
+#ifdef TNETW_MASTER_MODE
+        if(pMemMngr->buffersPool[count].dataBufPoolPtr)
+        {
+            os_memorySharedFree(pMemMngr->hOs,pMemMngr->buffersPool[count].dataBufPoolPtr,
+                pMemMngr->buffersPool[count].buffersSize*pMemMngr->buffersPool[count].dataBufMaxNumber,
+                pMemMngr->buffersPool[count].physicalDataBufPoolPtr);
+        }
+#else
+        if(pMemMngr->buffersPool[count].dataBufPoolPtr)
+        {
+            os_memoryFree(pMemMngr->hOs,pMemMngr->buffersPool[count].dataBufPoolPtr,
+                pMemMngr->buffersPool[count].buffersSize*pMemMngr->buffersPool[count].dataBufMaxNumber);
+        }
+#endif
+
+        if(pMemMngr->buffersPool[count].dataBufPool)
+        {
+            os_memoryFree(pMemMngr->hOs, pMemMngr->buffersPool[count].dataBufPool,
+                sizeof(mem_DataBuf_T)*pMemMngr->buffersPool[count].dataBufMaxNumber); 
+        }
+    }
+
+    /* free os_protect resources */
+    if(pMemMngr->hCriticalSectionProtect)
+        os_protectDestroy(pMemMngr->hOs,pMemMngr->hCriticalSectionProtect);
+
+    /* free the MemMngr control block */
+    os_memoryFree(pMemMngr->hOs, pMemMngr,sizeof(memMngr_t)); 
+
+    return OK;
+}
+
+/*************************************************************************
+*                        wlan_memMngrAllocDataBuf                        *
+**************************************************************************
+* DESCRIPTION:  This function allocates BDs and Data Buffers according 
+*               to the required length. The memory manager will allocate 
+*               the Data Buffers, update the buffer pointer in the BD 
+*               structure and link the BDs when more than one Data 
+*               Buffer is required. The Buffer length is selected that 
+*               minimum beffer len will allocted.
+*
+* INPUT:        hMemMngr - the object
+*               len - the length of the required data buffer
+*
+* OUTPUT:       BDPtr - a pointer in which this function will return 
+*                   to the allocated BD
+* 
+*RETURN:        OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocDataBuf(TI_HANDLE hMemMngr, mem_BD_T** bdPtr, UINT32 len)
+{
+    UINT32          poolIndex,count,dataBufNum;
+    mem_BD_T*       allocBdTmp;         /* pointer to the current allocated BD in the new list */
+    mem_DataBuf_T*  allocDataBufTmp;    /* pointer to the current allocated Data Buf */
+    buffersPool_t*  tempBuffersPool;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    /* calculate the length and the number of Data Buffers we need allocate */
+    for (poolIndex = 0; poolIndex < pMemMngr->currentNumberOfPools-1; poolIndex++) 
+    {
+        if(len < pMemMngr->buffersPool[poolIndex].buffersSize)
+            break;
+    }
+
+    /* the selected buffer pool */
+    tempBuffersPool = &pMemMngr->buffersPool[poolIndex];
+
+    /* calculate the number of buffers needed */
+    dataBufNum = (len / tempBuffersPool->buffersSize) + 1;
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+    
+    allocBdTmp = pMemMngr->firstFreeBD;
+    *bdPtr = pMemMngr->firstFreeBD;
+
+    allocDataBufTmp = tempBuffersPool->firstFreeDataBuf;
+
+    /* check if we have enough memory - Data buffers (in the selected pool) and Bds */
+    if ((pMemMngr->numFreeBD < dataBufNum) || (tempBuffersPool->numFreeDataBuf < dataBufNum)) 
+    {
+       os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* END OF CRITICAL SECTION */
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG, 
+            ("DB: mem_allocDataBuf: not enough memory numFreeBD=%d numFreeDataBuf=%d in Pool number=%d req DataBufs=%d\n",
+                pMemMngr->numFreeBD, tempBuffersPool->numFreeDataBuf,poolIndex, dataBufNum));
+        *bdPtr = NULL;
+        return NOK;
+    }
+
+    /* update the pointers to the head of the list */
+    for (count = 0 ; count < dataBufNum ; ++count) 
+    {
+        allocBdTmp->refCount = 1;
+        allocBdTmp->dataBuf = allocDataBufTmp;
+        allocBdTmp->data = (char*)(allocDataBufTmp->data);
+#ifdef TNETW_MASTER_MODE
+        allocBdTmp->data_physical_low = os_memoryGetPhysicalLow(allocDataBufTmp->data_physical);
+#endif
+        allocDataBufTmp->refCount = 1;
+        allocBdTmp->length = tempBuffersPool->buffersSize;
+        if (count == (dataBufNum-1)) 
+        {
+            /* the last BD in the allocated list */
+            pMemMngr->firstFreeBD = allocBdTmp->nextBDPtr;
+            tempBuffersPool->firstFreeDataBuf = allocDataBufTmp->nextDataBuf;
+            allocBdTmp->nextBDPtr = NULL;
+            allocDataBufTmp->nextDataBuf = NULL;
+        }
+        else 
+        {
+            allocBdTmp = allocBdTmp->nextBDPtr;
+            allocDataBufTmp = allocDataBufTmp->nextDataBuf;
+        }
+    }
+
+    /* update counter of free Bds and Data buffers */
+    pMemMngr->numFreeBD -= dataBufNum;
+    tempBuffersPool->numFreeDataBuf -= dataBufNum;
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* END OF CRITICAL SECTION */
+
+    return OK;
+}
+
+
+/*************************************************************************
+*                         wlan_memMngrAllocBDs                           *
+**************************************************************************
+* DESCRIPTION:  This function allocates and returns a pointer to a link
+*               list of BDs. This function allocates only Bds structure
+*               and does not allocate any memory buffers.
+*
+* INPUT:        hMemMngr - The object
+*               bdNumber - number of required BDs
+*               
+* OUTPUT:       bdPtr - a pointer in which this function will return 
+*                    to the first Bd in the allocated list
+*
+* RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocBDs(TI_HANDLE hMemMngr, UINT32 bdNumber, mem_BD_T** bdPtr)
+{
+    UINT32          count;
+    mem_BD_T*       allocBdTmp; /* pointer to the current allocated BD in the new list */
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    if (bdNumber == 0) 
+    {
+        *bdPtr = NULL;
+        return NOK;
+    }
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+    allocBdTmp = pMemMngr->firstFreeBD;
+    *bdPtr = pMemMngr->firstFreeBD;
+
+    /* check if we have enough Bds */
+    if (pMemMngr->numFreeBD < bdNumber) 
+    {
+        os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* END OF CRITICAL SECTION */
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+            ("DB: wlan_memMngrAllocBDs: not enough memory\n"));
+        *bdPtr = NULL;
+        return NOK;
+    }
+
+    /* update the pointers to the head of the list */
+    for (count = 0 ; count < bdNumber ; ++count) 
+    {
+        allocBdTmp->refCount = 1;
+        if (count == (bdNumber-1)) 
+        {
+            /* the last bd in the allocated list */
+            pMemMngr->firstFreeBD = allocBdTmp->nextBDPtr;
+            allocBdTmp->nextBDPtr = NULL;
+        }
+        else 
+        {
+            allocBdTmp = allocBdTmp->nextBDPtr;
+        }
+    }
+
+    /* update counter of free Bds  */
+    pMemMngr->numFreeBD -= bdNumber;
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+
+    return OK;
+}
+
+
+/*************************************************************************
+*                        wlan_memMngrAllocMSDU                           *
+**************************************************************************
+* DESCRIPTION:  This function allocates MSDU structure with a number of
+*               BDs and Data Buffers as required by 'len'.
+*
+* INPUT:        hMemMngr - The object
+*               len - the length of the required data buffer
+*                   if len=0, than only MSDU buffer will be allocated
+*               module - the module that allocate this Msdu
+*
+* OUTPUT:       MSDUPtr - a pointer in which this function will 
+*                   return to the allocated MSDU structure
+*
+* RETURN:     OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocMSDU (TI_HANDLE hMemMngr, mem_MSDU_T** MSDUPtr,  
+                              UINT32 len, allocatingModule_e module)
+{
+    UINT32      rc;
+    mem_BD_T*   bdTmp;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    if (pMemMngr->msduPool == NULL)
+    {
+        /* object not initiated yet (!!!) */
+        *MSDUPtr = NULL;
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+            ("wlan_memMngrAllocMSDU: failed!\n"));
+        memMngrPrint(hMemMngr);
+        return NOK;
+    }
+
+    if (len > 0) 
+    {   
+        /* we need to allocate BD and Data Buffers */
+        rc = wlan_memMngrAllocDataBuf(hMemMngr,&bdTmp, len);
+        if (rc == NOK)
+        {
+            *MSDUPtr = NULL;
+            WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("wlan_memMngrAllocMSDU: failed! no data bufs\n"));
+            memMngrPrint(hMemMngr);
+            return NOK;
+        }
+    }
+    else 
+    {
+        /* len = 0 - need to allocate msdu structure only */
+        rc = wlan_memMngrAllocMSDUBufferOnly(hMemMngr, MSDUPtr, module);
+        if (rc == NOK)
+        {
+            *MSDUPtr = NULL;
+            WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("wlan_memMngrAllocMSDU: failed to alloc buffer only!\n"));
+            memMngrPrint(hMemMngr);
+            return NOK;
+        }
+        return OK;
+        
+    }
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* START OF CRITICAL SECTION */
+    
+    /* check if we have enough free Msdu's */
+     if (pMemMngr->firstFreeMSDU == NULL) 
+    {
+        /* no free MSDU buffers */
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("wlan_memMngrAllocMSDU no free MSDU in MemMngr !!!\n"));
+       os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+        memMngrPrint(hMemMngr);
+        
+        /* In case we dont have free msdu - free the allocated Bds */
+        wlan_memMngrFreeBD(hMemMngr,bdTmp->handle);
+        *MSDUPtr = NULL;
+        return NOK;
+    }
+
+    *MSDUPtr = pMemMngr->firstFreeMSDU;
+    pMemMngr->firstFreeMSDU = pMemMngr->firstFreeMSDU->nextFreeMSDU;
+    pMemMngr->moduleAllocCount[module]++;
+
+    /* update counter of free msdu's  */
+    pMemMngr->numFreeMSDU--;
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+
+    (*MSDUPtr)->nextFreeMSDU = NULL;
+    (*MSDUPtr)->freeFunc = NULL;
+    (*MSDUPtr)->firstBDPtr = bdTmp;
+    (*MSDUPtr)->lastBDPtr = bdTmp;
+    (*MSDUPtr)->dataLen = len;
+    (*MSDUPtr)->nextMSDUinList = NULL; 
+    (*MSDUPtr)->prevMSDUinList = NULL; 
+    (*MSDUPtr)->txFlags = 0;        
+    (*MSDUPtr)->txCompleteFlags = 0;
+    (*MSDUPtr)->module = module;
+  #ifdef TI_DBG
+    (*MSDUPtr)->timeStampNum = 0;
+  #endif
+
+    return OK;
+}
+
+/*************************************************************************
+*                 wlan_memMngrAllocMSDUBufferOnly                        *
+**************************************************************************
+* DESCRIPTION:  This function allocates MSDU structure - without 
+*                   Bds and Data Buffers
+*
+* INPUT:        hMemMngr - The object
+*
+* OUTPUT:       MSDUPtr - a pointer in which this function will return 
+*                     to the allocated MSDU structure
+*               module - the module that allocate this Msdu
+*
+* RETURN:       OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrAllocMSDUBufferOnly(TI_HANDLE hMemMngr, mem_MSDU_T** MSDUPtr, allocatingModule_e module)
+{
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+    
+    if (pMemMngr->firstFreeMSDU == NULL) 
+    {
+        /* no free MSDU buffers */
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("wlan_memMngrAllocMSDUBufferOnly no free MSDU in MemMngr !!!\n"));
+        os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+        *MSDUPtr = NULL;
+        return NOK;
+    }
+
+    *MSDUPtr = pMemMngr->firstFreeMSDU;
+    pMemMngr->firstFreeMSDU = pMemMngr->firstFreeMSDU->nextFreeMSDU;
+    pMemMngr->moduleAllocCount[module]++;
+
+    /* update counter of free msdu's  */
+    pMemMngr->numFreeMSDU--;
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* END OF CRITICAL SECTION */
+
+    (*MSDUPtr)->nextFreeMSDU = NULL;
+    (*MSDUPtr)->freeFunc = NULL;
+    (*MSDUPtr)->firstBDPtr = NULL;
+    (*MSDUPtr)->lastBDPtr = NULL;
+    (*MSDUPtr)->dataLen = 0;
+    (*MSDUPtr)->nextMSDUinList = NULL; 
+    (*MSDUPtr)->prevMSDUinList = NULL; 
+    (*MSDUPtr)->txFlags = 0;
+    (*MSDUPtr)->txCompleteFlags = 0;
+    (*MSDUPtr)->module = module;
+  #ifdef TI_DBG
+    (*MSDUPtr)->timeStampNum = 0;
+  #endif
+
+    return OK;
+}
+
+/*************************************************************************
+*                     wlan_memMngrFreeListOfMSDU                         *
+**************************************************************************
+* DESCRIPTION:  Free list of MSDUs structure. This function will run 
+*               over the MSDU list (if exist) and free all MSDU's with 
+*               all BDs and Data Buffers that are bind to this MSDU.
+*
+* INPUT:        hMemMngr - The object
+*               handle - handle to the first MSDU in the list
+*
+* OUTPUT:       
+*
+* RETURN:       OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrFreeListOfMSDU(TI_HANDLE hMemMngr, UINT32 handle)
+{
+    mem_MSDU_T          *msduTmp,*nextTmpMsdu;  
+    
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    msduTmp = &(pMemMngr->msduPool[handle]);
+
+    while (msduTmp != NULL) 
+    {
+        nextTmpMsdu = msduTmp->nextMSDUinList;
+        if(wlan_memMngrFreeMSDU(hMemMngr,memMgr_MsduHandle(msduTmp)) != OK)
+        {
+            WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("wlan_memMngrFreeListOfMSDU This MSDU is already free\n"));
+                   //os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+            return NOK;
+        }
+        msduTmp = nextTmpMsdu;
+    }
+
+    return OK;
+}
+
+/*************************************************************************
+*                        wlan_memMngrFreeMSDU                            *
+**************************************************************************
+* DESCRIPTION:  Free ONE MSDU structure. This function will free all 
+*               BDs and Data Buffers that are bind to this MSDU.
+*
+* INPUT:        hMemMngr - The object
+*               handle - handle of the MSDU
+*
+* OUTPUT:
+*
+* RETURN:       OK/NOK
+**************************************************************************/
+TI_STATUS wlan_memMngrFreeMSDU(TI_HANDLE hMemMngr, UINT32 handle)
+{
+    UINT32 freeFlag;
+    ap_FreeMemFunc      freeFunc = NULL;        /* pointer to the Data Buffer free function */
+    UINT32              freeArgs[NUM_OF_FREE_ARGS]; /* arguments to be send with the free function */
+    int i;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    if( handle == WLAN_DRV_NULL_MEM_HANDLE )
+        return OK;
+
+    /* check if the msdu is already free */
+    if(pMemMngr->msduPool[handle].module == MODULE_FREE_MSDU)
+    {
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("wlan_memMngrFreeMSDU This MSDU is already free\n"));
+        return NOK;
+
+    }
+
+    if (pMemMngr->msduPool[handle].firstBDPtr != NULL) 
+    {
+        /* free all BDs and Data Buffers */
+        freeFlag = wlan_memMngrFreeBD(hMemMngr, pMemMngr->msduPool[handle].firstBDPtr->handle);
+
+        if ((freeFlag == TRUE) && (pMemMngr->msduPool[handle].freeFunc != NULL)) 
+        {
+            /* save the free parameters to do it at the end of the function */
+            freeFunc = pMemMngr->msduPool[handle].freeFunc;
+            for (i=0; i<NUM_OF_FREE_ARGS; i++)
+                freeArgs[i] = pMemMngr->msduPool[handle].freeArgs[i];
+        }
+    }
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* START OF CRITICAL SECTION */
+
+    /* reset the fields of the MSDU buffer */
+    pMemMngr->msduPool[handle].firstBDPtr = NULL;
+    pMemMngr->msduPool[handle].freeFunc = NULL;
+    pMemMngr->msduPool[handle].freeArgs[0] = 0;
+    pMemMngr->msduPool[handle].freeArgs[1] = 0;
+    pMemMngr->msduPool[handle].freeArgs[2] = 0;
+    pMemMngr->msduPool[handle].dataLen = 0;
+    pMemMngr->msduPool[handle].headerLen = 0;
+    pMemMngr->msduPool[handle].txFlags = 0;
+    pMemMngr->msduPool[handle].txCompleteFlags = 0;
+    pMemMngr->msduPool[handle].nextMSDUinList = 0;
+    pMemMngr->msduPool[handle].prevMSDUinList = 0;
+    pMemMngr->numFreeMSDU++;
+
+    pMemMngr->moduleAllocCount[pMemMngr->msduPool[handle].module]--;
+    
+    pMemMngr->msduPool[handle].module = MODULE_FREE_MSDU;
+
+    /* add the MSDU to the free MSDU list */
+    pMemMngr->msduPool[handle].nextFreeMSDU = pMemMngr->firstFreeMSDU;
+    pMemMngr->firstFreeMSDU = &(pMemMngr->msduPool[handle]);
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+
+    /* !!!!!!!! The free should be only after os_protectUnlock !!!!!!!! */
+    if (freeFunc != NULL) 
+    {
+        /* call free function */
+        freeFunc((TI_HANDLE)(freeArgs[0]),
+                 (TI_HANDLE)(freeArgs[1]),
+                 (TI_STATUS)(freeArgs[2]));
+    }
+
+    return OK;
+}
+
+
+/*************************************************************************
+*                            allocDataBuf                                *
+**************************************************************************
+* DESCRIPTION:  Allocate Data Buffer
+* 
+* INPUT:        hMemMngr - The object
+*               dataBuf - pointer to the new allocated Data Buffer
+*               poolIndex - The index of the pool to allocate from
+*
+* OUTPUT:
+*
+* RETURN:       OK/NOK
+**************************************************************************/
+#if 0
+static TI_STATUS allocDataBuf(TI_HANDLE hMemMngr, mem_DataBuf_T* dataBuf, UINT32 poolIndex)
+{
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* START OF CRITICAL SECTION */
+    if (pMemMngr->buffersPool[poolIndex].firstFreeDataBuf == NULL) {
+        os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* END OF CRITICAL SECTION */
+        return NOK;
+    }
+    dataBuf = pMemMngr->buffersPool[poolIndex].firstFreeDataBuf;
+    pMemMngr->buffersPool[poolIndex].firstFreeDataBuf = pMemMngr->buffersPool[poolIndex].firstFreeDataBuf->nextDataBuf;
+    pMemMngr->buffersPool[poolIndex].numFreeDataBuf--;
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* END OF CRITICAL SECTION */
+
+    return OK;
+}
+#endif
+
+
+/*************************************************************************
+*                          freeDataBuf                                   *
+**************************************************************************
+* DESCRIPTION:  Free Data Buffer. 
+*
+* INPUT:        hMemMngr - The object
+*               dataBuf - pointer to the Data Buffer
+*
+* OUTPUT:
+*
+* RETURN:       OK/NOK
+**************************************************************************/
+static TI_STATUS freeDataBuf(TI_HANDLE hMemMngr, mem_DataBuf_T* dataBuf)
+{
+    buffersPool_t   *tempBuffersPool;
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    if (dataBuf->refCount == 0) {
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+            ("DB: freeDataBuf FATAL ERROR: dataBuf->refCount < 0\n"));
+        return NOK;
+    }
+
+    if (--(dataBuf->refCount) == 0) {
+        tempBuffersPool = &pMemMngr->buffersPool[dataBuf->poolIndex];
+        /* add this Data Buffer to the free list of the correct pool*/
+        dataBuf->nextDataBuf = tempBuffersPool->firstFreeDataBuf;
+        tempBuffersPool->firstFreeDataBuf = dataBuf;
+        tempBuffersPool->numFreeDataBuf++;
+    }
+
+    return OK;
+}
+
+
+/*************************************************************************
+*                        wlan_memMngrFreeBD                              *
+**************************************************************************
+* DESCRIPTION:  Free BD structure. This function will free a list of BD
+*               structures and the Data Buffer that is being pointed by 
+*               these BD if any.
+*
+* INPUT:        hMemMngr - The object
+*               handle - handle of this BD
+* OUTPUT:
+* RETURN:       freeFlag - return TRUE if this BD list was freed
+*                   return FALSE if this BD list was not freed (refCount>0)
+**************************************************************************/
+UINT32 wlan_memMngrFreeBD(TI_HANDLE hMemMngr, UINT32 handle)
+{
+    UINT32              rc = FALSE;
+    mem_DataBuf_T*      dataBuf;
+    mem_BD_T*           bdTmp;     /* pointer to the current BD we need to free */
+    mem_BD_T*           nextBdTmp; /* pointer to the next BD we need to free    */
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    bdTmp = &(pMemMngr->bdPool[handle]);
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* START OF CRITICAL SECTION */    
+    
+    while (bdTmp != NULL) 
+    {
+        dataBuf = bdTmp->dataBuf;
+        nextBdTmp = bdTmp->nextBDPtr;
+        if (bdTmp->refCount == 0) 
+        {
+            WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,  
+                ("DB: wlan_memMngrFreeBD FATAL ERROR: bdTmp->refCount < 0\n"));
+            os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* END OF CRITICAL SECTION */
+            return FALSE;
+        }
+        if (dataBuf != NULL) 
+        {
+            freeDataBuf(hMemMngr, dataBuf);
+        }
+
+#ifdef TNETW_MASTER_MODE
+        if( bdTmp->freeFunc != NULL)
+        {
+            bdTmp->freeFunc(  bdTmp->freeArgs[0], bdTmp->freeArgs[1], bdTmp->freeArgs[2],
+                              bdTmp->freeArgs[3], bdTmp->freeArgs[4]);
+        }
+#endif
+
+        if (--(bdTmp->refCount) == 0) 
+        {
+            bdTmp->dataBuf = NULL;
+            bdTmp->data = NULL;
+
+#ifdef TNETW_MASTER_MODE
+            bdTmp->data_physical_low = 0;
+            bdTmp->freeFunc     = NULL;
+            os_memoryZero(pMemMngr->hOs, bdTmp->freeArgs, sizeof(UINT32)*NUM_OF_FREE_ARGS);
+#endif
+            bdTmp->dataOffset = 0;
+            bdTmp->length = 0; 
+            /* adding the free BD to the free BD list */
+            bdTmp->nextBDPtr = pMemMngr->firstFreeBD;
+            pMemMngr->firstFreeBD = bdTmp;
+            pMemMngr->numFreeBD++;
+        }
+        if (nextBdTmp == NULL)
+        {
+            if (bdTmp->refCount <= 0)
+            {
+                rc = TRUE;
+            }
+        }
+        bdTmp = nextBdTmp;
+    }
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect); /* END OF CRITICAL SECTION */
+    return rc;
+}
+
+
+/*************************************************************************
+*                wlan_memMngrFreeAllOsAlocatesBuffer                     *
+**************************************************************************
+* DESCRIPTION:  This function run over the all msdus in the MemMngr 
+*               and call the free function of the os allocated buffers
+*
+* INPUT:        hMemMngr - The object
+*           
+* OUTPUT:
+*               
+* RETURN:       OK
+**************************************************************************/
+
+TI_STATUS wlan_memMngrFreeAllOsAlocatesBuffer(TI_HANDLE hMemMngr)
+{
+    UINT32 count;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* START OF CRITICAL SECTION */
+
+    for(count = 0 ; count < pMemMngr->msduMaxNumber ; count++)
+    {
+        if (pMemMngr->msduPool[count].freeFunc)
+        {
+            WLAN_OS_REPORT(("wlan_memMngrFreeAllOsAlocatesBuffer() - Call Os free func */*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ :\n"));
+#ifndef TNETW_MASTER_MODE
+            pMemMngr->msduPool[count].freeArgs[2] = NOK;
+#endif
+            /* call free function */
+            pMemMngr->msduPool[count].freeFunc((TI_HANDLE)(pMemMngr->msduPool[count].freeArgs[0]),
+                                                (TI_HANDLE)(pMemMngr->msduPool[count].freeArgs[1]),
+                                                (TI_STATUS)(pMemMngr->msduPool[count].freeArgs[2]));
+
+            pMemMngr->msduPool[count].freeFunc = NULL;
+            pMemMngr->msduPool[count].freeArgs[0] = 0;
+            pMemMngr->msduPool[count].freeArgs[1] = 0;
+            pMemMngr->msduPool[count].freeArgs[2] = 0;
+        }
+    }
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* END OF CRITICAL SECTION */
+
+    return OK;
+}
+
+/*************************************************************************
+*                 wlan_memMngrCopyMsduFreeFunc                           *
+**************************************************************************
+* DESCRIPTION:  Copy The free function and the free arguments from on 
+*               Msdu to another 
+*
+* INPUT:        hMemMngr - The object
+*               destMsduHandle - the handle of the destination msdu
+*               sourceMsduHandle - the handle of the source msdu    
+* 
+* OUTPUT:
+*
+* RETURN:       OK
+**************************************************************************/
+
+TI_STATUS wlan_memMngrCopyMsduFreeFunc(TI_HANDLE hMemMngr, UINT32 destMsduHandle, UINT32 sourceMsduHandle)
+{
+    mem_MSDU_T*             sourceMsdu; 
+    mem_MSDU_T*             destMsdu;   
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+     if( destMsduHandle == WLAN_DRV_NULL_MEM_HANDLE || sourceMsduHandle == WLAN_DRV_NULL_MEM_HANDLE )
+         return NOK;
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* START OF CRITICAL SECTION */
+
+    sourceMsdu = &(pMemMngr->msduPool[sourceMsduHandle]);
+    destMsdu = &(pMemMngr->msduPool[destMsduHandle]);
+
+    destMsdu->freeFunc = sourceMsdu->freeFunc;
+    
+    os_memoryCopy(pMemMngr->hOs, (void *)destMsdu->freeArgs, (void *)sourceMsdu->freeArgs,(NUM_OF_FREE_ARGS*sizeof(UINT32)));
+
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* END OF CRITICAL SECTION */
+
+    return OK;
+}
+
+/*************************************************************************
+*                 wlan_memMngrChangeMsduOwner                            *
+**************************************************************************
+* DESCRIPTION:  the function changes the msdu module owner.
+*
+* INPUT:        hMemMngr - The object
+*               newModule - msdu new module owner
+*               pMsdu - the msdu to be changed  
+* 
+* OUTPUT:
+*
+* RETURN:       OK
+**************************************************************************/
+
+TI_STATUS wlan_memMngrChangeMsduOwner(TI_HANDLE hMemMngr,allocatingModule_e newModule,mem_MSDU_T *pMsdu)
+{
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+    allocatingModule_e oldModule;
+
+    if(pMsdu == NULL)
+    {
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,
+            ("wlan_memMngrChangeMsduOwner: pMsdu == NULL\n"));
+        return NOK;
+
+    }
+
+    oldModule = pMsdu->module;
+
+    if(pMemMngr->moduleAllocCount[oldModule] > 0)
+    {
+        pMemMngr->moduleAllocCount[oldModule]--;
+    }
+    else
+    {
+        WLAN_REPORT_ERROR(pMemMngr->hReport, MEM_MGR_MODULE_LOG,
+                            ("wlan_memMngrChangeMsduOwner: oldModule %d  AllocCount < 0 ,newModule %d\n", oldModule,newModule));
+        return NOK;
+    }
+    
+
+    pMemMngr->moduleAllocCount[newModule]++;
+
+    pMsdu->module = newModule;
+
+    WLAN_REPORT_INFORMATION(pMemMngr->hReport, MEM_MGR_MODULE_LOG,
+                        ("wlan_memMngrChangeMsduOwner: oldModule: %d , newModule: %d\n", oldModule, newModule));
+
+
+    return OK;
+
+
+
+    
+
+
+}
+
+
+/*************************************************************************
+*                 wlan_memMngrSwapMsdu                                  *
+**************************************************************************
+* DESCRIPTION:  Swap two Msdu, only the MSDU descriptor and not all fields
+*                
+* INPUT:        
+* 
+* OUTPUT:
+*
+* RETURN:       OK
+**************************************************************************/
+TI_STATUS wlan_memMngrSwapMsdu(TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu_1, mem_MSDU_T *pMsdu_2)
+{
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+    mem_MSDU_T Msdu_tmp;
+
+    os_protectLock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);  /* START OF CRITICAL SECTION */
+
+    /* copy msdu 1 to Temporary msdu */
+    Msdu_tmp.freeFunc = pMsdu_1->freeFunc;  
+    os_memoryCopy(pMemMngr->hOs, (void *)Msdu_tmp.freeArgs, (void *)pMsdu_1->freeArgs,(NUM_OF_FREE_ARGS*sizeof(UINT32)));
+    Msdu_tmp.dataLen = pMsdu_1->dataLen;
+    Msdu_tmp.headerLen = pMsdu_1->headerLen;
+    Msdu_tmp.firstBDPtr = pMsdu_1->firstBDPtr;
+    Msdu_tmp.lastBDPtr  = pMsdu_1->lastBDPtr;
+
+    /* copy msdu 2 to msdu 1 */
+    pMsdu_1->freeFunc = pMsdu_2->freeFunc;  
+    os_memoryCopy(pMemMngr->hOs, (void *)pMsdu_1->freeArgs, (void *)pMsdu_2->freeArgs,(NUM_OF_FREE_ARGS*sizeof(UINT32)));
+    pMsdu_1->dataLen = pMsdu_2->dataLen;
+    pMsdu_1->headerLen = pMsdu_2->headerLen;
+    pMsdu_1->firstBDPtr = pMsdu_2->firstBDPtr;
+    pMsdu_1->lastBDPtr  = pMsdu_2->lastBDPtr;
+
+    /* copy Temporary msdu to msdu 2 */
+    pMsdu_2->freeFunc = Msdu_tmp.freeFunc;  
+    os_memoryCopy(pMemMngr->hOs, (void *)pMsdu_2->freeArgs, (void *)Msdu_tmp.freeArgs,(NUM_OF_FREE_ARGS*sizeof(UINT32)));
+    pMsdu_2->dataLen = Msdu_tmp.dataLen;
+    pMsdu_2->headerLen = Msdu_tmp.headerLen;
+    pMsdu_2->firstBDPtr = Msdu_tmp.firstBDPtr;
+    pMsdu_2->lastBDPtr  = Msdu_tmp.lastBDPtr;
+        
+    os_protectUnlock(pMemMngr->hOs, pMemMngr->hCriticalSectionProtect);/* END OF CRITICAL SECTION */
+
+    return OK;
+}
+
+TI_STATUS wlan_memMngrGetMemMgrResources(TI_HANDLE hMemMngr, memMgrResources_t* memMgrResources)
+{
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    memMgrResources->numOfFreeBDs = pMemMngr->numFreeBD;
+    memMgrResources->numOfFreeMsdu = pMemMngr->numFreeMSDU;
+    memMgrResources->numOfFreeBufPool1 = pMemMngr->buffersPool[0].numFreeDataBuf;
+    memMgrResources->numOfFreeBufPool2 = pMemMngr->buffersPool[1].numFreeDataBuf;
+    memMgrResources->numOfFreeBufPool3 = pMemMngr->buffersPool[2].numFreeDataBuf;
+    
+    return OK;
+}
+
+
+TI_STATUS wlan_memMngrAddTimeStamp (TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu)
+{
+  #ifdef TI_DBG
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    if (pMsdu->timeStampNum < MAX_NUM_OF_TIME_STAMPS)
+        pMsdu->timeStamp[pMsdu->timeStampNum ++] =
+            os_timeStampUs (pMemMngr->hOs);
+  #endif
+
+    return OK;
+}
+
+
+/*************************************************************************
+**************************************************************************
+*                                                                        *
+*                            TEST FUNCTIONS                              *
+*                                                                        *
+**************************************************************************
+**************************************************************************/
+
+void memMngrPrintMSDU(mem_MSDU_T* pMsdu )
+{
+    WLAN_OS_REPORT(("\nPrinting MSDU :\n"));
+    WLAN_OS_REPORT(("handle          = %X\n",pMsdu->handle));
+    WLAN_OS_REPORT(("nextFreeMSDU         = %X\n",pMsdu->nextFreeMSDU));     
+    WLAN_OS_REPORT(("headerLen       = %d\n",pMsdu->headerLen));    
+    WLAN_OS_REPORT(("firstBDPtr      = %X\n",pMsdu->firstBDPtr));   
+    WLAN_OS_REPORT(("lastBDPtr       = %X\n",pMsdu->lastBDPtr));     
+    WLAN_OS_REPORT(("freeFunc        = %X\n",pMsdu->freeFunc));      
+    WLAN_OS_REPORT(("freeArgs[0]     = %X\n",pMsdu->freeArgs[0]));   
+    WLAN_OS_REPORT(("freeArgs[1]     = %X\n",pMsdu->freeArgs[1]));   
+    WLAN_OS_REPORT(("freeArgs[2]     = %X\n",pMsdu->freeArgs[2]));   
+    WLAN_OS_REPORT(("freeArgs[3]     = %X\n",pMsdu->freeArgs[3]));   
+    WLAN_OS_REPORT(("freeArgs[4]     = %X\n",pMsdu->freeArgs[4]));   
+    WLAN_OS_REPORT(("dataLen         = %d\n",pMsdu->dataLen));       
+    WLAN_OS_REPORT(("module          = %d\n",pMsdu->module));       
+    WLAN_OS_REPORT(("nextMSDUinList  = %X\n",pMsdu->nextMSDUinList));
+    WLAN_OS_REPORT(("prevMSDUinList  = %X\n",pMsdu->prevMSDUinList));
+    WLAN_OS_REPORT(("txFlags         = %X\n",pMsdu->txFlags));       
+    WLAN_OS_REPORT(("txCompleteFlags = %X\n",pMsdu->txCompleteFlags));       
+
+}
+
+void memMngrPrintBD(mem_BD_T * pBd )
+{
+    WLAN_OS_REPORT(("\nPrinting BD \n"));
+    WLAN_OS_REPORT(("handle           = %X\n",pBd->handle));     
+    WLAN_OS_REPORT(("refCount         = %d\n",pBd->refCount));   
+    WLAN_OS_REPORT(("dataBuf          = %X\n",pBd->dataBuf));    
+    WLAN_OS_REPORT(("data             = %X\n",pBd->data));       
+    WLAN_OS_REPORT(("dataOffset       = %d\n",pBd->dataOffset)); 
+    WLAN_OS_REPORT(("length           = %d\n",pBd->length));     
+    WLAN_OS_REPORT(("nextBDPtr        = %X\n",pBd->nextBDPtr));
+#ifdef TNETW_MASTER_MODE 
+    WLAN_OS_REPORT(("data_physical_low = %X\n",pBd->data_physical_low));
+#endif
+}
+
+void memMngrPrintDataBuf(mem_DataBuf_T* pDataBuf )
+{
+    WLAN_OS_REPORT(("\nPrinting DataBuf \n"));
+    WLAN_OS_REPORT(("handle      = %X\n",pDataBuf->handle));     
+    WLAN_OS_REPORT(("nextDataBuf = %X\n",pDataBuf->nextDataBuf));    
+    WLAN_OS_REPORT(("refCount    = %d\n",pDataBuf->refCount));  
+    WLAN_OS_REPORT(("poolIndex = %X\n",pDataBuf->poolIndex));       
+    WLAN_OS_REPORT(("data              = %d\n",pDataBuf->data)); 
+}
+
+void memMngrPrintMSDUWithItsBds(mem_MSDU_T* pMsdu )
+{
+    mem_BD_T *bdTmp = pMsdu->firstBDPtr;
+
+    memMngrPrintMSDU(pMsdu);
+
+    while(bdTmp != NULL)
+    {
+        memMngrPrintBD(bdTmp);
+        bdTmp = bdTmp->nextBDPtr;
+    }
+}
+
+void memMngrPrintHandle(TI_HANDLE hMemMngr, UINT32 handle)
+{
+    mem_BD_T*       tmpBD;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    WLAN_REPORT_INFORMATION(pMemMngr->hReport, MEM_MGR_MODULE_LOG, 
+        ("MSDU handle = %d firstBDPtr=%X length=%d\n", handle,  
+                            pMemMngr->msduPool[handle].firstBDPtr,
+                            pMemMngr->msduPool[handle].dataLen));
+
+    tmpBD = pMemMngr->msduPool[handle].firstBDPtr;
+    while (tmpBD != NULL) {
+        WLAN_REPORT_INFORMATION(pMemMngr->hReport, MEM_MGR_MODULE_LOG,
+            ("MSDU BD=%X handle=%d refCount=%d\n", tmpBD, tmpBD->handle, tmpBD->refCount));
+        tmpBD = tmpBD->nextBDPtr;
+    }
+
+}
+
+void memMngrFullPrint(TI_HANDLE hMemMngr)
+{
+    mem_MSDU_T*     tmpMSDU;
+    mem_BD_T*       tmpBD;
+    mem_DataBuf_T*  tmpDataBuf;
+    UINT32  j,i=0;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    WLAN_OS_REPORT(("memMngrPrint\n"));
+    WLAN_OS_REPORT(("numFreeMSDU %d numFreeBD %d  \n", pMemMngr->numFreeMSDU, pMemMngr->numFreeBD));
+    for(j = 0 ;j < pMemMngr->currentNumberOfPools; j++)
+        WLAN_OS_REPORT(("Pool Num %d   buffer length %d   numFreeDataBuf %d \n",
+        j, pMemMngr->buffersPool[j].buffersSize, pMemMngr->buffersPool[j].numFreeDataBuf));
+
+    WLAN_OS_REPORT(("\nAllocated by modules : MLME=%d, OS_ABS=%d,  RSN=%d,  HAL_RX=%d\n",
+        pMemMngr->moduleAllocCount[MLME_MODULE],pMemMngr->moduleAllocCount[OS_ABS_TX_MODULE],
+        pMemMngr->moduleAllocCount[RSN_MODULE],pMemMngr->moduleAllocCount[HAL_RX_MODULE]));
+
+
+    WLAN_OS_REPORT(("\nfirstFreeMSDU=%X\n",pMemMngr->firstFreeMSDU));
+    tmpMSDU = pMemMngr->firstFreeMSDU;
+    while (++i, tmpMSDU != NULL) {
+        WLAN_OS_REPORT(("tmpMSDU %d = %X handle=%d tmpMSDU->nextMSDU=%X\n", 
+            i, tmpMSDU, tmpMSDU->handle, tmpMSDU->nextFreeMSDU));
+        tmpMSDU = tmpMSDU->nextFreeMSDU;
+    }
+
+    WLAN_OS_REPORT(("\nfirstFreeBD=%X\n",pMemMngr->firstFreeBD));
+    i = 0;
+    tmpBD = pMemMngr->firstFreeBD;
+    while (++i, tmpBD != NULL) {
+        WLAN_OS_REPORT(("tmpBD %d = %X handle=%d tmpBD->nextBDPtr=%X\n",
+            i, tmpBD, tmpBD->handle, tmpBD->nextBDPtr));
+        tmpBD = tmpBD->nextBDPtr;
+    }
+    WLAN_OS_REPORT(("\n"));
+
+    for(j = 0 ;j < pMemMngr->currentNumberOfPools; j++) {
+        i = 0;
+        tmpDataBuf = pMemMngr->buffersPool[j].firstFreeDataBuf;
+        WLAN_OS_REPORT(("\npoolIndex=%d  firstFreeDataBuf=%X\n",j,pMemMngr->buffersPool[j].firstFreeDataBuf));
+        while (++i, tmpDataBuf != NULL) {
+            WLAN_OS_REPORT(("Buf %d = %X handle=%d  next=%X poolIndex=%d pData=%X\n", i, tmpDataBuf,
+                tmpDataBuf->handle,tmpDataBuf->nextDataBuf, tmpDataBuf->poolIndex, tmpDataBuf->data));
+            tmpDataBuf = tmpDataBuf->nextDataBuf;
+        }
+        WLAN_OS_REPORT(("\n"));
+    }
+    WLAN_OS_REPORT(("\n"));
+}
+
+
+void memMngrPrint(TI_HANDLE hMemMngr)
+{
+#if 0
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    WLAN_OS_REPORT(("memMngrPrint\n"));
+    WLAN_OS_REPORT(("numFreeMSDU %d numFreeBD %d  \n", pMemMngr->numFreeMSDU, pMemMngr->numFreeBD));
+    for(j = 0 ;j < pMemMngr->currentNumberOfPools; j++)
+        WLAN_OS_REPORT(("Pool Num %d   buffer length %d   numFreeDataBuf %d \n", j, 
+            pMemMngr->buffersPool[j].buffersSize, pMemMngr->buffersPool[j].numFreeDataBuf));
+
+    WLAN_OS_REPORT(("\nAllocated by modules on Tx\n"));
+
+
+    WLAN_OS_REPORT(("\nAllocated by modules : MLME=%d, OS_ABS=%d,  RSN=%d  \n", 
+                                            pMemMngr->moduleAllocCount[MLME_MODULE],
+                                            pMemMngr->moduleAllocCount[OS_ABS_TX_MODULE],
+                                            pMemMngr->moduleAllocCount[RSN_MODULE]));
+
+    WLAN_OS_REPORT(("\nAllocated by modules : HAL_TX=%d, CONCAT=%d,  DE_CONCAT=%d,  TX=%d\n", 
+                                            pMemMngr->moduleAllocCount[HAL_TX_MODULE],
+                                            pMemMngr->moduleAllocCount[CONCAT_MODULE],
+                                            pMemMngr->moduleAllocCount[DE_CONCAT_MODULE],
+                                            pMemMngr->moduleAllocCount[TX_MODULE]));
+
+    WLAN_OS_REPORT(("\nAllocated by modules : ACK_EMUL=%d, MEASUREMENT=%d,  SITE_MGR=%d,  EXC_MANAGER=%d\n", 
+                                            pMemMngr->moduleAllocCount[ACK_EMUL_MODULE],
+                                            pMemMngr->moduleAllocCount[MEASUREMENT_MODULE],
+                                            pMemMngr->moduleAllocCount[SITE_MGR_MODULE],
+                                            pMemMngr->moduleAllocCount[EXC_MANAGER_MODULE]));
+
+    WLAN_OS_REPORT(("\nAllocated by modules on Rx\n"));
+
+    WLAN_OS_REPORT(("\nAllocated by modules : HAL_RX=%d, CORE_RX=%d,  MLME_RX=%d,  OS_ABS_RX=%d\n", 
+                                            pMemMngr->moduleAllocCount[HAL_RX_MODULE],
+                                            pMemMngr->moduleAllocCount[CORE_RX_MODULE],
+                                            pMemMngr->moduleAllocCount[MLME_RX_MODULE],
+                                            pMemMngr->moduleAllocCount[OS_ABS_RX_MODULE]));
+
+    WLAN_OS_REPORT(("\nAllocated by modules : RSN_RX=%d, MEASUREMENT_RX=%d,  SITE_MGR_RX=%d,  EXC_MANAGER_RX=%d\n", 
+                                            pMemMngr->moduleAllocCount[RSN_RX_MODULE],
+                                            pMemMngr->moduleAllocCount[MEASUREMENT_RX_MODULE],
+                                            pMemMngr->moduleAllocCount[SITE_MGR_RX_MODULE],
+                                            pMemMngr->moduleAllocCount[EXC_MANAGER_RX_MODULE]));
+
+
+
+    WLAN_OS_REPORT(("\nAllocated by modules : HAL_WEP1_RX=%d, HAL_WEP2_RX=%d, HAL_DEFRAG_RX=%d,  HAL_DUPLICA_RX=%d\n", 
+                                            pMemMngr->moduleAllocCount[HAL_WEP1_RX],
+                                            pMemMngr->moduleAllocCount[HAL_WEP2_RX],
+                                            pMemMngr->moduleAllocCount[HAL_DEFRAG_RX],
+                                            pMemMngr->moduleAllocCount[HAL_DUPLICA_RX]));
+
+
+
+
+    WLAN_OS_REPORT(("\nAllocated by modules : FREE_MSDU=%d\n", 
+                                        pMemMngr->moduleAllocCount[MODULE_FREE_MSDU]));
+
+#endif
+}
+
+void print_MsduDataHeader(TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu)
+{
+    mem_BD_T            *pBd;
+    UINT8               tempBuffer[40],*pTempBuffer;
+    UINT32              lengthToPrint = 40;
+    UINT32              i;
+
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    pTempBuffer = tempBuffer;
+    pBd =  pMsdu->firstBDPtr;
+
+    while (lengthToPrint != 0)
+    {
+        if (pBd->length < lengthToPrint)    
+        {
+            os_memoryCopy(pMemMngr->hOs, (void *)pTempBuffer, (void *)pBd->data, pBd->length);
+            lengthToPrint -= pBd->length;
+            pTempBuffer += pBd->length;         
+            pBd = pBd->nextBDPtr;
+        }
+        else                            /* enough place in current BD*/
+        {
+            os_memoryCopy(pMemMngr->hOs, (void *)pTempBuffer, (void *)pBd->data, lengthToPrint);
+            lengthToPrint = 0;
+        }
+    }
+    WLAN_OS_REPORT(("\n"));
+    for(i = 0 ; i < 60 ; i++)
+    {
+        WLAN_OS_REPORT(("%02X ",tempBuffer[i]));
+    }
+    WLAN_OS_REPORT(("\n\n"));
+}
+/*void DumpMemory(char* data, int size)
+{
+    char NumStr[60], CharStr[20], ResStr[81];
+    int bank, i, space;
+    
+    bank = 0;
+    
+    for(i=0; i<size; i++) {
+        
+        sprintf(&NumStr[bank*3], "%02X ", (UCHAR)data[i]);
+        CharStr[bank] = (data[i]>=0x20 && data[i]<=0x7E) ? data[i] : '.';
+        
+        if(++bank == 16) {
+            CharStr[bank] = 0;
+            sprintf(ResStr, "%s        %s", NumStr, CharStr);
+            printf("%s\n",ResStr);
+            bank = 0;
+        }
+        
+    }
+    
+    if(bank) {
+        CharStr[bank] = 0;
+        printf("%s", NumStr);
+        if(size < 16)
+            space = 6;
+        else
+            space = 56-strlen(NumStr);
+        for(i=0; i<space; i++)
+            printf(" ");
+        printf("%s\n",CharStr);
+    }
+    
+}
+*/
+
+TI_STATUS txDataSTUB_txSendMsdu(TI_HANDLE hMemMngr, mem_MSDU_T *pMsdu)
+{
+    TI_STATUS status;
+    memMngr_t *pMemMngr = (memMngr_t *)hMemMngr;
+
+    status = wlan_memMngrFreeMSDU(pMemMngr, memMgr_MsduHandle(pMsdu));
+    if(status != OK)
+        return NOK;
+    
+    return OK;
+}
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/nrfsm.c b/sta_dk_4_0_4_32/common/src/utils/nrfsm.c
new file mode 100644 (file)
index 0000000..50376cf
--- /dev/null
@@ -0,0 +1,426 @@
+/** \file nrfsm.c
+ *  \brief non-recursive finite state machine source code
+ *
+ *  \see nrfsm.h
+ */
+
+ /****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE: fsm.c                                                      */
+/*    PURPOSE:  Finite State Machine source code                           */
+/*                                                                         */
+/***************************************************************************/
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "utils.h"
+#include "nrfsm.h"
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/* Structures */
+
+/** General NR-FSM structure */
+typedef struct
+{
+    TI_HANDLE               hOs;                    /**< OS handle */ 
+    nrfsm_matrix_t          matrix;                 /**< State\event matrix */
+    UINT32                  uMaxNoOfStates;         /**< Max number of states in the matrix */
+    UINT32                  uMaxNoOfEvents;         /**< Max number of events in the matrix */
+    UINT32                  uActNoOfStates;         /**< Actual number of states in the matrix */
+    UINT32                  uActNoOfEvents;         /**< Actual number of events in the matrix */
+    UINT32                  uInAction;              /**< Number of handled events */
+    UINT32                  state;                  /**< Current state */
+    UINT32                  event;                  /**< Last event sent */
+    void                   *pData;                  /**< Last event data */
+    BOOL                    bEventPending;          /**< Event pending indicator */
+
+} nrfsm_t;
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+/**
+*
+* nrfsm_Init  - Initialize the FSM structure
+*
+* \b Description: 
+*
+* Init The FSM structure. If matrix argument is NULL, allocate memory for
+* new matrix.
+*
+* \b ARGS:
+*
+*  I   - hOs  - OS handler
+*  O   - hFsm - the generated FSM module  \n
+*  I   - uMaxNoOfStates - Number of states in the module \n
+*  I   - uMaxNoOfEvents - Number of events in the module \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Event
+*/
+TI_STATUS nrfsm_Create (TI_HANDLE  hOs,
+                        TI_HANDLE *hFsm,
+                        UINT32     uMaxNoOfStates,
+                        UINT32     uMaxNoOfEvents)
+{
+    nrfsm_t *pFsm;
+
+    /* Check for preliminary conditions */
+    if (hFsm == NULL || uMaxNoOfStates == 0 || uMaxNoOfEvents == 0)
+    {
+        return NOK;
+    }
+
+    /* Allocate memory for FSM context */
+    pFsm = (nrfsm_t *)os_memoryAlloc (hOs, sizeof(nrfsm_t));
+    if (pFsm == NULL)
+    {
+        return NOK;
+    }
+
+    /* Allocate memory for FSM matrix */
+    pFsm->matrix = (nrfsm_matrix_t)os_memoryAlloc (hOs, uMaxNoOfStates * uMaxNoOfEvents * sizeof(nrfsm_action_cell_t));
+    if (pFsm->matrix == NULL)
+    {
+        os_memoryFree (hOs, pFsm, sizeof(nrfsm_t));
+        return NOK;
+    }
+
+    /* Update pFsm structure with parameters */
+    pFsm->uMaxNoOfStates = uMaxNoOfStates;
+    pFsm->uMaxNoOfEvents = uMaxNoOfEvents;
+    pFsm->hOs = hOs;
+
+    *hFsm = (TI_HANDLE)pFsm;
+
+    return OK;
+}
+
+
+/**
+*
+* nrfsm_Unload  - free all memory allocated to FSM structure
+*
+* \b Description: 
+*
+* Unload the FSM structure.
+*
+* \b ARGS:
+*
+*  I   - hFsm - the generated FSM module handle \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Event
+*/
+TI_STATUS nrfsm_Unload (TI_HANDLE hFsm)
+{
+    nrfsm_t *pFsm = (nrfsm_t *)hFsm;
+
+    /* Check for preliminary conditions */
+    if (pFsm == NULL)
+    {
+        return NOK;
+    }
+
+    /* Free memory of FSM matrix */
+    if (pFsm->matrix != NULL)
+    {
+        os_memoryFree (pFsm->hOs, 
+                       pFsm->matrix,
+                       pFsm->uMaxNoOfStates * pFsm->uMaxNoOfEvents * sizeof(nrfsm_action_cell_t));
+    }
+
+    /* Free memory for FSM context (no need to check for null) */
+    os_memoryFree (pFsm->hOs, pFsm, sizeof(nrfsm_t));
+
+    return OK;
+}
+
+
+/**
+*
+* fsm_Init  - Initialize the FSM structure
+*
+* \b Description: 
+*
+* Init The FSM structure. If matrix argument is NULL, allocate memory for
+* new matrix.
+*
+* \b ARGS:
+*
+*  O   - hFsm - the generated FSM module handle \n
+*  I   - uActNoOfStates - Actual number of states in the module \n
+*  I   - uActNoOfEvents - Actual number of events in the module \n
+*  I/O - pMatrix - the state event matrix pointer
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa fsm_Event
+*/
+TI_STATUS nrfsm_Config (TI_HANDLE      hFsm,
+                        nrfsm_matrix_t pMatrix,
+                        UINT32         uActNoOfStates,
+                        UINT32         uActNoOfEvents)
+{
+    nrfsm_t *pFsm = (nrfsm_t *)hFsm;   
+
+    /* Check for preliminary conditions */
+    if (pFsm == NULL || pMatrix == NULL)
+    {
+        return NOK;
+    }
+
+    if (uActNoOfStates > pFsm->uMaxNoOfStates || 
+        uActNoOfEvents > pFsm->uMaxNoOfEvents)
+    {
+        return NOK;
+    }
+
+    /* Copy matrix to FSM context */
+    os_memoryCopy (pFsm->hOs, 
+                   pFsm->matrix, 
+                   pMatrix,
+                   uActNoOfStates * uActNoOfEvents * sizeof(nrfsm_action_cell_t));
+
+    /* Update pFsm structure with parameters */
+    pFsm->uActNoOfStates = uActNoOfStates;
+    pFsm->uActNoOfEvents = uActNoOfEvents;
+    pFsm->uInAction = 0;
+    pFsm->state = 0;
+
+    return OK;
+}
+
+
+/**
+*
+* nrfsm_Event  - perform event transition in the matrix
+*
+* \b Description: 
+*
+* Perform event transition in the matrix
+*
+* \b ARGS:
+*
+*  I   - hFsm - the generated FSM module handle handle \n
+*  I   - event - event causing transition \n
+*  I   - pData - data for activation function \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure, 1 on pending in queue 
+*
+* \sa fsm_Init
+*/
+TI_STATUS nrfsm_Event (TI_HANDLE hFsm, UINT32 event, void *pData)
+{
+    nrfsm_t *pFsm = (nrfsm_t *)hFsm;   
+    UINT32   uIndex;
+    
+    /* Check for FSM existance */
+    if (pFsm == NULL)
+    {
+        return NOK;
+    }
+
+    /* Boundary check */
+    if (pFsm->state >= pFsm->uActNoOfStates || event >= pFsm->uActNoOfEvents)
+    {
+        return NOK;
+    }
+
+    /* Store request action */
+    pFsm->event = event;
+    pFsm->pData = pData;
+    pFsm->bEventPending = TRUE;
+    /*pFsm->uInAction ++;*/
+    
+    /* If currently performing an action, return (requested event will be handled when current action is finished) */
+    if (pFsm->uInAction > 0)
+    {
+        if (pFsm->uInAction > 1)
+            return NOK;
+        return (TI_STATUS)1;
+    }
+  
+    /* Perform requested events (avoid recursion when an action sends another event to any SM) */
+    while (pFsm->bEventPending/*pFsm->uInAction*/)
+    {
+        pFsm->uInAction ++;
+        pFsm->bEventPending = FALSE;
+
+        /* Calculate action cell index */
+        uIndex = pFsm->state * pFsm->uActNoOfEvents + pFsm->event;
+
+        /* Update current state */
+        pFsm->state = pFsm->matrix[uIndex].nState;
+
+        /* Activate transition function */
+        (*pFsm->matrix[uIndex].fAction) (pFsm->pData);
+
+        pFsm->uInAction --;
+    }
+
+    return OK;
+}
+
+
+/**
+*
+* nrfsm_SetState  - Set the initial state.
+*
+* \b Description: 
+*
+* Set the initial state.
+*
+* \b ARGS:
+*
+*  I   - hFsm - the generated FSM module handle \n
+*  I   - state - current state of the SM \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa 
+*/
+TI_STATUS nrfsm_SetState (TI_HANDLE hFsm, UINT32 state)                          
+{
+    nrfsm_t *pFsm = (nrfsm_t *)hFsm;   
+
+    /* Boundary check */
+    if (pFsm->state >= pFsm->uActNoOfStates)
+    {
+        return NOK;
+    }
+    else
+    {
+        pFsm->state = state; 
+        return OK;
+    }
+}
+
+
+/**
+*
+* nrfsm_GetNextState  - Return the current state.
+*
+* \b Description: 
+*
+* Return the current state.
+*
+* \b ARGS:
+*
+*  I   - hFsm - the generated FSM module handle \n
+*  O   - state - current state of the SM \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa 
+*/
+TI_STATUS nrfsm_GetState (TI_HANDLE hFsm, UINT32 *state)                       
+{
+    nrfsm_t *pFsm = (nrfsm_t *)hFsm;   
+
+    *state = pFsm->state;
+
+    return OK;
+}
+
+
+/**
+*
+* nrfsm_GetNextState  - Return the next state for a given current state and an event.
+*
+* \b Description: 
+*
+* Return the next state for a given current state and an event.
+*
+* \b ARGS:
+*
+*  I   - pFsm - the generated FSM module  \n
+*  I   - event - event causing transition \n
+*  O   - state - returned next state \n
+*
+* \b RETURNS:
+*
+*  OK on success, NOK on failure 
+*
+* \sa 
+*/
+TI_STATUS nrfsm_GetNextState (TI_HANDLE  hFsm, UINT32 event, UINT32 *state)
+{
+    nrfsm_t *pFsm = (nrfsm_t *)hFsm;   
+
+    if (pFsm != NULL)
+    {
+        if (pFsm->state < pFsm->uActNoOfStates && event < pFsm->uActNoOfEvents)
+        {
+            *state = pFsm->matrix[pFsm->state * pFsm->uActNoOfEvents + event].nState;
+            return OK;
+        }
+    }
+    
+    return NOK;
+}
+
+
+/*TI_STATUS action_nop(void *pData)
+{
+    return OK;
+}*/
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/nrfsm.h b/sta_dk_4_0_4_32/common/src/utils/nrfsm.h
new file mode 100644 (file)
index 0000000..9aff9d3
--- /dev/null
@@ -0,0 +1,107 @@
+/** \file fsm.h
+ *  \brief non-recursive finite state machine header file
+ *
+ *  \see fsm.c
+ */
+
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*      MODULE: fsm.h                                                      */
+/*    PURPOSE:  Finite State Machine API                                   */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef __NRFSM_H__
+#define __NRFSM_H__
+
+
+/* Constants */
+
+/* Enumerations */
+
+/* Typedefs */
+
+/** action function type definition */
+typedef TI_STATUS (*nrfsm_action_t) (void* pData);
+
+/* Structures */
+
+/* State\Event cell */
+typedef  struct
+{
+    UINT32          nState;      /**< next state in transition */
+    nrfsm_action_t  fAction;     /**< action function */
+} nrfsm_action_cell_t;
+
+/** matrix type */
+typedef nrfsm_action_cell_t*  nrfsm_matrix_t;
+
+
+/* External data definitions */
+
+/* External functions definitions */
+
+/* Function prototypes */
+
+TI_STATUS nrfsm_Create       (TI_HANDLE       hOs,
+                              TI_HANDLE      *hFsm,
+                              UINT32          uMaxNoOfStates,
+                              UINT32          uMaxNoOfEvents);
+
+TI_STATUS nrfsm_Unload       (TI_HANDLE       hFsm);
+
+TI_STATUS nrfsm_Config       (TI_HANDLE       hFsm,
+                              nrfsm_matrix_t  pMatrix,
+                              UINT32          uActNoOfStates,
+                              UINT32          uActNoOfEvents);
+
+TI_STATUS nrfsm_Event        (TI_HANDLE       hFsm,
+                              UINT32          event,
+                              void           *pData);
+
+TI_STATUS nrfsm_GetState     (TI_HANDLE       hFsm,
+                              UINT32         *state);
+
+TI_STATUS nrfsm_SetState     (TI_HANDLE       hFsm,
+                              UINT32          state);
+
+TI_STATUS nrfsm_GetNextState (TI_HANDLE       hFsm,
+                              UINT32          event,
+                              UINT32         *state);
+
+#endif /* __NRFSM_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/utils/report.c b/sta_dk_4_0_4_32/common/src/utils/report.c
new file mode 100644 (file)
index 0000000..7d4a0ed
--- /dev/null
@@ -0,0 +1,574 @@
+/** \file report.c
+ *  \brief report module implementation
+ *
+ *  \see report.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************************************/
+/*                                                                                                  */
+/*      MODULE:     report.c                                                                        */
+/*      PURPOSE:    report module implementation                                                    */
+/*                                                                                                  */
+/****************************************************************************************************/
+#include "osTIType.h"
+#include "osApi.h"
+#include "report.h"
+#include "commonTypes.h"
+#include "paramIn.h"
+#include "utils.h"
+
+
+/************************************************************************
+ *                        report_create                             *
+ ************************************************************************
+DESCRIPTION: Report module creation function, called by the config mgr in creation phase
+                performs the following:
+                -   Allocate the report handle
+
+INPUT:      hOs -           Handle to OS        
+
+
+OUTPUT:     
+
+RETURN:     Handle to the report module on success, NULL otherwise
+
+************************************************************************/
+TI_HANDLE report_create(TI_HANDLE hOs)
+{
+    report_t *pReport;
+
+    pReport = os_memoryAlloc(hOs, sizeof(report_t));
+    if(!pReport)
+        return NULL;
+
+    pReport->hOs = hOs;
+
+    return(pReport);
+}
+
+/************************************************************************
+ *                        report_config                                 *
+ ************************************************************************
+DESCRIPTION: Report module configuration function, called by the config mgr in configuration phase
+                performs the following:
+                -   Reset & init local variables
+                -   Resets all report modules bits
+                -   Resets all severities bits
+                -   Init the description strings
+
+INPUT:      hReport -   Report handle
+            hOs     -   OS handle
+
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS report_config(TI_HANDLE hReport, TI_HANDLE hOs, reportInitParams_t * init_params)
+{
+    report_t *pReport = (report_t *)hReport;
+
+    pReport->hOs = hOs;
+
+    os_memoryZero(NULL, pReport->SeverityTable, sizeof(pReport->SeverityTable));
+    os_memoryZero(NULL, pReport->ModuleTable, sizeof(pReport->ModuleTable));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CONFIG_MGR_MODULE_LOG]), "CONFIG_MGR", sizeof("CONFIG_MGR"));
+    
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SME_SM_MODULE_LOG]), "SME_SM    ", sizeof("SME_SM    "));
+    
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SITE_MGR_MODULE_LOG]), "SITE_MGR  ", sizeof("SITE_MGR  "));
+    
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CONN_MODULE_LOG]), "CONN      ", sizeof("CONN      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[MLME_SM_MODULE_LOG]), "MLME_SM   ", sizeof("MLME_SM   "));
+    
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[AUTH_MODULE_LOG]), "AUTH      ", sizeof("AUTH      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[ASSOC_MODULE_LOG]), "ASSOC     ", sizeof("ASSOC     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[RX_DATA_MODULE_LOG]), "RX_DATA   ", sizeof("RX_DATA   "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TX_DATA_MODULE_LOG]), "TX_DATA   ", sizeof("TX_DATA   "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CTRL_DATA_MODULE_LOG]), "CTRL_DATA ", sizeof("CTRL_DATA "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[RSN_MODULE_LOG]), "RSN       ", sizeof("RSN       "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[HAL_RX_MODULE_LOG]), "HAL_RX    ", sizeof("HAL_RX    "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[HAL_TX_MODULE_LOG]), "HAL_TX    ", sizeof("HAL_TX    "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[HAL_CTRL_MODULE_LOG]), "HAL_CTRL  ", sizeof("HAL_CTRL  "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[HAL_SECURITY_MODULE_LOG]), "HAL_SEC   ", sizeof("HAL_SEC   "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[MEM_MGR_MODULE_LOG]), "MEM_MGR   ", sizeof("MEM_MGR   "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[REPORT_MODULE_LOG]), "REPORT   ", sizeof("REPORT   "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SITE_UPDATE_MODULE_LOG]), "SITE_UPDATE", sizeof("SITE_UPDATE"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[REGULATORY_DOMAIN_MODULE_LOG]), "REGULATORY_DOMAIN      ", sizeof("REGULATORY_DOMAIN      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[MEASUREMENT_MNGR_MODULE_LOG]), "MEASUREMENT MNGR ", sizeof("MEASUREMENT MNGR "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[MEASUREMENT_SRV_MODULE_LOG]), "MEASUREMENT SRV  ", sizeof("MEASUREMENT SRV  "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SOFT_GEMINI_MODULE_LOG]), "SOFT_GEMINI      ", sizeof("SOFT_GEMINI      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SC_MODULE_LOG]), "SC_MODULE_LOG      ", sizeof("SC_MODULE_LOG      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[EXC_MANAGER_MODULE_LOG]), "EXC_MANAGER      ", sizeof("EXC_MANAGER      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[ROAMING_MANAGER_MODULE_LOG]), "ROAMING_MANAGER      ", sizeof("ROAMING_MANAGER      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[QOS_MANAGER_MODULE_LOG]), "QOS_MANAGER      ", sizeof("QOS_MANAGER      "));
+    
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TRAFFIC_ADM_CTRL_MODULE_LOG]), "TRAFFIC_ADM_CTRL    ", sizeof("TRAFFIC_ADM_CTRL    "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[POWER_MANAGER_MODULE_LOG]), "POWER_MANAGER  ", sizeof("POWER_MANAGER  "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[POWER_CONTROL_MODULE_LOG]), "POWER_CONTROL  ", sizeof("POWER_CONTROL  "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[POWER_SERVER_MODULE_LOG]), "POWER_SERVER  ", sizeof("POWER_SERVER  "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[ELP_MODULE_LOG]), "ELP            ", sizeof("ELP            "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SCR_MODULE_LOG]), "SCR              ", sizeof("SCR              "));    
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SCAN_SRV_MODULE_LOG]), "SCAN SERVICE     ", sizeof("SCAN SERVICE     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SCAN_CNCN_MODULE_LOG]), "SCAN CONCENTRATOR", sizeof("SCAN CONCENTRATOR"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[SCAN_MNGR_MODULE_LOG]), "SCAN MANAGER     ", sizeof("SCAN MANAGER     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[GWSI_ADAPT_MODULE_LOG]), "GWSI_ADAPT     ", sizeof("GWSI_ADAPT     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[GWSI_ADAPT_CB_MODULE_LOG]), "GWSI_ADAPT_CB     ", sizeof("GWSI_ADAPT_CB     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CORE_ADAPT_MODULE_LOG]), "CORE_ADAPT     ", sizeof("CORE_ADAPT     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TX_HW_QUEUE_MODULE_LOG]), "TX HW QUEUE      ", sizeof("TX HW QUEUE      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TX_CTRL_BLK_MODULE_LOG]), "TX CTRL BLK      ", sizeof("TX CTRL BLK      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TX_RESULT_MODULE_LOG]), "TX RESULT      ", sizeof("TX RESULT      "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TNETW_IF_MODULE_LOG]), "TNETW IF     ", sizeof("TNETW IF     "));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TNETW_ARBITER_MODULE_LOG]), "TNETW ARBITER", sizeof("TNETW ARBITER"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CURR_BSS_MODULE_LOG]), "CURR BSS", sizeof("CURR BSS"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[FW_EVENT_MODULE_LOG]), "FW EVENT", sizeof("FW EVENT"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CMD_MBOX_MODULE_LOG]), "CMD MBOX", sizeof("CMD MBOX"));
+
+       os_memoryCopy(hOs, (void *)(pReport->moduleDesc[CMDQUEUE_MODULE_LOG]), "CMD QUEUE", sizeof("CMD QUEUE"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[EVENT_MBOX_MODULE_LOG]), "EVENT MBOX", sizeof("EVENT MBOX"));
+
+    os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TNETW_DRV_MODULE_LOG]), "TNETW DRV", sizeof("TNETW DRV"));
+
+       os_memoryCopy(hOs, (void *)(pReport->moduleDesc[TNETW_XFER_MODULE_LOG]), "TX XFER      ", sizeof("TX XFER      "));
+
+       os_memoryCopy(hOs, (void *)(pReport->moduleDesc[RECOVERY_MGR_MODULE_LOG]), "RECOVERY MGR", sizeof("RECOVERY MGR"));
+
+       os_memoryCopy(hOs, (void *)(pReport->moduleDesc[RECOVERY_CTRL_MODULE_LOG]), "RECOVERY CTRL", sizeof("RECOVERY CTRL"));
+
+       os_memoryCopy(hOs, (void *)(pReport->moduleDesc[HW_INIT_MODULE_LOG]), "HW INIT", sizeof("HW INIT"));
+
+    report_setReportModuleTable( hReport, (tiUINT8 *)init_params->ModuleTable);
+    report_setReportSeverityTable( hReport, (tiUINT8 *)init_params->SeverityTable);
+    
+    return OK;
+}
+
+/************************************************************************
+ *                        report_unLoad                                 *
+ ************************************************************************
+DESCRIPTION: report module unload function, called by the config mgr in the unload phase
+                performs the following:
+                -   Free all memory allocated by the module
+
+INPUT:      hReport -   report handle.      
+
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS report_unLoad(TI_HANDLE hReport)
+{
+    report_t *pReport = (report_t *)hReport;
+
+#if defined(TIWLN_WINCE30) && defined(TI_DBG)
+    closeMyFile();
+#endif
+
+    utils_nullMemoryFree(pReport->hOs, pReport, sizeof(report_t));
+    return OK;
+}
+
+
+
+
+/**
+*
+* report_setReportModulet
+*
+* \b Description:
+*
+* Sets the relevant bit in the reportModule variable.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - module_index - Report module index in the table \n
+*
+* \b RETURNS:
+*
+*  None.
+*/
+void report_setReportModule(TI_HANDLE hReport, tiUINT8 module_index)
+{
+    ((report_t *)hReport)->ModuleTable[module_index] = 1;
+}
+
+
+/**
+*
+* report_clearReportModule
+*
+* \b Description:
+*
+* Clears the relevant bit in the reportModule variable.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - module_index - Report module index in the table \n
+
+*
+* \b RETURNS:
+*
+*  None.
+*/
+void report_clearReportModule(TI_HANDLE hReport, tiUINT8 module_index)
+{
+    ((report_t *)hReport)->ModuleTable[module_index] = 0;
+}
+
+
+/**
+*
+* report_getReportModuleValue
+*
+* \b Description:
+*
+* Returns the value of reportModule.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - module array - set index  \n
+*
+* \b RETURNS:
+*
+*  Report module value
+*/
+void report_getReportModuleTable(TI_HANDLE hReport, tiUINT8 *pModules)
+{
+    tiUINT8 index;
+
+    os_memoryCopy(NULL, (void *)pModules, (void *)(((report_t *)hReport)->ModuleTable), sizeof(((report_t *)hReport)->ModuleTable));
+
+    for (index = 0; index < sizeof(((report_t *)hReport)->ModuleTable); index++)
+    {
+        pModules[index] += '0';
+    }
+}
+
+
+/**
+*
+* report_setReportModuleTable
+*
+* \b Description:
+*
+* Sets the value of reportModule.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - module array - set index  \n
+
+*
+* \b RETURNS:
+*
+*  None.
+*/
+void report_setReportModuleTable(TI_HANDLE hReport, tiUINT8 *pModules)
+{
+    tiUINT8 index;
+
+    for (index = 0; index < sizeof(((report_t *)hReport)->ModuleTable); index++)
+    {
+        pModules[index] -= '0';
+    }
+
+    os_memoryCopy(NULL, (void *)(((report_t *)hReport)->ModuleTable), (void *)pModules, sizeof(((report_t *)hReport)->ModuleTable));
+}
+
+
+/**
+*
+* report_setReportSeverity
+*
+* \b Description:
+*
+* Sets the relevant bit in the reportSeverity variable.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - severity_index - Report severity index in the table \n
+*
+* \b RETURNS:
+*
+*  None.
+*/
+void report_setReportSeverity(TI_HANDLE hReport, tiUINT8 severity_index)
+{
+   ((report_t *)hReport)->SeverityTable[severity_index] = 0;
+}
+
+
+/**
+*
+* report_clearReportSeverityBit
+*
+* \b Description:
+*
+* Clears the relevant bit in the reportSeverity variable.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - severity_index - Report severity index in the table \n
+*
+* \b RETURNS:
+*
+*  None.
+*/
+void report_clearReportSeverity(TI_HANDLE hReport, tiUINT8 severity_index)
+{
+   ((report_t *)hReport)->SeverityTable[severity_index] = 1;
+}
+
+
+/**
+*
+* report_getReportSeverityValue
+*
+* \b Description:
+*
+* Returns the value of reportSeverity.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - severity_array 
+*
+* \b RETURNS:
+*
+*  None
+*/
+void report_getReportSeverityTable(TI_HANDLE hReport, tiUINT8 *pSeverities)
+{
+    tiUINT8 index;
+
+    os_memoryCopy(NULL, (void *)pSeverities, (void *)(((report_t *)hReport)->SeverityTable), sizeof(((report_t *)hReport)->SeverityTable));
+
+    for (index = 0; index < sizeof(((report_t *)hReport)->SeverityTable); index++)
+    {
+        pSeverities[index] += '0';
+    }
+}
+
+/**
+*
+* report_setReportSeverityValue
+*
+* \b Description:
+*
+* Sets the value of reportSeverity.
+*
+* \b ARGS:
+*
+*  I   - hReport - Report handle  \n
+*  I   - severity_array 
+*
+* \b RETURNS:
+*
+*  None.
+*/
+void report_setReportSeverityTable(TI_HANDLE hReport, tiUINT8 *pSeverities)
+{
+    tiUINT8 index;
+
+    for (index = 0; index < sizeof(((report_t *)hReport)->SeverityTable); index++)
+    {
+        pSeverities[index] -= '0';
+    }
+
+    os_memoryCopy(NULL, (void *)(((report_t *)hReport)->SeverityTable), (void *)pSeverities, sizeof(((report_t *)hReport)->SeverityTable));
+}
+
+
+/***********************************************************************
+ *                        report_setParam                                   
+ ***********************************************************************
+DESCRIPTION: Report set param function, called by the following:
+                -   config mgr in order to set a parameter from the OS abstraction layer.
+                -   Form inside the driver
+
+INPUT:      hReport -   Report handle.
+            pParam  -   Pointer to the parameter        
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS report_setParam(TI_HANDLE         hReport,
+                          whalParamInfo_t   *pParam)
+{
+    switch((externalParam_e)pParam->paramType)
+    {
+    case REPORT_MODULE_ON_PARAM:
+        report_setReportModule(hReport, pParam->content.ModuleTable[0]);
+        break;
+
+    case REPORT_MODULE_OFF_PARAM:
+        report_clearReportModule(hReport, pParam->content.ModuleTable[0]);
+        break;
+
+    case REPORT_MODULE_TABLE_PARAM:
+        report_setReportModuleTable(hReport, (tiUINT8 *)pParam->content.ModuleTable);
+        break;
+
+    case REPORT_SEVERITY_ON_PARAM:
+        report_setReportSeverity(hReport, pParam->content.SeverityTable[0]);
+        break;
+
+    case REPORT_SEVERITY_OFF_PARAM:
+        report_clearReportSeverity(hReport, pParam->content.SeverityTable[0]);
+        break;
+
+    case REPORT_SEVERITY_TABLE_PARAM:
+        report_setReportSeverityTable(hReport, (tiUINT8 *)pParam->content.SeverityTable);
+        break;
+        
+    case REPORT_PPMODE_VALUE_PARAM:
+        os_setDebugMode((BOOL)pParam->content.reportPPMode);
+        break;
+    default:
+        WLAN_REPORT_ERROR(hReport, REPORT_MODULE_LOG, ("Set param, Params is not supported, %d\n", pParam->paramType));
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+/***********************************************************************
+ *                        report_getParam                                   
+ ***********************************************************************
+DESCRIPTION: Report get param function, called by the following:
+            -   config mgr in order to get a parameter from the OS abstraction layer.
+            -   from inside the driver
+
+INPUT:      hReport -   Report handle.
+            pParam  -   Pointer to the parameter        
+
+OUTPUT:     
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS report_getParam(TI_HANDLE         hReport,
+                          whalParamInfo_t   *pParam)
+{
+
+    switch((externalParam_e)pParam->paramType)
+    {
+    case REPORT_MODULE_TABLE_PARAM:
+        report_getReportModuleTable(hReport, (tiUINT8 *)pParam->content.ModuleTable);
+        break;
+
+    case REPORT_SEVERITY_TABLE_PARAM:
+        report_getReportSeverityTable(hReport, (tiUINT8 *)pParam->content.SeverityTable);
+        break;
+
+    default:
+        WLAN_REPORT_ERROR(hReport, REPORT_MODULE_LOG, ("Get param, Params is not supported, %d\n", pParam->paramType));
+        return PARAM_NOT_SUPPORTED;
+    }
+
+    return OK;
+}
+
+
+/***********************************************************************
+ *                        report_dummy                                   
+ ***********************************************************************
+DESCRIPTION: Dummy function used to solve warning problems 
+             when REPORT_LOG flag is disabled
+
+INPUT:      
+
+OUTPUT:     
+
+RETURN:     
+
+************************************************************************/
+void report_dummy (const char* fmt, ...)
+{
+}
diff --git a/sta_dk_4_0_4_32/common/src/utils/report.h b/sta_dk_4_0_4_32/common/src/utils/report.h
new file mode 100644 (file)
index 0000000..6d46196
--- /dev/null
@@ -0,0 +1,185 @@
+/** \file report.h
+ *  \brief Report module API
+ *
+ *  \see report.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                          */
+/*    MODULE:   report.h                                                    */
+/*    PURPOSE:  Report module internal header API                           */
+/*                                                                          */
+/***************************************************************************/
+#ifndef __REPORT_H__
+#define __REPORT_H__
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "osApi.h"
+#include "utils.h"
+
+/* report handle */
+    
+#define MAX_STRING_LEN              128 
+
+typedef struct 
+{
+    TI_HANDLE       hOs;
+    tiUINT8         SeverityTable[WLAN_MAX_SEVERITIES];
+    tiUINT8         ModuleTable[WLAN_MAX_LOG_MODULES];
+    char            moduleDesc[WLAN_MAX_LOG_MODULES][MAX_STRING_LEN];
+} report_t;
+
+
+/* The report mechanism is like that:
+    Each module ahas a report flag. Each severity has a severity flag.
+    Only if bits are enabled, the message is printed */
+/* The modules which have their report flag enable are indicated by a bit map in the reportModule 
+    variable contained in the report handle*/
+/* The severities which have are enabled are indicated by a bit map in the reportSeverity
+    variable contained in the report handle*/
+
+#ifdef REPORT_LOG
+
+
+#define WLAN_REPORT_INIT(hReport, module, msg)                        \
+    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INIT])       && (((report_t *)hReport)->ModuleTable[module]))  \
+       { os_report ("$B%c%s,INIT:",             ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_INFORMATION(hReport, module, msg)                 \
+    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INFORMATION]) && (((report_t *)hReport)->ModuleTable[module])) \
+       { os_report ("$C%c%s,INFORMATION:",      ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_WARNING(hReport, module, msg)                     \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_WARNING])                                                      \
+       { os_report ("$D%c%s,WARNING:",          ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_ERROR(hReport, module, msg)                       \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_ERROR])                                                        \
+       { os_report ("$E%c%s,ERROR:",            ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_FATAL_ERROR(hReport, module, msg)                 \
+    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_FATAL_ERROR]) && (((report_t *)hReport)->ModuleTable[module])) \
+       { os_report ("$F%c%s,FATAL ERROR:",      ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_SM(hReport, module, msg)                          \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_SM])                                                           \
+       { os_report ("$G%c%s,SM:",               ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_CONSOLE(hReport, module, msg)                     \
+    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_CONSOLE])    && (((report_t *)hReport)->ModuleTable[module]))  \
+       { os_report ("$H%c%s,CONSOLE:",          ((char)module + 'A'),    ((report_t *)hReport)->moduleDesc[module]); os_report msg; } } while(0)
+#define WLAN_REPORT_DEBUG_RX(hReport, msg)                            \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_DEBUG_RX])                                                     \
+       { os_report ("$AA,DEBUG RX:");                                                                                os_report msg; } } while(0)
+#define WLAN_REPORT_DEBUG_TX(hReport, msg)                            \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_DEBUG_TX])                                                     \
+       { os_report ("$AA,DEBUG TX:");                                                                                os_report msg; } } while(0)
+#define WLAN_REPORT_DEBUG_CONTROL(hReport, msg)                       \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_DEBUG_CONTROL])                                                \
+       { os_report ("$AA,DEBUG CONTROL:");                                                                           os_report msg; } } while(0)
+#define WLAN_REPORT_GWSI_RECORDING(hReport, msg)                      \
+    do { if (hReport &&  ((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_GWSI_RECORDING])                                               \
+       { os_report ("$AA,GWSI RECORDING:");                                                                          os_report msg; } } while(0)
+#define WLAN_REPORT_HEX_INFORMATION(hReport, module, data, datalen)   \
+    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INFORMATION]) && (((report_t *)hReport)->ModuleTable[module])) \
+       { HexDumpData(data, datalen); } } while(0)
+#define WLAN_REPORT_MSDU_INFORMATION(hReport, module, pMsdu, title)   \
+    do { if (hReport && (((report_t *)hReport)->SeverityTable[WLAN_SEVERITY_INFORMATION]) && (((report_t *)hReport)->ModuleTable[module])) \
+       { msduContentDump(pMsdu, title); } } while(0)
+#define WLAN_OS_REPORT(msg)                                           \
+    do { os_report("$AA"); os_report msg;} while(0)
+
+#ifdef INIT_MESSAGES
+#define WLAN_INIT_REPORT(msg)                                         \
+    do { os_report("$AA"); os_report msg;} while(0)
+#else
+#define WLAN_INIT_REPORT(msg) 
+#endif
+
+#else   /* REPORT_LOG */
+
+
+/* NOTE: Keep a dummy report function call to treat compilation warnings */
+
+
+#define WLAN_REPORT_INIT(hReport,module,msg)                          \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_INFORMATION(hReport,module,msg)                   \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_WARNING(hReport,module,msg)                       \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_ERROR(hReport,module,msg)                         \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_FATAL_ERROR(hReport,module,msg)                   \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_SM(hReport,module,msg)                            \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_CONSOLE(hReport,module,msg)                       \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_HEX_INFORMATION(hReport,module,data,datalen)      \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_DEBUG_RX(hReport,msg)                             \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_DEBUG_TX(hReport,msg)                             \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_DEBUG_CONTROL(hReport,msg)                        \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_GWSI_RECORDING(hReport,msg)                       \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_REPORT_MSDU_INFORMATION(hReport,module,pMsdu,title)      \
+    do { if (hReport == NULL) { } } while (0)
+#define WLAN_OS_REPORT(msg)                                           \
+    do { } while (0)
+#define WLAN_INIT_REPORT(msg)                                         \
+    do { } while (0)
+
+#endif  /* REPORT_LOG */
+                            
+
+/* report module prototypes */
+TI_HANDLE report_create (TI_HANDLE hOs);
+TI_STATUS report_config (TI_HANDLE hReport, TI_HANDLE hOs, reportInitParams_t * init_params);
+TI_STATUS report_unLoad (TI_HANDLE hReport);
+
+void report_setReportModule (TI_HANDLE hReport, tiUINT8 module_index);
+void report_clearReportModule (TI_HANDLE hReport, tiUINT8 module_index);
+void report_getReportModuleTable (TI_HANDLE hReport, tiUINT8 *pModules); 
+void report_setReportModuleTable (TI_HANDLE hReport, tiUINT8 *pModules); 
+void report_setReportSeverity (TI_HANDLE hReport, tiUINT8 severity_index); 
+void report_clearReportSeverity (TI_HANDLE hReport, tiUINT8 severity_index); 
+void report_getReportSeverityTable (TI_HANDLE hReport, tiUINT8 *pSeverities);
+void report_setReportSeverityTable (TI_HANDLE hReport, tiUINT8 *pSeverities);
+TI_STATUS report_setParam (TI_HANDLE hReport, whalParamInfo_t *pParam);                   
+TI_STATUS report_getParam (TI_HANDLE hReport, whalParamInfo_t *pParam); 
+void report_dummy (const char* fmt, ...);                          
+
+#endif /* __REPORT_H__ */
diff --git a/sta_dk_4_0_4_32/common/src/utils/stack.h b/sta_dk_4_0_4_32/common/src/utils/stack.h
new file mode 100644 (file)
index 0000000..e565d15
--- /dev/null
@@ -0,0 +1,74 @@
+/** \file stack.h
+ *  \brief Seport module API
+ *
+ *  \see stack.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/***************************************************************************/
+/*                                                                         */
+/*    MODULE:   stack.h                                                    */
+/*    PURPOSE:  Stack module internal header API                           */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef STACK_H
+#define STACK_H
+
+
+typedef struct _Stack_t
+{
+    TI_HANDLE   hOs;
+    void       *pBuf;
+    unsigned    uPtr;
+    unsigned    uDep;
+    unsigned    uElemSize;
+    BOOL        bBuf;
+
+    void      (*fCpy) (TI_HANDLE, void*, void*, unsigned);
+
+} Stack_t;
+
+
+
+unsigned stackInit    (Stack_t *pStack, TI_HANDLE hOs, unsigned uElemSize, unsigned uDep, void *pBuf, void (*fCpy) (TI_HANDLE, void*, void*, unsigned));
+unsigned stackDestroy (Stack_t *pStack);
+unsigned stackPush    (Stack_t *pStack, void *pVal);
+unsigned stackPop     (Stack_t *pStack, void *pVal);
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/common/src/utils/utils.c b/sta_dk_4_0_4_32/common/src/utils/utils.c
new file mode 100644 (file)
index 0000000..cd9ad9f
--- /dev/null
@@ -0,0 +1,2019 @@
+/** \file utils.c
+ *  \brief General utilities implementation
+ *
+ *  \see utils.h
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                                                                                                     */
+/*             MODULE: utils.c                                                                                                         */
+/*    PURPOSE: General utilities implementation                                                        */
+/***************************************************************************/
+#include "osTIType.h"
+#include "osApi.h"
+#include "report.h"
+#include "commonTypes.h"
+#include "utils.h"
+#include "802_11Defs.h"
+
+#define NUM_OF_NIBBLES_IN_BYTE (2)
+#define NIBBLE_SIZE_IN_BITS (4)
+#define NIBBLE_MASK (0xF)
+
+/************************************************************************
+ *                        utils_nullMemoryFree                                                 *
+ ************************************************************************
+DESCRIPTION: Called in order to free memory space. 
+                       Calls the OS free function only if the memory is occupied
+                                                                                                   
+INPUT:      pOsContext         -       Handle to OS
+                       pMemPtr                 -       Pointer to the memory to be free        
+                       size                    -       Size of memory to be free       
+
+OUTPUT:                
+
+
+RETURN:     
+
+************************************************************************/
+void utils_nullMemoryFree(void* pOsContext, 
+                                                 void* pMemPtr, 
+                                                 unsigned long size)
+{
+       if (pMemPtr != NULL)
+               os_memoryFree(pOsContext, pMemPtr, size);
+}
+
+/************************************************************************
+ *                        utils_nullTimerDestroy                                                       *
+ ************************************************************************
+DESCRIPTION: Called in order to free OS timers. 
+                       Calls the OS timer destroy function only if the timer is not NULL
+                                                                                                   
+INPUT:      pOsContext         -       Handle to OS
+                       pTimerHandle    -       Pointer to timer handle 
+
+OUTPUT:                
+
+
+RETURN:     
+
+************************************************************************/
+void utils_nullTimerDestroy(void* pOsContext, 
+                                                void* pTimerHandle)
+{
+       os_timerStop(pOsContext,pTimerHandle);
+       os_timerDestroy(pOsContext, pTimerHandle);
+}
+
+/************************************************************************
+ *                        networkToHostRate                                                    *
+ ************************************************************************
+DESCRIPTION: Translates a network rate (0x02, 0x82, 0x84, etc...) to host rate (1, 2, 3, ....)
+                                                                                                   
+INPUT:      rate               -       Network rate
+
+OUTPUT:                
+
+
+RETURN:     Host rate if the input rate is valid, otherwise returns 0.
+
+************************************************************************/
+
+#define NET_BASIC_MASK         0x80
+#define NET_RATE_1M                    (0x02)
+#define NET_RATE_2M                    (0x04)
+#define NET_RATE_5_5M          (0x0B)
+#define NET_RATE_11M           (0x16)
+#define NET_RATE_22M           (0x2C)
+#define NET_RATE_6M                    (0x0C)
+#define NET_RATE_9M                    (0x12)
+#define NET_RATE_12M           (0x18)
+#define NET_RATE_18M           (0x24)
+#define NET_RATE_24M           (0x30)
+#define NET_RATE_36M           (0x48)
+#define NET_RATE_48M           (0x60)
+#define NET_RATE_54M           (0x6C)
+
+/*#define ONLY_802_11_A*/
+/*#ifdef ONLY_802_11_A
+#undef NET_RATE_1M
+#undef NET_RATE_2M
+#undef NET_RATE_5_5M
+#undef NET_RATE_11M
+#undef NET_RATE_22M
+#define NET_RATE_1M                    (NET_RATE_6M)
+#define NET_RATE_2M                    (NET_RATE_12M)
+#define NET_RATE_5_5M          (NET_RATE_24M)
+#define NET_RATE_11M           (NET_RATE_54M)
+#define NET_RATE_22M           (NET_RATE_48M)
+#endif
+*/
+
+#define NET_RATE_1M_BASIC      (NET_RATE_1M   | NET_BASIC_MASK)
+#define NET_RATE_2M_BASIC      (NET_RATE_2M   | NET_BASIC_MASK)
+#define NET_RATE_5_5M_BASIC    (NET_RATE_5_5M | NET_BASIC_MASK)
+#define NET_RATE_11M_BASIC     (NET_RATE_11M  | NET_BASIC_MASK)
+#define NET_RATE_22M_BASIC     (NET_RATE_22M  | NET_BASIC_MASK)
+#define NET_RATE_6M_BASIC      (NET_RATE_6M   | NET_BASIC_MASK)
+#define NET_RATE_9M_BASIC      (NET_RATE_9M   | NET_BASIC_MASK)
+#define NET_RATE_12M_BASIC     (NET_RATE_12M  | NET_BASIC_MASK)
+#define NET_RATE_18M_BASIC     (NET_RATE_18M  | NET_BASIC_MASK)
+#define NET_RATE_24M_BASIC     (NET_RATE_24M  | NET_BASIC_MASK)
+#define NET_RATE_36M_BASIC     (NET_RATE_36M  | NET_BASIC_MASK)
+#define NET_RATE_48M_BASIC     (NET_RATE_48M  | NET_BASIC_MASK)
+#define NET_RATE_54M_BASIC     (NET_RATE_54M  | NET_BASIC_MASK)
+
+
+#define FIRST_VALID_CHAR        32
+
+
+rate_e networkToHostRate(UINT8 rate)
+{
+       switch (rate)
+       {
+       case NET_RATE_1M:
+       case NET_RATE_1M_BASIC:
+               return DRV_RATE_1M;
+
+       case NET_RATE_2M:
+       case NET_RATE_2M_BASIC:
+               return DRV_RATE_2M;
+
+       case NET_RATE_5_5M:
+       case NET_RATE_5_5M_BASIC:
+               return DRV_RATE_5_5M;
+
+       case NET_RATE_11M:
+       case NET_RATE_11M_BASIC:
+               return DRV_RATE_11M;
+
+       case NET_RATE_22M:
+       case NET_RATE_22M_BASIC:
+               return DRV_RATE_22M;
+
+       case NET_RATE_6M:
+       case NET_RATE_6M_BASIC:
+               return DRV_RATE_6M;
+
+       case NET_RATE_9M:
+       case NET_RATE_9M_BASIC:
+               return DRV_RATE_9M;
+
+       case NET_RATE_12M:
+       case NET_RATE_12M_BASIC:
+               return DRV_RATE_12M;
+
+       case NET_RATE_18M:
+       case NET_RATE_18M_BASIC:
+               return DRV_RATE_18M;
+
+       case NET_RATE_24M:
+       case NET_RATE_24M_BASIC:
+               return DRV_RATE_24M;
+
+       case NET_RATE_36M:
+       case NET_RATE_36M_BASIC:
+               return DRV_RATE_36M;
+
+       case NET_RATE_48M:
+       case NET_RATE_48M_BASIC:
+               return DRV_RATE_48M;
+
+       case NET_RATE_54M:
+       case NET_RATE_54M_BASIC:
+               return DRV_RATE_54M;
+
+       default:
+               return DRV_RATE_INVALID;
+       }
+}
+
+/************************************************************************
+ *                        hostToNetworkRate                                                    *
+ ************************************************************************
+DESCRIPTION: Translates a host rate (1, 2, 3, ....) to network rate (0x02, 0x82, 0x84, etc...) 
+                                                                                                   
+INPUT:      rate               -       Host rate
+
+OUTPUT:                
+
+
+RETURN:     Network rate if the input rate is valid, otherwise returns 0.
+
+************************************************************************/
+UINT8 hostToNetworkRate(rate_e rate)
+{
+       switch (rate)
+       {
+       case DRV_RATE_1M:
+               return NET_RATE_1M;
+
+       case DRV_RATE_2M:
+               return NET_RATE_2M;
+
+       case DRV_RATE_5_5M:
+               return NET_RATE_5_5M;
+
+       case DRV_RATE_11M:
+               return NET_RATE_11M;
+
+       case DRV_RATE_22M:
+               return NET_RATE_22M;
+
+       case DRV_RATE_6M:
+               return NET_RATE_6M;
+
+       case DRV_RATE_9M:
+               return NET_RATE_9M;
+
+       case DRV_RATE_12M:
+               return NET_RATE_12M;
+
+       case DRV_RATE_18M:
+               return NET_RATE_18M;
+
+       case DRV_RATE_24M:
+               return NET_RATE_24M;
+
+       case DRV_RATE_36M:
+               return NET_RATE_36M;
+
+       case DRV_RATE_48M:
+               return NET_RATE_48M;
+
+       case DRV_RATE_54M:
+               return NET_RATE_54M;
+
+       default:
+               return 0;
+       }
+}
+
+
+/***************************************************************************
+*                                      getMaxActiveRatefromBitmap                                             *
+****************************************************************************
+* DESCRIPTION: 
+*
+* INPUTS:              hCtrlData - the object
+*                              
+* OUTPUT:              
+*
+* RETURNS:             
+***************************************************************************/
+rate_e getMaxRatefromBitmap(UINT32             ratesBitMap)
+{
+       rate_e rate = DRV_RATE_1M;
+
+       if(ratesBitMap & DRV_RATE_MASK_1_BARKER) rate = DRV_RATE_1M; 
+       if(ratesBitMap & DRV_RATE_MASK_2_BARKER) rate = DRV_RATE_2M;
+       if(ratesBitMap & DRV_RATE_MASK_5_5_CCK)  rate = DRV_RATE_5_5M;
+       if(ratesBitMap & DRV_RATE_MASK_11_CCK)   rate = DRV_RATE_11M; 
+       if(ratesBitMap & DRV_RATE_MASK_22_PBCC)  rate = DRV_RATE_22M;
+       if(ratesBitMap & DRV_RATE_MASK_6_OFDM)   rate = DRV_RATE_6M;
+       if(ratesBitMap & DRV_RATE_MASK_9_OFDM)   rate = DRV_RATE_9M;
+       if(ratesBitMap & DRV_RATE_MASK_12_OFDM)  rate = DRV_RATE_12M;
+       if(ratesBitMap & DRV_RATE_MASK_18_OFDM)  rate = DRV_RATE_18M;
+       if(ratesBitMap & DRV_RATE_MASK_24_OFDM)  rate = DRV_RATE_24M;
+       if(ratesBitMap & DRV_RATE_MASK_36_OFDM)  rate = DRV_RATE_36M;
+       if(ratesBitMap & DRV_RATE_MASK_48_OFDM)  rate = DRV_RATE_48M;
+       if(ratesBitMap & DRV_RATE_MASK_54_OFDM)  rate = DRV_RATE_54M;
+
+       return rate;
+}
+
+
+/************************************************************************
+ *                        getMaxBasicRate                                                      *
+ ************************************************************************
+DESCRIPTION: Goes over an array of network rates and returns the max basic rate
+                                                                                                   
+INPUT:      pRates             -       Rate array
+
+OUTPUT:                
+
+
+RETURN:     Max basic rate (in network units)
+
+************************************************************************/
+UINT8 getMaxBasicRatefromString(UINT8 *ratesString, UINT8 len, UINT8 maxRate)
+{
+       UINT8 i;
+       
+       for (i = 0; i < len; i++)
+       {
+               if ((IS_BASIC_RATE(ratesString[i])) &&
+                       (validateNetworkRate(ratesString[i]) == OK))
+               {
+                       maxRate = MAX(ratesString[i], maxRate);
+       }
+       }
+
+       return maxRate;
+}
+
+/************************************************************************
+ *                        getMaxActiveRate                                                     *
+ ************************************************************************
+DESCRIPTION: Goes over an array of network rates and returns the max active rate
+                                                                                                   
+INPUT:      pRates             -       Rate array
+
+OUTPUT:                
+
+
+RETURN:     Max active rate (in network units)
+
+************************************************************************/
+UINT8 getMaxActiveRatefromString(UINT8 *ratesString, UINT8 len, UINT8 maxRate)
+{
+       UINT8 i;
+       
+       for (i = 0; i < len; i++)
+       {
+               if ((IS_ACTIVE_RATE(ratesString[i])) &&
+                       (validateNetworkRate(ratesString[i]) == OK))
+               {
+                       maxRate = MAX(ratesString[i], maxRate);
+               }
+       }
+
+       return maxRate;
+}
+
+/************************************************************************
+ *                        validateNetworkRate                                                  *
+ ************************************************************************
+DESCRIPTION: Verify that the input nitwork rate is valid
+                                                                                                   
+INPUT:      rate       -       input network rate
+
+OUTPUT:                
+
+
+RETURN:     OK if valid, otherwise NOK
+
+************************************************************************/
+TI_STATUS validateNetworkRate(UINT8 rate)
+{
+       switch (rate)
+       {
+       case NET_RATE_1M:
+       case NET_RATE_1M_BASIC:
+       case NET_RATE_2M:
+       case NET_RATE_2M_BASIC:
+       case NET_RATE_5_5M:
+       case NET_RATE_5_5M_BASIC:
+       case NET_RATE_11M:
+       case NET_RATE_11M_BASIC:
+       case NET_RATE_22M:
+       case NET_RATE_22M_BASIC:
+       case NET_RATE_6M:
+       case NET_RATE_6M_BASIC:
+       case NET_RATE_9M:
+       case NET_RATE_9M_BASIC:
+       case NET_RATE_12M:
+       case NET_RATE_12M_BASIC:
+       case NET_RATE_18M:
+       case NET_RATE_18M_BASIC:
+       case NET_RATE_24M:
+       case NET_RATE_24M_BASIC:
+       case NET_RATE_36M:
+       case NET_RATE_36M_BASIC:
+       case NET_RATE_48M:
+       case NET_RATE_48M_BASIC:
+       case NET_RATE_54M:
+       case NET_RATE_54M_BASIC:
+               return OK;
+
+       default:
+               return NOK;
+       }
+}
+
+/************************************************************************
+ *                        hostToUtilityRate                                                    *
+ ************************************************************************
+DESCRIPTION: Translates a host rate (1, 2, 3, ....) to utility rate (2, 4, 11, 22, ....) 
+                                                                                                   
+INPUT:      rate               -       Host rate
+
+OUTPUT:                
+
+
+RETURN:     Utility rate if the input rate is valid, otherwise returns 0.
+
+************************************************************************/
+UINT8 hostToUtilityRate(rate_e rate)
+{
+       switch (rate)
+       {
+       case DRV_RATE_AUTO:
+               return 0;
+
+       case DRV_RATE_1M:
+               return NET_RATE_1M;
+
+       case DRV_RATE_2M:
+               return NET_RATE_2M;
+
+       case DRV_RATE_5_5M:
+               return NET_RATE_5_5M;
+
+       case DRV_RATE_11M:
+               return NET_RATE_11M;
+
+       case DRV_RATE_22M:
+               return NET_RATE_22M;
+
+       case DRV_RATE_6M:
+               return NET_RATE_6M;
+
+       case DRV_RATE_9M:
+               return NET_RATE_9M;
+
+       case DRV_RATE_12M:
+               return NET_RATE_12M;
+
+       case DRV_RATE_18M:
+               return NET_RATE_18M;
+
+       case DRV_RATE_24M:
+               return NET_RATE_24M;
+
+       case DRV_RATE_36M:
+               return NET_RATE_36M;
+
+       case DRV_RATE_48M:
+               return NET_RATE_48M;
+
+       case DRV_RATE_54M:
+               return NET_RATE_54M;
+
+       default:
+               return 0;
+       }
+}
+
+/************************************************************************
+ *                        utilityToHostRate                                                    *
+ ************************************************************************
+DESCRIPTION: Translates a utility rate (2, 4, 11, 22, ....) to host rate (1, 2, 3, ....) to
+                                                                                                   
+INPUT:      rate               -       Utility rate
+
+OUTPUT:                
+
+
+RETURN:     Host rate if the input rate is valid, otherwise returns 0.
+
+************************************************************************/
+rate_e utilityToHostRate(UINT8 rate)
+{
+       switch (rate)
+       {
+       case 0:
+               return DRV_RATE_AUTO;
+
+       case NET_RATE_1M:
+       case NET_RATE_1M_BASIC:
+               return DRV_RATE_1M;
+
+       case NET_RATE_2M:
+       case NET_RATE_2M_BASIC:
+               return DRV_RATE_2M;
+
+       case NET_RATE_5_5M:
+       case NET_RATE_5_5M_BASIC:
+               return DRV_RATE_5_5M;
+
+       case NET_RATE_11M:
+       case NET_RATE_11M_BASIC:
+               return DRV_RATE_11M;
+
+       case NET_RATE_22M:
+       case NET_RATE_22M_BASIC:
+               return DRV_RATE_22M;
+
+       case NET_RATE_6M:
+       case NET_RATE_6M_BASIC:
+               return DRV_RATE_6M;
+
+       case NET_RATE_9M:
+       case NET_RATE_9M_BASIC:
+               return DRV_RATE_9M;
+
+       case NET_RATE_12M:
+       case NET_RATE_12M_BASIC:
+               return DRV_RATE_12M;
+
+       case NET_RATE_18M:
+       case NET_RATE_18M_BASIC:
+               return DRV_RATE_18M;
+
+       case NET_RATE_24M:
+       case NET_RATE_24M_BASIC:
+               return DRV_RATE_24M;
+
+       case NET_RATE_36M:
+       case NET_RATE_36M_BASIC:
+               return DRV_RATE_36M;
+
+       case NET_RATE_48M:
+       case NET_RATE_48M_BASIC:
+               return DRV_RATE_48M;
+
+       case NET_RATE_54M:
+       case NET_RATE_54M_BASIC:
+               return DRV_RATE_54M;
+
+       default:
+               return DRV_RATE_AUTO;
+       }
+}
+
+
+/************************************************************************
+ *                        bitMapToNetworkStringRates                                   *
+ ************************************************************************
+DESCRIPTION: Converts bit map to the rates string
+                                                                                                   
+INPUT:      suppRatesBitMap            -       bit map of supported rates
+                       basicRatesBitMap        -   bit map of basic rates
+
+OUTPUT:                string - network format rates array,
+                       len - rates array length
+                       firstOFDMrateLoc - the index of first OFDM rate in the rates array.
+
+
+RETURN:     None
+
+************************************************************************/
+void bitMapToNetworkStringRates(UINT32 suppRatesBitMap, UINT32 basicRatesBitMap,
+                                                               UINT8 *string, UINT32 *len,
+                                                               UINT32 *firstOFDMrateLoc)
+{
+
+       UINT32 i = 0;
+
+       if(suppRatesBitMap & DRV_RATE_MASK_1_BARKER)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_1_BARKER)
+                       string[i++] = NET_RATE_1M_BASIC;
+               else 
+                       string[i++] = NET_RATE_1M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_2_BARKER)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_2_BARKER)
+                       string[i++] = NET_RATE_2M_BASIC;
+               else
+                       string[i++] = NET_RATE_2M;
+       }       
+       if(suppRatesBitMap & DRV_RATE_MASK_5_5_CCK)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_5_5_CCK)
+                       string[i++] = NET_RATE_5_5M_BASIC;
+               else
+                       string[i++] = NET_RATE_5_5M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_11_CCK)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_11_CCK)
+                       string[i++] = NET_RATE_11M_BASIC;
+               else
+                       string[i++] = NET_RATE_11M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_22_PBCC)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_22_PBCC)
+                       string[i++] = NET_RATE_22M_BASIC;
+               else
+                       string[i++] = NET_RATE_22M;
+       }
+
+       *firstOFDMrateLoc = i;
+       
+       if(suppRatesBitMap & DRV_RATE_MASK_6_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_6_OFDM)
+                       string[i++] = NET_RATE_6M_BASIC;
+               else
+                       string[i++] = NET_RATE_6M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_9_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_9_OFDM)
+                       string[i++] = NET_RATE_9M_BASIC;
+               else
+                       string[i++] = NET_RATE_9M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_12_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_12_OFDM)
+                       string[i++] = NET_RATE_12M_BASIC;
+               else
+                       string[i++] = NET_RATE_12M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_18_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_18_OFDM)
+                       string[i++] = NET_RATE_18M_BASIC;
+               else
+                       string[i++] = NET_RATE_18M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_24_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_24_OFDM)
+                       string[i++] = NET_RATE_24M_BASIC;
+               else
+                       string[i++] = NET_RATE_24M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_36_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_36_OFDM)
+                       string[i++] = NET_RATE_36M_BASIC;
+               else
+                       string[i++] = NET_RATE_36M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_48_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_48_OFDM)
+                       string[i++] = NET_RATE_48M_BASIC;
+               else
+                       string[i++] = NET_RATE_48M;
+       }
+       if(suppRatesBitMap & DRV_RATE_MASK_54_OFDM)
+       {
+               if(basicRatesBitMap & DRV_RATE_MASK_54_OFDM)
+                       string[i++] = NET_RATE_54M_BASIC;
+               else
+                       string[i++] = NET_RATE_54M;
+       }
+
+       *len = i;
+}
+
+/************************************************************************
+ *                        networkStringToBitMapSuppRates                               *
+ ************************************************************************
+DESCRIPTION: Converts supported rates string to the bit map
+                                                                                                   
+INPUT:      string             -       array of rates in the network format
+                       len - array length
+
+OUTPUT:                bitMap - bit map of rates.
+
+RETURN:     None
+
+************************************************************************/
+void networkStringToBitMapSuppRates(UINT32 *bitMap, UINT8 *string, UINT32 len)
+{
+       UINT32 i;
+
+       *bitMap = 0;
+
+       for(i=0; i<len; i++)
+       {
+               switch(string[i])
+               {
+                       case NET_RATE_1M:
+                       case NET_RATE_1M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_1_BARKER;
+                               break;
+                       case NET_RATE_2M:
+                       case NET_RATE_2M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_2_BARKER;
+                               break;
+                       case NET_RATE_5_5M:
+                       case NET_RATE_5_5M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_5_5_CCK;
+                               break;
+                       case NET_RATE_11M:
+                       case NET_RATE_11M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_11_CCK;
+                               break;
+                       case NET_RATE_22M:
+                       case NET_RATE_22M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_22_PBCC;
+                               break;
+                       case NET_RATE_6M:
+                       case NET_RATE_6M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_6_OFDM;
+                               break;
+                       case NET_RATE_9M:
+                       case NET_RATE_9M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_9_OFDM;
+                               break;
+                       case NET_RATE_12M:
+                       case NET_RATE_12M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_12_OFDM;
+                               break;
+                       case NET_RATE_18M:
+                       case NET_RATE_18M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_18_OFDM;
+                               break;
+                       case NET_RATE_24M:
+                       case NET_RATE_24M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_24_OFDM;
+                               break;
+                       case NET_RATE_36M:
+                       case NET_RATE_36M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_36_OFDM;
+                               break;
+                       case NET_RATE_48M:
+                       case NET_RATE_48M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_48_OFDM;
+                               break;
+                       case NET_RATE_54M:
+                       case NET_RATE_54M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_54_OFDM;
+                               break;
+                       default:
+                               break;
+               }
+       }
+}        
+
+/************************************************************************
+ *                        networkStringToBitMapBasicRates                              *
+ ************************************************************************
+DESCRIPTION: Converts basic rates string to the bit map
+                                                                                                   
+INPUT:      string             -       array of rates in the network format
+                       len - array length
+
+OUTPUT:                bitMap - bit map of rates.
+
+RETURN:     None
+
+************************************************************************/
+void networkStringToBitMapBasicRates(UINT32 *bitMap, UINT8 *string, UINT32 len)
+{
+       UINT32 i;
+
+       *bitMap = 0;
+
+       for(i=0; i<len; i++)
+       {
+               switch(string[i])
+               {
+                       case NET_RATE_1M_BASIC: 
+                               *bitMap |= DRV_RATE_MASK_1_BARKER;
+                               break;
+                       case NET_RATE_2M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_2_BARKER;
+                               break;
+                       case NET_RATE_5_5M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_5_5_CCK;
+                               break;
+                       case NET_RATE_11M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_11_CCK;
+                               break;
+                       case NET_RATE_22M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_22_PBCC;
+                               break;
+                       case NET_RATE_6M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_6_OFDM;
+                               break;
+                       case NET_RATE_9M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_9_OFDM;
+                               break;
+                       case NET_RATE_12M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_12_OFDM;
+                               break;
+                       case NET_RATE_18M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_18_OFDM;
+                               break;
+                       case NET_RATE_24M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_24_OFDM;
+                               break;
+                       case NET_RATE_36M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_36_OFDM;
+                               break;
+                       case NET_RATE_48M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_48_OFDM;
+                               break;
+                       case NET_RATE_54M_BASIC:
+                               *bitMap |= DRV_RATE_MASK_54_OFDM;
+                               break;
+                       default:
+                               break;
+               }
+       }
+}        
+
+void validateRates(UINT32 *pBasicRateMask, UINT32 *pSuppRateMask, 
+                                                 UINT32 *pTxRate, modulationType_e *modulation, BOOL dot11a)
+{
+       rate_e maxSuppRate;
+
+       /* Make sure that the basic rate set is included in the supported rate set */
+       (*pBasicRateMask) &= (*pSuppRateMask);
+
+       /* Ignore modulation in the Tx rate. */
+       switch (*pTxRate)
+       {
+       case REG_RATE_AUTO_BIT:
+               *pTxRate = DRV_RATE_AUTO;
+               break;
+
+       case REG_RATE_1M_BIT:
+               *pTxRate = DRV_RATE_1M;
+               break;
+
+       case REG_RATE_2M_BIT:
+               *pTxRate = DRV_RATE_2M;
+               break;
+
+       case REG_RATE_5_5M_CCK_BIT:
+               *pTxRate = DRV_RATE_5_5M;
+               break;
+
+       case REG_RATE_11M_CCK_BIT:
+               *pTxRate = DRV_RATE_11M;
+               break;
+
+       case REG_RATE_22M_PBCC_BIT:
+               *pTxRate = DRV_RATE_22M;
+               break;
+
+       case REG_RATE_6M_OFDM_BIT:
+               *pTxRate = DRV_RATE_6M;
+               break;
+       case REG_RATE_9M_OFDM_BIT:
+               *pTxRate = DRV_RATE_9M;
+               break;
+       case REG_RATE_12M_OFDM_BIT:
+               *pTxRate = DRV_RATE_12M;
+               break;
+       case REG_RATE_18M_OFDM_BIT:
+               *pTxRate = DRV_RATE_18M;
+               break;
+       case REG_RATE_24M_OFDM_BIT:
+               *pTxRate = DRV_RATE_24M;
+               break;
+       case REG_RATE_36M_OFDM_BIT:
+               *pTxRate = DRV_RATE_36M;
+               break;
+       case REG_RATE_48M_OFDM_BIT:
+               *pTxRate = DRV_RATE_48M;
+               break;
+       case REG_RATE_54M_OFDM_BIT:
+               *pTxRate = DRV_RATE_54M;
+               break;
+       default:
+               *pTxRate = DRV_RATE_AUTO;
+               break;
+       }
+
+       /* Make sure that in dot11a mode the desired tx rate is OFDM rate */
+       if(dot11a)
+               if((*pTxRate < DRV_RATE_6M) && (*pTxRate != DRV_RATE_AUTO))
+                       *pTxRate = DRV_RATE_6M;
+
+       /* Make sure that the Tx rate is less or equsl to the max supported rate */
+       maxSuppRate = calculateMaxSupportedRate(pSuppRateMask);
+       if(maxSuppRate == DRV_RATE_INVALID)
+       {
+               if(dot11a)
+                       *pTxRate = DRV_RATE_6M;
+               else
+                       *pTxRate = DRV_RATE_1M;
+       }
+       else if(*pTxRate > (UINT32)maxSuppRate)
+               *pTxRate = (UINT32)maxSuppRate;
+
+       /* Handle desired modulation */
+       if(maxSuppRate == DRV_RATE_22M)
+               *modulation = DRV_MODULATION_PBCC;
+       else if(maxSuppRate < DRV_RATE_22M)
+               *modulation = DRV_MODULATION_CCK;
+       else
+               *modulation = DRV_MODULATION_OFDM;
+}
+
+int ConvertHwBitRateToAppRate(UINT32 HwRate,rate_e *AppRate)
+{
+       rate_e Rate = DRV_RATE_AUTO;
+       int Stt = OK;
+
+       switch (HwRate)
+       {
+               /*
+                *      The handle for 5.5/11/22 PBCC was removed !!!
+                */
+
+       case HW_BIT_RATE_1MBPS:                                                  Rate = DRV_RATE_1M;            break;
+       case HW_BIT_RATE_2MBPS:                                                  Rate = DRV_RATE_2M;            break;
+       case HW_BIT_RATE_5_5MBPS:                                        Rate = DRV_RATE_5_5M;          break;
+       case HW_BIT_RATE_6MBPS:                                                  Rate = DRV_RATE_6M;            break;
+       case HW_BIT_RATE_9MBPS:                                                  Rate = DRV_RATE_9M;            break;
+       case HW_BIT_RATE_11MBPS:                                                 Rate = DRV_RATE_11M;           break;
+       case HW_BIT_RATE_12MBPS:                                                 Rate = DRV_RATE_12M;           break;
+       case HW_BIT_RATE_18MBPS:                                                 Rate = DRV_RATE_18M;           break;
+       case HW_BIT_RATE_22MBPS:                                                 Rate = DRV_RATE_22M;           break;
+       case HW_BIT_RATE_24MBPS:                                                 Rate = DRV_RATE_24M;           break;
+       case HW_BIT_RATE_36MBPS:                                                 Rate = DRV_RATE_36M;           break;
+       case HW_BIT_RATE_48MBPS:                                                 Rate = DRV_RATE_48M;           break;
+       case HW_BIT_RATE_54MBPS:                                                 Rate = DRV_RATE_54M;           break;
+       default:
+                       Stt = NOK;
+                       break;
+       }
+
+       if (Stt == OK)
+               *AppRate = Rate;
+       else
+               *AppRate = DRV_RATE_1M; 
+
+       return (Stt);
+}
+int ConvertAppRateToHwBitMapRate(UINT32 AppRate, UINT32 *HwRate)
+{
+       UINT32 Rate = 0;
+       int Stt = OK;
+
+       switch (AppRate)
+       {
+               /* when rateAdaptaion in FW */
+               case DRV_RATE_AUTO:                          Rate = 0; break;
+
+               case DRV_RATE_1M:                                                        Rate = HW_BIT_RATE_1MBPS;     break;
+               case DRV_RATE_2M:                                                        Rate = HW_BIT_RATE_2MBPS;     break;
+               case DRV_RATE_5_5M:                                              Rate = HW_BIT_RATE_5_5MBPS;   break;
+               case DRV_RATE_11M:                                                       Rate = HW_BIT_RATE_11MBPS;    break;
+               case DRV_RATE_22M:                                                       Rate = HW_BIT_RATE_22MBPS;    break;
+               case DRV_RATE_6M:                                                        Rate = HW_BIT_RATE_6MBPS;     break;
+               case DRV_RATE_9M:                                                        Rate = HW_BIT_RATE_9MBPS;     break;
+               case DRV_RATE_12M:                                                       Rate = HW_BIT_RATE_12MBPS;    break;
+               case DRV_RATE_18M:                                                       Rate = HW_BIT_RATE_18MBPS;    break;
+               case DRV_RATE_24M:                                                       Rate = HW_BIT_RATE_24MBPS;    break;
+               case DRV_RATE_36M:                                                       Rate = HW_BIT_RATE_36MBPS;    break;
+               case DRV_RATE_48M:                                                       Rate = HW_BIT_RATE_48MBPS;    break;
+               case DRV_RATE_54M:                                                       Rate = HW_BIT_RATE_54MBPS;    break;
+               default:
+                       Stt = NOK;
+                       break;
+       }
+
+       if (Stt == OK)
+               *HwRate = Rate;
+       else
+               *HwRate = HW_BIT_RATE_1MBPS; 
+
+
+
+       return (Stt);
+}
+
+int ConvertAppRatesToBitmap(UINT16 AppRatesBitmap, UINT32 *HwRatesBitmap)
+{
+       UINT16 RatesBitmap = 0;
+   
+       if (AppRatesBitmap & DRV_RATE_MASK_1_BARKER)    RatesBitmap |= HW_BIT_RATE_1MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_2_BARKER)    RatesBitmap |= HW_BIT_RATE_2MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_5_5_CCK)             RatesBitmap |= HW_BIT_RATE_5_5MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_11_CCK)              RatesBitmap |= HW_BIT_RATE_11MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_22_PBCC)             RatesBitmap |= HW_BIT_RATE_22MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_6_OFDM)              RatesBitmap |= HW_BIT_RATE_6MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_9_OFDM)              RatesBitmap |= HW_BIT_RATE_9MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_12_OFDM)             RatesBitmap |= HW_BIT_RATE_12MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_18_OFDM)             RatesBitmap |= HW_BIT_RATE_18MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_24_OFDM)             RatesBitmap |= HW_BIT_RATE_24MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_36_OFDM)             RatesBitmap |= HW_BIT_RATE_36MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_48_OFDM)             RatesBitmap |= HW_BIT_RATE_48MBPS;
+       if (AppRatesBitmap & DRV_RATE_MASK_54_OFDM)             RatesBitmap |= HW_BIT_RATE_54MBPS;
+
+       
+       *HwRatesBitmap = RatesBitmap;
+
+       return (OK);
+}
+
+/*
+ * ----------------------------------------------------------------------------
+ * Function : ConvertHwRateToDrvRate
+ *
+ * Input    :
+ * Output   :
+ * Process  : convert rate from Hw rate to Drv rate
+ * Note(s)  : 
+ * -----------------------------------------------------------------------------
+ */
+
+rate_e ConvertHwRateToDrvRate(UINT8 HwRate, BOOL bOFDMMudulation)
+{
+    /* 
+     * This special case is done because of identical values of HW_RATE_1M & RATE_12MBPS
+     * These values are Hw oriented and can't be changed. The way for distinguishing 
+     * between them is using the modulation of the packet
+     */
+    if ( (HwRate == RATE_12MBPS) && (bOFDMMudulation) )
+    {
+        return DRV_RATE_12M;
+    }
+
+       switch (HwRate)
+       {
+               case RATE_1MBPS:        return DRV_RATE_1M;     
+                       
+               case RATE_2MBPS:        return DRV_RATE_2M;     
+                     
+               case RATE_5_5MBPS:      return DRV_RATE_5_5M;   
+               
+               case RATE_6MBPS:        return DRV_RATE_6M;     
+               
+               case RATE_9MBPS:        return DRV_RATE_9M;     
+               
+               case RATE_11MBPS:       return DRV_RATE_11M;    
+                       
+        /* RATE_12MBPS is covered on the top */ 
+
+               case RATE_18MBPS:       return DRV_RATE_18M;    
+               
+               case RATE_22MBPS:       return DRV_RATE_22M;    
+               
+               case RATE_24MBPS:       return DRV_RATE_24M;    
+               
+               case RATE_36MBPS:       return DRV_RATE_36M;    
+               
+               case RATE_48MBPS:       return DRV_RATE_48M;    
+
+        case RATE_54MBPS:      return DRV_RATE_54M;    
+               
+               default:
+            /* Return error indication */
+                       return DRV_RATE_AUTO;                   
+       }
+}
+
+/*
+* ----------------------------------------------------------------------------
+* Function : ConvertHwRateToDrvRate
+*
+* Input    :
+* Output   :
+* Process  : convert rate from Drv rate to Hw rate
+* Note(s)  : 
+* -----------------------------------------------------------------------------
+*/
+UINT8 ConvertDrvRate2HwRate(rate_e eRate)
+{
+       switch(eRate)
+       {
+       case DRV_RATE_1M:       return RATE_1MBPS;
+
+       case DRV_RATE_2M:       return RATE_2MBPS;
+
+       case DRV_RATE_5_5M:     return RATE_5_5MBPS;
+
+       case DRV_RATE_11M:      return RATE_11MBPS;
+
+       case DRV_RATE_22M:      return RATE_22MBPS;
+
+       case DRV_RATE_6M:       return RATE_6MBPS;
+
+       case DRV_RATE_9M:       return RATE_9MBPS;
+
+       case DRV_RATE_12M:      return RATE_12MBPS;
+
+       case DRV_RATE_18M:      return RATE_18MBPS;
+
+       case DRV_RATE_24M:      return RATE_24MBPS;
+
+       case DRV_RATE_36M:      return RATE_36MBPS;
+
+       case DRV_RATE_48M:      return RATE_48MBPS;
+
+       case DRV_RATE_54M:      return RATE_54MBPS;
+
+       default:
+               WLAN_OS_REPORT(("ERROR: ConvertDrvRate2HwRate: Invalid input Rate = %d\n ", eRate));
+               return 0;
+       }
+}
+
+
+
+
+rate_e calculateMaxSupportedRate(UINT32 *pSuppRateMask)
+{
+       if((*pSuppRateMask) & DRV_RATE_MASK_54_OFDM)
+               return DRV_RATE_54M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_48_OFDM)
+               return DRV_RATE_48M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_36_OFDM)
+               return DRV_RATE_36M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_24_OFDM)
+               return DRV_RATE_24M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_22_PBCC)
+               return DRV_RATE_22M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_18_OFDM)
+               return DRV_RATE_18M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_12_OFDM)
+               return DRV_RATE_12M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_11_CCK)
+               return DRV_RATE_11M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_9_OFDM)
+               return DRV_RATE_9M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_6_OFDM)
+               return DRV_RATE_6M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_5_5_CCK)
+               return DRV_RATE_5_5M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_2_BARKER)
+               return DRV_RATE_2M;
+       if((*pSuppRateMask) & DRV_RATE_MASK_1_BARKER)
+               return DRV_RATE_1M;
+       
+       return DRV_RATE_INVALID;
+}
+
+
+
+/************************************************************************
+ *                        hex_to_string                                                                *
+ ************************************************************************
+DESCRIPTION: Converts hex buffer to string buffer.
+
+NOTE:           1. The caller has to make sure that the pString size is at 
+                               lease: ((Size * 2) + 1)
+                        2. A string terminator is inserted into lase char of the string
+************************************************************************/
+void convert_hex_to_string(tiUINT8 *pBuffer, char *pString, tiUINT8 Size)
+{
+       int index;
+       unsigned char temp_nibble;
+
+       /* Go over pBuffer and convert it to chars */ 
+       for (index = 0; index < Size; index++)
+       {
+               /* First nibble */
+               temp_nibble = (pBuffer[index] & 0x0F);
+               if (temp_nibble <= 9)
+               {
+                       pString[(index << 1) + 1] = temp_nibble + '0';
+               }
+               else
+               {
+                       pString[(index << 1) + 1] = temp_nibble - 10 + 'A';
+               }
+
+               /* Second nibble */
+               temp_nibble = ((pBuffer[index] & 0xF0) >> 4);
+               if (temp_nibble <= 9)
+               {
+                       pString[(index << 1)] = temp_nibble + '0';
+               }
+               else
+               {
+                       pString[(index << 1)] = temp_nibble - 10 + 'A';
+               }
+       }
+
+       /* Put string terminator */
+       pString[(Size * 2)] = 0;
+}
+
+
+
+
+
+
+
+
+UINT32 translateBasicRateValueToMask(UINT32 value, BOOL dot11a)
+{
+       if(!dot11a)
+       {
+               switch(value)
+               {
+                       case BASIC_RATE_SET_1_2:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER;
+                       case BASIC_RATE_SET_1_2_5_5_11:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK;
+                       case BASIC_RATE_SET_UP_TO_12:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM;
+                       case BASIC_RATE_SET_UP_TO_18:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM;
+                       case BASIC_RATE_SET_UP_TO_24:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM;
+                       case BASIC_RATE_SET_UP_TO_36:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM;
+                       case BASIC_RATE_SET_UP_TO_48:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM;
+                       case BASIC_RATE_SET_UP_TO_54:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+                       case BASIC_RATE_SET_6_12_24:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_24_OFDM;
+                       case BASIC_RATE_SET_1_2_5_5_6_11_12_24:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_24_OFDM;                   
+                       default:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER;
+               }
+       }
+       else
+       {
+               switch(value)
+               {
+                       case BASIC_RATE_SET_UP_TO_12:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM;
+                       case BASIC_RATE_SET_UP_TO_18:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM;
+                       case BASIC_RATE_SET_UP_TO_24:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM;
+                       case BASIC_RATE_SET_UP_TO_36:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM;
+                       case BASIC_RATE_SET_UP_TO_48:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM;
+                       case BASIC_RATE_SET_UP_TO_54:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+                       case BASIC_RATE_SET_6_12_24:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_24_OFDM;
+                       default:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_24_OFDM;
+               }
+       }
+}
+
+UINT32 translateSupportedRateValueToMask(UINT32 value, BOOL dot11a)
+{
+       if(!dot11a)
+       {
+               switch(value)
+               {
+                       case SUPPORTED_RATE_SET_1_2:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER;
+                       case SUPPORTED_RATE_SET_1_2_5_5_11:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK;
+                       case SUPPORTED_RATE_SET_1_2_5_5_11_22:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_22_PBCC; 
+                       case SUPPORTED_RATE_SET_UP_TO_18:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_24:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_36:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_48:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_54:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+                       case SUPPORTED_RATE_SET_ALL:
+                               return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_22_PBCC | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+                       case SUPPORTED_RATE_SET_ALL_OFDM:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+               default:
+                       return DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_22_PBCC | DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+               }
+       }
+       else
+       {
+               switch(value)
+               {
+                       case SUPPORTED_RATE_SET_UP_TO_18:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_24:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_36:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_48:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM;
+                       case SUPPORTED_RATE_SET_UP_TO_54:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+
+                       case SUPPORTED_RATE_SET_ALL:
+                       case SUPPORTED_RATE_SET_ALL_OFDM:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+                       default:
+                               return DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_9_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_18_OFDM | DRV_RATE_MASK_24_OFDM | DRV_RATE_MASK_36_OFDM | DRV_RATE_MASK_48_OFDM | DRV_RATE_MASK_54_OFDM;
+               }
+       }
+}
+
+void   validateRatesVsBand(UINT32 *supportedMask, UINT32 *basicMask, BOOL dot11a)
+{
+       if(dot11a)
+               *supportedMask &= ~(DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER | DRV_RATE_MASK_5_5_CCK | DRV_RATE_MASK_11_CCK | DRV_RATE_MASK_22_PBCC);
+
+       *basicMask &= *supportedMask;
+
+       if(*basicMask == 0)
+       {       
+               if(dot11a)
+                       *basicMask = DRV_RATE_MASK_6_OFDM | DRV_RATE_MASK_12_OFDM | DRV_RATE_MASK_24_OFDM;
+               else
+                       *basicMask = DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER;
+       }
+
+}
+
+
+rate_e findMaxActiveRate( UINT32 ratesBitMap)
+{
+       rate_e rate = DRV_RATE_1M;
+
+       if(ratesBitMap & DRV_RATE_MASK_1_BARKER) rate = DRV_RATE_1M; 
+       if(ratesBitMap & DRV_RATE_MASK_2_BARKER) rate = DRV_RATE_2M;
+       if(ratesBitMap & DRV_RATE_MASK_5_5_CCK)  rate = DRV_RATE_5_5M;
+       if(ratesBitMap & DRV_RATE_MASK_11_CCK)   rate = DRV_RATE_11M; 
+       if(ratesBitMap & DRV_RATE_MASK_22_PBCC)  rate = DRV_RATE_22M;
+       if(ratesBitMap & DRV_RATE_MASK_6_OFDM)   rate = DRV_RATE_6M;
+       if(ratesBitMap & DRV_RATE_MASK_9_OFDM)   rate = DRV_RATE_9M;
+       if(ratesBitMap & DRV_RATE_MASK_12_OFDM)  rate = DRV_RATE_12M;
+       if(ratesBitMap & DRV_RATE_MASK_18_OFDM)  rate = DRV_RATE_18M;
+       if(ratesBitMap & DRV_RATE_MASK_24_OFDM)  rate = DRV_RATE_24M;
+       if(ratesBitMap & DRV_RATE_MASK_36_OFDM)  rate = DRV_RATE_36M;
+       if(ratesBitMap & DRV_RATE_MASK_48_OFDM)  rate = DRV_RATE_48M;
+       if(ratesBitMap & DRV_RATE_MASK_54_OFDM)  rate = DRV_RATE_54M;
+
+       return rate;
+}
+
+
+/************************************************************************
+ *                        getMaxRate                                                                   *
+ ************************************************************************
+DESCRIPTION: This function return the Max rate.
+                        In addition return the matched modulation type
+                                                                                                   
+INPUT:      rateBitMap         -       The supported basic rates
+                       operationMode   -   Current operation mode, used only to set default rate.
+
+
+OUTPUT:                rate - The max rate from the OFDM allowed rates.
+                       modulation - The modulation of the Max Basic rate.
+
+RETURN:     None
+
+************************************************************************/
+void getMaxRate(UINT32 ratesBitMap, rate_e *rate, modulationType_e *modulation, dot11mode_e operationMode)
+{
+       rate_e maxRate = DRV_RATE_INVALID;
+
+    /* find max rate */
+    if(ratesBitMap & DRV_RATE_MASK_1_BARKER) maxRate = DRV_RATE_1M;
+    if(ratesBitMap & DRV_RATE_MASK_2_BARKER) maxRate = DRV_RATE_2M;
+    if(ratesBitMap & DRV_RATE_MASK_5_5_CCK)  maxRate = DRV_RATE_5_5M;
+    if(ratesBitMap & DRV_RATE_MASK_11_CCK)   maxRate = DRV_RATE_11M;
+
+    /* Ctrl and Mgmt frames should not be transmitted at 22Mbps PBCC */
+       /*if(ratesBitMap & DRV_RATE_MASK_22_PBCC)   maxRate = DRV_RATE_22M;*/
+
+       if(ratesBitMap & DRV_RATE_MASK_6_OFDM)   maxRate = DRV_RATE_6M;
+       if(ratesBitMap & DRV_RATE_MASK_9_OFDM)   maxRate = DRV_RATE_9M;
+       if(ratesBitMap & DRV_RATE_MASK_12_OFDM)  maxRate = DRV_RATE_12M;
+       if(ratesBitMap & DRV_RATE_MASK_18_OFDM)  maxRate = DRV_RATE_18M;
+       if(ratesBitMap & DRV_RATE_MASK_24_OFDM)  maxRate = DRV_RATE_24M;
+       if(ratesBitMap & DRV_RATE_MASK_36_OFDM)  maxRate = DRV_RATE_36M;
+       if(ratesBitMap & DRV_RATE_MASK_48_OFDM)  maxRate = DRV_RATE_48M;
+       if(ratesBitMap & DRV_RATE_MASK_54_OFDM)  maxRate = DRV_RATE_54M;
+       
+       if(maxRate == DRV_RATE_INVALID)
+       {
+               /* No rate is supported */
+               WLAN_OS_REPORT((" Error; The rate Bit field does not support any available rate\n"));
+               
+               if(operationMode == DOT11_A_MODE)
+               {
+                       /* Default value for A band is 6M */
+                       maxRate = DRV_RATE_6M;
+               }
+               else
+               {
+                       /* Default value for B/G band is 2M */
+                       maxRate = DRV_RATE_2M;
+               }
+       }
+
+       /* Return the Max rate */
+       *rate = maxRate;
+
+       /* Return the matched modulation type */
+       if(maxRate >= DRV_RATE_6M)
+       {
+               *modulation = DRV_MODULATION_OFDM;
+       }
+       else 
+       if(maxRate >= DRV_RATE_5_5M)
+       {
+               *modulation = DRV_MODULATION_CCK;
+       }
+       else
+       {
+               *modulation = DRV_MODULATION_QPSK;
+       }
+       
+       return;
+
+}
+
+/************************************************************************
+ *                        getMinRate                                                                   *
+ ************************************************************************
+DESCRIPTION: This function return the Min rate.
+                        In addition return the matched modulation type
+                                                                                                   
+INPUT:      rateBitMap         -       The supported basic rates
+                       operationMode   -   Current operation mode, used only to set default rate.
+
+
+OUTPUT:                rate - The min rate from the OFDM allowed rates.
+                       modulation - The modulation of the Min Basic rate.
+
+RETURN:     None
+
+************************************************************************/
+void getMinRate(UINT32 ratesBitMap, rate_e *rate, modulationType_e *modulation, dot11mode_e operationMode)
+{
+       rate_e minRate = DRV_RATE_INVALID;
+
+    /* find min rate */
+       if(ratesBitMap & DRV_RATE_MASK_54_OFDM)  minRate = DRV_RATE_54M;
+       if(ratesBitMap & DRV_RATE_MASK_48_OFDM)  minRate = DRV_RATE_48M;
+       if(ratesBitMap & DRV_RATE_MASK_36_OFDM)  minRate = DRV_RATE_36M;
+       if(ratesBitMap & DRV_RATE_MASK_24_OFDM)   minRate = DRV_RATE_24M;
+       if(ratesBitMap & DRV_RATE_MASK_18_OFDM)   minRate = DRV_RATE_18M;
+       if(ratesBitMap & DRV_RATE_MASK_12_OFDM)  minRate = DRV_RATE_12M;
+       if(ratesBitMap & DRV_RATE_MASK_9_OFDM)  minRate = DRV_RATE_9M;
+       if(ratesBitMap & DRV_RATE_MASK_6_OFDM)  minRate = DRV_RATE_6M;
+
+    /* Ctrl and Mgmt frames should not be transmitted at 22Mbps PBCC */
+    /*if(ratesBitMap & DRV_RATE_MASK_22_PBCC)  minRate = DRV_RATE_22M;*/
+
+       if(ratesBitMap & DRV_RATE_MASK_11_CCK)   minRate = DRV_RATE_11M;
+       if(ratesBitMap & DRV_RATE_MASK_5_5_CCK)  minRate = DRV_RATE_5_5M;
+       if(ratesBitMap & DRV_RATE_MASK_2_BARKER) minRate = DRV_RATE_2M;
+       if(ratesBitMap & DRV_RATE_MASK_1_BARKER) minRate = DRV_RATE_1M;
+
+       if(minRate == DRV_RATE_INVALID)
+       {
+               /* No rate is supported */
+               WLAN_OS_REPORT((" Error; The rate Bit field does not support any available rate\n"));
+               
+               if(operationMode == DOT11_A_MODE)
+               {
+                       /* Default value for A band is 6M */
+                       minRate = DRV_RATE_6M;
+               }
+               else
+               {
+                       /* Default value for B/G band is 2M */
+                       minRate = DRV_RATE_2M;
+               }
+       }
+
+       /* Return the Max rate */
+       *rate = minRate;
+
+       /* Return the matched modulation type */
+       if(minRate >= DRV_RATE_6M)
+       {
+               *modulation = DRV_MODULATION_OFDM;
+       }
+       else 
+       if(minRate >= DRV_RATE_5_5M)
+       {
+               *modulation = DRV_MODULATION_CCK;
+       }
+       else
+       {
+               *modulation = DRV_MODULATION_QPSK;
+       }
+       
+       return;
+
+}
+
+
+UINT8 hostRateToNumber(rate_e rate)
+{
+       switch (rate)
+       {
+       case DRV_RATE_1M:       return 1;
+       case DRV_RATE_2M:       return 2;
+       case DRV_RATE_5_5M:     return 5;
+       case DRV_RATE_11M:      return 11;
+       case DRV_RATE_22M:      return 22;
+       case DRV_RATE_6M:       return 6;
+       case DRV_RATE_9M:       return 9;
+       case DRV_RATE_12M:      return 12;
+       case DRV_RATE_18M:      return 18;
+       case DRV_RATE_24M:      return 24;
+       case DRV_RATE_36M:      return 36;
+       case DRV_RATE_48M:      return 48;
+       case DRV_RATE_54M:      return 54;
+
+       default:
+               return 0;
+       }
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:    RateNumberToHost
+Routine Description:
+Arguments:
+Return Value:    None
+-----------------------------------------------------------------------------*/
+rate_e  RateNumberToHost(UINT8 rateIn)
+{
+    switch(rateIn)
+    {
+    case 0x1:   return DRV_RATE_1M;
+    case 0x2:   return DRV_RATE_2M;
+    case 0x5:   return DRV_RATE_5_5M;
+    case 0xB:   return DRV_RATE_11M;
+    case 0x16:  return DRV_RATE_22M;
+    case 0x6:   return DRV_RATE_6M;
+    case 0x9:   return DRV_RATE_9M;
+    case 0xC:   return DRV_RATE_12M;
+    case 0x12:  return DRV_RATE_18M;
+    case 0x18:  return DRV_RATE_24M;
+    case 0x24:  return DRV_RATE_36M;
+    case 0x30:  return DRV_RATE_48M;
+    case 0x36:  return DRV_RATE_54M;
+    default:    return DRV_RATE_6M;
+    }
+}
+
+RateIndex_e rateNumberToIndex(UINT8 uRate)
+{
+       switch(uRate)
+       {
+       case 1:   return RATE_INDEX_1MBPS;
+       case 2:   return RATE_INDEX_2MBPS;
+       case 5:   return RATE_INDEX_5_5MBPS;
+       case 6:   return RATE_INDEX_6MBPS; 
+       case 9:   return RATE_INDEX_9MBPS; 
+       case 11:  return RATE_INDEX_11MBPS;
+       case 12:  return RATE_INDEX_12MBPS;
+       case 18:  return RATE_INDEX_18MBPS;
+       case 22:  return RATE_INDEX_22MBPS;
+       case 24:  return RATE_INDEX_24MBPS;
+       case 36:  return RATE_INDEX_36MBPS;
+       case 48:  return RATE_INDEX_48MBPS;
+       case 54:  return RATE_INDEX_54MBPS;
+       default:
+               return INVALID_RATE_INDEX;
+       }
+}
+
+
+BOOL utils_isAnySSID(ssid_t *pSsid)
+{
+       if (pSsid == NULL)
+       {
+               return TRUE;
+       }
+
+       if (pSsid->len == 0)
+       {
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+BOOL utils_isJunkSSID(ssid_t *pSsid)
+{
+       if (pSsid == NULL)
+       {
+               return TRUE;
+       }
+
+       if (pSsid->len > 2)
+       {
+               if ((pSsid->ssidString[0] < FIRST_VALID_CHAR) &&
+                       (pSsid->ssidString[1] < FIRST_VALID_CHAR) &&
+                       (pSsid->ssidString[2] < FIRST_VALID_CHAR))
+               {
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
+
+BOOL utils_isIESSID_Broadcast(dot11_SSID_t *pIESsid)
+{
+       if ((pIESsid == NULL) || (pIESsid->hdr.eleLen==0))
+       {
+               return TRUE;
+       }
+
+    /* According to 802.11, Broadcast SSID should be with length 0,
+        however, different vendors use invalid chanrs for Broadcast SSID. */
+    if (pIESsid->serviceSetId[0] < FIRST_VALID_CHAR)
+    {
+        return TRUE;
+    }
+
+       return FALSE;
+}
+
+/* HEX DUMP for BDs !!! Debug code only !!! */
+void HexDumpData (UINT8 *data, int datalen)
+{
+#ifdef TI_DBG
+int j,dbuflen=0;
+char dbuf[50];
+static char hexdigits[16] = "0123456789ABCDEF";
+
+       for(j=0; j < datalen;)
+       {
+               /* Add a byte to the line*/
+               dbuf[dbuflen] =  hexdigits[(data[j] >> 4)&0x0f];
+               dbuf[dbuflen+1] = hexdigits[data[j] & 0x0f];
+               dbuf[dbuflen+2] = ' ';
+               dbuf[dbuflen+3] = '\0';
+               dbuflen += 3;
+               j++;
+               if((j % 16) == 0)
+               {
+                       /* Dump a line every 16 hex digits*/
+                       WLAN_OS_REPORT(("%04.4x  %s\n", j-16, dbuf));
+                       dbuflen = 0;
+               }
+       }
+       /* Flush if something has left in the line*/
+       if(dbuflen)
+               WLAN_OS_REPORT(("%04.4x  %s\n", j & 0xfff0, dbuf));
+#endif
+}
+
+void msduContentDump (mem_MSDU_T* pMsdu, char *str)
+{      
+    INT32 msduLen;
+       mem_BD_T* pCurrBd;
+    
+       WLAN_OS_REPORT(("%s\n", str));
+       
+       WLAN_OS_REPORT(("totalLen = %d\n", pMsdu->dataLen));
+       WLAN_OS_REPORT(("headerLen = %d\n", pMsdu->headerLen));
+
+       msduLen = pMsdu->dataLen;
+       pCurrBd = pMsdu->firstBDPtr;
+       
+       while ((msduLen >= 0)&&(pCurrBd!=NULL))
+       {
+               WLAN_OS_REPORT(("\nBdLen = %d\n", pCurrBd->length));
+               
+               HexDumpData((UINT8*)(pCurrBd->data+pCurrBd->dataOffset), pCurrBd->length);
+       
+               msduLen -=  pCurrBd->length;
+               pCurrBd =  pCurrBd->nextBDPtr;
+       }
+
+}
+
+
+/**
+*
+* parseIeBuffer  - Parse a required information element.
+*
+* \b Description: 
+*
+* Parse an required information element
+* and returns a pointer to the IE.
+ * If given a matching buffer as well, returns a pointer to the first IE 
+ * that matches the IE ID and the given buffer.
+*
+* \b ARGS:
+*
+*  I   - hOs - pointer to OS context
+*  I   - pIeBuffer - pointer to the IE buffer  \n
+*  I   - length - the length of the whole buffer
+*  I   - desiredIeId - the desired IE ID 
+*  O   - pDesiredIe - a pointer to the desired IE
+*  I   - pMatchBuffer - a matching buffer in the IE buffer. Optional, if not required a NULL can be given. 
+*  I   - matchBufferLen - the matching buffer length. Optional, if not required zero can be given. 
+*  
+*  
+* \b RETURNS:
+*
+* TRUE if IE pointer was found, FALSE on failure. 
+*
+* \sa 
+*/
+BOOL parseIeBuffer(TI_HANDLE hOs, UINT8 *pIeBuffer, UINT16 length, UINT8 desiredIeId, UINT8 **pDesiredIe, UINT8 *pMatchBuffer, UINT8 matchBufferLen)
+{
+
+       dot11_eleHdr_t   *eleHdr;
+       UINT8            *pCurIe;
+
+
+       if (pDesiredIe!=NULL)
+       {
+               *pDesiredIe = NULL;
+       }
+
+       if ((pIeBuffer == NULL) || (length==0))
+       {
+          return FALSE;        
+       }
+
+       pCurIe = pIeBuffer;
+       
+       while (length>0)
+       {
+               eleHdr = (dot11_eleHdr_t*)pCurIe;
+               
+               if (length<(eleHdr->eleLen+2))
+               {
+                       return FALSE;
+               }
+               
+               if (eleHdr->eleId == desiredIeId)
+               {
+            if ((matchBufferLen==0) || (pMatchBuffer == NULL) ||
+                               (!os_memoryCompare(hOs, &pCurIe[2], pMatchBuffer, matchBufferLen)))
+                       {
+                               if (pDesiredIe!=NULL)
+                               {
+                                       *pDesiredIe = (UINT8*)eleHdr;
+                               }
+                               return TRUE;
+                       }
+
+               }
+               length -= eleHdr->eleLen+2;
+               pCurIe += eleHdr->eleLen+2;
+       }
+       return FALSE;
+}
+
+/***************************************************************************
+*                                                      TiWlanIntToStr                                                 *
+****************************************************************************
+DESCRIPTION:   convert from UINT8 to asci string.
+                               NOTE: the method assume that the convert number is positive.
+                               debug ststus - radix == 16.
+                                                                                                   
+INPUT:      the number to convert.
+                       the radix of the number.
+
+OUTPUT:                the convert string.
+                       on error return empty string.
+
+RETURN:     void
+****************************************************************************/
+void TiWlanIntToStr(UINT8 theNumber , char *theString , UINT8 theRadix)
+{
+       int nibbleIndex;
+       UINT8 temp , factor;
+
+       for (nibbleIndex = 0 ; nibbleIndex < NUM_OF_NIBBLES_IN_BYTE ; ++nibbleIndex)
+       {
+               temp = theNumber;
+               if ((nibbleIndex % NUM_OF_NIBBLES_IN_BYTE) == 0) /* if the upper nibble */
+               {
+                        temp >>= NIBBLE_SIZE_IN_BITS;
+               }
+               temp &= NIBBLE_MASK;
+
+               if (temp < 10)
+               {
+                       factor = 0x30;
+               }
+               else
+               {
+                       factor = 0x37;
+               }
+               theString[nibbleIndex] = temp + factor;
+       }
+       theString[nibbleIndex] = '\0';
+}
+
+
+UINT32 getBasicRateMaskForSpecialBGchannel(void)
+{
+       return (UINT32)(translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE));
+}
+
+
+UINT32 getSupportedRateMaskForSpecialBGchannel(void)
+{
+       return (UINT32)(translateSupportedRateValueToMask(SUPPORTED_RATE_SET_1_2_5_5_11, FALSE));               
+}
+
+
+/***************************************************************************
+*                                                      reminder64                                                     *
+****************************************************************************
+DESCRIPTION:   returns the reminder of a 64 bit number division by a 32
+                bit number.
+                                                                                                   
+INPUT:      The dividee (64 bit number to divide)
+                       The divider (32 bit number to divide by)
+
+OUTPUT:                
+                   
+
+RETURN:     The reminder
+****************************************************************************/
+UINT32 reminder64( UINT64 dividee, UINT32 divider )
+{
+    UINT32 divideeHigh, divideeLow, partA, partB, mod28n, mod24n, mod16n, partA8n, mod8n, mod4n;
+
+    divideeHigh = INT64_HIGHER( dividee );
+    divideeLow = INT64_LOWER( dividee );
+
+    mod8n = 256 % divider;
+    mod4n = 16 % divider;
+
+    partA = (mod4n * (divideeHigh % divider)) % divider;
+    partA8n = (partA * mod4n) % divider;
+    mod16n = (partA8n * mod8n) % divider;
+    mod24n = (mod8n * mod16n) % divider;
+    mod28n = (mod4n * mod24n) % divider;
+
+    partB = (mod4n * mod28n) % divider;
+    return ( partB + (divideeLow % divider)) % divider;
+}
+
+
+/***************************************************************************
+*                                                      print_TI_STATUS                                                    *
+****************************************************************************
+DESCRIPTION:   returns TI_STATUS as string
+****************************************************************************/
+char* convertTI_STATUS_toString(TI_STATUS status)
+{
+    switch (status)
+    {
+        case   OK:                           return "OK";              
+        case   NOK:                          return "NOK";             
+        case   PARAM_NOT_SUPPORTED:          return "PARAM_NOT_SUPPORTED";
+        case   PARAM_VALUE_NOT_VALID:        return "PARAM_VALUE_NOT_VALID";
+        case   CONFIGURATION_NOT_VALID:      return "CONFIGURATION_NOT_VALID";
+        case   NO_SITE_SELECTED_YET:         return "NO_SITE_SELECTED_YET";
+        case   RE_SCAN_NEEDED:               return "RE_SCAN_NEEDED";
+        case   EXTERNAL_SET_PARAM_DENIED   : return "EXTERNAL_SET_PARAM_DENIED";
+        case   EXTERNAL_GET_PARAM_DENIED   : return "EXTERNAL_GET_PARAM_DENIED";
+        case   PARAM_MODULE_NUMBER_INVALID : return "PARAM_MODULE_NUMBER_INVALID";
+        case   STATION_IS_NOT_RUNNING      : return "STATION_IS_NOT_RUNNING";
+        case   CARD_IS_NOT_INSTALLED       : return "CARD_IS_NOT_INSTALLED";
+        case   RX_MIC_FAILURE_ERROR        : return "RX_MIC_FAILURE_ERROR";
+        case   RX_DECRYPT_FAILURE          : return "RX_DECRYPT_FAILURE";
+        case   RX_STATUS_FAILURE           : return "RX_STATUS_FAILURE";
+        case   TX_QUEUE_SELECTED_OK        : return "TX_QUEUE_SELECTED_OK";  
+        case   NO_TX_QUEUE_SELECTED        : return "NO_TX_QUEUE_SELECTED";
+        case   TX_STATUS_PENDING           : return "TX_STATUS_PENDING";
+        case   TX_STATUS_NO_RESOURCES      : return "TX_STATUS_NO_RESOURCES";
+        case   TX_STATUS_FAILURE           : return "TX_STATUS_FAILURE";
+        case   TX_STATUS_OK                : return "TX_STATUS_OK";
+        case   MAKE_CONCATENATION          : return "MAKE_CONCATENATION"; 
+        case   SEND_ONE_MSDU               : return "SEND_ONE_MSDU";
+        case   DO_NOT_SEND_MSDU            : return "DO_NOT_SEND_MSDU";
+        case   FOUR_X_DISABLE              : return "FOUR_X_DISABLE";
+        case   NO_COUNTRY                  : return "NO_COUNTRY";
+        case   SCAN_ALREADY_IN_PROGRESS    : return "SCAN_ALREADY_IN_PROGRESS";
+        case   NO_SCAN_IN_PROGRESS         : return "NO_SCAN_IN_PROGRESS";
+        case   TX_POWER_SET_SAME_VALUE     : return "TX_POWER_SET_SAME_VALUE";
+        case   CHANNEL_CHANGED             : return "CHANNEL_CHANGED";
+        case   SUPPORT_IMMEDIATE_MEASUREMENT_ONLY : return "SUPPORT_IMMEDIATE_MEASUREMENT_ONLY";
+        case   MEASUREMENT_TYPE_NOT_SUPPORT : return "MEASUREMENT_TYPE_NOT_SUPPORT"; 
+        case   MEASUREMENT_CAN_NOT_EXECUTED_IN_PARALLEL : return "MEASUREMENT_CAN_NOT_EXECUTED_IN_PARALLEL";
+        case   MEASUREMENT_REQUEST_IGNORED : return "MEASUREMENT_REQUEST_IGNORED";
+        case   CANNOT_SET_MEASUREMENT_PARAM_WHEN_ACTIVATED : return "CANNOT_SET_MEASUREMENT_PARAM_WHEN_ACTIVATED";
+        case   CANNOT_SET_CHANNEL_THAT_IS_NOT_SUPPORTED : return "CANNOT_SET_CHANNEL_THAT_IS_NOT_SUPPORTED";
+        case   STATUS_BAD_KEY_PARAM : return "STATUS_BAD_KEY_PARAM";
+        case   STATUS_RX_MIC_FAIL : return "STATUS_RX_MIC_FAIL";
+        case   STATUS_FIRST_PRIMARY_SITE_SET : return "STATUS_FIRST_PRIMARY_SITE_SET";
+        case   POWER_SAVE_802_11_SUCCESS  : return "POWER_SAVE_802_11_SUCCESS";
+        case   POWER_SAVE_802_11_FAIL : return "POWER_SAVE_802_11_FAIL";
+        case   POWER_SAVE_802_11_NOT_ALLOWED : return "POWER_SAVE_802_11_NOT_ALLOWED";
+        case   PENDING : return "PENDING";
+        case   SEND_COMPLETE_SUCCESS : return "SEND_COMPLETE_SUCCESS";
+        case   SEND_COMPLETE_RETRY_EXCEEDED : return "SEND_COMPLETE_RETRY_EXCEEDED";
+        case   SEND_COMPLETE_LIFETIME_EXCEEDED : return "SEND_COMPLETE_LIFETIME_EXCEEDED";
+        case   SEND_COMPLETE_NO_LINK : return "SEND_COMPLETE_NO_LINK";
+        case   SEND_COMPLETE_MAC_CRASHED : return "SEND_COMPLETE_MAC_CRASHED";
+        case   POWER_SAVE_802_11_IS_CURRENT : return "POWER_SAVE_802_11_IS_CURRENT";
+        case   SEND_PACKET_XFER_DONE : return "SEND_PACKET_XFER_DONE";
+        case   SEND_PACKET_SUCCESS : return "SEND_PACKET_SUCCESS";
+        case   SEND_PACKET_PENDING : return "SEND_PACKET_PENDING";
+        case   SEND_PACKET_BUSY : return "SEND_PACKET_BUSY";
+        case   SEND_PACKET_ERROR : return "SEND_PACKET_ERROR";
+        case   TNETWIF_NONE : return "TNETWIF_NONE";
+        case   TNETWIF_OK : return "TNETWIF_OK";
+        case   TNETWIF_COMPLETE : return "TNETWIF_COMPLETE";
+        case   TNETWIF_PENDING : return "TNETWIF_PENDING";
+        case   TNETWIF_ERROR : return "TNETWIF_ERROR";
+        case   TNETWIF_MORE : return "TNETWIF_MORE";
+        default:
+            WLAN_OS_REPORT(("%s No matching for TI_STATUS = %d , please add me !!!\n",__FUNCTION__ ,status));
+            return "UnKnown";
+    }
+    
+}
+
+
+
+#if UTIL_DEBUG_PROFILE
+profileInfo_t profileInfo;
+profileInfo_t* pProfileInfo = &profileInfo;
+
+void util_initProfile(void)
+{
+    pProfileInfo->currentInfoElement = 0;
+    pProfileInfo->overlap = FALSE;
+}
+
+
+void util_recordProfile(UINT32 theTIWlanModuleLogName,
+                        UINT32 theEvent,
+                        UINT32 theParam_1,
+                        UINT32 theParam_2)
+{
+    pProfileInfo->profileInfoElement[pProfileInfo->currentInfoElement].timeStamp = os_timeStampUs(NULL);
+    pProfileInfo->profileInfoElement[pProfileInfo->currentInfoElement].TIWlanModuleLogName = theTIWlanModuleLogName;
+    pProfileInfo->profileInfoElement[pProfileInfo->currentInfoElement].Event = theEvent;
+    pProfileInfo->profileInfoElement[pProfileInfo->currentInfoElement].Param_1 = theParam_1;
+    pProfileInfo->profileInfoElement[pProfileInfo->currentInfoElement].Param_2 = theParam_2;
+
+    ++pProfileInfo->currentInfoElement;
+    if (pProfileInfo->currentInfoElement == PROFILE_BUFFER_SIZE)
+    {
+        pProfileInfo->overlap = TRUE;
+        pProfileInfo->currentInfoElement = 0;
+    }
+}
+
+void util_printProfile(void)
+{
+    UINT32 index;
+    UINT32 count;
+    UINT32 elemCount;
+
+    if (pProfileInfo->overlap == TRUE)
+    {
+        elemCount = PROFILE_BUFFER_SIZE;
+        index = pProfileInfo->currentInfoElement;
+    }
+    else
+    {
+        elemCount = pProfileInfo->currentInfoElement;
+        index = 0;
+    }
+
+    WLAN_OS_REPORT(("\nPrint profiling log (%d elements):\n",elemCount));
+
+    for (count = 0 ; count < elemCount ; ++count)
+    {
+        WLAN_OS_REPORT(("%d  - %d.%06d   0x%04X - 0x%08X: 0x%08X 0x%08X\n",
+                        index,
+                        pProfileInfo->profileInfoElement[index].timeStamp/1000000,
+                        pProfileInfo->profileInfoElement[index].timeStamp%1000000,
+                        pProfileInfo->profileInfoElement[index].TIWlanModuleLogName,
+                        pProfileInfo->profileInfoElement[index].Event,
+                        pProfileInfo->profileInfoElement[index].Param_1,
+                        pProfileInfo->profileInfoElement[index].Param_2));
+        ++index;
+    }
+
+    WLAN_OS_REPORT(("\n\n"));
+
+    util_initProfile();
+}
+
+
+
+#endif /* UTIL_DEBUG_PROFILE */
+
+
diff --git a/sta_dk_4_0_4_32/common/src/utils/utils.h b/sta_dk_4_0_4_32/common/src/utils/utils.h
new file mode 100644 (file)
index 0000000..6b6163c
--- /dev/null
@@ -0,0 +1,290 @@
+/** \file utils.h
+ *  \brief utils API
+ *
+ *  \see utils.c
+ */
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/****************************************************************************/
+/*                                                                          */
+/*    MODULE:   utils.h                                                     */
+/*    PURPOSE:  utilities API, contains some utilites function to be used   */
+/*              by the COre & HAL                                           */
+/*                                                                          */
+/***************************************************************************/
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+#include "osTIType.h"
+#include "commonTypes.h"
+#include "memMngrEx.h"
+#include "802_11Defs.h"
+
+/* TODO: replace the following macros with a faster code. */
+#define MAC_COPY(pOsContext,pDstMac,pSrcMac)         \
+        os_memoryCopy(pOsContext, (void *)((pDstMac)->addr), (void *)((pSrcMac)->addr), MAC_ADDR_LEN)
+#define MAC_EQUAL(pDstMac,pSrcMac)                   \
+        ((pDstMac)->addr[0] == (pSrcMac)->addr[0] && \
+         (pDstMac)->addr[1] == (pSrcMac)->addr[1] && \
+         (pDstMac)->addr[2] == (pSrcMac)->addr[2] && \
+         (pDstMac)->addr[3] == (pSrcMac)->addr[3] && \
+         (pDstMac)->addr[4] == (pSrcMac)->addr[4] && \
+         (pDstMac)->addr[5] == (pSrcMac)->addr[5])
+#define MAC_BROADCAST(pMac)                          \
+         ((pMac)->addr[0] == 0xFF &&                 \
+          (pMac)->addr[1] == 0xFF &&                 \
+          (pMac)->addr[2] == 0xFF &&                 \
+          (pMac)->addr[3] == 0xFF &&                 \
+          (pMac)->addr[4] == 0xFF &&                 \
+          (pMac)->addr[5] == 0xFF)
+#define MAC_MULTICAST(pMac) ((pMac)->addr[0] & 0x01)
+#define MAC_NULL(pMac)                               \
+        ((pMac)->addr[0] == 0x00 &&                  \
+         (pMac)->addr[1] == 0x00 &&                  \
+         (pMac)->addr[2] == 0x00 &&                  \
+         (pMac)->addr[3] == 0x00 &&                  \
+         (pMac)->addr[4] == 0x00 &&                  \
+         (pMac)->addr[5] == 0x00)
+
+
+#ifndef offsetof
+#define offsetof(type, field)    ((unsigned int) (&(((type *)(0))->field)))
+#endif
+
+
+/* NOTE - Network byte order is BIG endian. */
+
+static __inline unsigned short int __byte_swap_16 (unsigned short int __bsx) {
+  return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
+}
+
+static __inline unsigned int __byte_swap_32 (unsigned int __bsx) {
+  return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |
+          (((__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24));
+}
+
+
+#ifdef __BYTE_ORDER_BIG_ENDIAN
+
+
+#define wlan_ntohl(x)       (x)
+#define wlan_ntohs(x)       (x)
+#define wlan_htonl(x)       (x)
+#define wlan_htons(x)       (x)
+
+#define ENDIAN_HANDLE_WORD(x)   __byte_swap_16 (x)
+#define ENDIAN_HANDLE_LONG(x)   __byte_swap_32 (x)
+
+/* int64 handling macros */
+#define INT64_LOWER(x) *(((UINT32*)&(x))+1)
+#define INT64_HIGHER(x) *((UINT32*)&(x))
+
+#else
+
+#ifdef __BYTE_ORDER_LITTLE_ENDIAN
+
+#define wlan_ntohl(x)       __byte_swap_32 (x)
+#define wlan_ntohs(x)       __byte_swap_16 (x)
+#define wlan_htonl(x)       __byte_swap_32 (x)
+#define wlan_htons(x)       __byte_swap_16 (x)
+
+#define ENDIAN_HANDLE_WORD(x)   (x)
+#define ENDIAN_HANDLE_LONG(x)   (x)
+
+/* int64 handling macros */
+#define INT64_HIGHER(x) *(((UINT32*)&(x))+1)
+#define INT64_LOWER(x) *((UINT32*)&(x))
+
+/*#define COPY_UNALIGNED_WORD(srcWord, destWord)        ((UINT8 *)&destWord)[0] = ((UINT8 *)&srcWord)[0]; ((UINT8 *)&destWord)[1] = ((UINT8 *)&srcWord)[1];
+#define COPY_UNALIGNED_LONG(srcLong, destLong)      ((UINT8 *)&destWord)[0] = ((UINT8 *)&srcWord)[0]; ((UINT8 *)&destWord)[1] = ((UINT8 *)&srcWord)[1];((UINT8 *)&destWord)[2] = ((UINT8 *)&srcWord)[2]; ((UINT8 *)&destWord)[3] = ((UINT8 *)&srcWord)[3];
+*/
+#else
+
+#error "MUST define byte order (BIG/LITTLE ENDIAN)"
+
+#endif
+#endif
+
+#define COPY_UNALIGNED_WORD(pDest, pSrc)           {((UINT8 *)(pDest))[0] = ((UINT8 *)(pSrc))[0];\
+                                                    ((UINT8 *)(pDest))[1] = ((UINT8 *)(pSrc))[1];}
+
+#define COPY_UNALIGNED_LONG(pDest, pSrc)           {((UINT8 *)(pDest))[0] = ((UINT8 *)(pSrc))[0];\
+                                                    ((UINT8 *)(pDest))[1] = ((UINT8 *)(pSrc))[1];\
+                                                    ((UINT8 *)(pDest))[2] = ((UINT8 *)(pSrc))[2];\
+                                                    ((UINT8 *)(pDest))[3] = ((UINT8 *)(pSrc))[3];}
+
+void utils_nullMemoryFree(void* pOsContext,
+                          void* pMemPtr,
+                          unsigned long size);
+
+void utils_nullTimerDestroy(void* pOsContext,
+                         void* pTimerHandle);
+
+#define MAX(a,b)  (((a) > (b)) ? (a) : (b))
+#define MIN(a,b)  (((a) < (b)) ? (a) : (b))
+
+#ifndef min
+# define min MIN
+#endif
+
+#ifndef max
+# define max MAX
+#endif
+
+
+#define MAKE_BASIC_RATE(rate)                           rate |= 0x80
+
+#define IS_BASIC_RATE(rate)                             rate & 0x80
+
+#define IS_ACTIVE_RATE(rate)                            !(rate & 0x80)
+
+rate_e networkToHostRate(UINT8 rate);
+
+UINT8 hostToNetworkRate(rate_e rate);
+
+
+UINT8 getMaxBasicRatefromString(UINT8 *ratesString, UINT8 len, UINT8 maxRate);
+
+rate_e getMaxRatefromBitmap(UINT32 ratesBitMap);
+
+UINT8 getMaxActiveRatefromString(UINT8 *ratesString, UINT8 len, UINT8 maxRate);
+
+TI_STATUS validateNetworkRate(UINT8 rate);
+
+UINT8 hostToUtilityRate(rate_e rate);
+
+rate_e utilityToHostRate(UINT8 rate);
+
+UINT8 hostRateToNumber(rate_e rate);
+rate_e  RateNumberToHost(UINT8 rateIn);
+
+void bitMapToNetworkStringRates(UINT32 suppRatesBitMap, UINT32 basicRatesBitMap,
+                                UINT8 *string, UINT32 *len,
+                                UINT32 *firstOFDMrateLoc);
+
+void networkStringToBitMapSuppRates(UINT32 *bitMap, UINT8 *string, UINT32 len);
+void networkStringToBitMapBasicRates(UINT32 *bitMap, UINT8 *string, UINT32 len);
+
+UINT32 translateBasicRateValueToMask(UINT32 value, BOOL dot11a);
+UINT32 translateSupportedRateValueToMask(UINT32 value, BOOL dot11a);
+void validateRates(UINT32 *pBasicRateMask, UINT32 *pSuppRateMask, UINT32 *pTxRate, modulationType_e *modulation, BOOL dot11a);
+rate_e calculateMaxSupportedRate(UINT32 *pSuppRateMask);
+rate_e findMaxActiveRate(UINT32 ratesBitMap);
+void   validateRatesVsBand(UINT32 *supportedMask, UINT32 *basicMask, BOOL dot11a);
+
+BOOL utils_isAnySSID(ssid_t *pSsid);
+BOOL utils_isJunkSSID(ssid_t *pSsid);
+BOOL utils_isIESSID_Broadcast(dot11_SSID_t *pIESsid); /* routinte to check for Junk SSID in SSID IE */
+void    MsduContentDump (mem_MSDU_T* pMsdu, char *str);
+
+
+void HexDumpData (UINT8 *data, int datalen);
+void msduContentDump (mem_MSDU_T* pMsdu, char *str);
+
+
+BOOL parseIeBuffer(TI_HANDLE hOs, UINT8 *pIeBuffer, UINT16 length, UINT8 desiredIeId, UINT8 **pDesiredIe, UINT8 *pMatchBuffer, UINT8 matchBufferLen);
+void TiWlanIntToStr(UINT8 number , char *string, UINT8 radix);
+
+UINT32 getBasicRateMaskForSpecialBGchannel(void);
+UINT32 getSupportedRateMaskForSpecialBGchannel(void);
+
+int ConvertHwBitRateToAppRate(UINT32 HwRate,rate_e *AppRate);
+
+
+void getMaxRate(UINT32 ratesBitMap, rate_e *rate, modulationType_e *modulation, dot11mode_e operationMode);
+void getMinRate(UINT32 ratesBitMap, rate_e *rate, modulationType_e *modulation, dot11mode_e operationMode);
+
+UINT32 reminder64( UINT64 dividee, UINT32 divider );
+int ConvertHwBitRateToAppRate(UINT32 HwRate,rate_e *AppRate);
+int ConvertAppRatesToBitmap(UINT16 AppRatesBitmap, UINT32 *HwRatesBitmap);
+int ConvertAppRateToHwBitMapRate(UINT32 AppRate, UINT32 *HwRate);
+void convert_hex_to_string(tiUINT8 *pBuffer, char *pString, tiUINT8 Size);
+rate_e ConvertHwRateToDrvRate(UINT8 HwRate, BOOL bOFDMMudulation);
+UINT8 ConvertDrvRate2HwRate(rate_e eRate);
+RateIndex_e rateNumberToIndex(UINT8 uRate);
+
+/* returns TI_STATUS as string */
+char* convertTI_STATUS_toString(TI_STATUS status);
+
+/*
+++++++++ Profiling code ++++++++
+*/
+#define UTIL_DEBUG_PROFILE (0)
+
+void convert_hex_to_string(tiUINT8 *pBuffer, char *pString, tiUINT8 Size);
+
+/* 
+* Small macro to convert Dbm units into Dbm/10 units. This macro is important
+* in order to avoid over-flow of Dbm units bigger than 25
+*/
+#define DBM2DBMDIV10(uTxPower) \
+       ((uTxPower) > (MAX_TX_POWER / DBM_TO_TX_POWER_FACTOR) ? \
+               MAX_TX_POWER : (uTxPower) * DBM_TO_TX_POWER_FACTOR)             
+
+#if UTIL_DEBUG_PROFILE
+typedef struct
+{
+    UINT32 TIWlanModuleLogName;
+    UINT32 Event;
+    UINT32 Param_1;
+    UINT32 Param_2;
+    UINT32 timeStamp;
+} profileInfoElement_t;
+
+enum
+{
+    PROFILE_BUFFER_SIZE = 10000
+};
+
+typedef struct
+{
+    profileInfoElement_t profileInfoElement[PROFILE_BUFFER_SIZE];
+    UINT32 currentInfoElement;
+    BOOL overlap;
+} profileInfo_t;
+
+void util_initProfile(void);
+
+void util_recordProfile(UINT32 theTIWlanModuleLogName,
+                        UINT32 theEvent,
+                        UINT32 theParam_1,
+                        UINT32 theParam_2);
+
+void util_printProfile(void);
+#endif /* UTIL_DEBUG_PROFILE */
+
+
+#endif /* __UTILS_H__ */
diff --git a/sta_dk_4_0_4_32/drv_sources.inc b/sta_dk_4_0_4_32/drv_sources.inc
new file mode 100644 (file)
index 0000000..a44da8f
--- /dev/null
@@ -0,0 +1,314 @@
+#start of TNETW_INCS#    do not remove or change this comment
+TNETW_INCS = \
+    $(COMMON)/inc \
+    $(COMSRC)/inc \
+    $(COMSRC)/utils \
+    $(HALSRC)/hal/inc \
+    $(HALSRC)/hal/TnetwServices \
+    $(COMSRC)/TNETW_Driver/Export_Inc \
+    $(COMSRC)/TNETW_Driver/Data_Srv/inc \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/inc \
+    $(COMSRC)/TNETW_Driver/Ctrl/Export_Inc \
+    $(COMSRC)/TNETW_Driver/MacServices/inc \
+    $(COMSRC)/TNETW_Driver \
+    $(COMSRC)/TNETW_Driver/MacServices/Export_Inc \
+    $(COMSRC)/TNETW_Driver/MacServices/src/ScanServer \
+    $(COMSRC)/TNETW_Driver/MacServices/src/PowerSaveServer \
+    $(COMSRC)/TNETW_Driver/MacServices/src/MeasurementSRV \
+    $(COMSRC)/TNETW_Driver/TNETWIF/Export_Inc \
+    $(COMSRC)/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk \
+    $(COMSRC)/TNETW_Driver/TNETWIF/Inc 
+
+ifeq ($(PLATFORM),1251)
+    TNETW_INCS += \
+        $(HALSRC)/hal/TnetwServices/TNETW1251
+else
+    ifeq ($(PLATFORM),1150)
+        TNETW_INCS += \
+            $(HALSRC)/hal/TnetwServices/TNETW1150 
+    else
+        TNETW_INCS += \
+            $(HALSRC)/hal/TnetwServices/TNETW1130 
+    endif
+endif
+    
+TNETW_INCS += \
+    $(HALSRC)/hal/hl_data \
+    $(HALSRC)/hal/hl_ctrl \
+    $(HALSRC)/hal/hw_ctrl \
+    $(HALSRC)/hal/security \
+    $(HALSRC)/hal/Export_Inc \
+    $(HALSRC)/hal/FirmwareApi \
+    $(HALSRC)/BusAccess/Shm_Common \
+    $(HALSRC)/BusAccess/Export_Inc 
+
+ifeq ($(EXC),y)
+#end of TNETW_INCS_EXC#    do not remove or change this comment
+endif
+
+#end of TNETW_INCS#    do not remove or change this comment
+
+
+#end of GWSI_INCS#     do not remove or change this comment
+
+
+#start of CORE_INCS#     do not remove or change this comment
+CORE_INCS = \
+    $(COMSRC)/core/inc \
+    $(COMSRC)/core/ExpInc \
+    $(COMSRC)/core/data_ctrl/Tx \
+    $(COMSRC)/core/data_ctrl/Ctrl \
+    $(COMSRC)/core/data_ctrl/Ctrl/TrafficMonitor \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X \
+    $(COMSRC)/core/data_ctrl/Rx \
+    $(COMSRC)/core/Core_Adapt/Export_Inc \
+    $(COMSRC)/core/EvHandler \
+    $(COMSRC)/core/sme/Inc \
+    $(COMSRC)/core/sme/smeSm/ \
+    $(COMSRC)/core/sme/siteMgr \
+    $(COMSRC)/core/sme/configMgr \
+    $(COMSRC)/core/sme/conn \
+    $(COMSRC)/core/sme/HealthMonitor \
+    $(COMSRC)/core/srv/inc \
+    $(COMSRC)/core/srv/scanSrv \
+    $(COMSRC)/core/srv/scr \
+    $(COMSRC)/core/rsn \
+    $(COMSRC)/core/rsn/inc \
+    $(COMSRC)/core/mlme \
+    $(COMSRC)/core/mlme/Assoc \
+    $(COMSRC)/core/mlme/Auth/open \
+    $(COMSRC)/core/mlme/Auth/shared \
+    $(COMSRC)/Management/QOS/Inc/ \
+    $(COMSRC)/Management/Roaming/Inc \
+    $(COMSRC)/core/NetworkCtrl/inc \
+    $(COMSRC)/Management/AirLink/Measurement \
+    $(COMSRC)/Management/AirLink/Measurement/dot11h \
+    $(COMSRC)/Management/AirLink/inc \
+    $(COMSRC)/Management/scan/inc \
+    $(COMSRC)/Management/SoftGemini/inc \
+    $(COMSRC)/Management/scan/scanCncn \
+    $(COMSRC)/Management/SoftGemini/src \
+    $(COMSRC)/core/NetworkCtrl/RegulatoryDomain \
+    $(COMSRC)/Management/PowerMgr/ \
+    $(COMSRC)/Management/RecoveryMgr/ \
+    $(COMSRC)/core/NetworkCtrl/QOS \
+    $(COMSRC)/Application/inc \
+    $(COMSRC)/Application/ExpInc \
+    $(COMSRC)/Application/ScanMngr \
+    $(COMSRC)/Management/apConn \
+    $(COMSRC)/core/currBss \
+    $(COMSRC)/Management/scan/inc \
+    $(DBG_MDL)/inc
+
+#end of CORE_INCS_EXC#   do not remove or change this comment
+
+#end of CORE_INCS#   do not remove or change this comment
+
+
+#start of UTIL_SRCS#    do not remove or change this comment
+UTIL_SRCS = \
+    $(COMSRC)/utils/fsm.c \
+    $(COMSRC)/utils/nrfsm.c \
+    $(COMSRC)/utils/report.c \
+    $(COMSRC)/utils/utils.c \
+    $(COMSRC)/utils/bufferPool.c \
+    $(COMSRC)/utils/memMngrEx.c \
+#end of UTIL_SRCS#      do not remove or change this comment
+
+
+#start of TNETW_SRCS#   do not remove or change this comment
+TNETW_SRCS = \
+    $(COMSRC)/TNETW_Driver/MacServices/src/MacServices.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/ScanServer/ScanSrv.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/ScanServer/ScanSrvSM.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrv.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/PowerSaveServer/PowerSrvSM.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrv.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/MeasurementSRV/MeasurementSrvSM.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/MeasurementSRV/measurementSrvDbgPrint.c \
+    $(COMSRC)/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver.c \
+    $(COMSRC)/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/TNETW_Driver_Tx.c \
+    $(COMSRC)/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.c \
+    $(COMSRC)/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueue.c \
+    $(COMSRC)/TNETW_Driver/Data_Srv/Tx_HW_Queue/txHwQueueCalc.c \
+    $(COMSRC)/TNETW_Driver/Data_Srv/Tx_Ctrl_Blk/txCtrlBlk.c \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/Cmd_MBox/CmdMBox.c \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/Tx_Result/txResult.c \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/Tx_Xfer/Slave_Dbl_Buf/txXfer.c \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/FwEvent/FwEvent.c \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/Rx_Xfer/RxXfer.c \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/EventMbox/eventMbox.c \
+    $(COMSRC)/TNETW_Driver/MacServices/src/PowerAuthorization/PowerAuthorization.c \
+    $(COMSRC)/TNETW_Driver/TNETWIF/TNETWIF.c \
+    $(COMSRC)/TNETW_Driver/TNETWIF/ELP_Controller/ElpCtrl.c \
+    $(COMSRC)/TNETW_Driver/TNETWIF/BusTxn/whalHwAccess.c \
+    $(COMSRC)/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb.c \
+    $(COMSRC)/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArbSM.c \
+    $(COMSRC)/TNETW_Driver/TNETWIF/TNETWArbiter/TNETWArb_buffer.c \
+    $(HALSRC)/hal/hl_ctrl/whalCtrl.c \
+    $(HALSRC)/hal/hl_ctrl/whalParams.c \
+    $(HALSRC)/hal/hl_data/whalDefrag.c \
+    $(HALSRC)/hal/hl_data/whalEndpntEnt.c \
+    $(HALSRC)/BusAccess/Shm_Common/shmBus.c \
+    $(HALSRC)/BusAccess/Shm_Common/shmFwCtrl.c \
+    $(HALSRC)/BusAccess/Shm_Common/shmDebug.c \
+    $(HALSRC)/BusAccess/Shm_Common/shmUtils.c \
+    $(HALSRC)/hal/hw_ctrl/whalHwCtrl.c \
+    $(HALSRC)/BusAccess/Shm_Common/whalHwEeprom.c \
+    $(HALSRC)/hal/hw_ctrl/whalHwMboxConfig.c \
+    $(HALSRC)/hal/hw_ctrl/whalHwMboxCmd.c \
+    $(HALSRC)/hal/hw_ctrl/whalHwMboxCmdBit.c \
+    $(HALSRC)/hal/hl_ctrl/whalRecovery.c \
+    $(HALSRC)/hal/hl_ctrl/whalRadio.c \
+    $(HALSRC)/hal/hl_ctrl/whalDebug.c \
+    $(HALSRC)/hal/security/whalSecurity.c \
+    $(HALSRC)/hal/security/whalWep.c \
+    $(HALSRC)/hal/security/whalWpa.c
+
+ifndef GWSI_SA
+    TNETW_SRCS += \
+        $(COMSRC)/TNETW_Driver/FW_Transfer/HwInit/HwInit.c \
+        $(COMSRC)/TNETW_Driver/Ctrl/RecoverCtrl/recoveryCtrl.c
+endif
+
+ifeq ($(WSPI),y)
+    TNETW_SRCS += \
+        $(COMSRC)/TNETW_Driver/TNETWIF/BusTxn/wspi.c \
+        $(COMSRC)/TNETW_Driver/TNETWIF/BusTxn/tiwlanspi.c
+endif
+
+ifeq ($(DEBUG),y)
+    TNETW_SRCS += \
+        $(HALSRC)/BusAccess/Shm_Common/whalTrace.c \
+        $(COMSRC)/TNETW_Driver/FW_Transfer/DebugTrace_Xfer/DebugTraceXfer.c
+endif
+
+#end of TNETW_SRCS_EXC#   do not remove or change this comment
+
+#end of TNETW_SRCS#    do not remove or change this comment
+
+#end of GWSI_SRCS#    do not remove or change this comment
+
+#start of CORE_SRCS#   do not remove or change this comment
+CORE_SRCS = \
+    $(COMSRC)/core/data_ctrl/Tx/MsduList.c \
+    $(COMSRC)/core/data_ctrl/Tx/tx.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/Ctrl.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/Clsfr.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X/Concatenator.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X/DeConcatenator.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X/ackEmulDb.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X/ackEmulUtil.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X/fourX.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/4X/fourXManager.c \
+    $(COMSRC)/Management/PowerMgr/PowerMgr.c \
+    $(COMSRC)/Management/PowerMgr/PowerMgrDbgPrint.c \
+    $(COMSRC)/Management/RecoveryMgr/recoveryMgr.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/RateAdaptation.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/TrafficMonitor/GeneralUtil.c \
+    $(COMSRC)/core/data_ctrl/Ctrl/TrafficMonitor/TrafficMonitor.c \
+    $(COMSRC)/core/data_ctrl/Rx/rx.c \
+    $(COMSRC)/core/sme/conn/conn.c \
+    $(COMSRC)/core/sme/conn/connIbss.c \
+    $(COMSRC)/core/sme/conn/connInfra.c \
+    $(COMSRC)/core/sme/configMgr/configMgr.c \
+    $(COMSRC)/core/sme/smeSm/smeSmApi.c \
+    $(COMSRC)/core/sme/smeSm/smeSm.c \
+    $(COMSRC)/core/sme/HealthMonitor/healthMonitor.c \
+    $(COMSRC)/core/sme/siteMgr/siteMgr.c \
+    $(COMSRC)/core/sme/siteMgr/siteHash.c \
+    $(COMSRC)/core/sme/siteMgr/select.c \
+    $(COMSRC)/core/sme/siteMgr/templates.c \
+    $(COMSRC)/core/mlme/mlmeBuilder.c \
+    $(COMSRC)/core/mlme/mlmeParser.c \
+    $(COMSRC)/core/mlme/mlmeSm.c \
+    $(COMSRC)/core/mlme/Assoc/assocSM.c \
+    $(COMSRC)/core/mlme/Auth/authSm.c \
+    $(COMSRC)/core/mlme/Auth/open/openAuthSm.c \
+    $(COMSRC)/core/mlme/Auth/shared/sharedKeyAuthSm.c \
+    $(COMSRC)/core/rsn/rsn.c \
+    $(COMSRC)/core/rsn/mainSecSm.c \
+    $(COMSRC)/core/rsn/mainSecNull.c \
+    $(COMSRC)/core/rsn/mainSecKeysOnly.c \
+    $(COMSRC)/core/rsn/admCtrl.c \
+    $(COMSRC)/core/rsn/admCtrlWep.c \
+    $(COMSRC)/core/rsn/admCtrlNone.c \
+    $(COMSRC)/core/rsn/admCtrlWpa.c \
+    $(COMSRC)/core/rsn/admCtrlWpa2.c \
+    $(COMSRC)/core/srv/scr/scr.c \
+    $(COMSRC)/core/EvHandler/EvHandler.c \
+    $(COMSRC)/Management/AirLink/SwitchChannel/SwitchChannel.c \
+    $(COMSRC)/Management/AirLink/Measurement/measurementMgr.c \
+    $(COMSRC)/Management/AirLink/Measurement/measurementMgrSM.c \
+    $(COMSRC)/Management/AirLink/Measurement/dot11h/spectrumMngmntMgr.c \
+    $(COMSRC)/Management/AirLink/Measurement/requestHandler.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncn.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncnAppSM.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncnDrvSM.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncnOidSM.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncnRoamingContSM.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncnRoamingImmedSM.c \
+    $(COMSRC)/Management/scan/scanCncn/ScanCncnAppApi.c \
+    $(COMSRC)/Management/apConn/apConn.c \
+    $(COMSRC)/Management/SoftGemini/src/SoftGemini.c \
+    $(COMSRC)/core/NetworkCtrl/RegulatoryDomain/regulatoryDomain.c \
+    $(COMSRC)/core/rsn/keyDerive.c \
+    $(COMSRC)/core/rsn/keyDeriveWep.c \
+    $(COMSRC)/core/rsn/keyDeriveTkip.c \
+    $(COMSRC)/core/rsn/keyDeriveAes.c \
+    $(COMSRC)/core/rsn/keyParser.c \
+    $(COMSRC)/core/rsn/broadcastKeySM.c \
+    $(COMSRC)/core/rsn/unicastKeySM.c \
+    $(COMSRC)/core/rsn/broadcastKey802_1x.c \
+    $(COMSRC)/core/rsn/unicastKey802_1x.c \
+    $(COMSRC)/core/rsn/broadcastKeyNone.c \
+    $(COMSRC)/core/rsn/unicastKeyNone.c \
+    $(COMSRC)/core/rsn/keyParserExternal.c \
+    $(COMSRC)/core/rsn/keyParserWep.c \
+    $(COMSRC)/core/rsn/mainKeysSm.c \
+    $(COMSRC)/core/currBss/currBss.c \
+    $(COMSRC)/Application/ScanMngr/scanMngr.c \
+    $(COMSRC)/Application/Roaming/roamingMngr.c \
+    $(COMSRC)/core/Core_Adapt/Core_AdaptTx.c \
+    $(COMSRC)/Management/QOS/qosMngr.c \
+    $(COMSRC)/Management/QOS/trafficAdmControl.c
+
+ifeq ($(SUPPORT_4X),y)
+    CORE_SRCS += \
+        $(COMSRC)/core/data_ctrl/Ctrl/4X/Concatenator.c \
+        $(COMSRC)/core/data_ctrl/Ctrl/4X/DeConcatenator.c \
+        $(COMSRC)/core/data_ctrl/Ctrl/4X/ackEmulDb.c \
+        $(COMSRC)/core/data_ctrl/Ctrl/4X/ackEmulUtil.c \
+        $(COMSRC)/core/data_ctrl/Ctrl/4X/fourX.c \
+        $(COMSRC)/core/data_ctrl/Ctrl/4X/fourXManager.c
+endif
+
+#end of CORE_SRCS_EXC#   do not remove or change this comment
+
+#end of CORE_SRCS#   do not remove or change this comment
+
+
+ifdef GWSI_SA
+    DK_INCS = \
+        $(TNETW_INCS) \
+        $(GWSI_INCS)
+
+    DK_SRCS = \
+        $(GWSI_SRCS) \
+        $(TNETW_SRCS) \
+        $(UTIL_SRCS)
+
+else
+    DK_INCS = \
+        $(TNETW_INCS) \
+        $(CORE_INCS)
+
+    DK_SRCS = \
+        $(CORE_SRCS) \
+        $(TNETW_SRCS)
+endif
+
+
+
+DK_OBJS = $(patsubst %.c, %.o, $(DK_SRCS) $(UTIL_SRCS))
+
diff --git a/sta_dk_4_0_4_32/os_sources.inc b/sta_dk_4_0_4_32/os_sources.inc
new file mode 100644 (file)
index 0000000..e49f454
--- /dev/null
@@ -0,0 +1,105 @@
+
+#start of OS_DK_INCS_FILES#   do not remove or change this comment
+OS_DK_INCS_FILES = \
+    $(COMSRC)/inc/802_11Defs.h \
+    $(COMSRC)/inc/Ethernet.h \
+    $(COMSRC)/inc/paramIn.h \
+    $(COMMON)/inc/srcApi.h \
+    $(COMMON)/inc/TI_IPC_Api.h \
+    $(COMMON)/inc/memMngrEx.h \
+    $(COMMON)/inc/paramOut.h \
+    $(COMMON)/inc/osDot11.h \
+    $(COMMON)/inc/tiwlnif.h \
+    $(COMMON)/inc/ratesTypes.h \
+    $(COMMON)/inc/scanTypes.h \
+    $(COMMON)/inc/bssTypes.h \
+    $(COMMON)/inc/roamingMngrTypes.h \
+    $(COMMON)/inc/paramMng.h \
+    $(COMMON)/inc/commonTypes.h \
+    $(COMMON)/inc/coreDefaultParams.h \
+    $(COMMON)/inc/tiQosTypes.h \
+    $(COMMON)/inc/whalDefaultParams.h \
+    $(COMMON)/inc/TI_Results.h \
+    $(COMMON)/inc/tiioctl.h \
+    $(COMMON)/inc/wspVer.h \
+    $(COMSRC)/core/inc/mlmeApi.h \
+    $(COMSRC)/core/sme/configMgr/configMgr.h \
+    $(COMSRC)/core/sme/HealthMonitor/healthMonitor.h \
+    $(COMSRC)/utils/fsm.h \
+    $(COMSRC)/utils/report.h \
+    $(COMSRC)/utils/utils.h \
+    $(COMSRC)/driver_bypass/driver_bypass.h \
+    $(COMSRC)/TNETW_Driver/Export_Inc/TNETW_Driver_types.h \
+    $(COMSRC)/TNETW_Driver/Export_Inc/TNETW_Driver_api.h \
+    $(COMSRC)/TNETW_Driver/Ctrl/Export_Inc/CmdQueue_api.h \
+    $(COMSRC)/TNETW_Driver/MacServices/Export_Inc/MacServices_api.h \
+    $(COMSRC)/TNETW_Driver/MacServices/Export_Inc/measurementTypes.h \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/inc/rxXfer_api.h \
+    $(COMSRC)/BusAccess/Export_Inc/whalBus_Defs.h \
+    $(COMSRC)/BusAccess/Export_Inc/whalBus_Api.h \
+    $(COMSRC)/hal/inc/whalCommon.h \
+    $(COMSRC)/hal/FirmwareApi/public_descriptors.h \
+    $(COMSRC)/hal/FirmwareApi/public_infoele.h \
+    $(COMSRC)/hal/FirmwareApi/public_types.h \
+    $(COMSRC)/hal/FirmwareApi/public_host_int.h \
+    $(COMSRC)/hal/FirmwareApi/public_radio.h \
+    $(COMSRC)/hal/FirmwareApi/public_commands.h \
+    $(COMSRC)/hal/FirmwareApi/public_event_mbox.h \
+    $(COMSRC)/hal/FirmwareApi/whalHwDefs.h \
+    $(COMSRC)/hal/TnetwServices/tnetwCommon.h \
+    $(COMSRC)/hal/TnetwServices/TNETW1251/whalHwRegs.h \
+    $(COMSRC)/hal/TnetwServices/TNETW1251/TnetwRegisters.h \
+    $(COMSRC)/hal/Export_Inc/whalCtrl_api.h \
+    $(COMSRC)/hal/Export_Inc/whalCtrl_prm.h \
+    $(COMSRC)/hal/hw_ctrl/whalHwMboxCmdBit.h \
+    $(COMSRC)/hal/hw_ctrl/whalHwMboxCmd.h \
+    $(COMSRC)/hal/hw_ctrl/whalHwMboxConfig.h \
+    $(COMSRC)/hal/hw_ctrl/whalHwCtrl.h \
+    $(COMSRC)/hal/hl_ctrl/whalCtrl.h \
+    $(COMSRC)/hal/hl_ctrl/whalParams.h
+
+#start of OS_DK_INCS_FILES_CCX#   do not remove or change this comment
+ifeq ($(CCX),y)
+    OS_DK_INCS_FILES_CCX = \
+        $(COMMON)/inc/CCX/paramOutCcx.h \
+        $(COMMON)/inc/CCX/osDot11Ccx.h
+
+    OS_DK_INCS_FILES += $(OS_DK_INCS_FILES_CCX)
+endif
+#end of OS_DK_INCS_FILES_CCX#   do not remove or change this comment
+
+#start of OS_DK_INCS_FILES#   do not remove or change this comment
+
+
+#start of OS_DK_INCS#   do not remove or change this comment
+OS_DK_INCS = \
+    $(COMMON)/inc \
+    $(COMSRC)/inc \
+    $(COMSRC)/core/inc \
+    $(COMSRC)/core/sme/configMgr \
+    $(COMSRC)/core/sme/HealthMonitor \
+    $(COMSRC)/utils \
+    $(COMSRC)/driver_bypass \
+    $(COMSRC)/TNETW_Driver/Export_Inc \
+    $(COMSRC)/TNETW_Driver/Ctrl/Export_Inc \
+    $(COMSRC)/TNETW_Driver/MacServices/Export_Inc \
+    $(COMSRC)/TNETW_Driver/FW_Transfer/inc \
+    $(COMSRC)/BusAccess/Export_Inc \
+    $(COMSRC)/hal/inc \
+    $(COMSRC)/hal/FirmwareApi \
+    $(COMSRC)/hal/TnetwServices \
+    $(COMSRC)/hal/TnetwServices/TNETW1251 \
+    $(COMSRC)/hal/Export_Inc \
+    $(COMSRC)/hal/hw_ctrl \
+    $(COMSRC)/hal/hl_ctrl
+
+#start of OS_DK_INCS_CCX#   do not remove or change this comment
+ifeq ($(EXC),y)
+    OS_DK_INCS_CCX = \
+        $(COMMON)/inc/CCX
+
+    OS_DK_INCS += $(OS_DK_INCS_CCX)
+endif
+#end of OS_DK_INCS_CCX#   do not remove or change this comment
+
+#start of OS_DK_INCS#   do not remove or change this comment
diff --git a/sta_dk_4_0_4_32/pform/common/inc/IPCKernelApi.h b/sta_dk_4_0_4_32/pform/common/inc/IPCKernelApi.h
new file mode 100644 (file)
index 0000000..2e232b1
--- /dev/null
@@ -0,0 +1,47 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef _IPCKERNELAPI_H_
+#define _IPCKERNELAPI_H_
+#include "osTIType.h"
+
+UINT32 IPCKernelInit    (TI_HANDLE hAdapter,TI_HANDLE  hIPCEv);
+
+UINT32 IPCKernelDeInit  (TI_HANDLE hAdapter);
+
+ INT32 IPC_EventSend    (TI_HANDLE hAdapter, tiUINT8 *pEvData, tiUINT32 EvDataSize);
+
+
+#endif
diff --git a/sta_dk_4_0_4_32/pform/common/inc/cli_cu_common.h b/sta_dk_4_0_4_32/pform/common/inc/cli_cu_common.h
new file mode 100644 (file)
index 0000000..09f2bd4
--- /dev/null
@@ -0,0 +1,116 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef common_h
+#define common_h
+
+#include "osTIType.h"
+
+#ifdef _WINDOWS
+#endif
+
+#ifndef TIWLAN_DRV_NAME
+#define TIWLAN_DRV_NAME  DRV_NAME
+#endif
+
+#define IN     /* input parameter          */
+#define OUT    /* output parameter         */
+#define INOUT  /* input & output parameter */
+
+#ifndef TRUE
+#define TRUE  1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef NULL
+# define NULL 0L
+#endif
+
+#ifndef UNUSED
+# define UNUSED(p) ((void)p)
+#endif
+
+#ifndef _WINDOWS
+
+       #ifndef print
+               # define print(fmt, arg...) fprintf(stdout, fmt, ##arg)
+       #endif
+
+       #ifndef print_err
+               # define print_err(fmt, arg...) fprintf(stderr, fmt, ##arg)
+       #endif
+
+       #ifndef print_deb
+       # ifdef DEBUG_MESSAGES
+       #  define print_deb(fmt, arg...) fprintf(stdout, fmt, ##arg)
+       # else
+       #  define print_deb(fmt, arg...)
+       # endif /* DEBUG_MESSAGES */
+       #endif  /* print_deb */
+
+#endif /* __LINUX__ */
+
+#ifndef SIZE_ARR
+# define SIZE_ARR(a) (sizeof(a)/sizeof(a[0]) )
+#endif
+
+#ifndef min
+# define min(a, b)     (((a)<(b)) ? (a) : (b))
+#endif
+
+#ifndef max
+# define max(a, b)     (((a)>(b)) ? (a) : (b))
+#endif
+
+typedef struct
+{
+    tiUINT32 value;
+    char *name;
+} named_value_t;
+#ifdef _WINDOWS
+#else
+#define print_available_values(arr) \
+        {   int i; for(i=0; i<SIZE_ARR(arr); i++) \
+            print("%d - %s%s", arr[i].value, arr[i].name, (i>=SIZE_ARR(arr)-1) ? "\n" : ", " ); \
+        }
+#endif
+        
+void print_memory_dump(char *addr, int size );
+
+#endif /* common_h */
+
diff --git a/sta_dk_4_0_4_32/pform/common/inc/linux_ioctl_common.h b/sta_dk_4_0_4_32/pform/common/inc/linux_ioctl_common.h
new file mode 100644 (file)
index 0000000..8194f9e
--- /dev/null
@@ -0,0 +1,78 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef TI1610_IOCTL_COMMON_H
+#define TI1610_IOCTL_COMMON_H
+
+#include "osTIType.h"
+
+#ifndef SIZE_ARR
+#define SIZE_ARR(a)    (sizeof(a)/sizeof(a[0]))
+#endif
+
+
+typedef struct
+{
+    tiUINT32 func_id;
+    void *optional_param;
+} hal_print_param_t;
+
+#define IOCTL_GET    1
+#define IOCTL_SET    2
+#define IOCTL_SETGET 3
+
+typedef struct
+{
+    ULONG cmd;
+    ULONG cmd_type; /* IOCTL_SET or IOCTL_GET */
+    ULONG length;
+    ULONG user_data_pointer;    /* pointer to data or data if length <= sizeof(ULONG) */
+} tiioctl_req_t;
+
+
+/* TIWLN_SET_INIT_INFO request parameter
+ */
+typedef struct
+{
+  tiUINT32 eeprom_image_length;
+  tiUINT32 firmware_image_length;
+  tiUINT32 init_file_length;
+  /* eeprom image follows */
+  char data[1];
+  /* firmware image follows */
+  /* init file follows */
+} tiwlan_dev_init_t;
+
+#endif /* TI1610_IOCTL_COMMON_H */
diff --git a/sta_dk_4_0_4_32/pform/common/inc/osApi.h b/sta_dk_4_0_4_32/pform/common/inc/osApi.h
new file mode 100644 (file)
index 0000000..41696ab
--- /dev/null
@@ -0,0 +1,544 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:      OSAPI.H*/
+/**/
+/* Purpose:     This module defines unified interface to the OS specific*/
+/*              sources and services.*/
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef __OS_API_H__
+#define __OS_API_H__
+
+
+#include "osTIType.h"
+#include "TI_IPC_Api.h"
+//TRS:MEB
+#ifdef _WINDOWS
+#endif
+
+//TRS end
+
+
+/****************************************************************************************
+                                               START OF OS API (Common to all GWSI LIB, Driver and TI Driver)                          
+*****************************************************************************************/
+
+
+#define OS_API_MEM_ADRR  0x0000000
+#define OS_API_REG_ADRR  0x300000
+
+
+/****************************************************************************************
+                        OS HW API NEEDED BY DRIVER              
+*****************************************************************************************/
+
+
+#define OS_PAGE_SIZE 4096
+
+/* 
+Clear the WLAN Ready Interrupt Line stored in the PIC Controller
+*/
+VOID os_clearWlanReady(void);
+
+/* 
+Read the WLAN_IRQ line
+*/
+UINT32 os_senseIrqLine( TI_HANDLE OsContext );
+
+/* TRS: CDB Needed for osApi.C */
+#ifdef BSP_H5
+#define WLAN_GPIO_INTERRUPT_LINE               9
+#define WLAN_GPIO_POWER_ENABLET_LINE    10
+#else
+#define WLAN_GPIO_INTERRUPT_LINE    134
+#define WLAN_GPIO_POWER_ENABLET_LINE    71
+#endif
+
+
+VOID
+os_disableIrq( 
+    TI_HANDLE OsContext 
+    );
+
+VOID
+os_enableIrq( 
+    TI_HANDLE OsContext
+    );
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                             OS Report API                                                                                                   *       
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+
+VOID 
+os_setDebugMode(
+       BOOL enable
+       );
+
+VOID 
+os_printf(
+       const char *format ,...);
+
+VOID os_setDebugOutputToTicon(BOOL value);
+
+#define os_report   os_printf
+#define osPrintf os_printf  //TRS::CDB
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     OS DMA CALLBACK API                                                                                     *
+ ****************************************************************************************
+ *     Callback directly called at an IRQ context from the SPI modue                                           *
+ *     This should triger a tasklet_schedule so that the End of DMA will be handled            *
+ *     in a tasklet  context and then be directed to the TNETWIF to call the Client            *
+ *                                                                                                                                                                             *       
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+
+VOID 
+os_TNETWIF_BusTxn_Complete(
+       TI_HANDLE OsContext,
+       int status
+       );
+
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                             OS Memory API                                                                                                   *       
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+
+PVOID
+os_memoryAlloc(
+    TI_HANDLE OsContext,
+    UINT32 Size
+    );
+
+PVOID
+os_memoryCAlloc(
+    TI_HANDLE OsContext,
+    UINT32 Number,
+    UINT32 Size
+    );
+
+VOID
+os_memorySet(
+    TI_HANDLE OsContext,
+    PVOID pMemPtr,
+    INT32 Value,
+    UINT32 Length
+    );
+
+VOID
+os_memoryZero(
+    TI_HANDLE OsContext,
+    PVOID pMemPtr,
+    UINT32 Length
+   );
+
+VOID
+os_memoryCopy(
+    TI_HANDLE pOsContext,
+    PVOID pDestination,
+    PVOID pSource,
+    UINT32 Size
+   );
+
+VOID
+os_memoryMove(
+    TI_HANDLE pOsContext,
+    PVOID pDestination,
+    PVOID pSource,
+    UINT32 Size
+   );
+
+VOID
+os_memoryFree(
+    TI_HANDLE pOsContext,
+    PVOID pMemPtr,
+    UINT32 Size
+    );
+
+INT32
+os_memoryCompare(
+    TI_HANDLE OsContext,
+    PUINT8 Buf1,
+    PUINT8 Buf2,
+    INT32 Count
+    );
+
+PVOID
+os_memoryAlloc4HwDma(
+    TI_HANDLE pOsContext,
+    UINT32 Size
+    );
+
+VOID
+os_memory4HwDmaFree(
+    TI_HANDLE pOsContext,
+    PVOID pPMem_ptr,
+    UINT32 Size
+    );
+
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     OS TIMER API                                                                                            *
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+typedef void (*PTIMER_FUNCTION)(TI_HANDLE Context);
+
+TI_HANDLE
+os_timerCreate(
+    TI_HANDLE OsContext,
+    PTIMER_FUNCTION pRoutine,
+    TI_HANDLE Context
+    );
+
+VOID
+os_timerDestroy(
+    TI_HANDLE OsContext,
+    TI_HANDLE TimerHandle
+    );
+
+VOID
+os_timerStart(
+    TI_HANDLE OsContext,
+    TI_HANDLE TimerHandle,
+    UINT32 DelayMs,
+    BOOL bPeriodic
+    );
+
+VOID
+os_timerStop(
+    TI_HANDLE OsContext,
+    TI_HANDLE TimerHandle
+    );
+
+VOID
+os_periodicIntrTimerStart(
+       TI_HANDLE OsContext
+       );
+
+UINT32
+os_timeStampMs(
+    TI_HANDLE OsContext
+    );
+
+UINT32
+os_timeStampUs(
+    TI_HANDLE OsContext
+    );
+
+VOID
+os_StalluSec(
+    TI_HANDLE OsContext,
+    UINT32 uSec
+    );
+
+void os_ToggleDebugGPIO(int count);
+
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     Hardware access functions       API                                                             *
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+PVOID
+os_hwGetRegistersAddr(
+    TI_HANDLE OsContext
+    );
+
+
+PVOID
+os_hwGetMemoryAddr(
+    TI_HANDLE OsContext
+    );
+
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     Protection services     API                                                                             *
+ *                                                                                                                                                                             *
+ ****************************************************************************************
+ * OS protection is implemented as dummy functions because                                                             *
+ * all driver code is executed in context of a single tasklet,                                                 *
+ * except IOCTL handlers and xmition.                                                                                                  *
+ * Protection in IOCTL handlers and hard_start_xmit is done by different                               *
+ * means.                                                                                                                                                              *
+ ****************************************************************************************/
+TI_HANDLE
+os_protectCreate(
+    TI_HANDLE OsContext
+    );
+
+VOID
+os_protectDestroy(
+    TI_HANDLE OsContext,
+    TI_HANDLE ProtectContext
+    );
+
+VOID
+os_protectLock(
+    TI_HANDLE OsContext,
+    TI_HANDLE ProtectContext
+    );
+
+VOID
+os_protectUnlock(
+    TI_HANDLE OsContext,
+    TI_HANDLE ProtectContext
+    );
+
+
+
+#ifdef DRIVER_PROFILING
+  void _os_profile (TI_HANDLE OsContext, UINT32 fn, UINT32 par);
+  #define os_profile(hos,fn,par) _os_profile (hos, fn, par)
+#else
+  #define os_profile(hos,fn,par)
+#endif
+
+
+/****************************************************************************************
+                                               START OF GWSI DRIVER API                                
+*****************************************************************************************/
+VOID 
+os_Complete(
+       TI_HANDLE OsContext
+       );
+
+#ifndef GWSI_LIB
+
+VOID 
+os_WaitComplete(
+       TI_HANDLE OsContext
+       );
+
+UINT32
+os_memoryGetPhysicalLow (OS_PHYSICAL_ADDRESS pAddr);
+UINT32 
+os_memoryGetPhysicalHigh (OS_PHYSICAL_ADDRESS pAddr);
+
+/* MEB use native NDIS functions */
+#ifdef _WINDOWS
+#else
+
+  UINT32 os_memoryGetPhysicalLow(OS_PHYSICAL_ADDRESS pAddr);
+  UINT32 os_memoryGetPhysicalHigh(OS_PHYSICAL_ADDRESS pAddr);
+
+#endif
+
+  VOID os_hardResetTnetw(void);
+
+#endif
+
+
+/****************************************************************************************
+                                               START OF TI DRIVER API                          
+*****************************************************************************************/
+#if !defined(GWSI_DRIVER) && !defined(GWSI_LIB)
+
+typedef struct {
+    UINT32      Event;
+    UINT8*      Data;
+} TI_CONNECTION_STATUS, *PTI_CONNECTION_STATUS;
+
+
+
+PVOID
+os_memoryAlloc4HwCopy(
+    TI_HANDLE pOsContext,
+    UINT32 Size
+    );
+
+VOID
+os_memorySharedFree(
+    TI_HANDLE OsContext,
+    PVOID pVirtual,
+    UINT32 Size,
+    OS_PHYSICAL_ADDRESS pPhysical
+    );
+
+PVOID
+os_memorySharedAlloc(
+    TI_HANDLE OsContext,
+    UINT32 Size,
+    OS_PHYSICAL_ADDRESS *pPhysical
+    );
+
+VOID
+os_memoryMoveToHw(
+    TI_HANDLE OsContext,
+    PVOID pTarget,
+    PVOID pSource,
+    UINT32 Size
+    );
+
+VOID
+os_memoryMoveFromHw(
+    TI_HANDLE OsContext,
+    PVOID pTarget,
+    PVOID pSource,
+    UINT32 Size
+    );
+
+
+/**/
+/* Register access functions*/
+/**/
+VOID
+os_hwReadMemRegisterUINT32(
+    TI_HANDLE OsContext,
+    PUINT32 Register,
+    PUINT32 Data
+    );
+
+VOID
+os_hwWriteMemRegisterUINT32(
+    TI_HANDLE OsContext,
+    PUINT32 Register,
+    UINT32 Data
+    );
+
+VOID
+os_hwReadMemRegisterUINT16(
+    TI_HANDLE OsContext,
+    PUINT16 Register,
+    PUINT16 Data
+    );
+
+VOID
+os_hwWriteMemRegisterUINT16(
+    TI_HANDLE OsContext,
+    PUINT16 Register,
+    UINT16 Data
+    );
+
+VOID
+os_hwReadMemRegisterUINT8(
+    TI_HANDLE OsContext,
+    PUINT8 Register,
+    PUINT8 Data
+    );
+
+VOID
+os_hwWriteMemRegisterUINT8(
+    TI_HANDLE OsContext,
+    PUINT8 Register,
+    UINT8 Data
+    );
+
+int
+os_getFirmwareImage(
+    TI_HANDLE OsContext,
+    PUINT8 *pBuffer,
+    PUINT32 Length,
+    UINT8 RadioType
+    );
+
+int
+os_getRadioImage(
+    TI_HANDLE OsContext,
+    PUINT8 *pBuffer,
+    PUINT32 Length,
+    UINT8 RadioType
+    );
+
+VOID
+os_closeFirmwareImage( TI_HANDLE OsContext );
+
+VOID
+os_closeRadioImage( TI_HANDLE OsContext );
+
+BOOL
+os_receivePacket(
+    TI_HANDLE OsContext,
+    PVOID pPacket,
+    UINT16 Length
+    );
+
+INT32
+os_sendPacket(
+        TI_HANDLE OsContext,
+        PVOID pPacket,
+        UINT16 Length
+        );
+
+tiINT32
+os_IndicateEvent(
+    IPC_EV_DATA* pData
+    );
+
+VOID
+os_powerStateBusy(
+    TI_HANDLE OsContext
+    );
+
+VOID
+os_powerStateIdle(
+    TI_HANDLE OsContext
+    );
+
+VOID
+os_setWakeOnGpio(
+    TI_HANDLE OsContext
+    );
+
+VOID
+os_resetWakeOnGpio(
+    TI_HANDLE OsContext
+    );
+
+BOOL
+os_getEeepromImage(
+    TI_HANDLE OsContext,
+    PUINT8* pBuffer,
+    PUINT32 length
+    );
+
+// TRS:JCG missing in 4.03
+VOID 
+os_setPowerOfTnetw(
+    BOOL bPowerOn
+    );
+
+#endif
+
+#endif
diff --git a/sta_dk_4_0_4_32/pform/common/inc/osClsfr.h b/sta_dk_4_0_4_32/pform/common/inc/osClsfr.h
new file mode 100644 (file)
index 0000000..ee91861
--- /dev/null
@@ -0,0 +1,62 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* Module:             OSCLSFRI.H*/
+/**/
+/* Purpose:            This module demonstrate qos tag classification.*/
+/**/
+/*--------------------------------------------------------------------------*/
+
+#ifndef __OS_CLSFR_H__
+#define __OS_CLSFR_H__
+
+#include "srcApi.h"
+
+
+TI_STATUS 
+os_txClassifier(
+       mem_MSDU_T *pMsdu,
+       UINT8 *pQosClassifierTable
+       );
+
+TI_STATUS
+osSend_ConfigTxClassifier(
+       PTIWLN_ADAPTER_T pAdapter,
+       UINT32 bufferLength,
+       UINT8 *pQosClassifierBuffer
+       );
+
+#endif
diff --git a/sta_dk_4_0_4_32/pform/common/inc/osDebug.h b/sta_dk_4_0_4_32/pform/common/inc/osDebug.h
new file mode 100644 (file)
index 0000000..042c3f4
--- /dev/null
@@ -0,0 +1,142 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __OSDEBUG_H_
+#define __OSDEBUG_H_
+
+#ifdef TI_DBG 
+
+#ifdef TIWLAN_MSM7000
+#define debugFunction(a,b,c) 
+#endif
+
+#define IF_TIDEBUG(f)  if (!((TiDebugFlag & (f))^(f))) 
+extern unsigned long TiDebugFlag;
+
+#define PRINT(F, A)            IF_TIDEBUG( F ) { DbgPrint(A); }
+#define PRINTF(F, A)   IF_TIDEBUG( F ) { DbgPrint A; }
+
+#define DBG_INIT                               0x0001
+#define DBG_REGISTRY                   0x0002
+#define DBG_NDIS_CALLS                 0x0004
+#define DBG_NDIS_OIDS                  0x0008
+#define DBG_PCI_RES                            0x0010
+#define DBG_INTERRUPT                  0x0020
+#define DBG_IOCTL                              0x0040
+#define DBG_RECV                               0x0080
+#define DBG_SEND                               0x0100
+
+#define DBG_SEV_INFO                   0x0001
+#define DBG_SEV_LOUD                   0x0002
+#define DBG_SEV_VERY_LOUD              0x0004
+#define DBG_SEV_WARNING                        0x0008
+#define DBG_SEV_ERROR                  0x0010
+#define DBG_SEV_FATAL_ERROR            0x0020
+
+
+#define DBG_INIT_INFO                          ((DBG_INIT << 16) | DBG_SEV_INFO)
+#define DBG_INIT_LOUD                          ((DBG_INIT << 16) | DBG_SEV_LOUD)
+#define DBG_INIT_VERY_LOUD                     ((DBG_INIT << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_INIT_WARNING                       ((DBG_INIT << 16) | DBG_SEV_WARNING)
+#define DBG_INIT_ERROR                         ((DBG_INIT << 16) | DBG_SEV_ERROR)
+#define DBG_INIT_FATAL_ERROR           ((DBG_INIT << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_REGISTRY_INFO                      ((DBG_REGISTRY << 16) | DBG_SEV_INFO)
+#define DBG_REGISTRY_LOUD                      ((DBG_REGISTRY << 16) | DBG_SEV_LOUD)
+#define DBG_REGISTRY_VERY_LOUD         ((DBG_REGISTRY << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_REGISTRY_WARNING           ((DBG_REGISTRY << 16) | DBG_SEV_WARNING)
+#define DBG_REGISTRY_ERROR                     ((DBG_REGISTRY << 16) | DBG_SEV_ERROR)
+#define DBG_REGISTRY_FATAL_ERROR       ((DBG_REGISTRY << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_NDIS_CALLS_INFO                    ((DBG_NDIS_CALLS << 16) | DBG_SEV_INFO)
+#define DBG_NDIS_CALLS_LOUD                    ((DBG_NDIS_CALLS << 16) | DBG_SEV_LOUD)
+#define DBG_NDIS_CALLS_VERY_LOUD       ((DBG_NDIS_CALLS << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_NDIS_CALLS_WARNING         ((DBG_NDIS_CALLS << 16) | DBG_SEV_WARNING)
+#define DBG_NDIS_CALLS_ERROR           ((DBG_NDIS_CALLS << 16) | DBG_SEV_ERROR)
+#define DBG_NDIS_CALLS_FATAL_ERROR     ((DBG_NDIS_CALLS << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_NDIS_OIDS_INFO                     ((DBG_NDIS_OIDS << 16) | DBG_SEV_INFO)
+#define DBG_NDIS_OIDS_LOUD                     ((DBG_NDIS_OIDS << 16) | DBG_SEV_LOUD)
+#define DBG_NDIS_OIDS_VERY_LOUD                ((DBG_NDIS_OIDS << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_NDIS_OIDS_WARNING          ((DBG_NDIS_OIDS << 16) | DBG_SEV_WARNING)
+#define DBG_NDIS_OIDS_ERROR                    ((DBG_NDIS_OIDS << 16) | DBG_SEV_ERROR)
+#define DBG_NDIS_OIDS_FATAL_ERROR      ((DBG_NDIS_OIDS << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_PCI_RES_INFO                       ((DBG_PCI_RES << 16) | DBG_SEV_INFO)
+#define DBG_PCI_RES_LOUD                       ((DBG_PCI_RES << 16) | DBG_SEV_LOUD)
+#define DBG_PCI_RES_VERY_LOUD          ((DBG_PCI_RES << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_PCI_RES_WARNING                    ((DBG_PCI_RES << 16) | DBG_SEV_WARNING)
+#define DBG_PCI_RES_ERROR                      ((DBG_PCI_RES << 16) | DBG_SEV_ERROR)
+#define DBG_PCI_RES_FATAL_ERROR                ((DBG_PCI_RES << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_INTERRUPT_INFO                     ((DBG_INTERRUPT << 16) | DBG_SEV_INFO)
+#define DBG_INTERRUPT_LOUD                     ((DBG_INTERRUPT << 16) | DBG_SEV_LOUD)
+#define DBG_INTERRUPT_VERY_LOUD                ((DBG_INTERRUPT << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_INTERRUPT_WARNING          ((DBG_INTERRUPT << 16) | DBG_SEV_WARNING)
+#define DBG_INTERRUPT_ERROR                    ((DBG_INTERRUPT << 16) | DBG_SEV_ERROR)
+#define DBG_INTERRUPT_FATAL_ERROR      ((DBG_INTERRUPT << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_IOCTL_INFO                         ((DBG_IOCTL << 16) | DBG_SEV_INFO)
+#define DBG_IOCTL_LOUD                         ((DBG_IOCTL << 16) | DBG_SEV_LOUD)
+#define DBG_IOCTL_VERY_LOUD                    ((DBG_IOCTL << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_IOCTL_WARNING                      ((DBG_IOCTL << 16) | DBG_SEV_WARNING)
+#define DBG_IOCTL_ERROR                                ((DBG_IOCTL << 16) | DBG_SEV_ERROR)
+#define DBG_IOCTL_FATAL_ERROR          ((DBG_IOCTL << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_RECV_INFO                          ((DBG_RECV << 16) | DBG_SEV_INFO)
+#define DBG_RECV_LOUD                          ((DBG_RECV << 16) | DBG_SEV_LOUD)
+#define DBG_RECV_VERY_LOUD                     ((DBG_RECV << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_RECV_WARNING                       ((DBG_RECV << 16) | DBG_SEV_WARNING)
+#define DBG_RECV_ERROR                         ((DBG_RECV << 16) | DBG_SEV_ERROR)
+#define DBG_RECV_FATAL_ERROR           ((DBG_RECV << 16) | DBG_SEV_FATAL_ERROR)
+
+#define DBG_SEND_INFO                          ((DBG_SEND << 16) | DBG_SEV_INFO)
+#define DBG_SEND_LOUD                          ((DBG_SEND << 16) | DBG_SEV_LOUD)
+#define DBG_SEND_VERY_LOUD                     ((DBG_SEND << 16) | DBG_SEV_VERY_LOUD)
+#define DBG_SEND_WARNING                       ((DBG_SEND << 16) | DBG_SEV_WARNING)
+#define DBG_SEND_ERROR                         ((DBG_SEND << 16) | DBG_SEV_ERROR)
+#define DBG_SEND_FATAL_ERROR           ((DBG_SEND << 16) | DBG_SEV_FATAL_ERROR)
+
+
+#else
+
+#define PRINT(F, A)
+#define PRINTF(F, A)
+
+#endif
+
+
+#endif /* __OSDEBUG_H_*/
+
diff --git a/sta_dk_4_0_4_32/pform/common/inc/osRgstry.h b/sta_dk_4_0_4_32/pform/common/inc/osRgstry.h
new file mode 100644 (file)
index 0000000..d73fcfa
--- /dev/null
@@ -0,0 +1,136 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __OSRGSTRY_H_
+#define __OSRGSTRY_H_
+
+typedef struct {
+
+       PUCHAR                                  ParameterName;
+       NDIS_STRING                             NdisParameterName;
+
+       NDIS_PARAMETER_TYPE             ParameterType;
+
+       BOOLEAN                                 RangeCheck;
+
+       ULONG                                   DefaultValue;
+       ULONG                                   MinValue;
+       ULONG                                   MaxValue;
+
+       ULONG                                   FieldOffset;
+       ULONG                                   FieldSize;
+
+} REGISTRY_DATA, *PREGISTRY_DATA;
+
+
+VOID
+regFillInitTable(
+       PTIWLN_ADAPTER_T pAdapter,
+       PVOID pInitTable
+       );
+
+VOID
+regReadParameters(
+       PTIWLN_ADAPTER_T pAdapter
+       );
+
+VOID
+regWriteInstanceNumber(
+       PTIWLN_ADAPTER_T pAdapter
+       );
+
+VOID
+regReadIntegerParameter(
+                                PTIWLN_ADAPTER_T               pAdapter,
+                                PNDIS_STRING                   pParameterName,
+                                ULONG                                  defaultValue,
+                                ULONG                                  minValue,
+                                ULONG                                  maxValue,
+                                UCHAR                                  parameterSize,
+                                PUCHAR                                 pParameter
+                                );
+
+VOID
+regReadStringParameter(
+                                PTIWLN_ADAPTER_T               pAdapter,
+                                PNDIS_STRING                   pParameterName,
+                                PCHAR                                  pDefaultValue,
+                                USHORT                                 defaultLen,
+                                PUCHAR                                 pParameter,
+                                void*                                  pParameterSize
+                                );
+
+VOID
+regReadUnicodeStringParameter(
+                                PTIWLN_ADAPTER_T               pAdapter,
+                                PNDIS_STRING                   pParameterName,
+                                PCHAR                                  pDefaultValue,
+                                UCHAR                                  defaultLen,
+                                PUCHAR                                 pParameter,
+                                PUCHAR                                 pParameterSize
+                                );
+
+
+VOID
+regReadWepKeyParameter(
+                                PTIWLN_ADAPTER_T               pAdapter,
+                                PUCHAR                                 pKeysStructure,
+                                UINT8                                  defaultKeyId
+                                );
+
+VOID
+regReadNetworkAddress(PTIWLN_ADAPTER_T pAdapter);
+
+#ifdef TI_DBG
+
+VOID
+regReadLastDbgState(
+       PTIWLN_ADAPTER_T pAdapter
+       );
+
+VOID
+regWriteLastDbgState(
+       PTIWLN_ADAPTER_T pAdapter
+       );
+
+#endif
+
+// TRS:AS registry callbacks
+#if defined(_WINDOWS)  
+#endif /* if defined(_WINDOWS) */
+//TRS end
+
+#endif         // __OSRGSTRY_H_
+
diff --git a/sta_dk_4_0_4_32/pform/common/inc/osUtil.h b/sta_dk_4_0_4_32/pform/common/inc/osUtil.h
new file mode 100644 (file)
index 0000000..e7a0de8
--- /dev/null
@@ -0,0 +1,338 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifndef __OSUTIL_H_
+#define __OSUTIL_H_
+
+/*used for asynchron ioctl purposes*/
+void os_IoctlComplete(PTIWLN_ADAPTER_T pAdapter, TI_STATUS ReturnStatus) ;
+
+NTSTATUS 
+DispatchCommand(
+       PTIWLN_ADAPTER_T pAdapter,
+       ULONG ioControlCode,
+       PULONG outBufLen,
+       ULONG inBufLen,
+       PVOID ioBuffer,
+       PUINT8 pIoCompleteFlag
+       );
+
+ULONG UtilInfoCodeQueryInformation(    PTIWLN_ADAPTER_T pAdapter,PUCHAR pData,PULONG Length);
+ULONG UtilInfoCodeSetInformation(      PTIWLN_ADAPTER_T pAdapter,PUCHAR pData,ULONG Length);
+
+ULONG UtilGetSwVersion(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilSetBSSID(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetBSSID(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilSetSSID(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetSSID(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilNetworkTypesSupported(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilNetworkTypeInUseSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilNetworkTypeInUseGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilGetCurrentRssiLevel(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+VOID  RssiUtilIoctlCompleteCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff);
+VOID  SnrUtilIoctlCompleteCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff);
+
+ULONG UtilBssidListGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length, BOOLEAN ExtBssid, BOOLEAN allVarIes);
+ULONG UtilBssidListScanOid(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilInfrastructureModeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilInfrastructureModeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilFragmentationThresholdSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilFragmentationThresholdGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilRtsThresholdSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRtsThresholdGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilSupportedRates(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilSupportedRatesSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilCurrentRatesGet(PTIWLN_ADAPTER_T pAdapter,PUCHAR pData, PULONG Length);
+ULONG UtilDesiredRatesGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilBasicRatesGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilBasicRatesSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilConfigurationGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilConfigurationSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilReadReg(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilWriteReg(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilGetCounter(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Offset);
+ULONG UtilStatistics(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilTxStatistics(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG inLength, PULONG outLength);
+
+ULONG UtilAddWep(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length, BOOLEAN CalledFromIoctl);
+ULONG UtilRemoveWep(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilAddKey(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRemoveKey(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilWepStatusSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilWepStatusGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilAuthenticationModeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilAuthenticationModeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilExtAuthenticationModeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilExtAuthenticationModeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilAssociationInfoGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG Util802CapabilityGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG Util802PmkidGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG Util802PmkidSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG Util802FSWAvailableOptionsGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG Util802FSWOptionsGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG Util802FSWOptionsSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG Util802EapTypeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG Util802EapTypeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+
+ULONG UtilBthWlanCoeEnable(PTIWLN_ADAPTER_T pAdapter,  PUCHAR pData,   ULONG Length);
+ULONG UtilBthWlanCoeRate(PTIWLN_ADAPTER_T pAdapter,    PUCHAR pData,   ULONG Length);
+ULONG UtilBthWlanCoeConfig(PTIWLN_ADAPTER_T pAdapter,  PUCHAR pData,   ULONG Length);
+ULONG UtilBthWlanCoeGetStatus(PTIWLN_ADAPTER_T pAdapter,       PUCHAR pData,   ULONG *Length);
+
+
+ULONG UtilDesiredChannelSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilDesiredChannelGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilPowerModeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPowerModeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilPowerLevelPSGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilPowerLevelPSSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilPowerLevelDefaultGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilPowerLevelDefaultSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilPowerLevelDozeModeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilPowerLevelDozeModeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilBeaconFilterDesiredStateSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilBeaconFilterDesiredStateGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilShortPreambleSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilShortPreambleGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilShortRetryGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilShortRetrySet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilLongRetryGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilLongRetrySet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilRegulatoryDomain_enableDisable_802_11d( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRegulatoryDomain_enableDisable_802_11h( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRegulatoryDomain_Get_802_11d( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilRegulatoryDomain_Get_802_11h( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilRegulatoryDomain_setCountryIE_2_4( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRegulatoryDomain_getCountryIE_2_4( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilRegulatoryDomain_setCountryIE_5( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRegulatoryDomain_getCountryIE_5( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilRegulatoryDomain_setMinMaxDfsChannels( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);  
+ULONG UtilRegulatoryDomain_getMinMaxDfsChannels( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length); 
+
+
+ULONG UtilCurrentRegDomainGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilCurrentRegDomainSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilGetRegDomainTable(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilNumberOfAntennas(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilRxAntennaGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilRxAntennaSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilTxAntennaGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilTxAntennaSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilAntennaDivresitySet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilWepStatusGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG Util4xActiveStateGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilGetDesiredSSID(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilChannelGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilDesiredInfrastructureModeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilDriverStatusGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilDriverStatusSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilIbssProtectionGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilIbssProtectionSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilShortSlotGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilShortSlotSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilExtRatesIeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilExtRatesIeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilSetTrafficIntensityThresholds(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetTrafficIntensityThresholds(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilToggleTrafficIntensityEvents(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilSendDiscreteScanTrigger(PTIWLN_ADAPTER_T pAdapter, PUCHAR ioBuffer, ULONG inBufLen);
+ULONG UtilPollApPackets(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPollApPacketsFromAC(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilConfigTxClassifier(PTIWLN_ADAPTER_T pAdapter,PUCHAR ioBuffer,ULONG inBufLen);
+ULONG UtilRemoveClassifierEntry(PTIWLN_ADAPTER_T pAdapter,PUCHAR ioBuffer, ULONG inBufLen);
+ULONG UtilGetClsfrType(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilGetAPQosParams(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetAsyncCurrentRssiLevel (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetAsyncCurrentSnrRatio (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetAPQosCapabilities(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilAddTspec(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetTspecParams(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilDeleteTspec(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetCurrentAcStatus(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilSetMediumUsageThreshold(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilSetPhyRateThreshold(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetMediumUsageThreshold(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetPhyRateThreshold(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetUserPriorityOfStream(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetDesiredPsMode(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilConfigTxClass(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilEnableEvent(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilDisableEvent(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilConfigEvents(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetDrvCapabilities(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetSelectedBSSIDInfo(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetPrimaryBSSIDInfo(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilGetDriverState (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilStartAppScanSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilStopAppScanSet(PTIWLN_ADAPTER_T pAdapter,    PUCHAR pData, ULONG Length);
+ULONG UtilDrvScanParamSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilScanPolicyParamSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilScanBssListGet(PTIWLN_ADAPTER_T pAdapter,    PUCHAR pData, PULONG Length);
+
+ULONG UtilRssiGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilQosSetParams(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilQosSetRxTimeOut(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilSetDTagToAcMappingTable(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilSetVAD(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetVAD (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilConfigRSSI(PTIWLN_ADAPTER_T pAdapter, UINT32 pData, ULONG Length);
+ULONG UtilConfigPERLevel(PTIWLN_ADAPTER_T pAdapter, UINT32 pData, ULONG Length);
+
+ULONG UtilPrivacyFilterSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPrivacyFilterGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilDisassociate(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+VOID UtilDeviceSuspend(PTIWLN_ADAPTER_T pAdapter);
+VOID UtilDeviceResume(PTIWLN_ADAPTER_T pAdapter);
+
+ULONG UtilGetTxPowerValue(PTIWLN_ADAPTER_T pAdapter,externalParam_e ParamType,PUCHAR pData,ULONG Length);
+
+ULONG UtilSetTxPowerDbm(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length  );
+ULONG UtilGetTxPowerLevel(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length       );
+
+ULONG UtilEnableDisableRxDataFilters(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetRxDataFiltersStatistics(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilAddRxDataFilter(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilRemoveRxDataFilter(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilGetAPTxPowerLevel(PTIWLN_ADAPTER_T pAdapter,externalParam_e ParamType,PUCHAR pData,ULONG Length);
+
+
+ULONG UtilTxPowerLevelDbmGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilTxPowerLevelDbmSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+
+ULONG UtilGetCountryCode(PTIWLN_ADAPTER_T pAdapter,externalParam_e ParamType,PUCHAR pData,ULONG Length);
+ULONG UtilGetRegDomainBand(PTIWLN_ADAPTER_T pAdapter,externalParam_e ParamType,PUCHAR pData,ULONG Length);
+ULONG UtilTestOid(PTIWLN_ADAPTER_T pAdapter,PUCHAR pData,ULONG Length);
+
+ULONG UtilEarlyWakeupIeGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilEarlyWakeupIeSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilExcConfigurationGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilExcConfigurationSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilExcNetworkEapGet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilExcNetworkEapSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilExcRogueApDetectedSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilExcReportRogueApSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilExcAuthSuccessSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilExcCckmStartSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilExcCckmRequestSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilExcCckmResultSet(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilGetMACAddress(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG SendUserPacket(PTIWLN_ADAPTER_T pAdapter, TI_HANDLE pPacket,ULONG PacketLen);
+ULONG UtilSetMixedMode(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilGetMixedMode(PTIWLN_ADAPTER_T pAdapter, externalParam_e ParamType, PUCHAR pData, PULONG Length);
+
+ULONG UtilDriverSuspend(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilConfigRoamingParamsSet( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilConfigRoamingParamsGet( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+ULONG UtilMeasurementEnableDisableParamsSet( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilMeasurementMaxDurationParamsSet( PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+
+ULONG UtilGetPowerConsumptionStatistics(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+
+
+ULONG UtilPltReadRegister(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+VOID  UtilPltReadRegisterCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff);
+ULONG UtilPltWriteRegister(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+VOID  UtilPltRxPerCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff);
+ULONG UtilPltRxPerStart(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltRxPerStop(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltRxPerClear(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltRxPerGetResults(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length);
+ULONG UtilPltTxStop(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltTxCW(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltTxContinues(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltWriteMib(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length);
+ULONG UtilPltReadMib(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG pOutLength, ULONG InLength);
+VOID UtilPltReadMibCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff);
+ULONG UtilPltRxTxCal(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG pOutLength, ULONG InLength);
+VOID UtilPltRxTxCalCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff);
+ULONG UtilPltRxCal(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG pOutLength, ULONG InLength);
+ULONG utilRxCalibrationStatus(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG pOutLength, ULONG InLength);
+#endif         /*__OSUTIL_H_*/
diff --git a/sta_dk_4_0_4_32/pform/common/src/osClsfr.c b/sta_dk_4_0_4_32/pform/common/src/osClsfr.c
new file mode 100644 (file)
index 0000000..9e05c14
--- /dev/null
@@ -0,0 +1,144 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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 osClsfr.c
+ */
+
+#include "osAdapter.h"
+#include "srcApi.h"
+
+#define ETHERNET_HEADER_SIZE    14
+
+/************************************************************************
+ *                        os_txClassifier                                      *
+ ************************************************************************
+DESCRIPTION: the function demonstrate qos classification from UDP port
+             number.
+                                                                                                   
+INPUT:      pData               -      void pointer to Msdu.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+
+
+TI_STATUS os_txClassifier(mem_MSDU_T *pMsdu,UINT8 *pQosClassifierTable)
+{
+    UINT8              i;
+    UINT8              *pUdpHeader;
+    UINT8              *pIpHeader;
+    UINT8              ipHeaderLen;
+    UINT16             dstPortNum;
+    UINT32             ipAddr;
+    NWIF_CLSFR_ENTRY  *pCt;
+
+    pCt = (NWIF_CLSFR_ENTRY *)pQosClassifierTable;
+    /*pEthHeader = (EthernetHeader_t*)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr));*/
+    pIpHeader = (UINT8 *)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr)) + ETHERNET_HEADER_SIZE;
+    ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
+    pUdpHeader = pIpHeader + ipHeaderLen;
+
+    dstPortNum = *((UINT16 *)(pUdpHeader + 2));
+    ipAddr = *((UINT32 *)(pIpHeader + 16));
+
+       dstPortNum = ((dstPortNum >> 8) | (dstPortNum << 8));
+
+
+    pMsdu->qosTag = 0;
+    for(i = 0; i < NWIF_MAX_QOS_CONNS; i++ )
+    {
+        if ((pCt[i].ip == ipAddr) && (pCt[i].port == dstPortNum) )
+        {
+            pMsdu->qosTag = (UINT8)pCt[i].pri;
+            /*printk(KERN_ALERT "Found classifier match for ip=0x%x, port=%d, prio=%d \n",ipAddr, dstPortNum, pCt[i].pri);*/
+            break;
+        }
+    }
+    
+
+    return OK;
+
+}
+
+/************************************************************************
+ *                        os_txSetClassifier                                           *
+ ************************************************************************
+DESCRIPTION: the function demonstrate setting qos classification table.
+                                                                                                   
+INPUT:      pData               -      void pointer to Msdu.
+
+OUTPUT:                
+
+RETURN:     OK on success, NOK otherwise
+
+************************************************************************/
+TI_STATUS osSend_ConfigTxClassifier(PTIWLN_ADAPTER_T pAdapter,UINT32 bufferLength, UINT8 *pQosClassifierBuffer)
+{
+       NWIF_CLSFR_ENTRY *pSrc, *pDest;
+       UINT8 clsfrIndex;
+       UINT8 NumOfEntries;
+
+       if(bufferLength >  NWIF_MAX_QOS_CONNS * sizeof(NWIF_CLSFR_ENTRY))
+       {
+               return NOK;
+       }
+
+       if((pAdapter == NULL) || (pQosClassifierBuffer == NULL))
+       {
+               return NOK;
+       }
+
+       pDest = (NWIF_CLSFR_ENTRY *)(pAdapter->qosClassifierTable);
+       pSrc = (NWIF_CLSFR_ENTRY *)pQosClassifierBuffer;
+       
+       NumOfEntries = bufferLength / sizeof(NWIF_CLSFR_ENTRY);
+       for(clsfrIndex = 0; clsfrIndex <NumOfEntries ; clsfrIndex++)
+       {
+               pDest[clsfrIndex].ip = pSrc[clsfrIndex].ip;
+               pDest[clsfrIndex].port = pSrc[clsfrIndex].port;
+               pDest[clsfrIndex].pri = pSrc[clsfrIndex].pri;
+       }
+
+       return OK;
+
+}
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/pform/common/src/osCmd.c b/sta_dk_4_0_4_32/pform/common/src/osCmd.c
new file mode 100644 (file)
index 0000000..340ac89
--- /dev/null
@@ -0,0 +1,1217 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#undef BINARY_COMPATIBLE
+#define BINARY_COMPATIBLE 0
+
+#ifdef _WINDOWS
+#endif
+
+#include "osAdapter.h"
+#include "tiioctl.h"
+#include "paramOut.h"
+#include "osUtil.h"
+#include "srcApi.h"
+#include "configMgr.h"
+#include "TNETW_Driver_api.h"
+
+#ifdef GWSI_DRIVER
+#include "gwsi_tester_parser.h"
+#endif
+
+#include "IPCKernelApi.h"
+
+#ifdef TI_DBG
+#ifndef TIWLAN_MSM7000
+#include "debug.h"
+#endif
+#endif
+
+TI_STATUS report_setParam(TI_HANDLE hReport, whalParamInfo_t *pParam );
+TI_STATUS report_getParam(TI_HANDLE hReport, whalParamInfo_t *pParam );
+
+NTSTATUS
+DispatchCommand(
+    PTIWLN_ADAPTER_T pAdapter,
+    ULONG ioControlCode,
+    PULONG outBufLen,
+    ULONG inBufLen,
+    PVOID ioBuffer,
+    PUINT8 pIoCompleteFlag
+    )
+{
+    NTSTATUS    ntStatus = STATUS_SUCCESS;
+
+#ifdef TI_DBG
+    whalParamInfo_t     param;
+#endif
+
+    /*BOOL    builtInStatus;*/
+/**/
+/*     Block entrance from utility to the driver when the recovery is in progress */
+/*    UtilDriverBuiltInTestStsGet(pAdapter, &builtInStatus, sizeof(builtInStatus));*/
+/*    if(builtInStatus)*/
+/*        return STATUS_INVALID_PARAMETER;*/
+
+    // os_protectLock(pAdapter, pAdapter->SystemProtect); /* Bug. Replaced with the line below -- MCS00035801 */
+    /* Dm: os_protectLock(( (configMgr_t  *)(pAdapter->CoreHalCtx) )->hOs, pAdapter->SystemProtect); */
+
+
+    /* Initialiaze to TRUE all IOCTL's : Only in few cases there will be IOCTL that will
+    be implemented ar REALread from FW and then will have their completion callback later called */
+    *pIoCompleteFlag = TRUE;
+
+    switch(ioControlCode) {
+    case TIWLN_802_11_ENABLE_EVENT:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ENABLE_EVENT.\n");
+        ntStatus = configMgr_RegisterEvent(pAdapter->CoreHalCtx, ioBuffer, inBufLen);
+    break;
+
+    case TIWLN_802_11_DISABLE_EVENT:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DISABLE_EVENT.\n");
+#ifdef _WINDOWS
+#else
+        ntStatus = configMgr_UnRegisterEvent(pAdapter->CoreHalCtx, *(TI_HANDLE*)ioBuffer);
+#endif
+    break;
+
+#ifdef _WINDOWS
+#endif
+    case TIWLN_GET_SW_VERSION:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_GET_SW_VERSION.\n");
+        ntStatus = UtilGetSwVersion(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_BSSID_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_BSSID_GET.\n");
+        ntStatus = UtilGetBSSID(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_BSSID_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_BSSID_SET.\n");
+        ntStatus = UtilSetBSSID(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_SSID_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SSID_GET.\n");
+        ntStatus = UtilGetSSID(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_SSID_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SSID_SET.\n");
+        ntStatus = UtilSetSSID(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_DISASSOCIATE:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DISASSOCIATE.\n");
+        ntStatus = UtilDisassociate(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_NETWORK_TYPES_SUPPORTED:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_NETWORK_TYPES_SUPPORTED.\n");
+        ntStatus = UtilNetworkTypesSupported(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_NETWORK_TYPE_IN_USE_GET:
+        PRINT(DBG_IOCTL, "...IOCTL TIWLN_802_11_NETWORK_TYPE_IN_USE_GET.\n");
+        ntStatus = UtilNetworkTypeInUseGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_NETWORK_TYPE_IN_USE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_NETWORK_TYPE_IN_USE_SET.\n");
+        break;
+
+    case TIWLN_802_11_POWER_MODE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_MODE_SET.\n");
+        ntStatus = UtilPowerModeSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_POWER_MODE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_MODE_GET.\n");
+        ntStatus = UtilPowerModeGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_POWER_LEVEL_PS_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_LEVEL_PS_GET.\n");
+            ntStatus = UtilPowerLevelPSGet(pAdapter, ioBuffer, outBufLen);
+            break;
+
+    case TIWLN_802_11_POWER_LEVEL_PS_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_LEVEL_PS_SET.\n");
+            ntStatus = UtilPowerLevelPSSet(pAdapter, ioBuffer, outBufLen);
+            break;
+
+    case TIWLN_802_11_POWER_LEVEL_DEFAULT_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_LEVEL_DEFAULT_GET.\n");
+            ntStatus = UtilPowerLevelDefaultGet(pAdapter, ioBuffer, outBufLen);
+            break;
+
+    case TIWLN_802_11_POWER_LEVEL_DEFAULT_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_LEVEL_DEFAULT_SET.\n");
+            ntStatus = UtilPowerLevelDefaultSet(pAdapter, ioBuffer, outBufLen);
+            break;
+
+    case TIWLN_802_11_POWER_LEVEL_DOZE_MODE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_LEVEL_DOZE_MODE_GET.\n");
+            ntStatus = UtilPowerLevelDozeModeGet(pAdapter, ioBuffer, outBufLen);
+            break;
+
+    case TIWLN_802_11_POWER_LEVEL_DOZE_MODE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_LEVEL_DOZE_MODE_SET.\n");
+            ntStatus = UtilPowerLevelDozeModeSet(pAdapter, ioBuffer, outBufLen);
+            break;
+
+       case TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_SET.\n");
+            ntStatus = UtilBeaconFilterDesiredStateSet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_GET.\n");
+            ntStatus = UtilBeaconFilterDesiredStateGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_SET_TRAFFIC_INTENSITY_THRESHOLDS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_TRAFFIC_INTENSITY_THRESHOLDS.\n");
+       ntStatus = UtilSetTrafficIntensityThresholds(pAdapter, ioBuffer, inBufLen);
+       break;
+    case TIWLN_802_11_GET_TRAFFIC_INTENSITY_THRESHOLDS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_TRAFFIC_INTENSITY_THRESHOLDS.\n");
+       ntStatus = UtilGetTrafficIntensityThresholds(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS.\n");
+       ntStatus = UtilToggleTrafficIntensityEvents(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    /* TBD: CAN BE REMOVED ??? */
+    case TIWLN_802_11_POWER_MGR_PROFILE:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POWER_MGR_PROFILE.\n");
+        ntStatus = UtilPowerModeSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_TX_POWER_LEVEL_GET:
+        PRINT(DBG_IOCTL, "...IOCTL TIWLN_802_11_TX_POWER_LEVEL_GET.\n");
+        ntStatus = UtilGetTxPowerLevel (pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_TX_POWER_DBM_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_TX_POWER_DBM_GET.\n");
+        ntStatus = UtilTxPowerLevelDbmGet (pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_TX_POWER_DBM_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_TX_POWER_DBM_SET.\n");
+        ntStatus = UtilSetTxPowerDbm (pAdapter, ioBuffer, inBufLen);
+        break;
+
+    /*************************************************************************
+    ****  RSSI :Real Read from FW asynchronous then init the flag to False   ***
+    ***** The completion will happen when the Completion                     ***
+    ***** Callback IoctlCompleteCB function is called                        ***
+    *************************************************************************/
+    case TIWLN_802_11_RSSI:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_RSSI.\n");
+        *pIoCompleteFlag = FALSE;
+        ntStatus = UtilGetAsyncCurrentRssiLevel (pAdapter, ioBuffer, outBufLen);
+
+        /* ntStatus = UtilGetCurrentRssiLevel (pAdapter, ioBuffer, outBufLen);*/
+        break;
+
+    case TIWLN_802_11_SNR:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SNR.\n");
+        *pIoCompleteFlag = FALSE;
+        ntStatus = UtilGetAsyncCurrentSnrRatio (pAdapter, ioBuffer, outBufLen);
+        break;
+
+        /* TBD: REMOVE ???? */
+    case TIWLN_802_11_RSSI_TRIGGER_GET:
+        PRINT(DBG_IOCTL, "...IOCTL TIWLN_802_11_RSSI_TRIGGER_GET.\n");
+        *outBufLen = 4;
+        break;
+
+        /* TBD: REMOVE ???? */
+    case TIWLN_802_11_RSSI_TRIGGER_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_RSSI_TRIGGER_SET.\n");
+        *outBufLen = 4;
+        break;
+
+    case TIWLN_802_11_BSSID_LIST:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_BSSID_LIST.\n");
+        ntStatus = UtilBssidListGet(pAdapter, ioBuffer, outBufLen, TRUE, FALSE);
+        break;
+
+    case TIWLN_802_11_FULL_BSSID_LIST:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_FULL_BSSID_LIST.\n");
+        ntStatus = UtilBssidListGet(pAdapter, ioBuffer, outBufLen, TRUE, TRUE);
+        break;
+
+    case TIWLN_802_11_INFRASTRUCTURE_MODE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_INFRASTRUCTURE_MODE_GET.\n");
+        ntStatus = UtilInfrastructureModeGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_INFRASTRUCTURE_MODE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_INFRASTRUCTURE_MODE_SET.\n");
+        ntStatus = UtilInfrastructureModeSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_FRAGMENTATION_THRESHOLD_GET:
+        PRINT(DBG_IOCTL, "...IOCTL TIWLN_802_11_FRAGMENTATION_THRESHOLD_GET.\n");
+        ntStatus = UtilFragmentationThresholdGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_FRAGMENTATION_THRESHOLD_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_FRAGMENTATION_THRESHOLD_SET.\n");
+        ntStatus = UtilFragmentationThresholdSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_RTS_THRESHOLD_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_FRAGMENTATION_THRESHOLD_GET.\n");
+        ntStatus = UtilRtsThresholdGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_RTS_THRESHOLD_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_FRAGMENTATION_THRESHOLD_SET.\n");
+        ntStatus = UtilRtsThresholdSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_SUPPORTED_RATES:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SUPPORTED_RATES.\n");
+        ntStatus = UtilSupportedRates(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_SUPPORTED_RATES_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SUPPORTED_RATES_SET.\n");
+        ntStatus = UtilSupportedRatesSet(pAdapter, ioBuffer, inBufLen);
+        break;
+    
+    case TIWLN_802_11_DESIRED_RATES_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DESIRED_RATES_GET.\n");
+        ntStatus = UtilDesiredRatesGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_CURRENT_RATES_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DESIRED_RATES_GET.\n");
+        ntStatus = UtilCurrentRatesGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_STATISTICS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_STATISTICS.\n");
+        ntStatus = UtilStatistics(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_TX_STATISTICS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_TX_STATISTICS.\n");
+        ntStatus = UtilTxStatistics(pAdapter, ioBuffer, inBufLen, outBufLen);
+        break;
+
+    case TIWLN_802_11_ADD_WEP:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ADD_WEP.\n");
+        ntStatus = UtilAddWep(pAdapter, ioBuffer, inBufLen, TRUE);
+        break;
+
+    case TIWLN_802_11_REMOVE_WEP:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_REMOVE_WEP.\n");
+        ntStatus = UtilRemoveWep(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_WEP_STATUS_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_WEP_STATUS_GET.\n");
+        ntStatus = UtilWepStatusGet(pAdapter, ioBuffer, outBufLen);
+
+            switch (*(cipherSuite_e*)ioBuffer)
+            {
+            case RSN_CIPHER_NONE:
+                *(NDIS_802_11_WEP_STATUS*)ioBuffer = (NDIS_802_11_WEP_STATUS)os802_11WEPDisabled;
+                break;
+            case RSN_CIPHER_WEP: 
+                *(NDIS_802_11_WEP_STATUS*)ioBuffer = (NDIS_802_11_WEP_STATUS)os802_11WEPEnabled;
+                break; 
+            case RSN_CIPHER_TKIP:
+                *(NDIS_802_11_WEP_STATUS*)ioBuffer = (NDIS_802_11_WEP_STATUS)os802_11Encryption2Enabled;
+                break;
+            case RSN_CIPHER_AES_CCMP:
+                *(NDIS_802_11_WEP_STATUS*)ioBuffer = (NDIS_802_11_WEP_STATUS)os802_11Encryption3Enabled;
+                break;
+            default: 
+                break;
+            }
+
+        break;
+
+    case TIWLN_802_11_WEP_STATUS_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_WEP_STATUS_SET.\n");
+
+        /* Convert from cipher suite to encryption status */
+
+        switch (*(NDIS_802_11_WEP_STATUS*)ioBuffer)
+        {
+        case os802_11WEPDisabled:
+            *(cipherSuite_e*)ioBuffer = RSN_CIPHER_NONE;
+            break;
+        case os802_11WEPEnabled: 
+            *(cipherSuite_e*)ioBuffer = RSN_CIPHER_WEP;
+            break; 
+        case os802_11Encryption2Enabled:
+            *(cipherSuite_e*)ioBuffer = RSN_CIPHER_TKIP;
+            break;
+        case os802_11Encryption3Enabled:
+            *(cipherSuite_e*)ioBuffer = RSN_CIPHER_AES_CCMP;
+            break;
+        default: 
+            break;
+        }
+
+        ntStatus = UtilWepStatusSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_EAP_TYPE_GET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: TIWLN_802_11_EAP_TYPE_GET\n");
+        ntStatus = Util802EapTypeGet(pAdapter, ioBuffer, outBufLen);
+        break;
+        
+    case TIWLN_802_11_EAP_TYPE_DRIVER_SET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: TIWLN_802_11_EAP_TYPE_DRIVER_SET\n");
+        ntStatus = Util802EapTypeSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+        /* WPA2 start */
+
+    case TIWLN_802_11_PMKID_GET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: OID_802_11_PMKID GET\n");
+        ntStatus = Util802PmkidGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_PMKID_SET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: OID_802_11_PMKID SET\n");
+        ntStatus = Util802PmkidSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_CAPABILITY_GET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: TIWLN_802_11_CAPABILITY_GET \n");
+        ntStatus = Util802CapabilityGet(pAdapter, ioBuffer, outBufLen);
+        break;
+        
+    case  TIWLN_802_11_AVAILABLE_OPTIONS_GET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: TIWLN_802_11_AVAILABLE_OPTIONS_GET \n");
+        ntStatus = Util802FSWAvailableOptionsGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case  TIWLN_802_11_WPA_OPTIONS_GET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: TIWLN_802_11_WPA_OPTIONS_GET\n");
+        ntStatus = Util802FSWOptionsGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_WPA_OPTIONS_SET:
+        PRINT(DBG_NDIS_OIDS_LOUD, "TIWL: TIWLN_802_11_WPA_OPTIONS_SET\n");
+        ntStatus = Util802FSWOptionsSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+        /* wpa2 - end */
+
+    case TIWLN_802_11_AUTHENTICATION_MODE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_AUTHENTICATION_MODE_GET.\n");
+        ntStatus = UtilExtAuthenticationModeGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_AUTHENTICATION_MODE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_AUTHENTICATION_MODE_SET.\n");
+        ntStatus = UtilExtAuthenticationModeSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_NUMBER_OF_ANTENNAS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_NUMBER_OF_ANTENNAS.\n");
+        ntStatus = UtilNumberOfAntennas(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_RX_ANTENNA_SELECTED_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_RX_ANTENNA_SELECTED_GET.\n");
+        ntStatus = UtilRxAntennaGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_RX_ANTENNA_SELECTED_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_RX_ANTENNA_SELECTED_SET.\n");
+        ntStatus = UtilRxAntennaSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_TX_ANTENNA_SELECTED_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_TX_ANTENNA_SELECTED_GET.\n");
+        ntStatus = UtilTxAntennaGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_TX_ANTENNA_SELECTED_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_TX_ANTENNA_SELECTED_SET.\n");
+        ntStatus = UtilTxAntennaSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLAN_802_11_ANTENNA_DIVERSITY_PARAM_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLAN_802_11_ANTENNA_DIVERSITY_PARAM_SET.\n");
+        ntStatus = UtilAntennaDivresitySet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_DESIRED_CHANNEL_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DESIRED_CHANNEL_GET.\n");
+        ntStatus = UtilDesiredChannelGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_DESIRED_CHANNEL_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DESIRED_CHANNEL_SET.\n");
+        ntStatus = UtilDesiredChannelSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_SHORT_PREAMBLE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SHORT_PREAMBLE_GET.\n");
+        ntStatus = UtilShortPreambleGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_SHORT_PREAMBLE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SHORT_PREAMBLE_SET.\n");
+        ntStatus = UtilShortPreambleSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_CURRENT_REGDOMAIN_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_CURRENT_REGDOMAIN_GET.\n");
+        ntStatus = UtilCurrentRegDomainGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11D:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11D.\n");
+        ntStatus = UtilRegulatoryDomain_enableDisable_802_11d(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11H:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11H.\n");
+        ntStatus = UtilRegulatoryDomain_enableDisable_802_11h(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_GET_802_11D:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_GET_802_11D.\n");
+        ntStatus = UtilRegulatoryDomain_Get_802_11d(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_GET_802_11H:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_GET_802_11D.\n");
+        ntStatus = UtilRegulatoryDomain_Get_802_11h(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_SET_COUNTRY_2_4:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_SET_COUNTRY_2_4.\n");
+        ntStatus = UtilRegulatoryDomain_setCountryIE_2_4(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_GET_COUNTRY_2_4:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_GET_COUNTRY_2_4.\n");
+        ntStatus = UtilRegulatoryDomain_getCountryIE_2_4(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_SET_COUNTRY_5:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_SET_COUNTRY_5.\n");
+        ntStatus = UtilRegulatoryDomain_setCountryIE_5(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_GET_COUNTRY_5:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_GET_COUNTRY_5.\n");
+        ntStatus = UtilRegulatoryDomain_getCountryIE_5(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_SET_DFS_RANGE:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_SET_DFS_RANGE.\n");
+        ntStatus = UtilRegulatoryDomain_setMinMaxDfsChannels(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_REG_DOMAIN_GET_DFS_RANGE:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REG_DOMAIN_GET_DFS_RANGE.\n");
+        ntStatus = UtilRegulatoryDomain_getMinMaxDfsChannels(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_SHORT_RETRY_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SHORT_RETRY_GET.\n");
+        ntStatus = UtilShortRetryGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_SHORT_RETRY_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SHORT_RETRY_SET.\n");
+        ntStatus = UtilShortRetrySet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_LONG_RETRY_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_LONG_RETRY_GET.\n");
+        ntStatus = UtilLongRetryGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_LONG_RETRY_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_LONG_RETRY_SET.\n");
+        ntStatus = UtilLongRetrySet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_4XACTIVESTATE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_4XACTIVESTATE_GET.\n");
+        ntStatus = Util4xActiveStateGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_DESIRED_SSID_GET:
+            PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DESIRED_SSID_GET.\n");
+        ntStatus = UtilGetDesiredSSID(pAdapter, ioBuffer, outBufLen);
+        break;
+    
+    case TIWLN_802_11_CHANNEL_GET:
+            PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_CHANNEL_GET.\n");
+        ntStatus = UtilChannelGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_DESIRED_INFRASTRUCTURE_MODE:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DESIRED_INFRASTRUCTURE_MODE.\n");
+        ntStatus = UtilDesiredInfrastructureModeGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_DRIVER_STATUS_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_DRIVER_STATUS_GET.\n");
+        ntStatus = UtilDriverStatusGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_DRIVER_STATUS_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_DRIVER_STATUS_SET.\n");
+        ntStatus = UtilDriverStatusSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_DRIVER_SUSPEND:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_DRIVER_STATUS_SET.\n");
+            UtilDriverSuspend(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_IBSS_PROTECTION_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_IBSS_PROTECTION_GET.\n");
+        ntStatus = UtilIbssProtectionGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_IBSS_PROTECTION_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_IBSS_PROTECTION_GET.\n");
+        ntStatus = UtilIbssProtectionSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_SHORT_SLOT_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_SHORT_SLOT_GET.\n");
+        ntStatus = UtilShortSlotGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_SHORT_SLOT_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_SHORT_SLOT_SET.\n");
+        ntStatus = UtilShortSlotSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_EXT_RATES_IE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_EXT_RATES_IE_GET.\n");
+        ntStatus = UtilExtRatesIeGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_EXT_RATES_IE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_EXT_RATES_IE_SET.\n");
+        ntStatus = UtilExtRatesIeSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_REMOVE_KEY:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_REMOVE_KEY\n");
+        ntStatus = UtilRemoveKey(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_ADD_KEY:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ADD_KEY\n");
+        ntStatus = UtilAddKey(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_MIXED_MODE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_MIXED_MODE_SET\n");
+        ntStatus = UtilSetMixedMode(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_MIXED_MODE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_MIXED_MODE_GET\n");
+        ntStatus = UtilGetMixedMode(pAdapter, RSN_MIXED_MODE, ioBuffer, outBufLen);
+
+        break;
+#ifdef EXC_MODULE_INCLUDED
+    case TIWLN_802_11_EXC_CONFIGURATION_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_CONFIGURATION_SET\n");
+        ntStatus = UtilExcConfigurationSet(pAdapter, ioBuffer, inBufLen);
+        break;
+           
+    case TIWLN_802_11_EXC_CONFIGURATION_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_CONFIGURATION_GET\n");
+        ntStatus = UtilExcConfigurationGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_EXC_ROGUE_AP_DETECTED:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_ROGUE_AP_DETECTED\n");
+        ntStatus = UtilExcRogueApDetectedSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case    TIWLN_802_11_EXC_REPORT_ROGUE_APS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_REPORT_ROGUE_APS\n");
+        ntStatus = UtilExcReportRogueApSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case    TIWLN_802_11_EXC_CCKM_REQUEST:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_CCKM_REQUEST\n");
+        ntStatus = UtilExcCckmRequestSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case    TIWLN_802_11_EXC_CCKM_RESULT:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_CCKM_RESULT\n");
+        ntStatus = UtilExcCckmResultSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case    TIWLN_802_11_EXC_NETWORK_EAP_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_NETWORK_EAP_SET\n");
+        ntStatus = UtilExcNetworkEapSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_EXC_NETWORK_EAP_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_NETWORK_EAP_GET\n");
+        ntStatus = UtilExcNetworkEapGet(pAdapter, ioBuffer, outBufLen);
+        break;
+    case TIWLN_802_11_EXC_AUTH_SUCCESS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_EXC_AUTH_SUCCESS\n");
+    
+        *outBufLen = UtilExcAuthSuccessSet(pAdapter, ioBuffer, inBufLen);
+
+        break;
+/******************** measurement *********************/
+
+    case TIWLN_802_11_MEASUREMENT_ENABLE_DISABLE_PARAMS_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_MEASUREMENT_MAX_DURATION_PARAMS_SET.\n");
+        ntStatus = UtilMeasurementEnableDisableParamsSet(pAdapter, ioBuffer, inBufLen);
+         break;
+
+    case TIWLN_802_11_MEASUREMENT_MAX_DURATION_PARAMS_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_MEASUREMENT_MAX_DURATION_PARAMS_SET.\n");
+        ntStatus = UtilMeasurementMaxDurationParamsSet(pAdapter, ioBuffer, inBufLen);
+         break;
+
+#else
+         
+    case TIWLN_802_11_EXC_CONFIGURATION_SET:
+    case TIWLN_802_11_EXC_CONFIGURATION_GET:
+    case TIWLN_802_11_EXC_ROGUE_AP_DETECTED:
+    case TIWLN_802_11_EXC_REPORT_ROGUE_APS:
+    case TIWLN_802_11_EXC_CCKM_REQUEST:
+    case TIWLN_802_11_EXC_CCKM_RESULT:
+    case TIWLN_802_11_EXC_NETWORK_EAP_SET:
+    case TIWLN_802_11_EXC_NETWORK_EAP_GET:
+    case TIWLN_802_11_EXC_AUTH_SUCCESS:
+    case TIWLN_802_11_MEASUREMENT_ENABLE_DISABLE_PARAMS_SET:
+    case TIWLN_802_11_MEASUREMENT_MAX_DURATION_PARAMS_SET:
+    PRINT(DBG_IOCTL_LOUD, "...EXC IOCTL NOT Supported.\n");   
+    break;
+
+#endif /* EXC_MODULE_INCLUDED */
+
+/******************** QOS **********************/
+
+    case TIWLN_802_11_SET_QOS_PARAMS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_QOS_PARAMS.\n");
+       ntStatus = UtilQosSetParams(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_CONFIG_TX_CLASS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_CONFIG_TX_CLASS.\n");
+       ntStatus = UtilConfigTxClassifier(pAdapter,ioBuffer,inBufLen);
+       break;
+
+    case TIWLN_802_11_REMOVE_CLSFR_ENTRY:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_REMOVE_CLSFR_ENTRY.\n");
+       ntStatus = UtilRemoveClassifierEntry(pAdapter,ioBuffer,inBufLen);
+       break;
+    case TIWLN_802_11_GET_CLSFR_TYPE:
+         PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_CLSFR_TYPE.\n");
+       ntStatus = UtilGetClsfrType(pAdapter, ioBuffer, outBufLen);
+       break;
+    case TIWLN_802_11_GET_AP_QOS_PARAMS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_AP_QOS_PARAMS.\n");
+       ntStatus = UtilGetAPQosParams(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_GET_AP_QOS_CAPABILITIES:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_AP_QOS_CAPABILITIES.\n");
+       ntStatus = UtilGetAPQosCapabilities(pAdapter, ioBuffer, outBufLen);
+       break;
+    case TIWLN_802_11_ADD_TSPEC:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ADD_TSPEC.\n");
+       ntStatus = UtilAddTspec(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_GET_TSPEC_PARAMS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_TSPEC_PARAMS.\n");
+       ntStatus = UtilGetTspecParams(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_DELETE_TSPEC:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_DELETE_TSPEC.\n");
+       ntStatus = UtilDeleteTspec(pAdapter, ioBuffer, inBufLen);
+       break;
+    case TIWLN_802_11_GET_CURRENT_AC_STATUS:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_CURRENT_AC_STATUS.\n");
+       ntStatus = UtilGetCurrentAcStatus(pAdapter, ioBuffer, outBufLen);
+       break;
+    case TIWLN_802_11_SET_MEDIUM_USAGE_THRESHOLD:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_MEDIUM_USAGE_THRESHOLD.\n");
+       ntStatus = UtilSetMediumUsageThreshold(pAdapter, ioBuffer, inBufLen);
+       break;
+    case TIWLN_802_11_SET_PHY_RATE_THRESHOLD:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_PHY_RATE_THRESHOLD.\n");
+       ntStatus = UtilSetPhyRateThreshold(pAdapter, ioBuffer, inBufLen);
+       break;
+    case TIWLN_802_11_GET_MEDIUM_USAGE_THRESHOLD:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_MEDIUM_USAGE_THRESHOLD.\n");
+       ntStatus = UtilGetMediumUsageThreshold(pAdapter, ioBuffer, outBufLen);
+       break;
+    case TIWLN_802_11_GET_PHY_RATE_THRESHOLD:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_PHY_RATE_THRESHOLD.\n");
+       ntStatus = UtilGetPhyRateThreshold(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_GET_USER_PRIORITY_OF_STREAM:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_USER_PRIORITY_OF_STREAM.\n");
+       ntStatus = UtilGetUserPriorityOfStream(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_GET_DESIRED_PS_MODE:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_DESIRED_PS_MODE.\n");
+       ntStatus = UtilGetDesiredPsMode(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_POLL_AP_PACKETS:
+      PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POLL_AP_PACKETS.\n");
+       ntStatus = UtilPollApPackets(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_POLL_AP_PACKETS_FROM_AC:
+      PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_POLL_AP_PACKETS_FROM_AC.\n");
+       ntStatus = UtilPollApPacketsFromAC(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_CONFIG_EVENTS_RSSI:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_CONFIG_EVENTS.\n");
+       ntStatus = UtilConfigRSSI(pAdapter, (UINT32) ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_GET_DRIVERS_CAPABILITIES:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_DRIVERS_CAPABILITIES.\n");
+       ntStatus = UtilGetDrvCapabilities(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_GET_SELECTED_BSSID_INFO:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_SELECTED_BSSID_INFO.\n");
+       ntStatus = UtilGetSelectedBSSIDInfo(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_GET_PRIMARY_BSSID_INFO:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_PRIMARY_BSSID_INFO.\n");
+       ntStatus = UtilGetPrimaryBSSIDInfo(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_GET_DRIVER_STATE:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_DRIVER_STATE.\n");
+       ntStatus = UtilGetDriverState(pAdapter, ioBuffer, outBufLen);
+       break;
+
+    case TIWLN_802_11_SET_RX_TIMEOUT:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_RX_TIMEOUT.\n");
+       ntStatus = UtilQosSetRxTimeOut(pAdapter, ioBuffer, inBufLen);
+       break;
+
+    case TIWLN_802_11_SET_DTAG_TO_AC_MAPPING_TABLE:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_DTAG_TO_AC_MAPPING_TABLE.\n");
+       ntStatus = UtilSetDTagToAcMappingTable(pAdapter, ioBuffer, inBufLen);
+       break;
+       
+    case TIWLN_802_11_SET_VAD:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SET_VAD.\n");
+       ntStatus = UtilSetVAD(pAdapter, ioBuffer, inBufLen);
+       break;
+    case TIWLN_802_11_GET_VAD:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_GET_VAD.\n");
+       ntStatus = UtilGetVAD(pAdapter, ioBuffer, outBufLen);
+       break;
+/******************** scan *********************/
+
+    case TIWLN_802_11_START_APP_SCAN_SET:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_START_APP_SCAN_SET.\n");
+       ntStatus = UtilStartAppScanSet(pAdapter, ioBuffer, inBufLen);
+        break;
+    
+    case TIWLN_802_11_STOP_APP_SCAN_SET:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_STOP_APP_SCAN_SET.\n");
+       ntStatus = UtilStopAppScanSet(pAdapter, ioBuffer, inBufLen);
+        break;
+    
+    case TIWLN_802_11_SCAN_POLICY_PARAM_SET:
+       PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_SCAN_POLICY_PARAM_SET.\n");
+       ntStatus = UtilScanPolicyParamSet(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_11_SCAN_BSS_LIST_GET:
+        PRINT(DBG_IOCTL_LOUD, "...TIWLN_802_11_SCAN_BSS_LIST_GET.\n");
+       ntStatus = UtilScanBssListGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+/******************** Roaming *********************/
+
+    case TIWLN_802_11_ROAMING_CONFIG_PARAMS_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ROAMING_CONFIG_PARAMS_SET.\n");
+        ntStatus = UtilConfigRoamingParamsSet(pAdapter, ioBuffer, inBufLen);
+         break;
+
+    case TIWLN_802_11_ROAMING_CONFIG_PARAMS_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ROAMING_CONFIG_PARAMS_GET.\n");
+        ntStatus = UtilConfigRoamingParamsGet(pAdapter, ioBuffer, outBufLen);
+         break;
+
+/******************** misc *********************/
+
+    case TIWLN_HW_READ_REGISTER:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_HW_READ_REGISTER.\n");
+        ntStatus = UtilReadReg(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_HW_WRITE_REGISTER:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_HW_WRITE_REGISTER.\n");
+        ntStatus = UtilWriteReg(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_802_3_CURRENT_ADDRESS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_3_CURRENT_ADDRESS.\n");
+        ntStatus = UtilGetMACAddress(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_802_11_ASSOCIATION_INFORMATION:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_802_11_ASSOCIATION_INFORMATION.\n");
+        ntStatus = UtilAssociationInfoGet(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_IOCTL_OID_QUERY_INFORMATION:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_IOCTL_OID_QUERY_INFORMATION.\n");
+        ntStatus = UtilInfoCodeQueryInformation(pAdapter, (PUCHAR)ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_IOCTL_OID_SET_INFORMATION:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_IOCTL_OID_SET_INFORMATION.\n");
+        ntStatus = UtilInfoCodeSetInformation(pAdapter, (PUCHAR)ioBuffer, inBufLen);
+        break;
+
+    case GWSI_GET_INIT_TABLE_COMMAND:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL GWSI_GET_INIT_TABLE_COMMAND.\n");
+        configMgr_GetInitParams (pAdapter->CoreHalCtx, (UINT8 *) ioBuffer, (UINT16 *) outBufLen);
+        break;
+
+    case BT_COEXSISTANCE_SET_ENABLE:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL BT_COEXSISTANCE_SET_ENABLE.\n");
+        ntStatus = UtilBthWlanCoeEnable(pAdapter, (PUCHAR)ioBuffer, inBufLen);
+        break;
+
+    case BT_COEXSISTANCE_SET_RATE:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL BT_COEXSISTANCE_SET_RATE.\n");
+        ntStatus = UtilBthWlanCoeRate(pAdapter, (PUCHAR)ioBuffer, inBufLen);
+        break;
+
+    case BT_COEXSISTANCE_SET_CONFIG:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL BT_COEXSISTANCE_SET_CONFIG.\n");
+        ntStatus = UtilBthWlanCoeConfig(pAdapter, (PUCHAR)ioBuffer, inBufLen);
+        break;
+
+    case BT_COEXSISTANCE_GET_STATUS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL BT_COEXSISTANCE_GET_STATUS.\n");
+        ntStatus = UtilBthWlanCoeGetStatus(pAdapter, (PUCHAR)ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_EARLY_WAKEUP_IE_SET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_EARLY_WAKEUP_IE_SET.\n");
+        ntStatus = UtilEarlyWakeupIeSet(pAdapter, (PUCHAR)ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_EARLY_WAKEUP_IE_GET:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_EARLY_WAKEUP_IE_GET.\n");
+        ntStatus = UtilEarlyWakeupIeGet(pAdapter, (PUCHAR)ioBuffer, outBufLen);
+        break;
+
+#ifdef TI_DBG
+
+    case TIWLN_GET_DEBUG_FLAG:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_GET_DEBUG_FLAG.\n");
+        *(PULONG)ioBuffer = TiDebugFlag;
+        break;
+
+    case TIWLN_SET_DEBUG_FLAG:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_SET_DEBUG_FLAG - %#lX.\n", *(PULONG)ioBuffer));
+        TiDebugFlag = *(PULONG)ioBuffer;
+        break;
+
+    case TIWLN_DISPLAY_STATS:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_DISPLAY_STATS. Code:%lu  Data:%lu\n", *(PULONG)ioBuffer, *(PULONG)((PUCHAR)ioBuffer+4)));
+        debugFunction(pAdapter->CoreHalCtx, *(PULONG)ioBuffer, ((PUCHAR)ioBuffer+4));
+        break;
+
+    case TIWLN_REPORT_MODULE_GET:
+    case TIWLN_GET_MODULE:
+        PRINT(DBG_IOCTL_LOUD, "...TIWLN_GET_MODULE\n");
+        param.paramType = REPORT_MODULE_TABLE_PARAM;
+        report_getParam(((configMgr_t *)pAdapter->CoreHalCtx)->hReport, &param);
+
+        os_memoryCopy(NULL, ioBuffer, param.content.ModuleTable, sizeof(param.content.ModuleTable));
+        *outBufLen = sizeof(param.content.ModuleTable);
+        break;
+
+    case TIWLN_REPORT_MODULE_SET:  
+    case TIWLN_SET_MODULE:
+        PRINTF(DBG_IOCTL_LOUD, ("...TIWLN_SET_MODULE\n"));
+        param.paramType = REPORT_MODULE_TABLE_PARAM;
+        os_memoryCopy(NULL, param.content.ModuleTable, ioBuffer, sizeof(param.content.ModuleTable));
+
+        report_setParam(((configMgr_t *)pAdapter->CoreHalCtx)->hReport, &param);
+        *outBufLen = 0;
+        break;
+
+    case TIWLN_REPORT_SEVERITY_SET:
+    case TIWLN_SET_SEVERITY:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_SET_SEVERITY - %#lX\n", *(PULONG)ioBuffer));
+        param.paramType = REPORT_SEVERITY_TABLE_PARAM;
+        os_memoryCopy(NULL, param.content.SeverityTable, ioBuffer, sizeof(param.content.SeverityTable));        
+
+        report_setParam(((configMgr_t *)pAdapter->CoreHalCtx)->hReport, &param);
+        *outBufLen = 0;
+        break;
+
+    case TIWLN_REPORT_SEVERITY_GET:
+    case TIWLN_GET_SEVERITY:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_GET_SEVERITY (%X)\n",
+            TIWLN_GET_SEVERITY));
+        param.paramType = REPORT_SEVERITY_TABLE_PARAM;
+        report_getParam(((configMgr_t *)pAdapter->CoreHalCtx)->hReport, &param);
+        os_memoryCopy(NULL, ioBuffer, param.content.SeverityTable, sizeof(param.content.SeverityTable));
+
+        *outBufLen = sizeof(param.content.SeverityTable);
+        break;
+
+    case TIWLN_REPORT_PPMODE_SET:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_SET_PPMODE - %#lX\n", *(PULONG)ioBuffer));
+        param.paramType = REPORT_PPMODE_VALUE_PARAM;
+        *(PULONG)&param.content = *(PULONG)ioBuffer;
+        report_setParam(((configMgr_t *)pAdapter->CoreHalCtx)->hReport, &param);
+        *outBufLen = 0;
+        break;
+
+   case TIWLN_OS_DBG_STATE_GET:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_OS_DBG_STATE_GET - %#lX\n", *(PULONG)ioBuffer));
+        param.paramType = REPORT_OS_DBG_STATE_VALUE_PARAM;
+        param.content.osDbgState = TiDebugFlag;
+        *outBufLen = sizeof(param.content.osDbgState);
+        break;
+
+    case TIWLN_OS_DBG_STATE_SET:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_OS_DBG_STATE_SET - %#lX\n", *(PULONG)ioBuffer));
+        param.paramType = REPORT_OS_DBG_STATE_VALUE_PARAM;
+        *(PULONG)&param.content = *(PULONG)ioBuffer;
+        TiDebugFlag = param.content.osDbgState;
+        *outBufLen = 0;
+        break;
+
+
+#endif
+    case SET_IPC_EVENT_HANDLE:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL SET_IPC_EVENT_HANDLE (%X).\n",SET_IPC_EVENT_HANDLE));
+        *outBufLen = 0;
+        ntStatus = IPCKernelInit(pAdapter,ioBuffer);
+        
+    break;
+
+    case DESTROY_IPC_EVENT_HANDLE:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL DESTROY_IPC_EVENT_HANDLE (%X).\n",DESTROY_IPC_EVENT_HANDLE));
+        *outBufLen = 0;
+
+        IPCKernelDeInit(pAdapter);
+
+           /*KeSetEvent (pAdapter->IPC.pRxIPCEvent, 0, FALSE) ;*/
+           /* KeClearEvent (pAdapter->pRxIPCEvent) ;*/
+    break;
+
+    case TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS.\n");
+        ntStatus = UtilEnableDisableRxDataFilters(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_GET_RX_DATA_FILTERS_STATISTICS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_GET_RX_DATA_FILTERS_STATISTICS.\n");
+        *pIoCompleteFlag = FALSE;
+        ntStatus = UtilGetRxDataFiltersStatistics(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_ADD_RX_DATA_FILTER:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_ADD_RX_DATA_FILTER.\n");
+        ntStatus = UtilAddRxDataFilter(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_REMOVE_RX_DATA_FILTER:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_REMOVE_RX_DATA_FILTER.\n");
+        ntStatus = UtilRemoveRxDataFilter(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_GET_POWER_CONSUMPTION_STATISTICS:
+        PRINT(DBG_IOCTL_LOUD, "...IOCTL TIWLN_GET_POWER_CONSUMPTION_STATISTICS.\n");
+        *pIoCompleteFlag = FALSE;
+        ntStatus = UtilGetPowerConsumptionStatistics(pAdapter, ioBuffer, outBufLen);
+        break;
+
+/* PLT*/
+    case TIWLN_PLT_WRITE_REGISTER:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_WRITE_REGISTER (%X).\n", TIWLN_PLT_WRITE_REGISTER));        
+        ntStatus = UtilPltWriteRegister(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_READ_REGISTER:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_READ_REGISTER (%X).\n", TIWLN_PLT_READ_REGISTER));
+        *pIoCompleteFlag = FALSE;
+        ntStatus = UtilPltReadRegister(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_PLT_RX_PER_START:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_PER_START (%X).\n", TIWLN_PLT_RX_PER_START));
+        ntStatus = UtilPltRxPerStart(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_RX_PER_STOP:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_PER_STOP (%X).\n", TIWLN_PLT_RX_PER_STOP));
+        ntStatus = UtilPltRxPerStop(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_RX_PER_CLEAR:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_PER_CLEAR (%X).\n", TIWLN_PLT_RX_PER_CLEAR));
+        ntStatus = UtilPltRxPerClear(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_RX_PER_GET_RESULTS:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_PER_GET_RESULTS (%X).\n", TIWLN_PLT_RX_PER_GET_RESULTS));
+        *pIoCompleteFlag = FALSE;
+        ntStatus = UtilPltRxPerGetResults(pAdapter, ioBuffer, outBufLen);
+        break;
+
+    case TIWLN_PLT_TX_CW:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_TX_CW (%X).\n", TIWLN_PLT_TX_CW));
+        ntStatus = UtilPltTxCW(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_TX_CONTINUES:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_TX_CONTINUES (%X).\n", TIWLN_PLT_TX_CONTINUES));
+        ntStatus = UtilPltTxContinues(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_TX_STOP:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_TX_STOP (%X).\n", TIWLN_PLT_TX_STOP));
+        ntStatus = UtilPltTxStop(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_MIB_WRITE:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_MIB_WRITE (%X).\n", TIWLN_PLT_MIB_WRITE));
+        ntStatus = UtilPltWriteMib(pAdapter, ioBuffer, inBufLen);
+        break;
+
+    case TIWLN_PLT_MIB_READ:
+        {
+            PLT_MIB_t* pMib = (PLT_MIB_t*)ioBuffer;
+            PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_MIB_READ (%X).\n", TIWLN_PLT_MIB_READ));
+            /* find which MIBs return in the same contects*/
+            switch(pMib->aMib)
+            {
+            /*Sync mode MIBs - reads the MIBs data from the driver and not from the FW */
+            case PLT_MIB_dot11MaxReceiveLifetime:
+            case PLT_MIB_ctsToSelf:
+            case PLT_MIB_arpIpAddressesTable:
+            case PLT_MIB_dot11GroupAddressesTable:
+            case PLT_MIB_rxFilter:
+            case PLT_MIB_templateFrame:
+            case PLT_MIB_beaconFilterIETable:
+            case PLT_MIB_txRatePolicy:
+                break;
+
+            /*all other MIBs are Async mode MIBs - reads the MIBs data from the FW */
+            default:
+                *pIoCompleteFlag = FALSE;
+            }
+            ntStatus = UtilPltReadMib(pAdapter, ioBuffer, outBufLen, inBufLen);
+
+        }
+        break;
+
+    case TIWLN_PLT_RX_TX_CAL:
+        *pIoCompleteFlag = FALSE;
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_TX_CAL (%#lX).\n", ioControlCode));
+        ntStatus = UtilPltRxTxCal(pAdapter, ioBuffer, outBufLen, inBufLen);
+        break;
+
+    case TIWLN_PLT_RX_CAL:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_CAL (%#lX).\n", ioControlCode));
+        ntStatus = UtilPltRxCal(pAdapter, ioBuffer, outBufLen, inBufLen);
+        break;
+
+    case TIWLN_PLT_RX_CAL_RESULT:
+        PRINTF(DBG_IOCTL_LOUD, ("...IOCTL TIWLN_PLT_RX_CAL_RESULT (%#lX).\n", ioControlCode));
+        ntStatus = utilRxCalibrationStatus(pAdapter, ioBuffer,outBufLen, inBufLen);
+        break;
+
+    #ifdef _WINDOWS
+    #endif
+
+    default:
+        PRINTF(DBG_IOCTL_ERROR, ("...UNKNOWN IOCTL: %#lX\n", ioControlCode));
+        ntStatus = (NTSTATUS)STATUS_SUCCESS;
+
+    }
+
+    // os_protectUnlock(pAdapter, pAdapter->SystemProtect); /* Bug. Replaced with the line below. -- MCS00035801 */
+    /* Dm: os_protectUnlock( ((configMgr_t  *)(pAdapter->CoreHalCtx))->hOs, pAdapter->SystemProtect); */
+    
+    return ntStatus;
+}
diff --git a/sta_dk_4_0_4_32/pform/common/src/osRgstry.c b/sta_dk_4_0_4_32/pform/common/src/osRgstry.c
new file mode 100644 (file)
index 0000000..eb1048e
--- /dev/null
@@ -0,0 +1,5056 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#if defined(_WINDOWS)
+#elif defined( __LINUX__ )
+#include "osrgstry_parser.h"
+#elif defined(__ARMCC__) 
+#include "osrgstry_parser.h"
+#include "string.h"
+#endif
+
+#include "osRgstry.h"
+#include "paramOut.h"
+#include "osDot11.h"
+#include "osApi.h"
+
+
+/* TODO: remove this line!*/
+#include "802_11Defs.h"
+
+extern rate_e  RateNumberToHost(UINT8 rateIn);
+
+#define MAX_KEY_BUFFER_LEN      256
+
+#define N_STR(str)              NDIS_STRING_CONST(str)
+#define INIT_TBL_OFF(field)     FIELD_OFFSET(initTable_t, field)
+
+/* Reports */
+NDIS_STRING STR_ReportSeverityTable          = NDIS_STRING_CONST( "ReportSeverityTable" );
+NDIS_STRING STR_ReportModuleTable            = NDIS_STRING_CONST( "ReportModuleTable" );
+
+
+NDIS_STRING STRFilterEnabled            = NDIS_STRING_CONST( "Mac_Filter_Enabled");
+NDIS_STRING STRnumGroupAddrs            = NDIS_STRING_CONST( "numGroupAddrs" );
+NDIS_STRING STRGroup_addr0              = NDIS_STRING_CONST( "Group_addr0" );
+NDIS_STRING STRGroup_addr1              = NDIS_STRING_CONST( "Group_addr1" );
+NDIS_STRING STRGroup_addr2              = NDIS_STRING_CONST( "Group_addr2" );
+NDIS_STRING STRGroup_addr3              = NDIS_STRING_CONST( "Group_addr3" );
+NDIS_STRING STRGroup_addr4              = NDIS_STRING_CONST( "Group_addr4" );
+NDIS_STRING STRGroup_addr5              = NDIS_STRING_CONST( "Group_addr5" );
+NDIS_STRING STRGroup_addr6              = NDIS_STRING_CONST( "Group_addr6" );
+NDIS_STRING STRGroup_addr7              = NDIS_STRING_CONST( "Group_addr7" );
+
+/* Beacon timing */
+/* If Early Wakeup is Enabled, 1251 wakes-up EARLY_WAKEUP_TIME before expected Beacon reception occasion */
+/* If Early Wakeup is Disabled, 1251 wakes-up at the expected Beacon reception occasion. */
+NDIS_STRING STREarlyWakeup                 = NDIS_STRING_CONST( "EarlyWakeup" );
+    
+NDIS_STRING STRArp_Ip_Addr              = NDIS_STRING_CONST( "ArpIp_Addr" );
+NDIS_STRING STRArp_Ip_Filter_Ena        = NDIS_STRING_CONST( "ArpIp_Filter_ena");
+
+
+NDIS_STRING STRBeaconFilterDesiredState = NDIS_STRING_CONST( "Beacon_Filter_Desired_State") ;
+NDIS_STRING STRBeaconFilterStored       = NDIS_STRING_CONST( "Beacon_Filter_Stored") ;  
+
+/*this is for configuring table from ini file*/
+NDIS_STRING STRBeaconIETableSize            = NDIS_STRING_CONST( "Beacon_IE_Table_Size") ;  
+NDIS_STRING STRBeaconIETable                = NDIS_STRING_CONST( "Beacon_IE_Table") ;
+NDIS_STRING STRBeaconIETableNumOfElem       = NDIS_STRING_CONST( "Beacon_IE_Num_Of_Elem") ; 
+
+NDIS_STRING STRTxXferBufferFullTimeToRecovery = NDIS_STRING_CONST( "TxXferBufferFullTimeToRecovery" );
+
+/* ------------------------------------------------------ */
+NDIS_STRING STRFirmwareDebug                = NDIS_STRING_CONST( "FirmwareDebug" );
+NDIS_STRING STRTraceBufferSize              = NDIS_STRING_CONST( "TraceBufferSize" );
+NDIS_STRING STRPrintTrace                   = NDIS_STRING_CONST( "PrintTrace" );
+
+NDIS_STRING STRHwACXAccessMethod            = NDIS_STRING_CONST( "HwACXAccessMethod" );
+NDIS_STRING STRMaxSitesFragCollect          = NDIS_STRING_CONST( "MaxSitesFragCollect" );
+
+NDIS_STRING STRNumACXRxDescriptors          = NDIS_STRING_CONST( "NumACXRxDescriptors" );
+NDIS_STRING STRNumACXTxDescriptors          = NDIS_STRING_CONST( "NumACXTxDescriptors" );
+NDIS_STRING STRTxFlashEnable                = NDIS_STRING_CONST( "TxFlashEnable" );
+
+NDIS_STRING STRBetEnable                                       = NDIS_STRING_CONST( "BetEnable");
+NDIS_STRING STRBetMaxConsecutive                       = NDIS_STRING_CONST( "BetMaxConsecutive");
+NDIS_STRING STRMaxFullBeaconInterval        = NDIS_STRING_CONST( "MaxlFullBeaconReceptionInterval" );
+NDIS_STRING STRBetEnableThreshold                      = NDIS_STRING_CONST( "BetEnableThreshold");
+NDIS_STRING STRBetDisableThreshold                     = NDIS_STRING_CONST( "BetDisableThreshold");
+
+NDIS_STRING STRNumHostRxDescriptors         = NDIS_STRING_CONST( "NumHostRxDescriptors" );
+NDIS_STRING STRNumHostTxDescriptors         = NDIS_STRING_CONST( "NumHostTxDescriptors" );
+
+NDIS_STRING STRACXMemoryBlockSize           = NDIS_STRING_CONST( "ACXMemoryBlockSize" );
+NDIS_STRING STRACXRxMemoryBlockSize         = NDIS_STRING_CONST( "ACXMemoryBlockSize" );
+NDIS_STRING STRACXTxMemoryBlockSize         = NDIS_STRING_CONST( "ACXMemoryBlockSize" );
+
+NDIS_STRING STRACXUseTxDataInterrupt        = NDIS_STRING_CONST( "ACXUseTxDataInterrupt" );
+NDIS_STRING STRACXUseInterruptThreshold     = NDIS_STRING_CONST( "ACXUseInterruptThreshold" );
+
+NDIS_STRING STRCalibrationChannel2_4        = NDIS_STRING_CONST( "CalibrationChannel24" );
+NDIS_STRING STRCalibrationChannel5_0        = NDIS_STRING_CONST( "CalibrationChannel5" );
+NDIS_STRING STRdot11RTSThreshold            = NDIS_STRING_CONST( "dot11RTSThreshold" );
+NDIS_STRING STRRxDisableBroadcast           = NDIS_STRING_CONST( "RxDisableBroadcast" );
+NDIS_STRING STRRecoveryEnable               = NDIS_STRING_CONST( "RecoveryEnable" );
+NDIS_STRING STRdot11TxAntenna               = NDIS_STRING_CONST( "dot11TxAntenna" );
+NDIS_STRING STRdot11RxAntenna               = NDIS_STRING_CONST( "dot11RxAntenna" );
+NDIS_STRING STRTxCompleteThreshold          = NDIS_STRING_CONST( "TxCompleteThreshold" );
+
+NDIS_STRING STRdot11FragThreshold           = NDIS_STRING_CONST( "dot11FragmentationThreshold" );
+NDIS_STRING STRdot11MaxTxMSDULifetime       = NDIS_STRING_CONST( "dot11MaxTransmitMSDULifetime" );
+NDIS_STRING STRdot11MaxReceiveLifetime      = NDIS_STRING_CONST( "dot11MaxReceiveLifetime" );
+NDIS_STRING STRdot11RateFallBackRetryLimit  = NDIS_STRING_CONST( "dot11RateFallBackRetryLimit");
+
+NDIS_STRING STRListenInterval               = NDIS_STRING_CONST( "dot11ListenInterval" );
+NDIS_STRING STRExternalMode                 = NDIS_STRING_CONST( "DriverExternalMode" );
+NDIS_STRING STRWiFiAdHoc                    = NDIS_STRING_CONST( "WiFiAdhoc" );
+NDIS_STRING STRWiFiWmmPS                    = NDIS_STRING_CONST( "WiFiWmmPS" );
+NDIS_STRING STRKeepAliveEnable              = NDIS_STRING_CONST( "KeepAliveEnable" );
+NDIS_STRING STRdot11DesiredChannel          = NDIS_STRING_CONST( "dot11DesiredChannel");
+NDIS_STRING STRdot11DesiredSSID             = NDIS_STRING_CONST( "dot11DesiredSSID" );
+NDIS_STRING STRdot11DesiredBSSType          = NDIS_STRING_CONST( "dot11DesiredBSSType" );
+
+NDIS_STRING STRdot11BasicRateMask_B           = NDIS_STRING_CONST( "dot11BasicRateMaskB");
+NDIS_STRING STRdot11SupportedRateMask_B       = NDIS_STRING_CONST( "dot11SupportedRateMaskB");
+NDIS_STRING STRdot11BasicRateMask_G           = NDIS_STRING_CONST( "dot11BasicRateMaskG");
+NDIS_STRING STRdot11SupportedRateMask_G       = NDIS_STRING_CONST( "dot11SupportedRateMaskG");
+NDIS_STRING STRdot11BasicRateMask_A           = NDIS_STRING_CONST( "dot11BasicRateMaskA");
+NDIS_STRING STRdot11SupportedRateMask_A       = NDIS_STRING_CONST( "dot11SupportedRateMaskA");
+NDIS_STRING STRdot11BasicRateMask_AG           = NDIS_STRING_CONST( "dot11BasicRateMaskAG");
+NDIS_STRING STRdot11SupportedRateMask_AG       = NDIS_STRING_CONST( "dot11SupportedRateMaskAG");
+
+NDIS_STRING STRdot11DesiredTxRate           = NDIS_STRING_CONST( "dot11DesiredTxRate");
+NDIS_STRING STRdot11MgmtCtrlTxRateSelection = NDIS_STRING_CONST( "dot11MgmtCtrlTxRateSelection");
+NDIS_STRING STRdot11MgmtCtrlTxRate          = NDIS_STRING_CONST( "dot11MgmtCtrlTxRate");
+
+
+NDIS_STRING STRRadio11_RxLevel              = NDIS_STRING_CONST( "Radio11_RxLevel");
+NDIS_STRING STRRadio11_LNA                  = NDIS_STRING_CONST( "Radio11_LNA");
+NDIS_STRING STRRadio11_RSSI                 = NDIS_STRING_CONST( "Radio11_RSSI");
+NDIS_STRING STRRadio0D_RxLevel              = NDIS_STRING_CONST( "Radio0D_RxLevel");
+NDIS_STRING STRRadio0D_LNA                  = NDIS_STRING_CONST( "Radio0D_LNA");
+NDIS_STRING STRRadio0D_RSSI                 = NDIS_STRING_CONST( "Radio0D_RSSI");
+
+NDIS_STRING STRdot11DesiredNetworkType      = NDIS_STRING_CONST( "dot11NetworkType");
+NDIS_STRING STRdot11DefaultNetworkType      = NDIS_STRING_CONST( "dot11DefaultNetworkType");
+NDIS_STRING STRdot11SlotTime                = NDIS_STRING_CONST( "ShortSlotTime");
+NDIS_STRING STRdot11IbssProtection          = NDIS_STRING_CONST( "IbssProtectionType");
+NDIS_STRING STRdot11RtsCtsProtection        = NDIS_STRING_CONST( "dot11RtsCtsProtection");
+
+NDIS_STRING STRRxEnergyDetection              = NDIS_STRING_CONST( "RxEnergyDetection" );
+NDIS_STRING STRTxEnergyDetection              = NDIS_STRING_CONST( "TxEnergyDetection" );
+NDIS_STRING STRCrtCalibrationInterval       = NDIS_STRING_CONST( "CrtCalibrationInterval" );
+NDIS_STRING STRTddCalibrationInterval       = NDIS_STRING_CONST( "TddCalibrationInterval" );
+NDIS_STRING STRMacClockRate                 = NDIS_STRING_CONST( "MacClockRate" );
+NDIS_STRING STRArmClockRate                 = NDIS_STRING_CONST( "ArmClockRate" );
+NDIS_STRING STRg80211DraftNumber            = NDIS_STRING_CONST( "g80211DraftNumber" );
+
+NDIS_STRING STRRateAdaptationTable0         = NDIS_STRING_CONST( "RateAdaptationTable0" );
+NDIS_STRING STRRateAdaptationFBThd0         = NDIS_STRING_CONST( "RateAdaptationFBThd0" );
+NDIS_STRING STRRateAdaptationSUThd0         = NDIS_STRING_CONST( "RateAdaptationSUThd0" );
+
+NDIS_STRING STRRateAdaptationTable1         = NDIS_STRING_CONST( "RateAdaptationTable1" );
+NDIS_STRING STRRateAdaptationFBThd1         = NDIS_STRING_CONST( "RateAdaptationFBThd1" );
+NDIS_STRING STRRateAdaptationSUThd1         = NDIS_STRING_CONST( "RateAdaptationSUThd1" );
+
+NDIS_STRING STRRateAdaptationTable2         = NDIS_STRING_CONST( "RateAdaptationTable2" );
+NDIS_STRING STRRateAdaptationFBThd2         = NDIS_STRING_CONST( "RateAdaptationFBThd2" );
+NDIS_STRING STRRateAdaptationSUThd2         = NDIS_STRING_CONST( "RateAdaptationSUThd2" );
+
+NDIS_STRING STRRateAdaptationTable3         = NDIS_STRING_CONST( "RateAdaptationTable3" );
+NDIS_STRING STRRateAdaptationFBThd3         = NDIS_STRING_CONST( "RateAdaptationFBThd3" );
+NDIS_STRING STRRateAdaptationSUThd3         = NDIS_STRING_CONST( "RateAdaptationSUThd3" );
+
+/* Tspec Rate Thresholds */
+NDIS_STRING STRRateAdaptationHighTrshAcVO   = NDIS_STRING_CONST( "RateAdaptationHighTrshAcVO" );
+NDIS_STRING STRRateAdaptationHighTrshAcVI   = NDIS_STRING_CONST( "RateAdaptationHighTrshAcVI" );
+NDIS_STRING STRRateAdaptationHighTrshAcBE   = NDIS_STRING_CONST( "RateAdaptationHighTrshAcBE" );
+NDIS_STRING STRRateAdaptationHighTrshAcBK   = NDIS_STRING_CONST( "RateAdaptationHighTrshAcBK" );
+
+NDIS_STRING STRRateAdaptationLowTrshAcVO   = NDIS_STRING_CONST( "RateAdaptationLowTrshAcVO" );
+NDIS_STRING STRRateAdaptationLowTrshAcVI   = NDIS_STRING_CONST( "RateAdaptationLowTrshAcVI" );
+NDIS_STRING STRRateAdaptationLowTrshAcBE   = NDIS_STRING_CONST( "RateAdaptationLowTrshAcBE" );
+NDIS_STRING STRRateAdaptationLowTrshAcBK   = NDIS_STRING_CONST( "RateAdaptationLowTrshAcBK" );
+
+NDIS_STRING STRdot11ShortPreambleInvoked    = NDIS_STRING_CONST( "dot11ShortPreambleInvoked" );
+
+NDIS_STRING STRdot11BeaconPeriod            = NDIS_STRING_CONST( "dot11BeaconPeriod" );
+NDIS_STRING STRdot11MaxScanTime             = NDIS_STRING_CONST( "dot11MaxScanTime" );
+NDIS_STRING STRdot11MinScanTime             = NDIS_STRING_CONST( "dot11MinScanTime" );
+NDIS_STRING STRdot11MaxSiteLifetime         = NDIS_STRING_CONST( "dot11MaxSiteLifetime" );
+
+NDIS_STRING STRdot11MaxAuthRetry            = NDIS_STRING_CONST( "dot11MaxAuthRetry" );
+NDIS_STRING STRdot11MaxAssocRetry           = NDIS_STRING_CONST( "dot11MaxAssocRetry" );
+NDIS_STRING STRdot11AuthRespTimeout         = NDIS_STRING_CONST( "dot11AuthenticationResponseTimeout" );
+NDIS_STRING STRdot11AssocRespTimeout        = NDIS_STRING_CONST( "dot11AssociationResponseTimeout" );
+
+NDIS_STRING STRConnSelfTimeout              = NDIS_STRING_CONST( "ConnSelfTimeout" );
+
+NDIS_STRING STRNumTxDataQueues              = NDIS_STRING_CONST( "NumTxDataQueues" );
+NDIS_STRING STRCreditCalcTimout             = NDIS_STRING_CONST( "CreditCalcTimout" );
+NDIS_STRING STRCreditCalcTimerEnabled       = NDIS_STRING_CONST( "CreditCalcTimerEnabled" );
+NDIS_STRING STRFracOfLifeTimeToDrop         = NDIS_STRING_CONST( "FracOfLifeTimeToDrop" );
+NDIS_STRING STRAdmCtrlDelayDueToMediumTimeOverUsage = NDIS_STRING_CONST( "AdmCtrlDelayDueToMediumTimeOverUsage" );
+NDIS_STRING STRAdmissionDownGradeEnable     = NDIS_STRING_CONST( "AdmissionDownGradeEnable" );
+
+NDIS_STRING STRTrafficAdmControlTimeout     = NDIS_STRING_CONST("TrafficAdmControlTimeout");
+NDIS_STRING STRTrafficAdmControlUseFixedMsduSize = NDIS_STRING_CONST("TrafficAdmCtrlUseFixedMsduSize");
+NDIS_STRING STRDesiredMaxSpLen              = NDIS_STRING_CONST("DesiredMaxSpLen");
+
+NDIS_STRING STRRateContThreshold            = NDIS_STRING_CONST( "RateContThreshold");
+NDIS_STRING STRRateStepUpThreshold          = NDIS_STRING_CONST( "RateStepUpThreshold");
+NDIS_STRING STRFBShortInterval              = NDIS_STRING_CONST( "FBShortInterval");
+NDIS_STRING STRFBLongInterval               = NDIS_STRING_CONST( "FBLongInterval");
+NDIS_STRING STRRateAdaptationTimeout        = NDIS_STRING_CONST( "RateAdaptationTimeout");
+NDIS_STRING STRRateControlEnable            = NDIS_STRING_CONST( "RateControlEnable" );
+
+NDIS_STRING STRRatePolicyUserShortRetryLimit   = NDIS_STRING_CONST( "RatePolicyUserShortRetryLimit" );
+NDIS_STRING STRRatePolicyUserLongRetryLimit    = NDIS_STRING_CONST( "RatePolicyUserLongRetryLimit" );
+NDIS_STRING STRRatePolicyUserRetriesPerRateCck     = NDIS_STRING_CONST( "RatePolicyUserRetriesPerRateCck" );
+NDIS_STRING STRRatePolicyUserRetriesPerRatePbcc    = NDIS_STRING_CONST( "RatePolicyUserRetriesPerRatePbcc" );
+NDIS_STRING STRRatePolicyUserRetriesPerRateOfdm    = NDIS_STRING_CONST( "RatePolicyUserRetriesPerRateOfdm" );
+NDIS_STRING STRRatePolicyUserRetriesPerRateOfdmA   = NDIS_STRING_CONST( "RatePolicyUserRetriesPerRateOfdmA" );
+
+NDIS_STRING STRRatePolicySGShortRetryLimit   = NDIS_STRING_CONST( "RatePolicySGShortRetryLimit" );
+NDIS_STRING STRRatePolicySGLongRetryLimit    = NDIS_STRING_CONST( "RatePolicySGLongRetryLimit" );
+NDIS_STRING STRRatePolicySGRetriesPerRateCck     = NDIS_STRING_CONST( "RatePolicySGRetriesPerRateCck" );
+NDIS_STRING STRRatePolicySGRetriesPerRatePbcc    = NDIS_STRING_CONST( "RatePolicySGRetriesPerRatePbcc" );
+NDIS_STRING STRRatePolicySGRetriesPerRateOfdm    = NDIS_STRING_CONST( "RatePolicySGRetriesPerRateOfdm" );
+NDIS_STRING STRRatePolicySGRetriesPerRateOfdmA   = NDIS_STRING_CONST( "RatePolicySGRetriesPerRateOfdmA" );
+
+
+NDIS_STRING STRdot11FourXEnable             = NDIS_STRING_CONST( "Mode4x" );
+
+NDIS_STRING STRdot11AuthenticationMode      = NDIS_STRING_CONST( "dot11AuthenticationMode" );
+NDIS_STRING STRdot11WEPStatus               = NDIS_STRING_CONST( "dot11WEPStatus" );
+NDIS_STRING STRdot11ExcludeUnencrypted      = NDIS_STRING_CONST( "dot11ExcludeUnencrypted" );
+NDIS_STRING STRdot11WEPKeymappingLength     = NDIS_STRING_CONST( "dot11WEPKeymappingLength" );
+NDIS_STRING STRdot11WEPDefaultKeyID         = NDIS_STRING_CONST( "dot11WEPDefaultKeyID" );
+
+NDIS_STRING STRMixedMode                    = NDIS_STRING_CONST( "MixedMode" );
+
+NDIS_STRING STRWPAMixedMode                  = NDIS_STRING_CONST( "WPAMixedMode");
+NDIS_STRING STRRSNPreAuth                    = NDIS_STRING_CONST( "RSNPreAuthentication");
+NDIS_STRING STRRSNPreAuthTimeout             = NDIS_STRING_CONST( "RSNPreAuthTimeout" );
+
+NDIS_STRING STRTimeToResetCountryMs         = NDIS_STRING_CONST( "TimeToResetCountryMs" );
+NDIS_STRING STRMultiRegulatoryDomainEnabled = NDIS_STRING_CONST( "MultiRegulatoryDomain" );
+NDIS_STRING STRSpectrumManagementEnabled    = NDIS_STRING_CONST( "SpectrumManagement" );
+NDIS_STRING STRScanControlTable24           = NDIS_STRING_CONST( "AllowedChannelsTable24" );
+NDIS_STRING STRScanControlTable5            = NDIS_STRING_CONST( "AllowedChannelsTable5" );
+
+/*
+Power Manager
+*/
+NDIS_STRING STRPowerMode                    = NDIS_STRING_CONST( "dot11PowerMode" );
+NDIS_STRING STRBeaconReceiveTime            = NDIS_STRING_CONST( "BeaconReceiveTime" );
+NDIS_STRING STRBaseBandWakeUpTime           = NDIS_STRING_CONST( "BaseBandWakeUpTime" );
+NDIS_STRING STRHangoverPeriod               = NDIS_STRING_CONST( "HangoverPeriod" );
+NDIS_STRING STRBeaconListenInterval         = NDIS_STRING_CONST( "BeaconListenInterval" );
+NDIS_STRING STRDtimListenInterval         = NDIS_STRING_CONST( "DtimListenInterval" );
+NDIS_STRING STRNConsecutiveBeaconsMissed    = NDIS_STRING_CONST( "NConsecutiveBeaconsMissed" );
+NDIS_STRING STREnterTo802_11PsRetries       = NDIS_STRING_CONST( "EnterTo802_11PsRetries" );
+NDIS_STRING STRAutoPowerModeInterval        = NDIS_STRING_CONST( "AutoPowerModeInterval" );
+NDIS_STRING STRAutoPowerModeActiveTh        = NDIS_STRING_CONST( "AutoPowerModeActiveTh" );
+NDIS_STRING STRAutoPowerModeDozeTh          = NDIS_STRING_CONST( "AutoPowerModeDozeTh" );
+NDIS_STRING STRAutoPowerModeDozeMode        = NDIS_STRING_CONST( "AutoPowerModeDozeMode" );
+NDIS_STRING STRDefaultPowerLevel        = NDIS_STRING_CONST( "defaultPowerLevel" );
+NDIS_STRING STRPowerSavePowerLevel  = NDIS_STRING_CONST( "PowerSavePowerLevel" );
+
+NDIS_STRING STRPsPollDeliveryFailureRecoveryPeriod     = NDIS_STRING_CONST( "PsPollDeliveryFailureRecoveryPeriod" );
+
+NDIS_STRING STRPowerMgmtHangOverPeriod      = NDIS_STRING_CONST( "PowerMgmtHangOverPeriod" );
+NDIS_STRING STRPowerMgmtMode                = NDIS_STRING_CONST( "PowerMgmtMode" );
+NDIS_STRING STRPowerMgmtNeedToSendNullData  = NDIS_STRING_CONST( "PowerMgmtNeedToSendNullData" );
+NDIS_STRING STRPowerMgmtNullPktRateModulation = NDIS_STRING_CONST( "PowerMgmtNullPktRateModulation" );
+NDIS_STRING STRPowerMgmtNumNullPktRetries   = NDIS_STRING_CONST( "PowerMgmtNumNullPktRetries" );
+NDIS_STRING STRPowerMgmtPllLockTime         = NDIS_STRING_CONST( "PllLockTime" );
+
+NDIS_STRING STRBeaconRxTimeout     = NDIS_STRING_CONST( "BeaconRxTimeout" );
+NDIS_STRING STRBroadcastRxTimeout  = NDIS_STRING_CONST( "BroadcastRxTimeout" );
+NDIS_STRING STRRxBroadcastInPs     = NDIS_STRING_CONST( "RxBroadcastInPs" );
+
+NDIS_STRING STRConsecutivePsPollDeliveryFailureThreshold = NDIS_STRING_CONST( "ConsecutivePsPollDeliveryFailureThreshold" );
+
+NDIS_STRING STRTxPower                      = NDIS_STRING_CONST( "TxPower" );
+
+/* Scan SRV */
+NDIS_STRING STRNumberOfNoScanCompleteToRecovery         = NDIS_STRING_CONST( "NumberOfNoScanCompleteToRecovery" );
+NDIS_STRING STRTriggeredScanTimeOut                     = NDIS_STRING_CONST( "TriggeredScanTimeOut" );
+
+/*-----------------------------------*/
+/*   Bluetooth support               */
+/*-----------------------------------*/
+NDIS_STRING STRBThWlanCoexistEnable                     = NDIS_STRING_CONST( "BThWlanCoexistEnable" );
+NDIS_STRING STRBThWlanCoexistRate                       = NDIS_STRING_CONST( "BThWlanCoexistRate" );
+NDIS_STRING STRBThWlanCoexistParamsbtHpMaxTime          = NDIS_STRING_CONST( "BThWlanCoexistParamsbtHpMaxTime" );
+NDIS_STRING STRBThWlanCoexistParamswlanHpMaxTime            = NDIS_STRING_CONST( "BThWlanCoexistParamswlanHpMaxTime" );
+NDIS_STRING STRBThWlanCoexistParamssenseDisableTimer        = NDIS_STRING_CONST( "BThWlanCoexistParamssenseDisableTimer" );
+NDIS_STRING STRBThWlanCoexistParamsprotectiveRxTimeBeforeBtHp       = NDIS_STRING_CONST( "BThWlanCoexistParamsprotectiveRxTimeBeforeBtHp" );
+NDIS_STRING STRBThWlanCoexistParamsprotectiveTxTimeBeforeBtHp           = NDIS_STRING_CONST( "BThWlanCoexistParamstimeoutWlanPacketCount" );
+NDIS_STRING STRBThWlanCoexistParamsprotectiveRxTimeBeforeBtHpFastAp     = NDIS_STRING_CONST( "BThWlanCoexistParamsprotectiveRxTimeBeforeBtHpFastAp" );
+NDIS_STRING STRBThWlanCoexistParamsprotectiveTxTimeBeforeBtHpFastAp     = NDIS_STRING_CONST( "BThWlanCoexistParamsprotectiveTxTimeBeforeBtHpFastAp" );
+NDIS_STRING STRBThWlanCoexistParamsprotectiveWlanCycleTimeForFastAp     = NDIS_STRING_CONST( "BThWlanCoexistParamsprotectiveWlanCycleTimeForFastAp" );
+NDIS_STRING STRBThWlanCoexistParamstimeoutNextBtLpPacket = NDIS_STRING_CONST( "BThWlanCoexistParamstimeoutNextBtLpPacket" );
+NDIS_STRING STRBThWlanCoexistParamssgAntennaType        = NDIS_STRING_CONST( "BThWlanCoexistParamssgAntennaType" );
+NDIS_STRING STRBThWlanCoexistParamssignalingType        = NDIS_STRING_CONST( "BThWlanCoexistParamssignalingType" );
+NDIS_STRING STRBThWlanCoexistParamsafhLeverageOn    = NDIS_STRING_CONST( "BThWlanCoexistParamsafhLeverageOn" );
+NDIS_STRING STRBThWlanCoexistParamsnumberQuietCycle         = NDIS_STRING_CONST( "BThWlanCoexistParamsnumberQuietCycle" );
+NDIS_STRING STRBThWlanCoexistParamsmaxNumCts    = NDIS_STRING_CONST( "BThWlanCoexistParamsmaxNumCts" );
+NDIS_STRING STRBThWlanCoexistParamsnumberOfWlanPackets          = NDIS_STRING_CONST( "BThWlanCoexistParamsnumberOfWlanPackets" );
+NDIS_STRING STRBThWlanCoexistParamsnumberOfBtPackets            = NDIS_STRING_CONST( "BThWlanCoexistParamsnumberOfBtPackets" );
+NDIS_STRING STRBThWlanCoexistParamsnumberOfMissedRxForAvalancheTrigger          = NDIS_STRING_CONST( "BThWlanCoexistParamsnumberOfMissedRxForAvalancheTrigger" );
+NDIS_STRING STRBThWlanCoexistParamswlanElpHpSupport         = NDIS_STRING_CONST( "BThWlanCoexistParamswlanElpHpSupport" );
+NDIS_STRING STRBThWlanCoexistParamsbtAntiStarvationPeriod           = NDIS_STRING_CONST( "BThWlanCoexistParamsbtAntiStarvationPeriod" );
+NDIS_STRING STRBThWlanCoexistParamsbtAntiStarvationNumberOfCyclesWithinThePeriod            = NDIS_STRING_CONST( "BThWlanCoexistParamsbtAntiStarvationNumberOfCyclesWithinThePeriod" );
+NDIS_STRING STRBThWlanCoexistParamsackModeDuringBtLpInDualAnt            = NDIS_STRING_CONST( "BThWlanCoexistParamsackModeDuringBtLpInDualAnt" );
+NDIS_STRING STRBThWlanCoexistParamsallowPaSdToggleDuringBtActivityEnable = NDIS_STRING_CONST( "BThWlanCoexistParamsallowPaSdToggleDuringBtActivityEnable" );
+NDIS_STRING STRBThWlanCoexistParamswakeUpTimeBeforeBeacon            = NDIS_STRING_CONST( "BThWlanCoexistParamswakeUpTimeBeforeBeacon" );
+
+NDIS_STRING STRBThWlanCoexistParamshpdmMaxGuardTime = NDIS_STRING_CONST( "BThWlanCoexistParamshpdmMaxGuardTime" );
+NDIS_STRING STRBThWlanCoexistParamstimeoutNextWlanPacket = NDIS_STRING_CONST( "BThWlanCoexistParamstimeoutNextWlanPacket" );
+NDIS_STRING STRBThWlanCoexistParamssgAutoModeNoCts = NDIS_STRING_CONST( "BThWlanCoexistParamssgAutoModeNoCts" );
+NDIS_STRING STRBThWlanCoexistParamsnumOfBtHpRespectedReq = NDIS_STRING_CONST( "BThWlanCoexistParamsnumOfBtHpRespectedReq" );
+NDIS_STRING STRBThWlanCoexistParamswlanRxMinRateToRespectBtHp = NDIS_STRING_CONST( "BThWlanCoexistParamswlanRxMinRateToRespectBtHp" );
+
+NDIS_STRING STRBThWlanCoexistScanNumberOfProbes                 = NDIS_STRING_CONST( "BThWlanCoexistScanNumberOfProbes" );
+NDIS_STRING STRBThWlanCoexistScanCompensationPercent            = NDIS_STRING_CONST( "BThWlanCoexistScanCompensationPercent" );
+NDIS_STRING STRBThWlanCoexistScanCompensationMaxTime            = NDIS_STRING_CONST( "BThWlanCoexistScanCompensationMaxTime" );
+NDIS_STRING STRBThWlanCoexistBSSLossCompensationPercent         = NDIS_STRING_CONST( "BThWlanCoexistBSSLossCompensationPercent" );
+
+NDIS_STRING STRDisableSsidPending           = NDIS_STRING_CONST( "DisableSsidPending" );
+
+/*-----------------------------------*/
+/*   SME Init Params                 */
+/*-----------------------------------*/
+NDIS_STRING STRdot11SmeScanEnabled          = NDIS_STRING_CONST( "FirstConnScanEnabled" );
+NDIS_STRING STRdot11SmeInterScanMin         = NDIS_STRING_CONST( "FirstConnInterScanMinTimout" );
+NDIS_STRING STRdot11SmeInterScanMax         = NDIS_STRING_CONST( "FirstConnInterScanMaxTimout" );
+NDIS_STRING STRdot11SmeInterScanDelta       = NDIS_STRING_CONST( "FirstConnInterScanDeltaTimout" );
+
+/*      SME B/G Scan Params             */
+NDIS_STRING STRdot11SmeScanBGChannelList    = NDIS_STRING_CONST( "FirstConnScanBandB_ChannelList" );
+NDIS_STRING STRdot11SmeScanBGMinDwellTime   = NDIS_STRING_CONST( "FirstConnScanBandB_MinDwellTime" );
+NDIS_STRING STRdot11SmeScanBGMaxDwellTime   = NDIS_STRING_CONST( "FirstConnScanBandB_MaxDwellTime" );
+NDIS_STRING STRdot11SmeScanBGNumProbReq     = NDIS_STRING_CONST( "FirstConnScanBandB_NumOfProbReqs" );
+NDIS_STRING STRdot11SmeScanBGProbReqRate    = NDIS_STRING_CONST( "FirstConnScanBandB_ProbReqRate" );
+NDIS_STRING STRdot11SmeScanBGTxPowerLevel   = NDIS_STRING_CONST( "FirstConnScanBandB_TxPowerLevel" );
+
+/*      SME A Scan Params           */
+NDIS_STRING STRdot11SmeScanAChannelList     = NDIS_STRING_CONST( "FirstConnScanBandA_ChannelList" );
+NDIS_STRING STRdot11SmeScanAMinDwellTime    = NDIS_STRING_CONST( "FirstConnScanBandA_MinDwellTime" );
+NDIS_STRING STRdot11SmeScanAMaxDwellTime    = NDIS_STRING_CONST( "FirstConnScanBandA_MaxDwellTime" );
+NDIS_STRING STRdot11SmeScanANumProbReq      = NDIS_STRING_CONST( "FirstConnScanBandA_NumOfProbReqs" );
+NDIS_STRING STRdot11SmeScanAProbReqRate     = NDIS_STRING_CONST( "FirstConnScanBandA_ProbReqRate" );
+NDIS_STRING STRdot11SmeScanATxPowerLevel    = NDIS_STRING_CONST( "FirstConnScanBandA_TxPowerLevel" );
+
+
+/*-----------------------------------*/
+/*   Health Check Init Params        */
+/*-----------------------------------*/
+NDIS_STRING STRHealthMonitorCheckPeriod         = NDIS_STRING_CONST( "HealthMonitorCheckPeriod" );
+NDIS_STRING STRRecoveryEnabledNoScanComplete    = NDIS_STRING_CONST( "RecoveryEnabledNoScanComplete" );
+NDIS_STRING STRRecoveryEnabledMboxFailure       = NDIS_STRING_CONST( "RecoveryEnabledMboxFailure" );
+NDIS_STRING STRRecoveryEnabledHwAwakeFailure    = NDIS_STRING_CONST( "RecoveryEnabledHwAwakeFailure" );
+NDIS_STRING STRRecoveryEnabledBusError          = NDIS_STRING_CONST( "RecoveryEnabledBusError" );
+NDIS_STRING STRRecoveryEnabledDeviceError       = NDIS_STRING_CONST( "RecoveryEnabledDeviceError" );
+NDIS_STRING STRRecoveryEnabledTxStuck           = NDIS_STRING_CONST( "RecoveryEnabledTxStuck" );
+NDIS_STRING STRRecoveryEnabledDisconnectTimeout = NDIS_STRING_CONST( "RecoveryEnabledDisconnectTimeout" );
+NDIS_STRING STRRecoveryEnabledPowerSaveFailure  = NDIS_STRING_CONST( "RecoveryEnabledPowerSaveFailure" );
+NDIS_STRING STRRecoveryEnabledMeasurementFailure= NDIS_STRING_CONST( "RecoveryEnabledMeasurementFailure" );
+
+/*-----------------------------------*/
+/*   Hardware ACI recovery           */
+/*-----------------------------------*/
+NDIS_STRING STRHardwareACIMode                  = NDIS_STRING_CONST("HardwareACIMode" );
+NDIS_STRING STRHardwareACIInputCCA              = NDIS_STRING_CONST("HardwareACIInputCCA" );
+NDIS_STRING STRHardwareACIQualifiedCCA          = NDIS_STRING_CONST("HardwareACIQualifiedCCA" );
+NDIS_STRING STRHardwareACIStompForRx            = NDIS_STRING_CONST("HardwareACIStompForRx" );
+NDIS_STRING STRHardwareACIStompForTx            = NDIS_STRING_CONST("HardwareACIStompForTx" );
+NDIS_STRING STRHardwareACITxCCA                 = NDIS_STRING_CONST("HardwareACITxCCA" );
+
+/*-----------------------------------*/
+/* Tx Power control     */
+/*-----------------------------------*/
+NDIS_STRING STRTxPowerCheckTime                 = NDIS_STRING_CONST("TxPowerCheckTime");
+NDIS_STRING STRTxPowerControlOn                 = NDIS_STRING_CONST("TxPowerControlOn");
+NDIS_STRING STRTxPowerRssiThresh                = NDIS_STRING_CONST("TxPowerRssiThresh");
+NDIS_STRING STRTxPowerRssiRestoreThresh         = NDIS_STRING_CONST("TxPowerRssiRestoreThresh");
+NDIS_STRING STRTxPowerTempRecover              = NDIS_STRING_CONST("TxPowerTempRecover");
+
+
+/*-----------------------------------*/
+/*-----------------------------------*/
+/*        QOS Parameters             */
+/*-----------------------------------*/
+NDIS_STRING STRWMEEnable                        = NDIS_STRING_CONST("WME_Enable");
+NDIS_STRING STRTrafficAdmCtrlEnable             = NDIS_STRING_CONST("TrafficAdmCtrl_Enable");
+NDIS_STRING STRdesiredPsMode                    = NDIS_STRING_CONST("desiredPsMode");
+NDIS_STRING STRQOSmsduLifeTimeBE                = NDIS_STRING_CONST("QOS_msduLifeTimeBE");
+NDIS_STRING STRQOSmsduLifeTimeBK                = NDIS_STRING_CONST("QOS_msduLifeTimeBK");
+NDIS_STRING STRQOSmsduLifeTimeVI                = NDIS_STRING_CONST("QOS_msduLifeTimeVI");
+NDIS_STRING STRQOSmsduLifeTimeVO                = NDIS_STRING_CONST("QOS_msduLifeTimeVO");
+NDIS_STRING STRQOSrxTimeOutPsPoll               = NDIS_STRING_CONST("QOS_rxTimeoutPsPoll");
+NDIS_STRING STRQOSrxTimeOutUPSD                 = NDIS_STRING_CONST("QOS_rxTimeoutUPSD");
+NDIS_STRING STRQOStxQueue0Size                  = NDIS_STRING_CONST("QOS_txQueue0Size");
+NDIS_STRING STRQOStxQueue1Size                  = NDIS_STRING_CONST("QOS_txQueue1Size");
+NDIS_STRING STRQOStxQueue2Size                  = NDIS_STRING_CONST("QOS_txQueue2Size");
+NDIS_STRING STRQOStxQueue3Size                  = NDIS_STRING_CONST("QOS_txQueue3Size");
+NDIS_STRING STRQOSwmePsModeBE                   = NDIS_STRING_CONST("QOS_wmePsModeBE");
+NDIS_STRING STRQOSwmePsModeBK                   = NDIS_STRING_CONST("QOS_wmePsModeBK");
+NDIS_STRING STRQOSwmePsModeVI                   = NDIS_STRING_CONST("QOS_wmePsModeVI");
+NDIS_STRING STRQOSwmePsModeVO                   = NDIS_STRING_CONST("QOS_wmePsModeVO");
+NDIS_STRING STRQOSShortRetryLimitBE             = NDIS_STRING_CONST("QOS_ShortRetryLimitBE");
+NDIS_STRING STRQOSShortRetryLimitBK             = NDIS_STRING_CONST("QOS_ShortRetryLimitBK");
+NDIS_STRING STRQOSShortRetryLimitVI             = NDIS_STRING_CONST("QOS_ShortRetryLimitVI");
+NDIS_STRING STRQOSShortRetryLimitVO             = NDIS_STRING_CONST("QOS_ShortRetryLimitVO");
+NDIS_STRING STRQOSLongRetryLimitBE              = NDIS_STRING_CONST("QOS_LongRetryLimitBE");
+NDIS_STRING STRQOSLongRetryLimitBK              = NDIS_STRING_CONST("QOS_LongRetryLimitBK");
+NDIS_STRING STRQOSLongRetryLimitVI              = NDIS_STRING_CONST("QOS_LongRetryLimitVI");
+NDIS_STRING STRQOSLongRetryLimitVO              = NDIS_STRING_CONST("QOS_LongRetryLimitVO");
+
+NDIS_STRING STRQOSAckPolicyBE                   = NDIS_STRING_CONST("QOS_AckPolicyBE");
+NDIS_STRING STRQOSAckPolicyBK                   = NDIS_STRING_CONST("QOS_AckPolicyBK");
+NDIS_STRING STRQOSAckPolicyVI                   = NDIS_STRING_CONST("QOS_AckPolicyVI");
+NDIS_STRING STRQOSAckPolicyVO                   = NDIS_STRING_CONST("QOS_AckPolicyVO");
+NDIS_STRING STRQoSqueue0OverFlowPolicy          = NDIS_STRING_CONST("QOS_queue0OverFlowPolicy");
+NDIS_STRING STRQoSqueue1OverFlowPolicy          = NDIS_STRING_CONST("QOS_queue1OverFlowPolicy");
+NDIS_STRING STRQoSqueue2OverFlowPolicy          = NDIS_STRING_CONST("QOS_queue2OverFlowPolicy");
+NDIS_STRING STRQoSqueue3OverFlowPolicy          = NDIS_STRING_CONST("QOS_queue3OverFlowPolicy");
+
+
+
+/* HW Tx queues buffers allocation thresholds */
+NDIS_STRING STRQOStxBlksHighPrcntBE             = NDIS_STRING_CONST("QOS_txBlksHighPrcntBE");
+NDIS_STRING STRQOStxBlksHighPrcntBK             = NDIS_STRING_CONST("QOS_txBlksHighPrcntBK");
+NDIS_STRING STRQOStxBlksHighPrcntVI             = NDIS_STRING_CONST("QOS_txBlksHighPrcntVI");
+NDIS_STRING STRQOStxBlksHighPrcntVO             = NDIS_STRING_CONST("QOS_txBlksHighPrcntVO");
+NDIS_STRING STRQOStxBlksLowPrcntBE              = NDIS_STRING_CONST("QOS_txBlksLowPrcntBE");
+NDIS_STRING STRQOStxBlksLowPrcntBK              = NDIS_STRING_CONST("QOS_txBlksLowPrcntBK");
+NDIS_STRING STRQOStxBlksLowPrcntVI              = NDIS_STRING_CONST("QOS_txBlksLowPrcntVI");
+NDIS_STRING STRQOStxBlksLowPrcntVO              = NDIS_STRING_CONST("QOS_txBlksLowPrcntVO");
+
+/* Traffic Intensity parameters*/
+NDIS_STRING STRTrafficIntensityThresHigh        = NDIS_STRING_CONST("TrafficIntensityThresHigh");
+NDIS_STRING STRTrafficIntensityThresLow         = NDIS_STRING_CONST("TrafficIntensityThresLow");
+NDIS_STRING STRTrafficIntensityTestInterval     = NDIS_STRING_CONST("TrafficIntensityTestInterval");
+NDIS_STRING STRTrafficIntensityThresholdEnabled = NDIS_STRING_CONST("TrafficIntensityThresholdEnabled");
+NDIS_STRING STRTrafficMonitorMinIntervalPercentage = NDIS_STRING_CONST("TrafficMonitorMinIntervalPercent");
+
+
+/* Packet Burst parameters */
+NDIS_STRING STRQOSPacketBurstEnable             = NDIS_STRING_CONST("QOS_PacketBurstEnable");
+NDIS_STRING STRQOSPacketBurstTxOpLimit          = NDIS_STRING_CONST("QOS_PacketBurstTxOpLimit");
+
+/*-----------------------------------*/
+/*        QOS classifier Parameters  */
+/*-----------------------------------*/
+NDIS_STRING STRClsfr_Type                       = NDIS_STRING_CONST("Clsfr_Type");
+NDIS_STRING STRNumOfCodePoints                  = NDIS_STRING_CONST("NumOfCodePoints");
+NDIS_STRING STRNumOfDstPortClassifiers          = NDIS_STRING_CONST("NumOfDstPortClassifiers");
+NDIS_STRING STRNumOfDstIPPortClassifiers        = NDIS_STRING_CONST("NumOfDstIPPortClassifiers");
+
+NDIS_STRING STRDSCPClassifier00_CodePoint       = NDIS_STRING_CONST("DSCPClassifier00_CodePoint");
+NDIS_STRING STRDSCPClassifier01_CodePoint       = NDIS_STRING_CONST("DSCPClassifier01_CodePoint");
+NDIS_STRING STRDSCPClassifier02_CodePoint       = NDIS_STRING_CONST("DSCPClassifier02_CodePoint");
+NDIS_STRING STRDSCPClassifier03_CodePoint       = NDIS_STRING_CONST("DSCPClassifier03_CodePoint");
+NDIS_STRING STRDSCPClassifier04_CodePoint       = NDIS_STRING_CONST("DSCPClassifier04_CodePoint");
+NDIS_STRING STRDSCPClassifier05_CodePoint       = NDIS_STRING_CONST("DSCPClassifier05_CodePoint");
+NDIS_STRING STRDSCPClassifier06_CodePoint       = NDIS_STRING_CONST("DSCPClassifier06_CodePoint");
+NDIS_STRING STRDSCPClassifier07_CodePoint       = NDIS_STRING_CONST("DSCPClassifier07_CodePoint");
+NDIS_STRING STRDSCPClassifier08_CodePoint       = NDIS_STRING_CONST("DSCPClassifier08_CodePoint");
+NDIS_STRING STRDSCPClassifier09_CodePoint       = NDIS_STRING_CONST("DSCPClassifier09_CodePoint");
+NDIS_STRING STRDSCPClassifier10_CodePoint       = NDIS_STRING_CONST("DSCPClassifier10_CodePoint");
+NDIS_STRING STRDSCPClassifier11_CodePoint       = NDIS_STRING_CONST("DSCPClassifier11_CodePoint");
+NDIS_STRING STRDSCPClassifier12_CodePoint       = NDIS_STRING_CONST("DSCPClassifier12_CodePoint");
+NDIS_STRING STRDSCPClassifier13_CodePoint       = NDIS_STRING_CONST("DSCPClassifier13_CodePoint");
+NDIS_STRING STRDSCPClassifier14_CodePoint       = NDIS_STRING_CONST("DSCPClassifier14_CodePoint");
+NDIS_STRING STRDSCPClassifier15_CodePoint       = NDIS_STRING_CONST("DSCPClassifier15_CodePoint");
+
+NDIS_STRING STRDSCPClassifier00_DTag        = NDIS_STRING_CONST("DSCPClassifier00_DTag");
+NDIS_STRING STRDSCPClassifier01_DTag        = NDIS_STRING_CONST("DSCPClassifier01_DTag");
+NDIS_STRING STRDSCPClassifier02_DTag        = NDIS_STRING_CONST("DSCPClassifier02_DTag");
+NDIS_STRING STRDSCPClassifier03_DTag        = NDIS_STRING_CONST("DSCPClassifier03_DTag");
+NDIS_STRING STRDSCPClassifier04_DTag        = NDIS_STRING_CONST("DSCPClassifier04_DTag");
+NDIS_STRING STRDSCPClassifier05_DTag        = NDIS_STRING_CONST("DSCPClassifier05_DTag");
+NDIS_STRING STRDSCPClassifier06_DTag        = NDIS_STRING_CONST("DSCPClassifier06_DTag");
+NDIS_STRING STRDSCPClassifier07_DTag        = NDIS_STRING_CONST("DSCPClassifier07_DTag");
+NDIS_STRING STRDSCPClassifier08_DTag        = NDIS_STRING_CONST("DSCPClassifier08_DTag");
+NDIS_STRING STRDSCPClassifier09_DTag        = NDIS_STRING_CONST("DSCPClassifier09_DTag");
+NDIS_STRING STRDSCPClassifier10_DTag        = NDIS_STRING_CONST("DSCPClassifier10_DTag");
+NDIS_STRING STRDSCPClassifier11_DTag        = NDIS_STRING_CONST("DSCPClassifier11_DTag");
+NDIS_STRING STRDSCPClassifier12_DTag        = NDIS_STRING_CONST("DSCPClassifier12_DTag");
+NDIS_STRING STRDSCPClassifier13_DTag        = NDIS_STRING_CONST("DSCPClassifier13_DTag");
+NDIS_STRING STRDSCPClassifier14_DTag        = NDIS_STRING_CONST("DSCPClassifier14_DTag");
+NDIS_STRING STRDSCPClassifier15_DTag        = NDIS_STRING_CONST("DSCPClassifier15_DTag");
+
+
+NDIS_STRING STRPortClassifier00_Port            = NDIS_STRING_CONST("PortClassifier00_Port");
+NDIS_STRING STRPortClassifier01_Port            = NDIS_STRING_CONST("PortClassifier01_Port");
+NDIS_STRING STRPortClassifier02_Port            = NDIS_STRING_CONST("PortClassifier02_Port");
+NDIS_STRING STRPortClassifier03_Port            = NDIS_STRING_CONST("PortClassifier03_Port");
+NDIS_STRING STRPortClassifier04_Port            = NDIS_STRING_CONST("PortClassifier04_Port");
+NDIS_STRING STRPortClassifier05_Port            = NDIS_STRING_CONST("PortClassifier05_Port");
+NDIS_STRING STRPortClassifier06_Port            = NDIS_STRING_CONST("PortClassifier06_Port");
+NDIS_STRING STRPortClassifier07_Port            = NDIS_STRING_CONST("PortClassifier07_Port");
+NDIS_STRING STRPortClassifier08_Port            = NDIS_STRING_CONST("PortClassifier08_Port");
+NDIS_STRING STRPortClassifier09_Port            = NDIS_STRING_CONST("PortClassifier09_Port");
+NDIS_STRING STRPortClassifier10_Port            = NDIS_STRING_CONST("PortClassifier10_Port");
+NDIS_STRING STRPortClassifier11_Port            = NDIS_STRING_CONST("PortClassifier11_Port");
+NDIS_STRING STRPortClassifier12_Port            = NDIS_STRING_CONST("PortClassifier12_Port");
+NDIS_STRING STRPortClassifier13_Port            = NDIS_STRING_CONST("PortClassifier13_Port");
+NDIS_STRING STRPortClassifier14_Port            = NDIS_STRING_CONST("PortClassifier14_Port");
+NDIS_STRING STRPortClassifier15_Port            = NDIS_STRING_CONST("PortClassifier15_Port");
+
+NDIS_STRING STRPortClassifier00_DTag            = NDIS_STRING_CONST("PortClassifier00_DTag");
+NDIS_STRING STRPortClassifier01_DTag            = NDIS_STRING_CONST("PortClassifier01_DTag");
+NDIS_STRING STRPortClassifier02_DTag            = NDIS_STRING_CONST("PortClassifier02_DTag");
+NDIS_STRING STRPortClassifier03_DTag            = NDIS_STRING_CONST("PortClassifier03_DTag");
+NDIS_STRING STRPortClassifier04_DTag            = NDIS_STRING_CONST("PortClassifier04_DTag");
+NDIS_STRING STRPortClassifier05_DTag            = NDIS_STRING_CONST("PortClassifier05_DTag");
+NDIS_STRING STRPortClassifier06_DTag            = NDIS_STRING_CONST("PortClassifier06_DTag");
+NDIS_STRING STRPortClassifier07_DTag            = NDIS_STRING_CONST("PortClassifier07_DTag");
+NDIS_STRING STRPortClassifier08_DTag            = NDIS_STRING_CONST("PortClassifier08_DTag");
+NDIS_STRING STRPortClassifier09_DTag            = NDIS_STRING_CONST("PortClassifier09_DTag");
+NDIS_STRING STRPortClassifier10_DTag            = NDIS_STRING_CONST("PortClassifier10_DTag");
+NDIS_STRING STRPortClassifier11_DTag            = NDIS_STRING_CONST("PortClassifier11_DTag");
+NDIS_STRING STRPortClassifier12_DTag            = NDIS_STRING_CONST("PortClassifier12_DTag");
+NDIS_STRING STRPortClassifier13_DTag            = NDIS_STRING_CONST("PortClassifier13_DTag");
+NDIS_STRING STRPortClassifier14_DTag            = NDIS_STRING_CONST("PortClassifier14_DTag");
+NDIS_STRING STRPortClassifier15_DTag            = NDIS_STRING_CONST("PortClassifier15_DTag");
+
+NDIS_STRING STRIPPortClassifier00_IPAddress     = NDIS_STRING_CONST("IPPortClassifier00_IPAddress");
+NDIS_STRING STRIPPortClassifier01_IPAddress     = NDIS_STRING_CONST("IPPortClassifier01_IPAddress");
+NDIS_STRING STRIPPortClassifier02_IPAddress     = NDIS_STRING_CONST("IPPortClassifier02_IPAddress");
+NDIS_STRING STRIPPortClassifier03_IPAddress     = NDIS_STRING_CONST("IPPortClassifier03_IPAddress");
+NDIS_STRING STRIPPortClassifier04_IPAddress     = NDIS_STRING_CONST("IPPortClassifier04_IPAddress");
+NDIS_STRING STRIPPortClassifier05_IPAddress     = NDIS_STRING_CONST("IPPortClassifier05_IPAddress");
+NDIS_STRING STRIPPortClassifier06_IPAddress     = NDIS_STRING_CONST("IPPortClassifier06_IPAddress");
+NDIS_STRING STRIPPortClassifier07_IPAddress     = NDIS_STRING_CONST("IPPortClassifier07_IPAddress");
+NDIS_STRING STRIPPortClassifier08_IPAddress     = NDIS_STRING_CONST("IPPortClassifier08_IPAddress");
+NDIS_STRING STRIPPortClassifier09_IPAddress     = NDIS_STRING_CONST("IPPortClassifier09_IPAddress");
+NDIS_STRING STRIPPortClassifier10_IPAddress     = NDIS_STRING_CONST("IPPortClassifier10_IPAddress");
+NDIS_STRING STRIPPortClassifier11_IPAddress     = NDIS_STRING_CONST("IPPortClassifier11_IPAddress");
+NDIS_STRING STRIPPortClassifier12_IPAddress     = NDIS_STRING_CONST("IPPortClassifier12_IPAddress");
+NDIS_STRING STRIPPortClassifier13_IPAddress     = NDIS_STRING_CONST("IPPortClassifier13_IPAddress");
+NDIS_STRING STRIPPortClassifier14_IPAddress     = NDIS_STRING_CONST("IPPortClassifier14_IPAddress");
+NDIS_STRING STRIPPortClassifier15_IPAddress     = NDIS_STRING_CONST("IPPortClassifier15_IPAddress");
+
+NDIS_STRING STRIPPortClassifier00_Port          = NDIS_STRING_CONST("IPPortClassifier00_Port");
+NDIS_STRING STRIPPortClassifier01_Port          = NDIS_STRING_CONST("IPPortClassifier01_Port");
+NDIS_STRING STRIPPortClassifier02_Port          = NDIS_STRING_CONST("IPPortClassifier02_Port");
+NDIS_STRING STRIPPortClassifier03_Port          = NDIS_STRING_CONST("IPPortClassifier03_Port");
+NDIS_STRING STRIPPortClassifier04_Port          = NDIS_STRING_CONST("IPPortClassifier04_Port");
+NDIS_STRING STRIPPortClassifier05_Port          = NDIS_STRING_CONST("IPPortClassifier05_Port");
+NDIS_STRING STRIPPortClassifier06_Port          = NDIS_STRING_CONST("IPPortClassifier06_Port");
+NDIS_STRING STRIPPortClassifier07_Port          = NDIS_STRING_CONST("IPPortClassifier07_Port");
+NDIS_STRING STRIPPortClassifier08_Port          = NDIS_STRING_CONST("IPPortClassifier08_Port");
+NDIS_STRING STRIPPortClassifier09_Port          = NDIS_STRING_CONST("IPPortClassifier09_Port");
+NDIS_STRING STRIPPortClassifier10_Port          = NDIS_STRING_CONST("IPPortClassifier10_Port");
+NDIS_STRING STRIPPortClassifier11_Port          = NDIS_STRING_CONST("IPPortClassifier11_Port");
+NDIS_STRING STRIPPortClassifier12_Port          = NDIS_STRING_CONST("IPPortClassifier12_Port");
+NDIS_STRING STRIPPortClassifier13_Port          = NDIS_STRING_CONST("IPPortClassifier13_Port");
+NDIS_STRING STRIPPortClassifier14_Port          = NDIS_STRING_CONST("IPPortClassifier14_Port");
+NDIS_STRING STRIPPortClassifier15_Port          = NDIS_STRING_CONST("IPPortClassifier15_Port");
+
+NDIS_STRING STRIPPortClassifier00_DTag          = NDIS_STRING_CONST("IPPortClassifier00_DTag");
+NDIS_STRING STRIPPortClassifier01_DTag          = NDIS_STRING_CONST("IPPortClassifier01_DTag");
+NDIS_STRING STRIPPortClassifier02_DTag          = NDIS_STRING_CONST("IPPortClassifier02_DTag");
+NDIS_STRING STRIPPortClassifier03_DTag          = NDIS_STRING_CONST("IPPortClassifier03_DTag");
+NDIS_STRING STRIPPortClassifier04_DTag          = NDIS_STRING_CONST("IPPortClassifier04_DTag");
+NDIS_STRING STRIPPortClassifier05_DTag          = NDIS_STRING_CONST("IPPortClassifier05_DTag");
+NDIS_STRING STRIPPortClassifier06_DTag          = NDIS_STRING_CONST("IPPortClassifier06_DTag");
+NDIS_STRING STRIPPortClassifier07_DTag          = NDIS_STRING_CONST("IPPortClassifier07_DTag");
+NDIS_STRING STRIPPortClassifier08_DTag          = NDIS_STRING_CONST("IPPortClassifier08_DTag");
+NDIS_STRING STRIPPortClassifier09_DTag          = NDIS_STRING_CONST("IPPortClassifier09_DTag");
+NDIS_STRING STRIPPortClassifier10_DTag          = NDIS_STRING_CONST("IPPortClassifier10_DTag");
+NDIS_STRING STRIPPortClassifier11_DTag          = NDIS_STRING_CONST("IPPortClassifier11_DTag");
+NDIS_STRING STRIPPortClassifier12_DTag          = NDIS_STRING_CONST("IPPortClassifier12_DTag");
+NDIS_STRING STRIPPortClassifier13_DTag          = NDIS_STRING_CONST("IPPortClassifier13_DTag");
+NDIS_STRING STRIPPortClassifier14_DTag          = NDIS_STRING_CONST("IPPortClassifier14_DTag");
+NDIS_STRING STRIPPortClassifier15_DTag          = NDIS_STRING_CONST("IPPortClassifier15_DTag");
+
+/*-----------------------------
+   Rx Data Filter parameters
+-----------------------------*/
+NDIS_STRING STRRxDataFiltersEnabled             = NDIS_STRING_CONST("RxDataFilters_Enabled");
+NDIS_STRING STRRxDataFiltersDefaultAction       = NDIS_STRING_CONST("RxDataFilters_DefaultAction");
+
+NDIS_STRING STRRxDataFiltersFilter1Offset       = NDIS_STRING_CONST("RxDataFilters_Filter1Offset");
+NDIS_STRING STRRxDataFiltersFilter1Mask         = NDIS_STRING_CONST("RxDataFilters_Filter1Mask");
+NDIS_STRING STRRxDataFiltersFilter1Pattern      = NDIS_STRING_CONST("RxDataFilters_Filter1Pattern");
+
+NDIS_STRING STRRxDataFiltersFilter2Offset       = NDIS_STRING_CONST("RxDataFilters_Filter2Offset");
+NDIS_STRING STRRxDataFiltersFilter2Mask         = NDIS_STRING_CONST("RxDataFilters_Filter2Mask");
+NDIS_STRING STRRxDataFiltersFilter2Pattern      = NDIS_STRING_CONST("RxDataFilters_Filter2Pattern");
+
+NDIS_STRING STRRxDataFiltersFilter3Offset       = NDIS_STRING_CONST("RxDataFilters_Filter3Offset");
+NDIS_STRING STRRxDataFiltersFilter3Mask         = NDIS_STRING_CONST("RxDataFilters_Filter3Mask");
+NDIS_STRING STRRxDataFiltersFilter3Pattern      = NDIS_STRING_CONST("RxDataFilters_Filter3Pattern");
+
+NDIS_STRING STRRxDataFiltersFilter4Offset       = NDIS_STRING_CONST("RxDataFilters_Filter4Offset");
+NDIS_STRING STRRxDataFiltersFilter4Mask         = NDIS_STRING_CONST("RxDataFilters_Filter4Mask");
+NDIS_STRING STRRxDataFiltersFilter4Pattern      = NDIS_STRING_CONST("RxDataFilters_Filter4Pattern");
+
+
+/*---------------------------
+    Measurement parameters
+-----------------------------*/
+NDIS_STRING STRMeasurTrafficThreshold           = NDIS_STRING_CONST( "MeasurTrafficThreshold" );
+NDIS_STRING STRMeasurMaxDurationOnNonServingChannel = NDIS_STRING_CONST( "MeasurMaxDurationOnNonServingChannel" );
+
+/*---------------------------
+      EXC Manager parameters
+-----------------------------*/
+#ifdef EXC_MODULE_INCLUDED
+NDIS_STRING STRExcModeEnabled                   = NDIS_STRING_CONST( "ExcModeEnabled" );
+#endif
+
+NDIS_STRING STRExcTestIgnoreDeAuth0             = NDIS_STRING_CONST( "ExcTestRogeAP" );
+
+/*-----------------------------------*/
+/*   EEPROM-less support             */
+/*-----------------------------------*/
+NDIS_STRING STREEPROMlessModeSupported          = NDIS_STRING_CONST( "EEPROMlessModeSupported" );
+NDIS_STRING STRstationMacAddress                = NDIS_STRING_CONST("dot11StationID");
+
+
+/*-----------------------------------*/
+/*   INI file to configuration       */
+/*-----------------------------------*/
+
+NDIS_STRING SendINIBufferToUser                 = NDIS_STRING_CONST("SendINIBufferToUserMode");
+
+void regConvertStringtoMACAddress(UINT8 *staMACAddressString,UINT8 *MacAddressArray);
+void regConvertStringtoIpAddress(UINT8 *staIpAddressString,UINT8 *IpAddressArray);
+void regConvertStringtoBeaconIETable(UINT8 *staIpAddressString,UINT8 *BeaconIEArray, UINT8 size);
+
+/*-----------------------------------*/
+/*   Scan concentrator parameters    */
+/*-----------------------------------*/
+NDIS_STRING STRPassiveScanDwellTime      = NDIS_STRING_CONST( "DriverPassiveScanDefaultDwellTime" );
+// TRS: Scan changes from TI
+NDIS_STRING STRMinimumDurationBetweenOidScans = NDIS_STRING_CONST( "MinimumDurationBetweenOidScans" );
+//TRS: end of Scan changes from TI
+
+/*
+NDIS_STRING STRPctACXRxMemoryPool       = NDIS_STRING_CONST( "PctACXRxMemoryPool" );
+NDIS_STRING STRSendPacketsPerOID        = NDIS_STRING_CONST( "Dot11SendPacketsPerOID" );
+NDIS_STRING STRFragCacheSize            = NDIS_STRING_CONST( "FragCacheSize" );
+*/
+
+static int decryptWEP( PCHAR pSrc, PCHAR pDst, ULONG len);
+short _btoi ( char *sptr, short slen, int *pi, short base );
+static VOID initRadioValusFromRgstryString(  PCHAR pSrc,  PCHAR pDst,  ULONG len);
+
+
+
+static void readRates(PTIWLN_ADAPTER_T pAdapter, initTable_t *pInitTable);
+static void decryptScanControlTable(PUCHAR src, PUCHAR dst, USHORT len);
+
+static UINT32 regReadIntegerTable(PTIWLN_ADAPTER_T  pAdapter,
+                                PNDIS_STRING        pParameterName,
+                                PCHAR               pDefaultValue,
+                                USHORT              defaultLen,
+                                PUCHAR              pParameter);
+
+static void assignRegValue(PULONG lValue, PNDIS_CONFIGURATION_PARAMETER ndisParameter);
+
+static void parse_filter_request(rxDataFilterRequest_t * request, UINT8 offset, char * mask, UINT8 maskLength, char * pattern, UINT8 patternLength);
+
+/* ---------------------------------------------------------------------------*/
+/* Converts a string to a signed int. Assumes base 10. Assumes positive*/
+/*    number*/
+/**/
+/* Returns value on success, -1 on failure*/
+/**/
+/* ---------------------------------------------------------------------------*/
+ULONG
+tiwlnstrtoi(char *num, UINT length)
+{
+  ULONG value;
+
+  if(num == NULL || length == 0 )
+  {
+    return 0;
+  }
+
+  for(value=0;length&&*num;num++,length--)
+  {
+    if(*num<='9'&&*num>= '0')
+    {
+      value=(value*10)+(*num - '0');
+    }
+    else { /* Out of range*/
+      break;
+    }
+  }
+  return value;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadConfigString
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+BOOLEAN
+regReadConfigString(
+    IN NDIS_HANDLE hConfig,
+    IN NDIS_STRING *pParmName,
+    OUT PCHAR pStringOut,
+    OUT USHORT cbString
+    )
+{
+
+    BOOLEAN fRC = FALSE;
+    NDIS_STATUS rc;
+    PNDIS_CONFIGURATION_PARAMETER pParameter;
+
+    ANSI_STRING strAnsi;
+
+    do {
+
+        /* Read the string...*/
+        NdisReadConfiguration( &rc, &pParameter, hConfig, pParmName,
+            NdisParameterString );
+
+        if ( NDIS_STATUS_SUCCESS != rc ) break;
+
+        /* convert the string...*/
+        strAnsi.Length        = 0;
+        strAnsi.MaximumLength = cbString;
+        strAnsi.Buffer        = pStringOut;
+
+        rc = NdisUnicodeStringToAnsiString(&strAnsi,
+            &pParameter->ParameterData.StringData);
+
+        if ( NDIS_STATUS_SUCCESS != rc ) break;
+
+        /* NULL terminate the output string.  If we cannot fit the NULL, that's*/
+        /*  an error...*/
+        if ( cbString < strAnsi.Length + 1 ) break;
+
+        pStringOut[ strAnsi.Length ] = '\0';
+
+        fRC = TRUE;
+
+    } while( 0 );
+
+    return( fRC );
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadRatesConfigArray
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+BOOLEAN
+regReadRatesConfigArray(
+    NDIS_HANDLE SubKeyHandle,
+    PNDIS_STRING Str,
+    PUCHAR target,
+    PUCHAR def,
+    PULONG size
+    )
+{
+    BOOLEAN fRC = TRUE;
+    CHAR str[200];
+    UCHAR val;
+    int i,j;
+
+    if (!regReadConfigString(SubKeyHandle, Str, (PCHAR)str, 200) ) {
+
+        fRC = FALSE;
+
+    }
+    i=j=0;
+    do
+    {
+        val = 0;
+        if (!fRC) {
+            val = def[i];
+            if(!val) break;
+        }
+        else
+        {
+            if(!str[j])
+                break;
+
+            while (str[j] && (str[j]<'0' || str[j]>'9')) j++;
+            if (str[j])
+            {
+                while (str[j] && str[j]>='0' && str[j]<='9')
+                {
+                    val=10*val+str[j]-'0';
+                    j++;
+                }
+            }
+        }
+        target[i++] = val;
+    }
+    while (val);
+    *size = i;
+
+    return fRC;
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    convertRatesFromRegistryFormatToDriver
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+rate_e  convertRatesFromRegistryFormatToDriver(UCHAR rateIn)
+{
+    switch(rateIn)
+    {
+    case 0x1:   return DRV_RATE_1M;
+    case 0x2:   return DRV_RATE_2M;
+    case 0x5:   return DRV_RATE_5_5M;
+    case 0xB:   return DRV_RATE_11M;
+    case 0x16:  return DRV_RATE_22M;
+    case 0x6:   return DRV_RATE_6M;
+    case 0x9:   return DRV_RATE_9M;
+    case 0xC:   return DRV_RATE_12M;
+    case 0x12:  return DRV_RATE_18M;
+    case 0x18:  return DRV_RATE_24M;
+    case 0x24:  return DRV_RATE_36M;
+    case 0x30:  return DRV_RATE_48M;
+    case 0x36:  return DRV_RATE_54M;
+    default:    return DRV_RATE_6M;
+    }
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regConvertStringtoMACAddress
+
+Routine Description: Converts the MAC Adrress in a form of string readen from the Registry 
+to the MAC Address Array to be stored in the init_table struct 
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+void regConvertStringtoMACAddress(UINT8 *staMACAddressString,UINT8 *MacAddressArray)
+{
+
+char *ptr;
+UINT8 *tmpMacAddr;
+UINT8 value=0,value_l,value_h,add_value;
+int i;
+
+
+    /* Take the pointer to the string MAC Address to convert it to the Array MAC Address */
+    ptr=(char *)staMACAddressString;
+    tmpMacAddr = MacAddressArray;
+
+#if 0 
+    for(i=0 ; i<MAC_ADDR_LEN ; ptr++)
+    {
+        value_l = (*ptr-'0');
+
+        /* PRINTF(DBG_REGISTRY,("value_l [%d] *ptr %c value %d\n",value_l,*ptr,value));*/
+
+        if( value_l  < 9)
+        {
+            value = value*10 + value_l;             
+            /* PRINTF(DBG_REGISTRY,("value %d value_l %d  \n",value,value_l));*/
+
+
+        }
+        else
+        {
+            tmpMacAddr[i] = value;
+            /* PRINTF(DBG_REGISTRY,("tmpMacAddr[%d]  is %d\n",i,tmpMacAddr[i]));*/
+            value = 0;
+            i++;
+        }
+
+    }
+
+#else
+
+    for(i=0 ; i<MAC_ADDR_LEN ; ptr++)
+    {
+        
+        /* The value can be or "0-9" or from "a-f" */
+        value_l = (*ptr-'0');
+        value_h = (*ptr - 'a');
+
+        /*PRINTF(DBG_REGISTRY,("value_l [%d] value_h [%d] *ptr %c value %d\n",value_l,value_h,*ptr,value));*/
+
+        if( (value_l <= 9) || (value_h <= 15 ) )
+        {
+            /* We are in an expected range */
+            /* nCheck if 0-9 */
+            if(value_l <= 9 )
+            {
+                add_value = value_l;
+            }
+            /* Check if a-f */
+            else
+            {
+                /* 'a' is in fact 10 decimal in hexa */
+                add_value = value_h + 10;
+            }
+            value = value*16 + add_value;               
+        /*  PRINTF(DBG_REGISTRY,("value %d add_value %d  \n",value,add_value));*/
+
+
+        }
+        else
+        {
+            tmpMacAddr[i] = value;
+        /*  PRINTF(DBG_REGISTRY,("tmpMacAddr[%d]  is %x\n",i,tmpMacAddr[i]));*/
+            value = 0;
+            i++;
+        }
+
+    }
+#endif
+
+}
+
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regFillInitTable
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regFillInitTable(
+                PTIWLN_ADAPTER_T pAdapter,
+                PVOID pInitTable
+                )
+{
+    UINT8 radioString[3*RX_LEVEL_TABLE_SIZE];
+    UINT8 bssidBroadcast[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+    UINT8* RFMD_RxLevel = "bc b3 a9 9a 90 89 80 79 70 68 64 61 60 55 00";
+    UINT8* RFMD_Lna = "01 01 01 01 01 01 01 01 01 01 01 01 01 01 01";
+    UINT8* RFMD_Rssi = "0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b c8";
+
+    UINT8* MAXIM_RxLevel = "55 4f 4a 43 3a 32 5d 56 4e 46 3e 37 2a 23 1f";
+    UINT8* MAXIM_Lna = "00 00 00 00 00 00 01 01 01 01 01 01 01 01 01";
+    UINT8* MAXIM_Rssi = "0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b 5a";
+    char  dummySsidString[MAX_SSID_LEN];
+
+
+    ctrlData_rateAdapt_t RateAdapt;
+    UCHAR temp[MAX_SUPPORTED_RATES], i;
+
+    UINT8  *ClsfrIp = "0a 03 01 c9";
+    UINT8  ClsfrIpString[16];
+    UINT8 ClsfrIpStringSize;
+
+  /* EEPROM-less : MAC address */
+    UINT8 regMACstrLen = REG_MAC_ADDR_STR_LEN;
+    UINT8 staMACAddress[REG_MAC_ADDR_STR_LEN];
+    UINT8 defStaMacAddress[]= "00 22 11 33 44 55";
+
+    UINT8 regArpIpStrLen = REG_ARP_IP_ADDR_STR_LEN ; 
+    UINT8 staArpIpAddress[REG_ARP_IP_ADDR_STR_LEN];
+    UINT8 defArpIpAddress[] =  "0a 00 00 0a" ;       /*value by default*/
+
+    /*defaults values for beacon IE table*/
+    /*UINT8 defBeaconIETableSize = 0 ;*/
+    UINT8 defBeaconIETable[] = "00 01 01 01 32 01 2a 01 03 01 06 01 07 01 20 01 25 01 23 01 30 01 28 01 2e 01 85 01 dd 01 00 52 f2 02 00 01";
+    /*UINT8 tmpIeTable[BEACON_FILTER_TABLE_MAX_SIZE] ;*/
+    UINT8 staBeaconFilterIETable[BEACON_FILTER_STRING_MAX_LEN] ;
+    UINT8 tmpIeTableSize = 35;
+    UINT8 strSize = 104 ;
+
+    UINT filterOffset = 0;
+    char filterMask[16];
+    UINT8 filterMaskLength;
+    char filterPattern[16];
+    UINT8 filterPatternLength;
+
+    initTable_t* p = (initTable_t*) pInitTable;
+    USHORT  tableLen = 0;
+    USHORT  loopIndex = 0;
+    UINT8   ScanControlTable24Tmp[2 * NUM_OF_CHANNELS_24];
+    UINT8   ScanControlTable5Tmp[2 * A_5G_BAND_NUM_CHANNELS];
+    UINT8   ScanControlTable24Def[2* NUM_OF_CHANNELS_24] = "FFFFFFFFFFFFFFFFFFFFFFFFFFFF";
+    UINT8   ScanControlTable5Def[2 * A_5G_BAND_NUM_CHANNELS] = "FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000000000000000000000000000000000000000000000000000000000000000000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000000000000000FF000000FF000000FF000000FF00000000000000000000000000000000000000";
+    UINT8   reportSeverityTableDefaults[WLAN_MAX_SEVERITIES] = "000000000000";
+    UINT8   reportModuleTableDefaults[WLAN_MAX_LOG_MODULES];
+    UINT16  reportSeverityTableLen;
+    UINT16  reportModuleTableLen;
+    
+    int macIndex ; /*used for group address filtering*/
+    UINT32  localNumTxDesc;
+    PRINT(DBG_REGISTRY_LOUD, "TIWL: Reading InitTable parameters\n");
+    
+    /*set all report modules.as default*/
+    memset(reportModuleTableDefaults, '1', WLAN_MAX_LOG_MODULES );
+    
+    /* Reset structure */
+    NdisZeroMemory(p, sizeof(initTable_t));
+    NdisZeroMemory(&RateAdapt, sizeof(ctrlData_rateAdapt_t));
+    
+    /*reads the arp ip from table*/
+    regReadStringParameter(pAdapter ,&STRArp_Ip_Addr,
+                            (PCHAR)(defArpIpAddress),REG_ARP_IP_ADDR_STR_LEN,
+                            (PUCHAR)staArpIpAddress,&regArpIpStrLen ) ;
+
+    regReadIntegerParameter(pAdapter, &STRArp_Ip_Filter_Ena,
+                            DEF_FILTER_ENABLE_VALUE, MIN_FILTER_ENABLE_VALUE, MAX_FILTER_ENABLE_VALUE,
+                            sizeof p->TnetwDrv_InitParams.arpIpFilterParams.isFilterEnabled, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.arpIpFilterParams.isFilterEnabled );
+
+
+    regConvertStringtoIpAddress(staArpIpAddress, (PUCHAR)&(p->TnetwDrv_InitParams.arpIpFilterParams.arpIpInitParams.addr[0]) ); 
+    
+    /* Beacon filter*/
+    /*is the desired state ENABLED ?*/
+    regReadIntegerParameter(pAdapter, &STRBeaconFilterDesiredState,
+                            DEF_BEACON_FILTER_ENABLE_VALUE, MIN_BEACON_FILTER_ENABLE_VALUE, MAX_BEACON_FILTER_ENABLE_VALUE,
+                            sizeof p->siteMgrInitParams.beaconFilterParams.desiredState, 
+                            (PUCHAR)&p->siteMgrInitParams.beaconFilterParams.desiredState );
+    
+    regReadIntegerParameter(pAdapter, &STRBeaconFilterStored,
+                            DEF_NUM_STORED_FILTERS, MIN_NUM_STORED_FILTERS, MAX_NUM_STORED_FILTERS,
+                            sizeof p->siteMgrInitParams.beaconFilterParams.numOfStored, 
+                            (PUCHAR)&p->siteMgrInitParams.beaconFilterParams.numOfStored );
+
+    /*Read the beacon filter IE table*/
+    /*Read the size of the table*/
+    regReadIntegerParameter(pAdapter, &STRBeaconIETableSize,
+                            BEACON_FILTER_IE_TABLE_MIN_SIZE, BEACON_FILTER_IE_TABLE_MIN_SIZE,
+                            BEACON_FILTER_IE_TABLE_MAX_SIZE,
+                            sizeof p->siteMgrInitParams.beaconFilterParams.IETableSize, 
+                            (PUCHAR)(&p->siteMgrInitParams.beaconFilterParams.IETableSize) );
+    
+    tmpIeTableSize = p->siteMgrInitParams.beaconFilterParams.IETableSize;
+    
+    /*Read the number of elements in the table ( this is because 221 has 5 values following it )*/
+    regReadIntegerParameter(pAdapter, &STRBeaconIETableNumOfElem,
+                            DEF_BEACON_FILTER_IE_TABLE_NUM, BEACON_FILTER_IE_TABLE_MIN_NUM,
+                            BEACON_FILTER_IE_TABLE_MAX_NUM,
+                            sizeof p->siteMgrInitParams.beaconFilterParams.numOfElements, 
+                            (PUCHAR)(&p->siteMgrInitParams.beaconFilterParams.numOfElements) );
+
+    /*printk("\n  OsRgstr tmpIeTableSize = %d numOfElems = %d" , tmpIeTableSize , p->siteMgrInitParams.beaconFilterParams.numOfElements) ;*/
+    strSize = tmpIeTableSize*2 +tmpIeTableSize - 1 ; /*includes spaces between bytes*/
+    if ( ( tmpIeTableSize  > 0 ) && ( tmpIeTableSize <= BEACON_FILTER_IE_TABLE_MAX_SIZE) )
+    {
+    
+        regReadStringParameter(pAdapter, &STRBeaconIETable ,
+                            (PCHAR)(defBeaconIETable), strSize,
+                            (PUCHAR)staBeaconFilterIETable, &strSize);
+
+        regConvertStringtoBeaconIETable(staBeaconFilterIETable , (PUCHAR)&p->siteMgrInitParams.beaconFilterParams.IETable[0]/*(PUCHAR)&(tmpIeTable[0] )*/ , tmpIeTableSize);
+    }
+
+    /* MAC ADDRESSES FILTER*/
+    regReadIntegerParameter(pAdapter, &STRFilterEnabled,
+                            DEF_FILTER_ENABLE_VALUE, MIN_FILTER_ENABLE_VALUE,
+                            MAX_FILTER_ENABLE_VALUE,
+                            sizeof p->TnetwDrv_InitParams.macAddrFilterParams.isFilterEnabled, 
+                            (PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.isFilterEnabled);
+
+    regReadIntegerParameter(pAdapter, &STRnumGroupAddrs,
+                            NUM_GROUP_ADDRESS_VALUE_DEF, NUM_GROUP_ADDRESS_VALUE_MIN,
+                            NUM_GROUP_ADDRESS_VALUE_MAX,
+                            sizeof p->TnetwDrv_InitParams.macAddrFilterParams.numOfMacAddresses, 
+                            (PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.numOfMacAddresses);
+    
+    /*printk("\nOsRgstry Num Of Group Addr:%d \n" , p->TnetwDrv_InitParams.macAddrFilterParams.numOfMacAddresses) ;*/
+
+    macIndex = p->TnetwDrv_InitParams.macAddrFilterParams.numOfMacAddresses -1 ;
+    switch( macIndex )
+    {
+    case 7:
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr7,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[7].addr);      
+        --macIndex;
+        }
+
+    case 6:
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr6,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[6].addr);  
+        --macIndex;
+        }
+
+    case 5: 
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr5,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[5].addr);  
+        --macIndex;
+        }
+
+    case 4: 
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr4,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[4].addr);  
+        --macIndex;
+        }
+
+    case 3:
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr3,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[3].addr);      
+        --macIndex;
+        }
+
+    case 2:
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr2,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[2].addr ); 
+        --macIndex;
+        }
+
+    case 1:
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr1,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[1].addr);  
+        --macIndex;
+        }
+
+    
+    case 0:
+        {
+
+        regReadStringParameter(pAdapter, &STRGroup_addr0,
+                            (PCHAR)(defStaMacAddress), REG_MAC_ADDR_STR_LEN,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+
+        regConvertStringtoMACAddress(staMACAddress,(PUCHAR) &p->TnetwDrv_InitParams.macAddrFilterParams.macAddrTable[0].addr);  
+
+        
+        }
+
+    default:
+        {
+
+        }
+    }
+
+    /* Read Beacon early wakeup parmeter */
+    regReadIntegerParameter(pAdapter, &STREarlyWakeup,
+                            EARLY_WAKEUP_ENABLE_DEF, EARLY_WAKEUP_ENABLE_MIN,
+                            EARLY_WAKEUP_ENABLE_MAX,
+                            sizeof(p->TnetwDrv_InitParams.macPreambleParams.earlyWakeUp), 
+                            (PUCHAR) &p->TnetwDrv_InitParams.macPreambleParams.earlyWakeUp);
+
+    
+    /* Read TX XFER init parameters */
+    regReadIntegerParameter(pAdapter, &STRTxXferBufferFullTimeToRecovery,
+                            TX_XFER_HW_BUFFER_FULL_DUR_RECOVERY_DEF, TX_XFER_HW_BUFFER_FULL_DUR_RECOVERY_MIN,
+                            TX_XFER_HW_BUFFER_FULL_DUR_RECOVERY_MAX,
+                            sizeof (p->TnetwDrv_InitParams.txXferInitParams.timeToTxStuckMs), 
+                            (PUCHAR) &(p->TnetwDrv_InitParams.txXferInitParams.timeToTxStuckMs));
+
+
+    /************************/
+    /* Read severity table */
+    /**********************/
+
+    regReadStringParameter(pAdapter, &STR_ReportSeverityTable,
+                    (PCHAR)reportSeverityTableDefaults,
+                    (UCHAR)WLAN_MAX_SEVERITIES,
+                    (PUCHAR)p->TnetwDrv_InitParams.reportParams.SeverityTable,
+                    (PUCHAR)&reportSeverityTableLen);
+
+
+    /***********************/
+    /* Read modules table */
+    /*********************/
+
+    regReadStringParameter(pAdapter, &STR_ReportModuleTable,
+                    (PCHAR)reportModuleTableDefaults,
+                    (UCHAR)WLAN_MAX_LOG_MODULES,
+                    (PUCHAR)p->TnetwDrv_InitParams.reportParams.ModuleTable,
+                    (PUCHAR)&reportModuleTableLen);
+
+
+    /*
+        Default SSID should be non-Valid SSID, hence the STA will not try to connect
+    */
+    for(loopIndex = 0; loopIndex < MAX_SSID_LEN; loopIndex++)
+            dummySsidString[loopIndex] = (loopIndex+1);
+
+    /*
+     * Read CCK table
+    */
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationTable0,
+        temp, "\x1\x2\x5\xB",
+        (PULONG) &RateAdapt.len);
+    for(i=0; i<RateAdapt.len; i++) RateAdapt.rateAdaptRatesTable[i] =
+            RateNumberToHost(temp[i]);
+
+    NdisZeroMemory(temp, sizeof(temp));
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationFBThd0,
+        &RateAdapt.rateAdaptFBTable[0], "\x32\x32\x32\x32",
+        (PULONG) &RateAdapt.len);
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationSUThd0,
+        &RateAdapt.rateAdaptSUTable[0], "\x1E\x1E\x1E\x1E",
+        (PULONG) &RateAdapt.len);
+
+    NdisMoveMemory(&p->ctrlDataInitParams.rateTable.ctrlDataCckRateTable,
+        &RateAdapt, sizeof(ctrlData_rateAdapt_t));
+
+
+    /*
+     * Read PBCC table
+    */
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationTable1,
+        temp, "\x1\x2\x5\xB\x16",
+        (PULONG) &RateAdapt.len);
+    for(i=0; i<RateAdapt.len; i++) RateAdapt.rateAdaptRatesTable[i] =
+            RateNumberToHost(temp[i]);
+
+    NdisZeroMemory(temp, sizeof(temp));
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationFBThd1,
+        &RateAdapt.rateAdaptFBTable[0], "\x32\x32\x32\x32\x32",
+        (PULONG) &RateAdapt.len);
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationSUThd1,
+        &RateAdapt.rateAdaptSUTable[0], "\x1E\x1E\x1E\x1E\x1E",
+        (PULONG) &RateAdapt.len);
+
+    NdisMoveMemory(&p->ctrlDataInitParams.rateTable.ctrlDataPbccRateTable,
+        &RateAdapt, sizeof(ctrlData_rateAdapt_t));
+
+    /*
+     * Read OFDM table
+    */
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationTable2, 
+        temp, "\x1\x2\x5\x6\x9\xB\xC\x12\x18\x24\x30\x36", 
+        (PULONG) &RateAdapt.len);
+    for(i=0; i<RateAdapt.len; i++) RateAdapt.rateAdaptRatesTable[i] =
+            RateNumberToHost(temp[i]);
+
+    NdisZeroMemory(temp, sizeof(temp));
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationFBThd2,
+        &RateAdapt.rateAdaptFBTable[0], "\x32\x32\x32\x32\x32\x32\x32\x2D\x2D\x2D\x2D\x14", 
+        (PULONG) &RateAdapt.len);
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationSUThd2,
+        &RateAdapt.rateAdaptSUTable[0], "\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\xA\x5\x0", 
+        (PULONG) &RateAdapt.len);
+
+    NdisMoveMemory(&p->ctrlDataInitParams.rateTable.ctrlDataOfdmRateTable,
+        &RateAdapt, sizeof(ctrlData_rateAdapt_t));
+
+
+    /*
+     * Read OFDMA table
+    */
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationTable3,
+        temp, "\x6\x9\xC\x12\x18\x24\x30\x36",
+        (PULONG) &RateAdapt.len);
+    for(i=0; i<RateAdapt.len; i++) RateAdapt.rateAdaptRatesTable[i] =
+            RateNumberToHost(temp[i]);
+
+    NdisZeroMemory(temp, sizeof(temp));
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationFBThd3,
+        &RateAdapt.rateAdaptFBTable[0], "\x32\x32\x32\x32\x2D\x2D\x2D\x14",
+        (PULONG) &RateAdapt.len);
+
+    regReadRatesConfigArray(pAdapter->ConfigHandle, &STRRateAdaptationSUThd3,
+        &RateAdapt.rateAdaptSUTable[0], "\x1E\x1E\x1E\x1E\x1E\xA\x5\x0",
+        (PULONG) &RateAdapt.len);
+
+    NdisMoveMemory(&p->ctrlDataInitParams.rateTable.ctrlDataOfdmARateTable,
+        &RateAdapt, sizeof(ctrlData_rateAdapt_t));
+
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationLowTrshAcBK,
+                            RATE_ADAPT_LOW_TRSH_AC_BK_DEF, RATE_ADAPT_LOW_TRSH_AC_BK_MIN,
+                            RATE_ADAPT_LOW_TRSH_AC_BK_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BK].lowRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BK].lowRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationLowTrshAcBE,
+                            RATE_ADAPT_LOW_TRSH_AC_BE_DEF, RATE_ADAPT_LOW_TRSH_AC_BE_MIN,
+                            RATE_ADAPT_LOW_TRSH_AC_BE_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BE].lowRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BE].lowRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationLowTrshAcVI,
+                            RATE_ADAPT_LOW_TRSH_AC_VI_DEF, RATE_ADAPT_LOW_TRSH_AC_VI_MIN,
+                            RATE_ADAPT_LOW_TRSH_AC_VI_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VI].lowRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VI].lowRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationLowTrshAcVO,
+                            RATE_ADAPT_HIGH_TRSH_AC_VO_DEF, RATE_ADAPT_HIGH_TRSH_AC_VO_MIN,
+                            RATE_ADAPT_HIGH_TRSH_AC_VO_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VO].lowRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VO].lowRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationHighTrshAcBK,
+                            RATE_ADAPT_HIGH_TRSH_AC_BK_DEF, RATE_ADAPT_HIGH_TRSH_AC_BK_MIN,
+                            RATE_ADAPT_HIGH_TRSH_AC_BK_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BK].highRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BK].highRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationHighTrshAcBE,
+                            RATE_ADAPT_HIGH_TRSH_AC_BE_DEF, RATE_ADAPT_HIGH_TRSH_AC_BE_MIN,
+                            RATE_ADAPT_HIGH_TRSH_AC_BE_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BE].highRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_BE].highRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationHighTrshAcVI,
+                            RATE_ADAPT_HIGH_TRSH_AC_VI_DEF, RATE_ADAPT_HIGH_TRSH_AC_VI_MIN,
+                            RATE_ADAPT_HIGH_TRSH_AC_VI_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VI].highRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VI].highRateThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationHighTrshAcVO,
+                            RATE_ADAPT_HIGH_TRSH_AC_VO_DEF, RATE_ADAPT_HIGH_TRSH_AC_VO_MIN,
+                            RATE_ADAPT_HIGH_TRSH_AC_VO_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VO].highRateThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.tspecsRateParameters[QOS_AC_VO].highRateThreshold);
+
+    /* rate Policy Params */
+    regReadIntegerParameter(pAdapter, &STRRatePolicyUserShortRetryLimit,
+                            CTRL_DATA_RATE_POLICY_USER_SHORT_RETRY_LIMIT_DEF, 
+                            CTRL_DATA_RATE_POLICY_USER_SHORT_RETRY_LIMIT_MIN,
+                            CTRL_DATA_RATE_POLICY_USER_SHORT_RETRY_LIMIT_MAX,
+                            sizeof p->ctrlDataInitParams.ctrlDataTxRatePolicy[USER_RATE_CLASS].shortRetryLimit, 
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTxRatePolicy[USER_RATE_CLASS].shortRetryLimit);
+
+    regReadIntegerParameter(pAdapter, &STRRatePolicyUserLongRetryLimit,
+                            CTRL_DATA_RATE_POLICY_USER_LONG_RETRY_LIMIT_DEF,
+                            CTRL_DATA_RATE_POLICY_USER_LONG_RETRY_LIMIT_MIN,
+                            CTRL_DATA_RATE_POLICY_USER_LONG_RETRY_LIMIT_MAX,
+                            sizeof p->ctrlDataInitParams.ctrlDataTxRatePolicy[USER_RATE_CLASS].longRetryLimit, 
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTxRatePolicy[USER_RATE_CLASS].longRetryLimit);
+
+   regReadIntegerTable(pAdapter, &STRRatePolicyUserRetriesPerRateCck, CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_CCK_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayCck[USER_RATE_CLASS]);
+
+   regReadIntegerTable(pAdapter, &STRRatePolicyUserRetriesPerRatePbcc, CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_PBCC_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayPbcc[USER_RATE_CLASS]);
+
+   regReadIntegerTable(pAdapter, &STRRatePolicyUserRetriesPerRateOfdm, CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_OFDM_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayOfdm[USER_RATE_CLASS]);
+
+   regReadIntegerTable(pAdapter, &STRRatePolicyUserRetriesPerRateOfdmA, CTRL_DATA_RATE_POLICY_USER_RETRIES_PER_RATE_OFDMA_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayOfdmA[USER_RATE_CLASS]);
+
+
+    regReadIntegerParameter(pAdapter, &STRRatePolicySGShortRetryLimit,
+                            CTRL_DATA_RATE_POLICY_SG_SHORT_RETRY_LIMIT_DEF, 
+                            CTRL_DATA_RATE_POLICY_SG_SHORT_RETRY_LIMIT_MIN,
+                            CTRL_DATA_RATE_POLICY_SG_SHORT_RETRY_LIMIT_MAX,
+                            sizeof p->ctrlDataInitParams.ctrlDataTxRatePolicy[SG_RATE_CLASS].shortRetryLimit, 
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTxRatePolicy[SG_RATE_CLASS].shortRetryLimit);
+
+    regReadIntegerParameter(pAdapter, &STRRatePolicySGLongRetryLimit,
+                            CTRL_DATA_RATE_POLICY_SG_LONG_RETRY_LIMIT_DEF,
+                            CTRL_DATA_RATE_POLICY_SG_LONG_RETRY_LIMIT_MIN,
+                            CTRL_DATA_RATE_POLICY_SG_LONG_RETRY_LIMIT_MAX,
+                            sizeof p->ctrlDataInitParams.ctrlDataTxRatePolicy[SG_RATE_CLASS].longRetryLimit, 
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTxRatePolicy[SG_RATE_CLASS].longRetryLimit);
+    
+    regReadIntegerTable(pAdapter, &STRRatePolicySGRetriesPerRateCck, CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_CCK_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayCck[SG_RATE_CLASS]);
+    regReadIntegerTable(pAdapter, &STRRatePolicySGRetriesPerRatePbcc, CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_PBCC_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayPbcc[SG_RATE_CLASS]);
+    regReadIntegerTable(pAdapter, &STRRatePolicySGRetriesPerRateOfdm, CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_OFDM_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayOfdm[SG_RATE_CLASS]);
+    regReadIntegerTable(pAdapter, &STRRatePolicySGRetriesPerRateOfdmA, CTRL_DATA_RATE_POLICY_SG_RETRIES_PER_RATE_OFDMA_DEF,
+                              CTRL_DATA_RATE_POLICY_RETRIES_PER_RATE_MAX_LEN,
+                              (PUCHAR)&p->ctrlDataInitParams.policyClassRatesArrayOfdmA[SG_RATE_CLASS]);
+
+
+
+
+    regReadIntegerParameter(pAdapter, &STRRxEnergyDetection,
+            FALSE, FALSE, TRUE, 
+            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRxEnergyDetection,
+            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRxEnergyDetection);
+
+    regReadIntegerParameter(pAdapter, &STRTxEnergyDetection,
+            FALSE, FALSE, TRUE, 
+            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxEnergyDetection,
+            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxEnergyDetection);
+
+    regReadIntegerParameter(pAdapter, &STRTddCalibrationInterval,
+            300, 1, 0xFFFFFFFF, 
+            sizeof p->TnetwDrv_InitParams.whalCtrl_init.tddRadioCalTimout,
+            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.tddRadioCalTimout);
+
+    regReadIntegerParameter(pAdapter, &STRCrtCalibrationInterval,
+            2, 1, 0xFFFFFFFF, 
+            sizeof p->TnetwDrv_InitParams.whalCtrl_init.CrtRadioCalTimout,
+            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.CrtRadioCalTimout);
+
+    regReadIntegerParameter(pAdapter, &STRMacClockRate,
+            80, 0, 255, 
+            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlMacClock,
+            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlMacClock);
+
+    regReadIntegerParameter(pAdapter, &STRArmClockRate,
+            80, 0, 255, 
+            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlArmClock,
+            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlArmClock);
+
+    
+    regReadIntegerParameter(pAdapter, &STRg80211DraftNumber,
+            DRAFT_6_AND_LATER, DRAFT_5_AND_EARLIER, DRAFT_6_AND_LATER,
+            sizeof p->siteMgrInitParams.siteMgrUseDraftNum,
+            (PUCHAR)&p->siteMgrInitParams.siteMgrUseDraftNum);
+
+     
+    regReadIntegerParameter(pAdapter, &STRTraceBufferSize,
+            /*1024, 0, 1024, sizeof(ULONG), */
+            16, 16, 16, 
+            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TraceBufferSize,
+            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TraceBufferSize);
+   
+    regReadIntegerParameter(pAdapter, &STRPrintTrace, 
+            FALSE, FALSE, TRUE, 
+            sizeof p->TnetwDrv_InitParams.whalCtrl_init.bDoPrint, 
+            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.bDoPrint);
+   
+    regReadIntegerParameter(pAdapter, &STRFirmwareDebug, 
+            FALSE, FALSE, TRUE, 
+            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlFirmwareDebug, 
+            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlFirmwareDebug);
+
+
+#ifndef TIWLN_WINCE30
+    regReadIntegerParameter(pAdapter, &STRHwACXAccessMethod,
+                            HAL_CTRL_HW_ACCESS_METHOD_DEF, HAL_CTRL_HW_ACCESS_METHOD_MIN,
+                            HAL_CTRL_HW_ACCESS_METHOD_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.hwAccessMethod, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.hwAccessMethod);
+#else
+        /* Slave indirect*/
+    p->TnetwDrv_InitParams.whalCtrl_init.hwAccessMethod = 0;
+#endif
+    regReadIntegerParameter(pAdapter, &STRMaxSitesFragCollect,
+                            HAL_CTRL_SITE_FRAG_COLLECT_DEF, HAL_CTRL_SITE_FRAG_COLLECT_MIN,
+                            HAL_CTRL_SITE_FRAG_COLLECT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.maxSitesFragCollect, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.maxSitesFragCollect);
+
+    regReadIntegerParameter(pAdapter, &STRBetEnable,
+                            HAL_CTRL_BET_ENABLE_DEF, HAL_CTRL_BET_ENABLE_MIN,
+                            HAL_CTRL_BET_ENABLE_MAX,
+                            sizeof p->PowerMgrInitParams.BetEnable, 
+                            (PUCHAR)&p->PowerMgrInitParams.BetEnable);
+
+    regReadIntegerParameter(pAdapter, &STRBetMaxConsecutive,
+                            HAL_CTRL_BET_MAX_CONSC_DEF, HAL_CTRL_BET_MAX_CONSC_MIN,
+                            HAL_CTRL_BET_MAX_CONSC_MAX,
+                            sizeof p->PowerMgrInitParams.MaximumConsecutiveET, 
+                            (PUCHAR)&p->PowerMgrInitParams.MaximumConsecutiveET);
+
+    /*--------------- Maximal time between full beacon reception ------------------*/
+    regReadIntegerParameter(pAdapter, &STRMaxFullBeaconInterval,
+                            HAL_CTRL_MAX_FULL_BEACON_DEF, HAL_CTRL_MAX_FULL_BEACON_MIN,
+                            HAL_CTRL_MAX_FULL_BEACON_MAX,
+                            sizeof p->PowerMgrInitParams.MaximalFullBeaconReceptionInterval,
+                            (PUCHAR)&p->PowerMgrInitParams.MaximalFullBeaconReceptionInterval);
+
+    regReadIntegerParameter(pAdapter, &STRBetEnableThreshold,
+                            HAL_CTRL_BET_ENABLE_THRESHOLD_DEF, HAL_CTRL_BET_ENABLE_THRESHOLD_MIN,
+                            HAL_CTRL_BET_ENABLE_THRESHOLD_MAX,
+                            sizeof p->PowerMgrInitParams.BetEnableThreshold,
+                            (PUCHAR)&p->PowerMgrInitParams.BetEnableThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRBetDisableThreshold,
+                            HAL_CTRL_BET_DISABLE_THRESHOLD_DEF, HAL_CTRL_BET_DISABLE_THRESHOLD_MIN,
+                            HAL_CTRL_BET_DISABLE_THRESHOLD_MAX,
+                            sizeof p->PowerMgrInitParams.BetDisableThreshold,
+                            (PUCHAR)&p->PowerMgrInitParams.BetDisableThreshold);
+
+    p->TnetwDrv_InitParams.whalCtrl_init.rxMemBlkNumber = 60;
+    p->TnetwDrv_InitParams.whalCtrl_init.txMinMemBlkNumber = 60;
+    p->TnetwDrv_InitParams.whalCtrl_init.txCompleteTimeout = 500;  
+    p->TnetwDrv_InitParams.whalCtrl_init.txCompleteThreshold = 1; 
+
+    p->TnetwDrv_InitParams.whalCtrl_init.blockSize     = HAL_CTRL_ACX_BLOCK_SIZE_DEF;
+    p->TnetwDrv_InitParams.whalCtrl_init.UseTxDataInterrupt = HAL_CTRL_USE_TX_DATA_INTR_DEF;
+    p->TnetwDrv_InitParams.whalCtrl_init.UsePlcpHeader      = HAL_CTRL_USE_PLCP_HDR_DEF;
+
+    regReadIntegerParameter(pAdapter, &STRNumACXRxDescriptors,
+                            HAL_CTRL_ACX_RX_DESC_DEF, HAL_CTRL_ACX_RX_DESC_MIN,
+                            HAL_CTRL_ACX_RX_DESC_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.rxDescNum, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.rxDescNum);
+
+    regReadIntegerParameter(pAdapter, &STRNumACXTxDescriptors,
+                            HAL_CTRL_ACX_TX_DESC_DEF, HAL_CTRL_ACX_TX_DESC_MIN,
+                            HAL_CTRL_ACX_TX_DESC_MAX,
+                            sizeof localNumTxDesc, 
+                            (PUCHAR)&localNumTxDesc);
+
+    regReadIntegerParameter(pAdapter, &STRTxFlashEnable,
+                            HAL_CTRL_TX_FLASH_ENABLE_DEF, HAL_CTRL_TX_FLASH_ENABLE_MIN,
+                            HAL_CTRL_TX_FLASH_ENABLE_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxFlashEnable, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxFlashEnable);
+
+
+    p->TnetwDrv_InitParams.whalCtrl_init.numTxQueues    = MAX_NUM_OF_TX_QUEUES;
+    for (i=0;i<p->TnetwDrv_InitParams.whalCtrl_init.numTxQueues;i++){
+
+        p->TnetwDrv_InitParams.whalCtrl_init.tx_attrib_queue[i].numDesc  = localNumTxDesc;/*needed for validation phase only*/
+        /* (!!!) must use different priority for each queue */
+        p->TnetwDrv_InitParams.whalCtrl_init.tx_attrib_queue[i].priority = i;
+    }
+
+
+
+    p->TnetwDrv_InitParams.whalCtrl_init.beaconTemplateSize = sizeof(probeRspTemplate_t);
+    p->TnetwDrv_InitParams.whalCtrl_init.probeRequestTemplateSize = sizeof(probeReqTemplate_t);
+    p->TnetwDrv_InitParams.whalCtrl_init.probeResponseTemplateSize = sizeof(probeRspTemplate_t);
+    p->TnetwDrv_InitParams.whalCtrl_init.nullTemplateSize = sizeof(nullDataTemplate_t);
+    p->TnetwDrv_InitParams.whalCtrl_init.PsPollTemplateSize = sizeof(psPollTemplate_t);
+    p->TnetwDrv_InitParams.whalCtrl_init.qosNullDataTemplateSize = sizeof(QosNullDataTemplate_t);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRBeaconRxTimeout,
+                            BCN_RX_TIMEOUT_DEF_VALUE,
+                            BCN_RX_TIMEOUT_MIN_VALUE,
+                            BCN_RX_TIMEOUT_MAX_VALUE,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.BeaconRxTimeout,
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.BeaconRxTimeout);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRBroadcastRxTimeout,
+                            BROADCAST_RX_TIMEOUT_DEF_VALUE,
+                            BROADCAST_RX_TIMEOUT_MIN_VALUE,
+                            BROADCAST_RX_TIMEOUT_MAX_VALUE,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.BroadcastRxTimeout,
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.BroadcastRxTimeout);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRRxBroadcastInPs,
+                            RX_BROADCAST_IN_PS_DEF_VALUE,
+                            RX_BROADCAST_IN_PS_MIN_VALUE,
+                            RX_BROADCAST_IN_PS_MAX_VALUE,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.RxBroadcastInPs,
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.RxBroadcastInPs);
+
+    regReadIntegerParameter(pAdapter, &STRCalibrationChannel2_4,
+                            HAL_CTRL_CALIBRATION_CHANNEL_2_4_DEF, HAL_CTRL_CALIBRATION_CHANNEL_2_4_MIN,
+                            HAL_CTRL_CALIBRATION_CHANNEL_2_4_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlCalibrationChannel2_4, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlCalibrationChannel2_4);
+
+    regReadIntegerParameter(pAdapter, &STRCalibrationChannel5_0,
+                            HAL_CTRL_CALIBRATION_CHANNEL_5_0_DEF, HAL_CTRL_CALIBRATION_CHANNEL_5_0_MIN,
+                            HAL_CTRL_CALIBRATION_CHANNEL_5_0_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlCalibrationChannel5_0, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlCalibrationChannel5_0);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRConsecutivePsPollDeliveryFailureThreshold,
+                            CONSECUTIVE_PS_POLL_FAILURE_DEF,
+                            CONSECUTIVE_PS_POLL_FAILURE_MIN,
+                            CONSECUTIVE_PS_POLL_FAILURE_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.ConsecutivePsPollDeliveryFailureThreshold,
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.ConsecutivePsPollDeliveryFailureThreshold);
+
+
+    regReadIntegerParameter(pAdapter, &STRdot11RTSThreshold,
+                            HAL_CTRL_RTS_THRESHOLD_DEF, HAL_CTRL_RTS_THRESHOLD_MIN,
+                            HAL_CTRL_RTS_THRESHOLD_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRtsThreshold, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRtsThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRxDisableBroadcast,
+                            HAL_CTRL_RX_DISABLE_BROADCAST_DEF, HAL_CTRL_RX_DISABLE_BROADCAST_MIN,
+                            HAL_CTRL_RX_DISABLE_BROADCAST_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRxDisableBroadcast, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRxDisableBroadcast);
+
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnable,
+                            HAL_CTRL_RECOVERY_ENABLE_DEF, HAL_CTRL_RECOVERY_ENABLE_MIN,
+                            HAL_CTRL_RECOVERY_ENABLE_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRecoveryEnable, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRecoveryEnable);
+
+    p->healthMonitorInitParams.FullRecoveryEnable = (BOOL)p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRecoveryEnable;
+
+    regReadIntegerParameter(pAdapter, &STRdot11FragThreshold,
+                            HAL_CTRL_FRAG_THRESHOLD_DEF, HAL_CTRL_FRAG_THRESHOLD_MIN,
+                            HAL_CTRL_FRAG_THRESHOLD_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlFragThreshold, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlFragThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRdot11MaxTxMSDULifetime,
+                            HAL_CTRL_MAX_TX_MSDU_LIFETIME_DEF, HAL_CTRL_MAX_TX_MSDU_LIFETIME_MIN,
+                            HAL_CTRL_MAX_TX_MSDU_LIFETIME_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlMaxTxMsduLifetime, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlMaxTxMsduLifetime);
+
+    regReadIntegerParameter(pAdapter, &STRdot11MaxReceiveLifetime,
+                            HAL_CTRL_MAX_RX_MSDU_LIFETIME_DEF, HAL_CTRL_MAX_RX_MSDU_LIFETIME_MIN,
+                            HAL_CTRL_MAX_RX_MSDU_LIFETIME_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlMaxRxMsduLifetime, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlMaxRxMsduLifetime);
+    
+    regReadIntegerParameter(pAdapter, &STRdot11RateFallBackRetryLimit,
+                            HAL_CTRL_RATE_FB_RETRY_LIMIT_DEF, HAL_CTRL_RATE_FB_RETRY_LIMIT_MIN,
+                            HAL_CTRL_RATE_FB_RETRY_LIMIT_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRateFallbackRetry, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRateFallbackRetry);
+
+    regReadIntegerParameter(pAdapter, &STRListenInterval,
+                            HAL_CTRL_LISTEN_INTERVAL_DEF, HAL_CTRL_LISTEN_INTERVAL_MIN,
+                            HAL_CTRL_LISTEN_INTERVAL_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlListenInterval, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlListenInterval);
+
+    regReadIntegerParameter(pAdapter, &STRdot11TxAntenna,
+                            HAL_CTRL_TX_ANTENNA_DEF, HAL_CTRL_TX_ANTENNA_MIN,
+                            HAL_CTRL_TX_ANTENNA_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxAntenna, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxAntenna);
+    /* reverse tx antenna value - ACX and utility have reversed values */
+    if (p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxAntenna == TX_ANTENNA_2)
+       p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxAntenna = TX_ANTENNA_1;
+    else
+       p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxAntenna = TX_ANTENNA_2;
+
+
+    regReadIntegerParameter(pAdapter, &STRdot11RxAntenna,
+                            HAL_CTRL_RX_ANTENNA_DEF, HAL_CTRL_RX_ANTENNA_MIN,
+                            HAL_CTRL_RX_ANTENNA_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRxAntenna, 
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRxAntenna);
+
+    regReadIntegerParameter(pAdapter, &STRTxCompleteThreshold,
+                            HAL_CTRL_TX_CMPLT_THRESHOLD_DEF, HAL_CTRL_TX_CMPLT_THRESHOLD_MIN,
+                            HAL_CTRL_TX_CMPLT_THRESHOLD_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxCompleteThreshold, 
+                            (PUCHAR)&(p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxCompleteThreshold));
+
+    pAdapter->ExtMode = TRUE;
+
+    regReadIntegerParameter(pAdapter, &STRdot11DesiredChannel,
+                        SITE_MGR_CHANNEL_DEF, SITE_MGR_CHANNEL_MIN, SITE_MGR_CHANNEL_MAX,
+                        sizeof p->siteMgrInitParams.siteMgrDesiredChannel, 
+                        (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredChannel);
+
+    memcpy((void *)p->siteMgrInitParams.siteMgrDesiredBSSID.addr, &bssidBroadcast, MAC_ADDR_LEN);
+    
+    regReadStringParameter(pAdapter, &STRdot11DesiredSSID,
+                    (PCHAR)dummySsidString,
+                    (UCHAR)MAX_SSID_LEN,
+                    (PUCHAR)p->siteMgrInitParams.siteMgrDesiredSSID.ssidString,
+                    (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredSSID.len);
+
+     
+    regReadIntegerParameter(pAdapter, &STRdot11DesiredNetworkType,
+                            SITE_MGR_DOT_11_MODE_DEF, SITE_MGR_DOT_11_MODE_MIN, SITE_MGR_DOT_11_MODE_MAX,
+                            sizeof p->siteMgrInitParams.siteMgrDesiredDot11Mode, 
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredDot11Mode);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SlotTime,
+        PHY_SLOT_TIME_SHORT, PHY_SLOT_TIME_LONG, PHY_SLOT_TIME_SHORT,
+        sizeof p->siteMgrInitParams.siteMgrDesiredSlotTime,
+        (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredSlotTime);
+
+    regReadIntegerParameter(pAdapter, &STRdot11RtsCtsProtection,
+        0, 0, 1, 
+        sizeof p->ctrlDataInitParams.ctrlDataDesiredCtsRtsStatus,
+        (PUCHAR)&p->ctrlDataInitParams.ctrlDataDesiredCtsRtsStatus);
+
+    regReadIntegerParameter(pAdapter, &STRdot11IbssProtection,
+        ERP_PROTECTION_STANDARD, ERP_PROTECTION_NONE, ERP_PROTECTION_TI_TRICK,
+        sizeof p->ctrlDataInitParams.ctrlDataDesiredIbssProtection,
+        (PUCHAR)&p->ctrlDataInitParams.ctrlDataDesiredIbssProtection);
+
+    /* When working in band A, minimum channel is 36 and not 1*/
+    if (p->siteMgrInitParams.siteMgrDesiredDot11Mode  == DOT11_A_MODE)
+    {
+        if (p->siteMgrInitParams.siteMgrDesiredChannel < SITE_MGR_CHANNEL_A_MIN)
+            p->siteMgrInitParams.siteMgrDesiredChannel = SITE_MGR_CHANNEL_A_MIN;
+    }
+    /* should be read from the registry */
+    p->siteMgrInitParams.siteMgrRadioValues.siteMgr_radiaRadioValues.factorRSSI = 88;
+
+    if(1)
+    {
+        UINT32 Freq2ChannelTable[] = {0,2412000,2417000,2422000,2427000,2432000,2437000,
+                                      2442000,2447000,2452000,2457000,
+                                      2462000,2467000,2472000,2484000};
+
+        memcpy(p->siteMgrInitParams.siteMgrFreq2ChannelTable,
+               Freq2ChannelTable,
+               SITE_MGR_CHANNEL_MAX+1);
+    }
+
+    /* read TX rates from registry */
+    readRates(pAdapter, p);
+
+    regReadIntegerParameter(pAdapter, &STRdot11DesiredBSSType,
+                            SITE_MGR_BSS_TYPE_DEF, BSS_INDEPENDENT, BSS_ANY,
+                            sizeof p->siteMgrInitParams.siteMgrDesiredBSSType,
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredBSSType);
+
+    regReadIntegerParameter(pAdapter, &STRdot11BeaconPeriod,
+                            SITE_MGR_BEACON_INTERVAL_DEF, SITE_MGR_BEACON_INTERVAL_MIN,
+                            SITE_MGR_BEACON_INTERVAL_MAX,
+                            sizeof p->siteMgrInitParams.siteMgrDesiredBeaconInterval,
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredBeaconInterval);
+
+    regReadIntegerParameter(pAdapter, &STRdot11ShortPreambleInvoked,
+                            SITE_MGR_PREAMBLE_TYPE_DEF, PREAMBLE_LONG, PREAMBLE_SHORT,
+                            sizeof p->siteMgrInitParams.siteMgrDesiredPreambleType,
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredPreambleType);
+
+    /* RFMD */
+    regReadStringParameter(pAdapter, &STRRadio11_RxLevel,
+                            (PCHAR)RFMD_RxLevel, (USHORT)SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF,
+                            radioString, (PUCHAR)&p->siteMgrInitParams.siteMgrRadioValues.RxLevelTableSize);
+
+    initRadioValusFromRgstryString( (PCHAR)radioString,
+                                    (PCHAR)p->siteMgrInitParams.siteMgrRadioValues.siteMgr_rfmdRadioValues.siteMgr_radioRxLevel,
+                                    RX_LEVEL_TABLE_SIZE);
+
+    regReadStringParameter(pAdapter, &STRRadio11_LNA,
+                            (PCHAR)RFMD_Lna, (USHORT)SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF,
+                            radioString, (PUCHAR)&p->siteMgrInitParams.siteMgrRadioValues.RxLevelTableSize);
+
+    initRadioValusFromRgstryString( (PCHAR)radioString,
+                                    (PCHAR)p->siteMgrInitParams.siteMgrRadioValues.siteMgr_rfmdRadioValues.siteMgr_radioLNA,
+                                    RX_LEVEL_TABLE_SIZE);
+
+    regReadStringParameter(pAdapter, &STRRadio11_RSSI,
+                            (PCHAR)RFMD_Rssi, (USHORT)SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF,
+                            radioString, (PUCHAR)&p->siteMgrInitParams.siteMgrRadioValues.RxLevelTableSize);
+
+    initRadioValusFromRgstryString( (PCHAR)radioString,
+                                    (PCHAR)p->siteMgrInitParams.siteMgrRadioValues.siteMgr_rfmdRadioValues.siteMgr_radioRSSI,
+                                    RX_LEVEL_TABLE_SIZE);
+    /* MAXIM */
+
+    regReadStringParameter(pAdapter, &STRRadio0D_RxLevel,
+                           (PCHAR)MAXIM_RxLevel, (USHORT)SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF,
+                            radioString, (PUCHAR)&p->siteMgrInitParams.siteMgrRadioValues.RxLevelTableSize);
+
+    initRadioValusFromRgstryString( (PCHAR)radioString,
+                                    (PCHAR)p->siteMgrInitParams.siteMgrRadioValues.siteMgr_maximRadioValues.siteMgr_radioRxLevel,
+                                    RX_LEVEL_TABLE_SIZE);
+
+    regReadStringParameter(pAdapter, &STRRadio0D_LNA,
+                           (PCHAR)MAXIM_Lna, (USHORT)SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF,
+                            radioString, (PUCHAR)&p->siteMgrInitParams.siteMgrRadioValues.RxLevelTableSize);
+
+    initRadioValusFromRgstryString((PCHAR)radioString,
+                                    (PCHAR)p->siteMgrInitParams.siteMgrRadioValues.siteMgr_maximRadioValues.siteMgr_radioLNA,
+                                    RX_LEVEL_TABLE_SIZE);
+
+    regReadStringParameter(pAdapter, &STRRadio0D_RSSI,
+                            (PCHAR)MAXIM_Rssi, (USHORT)SITE_MGR_RX_LEVEL_TABLE_SIZE_DEF,
+                            radioString, (PUCHAR)&p->siteMgrInitParams.siteMgrRadioValues.RxLevelTableSize);
+
+    initRadioValusFromRgstryString((PCHAR)radioString,
+                                    (PCHAR)p->siteMgrInitParams.siteMgrRadioValues.siteMgr_maximRadioValues.siteMgr_radioRSSI,
+                                    RX_LEVEL_TABLE_SIZE);
+
+    regReadIntegerParameter(pAdapter, &STRExternalMode,
+                            SITE_MGR_EXTERNAL_MODE_DEF, SITE_MGR_EXTERNAL_MODE_MIN,
+                            SITE_MGR_EXTERNAL_MODE_MAX,
+                            sizeof p->siteMgrInitParams.siteMgrExternalConfiguration,
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrExternalConfiguration);
+
+    regReadIntegerParameter(pAdapter, &STRWiFiAdHoc,
+                            SITE_MGR_WiFiAdHoc_DEF, SITE_MGR_WiFiAdHoc_MIN, SITE_MGR_WiFiAdHoc_MAX,
+                            sizeof p->siteMgrInitParams.siteMgrWiFiAdhoc,
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrWiFiAdhoc);
+
+    regReadIntegerParameter(pAdapter, &STRWiFiWmmPS,
+                                                   WIFI_WMM_PS_DEF, WIFI_WMM_PS_MIN, WIFI_WMM_PS_MAX,
+                                                   sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.WiFiWmmPS,
+                                                   (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.WiFiWmmPS);
+
+    regReadIntegerParameter(pAdapter, &STRKeepAliveEnable,
+                            SITE_MGR_KEEP_ALIVE_DEF, SITE_MGR_KEEP_ALIVE_MIN, SITE_MGR_KEEP_ALIVE_MAX,
+                            sizeof p->siteMgrInitParams.siteMgrDesiredkeepAliveEnable,
+                            (PUCHAR)&p->siteMgrInitParams.siteMgrDesiredkeepAliveEnable);
+
+    pAdapter->IntMode = (BOOLEAN) p->siteMgrInitParams.siteMgrExternalConfiguration;
+
+    regReadIntegerParameter(pAdapter, &STRConnSelfTimeout,
+                            CONN_SELF_TIMEOUT_DEF, CONN_SELF_TIMEOUT_MIN, CONN_SELF_TIMEOUT_MAX,
+                            sizeof p->connInitParams.connSelfTimeout,
+                            (PUCHAR)&p->connInitParams.connSelfTimeout);
+
+    regReadIntegerParameter(pAdapter, &STRdot11AuthRespTimeout,
+                            AUTH_RESPONSE_TIMEOUT_DEF, AUTH_RESPONSE_TIMEOUT_MIN, AUTH_RESPONSE_TIMEOUT_MAX,
+                            sizeof p->authInitParams.authResponseTimeout,
+                            (PUCHAR)&p->authInitParams.authResponseTimeout);
+
+    regReadIntegerParameter(pAdapter, &STRdot11MaxAuthRetry,
+                            AUTH_MAX_RETRY_COUNT_DEF, AUTH_MAX_RETRY_COUNT_MIN, AUTH_MAX_RETRY_COUNT_MAX,
+                            sizeof p->authInitParams.authMaxRetryCount,
+                            (PUCHAR)&p->authInitParams.authMaxRetryCount);
+
+    regReadIntegerParameter(pAdapter, &STRdot11AssocRespTimeout,
+                            ASSOC_RESPONSE_TIMEOUT_DEF, ASSOC_RESPONSE_TIMEOUT_MIN, ASSOC_RESPONSE_TIMEOUT_MAX,
+                            sizeof p->assocInitParams.assocResponseTimeout,
+                            (PUCHAR)&p->assocInitParams.assocResponseTimeout);
+
+    regReadIntegerParameter(pAdapter, &STRdot11MaxAssocRetry,
+                            ASSOC_MAX_RETRY_COUNT_DEF, ASSOC_MAX_RETRY_COUNT_MIN, ASSOC_MAX_RETRY_COUNT_MAX,
+                            sizeof p->assocInitParams.assocMaxRetryCount,
+                            (PUCHAR)&p->assocInitParams.assocMaxRetryCount);
+
+    regReadIntegerParameter(pAdapter, &STRRxDataFiltersEnabled,
+                            RX_DATA_FILTERS_ENABLED_DEF, RX_DATA_FILTERS_ENABLED_MIN, RX_DATA_FILTERS_ENABLED_MAX,
+                            sizeof p->rxDataInitParams.rxDataFiltersEnabled,
+                            (PUCHAR)&p->rxDataInitParams.rxDataFiltersEnabled);
+
+    regReadIntegerParameter(pAdapter, &STRRxDataFiltersFilter1Offset,
+                            RX_DATA_FILTERS_FILTER_OFFSET_DEF, RX_DATA_FILTERS_FILTER_OFFSET_MIN, RX_DATA_FILTERS_FILTER_OFFSET_MAX,
+                            sizeof filterOffset,
+                            (PUCHAR) &filterOffset);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter1Mask,
+                            RX_DATA_FILTERS_FILTER_MASK_DEF, RX_DATA_FILTERS_FILTER_MASK_LEN_DEF,
+                            (PUCHAR) filterMask,
+                            (PUCHAR) &filterMaskLength);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter1Pattern,
+                            RX_DATA_FILTERS_FILTER_PATTERN_DEF, RX_DATA_FILTERS_FILTER_PATTERN_LEN_DEF,
+                            (PUCHAR) filterPattern,
+                            (PUCHAR) &filterPatternLength);
+
+    parse_filter_request(&p->rxDataInitParams.rxDataFilterRequests[0], filterOffset, filterMask, filterMaskLength, filterPattern, filterPatternLength);
+
+    regReadIntegerParameter(pAdapter, &STRRxDataFiltersFilter2Offset,
+                            RX_DATA_FILTERS_FILTER_OFFSET_DEF, RX_DATA_FILTERS_FILTER_OFFSET_MIN, RX_DATA_FILTERS_FILTER_OFFSET_MAX,
+                            sizeof filterOffset,
+                            (PUCHAR) &filterOffset);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter2Mask,
+                            RX_DATA_FILTERS_FILTER_MASK_DEF, RX_DATA_FILTERS_FILTER_MASK_LEN_DEF,
+                            (PUCHAR) filterMask,
+                            (PUCHAR) &filterMaskLength);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter2Pattern,
+                            RX_DATA_FILTERS_FILTER_PATTERN_DEF, RX_DATA_FILTERS_FILTER_PATTERN_LEN_DEF,
+                            (PUCHAR) filterPattern,
+                            (PUCHAR) &filterPatternLength);
+
+    parse_filter_request(&p->rxDataInitParams.rxDataFilterRequests[1], filterOffset, filterMask, filterMaskLength, filterPattern, filterPatternLength);
+
+    regReadIntegerParameter(pAdapter, &STRRxDataFiltersFilter3Offset,
+                            RX_DATA_FILTERS_FILTER_OFFSET_DEF, RX_DATA_FILTERS_FILTER_OFFSET_MIN, RX_DATA_FILTERS_FILTER_OFFSET_MAX,
+                            sizeof filterOffset,
+                            (PUCHAR) &filterOffset);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter3Mask,
+                            RX_DATA_FILTERS_FILTER_MASK_DEF, RX_DATA_FILTERS_FILTER_MASK_LEN_DEF,
+                            (PUCHAR) filterMask,
+                            (PUCHAR) &filterMaskLength);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter3Pattern,
+                            RX_DATA_FILTERS_FILTER_PATTERN_DEF, RX_DATA_FILTERS_FILTER_PATTERN_LEN_DEF,
+                            (PUCHAR) filterPattern,
+                            (PUCHAR) &filterPatternLength);
+
+    parse_filter_request(&p->rxDataInitParams.rxDataFilterRequests[2], filterOffset, filterMask, filterMaskLength, filterPattern, filterPatternLength);
+
+    regReadIntegerParameter(pAdapter, &STRRxDataFiltersFilter4Offset,
+                            RX_DATA_FILTERS_FILTER_OFFSET_DEF, RX_DATA_FILTERS_FILTER_OFFSET_MIN, RX_DATA_FILTERS_FILTER_OFFSET_MAX,
+                            sizeof filterOffset,
+                            (PUCHAR) &filterOffset);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter4Mask,
+                            RX_DATA_FILTERS_FILTER_MASK_DEF, RX_DATA_FILTERS_FILTER_MASK_LEN_DEF,
+                            (PUCHAR) filterMask,
+                            (PUCHAR) &filterMaskLength);
+
+    regReadStringParameter(pAdapter, &STRRxDataFiltersFilter4Pattern,
+                            RX_DATA_FILTERS_FILTER_PATTERN_DEF, RX_DATA_FILTERS_FILTER_PATTERN_LEN_DEF,
+                            (PUCHAR) filterPattern,
+                            (PUCHAR) &filterPatternLength);
+
+    parse_filter_request(&p->rxDataInitParams.rxDataFilterRequests[3], filterOffset, filterMask, filterMaskLength, filterPattern, filterPatternLength);
+
+    regReadIntegerParameter(pAdapter, &STRRxDataFiltersDefaultAction,
+                            RX_DATA_FILTERS_DEFAULT_ACTION_DEF, RX_DATA_FILTERS_DEFAULT_ACTION_MIN,
+                            RX_DATA_FILTERS_DEFAULT_ACTION_MAX,
+                            sizeof p->rxDataInitParams.rxDataFiltersDefaultAction,
+                            (PUCHAR)&p->rxDataInitParams.rxDataFiltersDefaultAction);
+
+    regReadIntegerParameter(pAdapter, &STRNumTxDataQueues,
+                            TX_DATA_NUMBER_OF_DATA_QUEUES_DEF, TX_DATA_NUMBER_OF_DATA_QUEUES_MIN,
+                            TX_DATA_NUMBER_OF_DATA_QUEUES_MAX,
+                            sizeof p->txDataInitParams.txDataNumOfDataQueues,
+                            (PUCHAR)&p->txDataInitParams.txDataNumOfDataQueues);
+
+    regReadIntegerParameter(pAdapter, &STRCreditCalcTimout,
+                            TX_DATA_CREDIT_CALC_TIMOEUT_DEF, TX_DATA_CREDIT_CALC_TIMOEUT_MIN,
+                            TX_DATA_CREDIT_CALC_TIMOEUT_MAX,
+                            sizeof p->txDataInitParams.creditCalculationTimeout,
+                            (PUCHAR)&p->txDataInitParams.creditCalculationTimeout);
+
+       regReadIntegerParameter(pAdapter, &STRCreditCalcTimerEnabled,
+                                                       FALSE, FALSE, TRUE,
+                                                       sizeof p->txDataInitParams.bCreditCalcTimerEnabled,
+                                                       (PUCHAR)&p->txDataInitParams.bCreditCalcTimerEnabled);
+
+    regReadIntegerParameter(pAdapter, &STRFracOfLifeTimeToDrop,
+                            TX_DATA_FRAC_OF_LIFE_TIME_TO_DROP_DEF, TX_DATA_FRAC_OF_LIFE_TIME_TO_DROP_MIN,
+                            TX_DATA_FRAC_OF_LIFE_TIME_TO_DROP_MAX,
+                            sizeof p->txDataInitParams.uFracOfLifeTimeToDrop,
+                            (PUCHAR)&p->txDataInitParams.uFracOfLifeTimeToDrop);
+
+    regReadIntegerParameter(pAdapter, &STRAdmCtrlDelayDueToMediumTimeOverUsage,
+                            TX_DATA_ADM_CTRL_DELAY_DUE_TO_MEDIUM_OVER_USAGE_DEF, TX_DATA_ADM_CTRL_DELAY_DUE_TO_MEDIUM_OVER_USAGE_MIN,
+                            TX_DATA_ADM_CTRL_DELAY_DUE_TO_MEDIUM_OVER_USAGE_MAX,
+                            sizeof p->txDataInitParams.admCtrlDelayDueToMediumTimeOverUsage,
+                            (PUCHAR)&p->txDataInitParams.admCtrlDelayDueToMediumTimeOverUsage);
+  
+    regReadIntegerParameter(pAdapter, &STRAdmissionDownGradeEnable,
+                            TX_DATA_ADM_CTRL_DOWN_GRADE_DEF, TX_DATA_ADM_CTRL_DOWN_GRADE_MIN,
+                            TX_DATA_ADM_CTRL_DOWN_GRADE_MAX,
+                            sizeof p->txDataInitParams.admissionDownGradeEnable,
+                            (PUCHAR)&p->txDataInitParams.admissionDownGradeEnable);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficAdmControlTimeout,
+                    TRAFFIC_ADM_CONTROL_TIMEOUT_DEF, TRAFFIC_ADM_CONTROL_TIMEOUT_MIN,
+                    TRAFFIC_ADM_CONTROL_TIMEOUT_MAX,
+                    sizeof p->qosMngrInitParams.trafficAdmCtrlInitParams.trafficAdmCtrlResponseTimeout,
+                    (PUCHAR)&p->qosMngrInitParams.trafficAdmCtrlInitParams.trafficAdmCtrlResponseTimeout);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficAdmControlUseFixedMsduSize,
+                    FALSE, FALSE, TRUE,
+                    sizeof p->qosMngrInitParams.trafficAdmCtrlInitParams.trafficAdmCtrlUseFixedMsduSize,
+                    (PUCHAR)&p->qosMngrInitParams.trafficAdmCtrlInitParams.trafficAdmCtrlUseFixedMsduSize);
+
+    regReadIntegerParameter(pAdapter, &STRDesiredMaxSpLen,
+                    QOS_MAX_SP_LEN_DEF, QOS_MAX_SP_LEN_MIN,
+                    QOS_MAX_SP_LEN_MAX,
+                    sizeof p->qosMngrInitParams.desiredMaxSpLen,
+                    (PUCHAR)&p->qosMngrInitParams.desiredMaxSpLen);
+
+    regReadIntegerParameter(pAdapter, &STRRateContThreshold,
+                            CTRL_DATA_CONT_TX_THRESHOLD_DEF, CTRL_DATA_CONT_TX_THRESHOLD_MIN,
+                            CTRL_DATA_CONT_TX_THRESHOLD_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.contTxPacketsThreshold,
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.contTxPacketsThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRRateStepUpThreshold,
+                            CTRL_DATA_STEP_UP_TX_THRESHOLD_DEF, CTRL_DATA_STEP_UP_TX_THRESHOLD_MIN,
+                            CTRL_DATA_STEP_UP_TX_THRESHOLD_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.stepUpTxPacketsThreshold,
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.stepUpTxPacketsThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRFBShortInterval,
+                            CTRL_DATA_FB_SHORT_INTERVAL_DEF, CTRL_DATA_FB_SHORT_INTERVAL_MIN,
+                            CTRL_DATA_FB_SHORT_INTERVAL_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.ctrlDataFBShortInterval,
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.ctrlDataFBShortInterval);
+
+    regReadIntegerParameter(pAdapter, &STRFBLongInterval,
+                            CTRL_DATA_FB_LONG_INTERVAL_DEF, CTRL_DATA_FB_LONG_INTERVAL_MIN,
+                            CTRL_DATA_FB_LONG_INTERVAL_MAX,
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.ctrlDataFBLongInterval,
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.ctrlDataFBLongInterval);
+
+    regReadIntegerParameter(pAdapter, &STRRateAdaptationTimeout,
+                            RATE_ADAPTATION_TIMEOUT_DEF , RATE_ADAPTATION_TIMEOUT_MIN, RATE_ADAPTATION_TIMEOUT_MAX, 
+                            sizeof p->ctrlDataInitParams.rateAdaptationInitParam.rateAdapt_timeout,
+                            (PUCHAR)&p->ctrlDataInitParams.rateAdaptationInitParam.rateAdapt_timeout);
+
+
+    regReadIntegerParameter(pAdapter, &STRRateControlEnable,
+                            CTRL_DATA_RATE_CONTROL_ENABLE_DEF, CTRL_DATA_RATE_CONTROL_ENABLE_MIN, CTRL_DATA_RATE_CONTROL_ENABLE_MAX,
+                            sizeof p->ctrlDataInitParams.ctrlDataRateControlEnable,
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataRateControlEnable);
+
+/*                              SME Initialization Parameters                           */
+/*                          ====================================                        */
+
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanEnabled,
+                            ENABLE_SME_SCAN_DEF, ENABLE_SME_SCAN_MIN, ENABLE_SME_SCAN_MAX,
+                            sizeof p->smeInitParams.EnableFirstConnScan,
+                            (PUCHAR)&p->smeInitParams.EnableFirstConnScan);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeInterScanMin,
+                            SME_INTER_SCAN_MIN_DEF, SME_INTER_SCAN_MIN_MIN, SME_INTER_SCAN_MIN_MAX,
+                            sizeof p->smeInitParams.InterScanIntervalMin,
+                            (PUCHAR)&p->smeInitParams.InterScanIntervalMin);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeInterScanMax,
+                            SME_INTER_SCAN_MAX_DEF, SME_INTER_SCAN_MAX_MIN, SME_INTER_SCAN_MAX_MAX,
+                            sizeof p->smeInitParams.InterScanIntervalMax,
+                            (PUCHAR)&p->smeInitParams.InterScanIntervalMax);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeInterScanDelta,
+                            SME_INTER_SCAN_DELTA_DEF, SME_INTER_SCAN_DELTA_MIN, SME_INTER_SCAN_DELTA_MAX,
+                            sizeof p->smeInitParams.InterScanIntervalDelta,
+                            (PUCHAR)&p->smeInitParams.InterScanIntervalDelta);
+
+
+
+    /*          B/G scan first scan params                    */
+    /*         ----------------------------                   */
+    regReadIntegerTable(pAdapter, &STRdot11SmeScanBGChannelList, SME_SCAN_BG_LIST_BAND_VAL_DEF,
+                              SME_SCAN_BG_LIST_BAND_STRING_MAX_SIZE,
+                              (PUCHAR)&p->smeInitParams.scanParamsBG.channelsList);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanBGMinDwellTime,
+                            SME_SCAN_BG_MIN_DWELL_TIME_DEF, SME_SCAN_BG_MIN_DWELL_TIME_MIN, SME_SCAN_BG_MIN_DWELL_TIME_MAX,
+                            sizeof p->smeInitParams.scanParamsBG.minDwellTime,
+                            (PUCHAR)&p->smeInitParams.scanParamsBG.minDwellTime);
+    
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanBGMaxDwellTime,
+                            SME_SCAN_BG_MAX_DWELL_TIME_DEF, SME_SCAN_BG_MAX_DWELL_TIME_MIN, SME_SCAN_BG_MAX_DWELL_TIME_MAX,
+                            sizeof p->smeInitParams.scanParamsBG.maxDwellTime,
+                            (PUCHAR)&p->smeInitParams.scanParamsBG.maxDwellTime);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanBGNumProbReq,
+                            SME_SCAN_BG_NUM_PROB_REQ_DEF, SME_SCAN_BG_NUM_PROB_REQ_MIN, SME_SCAN_BG_NUM_PROB_REQ_MAX,
+                            sizeof p->smeInitParams.scanParamsBG.probeReqNumber,
+                            (PUCHAR)&p->smeInitParams.scanParamsBG.probeReqNumber);
+    
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanBGProbReqRate,
+                            SME_SCAN_BG_PROB_REQ_RATE_DEF, SME_SCAN_BG_PROB_REQ_RATE_MIN, SME_SCAN_BG_NUM_PROB_REQ_RATE_MAX,
+                            sizeof p->smeInitParams.scanParamsBG.probeRequestRate,
+                            (PUCHAR)&p->smeInitParams.scanParamsBG.probeRequestRate);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanBGTxPowerLevel,
+                            SME_SCAN_BG_TX_POWER_DEF, SME_SCAN_BG_TX_POWER_MIN, SME_SCAN_BG_TX_POWER_MAX,
+                            sizeof p->smeInitParams.scanParamsBG.txPowerDbm,
+                            (PUCHAR)&p->smeInitParams.scanParamsBG.txPowerDbm);
+    
+
+
+
+    /*          A band first scan params                      */
+    /*         ----------------------------                   */
+    regReadIntegerTable(pAdapter, &STRdot11SmeScanAChannelList, SME_SCAN_A_LIST_BAND_VAL_DEF,
+                              SME_SCAN_A_LIST_BAND_STRING_MAX_SIZE,
+                              (PUCHAR)&p->smeInitParams.scanParamsA.channelsList);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanAMinDwellTime,
+                            SME_SCAN_A_MIN_DWELL_TIME_DEF, SME_SCAN_A_MIN_DWELL_TIME_MIN, SME_SCAN_A_MIN_DWELL_TIME_MAX,
+                            sizeof p->smeInitParams.scanParamsA.minDwellTime,
+                            (PUCHAR)&p->smeInitParams.scanParamsA.minDwellTime);
+    
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanAMaxDwellTime,
+                            SME_SCAN_A_MAX_DWELL_TIME_DEF, SME_SCAN_A_MAX_DWELL_TIME_MIN, SME_SCAN_A_MAX_DWELL_TIME_MAX,
+                            sizeof p->smeInitParams.scanParamsA.maxDwellTime,
+                            (PUCHAR)&p->smeInitParams.scanParamsA.maxDwellTime);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanANumProbReq,
+                            SME_SCAN_A_NUM_PROB_REQ_DEF, SME_SCAN_A_NUM_PROB_REQ_MIN, SME_SCAN_A_NUM_PROB_REQ_MAX,
+                            sizeof p->smeInitParams.scanParamsA.probeReqNumber,
+                            (PUCHAR)&p->smeInitParams.scanParamsA.probeReqNumber);
+    
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanAProbReqRate,
+                            SME_SCAN_A_PROB_REQ_RATE_DEF, SME_SCAN_A_PROB_REQ_RATE_MIN, SME_SCAN_A_NUM_PROB_REQ_RATE_MAX,
+                            sizeof p->smeInitParams.scanParamsA.probeRequestRate,
+                            (PUCHAR)&p->smeInitParams.scanParamsA.probeRequestRate);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SmeScanATxPowerLevel,
+                            SME_SCAN_A_TX_POWER_DEF, SME_SCAN_A_TX_POWER_MIN, SME_SCAN_A_TX_POWER_MAX,
+                            sizeof p->smeInitParams.scanParamsA.txPowerDbm,
+                            (PUCHAR)&p->smeInitParams.scanParamsA.txPowerDbm);
+
+    regReadIntegerParameter(pAdapter, &STRdot11AuthenticationMode,
+                            RSN_AUTH_SUITE_DEF, RSN_AUTH_SUITE_MIN, RSN_AUTH_SUITE_MAX,
+                            sizeof p->rsnInitParams.authSuite,
+                            (PUCHAR)&p->rsnInitParams.authSuite);
+
+    regReadIntegerParameter(pAdapter, &STRdot11FourXEnable,
+                            CTRL_DATA_FOUR_X_ENABLE_DEF, CTRL_DATA_FOUR_X_ENABLE_MIN, CTRL_DATA_FOUR_X_ENABLE_MAX,
+                            sizeof p->ctrlDataInitParams.ctrlDataFourXEnable,
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataFourXEnable);
+
+    /* Soft Gemini Section */
+    
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistEnable,
+                            SOFT_GEMINI_ENABLED_DEF, SOFT_GEMINI_ENABLED_MIN, SOFT_GEMINI_ENABLED_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiEnable, 
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiEnable);
+
+    regReadIntegerTable(pAdapter, &STRBThWlanCoexistRate, SG_RATES_DEF,
+                              SG_RATES_STRING_MAX_DEF,
+                              (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiRate);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsbtHpMaxTime,
+                            SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_DEF, SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_MIN, SOFT_GEMINI_PARAMS_BT_HP_MAXTIME_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.btHpMaxTime,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.btHpMaxTime);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamswlanHpMaxTime,
+                            SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_DEF, SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_MIN, SOFT_GEMINI_PARAMS_WLAN_HP_MAX_TIME_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.wlanHpMaxTime,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.wlanHpMaxTime);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamssenseDisableTimer,
+                            SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_DEF, SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_MIN, SOFT_GEMINI_PARAMS_SENSE_DISABLE_TIMER_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.senseDisableTimer,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.senseDisableTimer);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsprotectiveRxTimeBeforeBtHp,
+                            SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_DEF, SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.protectiveRxTimeBeforeBtHp,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.protectiveRxTimeBeforeBtHp);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsprotectiveTxTimeBeforeBtHp,
+                            SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_DEF, SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.protectiveTxTimeBeforeBtHp,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.protectiveTxTimeBeforeBtHp);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsprotectiveRxTimeBeforeBtHpFastAp,
+                            SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_DEF, SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_RX_TIME_FAST_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.protectiveRxTimeBeforeBtHpFastAp,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.protectiveRxTimeBeforeBtHpFastAp);
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsprotectiveTxTimeBeforeBtHpFastAp,
+                            SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_DEF, SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_MIN, SOFT_GEMINI_PARAMS_PROTECTIVE_TX_TIME_FAST_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.protectiveTxTimeBeforeBtHpFastAp, 
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.protectiveTxTimeBeforeBtHpFastAp);
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsprotectiveWlanCycleTimeForFastAp,
+                            SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_DEF, SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_MIN, SOFT_GEMINI_PARAMS_CYCLE_TIME_FAST_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.protectiveWlanCycleTimeForFastAp, 
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.protectiveWlanCycleTimeForFastAp);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamstimeoutNextBtLpPacket,
+                            SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_DEF, SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_MIN, SOFT_GEMINI_PARAMS_TIMEOUT_NEXT_BT_LP_PACKET_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.timeoutNextBtLpPacket,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.timeoutNextBtLpPacket);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamssgAntennaType,
+                            SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_DEF, SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_MIN, SOFT_GEMINI_PARAMS_SG_ANTENNA_TYPE_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.sgAntennaType,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.sgAntennaType);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamssignalingType,
+                            SOFT_GEMINI_PARAMS_SIGNALING_TYPE_DEF, SOFT_GEMINI_PARAMS_SIGNALING_TYPE_MIN, SOFT_GEMINI_PARAMS_SIGNALING_TYPE_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.signalingType,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.signalingType);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsafhLeverageOn,
+                            SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_DEF, SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_MIN, SOFT_GEMINI_PARAMS_AFH_LEVERAGE_ON_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.afhLeverageOn,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.afhLeverageOn);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsnumberQuietCycle,
+                            SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_DEF, SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_MIN, SOFT_GEMINI_PARAMS_NUMBER_QUIET_CYCLE_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.numberQuietCycle,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.numberQuietCycle);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsmaxNumCts,
+                            SOFT_GEMINI_PARAMS_MAX_NUM_CTS_DEF, SOFT_GEMINI_PARAMS_MAX_NUM_CTS_MIN, SOFT_GEMINI_PARAMS_MAX_NUM_CTS_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.maxNumCts,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.maxNumCts);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsnumberOfWlanPackets,
+                            SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_DEF, SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_MIN, SOFT_GEMINI_PARAMS_NUMBER_OF_WLAN_PACKETS_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.numberOfWlanPackets,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.numberOfWlanPackets);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsnumberOfBtPackets,
+                            SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_DEF, SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_MIN, SOFT_GEMINI_PARAMS_NUMBER_OF_BT_PACKETS_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.numberOfBtPackets,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.numberOfBtPackets);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsnumberOfMissedRxForAvalancheTrigger,
+                            SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_DEF, SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_MIN, SOFT_GEMINI_PARAMS_RX_FOR_AVALANCHE_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.numberOfMissedRxForAvalancheTrigger,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.numberOfMissedRxForAvalancheTrigger);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamswlanElpHpSupport,
+                            SOFT_GEMINI_PARAMS_ELP_HP_DEF, SOFT_GEMINI_PARAMS_ELP_HP_MIN, SOFT_GEMINI_PARAMS_ELP_HP_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.wlanElpHpSupport,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.wlanElpHpSupport);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsbtAntiStarvationPeriod,
+                            SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_DEF, SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_MIN, SOFT_GEMINI_PARAMS_ANTI_STARVE_PERIOD_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.btAntiStarvationPeriod,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.btAntiStarvationPeriod);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsbtAntiStarvationNumberOfCyclesWithinThePeriod,
+                            SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_DEF, SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_MIN, SOFT_GEMINI_PARAMS_ANTI_STARVE_NUM_CYCLE_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.btAntiStarvationNumberOfCyclesWithinThePeriod ,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.btAntiStarvationNumberOfCyclesWithinThePeriod);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsackModeDuringBtLpInDualAnt,
+                            SOFT_GEMINI_PARAMS_ACK_MODE_DEF, SOFT_GEMINI_PARAMS_ACK_MODE_MIN, SOFT_GEMINI_PARAMS_ACK_MODE_MAX,
+                            sizeof p->SoftGeminiInitParams.SoftGeminiParam.ackModeDuringBtLpInDualAnt ,
+                            (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.ackModeDuringBtLpInDualAnt);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsallowPaSdToggleDuringBtActivityEnable,
+        SOFT_GEMINI_PARAMS_ALLOW_PA_SD_DEF, SOFT_GEMINI_PARAMS_ALLOW_PA_SD_MIN, SOFT_GEMINI_PARAMS_ALLOW_PA_SD_MAX,
+        sizeof p->SoftGeminiInitParams.SoftGeminiParam.allowPaSdToggleDuringBtActivityEnable ,
+        (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.allowPaSdToggleDuringBtActivityEnable);
+    
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamswakeUpTimeBeforeBeacon,
+        SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_DEF, SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_MIN, SOFT_GEMINI_PARAMS_TIME_BEFORE_BEACON_MAX,
+        sizeof p->SoftGeminiInitParams.SoftGeminiParam.wakeUpTimeBeforeBeacon ,
+        (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.wakeUpTimeBeforeBeacon);
+
+       regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamshpdmMaxGuardTime,
+               SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_DEF, SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_MIN, SOFT_GEMINI_PARAMS_HPDM_MAX_TIME_MAX,
+               sizeof p->SoftGeminiInitParams.SoftGeminiParam.hpdmMaxGuardTime ,
+               (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.hpdmMaxGuardTime);
+
+       regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamstimeoutNextWlanPacket,
+               SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_DEF, SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_MIN, SOFT_GEMINI_PARAMS_TIME_OUT_NEXT_WLAN_MAX,
+               sizeof p->SoftGeminiInitParams.SoftGeminiParam.timeoutNextWlanPacket ,
+               (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.timeoutNextWlanPacket);
+
+       regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamssgAutoModeNoCts,
+               SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_DEF, SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_MIN, SOFT_GEMINI_PARAMS_AUTO_MODE_NO_CTS_MAX,
+               sizeof p->SoftGeminiInitParams.SoftGeminiParam.sgAutoModeNoCts ,
+               (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.sgAutoModeNoCts);
+
+       regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamsnumOfBtHpRespectedReq,
+               SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_DEF, SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_MIN, SOFT_GEMINI_PARAMS_BT_HP_RESPECTED_MAX,
+               sizeof p->SoftGeminiInitParams.SoftGeminiParam.numOfBtHpRespectedReq ,
+               (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.numOfBtHpRespectedReq);
+
+       regReadIntegerParameter(pAdapter, &STRBThWlanCoexistParamswlanRxMinRateToRespectBtHp,
+               SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_DEF, SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_MIN, SOFT_GEMINI_PARAMS_WLAN_RX_MIN_RATE_MAX,
+               sizeof p->SoftGeminiInitParams.SoftGeminiParam.wlanRxMinRateToRespectBtHp ,
+               (PUCHAR)&p->SoftGeminiInitParams.SoftGeminiParam.wlanRxMinRateToRespectBtHp);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistScanNumberOfProbes,
+                            SOFT_GEMINI_SCAN_NUMBER_OF_PROBE_REQUEST_DEF, SOFT_GEMINI_SCAN_NUMBER_OF_PROBE_REQUEST_MIN, SOFT_GEMINI_SCAN_NUMBER_OF_PROBE_REQUEST_MAX,
+                            sizeof p->SoftGeminiInitParams.scanNumOfProbeRequest, 
+                            (PUCHAR)&p->SoftGeminiInitParams.scanNumOfProbeRequest);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistScanCompensationPercent,
+                            SOFT_GEMINI_SCAN_COMPENSATION_PERCENT_DEF, SOFT_GEMINI_SCAN_COMPENSATION_PERCENT_MIN, SOFT_GEMINI_SCAN_COMPENSATION_PERCENT_MAX,
+                            sizeof p->SoftGeminiInitParams.scanCompensationPercent, 
+                            (PUCHAR)&p->SoftGeminiInitParams.scanCompensationPercent);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistScanCompensationMaxTime,
+                            SOFT_GEMINI_SCAN_COMPENSATION_MAX_TIME_DEF, SOFT_GEMINI_SCAN_COMPENSATION_MAX_TIME_MIN, SOFT_GEMINI_SCAN_COMPENSATION_MAX_TIME_MAX,
+                            sizeof p->SoftGeminiInitParams.scanCompensationMaxTime,
+                            (PUCHAR)&p->SoftGeminiInitParams.scanCompensationMaxTime);
+
+    regReadIntegerParameter(pAdapter, &STRBThWlanCoexistBSSLossCompensationPercent,
+                            SOFT_GEMINI_BSS_LOSS_COMPENSATION_PERCENT_DEF, SOFT_GEMINI_BSS_LOSS_COMPENSATION_PERCENT_MIN, SOFT_GEMINI_BSS_LOSS_COMPENSATION_PERCENT_MAX,
+                            sizeof p->SoftGeminiInitParams.BSSLossCompensationPercent,
+                            (PUCHAR)&p->SoftGeminiInitParams.BSSLossCompensationPercent);
+
+
+    /* update hal 4x params */
+    p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlEnable4x = p->ctrlDataInitParams.ctrlDataFourXEnable;
+
+    /*
+    Power Manager
+    */
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMode,
+                            POWER_MODE_DEF_VALUE,
+                            POWER_MODE_MIN_VALUE,
+                            POWER_MODE_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.powerMode,
+                            (PUCHAR)&p->PowerMgrInitParams.powerMode);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRBeaconReceiveTime,
+                            BEACON_RECEIVE_TIME_DEF_VALUE,
+                            BEACON_RECEIVE_TIME_MIN_VALUE,
+                            BEACON_RECEIVE_TIME_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.beaconReceiveTime,
+                            (PUCHAR)&p->PowerMgrInitParams.beaconReceiveTime);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRBaseBandWakeUpTime,
+                            BASE_BAND_WAKE_UP_TIME_DEF_VALUE,
+                            BASE_BAND_WAKE_UP_TIME_MIN_VALUE,
+                            BASE_BAND_WAKE_UP_TIME_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.BaseBandWakeUpTime,
+                            (PUCHAR)&p->PowerMgrInitParams.BaseBandWakeUpTime);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRHangoverPeriod,
+                            HANGOVER_PERIOD_DEF_VALUE,
+                            HANGOVER_PERIOD_MIN_VALUE,
+                            HANGOVER_PERIOD_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.hangoverPeriod,
+                            (PUCHAR)&p->PowerMgrInitParams.hangoverPeriod);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRBeaconListenInterval,
+                            BEACON_LISTEN_INTERVAL_DEF_VALUE,
+                            BEACON_LISTEN_INTERVAL_MIN_VALUE,
+                            BEACON_LISTEN_INTERVAL_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.beaconListenInterval,
+                            (PUCHAR)&p->PowerMgrInitParams.beaconListenInterval);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRDtimListenInterval,
+                            DTIM_LISTEN_INTERVAL_DEF_VALUE,
+                            DTIM_LISTEN_INTERVAL_MIN_VALUE,
+                            DTIM_LISTEN_INTERVAL_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.dtimListenInterval,
+                            (PUCHAR)&p->PowerMgrInitParams.dtimListenInterval);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRNConsecutiveBeaconsMissed,
+                            N_CONSECUTIVE_BEACONS_MISSED_DEF_VALUE,
+                            N_CONSECUTIVE_BEACONS_MISSED_MIN_VALUE,
+                            N_CONSECUTIVE_BEACONS_MISSED_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.nConsecutiveBeaconsMissed,
+                            (PUCHAR)&p->PowerMgrInitParams.nConsecutiveBeaconsMissed);
+
+    regReadIntegerParameter(pAdapter,
+                            &STREnterTo802_11PsRetries,
+                            ENTER_TO_802_11_POWER_SAVE_RETRIES_DEF_VALUE,
+                            ENTER_TO_802_11_POWER_SAVE_RETRIES_MIN_VALUE,
+                            ENTER_TO_802_11_POWER_SAVE_RETRIES_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.EnterTo802_11PsRetries,
+                            (PUCHAR)&p->PowerMgrInitParams.EnterTo802_11PsRetries);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRAutoPowerModeInterval,
+                            AUTO_POWER_MODE_INTERVAL_DEF_VALUE,
+                            AUTO_POWER_MODE_INTERVAL_MIN_VALUE,
+                            AUTO_POWER_MODE_INTERVAL_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.autoModeInterval,
+                            (PUCHAR)&p->PowerMgrInitParams.autoModeInterval);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRAutoPowerModeActiveTh,
+                            AUTO_POWER_MODE_ACTIVE_TH_DEF_VALUE,
+                            AUTO_POWER_MODE_ACTIVE_TH_MIN_VALUE,
+                            AUTO_POWER_MODE_ACTIVE_TH_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.autoModeActiveTH,
+                            (PUCHAR)&p->PowerMgrInitParams.autoModeActiveTH);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRAutoPowerModeDozeTh,
+                            AUTO_POWER_MODE_DOZE_TH_DEF_VALUE,
+                            AUTO_POWER_MODE_DOZE_TH_MIN_VALUE,
+                            AUTO_POWER_MODE_DOZE_TH_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.autoModeDozeTH,
+                            (PUCHAR)&p->PowerMgrInitParams.autoModeDozeTH);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRAutoPowerModeDozeMode,
+                            AUTO_POWER_MODE_DOZE_MODE_DEF_VALUE,
+                            AUTO_POWER_MODE_DOZE_MODE_MIN_VALUE,
+                            AUTO_POWER_MODE_DOZE_MODE_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.autoModeDozeMode,
+                            (PUCHAR)&p->PowerMgrInitParams.autoModeDozeMode);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRDefaultPowerLevel,
+                            DEFAULT_POWER_LEVEL_DEF_VALUE,
+                            DEFAULT_POWER_LEVEL_MIN_VALUE,
+                            DEFAULT_POWER_LEVEL_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.defaultPowerLevel,
+                            (PUCHAR)&p->PowerMgrInitParams.defaultPowerLevel);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerSavePowerLevel,
+                            PS_POWER_LEVEL_DEF_VALUE,
+                            PS_POWER_LEVEL_MIN_VALUE,
+                            PS_POWER_LEVEL_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.PowerSavePowerLevel,
+                            (PUCHAR)&p->PowerMgrInitParams.PowerSavePowerLevel);
+
+/*---------------------- Power Management Configuration -----------------------*/
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtHangOverPeriod,
+                            HANGOVER_PERIOD_DEF_VALUE,
+                            HANGOVER_PERIOD_MIN_VALUE,
+                            HANGOVER_PERIOD_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.hangOverPeriod,
+                            (PUCHAR)&p->PowerMgrInitParams.hangOverPeriod);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtNeedToSendNullData,
+                            POWER_MGMNT_NEED_TO_SEND_NULL_PACKET_DEF_VALUE,
+                            POWER_MGMNT_NEED_TO_SEND_NULL_PACKET_MIN_VALUE,
+                            POWER_MGMNT_NEED_TO_SEND_NULL_PACKET_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.needToSendNullData,
+                            (PUCHAR)&p->PowerMgrInitParams.needToSendNullData);
+    
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtNullPktRateModulation,
+                            POWER_MGMNT_NULL_PACKET_RATE_MOD_DEF_VALUE,
+                            POWER_MGMNT_NULL_PACKET_RATE_MOD_MIN_VALUE,
+                            POWER_MGMNT_NULL_PACKET_RATE_MOD_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.NullPktRateModulation,
+                            (PUCHAR)&p->PowerMgrInitParams.NullPktRateModulation);
+    
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtNumNullPktRetries,
+                            POWER_MGMNT_NUM_NULL_PACKET_RETRY_DEF_VALUE,
+                            POWER_MGMNT_NUM_NULL_PACKET_RETRY_MIN_VALUE,
+                            POWER_MGMNT_NUM_NULL_PACKET_RETRY_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.numNullPktRetries,
+                            (PUCHAR)&p->PowerMgrInitParams.numNullPktRetries);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtPllLockTime,
+                            PLL_LOCK_TIME_DEF_VALUE,
+                            PLL_LOCK_TIME_MIN_VALUE,
+                            PLL_LOCK_TIME_MAX_VALUE,
+                            sizeof p->PowerMgrInitParams.PLLlockTime,
+                            (PUCHAR)&p->PowerMgrInitParams.PLLlockTime);
+
+    regReadIntegerParameter(pAdapter,
+                            &STRPsPollDeliveryFailureRecoveryPeriod,
+                            PS_POLL_FAILURE_PERIOD_DEF,
+                            PS_POLL_FAILURE_PERIOD_MIN,
+                            PS_POLL_FAILURE_PERIOD_MAX,
+                            sizeof p->PowerMgrInitParams.PsPollDeliveryFailureRecoveryPeriod,
+                            (PUCHAR)&p->PowerMgrInitParams.PsPollDeliveryFailureRecoveryPeriod);
+
+        
+    /*--------------- Power Management Wake up conditions ------------------*/
+
+    regReadIntegerParameter(pAdapter, &STRListenInterval,
+                            HAL_CTRL_LISTEN_INTERVAL_DEF, HAL_CTRL_LISTEN_INTERVAL_MIN,
+                            HAL_CTRL_LISTEN_INTERVAL_MAX,
+                            sizeof p->PowerMgrInitParams.listenInterval,
+                            (PUCHAR)&p->PowerMgrInitParams.listenInterval);
+
+    /*-----------------------------------------------------------------------*/
+
+    /*--------------- Power Server Init Parameters ------------------*/
+    regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtNumNullPktRetries,
+                            POWER_MGMNT_NUM_NULL_PACKET_RETRY_DEF_VALUE,
+                            POWER_MGMNT_NUM_NULL_PACKET_RETRY_MIN_VALUE,
+                            POWER_MGMNT_NUM_NULL_PACKET_RETRY_MAX_VALUE,
+                            sizeof p->TnetwDrv_InitParams.PowerSrvInitParams.numNullPktRetries,
+                            (PUCHAR)&p->TnetwDrv_InitParams.PowerSrvInitParams.numNullPktRetries);
+
+        regReadIntegerParameter(pAdapter,
+                            &STRPowerMgmtHangOverPeriod,
+                            HANGOVER_PERIOD_DEF_VALUE,
+                            HANGOVER_PERIOD_MIN_VALUE,
+                            HANGOVER_PERIOD_MAX_VALUE,
+                            sizeof p->TnetwDrv_InitParams.PowerSrvInitParams.hangOverPeriod,
+                            (PUCHAR)&p->TnetwDrv_InitParams.PowerSrvInitParams.hangOverPeriod);
+    /*-----------------------------------------------------------------------*/
+    
+
+    /* Scan SRV */
+    regReadIntegerParameter(pAdapter, &STRNumberOfNoScanCompleteToRecovery,
+                            SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_DEF,
+                            SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_MIN,
+                            SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_MAX,
+                            sizeof (p->TnetwDrv_InitParams.scanSrvInitParams.numberOfNoScanCompleteToRecovery),
+                            (PUCHAR)&(p->TnetwDrv_InitParams.scanSrvInitParams.numberOfNoScanCompleteToRecovery) );
+
+    regReadIntegerParameter(pAdapter, &STRTriggeredScanTimeOut,
+        SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_DEF,
+        SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_MIN,
+        SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_MAX,
+        sizeof (p->TnetwDrv_InitParams.scanSrvInitParams.uTriggeredScanTimeOut),
+        (PUCHAR)&(p->TnetwDrv_InitParams.scanSrvInitParams.uTriggeredScanTimeOut) );
+
+    /* Regulatory Domain */
+
+    /* Indicate the time in which the STA didn't receive any country code and was not connected, and therefore
+       will delete its current country code */
+    regReadIntegerParameter(pAdapter, &STRTimeToResetCountryMs,
+                        REGULATORY_DOMAIN_COUNTRY_TIME_RESET_DEF, REGULATORY_DOMAIN_COUNTRY_TIME_RESET_MIN,
+                        REGULATORY_DOMAIN_COUNTRY_TIME_RESET_MAX, 
+                        sizeof p->regulatoryDomainInitParams.uTimeOutToResetCountryMs,
+                        (PUCHAR)&(p->regulatoryDomainInitParams.uTimeOutToResetCountryMs));
+
+    /* 802.11d/h */
+    regReadIntegerParameter(pAdapter, &STRMultiRegulatoryDomainEnabled,
+                            MULTI_REGULATORY_DOMAIN_ENABLED_DEF, MULTI_REGULATORY_DOMAIN_ENABLED_MIN,
+                            MULTI_REGULATORY_DOMAIN_ENABLED_MAX, 
+                            sizeof p->regulatoryDomainInitParams.multiRegulatoryDomainEnabled,
+                            (PUCHAR)&(p->regulatoryDomainInitParams.multiRegulatoryDomainEnabled));
+
+    regReadIntegerParameter(pAdapter, &STRSpectrumManagementEnabled,
+                            SPECTRUM_MANAGEMENT_ENABLED_DEF, SPECTRUM_MANAGEMENT_ENABLED_MIN,
+                            SPECTRUM_MANAGEMENT_ENABLED_MAX, 
+                            sizeof p->regulatoryDomainInitParams.spectrumManagementEnabled,
+                            (PUCHAR)&(p->regulatoryDomainInitParams.spectrumManagementEnabled));
+
+    regReadIntegerParameter(pAdapter, &STRSpectrumManagementEnabled,
+                            SPECTRUM_MANAGEMENT_ENABLED_DEF, SPECTRUM_MANAGEMENT_ENABLED_MIN,
+                            SPECTRUM_MANAGEMENT_ENABLED_MAX, 
+                            sizeof p->SwitchChannelInitParams.dot11SpectrumManagementRequired,
+                            (PUCHAR)&(p->SwitchChannelInitParams.dot11SpectrumManagementRequired));
+
+
+    /* Scan Control Tables */
+    regReadStringParameter(pAdapter, &STRScanControlTable24,
+                           (PCHAR)&ScanControlTable24Def[0],(USHORT)(2 * NUM_OF_CHANNELS_24),
+                            (PUCHAR)&(ScanControlTable24Tmp[0]),
+                            (PUSHORT)&tableLen);
+
+    for( loopIndex = tableLen ; loopIndex < 2 * NUM_OF_CHANNELS_24 ; loopIndex++)
+        ScanControlTable24Tmp[loopIndex] = '0';
+
+    decryptScanControlTable(ScanControlTable24Tmp,(PUCHAR)&(p->regulatoryDomainInitParams.desiredScanControlTable.ScanControlTable24.tableString[0]),2 * NUM_OF_CHANNELS_24);
+
+
+    /* Scan Control Tables for 5 Ghz*/
+    regReadStringParameter(pAdapter, &STRScanControlTable5,
+                           (PCHAR)&ScanControlTable5Def[0],(USHORT)(2 * A_5G_BAND_NUM_CHANNELS),
+                            (PUCHAR)&(ScanControlTable5Tmp[0]),
+                            (PUSHORT)&tableLen);
+
+
+    for( loopIndex = tableLen ; loopIndex < 2 * A_5G_BAND_NUM_CHANNELS ; loopIndex++)
+        ScanControlTable5Tmp[loopIndex] = '0';
+
+    decryptScanControlTable(ScanControlTable5Tmp,(PUCHAR)&(p->regulatoryDomainInitParams.desiredScanControlTable.ScanControlTable5.tableString[0]),2 * A_5G_BAND_NUM_CHANNELS);
+
+
+    /* Tx Power */
+    regReadIntegerParameter(pAdapter, &STRTxPower,
+                            MAX_TX_POWER, MIN_TX_POWER, MAX_TX_POWER,
+                            sizeof p->regulatoryDomainInitParams.desiredTxPower,
+                            (PUCHAR)&p->regulatoryDomainInitParams.desiredTxPower);
+
+    regReadIntegerParameter(pAdapter, &STRdot11WEPStatus,
+                            RSN_WEP_STATUS_DEF, RSN_WEP_STATUS_MIN, RSN_WEP_STATUS_MAX,
+                            sizeof p->rsnInitParams.privacyOn,
+                            (PUCHAR)&p->rsnInitParams.privacyOn);
+    /* reverse privacy value - windows is setting 1 as off */
+    /*
+        p->rsnInitParams.privacyMode = !(p->rsnInitParams.privacyOn);
+        p->rsnInitParams.privacyOn = !(p->rsnInitParams.privacyOn);
+    */
+
+    regReadIntegerParameter(pAdapter, &STRdot11WEPDefaultKeyID,
+                            RSN_DEFAULT_KEY_ID_DEF, RSN_DEFAULT_KEY_ID_MIN,
+                            RSN_DEFAULT_KEY_ID_MAX,
+                            sizeof p->rsnInitParams.defaultKeyId,
+                            (PUCHAR)&p->rsnInitParams.defaultKeyId);
+
+
+    regReadIntegerParameter(pAdapter, &STRMixedMode,
+                            RSN_WEPMIXEDMODE_ENABLED_DEF, RSN_WEPMIXEDMODE_ENABLED_MIN,
+                            RSN_WEPMIXEDMODE_ENABLED_MAX,
+                            sizeof p->rsnInitParams.mixedMode,
+                            (PUCHAR)&p->rsnInitParams.mixedMode);
+
+    regReadIntegerParameter(pAdapter, &STRWPAMixedMode,
+                            RSN_WPAMIXEDMODE_ENABLE_DEF, RSN_WPAMIXEDMODE_ENABLE_MIN, 
+                            RSN_WPAMIXEDMODE_ENABLE_MAX,                         
+                            sizeof p->rsnInitParams.WPAMixedModeEnable,
+                            (PUCHAR)&p->rsnInitParams.WPAMixedModeEnable);         
+
+    regReadIntegerParameter(pAdapter, &STRRSNPreAuth,
+                            RSN_PREAUTH_ENABLE_DEF, RSN_PREAUTH_ENABLE_MIN,
+                            RSN_PREAUTH_ENABLE_MAX,
+                            sizeof p->rsnInitParams.preAuthSupport,
+                            (PUCHAR)&p->rsnInitParams.preAuthSupport);
+
+    regReadIntegerParameter(pAdapter, &STRRSNPreAuthTimeout,
+                            RSN_PREAUTH_TIMEOUT_DEF, RSN_PREAUTH_TIMEOUT_MIN,
+                            RSN_PREAUTH_TIMEOUT_MAX,
+                            sizeof p->rsnInitParams.preAuthTimeout,
+                            (PUCHAR)&p->rsnInitParams.preAuthTimeout);
+
+    regReadWepKeyParameter(pAdapter, (PUCHAR)p->rsnInitParams.keys, p->rsnInitParams.defaultKeyId);
+
+
+    /*---------------------------
+            QOS parameters
+    -----------------------------*/
+
+    regReadIntegerParameter(pAdapter, &STRClsfr_Type,
+                            CLSFR_TYPE_DEF, CLSFR_TYPE_MIN, 
+                            CLSFR_TYPE_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.clsfrType,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.clsfrType); 
+
+    switch(p->ctrlDataInitParams.ClsfrInitParam.clsfrType)
+    {
+        case D_TAG_CLSFR:
+            /* Trivial mapping D-tag to D-tag - no need to read more keys*/
+        break;
+
+        case DSCP_CLSFR:
+
+            regReadIntegerParameter(pAdapter, &STRNumOfCodePoints,
+                            NUM_OF_CODE_POINTS_DEF, NUM_OF_CODE_POINTS_MIN, 
+                            NUM_OF_CODE_POINTS_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.NumOfActiveEntries,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.NumOfActiveEntries);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier00_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier01_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier02_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier03_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier04_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier05_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier06_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier07_CodePoint,
+                            DSCP_CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier08_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier09_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier10_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier11_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier12_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier13_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier14_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier15_CodePoint,
+                            CLASSIFIER_CODE_POINT_DEF, CLASSIFIER_CODE_POINT_MIN, 
+                            CLASSIFIER_CODE_POINT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.CodePoint,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.CodePoint);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier00_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier01_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier02_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier03_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier04_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier05_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier06_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier07_DTag,
+                            DSCP_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier08_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier09_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier10_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier11_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier12_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier13_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier14_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].DTag);
+            regReadIntegerParameter(pAdapter, &STRDSCPClassifier15_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].DTag);
+
+
+        break;
+
+        case PORT_CLSFR:
+
+            regReadIntegerParameter(pAdapter, &STRNumOfDstPortClassifiers,
+                            NUM_OF_PORT_CLASSIFIERS_DEF, NUM_OF_PORT_CLASSIFIERS_MIN, 
+                            NUM_OF_PORT_CLASSIFIERS_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.NumOfActiveEntries,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.NumOfActiveEntries);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier00_Port,
+                            PORT_CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier01_Port,
+                            PORT_CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier02_Port,
+                            PORT_CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier03_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier04_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier05_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier06_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier07_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier08_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier09_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier10_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier11_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier12_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier13_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier14_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier15_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier00_DTag,
+                            PORT_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier01_DTag,
+                            PORT_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier02_DTag,
+                            PORT_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier03_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier04_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier05_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier06_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier07_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier08_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier09_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier10_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier11_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier12_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier13_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier14_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].DTag);
+            regReadIntegerParameter(pAdapter, &STRPortClassifier15_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].DTag);
+    
+        break;
+
+
+        case IPPORT_CLSFR: 
+
+            regReadIntegerParameter(pAdapter, &STRNumOfDstIPPortClassifiers,
+                            NUM_OF_IPPORT_CLASSIFIERS_DEF, NUM_OF_IPPORT_CLASSIFIERS_MIN, 
+                            NUM_OF_IPPORT_CLASSIFIERS_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.NumOfActiveEntries,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.NumOfActiveEntries);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier00_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier01_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier02_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier03_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier04_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier05_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier06_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier07_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier08_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier09_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier10_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier11_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier12_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier13_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier14_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadStringParameter(pAdapter, &STRIPPortClassifier15_IPAddress, (PCHAR)(ClsfrIp), 11, (PUCHAR)ClsfrIpString, &ClsfrIpStringSize);
+            initRadioValusFromRgstryString( (PCHAR)(ClsfrIpString), (PCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.DstIPPort.DstIPAddress, 4);
+
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier00_Port,
+                            IPPORT_CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier01_Port,
+                            IPPORT_CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier02_Port,
+                            IPPORT_CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier03_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier04_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier05_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier06_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier07_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier08_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier09_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier10_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier11_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier12_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier13_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier14_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier15_Port,
+                            CLASSIFIER_PORT_DEF, CLASSIFIER_PORT_MIN, 
+                            CLASSIFIER_PORT_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.DstIPPort.DstPortNum,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].Dscp.DstIPPort.DstPortNum);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier00_DTag,
+                            IPPORT_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[0].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier01_DTag,
+                            IPPORT_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[1].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier02_DTag,
+                            IPPORT_CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[2].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier03_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[3].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier04_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[4].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier05_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[5].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier06_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[6].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier07_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[7].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier08_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[8].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier09_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[9].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier10_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[10].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier11_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[11].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier12_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[12].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier13_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[13].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier14_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[14].DTag);
+            regReadIntegerParameter(pAdapter, &STRIPPortClassifier15_DTag,
+                            CLASSIFIER_DTAG_DEF, CLASSIFIER_DTAG_MIN, 
+                            CLASSIFIER_DTAG_MAX,                         
+                            sizeof p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].DTag,
+                            (PUCHAR)&p->ctrlDataInitParams.ClsfrInitParam.ClsfrTable[15].DTag);
+    
+        break;
+
+    }
+
+
+
+  /* ---------------------------
+
+       Traffic Intensity Threshold 
+
+   ---------------------------*/
+    regReadIntegerParameter(pAdapter, &STRTrafficIntensityThresHigh, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_HIGH_DEF, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_HIGH_MIN, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_HIGH_MAX, 
+                            sizeof p->ctrlDataInitParams.ctrlDataTrafficThreshold.uHighThreshold, 
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTrafficThreshold.uHighThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficIntensityThresLow, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_LOW_DEF, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_LOW_MIN, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_LOW_MAX, 
+                            sizeof p->ctrlDataInitParams.ctrlDataTrafficThreshold.uLowThreshold,
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTrafficThreshold.uLowThreshold);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficIntensityTestInterval, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_INTERVAL_DEF, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_INTERVAL_MIN, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_INTERVAL_MAX, 
+                            sizeof p->ctrlDataInitParams.ctrlDataTrafficThreshold.TestInterval,
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTrafficThreshold.TestInterval);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficIntensityThresholdEnabled, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_ENABLED_DEF, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_ENABLED_MIN, 
+                            CTRL_DATA_TRAFFIC_THRESHOLD_ENABLED_MAX, 
+                            sizeof p->ctrlDataInitParams.ctrlDataTrafficThresholdEnabled,
+                            (PUCHAR)&p->ctrlDataInitParams.ctrlDataTrafficThresholdEnabled);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficMonitorMinIntervalPercentage, 
+                            TRAFFIC_MONITOR_MIN_INTERVAL_PERCENT_DEF, 
+                            TRAFFIC_MONITOR_MIN_INTERVAL_PERCENT_MIN, 
+                            TRAFFIC_MONITOR_MIN_INTERVAL_PERCENT_MAX, 
+                            sizeof(BOOL), (PUCHAR)&p->trafficMonitorMinIntervalPercentage);
+
+    regReadIntegerParameter(pAdapter, &STRWMEEnable,
+                            WME_ENABLED_DEF, WME_ENABLED_MIN,
+                            WME_ENABLED_MAX,
+                            sizeof p->qosMngrInitParams.wmeEnable,
+                            (PUCHAR)&p->qosMngrInitParams.wmeEnable);
+
+    regReadIntegerParameter(pAdapter, &STRTrafficAdmCtrlEnable,
+                            QOS_TRAFFIC_ADM_CTRL_ENABLED_DEF, QOS_TRAFFIC_ADM_CTRL_ENABLED_MIN, 
+                            QOS_TRAFFIC_ADM_CTRL_ENABLED_MAX,                         
+                            sizeof p->qosMngrInitParams.trafficAdmCtrlEnable,
+                            (PUCHAR)&p->qosMngrInitParams.trafficAdmCtrlEnable); 
+
+    regReadIntegerParameter(pAdapter, &STRdesiredPsMode,
+                            QOS_DESIRED_PS_MODE_DEF, QOS_DESIRED_PS_MODE_MIN, 
+                            QOS_DESIRED_PS_MODE_MAX,                         
+                            sizeof p->qosMngrInitParams.desiredPsMode,
+                            (PUCHAR)&p->qosMngrInitParams.desiredPsMode); 
+
+    regReadIntegerParameter(pAdapter, &STRQOSmsduLifeTimeBE,
+                    QOS_MSDU_LIFE_TIME_BE_DEF, QOS_MSDU_LIFE_TIME_BE_MIN,
+                    QOS_MSDU_LIFE_TIME_BE_MAX,
+                    sizeof p->qosMngrInitParams.MsduLifeTime[QOS_AC_BE],
+                    (PUCHAR)&p->qosMngrInitParams.MsduLifeTime[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSmsduLifeTimeBK,
+                            QOS_MSDU_LIFE_TIME_BK_DEF, QOS_MSDU_LIFE_TIME_BK_MIN,
+                            QOS_MSDU_LIFE_TIME_BK_MAX,
+                            sizeof p->qosMngrInitParams.MsduLifeTime[QOS_AC_BK],
+                            (PUCHAR)&p->qosMngrInitParams.MsduLifeTime[QOS_AC_BK]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSmsduLifeTimeVI,
+                            QOS_MSDU_LIFE_TIME_VI_DEF, QOS_MSDU_LIFE_TIME_VI_MIN,
+                            QOS_MSDU_LIFE_TIME_VI_MAX,
+                            sizeof p->qosMngrInitParams.MsduLifeTime[QOS_AC_VI],
+                            (PUCHAR)&p->qosMngrInitParams.MsduLifeTime[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSmsduLifeTimeVO,
+                            QOS_MSDU_LIFE_TIME_VO_DEF, QOS_MSDU_LIFE_TIME_VO_MIN,
+                            QOS_MSDU_LIFE_TIME_VO_MAX,
+                            sizeof p->qosMngrInitParams.MsduLifeTime[QOS_AC_VO],
+                            (PUCHAR)&p->qosMngrInitParams.MsduLifeTime[QOS_AC_VO]);
+
+
+    regReadIntegerParameter(pAdapter, &STRQOSrxTimeOutPsPoll,
+                    QOS_RX_TIMEOUT_PS_POLL_DEF, QOS_RX_TIMEOUT_PS_POLL_MIN,
+                    QOS_RX_TIMEOUT_PS_POLL_MAX,
+                    sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.rxTimeOut.psPoll,
+                    (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.rxTimeOut.psPoll);
+
+    regReadIntegerParameter(pAdapter, &STRQOSrxTimeOutUPSD,
+                    QOS_RX_TIMEOUT_UPSD_DEF, QOS_RX_TIMEOUT_UPSD_MIN,
+                    QOS_RX_TIMEOUT_UPSD_MAX,
+                    sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.rxTimeOut.UPSD,
+                    (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.rxTimeOut.UPSD);
+
+    /* Note: The PsPoll wait timeout should be aligned with the UPSD setting */
+   /* p->PowerMgrInitParams.HwPsPollResponseTimeout = (UINT8)p->qosMngrInitParams.rxTimeout.UPSD;*/
+
+    regReadIntegerParameter(pAdapter, &STRQOStxQueue0Size,
+                            QOS_TX_QUEUE0_SIZE_DEF, QOS_TX_QUEUE0_SIZE_MIN,
+                            QOS_TX_QUEUE0_SIZE_MAX,
+                            sizeof p->qosMngrInitParams.TxQueueSize[0],
+                            (PUCHAR)&p->qosMngrInitParams.TxQueueSize[0]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxQueue1Size,
+                            QOS_TX_QUEUE1_SIZE_DEF, QOS_TX_QUEUE1_SIZE_MIN,
+                            QOS_TX_QUEUE1_SIZE_MAX,
+                            sizeof p->qosMngrInitParams.TxQueueSize[1],
+                            (PUCHAR)&p->qosMngrInitParams.TxQueueSize[1]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxQueue2Size,
+                        QOS_TX_QUEUE2_SIZE_DEF, QOS_TX_QUEUE2_SIZE_MIN,
+                        QOS_TX_QUEUE2_SIZE_MAX,
+                        sizeof p->qosMngrInitParams.TxQueueSize[2],
+                        (PUCHAR)&p->qosMngrInitParams.TxQueueSize[2]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxQueue3Size,
+                        QOS_TX_QUEUE3_SIZE_DEF, QOS_TX_QUEUE3_SIZE_MIN,
+                        QOS_TX_QUEUE3_SIZE_MAX,
+                        sizeof p->qosMngrInitParams.TxQueueSize[3],
+                        (PUCHAR)&p->qosMngrInitParams.TxQueueSize[3]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSwmePsModeBE,
+                            QOS_WME_PS_MODE_BE_DEF, QOS_WME_PS_MODE_BE_MIN,
+                            QOS_WME_PS_MODE_BE_MAX,
+                            sizeof p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_BE],
+                            (PUCHAR)&p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSwmePsModeBK,
+                            QOS_WME_PS_MODE_BK_DEF, QOS_WME_PS_MODE_BK_MIN,
+                            QOS_WME_PS_MODE_BK_MAX,
+                            sizeof p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_BK],
+                            (PUCHAR)&p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_BK]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSwmePsModeVI,
+                        QOS_WME_PS_MODE_VI_DEF, QOS_WME_PS_MODE_VI_MIN,
+                        QOS_WME_PS_MODE_VI_MAX,
+                        sizeof p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_VI],
+                        (PUCHAR)&p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSwmePsModeVO,
+                        QOS_WME_PS_MODE_VO_DEF, QOS_WME_PS_MODE_VO_MIN,
+                        QOS_WME_PS_MODE_VO_MAX,
+                        sizeof p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_VO],
+                        (PUCHAR)&p->qosMngrInitParams.desiredWmeAcPsMode[QOS_AC_VO]);
+
+    /* HW Tx queues buffers allocation high threshold */
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksHighPrcntBE,
+                            QOS_TX_BLKS_HIGH_PRCNT_BE_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_BE],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksHighPrcntBK,
+                            QOS_TX_BLKS_HIGH_PRCNT_BK_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_BK],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_BK]);
+    
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksHighPrcntVI,
+                            QOS_TX_BLKS_HIGH_PRCNT_VI_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_VI],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksHighPrcntVO,
+                            QOS_TX_BLKS_HIGH_PRCNT_VO_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_VO],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksHighPercentPerAc[QOS_AC_VO]);
+
+    /* HW Tx queues buffers allocation low threshold */
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksLowPrcntBE,
+                            QOS_TX_BLKS_LOW_PRCNT_BE_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_BE],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksLowPrcntBK,
+                            QOS_TX_BLKS_LOW_PRCNT_BK_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_BK],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_BK]);
+    
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksLowPrcntVI,
+                            QOS_TX_BLKS_LOW_PRCNT_VI_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_VI],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOStxBlksLowPrcntVO,
+                            QOS_TX_BLKS_LOW_PRCNT_VO_DEF, QOS_TX_BLKS_HIGH_PRCNT_MIN,
+                            QOS_TX_BLKS_HIGH_PRCNT_MAX,
+                            sizeof p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_VO],
+                            (PUCHAR)&p->TnetwDrv_InitParams.whalCtrl_init.TxBlocksLowPercentPerAc[QOS_AC_VO]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSShortRetryLimitBE,
+                            QOS_SHORT_RETRY_LIMIT_BE_DEF, QOS_SHORT_RETRY_LIMIT_BE_MIN,
+                            QOS_SHORT_RETRY_LIMIT_BE_MAX,
+                            sizeof p->qosMngrInitParams.ShortRetryLimit[QOS_AC_BE],
+                            (PUCHAR)&p->qosMngrInitParams.ShortRetryLimit[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSShortRetryLimitBK,
+                            QOS_SHORT_RETRY_LIMIT_BK_DEF, QOS_SHORT_RETRY_LIMIT_BK_MIN,
+                            QOS_SHORT_RETRY_LIMIT_BK_MAX,
+                            sizeof p->qosMngrInitParams.ShortRetryLimit[QOS_AC_BK],
+                            (PUCHAR)&p->qosMngrInitParams.ShortRetryLimit[QOS_AC_BK]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSShortRetryLimitVI,
+                            QOS_SHORT_RETRY_LIMIT_VI_DEF, QOS_SHORT_RETRY_LIMIT_VI_MIN,
+                            QOS_SHORT_RETRY_LIMIT_VI_MAX,
+                            sizeof p->qosMngrInitParams.ShortRetryLimit[QOS_AC_VI],
+                            (PUCHAR)&p->qosMngrInitParams.ShortRetryLimit[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSShortRetryLimitVO,
+                            QOS_SHORT_RETRY_LIMIT_VO_DEF, QOS_SHORT_RETRY_LIMIT_VO_MIN,
+                            QOS_SHORT_RETRY_LIMIT_VO_MAX,
+                            sizeof p->qosMngrInitParams.ShortRetryLimit[QOS_AC_VO],
+                            (PUCHAR)&p->qosMngrInitParams.ShortRetryLimit[QOS_AC_VO]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSLongRetryLimitBE,
+                            QOS_LONG_RETRY_LIMIT_BE_DEF, QOS_LONG_RETRY_LIMIT_BE_MIN,
+                            QOS_LONG_RETRY_LIMIT_BE_MAX,
+                            sizeof p->qosMngrInitParams.LongRetryLimit[QOS_AC_BE],
+                            (PUCHAR)&p->qosMngrInitParams.LongRetryLimit[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSLongRetryLimitBK,
+                            QOS_LONG_RETRY_LIMIT_BK_DEF, QOS_LONG_RETRY_LIMIT_BK_MIN,
+                            QOS_LONG_RETRY_LIMIT_BK_MAX,
+                            sizeof p->qosMngrInitParams.LongRetryLimit[QOS_AC_BK],
+                            (PUCHAR)&p->qosMngrInitParams.LongRetryLimit[QOS_AC_BK]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSLongRetryLimitVI,
+                            QOS_LONG_RETRY_LIMIT_VI_DEF, QOS_LONG_RETRY_LIMIT_VI_MIN,
+                            QOS_LONG_RETRY_LIMIT_VI_MAX,
+                            sizeof p->qosMngrInitParams.LongRetryLimit[QOS_AC_VI],
+                            (PUCHAR)&p->qosMngrInitParams.LongRetryLimit[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSLongRetryLimitVO,
+                            QOS_LONG_RETRY_LIMIT_VO_DEF, QOS_LONG_RETRY_LIMIT_VO_MIN,
+                            QOS_LONG_RETRY_LIMIT_VO_MAX,
+                            sizeof p->qosMngrInitParams.LongRetryLimit[QOS_AC_VO],
+                            (PUCHAR)&p->qosMngrInitParams.LongRetryLimit[QOS_AC_VO]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSAckPolicyBE,
+                            QOS_ACK_POLICY_BE_DEF, QOS_ACK_POLICY_BE_MIN,
+                            QOS_ACK_POLICY_BE_MAX,
+                            sizeof p->qosMngrInitParams.acAckPolicy[QOS_AC_BE],
+                            (PUCHAR)&p->qosMngrInitParams.acAckPolicy[QOS_AC_BE]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSAckPolicyBK,
+                            QOS_ACK_POLICY_BK_DEF, QOS_ACK_POLICY_BK_MIN,
+                            QOS_ACK_POLICY_BK_MAX,
+                            sizeof p->qosMngrInitParams.acAckPolicy[QOS_AC_BK],
+                            (PUCHAR)&p->qosMngrInitParams.acAckPolicy[QOS_AC_BK]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSAckPolicyVI,
+                            QOS_ACK_POLICY_VI_DEF, QOS_ACK_POLICY_VI_MIN,
+                            QOS_ACK_POLICY_VI_MAX,
+                            sizeof p->qosMngrInitParams.acAckPolicy[QOS_AC_VI],
+                            (PUCHAR)&p->qosMngrInitParams.acAckPolicy[QOS_AC_VI]);
+
+    regReadIntegerParameter(pAdapter, &STRQOSAckPolicyVO,
+                            QOS_ACK_POLICY_VO_DEF, QOS_ACK_POLICY_VO_MIN,
+                            QOS_ACK_POLICY_VO_MAX,
+                            sizeof p->qosMngrInitParams.acAckPolicy[QOS_AC_VO],
+                            (PUCHAR)&p->qosMngrInitParams.acAckPolicy[QOS_AC_VO]);
+
+
+    regReadIntegerParameter(pAdapter, &STRQoSqueue0OverFlowPolicy,
+                    QOS_QUEUE_0_OVFLOW_POLICY_DEF, QOS_QUEUE_0_OVFLOW_POLICY_MIN,
+                    QOS_QUEUE_0_OVFLOW_POLICY_MAX,
+                    sizeof p->qosMngrInitParams.QueueOvFlowPolicy[0],
+                    (PUCHAR)&p->qosMngrInitParams.QueueOvFlowPolicy[0]);
+    
+    regReadIntegerParameter(pAdapter, &STRQoSqueue1OverFlowPolicy,
+                    QOS_QUEUE_1_OVFLOW_POLICY_DEF, QOS_QUEUE_1_OVFLOW_POLICY_MIN,
+                    QOS_QUEUE_1_OVFLOW_POLICY_MAX,
+                    sizeof p->qosMngrInitParams.QueueOvFlowPolicy[1],
+                    (PUCHAR)&p->qosMngrInitParams.QueueOvFlowPolicy[1]);
+
+    regReadIntegerParameter(pAdapter, &STRQoSqueue2OverFlowPolicy,
+                    QOS_QUEUE_2_OVFLOW_POLICY_DEF, QOS_QUEUE_2_OVFLOW_POLICY_MIN,
+                    QOS_QUEUE_2_OVFLOW_POLICY_MAX,
+                    sizeof p->qosMngrInitParams.QueueOvFlowPolicy[2],
+                    (PUCHAR)&p->qosMngrInitParams.QueueOvFlowPolicy[2]);
+
+    regReadIntegerParameter(pAdapter, &STRQoSqueue3OverFlowPolicy,
+                    QOS_QUEUE_3_OVFLOW_POLICY_DEF, QOS_QUEUE_3_OVFLOW_POLICY_MIN,
+                    QOS_QUEUE_3_OVFLOW_POLICY_MAX,
+                    sizeof p->qosMngrInitParams.QueueOvFlowPolicy[3],
+                    (PUCHAR)&p->qosMngrInitParams.QueueOvFlowPolicy[3]);
+
+    /* Packet Burst parameters    */
+
+    regReadIntegerParameter(pAdapter, &STRQOSPacketBurstEnable,
+                            QOS_PACKET_BURST_ENABLE_DEF, QOS_PACKET_BURST_ENABLE_MIN, 
+                            QOS_PACKET_BURST_ENABLE_MAX,                         
+                            sizeof p->qosMngrInitParams.PacketBurstEnable,
+                            (PUCHAR)&p->qosMngrInitParams.PacketBurstEnable); 
+    PRINTF(DBG_REGISTRY,( "STRQOSPacketBurstEnable = %d\n", p->qosMngrInitParams.PacketBurstEnable));
+    regReadIntegerParameter(pAdapter, &STRQOSPacketBurstTxOpLimit,
+                            QOS_PACKET_BURST_TXOP_LIMIT_DEF, QOS_PACKET_BURST_TXOP_LIMIT_MIN, 
+                            QOS_PACKET_BURST_TXOP_LIMIT_MAX,                         
+                            sizeof p->qosMngrInitParams.PacketBurstTxOpLimit,
+                            (PUCHAR)&p->qosMngrInitParams.PacketBurstTxOpLimit); 
+
+
+
+    /*---------------------------
+        Measurement parameters
+    -----------------------------*/
+
+    regReadIntegerParameter(pAdapter, &STRMeasurTrafficThreshold,
+                            MEASUREMENT_TRAFFIC_THRSHLD_DEF, MEASUREMENT_TRAFFIC_THRSHLD_MIN, MEASUREMENT_TRAFFIC_THRSHLD_MAX,
+                            sizeof p->measurementInitParams.trafficIntensityThreshold,
+                            (PUCHAR)&p->measurementInitParams.trafficIntensityThreshold);   
+
+    regReadIntegerParameter(pAdapter, &STRMeasurMaxDurationOnNonServingChannel,
+                            MEASUREMENT_MAX_DUR_NON_SRV_CHANNEL_DEF, MEASUREMENT_MAX_DUR_NON_SRV_CHANNEL_MIN, MEASUREMENT_MAX_DUR_NON_SRV_CHANNEL_MAX,
+                            sizeof p->measurementInitParams.maxDurationOnNonServingChannel,
+                            (PUCHAR)&p->measurementInitParams.maxDurationOnNonServingChannel);  
+
+
+    /*---------------------------
+          EXC Manager parameters
+    -----------------------------*/
+#ifdef EXC_MODULE_INCLUDED
+
+    regReadIntegerParameter(pAdapter, &STRExcModeEnabled,
+                            EXC_MNGR_ENABLE_DEF, EXC_MNGR_ENABLE_MIN, EXC_MNGR_ENABLE_MAX,
+                            sizeof p->excMngrParams.excEnabled,
+                            (PUCHAR)&p->excMngrParams.excEnabled);
+
+
+    p->measurementInitParams.excEnabled = p->excMngrParams.excEnabled;  
+
+#endif
+
+    regReadIntegerParameter(pAdapter, &STRExcTestIgnoreDeAuth0,
+                            EXC_TEST_IGNORE_DEAUTH_0_DEF, EXC_TEST_IGNORE_DEAUTH_0_MIN, EXC_TEST_IGNORE_DEAUTH_0_MAX,
+                            sizeof p->apConnParams.ignoreDeauthReason0,
+                            (PUCHAR)&p->apConnParams.ignoreDeauthReason0);
+    
+    /*---------------------------
+      EEPROM less support
+    -----------------------------*/
+    regReadIntegerParameter(pAdapter, &STREEPROMlessModeSupported,
+                            HAL_CTRL_EEPROMLESS_ENABLE_DEF, HAL_CTRL_EEPROMLESS_ENABLE_MIN,
+                            HAL_CTRL_EEPROMLESS_ENABLE_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlEepromLessEnable,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlEepromLessEnable);
+
+    pAdapter->EepromSupported = p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlEepromLessEnable;
+
+    
+    regReadStringParameter(pAdapter, &STRstationMacAddress,
+                            (PCHAR)(defStaMacAddress), 11,
+                            (PUCHAR)staMACAddress, &regMACstrLen);
+    
+    /*reads the arp ip from table*/
+    regReadStringParameter(pAdapter ,&STRArp_Ip_Addr,
+                            (PCHAR)(defArpIpAddress),REG_ARP_IP_ADDR_STR_LEN,
+                            (PUCHAR)staArpIpAddress,&regArpIpStrLen ) ;
+
+    regReadIntegerParameter(pAdapter, &STRArp_Ip_Filter_Ena,
+                            DEF_FILTER_ENABLE_VALUE, MIN_FILTER_ENABLE_VALUE, MAX_FILTER_ENABLE_VALUE,
+                            sizeof p->TnetwDrv_InitParams.arpIpFilterParams.isFilterEnabled,
+                            (PUCHAR)&p->TnetwDrv_InitParams.arpIpFilterParams.isFilterEnabled);
+
+
+    regConvertStringtoIpAddress(staArpIpAddress, (PUCHAR)&(p->TnetwDrv_InitParams.arpIpFilterParams.arpIpInitParams.addr[0]) ); 
+    
+    initRadioValusFromRgstryString( (PCHAR)(staMACAddress),
+                                    (PCHAR)&(p->TnetwDrv_InitParams.whalCtrl_init.StaMacAddress[0]),
+                                    6);
+/*fource FragThreshold to be even value (round it down)MR WLAN00003501*/
+    p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlFragThreshold &= 0xFFFE;
+
+
+
+
+
+/*----------------------------------
+    Health Monitor registry init
+------------------------------------*/
+
+    /* this time out is common to HealthCheck and TX power adjust */
+    regReadIntegerParameter(pAdapter, &STRHealthMonitorCheckPeriod,
+                            DEF_TX_POWER_ADJUST_TIME_OUT, 0, 65000,   /* in msec */
+                            sizeof p->healthMonitorInitParams.healthCheckPeriod,
+                            (PUCHAR)&p->healthMonitorInitParams.healthCheckPeriod);
+
+    /* No scan complete recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledNoScanComplete,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ NO_SCAN_COMPLETE_FAILURE ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ NO_SCAN_COMPLETE_FAILURE ]) );
+    
+    /* Mailbox failure recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledMboxFailure,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ MBOX_FAILURE ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ MBOX_FAILURE ]) );
+
+    /* HW awake failure recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledHwAwakeFailure,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ HW_AWAKE_FAILURE ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ HW_AWAKE_FAILURE ]) );
+    
+    /* Bus error recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledBusError,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ BUS_ERROR ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ BUS_ERROR ]) );
+    
+    /* Device error recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledDeviceError,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ DEVICE_ERROR ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ DEVICE_ERROR ]) );
+    
+    /* TX stuck recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledTxStuck,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ TX_STUCK ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ TX_STUCK ]) );
+    
+    /* disconnect timeout recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledDisconnectTimeout,
+                            0, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ DISCONNECT_TIMEOUT ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ DISCONNECT_TIMEOUT ]) );
+    
+    /* Power save failure recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledPowerSaveFailure,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ POWER_SAVE_FAILURE ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ POWER_SAVE_FAILURE ]) );
+    
+    /* Measurement failure recovery enabled */
+    regReadIntegerParameter(pAdapter, &STRRecoveryEnabledMeasurementFailure,
+                            1, 0, 1,   /* default is enabled */
+                            sizeof (p->healthMonitorInitParams.recoveryTriggerEnabled[ MEASUREMENT_FAILURE ]),
+                            (PUCHAR)&(p->healthMonitorInitParams.recoveryTriggerEnabled[ MEASUREMENT_FAILURE ]) );
+
+/*-----------------------------------*/
+/*   Hardware ACI recovery           */
+/*-----------------------------------*/
+
+    regReadIntegerParameter(pAdapter, &STRHardwareACIMode,
+                            HAL_CTRL_ACI_MODE_DEF, HAL_CTRL_ACI_MODE_MIN,
+                            HAL_CTRL_ACI_MODE_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlACIMode,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlACIMode);
+
+    regReadIntegerParameter(pAdapter, &STRHardwareACIInputCCA,
+                            HAL_CTRL_ACI_INPUT_CCA_DEF, HAL_CTRL_ACI_INPUT_CCA_MIN,
+                            HAL_CTRL_ACI_INPUT_CCA_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlInputCCA,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlInputCCA);
+
+    regReadIntegerParameter(pAdapter, &STRHardwareACIQualifiedCCA,
+                            HAL_CTRL_ACI_QUALIFIED_CCA_DEF, HAL_CTRL_ACI_QUALIFIED_CCA_MIN,
+                            HAL_CTRL_ACI_QUALIFIED_CCA_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlQualifiedCCA,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlQualifiedCCA);
+
+    regReadIntegerParameter(pAdapter, &STRHardwareACIStompForRx,
+                            HAL_CTRL_ACI_STOMP_FOR_RX_DEF, HAL_CTRL_ACI_STOMP_FOR_RX_MIN,
+                            HAL_CTRL_ACI_STOMP_FOR_RX_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlStompForRx,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlStompForRx);
+
+    regReadIntegerParameter(pAdapter, &STRHardwareACIStompForTx,
+                            HAL_CTRL_ACI_STOMP_FOR_TX_DEF, HAL_CTRL_ACI_STOMP_FOR_TX_MIN,
+                            HAL_CTRL_ACI_STOMP_FOR_TX_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlStompForTx,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlStompForTx);
+
+    regReadIntegerParameter(pAdapter, &STRHardwareACITxCCA,
+                            HAL_CTRL_ACI_TX_CCA_DEF, HAL_CTRL_ACI_TX_CCA_MIN,
+                            HAL_CTRL_ACI_TX_CCA_MAX,
+                            sizeof p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxCCA,
+                            (PUCHAR)&p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlTxCCA);
+
+/*----------------------------------
+ TX power adjust
+------------------------------------*/
+
+    regReadIntegerParameter(pAdapter, &STRTxPowerCheckTime,
+                            1, 1, 1200,  /* in units of 5000 ms */
+                            sizeof p->siteMgrInitParams.TxPowerCheckTime,
+                            (PUCHAR)&p->siteMgrInitParams.TxPowerCheckTime);
+
+
+    regReadIntegerParameter(pAdapter, &STRTxPowerControlOn,
+                            1, 0, 1,  /* on/off (1/0) default is on */
+                            sizeof p->siteMgrInitParams.TxPowerControlOn,
+                            (PUCHAR)&p->siteMgrInitParams.TxPowerControlOn);
+
+    regReadIntegerParameter(pAdapter, &STRTxPowerRssiThresh,
+                            38, 0, 200,  /* the value is positive and will be translated by driver */
+                            sizeof p->siteMgrInitParams.TxPowerRssiThresh,
+                            (PUCHAR)&p->siteMgrInitParams.TxPowerRssiThresh);
+
+    regReadIntegerParameter(pAdapter, &STRTxPowerRssiRestoreThresh,
+                            45, 0, 200,  /* the value is positive and will be translated by driver */
+                            sizeof p->siteMgrInitParams.TxPowerRssiRestoreThresh,
+                            (PUCHAR)&p->siteMgrInitParams.TxPowerRssiRestoreThresh);
+
+    regReadIntegerParameter(pAdapter, &STRTxPowerTempRecover,
+                            MIN_TX_POWER, MIN_TX_POWER, MAX_TX_POWER,  /* Set Min value for Atheros fix */
+                            sizeof p->regulatoryDomainInitParams.uTemporaryTxPower,
+                            (PUCHAR)&p->regulatoryDomainInitParams.uTemporaryTxPower);
+
+/*----------------------------------
+ end of TX power adjust
+------------------------------------*/
+
+/*----------------------------------
+ Scan Concentrator
+------------------------------------*/
+    regReadIntegerParameter( pAdapter, &STRPassiveScanDwellTime,
+                             SCAN_CNCN_DRIVER_DEFAULT_DWELL_TIME_DEF, SCAN_CNCN_DRIVER_DEFAULT_DWELL_TIME_MIN, SCAN_CNCN_DRIVER_DEFAULT_DWELL_TIME_MAX,
+                             sizeof p->scanConcentratorInitParams.passiveScanDwellTime,
+                             (PUCHAR)&p->scanConcentratorInitParams.passiveScanDwellTime );
+//TRS: Scan changes from TI
+       regReadIntegerParameter( pAdapter, &STRMinimumDurationBetweenOidScans,
+                                                        SCAN_CNCN_MIN_DURATION_FOR_OID_SCANS_DEF, SCAN_CNCN_MIN_DURATION_FOR_OID_SCANS_MIN, SCAN_CNCN_MIN_DURATION_FOR_OID_SCANS_MAX,
+                                                        sizeof p->scanConcentratorInitParams.minimumDurationBetweenOidScans,
+                                                        (PUCHAR)&p->scanConcentratorInitParams.minimumDurationBetweenOidScans );
+//TRS: end ofScan changes from TI
+   /*
+    *   set etherMaxPayloadSize parameter for MTU size setting
+    */
+    if(p->ctrlDataInitParams.ctrlDataFourXEnable == TRUE)
+    {
+        if(p->siteMgrInitParams.siteMgrDesiredBSSType == BSS_ANY)
+        {
+            /*disable 4x if we are in any mode*/
+            p->ctrlDataInitParams.ctrlDataFourXEnable = FALSE;
+            pAdapter->etherMaxPayloadSize = NOT_FOUR_X_MODE_PAYLOAD_SIZE;
+        }
+        else
+        if(p->siteMgrInitParams.siteMgrDesiredBSSType == BSS_INDEPENDENT)
+        {
+            pAdapter->etherMaxPayloadSize = IBSS_FOUR_X_MODE_PAYLOAD_SIZE;
+            p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlRtsThreshold = HAL_CTRL_RTS_THRESHOLD_MAX;
+            p->TnetwDrv_InitParams.halCtrlConfigParams.halCtrlFragThreshold = HAL_CTRL_FRAG_THRESHOLD_MAX;
+            p->ctrlDataInitParams.ctrlDataFourXEnable = FALSE;
+        }
+        else
+        if(p->siteMgrInitParams.siteMgrDesiredBSSType ==  BSS_INFRASTRUCTURE)
+        {
+            pAdapter->etherMaxPayloadSize = NOT_FOUR_X_MODE_PAYLOAD_SIZE;
+        }
+    }
+    else
+    {
+        pAdapter->etherMaxPayloadSize = NOT_FOUR_X_MODE_PAYLOAD_SIZE;
+    }
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadParameters
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regReadIntegerParameter(
+                 PTIWLN_ADAPTER_T       pAdapter,
+                 PNDIS_STRING           pParameterName,
+                 ULONG                  defaultValue,
+                 ULONG                  minValue,
+                 ULONG                  maxValue,
+                 UCHAR                  parameterSize,
+                 PUCHAR                 pParameter
+                 )
+{
+    PNDIS_CONFIGURATION_PARAMETER   RetValue;
+    NDIS_STATUS                     Status;
+    ULONG                           value;
+
+    NdisReadConfiguration(&Status, &RetValue,
+                          pAdapter->ConfigHandle, pParameterName,
+                          NdisParameterInteger);
+
+    if(Status != NDIS_STATUS_SUCCESS) {
+
+        NdisReadConfiguration(&Status, &RetValue,
+              pAdapter->ConfigHandle, pParameterName,
+              NdisParameterString
+              );
+
+        if(Status == NDIS_STATUS_SUCCESS) {
+            assignRegValue(&value, RetValue);
+            RetValue->ParameterData.IntegerData = value;
+
+        }
+
+    }
+
+
+    if (Status != NDIS_STATUS_SUCCESS ||
+        RetValue->ParameterData.IntegerData < minValue ||
+        RetValue->ParameterData.IntegerData > maxValue)
+    {
+        PRINTF(DBG_REGISTRY,( "NdisReadConfiguration fail\n"));
+        value = defaultValue;
+
+    } else
+    {
+        value = RetValue->ParameterData.IntegerData;
+    }
+
+    switch (parameterSize)
+    {
+    case 1:
+        *((PUCHAR) pParameter) = (UCHAR) value;
+        break;
+
+    case 2:
+        *((PUSHORT) pParameter) = (USHORT) value;
+        break;
+
+    case 4:
+        *((PULONG) pParameter) = (ULONG) value;
+        break;
+
+    default:
+        PRINT(DBG_REGISTRY_ERROR, "TIWL: Illegal Registry parameter size\n");
+        break;
+
+    }
+
+}
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadParameters
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regReadStringParameter(
+                 PTIWLN_ADAPTER_T       pAdapter,
+                 PNDIS_STRING           pParameterName,
+                 PCHAR                  pDefaultValue,
+                 USHORT                 defaultLen,
+                 PUCHAR                 pParameter,
+                 void*                  pParameterSize
+                 )
+{
+    PNDIS_CONFIGURATION_PARAMETER   RetValue;
+    NDIS_STATUS                     Status;
+    ANSI_STRING                     ansiString;
+    PUCHAR                          pSizeChar = 0;
+    PUSHORT                         pSizeShort = 0;
+
+    if(defaultLen <= 256)
+    {
+        pSizeChar = (PUCHAR)pParameterSize;
+        ansiString.MaximumLength = 256;
+    }
+    else
+    {
+        pSizeShort = (PUSHORT)pParameterSize;
+        ansiString.MaximumLength = 32576;
+    }
+
+    NdisReadConfiguration(&Status, &RetValue,
+                          pAdapter->ConfigHandle, pParameterName,
+                          NdisParameterString);
+
+    if (Status == NDIS_STATUS_SUCCESS)
+    {
+        ansiString.Buffer = (PCHAR)pParameter;
+
+        NdisUnicodeStringToAnsiString(&ansiString, &RetValue->ParameterData.StringData);
+        if(defaultLen <= 256)
+            *pSizeChar = (UCHAR)ansiString.Length;
+        else
+            *pSizeShort = (USHORT)ansiString.Length;
+    } else
+    {
+        if(defaultLen <= 256)
+            *pSizeChar = (UCHAR)defaultLen;
+        else
+            *pSizeShort = (USHORT)defaultLen;
+
+        memcpy(pParameter, pDefaultValue, defaultLen);
+    }
+
+    PRINTF(DBG_REGISTRY_LOUD, ("Read String Registry:  %c%c%c%c%c%c%c%c%c%c%c%c = %s\n",
+                          pParameterName->Buffer[0],
+                          pParameterName->Buffer[1],
+                          pParameterName->Buffer[2],
+                          pParameterName->Buffer[3],
+                          pParameterName->Buffer[4],
+                          pParameterName->Buffer[5],
+                          pParameterName->Buffer[6],
+                          pParameterName->Buffer[7],
+                          pParameterName->Buffer[8],
+                          pParameterName->Buffer[9],
+                          pParameterName->Buffer[10],
+                          pParameterName->Buffer[11],
+                          pParameter));
+
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadParameters
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regReadUnicodeStringParameter(
+                 PTIWLN_ADAPTER_T       pAdapter,
+                 PNDIS_STRING           pParameterName,
+                 PCHAR                  pDefaultValue,
+                 UCHAR                  defaultLen,
+                 PUCHAR                 pParameter,
+                 PUCHAR                 pParameterSize
+                 )
+{
+    PNDIS_CONFIGURATION_PARAMETER   RetValue;
+    NDIS_STATUS                     Status;
+
+    NdisReadConfiguration(&Status, &RetValue,
+                          pAdapter->ConfigHandle, pParameterName,
+                          NdisParameterString);
+
+    if (Status == NDIS_STATUS_SUCCESS)
+    {
+        *pParameterSize = (UCHAR)RetValue->ParameterData.StringData.Length;
+        memcpy(pParameter, (PUCHAR)RetValue->ParameterData.StringData.Buffer, *pParameterSize);
+    } else
+    {
+        *pParameterSize = defaultLen;
+        memcpy(pParameter, pDefaultValue, defaultLen);
+    }
+
+}
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadParameters
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regReadWepKeyParameter(
+                 PTIWLN_ADAPTER_T       pAdapter,
+                 PUCHAR                 pKeysStructure,
+                 UINT8                  defaultKeyId
+                 )
+{
+    NDIS_STATUS                         status;
+    securityKeys_t                      *pSecKeys;
+    int i;
+    int len;
+    UCHAR                               Buf[MAX_KEY_BUFFER_LEN];
+    PNDIS_CONFIGURATION_PARAMETER       RetValue;
+    ANSI_STRING                         ansiString;
+    NDIS_STRING                         STRdot11DefaultWEPKey[4] =
+                                                {   NDIS_STRING_CONST( "dot11WEPDefaultKey1" ),
+                                                    NDIS_STRING_CONST( "dot11WEPDefaultKey2" ),
+                                                    NDIS_STRING_CONST( "dot11WEPDefaultKey3" ),
+                                                    NDIS_STRING_CONST( "dot11WEPDefaultKey4" )
+                                                };
+
+
+
+    PRINTF(DBG_REGISTRY_LOUD, ("Reading WEP keys\n"));
+
+    pSecKeys = (securityKeys_t*)pKeysStructure;
+
+    /**/
+    /* Read WEP from registry*/
+    /**/
+    for ( i = 0; i < DOT11_MAX_DEFAULT_WEP_KEYS; i++ )
+    {
+        NdisReadConfiguration(&status, &RetValue,
+                              pAdapter->ConfigHandle, &STRdot11DefaultWEPKey[i],
+                              NdisParameterString);
+
+        if(status == NDIS_STATUS_SUCCESS)
+        {
+            ansiString.Buffer = (PCHAR)Buf;
+            ansiString.MaximumLength = MAX_KEY_BUFFER_LEN;
+
+            pSecKeys->keyIndex = i;
+            pSecKeys->keyType = WEP_KEY;
+            NdisZeroMemory((void *)pSecKeys->macAddress.addr, 6);
+
+            if(((char *)(RetValue->ParameterData.StringData.Buffer))[1] == 0)
+            {
+                NdisUnicodeStringToAnsiString(&ansiString, &RetValue->ParameterData.StringData);
+
+                len = decryptWEP((PCHAR)Buf, (PCHAR)pSecKeys->encKey, ansiString.Length);
+            } else {
+                len = decryptWEP((PCHAR)RetValue->ParameterData.StringData.Buffer,
+                                 (PCHAR)pSecKeys->encKey,
+                                 RetValue->ParameterData.StringData.Length);
+            }
+
+            if(len < ACX_64BITS_WEP_KEY_LENGTH_BYTES)
+            {
+                PRINTF(DBG_REGISTRY_ERROR, ("Error: minimum WEP key size is 5 bytes(%d)\n", len));
+                pSecKeys->keyType = NULL_KEY;
+                len = 0;
+            }
+            else if(len < ACX_128BITS_WEP_KEY_LENGTH_BYTES)
+            {
+                len = ACX_64BITS_WEP_KEY_LENGTH_BYTES;
+            }
+            else if(len < ACX_256BITS_WEP_KEY_LENGTH_BYTES)
+            {
+                len = ACX_128BITS_WEP_KEY_LENGTH_BYTES;
+            }
+            else
+                len = ACX_256BITS_WEP_KEY_LENGTH_BYTES;
+
+            pSecKeys->encLen = (UINT8)len;
+
+        } else
+        {
+            pSecKeys->keyType = NULL_KEY;
+            pSecKeys->encLen = 0;
+    }
+        /*create local keys cache*/
+        pAdapter->DefaultWepKeys[i].KeyIndex = i;
+        if(i==defaultKeyId)
+            pAdapter->DefaultWepKeys[i].KeyIndex |= 0x80000000;
+        pAdapter->DefaultWepKeys[i].KeyLength = pSecKeys->encLen;
+        NdisMoveMemory((void *)pAdapter->DefaultWepKeys[i].KeyMaterial,
+            (void *)pSecKeys->encKey, pSecKeys->encLen);
+        pAdapter->DefaultWepKeys[i].Length = sizeof(OS_802_11_WEP);
+        pSecKeys++;
+    }
+}
+
+#define iswhite(c) ( (c==' ') || (c=='\t') || (c=='\n') )
+
+/*
+ *
+ *       Fun:   isnumber
+ *
+ *       Desc:  check if the ascii character is a number in the given base
+ *
+ *       Ret:   1 if number is a digit, 0 if not.
+ *
+ *       Notes: none
+ *
+ *       File:  btoi.c
+ *
+ */
+BOOLEAN
+isnumber ( short *pi, char c, short base )
+{
+
+    /* return 1 if c is a digit in the give base, else return 0 */
+    /* place value of digit at pi */
+    if ( base == 16 )
+    {
+        if ( '0' <= c && c <= '9' )
+        {
+            *pi =  c - '0';
+            return (1);
+        }
+        else if ( 'a' <= c && c <= 'f' )
+        {
+            *pi =  c - 'a' + 10 ;
+            return (1);
+        }
+        else if ( 'A' <= c && c <= 'F' )
+        {
+            *pi =  c - 'A' + 10 ;
+            return (1);
+        }
+        else
+        {
+            return (0);
+        }
+    }
+    c -= '0';
+    if ( 0 <= (signed char)c && c < base )
+    {
+        *pi =  c ;
+        return (1);
+    }
+    else
+    {
+        return (0);
+    }
+} /* end of isnumber */
+
+
+short
+_btoi ( char *sptr, short slen, int *pi, short base )
+{
+    char    *s, c ;
+    short   d, sign ;
+    int     result ;
+    char    saved ;
+
+    s           =  sptr ;
+    result      =  0 ;
+    saved       =  sptr [slen];
+    sptr [slen] =  '\0';
+
+    /* skip initial white space */
+/*    while ( (c = *s++) && iswhite(c) ); */
+    do
+    {
+       c = *s++;
+       if (!(c  && iswhite(c))) 
+         break;
+    }while(1); 
+  
+    --s ;
+
+    /* recognize optional sign */
+    if ( *s == '-' )
+    {
+        sign =  - 1 ;
+        s++ ;
+    }
+    else if ( *s == '+' )
+    {
+        sign =  1 ;
+        s++ ;
+    }
+    else
+    {
+        sign =  1 ;
+    }
+
+    /* recognize optional hex# prefix */
+    if ((base == 16) && ((*s == '0') && ((*(s + 1) == 'x') || (*(s + 1) == 'X'))
+       ))
+        s += 2 ;
+
+    /* recognize digits */
+
+/*    for (; (c = *s++) && isnumber(&d, c, base) ; )
+    {
+        result =  base * result + d ;
+    }
+*/    
+    while(1)
+    {
+      c = *s++;
+      if (!(c && isnumber(&d, c, base)))       
+        break;
+      result =  base * result + d ;
+    };
+
+    *pi         =  sign * result ;
+    sptr [slen] =  saved ; /* restore character which we changed to null */
+    return (s - sptr - 1);
+} /* end of _btoi */
+
+static int decryptWEP
+(
+  PCHAR pSrc,
+  PCHAR pDst,
+  ULONG len
+)
+{
+  /**/
+  /* key to use for encryption*/
+  /**/
+  static LPCSTR lpEncryptKey = "jkljz98c&2>a+t)cl5[d=n3;\"f_um6\\d~v%$HO1";
+  int cnEncryptLen = strlen(lpEncryptKey);
+
+  char cIn, cCrypt, cHex[3];
+  int i, j, nLen;
+  int nPos;
+
+  nLen = len / 2;
+  nPos = len;
+
+  /* start reading from end*/
+  nPos = len - 2;
+
+  for(i = 0; (i < nLen) && (nPos >= 0); i++, nPos -= 2)
+  {
+    /* get hex character*/
+    cHex[0] = pSrc[nPos];
+    cHex[1] = pSrc[nPos + 1];
+    cHex[2] = 0;
+
+    _btoi ( cHex, 2, &j, 16);
+    cIn = (char) j;
+
+    cCrypt = lpEncryptKey[i % cnEncryptLen];
+    cIn = cIn ^ cCrypt;
+
+    pDst[i] = cIn;
+  }
+
+  PRINTF(DBG_REGISTRY_LOUD, ("First 5 bytes of WEP: %x-%x-%x-%x-%x\n",
+    pDst[0],
+    pDst[1],
+    pDst[2],
+    pDst[3],
+    pDst[4]));
+
+  return nLen;
+}
+
+static VOID initRadioValusFromRgstryString
+(
+  PCHAR pSrc,
+  PCHAR pDst,
+  ULONG len
+)
+{
+    int j;
+    ULONG count;
+    for (count = 0 ; count < len ; count++)
+    {
+        _btoi((char *) (pSrc+(count*3)),  2, &j, 16 );
+
+        pDst[count] = (UINT8) j;
+    }
+}
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadParameters
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regReadParameters(
+    PTIWLN_ADAPTER_T        pAdapter
+                 )
+{
+    NDIS_STRING SlotNumberStr = NDIS_STRING_CONST("SlotNumber");
+    PNDIS_CONFIGURATION_PARAMETER RetValue;
+    NDIS_STATUS Status;
+
+    NdisReadConfiguration(&Status, &RetValue,
+                          pAdapter->ConfigHandle, &SlotNumberStr,
+                          NdisParameterInteger);
+
+    if (Status != NDIS_STATUS_SUCCESS)
+        pAdapter->SlotNumber = 0;
+    else
+        pAdapter->SlotNumber = RetValue->ParameterData.IntegerData;
+
+
+    PRINTF(DBG_REGISTRY_VERY_LOUD, ("TIWL: SlotNumber-%ld\n", pAdapter->SlotNumber));
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regWriteInstanceNumber
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+VOID
+regWriteInstanceNumber(
+                      PTIWLN_ADAPTER_T pAdapter
+                      )
+{
+#ifdef _WINDOWS
+#endif /* _WINDOWS */
+}
+
+
+#ifdef TI_DBG
+
+
+VOID
+regReadLastDbgState(
+                   PTIWLN_ADAPTER_T pAdapter
+                   )
+{
+    NDIS_STRING OsDbgStr = NDIS_STRING_CONST("OsDbgState");
+    PNDIS_CONFIGURATION_PARAMETER Value;
+    NDIS_STATUS Status;
+
+    NdisReadConfiguration(&Status, &Value,
+                          pAdapter->ConfigHandle, &OsDbgStr,
+                          NdisParameterInteger
+                         );
+
+    if (Status != NDIS_STATUS_SUCCESS)
+    {
+
+        TiDebugFlag = ((DBG_NDIS_OIDS | DBG_INIT | DBG_RECV | DBG_SEND | DBG_IOCTL | DBG_INTERRUPT) << 16) |
+                DBG_SEV_VERY_LOUD | DBG_SEV_INFO | DBG_SEV_LOUD | DBG_SEV_ERROR | DBG_SEV_FATAL_ERROR;
+
+    } else
+    {
+
+        PRINTF(DBG_REGISTRY_VERY_LOUD, ("TIWL: New Flag - 0x%lX\n", Value->ParameterData.IntegerData));
+
+        TiDebugFlag = Value->ParameterData.IntegerData;
+
+    }
+}
+
+
+VOID
+regWriteLastDbgState(
+                    PTIWLN_ADAPTER_T pAdapter
+                    )
+{
+    NDIS_STRING OsDbgStr = NDIS_STRING_CONST("OsDbgState");
+    NDIS_CONFIGURATION_PARAMETER Value;
+    NDIS_STATUS Status;
+
+    Value.ParameterType = NdisParameterInteger;
+    Value.ParameterData.IntegerData = TiDebugFlag;
+
+    NdisWriteConfiguration(&Status, pAdapter->ConfigHandle,
+                           &OsDbgStr, &Value);
+}
+#endif
+
+
+
+static void readRates(PTIWLN_ADAPTER_T pAdapter, initTable_t *pInitTable)
+{
+    /*
+    ** B band
+    */
+    regReadIntegerParameter(pAdapter, &STRdot11BasicRateMask_B,
+                            BASIC_RATE_SET_1_2_5_5_11, BASIC_RATE_SET_1_2, BASIC_RATE_SET_1_2_5_5_11,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_B_MODE], 
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_B_MODE]);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SupportedRateMask_B,
+                          SUPPORTED_RATE_SET_1_2_5_5_11_22, SUPPORTED_RATE_SET_1_2, SUPPORTED_RATE_SET_1_2_5_5_11_22,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_B_MODE], 
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_B_MODE]);
+    /*
+    ** G band (B&G rates)
+    */
+    regReadIntegerParameter(pAdapter, &STRdot11BasicRateMask_G,
+                            BASIC_RATE_SET_1_2_5_5_11, BASIC_RATE_SET_1_2, BASIC_RATE_SET_1_2_5_5_11,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_G_MODE], 
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_G_MODE]);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SupportedRateMask_G,
+                            SUPPORTED_RATE_SET_ALL, SUPPORTED_RATE_SET_1_2, SUPPORTED_RATE_SET_ALL,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_G_MODE], 
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_G_MODE]);
+
+    /*
+    ** A band
+    */
+    regReadIntegerParameter(pAdapter, &STRdot11BasicRateMask_A,
+                            BASIC_RATE_SET_6_12_24, BASIC_RATE_SET_6_12_24, BASIC_RATE_SET_6_12_24,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_A_MODE], 
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_A_MODE]);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SupportedRateMask_A,
+                            SUPPORTED_RATE_SET_UP_TO_54, SUPPORTED_RATE_SET_1_2, SUPPORTED_RATE_SET_UP_TO_54,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_A_MODE], 
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_A_MODE]);
+
+    /*
+    ** Dual band (A&G)
+    */
+    regReadIntegerParameter(pAdapter, &STRdot11BasicRateMask_AG,
+                            BASIC_RATE_SET_1_2, BASIC_RATE_SET_1_2, BASIC_RATE_SET_1_2,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_DUAL_MODE],
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryBasicRate[DOT11_DUAL_MODE]);
+
+    regReadIntegerParameter(pAdapter, &STRdot11SupportedRateMask_AG,
+                            SUPPORTED_RATE_SET_ALL_OFDM, SUPPORTED_RATE_SET_1_2, SUPPORTED_RATE_SET_ALL_OFDM,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_DUAL_MODE],
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstrySuppRate[DOT11_DUAL_MODE]);
+
+    /* Tx Rate */
+    regReadIntegerParameter(pAdapter, &STRdot11DesiredTxRate,
+                            REG_RATE_AUTO_BIT, REG_RATE_AUTO_BIT, REG_RATE_54M_OFDM_BIT,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryDesiredTxRate,
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryDesiredTxRate);
+
+    /* Management & Ctrl Tx rate Selection (Fix rate/MinBasic/Max basic) */
+    regReadIntegerParameter(pAdapter, &STRdot11MgmtCtrlTxRateSelection,
+                            MAX_BASIC_TX_RATE, MIN_BASIC_TX_RATE, SPECIFIC_TX_RATE,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryDesiredMgmtCtrlTxRateOption,
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryDesiredMgmtCtrlTxRateOption);
+    
+    /* Management & Ctrl Tx rate (HW generated packets) */
+    regReadIntegerParameter(pAdapter, &STRdot11MgmtCtrlTxRate,
+                            REG_RATE_2M_BIT, REG_RATE_1M_BIT, REG_RATE_54M_OFDM_BIT,
+                            sizeof pInitTable->siteMgrInitParams.siteMgrRegstryDesiredMgmtCtrlTxRate,
+                            (PUCHAR)&pInitTable->siteMgrInitParams.siteMgrRegstryDesiredMgmtCtrlTxRate);
+
+}
+
+
+static void decryptScanControlTable(PUCHAR src, PUCHAR dst, USHORT len)
+{
+
+    USHORT i;
+    int parityFlag = 0;
+    char tmp = 0;
+    char finalChar = 0;
+
+    for(i=0; i < len; i++)
+    {
+        switch(src[i])
+        {
+        case 'A':
+        case 'a':
+            tmp = 10;
+            break;
+        case 'B':
+        case 'b':
+            tmp = 11;
+            break;
+        case 'C':
+        case 'c':
+            tmp = 12;
+            break;
+        case 'D':
+        case 'd':
+            tmp = 13;
+            break;
+        case 'E':
+        case 'e':
+            tmp = 14;
+            break;
+        case 'F':
+        case 'f':
+            tmp = 15;
+            break;
+        default:
+            if( (src[i] >='0') && (src[i] <= '9') )
+                tmp = (src[i] - '0');
+            else
+                return; /* ERROR input char */
+        }
+        if(parityFlag == 0)
+            finalChar =  tmp << 4;
+        else
+        {
+            finalChar |= (tmp & 0x0f);
+            dst[i/2] = finalChar;
+        }
+        parityFlag = 1-parityFlag;
+    }
+}
+
+VOID regReadNetworkAddress(PTIWLN_ADAPTER_T pAdapter)
+{
+  NDIS_STATUS Status;
+  PVOID pvNetworkAddress;
+  UINT cbNetworkAddress;
+
+  NdisReadNetworkAddress( &Status, &pvNetworkAddress, &cbNetworkAddress, pAdapter->ConfigHandle );
+  if ( ( NDIS_STATUS_SUCCESS == Status ) && ( ETH_ADDR_SIZE == cbNetworkAddress ) ) {
+    NdisMoveMemory( pAdapter->CurrentAddr, pvNetworkAddress, ETH_ADDR_SIZE);
+        pAdapter->bCurrentAddrFromRegistry = TRUE;
+  }
+}
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regReadIntegerTable
+
+Routine Description:
+    reads any table format and insert it to another string.
+    the delimiters of the tables can be:
+     - space (" ")
+     - comma (",")
+    the table reads only integers thus its reads the following chars:
+     - "0" till "9"
+     - minus sign ("-")
+
+Arguments:
+
+
+Return Value:
+
+    zero on success else - error number.
+
+-----------------------------------------------------------------------------*/
+UINT32
+regReadIntegerTable(
+                     PTIWLN_ADAPTER_T       pAdapter,
+                     PNDIS_STRING           pParameterName,
+                     PCHAR                  pDefaultValue,
+                     USHORT                 defaultLen,
+                     PUCHAR                 pParameter
+                     )
+{
+    UINT32 parameterIndex = 0;
+    int myNumber;
+
+    UINT32 index;
+    UINT32 bufferSize = 0;
+
+    char tempBuffer[15];
+    char *pTempBuffer = tempBuffer;
+    UINT32 tempBufferIndex = 0;
+
+    BOOL isDigit;
+    BOOL numberReady;
+    BOOL isSign;
+    BOOL    endOfLine;
+
+    UINT32 debugInfo = 0;
+
+    CHAR Buffer[MAX_KEY_BUFFER_LEN];
+    PCHAR pBuffer = (PCHAR)&Buffer;
+
+    regReadStringParameter(pAdapter,
+                           pParameterName,
+                           pDefaultValue,
+                           defaultLen,
+                           (PUCHAR)pBuffer,
+                           &bufferSize);
+
+
+
+    index=0;
+    do { /* Parsing one line */
+
+        isSign = FALSE;
+        isDigit = FALSE;
+        numberReady = FALSE;
+        tempBufferIndex = 0;
+        endOfLine = FALSE;
+
+        while ((numberReady==FALSE) && (index<bufferSize))
+        {
+            /* Parsing one number */
+            switch (pBuffer[index])
+            {
+                case '0':
+                case '1':
+                case '2':
+                case '3':
+                case '4':
+                case '5':
+                case '6':
+                case '7':
+                case '8':
+                case '9':
+                    pTempBuffer[tempBufferIndex] = pBuffer[index];
+                    ++tempBufferIndex;
+                    isDigit = TRUE;
+                    break;
+
+                case '-':
+                    pTempBuffer[tempBufferIndex] = pBuffer[index];
+                    ++tempBufferIndex;
+                    if (isDigit==TRUE)
+                    {
+                        PRINTF(DBG_REGISTRY_INFO, ("Error in read parameter %c in line index %d\n\
+                                               The sign '-' isn't in place!\n",pBuffer[index],index));
+                        debugInfo = 1;
+                    }
+                    isSign = TRUE;
+                    break;
+
+                case ' ':
+                case '\t': /* tab char */
+                    /* for space discard*/
+                    if ((isDigit==FALSE) && (isSign==FALSE))
+                    {
+                        break;
+                    }
+                    /*
+                    else we are continue to the code of the case ','
+                    */
+                case '\0':
+                    endOfLine = TRUE;
+
+                case ',':
+                    /* end of number reading */
+                    pTempBuffer[tempBufferIndex] = '\0';
+                    if (isDigit == FALSE)
+                    {
+                        PRINTF(DBG_REGISTRY_INFO, ("Error in end of number delimiter. number isn't ready.\
+                            check index %d",index));
+                        debugInfo = 2;
+                    }
+                    numberReady = TRUE;
+                    break;
+
+                default:
+                    PRINTF(DBG_REGISTRY_INFO, ("%s(%d) Error - unexpected parameter %c.\n",
+                        __FILE__,__LINE__,pBuffer[index]));
+                    debugInfo = 3;
+                    break;
+            }/* switch( pBuffer[index] ) */
+
+            if (debugInfo != 0)
+            {
+                return debugInfo;
+            }
+            ++index;
+
+        }/* while (numberReady==FALSE)*/
+
+        if (pTempBuffer[0] == '-')
+        {
+            ++pTempBuffer;
+            myNumber = tiwlnstrtoi(pTempBuffer,tempBufferIndex-1);
+            myNumber = -(myNumber);
+        }
+        else
+        {
+            myNumber = tiwlnstrtoi(pTempBuffer,tempBufferIndex);
+        }
+
+
+        pParameter[parameterIndex] = myNumber;
+        ++parameterIndex;
+    
+    }while ((index<bufferSize)&&(endOfLine==FALSE));
+
+    return debugInfo;
+}
+
+void assignRegValue(PULONG lValue, PNDIS_CONFIGURATION_PARAMETER ndisParameter)
+{ 
+    char b[8]; 
+    ANSI_STRING a = {0, 0, 0};
+
+    a.MaximumLength = sizeof(b);
+    a.Buffer=(PCHAR)b;
+
+    if(ndisParameter->ParameterData.StringData.Length <= sizeof (b) * 2) 
+    { 
+      if ( ((char *)(ndisParameter->ParameterData.StringData.Buffer))[1] == 0 )
+      {
+        NdisUnicodeStringToAnsiString ( &a, &(ndisParameter)->ParameterData.StringData );
+        *lValue = tiwlnstrtoi ( (char *)a.Buffer, a.Length ); 
+      } else { 
+        *lValue = tiwlnstrtoi ( (char *)(ndisParameter->ParameterData.StringData.Buffer), ndisParameter->ParameterData.StringData.Length); 
+      } 
+    } else {
+      *lValue = 0;
+    }
+  }
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regConvertStringtoIpAddress
+
+Routine Description: Converts the Ip Adrress in a form of string readen from the Registry 
+to the Ip Address Array to be stored in the init_table struct 
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+void regConvertStringtoIpAddress(UINT8 *staIpAddressString,UINT8 *IpAddressArray)
+{
+
+char *ptr;
+UINT8 *tmpIpAddr;
+UINT8 value=0,value_l,value_h,add_value;
+int i;
+
+
+    /* Take the pointer to the string MAC Address to convert it to the Array MAC Address */
+    ptr=(char *)staIpAddressString;
+    tmpIpAddr = IpAddressArray;
+
+#if 0 
+    for(i=0 ; i<4 ; ptr++)
+    {
+        value_l = (*ptr-'0');
+
+        /* PRINTF(DBG_REGISTRY,("value_l [%d] *ptr %c value %d\n",value_l,*ptr,value));*/
+
+        if( value_l  < 9)
+        {
+            value = value*10 + value_l;             
+            /* PRINTF(DBG_REGISTRY,("value %d value_l %d  \n",value,value_l));*/
+
+
+        }
+        else
+        {
+            tmpIpAddr[i] = value;
+            /* PRINTF(DBG_REGISTRY,("tmpMacAddr[%d]  is %d\n",i,tmpMacAddr[i]));*/
+            value = 0;
+            i++;
+        }
+
+    }
+
+#else
+
+    for(i=0 ; i<4 ; ptr++)
+    {
+        
+        /* The value can be or "0-9" or from "a-f" */
+        value_l = (*ptr-'0');
+        value_h = (*ptr - 'a');
+
+        /*PRINTF(DBG_REGISTRY,("value_l [%d] value_h [%d] *ptr %c value %d\n",value_l,value_h,*ptr,value));*/
+
+        if( (value_l <= 9) || (value_h <= 15 ) )
+        {
+            /* We are in an expected range */
+            /* nCheck if 0-9 */
+            if(value_l <= 9 )
+            {
+                add_value = value_l;
+            }
+            /* Check if a-f */
+            else
+            {
+                /* 'a' is in fact 10 decimal in hexa */
+                add_value = value_h + 10;
+            }
+            value = value*16 + add_value;               
+        /*  PRINTF(DBG_REGISTRY,("value %d add_value %d  \n",value,add_value));*/
+
+
+        }
+        else
+        {
+            tmpIpAddr[i] = value;
+        /*  PRINTF(DBG_REGISTRY,("tmpMacAddr[%d]  is %x\n",i,tmpMacAddr[i]));*/
+            value = 0;
+            i++;
+        }
+
+    }
+#endif
+
+}
+
+
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+    regConvertStringtoIpAddress
+
+Routine Description: Converts the Ip Adrress in a form of string readen from the Registry 
+to the Ip Address Array to be stored in the init_table struct 
+
+
+Arguments:
+
+
+Return Value:
+
+    None
+
+-----------------------------------------------------------------------------*/
+void regConvertStringtoBeaconIETable(UINT8 *staIpAddressString,UINT8 *IpAddressArray, UINT8 size)
+{
+
+char *ptr;
+UINT8 *tmpIpAddr;
+UINT8 value=0,value_l,value_h,add_value;
+int i;
+
+
+    /* Take the pointer to the string MAC Address to convert it to the Array MAC Address */
+    ptr=(char *)staIpAddressString;
+    tmpIpAddr = IpAddressArray;
+
+#if 0 
+    for(i=0 ; i<size ; ptr++)
+    {
+        value_l = (*ptr-'0');
+
+        /* PRINTF(DBG_REGISTRY,("value_l [%d] *ptr %c value %d\n",value_l,*ptr,value));*/
+
+        if( value_l  < 9)
+        {
+            value = value*10 + value_l;             
+            /* PRINTF(DBG_REGISTRY,("value %d value_l %d  \n",value,value_l));*/
+
+
+        }
+        else
+        {
+            tmpIpAddr[i] = value;
+            /* PRINTF(DBG_REGISTRY,("tmpMacAddr[%d]  is %d\n",i,tmpMacAddr[i]));*/
+            value = 0;
+            i++;
+        }
+
+    }
+
+#else
+
+    for(i=0 ; i<size ; ptr++)
+    {
+        
+        /* The value can be or "0-9" or from "a-f" */
+        value_l = (*ptr-'0');
+        value_h = (*ptr - 'a');
+
+        /*PRINTF(DBG_REGISTRY,("value_l [%d] value_h [%d] *ptr %c value %d\n",value_l,value_h,*ptr,value));*/
+
+        if( (value_l <= 9) || (value_h <= 15 ) )
+        {
+            /* We are in an expected range */
+            /* nCheck if 0-9 */
+            if(value_l <= 9 )
+            {
+                add_value = value_l;
+            }
+            /* Check if a-f */
+            else
+            {
+                /* 'a' is in fact 10 decimal in hexa */
+                add_value = value_h + 10;
+            }
+            value = value*16 + add_value;               
+        /*  PRINTF(DBG_REGISTRY,("value %d add_value %d  \n",value,add_value));*/
+
+
+        }
+        else
+        {
+            tmpIpAddr[i] = value;
+        /*  PRINTF(DBG_REGISTRY,("tmpMacAddr[%d]  is %x\n",i,tmpMacAddr[i]));*/
+            value = 0;
+            i++;
+        }
+
+    }
+#endif
+
+}
+
+//TRS:WDK provide callback functions
+#if defined(_WINDOWS)
+#endif
+//TRS end
+
+
+static void parse_hex_string(char * pString, tiUINT8 StrLength, tiUINT8 * pBuffer, tiUINT8 * Length)
+{
+    char ch;
+    int iter = 0;
+
+    while ((iter < StrLength) && ((ch = pString[iter]) != '\0'))
+    {
+        UINT8 val = ((ch >= '0' && ch <= '9') ? (ch - '0') : 
+                     (ch >= 'A' && ch <= 'F') ? (0xA + ch - 'A') :
+                     (ch >= 'a' && ch <= 'f') ? (0xA + ch - 'a') : 0);
+
+        /* even indexes go to the lower nibble, odd indexes push them to the */
+        /* higher nibble and then go themselves to the lower nibble. */
+        if (iter % 2)
+            pBuffer[iter / 2] = ((pBuffer[iter / 2] << (BIT_TO_BYTE_FACTOR / 2)) | val);
+        else
+            pBuffer[iter / 2] = val;
+
+        ++iter;
+    }
+
+    /* iter = 0 len = 0, iter = 1 len = 1, iter = 2 len = 1, and so on... */
+    *Length = (iter + 1) / 2;
+}
+
+static void parse_binary_string(char * pString, tiUINT8 StrLength, tiUINT8 * pBuffer, tiUINT8 * Length)
+{
+    char ch;
+    int iter = 0;
+
+    while ((iter < StrLength) && ((ch = pString[iter]) != '\0'))
+    {
+        UINT8 val = (ch == '1' ? 1 : 0);
+
+        if (iter % BIT_TO_BYTE_FACTOR)
+            pBuffer[iter / BIT_TO_BYTE_FACTOR] |= (val << (iter % BIT_TO_BYTE_FACTOR));
+        else
+            pBuffer[iter / BIT_TO_BYTE_FACTOR] = val;
+
+        ++iter;
+    }
+
+    /* iter = 0 len = 0, iter = 1 len = 1, iter = 8 len = 1, and so on... */
+    *Length = (iter + BIT_TO_BYTE_FACTOR - 1) / BIT_TO_BYTE_FACTOR;
+}
+
+static void parse_filter_request(rxDataFilterRequest_t * request, UINT8 offset, char * mask, UINT8 maskLength, char * pattern, UINT8 patternLength)
+{
+    request->offset = offset;
+    request->maskLength = request->patternLength = 0;
+
+    if (maskLength > 0)
+    {
+        parse_binary_string(mask, maskLength, request->mask, &request->maskLength);
+        parse_hex_string(pattern, patternLength, request->pattern, &request->patternLength);
+    }
+}
diff --git a/sta_dk_4_0_4_32/pform/common/src/osUtil.c b/sta_dk_4_0_4_32/pform/common/src/osUtil.c
new file mode 100644 (file)
index 0000000..757c443
--- /dev/null
@@ -0,0 +1,5590 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#ifdef _WINDOWS    /*nick*/
+#elif defined(__ARMCC__) 
+#include "string.h"
+#endif
+
+#include "osAdapter.h"
+#include "srcApi.h"
+#include "tiwlnif.h"
+#include "osDot11.h"
+#include "osUtil.h"
+#include "paramOut.h"
+#include "wspVer.h"
+#include "osClsfr.h"
+#include "whalHwMboxCmdBit.h"
+
+static TI_STATUS
+UtilRegulatoryDomain_setCountryIE(
+                                                                PTIWLN_ADAPTER_T pAdapter,
+                                                                externalParam_e ParamType,
+                                                                PUCHAR pData,
+                                                                ULONG Length
+                                                                );
+
+#ifdef TIWLN_WINCE30
+
+gprintf(const char *format ,... )
+{
+#if 1
+#ifdef DEBUG_PB
+       wchar_t Buf[500];
+#endif
+
+       FILE *Fpn;  
+
+       Fpn = fopen("TILog.txt","a"); 
+
+       if (Fpn)
+       {
+               char Msg[500];
+               va_list ap;
+               va_start(ap,format);
+               _vsnprintf(Msg,500,format,ap);
+               fprintf(Fpn,"%s", Msg);
+#ifdef DEBUG_PB
+               mbstowcs(Buf,Msg,strlen(Msg)+1);    
+               DEBUGMSG(1,(Buf));
+#endif
+
+               fclose(Fpn);
+
+       }
+#endif
+}
+
+#endif
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSetParam
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+TI_STATUS
+UtilSetParam(
+                       PTIWLN_ADAPTER_T pAdapter,
+                       externalParam_e ParamType,
+                       PUCHAR pData,
+                       ULONG Length
+                       )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       if (Length > sizeof(Param.content))
+       {
+               PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilSetParam: Buffer for parameter 0x%X is bigger(%d) then Param size(%d)\n", ParamType, (int)Length, sizeof(Param.content)));
+               Param.paramLength = sizeof(Param.content);
+               NdisMoveMemory(&Param.content, pData, sizeof(Param.content));
+       } else
+       {
+               Param.paramLength = Length;
+               NdisMoveMemory(&Param.content, pData, Length);
+       }
+
+       Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetParam
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+TI_STATUS
+UtilGetParam(
+                       PTIWLN_ADAPTER_T pAdapter,
+                       externalParam_e ParamType,
+                       PUCHAR pData,
+                       ULONG Length
+                       )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       Param.paramLength = Length;
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       if (Status == NOK)
+       {
+               PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilGetParam: ERROR on return from get param, status=%d, param=%d\n",
+                                                                                Status, ParamType));
+       } else if ( Status != NOK )
+       {
+               PRINTF(DBG_NDIS_OIDS_LOUD, (" UtilGetParam: WARNING on return from get param, status=%d, param=%d\n",
+                                                                       Status, ParamType));
+       }
+
+       if (Length > sizeof(Param.content))
+       {
+               PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilGetParam: Buffer for parameter 0x%X is bigger then Param size\n", ParamType));
+               NdisMoveMemory(pData, &Param.content, sizeof(Param.content));
+       } else
+       {
+               NdisMoveMemory(pData, &Param.content, Length);
+       }
+
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSetGetParam
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+TI_STATUS
+UtilSetGetParam(
+                          PTIWLN_ADAPTER_T pAdapter,
+                          externalParam_e ParamType,
+                          PUCHAR pData,
+                          ULONG Length
+                          )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       if (Length > sizeof(Param.content))
+       {
+               PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilSetParam: Buffer for parameter 0x%X is bigger(%d) then Param size(%d)\n", ParamType, (int)Length, sizeof(Param.content)));
+               Param.paramLength = sizeof(Param.content);
+               NdisMoveMemory(&Param.content, pData, sizeof(Param.content));
+       } else
+       {
+               Param.paramLength = Length;
+               NdisMoveMemory(&Param.content, pData, Length);
+       }
+
+       Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+       if (Length > sizeof(Param.content))
+       {
+               PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilGetParam: Buffer for parameter 0x%X is bigger then Param size\n", ParamType));
+               NdisMoveMemory(pData, &Param.content, sizeof(Param.content));
+       } else
+       {
+               NdisMoveMemory(pData, &Param.content, Length);
+       }
+
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetTxPowerValue
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetTxPowerValue(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  externalParam_e ParamType,
+                                  PUCHAR pData,
+                                  ULONG Length
+                                  )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       Param.paramLength = Length;
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = (ULONG)Param.content.regulatoryDomainParam.txPower;
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilSetTxPowerDbm
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilSetTxPowerDbm(PTIWLN_ADAPTER_T pAdapter,
+                                                 PUCHAR pData,
+                                                 ULONG Length)
+{
+       ULONG retValue;
+
+       retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData, sizeof(UINT8));
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetTxPowerLevel
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetTxPowerLevel(PTIWLN_ADAPTER_T pAdapter,
+                                                 PUCHAR pData,
+                                                 PULONG Length)
+{
+       ULONG retValue;
+
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_TX_POWER_LEVEL_TABLE_PARAM, pData, sizeof(TIWLAN_POWER_LEVEL_TABLE));
+       *Length=sizeof(TIWLAN_POWER_LEVEL_TABLE);
+
+       return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilEnableDisableRxDataFilters
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilEnableDisableRxDataFilters(PTIWLN_ADAPTER_T pAdapter,
+                                     PUCHAR pData,
+                                     ULONG Length)
+{
+    ULONG retValue;
+
+    retValue = UtilSetParam(pAdapter, RX_DATA_ENABLE_DISABLE_RX_DATA_FILTERS, pData, Length);
+
+    return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetRxDataFiltersStatisticsCB
+
+Routine Description: This is the CB triggered when Rx Data Filter statistics 
+                                        are returned by the FW.
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+static VOID UtilGetRxDataFiltersStatisticsCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hAdapter;
+    ACXDataFilteringStatistics_t * pStatistics = (ACXDataFilteringStatistics_t *) pReadBuff;
+    TIWLAN_DATA_FILTER_STATISTICS * pResult = (TIWLAN_DATA_FILTER_STATISTICS *) &(pAdapter->pIoBuffer[0]);
+    int i;
+
+    pResult->UnmatchedPacketsCount = pStatistics->unmatchedPacketsCount;
+
+    for (i = 0; i < MAX_DATA_FILTERS; ++i)
+    {
+        pResult->MatchedPacketsCount[i] = pStatistics->matchedPacketsCount[i];
+    }
+
+    *(pAdapter->pIoCompleteBuffSize) = sizeof(TIWLAN_DATA_FILTER_STATISTICS);
+
+    /* indicate that the buffer is ready */
+       os_IoctlComplete(pAdapter, status);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilEnableDisableRxDataFilters
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetRxDataFiltersStatistics(PTIWLN_ADAPTER_T pAdapter,
+                                     PUCHAR pData,
+                                     PULONG Length)
+{
+    paramInfo_t Param;
+
+    memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE);
+
+    pAdapter->pIoBuffer = pData;
+    pAdapter->pIoCompleteBuffSize = Length;
+
+    Param.paramType = RX_DATA_GET_RX_DATA_FILTERS_STATISTICS;
+    Param.paramLength = sizeof(TIWLAN_DATA_FILTER_STATISTICS);
+    Param.content.interogateCmdCBParams.CB_handle = (TI_HANDLE) pAdapter;
+    Param.content.interogateCmdCBParams.CB_Func = (PVOID) UtilGetRxDataFiltersStatisticsCB;
+    Param.content.interogateCmdCBParams.CB_buf = &(pAdapter->IoCompleteBuff[0]) ;
+
+    return configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetPowerConsumptionStatisticsCB
+
+Routine Description: This is the CB triggered when Power consumption statistics 
+                                        are returned by the FW.
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+static VOID UtilGetPowerConsumptionStatisticsCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hAdapter;
+    ACXPowerConsumptionTimeStat_t * pStatistics = (ACXPowerConsumptionTimeStat_t *) pReadBuff;
+    PowerConsumptionTimeStat_t * pResult = (PowerConsumptionTimeStat_t *) &(pAdapter->pIoBuffer[0]);
+
+    pResult->activeTimeCnt_Hi = pStatistics->activeTimeCnt_Hi;
+    pResult->activeTimeCnt_Low = pStatistics->activeTimeCnt_Low;
+    pResult->elpTimeCnt_Hi = pStatistics->elpTimeCnt_Hi;
+    pResult->elpTimeCnt_Low = pStatistics->elpTimeCnt_Low;
+    pResult->powerDownTimeCnt_Hi = pStatistics->powerDownTimeCnt_Hi;
+    pResult->powerDownTimeCnt_Low = pStatistics->powerDownTimeCnt_Low;
+    
+    *(pAdapter->pIoCompleteBuffSize) = sizeof(PowerConsumptionTimeStat_t);
+
+    /* indicate that the buffer is ready */
+       os_IoctlComplete(pAdapter, status);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetPowerConsumptionStatistics
+Routine Description: Request the power consumption statistics from the FW
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetPowerConsumptionStatistics(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
+{
+    paramInfo_t Param;
+
+    memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE);
+
+    pAdapter->pIoBuffer = pData;
+    pAdapter->pIoCompleteBuffSize = Length;
+
+    Param.paramType = HAL_CTRL_POWER_CONSUMPTION;
+    Param.paramLength = sizeof(PowerConsumptionTimeStat_t);
+    Param.content.interogateCmdCBParams.CB_handle = (TI_HANDLE) pAdapter;
+    Param.content.interogateCmdCBParams.CB_Func = (PVOID) UtilGetPowerConsumptionStatisticsCB;
+    Param.content.interogateCmdCBParams.CB_buf = &(pAdapter->IoCompleteBuff[0]);
+
+    return configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilAddRxDataFilter
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilAddRxDataFilter(PTIWLN_ADAPTER_T pAdapter,
+                          PUCHAR pData,
+                          ULONG Length)
+{
+    ULONG retValue;
+
+    retValue = UtilSetParam(pAdapter, RX_DATA_ADD_RX_DATA_FILTER, pData, Length);
+
+    return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilRemoveRxDataFilter
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilRemoveRxDataFilter(PTIWLN_ADAPTER_T pAdapter,
+                             PUCHAR pData,
+                             ULONG Length)
+{
+    ULONG retValue;
+
+    retValue = UtilSetParam(pAdapter, RX_DATA_REMOVE_RX_DATA_FILTER, pData, Length);
+
+    return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetCurrentRssiLevel
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetCurrentRssiLevel(PTIWLN_ADAPTER_T pAdapter,
+                                                         PUCHAR pData,
+                                                         PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_SIGNAL_PARAM, pData, sizeof(INT32));
+       *Length = sizeof(INT32);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  RssiUtilIoctlCompleteCB
+
+Routine Description: This is the CB triggered when  Rssi/Snr have been 
+                                       returned by FW - return RSSI only to user
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID RssiUtilIoctlCompleteCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
+       TIWLN_RADIO_RX_QUALITY tmpRadioRxQuality;
+       paramInfo_t Param;
+       ACXRoamingStatisticsTable_t * radioResults = (ACXRoamingStatisticsTable_t *) pReadBuff;
+
+       tmpRadioRxQuality.Rssi = radioResults->rssi;
+       tmpRadioRxQuality.Snr = (INT32) radioResults->snr;
+
+       /* here we update the site manager about these new values */
+       Param.paramType = SITE_MGR_CURRENT_SIGNAL_PARAM;
+       Param.paramLength = sizeof(INT32);
+       Param.content.siteMgrCurrentRssi = tmpRadioRxQuality.Rssi;
+       configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+
+       *(pAdapter->pIoCompleteBuffSize) = sizeof(INT32);
+       os_memoryCopy(hAdapter, (PVOID) &(pAdapter->pIoBuffer[0]), (PVOID) &(tmpRadioRxQuality.Rssi), sizeof(INT32));
+
+       /* Call back the Completion that will indicate to the user that the buffer is ready to be read */
+       os_IoctlComplete(pAdapter, status);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  SnrUtilIoctlCompleteCB
+
+Routine Description: This is the CB triggered when  Rssi/Snr have been 
+                                       returned by FW - return SNR only to user
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID SnrUtilIoctlCompleteCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hAdapter;
+       TIWLN_RADIO_RX_QUALITY tmpRadioRxQuality;
+       ACXRoamingStatisticsTable_t * radioResults = (ACXRoamingStatisticsTable_t *) pReadBuff;
+
+    tmpRadioRxQuality.Rssi = radioResults->rssi;
+       /* The SNR returned by FW is not true. We have to divide it by 2 and turns it to a signed */
+       tmpRadioRxQuality.Snr = (INT32) radioResults->snr;
+
+       *(pAdapter->pIoCompleteBuffSize) = sizeof(INT32);
+
+       os_memoryCopy(hAdapter, (PVOID) &(pAdapter->pIoBuffer[0]), (PVOID) &(tmpRadioRxQuality.Snr), sizeof(INT32));
+
+       os_IoctlComplete(pAdapter, status);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetAsyncCurrentRssiLevel
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetAsyncCurrentRssiLevel(PTIWLN_ADAPTER_T pAdapter,
+                                                                  PUCHAR pData,
+                                                                  PULONG Length)
+{
+       paramInfo_t Param;
+
+
+       TI_STATUS Status;
+
+       memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
+
+       /* To implement the Async IOCTL store the user buffer pointer to be filled at
+       the Command Completion calback */
+       pAdapter->pIoBuffer =  pData;
+       pAdapter->pIoCompleteBuffSize =  Length ;
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       Param.paramType = HAL_CTRL_RSSI_LEVEL_PARAM;
+       Param.paramLength = sizeof(INT32);
+       Param.content.interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       Param.content.interogateCmdCBParams.CB_Func    =  (PVOID)RssiUtilIoctlCompleteCB;
+       Param.content.interogateCmdCBParams.CB_buf     =  &(pAdapter->IoCompleteBuff[0]) ;
+
+       /* This Get Param will in fact get till the HAL and will interrogate the FW */
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetAsyncCurrentRssiLevel
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetAsyncCurrentSnrRatio(PTIWLN_ADAPTER_T pAdapter,
+                                                                 PUCHAR pData,
+                                                                 PULONG Length)
+{
+       paramInfo_t Param;
+
+
+       TI_STATUS Status;
+
+       memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
+
+       pAdapter->pIoBuffer =  pData;
+       pAdapter->pIoCompleteBuffSize =  Length ;
+
+       Param.paramType = HAL_CTRL_SNR_RATIO_PARAM;
+       Param.paramLength = sizeof(INT32);
+       Param.content.interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       Param.content.interogateCmdCBParams.CB_Func    =  (PVOID)SnrUtilIoctlCompleteCB;
+       Param.content.interogateCmdCBParams.CB_buf     =  &(pAdapter->IoCompleteBuff[0]) ;
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetAPTxPowerLevel
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetAPTxPowerLevel(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        externalParam_e ParamType,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       Param.paramLength = Length;
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = (ULONG)Param.content.APTxPower;
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetCountryCode
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetCountryCode(
+                                 PTIWLN_ADAPTER_T pAdapter,
+                                 externalParam_e ParamType,
+                                 PUCHAR pData,
+                                 ULONG Length
+                                 )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       Param.paramLength = Length;
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       NdisMoveMemory(pData, Param.content.pCountryString, Length);
+
+       return Status;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetRegDomainBand
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetRegDomainBand(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       externalParam_e ParamType,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       Param.paramLength = Length;
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = (ULONG) *(PUCHAR)&Param.content;
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetPacketBursting
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetPacketBursting(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        externalParam_e ParamType,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+       Param.paramLength = Length;
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = (ULONG)Param.content.qosPacketBurstEnb;
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetMixedMode
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetMixedMode(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               externalParam_e ParamType,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = (ULONG)Param.content.rsnMixedMode;
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetDefaultKeyId
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetDefaultKeyId(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  externalParam_e ParamType,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = ParamType;
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = (ULONG)Param.content.rsnDefaultKeyID;
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSetTrafficIntensityThresholds
+Routine Description: Sets the traffic intensity thresholds
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilSetTrafficIntensityThresholds(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter,CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD , pData, Length);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetTrafficIntensityThresholds
+Routine Description: retrieves the traffic intensity thresholds
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetTrafficIntensityThresholds(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD, pData, (*Length));
+       *Length = sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilToggleTrafficIntensityEvents
+Routine Description: Toggles ON/OFF traffic intensity events
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilToggleTrafficIntensityEvents(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter,CTRL_DATA_TOGGLE_TRAFFIC_INTENSITY_EVENTS , pData, Length);
+       return retValue;
+}
+
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:
+
+       UtilSetBSSID
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilSetBSSID(
+                       PTIWLN_ADAPTER_T pAdapter,
+                       PUCHAR pData,
+                       ULONG Length
+                       )
+{
+       return UtilSetParam(pAdapter, SITE_MGR_DESIRED_BSSID_PARAM, pData, ETH_ADDR_SIZE);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetBSSID
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetBSSID(
+                       PTIWLN_ADAPTER_T pAdapter,
+                       PUCHAR pData,
+                       PULONG Length
+                       )
+{
+       TI_STATUS res;
+
+       if (!Length)
+               return NOK;
+
+       res = UtilGetParam(pAdapter, CTRL_DATA_CURRENT_BSSID_PARAM, pData, ETH_ADDR_SIZE);
+
+       *Length = ETH_ADDR_SIZE;
+
+       return res;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetSSID
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetSSID(
+                  PTIWLN_ADAPTER_T pAdapter,
+                  PUCHAR pData,
+                  PULONG Length
+                  )
+{
+       ULONG size;
+       ssid_t ssid;
+       OS_802_11_SSID* RetSsid;
+
+       if (*Length<sizeof(OS_802_11_SSID))
+               return NOK;
+
+       size = sizeof(ssid_t);
+       UtilGetParam(pAdapter, SITE_MGR_CURRENT_SSID_PARAM, (PUCHAR)&ssid, size);
+
+       RetSsid = (OS_802_11_SSID*) pData;
+
+       RetSsid->SsidLength = ssid.len;
+       NdisMoveMemory((void *)RetSsid->Ssid, (void *)ssid.ssidString, ssid.len);
+
+       *Length = sizeof(OS_802_11_SSID);
+
+       return OK;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetDesiredSSID
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetDesiredSSID(
+                                 PTIWLN_ADAPTER_T pAdapter,
+                                 PUCHAR pData,
+                                 PULONG Length
+                                 )
+{
+       ULONG size,retValue;
+       ssid_t ssid;
+       OS_802_11_SSID* RetSsid;
+
+       if (!(*Length))
+       {
+               *Length = sizeof(OS_802_11_SSID);
+               return NOK;
+       }
+
+       size = sizeof(ssid_t);
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_SSID_PARAM, (PUCHAR)&ssid, size);
+
+       RetSsid = (OS_802_11_SSID*) pData;
+
+       RetSsid->SsidLength = ssid.len;
+       NdisMoveMemory((void *)RetSsid->Ssid, (void *)ssid.ssidString, ssid.len);
+
+       *Length = sizeof(OS_802_11_SSID);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSetSSID
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilSetSSID(
+                  PTIWLN_ADAPTER_T pAdapter,
+                  PUCHAR pData,
+                  ULONG Length
+                  )
+{
+       OS_802_11_SSID* UtilSsid;
+       ssid_t ssid;
+
+       UtilSsid = (OS_802_11_SSID*) pData;
+
+       if (UtilSsid->SsidLength<=MAX_SSID_LEN)
+       {
+               ssid.len = (UINT8)UtilSsid->SsidLength;
+
+               NdisMoveMemory((void *)ssid.ssidString, (void *)UtilSsid->Ssid, ssid.len);
+
+               /* The driver should support setting the SSID to NULL string */
+               if (ssid.len == 0)
+                       ssid.ssidString[0] = '\0';
+
+#ifdef TI_DBG
+               {    
+                       UCHAR   tempName[33];
+
+                       NdisMoveMemory(tempName, (void *)UtilSsid->Ssid, ssid.len);
+                       tempName[ssid.len] ='\0';
+
+                       PRINTF(DBG_NDIS_OIDS_LOUD, ("  SET SSID: Len=%d %s\n", ssid.len, tempName));
+               }
+#endif
+
+               UtilSetParam(pAdapter, SITE_MGR_DESIRED_SSID_PARAM, (PUCHAR)&ssid, sizeof(ssid_t));
+       }
+
+       return OK;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilNetworkTypesSupported
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilNetworkTypesSupported(
+                                                PTIWLN_ADAPTER_T pAdapter,
+                                                PUCHAR pData,
+                                                PULONG Length
+                                                )
+{
+       OS_802_11_NETWORK_TYPE_LIST * pList;
+       ULONG mode, size;
+
+       UtilGetParam(pAdapter, SITE_MGR_DESIRED_DOT11_MODE_PARAM, 
+                                                       (PUCHAR)&mode, sizeof(ULONG));
+
+       if (!(*Length))
+       {
+
+               /**/
+               /* Return the maximum size*/
+               /**/
+               size = sizeof(OS_802_11_NETWORK_TYPE_LIST) +
+                          3 * sizeof(OS_802_11_NETWORK_TYPE) -
+                          sizeof(OS_802_11_NETWORK_TYPE);
+
+               *Length = size;
+               return NOK;
+
+       }
+
+       pList = (OS_802_11_NETWORK_TYPE_LIST *) pData;
+
+       switch (mode)
+       {
+       
+       case 1:
+               pList->NumberOfItems = 1;
+               pList->NetworkType[0] = os802_11DS;
+               break;
+
+       case 2:
+               pList->NumberOfItems = 1;
+               pList->NetworkType[0] = os802_11OFDM5;
+               break;
+
+       case 3:
+               pList->NumberOfItems = 2;
+               pList->NetworkType[0] = os802_11DS;
+               pList->NetworkType[1] = os802_11OFDM24;
+               break;
+
+       case 4:
+               pList->NumberOfItems = 3;
+               pList->NetworkType[0] = os802_11DS;
+               pList->NetworkType[1] = os802_11OFDM24;
+               pList->NetworkType[2] = os802_11OFDM5;
+               break;
+
+       default:
+               pList->NumberOfItems = 1;
+               pList->NetworkType[0] = os802_11DS;
+               break;
+       }
+
+       size = sizeof(OS_802_11_NETWORK_TYPE_LIST) +
+                  pList->NumberOfItems * sizeof(OS_802_11_NETWORK_TYPE) -
+                  sizeof(OS_802_11_NETWORK_TYPE);
+
+       *Length = size;
+       return OK;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilNetworkTypeInUseGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilNetworkTypeInUseGet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          PULONG Length
+                                          )
+{
+       ULONG mode;
+       if (!(*Length))
+       {
+
+               *Length = sizeof(OS_802_11_NETWORK_TYPE);
+               return NOK;
+
+       }
+
+       UtilGetParam(pAdapter, SITE_MGR_DESIRED_DOT11_MODE_PARAM, 
+                                (PUCHAR)&mode, sizeof(ULONG));
+
+       switch (mode)
+       {
+       
+       case 1:
+               *((OS_802_11_NETWORK_TYPE *) pData) = os802_11DS;
+               break;
+
+       case 2:
+               *((OS_802_11_NETWORK_TYPE *) pData) = os802_11OFDM5;
+               break;
+
+       case 3:
+               *((OS_802_11_NETWORK_TYPE *) pData) = os802_11OFDM24;
+               break;
+
+       case 4:
+               *((OS_802_11_NETWORK_TYPE *) pData) = os802_11Automode;
+               break;
+
+       default:
+               *((OS_802_11_NETWORK_TYPE *) pData) = os802_11DS;
+               break;
+
+       }
+
+       *Length = sizeof(OS_802_11_NETWORK_TYPE);
+       return OK;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilNetworkTypeInUseSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilNetworkTypeInUseSet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          ULONG Length
+                                          )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_DOT11_MODE_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSetPacketBursting
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilSetPacketBursting(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = QOS_PACKET_BURST_ENABLE;
+       Param.content.qosPacketBurstEnb = *((UINT8*)pData);
+       Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSetMixedMode
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilSetMixedMode(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       Param.paramType = RSN_MIXED_MODE;
+       Param.content.rsnMixedMode = *((UINT32*)pData);
+       Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerModeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerModeSet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       ULONG retValue;
+       PowerMgr_PowerMode_t PowerMgr_PowerMode;
+       PowerMgr_PowerMode.PowerMode = (PowerMgr_PowerMode_e)*pData;
+       PowerMgr_PowerMode.powerMngPriority = POWER_MANAGER_USER_PRIORITY;
+       retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_MODE,(PUCHAR)&PowerMgr_PowerMode, sizeof(PowerMgr_PowerMode));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerModeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerModeGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_MODE, pData, sizeof(PowerMgr_PowerMode_e));
+       *Length = sizeof(PowerMgr_PowerMode_e);
+       return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerLevelPSGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerLevelPSGet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_LEVEL_PS, pData, sizeof(powerAutho_PowerPolicy_e));
+       *Length = sizeof(powerAutho_PowerPolicy_e);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerLevelPSSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerLevelPSSet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_LEVEL_PS, pData, sizeof(powerAutho_PowerPolicy_e));
+       *Length = sizeof(powerAutho_PowerPolicy_e);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerLevelDefaultGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerLevelDefaultGet(
+                                               PTIWLN_ADAPTER_T pAdapter,
+                                               PUCHAR pData,
+                                               PULONG Length
+                                               )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_LEVEL_DEFAULT, pData, sizeof(powerAutho_PowerPolicy_e));
+       *Length = sizeof(powerAutho_PowerPolicy_e);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerLevelDefaultSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerLevelDefaultSet(
+                                               PTIWLN_ADAPTER_T pAdapter,
+                                               PUCHAR pData,
+                                               PULONG Length
+                                               )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_LEVEL_DEFAULT, pData, sizeof(powerAutho_PowerPolicy_e));
+       *Length = sizeof(powerAutho_PowerPolicy_e);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerLevelDozeModeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerLevelDozeModeGet(
+    PTIWLN_ADAPTER_T pAdapter,
+    PUCHAR pData,
+    PULONG Length
+    )
+{
+   ULONG retValue;
+   retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_LEVEL_DOZE_MODE, pData, sizeof(PowerMgr_PowerMode_e));
+   *Length = sizeof(PowerMgr_PowerMode_e);
+   return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPowerLevelDozeModeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPowerLevelDozeModeSet(
+    PTIWLN_ADAPTER_T pAdapter,
+    PUCHAR pData,
+    PULONG Length
+    )
+{
+   ULONG retValue;
+   retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_LEVEL_DOZE_MODE, pData, sizeof(PowerMgr_PowerMode_e));
+   *Length = sizeof(PowerMgr_PowerMode_e);
+   return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilBeaconFilterDesiredStateSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBeaconFilterDesiredStateSet(
+                                                          PTIWLN_ADAPTER_T pAdapter,
+                                                          PUCHAR pData,
+                                                          PULONG Length
+                                                          )
+{
+       ULONG retValue;
+
+       retValue = UtilSetParam(pAdapter, SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM, pData, sizeof(UINT8));
+       *Length = sizeof(UINT8);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilBeaconFilterDesiredStateGet
+Routine Description: gets the current beacon filter state
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBeaconFilterDesiredStateGet(
+                                                          PTIWLN_ADAPTER_T pAdapter,
+                                                          PUCHAR pData,
+                                                          PULONG Length
+                                                          )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM, pData, sizeof(UINT8));
+       *Length = sizeof(UINT8);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilBssidListGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBssidListGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length,
+                               BOOLEAN ExtBssid,
+                               BOOLEAN allVarIes
+                               )
+{
+       OS_802_11_BSSID_LIST_EX* pListEx;
+       OS_802_11_BSSID_EX* pBssidEx;
+       OS_802_11_BSSID* pBssid;
+       OS_802_11_BSSID_LIST* pList;
+       paramInfo_t Param;
+       ULONG RetSize, i;
+       TI_STATUS Status;
+       PUCHAR pTempData=NULL;
+       ULONG LocalLength = sizeof(OS_802_11_BSSID_LIST_EX)+NUM_OF_SITE_TABLE*MAX_SITES_BG_BAND*sizeof(OS_802_11_BSSID);
+
+
+       /******  At the callback of RSSI update the RSSI in the Site TAble in the Site Manager *
+        Update Site Table in order to represent the RSSI of current AP correctly in the utility 
+       param.paramType = SITE_MGR_CURRENT_SIGNAL_PARAM;
+       param.content.siteMgrCurrentSignal.rssi = pCurrBSS->averageRssi;
+       siteMgr_setParam(pCurrBSS->hSiteMgr, &param);
+       ***************************************/
+
+
+       if (allVarIes)
+       {
+               Param.paramType = SITE_MGR_BSSID_FULL_LIST_PARAM;
+       } else
+       {
+               Param.paramType = SITE_MGR_BSSID_LIST_PARAM;
+       }
+
+       if (ExtBssid)
+       {
+               *(PULONG)&Param.content = (ULONG)pData;
+               Param.paramLength = *Length;
+       } else
+       {
+               if (*Length)
+               {
+                       pTempData = os_memoryAlloc(pAdapter, LocalLength);
+
+                       if (!pTempData)
+                       {
+                               *(PULONG)pData = LocalLength;
+                               *Length = 0;
+                               return NOK;
+                       }
+
+                       *(PULONG)&Param.content = (ULONG)pTempData;
+                       Param.paramLength = *Length;
+               } else
+               {
+                       *Length = LocalLength;
+                       return NOK;
+               }
+       }
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       if (!(*Length))
+       {
+
+               *Length = Param.paramLength * 4;
+               return NOK;
+
+       }
+
+       if (Status != OK)
+       {
+               *(PULONG)pData = Param.paramLength;
+               PRINT(DBG_IOCTL_LOUD, "...More buffer space needed\n");
+               if (!ExtBssid)
+                       os_memoryFree(pAdapter, pTempData, LocalLength);
+
+               *Length = 0;
+               return NOK;
+
+       }
+
+       if (!ExtBssid)
+       {
+
+               pListEx = (OS_802_11_BSSID_LIST_EX*) pTempData;
+
+               if (pListEx->NumberOfItems)
+               {
+
+                       if ((sizeof(OS_802_11_BSSID_LIST) + 
+                                sizeof(OS_802_11_BSSID)*pListEx->NumberOfItems - 
+                                sizeof(OS_802_11_BSSID)) > *Length)
+                       {
+                               PRINT(DBG_IOCTL_LOUD, "Utility buffer is too small\n");
+                               os_memoryFree(pAdapter, pTempData, LocalLength);
+                               *Length = 0;
+                               return NOK;
+                       }
+            if (pListEx->NumberOfItems > 
+                ((0xFFFFFFFFUL - ((ULONG)sizeof(OS_802_11_BSSID_LIST) - 1)) / 
+                 (ULONG)sizeof(OS_802_11_BSSID) + 1)) /* Dm: Security fix */
+            {
+                printk("TI: %s - Security Error\n", __FUNCTION__);
+                PRINT(DBG_IOCTL_LOUD, "Number of AP is too big\n");
+                os_memoryFree(pAdapter, pTempData, LocalLength);
+                *Length = 0;
+                return NOK;
+            }
+
+            pList = (OS_802_11_BSSID_LIST *)pData;
+                       pList->NumberOfItems = pListEx->NumberOfItems;
+
+                       *Length = RetSize = sizeof(OS_802_11_BSSID_LIST) + 
+                                         sizeof(OS_802_11_BSSID)*pList->NumberOfItems - 
+                                         sizeof(OS_802_11_BSSID);
+
+                       pBssidEx = pListEx->Bssid;
+
+                       for (i=0; i<pListEx->NumberOfItems; i++)
+                       {
+
+                               pBssid = (OS_802_11_BSSID*) pBssidEx;
+
+                               NdisMoveMemory(&pList->Bssid[i], pBssid,
+                                                          sizeof(OS_802_11_BSSID));
+
+                               pList->Bssid[i].Length = sizeof(OS_802_11_BSSID);
+
+                               pBssidEx = (OS_802_11_BSSID_EX*) ((PUCHAR)pBssidEx + 
+                                                                                                 pBssidEx->Length);
+
+                       }
+
+               }
+
+               else
+               {
+
+                       pList = (OS_802_11_BSSID_LIST*) pData;
+                       pList->NumberOfItems = 0;
+
+                       RetSize = sizeof(OS_802_11_BSSID_LIST);
+                       *Length = RetSize;
+
+               }
+
+               PRINT(DBG_IOCTL_LOUD, "...Copy done.\n");
+
+               os_memoryFree(pAdapter, pTempData, LocalLength);
+
+       }
+
+       else
+       {
+
+               RetSize = Param.paramLength;
+               *Length = RetSize;
+
+       }
+
+       return OK;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilStartAppScanSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilStartAppScanSet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  ULONG Length
+                                  )
+{
+       ULONG retValue;              
+       /* scan concentrator will start an application scan */
+       retValue = UtilSetParam(pAdapter, SCAN_CNCN_START_APP_SCAN, (PUCHAR)&pData, sizeof(PUCHAR));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilStopAppScanSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilStopAppScanSet(
+                                 PTIWLN_ADAPTER_T pAdapter,
+                                 PUCHAR pData,
+                                 ULONG Length
+                                 )
+{
+       ULONG retValue;
+       /* scan concentrator will stop the running application scan (if any) */
+       retValue = UtilSetParam(pAdapter, SCAN_CNCN_STOP_APP_SCAN, NULL, 0);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilScanPolicyParamSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilScanPolicyParamSet(
+                                         PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         ULONG Length
+                                         )
+{
+       ULONG retValue;
+
+       applicationConfigBuffer_t applicationConfigBuffer;
+
+       applicationConfigBuffer.buffer = pData;
+       applicationConfigBuffer.bufferSize = (UINT16)Length;
+
+       /* set the scan manager policy */
+       retValue = UtilSetParam( pAdapter, SCAN_MNGR_SET_CONFIGURATION, (PUCHAR)&applicationConfigBuffer, sizeof(applicationConfigBuffer_t) );
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilScanBssListGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilScanBssListGet(
+                                 PTIWLN_ADAPTER_T pAdapter,
+                                 PUCHAR pData,
+                                 PULONG Length
+                                 )
+{
+       paramInfo_t param;
+       TI_STATUS status;
+
+       param.paramType = SCAN_MNGR_BSS_LIST_GET;
+       param.paramLength = sizeof(PUCHAR);
+
+       status = configMgr_getParam(pAdapter->CoreHalCtx, &param);
+
+       NdisMoveMemory( pData, param.content.pScanBssList, *Length );
+       *Length = sizeof(bssList_t);
+
+       return status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilBssidListScanOid
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBssidListScanOid(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       TI_STATUS Status;
+//TRS: Scan changes from TI
+    Status = UtilSetParam(pAdapter, SCAN_CNCN_BSSID_LIST_SCAN_PARAM, pData, 0);
+//TRS: end of Scan changes from TI
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilInfrastructureModeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilInfrastructureModeGet(
+                                                PTIWLN_ADAPTER_T pAdapter,
+                                                PUCHAR pData,
+                                                PULONG Length
+                                                )
+{ 
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_CURRENT_BSS_TYPE_PARAM, pData, sizeof(bssType_e));
+       *Length = sizeof(ULONG);
+       return(retValue);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilDesiredInfrastructureModeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDesiredInfrastructureModeGet(
+                                                               PTIWLN_ADAPTER_T pAdapter,
+                                                               PUCHAR pData,
+                                                               PULONG Length
+                                                               )
+{ 
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_BSS_TYPE_PARAM, pData, sizeof(bssType_e));
+
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilInfrastructureModeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilInfrastructureModeSet(
+                                                PTIWLN_ADAPTER_T pAdapter,
+                                                PUCHAR pData,
+                                                ULONG Length
+                                                )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_BSS_TYPE_PARAM, pData, sizeof(bssType_e));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilFragmentationThresholdGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilFragmentationThresholdGet(
+                                                        PTIWLN_ADAPTER_T pAdapter,
+                                                        PUCHAR pData,
+                                                        PULONG Length
+                                                        )
+{
+       UINT16 FragThreshold;
+       ULONG retValue;
+
+       if (!Length)
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, HAL_CTRL_FRAG_THRESHOLD_PARAM, pData, sizeof(ULONG));
+
+       FragThreshold = *(PUINT16)pData;
+       *(PULONG)pData = FragThreshold;
+
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilFragmentationThresholdSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilFragmentationThresholdSet(
+                                                        PTIWLN_ADAPTER_T pAdapter,
+                                                        PUCHAR pData,
+                                                        ULONG Length
+                                                        )
+{
+       UINT16 FragThreshold = (UINT16) *(PULONG)pData;
+       ULONG retValue;
+
+       FragThreshold = ((FragThreshold+1)>>1) << 1; /*make it always even(GreenA)*/
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_FRAG_THRESHOLD_PARAM, (PUCHAR)&FragThreshold, sizeof(UINT16));
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRtsThresholdGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRtsThresholdGet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       UINT16 RtsThreshold;
+       ULONG retValue;
+
+       if (!Length)
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, HAL_CTRL_RTS_THRESHOLD_PARAM, pData, sizeof(ULONG));
+
+       RtsThreshold = *(PUINT16)pData;
+       *(PULONG)pData = RtsThreshold;
+       *Length = sizeof (ULONG);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSupportedRates
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilSupportedRates(
+                                 PTIWLN_ADAPTER_T pAdapter,
+                                 PUCHAR pData,
+                                 PULONG Length
+                                 )
+{
+       rates_t rateSet;
+       ULONG retValue;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM, (PUCHAR)&rateSet, sizeof(rates_t));
+
+       NdisMoveMemory(pData, (PUCHAR)&rateSet, *Length);
+       *Length = rateSet.len +1; /* 1 is added for the length field itself */
+
+       return retValue; 
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilSupportedRatesSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilSupportedRatesSet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       rates_t rateSet;
+       ULONG retValue;
+
+       NdisMoveMemory(&rateSet, pData, Length);
+
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM, (PUCHAR)&rateSet, sizeof(rates_t));
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRtsThresholdSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRtsThresholdSet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  ULONG Length
+                                  )
+{
+       UINT16 RtsThreshold = (UINT16) *(PULONG)pData;
+       ULONG retValue;
+
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_RTS_THRESHOLD_PARAM, 
+                                                       (PUCHAR)&RtsThreshold, sizeof(UINT16));
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilChannelGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilChannelGet(
+                         PTIWLN_ADAPTER_T pAdapter,
+                         PUCHAR pData,
+                         PULONG Length
+                         )
+{
+       ULONG Channel,retValue; 
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_CHANNEL_PARAM, pData, sizeof(ULONG));
+
+       Channel = *(PUCHAR)pData;
+       *(PULONG)pData = (ULONG) Channel;
+       *Length = sizeof (ULONG);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilDesiredChannelGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDesiredChannelGet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        PULONG Length
+                                        )
+{
+       ULONG Channel,retValue; 
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_CHANNEL_PARAM, pData, sizeof(ULONG));
+
+       Channel = *(PUCHAR)pData;
+       *(PULONG)pData = (ULONG) Channel;
+       *Length = sizeof (ULONG);
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilDesiredChannelSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDesiredChannelSet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       UINT8 Channel = *pData;
+       ULONG retValue;
+
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_CHANNEL_PARAM, &Channel, sizeof(UCHAR));
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilShortPreambleGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilShortPreambleGet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       PULONG Length
+                                       )
+{
+       ULONG retValue;
+       if (!Length)
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM, pData, sizeof(ULONG));
+
+       *Length = sizeof (ULONG);
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilShortPreambleSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilShortPreambleSet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM, 
+                                                       pData, sizeof(ULONG));
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_enableDisable_802_11d
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_enableDisable_802_11d(
+                                                                                 PTIWLN_ADAPTER_T pAdapter,
+                                                                                 PUCHAR pData,
+                                                                                 ULONG Length
+                                                                                 )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_ENABLE_DISABLE_802_11D, pData, sizeof(UINT8));
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_enableDisable_802_11h
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_enableDisable_802_11h(
+                                                                                 PTIWLN_ADAPTER_T pAdapter,
+                                                                                 PUCHAR pData,
+                                                                                 ULONG Length
+                                                                                 )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_ENABLE_DISABLE_802_11H, pData, sizeof(UINT8));
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_Get_802_11d
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_Get_802_11d(
+                                                               PTIWLN_ADAPTER_T pAdapter,
+                                                               PUCHAR pData,
+                                                               PULONG Length
+                                                               )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_ENABLED_PARAM, pData, sizeof(UINT8));
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_Get_802_11h
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_Get_802_11h(
+                                                               PTIWLN_ADAPTER_T pAdapter,
+                                                               PUCHAR pData,
+                                                               PULONG Length
+                                                               )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM, pData, sizeof(UINT8));
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_setCountryIE
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+static TI_STATUS
+UtilRegulatoryDomain_setCountryIE(
+                                                                PTIWLN_ADAPTER_T pAdapter,
+                                                                externalParam_e ParamType,
+                                                                PUCHAR pData,
+                                                                ULONG Length
+                                                                )
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+       country_t  countryIe;
+
+       Param.paramType = ParamType;
+       Param.paramLength = sizeof(country_t);
+       NdisMoveMemory(&countryIe, pData, Length);
+
+       Param.content.pCountry = &countryIe;
+       Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_setCountryIE_2_4
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_setCountryIE_2_4(
+                                                                        PTIWLN_ADAPTER_T pAdapter,
+                                                                        PUCHAR pData,
+                                                                        ULONG Length)
+{
+       ULONG retValue;
+
+       retValue = UtilRegulatoryDomain_setCountryIE(pAdapter, REGULATORY_DOMAIN_COUNTRY_2_4_PARAM, pData, sizeof(country_t));
+
+       return retValue;
+
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_getCountryIE_2_4
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_getCountryIE_2_4(
+                                                                        PTIWLN_ADAPTER_T pAdapter,
+                                                                        PUCHAR pData,
+                                                                        PULONG Length
+                                                                        )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_COUNTRY_2_4_PARAM, pData, COUNTRY_STRING_LEN);
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_setCountryIE_5
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_setCountryIE_5(
+                                                                  PTIWLN_ADAPTER_T pAdapter,
+                                                                  PUCHAR pData,
+                                                                  ULONG Length
+                                                                  )
+{
+       ULONG retValue;
+       retValue = UtilRegulatoryDomain_setCountryIE(pAdapter, REGULATORY_DOMAIN_COUNTRY_5_PARAM, pData, sizeof(country_t));
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_getCountryIE_5
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_getCountryIE_5(
+                                                                  PTIWLN_ADAPTER_T pAdapter,
+                                                                  PUCHAR pData,
+                                                                  PULONG Length
+                                                                  )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_COUNTRY_5_PARAM, pData, COUNTRY_STRING_LEN);
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_setMinMaxDfsChannels
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_setMinMaxDfsChannels(
+    PTIWLN_ADAPTER_T pAdapter,
+    PUCHAR pData,
+    ULONG Length
+    )
+{
+    ULONG retValue;
+
+    retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_DFS_CHANNELS_RANGE, pData, sizeof(DFS_ChannelRange_t));
+
+    return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRegulatoryDomain_getMinMaxDfsChannels
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRegulatoryDomain_getMinMaxDfsChannels(
+    PTIWLN_ADAPTER_T pAdapter,
+    PUCHAR pData,
+    PULONG Length
+    )
+{
+    ULONG retValue;
+    retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_DFS_CHANNELS_RANGE, pData, sizeof(DFS_ChannelRange_t));
+
+    return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilShortRetryGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilShortRetryGet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                PULONG Length
+                                )
+
+{
+       ULONG retValue;
+
+
+       txRatePolicy_t  TxRatePolicy;
+       /*
+        * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+        */
+
+
+       if (!Length)
+               return sizeof(ULONG);
+
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_SHORT_RETRY_LIMIT_PARAM, 
+                                                       (PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
+
+       *(PULONG)pData = TxRatePolicy.rateClass[0].shortRetryLimit;
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilShortRetrySet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilShortRetrySet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG retValue;
+       txRatePolicy_t  TxRatePolicy;
+
+       /*
+        * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+        */
+
+
+       TxRatePolicy.rateClass[0].shortRetryLimit = (UINT8) *(PULONG)pData;
+
+       retValue = UtilSetParam(pAdapter, CTRL_DATA_SHORT_RETRY_LIMIT_PARAM, 
+                                                       (PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
+
+       return retValue ;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilLongRetryGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilLongRetryGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       ULONG retValue;
+       txRatePolicy_t  TxRatePolicy;
+       /*
+        * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+        */
+
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_LONG_RETRY_LIMIT_PARAM, 
+                                                       (PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
+
+       *(PULONG)pData = TxRatePolicy.rateClass[0].longRetryLimit;
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilLongRetrySet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilLongRetrySet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       txRatePolicy_t  TxRatePolicy;
+       ULONG retValue;
+
+       /*
+        * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
+        */
+
+
+       TxRatePolicy.rateClass[0].longRetryLimit = (UINT8) *(PULONG)pData;
+
+       retValue = UtilSetParam(pAdapter, CTRL_DATA_SHORT_RETRY_LIMIT_PARAM, 
+                                                       (PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
+
+       return retValue;
+}
+/*-----------------------------------------------------------------------------*/
+ULONG
+UtilDesiredRatesGet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       UCHAR rate;
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_TX_RATE_PARAM, (PUCHAR)&rate, sizeof(UCHAR));
+
+       *Length = sizeof(UCHAR);
+       *(PUCHAR)pData = rate;
+
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilCurrentRatesGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilCurrentRatesGet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       UCHAR rate;
+       ULONG retValue;
+
+       rate = (UCHAR) *(PULONG)pData;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_TX_RATE_PARAM, (PUCHAR)&rate, sizeof(UCHAR));
+       *(PUCHAR)pData = rate;
+       *Length = sizeof(UCHAR);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilConfigurationGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilConfigurationGet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       PULONG Length
+                                       )
+{
+       paramInfo_t Param;
+       ULONG retValue;
+
+       if (!Length)
+       {
+               *Length = sizeof(OS_802_11_CONFIGURATION);
+               return NOK;
+       }
+
+       Param.paramType = SITE_MGR_CONFIGURATION_PARAM;
+       Param.paramLength = *Length;
+       *(PULONG)&Param.content = (ULONG)pData;
+
+       retValue = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *Length = sizeof(OS_802_11_CONFIGURATION);
+
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilConfigurationSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilConfigurationSet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       paramInfo_t Param;
+       ULONG retValue;
+
+       Param.paramType = SITE_MGR_CONFIGURATION_PARAM;
+       Param.paramLength = Length;
+       *(PULONG)&Param.content = (ULONG)pData;
+
+       retValue = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetCounter
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetCounter(
+                         PTIWLN_ADAPTER_T pAdapter,
+                         PUCHAR pData,
+                         ULONG Offset
+                         )
+{
+       TIWLN_COUNTERS TiCounters;
+
+       UtilGetParam(pAdapter, SITE_MGR_TI_WLAN_COUNTERS_PARAM, 
+                                (PUCHAR)&TiCounters, sizeof(TIWLN_COUNTERS));
+
+       NdisMoveMemory(pData, (PUCHAR)&TiCounters + Offset, sizeof(ULONG));
+
+       return sizeof(ULONG);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilStatistics
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilStatistics(
+                         PTIWLN_ADAPTER_T pAdapter,
+                         PUCHAR pData,
+                         PULONG Length
+                         )
+{
+       TIWLN_STATISTICS* pStats;
+       paramInfo_t Param;
+       ULONG RetSize, data,retValue,dataSize;
+
+
+    if (*Length >= sizeof(TIWLN_STATISTICS)) //TRS:GAA allow larger than needed buffer
+       {
+               pStats = (TIWLN_STATISTICS *) pData;
+               NdisZeroMemory(pStats, sizeof(TIWLN_STATISTICS));
+
+               RetSize = sizeof(TIWLN_STATISTICS);
+
+               NdisMoveMemory(&pStats->currentMACAddress, pAdapter->CurrentAddr, ETH_ADDR_SIZE);
+
+               dataSize = sizeof(tiUINT32);
+               if ((retValue = UtilPowerModeGet(pAdapter, (PUCHAR)&pStats->PowerMode, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(OS_802_11_SSID);
+               if ((retValue = UtilGetSSID(pAdapter, (PUCHAR)&pStats->dot11DesiredSSID, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(UINT32);
+               if ((retValue = UtilChannelGet(pAdapter, (PUCHAR)&pStats->dot11CurrentChannel, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilExtAuthenticationModeGet(pAdapter, (PUCHAR)&pStats->AuthenticationMode, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilRtsThresholdGet(pAdapter, (PUCHAR)&pStats->RTSThreshold,    &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilFragmentationThresholdGet(pAdapter, (PUCHAR)&pStats->FragmentationThreshold, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+        if ((retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, 
+                                                                       (PUCHAR)&pStats->TxPowerDbm, dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilInfrastructureModeGet(pAdapter, (PUCHAR)&pStats->dot11BSSType, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilWepStatusGet(pAdapter, (PUCHAR)&pStats->WEPStatus, &dataSize)) != OK)
+                       return retValue;
+
+               if ((retValue = UtilGetParam(pAdapter, SITE_MGR_CONNECTION_STATUS_PARAM, (PUCHAR)&pStats->dot11State, sizeof(ULONG))) != OK)
+                       return retValue;
+
+               pStats->dot11CurrentTxRate = pAdapter->LinkSpeed/5000;
+
+               if ((retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_PREAMBLE_TYPE_PARAM, (PUCHAR)&data, sizeof(ULONG))) != OK)
+                       return retValue;
+
+               pStats->bShortPreambleUsed = (BOOLEAN) data;
+
+               Param.paramType = SITE_MGR_GET_SELECTED_BSSID_INFO;
+               Param.content.pSiteMgrPrimarySiteDesc = &pStats->targetAP;
+               if ((retValue = configMgr_getParam(pAdapter->CoreHalCtx, &Param)) != OK)
+                       return retValue;
+
+               PRINTF(DBG_IOCTL_LOUD, ("...RSSI: %d\n", pStats->targetAP.Rssi));
+               pStats->RxLevel = pStats->targetAP.Rssi;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilTxAntennaGet(pAdapter, (PUCHAR)&pStats->TxAntenna, &dataSize)) != OK)
+                       return retValue;
+
+               dataSize = sizeof(ULONG);
+               if ((retValue = UtilRxAntennaGet(pAdapter, (PUCHAR)&pStats->RxAntenna, &dataSize)) != OK)
+                       return retValue;
+
+#ifdef EXC_MODULE_INCLUDED             
+               dataSize = sizeof(BOOL);
+               if ((retValue = UtilExcNetworkEapGet(pAdapter, (PUCHAR)&pStats->dwSecuritySuit, &dataSize)) != OK)
+                       return retValue;
+               if ((pStats->dwSecuritySuit==OS_EXC_NETWORK_EAP_ON) && (pStats->WEPStatus==os802_11WEPEnabled))
+               {
+                       pStats->dwSecuritySuit = TIWLN_STAT_SECURITY_RESERVE_1;
+               } else
+#else
+               {
+                       pStats->dwSecuritySuit = 0;
+               }
+#endif
+               if ((retValue = UtilGetParam(pAdapter, RSN_SECURITY_STATE_PARAM, (PUCHAR)&pStats->dwSecurityState, sizeof(ULONG))) != OK)
+                       return retValue;
+
+               pStats->dwSecurityAuthStatus = 0;
+               pStats->dwFeatureSuit = 0;
+
+               if ((retValue = UtilGetParam(pAdapter, SITE_MGR_TI_WLAN_COUNTERS_PARAM, (PUCHAR)&pStats->tiCounters, sizeof(TIWLN_COUNTERS))) != OK)
+                       return retValue;
+
+        if ((retValue = UtilGetParam(pAdapter, MLME_BEACON_RECV, (PUCHAR)&pStats->tiCounters, sizeof(TIWLN_COUNTERS))) != OK)
+                       return retValue;
+       }
+
+       else
+       {
+
+               NdisZeroMemory(pData, *Length);
+               *Length = 0;
+               return NOK;
+
+       }
+
+       *Length = RetSize;
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilTxStatistics
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilTxStatistics(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG inLength,
+                               PULONG outLength
+                               )
+{
+       ULONG retValue;
+       txDataCounters_t  *pTxDataCounters;
+       UINT32 resetStatsFlag;
+
+       if (*outLength == sizeof(TIWLN_TX_STATISTICS))
+       {
+               /* check whether statistics clear is also requested */
+               resetStatsFlag = *pData;
+
+               /* note that only the pointer (by reference!) is passed to UtilGetParam, and the actual copying of data
+                  is done here */
+               if ((retValue = UtilGetParam( pAdapter, TX_DATA_COUNTERS_PARAM, 
+                                                                         (PUCHAR)&pTxDataCounters, sizeof(txDataCounters_t*))) != OK)
+                       return retValue;
+
+               NdisMoveMemory( pData, pTxDataCounters, sizeof(TIWLN_TX_STATISTICS) );
+
+               *outLength = sizeof(TIWLN_TX_STATISTICS);
+
+               if ( 1 == resetStatsFlag )
+               {
+                       UtilSetParam( pAdapter, TX_DATA_RESET_COUNTERS_PARAM, NULL, 0 );
+               }
+       } else
+       {
+               NdisZeroMemory(pData, *outLength);
+               *outLength = 0;
+               return NOK;
+       }
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilAddWep
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilAddWep(
+                 PTIWLN_ADAPTER_T pAdapter,
+                 PUCHAR pData,
+                 ULONG Length,
+                 BOOLEAN CalledFromIoctl
+                 )
+{
+       OS_802_11_WEP* pWep;
+       OS_802_11_KEY  key;
+       UINT32         keyIndexTxRx;
+       TI_STATUS Status;
+
+       pWep = (OS_802_11_WEP*) pData;
+
+       if ((pWep->KeyIndex & 0x3FFFFFFF) > 3)
+       {
+               return 0;
+       }
+
+       if (CalledFromIoctl)
+       {
+               NdisMoveMemory(&pAdapter->DefaultWepKeys[pWep->KeyIndex & 0x3FFFFFFF],
+                                          pWep, sizeof(OS_802_11_WEP));
+       }
+       key.Length = pWep->Length;
+       /* Convert the Key index to match OS_802_11_KEY index */
+
+       keyIndexTxRx = (pWep->KeyIndex & 0x80000000); 
+
+       key.KeyIndex = keyIndexTxRx | /*(keyIndexTxRx>>1) |*/ 
+                                  (pWep->KeyIndex & 0x3FFFFFFF);
+
+       key.KeyLength = pWep->KeyLength;  
+
+    if( pWep->KeyLength > sizeof(key.KeyMaterial) ) { /* Dm: Security fix */
+        printk("TI: %s - Security Error\n", __FUNCTION__);
+        return EXTERNAL_SET_PARAM_DENIED;
+    }
+
+       NdisMoveMemory(key.KeyMaterial, (void *)pWep->KeyMaterial, pWep->KeyLength);
+       /* Set the MAC Address to zero for WEP */
+       NdisZeroMemory(key.BSSID, sizeof(key.BSSID));
+
+       Status = UtilSetParam(pAdapter, RSN_ADD_KEY_PARAM, 
+                                                 (PUCHAR)&key, sizeof(OS_802_11_KEY));
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRemoveWep
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRemoveWep(
+                        PTIWLN_ADAPTER_T pAdapter,
+                        PUCHAR pData,
+                        ULONG Length
+                        )
+{
+       UINT32          keyIndex;
+       OS_802_11_KEY  key;
+       TI_STATUS Status;
+
+       keyIndex = *(UINT32*)pData;
+
+       /* Convert the Key index to match OS_802_11_KEY index */
+       NdisZeroMemory(&key, sizeof(OS_802_11_KEY));
+
+       key.KeyIndex = keyIndex;
+
+       Status = UtilSetParam(pAdapter, RSN_REMOVE_KEY_PARAM, 
+                                                 (PUCHAR)&key, sizeof(OS_802_11_KEY));
+
+       return(Status);
+}
+
+
+#define ADD_KEY_HEADER_LENGTH 26
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilAddKey
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilAddKey(
+                 PTIWLN_ADAPTER_T pAdapter,
+                 PUCHAR pData,
+                 ULONG Length
+                 )
+{   
+       TI_STATUS   status;
+       OS_802_11_KEY* pKey;
+
+       pKey = (OS_802_11_KEY*) pData;
+
+       status = UtilSetParam(pAdapter, RSN_ADD_KEY_PARAM, pData, pKey->Length);
+
+       return status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRemoveKey
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRemoveKey(
+                        PTIWLN_ADAPTER_T pAdapter,
+                        PUCHAR pData,
+                        ULONG Length
+                        )
+{   
+       TI_STATUS               status;
+       OS_802_11_REMOVE_KEY    *pRemoveKey;
+       OS_802_11_KEY           key;
+
+       pRemoveKey = (OS_802_11_REMOVE_KEY*)pData;
+
+       key.KeyIndex = pRemoveKey->KeyIndex;
+       NdisMoveMemory(key.BSSID, (void *)pRemoveKey->BSSID, sizeof(key.BSSID));
+
+       status = UtilSetParam(pAdapter, RSN_REMOVE_KEY_PARAM, 
+                                                 (PUCHAR)&key, sizeof(OS_802_11_KEY));
+
+       return(status);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilExtAuthenticationModeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExtAuthenticationModeSet(
+                                                       PTIWLN_ADAPTER_T pAdapter,
+                                                       PUCHAR pData,
+                                                       ULONG Length
+                                                       )
+{       
+       ULONG retValue;
+
+       retValue = UtilSetParam(pAdapter, RSN_EXT_AUTHENTICATION_MODE, pData, sizeof(ULONG));
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilExtAuthenticationModeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExtAuthenticationModeGet(
+                                                       PTIWLN_ADAPTER_T pAdapter,
+                                                       PUCHAR pData,
+                                                       PULONG Length
+                                                       )
+{       
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, RSN_EXT_AUTHENTICATION_MODE, pData, sizeof(ULONG));
+
+       *Length = sizeof (ULONG);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: Util802CapabilityGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG Util802CapabilityGet(
+                                                 PTIWLN_ADAPTER_T pAdapter, 
+                                                 PUCHAR pData, 
+                                                 PULONG Length)
+{
+       OS_802_11_CAPABILITY         *capability_802_11;
+       rsnAuthEncrCapability_t       rsnAuthEncrCap;
+       OS_802_11_ENCRYPTION_STATUS   encrStatus = os802_11EncryptionDisabled;
+       ULONG                         neededLength = 0;
+       UINT                          i = 0;
+       paramInfo_t                   Param;
+       TI_STATUS                     status;
+
+       /* If length of the input buffer less than needed length, do nothing, */
+       /* return the needed length                                           */
+       neededLength = sizeof(OS_802_11_CAPABILITY) + 
+                                  (sizeof(OS_802_11_AUTH_ENCRYPTION) * (MAX_AUTH_ENCR_PAIR -1));
+
+       if (*Length < neededLength)
+       {
+               *Length = neededLength;
+               return NOK;
+       }
+
+       NdisZeroMemory (pData, neededLength);
+       capability_802_11  = (OS_802_11_CAPABILITY *)pData;
+
+       /* Fill Param fields and get the 802_11 capability information */
+       Param.paramType   = RSN_AUTH_ENCR_CAPABILITY;
+       Param.paramLength = neededLength;
+       Param.content.pRsnAuthEncrCapability = &rsnAuthEncrCap;
+
+       status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       if (status != OK)
+       {
+               /* return the default values only */
+               /* PMKIDs is 0, AUTH/Encr pairs is 1, Auth/Encr is OPEN/NONE (0/0) */
+               capability_802_11->Length     = sizeof(OS_802_11_CAPABILITY);
+               capability_802_11->Version    = OID_CAPABILITY_VERSION;
+               capability_802_11->NoOfPmKIDs = 0;
+               capability_802_11->NoOfAuthEncryptPairsSupported = 1;
+               capability_802_11->AuthEncryptionSupported[0].AuthModeSupported  = 
+               os802_11AuthModeOpen;
+               capability_802_11->AuthEncryptionSupported[0].EncryptionStatusSupported = 
+               os802_11EncryptionDisabled;
+
+
+               *Length = sizeof(OS_802_11_CAPABILITY);
+               return NOK;
+       }
+
+       /* Copy the received info to the OS_802_11_CAPABILITY needed format */
+       capability_802_11->Length     = neededLength;
+       capability_802_11->Version    = OID_CAPABILITY_VERSION;
+       capability_802_11->NoOfPmKIDs = rsnAuthEncrCap.NoOfPMKIDs;
+       capability_802_11->NoOfAuthEncryptPairsSupported = 
+       rsnAuthEncrCap.NoOfAuthEncrPairSupported;
+
+       /* Convert received cipher suite type to encr.status type */
+       for (i = 0; i < rsnAuthEncrCap.NoOfAuthEncrPairSupported; i ++)
+       {
+               capability_802_11->AuthEncryptionSupported[i].AuthModeSupported = 
+               (OS_802_11_AUTHENTICATION_MODE)rsnAuthEncrCap.authEncrPairs[i].authenticationMode;
+
+               switch (rsnAuthEncrCap.authEncrPairs[i].cipherSuite)
+               {
+               case RSN_CIPHER_NONE:
+                       encrStatus = os802_11EncryptionDisabled;
+                       break;
+
+               case RSN_CIPHER_WEP:
+                       encrStatus = os802_11WEPEnabled;
+                       break;
+
+               case RSN_CIPHER_TKIP:
+                       encrStatus = os802_11Encryption2Enabled;
+                       break;
+
+               case RSN_CIPHER_AES_CCMP:
+                       encrStatus = os802_11Encryption3Enabled;
+                       break;
+
+               default:
+                       encrStatus = os802_11EncryptionDisabled;
+                       break;
+
+               }
+               capability_802_11->AuthEncryptionSupported[i].EncryptionStatusSupported
+               = encrStatus;
+       }
+
+       /* Success; return the actual length of the written data */
+       *Length = neededLength;
+       return status;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802PmkidGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG Util802PmkidGet(
+                                        PTIWLN_ADAPTER_T pAdapter, 
+                                        PUCHAR pData, 
+                                        PULONG Length)
+{
+       OS_802_11_PMKID         *pPmkidList = (OS_802_11_PMKID *)pData;
+       TI_STATUS                status = NOK;
+
+       /* Check the data buffer size */
+       if (*Length < sizeof(OS_802_11_PMKID))
+       {
+               *Length = (sizeof(OS_802_11_PMKID));
+               return NOK;
+       }
+
+       NdisZeroMemory(pData, sizeof(OS_802_11_PMKID));
+       pPmkidList->Length = *Length;
+
+       status = UtilGetParam(pAdapter, RSN_PMKID_LIST, pData, *Length);
+
+       if (status != OK)
+       {
+               if (*Length < (pPmkidList->Length))
+                       *Length = pPmkidList->Length;
+               else
+                       *Length = 0;
+       } 
+    else
+       {
+               *Length = pPmkidList->Length;
+       }
+
+       return status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802PmkidSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+Util802PmkidSet(
+                          PTIWLN_ADAPTER_T pAdapter,
+                          PUCHAR pData,
+                          ULONG Length
+                          )
+{   
+       paramInfo_t Param;
+       TI_STATUS   status;
+
+       Param.paramType = RSN_PMKID_LIST;
+    Param.paramLength = Length;
+    if( Length > sizeof(Param.content) ) { /* Dm: Security fix */
+        printk("TI: %s - Security Error\n",__FUNCTION__);
+        return EXTERNAL_SET_PARAM_DENIED;
+    }
+       NdisMoveMemory(&Param.content, pData, Length);
+
+       status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
+
+       return(status);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802FSWAvailableOptionsGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+Util802FSWAvailableOptionsGet(
+                                                        PTIWLN_ADAPTER_T pAdapter, 
+                                                        PUCHAR pData, 
+                                                        PULONG Length)
+{
+       ULONG retValue;
+
+       if (!Length)
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, RSN_WPA_PROMOTE_AVAILABLE_OPTIONS, 
+                                                       pData, sizeof(ULONG));
+       *Length = sizeof(ULONG);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802FSWOptionsGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+Util802FSWOptionsGet(
+                                       PTIWLN_ADAPTER_T pAdapter, 
+                                       PUCHAR pData, 
+                                       PULONG Length)
+{
+       ULONG retValue;
+
+       if (!Length)
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, RSN_WPA_PROMOTE_OPTIONS, pData, sizeof(ULONG));
+
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802FSWOptionsSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+
+ULONG
+Util802FSWOptionsSet(
+                                       PTIWLN_ADAPTER_T pAdapter, 
+                                       PUCHAR pData, 
+                                       ULONG Length)
+{
+       ULONG retValue;
+
+       retValue = UtilSetParam(pAdapter, RSN_WPA_PROMOTE_OPTIONS, pData, sizeof(ULONG));
+
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilWepStatusGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilWepStatusGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       ULONG retValue;
+
+       if (!Length)
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, RSN_ENCRYPTION_STATUS_PARAM, pData, sizeof(ULONG));
+
+       *Length = sizeof(ULONG);
+       return retValue;
+
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilWepStatusSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilWepStatusSet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, RSN_ENCRYPTION_STATUS_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilAssociationInfoGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilAssociationInfoGet(
+                                         PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         PULONG Length
+                                         )
+{
+       OS_802_11_ASSOCIATION_INFORMATION  *assocInformation;
+       UINT8 *requestIEs;
+       UINT8 *responseIEs;
+       ULONG TotalLength = 0,retValue;
+       paramInfo_t param;
+
+       if (*Length < sizeof(OS_802_11_ASSOCIATION_INFORMATION))
+       {
+               PRINT(DBG_IOCTL_LOUD, "...More buffer space needed\n");
+               return(sizeof(OS_802_11_ASSOCIATION_INFORMATION));
+       }
+
+       param.paramType   = ASSOC_ASSOCIATION_INFORMATION_PARAM;
+       param.paramLength = *Length;
+
+       retValue = configMgr_getParam(pAdapter->CoreHalCtx, &param);
+
+       TotalLength =  sizeof(OS_802_11_ASSOCIATION_INFORMATION) + 
+                                  param.content.assocAssociationInformation.RequestIELength +
+                                  param.content.assocAssociationInformation.ResponseIELength;
+
+       if (TotalLength <= *Length)
+       {
+               NdisMoveMemory(pData, (UINT8 *)&param.content, sizeof(OS_802_11_ASSOCIATION_INFORMATION));
+               assocInformation = (OS_802_11_ASSOCIATION_INFORMATION*)pData;
+               requestIEs = (UINT8*)pData + sizeof(OS_802_11_ASSOCIATION_INFORMATION);
+
+               if (assocInformation->RequestIELength > 0)
+               {
+
+                       NdisMoveMemory(requestIEs, (UINT8*)assocInformation->OffsetRequestIEs, 
+                                                  assocInformation->RequestIELength); 
+
+                       assocInformation->OffsetRequestIEs = sizeof(OS_802_11_ASSOCIATION_INFORMATION);
+               }
+
+               if (assocInformation->ResponseIELength > 0)
+               {
+
+                       responseIEs = requestIEs + assocInformation->RequestIELength;
+
+                       NdisMoveMemory(responseIEs, (UINT8*)assocInformation->OffsetResponseIEs,
+                                                  assocInformation->ResponseIELength); 
+
+                       assocInformation->OffsetResponseIEs = 
+                       assocInformation->OffsetRequestIEs + assocInformation->RequestIELength;
+               }
+
+               PRINTF(DBG_IOCTL_LOUD, ("UtilAssociationInfoGet: pData=%p, "
+                                                               "OffsetRequestIEs=0x%lx, OffsetResponseIEs=0x%lx\n",
+                                                               pData, (long)assocInformation->OffsetRequestIEs, 
+                                                               (long)assocInformation->OffsetResponseIEs));
+       } else
+       {
+               *(PULONG)pData = TotalLength;
+               PRINT(DBG_IOCTL_LOUD, "...More buffer space needed\n");
+       }
+
+       *Length = TotalLength;
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilCurrentRegDomainGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilCurrentRegDomainGet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          PULONG Length
+                                          )
+{
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_REGULATORY_DOMAIN_PARAM, pData, sizeof(UINT8));
+
+       *Length = sizeof(UINT8);
+
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util4xActiveStateGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+Util4xActiveStateGet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       PULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM, pData, sizeof(UINT8));
+       *Length = sizeof(UINT8);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  power
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+static int power(int x, int y)
+{
+       int i = 0,z = 1;
+
+       for (i = 0; i < y; i++)
+               z *= x;
+
+       return z;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetSwVersion
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetSwVersion(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       TIWLN_VERSION* swVer;
+       ULONG retValue,tmpLen;
+       UCHAR FwVersion[FW_VERSION_LEN];
+       e2Version_t EepromVersion;
+       int i, start = 0, end = 0, temp = 0;
+
+       swVer = (TIWLN_VERSION *) pData;
+
+       swVer->DrvVersion.major = SW_VERSION_MAJOR;
+       swVer->DrvVersion.minor = SW_VERSION_MINOR;
+       swVer->DrvVersion.bugfix = SW_VERSION_PATCH;
+       swVer->DrvVersion.subld = SW_VERSION_SUBLD; 
+        swVer->DrvVersion.build = SW_VERSION_BUILD; 
+
+       NdisZeroMemory(&swVer->FWVersion, sizeof(swVer->FWVersion));
+
+       UtilGetParam(pAdapter, SITE_MGR_FIRMWARE_VERSION_PARAM, FwVersion, FW_VERSION_LEN);
+
+       /* major */
+       start = end = temp = 4;
+       while (FwVersion[end++] != '.');
+       temp = end;
+       end -= 2;
+       for (i = end; i>= start; i--)
+    {
+               swVer->FWVersion.major += (FwVersion[i] - 0x30)*power(10, end - i);
+    }
+               
+
+       /* minor */
+       start = end = temp;
+       while (FwVersion[end++] != '.');
+       temp = end;
+       end -= 2;
+       for (i = end; i>= start; i--)
+    {
+               swVer->FWVersion.minor += (FwVersion[i] - 0x30)*power(10, end - i);
+    }
+
+       /* bug fix */
+       start = end = temp;
+       while (FwVersion[end++] != '.');
+       temp = end;
+       end -= 2;
+       for (i = end; i>= start; i--)
+    {
+               swVer->FWVersion.bugfix += (FwVersion[i] - 0x30)*power(10, end - i);
+    }
+    
+
+    /* build */
+       start = end = temp;
+       while (FwVersion[end++] != '.');
+       temp = end;
+       end -= 2;
+       for (i = end; i>= start; i--)
+    {
+               swVer->FWVersion.subld += (FwVersion[i] - 0x30)*power(10, end - i);
+    }
+
+       /* minor build */
+       start = end = temp;
+       while (FwVersion[end++] != 0);
+       temp = end;
+       end -= 2;
+       for (i = end; i>= start; i--)
+    {
+               swVer->FWVersion.build += (FwVersion[i] - 0x30)*power(10, end - i);
+    }
+
+
+       NdisZeroMemory(&swVer->HWVersion, sizeof(swVer->HWVersion));
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_EEPROM_VERSION_PARAM, (PUCHAR)&EepromVersion, sizeof(e2Version_t));
+
+       swVer->HWVersion.major = (UCHAR) EepromVersion.major;
+       swVer->HWVersion.minor = (UCHAR) EepromVersion.minor;
+       swVer->HWVersion.bugfix = (UCHAR) EepromVersion.bugfix;
+
+       swVer->osNdisVersion  = (TIWLN_MAJOR_VERSION  << 16) + TIWLN_MINOR_VERSION;
+
+       tmpLen = sizeof(TIWLN_VERSION);
+
+    if (*Length >= sizeof(TIWLN_VERSION_EX)) //TRS:GAA allow larger than needed buffer
+       {
+
+               ((PTIWLN_VERSION_EX)swVer)->extVerSign = 2;
+
+               ((PTIWLN_VERSION_EX)swVer)->NVVersion.bugfix = EepromVersion.last;
+
+               ((PTIWLN_VERSION_EX)swVer)->NVVersion.minor = EepromVersion.minor;
+
+               ((PTIWLN_VERSION_EX)swVer)->NVVersion.major = 
+               (UCHAR)EepromVersion.major;
+
+               ((PTIWLN_VERSION_EX)swVer)->NVVersion.subld = 
+               (UCHAR)EepromVersion.bugfix;
+
+               tmpLen = sizeof(TIWLN_VERSION_EX);
+
+       }
+
+       *Length = tmpLen;
+
+       return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilRxAntennaSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRxAntennaSet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_RX_ANTENNA_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilRxAntennaGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRxAntennaGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       ULONG retValue;
+
+       if ((!Length) || (*Length == 0))
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, HAL_CTRL_RX_ANTENNA_PARAM, pData, sizeof(UINT8));
+       *Length = sizeof(UINT8);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilTxAntennaSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilTxAntennaSet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_TX_ANTENNA_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilTxAntennaGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilTxAntennaGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       ULONG retValue;
+
+       if ((!Length) || (*Length == 0))
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, HAL_CTRL_TX_ANTENNA_PARAM, pData, sizeof(UINT8));
+       *Length = sizeof (UINT8);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilNumberOfAntennas
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilNumberOfAntennas(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       PULONG Length
+                                       )
+{
+       if ((!Length) || (*Length == 0))
+               return NOK;
+
+       *(PULONG)pData = 2;
+       *Length = sizeof(ULONG);
+       return OK;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:
+       UtilAntennaDivresitySet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilAntennaDivresitySet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          ULONG Length
+                                          )
+{
+
+       return(UtilSetParam(pAdapter, HAL_CTRL_ANTENNA_DIVERSITY_PARAMS, pData, Length));
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDriverStatusGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDriverStatusGet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, DRIVER_STATUS_PARAM, pData, sizeof(ULONG));
+       *Length = sizeof (ULONG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDriverSuspend
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDriverSuspend(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG retValue;
+       OS_802_11_SSID FakeSsid;
+       UINT32 loopIndex;
+
+       for (loopIndex = 0; loopIndex < MAX_SSID_LEN; loopIndex++)
+               FakeSsid.Ssid[loopIndex] = (loopIndex+1);
+
+       FakeSsid.SsidLength = MAX_SSID_LEN;
+       retValue = UtilSetSSID(pAdapter, (PUCHAR)&FakeSsid, sizeof(OS_802_11_SSID));
+
+       return retValue;
+
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDriverStatusSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDriverStatusSet(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  ULONG Length
+                                  )
+{
+       ULONG retValue;
+
+       if (*(PULONG)pData)
+       {
+               retValue = configMgr_start(pAdapter->CoreHalCtx);
+       } else
+       {
+               retValue = configMgr_stop(pAdapter->CoreHalCtx);
+       }
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilRssiGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilRssiGet(
+                  PTIWLN_ADAPTER_T pAdapter,
+                  PUCHAR pData,
+                  PULONG Length
+                  )
+{
+       TIWLN_STATISTICS pStats;
+       paramInfo_t Param;
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       NdisZeroMemory(&pStats, sizeof(TIWLN_STATISTICS));
+
+       Param.paramType = SITE_MGR_GET_SELECTED_BSSID_INFO;
+       Param.content.pSiteMgrPrimarySiteDesc = &pStats.targetAP;
+
+       retValue = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       *(PULONG)pData = pStats.targetAP.Rssi;
+
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDeviceSuspend
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID
+UtilDeviceSuspend(
+                                PTIWLN_ADAPTER_T pAdapter
+                                )
+{
+       configMgr_stop(pAdapter->CoreHalCtx);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDeviceResume
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID
+UtilDeviceResume(
+                               PTIWLN_ADAPTER_T pAdapter
+                               )
+{
+       configMgr_start(pAdapter->CoreHalCtx);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilIbssProtectionGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilIbssProtectionGet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        PULONG Length
+                                        )
+{
+       ULONG retValue;
+       if (!Length)
+               return NOK;
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM, pData, sizeof(ULONG));
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilIbssProtectionSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilIbssProtectionSet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilShortSlotGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilShortSlotGet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               PULONG Length
+                               )
+{
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_SLOT_TIME_PARAM, pData, sizeof(ULONG));
+       *Length = sizeof (ULONG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilShortSlotSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilShortSlotSet(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_SLOT_TIME_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExtRatesIeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExtRatesIeGet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                PULONG Length
+                                )
+{
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, SITE_MGR_USE_DRAFT_NUM_PARAM, pData, sizeof(ULONG));
+
+       *Length = sizeof(ULONG);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExtRatesIeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExtRatesIeSet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_USE_DRAFT_NUM_PARAM, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilQosSetParams
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilQosSetParams(PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, QOS_MNGR_SET_OS_PARAMS, pData, Length);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilQosSetParams
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilQosSetRxTimeOut(PTIWLN_ADAPTER_T pAdapter,
+                                                 PUCHAR pData,
+                                                 ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, QOS_SET_RX_TIME_OUT, pData, Length);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilSetDTagToAcMappingTable
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilSetDTagToAcMappingTable(PTIWLN_ADAPTER_T pAdapter,
+                                                                 PUCHAR pData,
+                                                                 ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, TX_DATA_TAG_TO_AC_CLASSIFIER_TABLE, pData, Length);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilSetVAD
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilSetVAD(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, TX_DATA_SET_VAD, pData, Length);
+       return retValue;
+}
+
+ULONG UtilGetVAD (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, TX_DATA_GET_VAD , pData, sizeof(txDataVadTimerParams_t));
+       *Length = sizeof(txDataVadTimerParams_t);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilRemoveClassifierEntry
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilRemoveClassifierEntry(PTIWLN_ADAPTER_T pAdapter,
+                                                               PUCHAR ioBuffer,
+                                                               ULONG inBufLen)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, CTRL_DATA_CLSFR_REMOVE_ENTRY,ioBuffer, inBufLen);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilConfigTxClassifier
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilConfigTxClassifier(PTIWLN_ADAPTER_T pAdapter,
+                                                        PUCHAR ioBuffer,
+                                                        ULONG inBufLen)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, CTRL_DATA_CLSFR_CONFIG,ioBuffer, inBufLen);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetClsfrType
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetClsfrType(PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_CLSFR_TYPE , pData, sizeof(clsfrTypeAndSupport));
+       *Length = sizeof(clsfrTypeAndSupport);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetAPQosParams
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetAPQosParams(PTIWLN_ADAPTER_T pAdapter,
+                                                PUCHAR pData,
+                                                PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetGetParam(pAdapter, QOS_MNGR_AP_QOS_PARAMETERS , pData, sizeof(OS_802_11_AC_QOS_PARAMS));
+       *Length = sizeof(OS_802_11_AC_QOS_PARAMS);
+       return(retValue); 
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetAPQosCapabilities
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetAPQosCapabilities(PTIWLN_ADAPTER_T pAdapter,
+                                                          PUCHAR pData,
+                                                          PULONG Length)
+{
+       ULONG retValue;
+       *Length=sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS);
+       retValue = UtilGetParam(pAdapter, SITE_MGR_GET_AP_QOS_CAPABILITIES , pData, sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS));
+       return(retValue);
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilAddTspec
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilAddTspec(PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, QOS_MNGR_ADD_TSPEC_REQUEST , pData, sizeof(OS_802_11_QOS_TSPEC_PARAMS));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetTspecParams
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetTspecParams(PTIWLN_ADAPTER_T pAdapter,
+                                                PUCHAR pData,
+                                                PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetGetParam(pAdapter, QOS_MNGR_OS_TSPEC_PARAMS , pData, sizeof(OS_802_11_QOS_TSPEC_PARAMS));
+       *Length = sizeof(OS_802_11_QOS_TSPEC_PARAMS);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDeleteTspec
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilDeleteTspec(PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, QOS_MNGR_DEL_TSPEC_REQUEST , pData, sizeof(OS_802_11_QOS_DELETE_TSPEC_PARAMS));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetCurrentAcStatus
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetCurrentAcStatus(PTIWLN_ADAPTER_T pAdapter,
+                                                        PUCHAR pData,
+                                                        PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetGetParam(pAdapter, QOS_MNGR_AC_STATUS , pData, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS));
+       *Length = sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetUserPriorityOfStream
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetUserPriorityOfStream(PTIWLN_ADAPTER_T pAdapter,
+                                                                 PUCHAR pData,
+                                                                 PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetGetParam(pAdapter, CTRL_DATA_GET_USER_PRIORITY_OF_STREAM , pData, sizeof(STREAM_TRAFFIC_PROPERTIES));
+       *Length = sizeof(STREAM_TRAFFIC_PROPERTIES);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilSetMediumUsageThreshold
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilSetMediumUsageThreshold(PTIWLN_ADAPTER_T pAdapter,
+                                                                 PUCHAR pData,
+                                                                 ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, TX_DATA_SET_MEDIUM_USAGE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilSetPhyRateThreshold
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilSetPhyRateThreshold(PTIWLN_ADAPTER_T pAdapter,
+                                                         PUCHAR pData,
+                                                         ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, QOS_SET_RATE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetMediumUsageThreshold
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetMediumUsageThreshold(PTIWLN_ADAPTER_T pAdapter,
+                                                                 PUCHAR pData,
+                                                                 PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetGetParam(pAdapter, TX_DATA_GET_MEDIUM_USAGE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
+       *Length = sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetPhyRateThreshold
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetPhyRateThreshold(PTIWLN_ADAPTER_T pAdapter,
+                                                         PUCHAR pData,
+                                                         PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetGetParam(pAdapter, QOS_GET_RATE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
+       *Length = sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetDesiredPsMode
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetDesiredPsMode(PTIWLN_ADAPTER_T pAdapter,
+                                                  PUCHAR pData,
+                                                  PULONG  Length)
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, QOS_MNGR_GET_DESIRED_PS_MODE , pData, sizeof(OS_802_11_QOS_DESIRED_PS_MODE));
+       *Length = sizeof(OS_802_11_QOS_DESIRED_PS_MODE);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPollApPackets
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPollApPackets(PTIWLN_ADAPTER_T pAdapter,
+                                               PUCHAR pData,
+                                               ULONG Length)
+{
+       ULONG retValue;
+       retValue = configMgr_PollApPackets(pAdapter->CoreHalCtx);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPollApPacketsFromAC
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPollApPacketsFromAC(PTIWLN_ADAPTER_T pAdapter,
+                                                         PUCHAR pData,
+                                                         ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, TX_DATA_POLL_AP_PACKETS_FROM_AC , (unsigned char *)pData, Length);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilEnableEvent
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilEnableEvent(PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         ULONG Length)
+{
+       /*UtilSetParam(pAdapter,  , pData, Length);  EITAN TBD */
+       return PARAM_NOT_SUPPORTED;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDisableEvent
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilDisableEvent(PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          ULONG Length)
+{
+       /*UtilSetParam(pAdapter,  , pData, Length);  EITAN TBD */
+       return PARAM_NOT_SUPPORTED;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilConfigRSSI
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilConfigRSSI(PTIWLN_ADAPTER_T pAdapter,
+                                        UINT32 pData,
+                                        ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_RSSI_THRESHOLD_SET , (unsigned char *)pData, Length);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilConfigPERLevel
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilConfigPERLevel(PTIWLN_ADAPTER_T pAdapter,
+                                                UINT32 pData,
+                                                ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_TX_RATE_PRCT_SET , (unsigned char *)pData, Length);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetDrvCapabilities
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetDrvCapabilities(PTIWLN_ADAPTER_T pAdapter,
+                                                        PUCHAR pData,
+                                                        PULONG Length)
+{
+       /*UtilSetParam(pAdapter,  , pData, Length);  EITAN TBD */
+       return PARAM_NOT_SUPPORTED;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetPrimaryBSSIDInfo
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetPrimaryBSSIDInfo(PTIWLN_ADAPTER_T pAdapter,
+                       PUCHAR pData,
+                       PULONG Length)
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       if ( *Length < sizeof(OS_802_11_BSSID_EX) )
+    {
+               PRINTF(DBG_NDIS_OIDS_ERROR, ("UtilGetPrimaryBSSIDInfo: ERROR Length is:%ld < %d\n", 
+                                         *Length, sizeof(OS_802_11_BSSID)) );
+        return NOK;
+    }
+
+    Param.paramType = SITE_MGR_PRIMARY_SITE_PARAM;
+       Param.paramLength = *Length;
+       Param.content.pSiteMgrSelectedSiteInfo = (OS_802_11_BSSID_EX*)pData;
+    Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       if(Status != OK) {
+               PRINTF(DBG_NDIS_OIDS_ERROR, (" UtilGetPrimaryBSSIDInfo: ERROR on return from get param SITE_MGR_PRIMARY_SITE_PARAM\n"));
+    }
+    else
+    {
+        *Length = Param.paramLength;    
+    }
+
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetSelectedBSSIDInfo
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetSelectedBSSIDInfo(PTIWLN_ADAPTER_T pAdapter,
+                                                          PUCHAR pData,
+                                                          PULONG Length)
+{
+       paramInfo_t Param;
+       TI_STATUS Status;
+
+       if ( *Length < sizeof(OS_802_11_BSSID_EX) )
+       {
+               PRINTF(DBG_NDIS_OIDS_ERROR, ("UtilGetSelectedBSSIDInfo: ERROR Length is:%ld < %d", 
+                                                                                *Length, sizeof(OS_802_11_BSSID)) );
+               return NOK;
+       }
+
+       Param.paramType = SITE_MGR_GET_SELECTED_BSSID_INFO;
+       Param.paramLength = *Length;
+       Param.content.pSiteMgrPrimarySiteDesc = (OS_802_11_BSSID*)pData;
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       if(Status != OK)
+        {
+               PRINTF(DBG_NDIS_OIDS_ERROR, (" UtilGetSelectedBSSIDInfo: ERROR on return from get param SITE_MGR_GET_SELECTED_BSSID_INFO"));
+       }
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilGetDriverState
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilGetDriverState (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, SME_SM_STATE_PARAM , pData, *Length);
+       *Length = sizeof (ULONG);
+       return retValue;
+}
+
+
+/*#ifdef NDIS51_MINIPORT*/
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPrivacyFilterGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPrivacyFilterGet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       PULONG Length
+                                       )
+{
+       ULONG WepStatus,retValue,dataSize;
+
+       if (!Length)
+               return NOK;
+
+       dataSize = sizeof (ULONG);
+       retValue = UtilWepStatusGet(pAdapter, (PUCHAR)&WepStatus, &dataSize);
+
+       if (WepStatus)
+       {
+               *(PULONG)pData = os802_11PrivFilterAcceptAll;
+       } else
+       {
+               *(PULONG)pData = os802_11PrivFilter8021xWEP;
+       }
+       *Length = sizeof (ULONG);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPrivacyFilterSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPrivacyFilterSet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ULONG WepStatus,dataSize,retValue;
+
+       dataSize = sizeof(ULONG);
+       retValue = UtilWepStatusGet(pAdapter, (PUCHAR)&WepStatus, &dataSize);
+
+       if ((WepStatus && (*(PULONG)pData == os802_11PrivFilter8021xWEP)) || (retValue != OK))
+               return NOK;     /* was return -1 */
+
+       if ((!WepStatus) && (retValue == OK))
+       {
+               *(PULONG)pData = 0;
+               retValue = UtilSetParam(pAdapter, RX_DATA_EXCLUDE_UNENCRYPTED_PARAM, pData, sizeof(ULONG));
+       }
+
+       return retValue;
+}
+
+
+
+/*#endif*/
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilReadReg
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilReadReg(
+                  PTIWLN_ADAPTER_T pAdapter,
+                  PUCHAR pData,
+                  PULONG Length
+                  )
+{
+       TIWLN_REG_RW * pReg;
+
+       pReg = (TIWLN_REG_RW *) pData;
+
+#if defined(TNETW1150)
+       if (pReg->regAddr >= 0x3C0000)
+               pReg->regValue = configMgr_ReadPhyRegister(pAdapter->CoreHalCtx, pReg->regAddr);
+       else
+               pReg->regValue = configMgr_ReadMacRegister(pAdapter->CoreHalCtx, pReg->regAddr);
+#else
+       if (pReg->regAddr >= 0x1000)
+               pReg->regValue = configMgr_ReadPhyRegister(pAdapter->CoreHalCtx, pReg->regAddr);
+       else
+               pReg->regValue = configMgr_ReadMacRegister(pAdapter->CoreHalCtx, pReg->regAddr);
+#endif
+
+
+#ifdef __LINUX__
+       print_info("Register %#x=%#x(%d)\n", pReg->regAddr, pReg->regValue, pReg->regValue );
+#endif
+       *Length = sizeof(TIWLN_REG_RW);
+       return OK;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilWriteReg
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilWriteReg(
+                       PTIWLN_ADAPTER_T pAdapter,
+                       PUCHAR pData,
+                       ULONG Length
+                       )
+{
+       TIWLN_REG_RW * pReg;
+
+       pReg = (TIWLN_REG_RW *) pData;
+
+#if defined(TNETW1150)
+       if (pReg->regAddr >= 0x3C0000)
+               configMgr_WritePhyRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
+       else
+               configMgr_WriteMacRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
+#else
+       if (pReg->regAddr >= 0x1000)
+               configMgr_WritePhyRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
+       else
+               configMgr_WriteMacRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
+#endif
+
+       return OK;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilDisassociate
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilDisassociate(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       OS_802_11_SSID FakeSsid;
+       UINT32 loopIndex;
+       ULONG retValue;
+
+       /*
+        * Clean up desired SSID value
+       */
+       for (loopIndex = 0; loopIndex < MAX_SSID_LEN; loopIndex++)
+               FakeSsid.Ssid[loopIndex] = (loopIndex+1);
+
+       FakeSsid.SsidLength = MAX_SSID_LEN;
+
+       retValue = UtilSetSSID(pAdapter, (PUCHAR)&FakeSsid, sizeof(OS_802_11_SSID));
+
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilInfoCodeQueryInformation
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilInfoCodeQueryInformation(
+                                                       PTIWLN_ADAPTER_T pAdapter,
+                                                       PUCHAR pData,
+                                                       PULONG Length
+                                                       )
+{
+       UINT32 InfoCode, retVal, PureInfoLength;
+       ULONG dataSize;
+       PRINT(DBG_IOCTL_LOUD, "UtilInfoCodeQueryInformation\n");
+
+       retVal = OK;
+
+       if (*Length<sizeof(InfoCode))
+       {
+               *Length = sizeof(ULONG);
+               return NOK;
+       }
+
+       InfoCode = *((UINT32*)pData);
+       #ifndef _WINDOWS
+               PureInfoLength = *Length - sizeof(InfoCode);
+       #else 
+       #endif
+
+       switch (InfoCode)
+       {
+       case VAL_TX_POWER_VALUE:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_TX_POWER_VALUE (100)\n");
+               retVal = UtilGetTxPowerValue(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData, PureInfoLength);
+               break;
+       case VAL_NETWORK_TYPE:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_NETWORK_TYPE (101)\n");
+               dataSize = PureInfoLength;
+               retVal = UtilNetworkTypeInUseGet(pAdapter, pData, &dataSize);
+               break;
+       case VAL_AP_TX_POWER_LEVEL:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_AP_TX_POWER_LEVEL (102)\n");
+               retVal = UtilGetAPTxPowerLevel(pAdapter, SITE_MGR_AP_TX_POWER_PARAM, pData, PureInfoLength);
+               break;
+       case VAL_PACKET_BURSTING:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_PACKET_BURSTING (106)\n");
+               retVal = UtilGetPacketBursting(pAdapter, QOS_PACKET_BURST_ENABLE, pData, PureInfoLength);
+               break;
+       case VAL_MIXED_MODE:
+               dataSize = PureInfoLength;
+               retVal = UtilGetMixedMode(pAdapter, RSN_MIXED_MODE, pData, &dataSize);
+               break;
+       case VAL_DEFAULT_KEY_ID:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_DEFAULT_KEY_ID (110)\n");
+               dataSize = PureInfoLength;
+               retVal = UtilGetDefaultKeyId(pAdapter, RSN_DEFAULT_KEY_ID, pData, &dataSize);
+               break;
+       default:
+               PRINT(DBG_IOCTL_LOUD, "case default\n");
+               break;
+       }
+       *Length = PureInfoLength;
+       return retVal;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilInfoCodeSetInformation
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilInfoCodeSetInformation(
+                                                 PTIWLN_ADAPTER_T pAdapter,
+                                                 PUCHAR pData,
+                                                 ULONG Length
+                                                 )
+{
+       UINT32 InfoCode, retVal, PureInfoLength;
+
+       PRINT(DBG_IOCTL_LOUD, "UtilInfoCodeSetInformation\n");
+
+       if (Length<sizeof(UINT32))
+               return NOK;
+
+       InfoCode = *((UINT32*)pData);
+       retVal = PureInfoLength = Length - sizeof(InfoCode);
+
+       switch (InfoCode)
+       {
+       case VAL_TX_POWER_VALUE:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_TX_POWER_VALUE (100)\n");
+               retVal = UtilSetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData+sizeof(InfoCode), PureInfoLength);
+               break;
+       case VAL_NETWORK_TYPE:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_NETWORK_TYPE (101)\n");
+               retVal = UtilNetworkTypeInUseSet(pAdapter, pData+sizeof(InfoCode), PureInfoLength);
+               break;
+       case VAL_PACKET_BURSTING:
+               PRINT(DBG_IOCTL_LOUD, "case VAL_PACKET_BURSTING (106)\n");
+               retVal = UtilSetPacketBursting(pAdapter, pData+sizeof(InfoCode), PureInfoLength);
+               break;
+       case VAL_MIXED_MODE:
+               retVal = UtilSetMixedMode(pAdapter, pData+sizeof(InfoCode), PureInfoLength);
+               break;
+       case VAL_DEFAULT_KEY_ID:
+               retVal = UtilSetParam(pAdapter, RSN_DEFAULT_KEY_ID, pData+sizeof(InfoCode), PureInfoLength);
+               break;
+       default:
+               PRINT(DBG_IOCTL_LOUD, "case default\n");
+               break;
+       }
+       return retVal;
+}
+
+#ifdef _WINDOWS
+#endif /* _WINDOWS */
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilTxPowerLevelDbmGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilTxPowerLevelDbmGet(
+                                         PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         PULONG Length
+                                         )
+{ 
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData, sizeof(UINT8));
+       *Length = sizeof(INT8);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilTxPowerLevelDbmSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilTxPowerLevelDbmSet(
+                                         PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         ULONG Length
+                                         )
+{ 
+ULONG mW, Dbm, power,retValue;
+
+       if (!Length)
+               return NOK;
+
+       mW = *(PULONG)pData;
+
+       for (power=1; mW/10; mW/=10, power++); 
+
+       Dbm = 20 * power;
+
+
+       retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, (PUCHAR)&Dbm, sizeof(ULONG));
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802EapTypeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+Util802EapTypeGet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                PULONG Length
+                                )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, RSN_EAP_TYPE, pData, sizeof(ULONG));
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  Util802EapTypeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+Util802EapTypeSet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, RSN_EAP_TYPE, pData, sizeof(ULONG));
+       return retValue;
+}
+
+#ifdef EXC_MODULE_INCLUDED
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcConfigurationGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcConfigurationGet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          PULONG Length
+                                          )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, EXC_CONFIGURATION, pData, sizeof(ULONG));
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcNetworkEapGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcNetworkEapGet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       PULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, RSN_EXC_NETWORK_EAP, pData, sizeof(ULONG));
+       *Length = sizeof(ULONG);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcConfigurationSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcConfigurationSet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          ULONG Length
+                                          )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, EXC_CONFIGURATION, pData, sizeof(ULONG));
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcNetworkEapSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcNetworkEapSet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, RSN_EXC_NETWORK_EAP, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilExcRogueApDetectedSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcRogueApDetectedSet(
+                                                PTIWLN_ADAPTER_T pAdapter,
+                                                PUCHAR pData,
+                                                ULONG Length
+                                                )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, EXC_ROGUE_AP_DETECTED, pData, sizeof(OS_EXC_ROGUE_AP_DETECTED));
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcReportRogueApSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcReportRogueApSet(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          ULONG Length
+                                          )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, EXC_REPORT_ROGUE_APS, pData, 0);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcAuthSuccessSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcAuthSuccessSet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, EXC_AUTH_SUCCESS, pData, sizeof(OS_EXC_AUTH_SUCCESS));
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcCckmRequestSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcCckmRequestSet(
+                                        PTIWLN_ADAPTER_T pAdapter,
+                                        PUCHAR pData,
+                                        ULONG Length
+                                        )
+{
+       ULONG retValue;
+
+       OS_EXC_CCKM_REQUEST *cckmRequest = (OS_EXC_CCKM_REQUEST*)pData;
+       ULONG reqLength = cckmRequest->AssociationRequestIELength+sizeof(cckmRequest->RequestCode)+sizeof(cckmRequest->AssociationRequestIELength);
+
+       PRINTF(DBG_IOCTL_LOUD, ("UtilExcCckmRequestSet, In Length = %d, Required Length=%d\n",
+                                                       (int) Length, (int) reqLength));
+
+       if ((cckmRequest==NULL) || (reqLength > Length))
+       {
+               PRINTF(DBG_IOCTL_LOUD, ("UtilExcCckmRequestSet, wrong size or pointer, In Length = %d, Required Length=%d\n",
+                                                               (int) Length, (int) reqLength));
+               return NOK;
+       }
+       retValue = UtilSetParam(pAdapter, EXC_CCKM_REQUEST, pData, reqLength);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilExcCckmResultSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilExcCckmResultSet(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, EXC_CCKM_RESULT, pData, sizeof(ULONG));
+       return retValue;
+}
+
+#endif /* EXC_MODULE_INCLUDED */
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilGetMACAddress
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilGetMACAddress(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                PULONG Length
+                                )
+{
+       ULONG retValue;
+
+       if ((*Length) < MAC_ADDR_LEN)
+       {
+               *Length = MAC_ADDR_LEN;
+               return NOK;
+       }
+
+       retValue = UtilGetParam(pAdapter, CTRL_DATA_MAC_ADDRESS, pData, MAC_ADDR_LEN);
+       *Length = MAC_ADDR_LEN;
+       return retValue;
+}     
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilConfigRoamingParamsSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilConfigRoamingParamsSet(
+                                                 PTIWLN_ADAPTER_T pAdapter,
+                                                 PUCHAR pData,
+                                                 ULONG Length
+                                                 )
+{
+       ULONG retValue;
+       applicationConfigBuffer_t applicationConfigBuffer;
+
+       applicationConfigBuffer.buffer = pData;
+       applicationConfigBuffer.bufferSize = (UINT16)Length;
+
+       retValue = UtilSetParam(pAdapter, ROAMING_MNGR_APPLICATION_CONFIGURATION, (PUCHAR)&applicationConfigBuffer, sizeof(applicationConfigBuffer_t));
+
+       return retValue;
+}     
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilConfigRoamingParamsGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilConfigRoamingParamsGet(
+                                                 PTIWLN_ADAPTER_T pAdapter,
+                                                 PUCHAR pData,
+                                                 PULONG Length
+                                                 )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, ROAMING_MNGR_APPLICATION_CONFIGURATION, pData, *Length);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilMeasurementEnableDisableParamsSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilMeasurementEnableDisableParamsSet(
+                                                                        PTIWLN_ADAPTER_T pAdapter,
+                                                                        PUCHAR pData,
+                                                                        ULONG Length
+                                                                        )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, MEASUREMENT_ENABLE_DISABLE_PARAM, pData, Length);
+       return retValue;
+}     
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilMeasurementMaxDurationParamsSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilMeasurementMaxDurationParamsSet(
+                                                                  PTIWLN_ADAPTER_T pAdapter,
+                                                                  PUCHAR pData,
+                                                                  ULONG Length
+                                                                  )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, MEASUREMENT_MAX_DURATION_PARAM, pData, sizeof(UINT32));
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilEarlyWakeupIeGet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilEarlyWakeupIeGet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                PULONG Length
+                                )
+{
+       ULONG retValue;
+
+       if (!Length)
+               return NOK;
+
+       retValue = UtilGetParam(pAdapter, HAL_CTRL_EARLY_WAKEUP, pData, sizeof(UINT8));
+
+       *Length = sizeof(UINT8);
+
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilEarlyWakeupIeSet
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilEarlyWakeupIeSet(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_EARLY_WAKEUP, pData, sizeof(ULONG));
+       return retValue;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilBthWlanCoeEnable
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBthWlanCoeEnable(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SOFT_GEMINI_SET_ENABLE, pData, sizeof(ULONG));
+       return retValue;
+}     
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilBthWlanCoeRate
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBthWlanCoeRate(
+                                 PTIWLN_ADAPTER_T pAdapter,
+                                 PUCHAR pData,
+                                 ULONG Length
+                                 )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SOFT_GEMINI_SET_RATE, pData, sizeof(ULONG)*NUM_OF_RATES_IN_SG);
+       return retValue;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilBthWlanCoeConfig
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBthWlanCoeConfig(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, SOFT_GEMINI_SET_CONFIG, pData, sizeof(ULONG) * NUM_OF_CONFIG_PARAMS_IN_SG);
+       return retValue;
+}    
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilBthWlanCoeGetStatus
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilBthWlanCoeGetStatus(
+                                          PTIWLN_ADAPTER_T pAdapter,
+                                          PUCHAR pData,
+                                          PULONG Length
+                                          )
+{
+       ULONG retValue;
+       retValue = UtilGetParam(pAdapter, SOFT_GEMINI_GET_STATUS, pData, 0);
+       *Length = 0;
+       return retValue;
+} 
+
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltRxPerStart
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPltRxPerStart(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG Status;
+       interogateCmdCBParams_t interogateCmdCBParams;
+       memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       interogateCmdCBParams.CB_Func    =  NULL;
+       interogateCmdCBParams.CB_buf     =  NULL;
+       Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_RX_PER_START, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
+
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltRxPerStop
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPltRxPerStop(
+                               PTIWLN_ADAPTER_T pAdapter,
+                               PUCHAR pData,
+                               ULONG Length
+                               )
+{
+       ULONG Status;
+       interogateCmdCBParams_t interogateCmdCBParams;
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       interogateCmdCBParams.CB_Func    =  NULL;
+       interogateCmdCBParams.CB_buf     =  NULL;
+       Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_RX_PER_STOP, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltRxPerClear
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPltRxPerClear(
+                                PTIWLN_ADAPTER_T pAdapter,
+                                PUCHAR pData,
+                                ULONG Length
+                                )
+{
+       ULONG Status;
+       interogateCmdCBParams_t interogateCmdCBParams;
+       memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       interogateCmdCBParams.CB_Func    =  NULL;
+       interogateCmdCBParams.CB_buf     =  NULL;
+       Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_RX_PER_CLEAR, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltRxPerGetResults
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPltRxPerGetResults(
+                                         PTIWLN_ADAPTER_T pAdapter,
+                                         PUCHAR pData,
+                                         PULONG pLength
+                                         )
+{
+
+       ULONG Status;
+       paramInfo_t Param;
+       interogateCmdCBParams_t* pInterogateCmdCBParams = &Param.content.interogateCmdCBParams;
+
+       memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
+
+       /* To implement the Async IOCTL store the user buffer pointer to be filled at
+       the Command Completion calback */
+       pAdapter->pIoBuffer =  pData;
+       pAdapter->pIoCompleteBuffSize =  pLength ;
+
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       pInterogateCmdCBParams->CB_handle  =  (TI_HANDLE)pAdapter;
+       pInterogateCmdCBParams->CB_Func    =  (PVOID)UtilPltRxPerCB;
+       pInterogateCmdCBParams->CB_buf     =  &(pAdapter->IoCompleteBuff[0]);
+
+       Param.paramType = HAL_CTRL_PLT_RX_PER_GET_RESULTS;
+       Param.paramLength = sizeof(interogateCmdCBParams_t);
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPltRxPerCB
+
+Routine Description: This is the CB triggered when  PltRX command been 
+                                       returned by FW.
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID UtilPltRxPerCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
+{
+       HwMboxCmdBit_RxPer_t* pRxPer =  (HwMboxCmdBit_RxPer_t* )pReadBuff;
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
+       
+       if (pRxPer->CB_RxPerCmd == PLT_RX_PER_GETRESULTS)
+       {
+               *(pAdapter->pIoCompleteBuffSize) = sizeof(pRxPer->PltRxPer);
+               os_memoryCopy(hAdapter, (void*)&(pAdapter->pIoBuffer[0]) ,(void*) &(pRxPer->PltRxPer) , *(pAdapter->pIoCompleteBuffSize));
+               /* Call back the Completion that will indicate to the user that the buffer is ready to be read */
+               os_IoctlComplete(pAdapter, status);
+
+       }
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltTxCW
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltTxCW(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_TX_CW, pData, Length);
+       return retValue;
+}
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltTxContinues
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltTxContinues(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_TX_CONTINUES, pData, Length);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltTxStop
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltTxStop(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_TX_STOP, pData, 0);
+       return retValue;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltWriteMib
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltWriteMib(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
+{
+       ULONG retValue;
+       retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_WRITE_MIB, pData, Length);
+       return retValue;
+}
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltReadMib
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltReadMib(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG pOutLength, ULONG InLength)
+{
+       ULONG Status;
+       paramInfo_t Param;
+       
+       /* To implement the Async IOCTL store the user buffer pointer to be filled at
+       the Command Completion calback */
+       pAdapter->pIoBuffer =  pData;
+       pAdapter->pIoCompleteBuffSize =  pOutLength;
+
+       os_memoryCopy((TI_HANDLE)pAdapter, (PVOID)pAdapter->IoCompleteBuff, pData, InLength);
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       Param.content.interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       Param.content.interogateCmdCBParams.CB_Func  =  (PVOID)UtilPltReadMibCB;
+       Param.content.interogateCmdCBParams.CB_buf  =  pAdapter->IoCompleteBuff;
+
+       Param.paramType = HAL_CTRL_PLT_READ_MIB;
+       Param.paramLength = sizeof(interogateCmdCBParams_t);
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+
+       return Status;
+}
+
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPltReadMibCB
+
+Routine Description: This is the CB triggered when  PltReadRegister command been 
+                                       returned by FW.
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID UtilPltReadMibCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
+       PLT_MIB_t* pReturnMib = (PLT_MIB_t*)pAdapter->pIoBuffer;
+       tiBOOL IsAsync = TRUE;
+
+       switch (pReturnMib->aMib)
+       {
+       case PLT_MIB_dot11StationId:
+               {
+                       dot11StationIDStruct* pdot11StationID = (dot11StationIDStruct*)pReadBuff;
+                       pReturnMib->Length = sizeof(pReturnMib->aData.StationId);
+                       os_memoryCopy(hAdapter, (PVOID)pReturnMib->aData.StationId.addr, (PVOID)pdot11StationID->dot11StationID, sizeof(pReturnMib->aData.StationId));
+               }         
+               break;
+
+       case PLT_MIB_countersTable:
+               {
+                       ACXErrorCounters_t* pACXErrorCounters = (ACXErrorCounters_t*)pReadBuff;
+                       pReturnMib->Length = sizeof(pReturnMib->aData.CounterTable);
+                       pReturnMib->aData.CounterTable.FCSErrorCount = pACXErrorCounters->FCSErrorCount;
+                       pReturnMib->aData.CounterTable.PLCPErrorCount = pACXErrorCounters->PLCPErrorCount;
+               }
+               break;
+
+               /* MIBs with data which is already in pReadBuff and in the correct form. */
+       case PLT_MIB_ctsToSelf:
+       case PLT_MIB_dot11MaxReceiveLifetime:
+       case PLT_MIB_dot11GroupAddressesTable:
+       case PLT_MIB_arpIpAddressesTable:
+       case PLT_MIB_rxFilter:
+       case PLT_MIB_templateFrame:
+       case PLT_MIB_beaconFilterIETable:
+       case PLT_MIB_txRatePolicy:
+               IsAsync = FALSE;
+               PRINTF(DBG_NDIS_OIDS_LOUD, ("UtilPltReadMibCB:MIB aMib 0x%x \n",pReturnMib->aMib));
+               os_memoryCopy(hAdapter, (PVOID)pAdapter->pIoBuffer, (PVOID)pAdapter->IoCompleteBuff, sizeof(PLT_MIB_t));
+               break;
+       default:
+               PRINTF(DBG_NDIS_OIDS_LOUD, ("UtilPltReadMibCB:MIB aMib 0x%x Not supported\n",pReturnMib->aMib));
+       }
+       /* Call back the Completion that will indicate to the user that the buffer is ready to be read */
+       if (IsAsync)
+               os_IoctlComplete(pAdapter, status);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltReadRegister
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPltReadRegister(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG Length
+                                  )
+{
+
+       ULONG Status;
+       paramInfo_t Param;
+       interogateCmdCBParams_t* pInterogateCmdCBParams = &Param.content.interogateCmdCBParams;
+       ReadWriteCommand_t* pReadWriteCommandStruct = (ReadWriteCommand_t*)pAdapter->IoCompleteBuff;
+       UINT32* pRegAdress = (UINT32*)pData;
+
+       /* To implement the Async IOCTL store the user buffer pointer to be filled at
+       the Command Completion calback */
+       pAdapter->pIoBuffer =  pData;
+       pAdapter->pIoCompleteBuffSize =  Length ;
+
+       memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
+       pReadWriteCommandStruct->addr = *pRegAdress;
+       pReadWriteCommandStruct->size = 4;
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       pInterogateCmdCBParams->CB_handle  =  (TI_HANDLE)pAdapter;
+       pInterogateCmdCBParams->CB_Func    =  (PVOID)UtilPltReadRegisterCB;
+       pInterogateCmdCBParams->CB_buf     =  &(pAdapter->IoCompleteBuff[0]) ;
+
+       Param.paramType = HAL_CTRL_PLT_READ_REGISTER;
+       Param.paramLength = sizeof(interogateCmdCBParams_t);
+
+       Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPltReadRegisterCB
+
+Routine Description: This is the CB triggered when  PltReadRegister command been 
+                                       returned by FW.
+Arguments:
+
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID UtilPltReadRegisterCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
+       ReadWriteCommand_t* pReadWriteCommandStruct = (ReadWriteCommand_t*)pReadBuff;
+       UINT32* pRegDataReturn = (UINT32*)pAdapter->pIoBuffer;
+
+       *(pAdapter->pIoCompleteBuffSize) = sizeof(INT32);
+
+       /*Convert the returned data structure from ReadWriteCommandStruct to UINT32*/
+       os_memoryCopy(hAdapter, (PVOID)pRegDataReturn, (PVOID)pReadWriteCommandStruct->value, sizeof(UINT32));
+
+       /* Call back the Completion that will indicate to the user that the buffer is ready to be read */
+       os_IoctlComplete(pAdapter, status);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltWriteRegister
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG
+UtilPltWriteRegister(
+                                       PTIWLN_ADAPTER_T pAdapter,
+                                       PUCHAR pData,
+                                       ULONG Length
+                                       )
+{
+       ReadWriteCommand_t* pReadWriteCommandStruct = (ReadWriteCommand_t*)pAdapter->IoCompleteBuff;
+       TIWLN_REG_RW* pReg = (TIWLN_REG_RW*)pData;
+       interogateCmdCBParams_t interogateCmdCBParams;
+       UINT32 Status;
+
+
+       pReadWriteCommandStruct->addr = pReg->regAddr;
+       pReadWriteCommandStruct->size = pReg->regSize;
+       os_memoryCopy((TI_HANDLE)pAdapter, (PVOID)pReadWriteCommandStruct->value, (PVOID)&pReg->regValue, pReadWriteCommandStruct->size);
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
+       interogateCmdCBParams.CB_Func    =  NULL;
+       interogateCmdCBParams.CB_buf     =  pAdapter->IoCompleteBuff;
+       Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_WRITE_REGISTER, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
+       return Status;
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: utilPltRxTxCal
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltRxTxCal(
+                                  PTIWLN_ADAPTER_T pAdapter,
+                                  PUCHAR pData,
+                                  PULONG pOutLength,
+                                  ULONG  InLength)
+
+{
+       paramInfo_t Param;
+       interogateCmdCBParams_t* pInterogateCmdCBParams = &Param.content.interogateCmdCBParams;
+
+       /* To implement the Async IOCTL store the user buffer pointer to be filled at
+       the Command Completion callback */
+       pAdapter->pIoBuffer =  (PUINT8)pData;
+       pAdapter->pIoCompleteBuffSize =  pOutLength;
+
+       /* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
+       pInterogateCmdCBParams->CB_handle  =  (TI_HANDLE)pAdapter;
+       pInterogateCmdCBParams->CB_Func    =  (PVOID)UtilPltRxTxCalCB;
+    pInterogateCmdCBParams->CB_buf     = pAdapter->pIoBuffer;
+
+       Param.paramType = HAL_CTRL_PLT_RX_TX_CAL;
+       Param.paramLength = sizeof(interogateCmdCBParams_t);
+
+       return configMgr_getParam(pAdapter->CoreHalCtx, &Param);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name:  UtilPltRxTxCalCB
+
+Routine Description: This is the CB triggered when  utilPltRxTxCal command been 
+                                       returned by FW.
+Arguments:          pReadBuff - Should return the TestCmd_t
+
+Return Value:
+-----------------------------------------------------------------------------*/
+VOID UtilPltRxTxCalCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
+{
+       PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
+
+    *(pAdapter->pIoCompleteBuffSize) = sizeof(TestCmd_t);
+
+     /* Call back the Completion that will indicate to the user that the buffer is ready to be read */
+       os_IoctlComplete(pAdapter, status);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: UtilPltRxCal
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG UtilPltRxCal(
+                   PTIWLN_ADAPTER_T pAdapter,
+                   PUCHAR pData,
+                   PULONG pOutLength,
+                   ULONG InLength)
+{
+    whalParamInfo_t Param;
+
+    Param.paramType = HAL_CTRL_PLT_RX_TX_CAL;
+    Param.paramLength = sizeof(TestCmd_t*);
+    Param.content.interogateCmdCBParams.CB_Func = NULL;
+    Param.content.interogateCmdCBParams.CB_handle = NULL;
+    Param.content.interogateCmdCBParams.CB_buf = (PUINT8)pData;
+
+    return configMgr_getParam(pAdapter->CoreHalCtx, (paramInfo_t*)&Param);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: utilRxCalibrationStatus
+Routine Description:
+Arguments:
+Return Value:
+-----------------------------------------------------------------------------*/
+ULONG utilRxCalibrationStatus(
+                   PTIWLN_ADAPTER_T pAdapter,
+                   PUCHAR pData,
+                   PULONG pOutLength,
+                   ULONG  InLength)
+{
+    whalParamInfo_t Param;
+    ULONG status;
+
+    Param.paramType = HAL_CTRL_PLT_RX_CAL_STATUS;
+    Param.paramLength = sizeof(TI_STATUS);
+
+    status = configMgr_getParam(pAdapter->CoreHalCtx, (paramInfo_t*)&Param);
+
+    *pData = Param.content.PltRxCalibrationStatus;
+
+    return status;
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/arch_ti.h b/sta_dk_4_0_4_32/pform/linux/inc/arch_ti.h
new file mode 100644 (file)
index 0000000..b309bc2
--- /dev/null
@@ -0,0 +1,45 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef __ARCH_TI_H__
+#define __ARCH_TI_H__
+
+#define __NO_VERSION__
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#endif
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/bmtrace.h b/sta_dk_4_0_4_32/pform/linux/inc/bmtrace.h
new file mode 100644 (file)
index 0000000..9772025
--- /dev/null
@@ -0,0 +1,72 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+ /*
+ * Benchmark tracing utility
+ */
+
+#ifndef BM_TRACE_H
+
+#define BM_TRACE_H
+
+#ifndef BM_NUM_ENTRIES
+#define BM_NUM_ENTRIES 128
+#endif
+
+#ifdef TI_PROFILING
+
+#include <linux/stddef.h>
+
+/* Initialization */
+int bm_init(struct tiwlan_net_dev *drv);
+void bm_destroy(void);
+
+/* Add trace entry. not safe, but will do */
+/*void bm_trace(int loc, unsigned long p1, unsigned long p2);*/
+void bm_trace(int loc, unsigned long p1, unsigned long p2);
+
+#else  /* #ifdef TI_PROFILING */
+
+#define bm_trace(loc, p1, p2)
+#define bm_init(drv)
+#define bm_destroy()
+
+#endif /* #ifdef TI_PROFILING */
+
+/* Dummy trace macro */
+#define dbm_trace(loc, p1, p2)
+
+#endif
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/debug_module.h b/sta_dk_4_0_4_32/pform/linux/inc/debug_module.h
new file mode 100644 (file)
index 0000000..b894392
--- /dev/null
@@ -0,0 +1,114 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/**************************************************************************/
+
+#ifndef _DEBUG_MODULE_H
+#define _DEBUG_MODULE_H
+
+#include "osTIType.h"
+#include "debug_module_ioctl.h"
+
+/*****************************************************/
+/*****************************************************/
+/* Debug mode - use this define to debug this module */
+/* #define DEBUG_THIS_MODULE*/
+
+#ifdef DEBUG_THIS_MODULE
+  #ifdef _WINDOWS
+  #else  /* ifdef __LINUX__ */
+       #define DEBUG_MESSAGE(_msg) (report_d _msg)
+  #endif
+#else /* DEBUG_THIS_MODULE */
+       #define DEBUG_MESSAGE(_msg)
+#endif /* DEBUG_THIS_MODULE */
+
+/*****************************************************/
+/*****************************************************/
+
+#define MAX_CHAR_DRIVERS                                        (2)
+
+#define MAX_CHAR_DRIVER_NAME                            (30)
+#define SPI_CHAR_DRIVER_NAME                            ("SPI_char_driver")
+#define DEBUG_MSG_CHAR_DRIVER_NAME                      ("Debug_messages_char_driver")
+
+#define SPI_CHAR_DRIVER                                                 (0)
+#define DEBUG_MSG_CHAR_DRIVER                           (1)
+
+#define ENQUEUE_MESSAGE_CONTROL_SIZE            (1)
+#define CONTROL_CODE_TYPE_MESSAGE                       (0)
+
+#define REPORT_MESSAGE_PARAMS                           (3)
+#define REPORT_MESSAGE_LEN                                      (sizeof(unsigned int) * REPORT_MESSAGE_PARAMS)
+
+#define DEBUG_MODULE_TRACE_QUEUE_ID                     (0)
+
+typedef struct  
+{
+       unsigned int read_pointer;              /* Current read pointer */
+       unsigned int write_pointer;             /* Current write pointer */
+       unsigned int used_size;                 /* The used data size */
+       unsigned int size;                              /* Total size of the buffer */
+       unsigned int overrun_count;     /* Number of packets that were run over */
+
+       tiBOOL           waiting_for_data;      /* TRUE if the user mode is pending */ 
+} t_queue_status;
+
+extern tiBOOL module_enable;
+extern int *buffers_default_size[MAX_CHAR_DRIVERS];
+extern UINT8  *buffers[MAX_CHAR_DRIVERS];                                                                      /* Pointer to the allocated buffder */
+
+
+void init_queue(UINT8  device_index);
+
+unsigned char get_message_from_queue(UINT8 device_index, t_ioctol1_format *ioctl_data);
+void get_queue_information(UINT8 device_index, unsigned int *report_msg);
+tiBOOL debug_module_enqueue_message(UINT8 queue_id, UINT8 param, void *p_msg, unsigned int len, UINT8  message_type);
+
+tiBOOL debug_module_logic_allocate_queue(UINT8 device_index, UINT8 size_in_k);
+void debug_module_logic_deallocate_queue(UINT8 device_index, UINT8 size_in_k);
+
+/* OS depended function prototypes */
+void os_cmd_spin_lock_irqsave(void);
+void os_cmd_spin_unlock_irqrestore(void);
+void os_cmd_up(void);
+void os_cmd_down_interruptible(void);
+void os_cmd_copy_to_user(void *destination, const void *source, unsigned int size);
+void *os_malloc (UINT32 size);
+void os_free (void *p, UINT32 size);
+
+
+#endif /* _DEBUG_MODULE_H */
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/debug_module_ioctl.h b/sta_dk_4_0_4_32/pform/linux/inc/debug_module_ioctl.h
new file mode 100644 (file)
index 0000000..0f02553
--- /dev/null
@@ -0,0 +1,55 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef DEBUG_MODULE_IOCTL_H
+  #define DEBUG_MODULE_IOCTL_H
+
+  typedef struct  
+  {
+       unsigned char buffer_size;              /* buffer max size */
+       void *buffer;                                   /* output buffer address */
+       unsigned char *return_size;     /* how many bytes copied to the buffer */
+  } t_ioctol1_format;
+
+  #ifndef _WINDOWS
+    #define DEBUG_MODULE_IOCTL_GET_MESSAGE_FROM_USER (10)
+    #define DEBUG_MODULE_IOCTL_GET_QUEUE_INFORMATION (11)
+  #endif /* ifdef __LINUX__ */
+
+  #ifdef _WINDOWS
+  #endif /* ifdef _WINDOWS */
+#endif /* DEBUG_MODULE_IOCTL_H */
+
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h b/sta_dk_4_0_4_32/pform/linux/inc/esta_drv.h
new file mode 100644 (file)
index 0000000..8e9c07d
--- /dev/null
@@ -0,0 +1,289 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef ESTA_DRV_INCLUDE_FILE
+#define ESTA_DRV_INCLUDE_FILE
+
+#include <linux/version.h>
+#include <linux/completion.h>
+#include <linux/netdevice.h>
+#include <linux/interrupt.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+#include <asm/arch/gpio.h>
+#else
+#include <mach/gpio.h>
+#endif
+
+#ifdef CONFIG_ANDROID_POWER
+#include <linux/android_power.h>
+#endif
+
+#include "osTIType.h"
+#include "osAdapter.h"
+#include "paramOut.h"
+#ifndef GWSI_DRIVER /* for GWSI Stand Alone */
+#include "configMgr.h"
+#endif
+#include "linux_ioctl_common.h"
+
+#define TIWLAN_DRV_NAME    "tiwlan"
+#define TIWLAN_DRV_IF_NAME TIWLAN_DRV_NAME"%d"
+#define TIWLAN_DRV_NAME_WIRELESS_PROTO "IEEE 802.11-DS"
+
+#ifdef TIWLAN_MSM7000
+extern int trout_wifi_power(int on);
+extern void trout_wifi_reset(int on);
+extern void trout_wifi_set_carddetect(int val);
+#endif
+
+#ifndef TIWLAN_OMAP1610_REGBASE
+
+#if defined(TIWLAN_OMAP1610_INNOVATOR)
+#define TIWLAN_OMAP1610_REGBASE        0xEC100000      /* VA*/
+#elif defined(TIWLAN_OMAP1610_WIPP) || defined(TIWLAN_OMAP1610_CRTWIPP) 
+#ifndef OMAP_WLAN_BASE
+#define OMAP_WLAN_BASE  0
+#endif
+#define TIWLAN_OMAP1610_REGBASE        (OMAP_WLAN_BASE+0x100000)
+#else
+/* Dm: #error TIWLAN_OMAP1610_REGBASE not defined for this platform */
+#endif
+
+#endif /* #ifndef TIWLAN_OMAP1610_REGBASE */
+
+#ifdef TIWLAN_OMAP1610_REGBASE
+
+#define TIWLAN_OMAP1610_REGSIZE 0x10000
+#define TIWLAN_OMAP1610_MEMBASE (TIWLAN_OMAP1610_REGBASE | 0x20000)
+#define TIWLAN_OMAP1610_MEMSIZE 0x10000
+
+#endif /* #ifdef TIWLAN_OMAP1610_REGBASE */
+
+#ifndef TIWLAN_OMAP1610_IRQ
+
+#if defined(TIWLAN_OMAP1610_INNOVATOR)
+#define TIWLAN_OMAP1610_IRQ     (OMAP_GPIO_IRQ(8))
+#elif defined(TIWLAN_OMAP1610_CRTWIPP)
+#define TIWLAN_OMAP1610_IRQ     (OMAP_GPIO_IRQ(2))
+#elif defined(TIWLAN_OMAP1610_WIPP)
+#define TIWLAN_OMAP1610_IRQ     (OMAP_GPIO_IRQ(2))
+#endif
+
+#endif  /* TIWLAN_OMAP1610_IRQ */
+#define TIWLAN_IRQ_POLL_INTERVAL  HZ/100  /* Used when no Intr are handled from the FW */
+
+
+#ifdef TI_DBG
+#define ti_dprintf(log, fmt, args...) do { \
+   if (log != TIWLAN_LOG_OTHER) {   \
+      printk(KERN_INFO fmt, ## args); \
+   } \
+} while (0)
+#else
+#define ti_dprintf(log, fmt, args...)
+#endif
+
+
+#define ti_nodprintf(log, fmt, args...)
+
+typedef enum {
+   TIWLAN_LOG_ERROR,
+   TIWLAN_LOG_INFO,
+   TIWLAN_LOG_OTHER,
+   TIWLAN_LOG_DUMMY
+} tiwlan_log_t;
+
+typedef struct tiwlan_region {
+      unsigned long pa;
+      void *va;
+      unsigned long size;
+} tiwlan_region_t;
+
+/* Driver structure */
+typedef struct tiwlan_net_dev tiwlan_net_dev_t;
+
+#if defined (__KERNEL__)
+/* Request/response to/from control tasklet */
+typedef struct tiwlan_req {
+      struct list_head list;
+      tiwlan_net_dev_t *drv;
+      struct
+      {
+            struct {
+                  int (*f)(struct tiwlan_req *req);
+                  unsigned long p1;
+                  unsigned long p2;
+                  unsigned long p3;
+                  unsigned long p4;
+                  int reply_expected;     /* 1=reply expected */
+                  struct completion comp;
+            } req;
+            int reply;
+      } u;
+} tiwlan_req_t;
+
+/* Timer structure */
+typedef struct timer_obj {
+      tiwlan_req_t req;
+         /* Timer handler function ->p1 */
+         /* Timer handler function parameter ->p2 */
+         /* Periodic ->p3 */
+         /* jiffies ->p4 */
+      struct timer_list  timer;
+      int use_count;
+} timer_obj_t;
+
+
+#ifdef DRIVER_PROFILING
+
+/* Profiler banchmark function type */
+typedef void (*tiwlan_pfofile_t) (void*, unsigned);
+
+/* Maximum number of profile banchmarks */
+#define MAX_PROFILE_BM 10
+
+#endif
+
+#ifdef CONFIG_TROUT_PWRSINK
+#define PWRSINK_WIFI_PERCENT_BASE 4
+#endif
+
+/* #define DM_USE_WORKQUEUE */
+
+/* Driver structure */
+struct tiwlan_net_dev {
+      struct list_head list;
+
+      tiwlan_region_t acx_mem;
+      tiwlan_region_t acx_reg;
+      tiwlan_region_t eeprom_image;
+      tiwlan_region_t firmware_image;
+      int irq;
+#ifdef DM_USE_WORKQUEUE
+      struct workqueue_struct *tiwlan_wq; /* Work Queue */
+      struct work_struct tirq;         /* Work Task for interrupt */
+      struct work_struct tw;           /* Work Task for other stuff */
+      mem_MSDU_T *txmit_msdu_next;
+      mem_MSDU_T *txmit_msdu_last;
+      struct work_struct txmit;        /* Work Task for transmit */
+#else
+      struct tasklet_struct tl;        /* Control tasklet */
+#endif
+#ifdef CONFIG_TROUT_PWRSINK
+      struct delayed_work trxw;        /* Work Task for rx watchdog */
+#endif
+#ifdef CONFIG_ANDROID_POWER
+      android_suspend_lock_t irq_wake_lock; /* Suspend Lock to keep system awake */
+      android_suspend_lock_t xmit_wake_lock;
+      android_suspend_lock_t timer_wake_lock;
+      android_suspend_lock_t rx_wake_lock;
+      int receive_packet;              /* 1=packet was pushed to network stack */
+#endif
+      int interrupt_pending;           /* 1=tasklet has to handle interrupts when awakes */
+      int dma_done;
+      struct list_head request_q;      /* Requests queue: -> tasklet */
+      spinlock_t lock;
+      unsigned long flags;
+      struct timer_list poll_timer;    /* Polling timer. Used only when working without interrupts */
+      int started;                     /* 1=config manager started. 0=config manager stopped */
+      int initialized;                 /* 1=succeeded to pass init stage, 0=otherwise */     
+      int unload_driver;               /* Driver unload indicator */
+      struct net_device_stats stats;
+      int alloc_msdu_failures;         /* Extra statistics */
+      initTable_t  init_table;
+      TIWLN_ADAPTER_T adapter;
+      struct sock *wl_sock;
+      struct completion comp;
+      struct net_device *netdev;
+      void *priv;                      /* Pointer to struct net_device */
+
+#ifdef DRIVER_PROFILING
+      tiwlan_pfofile_t fpro [MAX_PROFILE_BM];   /* Profiler functions */
+
+      unsigned max_number_of_timers;            /* Maximum number of allocated timers */
+      unsigned cur_number_of_timers;            /* Current number of allocated timers */
+
+      unsigned max_heap_bytes_allocated;        /* Maximum number of allocated bytes on the heap */
+      unsigned cur_heap_bytes_allocated;        /* Current number of allocated bytes on the heap */
+      unsigned max_buf_bytes_allocated;         /* Maximum number of allocated bytes on the heap for TX/RX buffers */
+
+      unsigned cpu_usage_estimator_start_time;  /* Time measured when CPU estimation was started */
+      unsigned cpu_usage_estimator_stop_time;   /* Time measured when CPU estimation was stopped */
+      unsigned cpu_usage_estimator_resolution;  /* Resolution of the CPU estimation in us */
+      unsigned total_us_of_cpu_time;            /* Total number of CPU time used by the driver since CPU estimator started */
+      unsigned total_us_of_bus_access_cpu_time; /* Total number of CPU time used by the bus driver since CPU estimator started */
+      unsigned driver_entry_start_time;         /* Time measured at the start of last driver entry point */
+      unsigned bus_driver_entry_start_time;     /* Time measured at the start of last bus driver entry point */
+#endif
+
+#ifdef GWSI_DRIVER
+      void *gwsi;                      /* GWSI manager handler */
+      void *gwsi_ev;                   /* GWSI event handler */
+      char  gwsi_tester_buf [4096];    /* GWSI tester buffer */                                        
+#endif
+};
+
+
+#define VENDOR_ID_TI            0x104c
+#define DEVICE_ID_TI_WLAN       0x9066
+
+/* tiwlan_send_wait_reply
+   This internal interface function creates request and sends
+   it to the control tasklet for processing.
+   The calling process is blocked until the request is replied.
+   Function f is being called in the context of the control tasklet.
+   The request block that is passed to the function as a parameter
+   contains p1, p2, p3, p4.
+   The function return code is propagated back to the caller.
+   tiwlan_send_req_and_wait returns (*f) return code or
+   -ENOMEM if failed to allocate a request.
+*/
+int tiwlan_send_wait_reply(tiwlan_net_dev_t *drv,
+                           int (*f)(tiwlan_req_t *req),
+                           unsigned long p1,
+                           unsigned long p2,
+                           unsigned long p3,
+                           unsigned long p4);
+
+#endif /* #if defined (__KERNEL__)*/
+
+int tiwlan_init_drv(tiwlan_net_dev_t *drv, tiwlan_dev_init_t *init_info);
+int tiwlan_start_drv(tiwlan_net_dev_t *drv);
+int tiwlan_stop_drv(tiwlan_net_dev_t *drv);
+int tiwlan_stop_and_destroy_drv(tiwlan_net_dev_t *drv);
+int tiwlan_ioctl_init(struct net_device *dev);
+
+#endif /* ESTA_DRV_INCLUDE_FILE*/
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/ioctl_init.h b/sta_dk_4_0_4_32/pform/linux/inc/ioctl_init.h
new file mode 100644 (file)
index 0000000..41e1412
--- /dev/null
@@ -0,0 +1,76 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef TI1610_IOCTL_INIT
+#define TI1610_IOCTL_INIT
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "srcApi.h"
+
+#ifndef DRIVER_NAME
+#define DRIVER_NAME "TIWLAN"
+#endif
+
+#if defined(DEBUG_MESSAGES)
+#  define print_deb(fmt, arg...) printk(KERN_INFO DRIVER_NAME ": " fmt,##arg)
+#else
+#  define print_deb(fmt, arg...) 
+#endif
+
+#if defined(OS_INFO_MESSAGES)
+#  define print_info(fmt, arg...) printk(KERN_INFO DRIVER_NAME ": " fmt,##arg)
+#else
+#  define print_info(fmt, arg...)
+#endif
+
+#ifndef print_err
+#  define print_err(fmt, arg...) printk(KERN_ERR DRIVER_NAME ": " fmt,##arg)
+#endif
+
+/* extern const struct iw_handler_def ti1610_handler_def; */
+#include <linux/netdevice.h>
+#include "linux_ioctl_common.h"
+
+#define IS_CONFIG_MGR_STARTED(d)   (((tiwlan_net_dev_t *) (d)->priv)->started)
+#define TEST_CONFIG_MGR_STARTED(d)  if( !IS_CONFIG_MGR_STARTED(d))  {\
+                                print_err("Error: ConfigManager not STARTED!!\n");\
+                                return -EACCES;\
+                            }
+                                
+
+#endif /* TI1610_IOCTL_INIT */
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/mmc_omap_api.h b/sta_dk_4_0_4_32/pform/linux/inc/mmc_omap_api.h
new file mode 100644 (file)
index 0000000..51aace8
--- /dev/null
@@ -0,0 +1,570 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef MMC_OMAP_API_H
+#define MMC_OMAP_API_H
+
+#ifdef __LINUX__
+#include <asm/io.h>    /* include for SDIO Compilation */
+#endif
+
+/*
+   SDIO_SUCCESS,
+   SDIO_FAILURE - API return code (means success or failure of command invocation 
+   in unblocking mode and success or failure of command completion in blocking mode).
+   SDIO_BUSY - Busy means that bus is not avilable.
+   SDIO_BAD_ALIGNMENT - Bad alignment means that data passed for DMA transaction 
+   has been not aligned.
+   SDIO_TIMEOUT - Timeout menas that attempt to acquire bus was failed.
+   SDIO_BAD_INPUT_PARAMS - Bad input parameters means that parameters failed validation.
+   SDIO_BAD_ADDRESS - Input peripheral address is not in valid range.
+   SDIO_PACKET_SIZE_AND_MODE_INCONSISTENCY - Packet size inconsistency means that packet 
+   size does not fit the transaction mode (synchronous or asynchronous).
+   SDIO_CONTEXT_AND_MODE_INCONSISTENCY - Context inconsistency means that API has been 
+   called from context that has some conflicts with API input parameters.
+   SDIO_NON_AFFECTED - action was not failed, but it has no influence. 
+*/
+typedef enum {
+       SDIO_SUCCESS=0,
+       SDIO_FAILURE,
+       SDIO_BUSY,
+       SDIO_BAD_ALIGNMENT,
+       SDIO_TIMEOUT,
+       SDIO_BAD_INPUT_PARAMS,
+       SDIO_BAD_PERIPHERAL_ADDRESS,
+       SDIO_PACKET_SIZE_AND_MODE_INCONSISTENCY,
+       SDIO_CONTEXT_AND_MODE_INCONSISTENCY,
+       SDIO_NO_RESOURCES,
+       SDIO_NON_AFFECTED,
+} SDIO_Status;
+/* Pointer to the SDIO memory-mapped address space */
+typedef unsigned long SDIO_Address; 
+
+/* Peripheral address space */
+typedef unsigned long Peripheral_Address;
+
+/* 
+   SDIO_BufferLength: The length of the transaction. 
+   In byte-basis operation, this length is the number of 
+   bytes in the transaction. In block-basis operation, this 
+   length is the number of blocks in the transaction.
+*/
+typedef unsigned int SDIO_BufferLength;
+/* SDIO device driver activation states */
+typedef enum {
+       SDIO_Activation_InactiveState,    /* non initialized state */
+       SDIO_Activation_InitializedState, /* state after initialization or after stop */
+       SDIO_Activation_ActiveState,      /* state after start */
+       SDIO_Activation_PowerSaveState,   /* to be defined */
+       SDIO_Activation_EnchancedPowerSaveState,/* to be defined */
+       SDIO_Activation_None,
+} SDIO_ActivationState;
+
+/* Bus statuses */
+typedef enum {
+       SDIO_Bus_Busy,           /* in processing */
+       SDIO_Bus_Wait_Queue,     /* in processing - wait for the request from queue */
+       SDIO_Bus_Wait_Async,     /* in processing - wait for the asynchronous response */
+       SDIO_Bus_Available,      /* available for use */
+       SDIO_Bus_None,
+} SDIO_BusStatus;
+/* SDIO request statuses */
+typedef enum {
+       SDIO_Request_Completed = 0, /* last request has been successfully completed */
+       SDIO_Request_InProgress,    /* last request is still in progress */
+       SDIO_Request_FailedTimeOut, /* last request has been failed - timeout */
+       SDIO_Request_FailedCRC,     /* last request has been failed - CRC */
+       SDIO_Request_FailedSubmit,  /* last request has been failed - submit request */
+       SDIO_Request_Rejected,      /* last request has been rejected */
+       SDIO_Request_ReadFailed,    /* last read request has been failed */
+       SDIO_Request_WriteFailed,   /* last write request has been failed */
+       SDIO_Request_None,          /* no request has been submitted */
+} SDIO_RequestStatus;
+
+/* 
+   SDIO_RequestMode - how to proccess request.
+   SDIO read or write transaction mode.
+   OP Code 0 is used to read or write multiple bytes of 
+   data to/from a single I/O register address. 
+   This command is useful when I/O data is transferred 
+   using a FIFO inside of the I/O device. In this case, 
+   multiple bytes of data are transferred to/from a single 
+   register address.  
+   OP Code 1 is used to read or write multiple bytes of 
+   data to/from an I/O register address that increment 
+   by 1after each operation. This command is used used when 
+   large amounts of I/O data exist within the I/O card in a 
+   RAM like data buffer.
+*/
+
+typedef char SDIO_FunctionNumber; /* SDIO protocol function Id */
+typedef unsigned int SDIO_RequestMode;
+typedef unsigned int SDIO_BlockSize; /* Block size in case of SDIO is working in block mode */
+typedef unsigned int SDIO_ReportLevel; /* Debug report level */
+typedef unsigned int SDIO_DMAThreshold; /* Threshold with regards to DMA read and write operations */
+typedef void* SDIO_Handle; /* SDIO handle as returned from init routine (SDIO_Init) */
+typedef void* SDIO_Owner;  /* handle of the object called SDIO_Init */
+typedef struct SDIO_Request SDIO_Request_t;
+/* 
+   User callback function for request completion notification 
+*/
+typedef void (*FNotify)(struct SDIO_Request *, int status);
+
+/* 
+   User callback function for request error notification 
+*/
+typedef void (*FError)(struct SDIO_Request *, int status);
+
+/* Request external format */
+struct SDIO_Request {
+   u16                  block_len;      /* Block length. Zero means byte mode */
+   u8            *buffer;        /* Pointer to the data buffer. Data must be 
+                                    contiguously allocated and write and release
+                                    protected by application. */
+   unsigned long physical_buffer;/* Physical address of the same buffer */
+   u16           buffer_len;     /* Data buffer length in bytes */
+   SDIO_Address  peripheral_addr;/* SDIO peripheral address */
+   u32           acquire_window; /* Time out value. If not zero, means in case SDIO resources 
+                                    are not available, try to acquire it within acquire_window
+                                    time. Return with busy resources indication in case 
+                                    of expiration. */
+   u8           enqueue_flag;   /* 0 - reject request if bus is not avaialable;
+                                   1 - put request into waiting list.
+                                   This field is relevant only for synchronous requests.
+                                   In case acquire_window is not zero - the attempt to wait
+                                   for free bus is to be performed and this flag is ignored. */
+   SDIO_RequestMode mode;       /* One of the following values: 
+                                   - MMC_DEV_BYTE_INCREMENTAL_MODE     
+                                   - MMC_DEV_BLOCK_INCREMENTAL_MODE  
+                                   - MMC_DEV_BYTE_FIXED_MODE    
+                                   - MMC_DEV_BLOCK_FIXED_MODE */ 
+   SDIO_RequestStatus status;   /* Request complition or progress status */
+   SDIO_Handle          handle;         /* SDIO object handle */
+   SDIO_Owner   owner;          /* SDIO object owner handle */
+   void          *user;          /* Lower level handle */
+   u8            access_flag;    /* 0 means write operation !0 - read */
+   FNotify       fnotify;       /* callback for request completion notification */
+   FError        ferror;         /* callback for request error notification */
+};
+
+/* 
+   Peripheral configuration function 
+*/
+typedef void Peripheral_ConfigParams;
+typedef SDIO_Status (*FPeripheral)(SDIO_Handle, Peripheral_ConfigParams **);
+
+/* 
+   Convert peripheral adddress into 17 bits SDIO address.
+   Default empty function is provided for the case when a caller 
+   supplies already converted address.
+*/
+typedef SDIO_Address (*FConvert)(Peripheral_Address, SDIO_BufferLength);
+
+/* Constants that are used for device driver configuration and tuning */
+#define MMC_DEV_TIWIPP_CONFIG_SDIO1          0x00000001 /* use SDIO port 1 */
+#define MMC_DEV_TIWIPP_CONFIG_SDIO2          0x00000002 /* use SDIO port 2 */
+#define MMC_DEV_TIWIPP_CONFIG_SDDETECT_EN    0x00000004 /* auto detection is enable */
+#define MMC_DEV_INIT_BE_MODE                 0x00000010 /* big endian mode */
+#define MMC_DEV_INIT_LE_MODE                 0x00000020 /* little endian mode */
+#define MMC_DEV_IRQ_NOTIFY_MODE              0x00000100 /* request notify in irq */
+#define MMC_DEV_TASKLET_NOTIFY_MODE          0x00000200 /* request notify in tasklet */
+#define MMC_DEV_SDIO_BUS_WIDTH_1             0x00001000 /* 1-bit bus mode */
+#define MMC_DEV_SDIO_BUS_WIDTH_4             0x00002000 /* 4-bit bus mode */
+#define MMC_DEV_CALLBACK_BLOCKING_MODE       0x00010000 /* callbacks in blocking mode */
+#define MMC_DEV_CALLBACK_ASYNC_MODE          0x00020000 /* callbacks in asynchronous mode */
+#define MMC_DEV_DMA_ONE_CHUNK_MODE           0x01000000 /* buffer size <= transaction */
+#define MMC_DEV_DMA_MULTI_CHUNK_MODE         0x02000000 /* buffer size = n*transaction */
+#define MMC_DEV_CONTIGUOUSE_MEMORY_MODE      0x10000000 /* memory convergence is required */
+#define MMC_DEV_NON_CONTIGUOUSE_MEMORY_MODE  0x20000000 /* memory copy is required */
+#define MMC_DEV_VIRTUAL_MEMORY_MODE         0x40000000 /* application passes virtual address */
+#define MMC_DEV_PHYSICAL_MEMORY_MODE        0x80000000 /* application passes physical address*/
+#define MMC_DEV_DEFAULT_CLOCK_RATE           24000000  /* clock rate value (24MHz) */
+#define MMC_DEV_DEFAULT_AFL_SIZE                     2 /* 16-bit words used by DMA write */
+#define MMC_DEV_DEFAULT_AEL_SIZE                     2 /* 16-bit words used by DMA read */
+#define MMC_DEV_DEFAULT_VDD_VOLTAGE_WINDOW   0xFFFFC0   /* 0xFFFF00 is 2.0-3.6 volts window */
+#define MMC_DEV_MAX_FIFO_SIZE                        64 /* controller size in bytes */
+#define MMC_DEV_MIN_AFL_AEL_SIZE                      2 /* 2 16-bit words used by DMA */
+/* Static configuration parameters.*/
+typedef struct {
+       SDIO_Owner owner;              /* caller id */
+       unsigned int config_flags;     /* combination of the above "mode" values */
+       unsigned int clock_rate;       /* initial clock rate of SDIO bus in microseconds */
+       unsigned int size_for_afl;     /* AFL of MMC_BUF register (number of 16-bit words) */
+       unsigned int size_for_ael;     /* AEL of MMC_BUF register (number of 16-bit words) */
+       unsigned int vdd_voltage_window; /* VDD voltage window - OCR values */
+       /* User callback function for request completion notification */
+       FNotify fnotify_read;/* callback for read request completion notification */
+       FNotify fnotify_write;/* callback for write request completion notification */
+       FError ferror; /* callback for request error notification */
+       FPeripheral fconfig_peripheral; /* to be assigned to configuration peripheral target */
+       FConvert fconvert; /* convert peripheral address to host address function */
+} SDIO_ConfigParams;
+
+/* Clock and DMA threshold values – should be tuned */
+#define MMC_DEV_MASTER_CLOCK                48000000 /* deviser=MASTER_CLOCK/CLOCK_RATE */
+#define MMC_DEV_DATA_ALIGNMENT_DEFAULT            4
+#define MMC_DEV_DATA_BLOCK_SIZE_DEFAULT                 512
+#define MMC_DEV_WRITE_BYTE_DMA_THRESHOLD_DEFUALT   MMC_DEV_DEFAULT_AFL_SIZE
+                                                  /* use DMA for packet size > threshold */
+#define MMC_DEV_READ_BYTE_DMA_THRESHOLD_DEFUALT    MMC_DEV_DEFAULT_AEL_SIZE
+                                                  /* use DMA for packet size > threshold */
+#define MMC_DEV_FUNCTION_NUMBER_DEFUALT           1 /* default function code Id */
+#define MMC_DEV_BLOCK_MODE                0x01000000 /* transaction size in blocks */
+#define MMC_DEV_BYTE_MODE                 0x02000000 /* transaction size in bytes */
+#define MMC_DEV_INCREMENTAL_ADDRESS       0x10000000 /* transaction with OP code 0 */
+#define MMC_DEV_FIXED_ADDRESS             0x20000000 /* transaction with OP code 1 */
+#define MMC_DEV_BYTE_INCREMENTAL_MODE     (MMC_DEV_BYTE_MODE|MMC_DEV_INCREMENTAL_ADDRESS)
+#define MMC_DEV_BLOCK_INCREMENTAL_MODE    (MMC_DEV_BLOCK_MODE|MMC_DEV_INCREMENTAL_ADDRESS)
+#define MMC_DEV_BYTE_FIXED_MODE           (MMC_DEV_BYTE_MODE|MMC_DEV_FIXED_ADDRESS)
+#define MMC_DEV_BLOCK_FIXED_MODE          (MMC_DEV_BLOCK_MODE|MMC_DEV_FIXED_ADDRESS)
+/* Dynamic configuration parameters */
+typedef struct {
+       unsigned int write_bytes_threshold;
+       unsigned int read_bytes_threshold;
+       char card_function_code; /* Card function code */
+#ifdef CONFIG_MMC_DEBUG
+       unsigned int report_level;
+#endif
+} SDIO_DynamicParams;
+
+/* 
+  This function initializes the SDIO host controller. 
+  After the function is completed SDIO controller is 
+  ready for SDIO interface activating.  
+  The function creates SDIO object and returns a pointer to SDIO handler.
+  This function does not communicate with SDIO controller.
+*/
+SDIO_Status SDIO_Init(SDIO_ConfigParams*, SDIO_Handle*);
+/* 
+  This function frees all resources and destroys SDIO object.
+*/
+SDIO_Status SDIO_Shutdown(SDIO_Handle);
+/*
+   This function activates configured setup for the SDIO device.
+*/
+SDIO_Status SDIO_Start(SDIO_Handle);
+/*
+   This function disconnects the host CPU from the slave SDIO device. 
+   wait_window if non zero means to wait until last transaction is
+   completed or until wait_window is expired and only after that 
+   disconnect. 
+   wait_window has to be always zero in case API is called from
+   hardware interrupt context.
+*/
+SDIO_Status SDIO_Stop(SDIO_Handle, unsigned long wait_window);
+
+/*
+   This function re-activates configured setup for the SDIO device.
+   This function can be used for recovery purpose.
+   It performs the same set of actions like SDIO_Start with regard to 
+   SDIO controller. In addition it reset the bus state to the initial 
+   value, it drops a non-competed transaction if exist, it drops whole 
+   SDIO request (in case the request is multi transaction), in case such 
+   request is in progress.
+*/
+SDIO_Status SDIO_Reset(SDIO_Handle);
+/*
+   This function reads from SDIO interface. 
+   The input address is SDIO_Address, which is a pointer to 
+   the SDIO address space. The output address is local pointer in the virtual 
+   address space. 
+   The driver should convert the virtual address space to physical address 
+   space in case of DMA operation.
+   Read operation can't be processed in case SDIO interface is occupied by 
+   other transaction. But in case acquire_window in input request is not zero,
+   routine should try to acquire SDIO interface within acquire window.
+
+   request->buf            - pointer to the data buffer. Data must be contiguously allocated 
+                             and write and release protected by application.
+   request->physical_buffer- physical address of the same buffer.
+   request->buf_len        - data buffer length in bytes. It contains the number of 
+                             bytes that is requested to be read.
+                             The number of bytes that have been read within each transaction 
+                             is to be returned (one request can contain several transactions).
+   request->peripheral_addr- SDIO peripheral address.
+   request->acquire_window - time out value. If not zero, means in case SDIO resources 
+                             are not available, try to acquire it within acquire_window
+                             time. Return with busy resources indication in case  of
+                             expiration.
+   request->enqueue_flag   - flag indicating whether to put or not syncronouse request into
+                            device waiting list.
+   request->mode           - flag that is a valid combination of the following constants:  
+                             - MMC_DEV_BLOCK_MODE or MMC_DEV_BYTE_MODE;         
+                             - MMC_DEV_INCREMENTAL_ADDRESS or MMC_DEV_FIXED_ADDRESS.
+  
+   Upon request completion, the result is to be returned to the request 
+   originator.
+*/
+SDIO_Status SDIO_SyncRead(SDIO_Handle, SDIO_Request_t*);
+
+/*
+   The input address is a local pointer in the virtual address space.
+   The output address is SDIO_Address, which is a pointer to the SDIO 
+   address space.
+   Write operation can't be processed in case SDIO interface is occupied by 
+   other transaction. But in case acquire_window in input request is not zero,
+   routine should try to acquire SDIO interface within acquire window.
+
+   request->buf            - pointer to the data buffer. Data must be contiguously allocated 
+                             and write and release protected by application. 
+   request->physical_buffer- physical address of the same buffer. 
+   request->buf_len        - data buffer length in bytes. It contains the number of 
+                             bytes that is requested to be read.
+                             The number of bytes that have been written within each transaction 
+                             is to be returned (one request can contain several transactions).
+   request->peripheral_addr- SDIO peripheral address.
+   request->acquire_window - time out value. If not zero, means in case SDIO resources 
+                             are not available, try to acquire it within acquire_window
+                             time. Return with busy resources indication in case  of
+                             expiration.
+   request->enqueue_flag   - flag indicating whether to put or not syncronouse request into
+                            device waiting list.
+   request->mode           - flag that is a valid combination of the following constants:  
+                             - MMC_DEV_BLOCK_MODE or MMC_DEV_BYTE_MODE;         
+                             - MMC_DEV_INCREMENTAL_ADDRESS or MMC_DEV_FIXED_ADDRESS.
+  
+   Upon request completion, the result is to be returned to the request 
+   originator.
+*/
+SDIO_Status SDIO_SyncWrite(SDIO_Handle, SDIO_Request_t*);
+
+#ifdef CONFIG_ASYNC_API
+/*
+   This function reads from SDIO interface. 
+   Read operation request is to be proceeded in a chunks of 
+   pre-configured size (this size is set at the initialization time).
+   Upon part of the request completion (up to one chunk), the result 
+   is to be indicated through the related DMA callback.
+   The request control data, like number of bytes or blocks that 
+   should be read within transaction, bus status etc, are to be stored 
+   within request template.
+*/
+SDIO_Status SDIO_AsyncRead(SDIO_Handle, SDIO_Request_t*);
+
+/*
+   This function writes to SDIO interface.
+   Write operation request is to be proceeded in a chunks of 
+   pre-configured size (this size is set at the initialization time).
+   Upon part of the request completion (up to one chunk), the result is to 
+   be indicated through the related DMA callback.
+   The request control data, like number of bytes or blocks that should be 
+   read within transaction, bus status etc, are to be stored within request 
+   template.
+*/
+SDIO_Status SDIO_AsyncWrite(SDIO_Handle, SDIO_Request_t*);
+
+/* The same as SDIO_SyncKillRequest, but for asynchronous mode.
+   This function drops a non-competed transaction in case such transaction 
+   is exist, it drops whole SDIO request, in case such request is in progress.
+   A host communicating with SDIO device can abort data transfer just by 
+   writing to the ASx bits in the CCCR. Normally, the abort is used to 
+   stop an infinite block transfer (block count=0). If an exact number of 
+   blocks to be transferred, it is recommended that the host issue a block 
+   command with the correct block count, rather than using an infinite count 
+   and aborting the data at the correct time.
+   Additionally function runs user iterator function over each item from
+   driver asynchronous request queue. 
+ */
+SDIO_Status SDIO_AsyncKillRequest(SDIO_Handle sdioHandle, void(*fiterator)(void*, int));
+
+/* Go through asynchronous request queue and call fiterator function 
+   for each non empty entry.
+   Iterator function could be anything according to application needs: delete
+   entry, modify entry, print entry etc from asynchronous request queue.
+*/
+SDIO_Status SDIO_AsyncIterateQueue(SDIO_Handle sdioHandle, void(*fiterator)(void*, int));
+#endif /*CONFIG_ASYNC_API*/
+/*
+   Set activation mode - write it into sdio object control structure
+*/
+SDIO_Status SDIO_SetActivationState(SDIO_Handle, SDIO_ActivationState);
+
+/*
+   Get activation mode - read from sdio object control structure
+*/
+SDIO_ActivationState SDIO_GetActivationState(SDIO_Handle);
+/*
+   Set function number - write it into sdio object control structure
+*/
+SDIO_Status SDIO_SetFunctionNumber(SDIO_Handle, SDIO_FunctionNumber);
+
+/*
+   Get function number - read it from sdio object control structure
+*/
+SDIO_FunctionNumber SDIO_GetFunctionNumber(SDIO_Handle sdioHandle);
+/*
+   Set DMA threshold parameter for read transactions - write it into 
+   SDIO object control structure
+*/
+SDIO_Status SDIO_SetDMAReadThreshold(SDIO_Handle, SDIO_DMAThreshold);
+
+/*
+   Set DMA threshold parameter for write transactions - write it into 
+   SDIO object control structure
+*/
+SDIO_Status SDIO_SetDMAWriteThreshold(SDIO_Handle, SDIO_DMAThreshold);
+
+/*
+   Set sdio object debug report level - write it into sdio object control structure
+*/
+SDIO_Status SDIO_SetReportLevel(SDIO_Handle, SDIO_ReportLevel);
+
+/*
+   Set sdio object static parameters - write it into sdio object control 
+   structure. Initialization time only.
+*/
+SDIO_Status SDIO_SetStaticParams(SDIO_Handle sdioHandle, SDIO_ConfigParams *staticParams);
+
+/*
+   Get sdio object static parameters.
+   This function can be invoked at the initialization time only, it sets SDIO 
+   static parameters:
+   - sdio port (controller id);
+   - Card auto detection mode;
+   - Endian mode;
+   - Device driving mode (interrupt, polling or blind);
+   - Sdio bus width (1 or 4);
+   - Callback mode (blocking or non-blocking);
+   - Transfer mode (single or multi chunks);
+   - DMA channel allocation method (dynamic or static);
+   - Clock size.
+   SDIO object static parameters setting will be updated after validation, 
+   as following: object->static_params |= static_params.
+*/
+SDIO_ConfigParams *SDIO_GetStaticParams(SDIO_Handle sdioHandle);
+
+/*
+   Get sdio object dynamic parameters. 
+   This function can be invoked at the run-time, it sets SDIO parameters, 
+   for example:
+   - Activation mode;
+   - Function number;
+   - Read DMA threshold;
+   - Write DMA threshold;
+   - Report level;
+   - Transaction size (chunk);
+   SDIO object dynamic parameters setting will be updated after validation, 
+   as following: object->dynamic_params |= dynamic_params;
+*/
+SDIO_Status SDIO_SetDynamicParams(SDIO_Handle sdioHandle, SDIO_DynamicParams *dynamicParams);
+
+/*
+   Get sdio object dynamic parameters - write it into sdio 
+   object control structure.
+*/
+SDIO_DynamicParams *SDIO_GetDynamicParams(SDIO_Handle sdioHandle);
+/*
+   This function read bus status from SDIO object and returns it to 
+   the caller.
+   Note that bus status returned to the caller could be different 
+   from the real status, because this function does not run in a lock mode.
+*/
+SDIO_BusStatus SDIO_GetBusStatus(SDIO_Handle);
+/*
+   Set size of the block for the blocking mode.
+   The SDIO device may transfer data in an optional block format. 
+   The SDIO specification allows any block size from 1 byte to 2048 bytes
+   (power of 2) in order to accommodate the various natural block sizes 
+   for IO functions. Note that an SDIO card function may define a maximum 
+   block size or byte count in the CIS that is smaller than the maximum 
+   values described above.
+*/
+SDIO_Status SDIO_SetBlockSize(SDIO_Handle, SDIO_BlockSize);
+/*
+   This function can be used for recovery purpose.
+   This function drops a non-competed transaction in case such transaction 
+   is exist, it drops whole SDIO request, in case such request is in progress.
+   A host communicating with SDIO device can abort data transfer just by 
+   writing to the ASx bits in the CCCR. Normally, the abort is used to 
+   stop an infinite block transfer (block count=0). If an exact number of 
+   blocks to be transferred, it is recommended that the host issue a block 
+   command with the correct block count, rather than using an infinite count 
+   and aborting the data at the correct time.
+*/
+SDIO_Status SDIO_SyncKillRequest(SDIO_Handle);
+/*
+   Get status of the request executed last time.
+*/
+SDIO_RequestStatus SDIO_GetLastRequestStatus(SDIO_Handle);
+
+#ifdef CONFIG_FORCE_API
+/*
+   Like SDIO_SyncRead and SDIO_SyncWrite, but with enforcement to perform
+   transactions through DMA (only one chunck per transaction).
+   Both APIs must be called only in case the length of the buffer fits
+   the next condtition: 
+   MMC_DEV_MAX_FIFO_SIZE <= length <= MMC_DEV_DATA_BLOCK_SIZE_DEFAULT
+   For example:
+   sync_read_request.buffer = dest_addr;
+   sync_read_request.peripheral_addr = perph_addr;
+   sync_read_request.buffer_len = length;
+   if(lenght<MMC_DEV_MAX_FIFO_SIZE || length>MMC_DEV_DATA_BLOCK_SIZE_DEFAULT)
+      status=SDIO_SyncRead(pHwAccess->hSdio,&sync_read_request);
+   else
+      status=SDIO_ForceRead(pHwAccess->hSdio,&sync_read_request);
+   These APIs is faster then SDIO_SyncRead/SDIO_SyncWrite, but can be used
+   only for synchronous mode.
+*/
+SDIO_Status SDIO_ForceRead(SDIO_Handle sdioHandle, SDIO_Request_t *req);
+SDIO_Status SDIO_ForceWrite(SDIO_Handle sdioHandle, SDIO_Request_t *req);
+#endif
+
+#endif /* MMC_OMAP_API_H */
+
+
+
+
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/mmc_tnetw1150_api.h b/sta_dk_4_0_4_32/pform/linux/inc/mmc_tnetw1150_api.h
new file mode 100644 (file)
index 0000000..f158e7d
--- /dev/null
@@ -0,0 +1,115 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef MMC_TNETW1150_API_H
+#define MMC_TNETW1150_API_H
+
+#undef CONFIG_CEE
+#define CONFIG_CEE
+
+#include "mmc_omap_api.h"
+/* 
+   First partition is used to access first 90K of memory 
+   during FW download or 90K of data memory during WLAN driver 
+   regular work (0x00000-0x167FF; 0x00C800-0x22FFF - two 
+   regions with overlap).
+*/
+#define SDIO_DOWNLOAD_PARTITION_START  (0x000000)
+                                         /*  90K*/
+#define SDIO_DOWNLOAD_PARTITION_SIZE   (0x016800) 
+/*End of download partition is          (0x0167FF)    (90K)*/
+                                    /*  60K*/
+#define SDIO_MEM_PARTITION_START       (0x00F000)  
+                                    /*  90K*/ 
+#define SDIO_MEM_PARTITION_SIZE                (0x016800)  
+/*End of first partition is             (0x025799)   (150K)*/
+
+/* 
+   Second partition is 34K of registers.
+*/
+                                    /*3072K*/
+#define SDIO_REG_PARTITION_START       (0x300000)   
+                                    /*  34K*/
+#define SDIO_REG_PARTITION_SIZE                (0x008800)  
+/*End of second partition is            (0x3087FF)  (3106K) */
+                                         /*  90K*/ 
+#define SDIO_DRIVER_REG_PARTITION_START (0x016800) 
+
+#define AMAP_MAX_REGIONS                        4
+                                /*128K-64B*/
+#define AMAP_ONE_REGION                (0x01FFC0)  
+
+/* Status Card Register (SCR) address mapping */
+typedef struct {
+       unsigned int reg_size;  /* Region size */
+       unsigned int scr_offset; /* Region offset in SCR address space */
+} address_mapping_region;
+typedef struct {
+       unsigned int num_of_parts; /* number of partitions in use */
+        /* h/w-dependant base addresses */
+        address_mapping_region map_reg[AMAP_MAX_REGIONS]; /* CSR addresses */
+} SDIO_TNETWConfigParams;
+/*
+  Initialization of TNETW memory configuration.
+*/
+SDIO_Status SDIO_TNETWInit(SDIO_TNETWConfigParams *);
+/* 
+  This function configures the slave SDIO device for the required 
+  operation mode.
+*/
+SDIO_Status SDIO_TNETWConfig(SDIO_Handle, Peripheral_ConfigParams **);
+/* 
+  This function performs convertion of peripheral adddress into 17 bits 
+  SDIO address. If found that the memory partition configuration must be 
+  changed, the memory is re-mapped in accordance to requested address.
+*/
+SDIO_Address SDIO_ConvertTNETWToSDIOMaster(Peripheral_Address, SDIO_BufferLength);
+
+/* 
+  This function sets the ELP REG in the TNET
+*/
+SDIO_Status SDIO_TNETW_Set_ELP_Reg(SDIO_Handle sdioHandle, Peripheral_Address start_addr, unsigned int data);
+
+/* 
+This function gets the ELP REG in the TNET
+*/
+SDIO_Status SDIO_TNETW_Get_ELP_Reg(SDIO_Handle sdioHandle, Peripheral_Address start_addr, unsigned int *data);
+
+#endif /* MMC_TNETW1150_API_H */
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/osAdapter.h b/sta_dk_4_0_4_32/pform/linux/inc/osAdapter.h
new file mode 100644 (file)
index 0000000..63c17c9
--- /dev/null
@@ -0,0 +1,100 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef __OSADAPTER_H_
+#define __OSADAPTER_H_
+
+# include "windows_types.h"
+
+#include "osApi.h"
+#include "osDebug.h"
+#include "paramOut.h"
+
+/**/
+/* This tag will appear in any crash dump of the system that occurs*/
+/* subsequently. The tag will be presented in the reverse order, so*/
+/* it would appear as 'TIWL' (TI Wireless Lan) if pool is dumped or*/
+/* when tracking pool usage in the debugger.*/
+/**/
+#define TIWLN_MEM_TAG                                          (*(PULONG)"LWIT")
+
+#define TI_VENDOR_ID                                           0x104C
+
+#define MAX_ADAPTERS_NUM                                       4
+#define MAX_MULTICAST_ADDRESSES                                32
+
+#define ETH_ADDR_SIZE                                          6
+#define ETH_HEADER_SIZE                     14
+
+#define MAX_IO_BUFFER_COMPLETE_SIZE                    300
+
+
+
+#define DISABLE_PENDING_OFF                                    0
+#define DISABLE_PENDING_AUTO                           1
+#define DISABLE_PENDING_ALWAYS                         2
+
+typedef struct {
+       TI_HANDLE               CoreHalCtx;            /* pointer to ConfigManager */
+    NDIS_HANDLE                ConfigHandle;
+    TI_HANDLE       hEvHandler;
+       ULONG                   LinkSpeed;
+       UCHAR                   CurrentAddr[ETH_ADDR_SIZE];
+       BOOLEAN                 bCurrentAddrFromRegistry;
+       OS_802_11_WEP   DefaultWepKeys[DOT11_MAX_DEFAULT_WEP_KEYS];
+       TI_HANDLE               SystemProtect;
+
+    BOOLEAN                    IntMode;
+       BOOLEAN                 ExtMode;
+
+    ULONG                      SlotNumber;
+    ULONG                      etherMaxPayloadSize;
+       BOOL                    EepromSupported;
+       UINT8           qosClassifierTable[OS_CLSFR_TABLE_SIZE];
+       PUINT8                  pIoBuffer;
+       PULONG                  pIoCompleteBuffSize ;
+       struct completion         *IoctlComp;
+       int                               *pCompleteReply;
+
+       UINT8                   IoCompleteBuff[MAX_IO_BUFFER_COMPLETE_SIZE];
+
+
+} TIWLN_ADAPTER_T, *PTIWLN_ADAPTER_T;
+
+
+
+#endif
+
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/osTIType.h b/sta_dk_4_0_4_32/pform/linux/inc/osTIType.h
new file mode 100644 (file)
index 0000000..945e888
--- /dev/null
@@ -0,0 +1,176 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef __OS_TYPES_H__
+#define __OS_TYPES_H__
+
+#include <linux/version.h>
+
+#ifndef VOID
+#define VOID        void
+#define PVOID       void*
+#endif
+
+#if !defined(FALSE)
+#define FALSE               0
+#endif
+
+#if !defined(TRUE)
+#define TRUE                1
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+#if !defined(false)
+#define false               0
+#endif
+
+#if !defined(true)
+#define true                1
+#endif
+#endif
+
+#ifndef NULL
+#if defined(__cplusplus)
+#define NULL 0
+#else
+#define NULL ((void *)0)
+#endif
+#endif /* NULL */
+
+#ifndef UNUSED
+#define UNUSED(p) ((void)p)
+#endif
+
+#ifndef SIZE_ARR
+#define SIZE_ARR(a) (sizeof(a)/sizeof(a[0]) )
+#endif
+/*
+#ifdef _UNICODE
+#define _T  unsigned short
+#else
+#define _T
+#endif
+*/
+#ifndef TI_HANDLE
+typedef void*           TI_HANDLE;
+#endif
+#define TI_HANDLE_INVALID   NULL
+#define TI_OK     0
+#define TI_ERROR -1
+
+typedef signed char                    INT8, *PINT8, *PCHAR;
+typedef unsigned char       UINT8, *PUINT8, UCHAR, *PUCHAR;
+typedef short           INT16, *PINT16;
+typedef unsigned short      UINT16, *PUINT16;
+typedef unsigned int            UINT, *PUINT;
+
+typedef void            tiVOID, *tiPVOID;
+typedef unsigned int        tiBOOL;
+typedef tiBOOL    BOOLEAN, *PBOOLEAN;
+typedef UINT16              tiUINT16;
+typedef signed int          tiINT32;
+typedef unsigned int        tiUINT32;
+typedef UINT8               tiUINT8;
+typedef char                ti_char;
+typedef char                tiCHAR;
+typedef unsigned long long  tiULONGLONG;
+typedef long long           tiLONGLONG;
+
+#ifndef _BASETSD_H_
+typedef signed int      INT32, *PINT32;
+typedef unsigned long   /*LARGE_INTEGER, */ULONG, *PULONG;
+# ifndef _WINDOWS
+typedef union _LARGE_INTEGER_T {
+    struct {
+        tiUINT32 LowPart;
+        tiINT32  HighPart;
+    };
+    tiLONGLONG QuadPart;
+} LARGE_INTEGER;
+# endif /* _WINDOWS */
+
+# ifndef _SUPPLICANT_
+typedef unsigned int    UINT32, *PUINT32;
+typedef unsigned char   BOOL, *PBOOL;
+# endif /* _SUPPLICANT_ */
+#endif /* _BASETSD_H_ */
+
+/*
+typedef struct _GUID {
+    unsigned long  Data1;
+    unsigned short Data2;
+    unsigned short Data3;
+    unsigned char  Data4[ 8 ];
+} GUID;
+
+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) ;
+*/
+typedef unsigned long long      UINT64;
+typedef long long               INT64;
+#define CONSTANT64(x)           (x##LL)
+
+#define STRUCT typedef struct
+#define UNION typedef union
+#define ENUM typedef enum
+
+#define PACKED_STRUCT(name,content) STRUCT { content } __attribute__ ((packed)) name 
+#define PACKED_STRUCT_NO_TYPEDEF(content) struct { content } __attribute__ ((packed)) 
+#define PACKED_UNION(name,content) union { content } __attribute__ ((packed)) name 
+#define PACKED_UNION_NO_TYPEDEF(content) union { content } __attribute__ ((packed)) 
+#define ENUM_BODY(name, value) name  value,
+#define PACKED_ENUM(name, list) ENUM { list(ENUM_BODY) } __attribute__ ((packed)) name
+
+
+#define NWIF_MAX_QOS_CONNS 7
+
+#define BIT_TO_BYTE_FACTOR 8
+
+typedef struct nwif_clsfr_entry_t
+{
+    UINT32 ip;
+    UINT16 port;
+    UINT16 pri;
+} NWIF_CLSFR_ENTRY;
+/*The following define assumes that the structure above is 8 bytes.*/
+#define OS_CLSFR_TABLE_SIZE (NWIF_MAX_QOS_CONNS * 8)
+
+typedef UINT64 OS_PHYSICAL_ADDRESS;
+
+#define IMPORT_TI_API
+
+#endif /* __OS_TYPES_H__*/
+
+
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/osrgstry_parser.h b/sta_dk_4_0_4_32/pform/linux/inc/osrgstry_parser.h
new file mode 100644 (file)
index 0000000..717682b
--- /dev/null
@@ -0,0 +1,66 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef _OS_RGSTRY_PARSER_
+#define _OS_RGSTRY_PARSER_
+
+#include "ioctl_init.h"
+
+#include "osTIType.h"
+#include "osApi.h"
+#include "osDebug.h"
+
+
+
+#ifdef USE_INIT_FILE
+# define NDIS_STRING_CONST(a)    {sizeof(a), sizeof(a), a}
+#else
+# define NDIS_STRING_CONST(a)    { 0, 0, "" }
+#endif    /* USE_INIT_FILE */
+
+
+
+#include "osAdapter.h"
+#include "esta_drv.h"
+
+VOID regFillInitTable( PTIWLN_ADAPTER_T pAdapter, PVOID pInitTable);
+
+extern void osInitTable(initTable_t *InitTable);
+extern  int osInitTable_IniFile(tiwlan_net_dev_t *drv, initTable_t *InitTable, char *file_buf, int file_length);
+
+
+#endif /* _OS_RGSTRY_PARSER_ */
+
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/spi_api.h b/sta_dk_4_0_4_32/pform/linux/inc/spi_api.h
new file mode 100644 (file)
index 0000000..958fe52
--- /dev/null
@@ -0,0 +1,69 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef _SPI_API_H_
+#define _SPI_API_H_
+
+
+typedef void (*request_callback_t) (void *data, int status);
+
+
+typedef enum 
+{
+    SPI_OK                =  0,
+    SPI_TXN_COMPLETE      =  0,
+    SPI_TXN_PENDING       =  1,
+    SPI_ERR_UNKNOWN       = -1,
+    SPI_ERR_BUS_BUSY      = -2,
+    SPI_ERR_QUEUE_FULL    = -3,
+    SPI_ERR_ALLOC_MEM     = -4,
+    SPI_ERR_ASYNC_TIMEOUT = -5, 
+    SPI_ERR_WRONG_LENGTH  = -6,
+
+} SPI_Status_e; 
+
+
+void* SPI_Open         (void);
+int   SPI_Close        (void* hSPI);
+int   SPI_Write        (void* hSPI, UINT8 *data, UINT32 length, request_callback_t fCb, void *pCb, int more);                     
+int   SPI_Read         (void* hSPI, UINT8 *data, UINT32 length, request_callback_t fCb, void *pCb, int more);                      
+int   SPI_WriteRead    (void* hSPI, UINT8 *data, UINT32 length, UINT8 *rdata, UINT32 rlength, request_callback_t fCb, void* pCb, int more);
+int   SPI_WriteSync    (void* hSPI, UINT8 *data, UINT32 length);
+int   SPI_ReadSync     (void* hSPI, UINT8* data, UINT32 length);
+
+
+#endif /* _SPI_API_H_ */
+
diff --git a/sta_dk_4_0_4_32/pform/linux/inc/windows_types.h b/sta_dk_4_0_4_32/pform/linux/inc/windows_types.h
new file mode 100644 (file)
index 0000000..03e1ec8
--- /dev/null
@@ -0,0 +1,194 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef _WINDOWS_TYPES_H
+#define _WINDOWS_TYPES_H
+
+#include "osTIType.h"
+#include "ioctl_init.h"
+
+/*typedef tiBOOL    BOOLEAN, *PBOOLEAN;*/
+typedef UINT16    USHORT, *PUSHORT;
+typedef char      CHAR;
+typedef const char * LPCSTR;
+
+#define IN
+#define OUT
+#define NDIS_MAX_STRING_LEN   361
+
+typedef struct _STRING {
+  USHORT  Length;
+  USHORT  MaximumLength;
+  PCHAR  Buffer;
+} ANSI_STRING, *PANSI_STRING, UNICODE_STRING, *PUNICODE_STRING;
+
+typedef ANSI_STRING NDIS_STRING, *PNDIS_STRING;
+typedef void * NDIS_HANDLE;
+typedef int NDIS_STATUS, *PNDIS_STATUS;
+
+
+typedef ULONG NDIS_OID, *PNDIS_OID;
+#define PCI_TYPE0_ADDRESSES             6
+#define PCI_TYPE1_ADDRESSES             2
+typedef LARGE_INTEGER NDIS_PHYSICAL_ADDRESS;
+typedef PVOID *PDEVICE_OBJECT, *PDRIVER_OBJECT;
+typedef UINT32 NDIS_MINIPORT_INTERRUPT, NDIS_MINIPORT_TIMER, NDIS_SPIN_LOCK;
+typedef UINT32 PNDIS_PACKET, *PPNDIS_PACKET;
+
+typedef enum _NDIS_PARAMETER_TYPE {
+  NdisParameterInteger,
+  NdisParameterHexInteger,
+  NdisParameterString,
+  NdisParameterMultiString,
+  NdisParameterBinary
+} NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE;
+
+typedef struct {
+    USHORT  Length;
+    PVOID  Buffer;
+} BINARY_DATA;
+
+typedef struct _NDIS_CONFIGURATION_PARAMETER {
+  NDIS_PARAMETER_TYPE  ParameterType;
+  union {
+    ULONG  IntegerData;
+    NDIS_STRING  StringData;
+    BINARY_DATA  BinaryData;
+  } ParameterData;
+  char StringBuffer[NDIS_MAX_STRING_LEN];
+} NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER;
+
+typedef tiUINT32 NTSTATUS;
+
+#ifndef NDIS_STATUS_SUCCESS
+# define NDIS_STATUS_SUCCESS                        ((NDIS_STATUS)0x00000000L)
+# define NDIS_STATUS_PENDING                        ((NDIS_STATUS)0x00000103L)
+# define NDIS_STATUS_RESET_END                      ((NDIS_STATUS)0x40010005L)
+# define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION      ((NDIS_STATUS)0x40010012L)
+# define NDIS_STATUS_FAILURE                        ((NDIS_STATUS)0xC0000001L)
+# define NDIS_STATUS_ADAPTER_NOT_FOUND              ((NDIS_STATUS)0xC0010006L)
+# define NDIS_STATUS_INVALID_LENGTH                 ((NDIS_STATUS)0xC0010014L)
+# define NDIS_STATUS_BUFFER_TOO_SHORT               ((NDIS_STATUS)0xC0010016L)
+# define NDIS_STATUS_INVALID_OID                    ((NDIS_STATUS)0xC0010017L)
+#endif        /* NDIS_STATUS_SUCCESS */
+
+#define STATUS_SUCCESS                0
+#define STATUS_INVALID_PARAMETER     -1
+
+#define NdisZeroMemory(p, size)      os_memoryZero( NULL, p, size )
+#define NdisMoveMemory(d, s, size)   os_memoryCopy( NULL, d, s, size )
+
+NDIS_STATUS NdisUnicodeStringToAnsiString( IN OUT PANSI_STRING  DestinationString,
+    IN PUNICODE_STRING  SourceString );
+VOID NdisReadConfiguration( OUT PNDIS_STATUS  Status, OUT PNDIS_CONFIGURATION_PARAMETER  *ParameterValue,
+    IN NDIS_HANDLE  ConfigurationHandle, IN PNDIS_STRING  Keyword, IN NDIS_PARAMETER_TYPE  ParameterType );
+VOID NdisWriteConfiguration( OUT PNDIS_STATUS  Status, IN NDIS_HANDLE  ConfigurationHandle,
+    IN PNDIS_STRING  Keyword, IN PNDIS_CONFIGURATION_PARAMETER  ParameterValue );
+VOID NdisReadNetworkAddress( OUT PNDIS_STATUS  Status, OUT PVOID  *NetworkAddress, OUT PUINT  NetworkAddressLength,
+    IN NDIS_HANDLE  ConfigurationHandle );
+
+typedef struct _NDIS_PACKET_POOL {
+  NDIS_SPIN_LOCK  SpinLock;
+  struct _NDIS_PACKET *FreeList;
+  UINT  PacketLength;
+  UCHAR  Buffer[1];
+} NDIS_PACKET_POOL, * PNDIS_PACKET_POOL;
+
+typedef enum _NDIS_802_11_STATUS_TYPE
+{
+    Ndis802_11StatusType_Authentication,
+    Ndis802_11StatusTypeMax    /* not a real type, defined as an upper bound*/
+} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
+
+typedef UCHAR   NDIS_802_11_MAC_ADDRESS[6];
+
+typedef struct _NDIS_802_11_STATUS_INDICATION
+{
+    NDIS_802_11_STATUS_TYPE StatusType;
+} NDIS_802_11_STATUS_INDICATION, *PNDIS_802_11_STATUS_INDICATION;
+
+typedef struct _NDIS_802_11_AUTHENTICATION_REQUEST
+{
+    ULONG Length;            /* Length of structure*/
+    NDIS_802_11_MAC_ADDRESS Bssid;
+    ULONG Flags;
+} NDIS_802_11_AUTHENTICATION_REQUEST, *PNDIS_802_11_AUTHENTICATION_REQUEST;
+
+typedef tiINT32 NDIS_802_11_RSSI;           /* in dBm*/
+
+typedef struct _NDIS_802_11_TEST
+{
+       ULONG Length;
+       ULONG Type;
+       union {
+               struct _AuthenticationEvent {
+            NDIS_802_11_STATUS_INDICATION Status;
+            NDIS_802_11_AUTHENTICATION_REQUEST Request[1];
+               } AuthenticationEvent;
+               NDIS_802_11_RSSI RssiTrigger;
+       };
+} NDIS_802_11_TEST, *PNDIS_802_11_TEST;
+
+/* Added new encryption types*/
+/* Also aliased typedef to new name*/
+typedef enum _NDIS_802_11_WEP_STATUS
+{
+    Ndis802_11WEPEnabled,
+    Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
+    Ndis802_11WEPDisabled,
+    Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
+    Ndis802_11WEPKeyAbsent,
+    Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
+    Ndis802_11WEPNotSupported,
+    Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
+    Ndis802_11Encryption2Enabled,
+    Ndis802_11Encryption2KeyAbsent,
+    Ndis802_11Encryption3Enabled,
+    Ndis802_11Encryption3KeyAbsent
+} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
+  NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
+
+#ifdef TI_DBG
+#ifdef __KERNEL__
+#define DbgPrint     printk
+#else
+#define DbgPrint     printf
+#endif
+#else
+#define DbgPrint
+#endif
+
+#endif /* _WINDOWS_TYPES_H */
diff --git a/sta_dk_4_0_4_32/pform/linux/src/bmtrace.c b/sta_dk_4_0_4_32/pform/linux/src/bmtrace.c
new file mode 100644 (file)
index 0000000..0a6dea9
--- /dev/null
@@ -0,0 +1,183 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+
+#include "osApi.h"
+#include "esta_drv.h"
+#include "bmtrace.h"
+
+#define OS_READ_REG(drv,reg,p_val)    \
+   os_hwReadMemRegisterUINT32(drv, (UINT32 *)((unsigned long)drv->acx_reg.va + reg), p_val)
+
+typedef struct {
+      unsigned long loc;/* trace entry identification */
+      unsigned long ts;/* Timestamp */
+      unsigned long p1; /* Parameter 1 */
+      unsigned long p2; /* Parameter 2 */
+} bm_entry_t;
+
+typedef struct {
+      int pos;
+      int count;
+      int print_pos;
+      int nusers;
+      unsigned long self_delay;
+      tiwlan_net_dev_t *drv;
+      bm_entry_t entry[1]; /* Array of entries */
+} bm_control_t;
+
+static bm_control_t *bm_control;
+
+static inline int bm_control_size(void)
+{
+   return offsetof(bm_control_t, entry) + sizeof(bm_entry_t)*BM_NUM_ENTRIES;
+}
+
+static int bm_res_read_proc(char *page, char **start, off_t off,
+                           int count, int *eof, void *data)
+{
+   int i;
+   int len=0;
+   int limit=count-80;
+   int entry_count;
+   unsigned long prev=0;
+   int print_pos;
+
+   print_pos = bm_control->print_pos++; /* It will disable tracing as well */
+
+   entry_count = (bm_control->count > BM_NUM_ENTRIES) ? BM_NUM_ENTRIES : bm_control->count;
+
+   /* Skip off entries */
+   if ( print_pos >= entry_count) /* paranoid */
+   {
+      bm_control->pos = bm_control->count = bm_control->print_pos = 0;
+      *eof = 1;
+      return 0;
+   }
+
+   if (!off)
+   {
+      len = sprintf(page, "Events stored: %u   discarded: %u\n",
+                   entry_count, bm_control->count-entry_count);
+      len += sprintf(page+len, "loc delta      ts         p1         p2\n");
+   }
+
+   /* Initial index */
+   if (bm_control->count > BM_NUM_ENTRIES)
+      i = (bm_control->pos+print_pos-1)%BM_NUM_ENTRIES;
+   else
+      i = bm_control->print_pos-1;
+
+   for(; (print_pos<entry_count) && (len<=limit); print_pos++)
+   {
+      bm_entry_t *bme= &bm_control->entry[i];
+      len += sprintf(page+len,
+                    "%-3lu %-10lu %-10lu %-10lu %-10lu\n",
+                    bme->loc,
+                    ((bme->ts-prev)>bm_control->self_delay)?bme->ts-prev-bm_control->self_delay:0,
+                    bme->ts,
+                    bme->p1, bme->p2);
+      prev = bme->ts;
+      ++i;
+      i %= BM_NUM_ENTRIES;
+   }
+   if (print_pos >= entry_count)
+   {
+      *eof = 1;
+      bm_control->pos = bm_control->count = bm_control->print_pos = 0;
+   }
+   else
+      bm_control->print_pos = print_pos;
+   return len;
+}
+
+
+/* Initialization */
+int bm_init(struct tiwlan_net_dev *drv)
+{
+   if (bm_control)
+   {
+      ++bm_control->nusers;
+      return 0;
+   }
+   bm_control = (bm_control_t *)kmalloc(bm_control_size(), GFP_KERNEL);
+   if (!bm_control)
+      return -ENOMEM;
+   memset(bm_control, 0, offsetof(bm_control_t, entry) + sizeof(bm_entry_t)*BM_NUM_ENTRIES);
+   bm_control->nusers = 1;
+   bm_control->drv = drv;
+
+   create_proc_read_entry("bmtrace", 0, NULL, bm_res_read_proc, NULL);
+   /* Measure self-delay */
+   bm_trace(0, 0, 0);
+   bm_trace(0, 0, 0);
+   bm_control->self_delay = bm_control->entry[1].ts - bm_control->entry[0].ts;
+   bm_control->pos = bm_control->count = 0;
+   print_info("%s: self_delay=%lu\n", __FUNCTION__, bm_control->self_delay);
+   return 0;
+}
+
+/* De-initialization */
+void bm_destroy(void)
+{
+   if (--bm_control->nusers)
+      return;
+   remove_proc_entry("bmtrace", NULL);
+   kfree( bm_control );
+}
+
+
+/* Add trace entry. not safe, but will do */
+void bm_trace(int loc, unsigned long p1, unsigned long p2)
+{
+   int pos;
+   if (!bm_control || bm_control->print_pos)
+      return;
+   pos = bm_control->pos;
+   bm_control->pos = (pos+1) % BM_NUM_ENTRIES;
+   ++bm_control->count;
+
+   bm_control->entry[pos].ts = os_timeStampUs(NULL);
+   bm_control->entry[pos].loc= loc;
+   bm_control->entry[pos].p1 = p1;
+   bm_control->entry[pos].p2 = p2;
+}
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/env_tst.c b/sta_dk_4_0_4_32/pform/linux/src/env_tst.c
new file mode 100644 (file)
index 0000000..2c5ddf6
--- /dev/null
@@ -0,0 +1,106 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include <linux/errno.h>
+#include <linux/string.h>
+
+#include "arch_ti.h"
+#include "osTIType.h"
+#include "osApi.h"
+#include "ioctl_init.h"
+
+#include "802_11Defs.h"
+#include "mlmeApi.h"
+
+/****************************************************************************/
+/*                                                                          */
+/*              Definition of Constants                                     */
+/*                                                                          */
+/****************************************************************************/
+#define SIZEOF_DOT11_MGMT_HEADER 0x18
+#define SIZEOF_MLME_FRAME_INFO   0x60
+#ifdef EXC_MODULE_INCLUDED
+#define SIZEOF_BEACON_FRM        0x57
+#else
+#define SIZEOF_BEACON_FRM        0x53
+#endif
+#define SIZEOF_ELEMENT_HDR       0x02
+#define SIZEOF_MGMT_FRAME        0x920
+#define SIZEOF_ASSOC_RSP_TYPE    0x26
+#define SIZEOF_AUTH_MSG_TYPE     0x0a
+#define SIZEOF_DEATUH_MSG_TYPE   0x02
+#define SIZEOF_DISASSOC_MSG_TYPE 0x02
+
+#define CHECK_STRUCT_SIZE(_type,_size) \
+{ \
+  if (sizeof(_type) != _size) \
+  { \
+        print_info(KERN_INFO"\n.... ERROR in size of %s struct 0x%08x  should be 0x%08x.....\n", \
+                 #_type, (int)sizeof(_type),(int)_size); \
+        rc = -EINVAL; \
+  } \
+}
+
+/************************************************************************
+ *                        packed_strct_tst                                                              *
+ ************************************************************************
+DESCRIPTION: Used to test structures for the correct packed size
+
+INPUT:      Void
+
+OUTPUT:         Print Debug statements if the structures are not the expected size
+
+RETURN:    0=success
+           -EINVAL - failure
+
+************************************************************************/
+int packed_struct_tst (void)
+{
+   int rc = 0;
+   print_info("\nTIWLAN: Testing sizes of packed structures...\n");
+   CHECK_STRUCT_SIZE(dot11_mgmtHeader_t, SIZEOF_DOT11_MGMT_HEADER);
+   CHECK_STRUCT_SIZE(dot11_eleHdr_t, SIZEOF_ELEMENT_HDR);
+   CHECK_STRUCT_SIZE(beacon_probeRsp_t, SIZEOF_BEACON_FRM);
+   CHECK_STRUCT_SIZE(assocRsp_t, SIZEOF_ASSOC_RSP_TYPE );
+   CHECK_STRUCT_SIZE(authMsg_t, SIZEOF_AUTH_MSG_TYPE);
+   CHECK_STRUCT_SIZE(deAuth_t,  SIZEOF_DEATUH_MSG_TYPE);
+   CHECK_STRUCT_SIZE(disAssoc_t, SIZEOF_DISASSOC_MSG_TYPE);
+   CHECK_STRUCT_SIZE(dot11_mgmtFrame_t, SIZEOF_MGMT_FRAME);
+   CHECK_STRUCT_SIZE(mlmeFrameInfo_t,SIZEOF_MLME_FRAME_INFO);
+   print_info("TIWLAN: packet structure size test %s\n", rc?"failed":"passed");
+
+   return rc;
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c b/sta_dk_4_0_4_32/pform/linux/src/esta_drv.c
new file mode 100644 (file)
index 0000000..801e514
--- /dev/null
@@ -0,0 +1,1916 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <net/sock.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/netdevice.h>
+#include <linux/ioctl.h>
+#include <linux/wireless.h>
+#include <linux/etherdevice.h>
+#include <linux/netlink.h>
+#include <linux/completion.h>
+
+#ifdef TIWLAN_CARDBUS
+#include <linux/pci.h>
+#else
+#ifdef TIWLAN_OMAP1610
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+#include <asm/arch-omap/tc.h>
+#else
+#include <mach/tc.h>
+#endif
+#endif
+#ifdef TIWLAN_MSM7000
+#include <linux/mmc/core.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+#include <asm/arch/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/irqs.h>
+#else
+#include <mach/io.h>
+#include <mach/hardware.h>
+#include <mach/irqs.h>
+#endif
+#endif   /* !TIWLAN_CARDBUS */
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/if_arp.h>
+#include <linux/proc_fs.h>
+#include <linux/mm.h>
+#include <linux/delay.h>
+#include <linux/vmalloc.h>
+#include <linux/irq.h>
+
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/pgtable.h>
+
+#include "esta_drv.h"
+#include "srcApi.h"
+#include "osApi.h"
+#include "whalHwRegs.h"
+
+#if defined(DEBUG_UNKNOWN_INTERRUPT)
+#define _STRING_H
+#include "configMgr.h"
+#include "whalCtrl.h"
+#endif
+
+#include "bmtrace.h"
+#include "osrgstry_parser.h"
+#include "osClsfr.h"
+#include "TI_IPC_Api.h"
+#include "802_11Defs.h"
+#include "Ethernet.h"
+#include "tiwlan_profile.h"
+
+#ifdef CONFIG_TROUT_PWRSINK
+#include <asm/arch/trout_pwrsink.h>
+#define RX_RATE_INTERVAL_SEC 10
+unsigned long num_rx_pkt_new = 0;
+static unsigned long num_rx_pkt_last = 0;
+#endif
+
+#ifdef TIWLAN_MSM7000
+extern unsigned char *get_wifi_nvs_ram(void);
+extern void SDIO_SetFunc( struct sdio_func * );
+static struct proc_dir_entry *tiwlan_calibration;
+static struct completion sdio_wait;
+#endif
+
+/* Drivers list */
+static LIST_HEAD(tiwlan_drv_list);
+
+/* debug memory access */
+static struct proc_dir_entry *tiwlan_deb_entry;
+static __u32 memdebug_addr;
+static __u32 memdebug_size=1;
+static __u32 memdebug_trans_size;
+
+#define DRV_SHUTDOWN_TEST_DELAY_INTERVAL 100       /* Time in msec to "delay"(/sleep) while waiting for SME to shutdown */
+#define DRV_SHUTDOWN_TEST_MAX_COUNTER  20          /* How many delay/sleep iterations to perform while waiting for SME to shutdown) */
+
+MODULE_DESCRIPTION("TI WLAN Embedded Station Driver");
+MODULE_LICENSE("GPL");
+
+extern int packed_struct_tst(void);
+extern int proc_stat_init(TI_HANDLE);
+extern int proc_stat_destroy(void);
+
+typedef void (* tiwlan_drv_isr_t)(int, void *, struct pt_regs *);
+
+/* network device driver interface */
+static int tiwlan_drv_net_open(struct net_device * dev);
+static int tiwlan_drv_net_stop(struct net_device * dev);
+static int tiwlan_drv_net_xmit(struct sk_buff * skb, struct net_device * dev);
+static struct net_device_stats * tiwlan_drv_net_get_stats(struct net_device * dev);
+
+
+#define OS_WRITE_REG(drv,reg,val)   \
+    os_hwWriteMemRegisterUINT32(drv, (UINT32 *)((unsigned long)drv->acx_reg.va + reg), (__u32)(val))
+
+#define OS_READ_REG(drv,reg,val)    \
+    os_hwReadMemRegisterUINT32(drv, (UINT32 *)((unsigned long)drv->acx_reg.va + reg), &val)
+      
+#ifdef TIWLAN_OMAP1610
+static void omap_memif_init(void)
+{
+    printk ("First function offset is: %p\n", omap_memif_init);
+#if defined(TIWLAN_OMAP1610_INNOVATOR)
+    print_info("Setting CS1 Ref Clock = TC/4. \n");
+    omap_writel(0x00000004, 0xFFFECC40 ); /* wlan change for cs2 to dynamic wait state */
+    omap_writel(0x0000113a, 0xFFFECC18 ); /* EMIFS (nCS2) configuration */
+#elif defined(TIWLAN_OMAP1610_WIPP) || defined(TIWLAN_OMAP1610_CRTWIPP)
+
+#if defined(TIWLAN_OMAP1610_CRTWIPP)
+    /*
+    Init the GPIO to output*/
+
+    /* Set OMAP pin H19 to GPIO57*/
+
+    omap_writel(omap_readl(0xFFFE1014) | 0x00E00000, 0xFFFE1014 );
+
+    /*ELP_REQ (GPIO_57) by GPIO_DIRECTION - set it as output*/
+    omap_writel(omap_readl(0xFFFBBC34) & (~0x00000200), 0xFFFBBC34 );
+#endif  /* TIWLAN_OMAP1610_CRTWIPP */
+
+/* The below configuration enables GPIO25 and GPIO_27 as output GPIOs - for debug purposes */
+#if defined(TIWLAN_OMAP1610_CRTWIPP_GPIO_DEBUG)
+
+    omap_writel(omap_readl(0xFFFE1030) | 0x00000E00, 0xFFFE1030 );/* enable GPIO25 */
+    omap_writel(omap_readl(0xFFFE1030) | 0x00000038, 0xFFFE1030 );/* enable GPIO27 */
+
+    omap_writel(omap_readl(0xFFFBEC34) & (~0x00000200), 0xFFFBEC34 );/* Setting direction (as output) for GPIO25 */
+    omap_writel(omap_readl(0xFFFBEC34) & (~0x00000800), 0xFFFBEC34 );/* Setting direction (as output) for GPIO27 */
+#endif   /* TIWLAN_OMAP1610_CRTWIPP_GPIO_DEBUG */
+
+
+    /* RECOVERY*/
+    print_info("Hard reset,perform PMEN toggle\n");
+    os_hardResetTnetw();
+
+    print_info("Setting CS2 Ref Clock = TC/2. \n");
+    __raw_writel(0x1, TIWLAN_OMAP1610_REGBASE+0x4cc); /* CLK=80MHz */
+    omap_writel(0x20, EMIF_CFG_DYNAMIC_WS); /* Full handshake on CS2 */
+    omap_writel(0x2441, EMIFS_CS2_CONFIG); /* 0x2021 on reworked board */
+    omap_writel(0, EMIFS_ACS2);
+
+    print_info("%x=0x%lx\n", 0xFFFECC40, omap_readl(0xFFFECC40) );
+    print_info("%x=0x%lx\n", 0xFFFECC18, omap_readl(0xFFFECC18) );
+    print_info("%x=0x%lx\n", 0xFFFECC58, omap_readl(0xFFFECC58) );
+#endif /* WIPP, CRTWIPP */
+}
+#endif
+
+static int tiwlan_register_events(tiwlan_net_dev_t *drv)
+{
+    IPC_EVENT_PARAMS evParams;
+    int i = 0;
+    
+    evParams.uDeliveryType      = DELIVERY_PUSH;
+    evParams.uProcessID         = 0;
+    evParams.uEventID           = 0;
+    evParams.hUserParam        = drv;
+    evParams.pfEventCallback    = os_IndicateEvent;
+
+
+    for (;i < IPC_EVENT_MAX_OS_EVENT;i++) 
+    {
+        evParams.uEventType = i;
+
+        configMgr_RegisterEvent(drv->adapter.CoreHalCtx,(PUCHAR) &evParams,sizeof(IPC_EVENT_PARAMS));
+    }
+
+    return OK;
+}
+
+static int tiwlan_deb_read_proc(char *page, char **start, off_t off,
+                                int count, int *eof, void *data)
+{
+    __u32 addr=memdebug_addr;
+    __u32 size=memdebug_size;
+    __u32 trans_size=memdebug_trans_size;
+    __u32 end;
+    int in_line=0, max_in_line;
+    int limit=count-80;
+    int i=0;
+    static int toggle;
+
+    *eof = 1;
+    if (!addr || !trans_size)
+        return 0;
+
+    /* fixme: add address validation */
+
+    if (!size)
+        size=1;
+
+    end = addr + size*trans_size;
+    if (trans_size==4)
+        max_in_line = 4;
+    else if (trans_size==2)
+        max_in_line = 8;
+    else
+        max_in_line = 16;
+
+    while(i<limit && addr<end)
+    {
+        if (!in_line)
+            i += sprintf(page+i, "0x%08x: ", addr);
+        if (trans_size==4)
+        {
+            i += sprintf(page+i, "0x%08x", *(__u32 *)addr);
+            addr += 4;
+        }
+        else if (trans_size==2)
+        {
+            i += sprintf(page+i, "0x%04x", *(__u16 *)addr);
+            addr += 2;
+        }
+        else
+        {
+            i += sprintf(page+i, "0x%02x", *(__u8 *)addr);
+            addr += 1;
+        }
+        if (++in_line < max_in_line)
+            *(page+i++)=' ';
+        else
+        {
+            *(page+i++)='\n';
+            in_line = 0;
+        }
+    }
+    *(page+i++)='\n';
+    /* For some reason read proc is get called twice for
+       each "cat" operation
+    */
+    if (toggle)
+        memdebug_addr = addr;
+    toggle = !toggle;
+
+    return i;
+}
+
+static char *rm_get_token(const char **p_buffer, unsigned long *p_buffer_len,
+                          char *token, unsigned long token_len,
+                          char del)
+{
+    const char *buffer=*p_buffer;
+    __u32 buffer_len = *p_buffer_len;
+
+    while(buffer_len && token_len && *buffer!=del && *buffer)
+    {
+        *token++ = *buffer++;
+        --buffer_len;
+        --token_len;
+    }
+    while (buffer_len && *buffer==del)
+    {
+        ++buffer;
+        --buffer_len;
+    }
+    *token = 0;
+    *p_buffer = buffer;
+    *p_buffer_len = buffer_len;
+    return token;
+}
+
+static int tiwlan_deb_write_proc(struct file *file, const char *buffer,
+                                 unsigned long count, void *data)
+{
+    __u32 addr, size;
+    char token[15];
+    __u32 value;
+    char *end;
+    int buflen=count;
+
+    /* buffer format is:
+       d{w,h,b} addr[/size]
+       s{w,h,b} addr=value
+    */
+    /* Parse string */
+    rm_get_token(&buffer, &count, token, sizeof(token)-1, ' ');
+    if (token[0]=='d')
+    {
+        /* Display */
+        if (!strcmp(token, "dw"))
+            memdebug_trans_size = 4;
+        else if (!strcmp(token, "dh"))
+            memdebug_trans_size = 2;
+        else if (!strcmp(token, "db"))
+            memdebug_trans_size = 1;
+        else
+        {
+            printk(KERN_INFO "rm: mem file write op is dw|dh|db|sw|sh|sb\n");
+            return buflen;
+        }
+        /* Get address */
+        rm_get_token(&buffer, &count, token, sizeof(token)-1, '/');
+        addr = simple_strtoul(token, &end, 0);
+        if ((end && *end) /* || !iopa(addr)*/)
+        {
+            printk(KERN_INFO "rm: address <%s> is invalid\n", token);
+            return buflen;
+        }
+        if ((addr & (memdebug_trans_size-1)))
+        {
+            printk(KERN_INFO "rm: warning: address 0x%x is not aligned to size %u\n",
+                   addr, memdebug_trans_size);
+        }
+        memdebug_addr = addr;
+        if (count)
+        {
+            /* Get size */
+            rm_get_token(&buffer, &count, token, sizeof(token)-1, ' ');
+            size = simple_strtoul(token, &end, 0);
+            if (end && *end)
+            {
+                printk(KERN_INFO "rm: size <%s> is invalid. end=<%s>\n",
+                       token, end);
+                return buflen;
+            }
+            memdebug_size = size;
+        }
+        return buflen;
+    }
+    if (token[0]=='s')
+    {
+        /* Display */
+        if (!strcmp(token, "sw"))
+            size = 4;
+        else if (!strcmp(token, "sh"))
+            size = 2;
+        else if (!strcmp(token, "sb"))
+            size = 1;
+        else
+        {
+            printk(KERN_INFO "rm: mem file write op is dw|dh|db|sw|sh|sb\n");
+            return buflen;
+        }
+        /* Get address */
+        rm_get_token(&buffer, &count, token, sizeof(token)-1, ' ');
+        addr = simple_strtoul(token, &end, 0);
+        if ((end && *end) /*|| !iopa(addr)*/)
+        {
+            printk(KERN_INFO "rm: address <%s> is invalid\n", token);
+            return buflen;
+        }
+        if ((addr & (size-1)))
+        {
+            printk(KERN_INFO "rm: warning: address 0x%x is not aligned to size %u\n",
+                   addr, size);
+        }
+
+        /* Get value */
+        rm_get_token(&buffer, &count, token, sizeof(token)-1, ' ');
+        value = simple_strtoul(token, &end, 0);
+        if (end && *end)
+        {
+            printk(KERN_INFO "rm: value <%s> is invalid. end <%s>\n",
+                   token, end);
+            return buflen;
+        }
+        if (size==4)
+            *(__u32 *)addr = value;
+        else if (size==2)
+        {
+            if (value > 0xffff)
+            {
+                printk(KERN_INFO "rm: value <%s> is out of range\n", token);
+                return buflen;
+            }
+            *(__u16 *)addr = value;
+        }
+        else
+        {
+            if (value > 0xff)
+            {
+                printk(KERN_INFO "rm: value <%s> is out of range\n", token);
+                return buflen;
+            }
+            *(__u8 *)addr = value;
+        }
+        memdebug_addr = addr;
+        memdebug_size = 1;
+        memdebug_trans_size = size;
+    }
+    else
+        printk(KERN_INFO "rm: operation <%s> is not supported\n", token);
+    return buflen;
+}
+
+#ifdef TIWLAN_MSM7000
+#define WIFI_NVS_LEN_OFFSET     0x0C
+#define WIFI_NVS_DATA_OFFSET    0x40
+#define WIFI_NVS_MAX_SIZE       0x800UL
+
+static unsigned long tiwlan_get_nvs_size( void )
+{
+    unsigned char *ptr;
+    unsigned long len;
+
+    ptr = get_wifi_nvs_ram();
+    if( ptr == NULL ) {
+        return 0;
+    }
+    /* Size in format LE assumed */
+    memcpy( (void *)&len, (void *)(ptr + WIFI_NVS_LEN_OFFSET), sizeof(len) );
+    len = min( len, (WIFI_NVS_MAX_SIZE-WIFI_NVS_DATA_OFFSET) );
+    return len;
+}
+
+static int tiwlan_calibration_read_proc(char *page, char **start, off_t off,
+                                int count, int *eof, void *data)
+{
+    unsigned char *ptr;
+    unsigned long len;
+
+    ptr = get_wifi_nvs_ram();
+    if( ptr == NULL ) {
+        return 0;
+    }
+    len = tiwlan_get_nvs_size();
+    /* i += sprintf(page+i, "WiFi Calibration Size = %lu %x bytes\n", len); */
+    memcpy( (void *)page, (void *)(ptr + WIFI_NVS_DATA_OFFSET), len );
+    return len;
+}
+
+static int tiwlan_calibration_write_proc(struct file *file, const char *buffer,
+                                 unsigned long count, void *data)
+{
+    return 0;
+}
+#endif
+
+/*********************************************************************************************/
+/*                                      Impelementation                                      */
+/*********************************************************************************************/
+
+static int tiwlan_drv_net_open(struct net_device * dev)
+{
+   tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)dev->priv;
+
+   ti_nodprintf(TIWLAN_LOG_INFO, "tiwlan_drv_net_open()\n");
+
+   if (!drv->adapter.CoreHalCtx)
+      return -ENODEV;
+
+   netif_start_queue(dev);
+
+   return 0;
+}
+
+
+static int tiwlan_drv_net_stop(struct net_device * dev)
+{
+   ti_nodprintf(TIWLAN_LOG_ERROR, "tiwlan_drv_net_stop()\n");
+
+   netif_stop_queue(dev);
+
+   return 0;
+}
+
+
+/* dummy send packet from Linux TCP/IP stack to WLAN
+   Used when driver is not initialized
+ */
+static int tiwlan_drv_dummy_net_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+   /* Network stack takes care of deallocation */
+   return -ENODEV;
+}
+
+void sendFreeFunc(TI_HANDLE pSkb, TI_HANDLE dummy1, TI_STATUS status)
+{
+    struct sk_buff *skb = (struct sk_buff *) pSkb;
+
+    /* print_deb("^^^ free %p %d  bytes (%s)\n", skb->data, skb->len, (status==OK) ? "OK" : "ERROR" ); */
+    dev_kfree_skb(skb);
+}
+
+#ifdef DM_USE_WORKQUEUE
+void tiwlan_add_msdu(tiwlan_net_dev_t *drv, mem_MSDU_T *pMsdu)
+{
+    if( pMsdu == NULL )
+        return;
+    pMsdu->msdu_next = NULL;
+    if( drv->txmit_msdu_next != NULL ) {
+        drv->txmit_msdu_last->msdu_next = pMsdu;
+    }
+    else {
+        drv->txmit_msdu_next = pMsdu;
+    }
+    drv->txmit_msdu_last = pMsdu;
+}
+
+mem_MSDU_T *tiwlan_del_msdu(tiwlan_net_dev_t *drv)
+{
+    mem_MSDU_T *pMsdu = NULL;
+
+    if( drv->txmit_msdu_next != NULL ) {
+        pMsdu = drv->txmit_msdu_next;
+        drv->txmit_msdu_next = pMsdu->msdu_next;
+        if( drv->txmit_msdu_next == NULL ) { /* Last MSDU */
+            drv->txmit_msdu_last = NULL;
+        }
+    }
+    return( pMsdu );
+}
+
+static void tiwlan_xmit_handler( struct work_struct *work )
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)container_of( work, struct tiwlan_net_dev, txmit );
+    mem_MSDU_T *pMsdu;
+    unsigned long flags;
+
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+    do {
+        spin_lock_irqsave(&drv->lock, flags);
+        pMsdu = tiwlan_del_msdu(drv);
+        spin_unlock_irqrestore(&drv->lock, flags);
+        if( pMsdu ) {
+            configMgr_sendMsdu(drv->adapter.CoreHalCtx, pMsdu, 0);
+        }
+    } while( pMsdu != NULL );
+#ifdef CONFIG_ANDROID_POWER
+    android_unlock_suspend( &drv->xmit_wake_lock );
+#endif
+}
+#endif
+
+/* send packet from Linux TCP/IP stack to WLAN
+ */
+static int tiwlan_drv_net_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)dev->priv;
+    int status;
+    mem_MSDU_T *pMsdu;
+    UINT32      packetHeaderLength;
+
+#ifndef NO_COPY_SKB
+    char *pMsduData;
+#else
+    mem_BD_T *pCurBd=0;
+#endif
+
+#ifdef DRIVER_PROFILE
+    os_profile (drv, 0, 0);
+#endif    
+    bm_trace(20, skb->len, 0);
+
+#ifdef NO_COPY_SKB
+
+    status = configMgr_allocMSDUBufferOnly(drv->adapter.CoreHalCtx, &pMsdu, OS_ABS_TX_MODULE);
+    if(status != OK)
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, " configMgr_allocMSDUBufferOnly failed !!!\n");
+        ++drv->alloc_msdu_failures;
+        return -ENOMEM;
+    }
+    /* print_deb("$$$ configMgr_allocMSDUBufferOnly()=OK pMsdu=%p\n", pMsdu ); */
+
+    status = configMgr_allocBDs(drv->adapter.CoreHalCtx, 1, &pCurBd);
+
+    if(status != OK) {
+        ++drv->alloc_msdu_failures;
+        ti_dprintf(TIWLAN_LOG_ERROR, "  configMgr_allocBDs failed !!!\n");
+        configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, pMsdu->handle);
+        return -ENOMEM;
+    }
+    /* print_deb("$$$ configMgr_allocBDs()=OK pCurBd=%p first=%p\n", pCurBd, pMsdu->firstBDPtr ); */
+
+    pMsdu->freeFunc = sendFreeFunc;
+    pMsdu->freeArgs[0] = (UINT32) skb;
+    pMsdu->dataLen = skb->len;
+    pMsdu->firstBDPtr = pCurBd;
+    pCurBd->dataOffset = skb->data-skb->head;
+    pCurBd->length = skb->len;
+    pCurBd->data = skb->head;
+
+    drv->stats.tx_packets++;
+    drv->stats.tx_bytes += skb->len;
+
+#else /* NO_COPY_SKB */
+
+    /* 
+     * Retrieve the Packet Header length 
+     * from QoS Manager (through configMgr) 
+     * (Header type is determined upon association)  
+     */
+    packetHeaderLength = configMgr_getPacketHeaderLength(drv->adapter.CoreHalCtx,skb->data,TX_DATA_DATA_MSDU);
+
+   /*
+    * need to reserve enough space for header translation 
+    * in the same first Bd.
+    * Allocate enough place also for 802.11 header (24 bytes or 26 for QoS) and LLC (8 bytes)
+    * to replace the Ethernet header (14 bytes)
+    */
+    status = configMgr_allocMSDU(drv->adapter.CoreHalCtx, &pMsdu,
+                                     skb->len + packetHeaderLength, OS_ABS_TX_MODULE);
+
+    if(status != OK)
+    {
+        /*ti_dprintf(TIWLAN_LOG_ERROR, " configMgr_allocMSDU failed !!!\n");*/
+        ++drv->alloc_msdu_failures;
+        return -ENOMEM;
+    }
+
+    /* 
+     * case 1: only legacy wlan header 
+     *
+     * case 2: only QoS wlan header 
+     *
+     * case 3: only legacy wlan header with new snap
+     *
+     * case 4: only QoS wlan header with new snap
+     */
+    pMsdu->firstBDPtr->dataOffset = packetHeaderLength - ETHERNET_HDR_LEN;
+    pMsduData = pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset;
+    memcpy(pMsduData, skb->data, skb->len);
+    pMsdu->dataLen = skb->len;
+    pMsdu->firstBDPtr->length = pMsdu->dataLen + pMsdu->firstBDPtr->dataOffset;
+
+    drv->stats.tx_packets++;
+    drv->stats.tx_bytes += skb->len;
+    dev_kfree_skb(skb);
+#endif /* NO_COPY_SKB */
+
+    pMsdu->txFlags |= TX_DATA_FROM_OS;
+    pMsdu->qosTag = 0;
+    status = OK;
+
+#ifdef TI_DBG
+    /* Set packet-os-in time stamp */
+    /* TODO: the skb time stamp is not good */
+    /* printk ("\n### sec=%u, usec=%u", skb->stamp.tv_sec, skb->stamp.tv_usec);*/
+    /* pMsdu->timeStamp[0] = skb->stamp.tv_sec * 1000000 + skb->stamp.tv_usec; */
+    /* pMsdu->timeStampNum = 1; */
+#endif
+
+    bm_trace(21, 0, 0);
+   /*
+    * Propagate Msdu through Config Manager.
+    * Set DTag to zero 
+    * (note that classification is further handled in the Core)
+    */
+    if (status == OK) {
+#ifdef DM_USE_WORKQUEUE
+        unsigned long flags;
+
+        spin_lock_irqsave(&drv->lock, flags);
+        tiwlan_add_msdu(drv, pMsdu);
+        spin_unlock_irqrestore(&drv->lock, flags);
+        /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+        if( queue_work( drv->tiwlan_wq, &drv->txmit ) != 0 ) {
+#ifdef CONFIG_ANDROID_POWER
+            android_lock_suspend( &drv->xmit_wake_lock );
+#endif
+        }
+#else
+        status = configMgr_sendMsdu(drv->adapter.CoreHalCtx, pMsdu, 0);
+#endif
+    }
+    else
+        configMgr_memMngrFreeMSDU (drv->adapter.CoreHalCtx, (UINT32) pMsdu); /* If status != OK , we won't send the MSDU, so we need to free it */
+
+    if(unlikely(status != OK))
+    {
+        drv->stats.tx_errors++;
+#ifdef NO_COPY_SKB
+        dev_kfree_skb(skb);
+#endif
+    }
+
+    bm_trace(22, 0, 0);
+#ifdef DRIVER_PROFILE   
+    os_profile (drv, 1, 0);
+#endif   
+
+    return 0;
+}
+
+struct net_device_stats * tiwlan_drv_net_get_stats(struct net_device * dev)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)dev->priv;
+    ti_dprintf(TIWLAN_LOG_OTHER, "tiwlan_drv_net_get_stats()\n");
+
+    return &drv->stats;
+}
+
+
+static int setup_netif(tiwlan_net_dev_t *drv)
+{
+    struct net_device *dev;
+    int res;
+
+    dev = alloc_etherdev(0);
+    if (dev == NULL)
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, "alloc_etherdev() failed\n");
+        return -ENOMEM;
+    }
+    ether_setup(dev);
+    dev->priv = drv;
+    drv->netdev = dev;
+    strcpy(dev->name, TIWLAN_DRV_IF_NAME);
+    netif_carrier_off(dev);
+    dev->open = tiwlan_drv_net_open;
+    dev->stop = tiwlan_drv_net_stop;
+    dev->hard_start_xmit = tiwlan_drv_dummy_net_xmit;
+    dev->get_stats = tiwlan_drv_net_get_stats;
+    dev->tx_queue_len = 100;
+
+    res = tiwlan_ioctl_init(dev);
+    if( res < 0 )
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, "tiwlan_ioctl_init() failed : %d\n", res);
+        kfree(dev);
+        return res;
+    }
+
+    res = register_netdev(dev);
+    if (res != 0)
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, "register_netdev() failed : %d\n", res);
+        kfree(dev);
+        return res;
+    }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+    SET_MODULE_OWNER(dev);
+#endif
+    return 0;
+}
+
+
+/* tiwlan_interrupt
+   TIWLAN interrupt handler. Disables interrupts and awakes tasklet.
+*/
+#if !(defined(HW_ACCESS_SDIO)||defined(HW_ACCESS_WSPI))
+static irqreturn_t tiwlan_interrupt (int irq, void *netdrv, struct pt_regs *cpu_regs)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)netdrv;
+
+    /*
+     * Workaround for the Linux 2.6 pending IRQ bug:
+     * If a pending IRQ is handled on a WLAN ISR, the ISR is called again
+     * even though it disabled itself in the first call. To protect against
+     * re-entrance, this flag is checked, and if it is already set (meaning
+     * that the ISR is called twice before the tasklet was called) nothing is done.
+     */
+    if (drv->interrupt_pending == 0)
+    {
+        UINT32 interruptVector;
+
+        interruptVector = configMgr_checkInterrupts(drv->adapter.CoreHalCtx);
+        if (interruptVector != 0)
+        {
+            configMgr_disableInterrupts(drv->adapter.CoreHalCtx);
+            drv->interrupt_pending = 1;
+            tasklet_schedule (&drv->tl);     
+        }
+        else
+        {
+#if DEBUG_UNKNOWN_INTERRUPT
+            ti_dprintf (TIWLAN_LOG_ERROR, 
+                        "%s - ERROR - interrupt isn't TNET interrupt! interrupt vector = 0x%08X\n",
+                        __FUNCTION__, interruptVector);
+#endif
+        }
+    }
+    return IRQ_HANDLED;
+}
+
+#else
+
+static irqreturn_t tiwlan_interrupt (int irq, void *netdrv, struct pt_regs *cpu_regs)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)netdrv;
+
+       drv->interrupt_pending = 1;
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+#ifdef DM_USE_WORKQUEUE
+    if( queue_work( drv->tiwlan_wq, &drv->tirq ) != 0 ) {
+#ifdef CONFIG_ANDROID_POWER
+        android_lock_suspend( &drv->irq_wake_lock );
+#endif
+    }
+    /* disable_irq( drv->irq ); Dm: No need, we can loose IRQ */
+#else
+       tasklet_schedule( &drv->tl );
+#endif
+    return IRQ_HANDLED;
+}
+#endif
+
+
+static void tiwlan_poll_irq_handler(unsigned long parm)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)parm;
+    bm_trace(2, 0, 0);
+
+    tiwlan_interrupt(0, drv, NULL);
+    mod_timer(&drv->poll_timer, jiffies + TIWLAN_IRQ_POLL_INTERVAL);
+}
+
+static void tiwlan_handle_control_requests( tiwlan_net_dev_t *drv )
+{
+    bm_trace(4, 0, 0);
+
+    /* Handle control requests (timers, ioctls) */
+    while(!list_empty(&drv->request_q))
+    {
+       struct list_head *entry = drv->request_q.next;
+       tiwlan_req_t *req = list_entry(entry, tiwlan_req_t, list);
+       tiwlan_req_t tmp_req;
+       unsigned long flags;
+    
+       spin_lock_irqsave(&drv->lock, flags);
+       list_del_init(entry);
+       spin_unlock_irqrestore(&drv->lock, flags);
+
+       ti_nodprintf(TIWLAN_LOG_INFO, "%s: f=0x%x req=0x%x reply_expected=%d\n",
+                  __FUNCTION__, req->u.req.f, req, req->u.req.reply_expected);
+
+       tmp_req.u.req.p1 = 0x1234;
+       tmp_req.u.req.p2 = 0x4321;
+       tmp_req.u.req.p3 = 0x1221;
+       tmp_req.u.req.p4 = 0x4334;
+       tmp_req.u.req.reply_expected = 0x50;
+
+       req->u.reply = req->u.req.f(req);
+
+       if ((tmp_req.u.req.p1 != 0x1234) || (tmp_req.u.req.p2 != 0x4321) || (tmp_req.u.req.p3 != 0x1221) || (tmp_req.u.req.p4 != 0x4334) || (tmp_req.u.req.reply_expected != 0x50))
+       {
+               printk("\n\n !!! ERROR: STACK CORRUPTION !!! : \nf=%p\n", tmp_req.u.req.f);
+               if (!req->u.req.reply_expected)
+                       printk("timer handler: %p\n", (void *)tmp_req.u.req.p1);
+       }
+
+       ti_nodprintf(TIWLAN_LOG_INFO, "%s: f=0x%x req=0x%x reply_expected=%d reply=%d\n",
+                  __FUNCTION__, req->u.req.f, req, req->u.req.reply_expected, req->u.reply);
+       if (req->u.req.reply_expected)
+       {
+          ti_nodprintf(TIWLAN_LOG_INFO, "%s: about to awake task\n", __FUNCTION__);
+          complete(&req->u.req.comp);
+       }
+    }
+
+    bm_trace(5, 0, 0);
+
+       /* DbgCB_Insert(0, DBG_MODULE_OS, DBG_TYPE_TASKLET, 1)*/
+}
+
+#ifdef DM_USE_WORKQUEUE
+static void tiwlan_irq_handler( struct work_struct *work )
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)container_of( work, struct tiwlan_net_dev, tirq );
+
+    /* if the driver was unloaded by that time we need to ignore all the timers */   
+    if (drv->unload_driver) {
+#ifdef CONFIG_ANDROID_POWER
+        android_unlock_suspend( &drv->irq_wake_lock );
+#endif
+        /* enable_irq( drv->irq ); */
+        return;
+    }
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+    configMgr_handleInterrupts( drv->adapter.CoreHalCtx );
+    tiwlan_handle_control_requests( drv );
+#ifdef CONFIG_ANDROID_POWER
+    if( drv->receive_packet ) {
+        drv->receive_packet = 0;
+        /* Keep awake for 500 ms to give a chance to network stack */
+        android_lock_suspend_auto_expire( &drv->rx_wake_lock, (HZ >> 1) );
+    }
+    android_unlock_suspend( &drv->irq_wake_lock );
+#endif
+    /* enable_irq( drv->irq ); */
+}
+#endif
+
+/* tiwlan_tasklet_handler
+   WLAN protocol tasklet. Most of work happens in the
+   context of this tasklet.
+*/
+#ifdef DM_USE_WORKQUEUE
+static void tiwlan_work_handler( struct work_struct *work )
+#else
+static void tiwlan_tasklet_handler( unsigned long netdrv )
+#endif
+{
+#ifdef DM_USE_WORKQUEUE
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)container_of( work, struct tiwlan_net_dev, tw );
+#else
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)netdrv;
+#endif
+#ifdef STACK_PROFILE
+    unsigned int curr1, base1;
+    unsigned int curr2, base2;
+    static unsigned int maximum_stack = 0;
+#endif
+
+    /* if the driver was unloaded by that time we need to ignore all the timers */   
+    if (drv->unload_driver) {
+#ifdef CONFIG_ANDROID_POWER
+        android_unlock_suspend( &drv->timer_wake_lock );
+#endif
+        return;
+    }
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+#if 0
+    ti_dprintf(TIWLAN_LOG_INFO, "%s in\n" , __FUNCTION__);
+#endif
+
+#ifdef DRIVER_PROFILE
+    os_profile (drv, 0, 0);
+#endif    
+    bm_trace(3, 0, 0);
+
+#ifdef STACK_PROFILE
+    curr1 = check_stack_start(&base1);
+#endif
+
+    /* Handle bus transaction interrupts */    
+       if (drv->dma_done)
+       {
+               drv->dma_done = 0;
+               configMgr_HandleBusTxn_Complete(drv->adapter.CoreHalCtx);
+       }
+
+       /* don't call for "Handle interrupts, timers, ioctls" while recovery process */
+       if (configMgr_areInputsFromOsDisabled(drv->adapter.CoreHalCtx) == TRUE) {
+#ifdef CONFIG_ANDROID_POWER
+        android_unlock_suspend( &drv->timer_wake_lock );
+#endif
+               return;
+       }
+
+    /* Handle firmware interrupts */
+#ifndef DM_USE_WORKQUEUE
+    if (drv->interrupt_pending)
+    {
+        drv->interrupt_pending = 0;
+        configMgr_handleInterrupts(drv->adapter.CoreHalCtx);
+    }
+#endif
+
+    tiwlan_handle_control_requests( drv );
+
+#ifdef STACK_PROFILE
+       curr2 = check_stack_stop(&base2);
+
+    if (base2 == base1)
+    {   
+       /* if the current measurement is bigger then the maximum store it and print*/
+        if ((curr1 - curr2) > maximum_stack)
+        {
+            printk("STACK PROFILER GOT THE LOCAL MAXIMMUM!!!! \n");
+            printk("current operation stack use =%d \n",(curr1 - curr2));
+            printk("total stack use=%d \n",8192 - curr2 + base2);
+            printk("total stack usage= %d percent \n",100 * (8192 - curr2 + base2) / 8192);
+                       maximum_stack = curr1 - curr2;
+       }
+    }
+#endif
+
+#ifdef DRIVER_PROFILE
+    os_profile (drv, 1, 0);
+#endif    
+
+#if 0
+    ti_dprintf(TIWLAN_LOG_INFO, "%s out\n" , __FUNCTION__);
+#endif
+#ifdef CONFIG_ANDROID_POWER
+    android_unlock_suspend( &drv->timer_wake_lock );
+#endif
+}
+
+#ifdef CONFIG_TROUT_PWRSINK
+static void tiwlan_rx_watchdog(struct work_struct *work)
+{
+    struct delayed_work *dwork = (struct delayed_work *) container_of(work, struct delayed_work, work);
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)container_of( dwork, struct tiwlan_net_dev, trxw );
+
+    unsigned long num_rx_pkts = num_rx_pkt_new - num_rx_pkt_last;
+    /* Contribute 10mA (200mA x 5%) for 1 pkt/sec, and plus 8mA base. */
+    unsigned percent = (num_rx_pkts  / (2 * RX_RATE_INTERVAL_SEC)) * 10 + PWRSINK_WIFI_PERCENT_BASE;
+
+    if (drv->unload_driver)
+       return;
+       
+    percent = (percent > 100) ? 100 : percent;
+    /* printk(KERN_INFO "num_rx_pkts=%ld, percent=%d\n", num_rx_pkts, percent); */
+    trout_pwrsink_set(PWRSINK_WIFI, percent);
+
+    num_rx_pkt_last = num_rx_pkt_new;
+
+    if (drv && drv->tiwlan_wq)
+        queue_delayed_work(drv->tiwlan_wq, &drv->trxw, msecs_to_jiffies(MSEC_PER_SEC * RX_RATE_INTERVAL_SEC));
+}
+#endif
+
+/* tiwlan_send_wait_reply
+   This internal interface function creates request and sends
+   it to the control tasklet for processing.
+   The calling process is blocked until the request is replied.
+   Function f is being called in the context of the control tasklet.
+   The request block that is passed to the function as a parameter
+   contains p1, p2, p3, p4.
+   The function return code is propagated back to the caller.
+   tiwlan_send_req_and_wait returns (*f) return code or
+   -ENOMEM if failed to allocate a request.
+*/
+int tiwlan_send_wait_reply(tiwlan_net_dev_t *drv,
+                           int (*f)(tiwlan_req_t *req),
+                           unsigned long p1,
+                           unsigned long p2,
+                           unsigned long p3,
+                           unsigned long p4)
+{
+    tiwlan_req_t req;
+    unsigned long flags;
+
+    /* Send request to tiwlan_tasklet and wait for reply */
+
+    req.drv = drv;
+    req.u.req.f = f;
+    req.u.req.p1 = p1;
+    req.u.req.p2 = p2;
+    req.u.req.p3 = p3;
+    req.u.req.p4 = p4;
+    req.u.req.reply_expected = 1;
+    init_completion(&req.u.req.comp);
+
+    spin_lock_irqsave(&drv->lock, flags);
+    list_add_tail(&req.list, &drv->request_q);
+    spin_unlock_irqrestore(&drv->lock, flags);
+
+#ifdef DM_USE_WORKQUEUE
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+    if( queue_work( drv->tiwlan_wq, &drv->tw ) != 0 ) {
+#ifdef CONFIG_ANDROID_POWER
+        android_lock_suspend( &drv->timer_wake_lock );
+#endif
+    }
+#else
+    tasklet_schedule( &drv->tl );
+#endif
+    wait_for_completion(&req.u.req.comp);
+
+    return req.u.reply;
+}
+
+
+#define WLAN_PCMCIA_CFG_REG       0x0524
+/* tiwlan_set_hw_access */
+static int tiwlan_set_hw_access(tiwlan_net_dev_t *drv)
+{
+#ifdef TIWLAN_OMAP1610
+    OS_WRITE_REG(drv, HI_CFG, 0x00000a00);
+
+#if ! ((defined(HW_ACCESS_SDIO)||defined(HW_ACCESS_WSPI)) && defined(TNETW1150))
+    OS_WRITE_REG(drv, WLAN_PCMCIA_CFG_REG, 0xC6880000);
+    OS_WRITE_REG(drv, PCI_ARB_CFG, 0x2);
+#endif
+
+#endif
+    return 0;
+}
+
+
+/* tiwlan_free_drv
+   Unmap h/w regions and free driver's structure
+*/
+static void tiwlan_free_drv(tiwlan_net_dev_t *drv)
+{
+#ifdef TIWLAN_OMAP1610
+    if (drv->acx_mem.pa && drv->acx_mem.va)
+        iounmap(drv->acx_mem.va);
+    if (drv->acx_reg.pa && drv->acx_reg.va && drv->acx_reg.va != drv->acx_reg.va)
+        iounmap(drv->acx_reg.va);
+#endif
+    kfree(drv);
+}
+
+
+/* tiwlan_alloc_drv
+   Allocate driver's structure and map h/w regions
+*/
+static tiwlan_net_dev_t *
+tiwlan_alloc_drv(unsigned long reg_start, unsigned long reg_size,
+                 unsigned long mem_start, unsigned long mem_size,
+                 int map_io, int irq)
+{
+    static tiwlan_net_dev_t *drv;
+    drv = kmalloc(sizeof(tiwlan_net_dev_t), GFP_KERNEL);
+#ifdef TI_MEM_ALLOC_TRACE        
+    os_printf("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, sizeof(tiwlan_net_dev_t), GFP_KERNEL, sizeof(tiwlan_net_dev_t));
+#endif/*I_MEM_ALLOC_TRACE*/
+
+    if (!drv)
+        return NULL;
+    memset(drv, 0, sizeof(tiwlan_net_dev_t));
+    drv->acx_mem.size = mem_size;
+    drv->acx_reg.size = reg_size;
+#ifdef TIWLAN_OMAP1610
+    if (map_io)
+    {
+        drv->acx_mem.pa = mem_start;
+        drv->acx_reg.pa = reg_start;
+        drv->acx_mem.va = ioremap(drv->acx_mem.pa, drv->acx_mem.size);
+        if (drv->acx_mem.pa!=drv->acx_reg.pa || drv->acx_mem.size!=drv->acx_reg.size)
+            drv->acx_reg.va = ioremap(drv->acx_reg.pa, drv->acx_reg.size);
+        else
+            drv->acx_reg.va = drv->acx_mem.va;
+    }
+    else
+    {
+        /* Memory is already mapped */
+        drv->acx_mem.va = (void *)mem_start;
+        drv->acx_reg.va = (void *)reg_start;
+    }
+#endif /* Dm: */
+    drv->irq = irq;
+    return drv;
+}
+
+
+/* tiwlan_init_drv
+   Called in process context
+ */
+int tiwlan_init_drv (tiwlan_net_dev_t *drv, tiwlan_dev_init_t *init_info)
+{
+    initTable_t *init_table;
+    int rc;
+    void *pWLAN_Images[4];
+
+    /* printk("%s\n", __FUNCTION__); */
+    /* It is OK if already initialized */
+    if (drv->adapter.CoreHalCtx)
+        return 0;
+
+    init_table = os_memoryAlloc (drv, sizeof(initTable_t));
+
+#ifdef TI_MEM_ALLOC_TRACE        
+    osPrintf ("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, sizeof(initTable_t), GFP_KERNEL, sizeof(initTable_t));
+#endif/*I_MEM_ALLOC_TRACE*/
+    if (!init_table)
+    {
+            ti_dprintf(TIWLAN_LOG_ERROR, "Cannot allocate init_table\n");
+            return -ENOMEM;
+    }
+
+    if (init_info)
+    {
+          drv->eeprom_image.size = init_info->eeprom_image_length;
+        if (drv->eeprom_image.size)
+            {
+            drv->eeprom_image.va = os_memoryAlloc (drv, drv->eeprom_image.size);
+
+#ifdef TI_MEM_ALLOC_TRACE        
+            osPrintf ("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, drv->eeprom_image.size, GFP_KERNEL, drv->eeprom_image.size);
+#endif
+            if (!drv->eeprom_image.va)
+            {
+                ti_dprintf (TIWLAN_LOG_ERROR, "Cannot allocate buffer for eeprom image\n");
+                drv->eeprom_image.size = 0;
+                return -ENOMEM;
+            }
+            memcpy (drv->eeprom_image.va, &init_info->data[0], drv->eeprom_image.size );
+            }
+        
+#ifdef FIRMWARE_DYNAMIC_LOAD
+        drv->firmware_image.size = init_info->firmware_image_length;
+            if (!drv->firmware_image.size)
+            {
+            ti_dprintf (TIWLAN_LOG_ERROR, "No firmware image\n");
+                return -EINVAL;
+            }
+        drv->firmware_image.va = os_memoryAlloc (drv,drv->firmware_image.size);
+#ifdef TI_MEM_ALLOC_TRACE        
+        osPrintf ("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, drv->firmware_image.size, GFP_KERNEL, drv->firmware_image.size);
+#endif
+        if (!drv->firmware_image.va)
+            {
+                ti_dprintf(TIWLAN_LOG_ERROR, "Cannot allocate buffer for firmware image\n");
+                drv->firmware_image.size = 0;
+            if (drv->eeprom_image.va)
+                os_memoryFree (drv, drv->eeprom_image.va, drv->eeprom_image.size);
+                return -ENOMEM;
+          }
+        memcpy (drv->firmware_image.va,
+                    &init_info->data[init_info->eeprom_image_length],
+                drv->firmware_image.size);
+#else
+        extern unsigned char tiwlan_fwimage[];
+        extern unsigned int sizeof_tiwlan_fwimage;
+
+        drv->firmware_image.size = sizeof_tiwlan_fwimage;
+        drv->firmware_image.va = tiwlan_fwimage;
+#endif
+    }
+
+    print_deb ("--------- Eeeprom=%p(%lu), Firmware=%p(%lu)\n", 
+                drv->eeprom_image.va, 
+                drv->eeprom_image.size,
+                drv->firmware_image.va, 
+               drv->firmware_image.size);
+    
+    /* Init defaults */
+    if ((rc = osInitTable_IniFile (drv, 
+                                   init_table,
+                           (init_info && init_info->init_file_length) ?
+                             &init_info->data[init_info->eeprom_image_length+init_info->firmware_image_length] : NULL,
+                               init_info ? init_info->init_file_length : 0)))
+   {
+        ti_dprintf (TIWLAN_LOG_ERROR, "osInitTable_IniFile failed :cannot initialize defaults\n");
+        os_memoryFree (drv, init_table, sizeof(initTable_t));
+        
+#ifdef TI_MEM_ALLOC_TRACE        
+        os_printf("MTT:%s:%d ::kfree(0x%p) : %d\n", __FUNCTION__, __LINE__, sizeof(initTable_t), -sizeof(initTable_t));
+#endif
+      return rc;
+   }
+
+    pWLAN_Images[0] = (void *)drv->firmware_image.va;
+    pWLAN_Images[1] = (void *)drv->firmware_image.size;
+    pWLAN_Images[2] = (void *)drv->eeprom_image.va;
+    pWLAN_Images[3] = (void *)drv->eeprom_image.size;
+   
+    drv->adapter.CoreHalCtx = configMgr_create (drv, 
+                                                pWLAN_Images,
+                                                init_table, 
+                                                (macAddress_t *) &drv->adapter.CurrentAddr);
+
+    drv->interrupt_pending = 0;
+    drv->dma_done = 0;
+
+    if (drv->irq)
+    {
+#ifndef PRIODIC_INTERRUPT
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+        unsigned long flags;
+        /* 
+         * Disable all interrupts for not to catch the tiwlan irq 
+         * between request_irq and disable_irq
+         */
+        spin_lock_irqsave (&(drv->lock), flags);
+        if ((rc = request_irq (drv->irq, tiwlan_interrupt, SA_SHIRQ, drv->netdev->name, drv)))
+#else
+        if ((rc = request_irq (drv->irq, (irq_handler_t)tiwlan_interrupt, IRQF_SHARED | IRQF_TRIGGER_FALLING /*Dm:*/, drv->netdev->name, drv)))
+#endif 
+        {
+            print_err ("TIWLAN: Failed to register interrupt handler\n");
+            configMgr_stop (drv->adapter.CoreHalCtx);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+            spin_unlock_irqrestore (&drv->lock, flags);
+#endif
+            return rc;
+        }
+#ifdef CONFIG_ANDROID_POWER
+        set_irq_wake(drv->irq, 1);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+               set_irq_type (drv->irq, IRQT_FALLING);
+#else
+        set_irq_type (drv->irq, IRQ_TYPE_EDGE_FALLING);
+#endif
+        disable_irq (drv->irq);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+        spin_unlock_irqrestore (&drv->lock, flags);
+#endif
+#else
+        printk (" tiwlan_init_drv :PRIODIC_INTERRUPT drv->irq %x\n",drv->irq);
+#endif
+    }
+    else
+    {
+        /* Debug mode: polling */
+        mod_timer (&drv->poll_timer, jiffies + TIWLAN_IRQ_POLL_INTERVAL);
+    }
+
+    /* 
+     * Now that all parts of the driver have been created and handles linked 
+     * proceed to download the FW code
+     */
+    configMgr_init (drv, 
+                    drv->adapter.CoreHalCtx, 
+                    pWLAN_Images, 
+                    init_table, 
+                    (macAddress_t *) &drv->adapter.CurrentAddr);
+
+    /* Wait for the download to complete */
+    os_WaitComplete ((void *)drv);
+
+    os_memoryFree (drv, init_table, sizeof(initTable_t));
+
+    if (rc == OK)
+    {   
+        proc_stat_init (drv->adapter.CoreHalCtx);
+#ifdef TI_MEM_ALLOC_TRACE        
+        osPrintf ("MTT:%s:%d ::kfree(0x%p) : %d\n", __FUNCTION__, __LINE__, sizeof(initTable_t), -sizeof(initTable_t));
+#endif/*I_MEM_ALLOC_TRACE*/
+
+       if (drv->adapter.CoreHalCtx == NULL)
+       {
+           ti_dprintf (TIWLAN_LOG_ERROR, "configMgr_create failed\n");
+           return -ENODEV;
+       }
+
+       /* eeprom buffer is going to be deallocated by the caller. It is no longer needed anyway */
+#if 0
+        drv->eeprom_image.va = NULL;
+        drv->eeprom_image.size = 0;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+        drv->wl_sock = netlink_kernel_create(NETLINK_USERSOCK, 0, NULL, THIS_MODULE); /* Dm: */
+#else
+        drv->wl_sock = netlink_kernel_create(NETLINK_USERSOCK, 0, NULL, NULL, THIS_MODULE); /* Dm: */
+#endif
+#else
+        drv->wl_sock = netlink_kernel_create(&init_net, NETLINK_USERSOCK, 0, NULL, NULL, THIS_MODULE); /* Dm: */
+#endif    
+        if (drv->wl_sock == NULL)
+        {
+            ti_dprintf(TIWLAN_LOG_ERROR, "netlink_kernel_create() failed !\n");
+            /* TODO: free in destroy */
+            return -EINVAL;
+        }
+
+        /* Finalize network interface setup */
+        drv->netdev->hard_start_xmit = tiwlan_drv_net_xmit;
+        memcpy (drv->netdev->dev_addr, drv->adapter.CurrentAddr, MAC_ADDR_LEN);
+        drv->netdev->addr_len = MAC_ADDR_LEN;
+
+        /* Register the relevant events with the event handler */
+        tiwlan_register_events (drv); 
+
+        /* Mark that init stage has succeded */
+        drv->initialized = 1;
+
+        return 0;
+    }
+
+    return -ENODEV;
+}
+
+
+/* tiwlan_start_drv
+*/
+int tiwlan_start_drv(tiwlan_net_dev_t *drv)
+{
+    /* printk("%s\n", __FUNCTION__); */
+    if (!drv->initialized)
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, "Attempt to start driver before initilization has succeeded\n");
+        return -ENODEV;
+    }
+    if (!drv->adapter.CoreHalCtx)
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, "Attempt to start driver before creating config_manager\n");
+        return -ENODEV;
+    }
+    if (drv->started)
+    {
+        /*ti_dprintf(TIWLAN_LOG_ERROR, "Attempt to start driver that has already started\n");*/
+        return -EALREADY;
+    }
+    if (configMgr_start(drv->adapter.CoreHalCtx) != OK)
+    {
+        print_err("TIWLAN: Failed to start config manager\n");
+        return -EINVAL;
+    }
+    drv->started = 1;
+
+#ifdef SDIO_INTERRUPT_HANDLING_ON
+    configMgr_SlaveAckMaskNotification(drv->adapter.CoreHalCtx);
+#endif
+    if (drv->netdev)
+        netif_start_queue(drv->netdev);
+#ifdef CONFIG_TROUT_PWRSINK
+    trout_pwrsink_set(PWRSINK_WIFI, PWRSINK_WIFI_PERCENT_BASE);
+#endif
+    return 0;
+}
+
+
+/* tiwlan_destroy_drc
+*/
+static void tiwlan_destroy_drv(tiwlan_net_dev_t *drv)
+{
+    int waitShutdownCounter;
+
+    /* close the ipc_kernel socket*/
+    if (drv && drv->wl_sock) {
+        sock_release(drv->wl_sock->sk_socket);
+    }
+
+    bm_destroy();
+
+    tiwlan_stop_and_destroy_drv(drv);
+#ifdef DM_USE_WORKQUEUE
+    while( tiwlan_del_msdu(drv) != NULL );
+#endif
+    if (drv->adapter.CoreHalCtx)
+    {
+        /* Delay return to OS until all driver components (HAL/SME) are shutdown */
+        for (waitShutdownCounter=1; waitShutdownCounter<=DRV_SHUTDOWN_TEST_MAX_COUNTER; waitShutdownCounter++)
+        {
+            /* Check if HAL/SME are stopped - If so - exit loop and return to OS */
+            if (configMgr_DriverShutdownStatus(drv->adapter.CoreHalCtx) == DRIVER_SHUTDOWN_COMPLETE)
+            {
+                break;
+            }
+            /* Delay of 100ms between shutdown test */
+            mdelay ( DRV_SHUTDOWN_TEST_DELAY_INTERVAL );
+        }
+
+        /* If driver was not shutdown properly - destroy all timers "manually" and exit*/
+        if ( waitShutdownCounter == DRV_SHUTDOWN_TEST_MAX_COUNTER+1 )
+        {
+            os_printf("Timeout while waiting for driver to shutdown...Shutdown status flag=0x%x\n",configMgr_DriverShutdownStatus(drv->adapter.CoreHalCtx));
+        }
+   
+        drv->unload_driver = 1;
+
+        proc_stat_destroy();
+        if (drv->irq) {
+#ifdef CONFIG_ANDROID_POWER
+            set_irq_wake(drv->irq, 0);
+#endif
+            free_irq(drv->irq, drv);
+        }
+        else
+            del_timer_sync(&drv->poll_timer);
+
+        /* Unload all modules (free memory) & destroy timers */
+        configMgr_UnloadModules (drv->adapter.CoreHalCtx);
+
+#ifdef FIRMWARE_DYNAMIC_LOAD
+        if( drv->firmware_image.va ) {
+            os_memoryFree(drv,drv->firmware_image.va, drv->firmware_image.size);
+#ifdef TI_MEM_ALLOC_TRACE        
+            os_printf("MTT:%s:%d ::kfree(0x%p) : %d\n", __FUNCTION__, __LINE__, drv->firmware_image.size, -drv->firmware_image.size);
+#endif /*I_MEM_ALLOC_TRACE*/
+        }
+        if( drv->eeprom_image.va )
+        { 
+            os_memoryFree (drv, drv->eeprom_image.va, drv->eeprom_image.size);
+#ifdef TI_MEM_ALLOC_TRACE        
+            os_printf("MTT:%s:%d ::kfree(0x%p) : %d\n", __FUNCTION__, __LINE__, drv->eeprom_image.size, -drv->eeprom_image.size);
+#endif /*I_MEM_ALLOC_TRACE*/
+        }
+#endif /*FIRMWARE_DYNAMIC_LOAD*/
+    }
+#ifdef DM_USE_WORKQUEUE
+#ifdef CONFIG_TROUT_PWRSINK
+    cancel_delayed_work_sync(&drv->trxw);
+#endif    
+    destroy_workqueue(drv->tiwlan_wq);
+#endif
+#ifdef CONFIG_ANDROID_POWER
+    android_uninit_suspend_lock(&drv->irq_wake_lock);
+    android_uninit_suspend_lock(&drv->xmit_wake_lock);
+    android_uninit_suspend_lock(&drv->timer_wake_lock);
+    android_uninit_suspend_lock(&drv->rx_wake_lock);
+#endif
+    unregister_netdev(drv->netdev);
+    tiwlan_free_drv(drv);
+}
+
+
+/* tiwlan_create_dev
+   Create tiwlan device instance.
+   Returns 0 if OK
+*/
+static int
+tiwlan_create_drv(unsigned long reg_start, unsigned long reg_size,
+                  unsigned long mem_start, unsigned long mem_size,
+                  int map_io, int irq,
+                  void *priv, tiwlan_net_dev_t **p_drv)
+{
+    tiwlan_net_dev_t *drv;
+    int rc;
+
+    /* printk("%s\n", __FUNCTION__); */
+    /* Allocate device and map h/w regions */
+    drv = tiwlan_alloc_drv(reg_start, reg_size, mem_start, mem_size, map_io, irq);
+    if (!drv)
+        return -ENOMEM;
+
+    /* Check h/w access */
+    if (tiwlan_set_hw_access(drv))
+    {
+        tiwlan_free_drv(drv);
+        return -ENODEV;
+    }
+
+#ifdef DM_USE_WORKQUEUE
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+    drv->tiwlan_wq = create_singlethread_workqueue("tiwlan_wifi_wq");
+#else
+    drv->tiwlan_wq = create_freezeable_workqueue("tiwlan_wifi_wq");
+#endif
+    if( !(drv->tiwlan_wq) ) {
+        tiwlan_free_drv(drv);
+        printk(KERN_ERR "Failed to create workqueue\n");
+        return -EINVAL;
+    }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+    INIT_WORK( &drv->tw, tiwlan_work_handler, &drv->tw );
+    INIT_WORK( &drv->txmit, tiwlan_xmit_handler, &drv->txmit );
+    INIT_WORK( &drv->tirq, tiwlan_irq_handler, &drv->tirq );
+#else
+    INIT_WORK( &drv->tw, tiwlan_work_handler );
+    INIT_WORK( &drv->txmit, tiwlan_xmit_handler );
+    INIT_WORK( &drv->tirq, tiwlan_irq_handler );
+#endif
+    drv->txmit_msdu_next = drv->txmit_msdu_last = NULL;
+#else
+    tasklet_init( &drv->tl, tiwlan_tasklet_handler, (unsigned long)drv );
+#endif
+
+#ifdef CONFIG_TROUT_PWRSINK
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+    INIT_DELAYED_WORK( &drv->trxw, tiwlan_rx_watchdog, &drv->trxw );
+#else
+    INIT_DELAYED_WORK( &drv->trxw, tiwlan_rx_watchdog );
+#endif
+#endif
+
+#ifdef CONFIG_ANDROID_POWER
+    drv->receive_packet = 0;
+    drv->irq_wake_lock.name = "tiwlan_irq_wake";
+    android_init_suspend_lock(&drv->irq_wake_lock);
+    drv->xmit_wake_lock.name = "tiwlan_xmit_wake";
+    android_init_suspend_lock(&drv->xmit_wake_lock);
+    drv->timer_wake_lock.name = "tiwlan_timer_wake";
+    android_init_suspend_lock(&drv->timer_wake_lock);
+    drv->rx_wake_lock.name = "tiwlan_rx_wake";
+    android_init_suspend_lock(&drv->rx_wake_lock);
+#endif
+    spin_lock_init(&drv->lock);
+    INIT_LIST_HEAD(&drv->request_q);
+    init_timer(&drv->poll_timer);
+    drv->poll_timer.function = tiwlan_poll_irq_handler;
+    drv->poll_timer.data   = (unsigned long)drv;
+
+    /* Init the completion obhect needed for init async purpose */
+    init_completion(&drv->comp);
+
+    /* Register network device */
+    rc = setup_netif(drv);
+    if (rc)
+    {
+        tiwlan_free_drv(drv);
+        return rc;
+    }
+    drv->priv = priv;
+
+    list_add(&drv->list, &tiwlan_drv_list);
+    if (p_drv)
+        *p_drv = drv;
+
+    drv->initialized = 0;
+
+    /* Profiler */
+#ifdef DRIVER_PROFILING
+    tiwlan_profile_create (drv); 
+#endif
+
+    bm_init(drv);
+
+#ifdef NO_USERMODE_WORKAROUND
+    rc = tiwlan_init_drv(drv, NULL);
+    rc = rc ? rc : tiwlan_start_drv(drv);
+#endif
+
+    return 0;
+}
+
+/* tiwlan_stop_driver
+*/
+int tiwlan_stop_drv(tiwlan_net_dev_t *drv)
+{
+    if (!drv->adapter.CoreHalCtx)
+        return 0;
+
+    if (drv->netdev)
+        netif_stop_queue(drv->netdev);
+
+    configMgr_stop(drv->adapter.CoreHalCtx);
+
+    drv->started = 0;
+#ifdef CONFIG_TROUT_PWRSINK
+    trout_pwrsink_set(PWRSINK_WIFI, 0);
+#endif
+    return 0;
+}
+
+/* tiwlan_stop__and_destroy_driver
+*/
+int tiwlan_stop_and_destroy_drv(tiwlan_net_dev_t *drv)
+{
+    if (!drv->adapter.CoreHalCtx)
+        return 0;
+
+    if (drv->netdev)
+        netif_stop_queue(drv->netdev);
+
+    /* Start unload process by calling smeSm_stop, and halting the HAL */
+    /* SmeSm_stop finish notification will be one by setting flags */
+    configMgr_InitiateUnload(drv->adapter.CoreHalCtx);
+    drv->started = 0; 
+    return 0;
+}
+
+
+#ifdef TIWLAN_CARDBUS
+
+static struct pci_device_id tnetw1130_pci_tbl[] __devinitdata =
+{
+    { VENDOR_ID_TI, DEVICE_ID_TI_WLAN, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+    { 0, }
+};
+
+static int __devinit
+tnetw1130_pci_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
+{
+    tiwlan_net_dev_t *drv;
+    int rc;
+
+    print_info("tnetw1130_pci_init_one:\n");
+    /* IT: for some reason interrupt doesn't work. 
+       use poling mode for now (comments around
+       pcidev->irq below)
+    */
+    rc = tiwlan_create_drv(pcidev->resource[0].start,
+                           pcidev->resource[0].end - pcidev->resource[0].start,
+                           pcidev->resource[1].start,
+                           pcidev->resource[1].end - pcidev->resource[1].start,
+                           1,
+                           0/*pcidev->irq*/, pcidev, &drv);
+    if (!rc)
+        pcidev->driver_data = drv;
+    return rc;
+}
+
+void tnetw1130_pci_remove(struct pci_dev *dev)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)dev->driver_data;
+    if (drv)
+    {
+        dev->driver_data = NULL;
+        tiwlan_destroy_drv(drv);
+    }
+}
+
+static struct pci_driver tnetw1130_pci_driver = {
+    .name =      "tnetw1130",
+    .id_table =  tnetw1130_pci_tbl,
+    .probe = tnetw1130_pci_init_one,
+    .remove =    tnetw1130_pci_remove
+};
+
+#endif /* #ifdef TIWLAN_CARDBUS */
+
+#ifdef TIWLAN_OMAP1610
+int omap1610_drv_create(void)
+{
+    omap_memif_init();
+    return tiwlan_create_drv(TIWLAN_OMAP1610_REGBASE, TIWLAN_OMAP1610_REGSIZE,
+                             TIWLAN_OMAP1610_MEMBASE, TIWLAN_OMAP1610_MEMSIZE,
+                             0, TIWLAN_OMAP1610_IRQ, NULL, NULL);
+}
+#endif /* #ifdef TIWLAN_OMAP1610 */
+
+#ifdef TIWLAN_MSM7000
+
+#define TROUT_IRQ MSM_GPIO_TO_INT(29)
+
+static void tiwlan_sdio_irq(struct sdio_func *func)
+{
+    printk("%s:\n", __FUNCTION__);
+}
+
+static const struct sdio_device_id tiwlan_sdio_ids[] = {
+    { SDIO_DEVICE_CLASS(SDIO_CLASS_WLAN)    },
+    {                                       },
+};
+
+MODULE_DEVICE_TABLE(sdio, tiwlan_sdio_ids);
+
+int tiwlan_sdio_init(struct sdio_func *func)
+{
+    int rc;
+
+    rc = sdio_enable_func(func);
+    if (rc)
+        return rc;
+
+    rc = sdio_set_block_size(func, 512);
+    if( rc ) {
+        sdio_disable_func(func);
+    }
+    return rc;
+}
+
+static int tiwlan_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
+{
+       int rc;
+
+       SDIO_SetFunc( NULL );
+       if (func->vendor != VENDOR_ID_TI || func->device != DEVICE_ID_TI_WLAN)
+               return -ENODEV;
+
+       printk(KERN_INFO
+              "TIWLAN: Found SDIO controller (vendor 0x%x, device 0x%x)\n",
+              func->vendor, func->device);
+
+#ifdef CONFIG_TROUT_PWRSINK
+       trout_pwrsink_set(PWRSINK_WIFI, PWRSINK_WIFI_PERCENT_BASE);
+#endif
+
+       sdio_claim_host(func);
+
+       rc = tiwlan_sdio_init(func);
+       if (rc)
+               goto err2;
+
+       rc = sdio_claim_irq(func, tiwlan_sdio_irq);
+       if (rc)
+               goto err1;
+
+       SDIO_SetFunc( func );
+
+       rc = tiwlan_create_drv(0, 0, 0, 0, 0, TROUT_IRQ, NULL, NULL);
+
+       printk(KERN_INFO "TIWLAN: Driver initialized (rc %d)\n", rc);
+       complete(&sdio_wait);
+       return rc;
+err1:
+       sdio_disable_func(func);
+err2:
+       sdio_release_host(func);
+       complete(&sdio_wait);
+       printk(KERN_ERR "TIWLAN: SDIO failure (err %d)\n", rc);
+       return rc;
+}
+
+static void tiwlan_sdio_remove(struct sdio_func *func)
+{
+       printk(KERN_DEBUG "TIWLAN: Releasing SDIO resources\n");
+       sdio_release_irq(func);
+       sdio_disable_func(func);
+       sdio_release_host(func);
+       printk(KERN_DEBUG "TIWLAN: SDIO resources released\n");
+}
+
+static struct sdio_driver tiwlan_sdio_drv = {
+    .probe          = tiwlan_sdio_probe,
+    .remove         = tiwlan_sdio_remove,
+    .name           = "sdio_tiwlan",
+    .id_table       = tiwlan_sdio_ids,
+};
+#endif /* TIWLAN_MSM7000 */
+
+static int __init tiwlan_module_init(void)
+{
+    int rc = 0;
+
+    printk(KERN_INFO "TIWLAN: Driver loading\n");
+   /* Check sizes of basic structures to ensure that compilation
+      options are OK
+   */
+    if (packed_struct_tst())
+        ;/*IT: return -EINVAL; */
+
+    tiwlan_deb_entry = create_proc_entry("mem", 0644, NULL);
+    if (tiwlan_deb_entry == NULL)
+        return -EINVAL;
+    tiwlan_deb_entry->read_proc = tiwlan_deb_read_proc;
+    tiwlan_deb_entry->write_proc = tiwlan_deb_write_proc;
+#ifdef TIWLAN_MSM7000
+    init_completion(&sdio_wait);
+#endif
+#ifdef TIWLAN_CARDBUS
+    if ((rc=pci_register_driver(&tnetw1130_pci_driver)) <  0)
+        print_err("TIWLAN: PCMCIA driver failed to register\n");
+        return rc;
+    }
+    return 0;
+
+#elif defined(TIWLAN_OMAP1610)
+    rc = omap1610_drv_create();
+    return rc;
+
+#elif defined(TIWLAN_MSM7000)
+    trout_wifi_power(1);          /* Power On */
+    trout_wifi_reset(0);          /* Reset clear */
+    trout_wifi_set_carddetect(1); /* CardDetect (0->1) */
+
+    /* Register ourselves as an SDIO driver */
+    rc = sdio_register_driver(&tiwlan_sdio_drv);
+    if (rc < 0) {
+        printk(KERN_ERR "sdio register failed (%d)\n", rc);
+        return rc;
+    }
+    /* rc = tiwlan_create_drv(0, 0, 0, 0, 0, TROUT_IRQ, NULL, NULL); -- Called in probe */
+
+    tiwlan_calibration = create_proc_entry("calibration", 0644, NULL);
+    if (tiwlan_calibration == NULL)
+       return -EINVAL;
+    tiwlan_calibration->size = tiwlan_get_nvs_size();
+    tiwlan_calibration->read_proc = tiwlan_calibration_read_proc;
+    tiwlan_calibration->write_proc = tiwlan_calibration_write_proc;
+
+    if (!wait_for_completion_timeout(&sdio_wait, msecs_to_jiffies(10000))) {
+        printk(KERN_ERR "%s: Timed out waiting for device detect\n", __func__);
+        remove_proc_entry("calibration", NULL);
+        sdio_unregister_driver(&tiwlan_sdio_drv);
+        trout_wifi_set_carddetect(0); /* CardDetect (1->0) */
+        trout_wifi_reset(1);          /* Reset active */
+        trout_wifi_power(0);          /* Power Off */
+        return -ENODEV;
+    }
+    printk(KERN_INFO "TIWLAN: Driver loaded\n");
+    return 0;
+
+#else
+
+#error Either TIWLAN_CARDBUS, TIWLAN_OMAP1610 or TIWLAN_MSM7000 must be defined
+
+#endif
+}
+
+static void __exit tiwlan_module_cleanup(void)
+{
+    struct list_head *l;
+    struct list_head *tmp;
+
+    printk(KERN_INFO "TIWLAN: Driver unloading\n");
+#ifdef TIWLAN_CARDBUS
+    pci_unregister_driver(&tnetw1130_pci_driver);
+#endif
+    list_for_each_safe(l, tmp, &tiwlan_drv_list)
+    {
+        tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)list_entry(l, tiwlan_net_dev_t, list);
+        list_del(l);   
+        tiwlan_destroy_drv(drv);
+    }
+    remove_proc_entry("mem", NULL);
+#ifdef TIWLAN_MSM7000
+    remove_proc_entry("calibration", NULL);
+    sdio_unregister_driver(&tiwlan_sdio_drv);
+    trout_wifi_set_carddetect(0); /* CardDetect (1->0) */
+    trout_wifi_reset(1);          /* Reset active */
+    trout_wifi_power(0);          /* Power Off */
+#endif
+    printk(KERN_INFO "TIWLAN: Driver unloaded\n");
+}
+
+module_init(tiwlan_module_init);
+module_exit(tiwlan_module_cleanup);
diff --git a/sta_dk_4_0_4_32/pform/linux/src/ioctl_list.c b/sta_dk_4_0_4_32/pform/linux/src/ioctl_list.c
new file mode 100644 (file)
index 0000000..5c3fa32
--- /dev/null
@@ -0,0 +1,263 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include "arch_ti.h"
+
+#include <asm/uaccess.h>        /* copy_to_user() */
+#include <linux/netdevice.h>
+#include <linux/ioctl.h>
+#include <linux/completion.h>
+#include <linux/vmalloc.h>
+
+#include "esta_drv.h"
+#include "tiwlan_profile.h"
+#include "ioctl_init.h"
+#include "ioctl_utils.h"
+#include "tiioctl.h"
+#include "ipc_k.h"
+
+
+void print_priv_ioctl_params(struct net_device *dev, tiioctl_req_t *req, char *extra)
+{
+        print_deb(" priv_ioctl_params(*dev:%p,*req:%p, *extra:%p)\n", dev, req, extra);
+        print_deb("   wrqu.point: user_data=%p, length=%ld, cmd=%ld\n", (void *) req->user_data_pointer,
+                  req->length, req->cmd );
+        print_deb("   wrqu dump: ");
+        print_memory_dump((char *) req, sizeof(*req) );
+        print_deb("\n");
+
+        if( extra )
+        {
+                print_deb("   extra (%p) :", extra );
+                print_memory_dump(extra, req->length );
+                print_deb("\n");
+        }
+}
+
+/*sends complete to the user after to signal the completion of the asynchronous */
+/*operation (need to set *pIoCompleteFlag = FALSE, at osCmd.c).*/
+
+void os_IoctlComplete(PTIWLN_ADAPTER_T pAdapter, TI_STATUS ReturnStatus )
+{
+       *pAdapter->pCompleteReply = (int)ReturnStatus;
+    complete(pAdapter->IoctlComp);
+}
+
+
+NTSTATUS DispatchCommand(PTIWLN_ADAPTER_T pAdapter,ULONG ioControlCode,PULONG outBufLen,
+                    ULONG inBufLen,PVOID ioBuffer,PUINT8 pIoCompleteFlag);
+
+int ti1610_ioctl_priv_proc_tl(tiwlan_req_t *req_data)
+{
+    struct net_device *dev = req_data->drv->netdev;
+    tiioctl_req_t *req = (tiioctl_req_t *) req_data->u.req.p1;
+    static unsigned int drv_started = 0;
+       static UINT8 IoCompleteFlag ;
+
+    ULONG *data = (ULONG *) req_data->u.req.p2;
+
+    int res = -EINVAL;
+
+    print_deb("priv_ioctl_proc(): cmd=%ld, data=%p (user_data=%lx), lenght=%ld\n",
+                req->cmd, data, req->user_data_pointer, req->length);
+    if( !drv_started && (req->cmd != TIWLN_DRIVER_STATUS_SET)) { /* Dm: Fix */
+            return res;
+    }
+                                       
+    switch( req->cmd ) {
+        case TIWLN_DRIVER_STATUS_SET:
+            if(*data)
+                res = tiwlan_start_drv( (tiwlan_net_dev_t *)dev->priv );
+            else
+                res = tiwlan_stop_drv( (tiwlan_net_dev_t *)dev->priv );
+
+            if( res == OK )
+                    drv_started = !drv_started;
+            break;
+
+        case TIWLN_SEND_EAPOL_PACKET:
+            res = os_sendPacket(dev, data, req->length);
+            break;
+#ifdef TI_DBG
+        case TIWLN_DRIVER_DEBUG_PRINT:
+                res = util_hal_debug_print(dev, data);
+                break;
+#endif /* TI_DBG */
+        default:
+               {
+            res = DispatchCommand(&req_data->drv->adapter, req->cmd, &req->length, req->length, data,&IoCompleteFlag );
+                       /* If we do not have to send complete to user back then set the Falg to FALSE 
+                       The Complete will be sent from another contect of command completion from FW */
+                       if(IoCompleteFlag == FALSE)
+                       {
+                          req_data->u.req.reply_expected = FALSE;
+                          /****** TO DO - This solution will have a problem in case of two async ioctrls (in case of two utility adapters). ******/
+                          /* Store the semaphore for later competion */
+                          (req_data->drv->adapter).IoctlComp = &(req_data->u.req.comp);
+                          /* Store the pointer of the result status for later competion */
+                          (req_data->drv->adapter).pCompleteReply = &(req_data->u.reply);
+                       }
+
+               }
+    }
+    return res;
+}
+
+int ti1610_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+    tiioctl_req_t *req = (tiioctl_req_t *) &rq->ifr_ifru;
+    char *extra, *kbuf = NULL;
+    int res, aval_data_size = ((char *) req + sizeof(*req)) - (char *)&req->user_data_pointer;      /* = ~4 bytes */
+    /*int is_get_cmd = (req->cmd_type & IOCTL_GET);*/
+
+    print_deb("ti1610_do_ioctl(cmd=%lu(%s%s)) - user_data_pointer=0x%lx, len = %lu, aval_data_size=%d\n",
+                req->cmd,
+                (req->cmd_type & IOCTL_GET) ? "GET" : "", (req->cmd_type & IOCTL_SET) ? "SET" : "",
+                req->user_data_pointer, req->length, aval_data_size );
+
+       /* driver is already initialized */
+       if ((req->cmd == TIWLN_SET_INIT_INFO) && (((tiwlan_net_dev_t *)dev->priv)->adapter.CoreHalCtx))
+       {
+               return 0;
+       }
+
+       if( req->length > aval_data_size )
+    {
+        if( req->user_data_pointer == 0 )
+            return -EFAULT;
+
+        print_deb("ti1610_do_ioctl() - alloc %ld bytes\n", req->length );
+               kbuf = extra = os_memoryAlloc(NULL,req->length);
+#ifdef TI_MEM_ALLOC_TRACE        
+        os_printf("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, req->length, GFP_KERNEL, req->length);
+#endif/*I_MEM_ALLOC_TRACE*/
+
+        if( !extra )
+            return -ENOBUFS;
+        if( req->cmd_type & IOCTL_SET )
+        {
+            if( copy_from_user(extra, (void *) req->user_data_pointer, req->length) )
+                return -EFAULT;
+        }
+        else {
+            os_memoryZero( NULL, extra, req->length );
+        }
+    } else
+            extra = (char *) &req->user_data_pointer;
+
+    /* Driver initialization must be performed in process context.
+       The rest is handled in the context of dedicated tasklet
+    */
+    if (req->cmd == TIWLN_SET_INIT_INFO)
+    {
+       tiwlan_dev_init_t *init_info = (tiwlan_dev_init_t *)extra;
+       print_deb("TIWLN_SET_INIT_INFO: el=%d il=%d, fl=%d\n",
+              init_info?init_info->eeprom_image_length:0,
+              init_info?init_info->init_file_length:0,
+              init_info?init_info->firmware_image_length:0 );
+       res = tiwlan_init_drv((tiwlan_net_dev_t *)dev->priv, init_info);
+    }
+
+#ifdef DRIVER_PROFILING
+    else if (req->cmd == TIWLAN_PROFILING_REPORT) 
+    {
+       res = tiwlan_profile_report((tiwlan_net_dev_t *)dev->priv);
+    }
+    else if (req->cmd == TIWLAN_PROFILING_CPU_ESTIMATOR_CMD) {
+       /* get the command cpu estimator command parameter */
+       unsigned int command_param = *((unsigned int *)extra);
+       /* extract the command type which is the MSB byte of the command param*/
+       unsigned int command_type = 0xFF & (command_param >> 24);
+       /* extract the data of the command which are the 3 LSB bytes of the command param */
+       unsigned int command_data = 0xFFFFFF & command_param;
+       /* execute the command according to its type */
+       switch (command_type) 
+       {
+       case TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_START:
+           res = tiwlan_profile_cpu_usage_estimator_start((tiwlan_net_dev_t *)dev->priv,
+                                                          /* the data in this case is the estimator
+                                                          resolution in milliseconds */
+                                                          command_data * 1000);
+           break;
+       case TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_STOP:
+           res = tiwlan_profile_cpu_usage_estimator_stop((tiwlan_net_dev_t *)dev->priv);
+           break;
+       case TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_RESET:
+           res =tiwlan_profile_cpu_usage_estimator_reset((tiwlan_net_dev_t *)dev->priv);
+           break;
+       default:
+           res = 0;
+           printk("\n\n%s: cpu usage estimator unknow command: param = %x\n\n\n",
+                     __FUNCTION__, command_param);
+       }
+    }
+#endif
+
+    else
+    {
+       res = tiwlan_send_wait_reply((tiwlan_net_dev_t *)dev->priv, ti1610_ioctl_priv_proc_tl,
+                                    (unsigned long)req, (unsigned long)extra, 0, 0);
+    }
+
+    if( !res )
+    {
+            if( (req->cmd_type & IOCTL_GET) && kbuf /*req->length > aval_data_size*/ )
+            {
+                print_deb("ti1610_do_ioctl(): ...copy from %p to %p %ld bytes\n\n", extra, (void *) req->user_data_pointer, req->length );
+                print_memory_dump(extra, min(32,(int) req->length) );
+                if( copy_to_user( (void *) req->user_data_pointer, extra, req->length ) )
+                    return -EFAULT;
+            }
+    }
+    print_deb("ti1610_do_ioctl() = %d (req = %p, user_data_pointer=0x%lx, extra=%p)\n\n", res, req, req->user_data_pointer, extra );
+
+    if( kbuf ){
+               os_memoryFree(NULL,kbuf,sizeof(kbuf)); 
+#ifdef TI_MEM_ALLOC_TRACE        
+        os_printf("MTT:%s:%d ::kfree(0x%p) : %d\n", __FUNCTION__, __LINE__, kbuf, -req->length);
+#endif/*I_MEM_ALLOC_TRACE*/
+    }
+    return res;
+}
+
+
+int tiwlan_ioctl_init( struct net_device *dev )
+{
+        dev->do_ioctl       = ti1610_do_ioctl;
+
+        return 0;
+}
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/ioctl_utils.c b/sta_dk_4_0_4_32/pform/linux/src/ioctl_utils.c
new file mode 100644 (file)
index 0000000..54f4ac5
--- /dev/null
@@ -0,0 +1,164 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include "ioctl_init.h"
+#include "esta_drv.h"
+
+#include "ioctl_utils.h"
+
+#include "report.h"
+#include "osClsfr.h"
+
+#define CONFIG_MGR(dev) ((configMgr_t *) \
+    ((dev && dev->priv) ? ((tiwlan_net_dev_t *) dev->priv)->adapter.CoreHalCtx : NULL ) )
+
+
+typedef struct
+{
+    int err_code;
+    char *desc;
+}
+configMgr_error_desc_t;
+
+
+static configMgr_error_desc_t configMgr_error_desc[] =
+{
+    { OK,              "OK"    },
+    { NOK,             "NOK"   },
+    { PARAM_NOT_SUPPORTED,     "PARAM_NOT_SUPPORTED"   },
+    { PARAM_VALUE_NOT_VALID,   "PARAM_VALUE_NOT_VALID" },
+    { CONFIGURATION_NOT_VALID, "CONFIGURATION_NOT_VALID"       },
+    { NO_SITE_SELECTED_YET,            "NO_SITE_SELECTED_YET"  },
+    { RE_SCAN_NEEDED,          "RE_SCAN_NEEDED"        },
+    { EXTERNAL_SET_PARAM_DENIED,       "EXTERNAL_SET_PARAM_DENIED"     },
+    { EXTERNAL_GET_PARAM_DENIED,       "EXTERNAL_GET_PARAM_DENIED"     },
+    { PARAM_MODULE_NUMBER_INVALID,     "PARAM_MODULE_NUMBER_INVALID"   },
+    { STATION_IS_NOT_RUNNING,  "STATION_IS_NOT_RUNNING"        },
+    { CARD_IS_NOT_INSTALLED,   "CARD_IS_NOT_INSTALLED" },
+    /* Data path section */
+    /*         { RX_BSS_TYPE_ERROR                     ,*/
+    /*         { RX_BSS_ID_ERROR                               ,*/
+    /*         { TX_QUEUE_SELECTED_OK          ,*/
+    /*         { NO_TX_QUEUE_SELECTED          ,*/
+    /*         { TX_STATUS_PENDING                     ,*/
+    /*         { TX_STATUS_NO_RESOURCES                ,*/
+    /*         { TX_STATUS_FAILURE                     ,*/
+    /*         { TX_STATUS_OK                          ,*/
+
+    /* 4x section */
+    /*         { MAKE_CONCATENATION                    ,*/
+    /*         { SEND_ONE_MSDU                         ,*/
+    /*         { DO_NOT_SEND_MSDU                      ,*/
+    /*         { FOUR_X_DISABLE                                ,*/
+    /**/
+    /*          (Scanning section) */
+    /*         { NO_COUNTRY                                    ,*/
+    /**/
+    /*          (Setting power after select) */
+    /*         { TX_POWER_SHOULD_NOT_BE_SET    ,*/
+    /*         (changing service channel)       */
+    /*         { CHANNEL_CHANGED                               ,*/
+    /*         { SUPPORT_IMMEDIATE_MEASUREMENT_ONLY,*/
+    /*         { MEASUREMENT_TYPE_NOT_SUPPORT,*/
+    /*         { MEASUREMENT_CAN_NOT_EXECUTED_IN_PARALLEL,*/
+    /*         { MEASUREMENT_REQUEST_IGNORED,*/
+    /*         { CANNOT_SET_MEASUREMENT_PARAM_WHEN_ACTIVATED,*/
+    /*         { REGULATORY_DOMAIN_SET_TX_POWER_PARAM,*/
+    /*         { CANNOT_SET_CHANNEL_THAT_IS_NOT_SUPPORTED,*/
+};
+
+
+int print_err_desc(int err)
+{
+    int i;
+    for( i=0; i<SIZE_ARR(configMgr_error_desc);i++ )
+    {
+        if(configMgr_error_desc[i].err_code == err )
+        {
+            print_err("---err(%d) configMgr() = %s\n", err, configMgr_error_desc[i].desc );
+            return -err;
+        }
+    }
+    print_err("---err(%d) configMgr failed\n", err);
+    return -err;
+}
+
+void print_memory_dump(char *addr, int size )
+{
+#ifdef DEBUG_MESSAGES
+        int i;
+        char buf[4096];
+
+        if( size * 4 > sizeof(buf) ) {
+                print_err("print_memory_dump(): buffer too small\n");
+                return;
+        }
+
+        buf[0] = 0;
+        for(i=0; i<size; i++ ) {
+                if( !(i % 16) )
+                        sprintf(&buf[strlen(buf)], "%s%p: ", (i) ? "\n" : "", addr+i );
+                sprintf(&buf[strlen(buf)], "%02x ", (unsigned char)addr[i] );
+        }
+        print_info("%s\n", buf);
+#endif /* DEBUG_MESSAGES */
+}
+
+#ifdef TI_DBG
+#ifndef TIWLAN_MSM7000
+TI_STATUS debugFunction(TI_HANDLE hConfigMgr,
+                       UINT32 functionNumber,
+                       void *pParam);
+#endif                 
+#endif
+int util_hal_debug_print(struct net_device *dev, ULONG *data)
+{
+    hal_print_param_t *p = (hal_print_param_t *) data;
+    UINT32 opt_data = 0;
+    
+    if( p->optional_param )
+    {
+        if( copy_from_user(&opt_data, p->optional_param, sizeof(opt_data) ) )
+            return -EFAULT;
+    }
+
+    print_deb("HAL_DEBUG_PRINT: func_id=%d, param=%x\n", p->func_id, opt_data );
+#ifdef TI_DBG    
+    debugFunction(CONFIG_MGR(dev), p->func_id, &opt_data );
+#endif
+    return 0;
+}
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/ioctl_utils.h b/sta_dk_4_0_4_32/pform/linux/src/ioctl_utils.h
new file mode 100644 (file)
index 0000000..05dd459
--- /dev/null
@@ -0,0 +1,95 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef TI1610_IOCTL_UTILS
+#define TI1610_IOCTL_UTILS
+
+#include <linux/netdevice.h>
+#include <asm/uaccess.h>            /* copy_from_user() */
+
+#include "osTIType.h"
+
+void print_memory_dump(char *addr, int size );
+
+int util_get_statistics(struct net_device *dev, ULONG *statistic_data, ULONG *length );
+
+int util_get_param( struct net_device *dev, UINT32 param_type, ULONG *data, UINT32 max_param_len);
+int util_set_param( struct net_device *dev, UINT32 param_type, ULONG *data, UINT32 max_param_len );
+int util_get_report_param( struct net_device *dev, UINT32 param_type, ULONG *data, UINT32 max_param_len);
+int util_set_report_param( struct net_device *dev, UINT32 param_type, ULONG *data, UINT32 max_param_len);
+
+/*int util_get_bssid(struct net_device *dev, int cmd, union iwreq_data *wrqu );*/
+int util_get_network_type_in_use(struct net_device *dev, /*int cmd, */ULONG *data );
+int util_write_hw_register(struct net_device *dev, ULONG *data );
+int util_read_hw_register(struct net_device *dev, ULONG *data );
+int util_hal_debug_print(struct net_device *dev, ULONG *data);
+int util_get_sw_version(struct net_device *dev, ULONG *data );
+int util_get_network_types_supported(struct net_device *dev, ULONG *data );
+int util_get_number_of_antennas(struct net_device *dev, ULONG *data );
+int util_get_rssi(struct net_device *dev, ULONG *data );
+int util_get_bssid_list(struct net_device *dev, ULONG *data, ULONG *length );
+int util_set_privacy_filter(struct net_device *dev, ULONG *data );
+int util_get_privacy_filter(struct net_device *dev, ULONG *data, ULONG *length );
+int util_disassociate(struct net_device *dev);
+int util_set_ssid(struct net_device *dev, void *buf, ULONG length);            /* data - pointer to OS_802_11_SSID */
+int util_get_ssid(struct net_device *dev, ULONG configMgr_param, void *data, ULONG *length);
+/*int util_get_ssid(struct net_device *dev, void *data, ULONG *length);                ( data - pointer to OS_802_11_SSID) */
+
+int util_get_desired_channel(struct net_device *dev, ULONG *data);
+int util_get_authentication_mode(struct net_device *dev, ULONG *data);
+int util_get_rts_threshold(struct net_device *dev, ULONG *data);
+int util_get_short_preamble(struct net_device *dev, ULONG *data);
+
+int util_poll_ap_packets (struct net_device *dev);
+int util_config_tx_classifier(struct net_device *dev,UINT8 *inParamsBuff,UINT32 inParamsBuffLen);
+
+
+int util_get_fragmentation_threshold(struct net_device *dev, ULONG *data);
+int util_get_infrastructure_mode(struct net_device *dev, ULONG *data);
+int util_get_desired_infrastructure_mode(struct net_device *dev, ULONG *data);
+int util_get_wep_status(struct net_device *dev, ULONG *data);
+int util_get_power_mode(struct net_device *dev, ULONG *data);
+int util_get_tx_antenna(struct net_device *dev, ULONG *data);
+int util_get_rx_antenna(struct net_device *dev, ULONG *data);
+int util_get_short_preamble(struct net_device *dev, ULONG *data);
+int util_get_enable_leap(struct net_device *dev, ULONG *data);
+int util_set_wep_status(struct net_device *dev, ULONG *data);
+int util_add_wep(struct net_device *dev, void *data, ULONG length);
+int util_add_key(struct net_device *dev, void *data, ULONG length);
+int util_remove_key(struct net_device *dev, void *data, ULONG length);
+int util_remove_wep(struct net_device *dev, void *data, ULONG length);
+int util_get_association_info(struct net_device *dev, ULONG *data, ULONG *length );
+#endif
diff --git a/sta_dk_4_0_4_32/pform/linux/src/ipc_k.c b/sta_dk_4_0_4_32/pform/linux/src/ipc_k.c
new file mode 100644 (file)
index 0000000..9975c75
--- /dev/null
@@ -0,0 +1,120 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/stddef.h>
+#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
+#include <linux/netlink.h>
+
+#include "osTIType.h"
+#include "esta_drv.h"
+#include "osApi.h"
+#include "ioctl_init.h"
+#include "cli_cu_common.h"
+#include "TI_IPC_Api.h"
+
+UINT32 IPCKernelInit    (TI_HANDLE hAdapter,TI_HANDLE  hIPCEv)
+{
+    return 0;
+}
+
+UINT32 IPCKernelDeInit  (TI_HANDLE hAdapter)
+{
+    return 0;
+}
+
+
+/*******************************************************/
+INT32 IPC_EventSend(TI_HANDLE hAdapter, tiUINT8* pEvData, UINT32 EvDataSize)
+{
+        struct sk_buff *skb;
+     int res;
+     tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *) hAdapter;
+     UINT32 realSize = 0;
+     UINT32 msgSize;
+        struct nlmsghdr *nlh;
+     tiUINT8 *msg;
+
+     /* This event is targetted to the OS process Id 0 is not a valid pId for LINUX*/
+
+     if ((( IPC_EVENT_PARAMS *) pEvData) ->uProcessID == 0) 
+     {
+         (( IPC_EVENT_PARAMS *) pEvData) ->pfEventCallback(( IPC_EV_DATA *) pEvData);
+         return 0;
+     }
+
+     /* set the payload size */
+        msgSize = (( IPC_EV_DATA *) pEvData) ->uBufferSize + offsetof(IPC_EV_DATA,uBuffer);
+     
+        /* add the netlink header size */
+        realSize = NLMSG_SPACE(msgSize);
+
+        /* allocate the complete message */
+        skb = dev_alloc_skb(realSize);
+        if (!skb) {
+               printk(KERN_ERR "Failed to allocate new skb with size=%u.\n",realSize);
+               return -1;
+        }
+
+        /* set the netlink header params */
+        nlh = NLMSG_PUT(skb, 0, 0, NLMSG_DONE, realSize - sizeof(*nlh));
+        
+        /* get the payload pointer */
+        msg = (char *)NLMSG_DATA(nlh);
+        
+        /* copy the data to the payload */ 
+     memcpy(msg,pEvData,msgSize);
+
+        NETLINK_CB(skb).pid = 0;   /* from kernel */
+     NETLINK_CB(skb).dst_group = RTNLGRP_LINK;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+     NETLINK_CB(skb).dst_pid = (( IPC_EVENT_PARAMS *) pEvData) ->uProcessID; /* Dm: */
+#endif
+
+        /* send the message*/
+        res = netlink_unicast(drv->wl_sock, skb, (( IPC_EVENT_PARAMS *) pEvData) ->uProcessID, MSG_DONTWAIT);
+
+     /* Sanity checks. As far as we're concerned this error is unrecovarable.*/
+     if (res >= 0)
+     {
+               return 0;
+     }
+
+nlmsg_failure:
+    ti_dprintf(TIWLAN_LOG_INFO,"IPC kernel: did not send the netlink message\n");
+       return -1;
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/src/ipc_k.h b/sta_dk_4_0_4_32/pform/linux/src/ipc_k.h
new file mode 100644 (file)
index 0000000..e0b442f
--- /dev/null
@@ -0,0 +1,46 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef _IPC_K
+#define _IPC_K
+
+#include "osTIType.h"
+
+
+/*INT32 IPC_EventSend(struct net_device *dev, sk_buff *skb, UINT32 pid);*/
+#endif
+
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/mmc_tnetw1150_api.c b/sta_dk_4_0_4_32/pform/linux/src/mmc_tnetw1150_api.c
new file mode 100755 (executable)
index 0000000..4efee19
--- /dev/null
@@ -0,0 +1,545 @@
+/* mmc_tnetw1150_api.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Copyright © Texas Instruments Incorporated (Oct 2005)
+ * THIS CODE/PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDED BUT NOT LIMITED TO , THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * This program has been modified from its original operation by Texas
+ * Instruments Incorporated. These changes are covered under version 2
+ * of the GNU General Public License, dated June 1991.
+ *
+ * Copyright © Google Inc (Feb 2008)
+ */
+/*-------------------------------------------------------------------*/
+#ifdef TIWLAN_MSM7000
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include "mmc_tnetw1150_api.h"
+#include <linux/mmc/core.h>
+
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_func.h>
+
+#define SDIO_INVALID_PERIPHERAL_ADDRESS             0x1FFFF
+
+/* CCCR                                                 0x000000 - 0x0000ff          */
+/* Function Basic Register (Function 1)                 0x000100 - 0x0001ff          */
+       /* 0x101          - Function 1 Extended standard I/O device type code        */
+       /* 0x102          - RFU[4-0] EnableHighPower Supports High-Power[1-0] SHP[0] */
+       /* 0x103 - 0x108  - RFU                                                      */
+       /* 0x109 - 0x10b  - Pointer to Function 1 Card Information Structure         */
+       /* 0x10c - 0x10e  - Pointer to Function 1 Code Storage Area                  */
+       /* 0x10f          - Data access window to Function 1 Code Storage Area       */
+       /* 0x110 - 0x111  - I/O block size for Function 1                            */
+       /* 0x112 - 0x1ff  - RFU                                                      */
+/* Function Basic Register (Function 2)                 0x000200 - 0x0002ff          */
+/* Function Basic Register (Function 3)                 0x000300 - 0x0003ff          */
+/* Function Basic Register (Function 4)                 0x000400 - 0x0004ff          */
+/* Function Basic Register (Function 5)                 0x000500 - 0x0005ff          */
+/* Function Basic Register (Function 6)                 0x000600 - 0x0006ff          */
+/* Function Basic Register (Function 7)                 0x000700 - 0x0007ff          */
+/* RFU                                                 0x000800 - 0x000fff          */
+/* CIS common and per-function area                     0x001000 - 0x017fff          */
+/* RFU                                                  0x018000 - 0x01ffff          */
+#define SDIO_FUNC1_OFFSET    0x1FFC0
+
+typedef struct
+{
+       Peripheral_Address mem_start_addr;
+       Peripheral_Address mem_part_size;
+       Peripheral_Address mem_end_addr;
+       Peripheral_Address reg_start_addr;
+       Peripheral_Address reg_part_size;
+       Peripheral_Address reg_end_addr;
+} SDIO_TNETW_partitions;
+static SDIO_TNETW_partitions TNETW_table;
+
+static SDIO_TNETWConfigParams TNETW_params;
+
+#ifdef CONFIG_MMC_TNET_INFO
+typedef struct {
+       u8  scr_space[SDIO_FUNC1_OFFSET];       /* 0x000000 - 0x01ffbf;
+                                                  131072B(128kB)-64B=131008B(0x01ffc0) */
+       u32 amap_size1;                         /* 0x01ffc0 */
+       u32 amap_offset1;                       /* 0x01ffc4 */
+       u32 amap_size2;                         /* 0x01ffc8 */
+       u32 amap_offset2;                       /* 0x01ffcc */
+       u32 amap_size3;                         /* 0x01ffd0 */
+       u32 amap_offset3;                       /* 0x01ffd4 */
+       u32 amap_offset4;                       /* 0x01ffd8 */
+       u32 cis_offset;                         /* 0x01ffdc - Card Information Structure */
+       u32 csa_offset;                         /* 0x01ffe0 - Code Storage Area */
+       u8  filler[16];                         /* 0x01ffe4 - 0x01fff3 */
+       u32 wr_err_len;                         /* 0x01fff4 */
+       u32 wr_err_addr;                        /* 0x01fff8 */
+       u32 status;                             /* 0x01fffc */
+} SDIO_FUNC1AddressMap;
+SDIO_FUNC1AddressMap mapping;
+
+int sdio_tnetw1150_dump(int count)
+{
+       unsigned long from;
+       unsigned long br_offset;
+       unsigned long offset=0;
+       unsigned long p1_offset=0;
+       unsigned long p2_offset=0;
+       struct mmc_request request;
+       int lines;
+       int i=0;
+       int second_part=0;
+
+       printk("%s:\n", __FUNCTION__);
+#define TNETW1150_OFFSET 1024
+       from=TNETW1150_OFFSET*count;
+       if((from+TNETW1150_OFFSET)>(SDIO_FUNC1_OFFSET+64))
+               return -1;
+       br_offset=TNETW1150_OFFSET*count;
+       if(br_offset>=TNETW_params.map_reg[0].reg_size) {
+               second_part=1;
+               p2_offset = SDIO_DRIVER_REG_PARTITION_START;
+               offset = TNETW_params.map_reg[1].scr_offset - TNETW_params.map_reg[0].reg_size;
+       }
+       else {
+               p1_offset += SDIO_DOWNLOAD_PARTITION_START;
+               offset = TNETW_params.map_reg[0].scr_offset;
+       }
+
+       request.cmd=SD_IO_RW_DIRECT;
+       request.buffer_len=1;
+       request.nob=0;
+       request.block_len=0;
+       request.buffer=&mapping.scr_space[from];
+    printk(" TNETW1150 try br_offset:0x%08lx offset:0x%08lx):\n", br_offset, offset);
+       do {
+               request.arg = SDIO_CMD52_READ(0,FUNCTION_SELECT_1,0,br_offset);
+               if(__submit_control_request(omap_mmc_dev_get_handle(), &request)!=SDIO_SUCCESS)
+                       return SDIO_FAILURE;
+               udelay(1);
+               *request.buffer = (char)omap_readw(OMAP_MMC_RSP6);
+               i++;
+               request.buffer++;
+               br_offset++;
+       } while(i<TNETW1150_OFFSET);
+
+    printk(" TNETW1150 SCR Address Space (start:0x%08lx  end:0x%08lx part:%d offset:0x%08lx):\n", from, from+TNETW1150_OFFSET-1, second_part+1, (!second_part)?p1_offset:p2_offset);
+
+       lines=TNETW1150_OFFSET/16;
+       for(i=0; i<lines;i++, from+=16)
+        printk("SDIO:0x%04lx(SCR:0x%04lx): %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", from, (!second_part)?(from+p1_offset):(from-p2_offset+SDIO_REG_PARTITION_START), mapping.scr_space[from], mapping.scr_space[from+1], mapping.scr_space[from+2], mapping.scr_space[from+3], mapping.scr_space[from+4], mapping.scr_space[from+5], mapping.scr_space[from+6], mapping.scr_space[from+7], mapping.scr_space[from+8], mapping.scr_space[from+9], mapping.scr_space[from+10], mapping.scr_space[from+11], mapping.scr_space[from+12], mapping.scr_space[from+13], mapping.scr_space[from+14], mapping.scr_space[from+15]);
+
+    return 0;
+}
+EXPORT_SYMBOL(sdio_tnetw1150_dump);
+
+int sdio_tnetw1150_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+    int len=0;
+       int br_offset = SDIO_FUNC1_OFFSET;
+       struct mmc_request request;
+       u8 buf[64];
+       u8 buf3[3];
+       int bytes_to_read=64;
+       int i;
+#define CCCR_SIZE 17
+       u8 buf_ccr[CCCR_SIZE];
+       u8 buf_ccr_offset[CCCR_SIZE] = {
+               CCCR_SDIO_REVISION, CCCR_SD_SPECIFICATION_REVISION, CCCR_IO_ENABLE,
+               CCCR_IO_READY, CCCR_INT_ENABLE, CCCR_INT_PENDING,
+               CCCR_IO_ABORT, CCCR_BUS_INTERFACE_CONTOROL, CCCR_CARD_CAPABILITY,
+               CCCR_COMMON_CIS_POINTER, CCCR_COMMON_CIS_POINTER+1, CCCR_COMMON_CIS_POINTER+2,
+               CCCR_BUS_SUSPEND, CCCR_FUNCTION_SELECT, CCCR_EXEC_FLAGS,
+               CCCR_READY_FLAGS, CCCR_FNO_BLOCK_SIZE,
+       };
+#define FBR_SIZE 9
+       u8 buf_fbr[FBR_SIZE];
+       u16 buf_fbr_offset[FBR_SIZE] = {
+               FBR_PTR_F1_CIS, FBR_PTR_F1_CIS+1, FBR_PTR_F1_CIS+2,
+               FBR_PTR_F1_CSA, FBR_PTR_F1_CSA+1, FBR_PTR_F1_CSA+2,
+               FBR_WIN_F1_CSA, FBR_F1_IO_BLK_SIZE, FBR_F1_IO_BLK_SIZE+1,
+       };
+
+       request.cmd=SD_IO_RW_DIRECT;
+       request.buffer_len=1;
+       request.nob=0;
+       request.block_len=0;
+       request.buffer=&buf[0];
+       for (i=0; i<bytes_to_read;i++,request.buffer++,br_offset++) {
+               request.arg = SDIO_CMD52_READ(0,FUNCTION_SELECT_1,0,br_offset);
+               if(__submit_control_request(omap_mmc_dev_get_handle(), &request)!=SDIO_SUCCESS)
+                       return SDIO_FAILURE;
+               *request.buffer = (char)omap_readw(OMAP_MMC_RSP6);
+       }
+       memcpy(&mapping.amap_size1, &buf, 64);
+
+    count -= 80; /* some reserve */
+    len += (len<count)?sprintf(page+len, " TNETW1150 partitions:\n"):0;
+    len += (len<count)?sprintf(page+len, " Memory:      "):0;
+       len += (len<count)?sprintf(page+len, " start:0x%08lx  end:0x%08lx  size:0x%08lx bytes\n", TNETW_table.mem_start_addr, TNETW_table.mem_end_addr, TNETW_table.mem_part_size):0;
+    len += (len<count)?sprintf(page+len, " Registers:   "):0;
+       len += (len<count)?sprintf(page+len, " start:0x%08lx  end:0x%08lx  size:0x%08lx bytes\n", TNETW_table.reg_start_addr, TNETW_table.reg_end_addr, TNETW_table.reg_part_size):0;
+
+    len += (len<count)?sprintf(page+len, " SDIO Function 1 Address Map:\n"):0;
+       len += (len<count)?sprintf(page+len, " amap_size1:0x%08x  amap_offset1:0x%08x\n", mapping.amap_size1, mapping.amap_offset1):0;
+       len += (len<count)?sprintf(page+len, " amap_size2:0x%08x  amap_offset2:0x%08x\n", mapping.amap_size2, mapping.amap_offset2):0;
+       len += (len<count)?sprintf(page+len, " amap_size3:0x%08x  amap_offset3:0x%08x\n", mapping.amap_size3, mapping.amap_offset3):0;
+       len += (len<count)?sprintf(page+len, "                        amap_offset4:0x%08x\n", mapping.amap_offset4):0;
+       len += (len<count)?sprintf(page+len, " cis_offset:0x%08x  csa_offset  :0x%08x\n", mapping.cis_offset, mapping.csa_offset):0;
+       len += (len<count)?sprintf(page+len, " wr_err_len:0x%08x  wr_err_addr :0x%08x\n", mapping.wr_err_len, mapping.wr_err_addr):0;
+       len += (len<count)?sprintf(page+len, " status    :0x%08x\n", mapping.status):0;
+
+       request.cmd=SD_IO_RW_DIRECT;
+       request.buffer_len=1;
+       request.nob=0;
+       request.block_len=0;
+       request.buffer=&buf_ccr[0];
+       for (i=0; i<CCCR_SIZE;i++,request.buffer++) {
+               request.arg = SDIO_CMD52_READ(0,FUNCTION_SELECT_0,0,buf_ccr_offset[i]);
+               if(__submit_control_request(omap_mmc_dev_get_handle(), &request)!=SDIO_SUCCESS)
+                       return SDIO_FAILURE;
+               *request.buffer = (char)omap_readw(OMAP_MMC_RSP6);
+       }
+
+    len += (len<count)?sprintf(page+len, "\n Card Common Control Registers:\n"):0;
+       len += (len<count)?sprintf(page+len, " \
+ REVISION             :0x%02x  SD_SPEC_REVISION       :0x%02x   IO_ENABLE            :0x%02x\n \
+ IO_READY             :0x%02x  INT_ENABLE             :0x%02x   INT_PENDING          :0x%02x\n \
+ IO_ABORT             :0x%02x  BUS_INTERFACE_CONTOROL :0x%02x   CARD_CAPABILITY      :0x%02x\n \
+ COMMON_CIS_POINTER[2]:0x%02x  COMMON_CIS_POINTER[1]  :0x%02x   COMMON_CIS_POINTER[0]:0x%02x\n \
+ BUS_SUSPEND          :0x%02x  FUNCTION_SELECT        :0x%02x   EXEC_FLAGS           :0x%02x\n \
+ READY_FLAGS          :0x%02x  FNO_BLOCK_SIZE         :0x%02x\n" , buf_ccr[0], buf_ccr[1], buf_ccr[2], buf_ccr[3], buf_ccr[4], buf_ccr[5], buf_ccr[6], buf_ccr[7], buf_ccr[8], buf_ccr[11], buf_ccr[10], buf_ccr[9], buf_ccr[12], buf_ccr[13], buf_ccr[14], buf_ccr[15], buf_ccr[16]):0;
+
+       request.cmd=SD_IO_RW_DIRECT;
+       request.buffer_len=1;
+       request.nob=0;
+       request.block_len=0;
+
+       request.buffer=&buf3[0];
+       for (i=0; i<3;i++,request.buffer++) {
+               request.arg = SDIO_CMD52_READ(0,FUNCTION_SELECT_1,0,FBR_PTR_F1_IO_DEV);
+               if(__submit_control_request(omap_mmc_dev_get_handle(), &request)!=SDIO_SUCCESS)
+                       return SDIO_FAILURE;
+               *request.buffer = (char)omap_readw(OMAP_MMC_RSP6);
+       }
+
+       request.buffer=&buf_fbr[0];
+       for (i=0; i<FBR_SIZE;i++,request.buffer++) {
+               request.arg = SDIO_CMD52_READ(0,FUNCTION_SELECT_1,0,buf_fbr_offset[i]);
+               if(__submit_control_request(omap_mmc_dev_get_handle(), &request)!=SDIO_SUCCESS)
+                       return SDIO_FAILURE;
+               *request.buffer = (char)omap_readw(OMAP_MMC_RSP6);
+       }
+
+    len += (len<count)?sprintf(page+len, "\n Function Basic Registers(Func 1):\n"):0;
+       len += (len<count)?sprintf(page+len, " \
+ Func 1 CSA enable and CSA support              :     0x%02x 0x%02x\n \
+ Func 1 Ext stand. I/O device i/f and type code :     0x%02x 0x%02x\n \
+ EHP|SHP[1]|SHP[0]                              :          0x%02x\n \
+ Pointer to Func 1 Card Information Structure   :0x%02x 0x%02x 0x%02x\n \
+ Pointer to Func 1 Code Storage Area            :0x%02x 0x%02x 0x%02x\n \
+ Data access window to Func 1 Code Storage Area :          0x%02x\n \
+ I/O block size for Func 1                      :     0x%02x 0x%02x\n", ((buf3[0]&0x80)>>7), ((buf3[0]&0x40)>>6), (buf3[1]&0x0f), buf3[1], (buf3[2]&0x07), buf_fbr[2], buf_fbr[1], buf_fbr[0], buf_fbr[5], buf_fbr[4], buf_fbr[3], buf_fbr[6], buf_fbr[8], buf_fbr[7]):0;
+
+    *eof = 1;
+    return len;
+}
+#endif /*CONFIG_MMC_TNET_STATISTICS*/
+
+
+/*
+  Initialization of TNETW memory configuration.
+*/
+extern int debug_level;
+SDIO_Status SDIO_TNETWInit(SDIO_TNETWConfigParams *params)
+{
+    /* debug_level=3;    */   
+       /* printk("%s\n", __FUNCTION__); */
+
+       memset(&TNETW_params, 0, sizeof(SDIO_TNETWConfigParams));
+
+    if(!params) {
+               /* printk("%s set to default\n", __FUNCTION__); */
+               /* set to default value in case params is not presented */
+               TNETW_params.num_of_parts = 2;
+               /* First time initialization */
+               TNETW_params.map_reg[0].reg_size = SDIO_DOWNLOAD_PARTITION_SIZE;
+               TNETW_params.map_reg[0].scr_offset = SDIO_DOWNLOAD_PARTITION_START;
+               /* After firmware has been downloaded, data memory region
+                  has to be re-initialized as following:
+               TNETW_params.map_reg[0].reg_size = SDIO_MEM_PARTITION_START;
+               TNETW_params.map_reg[0].scr_offset = SDIO_MEM_PARTITION_SIZE;
+               */
+               TNETW_params.map_reg[1].reg_size = SDIO_REG_PARTITION_SIZE;
+               TNETW_params.map_reg[1].scr_offset = SDIO_REG_PARTITION_START;
+       }
+       else {
+               /* printk("%s: params->num_of_parts=%d\n", __FUNCTION__, params->num_of_parts); */
+               /* validate input parameters */
+               switch(params->num_of_parts) {
+               case 1:
+                       if(params->map_reg[0].reg_size > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               case 2:
+                       if((params->map_reg[0].reg_size + params->map_reg[1].reg_size) > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               case 3:
+                       if((params->map_reg[0].reg_size + params->map_reg[1].reg_size + params->map_reg[2].reg_size) > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               case 4:
+                       if((params->map_reg[0].reg_size + params->map_reg[1].reg_size + params->map_reg[2].reg_size + params->map_reg[3].reg_size) > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               default:
+                       return SDIO_FAILURE;
+               }
+               memcpy(&TNETW_params, params, sizeof(SDIO_TNETWConfigParams));
+       }
+
+#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_MMC_TNET_INFO
+       create_proc_read_entry("sdio_tnetw1150", 0, NULL, sdio_tnetw1150_read_proc, NULL);
+#endif
+#endif
+
+       /* printk("%s completed\n", __FUNCTION__); */
+
+       return SDIO_SUCCESS;
+}
+
+SDIO_Status SDIO_TNETWReset(SDIO_TNETWConfigParams *params)
+{
+       /* printk("%s\n", __FUNCTION__); */
+
+       memset(&TNETW_params, 0, sizeof(SDIO_TNETWConfigParams));
+
+       if(!params) {
+               /* printk("%s set to default\n", __FUNCTION__); */
+               /* set to default value in case params is not presented */
+               TNETW_params.num_of_parts = 2;
+
+               /* After firmware has been downloaded, data memory region
+                  has to be re-initialized as following */
+               TNETW_params.map_reg[0].reg_size = SDIO_MEM_PARTITION_START;
+               TNETW_params.map_reg[0].scr_offset = SDIO_MEM_PARTITION_SIZE;
+               TNETW_params.map_reg[1].reg_size = SDIO_REG_PARTITION_SIZE;
+               TNETW_params.map_reg[1].scr_offset = SDIO_REG_PARTITION_START;
+       }
+       else {
+               /* printk("%s: params->num_of_parts=%d\n", __FUNCTION__, params->num_of_parts); */
+               /* validate input parameters */
+               switch(params->num_of_parts) {
+               case 1:
+                       if(params->map_reg[0].reg_size > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               case 2:
+                       if((params->map_reg[0].reg_size + params->map_reg[1].reg_size) > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               case 3:
+                       if((params->map_reg[0].reg_size + params->map_reg[1].reg_size + params->map_reg[2].reg_size) > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               case 4:
+                       if((params->map_reg[0].reg_size + params->map_reg[1].reg_size + params->map_reg[2].reg_size + params->map_reg[3].reg_size) > AMAP_ONE_REGION)
+                               return SDIO_FAILURE;
+                       break;
+               default:
+                       return SDIO_FAILURE;
+               }
+               memcpy(&TNETW_params, params, sizeof(SDIO_TNETWConfigParams));
+       }
+
+       /* printk("%s completed\n", __FUNCTION__); */
+
+       return SDIO_SUCCESS;
+}
+
+
+static SDIO_Status config_partition(SDIO_Handle sdioHandle, int partition_no, Peripheral_Address start_addr, SDIO_BufferLength part_size)
+{
+       struct sdio_func *func = (struct sdio_func *) sdioHandle;
+       u8 data;
+       int br_offset = SDIO_FUNC1_OFFSET + (partition_no-1)*8;
+       int i, rc;
+
+       /* printk("%s: partition_no=%d\n", __FUNCTION__, partition_no); */
+
+       /* Set size - write out 4 bytes by 4 requests */
+       if (partition_no < AMAP_MAX_REGIONS)
+       {
+               for(i=0;i<4;i++,br_offset++) {
+                       data = (part_size>>(8*i))&0xFF;
+
+                       /* put R/W Flag (1 for write); Function Number(1), RAW Flag(0),
+                          Register Address - the address of the byte of data inside
+                          of the selected function that will be written
+                          (br_offset for func1),
+                          Write Data - for a direct write command, this is the byte=data,
+                          that will be written to the selected address=br_offset).
+                       */
+                       sdio_writeb(func, data, br_offset, &rc);
+                       if (rc < 0) {
+                               printk(KERN_ERR "%s: Error writing size\n", __FUNCTION__);
+                               return SDIO_FAILURE;
+                       }
+            /* printk("%s: offset byte=%d data=0x%08x at=0x%08x\n", __FUNCTION__, i, data, br_offset); */
+               }
+
+        /* Set offset - write out 4 bytes by 4 requests */
+        for(i=0;i<4;i++,br_offset++) {
+            data = (start_addr>>(8*i))&0xFF;
+            sdio_writeb(func, data, br_offset, &rc);
+            if (rc < 0) {
+                printk(KERN_ERR "%s: Error writing offset\n", __FUNCTION__);
+                return SDIO_FAILURE;
+            }
+            /* printk("%s: offset byte=%d data=0x%08x at=0x%08x\n", __FUNCTION__, i, data, br_offset); */
+        }
+    }
+#if 0
+    if( partition_no == 2 ) {
+        unsigned long id1;
+        for(i=0,br_offset=0x1ce34;i<4;i++,br_offset++) {
+            data = sdio_readb(func, br_offset, &rc);
+            if (rc < 0) {
+                printk(KERN_ERR "%s: Error reading offset\n", __FUNCTION__);
+                return SDIO_FAILURE;
+            }
+            printk("%s: offset byte=%d data=0x%08x at=0x%08x\n", __FUNCTION__, i, data, br_offset);
+        }
+        rc = sdio_memcpy_fromio(func, &id1, 0x1ce34, 4); /* Dm: Important - DO NOT REMOVE !!! */
+        if (rc < 0) {
+            printk(KERN_ERR "%s: Error reading offset\n", __FUNCTION__);
+            return SDIO_FAILURE;
+        }
+        printk("%s: data=0x%08x at=0x%08x\n", __FUNCTION__, id1, br_offset);
+    }
+#endif
+    return SDIO_SUCCESS;
+}
+
+/*
+  This function configures the slave SDIO device for the required
+  operation mode.
+*/
+SDIO_Status SDIO_TNETWConfig(SDIO_Handle sdioHandle, Peripheral_ConfigParams **peripheral_info)
+{
+       SDIO_Status rc;
+
+       /* printk("%s\n", __FUNCTION__); */
+
+       TNETW_table.mem_start_addr = TNETW_params.map_reg[0].scr_offset;
+       TNETW_table.mem_part_size = TNETW_params.map_reg[0].reg_size;
+       TNETW_table.mem_end_addr = TNETW_table.mem_start_addr + TNETW_table.mem_part_size - 1;
+
+       TNETW_table.reg_start_addr = TNETW_params.map_reg[1].scr_offset;
+       TNETW_table.reg_part_size = TNETW_params.map_reg[1].reg_size;
+       TNETW_table.reg_end_addr = TNETW_table.reg_start_addr + TNETW_table.reg_part_size - 1;
+#if 0
+       printk("%s: memory area: start_addr=0x%08lx end_addr=0x%08lx part_size=0x%08lx\n", __FUNCTION__, TNETW_table.mem_start_addr, TNETW_table.mem_end_addr, TNETW_table.mem_part_size);
+       printk("%s: register area: start_addr=0x%08lx end_addr=0x%08lx part_size=0x%08lx\n", __FUNCTION__, TNETW_table.reg_start_addr, TNETW_table.reg_end_addr, TNETW_table.reg_part_size);
+#endif
+       /* Configure 17-bits address range in peripheral */
+       rc=config_partition(sdioHandle, 1, TNETW_table.mem_start_addr, TNETW_table.mem_part_size);
+       rc = (rc==SDIO_SUCCESS)?config_partition(sdioHandle, 2, TNETW_table.reg_start_addr, TNETW_table.reg_part_size):rc;
+
+       if(*peripheral_info)
+               *peripheral_info = (void *)&TNETW_table;
+
+    /* printk("%s: TNETW1150 partitions:\n", __FUNCTION__);
+       printk("Memory   : start:0x%08lx  end:0x%08lx  size:0x%08lx bytes\n", TNETW_table.mem_start_addr, TNETW_table.mem_end_addr, TNETW_table.mem_part_size);
+       printk("Registers: start:0x%08lx  end:0x%08lx  size:0x%08lx bytes\n", TNETW_table.reg_start_addr, TNETW_table.reg_end_addr, TNETW_table.reg_part_size);
+    */
+
+       return rc;
+}
+
+/*
+  This function performs convertion of peripheral adddress into 17 bits
+  SDIO address. If found that the memory partition configuration must be
+  changed, the memory is re-mapped in accordance to requested address.
+*/
+SDIO_Address SDIO_ConvertTNETWToSDIOMaster(Peripheral_Address in_tnetw_address, SDIO_BufferLength packet_size)
+{
+       SDIO_Address out_sdio_address;
+
+#ifdef CONFIG_SDIO_ADDRESS_MAPPING_BY_APPLICATION
+       out_sdio_address = in_tnetw_address;
+#else
+       Peripheral_Address tnetw_last_address = in_tnetw_address + packet_size - 1;
+
+       /* printk("%s:\n", __FUNCTION__); */
+
+       if ((in_tnetw_address >= TNETW_table.mem_start_addr) && (tnetw_last_address <= TNETW_table.mem_end_addr)) {
+               /* printk("%s part1 from=0x%08lx to 0x%08lx\n", __FUNCTION__, in_tnetw_address, tnetw_last_address); */
+               /* address in the 1-st partition range (data memory space) */
+               out_sdio_address = in_tnetw_address - TNETW_table.mem_start_addr;
+       }
+       else if ((in_tnetw_address >= TNETW_table.reg_start_addr) && (tnetw_last_address <= TNETW_table.reg_end_addr)) {
+               /* printk("%s part2 from=0x%08lx to 0x%08lx\n", __FUNCTION__, in_tnetw_address, tnetw_last_address); */
+               /* address in the 2-nd partition range (register memory space) */
+               out_sdio_address = in_tnetw_address - TNETW_table.reg_start_addr + TNETW_table.mem_part_size;
+       }
+       else {
+               /* printk("%s peripheral addresses from=0x%08lx to 0x%08lx is out of range\n", __FUNCTION__, in_tnetw_address, tnetw_last_address); */
+               /* invalid address */
+               return SDIO_INVALID_PERIPHERAL_ADDRESS;
+       }
+       /* printk("%s: in_tnetw_addr=0x%08lx out_sdio_addr=0x%08lx\n", __FUNCTION__, in_tnetw_address, out_sdio_address); */
+
+#endif /* CONFIG_SDIO_ADDRESS_MAPPING_BY_APPLICATION */
+
+       return out_sdio_address;
+}
+
+SDIO_Status SDIO_TNETW_Set_ELP_Reg(SDIO_Handle sdioHandle, Peripheral_Address start_addr, unsigned int data)
+{
+       struct sdio_func *func = (struct sdio_func *) sdioHandle;
+       u8 data1 = 0;
+       int br_offset = start_addr;
+       int i, rc;
+
+       /* Set size - write out 4 bytes by 4 requests */
+       for(i=0;i<1;i++,br_offset++) {
+               data1 = (data>>(8*i))&0xFF;
+
+               /* put R/W Flag (1 for write); Function Number(1), RAW Flag(0),
+                          Register Address - the address of the byte of data inside
+                          of the selected function that will be written
+                          (br_offset for func1),
+                          Write Data - for a direct write command, this is the byte=data,
+                          that will be written to the selected address=br_offset).
+               */
+               sdio_writeb(func, data1, br_offset, &rc);
+               if (rc < 0) {
+                       printk(KERN_ERR "%s: Error writing size\n", __FUNCTION__);
+                       return SDIO_FAILURE;
+               }
+       }
+       return SDIO_SUCCESS;
+}
+
+SDIO_Status SDIO_TNETW_Get_ELP_Reg(SDIO_Handle sdioHandle, Peripheral_Address start_addr, unsigned int *data)
+{
+       struct sdio_func *func = (struct sdio_func *) sdioHandle;
+       int br_offset = start_addr;
+       int rc;
+
+       *(u8*)data = sdio_readb_ext(func, br_offset, &rc, 0x01);
+       if (rc) {
+               printk(KERN_ERR "%s: Error reading sdio register (%d)\n", __FUNCTION__, rc);
+               return SDIO_FAILURE;
+       }
+       return SDIO_SUCCESS;
+}
+
+#endif /* TIWLAN_MSM7000 */
diff --git a/sta_dk_4_0_4_32/pform/linux/src/osRgstry_parser.c b/sta_dk_4_0_4_32/pform/linux/src/osRgstry_parser.c
new file mode 100644 (file)
index 0000000..88c99d1
--- /dev/null
@@ -0,0 +1,232 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+#include "osrgstry_parser.h"
+
+extern VOID regReadLastDbgState(PTIWLN_ADAPTER_T pAdapter);
+
+static char *init_file     = NULL;
+static int init_file_length= 0;
+static PNDIS_CONFIGURATION_PARAMETER pNdisParm;
+
+extern  int osInitTable_IniFile(tiwlan_net_dev_t *drv, initTable_t *InitTable, char *file_buf, int file_length)
+{
+   NDIS_CONFIGURATION_PARAMETER parm;
+
+   init_file         = file_buf;
+   init_file_length  = file_length;
+   pNdisParm = &parm;
+
+   regFillInitTable( &drv->adapter, InitTable );
+#ifdef TI_DBG
+   regReadLastDbgState(&drv->adapter);
+#endif
+   
+   return 0;
+}
+
+unsigned long TiDebugFlag;
+
+/* void PRINT( char * type, char *format, ... )*/
+/* {*/
+/*     return ;*/
+/* }*/
+
+NDIS_STATUS NdisUnicodeStringToAnsiString( IN OUT PANSI_STRING  DestinationString,
+    IN PUNICODE_STRING  SourceString )
+{
+    if( DestinationString->MaximumLength < SourceString->Length )
+        return NDIS_STATUS_BUFFER_TOO_SHORT;
+
+    DestinationString->Length = SourceString->Length;
+    os_memoryCopy( NULL, DestinationString->Buffer, SourceString->Buffer, SourceString->Length );
+    return NDIS_STATUS_SUCCESS;
+
+}
+
+#ifndef tolower
+#define tolower(c)  ( (c) | 0x20)
+#endif
+
+    /* Search sub-string in memory buffer */
+    /* From '#' to EOL ---- remarks */
+char *mem_str(char *buf, char *str, char *end_buf)
+{
+    int i;
+
+    for( ; buf <= end_buf; buf++ )
+    {
+        if( *buf == '#' )
+        {
+            buf = strchr(buf+1, '\n' );
+            if( !buf )
+                return NULL;
+
+        }
+        for( i=0; &buf[i] <= end_buf && buf[i] && str[i] && (tolower(buf[i]) == tolower(str[i])); i++ ) ;
+
+        if ((!str[i]) && (!((tolower(*(buf-1))>='a') && (tolower(*(buf-1))<='z'))))
+            return buf;
+    }
+    return NULL;
+}
+
+char * ltrim(char *s )
+{
+    while( *s == ' ' || *s == '\t' ) s++;
+    return s;
+}
+
+VOID NdisReadConfiguration( OUT PNDIS_STATUS  status, OUT PNDIS_CONFIGURATION_PARAMETER  *param_value,
+    IN NDIS_HANDLE  config_handle, IN PNDIS_STRING  keyword, IN NDIS_PARAMETER_TYPE  param_type )
+{
+#ifdef USE_INIT_FILE
+    char *name = keyword->Buffer;
+    char *s, *buf = init_file, *end_buf = init_file + init_file_length;
+    static int count = 0;
+
+    *status = NDIS_STATUS_FAILURE;
+    *param_value = pNdisParm;
+
+    if( !count )
+    {
+        print_deb("\n++++++++++++\n%s+++++++++++\n", init_file);
+        count++;
+    }
+
+    if( !name || !*name || !init_file || !init_file_length )
+        return ;
+
+    memset(pNdisParm, 0, sizeof(NDIS_CONFIGURATION_PARAMETER));
+
+    while(buf < end_buf)
+    {
+        buf = ltrim(buf);
+        if( !(s = mem_str(buf, name, end_buf)) )
+            break;
+
+        buf = ltrim(s + strlen(name));
+        if( *buf == '=' )
+            buf++;
+        else {
+            /*print_err("\n...init_config err: delim not found (=): ** %s **\n", buf );*/
+            buf = s + 1; /*strlen(name);*/
+            continue;
+        }
+        buf = ltrim(buf);
+        if( param_type == NdisParameterString )
+        {
+            char *remark = NULL;
+
+            s = strchr(buf, '\n');
+            if( !s )
+                s = buf+strlen(buf);
+            
+            remark = memchr(buf, '#', s - buf);        /* skip remarks */
+            if( remark )
+            {
+                do {        /* remove whitespace  */
+                    remark--;
+                } while( *remark == ' ' || *remark == '\t' );    
+                
+                pNdisParm->ParameterData.StringData.Length = remark - buf + 1;
+            }
+            else
+                pNdisParm->ParameterData.StringData.Length = s - buf;
+                   
+            pNdisParm->ParameterData.StringData.Buffer = (PUCHAR)&pNdisParm->StringBuffer[0];
+            pNdisParm->ParameterData.StringData.MaximumLength = NDIS_MAX_STRING_LEN;
+            if( !pNdisParm->ParameterData.StringData.Length > NDIS_MAX_STRING_LEN )
+            {
+                *status = NDIS_STATUS_BUFFER_TOO_SHORT;
+                return;
+            }
+            memcpy(pNdisParm->ParameterData.StringData.Buffer, buf, pNdisParm->ParameterData.StringData.Length);
+            print_info("NdisReadConfiguration(): %s = (%d)'%s'\n", name, pNdisParm->ParameterData.StringData.Length, pNdisParm->ParameterData.StringData.Buffer);
+        }
+        else if( param_type == NdisParameterInteger )
+        {
+           char *end_p;
+            pNdisParm->ParameterData.IntegerData = simple_strtol(buf, &end_p, 0);
+            if (end_p && *end_p && *end_p!=' ' && *end_p!='\n'
+               && *end_p!='\r' && *end_p!='\t')
+            {
+                print_err("\n...init_config: invalid int value for <%s> : %s\n", name, buf );
+                return;
+            }
+            /*print_deb(" NdisReadConfiguration(): buf = %p (%.20s)\n", buf, buf );*/
+            print_info("NdisReadConfiguration(): %s = %d\n", name, (INT32) pNdisParm->ParameterData.IntegerData);
+        }
+        else
+        {
+            print_err("NdisReadConfiguration(): unknow parameter type %d for %s\n", param_type, name );
+            return;
+        }
+        *status = NDIS_STATUS_SUCCESS;
+        return;
+
+    }
+/*    print_deb("NdisReadConfiguration(%d): (%c)%s  - not found\n", init_file_length,*/
+/*                (param_type == NdisParameterString) ? 'S' : 'D', name );*/
+#else
+    /* No init file support */
+    *status = NDIS_STATUS_FAILURE;
+
+#endif
+    return ;
+}
+
+VOID NdisWriteConfiguration( OUT PNDIS_STATUS  Status, 
+                IN NDIS_HANDLE  ConfigurationHandle,
+                IN PNDIS_STRING  Keyword, 
+                IN PNDIS_CONFIGURATION_PARAMETER  ParameterValue )
+{
+    print_err(" NdisWriteConfiguration(): ** not implemented yet ...\n");
+}
+
+VOID NdisReadNetworkAddress( OUT PNDIS_STATUS  Status, OUT PVOID  *NetworkAddress, OUT PUINT  NetworkAddressLength,
+    IN NDIS_HANDLE  ConfigurationHandle )
+{
+    print_err(" NdisReadNetworkAddress(): ** not implemented yet ...\n");
+}
+
+VOID NdisMIndicateStatus(
+  NDIS_HANDLE MiniportAdapterHandle,
+  NDIS_STATUS GeneralStatus,
+  PVOID StatusBuffer,
+  UINT StatusBufferSize
+)
+{
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/src/osapi.c b/sta_dk_4_0_4_32/pform/linux/src/osapi.c
new file mode 100644 (file)
index 0000000..6378b2e
--- /dev/null
@@ -0,0 +1,1761 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include "arch_ti.h"
+
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/time.h>
+#include <linux/timer.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/vmalloc.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/time.h>
+#include <linux/list.h>
+#include <asm/io.h>
+#ifdef CONFIG_TROUT_PWRSINK
+#include <asm/arch/trout_pwrsink.h>
+#endif
+
+#include "debug_module.h"
+#include "esta_drv.h"
+#ifdef DRIVER_PROFILING
+#include "tiwlan_profile.h"
+#endif
+#include "osApi.h"
+#include "osTIType.h"
+#include "srcApi.h"
+#include "whalHwRegs.h"
+#include "bmtrace.h"
+#include "TI_IPC_Api.h"
+#include "whalBus_Defs.h"
+#include "802_11Defs.h"
+#include "Ethernet.h"
+
+#define OS_PROTECT_HANDLE   0xffffeee0
+/*#define DEBUG_REG_ACCESS*/
+
+#ifdef DEBUG_REG_ACCESS
+#define PRINT_REG(fmt, args...)     print_info(fmt, args)
+#else
+#define PRINT_REG(fmt, args...)
+#endif
+#define NOPRINT_REG(fmt, args...)
+
+#ifdef ESTA_TIMER_DEBUG
+#define esta_timer_log(fmt,args...)  printk(fmt, ## args)
+#else
+#define esta_timer_log(fmt,args...)
+#endif
+
+#define FRAG_SIZE        200
+
+/* Wlan chip reset defines */
+#define GPIO_16                                                16
+#define GPIO_16_DIRECTION_OUTPUT       0
+#define GPIO_16_CLEAR                          0
+#define GPIO_16_SET                                    1
+       
+#define GPIO1_IRQSTATUS1       0xFFFBE418
+#define GPIO1_DATAIN           0xFFFBE42C
+
+/*********************    LOCAL DECLARATIONS ************************/
+static inline void os_timer_dec_use_count(timer_obj_t *tmr);
+static int os_tl_timerHandlr(struct tiwlan_req *req);
+static void os_timerHandlr(unsigned long parm);
+static void send_frag(char* msg, int message_len, int level, int module);
+
+BOOL use_debug_module = FALSE;
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                             OS Report API                                                                                                   *       
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+
+/****************************************************************************************
+ *                        os_setDebugMode()                                 
+ ****************************************************************************************
+DESCRIPTION:   Set the Debug Mode 
+
+INPUT:            
+
+RETURN:                        None   
+
+NOTES:                 
+*****************************************************************************************/
+void os_setDebugMode(BOOL enable)
+{
+       use_debug_module = enable;
+}
+
+
+/****************************************************************************************
+ *                        os_printf()                                 
+ ****************************************************************************************
+DESCRIPTION:   Print formatted output. 
+
+INPUT:          format -  Specifies the string, to be printed
+
+RETURN:                        None   
+
+NOTES:                 
+*****************************************************************************************/
+void os_printf(const char *format ,...)
+{
+       static int from_new_line = 1;           /* Used to save the last message EOL */
+       static UINT8 module = 0;                        /* Used to save the last message module */
+       static UINT8 level = 0;                         /* Used to save the last message level */
+    va_list ap;
+    static char msg[500];
+       char *p_msg = msg;                                      /* Pointer to the message */
+       UINT16 message_len;                                     
+    UINT32 sec = 0;
+    UINT32 uSec = 0;
+   
+       /* Format the message and keep the message length */
+    va_start(ap,format);
+       message_len = vsnprintf(&msg[1], sizeof(msg) - 1, format, ap);
+
+    
+       if (use_debug_module)
+       {
+               /*********************/
+               /* Use debug module */
+               /*******************/
+
+               if (msg[1] == '$')
+               {
+                       /************************************
+                                 Message format:               "$XX" 
+                                                                                |||
+                                         message prefix ----|||
+                                         module index -------||
+                                         severity index ------|
+                       ************************************/
+
+                       level = (msg[2] - 'A');
+                       module = (msg[3] - 'A');
+               }
+               else
+               {
+            send_frag(msg, message_len, level, module);
+        }
+    }
+    else
+    {
+        /***********************/
+        /* Use regular printk */
+        /*********************/
+        
+        if( from_new_line )
+        {
+            if (msg[1] == '$')
+            {
+                p_msg += 4;
+            }
+            
+            sec = os_timeStampUs(NULL);
+            uSec = sec % 1000000;
+            sec /= 1000000;
+            
+            printk(KERN_INFO DRIVER_NAME ": %d.%06d: %s",sec,uSec,p_msg);
+        }
+        else
+        {
+            printk(&msg[1]);
+        }
+        
+        from_new_line = ( msg[message_len] == '\n' );
+    }
+}
+
+static void send_frag(char* msg, int message_len, int level, int module)
+{
+#ifdef TIWLAN_OMAP1610 /* Dm: */
+    int return_value;
+    int offset = 1;
+    int TmpLen;
+    char* FragMsg;
+    
+    do
+    {            
+        TmpLen = min(message_len - offset, FRAG_SIZE);
+        FragMsg = msg + offset - 1;
+        FragMsg[0] = module;
+        
+        return_value = debug_module_enqueue_message(DEBUG_MODULE_TRACE_QUEUE_ID, level, FragMsg, TmpLen+1, CONTROL_CODE_TYPE_MESSAGE);
+
+                       if (return_value)
+                       {
+                               /* Message overrun */
+
+                               /* Send the overrun indication to the debug module */
+                               os_memoryCopy(NULL, &msg[1], "*** Message Overrun ***", strlen("*** Message Overrun ***"));
+                               msg[0] = 0;
+                               debug_module_enqueue_message(DEBUG_MODULE_TRACE_QUEUE_ID, 0, msg, (strlen("*** Message Overrun ***") + 1), CONTROL_CODE_TYPE_MESSAGE);
+
+                               /* Print overrun indication to the terminal */
+                               /*printk(KERN_INFO DRIVER_NAME ": %d.%06d: %s\n", sec, uSec, "**** Debug module message overrun! ****\n");*/
+                       }
+        offset += TmpLen;
+    }while (offset < message_len);
+  
+#endif    
+}
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     OS DMA CALLBACK API                                                                                     *
+ ****************************************************************************************/
+/****************************************************************************************
+ *                        os_TNETWIF_BusTxn_Complete()                                 
+ ****************************************************************************************
+DESCRIPTION:    Callback directly called at an IRQ context from the SPI modue
+                               This should triger a tasklet_schedule so that the End of DMA will be handled
+                               in a tasklet  context and then be directed to the TNETWIF to call the Client callback.
+
+INPUT:          OsContext - our adapter context.
+
+RETURN:         None
+
+NOTES:                 
+*****************************************************************************************/
+void os_TNETWIF_BusTxn_Complete(TI_HANDLE OsContext,int status)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+
+    drv->dma_done = 1;
+#ifdef DM_USE_WORKQUEUE
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+    if( queue_work( drv->tiwlan_wq, &drv->tw ) != 0 ) {
+#ifdef CONFIG_ANDROID_POWER
+        android_lock_suspend( &drv->timer_wake_lock );
+#endif
+    }
+#else
+       tasklet_schedule(&drv->tl);
+#endif
+}
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     OS TIMER API                                                                                            *
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+
+/****************************************************************************************
+ *                        os_timerCreate()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function creates and initializes a timer object associated with a
+                caller's pRoutine function.
+
+ARGUMENTS:      
+
+RETURN:         A handle of the created timer.
+                TI_HANDLE_INVALID if there is insufficient memory available
+
+NOTES:          Using the Kernel timer feature, problem is that kernel timers are one-shots.
+                For timers that are periodic this abstraction layer will have to mediate
+                between the callback function and the re-submission of a timer request.
+
+*****************************************************************************************/
+TI_HANDLE
+os_timerCreate(
+        TI_HANDLE OsContext,
+        PTIMER_FUNCTION pRoutine,
+        TI_HANDLE Context
+        )
+{
+    timer_obj_t *tmr;
+
+#ifdef ESTA_TIMER_DEBUG
+    esta_timer_log("\n\n%s:%d ::os_timerCreate(%p,%p,%p)",__FUNCTION__, __LINE__,OsContext,pRoutine,Context);
+#endif
+    ti_nodprintf(TIWLAN_LOG_INFO, "\n----> os_timerCreate function = 0x%08x , context= 0x%08x",
+                 (int)pRoutine, (int)Context);
+
+    os_profile (OsContext, 6, 0);
+
+    tmr = os_memoryAlloc (OsContext, sizeof(timer_obj_t));
+    if (tmr == NULL)
+        return(TI_HANDLE_INVALID);
+
+    memset (tmr,0,sizeof(timer_obj_t));
+
+    init_timer(&tmr->timer);
+    INIT_LIST_HEAD(&tmr->req.list);
+    tmr->timer.function = os_timerHandlr;
+    tmr->timer.data = (int)tmr;
+    tmr->req.drv = (tiwlan_net_dev_t *)OsContext;
+    tmr->req.u.req.p1 = (UINT32)pRoutine;
+    tmr->req.u.req.p2 = (UINT32)Context;
+    tmr->req.u.req.f  = os_tl_timerHandlr;
+    tmr->use_count = 1;
+
+    esta_timer_log("=%p\n\n", tmr);
+
+    return (TI_HANDLE)tmr;
+}
+
+
+/****************************************************************************************
+ *                        os_timerDestroy()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function destroy the timer object.
+
+ARGUMENTS:      
+
+RETURN:         
+
+NOTES:          Returning the Kernel level timer_list memory allocation and the
+                abstraction level timer object.
+*****************************************************************************************/
+VOID
+os_timerDestroy(
+        TI_HANDLE OsContext,
+        TI_HANDLE TimerHandle
+        )
+{
+    timer_obj_t *tmr = TimerHandle;
+
+    os_profile (OsContext, 6, 0);
+
+    os_timerStop (OsContext, TimerHandle);
+    os_timer_dec_use_count (tmr);
+}
+
+
+/****************************************************************************************
+ *                        os_timerStart()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function start the timer object.
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_timerStart(
+        TI_HANDLE OsContext,
+        TI_HANDLE TimerHandle,
+        UINT32 DelayMs,
+        BOOL bPeriodic
+        )
+{
+   timer_obj_t *tmr= (timer_obj_t *)TimerHandle;
+
+   UINT32 jiffie_cnt = msecs_to_jiffies(DelayMs);
+
+#ifdef ESTA_TIMER_DEBUG
+       esta_timer_log("\n\n%s:%d ::os_timerStart(%p,%p,%u,%d)\n\n",__FUNCTION__, __LINE__,OsContext,TimerHandle,DelayMs,bPeriodic);
+#endif
+
+   tmr->req.u.req.p3 = bPeriodic;
+   tmr->req.u.req.p4 = jiffie_cnt;
+   tmr->timer.data    = (unsigned long)tmr;
+   mod_timer(&tmr->timer, jiffies + jiffie_cnt);
+
+
+   return;
+}
+
+/****************************************************************************************
+ *                        os_stopTimer()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function stop the timer object.
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_timerStop(
+        TI_HANDLE OsContext,
+        TI_HANDLE TimerHandle
+        )
+{
+   timer_obj_t *tmr= (timer_obj_t *)TimerHandle;
+
+   del_timer_sync(&tmr->timer);
+   tmr->req.u.req.p3 = 0; /* Turn "periodic" off */
+   list_del_init(&tmr->req.list);
+
+   return;
+}
+
+/****************************************************************************************
+ *                        os_periodicIntrTimerStart()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function starts the periodic interrupt mechanism. This mode is used 
+                               when interrupts that usually received from the Fw is now masked, and we are
+                               checking for any need of Fw handling in time periods.
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 Power level of the CHIP should be always awake in this mode (no ELP)
+*****************************************************************************************/
+VOID
+os_periodicIntrTimerStart(
+       TI_HANDLE OsContext
+       )
+{
+       tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+
+       mod_timer (&drv->poll_timer, jiffies + TIWLAN_IRQ_POLL_INTERVAL);
+}
+
+/****************************************************************************************
+ *                        os_timeStampMs()                                 
+ ****************************************************************************************
+DESCRIPTION:   This function returns the number of milliseconds that have elapsed since
+                               the system was booted.
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+UINT32
+os_timeStampMs(
+        TI_HANDLE OsContext
+        )
+{
+    struct timeval tv;
+    do_gettimeofday(&tv);
+    return tv.tv_sec*1000 + tv.tv_usec/1000;
+}
+
+/****************************************************************************************
+ *                        os_timeStampUs()                                 
+ ****************************************************************************************
+DESCRIPTION:   This function returns the number of microseconds that have elapsed since
+                               the system was booted.
+
+ARGUMENTS:             OsContext - our adapter context.
+                               Note that sometimes this function will be called with NULL(!!!) as argument!
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+UINT32
+os_timeStampUs(
+        TI_HANDLE OsContext
+        )
+{
+    struct timeval tv;
+    do_gettimeofday(&tv);
+    return tv.tv_sec*1000000 + tv.tv_usec;
+}
+
+/****************************************************************************************
+ *                        os_StalluSec()                                 
+ ****************************************************************************************
+DESCRIPTION:   This function make delay in microseconds.
+
+ARGUMENTS:             OsContext - our adapter context.
+                               uSec - delay time in microseconds
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_StalluSec(
+        TI_HANDLE OsContext,
+        UINT32 uSec
+        )
+{
+    /*UINT32 usec_now = os_timeStampUs(OsContext);
+    while(os_timeStampUs(OsContext) - usec_now < uSec)
+      ;
+       */
+    udelay(uSec);
+}
+
+/****************************************************************************************
+ *                        os_WaitComplete()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function start waiting for the complete
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 can be called only from process context, and not from tasklet
+*****************************************************************************************/
+VOID 
+os_WaitComplete(
+       TI_HANDLE OsContext
+       )
+{
+       tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+               
+       /* ti_dprintf(TIWLAN_LOG_INFO, "os_WaitComplete drv %x drv->comp %x\n",(UINT32)drv,(UINT32)&drv->comp); */
+       
+       /* 
+       he tasklet should them send back the user (here)the completion event so the user could
+       go through the configuration phase 
+       */
+       wait_for_completion(&drv->comp);
+}
+
+/****************************************************************************************
+ *                        os_Complete()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function signals to the waiting process that completion occured
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID 
+os_Complete(
+       TI_HANDLE OsContext
+       )
+{
+       tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+               
+       /* ti_dprintf(TIWLAN_LOG_INFO, "os_Complete drv %x drv->comp %x\n",(UINT32)drv, (UINT32)&drv->comp); */
+
+       /* 
+       Call the completion routine  that will unblock the caller that was waiting on that object 
+       */
+       complete(&drv->comp);
+}
+
+
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     Hardware access functions       API                                                             *
+ *                                                                                                                                                                             *
+ ****************************************************************************************/
+
+/****************************************************************************************
+ *                        os_clearWlanReady()                                 
+ ****************************************************************************************
+DESCRIPTION:   Clear the WLAN Ready Interrupt Line stored in the PIC Controller 
+
+INPUT:          None  
+
+RETURN:                        None   
+
+NOTES:                 
+*****************************************************************************************/
+
+__inline__ VOID
+os_clearWlanReady(
+       void)
+{
+#ifdef TIWLAN_OMAP1610
+    omap_writel(4,GPIO1_IRQSTATUS1);
+#endif
+}
+
+
+/****************************************************************************************
+ *                        os_senseIrqLine()                                 
+ ****************************************************************************************
+DESCRIPTION:   Read the WLAN_IRQ line 
+
+INPUT:          void
+
+RETURN:                        Read value   
+
+NOTES:                 
+*****************************************************************************************/
+
+__inline__  UINT32
+os_senseIrqLine(
+       TI_HANDLE OsContext
+    )
+{
+#ifdef TIWLAN_OMAP1610
+    return (omap_readl(GPIO1_DATAIN) & 0x4);
+#else
+    return 0;
+#endif
+}
+
+
+
+/****************************************************************************************
+ *                        os_hwGetRegistersAddr()                                 
+ ****************************************************************************************
+DESCRIPTION:   
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+PVOID
+os_hwGetRegistersAddr(
+        TI_HANDLE OsContext
+        )
+{
+       return (PVOID)OS_API_REG_ADRR;
+}
+
+/****************************************************************************************
+ *                        os_hwGetMemoryAddr()                                 
+ ****************************************************************************************
+DESCRIPTION:   
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+PVOID
+os_hwGetMemoryAddr(
+        TI_HANDLE OsContext
+        )
+{
+       return (PVOID)OS_API_MEM_ADRR;
+}
+
+/****************************************************************************************
+ *                        os_memoryGetPhysicalLow()                                 
+ ****************************************************************************************
+DESCRIPTION:   return the lower 32 bits of a 64bit number / address *  
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+UINT32 os_memoryGetPhysicalLow (OS_PHYSICAL_ADDRESS pAddr)
+{
+   UINT32 res;
+   res = pAddr & 0xffffffff;
+   ti_dprintf(TIWLAN_LOG_ERROR, "\n 64bit low. Got 0x%x; Returning 0x%x \n", (UINT32)pAddr, res);
+   return res;
+}
+
+/****************************************************************************************
+ *                        os_memoryGetPhysicalHigh()                                 
+ ****************************************************************************************
+DESCRIPTION:   return the higher order 32 bits of a 64bit number / address *   
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+UINT32 os_memoryGetPhysicalHigh (OS_PHYSICAL_ADDRESS pAddr)
+{
+   UINT32 res;
+   res = pAddr >> 32;
+   ti_dprintf(TIWLAN_LOG_ERROR, "\n 64bit high. Got 0x%x; Returning 0x%x \n", (UINT32)pAddr, res);
+   return res;
+}
+
+
+/****************************************************************************************
+ *                                                                                                                                                     *
+ *                                                     Protection services     API                                                                             *
+ *                                                                                                                                                                             *
+ ****************************************************************************************
+ * OS protection is implemented as dummy functions because                                                             *
+ * all driver code is executed in context of a single tasklet,                                                 *
+ * except IOCTL handlers and xmition.                                                                                                  *
+ * Protection in IOCTL handlers and hard_start_xmit is done by different                               *
+ * means.                                                                                                                                                              *
+ ****************************************************************************************/
+
+
+/****************************************************************************************
+ *                        os_protectCreate()                                 
+ ****************************************************************************************
+DESCRIPTION:   
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        A handle of the created mutex/spinlock.
+                               TI_HANDLE_INVALID if there is insufficient memory available or problems
+                               initializing the mutex
+
+NOTES:                 
+*****************************************************************************************/
+TI_HANDLE
+os_protectCreate(
+        TI_HANDLE OsContext
+        )
+{
+    return (TI_HANDLE)OS_PROTECT_HANDLE;
+}
+
+
+
+/****************************************************************************************
+ *                        os_protectDestroy()                                 
+ ****************************************************************************************
+DESCRIPTION:           
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        None - This had better work since there is not a return value to the user
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_protectDestroy(
+        TI_HANDLE OsContext,
+        TI_HANDLE ProtectCtx
+        )
+{
+    return;
+}
+
+
+/****************************************************************************************
+ *                        os_protectLock()                                 
+ ****************************************************************************************
+DESCRIPTION:           
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        None - This had better work since there is not a return value to the user
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_protectLock(
+        TI_HANDLE OsContext,
+        TI_HANDLE ProtectContext
+        )
+{
+#if 1    /* uncomment for work in INDIRECT mode (HwACXAccessMethod=0) */
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+    spin_lock_irqsave(&drv->lock, drv->flags);
+#endif
+}
+
+
+/****************************************************************************************
+ *                        os_protectUnlock()                                 
+ ****************************************************************************************
+DESCRIPTION:           
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        None - This had better work since there is not a return value to the user
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_protectUnlock(
+        TI_HANDLE OsContext,
+        TI_HANDLE ProtectContext
+        )
+{
+#if 1    /* uncomment for work in INDIRECT mode (HwACXAccessMethod=0) */
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+    spin_unlock_irqrestore(&drv->lock, drv->flags);
+#endif
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+        os_resetWakeOnGpio
+
+Routine Description:
+
+        set the GPIO to low after awaking the TNET from ELP.
+
+Arguments:
+
+        OsContext - our adapter context.
+
+
+Return Value:
+
+        None
+
+-----------------------------------------------------------------------------*/
+VOID
+os_hardResetTnetw( void )
+{
+/*
+ *  Define the OMAP GPIO registers, the TNETW reset is currently connected
+ *  to GPIO 16, this logic assumes that the loading code had muxed the 
+ *  GPIO 16 to the Y1 pinout.
+ */
+    /* direction out */
+#ifdef TIWLAN_OMAP1610    
+       omap_set_gpio_direction(GPIO_16, GPIO_16_DIRECTION_OUTPUT);
+       
+       /* clear reset WLAN chip */
+       omap_set_gpio_dataout(GPIO_16, GPIO_16_CLEAR);
+
+       /* wait for 50msec */
+    mdelay(50);
+       omap_set_gpio_dataout(GPIO_16, GPIO_16_SET);
+
+       /* wait for 50msec */
+       mdelay(50);
+#endif /* Dm: */
+#ifdef TIWLAN_MSM7000
+    trout_wifi_reset(1); /* Reset active */
+    trout_wifi_power(0); /* Power disable */
+    trout_wifi_power(1); /* Power enable */
+    trout_wifi_reset(0); /* Reset clear */
+#endif
+}
+
+
+#ifndef GWSI_DRIVER
+
+/****************************************************************************************
+                                               START OF TI DRIVER API                          
+*****************************************************************************************/
+
+/****************************************************************************************
+ *                        os_setWakeOnGpio()                                 
+ ****************************************************************************************
+DESCRIPTION:   set the GPIO to high for awaking the TNET from ELP.     
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_setWakeOnGpio(
+    TI_HANDLE OsContext
+    )
+{
+#ifdef TIWLAN_OMAP1610
+    /*
+    Clear ELP_REQ by GPIO_CLEAR_DATAOUT
+    */
+    os_resetWakeOnGpio(OsContext);
+
+    /*
+    Rising edge on ELP_REQ by GPIO_SET_DATAOUT
+    */
+    omap_writel(0x00000200, 0xFFFBBCF0);
+#endif
+}
+
+/****************************************************************************************
+ *                        os_resetWakeOnGpio()                                 
+ ****************************************************************************************
+DESCRIPTION:   set the GPIO to low after awaking the TNET from ELP.    
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_resetWakeOnGpio(
+    TI_HANDLE OsContext
+    )
+{
+    /*
+    Clear ELP_REQ by GPIO_CLEAR_DATAOUT
+    */
+#ifdef TIWLAN_OMAP1610
+    omap_writel(0x00000200, 0xFFFBBCB0);
+#endif
+}
+
+/****************************************************************************************
+ *                        _os_memorySharedFree()                                 
+ ****************************************************************************************
+DESCRIPTION:           
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+_os_memorySharedFree(
+    TI_HANDLE OsContext,
+    PVOID pVirtual,
+    UINT32 Size,
+    OS_PHYSICAL_ADDRESS pPhysical
+    )
+{
+    ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s is not implemented\n\n\n", __FUNCTION__);
+}
+
+/****************************************************************************************
+ *                        _os_memorySharedAlloc()                                 
+ ****************************************************************************************
+DESCRIPTION:           
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+PVOID
+_os_memorySharedAlloc(
+    TI_HANDLE OsContext,
+    UINT32 Size,
+    OS_PHYSICAL_ADDRESS *pPhysical
+    )
+{
+    ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s is not implemented\n\n\n", __FUNCTION__);
+    return NULL;
+}
+
+/****************************************************************************************
+ *                        os_powerStateBusy()                                 
+ ****************************************************************************************
+DESCRIPTION:   notify to the host that the TI_WLAN application is busy.        
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_powerStateBusy(
+    TI_HANDLE OsContext
+    )
+{
+#if 0
+    ti_dprintf(TIWLAN_LOG_INFO,
+               "%s(%d) - os_powerStateBusy: TI_WLAN is busy!\n",
+               __FILE__,__LINE__);
+#endif
+}
+
+/****************************************************************************************
+ *                        os_powerStateIdle()                                 
+ ****************************************************************************************
+DESCRIPTION:   notify to the host that the TI_WLAN application is idle.        
+
+ARGUMENTS:             OsContext - our adapter context.
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_powerStateIdle(
+    TI_HANDLE OsContext
+    )
+{
+#if 0
+    ti_dprintf(TIWLAN_LOG_INFO,
+               "%s(%d) - os_powerStateIdle: TI_WLAN is idle!\n",
+               __FILE__,__LINE__);
+#endif
+}
+
+/****************************************************************************************
+ *                        os_memoryMove()                                 
+ ****************************************************************************************
+DESCRIPTION:   Move memory block from pSource to pDestination  
+
+ARGUMENTS:             OsContext - Our adapter context.
+                               pDestination - destination
+                               pSource - source
+                               Size - Number of characters
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_memoryMove(
+        TI_HANDLE pOsContext,
+        PVOID pDestination,
+        PVOID pSource,
+        UINT32 Size
+        )
+{
+    memmove(pDestination, pSource, Size);
+}
+
+
+/****************************************************************************************
+ *                        os_memoryMoveToHw()                                 
+ ****************************************************************************************
+DESCRIPTION:   This function copies data from a system-space buffer to device memory.  
+
+ARGUMENTS:             OsContext - Our adapter context.
+
+                               pTarget - Specifies the base address within a device memory range where
+                the copy should begin.
+
+                               pSource - Pointer to a system-space buffer from which this function copies
+                data to the destination range.
+
+                               Size - Specifies the number of bytes to copy.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_memoryMoveToHw(
+        TI_HANDLE OsContext,
+        PVOID pTarget,
+        PVOID pSource,
+        UINT32 Size
+        )
+{
+    print_info("\nos_memoryMoveToHw pTarget 0x%08x pSource 0x%08x Size 0x%08x",(int)pTarget, (int)pSource,(int)Size);
+    print_info("\n-------------------------> Not Implemented <--------------------------------------------------- ");
+}
+
+/****************************************************************************************
+ *                        os_memoryMoveFromHw()                                 
+ ****************************************************************************************
+DESCRIPTION:   This function copies data from a system-space buffer to device memory.  
+
+ARGUMENTS:             OsContext - Our adapter context.
+
+                               pTarget - Pointer to a system-space buffer into which this function copies
+                data from device memory.
+
+                               pSource - Specifies the base virtual address within device memory from
+                which to copy the data.
+
+                               Size - Specifies the number of bytes to copy.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_memoryMoveFromHw(
+        TI_HANDLE OsContext,
+        PVOID pTarget,
+        PVOID pSource,
+        UINT32 Size
+        )
+{
+    print_info("\nos_memoryMoveFromHw pTarget 0x%08x pSource 0x%08x Size 0x%08x",(int)pTarget, (int)pSource,(int)Size);
+    print_info("\n-------------------------> Not Implemented <--------------------------------------------------- ");
+}
+
+/****************************************************************************************
+ *                        os_hwReadMemRegisterUINT8()                                 
+ ****************************************************************************************
+DESCRIPTION:   Reads a UINT8 from a memory-mapped device register.     
+
+ARGUMENTS:             OsContext - our adapter context.
+
+                               Register - Pointer to the memory-mapped register.
+
+                               Data - Pointer to the caller-supplied variable in which this function
+                returns the UINT8 read from Register.  
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_hwReadMemRegisterUINT8(
+        TI_HANDLE OsContext,
+        PUCHAR Register,
+        PUINT8 Data
+        )
+{
+    *Data = *Register;
+    PRINT_REG("R8: %p=0x%x\n", Register, *Data);
+    return;
+}
+
+/****************************************************************************************
+ *                        os_hwWriteMemRegisterUINT16()                                 
+ ****************************************************************************************
+DESCRIPTION:   Writes a 'unsigned short' to a memory-mapped device register.   
+
+ARGUMENTS:             OsContext - our adapter context.
+
+                               Register - Pointer to the memory-mapped register.
+
+                               Data - Specifies the caller-supplied UINT16 that this function transfers
+                to the Register.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_hwWriteMemRegisterUINT16(
+        TI_HANDLE OsContext,
+        PUINT16 Register,
+        UINT16 Data
+        )
+{
+    PRINT_REG("W16: %p=0x%x\n", Register, Data);
+    *Register = Data;
+    return;
+}
+
+/****************************************************************************************
+ *                        os_hwReadMemRegisterUINT16()                                 
+ ****************************************************************************************
+DESCRIPTION:   Reads a UINT16 from a memory-mapped device register.    
+
+ARGUMENTS:         OsContext - our adapter context.
+
+                               Register - Pointer to the memory-mapped register.
+
+                               Data - Pointer to the caller-supplied variable in which this function
+                returns the UINT16 read from Register.
+       
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_hwReadMemRegisterUINT16(
+        TI_HANDLE OsContext,
+        PUINT16 Register,
+        PUINT16 Data
+        )
+{
+    *Data = *Register;
+    PRINT_REG("R16: %p=0x%x\n", Register, *Data);
+    return;
+}
+
+/****************************************************************************************
+ *                        os_hwWriteMemRegisterUINT32()                                 
+ ****************************************************************************************
+DESCRIPTION:   Writes a 'unsigned long' to a memory-mapped device register.    
+
+ARGUMENTS:             OsContext - our adapter context.
+
+                               Register - Pointer to the memory-mapped register.
+
+                               Data - Specifies the caller-supplied UINT32 that this function transfers
+                to the Register.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_hwWriteMemRegisterUINT32(
+        TI_HANDLE OsContext,
+        PUINT32 Register,
+        UINT32 Data
+        )
+{
+    PRINT_REG("W32: %p=0x%x\n", Register, Data);
+    *Register = Data;
+    return;
+}
+
+
+/****************************************************************************************
+ *                        os_hwReadMemRegisterUINT32()                                 
+ ****************************************************************************************
+DESCRIPTION:   Reads a UINT32 from a memory-mapped device register.    
+
+ARGUMENTS:             OsContext - our adapter context.
+
+                               Register - Pointer to the memory-mapped register.
+
+                               Data - Pointer to the caller-supplied variable in which this function
+                returns the UINT32 read from Register.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+VOID
+os_hwReadMemRegisterUINT32(
+        TI_HANDLE OsContext,
+        PUINT32 Register,
+        PUINT32 Data
+        )
+{
+    *Data = *Register;
+    PRINT_REG("R32: %p=0x%x\n", Register, *Data);
+    return;
+}
+
+
+/****************************************************************************************
+ *                        os_receivePacket()                                 
+ ****************************************************************************************
+DESCRIPTION:           
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+BOOL
+os_receivePacket(
+        TI_HANDLE OsContext,
+        PVOID pPacket,
+        UINT16 Length
+        )
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+    struct sk_buff *skb;
+    mem_MSDU_T* pMsdu = (mem_MSDU_T*)pPacket;
+    mem_BD_T *pCurBd;
+    ti_nodprintf(TIWLAN_LOG_INFO, "os_receivePacket - Received EAPOL len-%d\n", pMsdu->firstBDPtr->length );
+
+    bm_trace(10, Length, 0);
+
+    if (pMsdu->firstBDPtr->length > Length) { /* Dm: Security fix */
+        ti_dprintf(TIWLAN_LOG_ERROR, " TI: %s - Security Error\n", __FUNCTION__);
+        return FALSE;
+    }
+
+    skb = dev_alloc_skb(Length+2);
+    if(!skb) {
+        print_deb(" os_receivePacket() : dev_alloc_skb failed!\n");
+        configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, memMgr_MsduHandle(pPacket));
+        drv->stats.rx_dropped++;
+        return FALSE;
+    }
+    skb_reserve(skb, 2);
+
+    pCurBd = pMsdu->firstBDPtr;
+    while (pCurBd) {
+        memcpy(skb_put(skb,pCurBd->length),pCurBd->data+pCurBd->dataOffset,pCurBd->length);
+        pCurBd = pCurBd->nextBDPtr;
+    }
+
+    skb->dev = drv->netdev;
+    skb->protocol = eth_type_trans(skb, drv->netdev);
+    skb->ip_summed = CHECKSUM_NONE;
+
+    drv->stats.rx_packets++;
+    drv->stats.rx_bytes += skb->len;
+
+    bm_trace(11, Length, 0);
+#ifdef CONFIG_ANDROID_POWER
+    drv->receive_packet = 1; /* Remember to stay awake */
+#endif
+    netif_rx(skb);
+
+    configMgr_memMngrFreeMSDU(drv->adapter.CoreHalCtx, memMgr_MsduHandle(pPacket));
+
+    bm_trace(12, Length, 0);
+
+    return TRUE;
+}
+
+/****************************************************************************************
+ *                        os_sendPacket()                                 
+ ****************************************************************************************
+DESCRIPTION:   send EAPOL packet from Supplicant       
+
+ARGUMENTS:             
+
+RETURN:                        
+
+NOTES:                 
+*****************************************************************************************/
+INT32
+os_sendPacket(
+        TI_HANDLE OsContext,
+        PVOID pPacket,
+        UINT16 Length
+        )
+{
+    struct net_device *dev = (struct net_device *)OsContext;
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)dev->priv;
+
+    INT32 status;
+    mem_MSDU_T* pMsdu;
+    char *pMsduData;
+    UINT32 packetHeaderLength;
+
+    ti_nodprintf(TIWLAN_LOG_INFO, "os_sendPacket - Transmit EAPOL len-%x\n",Length );
+
+   /*
+    * Allocate enough place also for 802.11 header (24 bytes) and LLC (8 bytes)
+    * to replace the Ethernet header (14 bytes)
+    */
+    if(!Length)
+    {
+        ti_dprintf(TIWLAN_LOG_ERROR, " EAPOL Packet Length = 0 \n");
+        return -1;
+    }
+       /* 
+        * Retrieve the Packet Header length 
+        * from QoS Manager (through configMgr) and RSN 
+        */
+       packetHeaderLength = configMgr_getPacketHeaderLength(drv->adapter.CoreHalCtx,pPacket,TX_DATA_EAPOL_MSDU);
+
+    /* 
+        * need to reserve enough space for header translation 
+        * in the same first Bd.
+        * Allocate enough place also for 802.11 header (24 bytes or 26 for QoS) and LLC (8 bytes)
+        * to replace the Ethernet header (14 bytes)
+        */
+
+       status = configMgr_allocMSDU(drv->adapter.CoreHalCtx, &pMsdu,
+                                                                        Length + packetHeaderLength , OS_ABS_TX_MODULE);
+       if(status != OK)
+       {
+          ti_dprintf(TIWLAN_LOG_ERROR, " configMgr_allocMSDU failed !!!\n");
+          ++drv->alloc_msdu_failures;
+          return -ENOMEM;
+       }
+
+       /* 
+        * case 1: only legacy wlan header 
+        *
+        * case 2: only QoS wlan header 
+        *
+        * case 3: only legacy wlan header with new snap
+        *
+        * case 4: only QoS wlan header with new snap
+        */
+       pMsdu->firstBDPtr->dataOffset = packetHeaderLength - ETHERNET_HDR_LEN;
+       pMsduData = pMsdu->firstBDPtr->data + pMsdu->firstBDPtr->dataOffset;
+       memcpy(pMsduData, pPacket, Length);
+       pMsdu->dataLen = Length;
+       pMsdu->firstBDPtr->length = pMsdu->dataLen + pMsdu->firstBDPtr->dataOffset;
+       pMsdu->freeFunc = 0;
+       pMsdu->freeArgs[0] = 0;
+       pMsdu->freeArgs[1] = 0;
+
+   /*
+    * Propagate Msdu through Config Manager.
+    * Set DTag to 0 
+       * (note that classification is further handled in the Core)
+    */
+    status = configMgr_sendMsdu(drv->adapter.CoreHalCtx, pMsdu, 0);
+
+    return status;
+}
+
+
+#endif /* NDEF  GWSI_DRIVER*/
+
+
+
+/*******************************************************************************************************
+  
+                                                                       LOCAL FUNCTIONS
+
+********************************************************************************************************/
+
+/*-----------------------------------------------------------------------------
+Routine Name:
+
+        os_timer_dec_use_count
+
+Routine Description:
+
+    This function is decrements timer use count.
+    When use_count becomes 0, the timer block is destroyed
+-----------------------------------------------------------------------------*/
+static inline void os_timer_dec_use_count(timer_obj_t *tmr)
+{
+    if (unlikely(!tmr->use_count)) {
+        ti_dprintf(TIWLAN_LOG_ERROR, "\n\n\n %s: attempt to delete a deleted timer %p\n\n\n", __FUNCTION__, tmr);
+        tmr->use_count = 1;
+    }
+    if (!(--tmr->use_count))
+        os_memoryFree(tmr->req.drv, tmr, sizeof(timer_obj_t));
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+        os_tl_timerHandlr
+
+Routine Description:
+
+    This function is called in context of the control tasklet.
+    It evokes user timer handler and restarts the timer if periodic
+
+Arguments:
+    p1 - user handler
+    p2 - user parameter
+    p3 - periodic
+    p4 - jiffies
+
+Return Value:
+
+    None.
+
+Notes:
+
+-----------------------------------------------------------------------------*/
+static int os_tl_timerHandlr(struct tiwlan_req *req)
+{
+    timer_obj_t *tmr= (timer_obj_t *)req;
+    PTIMER_FUNCTION f = (PTIMER_FUNCTION)req->u.req.p1;
+    TI_HANDLE parm = (TI_HANDLE)req->u.req.p2;
+
+    esta_timer_log("%s: req=0x%x f=0x%p parm=0x%p\n", __FUNCTION__, req, f, parm);
+    ++tmr->use_count;
+    f(parm);
+    if (req->u.req.p3) /* Periodic ? */
+        mod_timer(&tmr->timer, jiffies + req->u.req.p4);
+    os_timer_dec_use_count(tmr);
+
+    return 0;
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+        os_timerHandlr
+
+Routine Description:
+
+    This function is called on timer expiration in context of
+    softIsr. It delegates the timer handling to the control tasklet.
+
+Arguments:
+    parm - timer object handle
+
+Return Value:
+
+    None.
+
+Notes:
+
+-----------------------------------------------------------------------------*/
+static void os_timerHandlr(unsigned long parm)
+{
+    timer_obj_t *tmr= (timer_obj_t *)parm;
+    tiwlan_net_dev_t *drv = tmr->req.drv;
+    unsigned long flags;
+
+    esta_timer_log("%s: drv=%p f=0x%x ctx=0x%x\n",
+          __FUNCTION__, tmr->req.drv, tmr->req.u.req.p1, tmr->req.u.req.p2);
+
+    spin_lock_irqsave(&drv->lock, flags);
+    list_del(&tmr->req.list);
+    list_add_tail(&tmr->req.list, &drv->request_q);
+    spin_unlock_irqrestore(&drv->lock, flags);
+#ifdef DM_USE_WORKQUEUE
+    /* printk("TI: %s:\t%lu\n", __FUNCTION__, jiffies); */
+    if( queue_work( drv->tiwlan_wq, &drv->tw ) != 0 ) {
+#ifdef CONFIG_ANDROID_POWER
+        android_lock_suspend( &drv->timer_wake_lock );
+#endif
+    }
+#else
+    tasklet_schedule(&drv->tl);
+#endif
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+        os_connectionStatus
+
+Routine Description:
+
+The eSTA-DK will call this API so the OS stack is aware that the
+WLAN layer is ready to function.
+
+Arguments:
+cStatus = 1; WLAN in ready for network packets
+cStatus = 0; WLAN in not ready for network packets
+
+Return Value:
+
+        None
+
+-----------------------------------------------------------------------------*/
+
+tiINT32
+os_IndicateEvent(IPC_EV_DATA* pData)
+{
+   IPC_EVENT_PARAMS * pInParam =  (IPC_EVENT_PARAMS *)pData;
+   tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)(pInParam->hUserParam);
+   /*UCHAR AuthBuf[sizeof(ULONG) + sizeof(OS_802_11_AUTHENTICATION_REQUEST)];*/
+
+   ti_nodprintf(TIWLAN_LOG_INFO, "\n  os_ConnectionStatus Event 0x%08x \n", CsStatus->Event);
+   
+   switch(pInParam->uEventType)
+     {
+   case IPC_EVENT_ASSOCIATED:
+         if (drv->netdev != NULL) {
+            netif_carrier_on(drv->netdev);
+#ifdef CONFIG_TROUT_PWRSINK
+            queue_delayed_work(drv->tiwlan_wq, &drv->trxw, 0);
+#endif
+         }
+         break;
+
+       case IPC_EVENT_DISASSOCIATED:
+         if (drv->netdev != NULL) {
+#ifdef CONFIG_TROUT_PWRSINK
+            cancel_delayed_work_sync(&drv->trxw);
+            trout_pwrsink_set(PWRSINK_WIFI, PWRSINK_WIFI_PERCENT_BASE);        
+#endif
+            netif_carrier_off(drv->netdev);
+         }
+      break;
+
+      case IPC_EVENT_LINK_SPEED:
+         drv->adapter.LinkSpeed = (*(PULONG)pData->uBuffer * 10000) / 2;
+         ti_nodprintf(TIWLAN_LOG_INFO, "\n  Link Speed = 0x%08x \n",drv->adapter.LinkSpeed);
+      break;
+
+      case IPC_EVENT_AUTH_SUCC:
+/*         *(PULONG)AuthBuf = os802_11StatusType_Authentication;
+         memcpy((PUCHAR)&AuthBuf[sizeof(ULONG)], pData->uBuffer,sizeof(OS_802_11_AUTHENTICATION_REQUEST));*/
+         ti_dprintf(TIWLAN_LOG_OTHER, "\n  Auth Succ Event from Driver to another BSSID. \n");
+      break;
+
+      case IPC_EVENT_SCAN_COMPLETE:
+         ti_dprintf(TIWLAN_LOG_OTHER, "\n  Driver Event = Scan Complete. \n");
+      break;
+
+      case IPC_EVENT_TIMEOUT:
+         ti_dprintf(TIWLAN_LOG_OTHER, "\n  Driver Event = Timeout. \n");
+      break;
+
+      case IPC_EVENT_CCKM_START:
+         ti_dprintf(TIWLAN_LOG_OTHER, "\n  Driver Event = IPC_EVENT_CCKM_START \n");
+      break;
+
+      default:
+         ti_dprintf(TIWLAN_LOG_ERROR, "\n  Unrecognized driver event. \n");
+      break;
+
+   }
+
+   return OK;
+}
+
+
+/****************************************************************************/
+/* The following 4 functions are debug functions that enable the user
+   to set/reset GPIO_25 and GPIO_27 in the OMAP - for debug purposes.
+   Note: In order to enable GPIO_25/GPIO_27 the user must enable the define
+       TIWLAN_OMAP1610_CRTWIPP_GPIO_DEBUG in the esta_drv.c/osapi.c files.             */
+
+void os_ToggleDebugGPIO(int count)
+{
+#if 0
+    int i,j;
+
+       omap_writel(0x00000200, 0xFFFBBCB0 );/* 0 */
+       for(i=0;i<count;i++)
+       {
+               omap_writel(0x00000200, 0xFFFBBCF0 );/* 1 */
+               for(j=0;j<100;j++);
+               omap_writel(0x00000200, 0xFFFBBCB0 );/* 0 */
+               for(j=0;j<100;j++);
+       }
+#endif
+}                                      
+#ifdef TIWLAN_OMAP1610_CRTWIPP_GPIO_DEBUG
+VOID
+os_SetGpio_25(
+    TI_HANDLE OsContext
+    )
+{
+    /*
+    Setting GPIO_25 by GPIO_SET_DATAOUT
+    */
+    omap_writel(0x00000200, 0xFFFBECF0 );
+}
+
+
+VOID
+os_ResetGpio25(
+    TI_HANDLE OsContext
+    )
+{
+       /*
+    Clear GPIO_25 by GPIO_CLEAR_DATAOUT
+    */
+    omap_writel(0x00000200, 0xFFFBECB0 );
+}
+
+
+VOID
+os_SetGpio27(
+    TI_HANDLE OsContext
+    )
+{
+    /*
+    Setting GPIO_27 by GPIO_SET_DATAOUT
+    */
+    omap_writel(0x00000800, 0xFFFBECF0 );
+}
+
+
+VOID
+os_ResetGpio27(
+    TI_HANDLE OsContext
+    )
+{
+       /*
+    Clear GPIO_27 by GPIO_CLEAR_DATAOUT
+    */
+    omap_writel(0x00000800, 0xFFFBECB0 );
+}
+#endif
+/******************************************************************************/
+
+VOID
+os_disableIrq( TI_HANDLE OsContext)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+    disable_irq (drv->irq);
+}
+
+VOID
+os_enableIrq( TI_HANDLE OsContext)
+{
+    tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+    enable_irq (drv->irq);
+}
+
+int
+os_getFirmwareImage(
+        TI_HANDLE OsContext,
+        PUINT8 *pBuffer,
+        PUINT32 Length,
+        UINT8 RadioType
+        )
+{
+   tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+
+   *pBuffer = drv->firmware_image.va;
+   *Length = drv->firmware_image.size;
+
+   return OK;
+}
+
+
+/*-----------------------------------------------------------------------------
+
+Routine Name:
+
+        os_getRadioImage
+
+Routine Description:
+
+
+Arguments:
+
+
+Return Value:
+
+        OK
+
+-----------------------------------------------------------------------------*/
+int
+os_getRadioImage(
+        TI_HANDLE OsContext,
+        PUINT8 *pBuffer,
+        PUINT32 Length,
+        UINT8 RadioType
+        )
+{
+
+#ifdef FIRMWARE_DYNAMIC_LOAD
+   tiwlan_net_dev_t *drv = (tiwlan_net_dev_t *)OsContext;
+
+   *pBuffer = drv->eeprom_image.va;
+   *Length = drv->eeprom_image.size;
+#else
+   extern unsigned char tiwlan_radimage[];
+   extern unsigned int sizeof_tiwlan_radimage;
+   *pBuffer = (PUINT8)tiwlan_radimage;
+   *Length = sizeof_tiwlan_radimage;
+#endif
+   ti_dprintf(TIWLAN_LOG_INFO, "%s: radio type: 0x%x\n", __FUNCTION__, RadioType);
+
+   return OK;
+}
+
+
+#ifdef DRIVER_PROFILING
+void _os_profile (TI_HANDLE OsContext, UINT32 fn, UINT32 par)
+{
+    tiwlan_profile (OsContext, fn, par);
+}
+#endif
+
+VOID
+os_closeFirmwareImage( TI_HANDLE OsContext )
+{
+    return;
+}
+
+VOID
+os_closeRadioImage( TI_HANDLE OsContext )
+{
+    return;
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/src/osmemapi.c b/sta_dk_4_0_4_32/pform/linux/src/osmemapi.c
new file mode 100644 (file)
index 0000000..e7e658d
--- /dev/null
@@ -0,0 +1,427 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include "arch_ti.h"
+
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/time.h>
+#include <linux/timer.h>
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/vmalloc.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/time.h>
+#include <linux/list.h>
+
+#include "osApi.h"
+#include "osTIType.h"
+#include "esta_drv.h"
+
+typedef void (*os_free)(void *);
+struct os_mem_block
+{
+    struct list_head blk_list;
+    os_free f_free;
+    __u32 size;
+    __u32 signature;
+};
+#define MEM_BLOCK_START  (('m'<<24) | ('e'<<16) | ('m'<<8) | 's')
+#define MEM_BLOCK_END    (('m'<<24) | ('e'<<16) | ('m'<<8) | 'e')
+
+/****************************************************************************************
+ *                                                                                      *
+ *                      OS Memory API                                                   *       
+ *                                                                                      *
+ ****************************************************************************************/
+
+/****************************************************************************************
+ *                        os_memoryAlloc()                                 
+ ****************************************************************************************
+DESCRIPTION:    Allocates resident (nonpaged) system-space memory.
+
+ARGUMENTS:      OsContext   - our adapter context.
+                Size        - Specifies the size, in bytes, to be allocated.
+
+RETURN:         Pointer to the allocated memory.
+                NULL if there is insufficient memory available.
+
+NOTES:          With the call to vmalloc it is assumed that this function will
+                never be called in an interrupt context. vmalloc has the potential to
+                sleep the caller while waiting for memory to become available.
+
+*****************************************************************************************/
+PVOID
+os_memoryAlloc(
+        TI_HANDLE OsContext,
+        UINT32 Size
+        )
+{
+    struct os_mem_block *blk;
+    __u32 total_size = Size + sizeof(struct os_mem_block) + sizeof(__u32);
+
+#ifdef TI_MEM_ALLOC_TRACE
+    os_printf("MTT:%s:%d ::os_memoryAlloc(0x%p, %lu) : %lu\n",__FUNCTION__, __LINE__,OsContext,Size,total_size);
+#endif
+    if( total_size < Size ) { /* Dm: Security fix */
+        return NULL;
+    }
+    /* 
+        memory optimization issue. Allocate 8 kB and less from the SLAB allocator (2^n)
+        otherwise allocate from virtual pool.
+    */
+               /* 2 pages */
+    if (Size < 2 * 4096)
+    {
+        blk = kmalloc(total_size, GFP_ATOMIC);
+        if (!blk)
+            return NULL;
+        blk->f_free = (os_free)kfree;
+    }
+    else
+    {
+        /* We expect that the big allocations should be made outside the interrupt,
+            otherwise fail
+        */
+        if (in_interrupt())
+            return NULL;
+        blk = vmalloc(total_size);
+        if (!blk)
+            return NULL;
+        blk->f_free = (os_free)vfree;
+    }
+
+    os_profile (OsContext, 4, total_size);
+
+    /*list_add(&blk->blk_list, &drv->mem_blocks);*/
+    blk->size = Size;
+    blk->signature = MEM_BLOCK_START;
+    *(__u32 *)((unsigned char *)blk + total_size - sizeof(__u32)) = MEM_BLOCK_END;
+    return (PVOID)((char *)blk + sizeof(struct os_mem_block));
+}
+
+
+/****************************************************************************************
+ *                        os_memoryCAlloc()                                 
+ ****************************************************************************************
+DESCRIPTION:    Allocates an array in memory with elements initialized to 0.
+
+ARGUMENTS:             OsContext       -       our adapter context.
+                               Number          -       Number of elements
+                               Size            -       Length in bytes of each element
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+PVOID
+os_memoryCAlloc(
+        TI_HANDLE OsContext,
+        UINT32 Number,
+        UINT32 Size
+        )
+{
+   PVOID pAllocatedMem;
+   ULONG MemSize;
+
+#ifdef TI_MEM_ALLOC_TRACE
+   os_printf("MTT:%s:%d ::os_memoryCAlloc(0x%p, %lu, %lu) : %lu\n",__FUNCTION__,__LINE__,OsContext,Number,Size,Number*Size);
+#endif
+   MemSize = Number * Size;
+
+   if( (Number > 0) && (Size >= (0xFFFFFFFFUL / Number)) ) { /* Dm: Security fix */
+       return NULL;
+   }
+
+   pAllocatedMem = os_memoryAlloc(OsContext, MemSize);
+
+   if(!pAllocatedMem)
+      return NULL;
+
+   memset(pAllocatedMem,0,MemSize);
+
+   return pAllocatedMem;
+}
+
+
+
+/****************************************************************************************
+ *                        os_memoryFree()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function releases a block of memory previously allocated with the
+                os_memoryAlloc function.
+
+
+ARGUMENTS:      OsContext   -   our adapter context.
+                pMemPtr     -   Pointer to the base virtual address of the allocated memory.
+                                This address was returned by the os_memoryAlloc function.
+                Size        -   Specifies the size, in bytes, of the memory block to be released.
+                                This parameter must be identical to the Length that was passed to
+                                os_memoryAlloc.
+
+RETURN:         None
+
+NOTES:          
+*****************************************************************************************/
+VOID
+os_memoryFree(
+        TI_HANDLE OsContext,
+        PVOID pMemPtr,
+        UINT32 Size
+        )
+{
+    struct os_mem_block *blk =
+        (struct os_mem_block *)((char *)pMemPtr - sizeof(struct os_mem_block));
+   
+#ifdef TI_MEM_ALLOC_TRACE
+    os_printf("MTT:%s:%d ::os_memoryFree(0x%p, 0x%p, %lu) : %d\n",__FUNCTION__,__LINE__,OsContext,pMemPtr,Size,-Size);
+#endif
+    if (blk->signature != MEM_BLOCK_START)
+    {
+        printk("\n\n%s: memory block signature is incorrect - 0x%x\n\n\n",
+               __FUNCTION__, blk->signature);
+        return;
+    }
+    *(char *)(&blk->signature) = '~';
+    if (*(__u32 *)((unsigned char *)blk + blk->size + sizeof(struct os_mem_block))
+        != MEM_BLOCK_END)
+    {
+        printk("\n\n%s: memory block corruption. Size=%u\n\n\n",
+               __FUNCTION__, blk->size);
+    }
+
+    os_profile (OsContext, 5, blk->size + sizeof(struct os_mem_block) + sizeof(__u32));
+
+    blk->f_free(blk);
+}
+
+
+/****************************************************************************************
+ *                        os_memorySet()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function fills a block of memory with given value.
+
+ARGUMENTS:             OsContext       - our adapter context.
+                               pMemPtr         - Specifies the base address of a block of memory
+                               Value           - Specifies the value to set
+                               Length          - Specifies the size, in bytes, to copy.
+
+RETURN:                        None
+
+NOTES:       
+*****************************************************************************************/
+VOID
+os_memorySet(
+    TI_HANDLE OsContext,
+    PVOID pMemPtr,
+    INT32 Value,
+    UINT32 Length
+    )
+{
+   memset(pMemPtr,Value,Length);
+}
+
+/****************************************************************************************
+ *                        _os_memoryAlloc4HwDma()                                 
+ ****************************************************************************************
+DESCRIPTION:    Allocates resident (nonpaged) system-space memory for DMA operations.
+
+ARGUMENTS:             OsContext       - our adapter context.
+                               Size            - Specifies the size, in bytes, to be allocated.
+
+RETURN:                        Pointer to the allocated memory.
+                               NULL if there is insufficient memory available.
+
+NOTES:                         
+
+*****************************************************************************************/
+PVOID
+os_memoryAlloc4HwDma(
+    TI_HANDLE pOsContext,
+    UINT32 Size
+    )
+{
+       struct os_mem_block *blk;
+       __u32 total_size = Size + sizeof(struct os_mem_block) + sizeof(__u32);
+       /* 
+               if the size is greater than 2 pages then we cant allocate the memory through kmalloc so the function fails
+       */
+       if (Size < 2 * OS_PAGE_SIZE)
+       {
+               blk = kmalloc(total_size, GFP_ATOMIC);
+               if (!blk)
+                       return NULL;
+               blk->f_free = (os_free)kfree;
+       }
+       else
+       {
+               printk("\n\n%s: memory cant be allocated-Size = %d\n\n\n",
+               __FUNCTION__, Size);
+               return NULL;
+       }
+
+       blk->size = Size;
+       blk->signature = MEM_BLOCK_START;
+       *(__u32 *)((unsigned char *)blk + total_size - sizeof(__u32)) = MEM_BLOCK_END;
+       return (PVOID)((char *)blk + sizeof(struct os_mem_block));
+}
+
+/****************************************************************************************
+ *                        _os_memory4HwDmaFree()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function releases a block of memory previously allocated with the
+                               _os_memoryAlloc4HwDma function.
+
+
+ARGUMENTS:             OsContext       -       our adapter context.
+                               pMemPtr         -       Pointer to the base virtual address of the allocated memory.
+                                                               This address was returned by the os_memoryAlloc function.
+                               Size            -       Specifies the size, in bytes, of the memory block to be released.
+                                                               This parameter must be identical to the Length that was passed to
+                                                               os_memoryAlloc.
+
+RETURN:                        None
+
+NOTES:                 
+*****************************************************************************************/
+void
+os_memory4HwDmaFree(
+    TI_HANDLE pOsContext,
+    PVOID pMem_ptr,
+    UINT32 Size
+    )
+{
+    struct os_mem_block *blk =
+        (struct os_mem_block *)((char *)pMem_ptr - sizeof(struct os_mem_block));
+
+       if (blk->signature != MEM_BLOCK_START)
+    {
+               printk("\n\n%s: memory block signature is incorrect - 0x%x\n\n\n",
+               __FUNCTION__, blk->signature);
+        return;
+    }
+    *(char *)(&blk->signature) = '~';
+    if (*(__u32 *)((unsigned char *)blk + blk->size + sizeof(struct os_mem_block))
+        != MEM_BLOCK_END)
+    {
+               printk("\n\n%s: memory block corruption. Size=%u\n\n\n",
+               __FUNCTION__, blk->size);
+    }
+
+    blk->f_free(blk);
+}
+
+/****************************************************************************************
+ *                        os_memoryZero()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function fills a block of memory with 0s.
+
+ARGUMENTS:             OsContext       - our adapter context.
+                               pMemPtr         - Specifies the base address of a block of memory
+                               Length          - Specifies how many bytes to fill with 0s.
+
+RETURN:                        None
+
+NOTES:  
+*****************************************************************************************/
+VOID
+os_memoryZero(
+    TI_HANDLE OsContext,
+    PVOID pMemPtr,
+    UINT32 Length
+    )
+{
+   memset(pMemPtr,0,Length);
+}
+
+
+/****************************************************************************************
+ *                        os_memoryCopy()                                 
+ ****************************************************************************************
+DESCRIPTION:    This function copies a specified number of bytes from one caller-supplied
+                               location to another.
+
+ARGUMENTS:             OsContext       - our adapter context.
+                               pDstPtr         - Destination buffer
+                               pSrcPtr         - Source buffer
+                               Size            - Specifies the size, in bytes, to copy.
+
+RETURN:                        None
+
+NOTES:       
+*****************************************************************************************/
+VOID
+os_memoryCopy(
+    TI_HANDLE OsContext,
+    PVOID pDstPtr,
+    PVOID pSrcPtr,
+    UINT32 Size
+    )
+{
+   memcpy(pDstPtr,pSrcPtr,Size);
+}
+
+/****************************************************************************************
+ *                        os_memoryCompare()                                 
+ ****************************************************************************************
+DESCRIPTION:    Compare characters in two buffers.
+
+ARGUMENTS:             OsContext       - our adapter context.
+                               Buf1            - First buffer
+                               Buf2            - Second buffer
+                               Count           - Number of characters
+
+RETURN:                        The return value indicates the relationship between the buffers:
+                < 0 Buf1 less than Buf2
+                0 Buf1 identical to Buf2
+                > 0 Buf1 greater than Buf2
+
+NOTES:                 
+*****************************************************************************************/
+INT32
+os_memoryCompare(
+        TI_HANDLE OsContext,
+        PUINT8 Buf1,
+        PUINT8 Buf2,
+        INT32 Count
+        )
+{
+   return memcmp(Buf1, Buf2, Count);
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/src/proc_stat.c b/sta_dk_4_0_4_32/pform/linux/src/proc_stat.c
new file mode 100644 (file)
index 0000000..3c2c1fe
--- /dev/null
@@ -0,0 +1,105 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/* Dm: #include <linux/config.h> */
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+
+#include "healthMonitor.h"
+#include "whalCtrl.h" 
+#include "osTIType.h"
+#include "configMgr.h"
+
+int proc_stat_res_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data);
+static struct proc_dir_entry *res; 
+
+int proc_stat_init(TI_HANDLE     *pHandle)
+{
+    configMgr_t         *pConfigManager  = (configMgr_t *)pHandle;
+    res = proc_mkdir("tiwlan", NULL);
+    create_proc_read_entry("tiwlan0_proc_stat", 0, res, proc_stat_res_read_proc, pConfigManager->hHealthMonitor);
+    return 0;
+}
+
+int proc_stat_res_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+    int len=0;
+    healthMonitor_t  *pHealthMonitor = (healthMonitor_t*) data;
+    WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)pHealthMonitor->hHalCtrl;
+    whalCtrl_hwStatus_t *pHwStatus = &pWhalCtrl->pHwCtrl->HwStatus;
+
+    count -= 80; /* some reserve */
+
+    len += (len<count)?sprintf(page+len,"-------------- STA Health Configuration ---------------\n"):0;
+    len += (len<count)?sprintf(page+len,"Full recovery enabled      = %d\n",pHealthMonitor->bFullRecoveryEnable):0;
+    len += (len<count)?sprintf(page+len,"Timer interval             = %d msec\n",pHealthMonitor->timerInterval):0;
+    len += (len<count)?sprintf(page+len,"\n"):0;
+
+
+    len += (len<count)?sprintf(page+len,"-------------- STA Health Failure Statistics ---------------\n"):0;
+    len += (len<count)?sprintf(page+len,"Health test perfomred      = %d\n",pHealthMonitor->numOfHealthTests):0;
+    len += (len<count)?sprintf(page+len,"Full recovery performed    = %d\n",pHealthMonitor->numOfRecoveryPerformed):0;
+    len += (len<count)?sprintf(page+len,"No scan complete failure   = %d\n",pHealthMonitor->recoveryTriggersNumber[ NO_SCAN_COMPLETE_FAILURE ]):0;
+    len += (len<count)?sprintf(page+len,"Mailbox failure            = %d\n",pHealthMonitor->recoveryTriggersNumber[ MBOX_FAILURE ]):0;
+    len += (len<count)?sprintf(page+len,"HW awake failure           = %d\n",pHealthMonitor->recoveryTriggersNumber[ HW_AWAKE_FAILURE ]):0;
+    len += (len<count)?sprintf(page+len,"Bus error                     = %d\n",pHealthMonitor->recoveryTriggersNumber[ BUS_ERROR ]):0;
+    len += (len<count)?sprintf(page+len,"Device error               = %d\n",pHealthMonitor->recoveryTriggersNumber[ DEVICE_ERROR ]):0;
+    len += (len<count)?sprintf(page+len,"Tx Stuck Errors            = %d\n",pHealthMonitor->recoveryTriggersNumber[ TX_STUCK ]):0;
+    len += (len<count)?sprintf(page+len,"Disconnect timeouts        = %d\n",pHealthMonitor->recoveryTriggersNumber[ DISCONNECT_TIMEOUT ]):0;
+       len += (len<count)?sprintf(page+len,"Power save failures        = %d\n",pHealthMonitor->recoveryTriggersNumber[ POWER_SAVE_FAILURE ]):0;
+       len += (len<count)?sprintf(page+len,"measurement failures       = %d\n",pHealthMonitor->recoveryTriggersNumber[ MEASUREMENT_FAILURE ]):0;
+
+    len += (len<count)?sprintf(page+len,"--------------- whalCtrl_PrintHwStatus ---------------\n\n"):0;
+    len += (len<count)?sprintf(page+len,"NumMboxErrDueToPeriodicBuiltInTestCheck = %d\n", pHwStatus->NumMboxErrDueToPeriodicBuiltInTestCheck):0;
+    len += (len<count)?sprintf(page+len,"NumMboxFailures = %d\n", pHwStatus->NumMboxFailures):0;
+    len += (len<count)?sprintf(page+len, "\n"):0;
+    *eof = 1;
+    return len;
+}
+
+int proc_stat_destroy(void)
+{
+    remove_proc_entry("tiwlan0_proc_stat", res);
+    remove_proc_entry("tiwlan", NULL);
+    return 0;
+}
+
+
+
+
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/stack_profile.c b/sta_dk_4_0_4_32/pform/linux/src/stack_profile.c
new file mode 100644 (file)
index 0000000..fbe5839
--- /dev/null
@@ -0,0 +1,87 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#include <linux/stddef.h>
+
+unsigned long check_stack(unsigned long *base)
+{
+       
+       register unsigned long sp asm ("sp");
+       unsigned long retval = sp;
+       *base = ((sp & ~0x1fff) + 0x380);
+       return retval;
+}
+
+unsigned long check_stack_start(unsigned long *base)
+{
+    unsigned long i;
+       unsigned long from,to;
+
+       to = check_stack(&from);
+       *base = from;
+
+       /* run from the stack pointer down to the base */
+       for (i = from;i<to;i+=4) 
+       {
+               /* fill up the pattern */
+               *(long *)i = 0xdeadbeef;
+       }
+/*     printk("check_stack_start: from =%x to=%x data=%x\n",from,to,*(long *)(from+4));*/
+       return to;
+}
+
+unsigned long check_stack_stop(unsigned long *base)
+{
+    unsigned long i;
+       unsigned long from,to;
+
+       to = check_stack(&from);
+       *base = from;
+
+       /* run from the stack pointer down to the base */
+       for (i = from;i<to;i+=4) 
+       {
+               /* check up the pattern */
+               if ((*(long *)i) != 0xdeadbeef)
+                       break;
+       }
+
+       /*printk("check_stack_stop: from =%x to=%x data=%x data=%x i=0x%x\n",from,to,*(long *)from,*(long *)(from+4),i);*/
+       /* return the first time when the pattern doesn't match */
+       return i;
+}
+
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/string.c b/sta_dk_4_0_4_32/pform/linux/src/string.c
new file mode 100644 (file)
index 0000000..9b22807
--- /dev/null
@@ -0,0 +1,69 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+/**
+ * memcmp - Compare two areas of memory
+ * @cs: One area of memory
+ * @ct: Another area of memory
+ * @count: The size of the area.
+ */
+int memcmp(const void * cs,const void * ct, unsigned int count)
+{
+       const unsigned char *su1, *su2;
+       int res = 0;
+
+       for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
+               if ((res = *su1 - *su2) != 0)
+                       break;
+       return res;
+}
+
+/**
+ * strcmp - Compare two strings
+ * @cs: One string
+ * @ct: Another string
+ */
+int strcmp(const char * cs,const char * ct)
+{
+       register signed char __res;
+
+       while (1) {
+               if ((__res = *cs - *ct++) != 0 || !*cs++)
+                       break;
+       }
+
+       return __res;
+}
diff --git a/sta_dk_4_0_4_32/pform/linux/src/tiwlan_profile.c b/sta_dk_4_0_4_32/pform/linux/src/tiwlan_profile.c
new file mode 100644 (file)
index 0000000..fca59ea
--- /dev/null
@@ -0,0 +1,344 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+
+#include "esta_drv.h"
+
+
+static void tiwlan_profile_bus_access_start (void *os, unsigned);
+static void tiwlan_profile_bus_access_end (void *os, unsigned);
+static void tiwlan_profile_driver_entry_start (void *os, unsigned);
+static void tiwlan_profile_driver_entry_end (void *os, unsigned);
+static void tiwlan_profile_memory_alloc (void *os, unsigned);
+static void tiwlan_profile_memory_free (void *os, unsigned);
+static void tiwlan_profile_buf_alloc (void * os, unsigned);
+static void tiwlan_profile_timer_create (void * os, unsigned);
+static void tiwlan_profile_timer_destroy (void * os, unsigned);
+
+
+int tiwlan_profile_create (tiwlan_net_dev_t *drv)
+{
+    drv->fpro [0] = NULL;
+    drv->fpro [1] = NULL;
+    drv->fpro [2] = NULL;
+    drv->fpro [3] = NULL;
+    drv->fpro [4] = tiwlan_profile_memory_alloc;
+    drv->fpro [5] = tiwlan_profile_memory_free;
+    drv->fpro [6] = tiwlan_profile_timer_create;
+    drv->fpro [7] = tiwlan_profile_timer_destroy;
+    drv->fpro [8] = tiwlan_profile_buf_alloc;
+
+    drv->cpu_usage_estimator_start_time = 0;
+    drv->cpu_usage_estimator_stop_time = 0;
+    drv->max_heap_bytes_allocated = 0;
+    drv->max_buf_bytes_allocated = 0;
+    drv->cur_heap_bytes_allocated = 0;
+    drv->max_number_of_timers = 0; 
+    drv->cur_number_of_timers = 0;
+
+    return 0;
+}
+
+
+/* Call register profiler banchmark */
+int tiwlan_profile (tiwlan_net_dev_t *drv, unsigned bm, unsigned par)
+{
+    if (drv && bm < MAX_PROFILE_BM && drv->fpro [bm])
+    {
+        (*drv->fpro [bm]) (drv, par);
+    }
+
+    return 0;
+}
+
+
+/* Stop CPU estimation for a driver entry and maintains the resolution of the estimator */
+void tiwlan_profile_bus_access_start (void * os, unsigned par)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv != NULL)
+    {
+        /* Save the current entry's start time */
+        drv->bus_driver_entry_start_time = os_timeStampUs (drv);
+    }
+}
+
+
+/* Starts CPU estimation for a bus driver entry */
+void tiwlan_profile_bus_access_end (void * os, unsigned par)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+    unsigned current_entry_cpu_usage;
+
+    if (drv != NULL)
+    {
+        /* Save the current entry's start time */
+        current_entry_cpu_usage = os_timeStampUs (drv) - drv->bus_driver_entry_start_time;
+
+        /* Make sure that it is not a negative value */
+        if ((int)current_entry_cpu_usage < 0) 
+        {
+            printk("\n\n%s: cpu usage estimation corrupted. entry_start=%u, entry_cpu_time = %d\n\n\n",
+                   __FUNCTION__, drv->bus_driver_entry_start_time,  current_entry_cpu_usage);
+        }
+        /* Update the total time of driver CPU usage */
+        else 
+        {
+            drv->total_us_of_bus_access_cpu_time += current_entry_cpu_usage;
+        }
+    }
+}
+
+
+/* Starts CPU estimation for a driver entry */
+void tiwlan_profile_driver_entry_start (void * os, unsigned par)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv != NULL)
+    {
+        drv->driver_entry_start_time = os_timeStampUs (drv);
+    }
+}
+
+
+/* Stop CPU estimation for a driver entry and maintains the resolution of the estimator */
+void tiwlan_profile_driver_entry_end (void * os, unsigned par)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+    unsigned current_entry_cpu_usage, driver_entry_end_time;
+
+    if (drv == NULL)
+        return;
+
+    /* Get the current entry's end time */
+    driver_entry_end_time = os_timeStampUs (drv);
+
+    /* Calculate the current entries CPU run time */
+    current_entry_cpu_usage = driver_entry_end_time - drv->driver_entry_start_time;
+
+    /* Make sure that it is not a negative value */
+    if ((int)current_entry_cpu_usage < 0) 
+    {
+        printk("\n\n%s: cpu usage estimation corrupted. entry_start=%u, entry_end=%u, entry_cpu_time = %d\n\n\n",
+               __FUNCTION__, drv->driver_entry_start_time, driver_entry_end_time, current_entry_cpu_usage);
+    }
+    /* Update the total time of driver CPU usage */
+    else 
+    {
+        drv->total_us_of_cpu_time += current_entry_cpu_usage;
+    }
+}
+
+
+void tiwlan_profile_memory_alloc (void * os, unsigned size)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv != NULL) 
+    {
+        /* Increase current heap allocation counter */
+        drv->cur_heap_bytes_allocated += size;
+        /* Update maximum if execceded */
+        if (drv->max_heap_bytes_allocated < drv->cur_heap_bytes_allocated) 
+        {
+            drv->max_heap_bytes_allocated = drv->cur_heap_bytes_allocated;
+        }
+    }
+}
+
+
+void tiwlan_profile_memory_free (void * os, unsigned size)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv != NULL) 
+    {
+        /* Decrease amount from heap allocation counter */
+        drv->cur_heap_bytes_allocated -= size;
+        /* Check for overflow */
+        if ((int)drv->cur_heap_bytes_allocated < 0) 
+        {
+            printk("\n\n%s: memory heap allocation calculation corrupted. Size=%u, Current allocation = %d\n\n\n",
+                   __FUNCTION__, size, drv->cur_heap_bytes_allocated);
+            drv->cur_heap_bytes_allocated = 0;
+        }
+    }
+}
+
+
+void tiwlan_profile_buf_alloc (void * os, unsigned size)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv != NULL) 
+    {
+        drv->max_buf_bytes_allocated += size;
+    }
+}
+
+
+void tiwlan_profile_timer_create (void * os, unsigned par)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv)
+    {
+        /* Increase the current active timer counter */
+        drv->cur_number_of_timers ++;
+        /* Update maximum if execceded */
+        if (drv->max_number_of_timers < drv->cur_number_of_timers) 
+        {
+            drv->max_number_of_timers = drv->cur_number_of_timers;
+        }
+    }
+}
+
+
+void tiwlan_profile_timer_destroy (void * os, unsigned par)
+{
+    tiwlan_net_dev_t * drv = (tiwlan_net_dev_t *) os;
+
+    if (drv)
+    {
+        /* Decrease the current active timer counter */
+        drv->cur_number_of_timers --;
+    }
+}
+
+
+/* 
+ * Start CPU estimator 
+ * NOTE: this function does not run in a driver context 
+ */
+int tiwlan_profile_cpu_usage_estimator_start (tiwlan_net_dev_t * drv, unsigned int resolution)
+{
+    /* 
+     *  Reset estimation parameters - no need for spin lock since 
+     *  estimator is not running 
+     */
+    drv->total_us_of_cpu_time = 0;
+    drv->total_us_of_bus_access_cpu_time = 0;
+    drv->cpu_usage_estimator_start_time = os_timeStampUs (drv);
+    drv->cpu_usage_estimator_stop_time = 0;
+
+    /* Set the new resolution */
+    drv->cpu_usage_estimator_resolution = resolution;
+
+    /* Register profiler banchmarks */
+    drv->fpro [0] = tiwlan_profile_driver_entry_start;
+    drv->fpro [1] = tiwlan_profile_driver_entry_end;
+    drv->fpro [2] = tiwlan_profile_bus_access_start;
+    drv->fpro [3] = tiwlan_profile_bus_access_end;
+
+    return 0;
+}
+
+
+/* 
+ * Stop CPU estimator and save the last CPU estimation 
+ * NOTE: this function does not run in a driver context 
+ */
+int tiwlan_profile_cpu_usage_estimator_stop (tiwlan_net_dev_t * drv)
+{
+    drv->cpu_usage_estimator_stop_time = os_timeStampUs (drv);
+
+    /* Unregister profiler banchmarks */
+    drv->fpro [0] = NULL;
+    drv->fpro [1] = NULL;
+    drv->fpro [2] = NULL;
+    drv->fpro [3] = NULL;
+
+    return 0;
+}
+
+
+/* 
+ * Reset CPU estimation 
+ * NOTE: this function is not run in a driver context 
+ */
+int tiwlan_profile_cpu_usage_estimator_reset (tiwlan_net_dev_t * drv)
+{
+    /* Reset accumulated driver time and the last estimation */
+    drv->total_us_of_cpu_time = 0;
+    drv->total_us_of_bus_access_cpu_time = 0;
+    drv->cpu_usage_estimator_start_time = 0;
+    drv->cpu_usage_estimator_stop_time = 0;
+
+    return 0;
+}
+
+
+/* Print to the screen the latest resource usage and CPU estimation */
+int tiwlan_profile_report (tiwlan_net_dev_t *drv)
+{
+    unsigned total_time, drv_cpu_usage = 0, bus_cpu_usage = 0;
+
+    printk ("\nDriver Resource Usage");
+    printk ("\n=====================");
+    printk ("\nMaximum Heap Memory Allocated: %u (bytes)", drv->max_heap_bytes_allocated);
+    printk ("\nCurrent Heap Memory Allocated: %u (bytes)", drv->cur_heap_bytes_allocated);
+    printk ("\nBuffer Memory Allocated: %u (bytes)", drv->max_buf_bytes_allocated);
+    printk ("\nFirmware Image Memory Allocated: %u (bytes)", (unsigned)drv->firmware_image.size);
+    printk ("\nEEPROM Image Memory Allocated: %u (bytes)", (unsigned)drv->eeprom_image.size);
+    printk ("\nMaximum Active Timers: %u", drv->max_number_of_timers);
+    printk ("\nCurrent Active Timers: %u", drv->cur_number_of_timers);
+
+    /* Check that the estimation has been started and stopped stopped */
+    if (drv->cpu_usage_estimator_stop_time != 0)
+    {
+        total_time = drv->cpu_usage_estimator_stop_time - drv->cpu_usage_estimator_start_time;
+
+        total_time /= 100;
+
+        if ((int)total_time > 0)
+        {
+            drv_cpu_usage = drv->total_us_of_cpu_time / total_time;
+            bus_cpu_usage = drv->total_us_of_bus_access_cpu_time / total_time;
+
+            printk ("\nTotal Test Run Time: %u (usec)", total_time);
+            printk ("\nTotal Driver Run Time: %u (usec)", drv->total_us_of_cpu_time);
+            printk ("\nTotal Bus Access Time: %u (usec)", drv->total_us_of_bus_access_cpu_time);
+            printk ("\nTotal CPU Usage: %u%%", drv_cpu_usage);
+            printk ("\nBus Access CPU Usage: %u%%", bus_cpu_usage);
+            printk ("\n");
+        }
+    }
+
+    return 0;
+}
+
diff --git a/sta_dk_4_0_4_32/pform/linux/src/tiwlan_profile.h b/sta_dk_4_0_4_32/pform/linux/src/tiwlan_profile.h
new file mode 100644 (file)
index 0000000..b9bb34f
--- /dev/null
@@ -0,0 +1,52 @@
+/****************************************************************************
+**+-----------------------------------------------------------------------+**
+**|                                                                       |**
+**| Copyright(c) 1998 - 2008 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.  |**
+**|                                                                       |**
+**+-----------------------------------------------------------------------+**
+****************************************************************************/
+
+
+#ifndef TIWLAN_PROFILE
+#define TIWLAN_PROFILE
+
+#ifdef DRIVER_PROFILING
+
+int tiwlan_profile_create                    (tiwlan_net_dev_t *drv);
+int tiwlan_profile_cpu_usage_estimator_start (tiwlan_net_dev_t * drv, unsigned int resolution);
+int tiwlan_profile_cpu_usage_estimator_stop  (tiwlan_net_dev_t * drv);
+int tiwlan_profile_cpu_usage_estimator_reset (tiwlan_net_dev_t * drv);
+int tiwlan_profile_report                    (tiwlan_net_dev_t * drv);
+int tiwlan_profile                           (tiwlan_net_dev_t * drv, unsigned bm, unsigned par);
+
+
+#endif
+
+#endif
diff --git a/sta_dk_4_0_4_32/pform/linux/src/tnetw_sdio.c b/sta_dk_4_0_4_32/pform/linux/src/tnetw_sdio.c
new file mode 100755 (executable)
index 0000000..ac72619
--- /dev/null
@@ -0,0 +1,195 @@
+/* tnetw_sdio.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Copyright © Texas Instruments Incorporated (Oct 2005)
+ * THIS CODE/PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDED BUT NOT LIMITED TO , THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * This program has been modified from its original operation by Texas
+ * Instruments Incorporated. These changes are covered under version 2
+ * of the GNU General Public License, dated June 1991.
+ *
+ * Copyright © Google Inc (Feb 2008)
+ */
+/*-------------------------------------------------------------------*/
+#ifdef TIWLAN_MSM7000
+#include <linux/delay.h>
+#include <linux/mmc/core.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include "esta_drv.h"
+#include "mmc_omap_api.h"
+#include "osApi.h"
+/*-------------------------------------------------------------------*/
+extern int tiwlan_sdio_init(struct sdio_func *func);
+extern int sdio_reset_comm(struct mmc_card *card);
+/*-------------------------------------------------------------------*/
+static struct sdio_func *tiwlan_func = NULL;
+static int sdio_reset_flag = 0;
+/*-------------------------------------------------------------------*/
+void SDIO_SetFunc( struct sdio_func *func )
+{
+       tiwlan_func = func;
+}
+
+struct sdio_func *SDIO_GetFunc( void )
+{
+       return( tiwlan_func );
+}
+
+SDIO_Status SDIO_Init(SDIO_ConfigParams *ConfigParams, SDIO_Handle *Handle)
+{
+       if( Handle == NULL ) {
+               printk(KERN_ERR "Error: SDIO_Init() called with NULL!\n");
+               return SDIO_FAILURE;
+       }
+       *Handle = (SDIO_Handle)SDIO_GetFunc();
+       if( (*Handle) == NULL ) {
+               printk(KERN_ERR "Error: SDIO_Init() called before SDIO probe completed!\n");
+               return SDIO_FAILURE;
+       }
+       return SDIO_SUCCESS;
+}
+
+SDIO_Status SDIO_Shutdown(SDIO_Handle Handle)
+{
+       /* printk("%s:\n", __FUNCTION__); */
+       return SDIO_SUCCESS;
+}
+
+SDIO_Status SDIO_Start(SDIO_Handle Handle)
+{
+       struct sdio_func *func = (struct sdio_func *)Handle;
+
+       /* printk("%s:\n", __FUNCTION__); */
+       if( func ) {
+               if( sdio_reset_flag ) {
+                       sdio_reset_flag = 0;
+                       if( tiwlan_sdio_init(func) ) {
+                               printk("TI: tiwlan_sdio_init Error !\n");
+                               return SDIO_FAILURE;
+                       }
+               }
+       }
+       return SDIO_SUCCESS;
+}
+
+SDIO_Status SDIO_Reset(SDIO_Handle Handle)
+{
+       struct sdio_func *func = (struct sdio_func *)Handle;
+
+       /* printk("%s:\n", __FUNCTION__); */
+       if( func && func->card ) {
+               sdio_reset_comm(func->card);
+       }
+       return SDIO_SUCCESS;
+}
+
+SDIO_Status SDIO_Stop(SDIO_Handle Handle, unsigned long Wait_Window)
+{
+       /* printk("%s:\n", __FUNCTION__); */
+       sdio_reset_flag = 1;
+       return SDIO_Reset( Handle );
+}
+
+static int read_direct(struct sdio_func *func, unsigned char *buf, 
+                            unsigned long addr, unsigned len)
+{
+       unsigned i;
+       int rc0, rc = 0;
+
+       for(i=0;( i < len );i++,addr++) {
+               *buf++ = (unsigned char)sdio_readb(func, addr, &rc0);
+               if( rc0 != 0 )
+                       rc = rc0;
+       }
+       return rc;
+}
+
+static int write_direct(struct sdio_func *func, unsigned long addr,
+                       unsigned char *buf, unsigned len)
+{
+       unsigned i;
+       int rc0, rc = 0;
+
+       for(i=0;( i < len );i++,addr++) {
+               sdio_writeb(func, *buf++, addr, &rc0);
+               if( rc0 != 0 )
+                       rc = rc0;
+       }
+       return rc;
+}
+
+SDIO_Status SDIO_SyncRead(SDIO_Handle Handle, SDIO_Request_t *Req)
+{
+       struct sdio_func *func = (struct sdio_func *)Handle;
+       int rc;
+       int retries = 5;
+
+#if 0
+       printk("%s: p_addr = 0x%.8lx, sz = %d\n",
+              __FUNCTION__,
+              Req->peripheral_addr,
+              Req->buffer_len);
+#endif
+
+       while(retries) {
+        if( retries > 2 )
+            rc = sdio_memcpy_fromio(func, Req->buffer, Req->peripheral_addr, Req->buffer_len);
+        else
+            rc = read_direct(func, Req->buffer, Req->peripheral_addr, Req->buffer_len);
+
+               if (rc) {
+                       printk(KERN_ERR "%s: Read operation failed (%d) (retries = %d)\n",
+                               __FUNCTION__, rc, retries);
+                       retries--;
+                       continue;
+               }
+               if (retries != 5)
+                       printk(KERN_ERR "%s: Retry succeeded\n", __FUNCTION__);
+               return SDIO_SUCCESS;
+       }
+       printk(KERN_ERR "%s: Giving up\n", __FUNCTION__);
+       return SDIO_FAILURE;
+}
+
+SDIO_Status SDIO_SyncWrite(SDIO_Handle Handle, SDIO_Request_t *Req)
+{
+       struct sdio_func *func = (struct sdio_func *)Handle;
+       int rc;
+       int retries = 5;
+
+#if 0
+       printk("%s: p_addr = 0x%.8lx, sz = %d\n",
+              __FUNCTION__,
+              Req->peripheral_addr,
+              Req->buffer_len);
+#endif
+
+       while(retries) {
+        if( retries > 2 ) {
+            rc = sdio_memcpy_toio(func, Req->peripheral_addr, Req->buffer, Req->buffer_len);
+        }
+        else
+            rc = write_direct(func, Req->peripheral_addr, Req->buffer, Req->buffer_len);
+
+               if (rc) {
+                       printk(KERN_ERR "%s: Write operation failed (%d) (retries = %d)\n",
+                       __FUNCTION__, rc, retries);
+                       retries--;
+                       continue;
+               }
+
+               if (retries != 5)
+                       printk(KERN_ERR "%s: Retry succeeded\n", __FUNCTION__);
+               return SDIO_SUCCESS;
+       }
+       printk(KERN_ERR "%s: Giving up\n", __FUNCTION__);
+       return SDIO_FAILURE;
+}
+#endif
diff --git a/wpa_supplicant_lib/Android.mk b/wpa_supplicant_lib/Android.mk
new file mode 100644 (file)
index 0000000..70d77a1
--- /dev/null
@@ -0,0 +1,145 @@
+LOCAL_PATH := $(call my-dir)
+WPA_BUILD_SUPPLICANT_LIB := false
+ifeq ($(HAVE_CUSTOM_WIFI_DRIVER_2),true)
+WPA_BUILD_SUPPLICANT_LIB := true
+STA_DK_ROOT = $(LOCAL_PATH)/../..
+endif
+
+DK_ROOT = $(STA_DK_ROOT)
+OS_ROOT = $(STA_DK_ROOT)/pform
+COMMON  = $(DK_ROOT)/common
+COMSRC  = $(COMMON)/src
+CUDK_ROOT = $(DK_ROOT)/CUDK
+
+include external/wpa_supplicant/.config
+
+# To force sizeof(enum) = 4
+ifneq ($(TARGET_SIMULATOR),true)
+L_CFLAGS += -mabi=aapcs-linux
+endif
+
+INCLUDES = $(COMMON)/inc \
+       $(COMSRC)/inc \
+       $(COMSRC)/utils \
+       $(COMSRC)/hal/inc \
+       $(COMSRC)/hal/TnetwServices  \
+       $(COMSRC)/hal/TnetwServices/TNETW1150  \
+       $(COMSRC)/hal/FirmwareApi \
+       $(COMSRC)/hal/hl_data \
+       $(COMSRC)/hal/hl_ctrl \
+       $(COMSRC)/hal/hl_ctrl/PowerCtrl \
+       $(COMSRC)/hal/hw_data \
+       $(COMSRC)/hal/hw_ctrl \
+       $(COMSRC)/hal/security \
+       $(COMSRC)/hal/security/CCX \
+       $(COMSRC)/hal/security/Privacy \
+       $(COMSRC)/hal/security/Privacy/Enc/Ckip \
+       $(COMSRC)/hal/security/Privacy/Enc/KP \
+       $(COMSRC)/hal/security/Privacy/Enc/KP/Ckip \
+       $(COMSRC)/hal/security/Privacy/ICV \
+       $(COMSRC)/hal/security/Privacy/IV \
+       $(COMSRC)/hal/security/Privacy/IV/WEP \
+       $(COMSRC)/hal/security/Privacy/MIC \
+       $(COMSRC)/hal/security/Privacy/MIC/Michael \
+       $(COMSRC)/hal/security/Privacy/MIC/MMH \
+       $(COMSRC)/hal/security/Privacy/Seq \
+       $(COMSRC)/hal/security/Privacy/Seq/CCX \
+       $(COMSRC)/hal/Export_Inc \
+       $(COMSRC)/BusAccess/Shm_Common \
+       $(COMSRC)/BusAccess/Export_Inc \
+       $(COMSRC)/BusAccess/Shm_Slave \
+       $(COMSRC)/core/inc \
+       $(COMSRC)/core/ExpInc \
+       $(COMSRC)/core/data_ctrl/Tx \
+       $(COMSRC)/core/data_ctrl/Ctrl \
+       $(COMSRC)/core/data_ctrl/Ctrl/TrafficMonitor \
+       $(COMSRC)/core/data_ctrl/Ctrl/4X \
+       $(COMSRC)/core/data_ctrl/Rx \
+       $(COMSRC)/core/EvHandler \
+       $(COMSRC)/core/sme/Inc \
+       $(COMSRC)/core/sme/smeSm/ \
+       $(COMSRC)/core/sme/siteMgr \
+       $(COMSRC)/core/sme/configMgr \
+       $(COMSRC)/core/sme/conn \
+       $(COMSRC)/core/sme/HealthMonitor \
+       $(COMSRC)/core/srv/inc \
+       $(COMSRC)/core/srv/scanSrv \
+       $(COMSRC)/core/srv/scr \
+       $(COMSRC)/core/rsn \
+       $(COMSRC)/core/rsn/mainKeysSm \
+       $(COMSRC)/core/rsn/mainKeysSm/keyDerive \
+       $(COMSRC)/core/rsn/adm_ctrl/WPA \
+       $(COMSRC)/core/rsn/adm_ctrl/WPA2 \
+       $(COMSRC)/core/rsn/adm_ctrl/WEP/CCX \
+       $(COMSRC)/core/rsn/inc \
+       $(COMSRC)/core/rsn/algorithms \
+       $(COMSRC)/core/mlme \
+       $(COMSRC)/core/mlme/Assoc \
+       $(COMSRC)/core/mlme/Auth/open \
+       $(COMSRC)/core/mlme/Auth/shared \
+       $(COMSRC)/Management/QOS/Inc/ \
+       $(COMSRC)/Management/CCX/Inc/ \
+       $(COMSRC)/Management/Roaming/Inc/ \
+       $(COMSRC)/core/NetworkCtrl/inc \
+       $(COMSRC)/Management/AirLink/Measurement \
+       $(COMSRC)/Management/AirLink/Measurement/CCX \
+       $(COMSRC)/Management/AirLink/Measurement/dot11h \
+       $(COMSRC)/Management/AirLink/inc \
+       $(COMSRC)/Management/scan/inc \
+       $(COMSRC)/Management/scan/scanCncn \
+       $(COMSRC)/core/NetworkCtrl/RegulatoryDomain \
+       $(COMSRC)/core/NetworkCtrl/RegulatoryDomain/CCX \
+       $(COMSRC)/Management/PowerMgr/ \
+       $(COMSRC)/core/NetworkCtrl/QOS \
+       $(COMSRC)/Application/inc \
+       $(COMSRC)/Application/\ExpInc \
+       $(COMSRC)/Application/ScanMngr \
+       $(COMSRC)/Management/apConn \
+       $(COMSRC)/core/currBss \
+       $(COMSRC)/Management/scan/inc \
+       $(CUDK_ROOT)/Inc \
+       $(OS_ROOT)/common/inc \
+       $(OS_ROOT)/linux/inc \
+       $(OS_ROOT)/linux/src \
+       $(COMSRC)/core/EvHandler \
+       $(CUDK_ROOT)/IPC/Linux \
+       $(CUDK_ROOT)/UtilityAdapter \
+       external/openssl/include \
+       external/wpa_supplicant
+  
+L_CFLAGS += -DCONFIG_DRIVER_CUSTOM -DHOST_COMPILE
+ifeq ($(HAVE_CUSTOM_WIFI_DRIVER_0),true) 
+L_CFLAGS += -DSTA_DK_VER_5_0_0_94 
+endif
+OBJS = driver_ti.c
+
+ifdef CONFIG_NO_STDOUT_DEBUG
+L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
+endif
+
+ifdef CONFIG_DEBUG_FILE
+L_CFLAGS += -DCONFIG_DEBUG_FILE
+endif
+
+ifdef CONFIG_IEEE8021X_EAPOL
+L_CFLAGS += -DIEEE8021X_EAPOL
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+ifeq ($(WPA_BUILD_SUPPLICANT_LIB),true)
+
+########################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libCustomWifi
+LOCAL_STATIC_LIBRARIES := libWifiApi
+LOCAL_SHARED_LIBRARIES := libc
+LOCAL_CFLAGS := $(L_CFLAGS)
+LOCAL_SRC_FILES := $(OBJS)
+LOCAL_C_INCLUDES := $(INCLUDES)
+include $(BUILD_STATIC_LIBRARY)
+
+########################
+
+endif # ifeq ($(WPA_BUILD_SUPPLICANT_LIB),true)
+endif # ifneq ($(TARGET_SIMULATOR),true)
diff --git a/wpa_supplicant_lib/driver_ti.c b/wpa_supplicant_lib/driver_ti.c
new file mode 100644 (file)
index 0000000..2bbd18d
--- /dev/null
@@ -0,0 +1,1610 @@
+/*
+ * WPA Supplicant - driver interaction with TI station
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ */
+
+/* Copyright © Texas Instruments Incorporated (Oct 2005)
+ * THIS CODE/PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
+ * EITHER EXPRESS OR IMPLIED, INCLUDED BUT NOT LIMITED TO , THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
+ * This program has been modified from its original operation by Texas 
+ * Instruments Incorporated. These changes are covered under version 2 
+ * of the GNU General Public License, dated June 1991. 
+ *
+ * Copyright © Google Inc (Feb 2008)
+*/
+/*-------------------------------------------------------------------*/
+#include "includes.h"
+#include <sys/ioctl.h>
+#include <net/route.h>
+#include <net/if.h>
+#include <fcntl.h>
+#include <netpacket/packet.h>
+#include <stddef.h>
+#include "common.h"
+#include "driver.h"
+#include "eloop.h"
+#include "wpa.h"
+#include "wpa_supplicant.h"
+#include "config.h"
+#include "wpa_supplicant_i.h"
+#include "wpa_i.h"
+#include "l2_packet.h"
+#include "wpa_ctrl.h"
+/*----- STA_DK files -----*/
+#include "wspVer.h"
+#include "driver_ti.h"
+#include "scanMngrTypes.h"
+/*-------------------------------------------------------------------*/
+#define TI_DRIVER_MSG_PORT      9000
+#define TI2WPA_STATUS(s)        (((s) != OK) ? -1 : 0)
+#define TI_CHECK_DRIVER(f,r)    \
+    if( !(f) ) { \
+        wpa_printf(MSG_ERROR,"TI: Driver not initialized yet...aborting..."); \
+        return( r ); \
+    }
+/*-------------------------------------------------------------------*/
+/* Lock file pointer - used to access pid-lock-file to prevent two instances of wpa_supplicant */
+#ifdef CONFIG_TI_LOCKFILE
+static int lfp;
+#endif
+/*-------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_event_receive
+Routine Description: driver events callback, called from driver IPC
+Arguments: 
+   priv - pointer to private data structure
+   pData - pointer to event information
+Return Value: 
+-----------------------------------------------------------------------------*/
+void wpa_driver_tista_event_receive( IPC_EV_DATA *pData )
+{
+    struct wpa_driver_ti_data *mySuppl;
+    struct sockaddr_in echoserver;
+    int res, msg_size;
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_event_receive called: %d", 
+               pData->uBufferSize);
+
+    mySuppl = pData->EvParams.hUserParam;
+    msg_size = (int)(pData->uBufferSize + offsetof(IPC_EV_DATA, uBuffer));
+
+    os_memset( &echoserver, 0, sizeof(echoserver) );     /* Clear struct */
+    echoserver.sin_family = AF_INET;                     /* Internet/IP */
+    echoserver.sin_addr.s_addr = inet_addr("127.0.0.1"); /* IP address */
+    echoserver.sin_port = htons(TI_DRIVER_MSG_PORT);     /* server port */
+
+    res = sendto(mySuppl->driverEventsSocket, pData, msg_size, 0, (struct sockaddr *)&echoserver, sizeof(echoserver));
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_register_events
+Routine Description: register to driver events
+Arguments: 
+   ctx - pointer to private data structure
+Return Value: None
+-----------------------------------------------------------------------------*/
+void wpa_driver_tista_register_events( void *ctx )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)ctx;
+    IPC_EVENT_PARAMS pEvent;
+    int i;
+
+    os_memset( myDrv->hEvents, 0, sizeof(ULONG) * IPC_EVENT_MAX );
+    for(i=IPC_EVENT_ASSOCIATED;( i < IPC_EVENT_MAX );i++) {
+        /* Register to receive driver events */
+        pEvent.uEventType       = i;
+        pEvent.uDeliveryType    = DELIVERY_PUSH;
+        pEvent.hUserParam       = (TI_HANDLE)myDrv;
+        pEvent.pfEventCallback  = (TI_EVENT_CALLBACK)wpa_driver_tista_event_receive;
+        TI_RegisterEvent( myDrv->hDriver, &pEvent );
+        myDrv->hEvents[i] = pEvent.uEventID;
+    }
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_unregister_events
+Routine Description: unregister driver events
+Arguments: 
+   ctx - pointer to private data structure
+Return Value: None
+-----------------------------------------------------------------------------*/
+void wpa_driver_tista_unregister_events( void *ctx )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)ctx;
+    IPC_EVENT_PARAMS pEvent;
+    int idx;
+
+    for(idx=0;( idx < IPC_EVENT_MAX );idx++) {
+        if( myDrv->hEvents[idx] ) {
+            pEvent.uEventType = idx;
+            pEvent.uEventID = myDrv->hEvents[idx];
+            TI_UnRegisterEvent( myDrv->hDriver, &pEvent );
+        }
+    }
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_get_bssid
+Routine Description: get current BSSID from driver
+Arguments: 
+   priv - pointer to private data structure
+   bssid - pointer to hold bssid         
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_get_bssid( void *priv, u8 *bssid )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_MAC_ADDRESS tiAPMacAddr;
+    TI_STATUS retValue;
+
+    wpa_printf(MSG_DEBUG, "wpa_driver_tista_get_bssid called");
+
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    /* Get MAC address of current AP */
+    if( TI_GetBSSID( myDrv->hDriver, &tiAPMacAddr ) != TI_RESULT_OK )
+        return( -1 );
+
+    /* Copy BSSID into caller pointer provided in routine parameters */
+    os_memcpy( (void *)bssid, (void *)&tiAPMacAddr, MAC_ADDR_LEN );
+    wpa_hexdump(MSG_DEBUG, "get_bssid:", bssid, MAC_ADDR_LEN);
+    return( 0 );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_get_ssid
+Routine Description: get current SSID
+Arguments: 
+   priv - pointer to private data structure
+   ssid - pointer to hold current bssid         
+Return Value: Length of SSID string
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_get_ssid( void *priv, u8 *ssid )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_SSID myssid;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_get_ssid called");
+
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    /* Get current SSID from driver */
+    if( TI_GetCurrentSSID(myDrv->hDriver, &myssid) != TI_RESULT_OK )
+        return( -1 );
+    
+    /* Copy to user supplied pointer */
+    os_memcpy( (void *)ssid, (void *)&myssid.Ssid, myssid.SsidLength );
+
+    /* Return length of SSID */
+    return( myssid.SsidLength );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_ssid
+Routine Description: sets current SSID (Associates)
+Arguments: 
+   priv - pointer to private data structure
+   ssid - pointer to ssid
+   ssid_len - length of ssid
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_ssid( void *priv, const u8 *ssid, size_t ssid_len )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    char ssidBuf[MAX_SSID_LEN];
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_ssid called: %s", ssid);
+
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    /* Copy user supplied SSID into local buffer */
+    os_memset( ssidBuf, 0, MAX_SSID_LEN );
+    os_memcpy( ssidBuf, ssid, ssid_len );
+
+    /* Set local SSID buffer to driver - triggering connection process in driver */
+    wpa_printf(MSG_DEBUG,"Associate: SSID = %s", ssidBuf); /* Dm: */
+#ifdef STA_DK_VER_5_0_0_94
+    ret = (int)TI_SetSSID( myDrv->hDriver, (char *)ssidBuf );
+#else
+    ret = (int)TI_SetSSID( myDrv->hDriver, (u8 *)ssidBuf );
+#endif
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_wpa
+Routine Description: enable/disable WPA support in driver - not implemented since not supported in driver. also obselete for wpa-suppl core
+Arguments: 
+   priv - pointer to private data structure
+   enabled - enable/disable flag
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_wpa(void *priv, int enabled)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_wpa called: %d",enabled);
+    return( 0 );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_proto
+Routine Description: set authentication protocol (WPA/WPA2(RSN))
+Arguments: 
+   priv - pointer to private data structure
+   proto - authentication suite
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_proto( void *priv, int proto )
+{
+   struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+   wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_proto called: %d", proto);
+   myDrv->proto = proto;
+
+   return( 0 );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_wpa_options
+Routine Description: set wpa_options
+Arguments: 
+   priv - pointer to private data structure
+   wpa_options - WPA options (0 - disable, 3 - enable)
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_wpa_options( void *priv, int key_mgmt_suite )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    UINT32 wpa_opt = WPA_OPTIONS_DISABLE;
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_wpa_options called: %d", key_mgmt_suite);
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    myDrv->key_mgmt = key_mgmt_suite;
+
+    switch( key_mgmt_suite ) {
+        case KEY_MGMT_802_1X:          /* Dm: EAP */
+            wpa_opt = WPA_OPTIONS_ENABLE; /* wpa_auth = 1; */
+            break;
+
+        case KEY_MGMT_PSK:             /* Dm: PSK */
+            wpa_opt = WPA_OPTIONS_ENABLE; /* wpa_auth = 2; */
+            break;
+
+        case KEY_MGMT_802_1X_NO_WPA:   /* Dm: ??? */
+            break;
+
+        case KEY_MGMT_WPA_NONE:        /* Dm: ??? */
+            break;
+
+        case KEY_MGMT_NONE:
+        default:
+            wpa_opt = WPA_OPTIONS_DISABLE; /* wpa_auth = 255; */
+            break;
+    }
+
+    /* Set WPA Options */
+    ret = TI_SetWpaOptions( myDrv->hDriver, wpa_opt );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_encryption
+Routine Description: set authentication protocol (WPA/WPA2(RSN))
+Arguments: 
+   priv - pointer to private data structure
+   proto - authentication suite
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_encryption( void *priv, int encryption )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    int ret = -1;
+    OS_802_11_ENCRYPTION_TYPES wpa_cipher = OS_ENCRYPTION_TYPE_NONE;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_encryption called: %d",encryption);
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    myDrv->encryption = encryption;
+    switch( encryption ) {
+        case CIPHER_WEP40:
+        case CIPHER_WEP104:
+            wpa_printf(MSG_DEBUG, "encryption: OS_ENCRYPTION_TYPE_WEP");
+            wpa_cipher = OS_ENCRYPTION_TYPE_WEP;
+            break;
+
+        case CIPHER_TKIP:
+            wpa_printf(MSG_DEBUG, "encryption: OS_ENCRYPTION_TYPE_TKIP");
+            wpa_cipher = OS_ENCRYPTION_TYPE_TKIP;
+            break;
+
+        case CIPHER_CCMP:
+            wpa_printf(MSG_DEBUG, "encryption: OS_ENCRYPTION_TYPE_AES");
+            wpa_cipher = OS_ENCRYPTION_TYPE_AES;
+            break;
+
+        case CIPHER_NONE:
+        default:
+            wpa_printf(MSG_DEBUG, "encryption: OS_ENCRYPTION_TYPE_NONE");
+            wpa_cipher = OS_ENCRYPTION_TYPE_NONE;
+            break;
+    }
+    ret = TI_SetEncryptionType( myDrv->hDriver, wpa_cipher );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*---------------------------------------------------------------------------*/
+void wpa_driver_tista_print_auth_mode( OS_802_11_AUTHENTICATION_MODE myAuth )
+{
+    char *mode_name = NULL;
+    
+    switch( myAuth ) {
+       case os802_11AuthModeOpen:
+           mode_name = "os802_11AuthModeOpen";
+           break;
+       case os802_11AuthModeShared:
+           mode_name = "os802_11AuthModeShared";
+           break;
+       case os802_11AuthModeAutoSwitch:
+           mode_name = "os802_11AuthModeAutoSwitch";
+           break;
+       case os802_11AuthModeWPA:
+           mode_name = "os802_11AuthModeWPA";
+           break;
+       case os802_11AuthModeWPAPSK:
+           mode_name = "os802_11AuthModeWPAPSK";
+           break;
+       case os802_11AuthModeWPANone:
+           mode_name = "os802_11AuthModeWPANone";
+           break;
+       case os802_11AuthModeWPA2:
+           mode_name = "os802_11AuthModeWPA2";
+           break;
+       case os802_11AuthModeWPA2PSK:
+           mode_name = "os802_11AuthModeWPA2PSK";
+           break;
+       case os802_11AuthModeMax:
+       default:
+           mode_name = "Unknown";
+           break;
+    }
+    wpa_printf(MSG_DEBUG, "Selected AuthMode: %s", mode_name);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_auth_mode
+Routine Description: 
+Arguments: 
+   priv - pointer to private data structure
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_auth_mode( void *priv )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_AUTHENTICATION_MODE myAuth = os802_11AuthModeAutoSwitch;
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_auth_mode called");
+
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    wpa_driver_tista_set_proto( priv, ((struct wpa_supplicant *)myDrv->hWpaSupplicant)->wpa->proto );
+    wpa_printf(MSG_DEBUG, "proto: %d", myDrv->proto); /* should be set BEFORE */
+    wpa_printf(MSG_DEBUG, "auth_alg: %d",myDrv->auth_alg);
+
+    if( myDrv->auth_alg == AUTH_ALG_OPEN_SYSTEM ) {
+        switch( myDrv->key_mgmt ) {
+            case KEY_MGMT_802_1X:
+                if( myDrv->proto & WPA_PROTO_WPA ) {
+                    myAuth = os802_11AuthModeWPA;
+                } 
+                else if( myDrv->proto & WPA_PROTO_RSN ) {
+                    myAuth = os802_11AuthModeWPA2;
+                }
+                break;
+            case KEY_MGMT_PSK:
+                if( myDrv->proto & WPA_PROTO_WPA ) {
+                    myAuth = os802_11AuthModeWPAPSK;
+                } 
+                else if( myDrv->proto & WPA_PROTO_RSN ) {
+                    myAuth = os802_11AuthModeWPA2PSK;
+                }
+                break;
+            case KEY_MGMT_802_1X_NO_WPA:
+            case KEY_MGMT_WPA_NONE:
+                myAuth = os802_11AuthModeWPANone;
+                break;
+            case KEY_MGMT_NONE:
+            default:
+                myAuth = os802_11AuthModeOpen;
+                break;
+        }
+    }
+    else if( myDrv->auth_alg == AUTH_ALG_SHARED_KEY ) {
+        myAuth = os802_11AuthModeShared;
+    }
+    else if( myDrv->auth_alg == AUTH_ALG_LEAP ) {                 /* Dm: ??? */
+        myAuth = os802_11AuthModeWPA;
+    }
+    wpa_driver_tista_print_auth_mode( myAuth );
+    ret = TI_SetAuthenticationMode( myDrv->hDriver, myAuth );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_del_key
+Routine Description: remove key from driver
+Arguments: 
+   priv - pointer to private data structure
+   key_idx - key index
+   addr - key address (unicast/broadcast)
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_del_key(void *priv, int key_idx,
+                       const unsigned char *addr)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_REMOVE_KEY myKey;
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_del_key called");
+    wpa_printf(MSG_DEBUG,"key_idx = %d, addr = " TIMACSTR, key_idx, MAC2STR(addr));
+
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    /* copy parameters (MAC of key to remove, etc) to local structure */
+    myKey.Length = sizeof(OS_802_11_REMOVE_KEY);
+    os_memcpy(&myKey.BSSID,addr,MAC_ADDR_LEN);
+    myKey.KeyIndex = key_idx;
+
+    /* Call Utility adapter to remove the key */
+    ret = TI_RemoveKey( myDrv->hDriver, &myKey );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_key
+Routine Description: set key in driver
+Arguments: 
+   priv - pointer to private data structure
+   alg - type of key
+   addr - key address (unicast/broadcast)
+   key_idx - key index
+   set_tx - use key for immidiate tx
+   seq - sequence counter (for replay detection)
+   seq_len - sequence counter buffer len
+   key - key content
+   key_len - length of key (32 for TKIP, 16 for AES)
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_key(void *priv, wpa_alg alg,
+                       const unsigned char *addr, int key_idx, int set_tx,
+                       const u8 *seq, size_t seq_len,
+                       const u8 *key, size_t key_len)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_KEY myKey;
+    OS_802_11_WEP myWepKey;
+    UINT8 temp[TKIP_KEY_LENGTH];
+    int ret = -1;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_key called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    wpa_printf(MSG_DEBUG, "add_key (addr): " MACSTR, MAC2STR(addr));
+    wpa_printf(MSG_DEBUG, "add_key (key_idx): %d", key_idx);
+    wpa_printf(MSG_DEBUG, "add_key (alg): %d", alg);
+    wpa_printf(MSG_DEBUG, "add_key (set_tx): %d", set_tx);
+    wpa_hexdump(MSG_DEBUG, "add_key (seq):", seq, seq_len);
+    wpa_hexdump(MSG_DEBUG, "add_key (key):", key, key_len);
+   
+    switch( key_len ) {
+        case TKIP_KEY_LENGTH:          /* 32 */
+        case AES_KEY_LENGTH:           /* 16 */
+            /* Set key index */
+            myKey.KeyIndex = key_idx;
+            /* Set key length and content */
+            myKey.KeyLength = key_len;
+            /* Set structure size */
+            myKey.Length = sizeof(OS_802_11_KEY);
+            /* set key MAC address - FF:FF:FF:FF:FF:FF for broadcast, other for unicast */
+            os_memcpy( &myKey.BSSID, addr, MAC_ADDR_LEN );
+
+            if( seq_len ) {
+                /* Set key RSC */
+                os_memcpy( &myKey.KeyRSC, seq, seq_len );
+                myKey.KeyIndex |= TIWLAN_KEY_FLAGS_SET_KEY_RSC;
+            }
+
+            if( set_tx ) {
+                myKey.KeyIndex |= TIWLAN_KEY_FLAGS_TRANSMIT;
+            }
+
+            if( myKey.BSSID[0] != 0xFF ) {   
+                myKey.KeyIndex |= TIWLAN_KEY_FLAGS_PAIRWISE;
+            }
+
+            os_memcpy( &temp, key, AES_KEY_LENGTH );
+            if( key_len == TKIP_KEY_LENGTH ) {
+                /* need to switch RX and TX MIC set with key (to match driver API) */
+                os_memcpy( (UINT8*)(((UINT8*)&temp)+24), (UINT8*)(((UINT8*)key)+16), 8 );
+                os_memcpy( (UINT8*)(((UINT8*)&temp)+16), (UINT8*)(((UINT8*)key)+24), 8 );
+            }
+            os_memcpy( &myKey.KeyMaterial, &temp, key_len );
+            ret = TI_AddKey( myDrv->hDriver, &myKey );
+            break;
+
+        case WEP_KEY_LENGTH_40:        /* 5 */
+        case WEP_KEY_LENGTH_104:       /* 13 */
+            if( key_len != 0 ) {
+                /* Set key index */
+                myWepKey.KeyIndex = key_idx;
+                /* Set key length and content */
+                myWepKey.KeyLength = key_len;
+                /* Set structure size */
+                myWepKey.Length = sizeof(OS_802_11_WEP);
+
+                if( set_tx ) {
+                    myWepKey.KeyIndex |= TIWLAN_KEY_FLAGS_TRANSMIT;
+                    wpa_printf(MSG_DEBUG, "setting this key to be the index: 0x%x", myWepKey.KeyIndex);
+                }
+
+                os_memcpy( &myWepKey.KeyMaterial, key, key_len );
+                wpa_printf(MSG_DEBUG, "Adding WEP key index: 0x%x", key_idx);
+                ret = TI_AddWEPKey( myDrv->hDriver, &myWepKey );
+            }
+            else {
+                wpa_printf(MSG_DEBUG, "Removing WEP key index: 0x%x", key_idx);
+                ret = TI_RemoveWEPKey( myDrv->hDriver, key_idx );
+            }
+            break;
+
+        default:
+            wpa_printf(MSG_ERROR,"Set_key: Wrong Key\n");
+            break;
+    }
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_countermeasures
+Routine Description: start/stop countermeasures (drop packets due to replay attack detection)
+Arguments: 
+   priv - pointer to private data structure
+   enabled - enable/disable flag
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_countermeasures(void *priv, int enabled)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_countermeasures called: %d", enabled);
+    return( 0 );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_drop_unencrypted
+Routine Description: enable/disable EAPOL-only tx by driver 
+Arguments: 
+   priv - pointer to private data structure
+   enabled - enable/disable flag
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_drop_unencrypted(void *priv, int enabled)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+    wpa_printf(MSG_DEBUG,"TI: wpa_driver_tista_set_drop_unencrypted called: %d - not implemented", enabled);
+    return( 0 );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_deauthenticate
+Routine Description: send deauthentication packet
+Arguments: 
+   priv - pointer to private data structure
+   addr - address to send deauth packet to
+   reason_code - reason code supplied in deauth packet
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_deauthenticate(void *priv, const UINT8 *addr, int reason_code)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_deauthenticate called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    /* Block any pending disassoc event until successfully connected */
+    if( myDrv->block_disassoc_events == NO_BLOCK )
+        myDrv->block_disassoc_events = NO_BLOCK_DISASSOC_IN_PROGRESS;
+
+    ret = TI_Disassociate( myDrv->hDriver );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_disassociate
+Routine Description: disassociate from AP
+Arguments: 
+   priv - pointer to private data structure
+   addr - address to send deauth packet to
+   reason_code - reason code supplied in deauth packet
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_disassociate(void *priv, const UINT8 *addr, int reason_code)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"TI: wpa_driver_tista_disassociate called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    /* Block any pending disassoc event until successfully connected */
+    if( myDrv->block_disassoc_events == NO_BLOCK )
+        myDrv->block_disassoc_events = NO_BLOCK_DISASSOC_IN_PROGRESS;
+
+    ret = TI_Disassociate( myDrv->hDriver );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_associate
+Routine Description: associate with AP
+Arguments: 
+   priv - pointer to private data structure
+   params - struct wpa_driver_associate_params (ssid, bssid, etc)
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_associate(void *priv, struct wpa_driver_associate_params *params)
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
+    int wpa_opt, wpa_cipher, ret;
+
+    wpa_printf(MSG_DEBUG,"TI: wpa_driver_tista_associate called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    if( myDrv->block_disassoc_events == NO_BLOCK_DISASSOC_IN_PROGRESS )
+        myDrv->block_disassoc_events = BLOCK_DISASSOC;
+
+    if( params->bssid ) {
+        wpa_printf(MSG_DEBUG, "TI: BSSID=" MACSTR, MAC2STR(params->bssid));
+        /* if there is bssid -> set it */
+        if( os_memcmp( params->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN ) != 0 ) {
+            os_memcpy( &bssid, params->bssid, ETH_ALEN );
+            TI_SetBSSID( myDrv->hDriver, &bssid );
+        }
+    }
+    else {
+        /* else set it to {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} */
+        TI_SetBSSID( myDrv->hDriver, &bssid );
+    }
+
+    /* Set driver network mode (Adhoc/Infrastructure) according to supplied parameters */
+    if( params->mode == IEEE80211_MODE_INFRA ) {
+        wpa_printf(MSG_DEBUG,"TI: setting os802_11Infrastructure mode...");
+        TI_SetBSSType( myDrv->hDriver, os802_11Infrastructure );
+    }
+    else if( params->mode == IEEE80211_MODE_IBSS ) {
+        wpa_printf(MSG_DEBUG,"TI: setting os802_11IBSS mode...");
+        TI_SetBSSType( myDrv->hDriver, os802_11IBSS );
+    }
+    else {
+        wpa_printf(MSG_ERROR,"TI: Associate: invalid mode specified...");
+    }
+
+    wpa_driver_tista_set_wpa_options( priv, params->key_mgmt_suite );
+    wpa_driver_tista_set_auth_mode( priv );
+    wpa_driver_tista_set_encryption( priv, params->pairwise_suite );
+
+    /* And trigger connection/association process in driver by setting SSID */
+    ret = wpa_driver_tista_set_ssid( priv, params->ssid, params->ssid_len);
+    return( ret );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: ti_init_scan_params
+Routine Description: int scan parameters before scan command
+Arguments: 
+   pScanParams - pointer to scan paramters structure
+   pScanPolicy - pointer to scan policy structure
+   scanType    - scan type
+   noOfChan    - number of allowed channels
+Return Value: None
+-----------------------------------------------------------------------------*/
+static void ti_init_scan_params( scan_Params_t *pScanParams, scan_Policy_t *pScanPolicy,
+                                 int scanType, int noOfChan )
+{
+    int i, j;
+
+    if( noOfChan > MAX_NUMBER_OF_CHANNELS_PER_SCAN )
+        noOfChan = MAX_NUMBER_OF_CHANNELS_PER_SCAN;
+    /* init application scan default params */
+    pScanParams->desiredSsid.len = 0;
+    pScanParams->scanType = scanType;
+    pScanParams->band = RADIO_BAND_2_4_GHZ;
+    pScanParams->probeReqNumber = 3;
+    pScanParams->probeRequestRate = DRV_RATE_MASK_2_BARKER;
+    pScanParams->numOfChannels = (UINT8)noOfChan;
+    for(i=0;( i < noOfChan );i++) {
+        for(j=0;( j < MAC_ADDR_LEN );j++) {
+            pScanParams->channelEntry[ i ].normalChannelEntry.bssId.addr[ j ] = 0xff;
+        }
+        pScanParams->channelEntry[ i ].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+        pScanParams->channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes = 0;
+        pScanParams->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 60000;
+        pScanParams->channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 30000;
+#ifdef STA_DK_VER_5_0_0_94
+        pScanParams->channelEntry[ i ].normalChannelEntry.txPowerLevel = 1;
+#else
+        pScanParams->channelEntry[ i ].normalChannelEntry.txPowerDbm = MAX_TX_POWER;
+#endif
+        pScanParams->channelEntry[ i ].normalChannelEntry.channel = i + 1;
+    }
+
+    /* init default scan policy */
+    pScanPolicy->normalScanInterval = 10000;
+    pScanPolicy->deterioratingScanInterval = 5000;
+    pScanPolicy->maxTrackFailures = 3;
+    pScanPolicy->BSSListSize = 4;
+    pScanPolicy->BSSNumberToStartDiscovery = 1;
+    pScanPolicy->numOfBands = 1;
+    pScanPolicy->bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ;
+    pScanPolicy->bandScanPolicy[ 0 ].rxRSSIThreshold = -80;
+    pScanPolicy->bandScanPolicy[ 0 ].numOfChannles = (UINT8)noOfChan;
+    pScanPolicy->bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3;
+    for(i=0;( i < noOfChan );i++) {
+        pScanPolicy->bandScanPolicy[ 0 ].channelList[ i ] = i + 1;
+    }
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.scanType = scanType;
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000;
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_1_BARKER;
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
+#ifdef STA_DK_VER_5_0_0_94
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txLevel = 1;
+#else
+    pScanPolicy->bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
+#endif
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.scanType = scanType;
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000;
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_2_BARKER;
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
+#ifdef STA_DK_VER_5_0_0_94
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txLevel = 1;
+#else
+    pScanPolicy->bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
+#endif
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.scanType = scanType;
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000;
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_5_5_CCK;
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
+#ifdef STA_DK_VER_5_0_0_94
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txLevel = 1;
+#else
+    pScanPolicy->bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_scan
+Routine Description: request scan from driver
+Arguments: 
+   priv - pointer to private data structure
+   ssid - ssid buffer
+   ssid_len - length of ssid
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_scan( void *priv, const UINT8 *ssid, size_t ssid_len )
+{
+    scan_Params_t scanParams;
+    scan_Policy_t scanPolicy;
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    int ret;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_scan called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    ti_init_scan_params( &scanParams, &scanPolicy, myDrv->scan_type, 
+                         myDrv->scan_channels );
+    if (ssid && ssid_len > 0 && ssid_len <= sizeof(scanParams.desiredSsid.ssidString)) {
+        os_memcpy(scanParams.desiredSsid.ssidString, ssid, ssid_len);
+        scanParams.desiredSsid.len = ssid_len;
+    }
+    TI_SetScanPolicy( myDrv->hDriver, (UINT8 *)&scanPolicy, sizeof(scan_Policy_t) );
+    ret = TI_StartScan( myDrv->hDriver, (scan_Params_t *)&scanParams );
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_set_auth_alg
+Routine Description: set authentication in driver
+Arguments: 
+   priv - pointer to private data structure
+   auth_alg - Open/Shared/LEAP
+Return Value: 0 on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_set_auth_alg( void *priv, int auth_alg )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_set_auth_alg called: %d", auth_alg);
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+    myDrv->auth_alg = auth_alg;
+    return( 0 );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_get_bssid_info
+Routine Description: retrieve bssid full info
+Arguments: 
+   hDriver - pointer to driver structure
+Return Value: pointer to BSSID structure or NULL
+-----------------------------------------------------------------------------*/
+static OS_802_11_BSSID_EX *wpa_driver_tista_get_bssid_info( TI_HANDLE hDriver )
+{
+    OS_802_11_BSSID_EX mySelectedBssidInfo;
+    OS_802_11_BSSID_LIST_EX *bssid_list;
+    OS_802_11_BSSID_EX *pBssid, *nBssid = NULL;
+    int i, number_items, res;
+
+    res = TI_GetSelectedBSSIDInfo( hDriver, &mySelectedBssidInfo );
+    if( res != TI_RESULT_OK )
+        return( nBssid );
+
+    if( TI_GetBSSIDList( hDriver, &bssid_list ) || !bssid_list )
+        return( nBssid ); 
+
+    pBssid = &bssid_list->Bssid[0];
+    number_items = (int)(bssid_list->NumberOfItems);
+    for(i=0;( i < number_items );i++) {
+        if( os_memcmp( mySelectedBssidInfo.Ssid.Ssid, pBssid->Ssid.Ssid, pBssid->Ssid.SsidLength ) == 0 ) {
+            nBssid = (OS_802_11_BSSID_EX *)os_malloc( pBssid->Length );
+            if( nBssid != NULL )
+                os_memcpy( nBssid, pBssid, pBssid->Length );
+            break;
+        }
+        pBssid = (OS_802_11_BSSID_EX *)(((char *)pBssid) + pBssid->Length);
+    }
+    os_free( bssid_list );
+    return( nBssid );
+}
+
+/*-----------------------------------------------------------------------------
+Compare function for sorting scan results. Return >0 if @b is considered better.
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_scan_result_compare(const void *a, const void *b)
+{
+    const struct wpa_scan_result *wa = a;
+    const struct wpa_scan_result *wb = b;
+       
+    return( wb->level - wa->level );
+}
+                                                       
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_get_scan_results
+Routine Description: retrieve driver scan results
+Arguments: 
+   priv - pointer to private data structure
+   results - pointer to buffer
+   max_size - maximum size of results buffer
+Return Value: number of SSID on success, -1 on failure
+-----------------------------------------------------------------------------*/
+static int wpa_driver_tista_get_scan_results( void *priv,
+                                     struct wpa_scan_result *results,
+                                     size_t max_size )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    OS_802_11_BSSID_LIST_EX *bssid_list;
+    OS_802_11_BSSID_EX *pBssid;
+    OS_802_11_FIXED_IEs *pFixedIes;
+    OS_802_11_VARIABLE_IEs *pVarIes;
+    unsigned int number_items, i, index;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_get_scan_results called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+
+    if( TI_GetBSSIDList(myDrv->hDriver, &bssid_list) || !bssid_list )
+        return( -1 ); 
+
+    pBssid = &bssid_list->Bssid[0];
+    number_items = (int)(bssid_list->NumberOfItems);
+
+    wpa_printf(MSG_MSGDUMP, "Received %d bytes of scan results (%d BSSes)",
+           number_items * sizeof(OS_802_11_BSSID_EX), number_items);
+
+    os_memset( results, 0, max_size * sizeof(struct wpa_scan_result) );
+    number_items = MIN( number_items, max_size );
+
+    for(index=0; index < number_items; index++) {
+        os_memcpy( results[index].bssid, &pBssid->MacAddress, ETH_ALEN );
+        os_memcpy( results[index].ssid, pBssid->Ssid.Ssid, pBssid->Ssid.SsidLength );
+        results[index].ssid_len = pBssid->Ssid.SsidLength;
+#ifdef STA_DK_VER_5_0_0_94
+        results[index].freq = pBssid->Configuration.channel / 1000;
+        results[index].caps = pBssid->Capabilities;
+#else
+        results[index].freq = pBssid->Configuration.Union.channel / 1000;
+        results[index].caps = pBssid->Union.Capabilities;
+#endif
+        results[index].level = pBssid->Rssi;
+        results[index].maxrate = 0; /* In units of 0.5 Mb/s */
+        for (i = 0; i < sizeof(pBssid->SupportedRates); i++) {
+            if (pBssid->SupportedRates[i] > (unsigned)results[index].maxrate) {
+                results[index].maxrate = pBssid->SupportedRates[i];
+             }
+        }
+        wpa_printf(MSG_DEBUG,"TI: Net: %s Cap: 0x%04x Priv: 0x%x NetType: 0x%x InfraMode: 0x%x IELen: %d",
+#ifdef STA_DK_VER_5_0_0_94
+                   pBssid->Ssid.Ssid, pBssid->Capabilities, pBssid->Privacy, pBssid->NetworkTypeInUse,
+#else
+                   pBssid->Ssid.Ssid, pBssid->Union.Capabilities, pBssid->Privacy, pBssid->NetworkTypeInUse,
+#endif
+                   pBssid->InfrastructureMode, pBssid->IELength );
+
+        /* Fixed IEs from site entry - same Capabilities */
+        pFixedIes = (OS_802_11_FIXED_IEs *)&pBssid->IEs[0];
+        wpa_printf(MSG_DEBUG,"TI: Fixed IEs: Beacon: 0x%x Cap: 0x%x", pFixedIes->BeaconInterval, pFixedIes->Capabilities);
+        for(i=sizeof(OS_802_11_FIXED_IEs); i < pBssid->IELength;) {
+            pVarIes = (OS_802_11_VARIABLE_IEs *)&pBssid->IEs[i];
+            wpa_printf(MSG_DEBUG,"TI: Variable IEs: ID: 0x%x Len: %d", pVarIes->ElementID, pVarIes->Length);
+            wpa_hexdump(MSG_DEBUG,"TI: oui:", pVarIes->data, pVarIes->Length);
+            switch( pVarIes->ElementID ) {
+                case GENERIC_INFO_ELEM: /* 0xdd */
+                    if( (pVarIes->Length > 3) && (os_memcmp(pVarIes->data, WPA_OUI, 4) == 0) ) {
+                        results[index].wpa_ie_len = MIN((pVarIes->Length + 2), SSID_MAX_WPA_IE_LEN);
+                        os_memcpy( results[index].wpa_ie, pVarIes, results[index].wpa_ie_len );
+                    }
+                    break;
+
+                case RSN_INFO_ELEM:     /* 0x30 */
+                    results[index].rsn_ie_len = MIN((pVarIes->Length + 2), SSID_MAX_WPA_IE_LEN);
+                    os_memcpy( results[index].rsn_ie, pVarIes, results[index].rsn_ie_len );
+                    break;
+            }
+            i += (pVarIes->Length + (2 * sizeof(tiUINT8)));
+        }
+        pBssid = (OS_802_11_BSSID_EX *)(((u8 *)pBssid) + pBssid->Length);
+    }
+    
+    qsort(results, number_items, sizeof(struct wpa_scan_result),
+          wpa_driver_tista_scan_result_compare);
+                 
+    os_free( bssid_list );
+    return( number_items );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_get_scan_results
+Routine Description: retrieve driver scan results
+Arguments: 
+   sock - socket
+   priv - pointer to private data structure
+   sock_ctx - pointer to other private data
+Return Value: None
+-----------------------------------------------------------------------------*/
+static void wpa_driver_tista_receive_driver_event( int sock, void *priv, void *sock_ctx )
+{
+    IPC_EV_DATA myBuf;
+    UINT8 *buf;
+    UINT32 *bufLong;
+    union wpa_event_data myEventData;
+    struct wpa_driver_ti_data *mySuppl;
+    OS_802_11_ASSOCIATION_INFORMATION *pInfo = NULL; 
+    OS_802_11_AUTHENTICATION_REQUEST *pMediaSpecificBuf;
+    OS_802_11_BSSID_EX *pSelectedBssidInfo = NULL;
+    OS_802_11_NETWORK_MODE myBssType;
+    IPC_EV_DATA *pData = &myBuf;
+    int res;
+#ifndef STA_DK_VER_5_0_0_94    
+    btCoexStatus_t *btCoexStatus;
+#endif
+    
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_receive_driver_event...");
+
+    res = recv( sock, &myBuf, sizeof(myBuf), 0 );
+    if( res < 0 ) {
+        wpa_printf(MSG_ERROR,"l2_packet_receive - recvfrom");
+        return;
+    }
+
+    mySuppl = pData->EvParams.hUserParam;
+
+    switch( ((IPC_EVENT_PARAMS*)pData)->uEventType ) {
+        case IPC_EVENT_ASSOCIATED:
+            /* Associated event is called after successfull ASSOC_RSP packet is received */
+            wpa_printf(MSG_INFO,"wpa_supplicant - Associated");
+
+            TI_GetBSSType( mySuppl->hDriver, &myBssType );
+            wpa_printf(MSG_DEBUG,"myBssType = %d",myBssType);
+
+            if( myBssType == os802_11Infrastructure ) {
+                /* Get ASSOC_REQ and ASSOC_RSP IE */
+                res = TI_GetAssociationInfo( mySuppl->hDriver, &pInfo );
+                buf = (UINT8 *)pInfo;
+
+                if( buf != NULL ) {
+                    myEventData.assoc_info.req_ies = buf + pInfo->OffsetRequestIEs;
+                    myEventData.assoc_info.req_ies_len = pInfo->RequestIELength;
+                    myEventData.assoc_info.resp_ies = buf + pInfo->OffsetResponseIEs;
+                    myEventData.assoc_info.resp_ies_len = pInfo->ResponseIELength;
+                    myEventData.assoc_info.beacon_ies = NULL;
+                    myEventData.assoc_info.beacon_ies_len = 0;
+
+                    /* Get AP Beacon IEs - especially WPA/RSN IE */
+                    pSelectedBssidInfo = wpa_driver_tista_get_bssid_info( mySuppl->hDriver );
+                    if( pSelectedBssidInfo ) {
+                        if( pSelectedBssidInfo->IELength && pSelectedBssidInfo->IEs ) { // Dm: Fixed IEs ???
+                            myEventData.assoc_info.beacon_ies = (UINT8 *)pSelectedBssidInfo->IEs + sizeof(OS_802_11_FIXED_IEs);
+                            myEventData.assoc_info.beacon_ies_len = pSelectedBssidInfo->IELength - sizeof(OS_802_11_FIXED_IEs);
+                        }
+                    }
+                    wpa_printf(MSG_DEBUG,"myEventData.assoc_info.req_ies = 0x%x",(unsigned)myEventData.assoc_info.req_ies);
+                    wpa_printf(MSG_DEBUG,"myEventData.assoc_info.req_ies_len = %d",myEventData.assoc_info.req_ies_len);
+                    wpa_printf(MSG_DEBUG,"myEventData.assoc_info.resp_ies = 0x%x",(unsigned)myEventData.assoc_info.resp_ies);
+                    wpa_printf(MSG_DEBUG,"myEventData.assoc_info.resp_ies_len = %d",myEventData.assoc_info.resp_ies_len);
+                    wpa_printf(MSG_DEBUG,"myEventData.assoc_info.beacon_ies = 0x%x",(unsigned)myEventData.assoc_info.beacon_ies);
+                    wpa_printf(MSG_DEBUG,"myEventData.assoc_info.beacon_ies_len = %d",myEventData.assoc_info.beacon_ies_len);
+                    wpa_hexdump(MSG_DEBUG, "WPA: beacon_ies", myEventData.assoc_info.beacon_ies, myEventData.assoc_info.beacon_ies_len);
+
+                    /* First we notify wpa_supplicant and give it all the above IEs */
+                    wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_ASSOCINFO, &myEventData );
+
+                    /* Since both ASSOC_REQ/RSP and beacon IEs are allocated dynamically by the Utility Adapter - we need to free the buffers */
+                    os_free( pInfo );
+                    if( pSelectedBssidInfo ) {
+                        os_free( pSelectedBssidInfo );
+                    }
+                }
+            }
+            else {
+                myEventData.assoc_info.req_ies = NULL;
+                myEventData.assoc_info.req_ies_len = 0;
+                myEventData.assoc_info.resp_ies = NULL;
+                myEventData.assoc_info.resp_ies_len = 0;
+                myEventData.assoc_info.beacon_ies = NULL;
+                myEventData.assoc_info.beacon_ies_len = 0;
+                wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_ASSOCINFO, &myEventData );
+            }
+            /* We now can notify wpa_supplicant of the association event so it could start key negotiation (if needed) */
+            wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_ASSOC, NULL );
+            /* Allow Disassociation */
+            mySuppl->block_disassoc_events = NO_BLOCK;
+            break;
+
+        case IPC_EVENT_DISASSOCIATED:
+            if( mySuppl->block_disassoc_events != BLOCK_DISASSOC ) {
+               wpa_printf(MSG_INFO,"wpa_supplicant - Disassociated");
+               wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_DISASSOC, NULL );
+            }
+            else {
+               wpa_printf(MSG_INFO,"wpa_supplicant - Disassociated (blocked)");
+            }
+            break;
+
+        case IPC_EVENT_SCAN_COMPLETE:
+            wpa_printf(MSG_INFO,"wpa_supplicant - IPC_EVENT_SCAN_COMPLETE");
+            wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_SCAN_RESULTS, NULL );
+            break;
+
+        case IPC_EVENT_AUTH_SUCC:
+            wpa_printf(MSG_INFO,"wpa_supplicant - IPC_EVENT_AUTH_SUCC");
+            break;
+
+        case IPC_EVENT_EAPOL:
+            wpa_printf(MSG_INFO,"wpa_supplicant - EAPOL");
+            buf = pData->uBuffer;
+            wpa_supplicant_rx_eapol( mySuppl->hWpaSupplicant, (UINT8 *)(buf + MAC_ADDR_LEN), 
+                                     (UINT8 *)(buf + ETHERNET_HDR_LEN), (pData->uBufferSize - ETHERNET_HDR_LEN) );
+            break;
+
+        case IPC_EVENT_MEDIA_SPECIFIC:
+            wpa_printf(MSG_INFO,"wpa_supplicant - Media_Specific");
+            bufLong = (UINT32 *)pData->uBuffer;
+            /* Check for Authentication type messages from driver */
+            if( (*bufLong) == os802_11StatusType_Authentication ) {
+                pMediaSpecificBuf = (OS_802_11_AUTHENTICATION_REQUEST *)(bufLong + 1);
+                wpa_printf(MSG_DEBUG,"wpa_supplicant - Media_Specific - Authentication message detected: %u", pMediaSpecificBuf->Flags);
+                /* Check for MIC failure event */
+                if( (pMediaSpecificBuf->Flags == OS_802_11_REQUEST_PAIRWISE_ERROR) || (pMediaSpecificBuf->Flags == OS_802_11_REQUEST_GROUP_ERROR)) {
+                    /* Notify wpa_supplicant of MIC failure */
+                    myEventData.michael_mic_failure.unicast = 1;
+                    wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_MICHAEL_MIC_FAILURE, &myEventData );
+                }
+                /* OS_802_11_REQUEST_REAUTH - is handled automatically */
+                /* OS_802_11_REQUEST_KEYUPDATE - no event of this type */
+            }
+            break;
+
+        case IPC_EVENT_LINK_SPEED:
+            bufLong = (UINT32 *)pData->uBuffer;
+            wpa_printf(MSG_INFO,"wpa_supplicant - Link Speed = %u MB/s", ((*bufLong) / 2));
+            /* wpa_msg(mySuppl->hWpaSupplicant, MSG_INFO, WPA_EVENT_LINK_SPEED "%u MB/s", ((*bufLong) / 2)); */
+            mySuppl->link_speed = (unsigned)((*bufLong) / 2);
+            break;
+
+        case IPC_EVENT_WPA2_PREAUTHENTICATION:
+            wpa_printf(MSG_INFO,"wpa_supplicant - WPA2_PREAUTHENTICATION");
+            bufLong = (UINT32 *)pData->uBuffer;
+            wpa_printf(MSG_INFO,"Preauth Status Code = %u",*bufLong);
+            /* Dm: wpa_supplicant_event( mySuppl->hWpaSupplicant, EVENT_PMKID_CANDIDATE, &data); */
+            break;
+
+#ifndef STA_DK_VER_5_0_0_94
+        case IPC_EVENT_BT_COEX_MODE:
+            btCoexStatus = (btCoexStatus_t *)pData->uBuffer;
+            if( (btCoexStatus != NULL) && btCoexStatus->state ) {
+                wpa_printf(MSG_INFO,"wpa_supplicant - BT_COEX_MODE (SG is ON, minTxRate = %d)\n", btCoexStatus->minTxRate);
+            }
+            else {
+                wpa_printf(MSG_INFO,"wpa_supplicant - BT_COEX_MODE (SG is OFF)\n");
+            }          
+            break;
+#endif
+
+        default:
+            wpa_printf(MSG_ERROR,"wpa_supplicant - Unhandled driver event: %d", ((IPC_EVENT_PARAMS*)pData)->uEventType);
+            break;
+    }
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_init
+Routine Description: init driver interface
+Arguments: 
+   priv - pointer to private data structure
+   ifname - return interface name
+Return Value: pointer to driver structure (to be supplied later by supplicant to wrappers)
+-----------------------------------------------------------------------------*/
+static void *wpa_driver_tista_init( void *priv, const char *ifname )
+{
+    struct wpa_driver_ti_data *myDrv;
+    int status;
+    UINT32 driverStatus,res;
+    struct sockaddr_in echoserver;
+    OS_802_11_MAC_ADDRESS myMac;
+#ifdef CONFIG_TI_LOCKFILE
+    char str[10];
+#endif
+
+    wpa_printf(MSG_DEBUG,"Initializing STA-DK %s interface...",SW_VERSION_STR);
+#ifdef CONFIG_TI_LOCKFILE
+    /* Try to open the lock file */
+    lfp = open("./.wpa_supplicant_lockfile.pid", (O_RDWR | O_CREAT | O_EXCL), 0640);
+    if( lfp < 0 ) {
+        wpa_printf(MSG_ERROR,"Cannot open pid-file...Aborting...\n");
+        return( NULL );
+    }
+    /* Try to get a file lock on the pid-file. If another instance is running and already has a lock - we will fail */
+#ifndef ANDROID /* Dm: !!! lockf is not implemented in Android */
+    if( lockf(lfp,F_TLOCK,0) < 0 ) {
+        wpa_printf(MSG_ERROR,"Another instance of wpa_supplicant is running...Aborting...\n");
+        return( NULL );
+    }
+#endif
+    /* If we got here - it means that no other instance is running - write process id to pid_file */
+    sprintf(str, "%d\n", getpid());
+    write(lfp,str,os_strlen(str)); /* record pid to lockfile */
+#endif
+
+    /* Allocate internal data structure to manage driver */
+    myDrv = os_malloc( sizeof(struct wpa_driver_ti_data) );
+
+    /* If failed to allocate */
+    if( myDrv == NULL ) {
+        wpa_printf(MSG_ERROR,"Failed to allocate memory for control structure...Aborting...");
+        goto label_init_error_file;
+    }
+
+    /* Zero memory */
+    os_memset( myDrv, 0, sizeof(struct wpa_driver_ti_data) );
+
+    /* Initialize Utility Adapter module */
+    myDrv->hDriver = TI_AdapterInit( TIWLAN_DRV_NAME );
+
+    /* If couldn't initialize - return NULL to indicate error */
+    if( myDrv->hDriver == 0 ) {
+        wpa_printf(MSG_ERROR,"Error: failed to initialize Utility Adapter interface...");
+        goto label_init_error_free;
+    }
+
+    /* Get WLAN interface mac address through Utility Adapter */
+    res = TI_GetCurrentAddress( myDrv->hDriver, &myMac );
+        
+    if( res == (UINT32)-1 ) {
+        wpa_printf(MSG_ERROR,"Error: failed to initialize Utility Adapter interface...");
+        goto label_init_error_free;
+    }
+
+    os_memcpy( &myDrv->own_addr, &myMac, MAC_ADDR_LEN );
+
+    wpa_driver_tista_register_events( myDrv );
+
+    /* Block disassoc events until connected */
+    if( myDrv->block_disassoc_events == NO_BLOCK )
+        myDrv->block_disassoc_events = NO_BLOCK_DISASSOC_IN_PROGRESS;
+    
+    /* Store wpa_supplicant context */
+    myDrv->hWpaSupplicant = priv;
+
+    myDrv->driverEventsSocket = socket( PF_INET, SOCK_DGRAM, IPPROTO_UDP );
+
+    if( myDrv->driverEventsSocket < 0 ) {
+        wpa_printf(MSG_ERROR,"Error: failed to create driver events socket...");
+        goto label_init_error_free;
+    }
+
+    os_memset( &echoserver, 0, sizeof(echoserver) );  /* Clear struct */
+    echoserver.sin_family = AF_INET;                  /* Internet/IP */
+    echoserver.sin_addr.s_addr = htonl(INADDR_ANY);   /* IP address */
+    echoserver.sin_port = htons(TI_DRIVER_MSG_PORT);  /* server port */
+
+    if( bind(myDrv->driverEventsSocket, (struct sockaddr *) &echoserver, sizeof(echoserver)) < 0 ) {
+        wpa_printf(MSG_ERROR,"Error: failed to create driver events socket...");
+        close(myDrv->driverEventsSocket);
+        goto label_init_error_free;
+    }
+
+    status = eloop_register_read_sock( myDrv->driverEventsSocket, wpa_driver_tista_receive_driver_event, priv, myDrv );
+
+    if( status != 0 ) {
+        wpa_printf(MSG_ERROR,"Error: failed to register socket handler...");
+    }
+
+    wpa_printf(MSG_DEBUG,"driver events socket is 0x%x...",myDrv->driverEventsSocket);
+
+    /* Signal that driver is not loaded yet */
+    myDrv->driver_is_loaded = TRUE;
+
+    /* Set default scan type */
+    myDrv->scan_type = SCAN_TYPE_NORMAL_ACTIVE;
+
+    /* Set default amount of channels */
+    myDrv->scan_channels = NUMBER_SCAN_CHANNELS_FCC;
+
+    /* Link Speed will be set by the message from the driver */
+    myDrv->link_speed = 0;
+
+    /* BtCoex mode is read from tiwlan.ini file */
+    myDrv->btcoex_mode = 1; /* SG_DISABLE */
+
+    /* Return pointer to our driver structure */
+    return( myDrv );
+
+label_init_error_free:
+    os_free( myDrv );
+label_init_error_file:
+#ifdef CONFIG_TI_LOCKFILE
+    /* Close and delete the pid-lock-file */
+    close(lfp);
+    unlink("./wpa_supplicant_lockfile.pid");
+#endif
+    return( NULL );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_unload
+Routine Description: unload driver
+Arguments: 
+   priv - pointer to private data structure
+Return Value: None
+-----------------------------------------------------------------------------*/
+static void wpa_driver_tista_unload( void *priv )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+    wpa_printf(MSG_INFO,"wpa_driver_tista_unload called");
+    /* Unregister driver events */
+    wpa_driver_tista_unregister_events( priv );
+    /* Close connection socket */
+        close(myDrv->driverEventsSocket);
+    /* Unload Utility Adapter */
+    TI_AdapterDeinit( myDrv->hDriver );
+    /* Free all allocated memory */
+    os_free( myDrv );
+#ifdef CONFIG_TI_LOCKFILE
+    /* Close and delete the pid-lock-file */
+    close(lfp);
+    unlink("./wpa_supplicant_lockfile.pid");
+#endif
+    wpa_printf(MSG_DEBUG,"STA-DK %s interface Deinitialized...bye!", SW_VERSION_STR);
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_get_mac_addr
+Routine Description: return WLAN MAC address
+Arguments: 
+   priv - pointer to private data structure
+Return Value: pointer to BSSID
+-----------------------------------------------------------------------------*/
+const u8 *wpa_driver_tista_get_mac_addr( void *priv )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+
+    wpa_printf(MSG_DEBUG,"wpa_driver_tista_get_mac_addr called");
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, NULL );
+    return( (const u8 *)&myDrv->own_addr );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_send_eapol
+Routine Description: transmit EAPOL
+Arguments: 
+   priv - pointer to private data structure
+   data - pointer to EAPOL data
+   data_len - length of EAPOL data
+Return Value: None
+-----------------------------------------------------------------------------*/
+static int ti_send_eapol( void *priv, const u8 *dest, u16 proto,
+                          const u8 *data, size_t data_len )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    u8* DataWithHeader = NULL;
+    u16 protoNetwork;
+    int ret = 0;
+
+    wpa_printf(MSG_DEBUG,"TI send_eapol called");
+#ifdef IEEE8021X_EAPOL   
+    DataWithHeader = os_malloc(data_len + ETHERNET_HDR_LEN); /* 14 bytes */
+    if( DataWithHeader == NULL ) {
+        wpa_printf(MSG_ERROR,"TI send_eapol failed to alloc full buffer");
+        return( -1 );
+    }
+
+    os_memcpy(DataWithHeader, dest, MAC_ADDR_LEN); /* 6 bytes */
+    os_memcpy(DataWithHeader+MAC_ADDR_LEN, myDrv->own_addr, MAC_ADDR_LEN);
+    protoNetwork = htons(proto);
+    os_memcpy(DataWithHeader+(MAC_ADDR_LEN<<1), &protoNetwork, sizeof(u16)); /* 2 bytes */
+
+    os_memcpy(DataWithHeader+ETHERNET_HDR_LEN, data, data_len);
+    data_len += ETHERNET_HDR_LEN;
+
+    wpa_hexdump(MSG_DEBUG, "WPA: FULL TX EAPOL-Key", DataWithHeader, data_len);
+  
+    /* Transmit EAPOL packet */
+    ret = TI_Send_EAPOL_Packet( myDrv->hDriver, (void *)DataWithHeader, data_len );
+    os_free(DataWithHeader);
+#endif   
+    return( TI2WPA_STATUS(ret) );
+}
+
+/*-----------------------------------------------------------------------------
+Routine Name: wpa_driver_tista_driver_cmd
+Routine Description: executes driver-specific commands
+Arguments: 
+   priv - pointer to private data structure
+   cmd - command
+   buf - return buffer
+   buf_len - buffer length
+Return Value: actual buffer length - success, -1 - failure
+-----------------------------------------------------------------------------*/
+int wpa_driver_tista_driver_cmd( void *priv, char *cmd, char *buf, size_t buf_len )
+{
+    struct wpa_driver_ti_data *myDrv = (struct wpa_driver_ti_data *)priv;
+    int ret = -1, prev_events;
+
+    wpa_printf(MSG_DEBUG, "%s %s", __func__, cmd);
+
+    if( os_strcasecmp(cmd, "start") == 0 ) {
+        wpa_printf(MSG_DEBUG,"Start command");
+        prev_events = myDrv->block_disassoc_events;
+        myDrv->block_disassoc_events = myDrv->block_disassoc_prev;
+        ret = TI_Start( myDrv->hDriver );
+        if( ret == OK ) {
+            /* Signal that driver is not loaded yet */
+            myDrv->driver_is_loaded = TRUE;
+            wpa_msg(myDrv->hWpaSupplicant, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
+        }
+       else
+           myDrv->block_disassoc_events = prev_events;
+        return( TI2WPA_STATUS(ret) );  
+    }
+
+    /* If driver is not initialized yet - we cannot access it so return */
+    TI_CHECK_DRIVER( myDrv->driver_is_loaded, -1 );
+    
+    if( os_strcasecmp(cmd, "stop") == 0 ) {
+        wpa_printf(MSG_DEBUG,"Stop command");
+       myDrv->block_disassoc_prev = myDrv->block_disassoc_events;
+        myDrv->block_disassoc_events = BLOCK_DISASSOC; /* Block message */
+        ret = TI_Stop( myDrv->hDriver );
+        if( ret == OK ) { 
+            /* Signal that driver is not loaded yet */
+            myDrv->driver_is_loaded = FALSE;
+            wpa_msg(myDrv->hWpaSupplicant, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
+        }
+       else
+           myDrv->block_disassoc_events = myDrv->block_disassoc_prev;
+    }
+    else if( os_strcasecmp(cmd, "macaddr") == 0 ) {
+        u8 *macaddr = (u8 *)wpa_driver_tista_get_mac_addr(priv);
+        wpa_printf(MSG_DEBUG,"Macaddr command");
+        wpa_printf(MSG_DEBUG, "   Macaddr = " MACSTR, MAC2STR(macaddr));
+        ret = sprintf(buf, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
+        return( ret );
+    }
+    else if( os_strcasecmp(cmd, "scan-passive") == 0 ) {
+        wpa_printf(MSG_DEBUG,"Scan Passive command");
+        myDrv->scan_type =  SCAN_TYPE_NORMAL_PASSIVE;
+        ret = 0;
+    }
+    else if( os_strcasecmp(cmd, "scan-active") == 0 ) {
+        wpa_printf(MSG_DEBUG,"Scan Active command");
+        myDrv->scan_type =  SCAN_TYPE_NORMAL_ACTIVE;
+        ret = 0;
+    }
+    else if( os_strcasecmp(cmd, "linkspeed") == 0 ) {
+        wpa_printf(MSG_DEBUG,"Link Speed command");
+        ret = sprintf(buf,"LinkSpeed %u\n", myDrv->link_speed); 
+        return( ret );
+    }
+    else if( os_strncasecmp(cmd, "scan-channels", 13) == 0 ) {
+        int noOfChan;
+
+        noOfChan = atoi(cmd + 13);
+        wpa_printf(MSG_DEBUG,"Scan Channels command = %d", noOfChan);
+        if( (noOfChan > 0) && (noOfChan <= MAX_NUMBER_OF_CHANNELS_PER_SCAN) )
+           myDrv->scan_channels = noOfChan;
+        ret = sprintf(buf,"Scan-Channels = %d\n", myDrv->scan_channels); 
+        return( ret );
+    }
+    else if( os_strcasecmp(cmd, "rssi") == 0 ) {
+#if 1    
+       u8 ssid[MAX_SSID_LEN];
+       int rssi, len;
+
+        wpa_printf(MSG_DEBUG,"rssi command");
+       
+       ret = TI_GetRSSI( myDrv->hDriver, &rssi );
+       if( ret == OK ) {
+            len = wpa_driver_tista_get_ssid( priv, (u8 *)ssid );
+           if( (len > 0) && (len <= MAX_SSID_LEN) ) {
+                os_memcpy( (void *)buf, (void *)ssid, len );
+                ret = len;
+               ret += sprintf(&buf[ret], " rssi %d\n", rssi);
+               return( ret );
+           }
+       }
+       else {
+            ret = -1;
+       }
+#else  
+        OS_802_11_BSSID_EX bssidInfo;
+       
+        wpa_printf(MSG_DEBUG,"rssi command");  
+       
+        ret = TI_GetSelectedBSSIDInfo( myDrv->hDriver, (OS_802_11_BSSID_EX *)&bssidInfo );
+        if( ret == OK ) {
+            if( bssidInfo.Ssid.SsidLength != 0 ) {
+                os_memcpy( (void *)buf, (void *)(bssidInfo.Ssid.Ssid), bssidInfo.Ssid.SsidLength );
+                ret = bssidInfo.Ssid.SsidLength;
+                ret += sprintf(&buf[ret]," rssi %d\n", bssidInfo.Rssi);
+                return( ret );
+            }
+            ret = -1;
+        }
+#endif 
+    }
+    else if( os_strncasecmp(cmd, "powermode", 9) == 0 ) {
+        u32 mode;
+       
+        mode = (u32)atoi(cmd + 9);
+        wpa_printf(MSG_DEBUG,"Power Mode command = %u", mode);
+        if( mode <= OS_POWER_MODE_LONG_DOZE )
+           ret = TI_ConfigPowerManagement( myDrv->hDriver, mode );
+    }
+    else if (os_strncasecmp(cmd, "getpower", 8) == 0 ) {
+        u32 mode;
+
+        ret = TI_GetPowerMode( myDrv->hDriver, (OS_802_11_POWER_PROFILE *)&mode);
+        if( ret == OK ) {
+            ret = sprintf(buf, "powermode = %u\n", mode);
+            return( ret );
+        }
+        ret = -1;
+    }
+#ifndef STA_DK_VER_5_0_0_94
+    else if( os_strncasecmp(cmd, "btcoexmode", 10) == 0 ) {
+        u32 mode;
+       
+        mode = (u32)atoi(cmd + 10);
+        wpa_printf(MSG_DEBUG,"BtCoex Mode command = %u", mode);
+        ret = TI_SetBtCoeEnable( myDrv->hDriver, mode );
+        if( ret == OK ) {
+            myDrv->btcoex_mode = mode;
+        }
+    }
+    else if( os_strcasecmp(cmd, "btcoexstat") == 0 ) {
+        u32 status = myDrv->btcoex_mode;
+       
+        wpa_printf(MSG_DEBUG,"BtCoex Status");         
+        ret = TI_SetBtCoeGetStatus( myDrv->hDriver, (tiUINT32 *)&status );
+        if( ret == OK ) {
+            ret = sprintf(buf, "btcoexstatus = 0x%x\n", status);
+            return( ret );
+        }
+        ret = -1;
+    }
+#endif
+    else {
+        wpa_printf(MSG_DEBUG,"Unsupported command");
+    }
+    return( TI2WPA_STATUS(ret) );
+}
+
+/* Fill driver_ops structure to provide wpa_supplicant core with wrapper routines */
+struct wpa_driver_ops wpa_driver_custom_ops = {
+    .name           = TIWLAN_DRV_NAME,
+    .desc           = "TI Station Driver",
+    .init           = wpa_driver_tista_init,
+    .deinit         = wpa_driver_tista_unload,
+    .get_bssid      = wpa_driver_tista_get_bssid,
+    .get_ssid       = wpa_driver_tista_get_ssid,
+    .set_wpa        = wpa_driver_tista_set_wpa,
+    .set_key        = wpa_driver_tista_set_key,
+    .set_param      = NULL,
+    .set_countermeasures    = wpa_driver_tista_set_countermeasures,
+    .set_drop_unencrypted   = wpa_driver_tista_set_drop_unencrypted,
+    .scan                   = wpa_driver_tista_scan,
+    .get_scan_results       = wpa_driver_tista_get_scan_results,
+    .deauthenticate = wpa_driver_tista_deauthenticate,
+    .disassociate   = wpa_driver_tista_disassociate,
+    .associate      = wpa_driver_tista_associate,
+    .set_auth_alg   = wpa_driver_tista_set_auth_alg,
+    .get_mac_addr   = wpa_driver_tista_get_mac_addr,
+    .send_eapol     = ti_send_eapol,
+    .add_pmkid      = NULL,
+    .remove_pmkid   = NULL,
+    .flush_pmkid    = NULL,
+    .get_capa       = NULL,
+    .poll           = NULL, 
+    .get_ifname     = NULL, /* Not nesessary */
+    .set_operstate  = NULL,
+#ifdef CONFIG_CLIENT_MLME
+    .get_hw_modes   = NULL,
+    .set_channel    = NULL,
+    .set_ssid       = wpa_driver_tista_set_ssid,
+    .set_bssid      = NULL,
+    .send_mlme      = NULL,
+    .mlme_add_sta   = NULL,
+    .mlme_remove_sta    = NULL,
+    .mlme_setprotection = NULL,
+#endif /* CONFIG_CLIENT_MLME */
+    .driver_cmd     = wpa_driver_tista_driver_cmd
+};
diff --git a/wpa_supplicant_lib/driver_ti.h b/wpa_supplicant_lib/driver_ti.h
new file mode 100644 (file)
index 0000000..240ebb8
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * WPA Supplicant - driver interaction with TI station
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ */
+
+/* Copyright © Texas Instruments Incorporated (Oct 2005)
+ * THIS CODE/PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
+ * EITHER EXPRESS OR IMPLIED, INCLUDED BUT NOT LIMITED TO , THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
+ * This program has been modified from its original operation by Texas 
+ * Instruments Incorporated. These changes are covered under version 2 
+ * of the GNU General Public License, dated June 1991. 
+ *
+ * Copyright © Google Inc (Feb 2008)
+*/
+/*-------------------------------------------------------------------*/
+#ifndef _DRIVER_TI_H_
+#define _DRIVER_TI_H_
+
+#include "wpa.h"
+#include "config.h"
+#include "osDot11.h"
+#include "802_11Defs.h"
+#include "TI_AdapterApiC.h"
+#include "tiioctl.h"
+/*-------------------------------------------------------------------*/
+#define TIWLAN_DRV_NAME                "tiwlan0"
+#define TKIP_KEY_LENGTH                32
+#define AES_KEY_LENGTH         16
+#define WEP_KEY_LENGTH_40      5
+#define WEP_KEY_LENGTH_104     13
+
+#define TIMAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define TIMACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+typedef enum _TIWLAN_KEY_FLAGS
+{
+       TIWLAN_KEY_FLAGS_TRANSMIT       = 0x80000000,           /* Used whenever key should be immidiately used for TX */
+       TIWLAN_KEY_FLAGS_PAIRWISE       = 0x40000000,           /* Used to indicate pairwise key */
+       TIWLAN_KEY_FLAGS_SET_KEY_RSC    = 0x20000000,           /* Used to set RSC (receive sequence counter) to driver */
+       TIWLAN_KEY_FLAGS_AUTHENTICATOR  = 0x10000000            /* Not used currently */
+} TIWLAN_KEY_FLAGS;
+
+#define NO_BLOCK                          0
+#define NO_BLOCK_DISASSOC_IN_PROGRESS     1
+#define BLOCK_DISASSOC                    2
+#define NO_BLOCK_WPS                      3
+
+#ifndef WPA_OUI
+/* { 0x00, 0x50, 0xf2, 0x01 } */
+#define WPA_OUI "\x00\x50\xf2\x01"
+#endif
+
+#define NUMBER_SCAN_CHANNELS_FCC       11
+
+#ifndef ETHERNET_HDR_LEN
+#define ETHERNET_HDR_LEN        14
+#endif
+
+#define WPA_OPTIONS_DISABLE     0
+#define WPA_OPTIONS_ENABLE      3
+
+#ifndef MIN
+#define MIN(x,y)                (((x) < (y)) ? (x) : (y))
+#endif
+
+/* TI station control structure */
+struct wpa_driver_ti_data {
+    UINT8 own_addr[ETH_ALEN];          /* MAC address of WLAN interface */
+    void *hWpaSupplicant;              /* Handle to wpa_supplicant */
+    TI_HANDLE hDriver;                 /* Handle to self */
+    TI_HANDLE hEvents[IPC_EVENT_MAX];  /* Event handles - needed to register to driver events */
+    int key_mgmt;                      /* Key Management: 802_1X/PSK/NONE/802_1X_NO_WPA/WPA_NONE */
+    int proto;                         /* Protocol (WPA/WPA2/RSN) */
+    int encryption;                    /* Encryption type */
+    int auth_alg;                      /* Authentication Alg: Open, Shared or LEAP */ 
+    int driver_is_loaded;              /* TRUE/FALSE flag if driver is already loaded and can be accessed */
+    int scan_type;                     /* SCAN_TYPE_NORMAL_ACTIVE or  SCAN_TYPE_NORMAL_PASSIVE */
+    int scan_channels;                 /* Number of allowed scan channels */
+    unsigned link_speed;               /* Link Speed */
+    unsigned btcoex_mode;              /* BtCoex Mode */
+    int driverEventsSocket;
+    int block_disassoc_events;
+    int block_disassoc_prev;
+};
+
+/* external symbols from common.c - will be used to dynamically change debug level by IOCTLs */
+extern int wpa_debug_level;
+extern int wpa_debug_show_keys;
+extern int wpa_debug_timestamp;
+#endif /* _DRIVER_TI_H_ */